Microsoft Azure Container Instance Client Library for Python providing comprehensive management capabilities for containerized applications in Azure cloud.
—
Quality
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
The Operations class provides access to the complete list of available operations for the Microsoft.ContainerInstance resource provider. This is useful for discovering supported functionality and for programmatic access to operation metadata.
def list(**kwargs) -> Iterable[Operation]:
"""
List all available operations for the Microsoft.ContainerInstance resource provider.
Returns:
Iterable[Operation]: All available operations with their metadata
Example:
# Get all available operations
operations = client.operations.list()
for operation in operations:
print(f"Operation: {operation.name}")
print(f"Display Name: {operation.display.operation}")
print(f"Provider: {operation.display.provider}")
print(f"Resource: {operation.display.resource}")
print(f"Description: {operation.display.description}")
print("---")
"""def discover_container_instance_operations(client):
"""
Discover and categorize all available Container Instance operations.
Args:
client: ContainerInstanceManagementClient instance
Returns:
dict: Categorized operations by resource type
"""
operations = client.operations.list()
categorized_operations = {
'containerGroups': [],
'containers': [],
'location': [],
'other': []
}
for operation in operations:
operation_name = operation.name.lower()
if 'containergroups' in operation_name:
categorized_operations['containerGroups'].append({
'name': operation.name,
'display_name': operation.display.operation,
'description': operation.display.description
})
elif 'containers' in operation_name and 'containergroups' not in operation_name:
categorized_operations['containers'].append({
'name': operation.name,
'display_name': operation.display.operation,
'description': operation.display.description
})
elif 'location' in operation_name:
categorized_operations['location'].append({
'name': operation.name,
'display_name': operation.display.operation,
'description': operation.display.description
})
else:
categorized_operations['other'].append({
'name': operation.name,
'display_name': operation.display.operation,
'description': operation.display.description
})
return categorized_operations
# Usage
operations_by_category = discover_container_instance_operations(client)
print("Container Group Operations:")
for op in operations_by_category['containerGroups']:
print(f" - {op['display_name']}: {op['description']}")
print("\nContainer Operations:")
for op in operations_by_category['containers']:
print(f" - {op['display_name']}: {op['description']}")
print("\nLocation Operations:")
for op in operations_by_category['location']:
print(f" - {op['display_name']}: {op['description']}")def check_operation_support(client, operation_name):
"""
Check if a specific operation is supported.
Args:
client: ContainerInstanceManagementClient instance
operation_name (str): Operation name to check
Returns:
dict: Operation details if found, None otherwise
"""
operations = client.operations.list()
for operation in operations:
if operation_name.lower() in operation.name.lower():
return {
'name': operation.name,
'display_name': operation.display.operation,
'provider': operation.display.provider,
'resource': operation.display.resource,
'description': operation.display.description,
'supported': True
}
return {
'name': operation_name,
'supported': False,
'message': f"Operation '{operation_name}' not found"
}
# Usage examples
print("Checking for container group creation support:")
create_support = check_operation_support(client, "create")
if create_support['supported']:
print(f"✅ {create_support['display_name']} is supported")
print(f" Description: {create_support['description']}")
else:
print(f"❌ {create_support['message']}")
print("\nChecking for log retrieval support:")
logs_support = check_operation_support(client, "logs")
if logs_support['supported']:
print(f"✅ {logs_support['display_name']} is supported")
print(f" Description: {logs_support['description']}")
else:
print(f"❌ {logs_support['message']}")def generate_operations_documentation(client, output_file="operations_doc.md"):
"""
Generate markdown documentation for all available operations.
Args:
client: ContainerInstanceManagementClient instance
output_file (str): Output file path for documentation
"""
operations = client.operations.list()
# Group operations by resource
operations_by_resource = {}
for operation in operations:
resource = operation.display.resource
if resource not in operations_by_resource:
operations_by_resource[resource] = []
operations_by_resource[resource].append(operation)
# Generate markdown
with open(output_file, 'w') as f:
f.write("# Azure Container Instance Operations\n\n")
f.write("Complete list of available operations for the Microsoft.ContainerInstance resource provider.\n\n")
for resource, ops in operations_by_resource.items():
f.write(f"## {resource}\n\n")
for op in ops:
f.write(f"### {op.display.operation}\n\n")
f.write(f"**Operation Name:** `{op.name}`\n\n")
f.write(f"**Description:** {op.display.description}\n\n")
f.write("---\n\n")
print(f"Operations documentation written to {output_file}")
# Usage
generate_operations_documentation(client)class Operation:
"""
Details of a REST API operation, returned from the Resource Provider Operations API.
Properties:
name (str): Operation name: {provider}/{resource}/{operation}
is_data_action (bool): Indicates whether the operation is a data operation
display (OperationDisplay): Localized display information for this particular operation
action_type (str): Enum. Indicates the action type
origin (str): The intended executor of the operation
"""
class OperationDisplay:
"""
Localized display information for operation.
Properties:
provider (str): Service provider: Microsoft.ContainerInstance
resource (str): Resource on which the operation is performed
operation (str): Type of operation: get, read, delete, etc.
description (str): Description of the operation
"""Install with Tessl CLI
npx tessl i tessl/pypi-azure-mgmt-containerinstance