azure.storage.queue package¶
-
class
azure.storage.queue.
QueueClient
(account_url, queue_name, credential=None, **kwargs)[source]¶ A client to interact with a specific Queue.
- Parameters
account_url (str) – The URL to the storage account. In order to create a client given the full URI to the queue, use the
from_queue_url()
classmethod.queue_name (str) – The name of the queue.
credential – The credentials with which to authenticate. This is optional if the account URL already has a SAS token. The value can be a SAS token string, an account shared access key, or an instance of a TokenCredentials class from azure.identity.
- Keyword Arguments
api_version (str) – The Storage API version to use for requests. Default value is ‘2019-07-07’. Setting to an older version may result in reduced feature compatibility.
secondary_hostname (str) – The hostname of the secondary endpoint.
message_encode_policy – The encoding policy to use on outgoing messages. Default is not to encode messages. Other options include
TextBase64EncodePolicy
,BinaryBase64EncodePolicy
or None.message_decode_policy – The decoding policy to use on incoming messages. Default value is not to decode messages. Other options include
TextBase64DecodePolicy
,BinaryBase64DecodePolicy
or None.
Example:
token_auth_queue = QueueClient.from_queue_url( queue_url=queue.url, credential=sas_token )
-
clear_messages
(**kwargs)[source]¶ Deletes all messages from the specified queue.
- Keyword Arguments
timeout (int) – The server timeout, expressed in seconds.
Example:
queue.clear_messages()
-
close
()¶ This method is to close the sockets opened by the client. It need not be used when using with a context manager.
-
create_queue
(**kwargs)[source]¶ Creates a new queue in the storage account.
If a queue with the same name already exists, the operation fails with a ResourceExistsError.
- Keyword Arguments
- Returns
None or the result of cls(response)
- Return type
- Raises
StorageErrorException
Example:
queue.create_queue()
-
delete_message
(message, pop_receipt=None, **kwargs)[source]¶ Deletes the specified message.
Normally after a client retrieves a message with the receive messages operation, the client is expected to process and delete the message. To delete the message, you must have the message object itself, or two items of data: id and pop_receipt. The id is returned from the previous receive_messages operation. The pop_receipt is returned from the most recent
receive_messages()
orupdate_message()
operation. In order for the delete_message operation to succeed, the pop_receipt specified on the request must match the pop_receipt returned from thereceive_messages()
orupdate_message()
operation.- Parameters
message (str or QueueMessage) – The message object or id identifying the message to delete.
pop_receipt (str) – A valid pop receipt value returned from an earlier call to the
receive_messages()
orupdate_message()
.
- Keyword Arguments
timeout (int) – The server timeout, expressed in seconds.
Example:
# Get the message at the front of the queue msg = next(queue.receive_messages()) # Delete the specified message queue.delete_message(msg)
-
delete_queue
(**kwargs)[source]¶ Deletes the specified queue and any messages it contains.
When a queue is successfully deleted, it is immediately marked for deletion and is no longer accessible to clients. The queue is later removed from the Queue service during garbage collection.
Note that deleting a queue is likely to take at least 40 seconds to complete. If an operation is attempted against the queue while it was being deleted, an
HttpResponseError
will be thrown.Example:
queue.delete_queue()
-
classmethod
from_connection_string
(conn_str, queue_name, credential=None, **kwargs)[source]¶ Create QueueClient from a Connection String.
- Parameters
conn_str (str) – A connection string to an Azure Storage account.
queue_name (str) – The queue name.
credential – The credentials with which to authenticate. This is optional if the account URL already has a SAS token, or the connection string already has shared access key values. The value can be a SAS token string, an account shared access key, or an instance of a TokenCredentials class from azure.identity.
- Returns
A queue client.
- Return type
Example:
from azure.storage.queue import QueueClient queue = QueueClient.from_connection_string(self.connection_string, "myqueue1")
-
classmethod
from_queue_url
(queue_url, credential=None, **kwargs)[source]¶ A client to interact with a specific Queue.
- Parameters
queue_url (str) – The full URI to the queue, including SAS token if used.
credential – The credentials with which to authenticate. This is optional if the account URL already has a SAS token. The value can be a SAS token string, an account shared access key, or an instance of a TokenCredentials class from azure.identity.
- Returns
A queue client.
- Return type
-
get_queue_access_policy
(**kwargs)[source]¶ Returns details about any stored access policies specified on the queue that may be used with Shared Access Signatures.
- Keyword Arguments
timeout (int) – The server timeout, expressed in seconds.
- Returns
A dictionary of access policies associated with the queue.
- Return type
-
get_queue_properties
(**kwargs)[source]¶ Returns all user-defined metadata for the specified queue.
The data returned does not include the queue’s list of messages.
- Keyword Arguments
timeout (int) – The timeout parameter is expressed in seconds.
- Returns
User-defined metadata for the queue.
- Return type
Example:
properties = queue.get_queue_properties().metadata
-
peek_messages
(max_messages=None, **kwargs)[source]¶ Retrieves one or more messages from the front of the queue, but does not alter the visibility of the message.
Only messages that are visible may be retrieved. When a message is retrieved for the first time with a call to
receive_messages()
, its dequeue_count property is set to 1. If it is not deleted and is subsequently retrieved again, the dequeue_count property is incremented. The client may use this value to determine how many times a message has been retrieved. Note that a call to peek_messages does not increment the value of dequeue_count, but returns this value for the client to read.If the key-encryption-key or resolver field is set on the local service object, the messages will be decrypted before being returned.
- Parameters
max_messages (int) – A nonzero integer value that specifies the number of messages to peek from the queue, up to a maximum of 32. By default, a single message is peeked from the queue with this operation.
- Keyword Arguments
timeout (int) – The server timeout, expressed in seconds.
- Returns
A list of
QueueMessage
objects. Note that next_visible_on and pop_receipt will not be populated as peek does not pop the message and can only retrieve already visible messages.- Return type
list(
QueueMessage
)
Example:
# Peek at one message at the front of the queue msg = queue.peek_messages() # Peek at the last 5 messages messages = queue.peek_messages(max_messages=5) # Print the last 5 messages for message in messages: print(message.content)
-
receive_messages
(**kwargs)[source]¶ Removes one or more messages from the front of the queue.
When a message is retrieved from the queue, the response includes the message content and a pop_receipt value, which is required to delete the message. The message is not automatically deleted from the queue, but after it has been retrieved, it is not visible to other clients for the time interval specified by the visibility_timeout parameter.
If the key-encryption-key or resolver field is set on the local service object, the messages will be decrypted before being returned.
- Keyword Arguments
messages_per_page (int) – A nonzero integer value that specifies the number of messages to retrieve from the queue, up to a maximum of 32. If fewer are visible, the visible messages are returned. By default, a single message is retrieved from the queue with this operation.
visibility_timeout (int) – If not specified, the default value is 0. Specifies the new visibility timeout value, in seconds, relative to server time. The value must be larger than or equal to 0, and cannot be larger than 7 days. The visibility timeout of a message cannot be set to a value later than the expiry time. visibility_timeout should be set to a value smaller than the time-to-live value.
timeout (int) – The server timeout, expressed in seconds.
- Returns
Returns a message iterator of dict-like Message objects.
- Return type
Example:
# Receive messages one-by-one messages = queue.receive_messages() for msg in messages: print(msg.content) # Receive messages by batch messages = queue.receive_messages(messages_per_page=5) for msg_batch in messages.by_page(): for msg in msg_batch: print(msg.content) queue.delete_message(msg)
-
send_message
(content, **kwargs)[source]¶ Adds a new message to the back of the message queue.
The visibility timeout specifies the time that the message will be invisible. After the timeout expires, the message will become visible. If a visibility timeout is not specified, the default value of 0 is used.
The message time-to-live specifies how long a message will remain in the queue. The message will be deleted from the queue when the time-to-live period expires.
If the key-encryption-key field is set on the local service object, this method will encrypt the content before uploading.
- Parameters
content (obj) – Message content. Allowed type is determined by the encode_function set on the service. Default is str. The encoded message can be up to 64KB in size.
- Keyword Arguments
visibility_timeout (int) – If not specified, the default value is 0. Specifies the new visibility timeout value, in seconds, relative to server time. The value must be larger than or equal to 0, and cannot be larger than 7 days. The visibility timeout of a message cannot be set to a value later than the expiry time. visibility_timeout should be set to a value smaller than the time-to-live value.
time_to_live (int) – Specifies the time-to-live interval for the message, in seconds. The time-to-live may be any positive number or -1 for infinity. If this parameter is omitted, the default time-to-live is 7 days.
timeout (int) – The server timeout, expressed in seconds.
- Returns
A
QueueMessage
object. This object is also populated with the content although it is not returned from the service.- Return type
Example:
queue.send_message(u"message1") queue.send_message(u"message2", visibility_timeout=30) # wait 30s before becoming visible queue.send_message(u"message3") queue.send_message(u"message4") queue.send_message(u"message5")
-
set_queue_access_policy
(signed_identifiers, **kwargs)[source]¶ Sets stored access policies for the queue that may be used with Shared Access Signatures.
When you set permissions for a queue, the existing permissions are replaced. To update the queue’s permissions, call
get_queue_access_policy()
to fetch all access policies associated with the queue, modify the access policy that you wish to change, and then call this function with the complete set of data to perform the update.When you establish a stored access policy on a queue, it may take up to 30 seconds to take effect. During this interval, a shared access signature that is associated with the stored access policy will throw an
HttpResponseError
until the access policy becomes active.- Parameters
signed_identifiers (dict(str, AccessPolicy)) – SignedIdentifier access policies to associate with the queue. This may contain up to 5 elements. An empty dict will clear the access policies set on the service.
- Keyword Arguments
timeout (int) – The server timeout, expressed in seconds.
Example:
# Create an access policy from azure.storage.queue import AccessPolicy, QueueSasPermissions access_policy = AccessPolicy() access_policy.start = datetime.utcnow() - timedelta(hours=1) access_policy.expiry = datetime.utcnow() + timedelta(hours=1) access_policy.permission = QueueSasPermissions(read=True) identifiers = {'my-access-policy-id': access_policy} # Set the access policy queue.set_queue_access_policy(identifiers)
-
set_queue_metadata
(metadata=None, **kwargs)[source]¶ Sets user-defined metadata on the specified queue.
Metadata is associated with the queue as name-value pairs.
- Parameters
metadata (dict(str, str)) – A dict containing name-value pairs to associate with the queue as metadata.
- Keyword Arguments
timeout (int) – The server timeout, expressed in seconds.
Example:
metadata = {'foo': 'val1', 'bar': 'val2', 'baz': 'val3'} queue.set_queue_metadata(metadata=metadata)
-
update_message
(message, pop_receipt=None, content=None, **kwargs)[source]¶ Updates the visibility timeout of a message. You can also use this operation to update the contents of a message.
This operation can be used to continually extend the invisibility of a queue message. This functionality can be useful if you want a worker role to “lease” a queue message. For example, if a worker role calls
receive_messages()
and recognizes that it needs more time to process a message, it can continually extend the message’s invisibility until it is processed. If the worker role were to fail during processing, eventually the message would become visible again and another worker role could process it.If the key-encryption-key field is set on the local service object, this method will encrypt the content before uploading.
- Parameters
message (str or QueueMessage) – The message object or id identifying the message to update.
pop_receipt (str) – A valid pop receipt value returned from an earlier call to the
receive_messages()
orupdate_message()
operation.content (obj) – Message content. Allowed type is determined by the encode_function set on the service. Default is str.
- Keyword Arguments
visibility_timeout (int) – Specifies the new visibility timeout value, in seconds, relative to server time. The new value must be larger than or equal to 0, and cannot be larger than 7 days. The visibility timeout of a message cannot be set to a value later than the expiry time. A message can be updated until it has been deleted or has expired. The message object or message id identifying the message to update.
timeout (int) – The server timeout, expressed in seconds.
- Returns
A
QueueMessage
object. For convenience, this object is also populated with the content, although it is not returned by the service.- Return type
Example:
# Send a message queue.send_message(u"update me") # Receive the message messages = queue.receive_messages() # Update the message list_result = next(messages) message = queue.update_message( list_result.id, pop_receipt=list_result.pop_receipt, visibility_timeout=0, content=u"updated")
-
property
location_mode
¶ The location mode that the client is currently using.
By default this will be “primary”. Options include “primary” and “secondary”.
- Type
-
property
secondary_endpoint
¶ The full secondary endpoint URL if configured.
If not available a ValueError will be raised. To explicitly specify a secondary hostname, use the optional secondary_hostname keyword argument on instantiation.
- Type
- Raises
-
property
secondary_hostname
¶ The hostname of the secondary endpoint.
If not available this will be None. To explicitly specify a secondary hostname, use the optional secondary_hostname keyword argument on instantiation.
-
property
url
¶ The full endpoint URL to this entity, including SAS token if used.
This could be either the primary endpoint, or the secondary endpoint depending on the current
location_mode()
.
-
class
azure.storage.queue.
QueueServiceClient
(account_url, credential=None, **kwargs)[source]¶ A client to interact with the Queue Service at the account level.
This client provides operations to retrieve and configure the account properties as well as list, create and delete queues within the account. For operations relating to a specific queue, a client for this entity can be retrieved using the
get_queue_client()
function.- Parameters
account_url (str) – The URL to the queue service endpoint. Any other entities included in the URL path (e.g. queue) will be discarded. This URL can be optionally authenticated with a SAS token.
credential – The credentials with which to authenticate. This is optional if the account URL already has a SAS token. The value can be a SAS token string, an account shared access key, or an instance of a TokenCredentials class from azure.identity.
- Keyword Arguments
Example:
from azure.storage.queue import QueueServiceClient queue_service = QueueServiceClient(account_url=self.account_url, credential=self.access_key)
# Get a token credential for authentication from azure.identity import ClientSecretCredential token_credential = ClientSecretCredential( self.active_directory_tenant_id, self.active_directory_application_id, self.active_directory_application_secret ) # Instantiate a QueueServiceClient using a token credential from azure.storage.queue import QueueServiceClient queue_service = QueueServiceClient(account_url=self.account_url, credential=token_credential)
-
close
()¶ This method is to close the sockets opened by the client. It need not be used when using with a context manager.
-
create_queue
(name, metadata=None, **kwargs)[source]¶ Creates a new queue under the specified account.
If a queue with the same name already exists, the operation fails. Returns a client with which to interact with the newly created queue.
- Parameters
- Keyword Arguments
timeout (int) – The timeout parameter is expressed in seconds.
- Return type
Example:
queue_service.create_queue("myqueue1")
-
delete_queue
(queue, **kwargs)[source]¶ Deletes the specified queue and any messages it contains.
When a queue is successfully deleted, it is immediately marked for deletion and is no longer accessible to clients. The queue is later removed from the Queue service during garbage collection.
Note that deleting a queue is likely to take at least 40 seconds to complete. If an operation is attempted against the queue while it was being deleted, an
HttpResponseError
will be thrown.- Parameters
queue (str or QueueProperties) – The queue to delete. This can either be the name of the queue, or an instance of QueueProperties.
- Keyword Arguments
timeout (int) – The timeout parameter is expressed in seconds.
- Return type
Example:
queue_service.delete_queue("myqueue1")
-
classmethod
from_connection_string
(conn_str, credential=None, **kwargs)[source]¶ Create QueueServiceClient from a Connection String.
- Parameters
conn_str (str) – A connection string to an Azure Storage account.
credential – The credentials with which to authenticate. This is optional if the account URL already has a SAS token, or the connection string already has shared access key values. The value can be a SAS token string, an account shared access key, or an instance of a TokenCredentials class from azure.identity.
- Returns
A Queue service client.
- Return type
Example:
from azure.storage.queue import QueueServiceClient queue_service = QueueServiceClient.from_connection_string(conn_str=self.connection_string)
-
get_queue_client
(queue, **kwargs)[source]¶ Get a client to interact with the specified queue.
The queue need not already exist.
- Parameters
queue (str or QueueProperties) – The queue. This can either be the name of the queue, or an instance of QueueProperties.
- Returns
A
QueueClient
object.- Return type
Example:
# Get the queue client to interact with a specific queue queue = queue_service.get_queue_client(queue="myqueue2")
-
get_service_properties
(**kwargs)[source]¶ Gets the properties of a storage account’s Queue service, including Azure Storage Analytics.
- Keyword Arguments
timeout (int) – The timeout parameter is expressed in seconds.
- Returns
An object containing queue service properties such as analytics logging, hour/minute metrics, cors rules, etc.
- Return type
Dict[str, Any]
Example:
properties = queue_service.get_service_properties()
-
get_service_stats
(**kwargs)[source]¶ Retrieves statistics related to replication for the Queue service.
It is only available when read-access geo-redundant replication is enabled for the storage account.
With geo-redundant replication, Azure Storage maintains your data durable in two locations. In both locations, Azure Storage constantly maintains multiple healthy replicas of your data. The location where you read, create, update, or delete data is the primary storage account location. The primary location exists in the region you choose at the time you create an account via the Azure Management Azure classic portal, for example, North Central US. The location to which your data is replicated is the secondary location. The secondary location is automatically determined based on the location of the primary; it is in a second data center that resides in the same region as the primary location. Read-only access is available from the secondary location, if read-access geo-redundant replication is enabled for your storage account.
-
list_queues
(name_starts_with=None, include_metadata=False, **kwargs)[source]¶ Returns a generator to list the queues under the specified account.
The generator will lazily follow the continuation tokens returned by the service and stop when all queues have been returned.
- Parameters
- Keyword Arguments
results_per_page (int) – The maximum number of queue names to retrieve per API call. If the request does not specify the server will return up to 5,000 items.
timeout (int) – The server timeout, expressed in seconds. This function may make multiple calls to the service in which case the timeout value specified will be applied to each individual call.
- Returns
An iterable (auto-paging) of QueueProperties.
- Return type
Example:
# List all the queues in the service list_queues = queue_service.list_queues() for queue in list_queues: print(queue) # List the queues in the service that start with the name "my" list_my_queues = queue_service.list_queues(name_starts_with="my") for queue in list_my_queues: print(queue)
-
set_service_properties
(analytics_logging=None, hour_metrics=None, minute_metrics=None, cors=None, **kwargs)[source]¶ Sets the properties of a storage account’s Queue service, including Azure Storage Analytics.
If an element (e.g. analytics_logging) is left as None, the existing settings on the service for that functionality are preserved.
- Parameters
analytics_logging (QueueAnalyticsLogging) – Groups the Azure Analytics Logging settings.
hour_metrics (Metrics) – The hour metrics settings provide a summary of request statistics grouped by API in hourly aggregates for queues.
minute_metrics (Metrics) – The minute metrics settings provide request statistics for each minute for queues.
cors (list(CorsRule)) – You can include up to five CorsRule elements in the list. If an empty list is specified, all CORS rules will be deleted, and CORS will be disabled for the service.
- Keyword Arguments
timeout (int) – The timeout parameter is expressed in seconds.
- Return type
Example:
# Create service properties from azure.storage.queue import QueueAnalyticsLogging, Metrics, CorsRule, RetentionPolicy # Create logging settings logging = QueueAnalyticsLogging(read=True, write=True, delete=True, retention_policy=RetentionPolicy(enabled=True, days=5)) # Create metrics for requests statistics hour_metrics = Metrics(enabled=True, include_apis=True, retention_policy=RetentionPolicy(enabled=True, days=5)) minute_metrics = Metrics(enabled=True, include_apis=True, retention_policy=RetentionPolicy(enabled=True, days=5)) # Create CORS rules cors_rule1 = CorsRule(['www.xyz.com'], ['GET']) allowed_origins = ['www.xyz.com', "www.ab.com", "www.bc.com"] allowed_methods = ['GET', 'PUT'] max_age_in_seconds = 500 exposed_headers = ["x-ms-meta-data*", "x-ms-meta-source*", "x-ms-meta-abc", "x-ms-meta-bcd"] allowed_headers = ["x-ms-meta-data*", "x-ms-meta-target*", "x-ms-meta-xyz", "x-ms-meta-foo"] cors_rule2 = CorsRule( allowed_origins, allowed_methods, max_age_in_seconds=max_age_in_seconds, exposed_headers=exposed_headers, allowed_headers=allowed_headers ) cors = [cors_rule1, cors_rule2] # Set the service properties queue_service.set_service_properties(logging, hour_metrics, minute_metrics, cors)
-
property
location_mode
¶ The location mode that the client is currently using.
By default this will be “primary”. Options include “primary” and “secondary”.
- Type
-
property
secondary_endpoint
¶ The full secondary endpoint URL if configured.
If not available a ValueError will be raised. To explicitly specify a secondary hostname, use the optional secondary_hostname keyword argument on instantiation.
- Type
- Raises
-
property
secondary_hostname
¶ The hostname of the secondary endpoint.
If not available this will be None. To explicitly specify a secondary hostname, use the optional secondary_hostname keyword argument on instantiation.
-
property
url
¶ The full endpoint URL to this entity, including SAS token if used.
This could be either the primary endpoint, or the secondary endpoint depending on the current
location_mode()
.
-
class
azure.storage.queue.
ExponentialRetry
(initial_backoff=15, increment_base=3, retry_total=3, retry_to_secondary=False, random_jitter_range=3, **kwargs)[source]¶ 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. For example, by default the first retry occurs after 15 seconds, the second after (15+3^1) = 18 seconds, and the third after (15+3^2) = 24 seconds.
- Parameters
initial_backoff (int) – The initial backoff interval, in seconds, for the first retry.
increment_base (int) – The base, in seconds, to increment the initial_backoff by after the first retry.
max_attempts (int) – The maximum number of retry attempts.
retry_to_secondary (bool) – Whether the request should be retried to secondary, if able. This should only be enabled of RA-GRS accounts are used and potentially stale data can be handled.
random_jitter_range (int) – A number in seconds which indicates a range to jitter/randomize for the back-off interval. For example, a random_jitter_range of 3 results in the back-off interval x to vary between x+3 and x-3.
-
configure_retries
(request)¶
-
increment
(settings, request, response=None, error=None)¶ Increment the retry counters.
- Parameters
response – A pipeline response object.
error – An error encountered during the request, or None if the response was received successfully.
- Returns
Whether the retry attempts are exhausted.
-
send
(request)¶ Abstract send method for a synchronous pipeline. Mutates the request.
Context content is dependent on the HttpTransport.
- Parameters
request (PipelineRequest) – The pipeline request object
- Returns
The pipeline response object.
- Return type
-
sleep
(settings, transport)¶
-
class
azure.storage.queue.
LinearRetry
(backoff=15, retry_total=3, retry_to_secondary=False, random_jitter_range=3, **kwargs)[source]¶ Linear retry.
Constructs a Linear retry object.
- Parameters
backoff (int) – The backoff interval, in seconds, between retries.
max_attempts (int) – The maximum number of retry attempts.
retry_to_secondary (bool) – Whether the request should be retried to secondary, if able. This should only be enabled of RA-GRS accounts are used and potentially stale data can be handled.
random_jitter_range (int) – A number in seconds which indicates a range to jitter/randomize for the back-off interval. For example, a random_jitter_range of 3 results in the back-off interval x to vary between x+3 and x-3.
-
configure_retries
(request)¶
-
increment
(settings, request, response=None, error=None)¶ Increment the retry counters.
- Parameters
response – A pipeline response object.
error – An error encountered during the request, or None if the response was received successfully.
- Returns
Whether the retry attempts are exhausted.
-
send
(request)¶ Abstract send method for a synchronous pipeline. Mutates the request.
Context content is dependent on the HttpTransport.
- Parameters
request (PipelineRequest) – The pipeline request object
- Returns
The pipeline response object.
- Return type
-
sleep
(settings, transport)¶
-
class
azure.storage.queue.
LocationMode
[source]¶ 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.queue.
ResourceTypes
(service=False, container=False, object=False)[source]¶ Specifies the resource types that are accessible with the account SAS.
- Parameters
service (bool) – Access to service-level APIs (e.g., Get/Set Service Properties, Get Service Stats, List Containers/Queues/Shares)
container (bool) – Access to container-level APIs (e.g., Create/Delete Container, Create/Delete Queue, Create/Delete Share, List Blobs/Files and Directories)
object (bool) – Access to object-level APIs for blobs, queue messages, and files(e.g. Put Blob, Query Entity, Get Messages, Create File, etc.)
-
classmethod
from_string
(string)[source]¶ Create a ResourceTypes from a string.
To specify service, container, or object you need only to include the first letter of the word in the string. E.g. service and container, you would provide a string “sc”.
- Parameters
string (str) – Specify service, container, or object in in the string with the first letter of the word.
- Returns
A ResourceTypes object
- Return type
-
class
azure.storage.queue.
AccountSasPermissions
(read=False, write=False, delete=False, list=False, add=False, create=False, update=False, process=False)[source]¶ 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.- 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, 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.
process (bool) – Valid for the following Object resource type only: queue messages.
-
classmethod
from_string
(permission)[source]¶ Create AccountSasPermissions from a string.
To specify read, write, delete, etc. permissions you need only to include the first letter of the word in the string. E.g. for read and write permissions you would provide a string “rw”.
- Parameters
permission (str) – Specify permissions in the string with the first letter of the word.
- Returns
A AccountSasPermissions object
- Return type
-
class
azure.storage.queue.
StorageErrorCode
[source]¶ An enumeration.
-
account_already_exists
= 'AccountAlreadyExists'¶
-
account_being_created
= 'AccountBeingCreated'¶
-
account_is_disabled
= 'AccountIsDisabled'¶
-
append_position_condition_not_met
= 'AppendPositionConditionNotMet'¶
-
authentication_failed
= 'AuthenticationFailed'¶
-
blob_already_exists
= 'BlobAlreadyExists'¶
-
blob_archived
= 'BlobArchived'¶
-
blob_being_rehydrated
= 'BlobBeingRehydrated'¶
-
blob_not_archived
= 'BlobNotArchived'¶
-
blob_not_found
= 'BlobNotFound'¶
-
blob_overwritten
= 'BlobOverwritten'¶
-
blob_tier_inadequate_for_content_length
= 'BlobTierInadequateForContentLength'¶
-
block_count_exceeds_limit
= 'BlockCountExceedsLimit'¶
-
block_list_too_long
= 'BlockListTooLong'¶
-
cannot_change_to_lower_tier
= 'CannotChangeToLowerTier'¶
-
cannot_delete_file_or_directory
= 'CannotDeleteFileOrDirectory'¶
-
cannot_verify_copy_source
= 'CannotVerifyCopySource'¶
-
client_cache_flush_delay
= 'ClientCacheFlushDelay'¶
-
condition_headers_not_supported
= 'ConditionHeadersNotSupported'¶
-
condition_not_met
= 'ConditionNotMet'¶
-
container_already_exists
= 'ContainerAlreadyExists'¶
-
container_being_deleted
= 'ContainerBeingDeleted'¶
-
container_disabled
= 'ContainerDisabled'¶
-
container_not_found
= 'ContainerNotFound'¶
-
container_quota_downgrade_not_allowed
= 'ContainerQuotaDowngradeNotAllowed'¶
-
content_length_larger_than_tier_limit
= 'ContentLengthLargerThanTierLimit'¶
-
content_length_must_be_zero
= 'ContentLengthMustBeZero'¶
-
copy_across_accounts_not_supported
= 'CopyAcrossAccountsNotSupported'¶
-
copy_id_mismatch
= 'CopyIdMismatch'¶
-
delete_pending
= 'DeletePending'¶
-
destination_path_is_being_deleted
= 'DestinationPathIsBeingDeleted'¶
-
directory_not_empty
= 'DirectoryNotEmpty'¶
-
empty_metadata_key
= 'EmptyMetadataKey'¶
-
feature_version_mismatch
= 'FeatureVersionMismatch'¶
-
file_lock_conflict
= 'FileLockConflict'¶
-
file_system_already_exists
= 'FilesystemAlreadyExists'¶
-
file_system_being_deleted
= 'FilesystemBeingDeleted'¶
-
file_system_not_found
= 'FilesystemNotFound'¶
-
incremental_copy_blob_mismatch
= 'IncrementalCopyBlobMismatch'¶
-
incremental_copy_of_eralier_version_snapshot_not_allowed
= 'IncrementalCopyOfEralierVersionSnapshotNotAllowed'¶
-
incremental_copy_source_must_be_snapshot
= 'IncrementalCopySourceMustBeSnapshot'¶
-
infinite_lease_duration_required
= 'InfiniteLeaseDurationRequired'¶
-
insufficient_account_permissions
= 'InsufficientAccountPermissions'¶
-
internal_error
= 'InternalError'¶
-
invalid_authentication_info
= 'InvalidAuthenticationInfo'¶
-
invalid_blob_or_block
= 'InvalidBlobOrBlock'¶
-
invalid_blob_tier
= 'InvalidBlobTier'¶
-
invalid_blob_type
= 'InvalidBlobType'¶
-
invalid_block_id
= 'InvalidBlockId'¶
-
invalid_block_list
= 'InvalidBlockList'¶
-
invalid_destination_path
= 'InvalidDestinationPath'¶
-
invalid_file_or_directory_path_name
= 'InvalidFileOrDirectoryPathName'¶
-
invalid_flush_position
= 'InvalidFlushPosition'¶
-
invalid_header_value
= 'InvalidHeaderValue'¶
-
invalid_http_verb
= 'InvalidHttpVerb'¶
-
invalid_input
= 'InvalidInput'¶
-
invalid_marker
= 'InvalidMarker'¶
-
invalid_md5
= 'InvalidMd5'¶
-
invalid_metadata
= 'InvalidMetadata'¶
-
invalid_operation
= 'InvalidOperation'¶
-
invalid_page_range
= 'InvalidPageRange'¶
-
invalid_property_name
= 'InvalidPropertyName'¶
-
invalid_query_parameter_value
= 'InvalidQueryParameterValue'¶
-
invalid_range
= 'InvalidRange'¶
-
invalid_rename_source_path
= 'InvalidRenameSourcePath'¶
-
invalid_resource_name
= 'InvalidResourceName'¶
-
invalid_source_blob_type
= 'InvalidSourceBlobType'¶
-
invalid_source_blob_url
= 'InvalidSourceBlobUrl'¶
-
invalid_source_or_destination_resource_type
= 'InvalidSourceOrDestinationResourceType'¶
-
invalid_source_uri
= 'InvalidSourceUri'¶
-
invalid_uri
= 'InvalidUri'¶
-
invalid_version_for_page_blob_operation
= 'InvalidVersionForPageBlobOperation'¶
-
invalid_xml_document
= 'InvalidXmlDocument'¶
-
invalid_xml_node_value
= 'InvalidXmlNodeValue'¶
-
lease_already_broken
= 'LeaseAlreadyBroken'¶
-
lease_already_present
= 'LeaseAlreadyPresent'¶
-
lease_id_mismatch_with_blob_operation
= 'LeaseIdMismatchWithBlobOperation'¶
-
lease_id_mismatch_with_container_operation
= 'LeaseIdMismatchWithContainerOperation'¶
-
lease_id_mismatch_with_lease_operation
= 'LeaseIdMismatchWithLeaseOperation'¶
-
lease_id_missing
= 'LeaseIdMissing'¶
-
lease_is_already_broken
= 'LeaseIsAlreadyBroken'¶
-
lease_is_breaking_and_cannot_be_acquired
= 'LeaseIsBreakingAndCannotBeAcquired'¶
-
lease_is_breaking_and_cannot_be_changed
= 'LeaseIsBreakingAndCannotBeChanged'¶
-
lease_is_broken_and_cannot_be_renewed
= 'LeaseIsBrokenAndCannotBeRenewed'¶
-
lease_lost
= 'LeaseLost'¶
-
lease_name_mismatch
= 'LeaseNameMismatch'¶
-
lease_not_present_with_blob_operation
= 'LeaseNotPresentWithBlobOperation'¶
-
lease_not_present_with_container_operation
= 'LeaseNotPresentWithContainerOperation'¶
-
lease_not_present_with_lease_operation
= 'LeaseNotPresentWithLeaseOperation'¶
-
max_blob_size_condition_not_met
= 'MaxBlobSizeConditionNotMet'¶
-
md5_mismatch
= 'Md5Mismatch'¶
-
message_not_found
= 'MessageNotFound'¶
-
message_too_large
= 'MessageTooLarge'¶
-
metadata_too_large
= 'MetadataTooLarge'¶
-
missing_content_length_header
= 'MissingContentLengthHeader'¶
-
missing_required_header
= 'MissingRequiredHeader'¶
-
missing_required_query_parameter
= 'MissingRequiredQueryParameter'¶
-
missing_required_xml_node
= 'MissingRequiredXmlNode'¶
-
multiple_condition_headers_not_supported
= 'MultipleConditionHeadersNotSupported'¶
-
no_authentication_information
= 'NoAuthenticationInformation'¶
-
no_pending_copy_operation
= 'NoPendingCopyOperation'¶
-
operation_not_allowed_on_incremental_copy_blob
= 'OperationNotAllowedOnIncrementalCopyBlob'¶
-
operation_timed_out
= 'OperationTimedOut'¶
-
out_of_range_input
= 'OutOfRangeInput'¶
-
out_of_range_query_parameter_value
= 'OutOfRangeQueryParameterValue'¶
-
parent_not_found
= 'ParentNotFound'¶
-
path_already_exists
= 'PathAlreadyExists'¶
-
path_conflict
= 'PathConflict'¶
-
path_not_found
= 'PathNotFound'¶
-
pending_copy_operation
= 'PendingCopyOperation'¶
-
pop_receipt_mismatch
= 'PopReceiptMismatch'¶
-
previous_snapshot_cannot_be_newer
= 'PreviousSnapshotCannotBeNewer'¶
-
previous_snapshot_not_found
= 'PreviousSnapshotNotFound'¶
-
previous_snapshot_operation_not_supported
= 'PreviousSnapshotOperationNotSupported'¶
-
queue_already_exists
= 'QueueAlreadyExists'¶
-
queue_being_deleted
= 'QueueBeingDeleted'¶
-
queue_disabled
= 'QueueDisabled'¶
-
queue_not_empty
= 'QueueNotEmpty'¶
-
queue_not_found
= 'QueueNotFound'¶
-
read_only_attribute
= 'ReadOnlyAttribute'¶
-
rename_destination_parent_path_not_found
= 'RenameDestinationParentPathNotFound'¶
-
request_body_too_large
= 'RequestBodyTooLarge'¶
-
request_url_failed_to_parse
= 'RequestUrlFailedToParse'¶
-
resource_already_exists
= 'ResourceAlreadyExists'¶
-
resource_not_found
= 'ResourceNotFound'¶
-
resource_type_mismatch
= 'ResourceTypeMismatch'¶
-
sequence_number_condition_not_met
= 'SequenceNumberConditionNotMet'¶
-
sequence_number_increment_too_large
= 'SequenceNumberIncrementTooLarge'¶
-
server_busy
= 'ServerBusy'¶
-
sharing_violation
= 'SharingViolation'¶
-
snaphot_operation_rate_exceeded
= 'SnaphotOperationRateExceeded'¶
-
snapshot_count_exceeded
= 'SnapshotCountExceeded'¶
-
snapshots_present
= 'SnapshotsPresent'¶
-
source_condition_not_met
= 'SourceConditionNotMet'¶
-
source_path_is_being_deleted
= 'SourcePathIsBeingDeleted'¶
-
source_path_not_found
= 'SourcePathNotFound'¶
-
system_in_use
= 'SystemInUse'¶
-
target_condition_not_met
= 'TargetConditionNotMet'¶
-
unsupported_header
= 'UnsupportedHeader'¶
-
unsupported_http_verb
= 'UnsupportedHttpVerb'¶
-
unsupported_query_parameter
= 'UnsupportedQueryParameter'¶
-
unsupported_rest_version
= 'UnsupportedRestVersion'¶
-
unsupported_xml_node
= 'UnsupportedXmlNode'¶
-
-
class
azure.storage.queue.
QueueMessage
(content=None)[source]¶ Represents a queue message.
- Variables
id (str) – A GUID value assigned to the message by the Queue service that identifies the message in the queue. This value may be used together with the value of pop_receipt to delete a message from the queue after it has been retrieved with the receive messages operation.
inserted_on (date) – A UTC date value representing the time the messages was inserted.
expires_on (date) – A UTC date value representing the time the message expires.
dequeue_count (int) – Begins with a value of 1 the first time the message is received. This value is incremented each time the message is subsequently received.
pop_receipt (str) – A receipt str which can be used together with the message_id element to delete a message from the queue after it has been retrieved with the receive messages operation. Only returned by receive messages operations. Set to None for peek messages.
next_visible_on (date) – A UTC date value representing the time the message will next be visible. Only returned by receive messages operations. Set to None for peek messages.
- Parameters
content (obj) – The message content. Type is determined by the decode_function set on the service. Default is str.
-
get
(key, default=None)¶
-
has_key
(k)¶
-
items
()¶
-
keys
()¶
-
update
(*args, **kwargs)¶
-
values
()¶
-
class
azure.storage.queue.
QueueProperties
(**kwargs)[source]¶ Queue Properties.
- Variables
name (str) – The name of the queue.
- Keyword Arguments
metadata (dict(str,str)) – A dict containing name-value pairs associated with the queue as metadata. This var is set to None unless the include=metadata param was included for the list queues operation. If this parameter was specified but the
-
get
(key, default=None)¶
-
has_key
(k)¶
-
items
()¶
-
keys
()¶
-
update
(*args, **kwargs)¶
-
values
()¶
-
class
azure.storage.queue.
QueueSasPermissions
(read=False, add=False, update=False, process=False)[source]¶ QueueSasPermissions class to be used with the
generate_queue_sas()
function and for the AccessPolicies used withset_queue_access_policy()
.- Parameters
read (bool) – Read metadata and properties, including message count. Peek at messages.
add (bool) – Add messages to the queue.
update (bool) – Update messages in the queue. Note: Use the Process permission with Update so you can first get the message you want to update.
process (bool) – Get and delete messages from the queue.
-
classmethod
from_string
(permission)[source]¶ Create a QueueSasPermissions from a string.
To specify read, add, update, or process permissions you need only to include the first letter of the word in the string. E.g. For read and update permissions, you would provide a string “ru”.
- Parameters
permission (str) – The string which dictates the read, add, update, or process permissions.
- Returns
A QueueSasPermissions object
- Return type
-
class
azure.storage.queue.
AccessPolicy
(permission=None, expiry=None, start=None)[source]¶ Access Policy class used by the set and get access policy methods.
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).
- 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 (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 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.
-
as_dict
(keep_readonly=True, key_transformer=<function attribute_transformer>, **kwargs)¶ Return a dict that can be JSONify using json.dump.
Advanced usage might optionaly use a callback as parameter:
Key is the attribute name used in Python. Attr_desc is a dict of metadata. Currently contains ‘type’ with the msrest type and ‘key’ with the RestAPI encoded key. Value is the current value in this object.
The string returned will be used to serialize the key. If the return type is a list, this is considered hierarchical result dict.
See the three examples in this file:
attribute_transformer
full_restapi_key_transformer
last_restapi_key_transformer
If you want XML serialization, you can pass the kwargs is_xml=True.
- Parameters
key_transformer (function) – A key transformer function.
- Returns
A dict JSON compatible object
- Return type
-
classmethod
deserialize
(data, content_type=None)¶ Parse a str using the RestAPI syntax and return a model.
-
classmethod
enable_additional_properties_sending
()¶
-
classmethod
from_dict
(data, key_extractors=None, content_type=None)¶ Parse a dict using given key extractor return a model.
By default consider key extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor and last_rest_key_case_insensitive_extractor)
-
classmethod
is_xml_model
()¶
-
serialize
(keep_readonly=False, **kwargs)¶ Return the JSON that would be sent to azure from this model.
This is an alias to as_dict(full_restapi_key_transformer, keep_readonly=False).
If you want XML serialization, you can pass the kwargs is_xml=True.
-
class
azure.storage.queue.
TextBase64EncodePolicy
[source]¶ Base 64 message encoding policy for text messages.
Encodes text (unicode) messages to base 64. If the input content is not text, a TypeError will be raised. Input text must support UTF-8.
-
configure
(require_encryption, key_encryption_key, resolver)¶
-
-
class
azure.storage.queue.
TextBase64DecodePolicy
[source]¶ Message decoding policy for base 64-encoded messages into text.
Decodes base64-encoded messages to text (unicode). If the input content is not valid base 64, a DecodeError will be raised. Message data must support UTF-8.
-
configure
(require_encryption, key_encryption_key, resolver)¶
-
-
class
azure.storage.queue.
BinaryBase64EncodePolicy
[source]¶ Base 64 message encoding policy for binary messages.
Encodes binary messages to base 64. If the input content is not bytes, a TypeError will be raised.
-
configure
(require_encryption, key_encryption_key, resolver)¶
-
-
class
azure.storage.queue.
BinaryBase64DecodePolicy
[source]¶ Message decoding policy for base 64-encoded messages into bytes.
Decodes base64-encoded messages to bytes. If the input content is not valid base 64, a DecodeError will be raised.
-
configure
(require_encryption, key_encryption_key, resolver)¶
-
-
class
azure.storage.queue.
QueueAnalyticsLogging
(**kwargs)[source]¶ Azure Analytics Logging settings.
All required parameters must be populated in order to send to Azure.
- Keyword Arguments
version (str) – Required. The version of Storage Analytics to configure.
delete (bool) – Required. Indicates whether all delete requests should be logged.
read (bool) – Required. Indicates whether all read requests should be logged.
write (bool) – Required. Indicates whether all write requests should be logged.
retention_policy (RetentionPolicy) – Required. The retention policy for the metrics.
-
as_dict
(keep_readonly=True, key_transformer=<function attribute_transformer>, **kwargs)¶ Return a dict that can be JSONify using json.dump.
Advanced usage might optionaly use a callback as parameter:
Key is the attribute name used in Python. Attr_desc is a dict of metadata. Currently contains ‘type’ with the msrest type and ‘key’ with the RestAPI encoded key. Value is the current value in this object.
The string returned will be used to serialize the key. If the return type is a list, this is considered hierarchical result dict.
See the three examples in this file:
attribute_transformer
full_restapi_key_transformer
last_restapi_key_transformer
If you want XML serialization, you can pass the kwargs is_xml=True.
- Parameters
key_transformer (function) – A key transformer function.
- Returns
A dict JSON compatible object
- Return type
-
classmethod
deserialize
(data, content_type=None)¶ Parse a str using the RestAPI syntax and return a model.
-
classmethod
enable_additional_properties_sending
()¶
-
classmethod
from_dict
(data, key_extractors=None, content_type=None)¶ Parse a dict using given key extractor return a model.
By default consider key extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor and last_rest_key_case_insensitive_extractor)
-
classmethod
is_xml_model
()¶
-
serialize
(keep_readonly=False, **kwargs)¶ Return the JSON that would be sent to azure from this model.
This is an alias to as_dict(full_restapi_key_transformer, keep_readonly=False).
If you want XML serialization, you can pass the kwargs is_xml=True.
-
class
azure.storage.queue.
Metrics
(**kwargs)[source]¶ A summary of request statistics grouped by API in hour or minute aggregates.
All required parameters must be populated in order to send to Azure.
- Keyword Arguments
version (str) – The version of Storage Analytics to configure.
enabled (bool) – Required. Indicates whether metrics are enabled for the service.
include_ap_is (bool) – Indicates whether metrics should generate summary statistics for called API operations.
retention_policy (RetentionPolicy) – Required. The retention policy for the metrics.
-
as_dict
(keep_readonly=True, key_transformer=<function attribute_transformer>, **kwargs)¶ Return a dict that can be JSONify using json.dump.
Advanced usage might optionaly use a callback as parameter:
Key is the attribute name used in Python. Attr_desc is a dict of metadata. Currently contains ‘type’ with the msrest type and ‘key’ with the RestAPI encoded key. Value is the current value in this object.
The string returned will be used to serialize the key. If the return type is a list, this is considered hierarchical result dict.
See the three examples in this file:
attribute_transformer
full_restapi_key_transformer
last_restapi_key_transformer
If you want XML serialization, you can pass the kwargs is_xml=True.
- Parameters
key_transformer (function) – A key transformer function.
- Returns
A dict JSON compatible object
- Return type
-
classmethod
deserialize
(data, content_type=None)¶ Parse a str using the RestAPI syntax and return a model.
-
classmethod
enable_additional_properties_sending
()¶
-
classmethod
from_dict
(data, key_extractors=None, content_type=None)¶ Parse a dict using given key extractor return a model.
By default consider key extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor and last_rest_key_case_insensitive_extractor)
-
classmethod
is_xml_model
()¶
-
serialize
(keep_readonly=False, **kwargs)¶ Return the JSON that would be sent to azure from this model.
This is an alias to as_dict(full_restapi_key_transformer, keep_readonly=False).
If you want XML serialization, you can pass the kwargs is_xml=True.
-
class
azure.storage.queue.
CorsRule
(allowed_origins, allowed_methods, **kwargs)[source]¶ 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.
- Parameters
allowed_origins (list(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(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.
- Keyword Arguments
max_age_in_seconds (int) – The number of seconds that the client/browser should cache a pre-flight response.
exposed_headers (list(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(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.
-
as_dict
(keep_readonly=True, key_transformer=<function attribute_transformer>, **kwargs)¶ Return a dict that can be JSONify using json.dump.
Advanced usage might optionaly use a callback as parameter:
Key is the attribute name used in Python. Attr_desc is a dict of metadata. Currently contains ‘type’ with the msrest type and ‘key’ with the RestAPI encoded key. Value is the current value in this object.
The string returned will be used to serialize the key. If the return type is a list, this is considered hierarchical result dict.
See the three examples in this file:
attribute_transformer
full_restapi_key_transformer
last_restapi_key_transformer
If you want XML serialization, you can pass the kwargs is_xml=True.
- Parameters
key_transformer (function) – A key transformer function.
- Returns
A dict JSON compatible object
- Return type
-
classmethod
deserialize
(data, content_type=None)¶ Parse a str using the RestAPI syntax and return a model.
-
classmethod
enable_additional_properties_sending
()¶
-
classmethod
from_dict
(data, key_extractors=None, content_type=None)¶ Parse a dict using given key extractor return a model.
By default consider key extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor and last_rest_key_case_insensitive_extractor)
-
classmethod
is_xml_model
()¶
-
serialize
(keep_readonly=False, **kwargs)¶ Return the JSON that would be sent to azure from this model.
This is an alias to as_dict(full_restapi_key_transformer, keep_readonly=False).
If you want XML serialization, you can pass the kwargs is_xml=True.
-
class
azure.storage.queue.
RetentionPolicy
(enabled=False, days=None)[source]¶ The retention policy which determines how long the associated data should persist.
All required parameters must be populated in order to send to Azure.
- Parameters
-
as_dict
(keep_readonly=True, key_transformer=<function attribute_transformer>, **kwargs)¶ Return a dict that can be JSONify using json.dump.
Advanced usage might optionaly use a callback as parameter:
Key is the attribute name used in Python. Attr_desc is a dict of metadata. Currently contains ‘type’ with the msrest type and ‘key’ with the RestAPI encoded key. Value is the current value in this object.
The string returned will be used to serialize the key. If the return type is a list, this is considered hierarchical result dict.
See the three examples in this file:
attribute_transformer
full_restapi_key_transformer
last_restapi_key_transformer
If you want XML serialization, you can pass the kwargs is_xml=True.
- Parameters
key_transformer (function) – A key transformer function.
- Returns
A dict JSON compatible object
- Return type
-
classmethod
deserialize
(data, content_type=None)¶ Parse a str using the RestAPI syntax and return a model.
-
classmethod
enable_additional_properties_sending
()¶
-
classmethod
from_dict
(data, key_extractors=None, content_type=None)¶ Parse a dict using given key extractor return a model.
By default consider key extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor and last_rest_key_case_insensitive_extractor)
-
classmethod
is_xml_model
()¶
-
serialize
(keep_readonly=False, **kwargs)¶ Return the JSON that would be sent to azure from this model.
This is an alias to as_dict(full_restapi_key_transformer, keep_readonly=False).
If you want XML serialization, you can pass the kwargs is_xml=True.
-
azure.storage.queue.
generate_account_sas
(account_name, account_key, resource_types, permission, expiry, start=None, ip=None, **kwargs)[source]¶ Generates a shared access signature for the queue service.
Use the returned signature with the credential parameter of any Queue Service.
- 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.
expiry (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 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.
- Keyword Arguments
protocol (str) – Specifies the protocol permitted for a request made. The default value is https.
- Returns
A Shared Access Signature (sas) token.
- Return type
-
azure.storage.queue.
generate_queue_sas
(account_name, queue_name, account_key, permission=None, expiry=None, start=None, policy_id=None, ip=None, **kwargs)[source]¶ Generates a shared access signature for a queue.
Use the returned signature with the credential parameter of any Queue Service.
- Parameters
account_name (str) – The storage account name used to generate the shared access signature.
queue_name (str) – The name of the queue.
account_key (str) – The account key, also called shared key or access key, to generate the shared access signature.
permission (QueueSasPermissions) – The permissions associated with the shared access signature. The user is restricted to operations allowed by the permissions. Required unless a policy_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 or str) – The time at which the shared access signature becomes invalid. Required unless a policy_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 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_queue_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.
- Keyword Arguments
protocol (str) – Specifies the protocol permitted for a request made. The default value is https.
- Returns
A Shared Access Signature (sas) token.
- Return type
Example:
from azure.storage.queue import generate_queue_sas sas_token = generate_queue_sas( queue.account_name, queue.queue_name, queue.credential.account_key, policy_id='my-access-policy-id' )