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

restore-operations.mddocs/

Point-in-Time Restore Operations

Comprehensive point-in-time restore capabilities for discovering restorable resources across all APIs and time ranges. These operations enable precise backup and recovery scenarios by providing detailed information about what resources can be restored and from which points in time.

Capabilities

Restorable Database Account Discovery

Discover database accounts that can be restored from a specific time range and location.

def list(self) -> ItemPaged[RestorableDatabaseAccountGetResult]:
    """
    List all restorable database accounts in the subscription.
    
    Returns:
    ItemPaged[RestorableDatabaseAccountGetResult]: Paginated list of restorable accounts
    """

def list_by_location(self, location: str) -> ItemPaged[RestorableDatabaseAccountGetResult]:
    """
    List restorable database accounts in a specific location.
    
    Parameters:
    - location: Azure region name (e.g., "East US", "West Europe")
    
    Returns:
    ItemPaged[RestorableDatabaseAccountGetResult]: Paginated list of restorable accounts in the location
    """

def get_by_location(
    self,
    location: str,
    instance_id: str
) -> RestorableDatabaseAccountGetResult:
    """
    Get details of a restorable database account by location and instance ID.
    
    Parameters:
    - location: Azure region name
    - instance_id: Unique identifier of the database account instance
    
    Returns:
    RestorableDatabaseAccountGetResult: Restorable account details and timeline
    """

SQL API Restore Discovery

Discover restorable SQL API resources including databases, containers, and related resources.

def list(
    self,
    location: str,
    instance_id: str,
    restore_location: Optional[str] = None,
    restore_timestamp_in_utc: Optional[str] = None
) -> ItemPaged[RestorableSqlResourcesGetResult]:
    """
    List all restorable SQL resources for a database account.
    
    Parameters:
    - location: Location of the source account
    - instance_id: Instance ID of the source account
    - restore_location: Target location for restore (optional)
    - restore_timestamp_in_utc: Restore point in UTC (optional)
    
    Returns:
    ItemPaged[RestorableSqlResourcesGetResult]: Paginated list of restorable SQL resources
    """

def list_sql_databases(
    self,
    location: str,
    instance_id: str,
    start_time: Optional[str] = None,
    end_time: Optional[str] = None
) -> ItemPaged[RestorableSqlDatabaseGetResult]:
    """
    List restorable SQL databases for a specific account and time range.
    
    Parameters:
    - location: Location of the source account
    - instance_id: Instance ID of the source account
    - start_time: Start time for the restore range in UTC
    - end_time: End time for the restore range in UTC
    
    Returns:
    ItemPaged[RestorableSqlDatabaseGetResult]: Paginated list of restorable databases
    """

def list_sql_containers(
    self,
    location: str,
    instance_id: str,
    database_rid: str,
    start_time: Optional[str] = None,
    end_time: Optional[str] = None
) -> ItemPaged[RestorableSqlContainerGetResult]:
    """
    List restorable SQL containers in a database for a specific time range.
    
    Parameters:
    - location: Location of the source account
    - instance_id: Instance ID of the source account
    - database_rid: Resource ID of the database
    - start_time: Start time for the restore range in UTC
    - end_time: End time for the restore range in UTC
    
    Returns:
    ItemPaged[RestorableSqlContainerGetResult]: Paginated list of restorable containers
    """

MongoDB API Restore Discovery

Discover restorable MongoDB API resources including databases, collections, and configurations.

def list(
    self,
    location: str,
    instance_id: str,
    restore_location: Optional[str] = None,
    restore_timestamp_in_utc: Optional[str] = None
) -> ItemPaged[RestorableMongodbResourcesGetResult]:
    """
    List all restorable MongoDB resources for a database account.
    
    Parameters:
    - location: Location of the source account
    - instance_id: Instance ID of the source account
    - restore_location: Target location for restore (optional)
    - restore_timestamp_in_utc: Restore point in UTC (optional)
    
    Returns:
    ItemPaged[RestorableMongodbResourcesGetResult]: Paginated list of restorable MongoDB resources
    """

def list_mongodb_databases(
    self,
    location: str,
    instance_id: str,
    start_time: Optional[str] = None,
    end_time: Optional[str] = None
) -> ItemPaged[RestorableMongodbDatabaseGetResult]:
    """
    List restorable MongoDB databases for a specific account and time range.
    
    Parameters:
    - location: Location of the source account
    - instance_id: Instance ID of the source account
    - start_time: Start time for the restore range in UTC
    - end_time: End time for the restore range in UTC
    
    Returns:
    ItemPaged[RestorableMongodbDatabaseGetResult]: Paginated list of restorable databases
    """

def list_mongodb_collections(
    self,
    location: str,
    instance_id: str,
    database_rid: str,
    start_time: Optional[str] = None,
    end_time: Optional[str] = None
) -> ItemPaged[RestorableMongodbCollectionGetResult]:
    """
    List restorable MongoDB collections in a database for a specific time range.
    
    Parameters:
    - location: Location of the source account
    - instance_id: Instance ID of the source account
    - database_rid: Resource ID of the database
    - start_time: Start time for the restore range in UTC
    - end_time: End time for the restore range in UTC
    
    Returns:
    ItemPaged[RestorableMongodbCollectionGetResult]: Paginated list of restorable collections
    """

