pub struct ApiKey {
pub id: String,
pub name: String,
pub created_at: String,
pub created_by: ApiKeyCreator,
pub partial_key_hint: Option<String>,
pub status: ApiKeyStatus,
pub key_type: String,
pub workspace_id: Option<String>,
}Expand description
An API key available through the Anthropic Admin API.
Fields§
§id: StringUnique API key identifier
name: StringName of the API key
created_at: StringRFC 3339 datetime string representing the time at which the API key was created
created_by: ApiKeyCreatorInformation about who created the API key
partial_key_hint: Option<String>Partially redacted hint for the API key
status: ApiKeyStatusStatus of the API key
key_type: StringObject type (always “api_key” for API Keys)
workspace_id: Option<String>ID of the Workspace associated with the API key, or null if the API key belongs to the default Workspace
Implementations§
Source§impl ApiKey
impl ApiKey
Sourcepub fn builder(api_key_id: impl Into<String>) -> ApiKeyBuilder
pub fn builder(api_key_id: impl Into<String>) -> ApiKeyBuilder
Creates a builder for getting a specific API key.
§Example
let credentials = Credentials::from_env();
let api_key = ApiKey::builder("api_key_123456789")
.credentials(credentials)
.create()
.await?;Sourcepub async fn create(request: ApiKeyRequest) -> ApiResponseOrError<Self>
pub async fn create(request: ApiKeyRequest) -> ApiResponseOrError<Self>
Gets information about a specific API key.
§Example
let credentials = Credentials::from_env();
let request = ApiKeyRequest {
api_key_id: "api_key_123456789".to_string(),
credentials: Some(credentials),
};
let api_key = ApiKey::create(request).await?;Sourcepub fn update_builder(api_key_id: impl Into<String>) -> ApiKeyUpdateBuilder
pub fn update_builder(api_key_id: impl Into<String>) -> ApiKeyUpdateBuilder
Creates a builder for updating an API key.
§Example
let credentials = Credentials::from_env();
let updated_api_key = ApiKey::update_builder("api_key_123456789")
.credentials(credentials)
.name("New API Key Name")
.status(ApiKeyStatus::Inactive)
.create()
.await?;Sourcepub async fn update(request: ApiKeyUpdateRequest) -> ApiResponseOrError<Self>
pub async fn update(request: ApiKeyUpdateRequest) -> ApiResponseOrError<Self>
Updates an API key with the given request parameters.
§Example
let credentials = Credentials::from_env();
let request = ApiKeyUpdateRequest {
api_key_id: "api_key_123456789".to_string(),
name: Some("New API Key Name".to_string()),
status: Some(ApiKeyStatus::Inactive),
credentials: Some(credentials),
};
let updated_api_key = ApiKey::update(request).await?;Trait Implementations§
Source§impl<'de> Deserialize<'de> for ApiKey
impl<'de> Deserialize<'de> for ApiKey
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for ApiKey
impl StructuralPartialEq for ApiKey
Auto Trait Implementations§
impl Freeze for ApiKey
impl RefUnwindSafe for ApiKey
impl Send for ApiKey
impl Sync for ApiKey
impl Unpin for ApiKey
impl UnwindSafe for ApiKey
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.