Provided by: python3-azure-cosmosdb-table_1.0.5+git20191025-6_all
NAME
azurecosmosdbsdkforpython - Azure CosmosDB SDK for Python 1.0.6
INSTALLATION:
Please refer to the Github page for the installation instructions: https://github.com/Azure/azure-cosmosdb-python If you are looking for Azure Service Bus or the Azure management libraries, please visit https://github.com/Azure/azure-sdk-for-python
DOCUMENTATION:
• Table Getting Started Doc -- (API) • Reference Documentation - All Services
FEATURES:
• Table • Create/Read/Update/Delete Tables • Create/Read/Update/Delete Entities • Batch operations • Advanced Table Operations
SYSTEM REQUIREMENTS:
The supported Python versions are 2.7.x, 3.3.x, 3.4.x, and 3.5.x. To download Python, please visit https://www.python.org/download/ We recommend Python Tools for Visual Studio as a development environment for developing your applications. Please visit http://aka.ms/python for more information.
NEED HELP?:
Be sure to check out the Microsoft Azure Developer Forums on Stack Overflow if you have trouble with the provided code.
CONTRIBUTING:
Contribute Code or Provide Feedback: If you would like to become an active contributor to this project, please follow the instructions provided in Microsoft Azure Projects Contribution Guidelines. If you encounter any bugs with the library, please file an issue in the Issues section of the project. Microsoft Azure Python Developer Center • Index • Module Index • Search Page
UPGRADE GUIDE
This guide is intended to help upgrade code written for the Azure Storage Python library before version 0.30.0. The best way to see how to upgrade a specific API is to take a look at the usage samples in the Samples directory on GitHub. A very specific set of changes as well as additions can be found in the ChangeLog and BreakingChanges documents. The below is a summary of those documents containing the most relevant pieces for the upgrade scenario.
GENERAL CHANGES
In general, we attempted to use more appropriate Python types for parameter and return values rather than always taking and receiving strings. Parameter and return values previously prefixed with x_ms were simplified by removing this prefix, and parameter values are divided by '_' between words as is idiomatic. Listing returns a generator rather than a result segment. This generator automatically follows continuation tokens as more results are requested. SAS methods take several individual parameters rather than a single paramter object. Similarly, ACL getters and setters take dictionaries mapping id to AccessPolicy rather than a list of SignedIdentifiers each holding an id and an AccessPolicy.
BLOB
The single BlobService object was divided into three subservices for the different blob types (BlockBlobService, PageBlobService, AppendBlobService) with common methods in the abstract BaseBlobService these inherit from. This was done for two reasons. First, to reduce confusion when blob-type specific methods were used on the incorrect blob type. Second, to simplify the BlobService object which had grown to be quite extensive when append blob was added. ContentSettings objects have replaced all content_* and cache_control parameters and return values for applicable APIs. This is intended to highlight that the semantics of setting content properties is replace rather than merge, meaning that setting any one property will cause any unspecified properties to be cleared on the blob. On the performance side, single-threaded blob download APIs will now download the blob without chunking to improve perf and not do an initial get to find the size of the blob. However, as a result the progress_callback may receive None for its total parameter when parallelism is off to allow for this optimization.
QUEUE
The largest change to the QueueService class is that queue messages are both XML encoded and decoded by default. In past versions, either messages were not encoded or decoded by default, or only encoded. Encoding and decoding methods can be modified using the QueueService encode_function and decode_function instance variables. Methods operating on queue messages and which have return values will return QueueMessage objects. QueueMessages objects contain essentially the same fields as previously, but the times are returned as dates rather than strings and the dequeue count is returned as an int.
TABLE
Rather than having a boolean switch for turning batching on and off, batches are an object which can be populated and then committed. Entities can be sent as dictionaries or as Entity objects, and returned entities are accessible as either objects or dictionaries. Methods which access and modify entites have been simplified so that if they take an entity object they extract the partition key and row key from that object rather than requiring these be sent separately. All table entity integer values are stored on the service with type Edm.Int64 unless the type is explicitly overridden as Edm.Int32. Formerly, the type was decided based on the size of the number, but this resulted in hard to predict types on the service. So, the more consistent option was chosen. Operations no longer echo content from the service and JSON is used instead of AtomPub, improving performance.
AZURE PACKAGE
Subpackages azure.cosmosdb package Subpackages azure.cosmosdb.table package Submodules azure.cosmosdb.table.models module exception azure.cosmosdb.table.models.AzureBatchOperationError(message, status_code, *args, **kwargs) Bases: azure.common.AzureHttpError Indicates that a batch operation failed. Variables • message (str) -- A detailed error message indicating the index of the batch request which failed and the reason for the failure. For example, '0:One of the request inputs is out of range.' indicates the 0th batch request failed as one of its property values was out of range. • status_code (int) -- The HTTP status code of the batch request. For example, 400. • batch_code (str) -- The batch status code. For example, 'OutOfRangeInput'. exception azure.cosmosdb.table.models.AzureBatchValidationError Bases: azure.common.AzureException Indicates that a batch operation cannot proceed due to invalid input. Variables message (str) -- A detailed error message indicating the reason for the failure. class azure.cosmosdb.table.models.EdmType Bases: object Used by EntityProperty to represent the type of the entity property to be stored by the Table service. BINARY = 'Edm.Binary' Represents byte data. Must be specified. BOOLEAN = 'Edm.Boolean' Represents a boolean. This type will be inferred for Python bools. DATETIME = 'Edm.DateTime' Represents a date. This type will be inferred for Python datetime objects. DOUBLE = 'Edm.Double' Represents a double. This type will be inferred for Python floating point numbers. GUID = 'Edm.Guid' Represents a GUID. Must be specified. INT32 = 'Edm.Int32' Represents a number between -(2^15) and 2^15. Must be specified or numbers will default to INT64. INT64 = 'Edm.Int64' Represents a number between -(2^31) and 2^31. This is the default type for Python numbers. STRING = 'Edm.String' Represents a string. This type will be inferred for Python strings. class azure.cosmosdb.table.models.Entity Bases: dict An entity object. Can be accessed as a dict or as an obj. The attributes of the entity will be created dynamically. For example, the following are both valid: entity = Entity() entity.a = 'b' entity['x'] = 'y' class azure.cosmosdb.table.models.EntityProperty(type=None, value=None, encrypt=False) Bases: object An entity property. Used to explicitly set EdmType when necessary. Values which require explicit typing are GUID, INT32, and BINARY. Other EdmTypes may be explicitly create as EntityProperty objects but need not be. For example, the below with both create STRING typed properties on the entity: entity = Entity() entity.a = 'b' entity.x = EntityProperty(EdmType.STRING, 'y') Represents an Azure Table. Returned by list_tables. Parameters • type (str) -- The type of the property. • value (EdmType) -- The value of the property. • encrypt (bool) -- Indicates whether or not the property should be encrypted. class azure.cosmosdb.table.models.Table Bases: object Represents an Azure Table. Returned by list_tables. Variables name (str) -- The name of the table. class azure.cosmosdb.table.models.TablePayloadFormat Bases: object Specifies the accepted content type of the response payload. More information can be found here: https://msdn.microsoft.com/en-us/library/azure/dn535600.aspx JSON_FULL_METADATA = 'application/json;odata=fullmetadata' Returns minimal type information for the entity properties plus some extra odata properties. JSON_MINIMAL_METADATA = 'application/json;odata=minimalmetadata' Returns minimal type information for the entity properties. JSON_NO_METADATA = 'application/json;odata=nometadata' Returns no type information for the entity properties. class azure.cosmosdb.table.models.TablePermissions(query=False, add=False, update=False, delete=False, _str=None) Bases: object TablePermissions class to be used with the generate_table_shared_access_signature() method and for the AccessPolicies used with set_table_acl(). Variables • TablePermissions.QUERY (TablePermissions) -- Get entities and query entities. • TablePermissions.ADD (TablePermissions) -- Add entities. • TablePermissions.UPDATE (TablePermissions) -- Update entities. • TablePermissions.DELETE (TablePermissions) -- Delete entities. Parameters • query (bool) -- Get entities and query entities. • add (bool) -- Add entities. Add and Update permissions are required for upsert operations. • update (bool) -- Update entities. Add and Update permissions are required for upsert operations. • delete (bool) -- Delete entities. • _str (str) -- A string representing the permissions. ADD = <azure.cosmosdb.table.models.TablePermissions object> DELETE = <azure.cosmosdb.table.models.TablePermissions object> QUERY = <azure.cosmosdb.table.models.TablePermissions object> UPDATE = <azure.cosmosdb.table.models.TablePermissions object> class azure.cosmosdb.table.models.TableServices Bases: azure.cosmosdb.table.common.models.Services Parameters • table (bool) -- Access to the .TableService • _str (str) -- A string representing the services. azure.cosmosdb.table.tablebatch module class azure.cosmosdb.table.tablebatch.TableBatch(require_encryption=False, key_encryption_key=None, encryption_resolver=None) Bases: object This is the class that is used for batch operation for storage table service. The Table service supports batch transactions on entities that are in the same table and belong to the same partition group. Multiple operations are supported within a single transaction. The batch can include at most 100 entities, and its total payload may be no more than 4 MB in size. delete_entity(partition_key, row_key, if_match='*') Adds a delete entity operation to the batch. See delete_entity() for more information on deletes. The operation will not be executed until the batch is committed. Parameters • partition_key (str) -- The PartitionKey of the entity. • row_key (str) -- The RowKey of the entity. • if_match (str) -- The client may specify the ETag for the entity on the request in order to compare to the ETag maintained by the service for the purpose of optimistic concurrency. The delete operation will be performed only if the ETag sent by the client matches the value maintained by the server, indicating that the entity has not been modified since it was retrieved by the client. To force an unconditional delete, set If-Match to the wildcard character (*). insert_entity(entity) Adds an insert entity operation to the batch. See insert_entity() for more information on inserts. The operation will not be executed until the batch is committed. Parameters entity (dict or Entity) -- The entity to insert. Could be a dict or an entity object. Must contain a PartitionKey and a RowKey. insert_or_merge_entity(entity) Adds an insert or merge entity operation to the batch. See insert_or_merge_entity() for more information on insert or merge operations. The operation will not be executed until the batch is committed. Parameters entity (dict or Entity) -- The entity to insert or merge. Could be a dict or an entity object. Must contain a PartitionKey and a RowKey. insert_or_replace_entity(entity) Adds an insert or replace entity operation to the batch. See insert_or_replace_entity() for more information on insert or replace operations. The operation will not be executed until the batch is committed. Parameters entity (dict or Entity) -- The entity to insert or replace. Could be a dict or an entity object. Must contain a PartitionKey and a RowKey. merge_entity(entity, if_match='*') Adds a merge entity operation to the batch. See merge_entity() for more information on merges. The operation will not be executed until the batch is committed. Parameters • entity (dict or Entity) -- The entity to merge. Could be a dict or an entity object. Must contain a PartitionKey and a RowKey. • if_match (str) -- The client may specify the ETag for the entity on the request in order to compare to the ETag maintained by the service for the purpose of optimistic concurrency. The merge operation will be performed only if the ETag sent by the client matches the value maintained by the server, indicating that the entity has not been modified since it was retrieved by the client. To force an unconditional merge, set If-Match to the wildcard character (*). update_entity(entity, if_match='*') Adds an update entity operation to the batch. See update_entity() for more information on updates. The operation will not be executed until the batch is committed. Parameters • entity (dict or Entity) -- The entity to update. Could be a dict or an entity object. Must contain a PartitionKey and a RowKey. • if_match (str) -- The client may specify the ETag for the entity on the request in order to compare to the ETag maintained by the service for the purpose of optimistic concurrency. The update operation will be performed only if the ETag sent by the client matches the value maintained by the server, indicating that the entity has not been modified since it was retrieved by the client. To force an unconditional update, set If-Match to the wildcard character (*). azure.cosmosdb.table.tableservice module class azure.cosmosdb.table.tableservice.TableService(account_name=None, account_key=None, sas_token=None, is_emulated=False, protocol='https', endpoint_suffix='core.windows.net', request_session=None, connection_string=None, socket_timeout=None) Bases: azure.cosmosdb.table.common.storageclient.StorageClient This is the main class managing Azure Table resources. The Azure Table service offers structured storage in the form of tables. Tables store data as collections of entities. Entities are similar to rows. An entity has a primary key and a set of properties. A property is a name, typed-value pair, similar to a column. The Table service does not enforce any schema for tables, so two entities in the same table may have different sets of properties. Developers may choose to enforce a schema on the client side. A table may contain any number of entities. Variables • key_encryption_key (object) -- The key-encryption-key optionally provided by the user. If provided, will be used to encrypt/decrypt in supported methods. For methods requiring decryption, either the key_encryption_key OR the resolver must be provided. If both are provided, the resolver will take precedence. Must implement the following methods for APIs requiring encryption: wrap_key(key)--wraps the specified key (bytes) using an algorithm of the user's choice. Returns the encrypted key as bytes. get_key_wrap_algorithm()--returns the algorithm used to wrap the specified symmetric key. get_kid()--returns a string key id for this key-encryption-key. Must implement the following methods for APIs requiring decryption: unwrap_key(key, algorithm)--returns the unwrapped form of the specified symmetric key using the string-specified algorithm. get_kid()--returns a string key id for this key-encryption-key. • key_resolver_function(kid) (function) -- A function to resolve keys optionally provided by the user. If provided, will be used to decrypt in supported methods. For methods requiring decryption, either the key_encryption_key OR the resolver must be provided. If both are provided, the resolver will take precedence. It uses the kid string to return a key-encryption-key implementing the interface defined above. • encryption_resolver_functions (function(partition_key, row_key, property_name)) -- A function that takes in an entity's partition key, row key, and property name and returns a boolean that indicates whether that property should be encrypted. • require_encryption (bool) -- A flag that may be set to ensure that all messages successfully uploaded to the queue and all those downloaded and successfully read from the queue are/were encrypted while on the server. If this flag is set, all required parameters for encryption/decryption must be provided. See the above comments on the key_encryption_key and resolver. Parameters • account_name (str) -- The storage account name. This is used to authenticate requests signed with an account key and to construct the storage endpoint. It is required unless a connection string is given. • account_key (str) -- The storage account key. This is used for shared key authentication. • sas_token (str) -- A shared access signature token to use to authenticate requests instead of the account key. If account key and sas token are both specified, account key will be used to sign. • is_emulated (bool) -- Whether to use the emulator. Defaults to False. If specified, will override all other parameters besides connection string and request session. • protocol (str) -- The protocol to use for requests. Defaults to https. • endpoint_suffix (str) -- The host base component of the url, minus the account name. Defaults to Azure (core.windows.net). Override this to use the China cloud (core.chinacloudapi.cn). • request_session (requests.Session) -- The session object to use for http requests. • connection_string (str) -- If specified, this will override all other parameters besides request session. See http://azure.microsoft.com/en-us/documentation/articles/storage-configure-connection-string/ for the connection string format. • socket_timeout (int) -- If specified, this will override the default socket timeout. The timeout specified is in seconds. See DEFAULT_SOCKET_TIMEOUT in _constants.py for the default value. batch(table_name, timeout=None) Creates a batch object which can be used as a context manager. Commits the batch on exit. Parameters • table_name (str) -- The name of the table to commit the batch to. • timeout (int) -- The server timeout, expressed in seconds. commit_batch(table_name, batch, timeout=None) Commits a TableBatch request. Parameters • table_name (str) -- The name of the table to commit the batch to. • batch (TableBatch) -- The batch to commit. • timeout (int) -- The server timeout, expressed in seconds. Returns A list of the batch responses corresponding to the requests in the batch. The items could either be an etag, in case of success, or an error object in case of failure. Return type list(AzureBatchOperationError, str) create_table(table_name, fail_on_exist=False, timeout=None) Creates a new table in the storage account. Parameters • table_name (str) -- The name of the table to create. The table name may contain only alphanumeric characters and cannot begin with a numeric character. It is case-insensitive and must be from 3 to 63 characters long. • fail_on_exist (bool) -- Specifies whether to throw an exception if the table already exists. • timeout (int) -- The server timeout, expressed in seconds. Returns A boolean indicating whether the table was created. If fail_on_exist was set to True, this will throw instead of returning false. Return type bool delete_entity(table_name, partition_key, row_key, if_match='*', timeout=None) Deletes an existing entity in a table. Throws if the entity does not exist. When an entity is successfully deleted, the entity is immediately marked for deletion and is no longer accessible to clients. The entity is later removed from the Table service during garbage collection. Parameters • table_name (str) -- The name of the table containing the entity to delete. • partition_key (str) -- The PartitionKey of the entity. • row_key (str) -- The RowKey of the entity. • if_match (str) -- The client may specify the ETag for the entity on the request in order to compare to the ETag maintained by the service for the purpose of optimistic concurrency. The delete operation will be performed only if the ETag sent by the client matches the value maintained by the server, indicating that the entity has not been modified since it was retrieved by the client. To force an unconditional delete, set If-Match to the wildcard character (*). • timeout (int) -- The server timeout, expressed in seconds. delete_table(table_name, fail_not_exist=False, timeout=None) Deletes the specified table and any data it contains. When a table is successfully deleted, it is immediately marked for deletion and is no longer accessible to clients. The table is later removed from the Table service during garbage collection. Note that deleting a table is likely to take at least 40 seconds to complete. If an operation is attempted against the table while it was being deleted, an AzureConflictHttpError will be thrown. Parameters • table_name (str) -- The name of the table to delete. • fail_not_exist (bool) -- Specifies whether to throw an exception if the table doesn't exist. • timeout (int) -- The server timeout, expressed in seconds. Returns A boolean indicating whether the table was deleted. If fail_not_exist was set to True, this will throw instead of returning false. Return type bool exists(table_name, timeout=None) Returns a boolean indicating whether the table exists. Parameters • table_name (str) -- The name of table to check for existence. • timeout (int) -- The server timeout, expressed in seconds. Returns A boolean indicating whether the table exists. Return type bool generate_account_shared_access_signature(resource_types, permission, expiry, start=None, ip=None, protocol=None) Generates a shared access signature for the table service. Use the returned signature with the sas_token parameter of TableService. Parameters • resource_types (ResourceTypes) -- Specifies the resource types that are accessible with the account SAS. • permission (AccountPermissions) -- 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. • 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. • protocol (str) -- Specifies the protocol permitted for a request made. The default value is https,http. See Protocol for possible values. Returns A Shared Access Signature (sas) token. Return type str generate_table_shared_access_signature(table_name, permission=None, expiry=None, start=None, id=None, ip=None, protocol=None, start_pk=None, start_rk=None, end_pk=None, end_rk=None) Generates a shared access signature for the table. Use the returned signature with the sas_token parameter of TableService. Parameters • table_name (str) -- The name of the table to create a SAS token for. • permission (TablePermissions) -- 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. • 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_table_acl(). • 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. • protocol (str) -- Specifies the protocol permitted for a request made. The default value is https,http. See Protocol for possible values. • start_pk (str) -- The minimum partition key accessible with this shared access signature. startpk must accompany startrk. Key values are inclusive. If omitted, there is no lower bound on the table entities that can be accessed. • start_rk (str) -- The minimum row key accessible with this shared access signature. startpk must accompany startrk. Key values are inclusive. If omitted, there is no lower bound on the table entities that can be accessed. • end_pk (str) -- The maximum partition key accessible with this shared access signature. endpk must accompany endrk. Key values are inclusive. If omitted, there is no upper bound on the table entities that can be accessed. • end_rk (str) -- The maximum row key accessible with this shared access signature. endpk must accompany endrk. Key values are inclusive. If omitted, there is no upper bound on the table entities that can be accessed. Returns A Shared Access Signature (sas) token. Return type str get_entity(table_name, partition_key, row_key, select=None, accept='application/json;odata=minimalmetadata', property_resolver=None, timeout=None) Get an entity from the specified table. Throws if the entity does not exist. Parameters • table_name (str) -- The name of the table to get the entity from. • partition_key (str) -- The PartitionKey of the entity. • row_key (str) -- The RowKey of the entity. • select (str) -- Returns only the desired properties of an entity from the set. • accept (str) -- Specifies the accepted content type of the response payload. See TablePayloadFormat for possible values. • property_resolver (func(pk, rk, prop_name, prop_value, service_edm_type)) -- A function which given the partition key, row key, property name, property value, and the property EdmType if returned by the service, returns the EdmType of the property. Generally used if accept is set to JSON_NO_METADATA. • timeout (int) -- The server timeout, expressed in seconds. Returns The retrieved entity. Return type Entity get_table_acl(table_name, timeout=None) Returns details about any stored access policies specified on the table that may be used with Shared Access Signatures. Parameters • table_name (str) -- The name of an existing table. • timeout (int) -- The server timeout, expressed in seconds. Returns A dictionary of access policies associated with the table. Return type dict(str, AccessPolicy) get_table_service_properties(timeout=None) Gets the properties of a storage account's Table service, including logging, analytics and CORS rules. Parameters timeout (int) -- The server timeout, expressed in seconds. Returns The table service properties. Return type ServiceProperties get_table_service_stats(timeout=None) Retrieves statistics related to replication for the Table 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. Parameters timeout (int) -- The timeout parameter is expressed in seconds. Returns The table service stats. Return type ServiceStats insert_entity(table_name, entity, timeout=None) Inserts a new entity into the table. Throws if an entity with the same PartitionKey and RowKey already exists. When inserting an entity into a table, you must specify values for the PartitionKey and RowKey system properties. Together, these properties form the primary key and must be unique within the table. Both the PartitionKey and RowKey values must be string values; each key value may be up to 64 KB in size. If you are using an integer value for the key value, you should convert the integer to a fixed-width string, because they are canonically sorted. For example, you should convert the value 1 to 0000001 to ensure proper sorting. Parameters • table_name (str) -- The name of the table to insert the entity into. • entity (dict or Entity) -- The entity to insert. Could be a dict or an entity object. Must contain a PartitionKey and a RowKey. • timeout (int) -- The server timeout, expressed in seconds. Returns The etag of the inserted entity. Return type str insert_or_merge_entity(table_name, entity, timeout=None) Merges an existing entity or inserts a new entity if it does not exist in the table. If insert_or_merge_entity is used to merge an entity, any properties from the previous entity will be retained if the request does not define or include them. Parameters • table_name (str) -- The name of the table in which to insert or merge the entity. • entity (dict or Entity) -- The entity to insert or merge. Could be a dict or an entity object. Must contain a PartitionKey and a RowKey. • timeout (int) -- The server timeout, expressed in seconds. Returns The etag of the entity. Return type str insert_or_replace_entity(table_name, entity, timeout=None) Replaces an existing entity or inserts a new entity if it does not exist in the table. Because this operation can insert or update an entity, it is also known as an "upsert" operation. If insert_or_replace_entity is used to replace an entity, any properties from the previous entity will be removed if the new entity does not define them. Parameters • table_name (str) -- The name of the table in which to insert or replace the entity. • entity (dict or Entity) -- The entity to insert or replace. Could be a dict or an entity object. Must contain a PartitionKey and a RowKey. • timeout (int) -- The server timeout, expressed in seconds. Returns The etag of the entity. Return type str list_tables(num_results=None, marker=None, timeout=None) Returns a generator to list the tables. The generator will lazily follow the continuation tokens returned by the service and stop when all tables have been returned or num_results is reached. If num_results is specified and the account has more than that number of tables, 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. Parameters • num_results (int) -- The maximum number of tables to return. • marker (obj) -- An opaque continuation object. This value can be retrieved from the next_marker field of a previous generator object if num_results was specified and that generator has finished enumerating results. If specified, this generator will begin returning results from the point where the previous generator stopped. • 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 A generator which produces Table objects. Return type ListGenerator: merge_entity(table_name, entity, if_match='*', timeout=None) Updates an existing entity by merging the entity's properties. Throws if the entity does not exist. This operation does not replace the existing entity as the update_entity operation does. A property cannot be removed with merge_entity. Any properties with null values are ignored. All other properties will be updated or added. Parameters • table_name (str) -- The name of the table containing the entity to merge. • entity (dict or Entity) -- The entity to merge. Could be a dict or an entity object. Must contain a PartitionKey and a RowKey. • if_match (str) -- The client may specify the ETag for the entity on the request in order to compare to the ETag maintained by the service for the purpose of optimistic concurrency. The merge operation will be performed only if the ETag sent by the client matches the value maintained by the server, indicating that the entity has not been modified since it was retrieved by the client. To force an unconditional merge, set If-Match to the wildcard character (*). • timeout (int) -- The server timeout, expressed in seconds. Returns The etag of the entity. Return type str query_entities(table_name, filter=None, select=None, num_results=None, marker=None, accept='application/json;odata=minimalmetadata', property_resolver=None, timeout=None) Returns a generator to list the entities in the table specified. The generator will lazily follow the continuation tokens returned by the service and stop when all entities have been returned or num_results is reached. If num_results is specified and the account has more than that number of entities, 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. Parameters • table_name (str) -- The name of the table to query. • filter (str) -- Returns only entities that satisfy the specified filter. Note that no more than 15 discrete comparisons are permitted within a $filter string. See http://msdn.microsoft.com/en-us/library/windowsazure/dd894031.aspx for more information on constructing filters. • select (str) -- Returns only the desired properties of an entity from the set. • num_results (int) -- The maximum number of entities to return. • marker (obj) -- An opaque continuation object. This value can be retrieved from the next_marker field of a previous generator object if max_results was specified and that generator has finished enumerating results. If specified, this generator will begin returning results from the point where the previous generator stopped. • accept (str) -- Specifies the accepted content type of the response payload. See TablePayloadFormat for possible values. • property_resolver (func(pk, rk, prop_name, prop_value, service_edm_type)) -- A function which given the partition key, row key, property name, property value, and the property EdmType if returned by the service, returns the EdmType of the property. Generally used if accept is set to JSON_NO_METADATA. • 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 A generator which produces Entity objects. Return type ListGenerator set_table_acl(table_name, signed_identifiers=None, timeout=None) Sets stored access policies for the table that may be used with Shared Access Signatures. When you set permissions for a table, the existing permissions are replaced. To update the table's permissions, call get_table_acl() to fetch all access policies associated with the table, 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 table, 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 AzureHttpError until the access policy becomes active. Parameters • table_name (str) -- The name of an existing table. • signed_identifiers (dict(str, AccessPolicy)) -- A dictionary of access policies to associate with the table. The dictionary may contain up to 5 elements. An empty dictionary will clear the access policies set on the service. • timeout (int) -- The server timeout, expressed in seconds. set_table_service_properties(logging=None, hour_metrics=None, minute_metrics=None, cors=None, timeout=None) Sets the properties of a storage account's Table service, including Azure Storage Analytics. If an element (ex Logging) is left as None, the existing settings on the service for that functionality are preserved. For more information on Azure Storage Analytics, see https://msdn.microsoft.com/en-us/library/azure/hh343270.aspx. Parameters • logging (Logging) -- The logging settings provide request logs. • hour_metrics (Metrics) -- The hour metrics settings provide a summary of request statistics grouped by API in hourly aggregates for tables. • minute_metrics (Metrics) -- The minute metrics settings provide request statistics for each minute for tables. • 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. For detailed information about CORS rules and evaluation logic, see https://msdn.microsoft.com/en-us/library/azure/dn535601.aspx. • timeout (int) -- The server timeout, expressed in seconds. update_entity(table_name, entity, if_match='*', timeout=None) Updates an existing entity in a table. Throws if the entity does not exist. The update_entity operation replaces the entire entity and can be used to remove properties. Parameters • table_name (str) -- The name of the table containing the entity to update. • entity (dict or Entity) -- The entity to update. Could be a dict or an entity object. Must contain a PartitionKey and a RowKey. • if_match (str) -- The client may specify the ETag for the entity on the request in order to compare to the ETag maintained by the service for the purpose of optimistic concurrency. The update operation will be performed only if the ETag sent by the client matches the value maintained by the server, indicating that the entity has not been modified since it was retrieved by the client. To force an unconditional update, set If-Match to the wildcard character (*). • timeout (int) -- The server timeout, expressed in seconds. Returns The etag of the entity. Return type str Module contents Module contents Module contents
AZURE.COSMOSDB.TABLE.SHAREDACCESSSIGNATURE MODULE
class azure.cosmosdb.table.sharedaccesssignature.TableSharedAccessSignature(account_name, account_key) Bases: azure.cosmosdb.table.common.sharedaccesssignature.SharedAccessSignature Provides a factory for creating file and share access signature tokens with a common account name and account key. Users can either use the factory or can construct the appropriate service and use the generate_*_shared_access_signature method directly. Parameters • account_name (str) -- The storage account name used to generate the shared access signatures. • account_key (str) -- The access key to generate the shares access signatures. generate_table(table_name, permission=None, expiry=None, start=None, id=None, ip=None, protocol=None, start_pk=None, start_rk=None, end_pk=None, end_rk=None) Generates a shared access signature for the table. Use the returned signature with the sas_token parameter of TableService. Parameters • table_name (str) -- Name of table. • permission (TablePermissions) -- 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. • 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_table_service_properties. • 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. • protocol (str) -- Specifies the protocol permitted for a request made. The default value is https,http. See Protocol for possible values. • start_pk (str) -- The minimum partition key accessible with this shared access signature. startpk must accompany startrk. Key values are inclusive. If omitted, there is no lower bound on the table entities that can be accessed. • start_rk (str) -- The minimum row key accessible with this shared access signature. startpk must accompany startrk. Key values are inclusive. If omitted, there is no lower bound on the table entities that can be accessed. • end_pk (str) -- The maximum partition key accessible with this shared access signature. endpk must accompany endrk. Key values are inclusive. If omitted, there is no upper bound on the table entities that can be accessed. • end_rk (str) -- The maximum row key accessible with this shared access signature. endpk must accompany endrk. Key values are inclusive. If omitted, there is no upper bound on the table entities that can be accessed.
AZURE
AUTHOR
unknown
COPYRIGHT
2022, Microsoft