Skip to content

Add User API support and current-user endpoints#117

Open
TanyaSingh369-svg wants to merge 6 commits intohashicorp:next-1.0.0from
TanyaSingh369-svg:user-api
Open

Add User API support and current-user endpoints#117
TanyaSingh369-svg wants to merge 6 commits intohashicorp:next-1.0.0from
TanyaSingh369-svg:user-api

Conversation

@TanyaSingh369-svg
Copy link

@TanyaSingh369-svg TanyaSingh369-svg commented Mar 18, 2026

Description

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.

Confirmed that the full unit test suite runs without failures.
Screenshot 2026-03-23 at 3 34 34 PM
Screenshot 2026-03-23 at 3 41 59 PM

Run the example:
Screenshot 2026-03-23 at 3 34 56 PM

@TanyaSingh369-svg TanyaSingh369-svg requested a review from a team as a code owner March 18, 2026 10:41
@TanyaSingh369-svg TanyaSingh369-svg changed the title Add Users.read endpoint for Terraform Cloud User API Add User API support and current-user endpoints Mar 23, 2026
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