fileshare package
Packages
| aio |
Classes
| ShareFileClient |
A client to interact with a specific file, although that file may not yet exist. |
| 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(directory_name, **kwargs) and get_file_client(file_name, **kwargs) functions. |
| 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(directory_path=None) and get_file_client(file_path) functions. |
| 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(share, snapshot=None) function. |
| ShareLeaseClient |
Creates a new ShareLeaseClient. This client provides lease operations on a ShareFileClient. |
| ExponentialRetry |
Exponential retry. |
| LinearRetry |
Linear retry. |
| 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. |
| ResourceTypes |
Specifies the resource types that are accessible with the account SAS. |
| 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. |
| StorageErrorCode |
An enumeration. |
| 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. |
| 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. |
| 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. |
| 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). |
| FileSasPermissions |
FileSasPermissions class to be used with generating shared access signature operations. |
| ShareSasPermissions |
ShareSasPermissions class to be used to be used with generating shared access signature and access policy operations. |
| ShareProperties |
Share's properties class. |
| DirectoryProperties |
Directory's properties class. |
| FileProperties |
File's properties class. |
| ContentSettings |
Used to store the content settings of a file. |
| Handle |
A listed Azure Storage handle item. 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. |
| HandleItem |
A listed Azure Storage handle item. All required parameters must be populated in order to send to Azure. |
Functions
generate_account_sas(account_name, account_key, resource_types, permission, expiry, start=None, ip=None, **kwargs)
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, account_key, resource_types, permission, expiry, start=None, ip=None, **kwargs)
Parameters
- account_name
- str
The storage account name used to generate the shared access signature.
- account_key
- str
The account key, also called shared key or access key, to generate the shared access signature.
- resource_types
- ResourceTypes
Specifies the resource types that are accessible with the account SAS.
- permission
- AccountSasPermissions
The permissions associated with the shared access signature. The user is restricted to operations allowed by the permissions. 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.
- expiry
- datetime.datetime or str
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.
- start
- datetime.datetime or str
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.
- 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.
Returns
A Shared Access Signature (sas) token.
Return type
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_share_sas(account_name, share_name, account_key, permission=None, expiry=None, start=None, policy_id=None, ip=None, **kwargs)
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, share_name, account_key, permission=None, expiry=None, start=None, policy_id=None, ip=None, **kwargs)
Parameters
- account_name
- str
The storage account name used to generate the shared access signature.
- share_name
- str
The name of the share.
- account_key
- str
The account key, also called shared key or access key, to generate the shared access signature.
- permission
- ShareSasPermissions
The permissions associated with the shared access signature. The user is restricted to operations allowed by the permissions. Permissions must be ordered read, create, write, delete, list. 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.
- expiry
- datetime.datetime or str
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.
- start
- datetime.datetime or str
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.
- 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(signed_identifiers, **kwargs).
- 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.
Returns
A Shared Access Signature (sas) token.
Return type
generate_file_sas(account_name, share_name, file_path, account_key, permission=None, expiry=None, start=None, policy_id=None, ip=None, **kwargs)
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, share_name, file_path, account_key, permission=None, expiry=None, start=None, policy_id=None, ip=None, **kwargs)
Parameters
- account_name
- str
The storage account name used to generate the shared access signature.
- share_name
- str
The name of the share.
- file_path
- List[str]
The file path represented as a list of path segments, including the file name.
- account_key
- str
The account key, also called shared key or access key, to generate the shared access signature.
- permission
- FileSasPermissions
The permissions associated with the shared access signature. The user is restricted to operations allowed by the permissions. Permissions must be ordered read, write, delete, list. 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.
- expiry
- datetime.datetime or str
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.
- start
- datetime.datetime or str
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.
- policy_id
- str
A unique value up to 64 characters in length that correlates to a stored access policy.
- 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.
Returns
A Shared Access Signature (sas) token.