Apikeys
Rust apikeys API reference: typed methods, request options, return values, and resource models.
goodmem::api::Apikeys
Access this service with client.apikeys().
pub struct Apikeys<'a> {
/* private fields */
}Methods
| Method | HTTP | Path |
|---|---|---|
create | POST | /v1/apikeys |
delete | DELETE | /v1/apikeys/{id} |
get | GET | /v1/apikeys/{id} |
list | GET | /v1/apikeys |
list_pages | GET | /v1/apikeys |
update | PUT | /v1/apikeys/{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 Apikeys<'_>
create
pub async fn create(&self, body: &CreateApiKeyRequest) ->Result<CreateApiKeyResponse>
Create a new API key
Issues a new API key and returns its raw value exactly once. Omitted subject and authorityMode create a self-issued human key that inherits the subject's live authority. A SCOPED key requires a nonempty immutable ceiling, and every ceiling rule must be conservatively covered by both the subject's live authority and the issuing credential's effective authority. A scoped issuer can create only scoped children. SERVICE subjects require SCOPED mode and MANAGE_ACCESS on the service identity.
AUTHORIZATION: Requires CREATE_API_KEY on the proposed credential; subject and ceiling checks are repeated by the final insertion statement.
Errors include local validation, HTTP failures, and malformed responses.
HTTP: POST /v1/apikeys
delete
pub async fn delete(&self, id: impl std::fmt::Display) ->Result<()>
Delete an API key
Permanently revokes an API key and immediately rejects it for future authentication. The durable credential and audit history remain stored. This operation requires DELETE_API_KEY and records the revocation time and actor; it cannot be undone. PUT /v1/apikeys/{id} with status=INACTIVE performs the same protected lifecycle transition.
Errors include local validation, HTTP failures, and malformed responses.
HTTP: DELETE /v1/apikeys/{id}
get
pub async fn get(&self, id: impl std::fmt::Display) ->Result<ApiKeyResponse>
Get an API key
Returns complete non-secret metadata for one existing credential after requiring effective READ_API_KEY authority. The immutable ceiling is always complete and ceilingOmitted is false. Raw key material and hashes are never returned.
Errors include local validation, HTTP failures, and malformed responses.
HTTP: GET /v1/apikeys/{id}
list
pub async fn list(&self, options: &ApikeysListOptions) ->Result<ListApiKeysResponse>
List API keys
Requires LIST_API_KEY on the singleton instance, then retrieves one UUID-ordered page containing only credentials that independently pass READ_API_KEY. Both gates use the authenticated principal's live authority and any scoped-key ceiling. Subject, owner, and lifecycle filters are applied after authorization. FULL includes complete immutable ceilings; BASIC omits them, sets ceilingOmitted=true, and permits larger pages. Raw key values and key hashes are never returned.
Errors include local validation, HTTP failures, and malformed responses.
HTTP: GET /v1/apikeys
list_pages
pub fn list_pages( &self, options: &ApikeysListOptions, ) ->Result<EventStream<ListApiKeysResponse>>
Lazily fetch pages for apikeys.list. Drop the stream to cancel.
Requires LIST_API_KEY on the singleton instance, then retrieves one UUID-ordered page containing only credentials that independently pass READ_API_KEY. Both gates use the authenticated principal's live authority and any scoped-key ceiling. Subject, owner, and lifecycle filters are applied after authorization. FULL includes complete immutable ceilings; BASIC omits them, sets ceilingOmitted=true, and permits larger pages. Raw key values and key hashes are never returned.
HTTP: GET /v1/apikeys
update
pub async fn update( &self, id: impl std::fmt::Display, body: &UpdateApiKeyRequest, ) ->Result<ApiKeyResponse>
Update an API key
Updates an existing API key's labels or lifecycle status. Key ID, subject, ownership, key material, validity window, and creation audit fields remain immutable. Label changes require UPDATE_API_KEY; setting status=INACTIVE permanently revokes the key and requires DELETE_API_KEY; a request doing both requires both operations. Revoked keys cannot be reactivated. Side effects include updating administrative audit fields and, for revocation, recording the revocation time and actor.
Errors include local validation, HTTP failures, and malformed responses.
HTTP: PUT /v1/apikeys/{id}
Types
ApiKeyResponseApikeysListOptionsCreateApiKeyRequestCreateApiKeyResponseListApiKeysResponseUpdateApiKeyRequest
Trait implementations
Clone(derived)Copy(derived)Debug(derived)