Skip to content

Feature/api clients #389

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Sep 27, 2022
Merged

Feature/api clients #389

merged 9 commits into from
Sep 27, 2022

Conversation

tora-kozic
Copy link
Contributor

Adds API client support

  • adds code42 profile create-api-client command
  • adds --secret and --api-client-id options to code42 profile update
  • slight changes to code42 legal-hold list and code42 legal-hold show

@disable_ssl_option
@use_v2_file_events_option
@debug_option
def create_api_client(
Copy link
Contributor Author

@tora-kozic tora-kozic Sep 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I chose to make this a separate create command for a couple reasons

  • py42's sdk uses two different auth methods
  • the totp option isn't applicable with api-client auth
  • I didn't think an optional password/secret (and in turn prompting the user for authentication on every command) made sense in the case of api clients.
  • allowing users to pass in secret and password interchangeably makes it difficult to understand what the users trying to do in the case of the code42 profile update command

Whether or not this should be a separate command or if we should just add options to the original create command (which is how the ticket was initially authored) is definitely open for discussion.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, a separate command makes sense, given there's enough differences. Making it explicit makes it easier to document and harder for a user to do something wrong unintentionally.

@username_option()
@password_option
@totp_option
@disable_ssl_option
@use_v2_file_events_option
@yes_option(hidden=True)
@debug_option
def update(
Copy link
Contributor Author

@tora-kozic tora-kozic Sep 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this method is now too unsightly for mortal eyes I could move the param error checking into a helper function

@@ -105,24 +120,6 @@ def delete_profile(self, name):
self._internal[self.DEFAULT_PROFILE] = self.DEFAULT_VALUE
self._save()

def _set_authority_url(self, new_value, profile):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

simplified these one liners

]
for matter in matters:
try:
matter["creator_username"] = matter["creator"]["user"]["email"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will fail if the matter was created via an API client, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what the conditions for the field being populated are (but that would make sense). This creator user email field isn't even included on the response documentation and isn't on every matter, but it does exist and is populated on some of them.

@tora-kozic tora-kozic merged commit 1ec784d into main Sep 27, 2022
@tora-kozic tora-kozic deleted the feature/api-clients branch November 30, 2023 21:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants