CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-azure-mgmt-cosmosdb

Microsoft Azure Cosmos DB Management Client Library for Python

Pending

Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

Overview
Eval results
Files

multi-api-resources.mddocs/

Multi-API Resource Management

Management operations for Table API, Cassandra API, and Gremlin API resources. These APIs provide specialized data models and query capabilities while leveraging Cosmos DB's global distribution and enterprise features.

Table API Resources

Table Management

Manage Azure Table API tables with throughput configuration and scaling options.

def list_tables(
    self,
    resource_group_name: str,
    account_name: str
) -> ItemPaged[TableGetResults]:
    """
    List tables in a Cosmos DB account with Table API.
    
    Parameters:
    - resource_group_name: Name of the resource group
    - account_name: Name of the Cosmos DB account
    
    Returns:
    ItemPaged[TableGetResults]: Paginated list of tables
    """

def get_table(
    self,
    resource_group_name: str,
    account_name: str,
    table_name: str
) -> TableGetResults:
    """
    Get properties of a table.
    
    Parameters:
    - resource_group_name: Name of the resource group
    - account_name: Name of the Cosmos DB account
    - table_name: Name of the table
    
    Returns:
    TableGetResults: Table properties and configuration
    """

def begin_create_update_table(
    self,
    resource_group_name: str,
    account_name: str,
    table_name: str,
    create_update_table_parameters: TableCreateUpdateParameters
) -> LROPoller[TableGetResults]:
    """
    Create or update a table (Long Running Operation).
    
    Parameters:
    - resource_group_name: Name of the resource group
    - account_name: Name of the Cosmos DB account
    - table_name: Name of the table to create/update
    - create_update_table_parameters: Table configuration parameters
    
    Returns:
    LROPoller[TableGetResults]: Poller for monitoring operation progress
    """

def begin_delete_table(
    self,
    resource_group_name: str,
    account_name: str,
    table_name: str
) -> LROPoller[None]:
    """
    Delete a table (Long Running Operation).
    
    Parameters:
    - resource_group_name: Name of the resource group
    - account_name: Name of the Cosmos DB account
    - table_name: Name of the table to delete
    
    Returns:
    LROPoller[None]: Poller for monitoring operation progress
    """

def get_table_throughput(
    self,
    resource_group_name: str,
    account_name: str,
    table_name: str
) -> ThroughputSettingsGetResults:
    """
    Get throughput settings for a table.
    
    Parameters:
    - resource_group_name: Name of the resource group
    - account_name: Name of the Cosmos DB account
    - table_name: Name of the table
    
    Returns:
    ThroughputSettingsGetResults: Current throughput configuration
    """

def begin_update_table_throughput(
    self,
    resource_group_name: str,
    account_name: str,
    table_name: str,
    update_throughput_parameters: ThroughputSettingsUpdateParameters
) -> LROPoller[ThroughputSettingsGetResults]:
    """
    Update throughput settings for a table (Long Running Operation).
    
    Parameters:
    - resource_group_name: Name of the resource group
    - account_name: Name of the Cosmos DB account
    - table_name: Name of the table
    - update_throughput_parameters: New throughput configuration
    
    Returns:
    LROPoller[ThroughputSettingsGetResults]: Poller for monitoring operation progress
    """

Cassandra API Resources

Cassandra Keyspace Management

Manage Cassandra keyspaces with throughput and replication settings.

def list_cassandra_keyspaces(
    self,
    resource_group_name: str,
    account_name: str
) -> ItemPaged[CassandraKeyspaceGetResults]:
    """
    List Cassandra keyspaces in a Cosmos DB account.
    
    Parameters:
    - resource_group_name: Name of the resource group
    - account_name: Name of the Cosmos DB account
    
    Returns:
    ItemPaged[CassandraKeyspaceGetResults]: Paginated list of keyspaces
    """

def get_cassandra_keyspace(
    self,
    resource_group_name: str,
    account_name: str,
    keyspace_name: str
) -> CassandraKeyspaceGetResults:
    """
    Get properties of a Cassandra keyspace.
    
    Parameters:
    - resource_group_name: Name of the resource group
    - account_name: Name of the Cosmos DB account
    - keyspace_name: Name of the Cassandra keyspace
    
    Returns:
    CassandraKeyspaceGetResults: Keyspace properties and configuration
    """

def begin_create_update_cassandra_keyspace(
    self,
    resource_group_name: str,
    account_name: str,
    keyspace_name: str,
    create_update_cassandra_keyspace_parameters: CassandraKeyspaceCreateUpdateParameters
) -> LROPoller[CassandraKeyspaceGetResults]:
    """
    Create or update a Cassandra keyspace (Long Running Operation).
    
    Parameters:
    - resource_group_name: Name of the resource group
    - account_name: Name of the Cosmos DB account
    - keyspace_name: Name of the keyspace to create/update
    - create_update_cassandra_keyspace_parameters: Keyspace configuration parameters
    
    Returns:
    LROPoller[CassandraKeyspaceGetResults]: Poller for monitoring operation progress
    """

def begin_delete_cassandra_keyspace(
    self,
    resource_group_name: str,
    account_name: str,
    keyspace_name: str
) -> LROPoller[None]:
    """
    Delete a Cassandra keyspace (Long Running Operation).
    
    Parameters:
    - resource_group_name: Name of the resource group
    - account_name: Name of the Cosmos DB account
    - keyspace_name: Name of the keyspace to delete
    
    Returns:
    LROPoller[None]: Poller for monitoring operation progress
    """

Cassandra Table Management

Manage Cassandra tables with schema, clustering keys, and partition configuration.

def list_cassandra_tables(
    self,
    resource_group_name: str,
    account_name: str,
    keyspace_name: str
) -> ItemPaged[CassandraTableGetResults]:
    """
    List Cassandra tables in a keyspace.
    
    Parameters:
    - resource_group_name: Name of the resource group
    - account_name: Name of the Cosmos DB account
    - keyspace_name: Name of the Cassandra keyspace
    
    Returns:
    ItemPaged[CassandraTableGetResults]: Paginated list of tables
    """

def get_cassandra_table(
    self,
    resource_group_name: str,
    account_name: str,
    keyspace_name: str,
    table_name: str
) -> CassandraTableGetResults:
    """
    Get properties of a Cassandra table.
    
    Parameters:
    - resource_group_name: Name of the resource group
    - account_name: Name of the Cosmos DB account
    - keyspace_name: Name of the Cassandra keyspace
    - table_name: Name of the Cassandra table
    
    Returns:
    CassandraTableGetResults: Table properties including schema and configuration
    """

def begin_create_update_cassandra_table(
    self,
    resource_group_name: str,
    account_name: str,
    keyspace_name: str,
    table_name: str,
    create_update_cassandra_table_parameters: CassandraTableCreateUpdateParameters
) -> LROPoller[CassandraTableGetResults]:
    """
    Create or update a Cassandra table (Long Running Operation).
    
    Parameters:
    - resource_group_name: Name of the resource group
    - account_name: Name of the Cosmos DB account
    - keyspace_name: Name of the Cassandra keyspace
    - table_name: Name of the table to create/update
    - create_update_cassandra_table_parameters: Table configuration parameters
    
    Returns:
    LROPoller[CassandraTableGetResults]: Poller for monitoring operation progress
    """

def get_cassandra_table_throughput(
    self,
    resource_group_name: str,
    account_name: str,
    keyspace_name: str,
    table_name: str
) -> ThroughputSettingsGetResults:
    """
    Get throughput settings for a Cassandra table.
    
    Parameters:
    - resource_group_name: Name of the resource group
    - account_name: Name of the Cosmos DB account
    - keyspace_name: Name of the Cassandra keyspace
    - table_name: Name of the Cassandra table
    
    Returns:
    ThroughputSettingsGetResults: Current throughput configuration
    """

Gremlin API Resources

Gremlin Database Management

Manage Gremlin databases for graph workloads with throughput configuration.

def list_gremlin_databases(
    self,
    resource_group_name: str,
    account_name: str
) -> ItemPaged[GremlinDatabaseGetResults]:
    """
    List Gremlin databases in a Cosmos DB account.
    
    Parameters:
    - resource_group_name: Name of the resource group
    - account_name: Name of the Cosmos DB account
    
    Returns:
    ItemPaged[GremlinDatabaseGetResults]: Paginated list of Gremlin databases
    """

def get_gremlin_database(
    self,
    resource_group_name: str,
    account_name: str,
    database_name: str
) -> GremlinDatabaseGetResults:
    """
    Get properties of a Gremlin database.
    
    Parameters:
    - resource_group_name: Name of the resource group
    - account_name: Name of the Cosmos DB account
    - database_name: Name of the Gremlin database
    
    Returns:
    GremlinDatabaseGetResults: Gremlin database properties and configuration
    """

def begin_create_update_gremlin_database(
    self,
    resource_group_name: str,
    account_name: str,
    database_name: str,
    create_update_gremlin_database_parameters: GremlinDatabaseCreateUpdateParameters
) -> LROPoller[GremlinDatabaseGetResults]:
    """
    Create or update a Gremlin database (Long Running Operation).
    
    Parameters:
    - resource_group_name: Name of the resource group
    - account_name: Name of the Cosmos DB account
    - database_name: Name of the database to create/update
    - create_update_gremlin_database_parameters: Database configuration parameters
    
    Returns:
    LROPoller[GremlinDatabaseGetResults]: Poller for monitoring operation progress
    """

