Struct HmacKey

Source
pub struct HmacKey {
    pub kind: String,
    pub metadata: HmacMeta,
    pub secret: String,
}
Expand description

The HmacKey resource represents an HMAC key within Cloud Storage. The resource consists of a secret and HmacMeta. HMAC keys can be used as credentials for service accounts. For more information, see HMAC Keys.

Note that the HmacKey resource is only returned when you use HmacKey::create. Other methods, such as HmacKey::read, return the metadata portion of the HMAC key resource.

Fields§

§kind: String

The kind of item this is. For HMAC keys, this is always storage#hmacKey.

§metadata: HmacMeta

HMAC key metadata.

§secret: String

HMAC secret key material.

Implementations§

Source§

impl HmacKey

Source

pub async fn create() -> Result<Self>

Creates a new HMAC key for the specified service account.

The authenticated user must have storage.hmacKeys.create permission for the project in which the key will be created.

For general information about HMAC keys in Cloud Storage, see HMAC Keys.

§Example
use cloud_storage::hmac_key::HmacKey;

let hmac_key = HmacKey::create().await?;
Source

pub fn create_sync() -> Result<Self>

The synchronous equivalent of HmacKey::create.

§Features

This function requires that the feature flag sync is enabled in Cargo.toml.

Source

pub async fn list() -> Result<Vec<HmacMeta>>

Retrieves a list of HMAC keys matching the criteria. Since the HmacKey is secret, this does not return a HmacKey, but a HmacMeta. This is a redacted version of a HmacKey, but with the secret data omitted.

The authenticated user must have storage.hmacKeys.list permission for the project in which the key exists.

For general information about HMAC keys in Cloud Storage, see HMAC Keys.

§Example
use cloud_storage::hmac_key::HmacKey;

let all_hmac_keys = HmacKey::list().await?;
Source

pub fn list_sync() -> Result<Vec<HmacMeta>>

The synchronous equivalent of HmacKey::list.

§Features

This function requires that the feature flag sync is enabled in Cargo.toml.

Source

pub async fn read(access_id: &str) -> Result<HmacMeta>

Retrieves an HMAC key’s metadata. Since the HmacKey is secret, this does not return a HmacKey, but a HmacMeta. This is a redacted version of a HmacKey, but with the secret data omitted.

The authenticated user must have storage.hmacKeys.get permission for the project in which the key exists.

For general information about HMAC keys in Cloud Storage, see HMAC Keys.

§Example
use cloud_storage::hmac_key::HmacKey;

let key = HmacKey::read("some identifier").await?;
Source

pub fn read_sync(access_id: &str) -> Result<HmacMeta>

The synchronous equivalent of HmacKey::read.

§Features

This function requires that the feature flag sync is enabled in Cargo.toml.

Source

pub async fn update(access_id: &str, state: HmacState) -> Result<HmacMeta>

Updates the state of an HMAC key. See the HMAC Key resource descriptor for valid states. Since the HmacKey is secret, this does not return a HmacKey, but a HmacMeta. This is a redacted version of a HmacKey, but with the secret data omitted.

The authenticated user must have storage.hmacKeys.update permission for the project in which the key exists.

For general information about HMAC keys in Cloud Storage, see HMAC Keys.

§Example
use cloud_storage::hmac_key::{HmacKey, HmacState};

let key = HmacKey::update("your key", HmacState::Active).await?;
Source

pub fn update_sync(access_id: &str, state: HmacState) -> Result<HmacMeta>

The synchronous equivalent of HmacKey::update.

§Features

This function requires that the feature flag sync is enabled in Cargo.toml.

Source

pub async fn delete(access_id: &str) -> Result<()>

Deletes an HMAC key. Note that a key must be set to Inactive first.

The authenticated user must have storage.hmacKeys.delete permission for the project in which the key exists.

For general information about HMAC keys in Cloud Storage, see HMAC Keys.

§Example
use cloud_storage::hmac_key::{HmacKey, HmacState};

let key = HmacKey::update("your key", HmacState::Inactive).await?; // this is required.
HmacKey::delete(&key.access_id).await?;
Source

pub fn delete_sync(access_id: &str) -> Result<()>

The synchronous equivalent of HmacKey::delete.

Trait Implementations§

Source§

impl Debug for HmacKey

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for HmacKey

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for HmacKey

Source§

fn eq(&self, other: &HmacKey) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for HmacKey

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for HmacKey

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T