GoodMemGoodMem
ReferenceClient SDKsRust

Users

Rust users API reference: typed methods, request options, return values, and resource models.

goodmem::api::Users

Access this service with client.users().

pub struct Users<'a> {
    /* private fields */
}

Methods

MethodHTTPPath
createPOST/v1/users
create_enrollmentPOST/v1/users/{userId}/enrollments
deleteDELETE/v1/users/{id}
getGET/v1/users/{id}
get_by_emailGET/v1/users/email/{email}
get_by_usernameGET/v1/users/username/{username}
get_enrollmentGET/v1/users/{userId}/enrollments/{enrollmentId}
listGET/v1/users
list_pagesGET/v1/users
list_enrollmentsGET/v1/users/{userId}/enrollments
meGET/v1/users/me
revoke_enrollmentDELETE/v1/users/{userId}/enrollments/{enrollmentId}
updatePUT/v1/users/{id}

Errors and cancellation

Calls return Result<T>. See Error for validation, HTTP, transport, decoding, and timeout failures. Stream items can also return errors after the call succeeds.

Pagination helpers fetch pages when polled. Drop a page or event stream to cancel further work.

Implementations

impl Users<'_>

create

pub async fn create(&self, body: &CreateUserRequest) -> Result<UserResponse>

Create a human user

Creates one dormant human user after requiring instance-wide CREATE_USER authority. Creation does not issue a credential or create a role, grant, or authentication mapping.

Errors include local validation, HTTP failures, and malformed responses.

HTTP: POST /v1/users

create_enrollment

pub async fn create_enrollment( &self, user_id: impl std::fmt::Display, body: &CreateUserEnrollmentRequest, ) -> Result<CreateUserEnrollmentResponse>

Create a human-user enrollment

Creates a short-lived, one-time enrollment credential for an existing dormant human. Requires MANAGE_USER_ENROLLMENT with ANY or EXACT authority on the target user. The raw credential is returned only once. rotateExisting atomically revokes and replaces a live enrollment; an expired enrollment is replaced automatically.

Errors include local validation, HTTP failures, and malformed responses.

HTTP: POST /v1/users/{userId}/enrollments

delete

pub async fn delete(&self, id: impl std::fmt::Display) -> Result<()>

Delete a human user

Permanently soft-deletes the user and invalidates credentials acting for that subject. The GoodMem instance owner cannot be deleted; transfer ownership first. Repeating an authorized delete succeeds without rewriting audit data.

Errors include local validation, HTTP failures, and malformed responses.

HTTP: DELETE /v1/users/{id}

get

pub async fn get( &self, id: impl std::fmt::Display, options: &UsersGetOptions, ) -> Result<UserResponse>

Get a user by ID

Returns a user selected by UUID after applying READ_USER authority. includeDeleted permits an authorized caller to inspect a permanent tombstone; it does not grant additional authority.

Errors include local validation, HTTP failures, and malformed responses.

HTTP: GET /v1/users/{id}

get_by_email

pub async fn get_by_email( &self, email: impl std::fmt::Display, options: &UsersGetByEmailOptions, ) -> Result<UserResponse>

Get a user by ID

Returns a user selected by UUID after applying READ_USER authority. includeDeleted permits an authorized caller to inspect a permanent tombstone; it does not grant additional authority.

Errors include local validation, HTTP failures, and malformed responses.

HTTP: GET /v1/users/email/{email}

get_by_username

pub async fn get_by_username( &self, username: impl std::fmt::Display, options: &UsersGetByUsernameOptions, ) -> Result<UserResponse>

Get user by username

Returns a user selected by exact username after applying READ_USER authority. includeDeleted permits an authorized caller to inspect a permanent tombstone; it does not grant additional authority. Missing and unauthorized matches both return 404 so this guessable identifier cannot reveal whether a user exists.

Errors include local validation, HTTP failures, and malformed responses.

HTTP: GET /v1/users/username/{username}

get_enrollment

pub async fn get_enrollment( &self, user_id: impl std::fmt::Display, enrollment_id: impl std::fmt::Display, ) -> Result<UserEnrollmentResponse>

Get a human-user enrollment

Returns non-secret metadata for one current or historical enrollment. The target user is resolved before the enrollment, and MANAGE_USER_ENROLLMENT with ANY or EXACT authority on that user is required. Raw enrollment tokens are never returned.

Errors include local validation, HTTP failures, and malformed responses.

HTTP: GET /v1/users/{userId}/enrollments/{enrollmentId}

list

pub async fn list(&self, options: &UsersListOptions) -> Result<ListUsersResponse>

List human users

Requires LIST_USER on the GoodMem instance and READ_USER on each returned row. Authorization, label filtering, lifecycle filtering, and keyset pagination run in PostgreSQL. includeDeleted expands the lifecycle view but grants no access. includeEnrollmentSummary requests non-secret bootstrap posture only on active rows where MANAGE_USER_ENROLLMENT is independently authorized.

LABEL FILTERS: Label filters accept either label.<key>=<value> or label[key]=value (for example, label.environment=production or label[environment]=production).

Errors include local validation, HTTP failures, and malformed responses.

HTTP: GET /v1/users

list_pages

pub fn list_pages(&self, options: &UsersListOptions) -> Result<EventStream<ListUsersResponse>>

Lazily fetch pages for users.list. Drop the stream to cancel.

Requires LIST_USER on the GoodMem instance and READ_USER on each returned row. Authorization, label filtering, lifecycle filtering, and keyset pagination run in PostgreSQL. includeDeleted expands the lifecycle view but grants no access. includeEnrollmentSummary requests non-secret bootstrap posture only on active rows where MANAGE_USER_ENROLLMENT is independently authorized.

LABEL FILTERS: Label filters accept either label.<key>=<value> or label[key]=value (for example, label.environment=production or label[environment]=production).

HTTP: GET /v1/users

list_enrollments

pub async fn list_enrollments( &self, user_id: impl std::fmt::Display, options: &UsersListEnrollmentsOptions, ) -> Result<ListUserEnrollmentsResponse>

List a human user's enrollments

Returns one newest-first page containing pending, expired, consumed, and revoked enrollment metadata. MANAGE_USER_ENROLLMENT with ANY or EXACT authority on the target user is required. The page never contains raw credentials.

Errors include local validation, HTTP failures, and malformed responses.

HTTP: GET /v1/users/{userId}/enrollments

me

pub async fn me(&self) -> Result<UserResponse>

Get current user profile

Returns the human-user profile associated with the authenticated principal. Service principals do not have a human-user profile.

Errors include local validation, HTTP failures, and malformed responses.

HTTP: GET /v1/users/me

revoke_enrollment

pub async fn revoke_enrollment( &self, user_id: impl std::fmt::Display, enrollment_id: impl std::fmt::Display, ) -> Result<()>

Revoke a human-user enrollment

Permanently revokes one outstanding enrollment after requiring MANAGE_USER_ENROLLMENT on its target user. Repeating an authorized revocation succeeds without replacing its original audit provenance. Consumed enrollments cannot be revoked.

Errors include local validation, HTTP failures, and malformed responses.

HTTP: DELETE /v1/users/{userId}/enrollments/{enrollmentId}

update

pub async fn update( &self, id: impl std::fmt::Display, body: &UpdateUserRequest, ) -> Result<UserResponse>

Update a human user

Updates only fields present in the request. Empty username or displayName values clear those optional fields. Updating a deleted user fails with 412.

Errors include local validation, HTTP failures, and malformed responses.

HTTP: PUT /v1/users/{id}

Types

Trait implementations

  • Clone (derived)
  • Copy (derived)
  • Debug (derived)

On this page