Skip to content
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

feat: update user's password by users_api #498

Merged
merged 2 commits into from
Sep 14, 2022
Merged

feat: update user's password by users_api #498

merged 2 commits into from
Sep 14, 2022

Conversation

bednar
Copy link
Contributor

@bednar bednar commented Sep 12, 2022

Related to https://influxcommunity.slack.com/archives/CHQ5VG6F8/p1662739448171649

Proposed Changes

  1. Updated InfluxDB UsersAPI to latest version
  2. Added possibility to update user's password by wrapped API:
    from datetime import datetime
    
    from influxdb_client import InfluxDBClient, OrganizationsService, AddResourceMemberRequestBody
    
    with InfluxDBClient(url="http://localhost:8086", token="my-token", org="my-org", debug=False) as client:
        user = client.users_api().create_user(f"New User_{datetime.now().timestamp()}")
        print(f"Created user: {user}")
    
        orgs_service = OrganizationsService(client.api_client)
        organization = orgs_service.get_orgs(org="my-org").orgs[0]
        member = orgs_service.post_orgs_id_members(org_id=organization.id,
                                                   add_resource_member_request_body=
                                                   AddResourceMemberRequestBody(id=user.id))
        print(f"Associated member: {member}")
    
        client.users_api().update_password(user, "password")
        print("Updated password...")

Checklist

  • CHANGELOG.md updated
  • Rebased/mergeable
  • A test has been added if appropriate
  • pytest tests completes successfully
  • Commit messages are conventional
  • Sign CLA (if not already signed)

@codecov-commenter
Copy link

codecov-commenter commented Sep 12, 2022

Codecov Report

Merging #498 (779211b) into master (9e9a10c) will increase coverage by 0.01%.
The diff coverage is 83.33%.

@@            Coverage Diff             @@
##           master     #498      +/-   ##
==========================================
+ Coverage   90.53%   90.54%   +0.01%     
==========================================
  Files          39       39              
  Lines        3359     3365       +6     
==========================================
+ Hits         3041     3047       +6     
  Misses        318      318              
Impacted Files Coverage Δ
influxdb_client/client/users_api.py 93.10% <83.33%> (+1.79%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@bednar bednar changed the title feat: update user's password by wrapped API feat: update user's password by users_api Sep 12, 2022
@bednar bednar marked this pull request as ready for review September 12, 2022 07:55
@bednar bednar requested a review from powersj September 12, 2022 07:56
Copy link
Contributor

@powersj powersj left a comment

Choose a reason for hiding this comment

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

Thanks for the quick fix

@bednar bednar merged commit 0722416 into master Sep 14, 2022
@bednar bednar deleted the user_password branch September 14, 2022 08:38
@bednar bednar added this to the 1.33.0 milestone Sep 14, 2022
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.

3 participants