fileshare Package

Packages

aio

Classes

AccessPolicy

Access Policy class used by the set and get acl methods in each service.

A stored access policy can specify the start time, expiry time, and permissions for the Shared Access Signatures with which it's associated. Depending on how you want to control access to your resource, you can specify all of these parameters within the stored access policy, and omit them from the URL for the Shared Access Signature. Doing so permits you to modify the associated signature's behavior at any time, as well as to revoke it. Or you can specify one or more of the access policy parameters within the stored access policy, and the others on the URL. Finally, you can specify all of the parameters on the URL. In this case, you can use the stored access policy to revoke the signature, but not to modify its behavior.

Together the Shared Access Signature and the stored access policy must include all fields required to authenticate the signature. If any required fields are missing, the request will fail. Likewise, if a field is specified both in the Shared Access Signature URL and in the stored access policy, the request will fail with status code 400 (Bad Request).

AccountSasPermissions

ResourceTypes class to be used with generate_account_sas function and for the AccessPolicies used with set_*_acl. There are two types of SAS which may be used to grant resource access. One is to grant access to a specific resource (resource-specific). Another is to grant access to the entire service for a specific account and allow certain operations based on perms found here.

ContentSettings

Used to store the content settings of a file.

CorsRule

CORS is an HTTP feature that enables a web application running under one domain to access resources in another domain. Web browsers implement a security restriction known as same-origin policy that prevents a web page from calling APIs in a different domain; CORS provides a secure way to allow one domain (the origin domain) to call APIs in another domain.

All required parameters must be populated in order to send to Azure.

DirectoryProperties

Directory's properties class.

ExponentialRetry

Exponential retry.

Constructs an Exponential retry object. The initial_backoff is used for the first retry. Subsequent retries are retried after initial_backoff + increment_power^retry_count seconds.

FileProperties

File's properties class.

FileSasPermissions

FileSasPermissions class to be used with generating shared access signature operations.

Handle

A listed Azure Storage handle item.

All required parameters must be populated in order to send to Azure.

LinearRetry

Linear retry.

Constructs a Linear retry object.

LocationMode

Specifies the location the request should be sent to. This mode only applies for RA-GRS accounts which allow secondary read access. All other account types must use PRIMARY.

Metrics

A summary of request statistics grouped by API in hour or minute aggregates for files.

All required parameters must be populated in order to send to Azure.

NTFSAttributes

Valid set of attributes to set for file or directory. To set attribute for directory, 'Directory' should always be enabled except setting 'None' for directory.

ResourceTypes

Specifies the resource types that are accessible with the account SAS.

RetentionPolicy

The retention policy which determines how long the associated data should persist.

All required parameters must be populated in order to send to Azure.

ShareClient

A client to interact with a specific share, although that share may not yet exist.

For operations relating to a specific directory or file in this share, the clients for those entities can also be retrieved using the get_directory_client and get_file_client functions.

For more optional configuration, please click here.

ShareDirectoryClient

A client to interact with a specific directory, although it may not yet exist.

For operations relating to a specific subdirectory or file in this share, the clients for those entities can also be retrieved using the get_subdirectory_client and get_file_client functions.

For more optional configuration, please click here.

ShareFileClient

A client to interact with a specific file, although that file may not yet exist.

For more optional configuration, please click here.

ShareLeaseClient

Creates a new ShareLeaseClient.

This client provides lease operations on a ShareClient or ShareFileClient.

ShareProperties

Share's properties class.

ShareProtocolSettings

Protocol Settings class used by the set and get service properties methods in the share service.

Contains protocol properties of the share service such as the SMB setting of the share service.

ShareSasPermissions

ShareSasPermissions class to be used to be used with generating shared access signature and access policy operations.

ShareServiceClient

A client to interact with the File Share Service at the account level.

This client provides operations to retrieve and configure the account properties as well as list, create and delete shares within the account. For operations relating to a specific share, a client for that entity can also be retrieved using the get_share_client function.

For more optional configuration, please click here.

ShareSmbSettings

Settings for the SMB protocol.

SmbMultichannel

Settings for Multichannel.

Enums

ShareAccessTier

ShareAccessTier.

ShareProtocols

Enabled protocols on the share

ShareRootSquash

ShareRootSquash.

StorageErrorCode

Functions

generate_account_sas

Generates a shared access signature for the file service.

Use the returned signature with the credential parameter of any ShareServiceClient, ShareClient, ShareDirectoryClient, or ShareFileClient.

generate_account_sas(account_name: str, account_key: str, resource_types: ResourceTypes | str, permission: AccountSasPermissions | str, expiry: datetime | str, start: datetime | str | None = None, ip: str | None = None, **kwargs: Any) -> str

Parameters

Name Description
account_name
Required
str

The storage account name used to generate the shared access signature.

account_key
Required
str

The account key, also called shared key or access key, to generate the shared access signature.

resource_types
Required

Specifies the resource types that are accessible with the account SAS.

permission
Required

The permissions associated with the shared access signature. The user is restricted to operations allowed by the permissions.

expiry
Required

The time at which the shared access signature becomes invalid. Azure will always convert values to UTC. If a date is passed in without timezone info, it is assumed to be UTC.

start

The time at which the shared access signature becomes valid. If omitted, start time for this call is assumed to be the time when the storage service receives the request. Azure will always convert values to UTC. If a date is passed in without timezone info, it is assumed to be UTC.

default value: None
ip
str

Specifies an IP address or a range of IP addresses from which to accept requests. If the IP address from which the request originates does not match the IP address or address range specified on the SAS token, the request is not authenticated. For example, specifying sip=168.1.5.65 or sip=168.1.5.60-168.1.5.70 on the SAS restricts the request to those IP addresses.

default value: None

