Skip to content

Add Users resource with read and current-user endpoints#140

Closed
TanyaSingh369-svg wants to merge 5 commits into
next-1.0.0from
feature/add-user-api-and-current-user-endpoints
Closed

Add Users resource with read and current-user endpoints#140
TanyaSingh369-svg wants to merge 5 commits into
next-1.0.0from
feature/add-user-api-and-current-user-endpoints

Conversation

@TanyaSingh369-svg

@TanyaSingh369-svg TanyaSingh369-svg commented May 4, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR adds support for the Terraform Cloud User API in the Python SDK.

It introduces a Users resource with support for:

  • Reading a user by ID
  • Reading the currently authenticated user
  • Updating the currently authenticated user

Changes

  • Implemented Users.read(user_id) using GET /api/v2/users/{user_id}
  • Added read_current() and update_current() methods
  • Added input validation and integrated Users into TFEClient
  • Updated the User model:
    - handled nullable fields (auth_method, avatar_url, email, unconfirmed_email)
    - added TwoFactor and UserPermissions
    - aligned nullable booleans with the Go SDK
    - added UserUpdateCurrentOptions
  • Parsed API responses into structured models
  • Added unit tests for:
    - read(user_id)
    - invalid ID validation
    - read_current()
    - update_current()
    - nullable field handling
    - two_factor parsing
    - nullable booleans
  • Added an example demonstrating read_current() and optional read(user_id)

Output

Added unit tests covering the new Users.read functionality.

Verified that the new tests pass successfully.

Screenshot 2026-05-05 at 2 49 56 AM

Run the Examples

Screenshot 2026-05-05 at 2 52 32 AM

- Add Users resource
- Implement read(user_id) and read_current()
- Add user model updates
- Add unit tests for user endpoints
- Add example usage in examples/user.py
@TanyaSingh369-svg TanyaSingh369-svg requested a review from a team as a code owner May 4, 2026 20:41
@TanyaSingh369-svg

Copy link
Copy Markdown
Contributor Author

Closing this PR due to linting and formatting issues. Will raise a fresh PR with a clean branch and fixes applied.

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.

1 participant