Mercurial > repos > shellac > guppy_basecaller
comparison env/lib/python3.7/site-packages/boto/cloudformation/stack.py @ 0:26e78fe6e8c4 draft
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
author | shellac |
---|---|
date | Sat, 02 May 2020 07:14:21 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:26e78fe6e8c4 |
---|---|
1 from datetime import datetime | |
2 | |
3 from boto.resultset import ResultSet | |
4 | |
5 | |
6 class Stack(object): | |
7 def __init__(self, connection=None): | |
8 self.connection = connection | |
9 self.creation_time = None | |
10 self.description = None | |
11 self.disable_rollback = None | |
12 self.notification_arns = [] | |
13 self.outputs = [] | |
14 self.parameters = [] | |
15 self.capabilities = [] | |
16 self.tags = [] | |
17 self.stack_id = None | |
18 self.stack_status = None | |
19 self.stack_status_reason = None | |
20 self.stack_name = None | |
21 self.timeout_in_minutes = None | |
22 | |
23 @property | |
24 def stack_name_reason(self): | |
25 return self.stack_status_reason | |
26 | |
27 @stack_name_reason.setter | |
28 def stack_name_reason(self, value): | |
29 self.stack_status_reason = value | |
30 | |
31 def startElement(self, name, attrs, connection): | |
32 if name == "Parameters": | |
33 self.parameters = ResultSet([('member', Parameter)]) | |
34 return self.parameters | |
35 elif name == "Outputs": | |
36 self.outputs = ResultSet([('member', Output)]) | |
37 return self.outputs | |
38 elif name == "Capabilities": | |
39 self.capabilities = ResultSet([('member', Capability)]) | |
40 return self.capabilities | |
41 elif name == "Tags": | |
42 self.tags = Tag() | |
43 return self.tags | |
44 elif name == 'NotificationARNs': | |
45 self.notification_arns = ResultSet([('member', NotificationARN)]) | |
46 return self.notification_arns | |
47 else: | |
48 return None | |
49 | |
50 def endElement(self, name, value, connection): | |
51 if name == 'CreationTime': | |
52 try: | |
53 self.creation_time = datetime.strptime(value, '%Y-%m-%dT%H:%M:%SZ') | |
54 except ValueError: | |
55 self.creation_time = datetime.strptime(value, '%Y-%m-%dT%H:%M:%S.%fZ') | |
56 elif name == "Description": | |
57 self.description = value | |
58 elif name == "DisableRollback": | |
59 if str(value).lower() == 'true': | |
60 self.disable_rollback = True | |
61 else: | |
62 self.disable_rollback = False | |
63 elif name == 'StackId': | |
64 self.stack_id = value | |
65 elif name == 'StackName': | |
66 self.stack_name = value | |
67 elif name == 'StackStatus': | |
68 self.stack_status = value | |
69 elif name == "StackStatusReason": | |
70 self.stack_status_reason = value | |
71 elif name == "TimeoutInMinutes": | |
72 self.timeout_in_minutes = int(value) | |
73 elif name == "member": | |
74 pass | |
75 else: | |
76 setattr(self, name, value) | |
77 | |
78 def delete(self): | |
79 return self.connection.delete_stack(stack_name_or_id=self.stack_id) | |
80 | |
81 def describe_events(self, next_token=None): | |
82 return self.connection.describe_stack_events( | |
83 stack_name_or_id=self.stack_id, | |
84 next_token=next_token | |
85 ) | |
86 | |
87 def describe_resource(self, logical_resource_id): | |
88 return self.connection.describe_stack_resource( | |
89 stack_name_or_id=self.stack_id, | |
90 logical_resource_id=logical_resource_id | |
91 ) | |
92 | |
93 def describe_resources(self, logical_resource_id=None, | |
94 physical_resource_id=None): | |
95 return self.connection.describe_stack_resources( | |
96 stack_name_or_id=self.stack_id, | |
97 logical_resource_id=logical_resource_id, | |
98 physical_resource_id=physical_resource_id | |
99 ) | |
100 | |
101 def list_resources(self, next_token=None): | |
102 return self.connection.list_stack_resources( | |
103 stack_name_or_id=self.stack_id, | |
104 next_token=next_token | |
105 ) | |
106 | |
107 def update(self): | |
108 rs = self.connection.describe_stacks(self.stack_id) | |
109 if len(rs) == 1 and rs[0].stack_id == self.stack_id: | |
110 self.__dict__.update(rs[0].__dict__) | |
111 else: | |
112 raise ValueError("%s is not a valid Stack ID or Name" % | |
113 self.stack_id) | |
114 | |
115 def get_template(self): | |
116 return self.connection.get_template(stack_name_or_id=self.stack_id) | |
117 | |
118 def get_policy(self): | |
119 """ | |
120 Returns the stack policy for this stack. If it has no policy | |
121 then, a null value is returned. | |
122 """ | |
123 return self.connection.get_stack_policy(self.stack_id) | |
124 | |
125 def set_policy(self, stack_policy_body=None, stack_policy_url=None): | |
126 """ | |
127 Sets a stack policy for this stack. | |
128 | |
129 :type stack_policy_body: string | |
130 :param stack_policy_body: Structure containing the stack policy body. | |
131 (For more information, go to ` Prevent Updates to Stack Resources`_ | |
132 in the AWS CloudFormation User Guide.) | |
133 You must pass `StackPolicyBody` or `StackPolicyURL`. If both are | |
134 passed, only `StackPolicyBody` is used. | |
135 | |
136 :type stack_policy_url: string | |
137 :param stack_policy_url: Location of a file containing the stack | |
138 policy. The URL must point to a policy (max size: 16KB) located in | |
139 an S3 bucket in the same region as the stack. You must pass | |
140 `StackPolicyBody` or `StackPolicyURL`. If both are passed, only | |
141 `StackPolicyBody` is used. | |
142 """ | |
143 return self.connection.set_stack_policy(self.stack_id, | |
144 stack_policy_body=stack_policy_body, | |
145 stack_policy_url=stack_policy_url) | |
146 | |
147 | |
148 class StackSummary(object): | |
149 def __init__(self, connection=None): | |
150 self.connection = connection | |
151 self.stack_id = None | |
152 self.stack_status = None | |
153 self.stack_name = None | |
154 self.creation_time = None | |
155 self.deletion_time = None | |
156 self.template_description = None | |
157 | |
158 def startElement(self, name, attrs, connection): | |
159 return None | |
160 | |
161 def endElement(self, name, value, connection): | |
162 if name == 'StackId': | |
163 self.stack_id = value | |
164 elif name == 'StackStatus': | |
165 self.stack_status = value | |
166 elif name == 'StackName': | |
167 self.stack_name = value | |
168 elif name == 'CreationTime': | |
169 try: | |
170 self.creation_time = datetime.strptime(value, '%Y-%m-%dT%H:%M:%SZ') | |
171 except ValueError: | |
172 self.creation_time = datetime.strptime(value, '%Y-%m-%dT%H:%M:%S.%fZ') | |
173 elif name == "DeletionTime": | |
174 try: | |
175 self.deletion_time = datetime.strptime(value, '%Y-%m-%dT%H:%M:%SZ') | |
176 except ValueError: | |
177 self.deletion_time = datetime.strptime(value, '%Y-%m-%dT%H:%M:%S.%fZ') | |
178 elif name == 'TemplateDescription': | |
179 self.template_description = value | |
180 elif name == "member": | |
181 pass | |
182 else: | |
183 setattr(self, name, value) | |
184 | |
185 | |
186 class Parameter(object): | |
187 def __init__(self, connection=None): | |
188 self.connection = None | |
189 self.key = None | |
190 self.value = None | |
191 | |
192 def startElement(self, name, attrs, connection): | |
193 return None | |
194 | |
195 def endElement(self, name, value, connection): | |
196 if name == "ParameterKey": | |
197 self.key = value | |
198 elif name == "ParameterValue": | |
199 self.value = value | |
200 else: | |
201 setattr(self, name, value) | |
202 | |
203 def __repr__(self): | |
204 return "Parameter:\"%s\"=\"%s\"" % (self.key, self.value) | |
205 | |
206 | |
207 class Output(object): | |
208 def __init__(self, connection=None): | |
209 self.connection = connection | |
210 self.description = None | |
211 self.key = None | |
212 self.value = None | |
213 | |
214 def startElement(self, name, attrs, connection): | |
215 return None | |
216 | |
217 def endElement(self, name, value, connection): | |
218 if name == "Description": | |
219 self.description = value | |
220 elif name == "OutputKey": | |
221 self.key = value | |
222 elif name == "OutputValue": | |
223 self.value = value | |
224 else: | |
225 setattr(self, name, value) | |
226 | |
227 def __repr__(self): | |
228 return "Output:\"%s\"=\"%s\"" % (self.key, self.value) | |
229 | |
230 | |
231 class Capability(object): | |
232 def __init__(self, connection=None): | |
233 self.connection = None | |
234 self.value = None | |
235 | |
236 def startElement(self, name, attrs, connection): | |
237 return None | |
238 | |
239 def endElement(self, name, value, connection): | |
240 self.value = value | |
241 | |
242 def __repr__(self): | |
243 return "Capability:\"%s\"" % (self.value) | |
244 | |
245 | |
246 class Tag(dict): | |
247 | |
248 def __init__(self, connection=None): | |
249 dict.__init__(self) | |
250 self.connection = connection | |
251 self._current_key = None | |
252 self._current_value = None | |
253 | |
254 def startElement(self, name, attrs, connection): | |
255 return None | |
256 | |
257 def endElement(self, name, value, connection): | |
258 if name == "Key": | |
259 self._current_key = value | |
260 elif name == "Value": | |
261 self._current_value = value | |
262 else: | |
263 setattr(self, name, value) | |
264 | |
265 if self._current_key and self._current_value: | |
266 self[self._current_key] = self._current_value | |
267 self._current_key = None | |
268 self._current_value = None | |
269 | |
270 | |
271 class NotificationARN(object): | |
272 def __init__(self, connection=None): | |
273 self.connection = None | |
274 self.value = None | |
275 | |
276 def startElement(self, name, attrs, connection): | |
277 return None | |
278 | |
279 def endElement(self, name, value, connection): | |
280 self.value = value | |
281 | |
282 def __repr__(self): | |
283 return "NotificationARN:\"%s\"" % (self.value) | |
284 | |
285 | |
286 class StackResource(object): | |
287 def __init__(self, connection=None): | |
288 self.connection = connection | |
289 self.description = None | |
290 self.logical_resource_id = None | |
291 self.physical_resource_id = None | |
292 self.resource_status = None | |
293 self.resource_status_reason = None | |
294 self.resource_type = None | |
295 self.stack_id = None | |
296 self.stack_name = None | |
297 self.timestamp = None | |
298 | |
299 def startElement(self, name, attrs, connection): | |
300 return None | |
301 | |
302 def endElement(self, name, value, connection): | |
303 if name == "Description": | |
304 self.description = value | |
305 elif name == "LogicalResourceId": | |
306 self.logical_resource_id = value | |
307 elif name == "PhysicalResourceId": | |
308 self.physical_resource_id = value | |
309 elif name == "ResourceStatus": | |
310 self.resource_status = value | |
311 elif name == "ResourceStatusReason": | |
312 self.resource_status_reason = value | |
313 elif name == "ResourceType": | |
314 self.resource_type = value | |
315 elif name == "StackId": | |
316 self.stack_id = value | |
317 elif name == "StackName": | |
318 self.stack_name = value | |
319 elif name == "Timestamp": | |
320 try: | |
321 self.timestamp = datetime.strptime(value, '%Y-%m-%dT%H:%M:%SZ') | |
322 except ValueError: | |
323 self.timestamp = datetime.strptime(value, '%Y-%m-%dT%H:%M:%S.%fZ') | |
324 else: | |
325 setattr(self, name, value) | |
326 | |
327 def __repr__(self): | |
328 return "StackResource:%s (%s)" % (self.logical_resource_id, | |
329 self.resource_type) | |
330 | |
331 | |
332 class StackResourceSummary(object): | |
333 def __init__(self, connection=None): | |
334 self.connection = connection | |
335 self.last_updated_time = None | |
336 self.logical_resource_id = None | |
337 self.physical_resource_id = None | |
338 self.resource_status = None | |
339 self.resource_status_reason = None | |
340 self.resource_type = None | |
341 | |
342 def startElement(self, name, attrs, connection): | |
343 return None | |
344 | |
345 def endElement(self, name, value, connection): | |
346 if name == "LastUpdatedTime": | |
347 try: | |
348 self.last_updated_time = datetime.strptime( | |
349 value, | |
350 '%Y-%m-%dT%H:%M:%SZ' | |
351 ) | |
352 except ValueError: | |
353 self.last_updated_time = datetime.strptime( | |
354 value, | |
355 '%Y-%m-%dT%H:%M:%S.%fZ' | |
356 ) | |
357 elif name == "LogicalResourceId": | |
358 self.logical_resource_id = value | |
359 elif name == "PhysicalResourceId": | |
360 self.physical_resource_id = value | |
361 elif name == "ResourceStatus": | |
362 self.resource_status = value | |
363 elif name == "ResourceStatusReason": | |
364 self.resource_status_reason = value | |
365 elif name == "ResourceType": | |
366 self.resource_type = value | |
367 else: | |
368 setattr(self, name, value) | |
369 | |
370 def __repr__(self): | |
371 return "StackResourceSummary:%s (%s)" % (self.logical_resource_id, | |
372 self.resource_type) | |
373 | |
374 | |
375 class StackEvent(object): | |
376 valid_states = ("CREATE_IN_PROGRESS", "CREATE_FAILED", "CREATE_COMPLETE", | |
377 "DELETE_IN_PROGRESS", "DELETE_FAILED", "DELETE_COMPLETE") | |
378 def __init__(self, connection=None): | |
379 self.connection = connection | |
380 self.event_id = None | |
381 self.logical_resource_id = None | |
382 self.physical_resource_id = None | |
383 self.resource_properties = None | |
384 self.resource_status = None | |
385 self.resource_status_reason = None | |
386 self.resource_type = None | |
387 self.stack_id = None | |
388 self.stack_name = None | |
389 self.timestamp = None | |
390 | |
391 def startElement(self, name, attrs, connection): | |
392 return None | |
393 | |
394 def endElement(self, name, value, connection): | |
395 if name == "EventId": | |
396 self.event_id = value | |
397 elif name == "LogicalResourceId": | |
398 self.logical_resource_id = value | |
399 elif name == "PhysicalResourceId": | |
400 self.physical_resource_id = value | |
401 elif name == "ResourceProperties": | |
402 self.resource_properties = value | |
403 elif name == "ResourceStatus": | |
404 self.resource_status = value | |
405 elif name == "ResourceStatusReason": | |
406 self.resource_status_reason = value | |
407 elif name == "ResourceType": | |
408 self.resource_type = value | |
409 elif name == "StackId": | |
410 self.stack_id = value | |
411 elif name == "StackName": | |
412 self.stack_name = value | |
413 elif name == "Timestamp": | |
414 try: | |
415 self.timestamp = datetime.strptime(value, '%Y-%m-%dT%H:%M:%SZ') | |
416 except ValueError: | |
417 self.timestamp = datetime.strptime(value, '%Y-%m-%dT%H:%M:%S.%fZ') | |
418 else: | |
419 setattr(self, name, value) | |
420 | |
421 def __repr__(self): | |
422 return "StackEvent %s %s %s" % (self.resource_type, | |
423 self.logical_resource_id, self.resource_status) |