Keyword-Only Parameters

Name Description
protocol
str

Specifies the protocol permitted for a request made. The default value is https.

Returns

Type Description
str

A Shared Access Signature (sas) token.

Examples

Generate a sas token.


   from azure.storage.fileshare import ShareServiceClient
   share_service_client = ShareServiceClient.from_connection_string(self.connection_string)

   # Create a SAS token to use to authenticate a new client
   from azure.storage.fileshare import generate_account_sas, ResourceTypes, AccountSasPermissions

   sas_token = generate_account_sas(
       self.account_name,
       self.access_key,
       resource_types=ResourceTypes(service=True),
       permission=AccountSasPermissions(read=True),
       expiry=datetime.utcnow() + timedelta(hours=1)
   )

generate_file_sas

Generates a shared access signature for a file.

Use the returned signature with the credential parameter of any ShareServiceClient, ShareClient, ShareDirectoryClient, or ShareFileClient.

generate_file_sas(account_name: str, share_name: str, file_path: List[str], account_key: str, permission: FileSasPermissions | str | None = None, expiry: datetime | str | None = None, start: datetime | str | None = None, policy_id: str | None = None, ip: str | None = None, **kwargs: Any) -> str

Parameters

Name Description
account_name
Required
str

The storage account name used to generate the shared access signature.

share_name
Required
str

The name of the share.

file_path
Required

The file path represented as a list of path segments, including the file name.

account_key
Required
str

The account key, also called shared key or access key, to generate the shared access signature.

permission

The permissions associated with the shared access signature. The user is restricted to operations allowed by the permissions. Permissions must be ordered rcwd. Required unless an id is given referencing a stored access policy which contains this field. This field must be omitted if it has been specified in an associated stored access policy.

default value: None
expiry

The time at which the shared access signature becomes invalid. Required unless an id is given referencing a stored access policy which contains this field. This field must be omitted if it has been specified in an associated stored access policy. Azure will always convert values to UTC. If a date is passed in without timezone info, it is assumed to be UTC.

default value: None
start

The time at which the shared access signature becomes valid. If omitted, start time for this call is assumed to be the time when the storage service receives the request. Azure will always convert values to UTC. If a date is passed in without timezone info, it is assumed to be UTC.

default value: None
policy_id
str

A unique value up to 64 characters in length that correlates to a stored access policy.

default value: None
ip
str

Specifies an IP address or a range of IP addresses from which to accept requests. If the IP address from which the request originates does not match the IP address or address range specified on the SAS token, the request is not authenticated. For example, specifying sip=168.1.5.65 or sip=168.1.5.60-168.1.5.70 on the SAS restricts the request to those IP addresses.

default value: None

Keyword-Only Parameters

Name Description
cache_control
str

Response header value for Cache-Control when resource is accessed using this shared access signature.

content_disposition
str

Response header value for Content-Disposition when resource is accessed using this shared access signature.

content_encoding
str

Response header value for Content-Encoding when resource is accessed using this shared access signature.

content_language
str

Response header value for Content-Language when resource is accessed using this shared access signature.

content_type
str

Response header value for Content-Type when resource is accessed using this shared access signature.

protocol
str

Specifies the protocol permitted for a request made. The default value is https.

Returns

Type Description
str

A Shared Access Signature (sas) token.

generate_share_sas

Generates a shared access signature for a share.

Use the returned signature with the credential parameter of any ShareServiceClient, ShareClient, ShareDirectoryClient, or ShareFileClient.

generate_share_sas(account_name: str, share_name: str, account_key: str, permission: ShareSasPermissions | str | None = None, expiry: datetime | str | None = None, start: datetime | str | None = None, policy_id: str | None = None, ip: str | None = None, **kwargs: Any) -> str

Parameters

Name Description
account_name
Required
str

The storage account name used to generate the shared access signature.

share_name
Required
str

The name of the share.

account_key
Required
str

The account key, also called shared key or access key, to generate the shared access signature.

permission

The permissions associated with the shared access signature. The user is restricted to operations allowed by the permissions. Permissions must be ordered rcwdl. Required unless an id is given referencing a stored access policy which contains this field. This field must be omitted if it has been specified in an associated stored access policy.

default value: None
expiry

The time at which the shared access signature becomes invalid. Required unless an id is given referencing a stored access policy which contains this field. This field must be omitted if it has been specified in an associated stored access policy. Azure will always convert values to UTC. If a date is passed in without timezone info, it is assumed to be UTC.

default value: None
start

The time at which the shared access signature becomes valid. If omitted, start time for this call is assumed to be the time when the storage service receives the request. Azure will always convert values to UTC. If a date is passed in without timezone info, it is assumed to be UTC.

default value: None
policy_id
str

A unique value up to 64 characters in length that correlates to a stored access policy. To create a stored access policy, use set_share_access_policy.

default value: None
ip
str

Specifies an IP address or a range of IP addresses from which to accept requests. If the IP address from which the request originates does not match the IP address or address range specified on the SAS token, the request is not authenticated. For example, specifying sip=168.1.5.65 or sip=168.1.5.60-168.1.5.70 on the SAS restricts the request to those IP addresses.

default value: None

Keyword-Only Parameters

Name Description
cache_control
str

Response header value for Cache-Control when resource is accessed using this shared access signature.

content_disposition
str

Response header value for Content-Disposition when resource is accessed using this shared access signature.

content_encoding
str

Response header value for Content-Encoding when resource is accessed using this shared access signature.

content_language
str

Response header value for Content-Language when resource is accessed using this shared access signature.

content_type
str

Response header value for Content-Type when resource is accessed using this shared access signature.

protocol
str

Specifies the protocol permitted for a request made. The default value is https.

Returns

Type Description
str

A Shared Access Signature (sas) token.