/// <summary> /// Initializes a new instance of the <see cref="AccountSasBuilder"/> /// class to create a Blob Container Service Sas. /// </summary> /// <param name="permissions"> /// The time at which the shared access signature becomes invalid. /// This field must be omitted if it has been specified in an /// associated stored access policy. /// </param> /// <param name="expiresOn"> /// The time at which the shared access signature becomes invalid. /// This field must be omitted if it has been specified in an /// associated stored access policy. /// </param> /// <param name="services"> /// Specifies the services accessible from an account level shared access /// signature. /// </param> /// <param name="resourceTypes"> /// Specifies the resource types accessible from an account level shared /// access signature. /// </param> public AccountSasBuilder( AccountSasPermissions permissions, DateTimeOffset expiresOn, AccountSasServices services, AccountSasResourceTypes resourceTypes) { ExpiresOn = expiresOn; SetPermissions(permissions); Services = services; ResourceTypes = resourceTypes; }
/// <summary> /// Parse a string representing which services are accessible from a /// shared access signature. /// </summary> /// <param name="s"> /// A string representing which services are accessible. /// </param> /// <returns> /// An <see cref="AccountSasServices"/> instance. /// </returns> internal static AccountSasServices ParseAccountServices(string s) { AccountSasServices svcs = default; foreach (var ch in s) { svcs |= ch switch { Constants.Sas.AccountServices.Blob => AccountSasServices.Blobs, Constants.Sas.AccountServices.Queue => AccountSasServices.Queues, Constants.Sas.AccountServices.File => AccountSasServices.Files, _ => throw Errors.InvalidService(ch), }; } return(svcs); }
/// <summary> /// Creates a string representing which services can be used for /// <see cref="AccountSasBuilder.Services"/>. /// </summary> /// <returns> /// A string representing which services are allowed. /// </returns> internal static string ToPermissionsString(this AccountSasServices services) { var sb = new StringBuilder(); if ((services & AccountSasServices.Blobs) == AccountSasServices.Blobs) { sb.Append(Constants.Sas.AccountServices.Blob); } if ((services & AccountSasServices.Queues) == AccountSasServices.Queues) { sb.Append(Constants.Sas.AccountServices.Queue); } if ((services & AccountSasServices.Files) == AccountSasServices.Files) { sb.Append(Constants.Sas.AccountServices.File); } return(sb.ToString()); }