Struct cloud_storage::hmac_key::HmacKey
source · [−]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
sourceimpl HmacKey
impl HmacKey
sourcepub async fn create() -> Result<Self>
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?;
sourcepub fn create_sync() -> Result<Self>
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
.
sourcepub async fn list() -> Result<Vec<HmacMeta>>
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?;
sourcepub fn list_sync() -> Result<Vec<HmacMeta>>
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
.
sourcepub async fn read(access_id: &str) -> Result<HmacMeta>
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?;
sourcepub fn read_sync(access_id: &str) -> Result<HmacMeta>
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
.
sourcepub async fn update(access_id: &str, state: HmacState) -> Result<HmacMeta>
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?;
sourcepub fn update_sync(access_id: &str, state: HmacState) -> Result<HmacMeta>
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
.
sourcepub async fn delete(access_id: &str) -> Result<()>
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?;
sourcepub fn delete_sync(access_id: &str) -> Result<()>
pub fn delete_sync(access_id: &str) -> Result<()>
The synchronous equivalent of HmacKey::delete
.
Trait Implementations
sourceimpl<'de> Deserialize<'de> for HmacKey
impl<'de> Deserialize<'de> for HmacKey
sourcefn 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 StructuralPartialEq for HmacKey
Auto Trait Implementations
impl RefUnwindSafe for HmacKey
impl Send for HmacKey
impl Sync for HmacKey
impl Unpin for HmacKey
impl UnwindSafe for HmacKey
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
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
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more