Skip to content

Add last_login, password_created and verified_phone_number to User - #768

Open
annastudios wants to merge 1 commit into
linode:devfrom
annastudios:add-user-login-and-password-fields
Open

annastudios wants to merge 1 commit into
linode:devfrom
annastudios:add-user-login-and-password-fields

Conversation

@annastudios

Copy link
Copy Markdown

📝 Description

What does this PR do and why is this change necessary?

Get a user (GET /account/users/{username}) returns three read-only fields that User doesn't declare: last_login, password_created and verified_phone_number. Since Base._populate only sets declared properties, the SDK drops them, and they're only reachable through user._raw_json.

This adds them to User.properties:

  • last_login: a new UserLastLogin JSONObject with login_datetime and status (successful or failed). The API returns null until the user first logs in, so it's None then.
  • password_created: parsed as a datetime with is_datetime=True, like the other timestamps in account.py.
  • verified_phone_number: a plain property, as on Profile.

All three are read-only, so they are not sent back by save().

I found these by comparing the User properties against the response schema in the Linode OpenAPI spec (release-20261028).

✔️ How to Test

What are the steps to reproduce the issue or verify the changes?

user = client.load(User, "some-user")
user.last_login          # before: AttributeError; after: UserLastLogin(login_datetime=..., status=...)
user.password_created    # before: AttributeError; after: datetime
user.verified_phone_number

How do I run the relevant unit/integration tests?

pytest test/unit/objects/account_test.py -k user
  • test_get_user now checks the three fields against the updated account_users_test-user.json fixture.
  • New test_user_without_login_or_password checks that null values load as None.

Both fail without the change. The full unit suite passes locally: pytest test/unit gives 584 passed. black and isort are clean.

AI-assisted.

GET /account/users/{username} returns these read-only fields, but User did not declare them, so Base._populate dropped them and they were only reachable through _raw_json. last_login is exposed as a UserLastLogin JSONObject (login_datetime, status) and is None until the user first logs in; password_created is parsed as a datetime.
@annastudios
annastudios requested review from a team as code owners December 4, 2026 12:00
@annastudios
annastudios requested review from josephcardillo-akamai and mawilk90 and removed request for a team December 4, 2026 12:00

This branch has not been deployed

No deployments
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