Gremlin API Restore Discovery

Discover restorable Gremlin API resources including databases and graphs.

def list(
    self,
    location: str,
    instance_id: str,
    restore_location: Optional[str] = None,
    restore_timestamp_in_utc: Optional[str] = None
) -> ItemPaged[RestorableGremlinResourcesGetResult]:
    """
    List all restorable Gremlin resources for a database account.
    
    Parameters:
    - location: Location of the source account
    - instance_id: Instance ID of the source account
    - restore_location: Target location for restore (optional)
    - restore_timestamp_in_utc: Restore point in UTC (optional)
    
    Returns:
    ItemPaged[RestorableGremlinResourcesGetResult]: Paginated list of restorable Gremlin resources
    """

def list_gremlin_databases(
    self,
    location: str,
    instance_id: str,
    start_time: Optional[str] = None,
    end_time: Optional[str] = None
) -> ItemPaged[RestorableGremlinDatabaseGetResult]:
    """
    List restorable Gremlin databases for a specific account and time range.
    
    Parameters:
    - location: Location of the source account
    - instance_id: Instance ID of the source account
    - start_time: Start time for the restore range in UTC
    - end_time: End time for the restore range in UTC
    
    Returns:
    ItemPaged[RestorableGremlinDatabaseGetResult]: Paginated list of restorable databases
    """

def list_gremlin_graphs(
    self,
    location: str,
    instance_id: str,
    database_rid: str,
    start_time: Optional[str] = None,
    end_time: Optional[str] = None
) -> ItemPaged[RestorableGremlinGraphGetResult]:
    """
    List restorable Gremlin graphs in a database for a specific time range.
    
    Parameters:
    - location: Location of the source account
    - instance_id: Instance ID of the source account
    - database_rid: Resource ID of the database
    - start_time: Start time for the restore range in UTC
    - end_time: End time for the restore range in UTC
    
    Returns:
    ItemPaged[RestorableGremlinGraphGetResult]: Paginated list of restorable graphs
    """

Table API Restore Discovery

Discover restorable Table API resources.

def list(
    self,
    location: str,
    instance_id: str,
    restore_location: Optional[str] = None,
    restore_timestamp_in_utc: Optional[str] = None
) -> ItemPaged[RestorableTableResourcesGetResult]:
    """
    List all restorable table resources for a database account.
    
    Parameters:
    - location: Location of the source account
    - instance_id: Instance ID of the source account
    - restore_location: Target location for restore (optional)
    - restore_timestamp_in_utc: Restore point in UTC (optional)
    
    Returns:
    ItemPaged[RestorableTableResourcesGetResult]: Paginated list of restorable table resources
    """

def list_tables(
    self,
    location: str,
    instance_id: str,
    start_time: Optional[str] = None,
    end_time: Optional[str] = None
) -> ItemPaged[RestorableTableGetResult]:
    """
    List restorable tables for a specific account and time range.
    
    Parameters:
    - location: Location of the source account
    - instance_id: Instance ID of the source account
    - start_time: Start time for the restore range in UTC
    - end_time: End time for the restore range in UTC
    
    Returns:
    ItemPaged[RestorableTableGetResult]: Paginated list of restorable tables
    """

Usage Examples

Discovering Restorable Accounts

from azure.mgmt.cosmosdb import CosmosDBManagementClient
from azure.identity import DefaultAzureCredential
from datetime import datetime, timedelta

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

# List all restorable accounts in East US
restorable_accounts = client.restorable_database_accounts.list_by_location("East US")

for account in restorable_accounts:
    print(f"Account: {account.account_name}")
    print(f"Instance ID: {account.instance_id}")
    print(f"Creation Time: {account.creation_time}")
    print(f"Deletion Time: {account.deletion_time}")
    print(f"API Type: {account.api_type}")
    print("---")

Finding Restorable Resources for a Specific Time

from datetime import datetime, timezone

# Target restore time (24 hours ago)
restore_time = datetime.now(timezone.utc) - timedelta(hours=24)
restore_timestamp = restore_time.strftime("%Y-%m-%dT%H:%M:%SZ")

# Get instance ID from a restorable account
account_instance_id = "12345678-1234-1234-1234-123456789012"
location = "East US"

# Discover all restorable SQL resources at the target time
sql_resources = client.restorable_sql_resources.list(
    location=location,
    instance_id=account_instance_id,
    restore_timestamp_in_utc=restore_timestamp
)

for resource in sql_resources:
    print(f"Resource Type: {resource.resource.resource_type}")
    print(f"Resource ID: {resource.resource.resource_id}")
    print(f"Restore Parameters: {resource.resource.restore_parameters}")
    print("---")

Discovering Restorable Collections in a Time Range

# Define time range for discovery (last 7 days)
end_time = datetime.now(timezone.utc)
start_time = end_time - timedelta(days=7)

start_timestamp = start_time.strftime("%Y-%m-%dT%H:%M:%SZ")
end_timestamp = end_time.strftime("%Y-%m-%dT%H:%M:%SZ")

