Skip to content

Commit da64475

Browse files
committed
bugix/update-profile-option-checking
1 parent 1ec784d commit da64475

File tree

2 files changed

+21
-23
lines changed

2 files changed

+21
-23
lines changed

docs/userguides/profile.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ time you run a command.
2121

2222
Once you've generated an API Client in your Code42 console, use the following command to create your profile with API client authentication:
2323
```bash
24-
code42 profile create-api-client --name MY_API_CLIENT_PROFILE --server example.authority.com --api-client-id "key-42" --secret "code42%api%client%secret"
24+
code42 profile create-api-client --name MY_API_CLIENT_PROFILE --server example.authority.com --api-client-id 'key-42' --secret 'code42%api%client%secret'
2525
```
2626

2727
```{eval-rst}

src/code42cli/cmds/profile.py

+20-22
Original file line numberDiff line numberDiff line change
@@ -228,21 +228,31 @@ def update(
228228
"""Update an existing profile."""
229229
c42profile = cliprofile.get_profile(name)
230230

231-
if c42profile.api_client_auth == "True":
232-
if not any(
233-
[
234-
server,
235-
api_client_id,
236-
secret,
237-
disable_ssl_errors is not None,
238-
use_v2_file_events is not None,
239-
]
240-
):
231+
if not any(
232+
[
233+
server,
234+
api_client_id,
235+
secret,
236+
username,
237+
password,
238+
disable_ssl_errors is not None,
239+
use_v2_file_events is not None,
240+
]
241+
):
242+
if c42profile.api_client_auth == "True":
241243
raise click.UsageError(
242244
"Must provide at least one of `--server`, `--api-client-id`, `--secret`, `--use-v2-file-events` or "
243245
"`--disable-ssl-errors` when updating an API client profile. "
244246
"Provide both `--username` and `--password` options to switch this profile to username/password authentication."
245247
)
248+
else:
249+
raise click.UsageError(
250+
"Must provide at least one of `--server`, `--username`, `--password`, `--use-v2-file-events` or "
251+
"`--disable-ssl-errors` when updating a username/password authenticated profile. "
252+
"Provide both `--api-client-id` and `--secret` options to switch this profile to Code42 API client authentication."
253+
)
254+
255+
if c42profile.api_client_auth == "True":
246256
if (username and not password) or (password and not username):
247257
raise click.UsageError(
248258
"This profile currently uses API client authentication. "
@@ -277,18 +287,6 @@ def update(
277287
_set_pw(c42profile.name, secret, debug, api_client=True)
278288

279289
else:
280-
if (
281-
not server
282-
and not username
283-
and not password
284-
and disable_ssl_errors is None
285-
and use_v2_file_events is None
286-
):
287-
raise click.UsageError(
288-
"Must provide at least one of `--server`, `--username`, `--password`, `--use-v2-file-events` or "
289-
"`--disable-ssl-errors` when updating a username/password authenticated profile. "
290-
"Provide both `--api-client-id` and `--secret` options to switch this profile to Code42 API client authentication."
291-
)
292290
if (api_client_id and not secret) or (api_client_id and not secret):
293291
raise click.UsageError(
294292
"This profile currently uses username/password authentication. "

0 commit comments

Comments
 (0)