0
# Service Models and Data Types
1
2
Data-driven service models that define AWS service APIs, operations, and data structures. Models automatically update with AWS API changes and provide type definitions for request/response handling.
3
4
## Capabilities
5
6
### Service Model
7
8
Core service model class containing AWS service definitions.
9
10
```python { .api }
11
class ServiceModel:
12
def __init__(self, service_description: dict, service_name: str = None):
13
"""
14
Initialize service model.
15
16
Args:
17
service_description: Service definition dictionary
18
service_name: AWS service name override
19
"""
20
21
@property
22
def service_name(self) -> str:
23
"""AWS service name (e.g., 's3', 'ec2')."""
24
25
@property
26
def service_id(self) -> str:
27
"""AWS service identifier."""
28
29
@property
30
def api_version(self) -> str:
31
"""API version string."""
32
33
@property
34
def protocol(self) -> str:
35
"""Service protocol (e.g., 'rest-xml', 'json')."""
36
37
@property
38
def operation_names(self) -> List[str]:
39
"""List of available operation names."""
40
41
def operation_model(self, operation_name: str) -> OperationModel:
42
"""
43
Get operation model by name.
44
45
Args:
46
operation_name: AWS operation name
47
48
Returns:
49
OperationModel: Operation model object
50
"""
51
```
52
53
### Operation Model
54
55
Model for individual AWS service operations.
56
57
```python { .api }
58
class OperationModel:
59
def __init__(self, operation_model: dict, service_model: ServiceModel):
60
"""
61
Initialize operation model.
62
63
Args:
64
operation_model: Operation definition dictionary
65
service_model: Parent service model
66
"""
67
68
@property
69
def name(self) -> str:
70
"""Operation name."""
71
72
@property
73
def input_shape(self) -> Shape:
74
"""Input parameters shape definition."""
75
76
@property
77
def output_shape(self) -> Shape:
78
"""Output response shape definition."""
79
80
@property
81
def error_shapes(self) -> List[Shape]:
82
"""List of possible error response shapes."""
83
84
@property
85
def http(self) -> dict:
86
"""HTTP method and URI information."""
87
```
88
89
### Shape Classes
90
91
Data shape definitions for request/response structures.
92
93
```python { .api }
94
class Shape:
95
"""Base shape class for all data types."""
96
97
def __init__(self, shape_name: str, type_name: str, shape_model: dict):
98
"""
99
Initialize shape.
100
101
Args:
102
shape_name: Name of the shape
103
type_name: Shape type name
104
shape_model: Shape definition dictionary
105
"""
106
107
@property
108
def name(self) -> str:
109
"""Shape name."""
110
111
@property
112
def type_name(self) -> str:
113
"""Shape type name."""
114
115
class StructureShape(Shape):
116
"""Complex structure with named members."""
117
118
@property
119
def members(self) -> dict:
120
"""Dictionary of member shapes."""
121
122
@property
123
def required_members(self) -> List[str]:
124
"""List of required member names."""
125
126
class ListShape(Shape):
127
"""Array/list shape."""
128
129
@property
130
def member(self) -> Shape:
131
"""Shape of list elements."""
132
133
class MapShape(Shape):
134
"""Dictionary/map shape."""
135
136
@property
137
def key(self) -> Shape:
138
"""Shape of map keys."""
139
140
@property
141
def value(self) -> Shape:
142
"""Shape of map values."""
143
144
class StringShape(Shape):
145
"""String type shape."""
146
147
@property
148
def enum(self) -> List[str]:
149
"""Allowed string values (if enumerated)."""
150
```
151
152
## Usage Examples
153
154
### Service Model Access
155
156
```python
157
from botocore.session import get_session
158
159
session = get_session()
160
service_model = session.get_service_model('s3')
161
162
print(f"Service: {service_model.service_name}")
163
print(f"API Version: {service_model.api_version}")
164
print(f"Operations: {len(service_model.operation_names)}")
165
```
166
167
### Operation Analysis
168
169
```python
170
# Get operation model
171
op_model = service_model.operation_model('GetObject')
172
173
print(f"Operation: {op_model.name}")
174
print(f"HTTP Method: {op_model.http.get('method')}")
175
print(f"URI: {op_model.http.get('requestUri')}")
176
177
# Analyze input parameters
178
input_shape = op_model.input_shape
179
if input_shape:
180
print(f"Required params: {input_shape.required_members}")
181
for member_name, member_shape in input_shape.members.items():
182
print(f" {member_name}: {member_shape.type_name}")
183
```