def begin_delete_gremlin_database(
    self,
    resource_group_name: str,
    account_name: str,
    database_name: str
) -> LROPoller[None]:
    """
    Delete a Gremlin database (Long Running Operation).
    
    Parameters:
    - resource_group_name: Name of the resource group
    - account_name: Name of the Cosmos DB account
    - database_name: Name of the database to delete
    
    Returns:
    LROPoller[None]: Poller for monitoring operation progress
    """

Gremlin Graph Management

Manage Gremlin graphs with partitioning and indexing for graph workloads.

def list_gremlin_graphs(
    self,
    resource_group_name: str,
    account_name: str,
    database_name: str
) -> ItemPaged[GremlinGraphGetResults]:
    """
    List Gremlin graphs in a database.
    
    Parameters:
    - resource_group_name: Name of the resource group
    - account_name: Name of the Cosmos DB account
    - database_name: Name of the Gremlin database
    
    Returns:
    ItemPaged[GremlinGraphGetResults]: Paginated list of graphs
    """

def get_gremlin_graph(
    self,
    resource_group_name: str,
    account_name: str,
    database_name: str,
    graph_name: str
) -> GremlinGraphGetResults:
    """
    Get properties of a Gremlin graph.
    
    Parameters:
    - resource_group_name: Name of the resource group
    - account_name: Name of the Cosmos DB account
    - database_name: Name of the Gremlin database
    - graph_name: Name of the Gremlin graph
    
    Returns:
    GremlinGraphGetResults: Graph properties including partition key and indexing policy
    """

def begin_create_update_gremlin_graph(
    self,
    resource_group_name: str,
    account_name: str,
    database_name: str,
    graph_name: str,
    create_update_gremlin_graph_parameters: GremlinGraphCreateUpdateParameters
) -> LROPoller[GremlinGraphGetResults]:
    """
    Create or update a Gremlin graph (Long Running Operation).
    
    Parameters:
    - resource_group_name: Name of the resource group
    - account_name: Name of the Cosmos DB account
    - database_name: Name of the Gremlin database
    - graph_name: Name of the graph to create/update
    - create_update_gremlin_graph_parameters: Graph configuration parameters
    
    Returns:
    LROPoller[GremlinGraphGetResults]: Poller for monitoring operation progress
    """

def get_gremlin_graph_throughput(
    self,
    resource_group_name: str,
    account_name: str,
    database_name: str,
    graph_name: str
) -> ThroughputSettingsGetResults:
    """
    Get throughput settings for a Gremlin graph.
    
    Parameters:
    - resource_group_name: Name of the resource group
    - account_name: Name of the Cosmos DB account
    - database_name: Name of the Gremlin database
    - graph_name: Name of the Gremlin graph
    
    Returns:
    ThroughputSettingsGetResults: Current throughput configuration
    """

Usage Examples

Creating a Table API Table

from azure.mgmt.cosmosdb import CosmosDBManagementClient
from azure.mgmt.cosmosdb.models import TableCreateUpdateParameters, TableResource, CreateUpdateOptions
from azure.identity import DefaultAzureCredential

client = CosmosDBManagementClient(DefaultAzureCredential(), "subscription-id")

# Create Table API table
table_params = TableCreateUpdateParameters(
    resource=TableResource(id="customers"),
    options=CreateUpdateOptions(throughput=400)
)

poller = client.table_resources.begin_create_update_table(
    "my-resource-group",
    "my-cosmos-account",
    "customers",
    table_params
)

table = poller.result()
print(f"Created table: {table.name}")

Creating a Cassandra Keyspace and Table

from azure.mgmt.cosmosdb.models import (
    CassandraKeyspaceCreateUpdateParameters,
    CassandraKeyspaceResource,
    CassandraTableCreateUpdateParameters,
    CassandraTableResource,
    CassandraSchema,
    Column,
    CassandraPartitionKey,
    ClusterKey
)

# Create keyspace
keyspace_params = CassandraKeyspaceCreateUpdateParameters(
    resource=CassandraKeyspaceResource(id="inventory"),
    options=CreateUpdateOptions(throughput=600)
)

poller = client.cassandra_resources.begin_create_update_cassandra_keyspace(
    "my-resource-group",
    "my-cosmos-account",
    "inventory",
    keyspace_params
)
keyspace = poller.result()

# Create table with schema
table_resource = CassandraTableResource(
    id="products",
    schema=CassandraSchema(
        columns=[
            Column(name="product_id", type="uuid"),
            Column(name="category", type="text"),
            Column(name="name", type="text"),
            Column(name="price", type="decimal"),
            Column(name="created_at", type="timestamp")
        ],
        partition_keys=[
            CassandraPartitionKey(name="category")
        ],
        cluster_keys=[
            ClusterKey(name="created_at", order_by="DESC")
        ]
    )
)

