1- .. _atlas-cli-save-connection-settings :
1+ .. _atlas-cli-profiles :
22
33========================
44Save Connection Settings
@@ -12,8 +12,209 @@ Save Connection Settings
1212 :depth: 1
1313 :class: singlecol
1414
15- Content Placeholder
15+ You can save your frequently-used connection settings as profiles.
16+ Profiles store the project IDs, organization
17+ IDs, and, optionally, |api| keys to use in future {+atlas-cli+}
18+ sessions. To save time, you can specify a profile instead of using the
19+ ``--projectId`` and ``--orgId`` flags with each command. The {+atlas-cli+}
20+ stores your profiles in a :ref:`configuration file <config-toml-location>`
21+ called ``config.toml``.
22+
23+ .. note::
24+
25+ Any settings stored in :ref:`environment variables <atlas-cli-env-vars>`
26+ take precedence over settings stored in profiles. Any project or organization
27+ specified with the ``--projectId`` and ``--orgId`` flags take precedence over
28+ both the profile and the environment variables.
1629
1730.. _config-toml-location:
1831
19- Content on where to find the config file
32+ Locate the Configuration File
33+ -----------------------------
34+
35+ The {+atlas-cli+} saves the configuration file to the following
36+ location depending on your operating system:
37+
38+ .. tabs-platforms::
39+
40+ .. tab::
41+ :tabid: macos
42+
43+ .. code-block::
44+
45+ /Users/{username}/Library/Application Support/atlascli
46+
47+ .. tab::
48+ :tabid: windows
49+
50+ .. code-block::
51+
52+ %AppData/atlascli
53+
54+ .. tab::
55+ :tabid: linux
56+
57+ .. code-block::
58+
59+ $XDG_CONFIG_HOME/atlascli
60+
61+ If ``$XDG_CONFIG_HOME`` is not set, the {+atlas-cli+} uses:
62+
63+ .. code-block::
64+
65+ $HOME/.config/atlascli
66+
67+ The
68+ {+atlas-cli+} grants the user who ran the command read and write access to
69+ the file.
70+
71+ .. _atlas-cli-set-profile:
72+
73+ Create a Profile
74+ ----------------
75+
76+ The first time you run the
77+ ``atlas auth login`` or ``atlas config init`` command, the
78+ {+atlas-cli+} automatically creates the ``config.toml`` file and a default
79+ profile. If you run a command without specifying a profile, environment
80+ variables, or ``--projectId`` and ``--orgId`` flags, the {+atlas-cli+} uses the
81+ default profile for the command.
82+
83+ Select Your Use Case
84+ ~~~~~~~~~~~~~~~~~~~~
85+
86+ Select a connection method based on your use case:
87+
88+ .. include:: /includes/list-table-atlas-cli-auth.rst
89+
90+ To learn more, see :ref:`Select a Connection Method <connect-atlas-cli>`.
91+
92+ Complete the Prerequisites
93+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
94+
95+ - :ref:`Install the {+atlas-cli+} <install-atlas-cli>`.
96+ - Add your host's IP address to the :ref:`IP access list <access-list>`.
97+ - If you select ``atlas config init`` as your connection method, you must
98+ :ref:`Configure API keys <atlas-admin-api-access>`.
99+
100+ Follow These Steps
101+ ~~~~~~~~~~~~~~~~~~
102+
103+ Select a use case and follow the procedure to create a profile.
104+
105+ .. tabs::
106+
107+ .. tab:: Non-programmatic Use
108+ :tabid: atlas-auth-login
109+
110+ .. include:: /includes/fact-default-vs-named-profile.rst
111+
112+ .. tabs::
113+
114+ .. tab:: Default Profile
115+ :tabid: Default
116+
117+ Follow these steps to create the default profile. If the default profile already
118+ exists, these commands update the default profile's values.
119+
120+ .. procedure::
121+
122+ .. include:: /includes/steps-atlas-cli-auth-nonprog-default.rst
123+
124+ .. include:: /includes/steps-atlas-cli-add-profile-nonprogrammatic.rst
125+
126+ .. tab:: Named Profile
127+ :tabid: Named
128+
129+ Follow these steps to create a profile with a custom name.
130+
131+ .. procedure::
132+
133+ .. step:: Run the authentication command.
134+
135+ Run the ``atlas auth login`` command in your terminal with the
136+ ``profile <profileName>`` flag. ``<profileName>`` should be
137+ the desired name for your new profile.
138+
139+ .. code-block:: sh
140+
141+ atlas auth login --profile myProfile
142+
143+ The command opens a browser window and returns a one-time
144+ activation code. This code expires after 10 minutes.
145+
146+ .. include:: /includes/steps-atlas-cli-add-profile-nonprogrammatic.rst
147+
148+ .. tab:: Programmatic Use
149+ :tabid: atlas-config-init
150+
151+ .. include:: /includes/fact-default-vs-named-profile.rst
152+
153+ .. tabs::
154+
155+ .. tab:: Default Profile
156+ :tabid: Default
157+
158+ Follow these steps to create the default profile. If the default profile already
159+ exists, these commands update the default profile's values.
160+
161+ .. procedure::
162+
163+ .. include:: /includes/steps-atlas-cli-auth-prog-default.rst
164+
165+ .. include:: /includes/steps-atlas-cli-add-profile-programmatic.rst
166+
167+ .. tab:: Named Profile
168+ :tabid: Named
169+
170+ Follow these steps to create a profile with a custom name.
171+
172+ .. procedure::
173+
174+ .. step:: Run the authentication command.
175+
176+ Run the ``atlas config init`` command in your terminal with the
177+ ``profile <profileName>`` flag. ``<profileName>`` should be
178+ the desired name for your new profile.
179+
180+ .. code-block:: sh
181+
182+ atlas config init --profile myProfile
183+
184+ .. include:: /includes/steps-atlas-cli-add-profile-nonprogrammatic.rst
185+
186+
187+ .. _atlas-cli-profile-update:
188+
189+ Update a Profile
190+ ----------------
191+
192+ You can update the
193+ settings stored in your configuration file in the following ways:
194+
195+ - Edit the ``config.toml`` file with a text editor.
196+ - Run the ``atlas config set`` command for a setting. This edits an individual
197+ value in the ``config.toml`` file.
198+
199+ Run a Command with a Profile
200+ ----------------------------
201+
202+ To run an {+atlas-cli+} command using a profile:
203+
204+ - :ref:`<atlas-cli-set-profile>`.
205+ - Append the ``--profile <profileName>`` flag to a command or omit the
206+ ``--profile <profileName>`` flag to use the default profile.
207+
208+ .. example::
209+
210+ This command uses a profile named ``myProfile``:
211+
212+ .. code-block::
213+
214+ atlas <command> --profile myProfile
215+
216+ This command uses the default profile:
217+
218+ .. code-block::
219+
220+ atlas <command>
0 commit comments