comparison venv/lib/python2.7/site-packages/boto/beanstalk/layer1.py @ 0:d67268158946 draft

planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
author bcclaywell
date Mon, 12 Oct 2015 17:43:33 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:d67268158946
1 # Copyright (c) 2012 Mitch Garnaat http://garnaat.org/
2 # Copyright (c) 2012 Amazon.com, Inc. or its affiliates.
3 # All Rights Reserved
4 #
5 # Permission is hereby granted, free of charge, to any person obtaining a
6 # copy of this software and associated documentation files (the
7 # "Software"), to deal in the Software without restriction, including
8 # without limitation the rights to use, copy, modify, merge, publish, dis-
9 # tribute, sublicense, and/or sell copies of the Software, and to permit
10 # persons to whom the Software is furnished to do so, subject to the fol-
11 # lowing conditions:
12 #
13 # The above copyright notice and this permission notice shall be included
14 # in all copies or substantial portions of the Software.
15 #
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17 # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
18 # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
19 # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20 # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22 # IN THE SOFTWARE.
23 #
24
25 import boto
26 import boto.jsonresponse
27 from boto.compat import json
28 from boto.regioninfo import RegionInfo
29 from boto.connection import AWSQueryConnection
30
31
32 class Layer1(AWSQueryConnection):
33
34 APIVersion = '2010-12-01'
35 DefaultRegionName = 'us-east-1'
36 DefaultRegionEndpoint = 'elasticbeanstalk.us-east-1.amazonaws.com'
37
38 def __init__(self, aws_access_key_id=None, aws_secret_access_key=None,
39 is_secure=True, port=None,
40 proxy=None, proxy_port=None,
41 proxy_user=None, proxy_pass=None, debug=0,
42 https_connection_factory=None, region=None, path='/',
43 api_version=None, security_token=None, profile_name=None):
44 if not region:
45 region = RegionInfo(self, self.DefaultRegionName,
46 self.DefaultRegionEndpoint)
47 self.region = region
48 super(Layer1, self).__init__(aws_access_key_id,
49 aws_secret_access_key,
50 is_secure, port, proxy, proxy_port,
51 proxy_user, proxy_pass,
52 self.region.endpoint, debug,
53 https_connection_factory, path,
54 security_token, profile_name=profile_name)
55
56 def _required_auth_capability(self):
57 return ['hmac-v4']
58
59 def _encode_bool(self, v):
60 v = bool(v)
61 return {True: "true", False: "false"}[v]
62
63 def _get_response(self, action, params, path='/', verb='GET'):
64 params['ContentType'] = 'JSON'
65 response = self.make_request(action, params, path, verb)
66 body = response.read().decode('utf-8')
67 boto.log.debug(body)
68 if response.status == 200:
69 return json.loads(body)
70 else:
71 raise self.ResponseError(response.status, response.reason, body)
72
73 def check_dns_availability(self, cname_prefix):
74 """Checks if the specified CNAME is available.
75
76 :type cname_prefix: string
77 :param cname_prefix: The prefix used when this CNAME is
78 reserved.
79 """
80 params = {'CNAMEPrefix': cname_prefix}
81 return self._get_response('CheckDNSAvailability', params)
82
83 def create_application(self, application_name, description=None):
84 """
85 Creates an application that has one configuration template
86 named default and no application versions.
87
88 :type application_name: string
89 :param application_name: The name of the application.
90 Constraint: This name must be unique within your account. If the
91 specified name already exists, the action returns an
92 InvalidParameterValue error.
93
94 :type description: string
95 :param description: Describes the application.
96
97 :raises: TooManyApplicationsException
98 """
99 params = {'ApplicationName': application_name}
100 if description:
101 params['Description'] = description
102 return self._get_response('CreateApplication', params)
103
104 def create_application_version(self, application_name, version_label,
105 description=None, s3_bucket=None,
106 s3_key=None, auto_create_application=None):
107 """Creates an application version for the specified application.
108
109 :type application_name: string
110 :param application_name: The name of the application. If no
111 application is found with this name, and AutoCreateApplication is
112 false, returns an InvalidParameterValue error.
113
114 :type version_label: string
115 :param version_label: A label identifying this version. Constraint:
116 Must be unique per application. If an application version already
117 exists with this label for the specified application, AWS Elastic
118 Beanstalk returns an InvalidParameterValue error.
119
120 :type description: string
121 :param description: Describes this version.
122
123 :type s3_bucket: string
124 :param s3_bucket: The Amazon S3 bucket where the data is located.
125
126 :type s3_key: string
127 :param s3_key: The Amazon S3 key where the data is located. Both
128 s3_bucket and s3_key must be specified in order to use a specific
129 source bundle. If both of these values are not specified the
130 sample application will be used.
131
132 :type auto_create_application: boolean
133 :param auto_create_application: Determines how the system behaves if
134 the specified application for this version does not already exist:
135 true: Automatically creates the specified application for this
136 version if it does not already exist. false: Returns an
137 InvalidParameterValue if the specified application for this version
138 does not already exist. Default: false Valid Values: true | false
139
140 :raises: TooManyApplicationsException,
141 TooManyApplicationVersionsException,
142 InsufficientPrivilegesException,
143 S3LocationNotInServiceRegionException
144
145 """
146 params = {'ApplicationName': application_name,
147 'VersionLabel': version_label}
148 if description:
149 params['Description'] = description
150 if s3_bucket and s3_key:
151 params['SourceBundle.S3Bucket'] = s3_bucket
152 params['SourceBundle.S3Key'] = s3_key
153 if auto_create_application:
154 params['AutoCreateApplication'] = self._encode_bool(
155 auto_create_application)
156 return self._get_response('CreateApplicationVersion', params)
157
158 def create_configuration_template(self, application_name, template_name,
159 solution_stack_name=None,
160 source_configuration_application_name=None,
161 source_configuration_template_name=None,
162 environment_id=None, description=None,
163 option_settings=None):
164 """Creates a configuration template.
165
166 Templates are associated with a specific application and are used to
167 deploy different versions of the application with the same
168 configuration settings.
169
170 :type application_name: string
171 :param application_name: The name of the application to associate with
172 this configuration template. If no application is found with this
173 name, AWS Elastic Beanstalk returns an InvalidParameterValue error.
174
175 :type template_name: string
176 :param template_name: The name of the configuration template.
177 Constraint: This name must be unique per application. Default: If
178 a configuration template already exists with this name, AWS Elastic
179 Beanstalk returns an InvalidParameterValue error.
180
181 :type solution_stack_name: string
182 :param solution_stack_name: The name of the solution stack used by this
183 configuration. The solution stack specifies the operating system,
184 architecture, and application server for a configuration template.
185 It determines the set of configuration options as well as the
186 possible and default values. Use ListAvailableSolutionStacks to
187 obtain a list of available solution stacks. Default: If the
188 SolutionStackName is not specified and the source configuration
189 parameter is blank, AWS Elastic Beanstalk uses the default solution
190 stack. If not specified and the source configuration parameter is
191 specified, AWS Elastic Beanstalk uses the same solution stack as
192 the source configuration template.
193
194 :type source_configuration_application_name: string
195 :param source_configuration_application_name: The name of the
196 application associated with the configuration.
197
198 :type source_configuration_template_name: string
199 :param source_configuration_template_name: The name of the
200 configuration template.
201
202 :type environment_id: string
203 :param environment_id: The ID of the environment used with this
204 configuration template.
205
206 :type description: string
207 :param description: Describes this configuration.
208
209 :type option_settings: list
210 :param option_settings: If specified, AWS Elastic Beanstalk sets the
211 specified configuration option to the requested value. The new
212 value overrides the value obtained from the solution stack or the
213 source configuration template.
214
215 :raises: InsufficientPrivilegesException,
216 TooManyConfigurationTemplatesException
217 """
218 params = {'ApplicationName': application_name,
219 'TemplateName': template_name}
220 if solution_stack_name:
221 params['SolutionStackName'] = solution_stack_name
222 if source_configuration_application_name:
223 params['SourceConfiguration.ApplicationName'] = source_configuration_application_name
224 if source_configuration_template_name:
225 params['SourceConfiguration.TemplateName'] = source_configuration_template_name
226 if environment_id:
227 params['EnvironmentId'] = environment_id
228 if description:
229 params['Description'] = description
230 if option_settings:
231 self._build_list_params(params, option_settings,
232 'OptionSettings.member',
233 ('Namespace', 'OptionName', 'Value'))
234 return self._get_response('CreateConfigurationTemplate', params)
235
236 def create_environment(self, application_name, environment_name,
237 version_label=None, template_name=None,
238 solution_stack_name=None, cname_prefix=None,
239 description=None, option_settings=None,
240 options_to_remove=None, tier_name=None,
241 tier_type=None, tier_version='1.0'):
242 """Launches an environment for the application using a configuration.
243
244 :type application_name: string
245 :param application_name: The name of the application that contains the
246 version to be deployed. If no application is found with this name,
247 CreateEnvironment returns an InvalidParameterValue error.
248
249 :type environment_name: string
250 :param environment_name: A unique name for the deployment environment.
251 Used in the application URL. Constraint: Must be from 4 to 23
252 characters in length. The name can contain only letters, numbers,
253 and hyphens. It cannot start or end with a hyphen. This name must
254 be unique in your account. If the specified name already exists,
255 AWS Elastic Beanstalk returns an InvalidParameterValue error.
256 Default: If the CNAME parameter is not specified, the environment
257 name becomes part of the CNAME, and therefore part of the visible
258 URL for your application.
259
260 :type version_label: string
261 :param version_label: The name of the application version to deploy. If
262 the specified application has no associated application versions,
263 AWS Elastic Beanstalk UpdateEnvironment returns an
264 InvalidParameterValue error. Default: If not specified, AWS
265 Elastic Beanstalk attempts to launch the most recently created
266 application version.
267
268 :type template_name: string
269 :param template_name: The name of the configuration template to
270 use in deployment. If no configuration template is found with this
271 name, AWS Elastic Beanstalk returns an InvalidParameterValue error.
272 Condition: You must specify either this parameter or a
273 SolutionStackName, but not both. If you specify both, AWS Elastic
274 Beanstalk returns an InvalidParameterCombination error. If you do
275 not specify either, AWS Elastic Beanstalk returns a
276 MissingRequiredParameter error.
277
278 :type solution_stack_name: string
279 :param solution_stack_name: This is an alternative to specifying a
280 configuration name. If specified, AWS Elastic Beanstalk sets the
281 configuration values to the default values associated with the
282 specified solution stack. Condition: You must specify either this
283 or a TemplateName, but not both. If you specify both, AWS Elastic
284 Beanstalk returns an InvalidParameterCombination error. If you do
285 not specify either, AWS Elastic Beanstalk returns a
286 MissingRequiredParameter error.
287
288 :type cname_prefix: string
289 :param cname_prefix: If specified, the environment attempts to use this
290 value as the prefix for the CNAME. If not specified, the
291 environment uses the environment name.
292
293 :type description: string
294 :param description: Describes this environment.
295
296 :type option_settings: list
297 :param option_settings: If specified, AWS Elastic Beanstalk sets the
298 specified configuration options to the requested value in the
299 configuration set for the new environment. These override the
300 values obtained from the solution stack or the configuration
301 template. Each element in the list is a tuple of (Namespace,
302 OptionName, Value), for example::
303
304 [('aws:autoscaling:launchconfiguration',
305 'Ec2KeyName', 'mykeypair')]
306
307 :type options_to_remove: list
308 :param options_to_remove: A list of custom user-defined configuration
309 options to remove from the configuration set for this new
310 environment.
311
312 :type tier_name: string
313 :param tier_name: The name of the tier. Valid values are
314 "WebServer" and "Worker". Defaults to "WebServer".
315 The ``tier_name`` and a ``tier_type`` parameters are
316 related and the values provided must be valid.
317 The possible combinations are:
318
319 * "WebServer" and "Standard" (the default)
320 * "Worker" and "SQS/HTTP"
321
322 :type tier_type: string
323 :param tier_type: The type of the tier. Valid values are
324 "Standard" if ``tier_name`` is "WebServer" and "SQS/HTTP"
325 if ``tier_name`` is "Worker". Defaults to "Standard".
326
327 :type tier_version: string
328 :type tier_version: The version of the tier. Valid values
329 currently are "1.0". Defaults to "1.0".
330
331 :raises: TooManyEnvironmentsException, InsufficientPrivilegesException
332
333 """
334 params = {'ApplicationName': application_name,
335 'EnvironmentName': environment_name}
336 if version_label:
337 params['VersionLabel'] = version_label
338 if template_name:
339 params['TemplateName'] = template_name
340 if solution_stack_name:
341 params['SolutionStackName'] = solution_stack_name
342 if cname_prefix:
343 params['CNAMEPrefix'] = cname_prefix
344 if description:
345 params['Description'] = description
346 if option_settings:
347 self._build_list_params(params, option_settings,
348 'OptionSettings.member',
349 ('Namespace', 'OptionName', 'Value'))
350 if options_to_remove:
351 self.build_list_params(params, options_to_remove,
352 'OptionsToRemove.member')
353 if tier_name and tier_type and tier_version:
354 params['Tier.Name'] = tier_name
355 params['Tier.Type'] = tier_type
356 params['Tier.Version'] = tier_version
357 return self._get_response('CreateEnvironment', params)
358
359 def create_storage_location(self):
360 """
361 Creates the Amazon S3 storage location for the account. This
362 location is used to store user log files.
363
364 :raises: TooManyBucketsException,
365 S3SubscriptionRequiredException,
366 InsufficientPrivilegesException
367
368 """
369 return self._get_response('CreateStorageLocation', params={})
370
371 def delete_application(self, application_name,
372 terminate_env_by_force=None):
373 """
374 Deletes the specified application along with all associated
375 versions and configurations. The application versions will not
376 be deleted from your Amazon S3 bucket.
377
378 :type application_name: string
379 :param application_name: The name of the application to delete.
380
381 :type terminate_env_by_force: boolean
382 :param terminate_env_by_force: When set to true, running
383 environments will be terminated before deleting the application.
384
385 :raises: OperationInProgressException
386
387 """
388 params = {'ApplicationName': application_name}
389 if terminate_env_by_force:
390 params['TerminateEnvByForce'] = self._encode_bool(
391 terminate_env_by_force)
392 return self._get_response('DeleteApplication', params)
393
394 def delete_application_version(self, application_name, version_label,
395 delete_source_bundle=None):
396 """Deletes the specified version from the specified application.
397
398 :type application_name: string
399 :param application_name: The name of the application to delete
400 releases from.
401
402 :type version_label: string
403 :param version_label: The label of the version to delete.
404
405 :type delete_source_bundle: boolean
406 :param delete_source_bundle: Indicates whether to delete the
407 associated source bundle from Amazon S3. Valid Values: true |
408 false
409
410 :raises: SourceBundleDeletionException,
411 InsufficientPrivilegesException,
412 OperationInProgressException,
413 S3LocationNotInServiceRegionException
414 """
415 params = {'ApplicationName': application_name,
416 'VersionLabel': version_label}
417 if delete_source_bundle:
418 params['DeleteSourceBundle'] = self._encode_bool(
419 delete_source_bundle)
420 return self._get_response('DeleteApplicationVersion', params)
421
422 def delete_configuration_template(self, application_name, template_name):
423 """Deletes the specified configuration template.
424
425 :type application_name: string
426 :param application_name: The name of the application to delete
427 the configuration template from.
428
429 :type template_name: string
430 :param template_name: The name of the configuration template to
431 delete.
432
433 :raises: OperationInProgressException
434
435 """
436 params = {'ApplicationName': application_name,
437 'TemplateName': template_name}
438 return self._get_response('DeleteConfigurationTemplate', params)
439
440 def delete_environment_configuration(self, application_name,
441 environment_name):
442 """
443 Deletes the draft configuration associated with the running
444 environment. Updating a running environment with any
445 configuration changes creates a draft configuration set. You can
446 get the draft configuration using DescribeConfigurationSettings
447 while the update is in progress or if the update fails. The
448 DeploymentStatus for the draft configuration indicates whether
449 the deployment is in process or has failed. The draft
450 configuration remains in existence until it is deleted with this
451 action.
452
453 :type application_name: string
454 :param application_name: The name of the application the
455 environment is associated with.
456
457 :type environment_name: string
458 :param environment_name: The name of the environment to delete
459 the draft configuration from.
460
461 """
462 params = {'ApplicationName': application_name,
463 'EnvironmentName': environment_name}
464 return self._get_response('DeleteEnvironmentConfiguration', params)
465
466 def describe_application_versions(self, application_name=None,
467 version_labels=None):
468 """Returns descriptions for existing application versions.
469
470 :type application_name: string
471 :param application_name: If specified, AWS Elastic Beanstalk restricts
472 the returned descriptions to only include ones that are associated
473 with the specified application.
474
475 :type version_labels: list
476 :param version_labels: If specified, restricts the returned
477 descriptions to only include ones that have the specified version
478 labels.
479
480 """
481 params = {}
482 if application_name:
483 params['ApplicationName'] = application_name
484 if version_labels:
485 self.build_list_params(params, version_labels,
486 'VersionLabels.member')
487 return self._get_response('DescribeApplicationVersions', params)
488
489 def describe_applications(self, application_names=None):
490 """Returns the descriptions of existing applications.
491
492 :type application_names: list
493 :param application_names: If specified, AWS Elastic Beanstalk restricts
494 the returned descriptions to only include those with the specified
495 names.
496
497 """
498 params = {}
499 if application_names:
500 self.build_list_params(params, application_names,
501 'ApplicationNames.member')
502 return self._get_response('DescribeApplications', params)
503
504 def describe_configuration_options(self, application_name=None,
505 template_name=None,
506 environment_name=None,
507 solution_stack_name=None, options=None):
508 """Describes configuration options used in a template or environment.
509
510 Describes the configuration options that are used in a
511 particular configuration template or environment, or that a
512 specified solution stack defines. The description includes the
513 values the options, their default values, and an indication of
514 the required action on a running environment if an option value
515 is changed.
516
517 :type application_name: string
518 :param application_name: The name of the application associated with
519 the configuration template or environment. Only needed if you want
520 to describe the configuration options associated with either the
521 configuration template or environment.
522
523 :type template_name: string
524 :param template_name: The name of the configuration template whose
525 configuration options you want to describe.
526
527 :type environment_name: string
528 :param environment_name: The name of the environment whose
529 configuration options you want to describe.
530
531 :type solution_stack_name: string
532 :param solution_stack_name: The name of the solution stack whose
533 configuration options you want to describe.
534
535 :type options: list
536 :param options: If specified, restricts the descriptions to only
537 the specified options.
538 """
539 params = {}
540 if application_name:
541 params['ApplicationName'] = application_name
542 if template_name:
543 params['TemplateName'] = template_name
544 if environment_name:
545 params['EnvironmentName'] = environment_name
546 if solution_stack_name:
547 params['SolutionStackName'] = solution_stack_name
548 if options:
549 self.build_list_params(params, options, 'Options.member')
550 return self._get_response('DescribeConfigurationOptions', params)
551
552 def describe_configuration_settings(self, application_name,
553 template_name=None,
554 environment_name=None):
555 """
556 Returns a description of the settings for the specified
557 configuration set, that is, either a configuration template or
558 the configuration set associated with a running environment.
559 When describing the settings for the configuration set
560 associated with a running environment, it is possible to receive
561 two sets of setting descriptions. One is the deployed
562 configuration set, and the other is a draft configuration of an
563 environment that is either in the process of deployment or that
564 failed to deploy.
565
566 :type application_name: string
567 :param application_name: The application for the environment or
568 configuration template.
569
570 :type template_name: string
571 :param template_name: The name of the configuration template to
572 describe. Conditional: You must specify either this parameter or
573 an EnvironmentName, but not both. If you specify both, AWS Elastic
574 Beanstalk returns an InvalidParameterCombination error. If you do
575 not specify either, AWS Elastic Beanstalk returns a
576 MissingRequiredParameter error.
577
578 :type environment_name: string
579 :param environment_name: The name of the environment to describe.
580 Condition: You must specify either this or a TemplateName, but not
581 both. If you specify both, AWS Elastic Beanstalk returns an
582 InvalidParameterCombination error. If you do not specify either,
583 AWS Elastic Beanstalk returns MissingRequiredParameter error.
584 """
585 params = {'ApplicationName': application_name}
586 if template_name:
587 params['TemplateName'] = template_name
588 if environment_name:
589 params['EnvironmentName'] = environment_name
590 return self._get_response('DescribeConfigurationSettings', params)
591
592 def describe_environment_resources(self, environment_id=None,
593 environment_name=None):
594 """Returns AWS resources for this environment.
595
596 :type environment_id: string
597 :param environment_id: The ID of the environment to retrieve AWS
598 resource usage data. Condition: You must specify either this or an
599 EnvironmentName, or both. If you do not specify either, AWS Elastic
600 Beanstalk returns MissingRequiredParameter error.
601
602 :type environment_name: string
603 :param environment_name: The name of the environment to retrieve
604 AWS resource usage data. Condition: You must specify either this
605 or an EnvironmentId, or both. If you do not specify either, AWS
606 Elastic Beanstalk returns MissingRequiredParameter error.
607
608 :raises: InsufficientPrivilegesException
609 """
610 params = {}
611 if environment_id:
612 params['EnvironmentId'] = environment_id
613 if environment_name:
614 params['EnvironmentName'] = environment_name
615 return self._get_response('DescribeEnvironmentResources', params)
616
617 def describe_environments(self, application_name=None, version_label=None,
618 environment_ids=None, environment_names=None,
619 include_deleted=None,
620 included_deleted_back_to=None):
621 """Returns descriptions for existing environments.
622
623 :type application_name: string
624 :param application_name: If specified, AWS Elastic Beanstalk restricts
625 the returned descriptions to include only those that are associated
626 with this application.
627
628 :type version_label: string
629 :param version_label: If specified, AWS Elastic Beanstalk restricts the
630 returned descriptions to include only those that are associated
631 with this application version.
632
633 :type environment_ids: list
634 :param environment_ids: If specified, AWS Elastic Beanstalk restricts
635 the returned descriptions to include only those that have the
636 specified IDs.
637
638 :type environment_names: list
639 :param environment_names: If specified, AWS Elastic Beanstalk restricts
640 the returned descriptions to include only those that have the
641 specified names.
642
643 :type include_deleted: boolean
644 :param include_deleted: Indicates whether to include deleted
645 environments: true: Environments that have been deleted after
646 IncludedDeletedBackTo are displayed. false: Do not include deleted
647 environments.
648
649 :type included_deleted_back_to: timestamp
650 :param included_deleted_back_to: If specified when IncludeDeleted is
651 set to true, then environments deleted after this date are
652 displayed.
653 """
654 params = {}
655 if application_name:
656 params['ApplicationName'] = application_name
657 if version_label:
658 params['VersionLabel'] = version_label
659 if environment_ids:
660 self.build_list_params(params, environment_ids,
661 'EnvironmentIds.member')
662 if environment_names:
663 self.build_list_params(params, environment_names,
664 'EnvironmentNames.member')
665 if include_deleted:
666 params['IncludeDeleted'] = self._encode_bool(include_deleted)
667 if included_deleted_back_to:
668 params['IncludedDeletedBackTo'] = included_deleted_back_to
669 return self._get_response('DescribeEnvironments', params)
670
671 def describe_events(self, application_name=None, version_label=None,
672 template_name=None, environment_id=None,
673 environment_name=None, request_id=None, severity=None,
674 start_time=None, end_time=None, max_records=None,
675 next_token=None):
676 """Returns event descriptions matching criteria up to the last 6 weeks.
677
678 :type application_name: string
679 :param application_name: If specified, AWS Elastic Beanstalk restricts
680 the returned descriptions to include only those associated with
681 this application.
682
683 :type version_label: string
684 :param version_label: If specified, AWS Elastic Beanstalk restricts the
685 returned descriptions to those associated with this application
686 version.
687
688 :type template_name: string
689 :param template_name: If specified, AWS Elastic Beanstalk restricts the
690 returned descriptions to those that are associated with this
691 environment configuration.
692
693 :type environment_id: string
694 :param environment_id: If specified, AWS Elastic Beanstalk restricts
695 the returned descriptions to those associated with this
696 environment.
697
698 :type environment_name: string
699 :param environment_name: If specified, AWS Elastic Beanstalk restricts
700 the returned descriptions to those associated with this
701 environment.
702
703 :type request_id: string
704 :param request_id: If specified, AWS Elastic Beanstalk restricts the
705 described events to include only those associated with this request
706 ID.
707
708 :type severity: string
709 :param severity: If specified, limits the events returned from this
710 call to include only those with the specified severity or higher.
711
712 :type start_time: timestamp
713 :param start_time: If specified, AWS Elastic Beanstalk restricts the
714 returned descriptions to those that occur on or after this time.
715
716 :type end_time: timestamp
717 :param end_time: If specified, AWS Elastic Beanstalk restricts the
718 returned descriptions to those that occur up to, but not including,
719 the EndTime.
720
721 :type max_records: integer
722 :param max_records: Specifies the maximum number of events that can be
723 returned, beginning with the most recent event.
724
725 :type next_token: string
726 :param next_token: Pagination token. If specified, the events return
727 the next batch of results.
728 """
729 params = {}
730 if application_name:
731 params['ApplicationName'] = application_name
732 if version_label:
733 params['VersionLabel'] = version_label
734 if template_name:
735 params['TemplateName'] = template_name
736 if environment_id:
737 params['EnvironmentId'] = environment_id
738 if environment_name:
739 params['EnvironmentName'] = environment_name
740 if request_id:
741 params['RequestId'] = request_id
742 if severity:
743 params['Severity'] = severity
744 if start_time:
745 params['StartTime'] = start_time
746 if end_time:
747 params['EndTime'] = end_time
748 if max_records:
749 params['MaxRecords'] = max_records
750 if next_token:
751 params['NextToken'] = next_token
752 return self._get_response('DescribeEvents', params)
753
754 def list_available_solution_stacks(self):
755 """Returns a list of the available solution stack names."""
756 return self._get_response('ListAvailableSolutionStacks', params={})
757
758 def rebuild_environment(self, environment_id=None, environment_name=None):
759 """
760 Deletes and recreates all of the AWS resources (for example:
761 the Auto Scaling group, load balancer, etc.) for a specified
762 environment and forces a restart.
763
764 :type environment_id: string
765 :param environment_id: The ID of the environment to rebuild.
766 Condition: You must specify either this or an EnvironmentName, or
767 both. If you do not specify either, AWS Elastic Beanstalk returns
768 MissingRequiredParameter error.
769
770 :type environment_name: string
771 :param environment_name: The name of the environment to rebuild.
772 Condition: You must specify either this or an EnvironmentId, or
773 both. If you do not specify either, AWS Elastic Beanstalk returns
774 MissingRequiredParameter error.
775
776 :raises: InsufficientPrivilegesException
777 """
778 params = {}
779 if environment_id:
780 params['EnvironmentId'] = environment_id
781 if environment_name:
782 params['EnvironmentName'] = environment_name
783 return self._get_response('RebuildEnvironment', params)
784
785 def request_environment_info(self, info_type='tail', environment_id=None,
786 environment_name=None):
787 """
788 Initiates a request to compile the specified type of
789 information of the deployed environment. Setting the InfoType
790 to tail compiles the last lines from the application server log
791 files of every Amazon EC2 instance in your environment. Use
792 RetrieveEnvironmentInfo to access the compiled information.
793
794 :type info_type: string
795 :param info_type: The type of information to request.
796
797 :type environment_id: string
798 :param environment_id: The ID of the environment of the
799 requested data. If no such environment is found,
800 RequestEnvironmentInfo returns an InvalidParameterValue error.
801 Condition: You must specify either this or an EnvironmentName, or
802 both. If you do not specify either, AWS Elastic Beanstalk returns
803 MissingRequiredParameter error.
804
805 :type environment_name: string
806 :param environment_name: The name of the environment of the
807 requested data. If no such environment is found,
808 RequestEnvironmentInfo returns an InvalidParameterValue error.
809 Condition: You must specify either this or an EnvironmentId, or
810 both. If you do not specify either, AWS Elastic Beanstalk returns
811 MissingRequiredParameter error.
812 """
813 params = {'InfoType': info_type}
814 if environment_id:
815 params['EnvironmentId'] = environment_id
816 if environment_name:
817 params['EnvironmentName'] = environment_name
818 return self._get_response('RequestEnvironmentInfo', params)
819
820 def restart_app_server(self, environment_id=None, environment_name=None):
821 """
822 Causes the environment to restart the application container
823 server running on each Amazon EC2 instance.
824
825 :type environment_id: string
826 :param environment_id: The ID of the environment to restart the server
827 for. Condition: You must specify either this or an
828 EnvironmentName, or both. If you do not specify either, AWS Elastic
829 Beanstalk returns MissingRequiredParameter error.
830
831 :type environment_name: string
832 :param environment_name: The name of the environment to restart the
833 server for. Condition: You must specify either this or an
834 EnvironmentId, or both. If you do not specify either, AWS Elastic
835 Beanstalk returns MissingRequiredParameter error.
836 """
837 params = {}
838 if environment_id:
839 params['EnvironmentId'] = environment_id
840 if environment_name:
841 params['EnvironmentName'] = environment_name
842 return self._get_response('RestartAppServer', params)
843
844 def retrieve_environment_info(self, info_type='tail', environment_id=None,
845 environment_name=None):
846 """
847 Retrieves the compiled information from a RequestEnvironmentInfo
848 request.
849
850 :type info_type: string
851 :param info_type: The type of information to retrieve.
852
853 :type environment_id: string
854 :param environment_id: The ID of the data's environment. If no such
855 environment is found, returns an InvalidParameterValue error.
856 Condition: You must specify either this or an EnvironmentName, or
857 both. If you do not specify either, AWS Elastic Beanstalk returns
858 MissingRequiredParameter error.
859
860 :type environment_name: string
861 :param environment_name: The name of the data's environment. If no such
862 environment is found, returns an InvalidParameterValue error.
863 Condition: You must specify either this or an EnvironmentId, or
864 both. If you do not specify either, AWS Elastic Beanstalk returns
865 MissingRequiredParameter error.
866 """
867 params = {'InfoType': info_type}
868 if environment_id:
869 params['EnvironmentId'] = environment_id
870 if environment_name:
871 params['EnvironmentName'] = environment_name
872 return self._get_response('RetrieveEnvironmentInfo', params)
873
874 def swap_environment_cnames(self, source_environment_id=None,
875 source_environment_name=None,
876 destination_environment_id=None,
877 destination_environment_name=None):
878 """Swaps the CNAMEs of two environments.
879
880 :type source_environment_id: string
881 :param source_environment_id: The ID of the source environment.
882 Condition: You must specify at least the SourceEnvironmentID or the
883 SourceEnvironmentName. You may also specify both. If you specify
884 the SourceEnvironmentId, you must specify the
885 DestinationEnvironmentId.
886
887 :type source_environment_name: string
888 :param source_environment_name: The name of the source environment.
889 Condition: You must specify at least the SourceEnvironmentID or the
890 SourceEnvironmentName. You may also specify both. If you specify
891 the SourceEnvironmentName, you must specify the
892 DestinationEnvironmentName.
893
894 :type destination_environment_id: string
895 :param destination_environment_id: The ID of the destination
896 environment. Condition: You must specify at least the
897 DestinationEnvironmentID or the DestinationEnvironmentName. You may
898 also specify both. You must specify the SourceEnvironmentId with
899 the DestinationEnvironmentId.
900
901 :type destination_environment_name: string
902 :param destination_environment_name: The name of the destination
903 environment. Condition: You must specify at least the
904 DestinationEnvironmentID or the DestinationEnvironmentName. You may
905 also specify both. You must specify the SourceEnvironmentName with
906 the DestinationEnvironmentName.
907 """
908 params = {}
909 if source_environment_id:
910 params['SourceEnvironmentId'] = source_environment_id
911 if source_environment_name:
912 params['SourceEnvironmentName'] = source_environment_name
913 if destination_environment_id:
914 params['DestinationEnvironmentId'] = destination_environment_id
915 if destination_environment_name:
916 params['DestinationEnvironmentName'] = destination_environment_name
917 return self._get_response('SwapEnvironmentCNAMEs', params)
918
919 def terminate_environment(self, environment_id=None, environment_name=None,
920 terminate_resources=None):
921 """Terminates the specified environment.
922
923 :type environment_id: string
924 :param environment_id: The ID of the environment to terminate.
925 Condition: You must specify either this or an EnvironmentName, or
926 both. If you do not specify either, AWS Elastic Beanstalk returns
927 MissingRequiredParameter error.
928
929 :type environment_name: string
930 :param environment_name: The name of the environment to terminate.
931 Condition: You must specify either this or an EnvironmentId, or
932 both. If you do not specify either, AWS Elastic Beanstalk returns
933 MissingRequiredParameter error.
934
935 :type terminate_resources: boolean
936 :param terminate_resources: Indicates whether the associated AWS
937 resources should shut down when the environment is terminated:
938 true: (default) The user AWS resources (for example, the Auto
939 Scaling group, LoadBalancer, etc.) are terminated along with the
940 environment. false: The environment is removed from the AWS
941 Elastic Beanstalk but the AWS resources continue to operate. For
942 more information, see the AWS Elastic Beanstalk User Guide.
943 Default: true Valid Values: true | false
944
945 :raises: InsufficientPrivilegesException
946 """
947 params = {}
948 if environment_id:
949 params['EnvironmentId'] = environment_id
950 if environment_name:
951 params['EnvironmentName'] = environment_name
952 if terminate_resources:
953 params['TerminateResources'] = self._encode_bool(
954 terminate_resources)
955 return self._get_response('TerminateEnvironment', params)
956
957 def update_application(self, application_name, description=None):
958 """
959 Updates the specified application to have the specified
960 properties.
961
962 :type application_name: string
963 :param application_name: The name of the application to update.
964 If no such application is found, UpdateApplication returns an
965 InvalidParameterValue error.
966
967 :type description: string
968 :param description: A new description for the application. Default: If
969 not specified, AWS Elastic Beanstalk does not update the
970 description.
971 """
972 params = {'ApplicationName': application_name}
973 if description:
974 params['Description'] = description
975 return self._get_response('UpdateApplication', params)
976
977 def update_application_version(self, application_name, version_label,
978 description=None):
979 """Updates the application version to have the properties.
980
981 :type application_name: string
982 :param application_name: The name of the application associated with
983 this version. If no application is found with this name,
984 UpdateApplication returns an InvalidParameterValue error.
985
986 :type version_label: string
987 :param version_label: The name of the version to update. If no
988 application version is found with this label, UpdateApplication
989 returns an InvalidParameterValue error.
990
991 :type description: string
992 :param description: A new description for this release.
993 """
994 params = {'ApplicationName': application_name,
995 'VersionLabel': version_label}
996 if description:
997 params['Description'] = description
998 return self._get_response('UpdateApplicationVersion', params)
999
1000 def update_configuration_template(self, application_name, template_name,
1001 description=None, option_settings=None,
1002 options_to_remove=None):
1003 """
1004 Updates the specified configuration template to have the
1005 specified properties or configuration option values.
1006
1007 :type application_name: string
1008 :param application_name: The name of the application associated with
1009 the configuration template to update. If no application is found
1010 with this name, UpdateConfigurationTemplate returns an
1011 InvalidParameterValue error.
1012
1013 :type template_name: string
1014 :param template_name: The name of the configuration template to update.
1015 If no configuration template is found with this name,
1016 UpdateConfigurationTemplate returns an InvalidParameterValue error.
1017
1018 :type description: string
1019 :param description: A new description for the configuration.
1020
1021 :type option_settings: list
1022 :param option_settings: A list of configuration option settings to
1023 update with the new specified option value.
1024
1025 :type options_to_remove: list
1026 :param options_to_remove: A list of configuration options to remove
1027 from the configuration set. Constraint: You can remove only
1028 UserDefined configuration options.
1029
1030 :raises: InsufficientPrivilegesException
1031 """
1032 params = {'ApplicationName': application_name,
1033 'TemplateName': template_name}
1034 if description:
1035 params['Description'] = description
1036 if option_settings:
1037 self._build_list_params(params, option_settings,
1038 'OptionSettings.member',
1039 ('Namespace', 'OptionName', 'Value'))
1040 if options_to_remove:
1041 self.build_list_params(params, options_to_remove,
1042 'OptionsToRemove.member')
1043 return self._get_response('UpdateConfigurationTemplate', params)
1044
1045 def update_environment(self, environment_id=None, environment_name=None,
1046 version_label=None, template_name=None,
1047 description=None, option_settings=None,
1048 options_to_remove=None, tier_name=None,
1049 tier_type=None, tier_version='1.0'):
1050 """
1051 Updates the environment description, deploys a new application
1052 version, updates the configuration settings to an entirely new
1053 configuration template, or updates select configuration option
1054 values in the running environment. Attempting to update both
1055 the release and configuration is not allowed and AWS Elastic
1056 Beanstalk returns an InvalidParameterCombination error. When
1057 updating the configuration settings to a new template or
1058 individual settings, a draft configuration is created and
1059 DescribeConfigurationSettings for this environment returns two
1060 setting descriptions with different DeploymentStatus values.
1061
1062 :type environment_id: string
1063 :param environment_id: The ID of the environment to update. If no
1064 environment with this ID exists, AWS Elastic Beanstalk returns an
1065 InvalidParameterValue error. Condition: You must specify either
1066 this or an EnvironmentName, or both. If you do not specify either,
1067 AWS Elastic Beanstalk returns MissingRequiredParameter error.
1068
1069 :type environment_name: string
1070 :param environment_name: The name of the environment to update. If no
1071 environment with this name exists, AWS Elastic Beanstalk returns an
1072 InvalidParameterValue error. Condition: You must specify either
1073 this or an EnvironmentId, or both. If you do not specify either,
1074 AWS Elastic Beanstalk returns MissingRequiredParameter error.
1075
1076 :type version_label: string
1077 :param version_label: If this parameter is specified, AWS Elastic
1078 Beanstalk deploys the named application version to the environment.
1079 If no such application version is found, returns an
1080 InvalidParameterValue error.
1081
1082 :type template_name: string
1083 :param template_name: If this parameter is specified, AWS Elastic
1084 Beanstalk deploys this configuration template to the environment.
1085 If no such configuration template is found, AWS Elastic Beanstalk
1086 returns an InvalidParameterValue error.
1087
1088 :type description: string
1089 :param description: If this parameter is specified, AWS Elastic
1090 Beanstalk updates the description of this environment.
1091
1092 :type option_settings: list
1093 :param option_settings: If specified, AWS Elastic Beanstalk updates the
1094 configuration set associated with the running environment and sets
1095 the specified configuration options to the requested value.
1096
1097 :type options_to_remove: list
1098 :param options_to_remove: A list of custom user-defined configuration
1099 options to remove from the configuration set for this environment.
1100
1101 :type tier_name: string
1102 :param tier_name: The name of the tier. Valid values are
1103 "WebServer" and "Worker". Defaults to "WebServer".
1104 The ``tier_name`` and a ``tier_type`` parameters are
1105 related and the values provided must be valid.
1106 The possible combinations are:
1107
1108 * "WebServer" and "Standard" (the default)
1109 * "Worker" and "SQS/HTTP"
1110
1111 :type tier_type: string
1112 :param tier_type: The type of the tier. Valid values are
1113 "Standard" if ``tier_name`` is "WebServer" and "SQS/HTTP"
1114 if ``tier_name`` is "Worker". Defaults to "Standard".
1115
1116 :type tier_version: string
1117 :type tier_version: The version of the tier. Valid values
1118 currently are "1.0". Defaults to "1.0".
1119
1120 :raises: InsufficientPrivilegesException
1121 """
1122 params = {}
1123 if environment_id:
1124 params['EnvironmentId'] = environment_id
1125 if environment_name:
1126 params['EnvironmentName'] = environment_name
1127 if version_label:
1128 params['VersionLabel'] = version_label
1129 if template_name:
1130 params['TemplateName'] = template_name
1131 if description:
1132 params['Description'] = description
1133 if option_settings:
1134 self._build_list_params(params, option_settings,
1135 'OptionSettings.member',
1136 ('Namespace', 'OptionName', 'Value'))
1137 if options_to_remove:
1138 self.build_list_params(params, options_to_remove,
1139 'OptionsToRemove.member')
1140 if tier_name and tier_type and tier_version:
1141 params['Tier.Name'] = tier_name
1142 params['Tier.Type'] = tier_type
1143 params['Tier.Version'] = tier_version
1144 return self._get_response('UpdateEnvironment', params)
1145
1146 def validate_configuration_settings(self, application_name,
1147 option_settings, template_name=None,
1148 environment_name=None):
1149 """
1150 Takes a set of configuration settings and either a
1151 configuration template or environment, and determines whether
1152 those values are valid. This action returns a list of messages
1153 indicating any errors or warnings associated with the selection
1154 of option values.
1155
1156 :type application_name: string
1157 :param application_name: The name of the application that the
1158 configuration template or environment belongs to.
1159
1160 :type template_name: string
1161 :param template_name: The name of the configuration template to
1162 validate the settings against. Condition: You cannot specify both
1163 this and an environment name.
1164
1165 :type environment_name: string
1166 :param environment_name: The name of the environment to validate the
1167 settings against. Condition: You cannot specify both this and a
1168 configuration template name.
1169
1170 :type option_settings: list
1171 :param option_settings: A list of the options and desired values to
1172 evaluate.
1173
1174 :raises: InsufficientPrivilegesException
1175 """
1176 params = {'ApplicationName': application_name}
1177 self._build_list_params(params, option_settings,
1178 'OptionSettings.member',
1179 ('Namespace', 'OptionName', 'Value'))
1180 if template_name:
1181 params['TemplateName'] = template_name
1182 if environment_name:
1183 params['EnvironmentName'] = environment_name
1184 return self._get_response('ValidateConfigurationSettings', params)
1185
1186 def _build_list_params(self, params, user_values, prefix, tuple_names):
1187 # For params such as the ConfigurationOptionSettings,
1188 # they can specify a list of tuples where each tuple maps to a specific
1189 # arg. For example:
1190 # user_values = [('foo', 'bar', 'baz']
1191 # prefix=MyOption.member
1192 # tuple_names=('One', 'Two', 'Three')
1193 # would result in:
1194 # MyOption.member.1.One = foo
1195 # MyOption.member.1.Two = bar
1196 # MyOption.member.1.Three = baz
1197 for i, user_value in enumerate(user_values, 1):
1198 current_prefix = '%s.%s' % (prefix, i)
1199 for key, value in zip(tuple_names, user_value):
1200 full_key = '%s.%s' % (current_prefix, key)
1201 params[full_key] = value