Skip to content

Commit 282edaa

Browse files
authored
Simplify builder for account sas (#865)
1 parent 0d28f09 commit 282edaa

File tree

4 files changed

+58
-460
lines changed

4 files changed

+58
-460
lines changed

sdk/storage/src/core/clients/storage_account_client.rs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
use crate::authorization_policy::AuthorizationPolicy;
22
use crate::ConnectionString;
33
use crate::{
4-
core::No,
5-
hmac::sign,
6-
shared_access_signature::account_sas::{
7-
AccountSharedAccessSignatureBuilder, ClientAccountSharedAccessSignature,
8-
},
4+
hmac::sign, shared_access_signature::account_sas::AccountSharedAccessSignatureBuilder,
95
};
106
use azure_core::Method;
117
use azure_core::{
@@ -512,15 +508,13 @@ impl StorageAccountClient {
512508
None,
513509
)
514510
}
515-
}
516511

517-
impl ClientAccountSharedAccessSignature for StorageAccountClient {
518-
fn shared_access_signature(
512+
pub fn shared_access_signature(
519513
&self,
520-
) -> azure_core::Result<AccountSharedAccessSignatureBuilder<No, No, No, No>> {
521-
match self.storage_credentials {
522-
StorageCredentials::Key(ref account, ref key) => {
523-
Ok(AccountSharedAccessSignatureBuilder::new(account, key))
514+
) -> azure_core::Result<AccountSharedAccessSignatureBuilder> {
515+
match &self.storage_credentials {
516+
StorageCredentials::Key(account, key) => {
517+
Ok(AccountSharedAccessSignatureBuilder::new(account.clone(), key.clone()))
524518
}
525519
_ => Err(Error::message(ErrorKind::Other, "failed shared access signature generation. SAS can be generated only from key and account clients")),
526520
}

sdk/storage/src/core/mod.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,6 @@ mod stored_access_policy;
2121
pub use azure_core::error::{Error, ErrorKind, ResultExt};
2222
pub mod xml;
2323

24-
#[derive(Debug, Clone, Eq, PartialEq, Copy, Serialize, Deserialize)]
25-
pub struct Yes;
26-
#[derive(Debug, Clone, Eq, PartialEq, Copy, Serialize, Deserialize)]
27-
pub struct No;
28-
29-
pub trait ToAssign: std::fmt::Debug {}
30-
pub trait Assigned: ToAssign {}
31-
pub trait NotAssigned: ToAssign {}
32-
33-
impl ToAssign for Yes {}
34-
impl ToAssign for No {}
35-
36-
impl Assigned for Yes {}
37-
impl NotAssigned for No {}
38-
3924
#[derive(Debug, Clone, PartialEq)]
4025
pub struct IPRange {
4126
pub start: std::net::IpAddr,

sdk/storage/src/core/prelude.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
pub use crate::core::{
22
clients::{AsStorageClient, StorageAccountClient, StorageClient},
33
shared_access_signature::{
4-
account_sas::{
5-
AccountSasPermissions, AccountSasResource, AccountSasResourceType,
6-
ClientAccountSharedAccessSignature, SasExpirySupport, SasPermissionsSupport,
7-
SasProtocolSupport, SasResourceSupport, SasResourceTypeSupport, SasStartSupport,
8-
},
4+
account_sas::{AccountSasPermissions, AccountSasResource, AccountSasResourceType},
95
service_sas::{BlobSasPermissions, BlobSignedResource},
106
SasProtocol, SasToken,
117
},

0 commit comments

Comments
 (0)