# List restorable SQL containers in a specific database
database_rid = "dbs/products"
containers = client.restorable_sql_containers.list(
    location=location,
    instance_id=account_instance_id,
    database_rid=database_rid,
    start_time=start_timestamp,
    end_time=end_timestamp
)

for container in containers:
    print(f"Container: {container.resource.container_name}")
    print(f"Operation Type: {container.resource.operation_type}")
    print(f"Event Timestamp: {container.resource.event_timestamp}")
    print(f"Owner ID: {container.resource.owner_id}")
    print("---")

Cross-Region Restore Discovery

# Discover resources that can be restored to a different region
source_location = "East US"
target_location = "West US"

gremlin_resources = client.restorable_gremlin_resources.list(
    location=source_location,
    instance_id=account_instance_id,
    restore_location=target_location,
    restore_timestamp_in_utc=restore_timestamp
)

for resource in gremlin_resources:
    print(f"Can restore {resource.resource.resource_type} to {target_location}")
    print(f"Resource: {resource.resource.resource_id}")
    print("---")

Key Types

class RestorableDatabaseAccountGetResult:
    """Information about a restorable database account."""
    id: str
    name: str
    type: str
    location: str
    account_name: str  # Original account name
    instance_id: str  # Unique identifier for the account instance
    creation_time: str  # Account creation time in UTC
    deletion_time: str  # Account deletion time in UTC (null if not deleted)
    api_type: str  # API type ("Sql", "MongoDB", "Cassandra", "Table", "Gremlin")
    restorable_locations: List[RestorableLocationResource]
    oldest_restorable_time: str  # Oldest point-in-time that can be restored

class RestorableLocationResource:
    """Information about a restorable location."""
    location_name: str  # Azure region name
    regional_database_account_instance_id: str  # Regional instance identifier
    creation_time: str  # Regional account creation time
    deletion_time: str  # Regional account deletion time (null if not deleted)

class RestorableSqlResourcesGetResult:
    """Restorable SQL resources information."""
    id: str
    name: str
    type: str
    resource: RestorableSqlResourcesGetResultResource

class RestorableSqlResourcesGetResultResource:
    """Details of restorable SQL resources."""
    database_name: str  # Database name
    collection_names: List[str]  # List of container names
    resource_type: str  # Type of resource
    resource_id: str  # Resource identifier
    restore_parameters: Dict[str, Any]  # Parameters needed for restore

class RestorableSqlDatabaseGetResult:
    """Information about a restorable SQL database."""
    id: str
    name: str
    type: str
    resource: RestorableSqlDatabaseResource

class RestorableSqlDatabaseResource:
    """Details of a restorable SQL database."""
    database_name: str  # Name of the database
    operation_type: str  # Operation that created this restore point ("Create", "Delete", "Replace", "SystemOperation")
    event_timestamp: str  # Timestamp when the operation occurred
    owner_id: str  # Owner identifier
    owner_resource_id: str  # Owner resource identifier

class RestorableSqlContainerGetResult:
    """Information about a restorable SQL container."""
    id: str
    name: str
    type: str
    resource: RestorableSqlContainerResource

class RestorableSqlContainerResource:
    """Details of a restorable SQL container."""
    container_name: str  # Name of the container
    operation_type: str  # Operation that created this restore point
    event_timestamp: str  # Timestamp when the operation occurred
    owner_id: str  # Owner identifier
    owner_resource_id: str  # Owner resource identifier

class RestorableMongodbResourcesGetResult:
    """Restorable MongoDB resources information."""
    id: str
    name: str
    type: str
    resource: RestorableMongodbResourcesGetResultResource

class RestorableMongodbResourcesGetResultResource:
    """Details of restorable MongoDB resources."""
    database_name: str  # Database name
    collection_names: List[str]  # List of collection names
    resource_type: str  # Type of resource
    resource_id: str  # Resource identifier
    restore_parameters: Dict[str, Any]  # Parameters needed for restore

class RestorableMongodbDatabaseGetResult:
    """Information about a restorable MongoDB database."""
    id: str
    name: str
    type: str
    resource: RestorableMongodbDatabaseResource

class RestorableMongodbDatabaseResource:
    """Details of a restorable MongoDB database."""
    database_name: str  # Name of the database
    operation_type: str  # Operation that created this restore point
    event_timestamp: str  # Timestamp when the operation occurred
    owner_id: str  # Owner identifier
    owner_resource_id: str  # Owner resource identifier

class RestorableGremlinResourcesGetResult:
    """Restorable Gremlin resources information."""
    id: str
    name: str
    type: str
    resource: RestorableGremlinResourcesGetResultResource

class RestorableTableResourcesGetResult:
    """Restorable Table resources information."""
    id: str
    name: str
    type: str
    resource: RestorableTableResourcesGetResultResource

class RestorableTableResourcesGetResultResource:
    """Details of restorable Table resources."""
    table_names: List[str]  # List of table names
    resource_type: str  # Type of resource
    resource_id: str  # Resource identifier
    restore_parameters: Dict[str, Any]  # Parameters needed for restore

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