table_params = CassandraTableCreateUpdateParameters(
    resource=table_resource,
    options=CreateUpdateOptions(throughput=400)
)

poller = client.cassandra_resources.begin_create_update_cassandra_table(
    "my-resource-group",
    "my-cosmos-account",
    "inventory",
    "products",
    table_params
)
table = poller.result()

print(f"Created Cassandra table: {table.name} with partition key: {table.resource.schema.partition_keys[0].name}")

Creating a Gremlin Graph

from azure.mgmt.cosmosdb.models import (
    GremlinDatabaseCreateUpdateParameters,
    GremlinDatabaseResource,
    GremlinGraphCreateUpdateParameters,
    GremlinGraphResource,
    ContainerPartitionKey,
    IndexingPolicy
)

# Create Gremlin database
database_params = GremlinDatabaseCreateUpdateParameters(
    resource=GremlinDatabaseResource(id="social"),
    options=CreateUpdateOptions(throughput=800)
)

poller = client.gremlin_resources.begin_create_update_gremlin_database(
    "my-resource-group",
    "my-cosmos-account",
    "social",
    database_params
)
database = poller.result()

# Create graph with partition key
graph_resource = GremlinGraphResource(
    id="friendships",
    partition_key=ContainerPartitionKey(
        paths=["/userId"],
        kind="Hash"
    ),
    indexing_policy=IndexingPolicy(
        indexing_mode="Consistent",
        automatic=True
    )
)

graph_params = GremlinGraphCreateUpdateParameters(
    resource=graph_resource,
    options=CreateUpdateOptions(throughput=400)
)

poller = client.gremlin_resources.begin_create_update_gremlin_graph(
    "my-resource-group",
    "my-cosmos-account",
    "social",
    "friendships",
    graph_params
)
graph = poller.result()

print(f"Created Gremlin graph: {graph.name} with partition key: {graph.resource.partition_key.paths}")

Key Types

# Table API Types
class TableGetResults:
    """Table API table properties and configuration."""
    id: str
    name: str
    type: str
    resource: TableGetPropertiesResource
    options: TableGetPropertiesOptions

class TableResource:
    """Table API table resource definition."""
    id: str  # Table name

# Cassandra API Types
class CassandraKeyspaceGetResults:
    """Cassandra keyspace properties and configuration."""
    id: str
    name: str
    type: str
    resource: CassandraKeyspaceGetPropertiesResource
    options: CassandraKeyspaceGetPropertiesOptions

class CassandraKeyspaceResource:
    """Cassandra keyspace resource definition."""
    id: str  # Keyspace name

class CassandraTableGetResults:
    """Cassandra table properties and configuration."""
    id: str
    name: str
    type: str
    resource: CassandraTableGetPropertiesResource
    options: CassandraTableGetPropertiesOptions

class CassandraTableResource:
    """Cassandra table resource definition."""
    id: str  # Table name
    schema: CassandraSchema  # Table schema definition

class CassandraSchema:
    """Cassandra table schema definition."""
    columns: List[Column]  # Column definitions
    partition_keys: List[CassandraPartitionKey]  # Partition key columns
    cluster_keys: List[ClusterKey]  # Clustering key columns

class Column:
    """Cassandra table column definition."""
    name: str  # Column name
    type: str  # Column data type (text, int, uuid, timestamp, etc.)

class CassandraPartitionKey:
    """Cassandra partition key definition."""
    name: str  # Column name for partitioning

class ClusterKey:
    """Cassandra clustering key definition."""
    name: str  # Column name for clustering
    order_by: str  # Sort order ("ASC" or "DESC")

# Gremlin API Types
class GremlinDatabaseGetResults:
    """Gremlin database properties and configuration."""
    id: str
    name: str
    type: str
    resource: GremlinDatabaseGetPropertiesResource
    options: GremlinDatabaseGetPropertiesOptions

class GremlinDatabaseResource:
    """Gremlin database resource definition."""
    id: str  # Database name

class GremlinGraphGetResults:
    """Gremlin graph properties and configuration."""
    id: str
    name: str
    type: str
    resource: GremlinGraphGetPropertiesResource
    options: GremlinGraphGetPropertiesOptions

class GremlinGraphResource:
    """Gremlin graph resource definition."""
    id: str  # Graph name
    partition_key: ContainerPartitionKey  # Partition key for the graph
    indexing_policy: IndexingPolicy  # Indexing policy for vertices and edges
    conflict_resolution_policy: ConflictResolutionPolicy  # Conflict resolution settings
    unique_key_policy: UniqueKeyPolicy  # Unique key constraints

Install with Tessl CLI

npx tessl i tessl/pypi-azure-mgmt-cosmosdb

docs

database-accounts.md

index.md

mongodb-resources.md

monitoring-metrics.md

multi-api-resources.md

networking-security.md

restore-operations.md

service-management.md

sql-resources.md

tile.json