0
# Available Operations
1
2
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.
3
4
## Capabilities
5
6
### List Available Operations { .api }
7
8
```python
9
def list(**kwargs) -> Iterable[Operation]:
10
"""
11
List all available operations for the Microsoft.ContainerInstance resource provider.
12
13
Returns:
14
Iterable[Operation]: All available operations with their metadata
15
16
Example:
17
# Get all available operations
18
operations = client.operations.list()
19
20
for operation in operations:
21
print(f"Operation: {operation.name}")
22
print(f"Display Name: {operation.display.operation}")
23
print(f"Provider: {operation.display.provider}")
24
print(f"Resource: {operation.display.resource}")
25
print(f"Description: {operation.display.description}")
26
print("---")
27
"""
28
```
29
30
## Usage Examples
31
32
### Discover Available Functionality
33
34
```python
35
def discover_container_instance_operations(client):
36
"""
37
Discover and categorize all available Container Instance operations.
38
39
Args:
40
client: ContainerInstanceManagementClient instance
41
42
Returns:
43
dict: Categorized operations by resource type
44
"""
45
46
operations = client.operations.list()
47
categorized_operations = {
48
'containerGroups': [],
49
'containers': [],
50
'location': [],
51
'other': []
52
}
53
54
for operation in operations:
55
operation_name = operation.name.lower()
56
57
if 'containergroups' in operation_name:
58
categorized_operations['containerGroups'].append({
59
'name': operation.name,
60
'display_name': operation.display.operation,
61
'description': operation.display.description
62
})
63
elif 'containers' in operation_name and 'containergroups' not in operation_name:
64
categorized_operations['containers'].append({
65
'name': operation.name,
66
'display_name': operation.display.operation,
67
'description': operation.display.description
68
})
69
elif 'location' in operation_name:
70
categorized_operations['location'].append({
71
'name': operation.name,
72
'display_name': operation.display.operation,
73
'description': operation.display.description
74
})
75
else:
76
categorized_operations['other'].append({
77
'name': operation.name,
78
'display_name': operation.display.operation,
79
'description': operation.display.description
80
})
81
82
return categorized_operations
83
84
# Usage
85
operations_by_category = discover_container_instance_operations(client)
86
87
print("Container Group Operations:")
88
for op in operations_by_category['containerGroups']:
89
print(f" - {op['display_name']}: {op['description']}")
90
91
print("\nContainer Operations:")
92
for op in operations_by_category['containers']:
93
print(f" - {op['display_name']}: {op['description']}")
94
95
print("\nLocation Operations:")
96
for op in operations_by_category['location']:
97
print(f" - {op['display_name']}: {op['description']}")
98
```
99
100
### Check Operation Availability
101
102
```python
103
def check_operation_support(client, operation_name):
104
"""
105
Check if a specific operation is supported.
106
107
Args:
108
client: ContainerInstanceManagementClient instance
109
operation_name (str): Operation name to check
110
111
Returns:
112
dict: Operation details if found, None otherwise
113
"""
114
115
operations = client.operations.list()
116
117
for operation in operations:
118
if operation_name.lower() in operation.name.lower():
119
return {
120
'name': operation.name,
121
'display_name': operation.display.operation,
122
'provider': operation.display.provider,
123
'resource': operation.display.resource,
124
'description': operation.display.description,
125
'supported': True
126
}
127
128
return {
129
'name': operation_name,
130
'supported': False,
131
'message': f"Operation '{operation_name}' not found"
132
}
133
134
# Usage examples
135
print("Checking for container group creation support:")
136
create_support = check_operation_support(client, "create")
137
if create_support['supported']:
138
print(f"✅ {create_support['display_name']} is supported")
139
print(f" Description: {create_support['description']}")
140
else:
141
print(f"❌ {create_support['message']}")
142
143
print("\nChecking for log retrieval support:")
144
logs_support = check_operation_support(client, "logs")
145
if logs_support['supported']:
146
print(f"✅ {logs_support['display_name']} is supported")
147
print(f" Description: {logs_support['description']}")
148
else:
149
print(f"❌ {logs_support['message']}")
150
```
151
152
### Generate Operations Documentation
153
154
```python
155
def generate_operations_documentation(client, output_file="operations_doc.md"):
156
"""
157
Generate markdown documentation for all available operations.
158
159
Args:
160
client: ContainerInstanceManagementClient instance
161
output_file (str): Output file path for documentation
162
"""
163
164
operations = client.operations.list()
165
166
# Group operations by resource
167
operations_by_resource = {}
168
for operation in operations:
169
resource = operation.display.resource
170
if resource not in operations_by_resource:
171
operations_by_resource[resource] = []
172
173
operations_by_resource[resource].append(operation)
174
175
# Generate markdown
176
with open(output_file, 'w') as f:
177
f.write("# Azure Container Instance Operations\n\n")
178
f.write("Complete list of available operations for the Microsoft.ContainerInstance resource provider.\n\n")
179
180
for resource, ops in operations_by_resource.items():
181
f.write(f"## {resource}\n\n")
182
183
for op in ops:
184
f.write(f"### {op.display.operation}\n\n")
185
f.write(f"**Operation Name:** `{op.name}`\n\n")
186
f.write(f"**Description:** {op.display.description}\n\n")
187
f.write("---\n\n")
188
189
print(f"Operations documentation written to {output_file}")
190
191
# Usage
192
generate_operations_documentation(client)
193
```
194
195
## Type Definitions
196
197
```python { .api }
198
class Operation:
199
"""
200
Details of a REST API operation, returned from the Resource Provider Operations API.
201
202
Properties:
203
name (str): Operation name: {provider}/{resource}/{operation}
204
is_data_action (bool): Indicates whether the operation is a data operation
205
display (OperationDisplay): Localized display information for this particular operation
206
action_type (str): Enum. Indicates the action type
207
origin (str): The intended executor of the operation
208
"""
209
210
class OperationDisplay:
211
"""
212
Localized display information for operation.
213
214
Properties:
215
provider (str): Service provider: Microsoft.ContainerInstance
216
resource (str): Resource on which the operation is performed
217
operation (str): Type of operation: get, read, delete, etc.
218
description (str): Description of the operation
219
"""
220
```