Skip to content
This repository has been archived by the owner on Mar 17, 2021. It is now read-only.

Refactor User Type, Add Additional User Endpoints #61

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

trotttrotttrott
Copy link

These changes are part of an effort to implement users in the Terraform Grafana provider - https://github.com/terraform-providers/terraform-provider-grafana/issues/51.

Refactor User Type

Additional fields were added to User to capture all available information from the API.

The UserSearch type was added. This is structured after user objects returned from the search users API.

User and UserSearch are modeled after UserProfileDTO and UserSearchHitDTO in the Grafana codebase. Attempting to reuse a single type is going to lead to problems and workarounds like what's being removed from the UserByEmail function (where a temporary/alternate struct is created and then cast to a User).

Added Enpoints

  • User implements the user by ID API.
  • UserUpdate implements the user update API.
  • UpdateUserPassword implements the password for user admin API for updating user passwords. This field cannot be updated with UserUpdate.
  • UpdateUserPermissions implements the user permissions admin API for updating a user's IsAdmin property. This field also cannot be updated with UserUpdate.

API endpoints that return a collection of users do not structure user
objects the same as those that return a single user.

Collections of users intentionally have reduced fields. They are
different structs in the Grafana codebase: UserProfileDTO &
UserSearchHitDTO. They should be treated as differnt structs here as
well.
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.

1 participant