Skip to content

added update user method #304

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 8 commits into from
Mar 25, 2021
Merged

Conversation

ceciliastevens
Copy link
Contributor

Description of Change

Currently, py42 can create a user, but cannot update a user that already exists. This change adds a method to allow updates to existing users.

Issues Resolved

n/a, this is a prerequesite for work on parts of code42/code42cli#259

Testing Procedure

  1. Create a user in Code42.
  2. Create an SDK object using py42.
  3. Run sdk.users.update_user(user_id, username="[email protected]", email="[email protected]", first_name="new", last_name="name")
  4. Verify using the Code42 console that changes have applied as expected.

PR Checklist

Did you remember to do the below?

  • Add unit tests to verify this change
  • Add an entry to CHANGELOG.md describing this change
  • Add docstrings for any new public parameters / methods / classes

@github-actions
Copy link
Contributor

github-actions bot commented Mar 19, 2021

CLA Assistant Lite bot All contributors have signed the CLA ✍️

`REST Documentation <https://console.us.code42.com/apidocviewer/#User-put>`__

Args:
user_id (int): An ID for the user.
Copy link
Contributor

@antazoey antazoey Mar 19, 2021

Choose a reason for hiding this comment

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

This looks like the userUid (via the REST documentation). In the users service, we still refer to user_uid (and user_id meaning the legacy id) since that will match the response, and won't be confused with other methods that use user_id as a reference to the legacy id

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the REST endpoint can accept user_uid or user_id, I used user_id for consistency with the other methods in py42, would you like me to change it to user_uid instead?

Copy link
Contributor

@antazoey antazoey Mar 19, 2021

Choose a reason for hiding this comment

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

I think we tend to use user_uid whenever possible, so yes I would prefer it here. The methods that are located near this method happen to use the legacy ID because of obligation, but other methods in this service use the user_uid.

Copy link
Contributor

Choose a reason for hiding this comment

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

Obligation or mistake, in case there are any that slipped through when not necessary

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense. I've updated it to use uid.

:class:`py42.response.Py42Response`
"""

uri = u"/api/User/{}?idType=uid".format(user_uid)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is fine, but usually we let the params= argument take care of query parameters

@antazoey antazoey merged commit c1a7075 into code42:master Mar 25, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Mar 25, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants