azure.storage.models module

class azure.storage.models.AccessPolicy(permission=None, expiry=None, start=None)[source]

Bases: object

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 table 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).

Parameters:
  • permission (str) – 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 (date 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 (date 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.
class azure.storage.models.AccountPermissions(read=False, write=False, delete=False, list=False, add=False, create=False, update=False, process=False, _str=None)[source]

Bases: object

ResourceTypes class to be used with generate_shared_access_signature method 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.

Variables:
Parameters:
  • read (bool) – Valid for all signed resources types (Service, Container, and Object). Permits read permissions to the specified resource type.
  • write (bool) – Valid for all signed resources types (Service, Container, and Object). Permits write permissions to the specified resource type.
  • delete (bool) – Valid for Container and Object resource types, except for queue messages.
  • list (bool) – Valid for Service and Container resource types only.
  • add (bool) – Valid for the following Object resource types only: queue messages, table entities, and append blobs.
  • create (bool) – Valid for the following Object resource types only: blobs and files. Users can create new blobs or files, but may not overwrite existing blobs or files.
  • update (bool) – Valid for the following Object resource types only: queue messages and table entities.
  • process (bool) – Valid for the following Object resource type only: queue messages.
  • _str (str) – A string representing the permissions.
ADD = <azure.storage.models.AccountPermissions object>
CREATE = <azure.storage.models.AccountPermissions object>
DELETE = <azure.storage.models.AccountPermissions object>
LIST = <azure.storage.models.AccountPermissions object>
PROCESS = <azure.storage.models.AccountPermissions object>
READ = <azure.storage.models.AccountPermissions object>
UPDATE = <azure.storage.models.AccountPermissions object>
WRITE = <azure.storage.models.AccountPermissions object>
class azure.storage.models.CorsRule(allowed_origins, allowed_methods, max_age_in_seconds=0, exposed_headers=None, allowed_headers=None)[source]

Bases: object

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.

For more information, see https://msdn.microsoft.com/en-us/library/azure/dn535601.aspx

Parameters:
  • allowed_origins (list of str) – A list of origin domains that will be allowed via CORS, or “*” to allow all domains. The list of must contain at least one entry. Limited to 64 origin domains. Each allowed origin can have up to 256 characters.
  • allowed_methods (list of str) – A list of HTTP methods that are allowed to be executed by the origin. The list of must contain at least one entry. For Azure Storage, permitted methods are DELETE, GET, HEAD, MERGE, POST, OPTIONS or PUT.
  • max_age_in_seconds (int) – The number of seconds that the client/browser should cache a preflight response.
  • exposed_headers (list of str) – Defaults to an empty list. A list of response headers to expose to CORS clients. Limited to 64 defined headers and two prefixed headers. Each header can be up to 256 characters.
  • allowed_headers (list of str) – Defaults to an empty list. A list of headers allowed to be part of the cross-origin request. Limited to 64 defined headers and 2 prefixed headers. Each header can be up to 256 characters.
class azure.storage.models.GeoReplication[source]

Bases: object

Contains statistics related to replication for the given service.

Variables:
  • status (str) –
    The status of the secondary location. Possible values are:
    live: Indicates that the secondary location is active and operational. bootstrap: Indicates initial synchronization from the primary location
    to the secondary location is in progress. This typically occurs when replication is first enabled.
    unavailable: Indicates that the secondary location is temporarily
    unavailable.
  • last_sync_time (date) – A GMT date value, to the second. All primary writes preceding this value are guaranteed to be available for read operations at the secondary. Primary writes after this point in time may or may not be available for reads. The value may be empty if LastSyncTime is not available. This can happen if the replication status is bootstrap or unavailable. Although geo-replication is continuously enabled, the LastSyncTime result may reflect a cached value from the service that is refreshed every few minutes.
class azure.storage.models.ListGenerator(resources, list_method, list_args, list_kwargs)[source]

Bases: _abcoll.Iterable

A generator object used to list storage resources. The generator will lazily follow the continuation tokens returned by the service and stop when all resources have been returned or max_results is reached.

If max_results is specified and the account has more than that number of resources, the generator will have a populated next_marker field once it finishes. This marker can be used to create a new generator if more results are desired.

class azure.storage.models.LocationMode[source]

Bases: object

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.

PRIMARY = 'primary'

Requests should be sent to the primary location.

SECONDARY = 'secondary'

Requests should be sent to the secondary location, if possible.

class azure.storage.models.Logging(delete=False, read=False, write=False, retention_policy=None)[source]

Bases: object

Storage Analytics logs detailed information about successful and failed requests to a storage service. This information can be used to monitor individual requests and to diagnose issues with a storage service. Requests are logged on a best-effort basis.

All logs are stored in block blobs in a container named $logs, which is automatically created when Storage Analytics is enabled for a storage account. The $logs container is located in the blob namespace of the storage account. This container cannot be deleted once Storage Analytics has been enabled, though its contents can be deleted.

For more information, see https://msdn.microsoft.com/en-us/library/azure/hh343262.aspx

Parameters:
  • delete (bool) – Indicates whether all delete requests should be logged.
  • read (bool) – Indicates whether all read requests should be logged.
  • write (bool) – Indicates whether all write requests should be logged.
  • retention_policy (RetentionPolicy) – The retention policy for the metrics.
class azure.storage.models.Metrics(enabled=False, include_apis=None, retention_policy=None)[source]

Bases: object

Metrics include aggregated transaction statistics and capacity data about requests to a storage service. Transactions are reported at both the API operation level as well as at the storage service level, and capacity is reported at the storage service level. Metrics data can be used to analyze storage service usage, diagnose issues with requests made against the storage service, and to improve the performance of applications that use a service.

For more information, see https://msdn.microsoft.com/en-us/library/azure/hh343258.aspx

Parameters:
  • enabled (bool) – Indicates whether metrics are enabled for the service.
  • include_apis (bool) – Required if enabled is True. Indicates whether metrics should generate summary statistics for called API operations.
  • retention_policy (RetentionPolicy) – The retention policy for the metrics.
class azure.storage.models.Protocol[source]

Bases: object

Specifies the protocol permitted for a SAS token. Note that HTTP only is not allowed.

HTTPS = 'https'

Allow HTTPS requests only.

HTTPS_HTTP = 'https,http'

Allow HTTP and HTTPS requests.

class azure.storage.models.ResourceTypes(service=False, container=False, object=False, _str=None)[source]

Bases: object

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

Variables:
  • ResourceTypes.CONTAINER (ResourceTypes) – Access to container-level APIs (e.g., Create/Delete Container, Create/Delete Queue, Create/Delete Table, Create/Delete Share, List Blobs/Files and Directories)
  • ResourceTypes.OBJECT (ResourceTypes) – Access to object-level APIs for blobs, queue messages, table entities, and files(e.g. Put Blob, Query Entity, Get Messages, Create File, etc.)
  • ResourceTypes.SERVICE (ResourceTypes) – Access to service-level APIs (e.g., Get/Set Service Properties, Get Service Stats, List Containers/Queues/Tables/Shares)
Parameters:
  • service (bool) – Access to service-level APIs (e.g., Get/Set Service Properties, Get Service Stats, List Containers/Queues/Tables/Shares)
  • container (bool) – Access to container-level APIs (e.g., Create/Delete Container, Create/Delete Queue, Create/Delete Table, Create/Delete Share, List Blobs/Files and Directories)
  • object (bool) – Access to object-level APIs for blobs, queue messages, table entities, and files(e.g. Put Blob, Query Entity, Get Messages, Create File, etc.)
  • _str (str) – A string representing the resource types.
CONTAINER = <azure.storage.models.ResourceTypes object>
OBJECT = <azure.storage.models.ResourceTypes object>
SERVICE = <azure.storage.models.ResourceTypes object>
class azure.storage.models.RetentionPolicy(enabled=False, days=None)[source]

Bases: object

By default, Storage Analytics will not delete any logging or metrics data. Blobs and table entities will continue to be written until the shared 20TB limit is reached. Once the 20TB limit is reached, Storage Analytics will stop writing new data and will not resume until free space is available. This 20TB limit is independent of the total limit for your storage account.

There are two ways to delete Storage Analytics data: by manually making deletion requests or by setting a data retention policy. Manual requests to delete Storage Analytics data are billable, but delete requests resulting from a retention policy are not billable.

Parameters:
  • enabled (bool) – Indicates whether a retention policy is enabled for the storage service. If disabled, logging and metrics data will be retained infinitely by the service unless explicitly deleted.
  • days (int) – Required if enabled is true. Indicates the number of days that metrics or logging data should be retained. All data older than this value will be deleted. The minimum value you can specify is 1; the largest value is 365 (one year).
class azure.storage.models.RetryContext[source]

Bases: object

Contains the request and response information that can be used to determine whether and how to retry. This context is stored across retries and may be used to store other information relevant to the retry strategy.

:ivar HTTPRequest request:
The request sent to the storage service.
:ivar HTTPResponse response:
The response returned by the storage service.
Variables:location_mode (LocationMode) – The location the request was sent to.
class azure.storage.models.ServiceProperties[source]

Bases: object

Returned by get_*_service_properties functions. Contains the properties of a storage service, including Analytics and CORS rules.

Azure Storage Analytics performs logging and provides metrics data for a storage account. You can use this data to trace requests, analyze usage trends, and diagnose issues with your storage account. To use Storage Analytics, you must enable it individually for each service you want to monitor.

The aggregated data is stored in a well-known blob (for logging) and in well-known tables (for metrics), which may be accessed using the Blob service and Table service APIs.

For an in-depth guide on using Storage Analytics and other tools to identify, diagnose, and troubleshoot Azure Storage-related issues, see http://azure.microsoft.com/documentation/articles/storage-monitoring-diagnosing-troubleshooting/

For more information on CORS, see https://msdn.microsoft.com/en-us/library/azure/dn535601.aspx

class azure.storage.models.ServiceStats[source]

Bases: object

Returned by get_*_service_stats functions. Contains statistics related to replication for the given service. It is only available when read-access geo-redundant replication is enabled for the storage account.

Variables:geo_replication (GeoReplication) – An object containing statistics related to replication for the given service.
class azure.storage.models.Services(blob=False, queue=False, table=False, file=False, _str=None)[source]

Bases: object

Specifies the services accessible with the account SAS.

Variables:
Parameters:
  • blob (bool) – Access to any blob service, for example, the .BlockBlobService
  • queue (bool) – Access to the .QueueService
  • table (bool) – Access to the .TableService
  • file (bool) – Access to the .FileService
  • _str (str) – A string representing the services.
BLOB = <azure.storage.models.Services object>
FILE = <azure.storage.models.Services object>
QUEUE = <azure.storage.models.Services object>
TABLE = <azure.storage.models.Services object>