├── .gitignore ├── LICENSE ├── MANIFEST.in ├── NOTICE.txt ├── README.md ├── aws ├── __init__.py └── cfn │ ├── __init__.py │ └── bridge │ ├── __init__.py │ ├── config.py │ ├── processes.py │ ├── resources.py │ ├── runner.py │ ├── util.py │ └── vendored │ ├── __init__.py │ └── botocore │ ├── __init__.py │ ├── auth.py │ ├── awsrequest.py │ ├── client.py │ ├── compat.py │ ├── config.py │ ├── credentials.py │ ├── data │ └── aws │ │ ├── _endpoints.json │ │ ├── _retry.json │ │ ├── autoscaling │ │ ├── 2011-01-01.api.json │ │ └── 2011-01-01.paginators.json │ │ ├── cloudformation │ │ ├── 2010-05-15.api.json │ │ └── 2010-05-15.paginators.json │ │ ├── cloudfront │ │ ├── 2014-05-31.api.json │ │ ├── 2014-05-31.paginators.json │ │ ├── 2014-05-31.waiters.json │ │ ├── 2014-10-21.api.json │ │ ├── 2014-10-21.paginators.json │ │ └── 2014-10-21.waiters.json │ │ ├── cloudsearch │ │ └── 2013-01-01.api.json │ │ ├── cloudsearchdomain │ │ └── 2013-01-01.api.json │ │ ├── cloudtrail │ │ └── 2013-11-01.api.json │ │ ├── cloudwatch │ │ ├── 2010-08-01.api.json │ │ └── 2010-08-01.paginators.json │ │ ├── codedeploy │ │ └── 2014-10-06.api.json │ │ ├── cognito-identity │ │ └── 2014-06-30.api.json │ │ ├── cognito-sync │ │ └── 2014-06-30.api.json │ │ ├── config │ │ └── 2014-11-12.api.json │ │ ├── datapipeline │ │ ├── 2012-10-29.api.json │ │ └── 2012-10-29.paginators.json │ │ ├── directconnect │ │ └── 2012-10-25.api.json │ │ ├── dynamodb │ │ ├── 2012-08-10.api.json │ │ ├── 2012-08-10.paginators.json │ │ └── 2012-08-10.waiters.json │ │ ├── ec2 │ │ ├── 2014-09-01.api.json │ │ ├── 2014-09-01.paginators.json │ │ ├── 2014-09-01.waiters.json │ │ ├── 2014-10-01.api.json │ │ ├── 2014-10-01.paginators.json │ │ └── 2014-10-01.waiters.json │ │ ├── elasticache │ │ ├── 2014-09-30.api.json │ │ └── 2014-09-30.paginators.json │ │ ├── elasticbeanstalk │ │ ├── 2010-12-01.api.json │ │ └── 2010-12-01.paginators.json │ │ ├── elastictranscoder │ │ ├── 2012-09-25.api.json │ │ ├── 2012-09-25.paginators.json │ │ └── 2012-09-25.waiters.json │ │ ├── elb │ │ ├── 2012-06-01.api.json │ │ └── 2012-06-01.paginators.json │ │ ├── emr │ │ ├── 2009-03-31.api.json │ │ ├── 2009-03-31.paginators.json │ │ └── 2009-03-31.waiters.json │ │ ├── iam │ │ ├── 2010-05-08.api.json │ │ └── 2010-05-08.paginators.json │ │ ├── importexport │ │ ├── 2010-06-01.api.json │ │ └── 2010-06-01.paginators.json │ │ ├── kinesis │ │ ├── 2013-12-02.api.json │ │ └── 2013-12-02.paginators.json │ │ ├── kms │ │ └── 2014-11-01.api.json │ │ ├── lambda │ │ └── 2014-11-11.api.json │ │ ├── logs │ │ └── 2014-03-28.api.json │ │ ├── opsworks │ │ └── 2013-02-18.api.json │ │ ├── rds │ │ ├── 2014-09-01.api.json │ │ ├── 2014-09-01.paginators.json │ │ └── 2014-09-01.waiters.json │ │ ├── redshift │ │ ├── 2012-12-01.api.json │ │ ├── 2012-12-01.paginators.json │ │ └── 2012-12-01.waiters.json │ │ ├── route53 │ │ ├── 2013-04-01.api.json │ │ └── 2013-04-01.paginators.json │ │ ├── route53domains │ │ └── 2014-05-15.api.json │ │ ├── s3 │ │ ├── 2006-03-01.api.json │ │ ├── 2006-03-01.paginators.json │ │ └── 2006-03-01.waiters.json │ │ ├── sdb │ │ ├── 2009-04-15.api.json │ │ └── 2009-04-15.paginators.json │ │ ├── ses │ │ ├── 2010-12-01.api.json │ │ ├── 2010-12-01.paginators.json │ │ └── 2010-12-01.waiters.json │ │ ├── sns │ │ ├── 2010-03-31.api.json │ │ └── 2010-03-31.paginators.json │ │ ├── sqs │ │ └── 2012-11-05.api.json │ │ ├── storagegateway │ │ ├── 2013-06-30.api.json │ │ └── 2013-06-30.paginators.json │ │ ├── sts │ │ └── 2011-06-15.api.json │ │ ├── support │ │ ├── 2013-04-15.api.json │ │ └── 2013-04-15.paginators.json │ │ └── swf │ │ ├── 2012-01-25.api.json │ │ └── 2012-01-25.paginators.json │ ├── endpoint.py │ ├── exceptions.py │ ├── handlers.py │ ├── hooks.py │ ├── loaders.py │ ├── model.py │ ├── operation.py │ ├── paginate.py │ ├── parsers.py │ ├── provider.py │ ├── regions.py │ ├── response.py │ ├── retryhandler.py │ ├── serialize.py │ ├── service.py │ ├── session.py │ ├── translate.py │ ├── utils.py │ ├── validate.py │ ├── vendored │ ├── __init__.py │ └── requests │ │ ├── __init__.py │ │ ├── adapters.py │ │ ├── api.py │ │ ├── auth.py │ │ ├── cacert.pem │ │ ├── certs.py │ │ ├── compat.py │ │ ├── cookies.py │ │ ├── exceptions.py │ │ ├── hooks.py │ │ ├── models.py │ │ ├── packages │ │ ├── __init__.py │ │ ├── charade │ │ │ ├── __init__.py │ │ │ ├── __main__.py │ │ │ ├── big5freq.py │ │ │ ├── big5prober.py │ │ │ ├── chardistribution.py │ │ │ ├── charsetgroupprober.py │ │ │ ├── charsetprober.py │ │ │ ├── codingstatemachine.py │ │ │ ├── compat.py │ │ │ ├── constants.py │ │ │ ├── cp949prober.py │ │ │ ├── escprober.py │ │ │ ├── escsm.py │ │ │ ├── eucjpprober.py │ │ │ ├── euckrfreq.py │ │ │ ├── euckrprober.py │ │ │ ├── euctwfreq.py │ │ │ ├── euctwprober.py │ │ │ ├── gb2312freq.py │ │ │ ├── gb2312prober.py │ │ │ ├── hebrewprober.py │ │ │ ├── jisfreq.py │ │ │ ├── jpcntx.py │ │ │ ├── langbulgarianmodel.py │ │ │ ├── langcyrillicmodel.py │ │ │ ├── langgreekmodel.py │ │ │ ├── langhebrewmodel.py │ │ │ ├── langhungarianmodel.py │ │ │ ├── langthaimodel.py │ │ │ ├── latin1prober.py │ │ │ ├── mbcharsetprober.py │ │ │ ├── mbcsgroupprober.py │ │ │ ├── mbcssm.py │ │ │ ├── sbcharsetprober.py │ │ │ ├── sbcsgroupprober.py │ │ │ ├── sjisprober.py │ │ │ ├── universaldetector.py │ │ │ └── utf8prober.py │ │ └── urllib3 │ │ │ ├── __init__.py │ │ │ ├── _collections.py │ │ │ ├── connection.py │ │ │ ├── connectionpool.py │ │ │ ├── contrib │ │ │ ├── __init__.py │ │ │ ├── ntlmpool.py │ │ │ └── pyopenssl.py │ │ │ ├── exceptions.py │ │ │ ├── fields.py │ │ │ ├── filepost.py │ │ │ ├── packages │ │ │ ├── __init__.py │ │ │ ├── ordered_dict.py │ │ │ ├── six.py │ │ │ └── ssl_match_hostname │ │ │ │ └── __init__.py │ │ │ ├── poolmanager.py │ │ │ ├── request.py │ │ │ ├── response.py │ │ │ └── util.py │ │ ├── sessions.py │ │ ├── status_codes.py │ │ ├── structures.py │ │ └── utils.py │ └── waiter.py ├── bin └── cfn-resource-bridge ├── init ├── redhat │ └── cfn-resource-bridge └── ubuntu │ └── cfn-resource-bridge ├── rpm_support ├── install.sh ├── postinstall.sh ├── postun.sh ├── prep.sh └── preun.sh ├── setup.py └── tests ├── __init__.py └── unit ├── __init__.py └── test_custom_resources.py /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | *.pyc 3 | MANIFEST 4 | aws-cfn-resource-bridge-*.tar.gz 5 | dist/ 6 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include LICENSE 2 | include NOTICE.txt 3 | include MANIFEST.in 4 | include init/redhat/cfn-resource-bridge 5 | include init/ubuntu/cfn-resource-bridge 6 | include README.md 7 | include aws/cfn/bridge/vendored/botocore/vendored/requests/cacert.pem 8 | recursive-include aws/cfn/bridge/vendored/botocore/data *.json 9 | -------------------------------------------------------------------------------- /NOTICE.txt: -------------------------------------------------------------------------------- 1 | aws-cfn-resource-bridge 2 | Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Archived 2 | ======== 3 | 4 | This project has been archived. Please use CloudFormation’s native support for Custom Resources as documented at https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-custom-resources.html. 5 | 6 | --- 7 | 8 | aws-cfn-resource-bridge 9 | ======================= 10 | 11 | A custom resource framework for AWS CloudFormation 12 | 13 | Installation 14 | ------------ 15 | Clone the repo and run the ```setup.py``` file in the root: 16 | 17 | ``` 18 | python setup.py install 19 | ``` 20 | 21 | You can also use the file to build an RPM: 22 | 23 | ``` 24 | python setup.py bdist_rpm 25 | ``` 26 | 27 | As well as ```python```, the resulting RPM will also depend on ```python-argparse```, ```python-botocore``` and ```python-daemon```, packaged as RPMs. 28 | 29 | Usage 30 | ----- 31 | The options for the ```cfn-resource-bridge``` script are shown below. The ```CONFIG_PATH``` needs to contain a file named ```cfn-resource-bridge.conf``` with the details of the incoming custom resources and commands to run. 32 | 33 | ``` 34 | usage: cfn-resource-bridge [-h] [-c CONFIG_PATH] [--no-daemon] [-v] 35 | [-t THREADS] 36 | 37 | optional arguments: 38 | -h, --help show this help message and exit 39 | -c CONFIG_PATH, --config CONFIG_PATH 40 | The configuration directory (default: /etc/cfn) 41 | --no-daemon Do not daemonize 42 | -v, --verbose Enables verbose logging 43 | -t THREADS, --threads THREADS 44 | Configure the number of threads to use 45 | ``` 46 | 47 | Example config file: 48 | 49 | ``` 50 | [eip-lookup] 51 | resource_type=Custom::EipLookup 52 | queue_url=https://your-sqs-queue-url-that-is-subscribed-to-the-sns-topic-in-the-service-token 53 | timeout=60 54 | default_action=/home/ec2-user/lookup-eip.py 55 | ``` 56 | 57 | The config file ```cfn-resource-bridge.conf``` can contain multiple sections and each section can contain the following options: 58 | 59 | - ```queue_url``` - the URL of the queue to pull messages from. 60 | - ```default_action``` - the default action to perform when a message is received. 61 | - ```create_action``` - the action to perform when a ```Create``` message is received. 62 | - ```delete_action``` - the action to perform when a ```Delete``` message is received. 63 | - ```update_action``` - the action to perform when a ```Update``` message is received. 64 | - ```timeout``` - the default timeout for messages taken from the queue. 65 | - ```create_timeout``` - the message timeout for create actions. 66 | - ```delete_timeout``` - the message timeout for delete actions. 67 | - ```update_timeout``` - the message timeout for update actions. 68 | - ```flatten``` - flatten resource properties in environment variables (true by default). 69 | - ```service_token``` - optional service token for the event. 70 | - ```resource_type``` - the custom resource type. 71 | - ```region``` - the AWS region - only required if it can't be determined from the queue URL. 72 | 73 | Contributing 74 | ------------- 75 | 1. Fork it 76 | 2. Create your feature branch (`git checkout -b my-new-feature`) 77 | 3. Commit your changes (`git commit -am 'Add some feature'`) 78 | 4. Push to the branch (`git push origin my-new-feature`) 79 | 5. Create new Pull Request 80 | -------------------------------------------------------------------------------- /aws/__init__.py: -------------------------------------------------------------------------------- 1 | #============================================================================== 2 | # Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | #============================================================================== 16 | __author__ = 'aws' 17 | -------------------------------------------------------------------------------- /aws/cfn/__init__.py: -------------------------------------------------------------------------------- 1 | #============================================================================== 2 | # Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | #============================================================================== 16 | __author__ = 'aws' 17 | -------------------------------------------------------------------------------- /aws/cfn/bridge/__init__.py: -------------------------------------------------------------------------------- 1 | #============================================================================== 2 | # Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | #============================================================================== 16 | __author__ = 'aws' 17 | __version__ = '0.2' 18 | 19 | import logging.config 20 | import os.path 21 | import sys 22 | import StringIO 23 | 24 | try: 25 | from logging import NullHandler 26 | except ImportError: 27 | class NullHandler(logging.Handler): 28 | def emit(self, record): 29 | pass 30 | 31 | _config = """[loggers] 32 | keys=root,cfnresourcebridge 33 | [handlers] 34 | keys=%(all_handlers)s 35 | [formatters] 36 | keys=amzn 37 | [logger_root] 38 | level=NOTSET 39 | handlers=%(root_handler)s 40 | [logger_cfnresourcebridge] 41 | level=NOTSET 42 | handlers=%(root_handler)s 43 | qualname=cfn.resourcebridge 44 | propagate=0 45 | [logger_wire] 46 | level=NOTSET 47 | handlers=%(wire_handler)s 48 | qualname=wire 49 | propagate=0 50 | [handler_default] 51 | class=handlers.RotatingFileHandler 52 | level=%(conf_level)s 53 | formatter=amzn 54 | args=('%(conf_file)s', 'a', 5242880, 5, 'UTF-8') 55 | [handler_wire] 56 | class=handlers.RotatingFileHandler 57 | level=DEBUG 58 | formatter=amzn 59 | args=('%(wire_file)s', 'a', 5242880, 5, 'UTF-8') 60 | [handler_tostderr] 61 | class=StreamHandler 62 | level=%(conf_level)s 63 | formatter=amzn 64 | args=(sys.stderr,) 65 | [formatter_amzn] 66 | format=%(asctime)s [%(levelname)s] %(message)s 67 | datefmt= 68 | class=logging.Formatter 69 | """ 70 | 71 | 72 | def _get_log_file(filename): 73 | if os.name == 'nt': 74 | logdir = os.path.expandvars(r'${SystemDrive}\cfn\log') 75 | if not os.path.exists(logdir): 76 | os.makedirs(logdir) 77 | return logdir + os.path.sep + filename 78 | 79 | return '/var/log/%s' % filename 80 | 81 | 82 | def configure_logging(level='INFO', quiet=False, filename='cfn-resource-bridge.log', log_dir=None, wire_log=True): 83 | if not log_dir: 84 | output_file = _get_log_file(filename) 85 | wire_file = _get_log_file('cfn-resource-bridge-wire.log') if wire_log else None 86 | else: 87 | output_file = os.path.join(log_dir, filename) 88 | wire_file = os.path.join(log_dir, 'cfn-resource-bridge-wire.log') if wire_log else None 89 | 90 | config = {'conf_level': level, 91 | 'all_handlers': 'default' + (',wire' if wire_log else ''), 92 | 'root_handler': 'default', 93 | 'wire_handler': 'wire' if wire_log else None, 94 | 'conf_file': output_file} 95 | 96 | if wire_file: 97 | config['wire_file'] = wire_file 98 | 99 | try: 100 | logging.config.fileConfig(StringIO.StringIO(_config), config) 101 | if not wire_log: 102 | logging.getLogger('wire').addHandler(NullHandler()) 103 | except IOError: 104 | config['all_handlers'] = 'tostderr' 105 | config['root_handler'] = 'tostderr' 106 | config['wire_handler'] = None 107 | if not quiet: 108 | print >> sys.stderr, "Could not open %s for logging. Using stderr instead." % output_file 109 | logging.config.fileConfig(StringIO.StringIO(_config), config) 110 | logging.getLogger('wire').addHandler(NullHandler()) 111 | 112 | configure_logging(quiet=True, wire_log=True) 113 | -------------------------------------------------------------------------------- /aws/cfn/bridge/config.py: -------------------------------------------------------------------------------- 1 | #============================================================================== 2 | # Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | #============================================================================== 16 | import os 17 | import ConfigParser 18 | import logging 19 | 20 | from .resources import CustomResource 21 | 22 | # Construct a logger to write messages about bridges 23 | log = logging.getLogger("cfn.resourcebridge") 24 | 25 | 26 | def _parse_config(config_file): 27 | """Parses the provided configuration; returns list of sections 28 | 29 | When provided with a valid configuration file, will load all of the sections and return a list of 30 | CustomResources that match the provided configuration. It is assumed the file was already checked 31 | for existence before being passed in. 32 | """ 33 | config = ConfigParser.SafeConfigParser() 34 | config.read(config_file) 35 | 36 | resources = [] 37 | for resource_name in config.sections(): 38 | # Convert configuration options into dictionary (lowercasing all keys) 39 | options = dict((i[0].lower(), i[1]) for i in config.items(resource_name)) 40 | 41 | # Construct a new CustomResource with the provided configuration 42 | resources.append(CustomResource(resource_name, config_file, options)) 43 | 44 | return resources 45 | 46 | 47 | def _parse_configurations(config_files): 48 | """Parses the provided configurations; returns a list of CustomResources 49 | 50 | Iterates over the list of configuration files and creates a list of CustomResources matching 51 | the sections in the configurations. It is assumed the files were already checked for existence. 52 | """ 53 | resources = [] 54 | # Iterate through the config files and try to parse them 55 | for bridge_file in config_files: 56 | # Attempt to parse the configuration 57 | resources += _parse_config(bridge_file) 58 | 59 | return resources 60 | 61 | 62 | def load_resources_from_configuration(config_dir): 63 | """Locates and parses configuration files 64 | 65 | Given a configuration directory, reads in the cfn-resource-bridge.conf file 66 | and any configurations under the bridge.d/ directory. It requires at least 67 | one configuration file to exist. 68 | """ 69 | config_file = os.path.join(config_dir, 'cfn-resource-bridge.conf') 70 | bridge_files = [] 71 | 72 | # Add the default configuration file if it exists 73 | if os.path.isfile(config_file): 74 | bridge_files.append(config_file) 75 | 76 | # Add any bridge hook files, if they exist 77 | bridges_dir = os.path.join(config_dir, 'bridge.d') 78 | if os.path.isdir(bridges_dir): 79 | for hook_file in os.listdir(bridges_dir): 80 | if os.path.isfile(os.path.join(bridges_dir, hook_file)) and hook_file.endswith('.conf'): 81 | bridge_files.append(os.path.join(bridges_dir, hook_file)) 82 | 83 | # If we can't find any bridge files, error out. 84 | if not bridge_files: 85 | raise ValueError(u"Could not find default configuration file, %s, or additional" 86 | u" configurations in the %s directory" 87 | % (config_file, bridges_dir)) 88 | 89 | # Load our configurations and get the custom resource definitions 90 | resources = _parse_configurations(bridge_files) 91 | 92 | # Fail if we have not found any custom resources. 93 | if not resources: 94 | raise ValueError(u"No resources were defined in (%s)" % bridge_files) 95 | 96 | return resources -------------------------------------------------------------------------------- /aws/cfn/bridge/processes.py: -------------------------------------------------------------------------------- 1 | #============================================================================== 2 | # Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | #============================================================================== 16 | import subprocess 17 | import os 18 | 19 | 20 | class ProcessResult(object): 21 | """ 22 | Return object for ProcessHelper 23 | 24 | """ 25 | def __init__(self, returncode, stdout, stderr): 26 | self._returncode = returncode 27 | self._stdout = stdout if not stdout else stdout.decode('utf-8') 28 | self._stderr = stderr if not stderr else stderr.decode('utf-8') 29 | 30 | @property 31 | def returncode(self): 32 | return self._returncode 33 | 34 | @property 35 | def stdout(self): 36 | return self._stdout 37 | 38 | @property 39 | def stderr(self): 40 | return self._stderr 41 | 42 | 43 | class ProcessHelper(object): 44 | """ 45 | Helper to simplify command line execution 46 | 47 | """ 48 | def __init__(self, cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=None, cwd=None): 49 | self._cmd = cmd 50 | self._stdout = stdout 51 | self._stderr = stderr 52 | if not env: 53 | self._env = None 54 | elif os.name == 'nt': # stringify the environment in Windows, which cannot handle unicodes 55 | # Windows requires inheriting some of the parent process' environment, so just take them all. 56 | self._env = dict(((str(k), str(v)) for k, v in os.environ.iteritems())) 57 | self._env.update(dict(((str(k), str(v)) for k, v in env.iteritems()))) 58 | else: 59 | self._env = dict(os.environ.copy()) 60 | self._env.update(dict(env)) 61 | 62 | self._cwd = cwd 63 | 64 | def call(self): 65 | """ 66 | Calls the command, returning a tuple of (returncode, stdout, stderr) 67 | """ 68 | 69 | process = subprocess.Popen(self._cmd, stdout=self._stdout, stderr=self._stderr, 70 | shell=isinstance(self._cmd, basestring), env=self._env, cwd=self._cwd) 71 | return_data = process.communicate() 72 | 73 | return ProcessResult(process.returncode, return_data[0], return_data[1]) 74 | -------------------------------------------------------------------------------- /aws/cfn/bridge/util.py: -------------------------------------------------------------------------------- 1 | #============================================================================== 2 | # Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | #============================================================================== 16 | from .vendored.botocore.vendored.requests.exceptions import ConnectionError, HTTPError, Timeout, SSLError 17 | import logging 18 | import random 19 | import time 20 | 21 | log = logging.getLogger("cfn.resourcebridge") 22 | wire_log = logging.getLogger("wire") 23 | 24 | 25 | class RemoteError(IOError): 26 | retry_modes = frozenset(['TERMINAL', 'RETRIABLE', 'RETRIABLE_FOREVER']) 27 | 28 | def __init__(self, code, msg, retry_mode='RETRIABLE'): 29 | super(RemoteError, self).__init__(code, msg) 30 | if not retry_mode in RemoteError.retry_modes: 31 | raise ValueError("Invalid retry mode: %s" % retry_mode) 32 | self.retry_mode = retry_mode 33 | 34 | 35 | def _extract_http_error(resp): 36 | if resp.status_code == 503: 37 | retry_mode = 'RETRIABLE_FOREVER' 38 | elif resp.status_code < 500 and resp.status_code not in (404, 408): 39 | retry_mode = 'TERMINAL' 40 | else: 41 | retry_mode = 'RETRIABLE' 42 | 43 | return RemoteError(resp.status_code, u"HTTP Error %s : %s" % (resp.status_code, resp.text), retry_mode) 44 | 45 | 46 | def exponential_backoff(max_tries, max_sleep=20): 47 | """ 48 | Returns a series of floating point numbers between 0 and min(max_sleep, 2^i-1) for i in 0 to max_tries 49 | """ 50 | return [random.random() * min(max_sleep, (2 ** i - 1)) for i in range(0, max_tries)] 51 | 52 | 53 | def extend_backoff(durations, max_sleep=20): 54 | """ 55 | Adds another exponential delay time to a list of delay times 56 | """ 57 | durations.append(random.random() * min(max_sleep, (2 ** len(durations) - 1))) 58 | 59 | 60 | def retry_on_failure(max_tries=5, http_error_extractor=_extract_http_error): 61 | def _decorate(f): 62 | def _retry(*args, **kwargs): 63 | durations = exponential_backoff(max_tries) 64 | for i in durations: 65 | if i > 0: 66 | log.debug(u"Sleeping for %f seconds before retrying", i) 67 | time.sleep(i) 68 | 69 | try: 70 | return f(*args, **kwargs) 71 | except SSLError, e: 72 | log.exception(u"SSLError") 73 | raise RemoteError(None, str(e), retry_mode='TERMINAL') 74 | except ConnectionError, e: 75 | log.exception(u"ConnectionError") 76 | last_error = RemoteError(None, str(e)) 77 | except HTTPError, e: 78 | last_error = http_error_extractor(e.response) 79 | if last_error.retry_mode == 'TERMINAL': 80 | raise last_error 81 | elif last_error.retry_mode == 'RETRIABLE_FOREVER': 82 | extend_backoff(durations) 83 | 84 | log.exception(last_error.strerror) 85 | except Timeout, e: 86 | log.exception(u"Timeout") 87 | last_error = RemoteError(None, str(e)) 88 | else: 89 | raise last_error 90 | return _retry 91 | return _decorate 92 | -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/__init__.py: -------------------------------------------------------------------------------- 1 | #============================================================================== 2 | # Copyright 2014 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | #============================================================================== 16 | __author__ = 'aws' -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/botocore/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2012-2013 Mitch Garnaat http://garnaat.org/ 2 | # Copyright 2012-2014 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You 5 | # may not use this file except in compliance with the License. A copy of 6 | # the License is located at 7 | # 8 | # http://aws.amazon.com/apache2.0/ 9 | # 10 | # or in the "license" file accompanying this file. This file is 11 | # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 12 | # ANY KIND, either express or implied. See the License for the specific 13 | # language governing permissions and limitations under the License. 14 | 15 | import os 16 | import re 17 | import logging 18 | 19 | __version__ = '0.73.0' 20 | 21 | 22 | class NullHandler(logging.Handler): 23 | def emit(self, record): 24 | pass 25 | 26 | # Configure default logger to do nothing 27 | log = logging.getLogger('botocore') 28 | log.addHandler(NullHandler()) 29 | 30 | 31 | _first_cap_regex = re.compile('(.)([A-Z][a-z]+)') 32 | _number_cap_regex = re.compile('([a-z])([0-9]+)') 33 | _end_cap_regex = re.compile('([a-z0-9])([A-Z])') 34 | # Prepopulate the cache with special cases that don't match 35 | # our regular transformation. 36 | _xform_cache = { 37 | ('SwapEnvironmentCNAMEs', '_'): 'swap_environment_cnames', 38 | ('SwapEnvironmentCNAMEs', '-'): 'swap-environment-cnames', 39 | ('CreateCachediSCSIVolume', '_'): 'create_cached_iscsi_volume', 40 | ('CreateCachediSCSIVolume', '-'): 'create-cached-iscsi-volume', 41 | ('DescribeCachediSCSIVolumes', '_'): 'describe_cached_iscsi_volumes', 42 | ('DescribeCachediSCSIVolumes', '-'): 'describe-cached-iscsi-volumes', 43 | ('DescribeStorediSCSIVolumes', '_'): 'describe_stored_iscsi_volumes', 44 | ('DescribeStorediSCSIVolumes', '-'): 'describe-stored-iscsi-volumes', 45 | ('CreateStorediSCSIVolume', '_'): 'create_stored_iscsi_volume', 46 | ('CreateStorediSCSIVolume', '-'): 'create-stored-iscsi-volume', 47 | ('NotificationARNs', '_'): 'notification_arns', 48 | ('NotificationARNs', '-'): 'notification-arns', 49 | } 50 | ScalarTypes = ('string', 'integer', 'boolean', 'timestamp', 'float', 'double') 51 | 52 | BOTOCORE_ROOT = os.path.dirname(os.path.abspath(__file__)) 53 | 54 | 55 | def xform_name(name, sep='_', _xform_cache=_xform_cache): 56 | """Convert camel case to a "pythonic" name. 57 | 58 | If the name contains the ``sep`` character, then it is 59 | returned unchanged. 60 | 61 | """ 62 | if sep in name: 63 | # If the sep is in the name, assume that it's already 64 | # transformed and return the string unchanged. 65 | return name 66 | key = (name, sep) 67 | if key not in _xform_cache: 68 | s1 = _first_cap_regex.sub(r'\1' + sep + r'\2', name) 69 | s2 = _number_cap_regex.sub(r'\1' + sep + r'\2', s1) 70 | transformed = _end_cap_regex.sub(r'\1' + sep + r'\2', s2).lower() 71 | _xform_cache[key] = transformed 72 | return _xform_cache[key] 73 | 74 | 75 | class BotoCoreObject(object): 76 | 77 | def __init__(self, **kwargs): 78 | self.name = '' 79 | self.py_name = None 80 | self.cli_name = None 81 | self.type = None 82 | self.members = [] 83 | self.documentation = '' 84 | self.__dict__.update(kwargs) 85 | if self.py_name is None: 86 | self.py_name = xform_name(self.name, '_') 87 | if self.cli_name is None: 88 | self.cli_name = xform_name(self.name, '-') 89 | 90 | def __repr__(self): 91 | return '%s:%s' % (self.type, self.name) 92 | -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/botocore/data/aws/_endpoints.json: -------------------------------------------------------------------------------- 1 | { 2 | "_default":[ 3 | { 4 | "uri":"{scheme}://{service}.{region}.amazonaws.com.cn", 5 | "constraints":[ 6 | ["region", "startsWith", "cn-"] 7 | ], 8 | "properties": { 9 | "signatureVersion": "v4" 10 | } 11 | }, 12 | { 13 | "uri":"{scheme}://{service}.{region}.amazonaws.com", 14 | "constraints": [ 15 | ["region", "notEquals", null] 16 | ] 17 | } 18 | ], 19 | "iam":[ 20 | { 21 | "uri":"https://{service}.cn-north-1.amazonaws.com.cn", 22 | "constraints":[ 23 | ["region", "startsWith", "cn-"] 24 | ] 25 | }, 26 | { 27 | "uri":"https://{service}.us-gov.amazonaws.com", 28 | "constraints":[ 29 | ["region", "startsWith", "us-gov"] 30 | ] 31 | }, 32 | { 33 | "uri":"https://iam.amazonaws.com", 34 | "properties": { 35 | "credentialScope": { 36 | "region": "us-east-1" 37 | } 38 | } 39 | } 40 | ], 41 | "sdb":[ 42 | { 43 | "uri":"https://sdb.amazonaws.com", 44 | "constraints":[ 45 | ["region", "equals", "us-east-1"] 46 | ] 47 | } 48 | ], 49 | "sts":[ 50 | { 51 | "uri":"{scheme}://{service}.cn-north-1.amazonaws.com.cn", 52 | "constraints":[ 53 | ["region", "startsWith", "cn-"] 54 | ] 55 | }, 56 | { 57 | "uri":"https://{service}.{region}.amazonaws.com", 58 | "constraints":[ 59 | ["region", "startsWith", "us-gov"] 60 | ] 61 | }, 62 | { 63 | "uri":"https://sts.amazonaws.com", 64 | "properties": { 65 | "credentialScope": { 66 | "region": "us-east-1" 67 | } 68 | } 69 | } 70 | ], 71 | "s3":[ 72 | { 73 | "uri":"{scheme}://s3.amazonaws.com", 74 | "constraints":[ 75 | ["region", "oneOf", ["us-east-1", null]] 76 | ], 77 | "properties": { 78 | "credentialScope": { 79 | "region": "us-east-1" 80 | } 81 | } 82 | }, 83 | { 84 | "uri":"{scheme}://{service}.{region}.amazonaws.com.cn", 85 | "constraints": [ 86 | ["region", "startsWith", "cn-"] 87 | ], 88 | "properties": { 89 | "signatureVersion": "s3v4" 90 | } 91 | }, 92 | { 93 | "uri":"{scheme}://{service}-{region}.amazonaws.com", 94 | "constraints": [ 95 | ["region", "oneOf", ["us-east-1", "ap-northeast-1", "sa-east-1", 96 | "ap-southeast-1", "ap-southeast-2", "us-west-2", 97 | "us-west-1", "eu-west-1", "us-gov-west-1", 98 | "fips-us-gov-west-1"]] 99 | ] 100 | }, 101 | { 102 | "uri":"{scheme}://{service}.{region}.amazonaws.com", 103 | "constraints": [ 104 | ["region", "notEquals", null] 105 | ], 106 | "properties": { 107 | "signatureVersion": "s3v4" 108 | } 109 | } 110 | ], 111 | "rds":[ 112 | { 113 | "uri":"https://rds.amazonaws.com", 114 | "constraints": [ 115 | ["region", "equals", "us-east-1"] 116 | ] 117 | } 118 | ], 119 | "route53":[ 120 | { 121 | "uri":"https://route53.amazonaws.com", 122 | "constraints": [ 123 | ["region", "notStartsWith", "cn-"] 124 | ] 125 | } 126 | ], 127 | "emr":[ 128 | { 129 | "uri":"https://elasticmapreduce.us-east-1.amazonaws.com", 130 | "constraints":[ 131 | ["region", "equals", "us-east-1"] 132 | ] 133 | }, 134 | { 135 | "uri":"https://{region}.elasticmapreduce.amazonaws.com", 136 | "constraints": [ 137 | ["region", "notEquals", null] 138 | ] 139 | } 140 | ], 141 | "sqs":[ 142 | { 143 | "uri":"https://queue.amazonaws.com", 144 | "constraints": [ 145 | ["region", "equals", "us-east-1"] 146 | ] 147 | }, 148 | { 149 | "uri":"https://{region}.queue.amazonaws.com.cn", 150 | "constraints":[ 151 | ["region", "startsWith", "cn-"] 152 | ] 153 | }, 154 | { 155 | "uri":"https://{region}.queue.amazonaws.com", 156 | "constraints": [ 157 | ["region", "notEquals", null] 158 | ] 159 | } 160 | ], 161 | "importexport": [ 162 | { 163 | "uri":"https://importexport.amazonaws.com", 164 | "constraints": [ 165 | ["region", "notStartsWith", "cn-"] 166 | ] 167 | } 168 | ], 169 | "cloudfront":[ 170 | { 171 | "uri":"https://cloudfront.amazonaws.com", 172 | "constraints": [ 173 | ["region", "notStartsWith", "cn-"] 174 | ], 175 | "properties": { 176 | "credentialScope": { 177 | "region": "us-east-1" 178 | } 179 | } 180 | } 181 | ], 182 | "dynamodb": [ 183 | { 184 | "uri": "http://localhost:8000", 185 | "constraints": [ 186 | ["region", "equals", "local"] 187 | ], 188 | "properties": { 189 | "credentialScope": { 190 | "region": "us-east-1", 191 | "service": "dynamodb" 192 | } 193 | } 194 | } 195 | ] 196 | } 197 | -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/botocore/data/aws/autoscaling/2011-01-01.paginators.json: -------------------------------------------------------------------------------- 1 | { 2 | "pagination": { 3 | "DescribeAutoScalingGroups": { 4 | "input_token": "NextToken", 5 | "output_token": "NextToken", 6 | "limit_key": "MaxRecords", 7 | "result_key": "AutoScalingGroups" 8 | }, 9 | "DescribeAutoScalingInstances": { 10 | "input_token": "NextToken", 11 | "output_token": "NextToken", 12 | "limit_key": "MaxRecords", 13 | "result_key": "AutoScalingInstances" 14 | }, 15 | "DescribeLaunchConfigurations": { 16 | "input_token": "NextToken", 17 | "output_token": "NextToken", 18 | "limit_key": "MaxRecords", 19 | "result_key": "LaunchConfigurations" 20 | }, 21 | "DescribeNotificationConfigurations": { 22 | "input_token": "NextToken", 23 | "output_token": "NextToken", 24 | "limit_key": "MaxRecords", 25 | "result_key": "NotificationConfigurations" 26 | }, 27 | "DescribePolicies": { 28 | "input_token": "NextToken", 29 | "output_token": "NextToken", 30 | "limit_key": "MaxRecords", 31 | "result_key": "ScalingPolicies" 32 | }, 33 | "DescribeScalingActivities": { 34 | "input_token": "NextToken", 35 | "output_token": "NextToken", 36 | "limit_key": "MaxRecords", 37 | "result_key": "Activities" 38 | }, 39 | "DescribeScheduledActions": { 40 | "input_token": "NextToken", 41 | "output_token": "NextToken", 42 | "limit_key": "MaxRecords", 43 | "result_key": "ScheduledUpdateGroupActions" 44 | }, 45 | "DescribeTags": { 46 | "input_token": "NextToken", 47 | "output_token": "NextToken", 48 | "limit_key": "MaxRecords", 49 | "result_key": "Tags" 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/botocore/data/aws/cloudformation/2010-05-15.paginators.json: -------------------------------------------------------------------------------- 1 | { 2 | "pagination": { 3 | "DescribeStackEvents": { 4 | "input_token": "NextToken", 5 | "output_token": "NextToken", 6 | "result_key": "StackEvents" 7 | }, 8 | "DescribeStacks": { 9 | "input_token": "NextToken", 10 | "output_token": "NextToken", 11 | "result_key": "Stacks" 12 | }, 13 | "ListStackResources": { 14 | "input_token": "NextToken", 15 | "output_token": "NextToken", 16 | "result_key": "StackResourceSummaries" 17 | }, 18 | "ListStacks": { 19 | "input_token": "NextToken", 20 | "output_token": "NextToken", 21 | "result_key": "StackSummaries" 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/botocore/data/aws/cloudfront/2014-05-31.paginators.json: -------------------------------------------------------------------------------- 1 | { 2 | "pagination": { 3 | "ListCloudFrontOriginAccessIdentities": { 4 | "input_token": "Marker", 5 | "output_token": "CloudFrontOriginAccessIdentityList.NextMarker", 6 | "limit_key": "MaxItems", 7 | "more_results": "CloudFrontOriginAccessIdentityList.IsTruncated", 8 | "result_key": "CloudFrontOriginAccessIdentityList.Items" 9 | }, 10 | "ListDistributions": { 11 | "input_token": "Marker", 12 | "output_token": "DistributionList.NextMarker", 13 | "limit_key": "MaxItems", 14 | "more_results": "DistributionList.IsTruncated", 15 | "result_key": "DistributionList.Items" 16 | }, 17 | "ListInvalidations": { 18 | "input_token": "Marker", 19 | "output_token": "InvalidationList.NextMarker", 20 | "limit_key": "MaxItems", 21 | "more_results": "InvalidationList.IsTruncated", 22 | "result_key": "InvalidationList.Items" 23 | }, 24 | "ListStreamingDistributions": { 25 | "input_token": "Marker", 26 | "output_token": "StreamingDistributionList.NextMarker", 27 | "limit_key": "MaxItems", 28 | "more_results": "StreamingDistributionList.IsTruncated", 29 | "result_key": "StreamingDistributionList.Items" 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/botocore/data/aws/cloudfront/2014-05-31.waiters.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 2, 3 | "waiters": { 4 | "DistributionDeployed": { 5 | "delay": 60, 6 | "operation": "GetDistribution", 7 | "maxAttempts": 25, 8 | "description": "Wait until a distribution is deployed.", 9 | "acceptors": [ 10 | { 11 | "expected": "Deployed", 12 | "matcher": "path", 13 | "state": "success", 14 | "argument": "Status" 15 | } 16 | ] 17 | }, 18 | "InvalidationCompleted": { 19 | "delay": 20, 20 | "operation": "GetInvalidation", 21 | "maxAttempts": 30, 22 | "description": "Wait until an invalidation has completed.", 23 | "acceptors": [ 24 | { 25 | "expected": "Completed", 26 | "matcher": "path", 27 | "state": "success", 28 | "argument": "Status" 29 | } 30 | ] 31 | }, 32 | "StreamingDistributionDeployed": { 33 | "delay": 60, 34 | "operation": "GetStreamingDistribution", 35 | "maxAttempts": 25, 36 | "description": "Wait until a streaming distribution is deployed.", 37 | "acceptors": [ 38 | { 39 | "expected": "Deployed", 40 | "matcher": "path", 41 | "state": "success", 42 | "argument": "Status" 43 | } 44 | ] 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/botocore/data/aws/cloudfront/2014-10-21.paginators.json: -------------------------------------------------------------------------------- 1 | { 2 | "pagination": { 3 | "ListCloudFrontOriginAccessIdentities": { 4 | "input_token": "Marker", 5 | "output_token": "CloudFrontOriginAccessIdentityList.NextMarker", 6 | "limit_key": "MaxItems", 7 | "more_results": "CloudFrontOriginAccessIdentityList.IsTruncated", 8 | "result_key": "CloudFrontOriginAccessIdentityList.Items" 9 | }, 10 | "ListDistributions": { 11 | "input_token": "Marker", 12 | "output_token": "DistributionList.NextMarker", 13 | "limit_key": "MaxItems", 14 | "more_results": "DistributionList.IsTruncated", 15 | "result_key": "DistributionList.Items" 16 | }, 17 | "ListInvalidations": { 18 | "input_token": "Marker", 19 | "output_token": "InvalidationList.NextMarker", 20 | "limit_key": "MaxItems", 21 | "more_results": "InvalidationList.IsTruncated", 22 | "result_key": "InvalidationList.Items" 23 | }, 24 | "ListStreamingDistributions": { 25 | "input_token": "Marker", 26 | "output_token": "StreamingDistributionList.NextMarker", 27 | "limit_key": "MaxItems", 28 | "more_results": "StreamingDistributionList.IsTruncated", 29 | "result_key": "StreamingDistributionList.Items" 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/botocore/data/aws/cloudfront/2014-10-21.waiters.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 2, 3 | "waiters": { 4 | "DistributionDeployed": { 5 | "delay": 60, 6 | "operation": "GetDistribution", 7 | "maxAttempts": 25, 8 | "description": "Wait until a distribution is deployed.", 9 | "acceptors": [ 10 | { 11 | "expected": "Deployed", 12 | "matcher": "path", 13 | "state": "success", 14 | "argument": "Status" 15 | } 16 | ] 17 | }, 18 | "InvalidationCompleted": { 19 | "delay": 20, 20 | "operation": "GetInvalidation", 21 | "maxAttempts": 30, 22 | "description": "Wait until an invalidation has completed.", 23 | "acceptors": [ 24 | { 25 | "expected": "Completed", 26 | "matcher": "path", 27 | "state": "success", 28 | "argument": "Status" 29 | } 30 | ] 31 | }, 32 | "StreamingDistributionDeployed": { 33 | "delay": 60, 34 | "operation": "GetStreamingDistribution", 35 | "maxAttempts": 25, 36 | "description": "Wait until a streaming distribution is deployed.", 37 | "acceptors": [ 38 | { 39 | "expected": "Deployed", 40 | "matcher": "path", 41 | "state": "success", 42 | "argument": "Status" 43 | } 44 | ] 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/botocore/data/aws/cloudwatch/2010-08-01.paginators.json: -------------------------------------------------------------------------------- 1 | { 2 | "pagination": { 3 | "DescribeAlarmHistory": { 4 | "input_token": "NextToken", 5 | "output_token": "NextToken", 6 | "limit_key": "MaxRecords", 7 | "result_key": "AlarmHistoryItems" 8 | }, 9 | "DescribeAlarms": { 10 | "input_token": "NextToken", 11 | "output_token": "NextToken", 12 | "limit_key": "MaxRecords", 13 | "result_key": "MetricAlarms" 14 | }, 15 | "ListMetrics": { 16 | "input_token": "NextToken", 17 | "output_token": "NextToken", 18 | "result_key": "Metrics" 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/botocore/data/aws/datapipeline/2012-10-29.paginators.json: -------------------------------------------------------------------------------- 1 | { 2 | "pagination": { 3 | "ListPipelines": { 4 | "input_token": "marker", 5 | "output_token": "marker", 6 | "more_results": "hasMoreResults", 7 | "result_key": "pipelineIdList" 8 | }, 9 | "DescribeObjects": { 10 | "input_token": "marker", 11 | "output_token": "marker", 12 | "more_results": "hasMoreResults", 13 | "result_key": "pipelineObjects" 14 | }, 15 | "QueryObjects": { 16 | "input_token": "marker", 17 | "output_token": "marker", 18 | "more_results": "hasMoreResults", 19 | "limit_key": "limit", 20 | "result_key": "ids" 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/botocore/data/aws/dynamodb/2012-08-10.paginators.json: -------------------------------------------------------------------------------- 1 | { 2 | "pagination": { 3 | "ListTables": { 4 | "input_token": "ExclusiveStartTableName", 5 | "output_token": "LastEvaluatedTableName", 6 | "limit_key": "Limit", 7 | "result_key": "TableNames" 8 | }, 9 | "Query": { 10 | "input_token": "ExclusiveStartKey", 11 | "output_token": "LastEvaluatedKey", 12 | "limit_key": "Limit", 13 | "result_key": "Items", 14 | "non_aggregate_keys": [ 15 | "Count", 16 | "ScannedCount", 17 | "ConsumedCapacity" 18 | ] 19 | }, 20 | "Scan": { 21 | "input_token": "ExclusiveStartKey", 22 | "output_token": "LastEvaluatedKey", 23 | "limit_key": "Limit", 24 | "result_key": "Items", 25 | "non_aggregate_keys": [ 26 | "Count", 27 | "ScannedCount", 28 | "ConsumedCapacity" 29 | ] 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/botocore/data/aws/dynamodb/2012-08-10.waiters.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 2, 3 | "waiters": { 4 | "TableExists": { 5 | "delay": 20, 6 | "operation": "DescribeTable", 7 | "maxAttempts": 25, 8 | "acceptors": [ 9 | { 10 | "expected": "ACTIVE", 11 | "matcher": "path", 12 | "state": "success", 13 | "argument": "Table.TableStatus" 14 | }, 15 | { 16 | "expected": "ResourceNotFoundException", 17 | "matcher": "error", 18 | "state": "retry" 19 | } 20 | ] 21 | }, 22 | "TableNotExists": { 23 | "delay": 20, 24 | "operation": "DescribeTable", 25 | "maxAttempts": 25, 26 | "acceptors": [ 27 | { 28 | "expected": "ResourceNotFoundException", 29 | "matcher": "error", 30 | "state": "success" 31 | } 32 | ] 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/botocore/data/aws/ec2/2014-09-01.paginators.json: -------------------------------------------------------------------------------- 1 | { 2 | "pagination": { 3 | "DescribeInstanceStatus": { 4 | "input_token": "NextToken", 5 | "output_token": "NextToken", 6 | "limit_key": "MaxResults", 7 | "result_key": "InstanceStatuses" 8 | }, 9 | "DescribeInstances": { 10 | "input_token": "NextToken", 11 | "output_token": "NextToken", 12 | "limit_key": "MaxResults", 13 | "result_key": "Reservations" 14 | }, 15 | "DescribeReservedInstancesModifications": { 16 | "input_token": "NextToken", 17 | "output_token": "NextToken", 18 | "result_key": "ReservedInstancesModifications" 19 | }, 20 | "DescribeReservedInstancesOfferings": { 21 | "input_token": "NextToken", 22 | "output_token": "NextToken", 23 | "limit_key": "MaxResults", 24 | "result_key": "ReservedInstancesOfferings" 25 | }, 26 | "DescribeSpotPriceHistory": { 27 | "input_token": "NextToken", 28 | "output_token": "NextToken", 29 | "limit_key": "MaxResults", 30 | "result_key": "SpotPriceHistory" 31 | }, 32 | "DescribeTags": { 33 | "input_token": "NextToken", 34 | "output_token": "NextToken", 35 | "limit_key": "MaxResults", 36 | "result_key": "Tags" 37 | }, 38 | "DescribeVolumeStatus": { 39 | "input_token": "NextToken", 40 | "output_token": "NextToken", 41 | "limit_key": "MaxResults", 42 | "result_key": "VolumeStatuses" 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/botocore/data/aws/ec2/2014-10-01.paginators.json: -------------------------------------------------------------------------------- 1 | { 2 | "pagination": { 3 | "DescribeInstanceStatus": { 4 | "input_token": "NextToken", 5 | "output_token": "NextToken", 6 | "limit_key": "MaxResults", 7 | "result_key": "InstanceStatuses" 8 | }, 9 | "DescribeInstances": { 10 | "input_token": "NextToken", 11 | "output_token": "NextToken", 12 | "limit_key": "MaxResults", 13 | "result_key": "Reservations" 14 | }, 15 | "DescribeReservedInstancesModifications": { 16 | "input_token": "NextToken", 17 | "output_token": "NextToken", 18 | "result_key": "ReservedInstancesModifications" 19 | }, 20 | "DescribeReservedInstancesOfferings": { 21 | "input_token": "NextToken", 22 | "output_token": "NextToken", 23 | "limit_key": "MaxResults", 24 | "result_key": "ReservedInstancesOfferings" 25 | }, 26 | "DescribeSpotPriceHistory": { 27 | "input_token": "NextToken", 28 | "output_token": "NextToken", 29 | "limit_key": "MaxResults", 30 | "result_key": "SpotPriceHistory" 31 | }, 32 | "DescribeTags": { 33 | "input_token": "NextToken", 34 | "output_token": "NextToken", 35 | "limit_key": "MaxResults", 36 | "result_key": "Tags" 37 | }, 38 | "DescribeVolumeStatus": { 39 | "input_token": "NextToken", 40 | "output_token": "NextToken", 41 | "limit_key": "MaxResults", 42 | "result_key": "VolumeStatuses" 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/botocore/data/aws/elasticache/2014-09-30.paginators.json: -------------------------------------------------------------------------------- 1 | { 2 | "pagination": { 3 | "DescribeCacheClusters": { 4 | "input_token": "Marker", 5 | "output_token": "Marker", 6 | "limit_key": "MaxRecords", 7 | "result_key": "CacheClusters" 8 | }, 9 | "DescribeCacheEngineVersions": { 10 | "input_token": "Marker", 11 | "output_token": "Marker", 12 | "limit_key": "MaxRecords", 13 | "result_key": "CacheEngineVersions" 14 | }, 15 | "DescribeCacheParameterGroups": { 16 | "input_token": "Marker", 17 | "output_token": "Marker", 18 | "limit_key": "MaxRecords", 19 | "result_key": "CacheParameterGroups" 20 | }, 21 | "DescribeCacheParameters": { 22 | "input_token": "Marker", 23 | "output_token": "Marker", 24 | "limit_key": "MaxRecords", 25 | "result_key": "Parameters" 26 | }, 27 | "DescribeCacheSecurityGroups": { 28 | "input_token": "Marker", 29 | "output_token": "Marker", 30 | "limit_key": "MaxRecords", 31 | "result_key": "CacheSecurityGroups" 32 | }, 33 | "DescribeCacheSubnetGroups": { 34 | "input_token": "Marker", 35 | "output_token": "Marker", 36 | "limit_key": "MaxRecords", 37 | "result_key": "CacheSubnetGroups" 38 | }, 39 | "DescribeEngineDefaultParameters": { 40 | "input_token": "Marker", 41 | "output_token": "EngineDefaults.Marker", 42 | "limit_key": "MaxRecords", 43 | "result_key": "EngineDefaults.Parameters" 44 | }, 45 | "DescribeEvents": { 46 | "input_token": "Marker", 47 | "output_token": "Marker", 48 | "limit_key": "MaxRecords", 49 | "result_key": "Events" 50 | }, 51 | "DescribeReservedCacheNodes": { 52 | "input_token": "Marker", 53 | "output_token": "Marker", 54 | "limit_key": "MaxRecords", 55 | "result_key": "ReservedCacheNodes" 56 | }, 57 | "DescribeReservedCacheNodesOfferings": { 58 | "input_token": "Marker", 59 | "output_token": "Marker", 60 | "limit_key": "MaxRecords", 61 | "result_key": "ReservedCacheNodesOfferings" 62 | }, 63 | "DescribeReplicationGroups": { 64 | "input_token": "Marker", 65 | "output_token": "Marker", 66 | "limit_key": "MaxRecords", 67 | "result_key": "ReplicationGroups" 68 | }, 69 | "DescribeSnapshots": { 70 | "input_token": "Marker", 71 | "output_token": "Marker", 72 | "limit_key": "MaxRecords", 73 | "result_key": "Snapshots" 74 | } 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/botocore/data/aws/elasticbeanstalk/2010-12-01.paginators.json: -------------------------------------------------------------------------------- 1 | { 2 | "pagination": { 3 | "DescribeEvents": { 4 | "input_token": "NextToken", 5 | "output_token": "NextToken", 6 | "limit_key": "MaxRecords", 7 | "result_key": "Events" 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/botocore/data/aws/elastictranscoder/2012-09-25.paginators.json: -------------------------------------------------------------------------------- 1 | { 2 | "pagination": { 3 | "ListJobsByPipeline": { 4 | "input_token": "PageToken", 5 | "output_token": "NextPageToken", 6 | "result_key": "Jobs" 7 | }, 8 | "ListJobsByStatus": { 9 | "input_token": "PageToken", 10 | "output_token": "NextPageToken", 11 | "result_key": "Jobs" 12 | }, 13 | "ListPipelines": { 14 | "input_token": "PageToken", 15 | "output_token": "NextPageToken", 16 | "result_key": "Pipelines" 17 | }, 18 | "ListPresets": { 19 | "input_token": "PageToken", 20 | "output_token": "NextPageToken", 21 | "result_key": "Presets" 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/botocore/data/aws/elastictranscoder/2012-09-25.waiters.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 2, 3 | "waiters": { 4 | "JobComplete": { 5 | "delay": 30, 6 | "operation": "ReadJob", 7 | "maxAttempts": 120, 8 | "acceptors": [ 9 | { 10 | "expected": "Complete", 11 | "matcher": "path", 12 | "state": "success", 13 | "argument": "Job.Status" 14 | }, 15 | { 16 | "expected": "Canceled", 17 | "matcher": "path", 18 | "state": "failure", 19 | "argument": "Job.Status" 20 | }, 21 | { 22 | "expected": "Error", 23 | "matcher": "path", 24 | "state": "failure", 25 | "argument": "Job.Status" 26 | } 27 | ] 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/botocore/data/aws/elb/2012-06-01.paginators.json: -------------------------------------------------------------------------------- 1 | { 2 | "pagination": { 3 | "DescribeLoadBalancers": { 4 | "input_token": "Marker", 5 | "output_token": "NextMarker", 6 | "result_key": "LoadBalancerDescriptions", 7 | "limit_key": "PageSize" 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/botocore/data/aws/emr/2009-03-31.paginators.json: -------------------------------------------------------------------------------- 1 | { 2 | "pagination": { 3 | "ListBootstrapActions": { 4 | "input_token": "Marker", 5 | "output_token": "Marker", 6 | "result_key": "BootstrapActions" 7 | }, 8 | "ListClusters": { 9 | "input_token": "Marker", 10 | "output_token": "Marker", 11 | "result_key": "Clusters" 12 | }, 13 | "ListInstanceGroups": { 14 | "input_token": "Marker", 15 | "output_token": "Marker", 16 | "result_key": "InstanceGroups" 17 | }, 18 | "ListInstances": { 19 | "input_token": "Marker", 20 | "output_token": "Marker", 21 | "result_key": "Instances" 22 | }, 23 | "ListSteps": { 24 | "input_token": "Marker", 25 | "output_token": "Marker", 26 | "result_key": "Steps" 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/botocore/data/aws/emr/2009-03-31.waiters.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 2, 3 | "waiters": { 4 | "ClusterRunning": { 5 | "delay": 30, 6 | "operation": "DescribeCluster", 7 | "maxAttempts": 60, 8 | "acceptors": [ 9 | { 10 | "state": "success", 11 | "matcher": "path", 12 | "argument": "Cluster.Status.State", 13 | "expected": "RUNNING" 14 | }, 15 | { 16 | "state": "failure", 17 | "matcher": "path", 18 | "argument": "Cluster.Status.State", 19 | "expected": "TERMINATING" 20 | }, 21 | { 22 | "state": "failure", 23 | "matcher": "path", 24 | "argument": "Cluster.Status.State", 25 | "expected": "TERMINATED" 26 | }, 27 | { 28 | "state": "failure", 29 | "matcher": "path", 30 | "argument": "Cluster.Status.State", 31 | "expected": "TERMINATED_WITH_ERRORS" 32 | } 33 | ] 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/botocore/data/aws/iam/2010-05-08.paginators.json: -------------------------------------------------------------------------------- 1 | { 2 | "pagination": { 3 | "GetGroup": { 4 | "input_token": "Marker", 5 | "output_token": "Marker", 6 | "more_results": "IsTruncated", 7 | "limit_key": "MaxItems", 8 | "result_key": "Users", 9 | "non_aggregate_keys": [ 10 | "Group" 11 | ] 12 | }, 13 | "ListAccessKeys": { 14 | "input_token": "Marker", 15 | "output_token": "Marker", 16 | "more_results": "IsTruncated", 17 | "limit_key": "MaxItems", 18 | "result_key": "AccessKeyMetadata" 19 | }, 20 | "ListAccountAliases": { 21 | "input_token": "Marker", 22 | "output_token": "Marker", 23 | "more_results": "IsTruncated", 24 | "limit_key": "MaxItems", 25 | "result_key": "AccountAliases" 26 | }, 27 | "ListGroupPolicies": { 28 | "input_token": "Marker", 29 | "output_token": "Marker", 30 | "more_results": "IsTruncated", 31 | "limit_key": "MaxItems", 32 | "result_key": "PolicyNames" 33 | }, 34 | "ListGroups": { 35 | "input_token": "Marker", 36 | "output_token": "Marker", 37 | "more_results": "IsTruncated", 38 | "limit_key": "MaxItems", 39 | "result_key": "Groups" 40 | }, 41 | "ListGroupsForUser": { 42 | "input_token": "Marker", 43 | "output_token": "Marker", 44 | "more_results": "IsTruncated", 45 | "limit_key": "MaxItems", 46 | "result_key": "Groups" 47 | }, 48 | "ListInstanceProfiles": { 49 | "input_token": "Marker", 50 | "output_token": "Marker", 51 | "more_results": "IsTruncated", 52 | "limit_key": "MaxItems", 53 | "result_key": "InstanceProfiles" 54 | }, 55 | "ListInstanceProfilesForRole": { 56 | "input_token": "Marker", 57 | "output_token": "Marker", 58 | "more_results": "IsTruncated", 59 | "limit_key": "MaxItems", 60 | "result_key": "InstanceProfiles" 61 | }, 62 | "ListMFADevices": { 63 | "input_token": "Marker", 64 | "output_token": "Marker", 65 | "more_results": "IsTruncated", 66 | "limit_key": "MaxItems", 67 | "result_key": "MFADevices" 68 | }, 69 | "ListRolePolicies": { 70 | "input_token": "Marker", 71 | "output_token": "Marker", 72 | "more_results": "IsTruncated", 73 | "limit_key": "MaxItems", 74 | "result_key": "PolicyNames" 75 | }, 76 | "ListRoles": { 77 | "input_token": "Marker", 78 | "output_token": "Marker", 79 | "more_results": "IsTruncated", 80 | "limit_key": "MaxItems", 81 | "result_key": "Roles" 82 | }, 83 | "ListServerCertificates": { 84 | "input_token": "Marker", 85 | "output_token": "Marker", 86 | "more_results": "IsTruncated", 87 | "limit_key": "MaxItems", 88 | "result_key": "ServerCertificateMetadataList" 89 | }, 90 | "ListSigningCertificates": { 91 | "input_token": "Marker", 92 | "output_token": "Marker", 93 | "more_results": "IsTruncated", 94 | "limit_key": "MaxItems", 95 | "result_key": "Certificates" 96 | }, 97 | "ListUserPolicies": { 98 | "input_token": "Marker", 99 | "output_token": "Marker", 100 | "more_results": "IsTruncated", 101 | "limit_key": "MaxItems", 102 | "result_key": "PolicyNames" 103 | }, 104 | "ListUsers": { 105 | "input_token": "Marker", 106 | "output_token": "Marker", 107 | "more_results": "IsTruncated", 108 | "limit_key": "MaxItems", 109 | "result_key": "Users" 110 | }, 111 | "ListVirtualMFADevices": { 112 | "input_token": "Marker", 113 | "output_token": "Marker", 114 | "more_results": "IsTruncated", 115 | "limit_key": "MaxItems", 116 | "result_key": "VirtualMFADevices" 117 | } 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/botocore/data/aws/importexport/2010-06-01.paginators.json: -------------------------------------------------------------------------------- 1 | { 2 | "pagination": { 3 | "ListJobs": { 4 | "input_token": "Marker", 5 | "output_token": "Jobs[-1].JobId", 6 | "more_results": "IsTruncated", 7 | "limit_key": "MaxJobs", 8 | "result_key": "Jobs" 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/botocore/data/aws/kinesis/2013-12-02.paginators.json: -------------------------------------------------------------------------------- 1 | { 2 | "pagination": { 3 | "DescribeStream": { 4 | "input_token": "ExclusiveStartShardId", 5 | "limit_key": "Limit", 6 | "more_results": "StreamDescription.HasMoreShards", 7 | "output_token": "StreamDescription.Shards[-1].ShardId", 8 | "result_key": "StreamDescription.Shards", 9 | "non_aggregate_keys": [ 10 | "StreamDescription.StreamARN", 11 | "StreamDescription.StreamName", 12 | "StreamDescription.StreamStatus" 13 | ] 14 | }, 15 | "ListStreams": { 16 | "input_token": "ExclusiveStartStreamName", 17 | "limit_key": "Limit", 18 | "more_results": "HasMoreStreams", 19 | "output_token": "StreamNames[-1]", 20 | "result_key": "StreamNames" 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/botocore/data/aws/rds/2014-09-01.paginators.json: -------------------------------------------------------------------------------- 1 | { 2 | "pagination": { 3 | "DescribeDBEngineVersions": { 4 | "input_token": "Marker", 5 | "output_token": "Marker", 6 | "limit_key": "MaxRecords", 7 | "result_key": "DBEngineVersions" 8 | }, 9 | "DescribeDBInstances": { 10 | "input_token": "Marker", 11 | "output_token": "Marker", 12 | "limit_key": "MaxRecords", 13 | "result_key": "DBInstances" 14 | }, 15 | "DescribeDBLogFiles": { 16 | "input_token": "Marker", 17 | "output_token": "Marker", 18 | "limit_key": "MaxRecords", 19 | "result_key": "DescribeDBLogFiles" 20 | }, 21 | "DescribeDBParameterGroups": { 22 | "input_token": "Marker", 23 | "output_token": "Marker", 24 | "limit_key": "MaxRecords", 25 | "result_key": "DBParameterGroups" 26 | }, 27 | "DescribeDBParameters": { 28 | "input_token": "Marker", 29 | "output_token": "Marker", 30 | "limit_key": "MaxRecords", 31 | "result_key": "Parameters" 32 | }, 33 | "DescribeDBSecurityGroups": { 34 | "input_token": "Marker", 35 | "output_token": "Marker", 36 | "limit_key": "MaxRecords", 37 | "result_key": "DBSecurityGroups" 38 | }, 39 | "DescribeDBSnapshots": { 40 | "input_token": "Marker", 41 | "output_token": "Marker", 42 | "limit_key": "MaxRecords", 43 | "result_key": "DBSnapshots" 44 | }, 45 | "DescribeDBSubnetGroups": { 46 | "input_token": "Marker", 47 | "output_token": "Marker", 48 | "limit_key": "MaxRecords", 49 | "result_key": "DBSubnetGroups" 50 | }, 51 | "DescribeEngineDefaultParameters": { 52 | "input_token": "Marker", 53 | "output_token": "EngineDefaults.Marker", 54 | "limit_key": "MaxRecords", 55 | "result_key": "EngineDefaults.Parameters" 56 | }, 57 | "DescribeEventSubscriptions": { 58 | "input_token": "Marker", 59 | "output_token": "Marker", 60 | "limit_key": "MaxRecords", 61 | "result_key": "EventSubscriptionsList" 62 | }, 63 | "DescribeEvents": { 64 | "input_token": "Marker", 65 | "output_token": "Marker", 66 | "limit_key": "MaxRecords", 67 | "result_key": "Events" 68 | }, 69 | "DescribeOptionGroupOptions": { 70 | "input_token": "Marker", 71 | "output_token": "Marker", 72 | "limit_key": "MaxRecords", 73 | "result_key": "OptionGroupOptions" 74 | }, 75 | "DescribeOptionGroups": { 76 | "input_token": "Marker", 77 | "output_token": "Marker", 78 | "limit_key": "MaxRecords", 79 | "result_key": "OptionGroupsList" 80 | }, 81 | "DescribeOrderableDBInstanceOptions": { 82 | "input_token": "Marker", 83 | "output_token": "Marker", 84 | "limit_key": "MaxRecords", 85 | "result_key": "OrderableDBInstanceOptions" 86 | }, 87 | "DescribeReservedDBInstances": { 88 | "input_token": "Marker", 89 | "output_token": "Marker", 90 | "limit_key": "MaxRecords", 91 | "result_key": "ReservedDBInstances" 92 | }, 93 | "DescribeReservedDBInstancesOfferings": { 94 | "input_token": "Marker", 95 | "output_token": "Marker", 96 | "limit_key": "MaxRecords", 97 | "result_key": "ReservedDBInstancesOfferings" 98 | }, 99 | "DownloadDBLogFilePortion": { 100 | "input_token": "Marker", 101 | "output_token": "Marker", 102 | "limit_key": "NumberOfLines", 103 | "more_results": "AdditionalDataPending", 104 | "result_key": "LogFileData" 105 | } 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/botocore/data/aws/rds/2014-09-01.waiters.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 2, 3 | "waiters": { 4 | "DBInstanceAvailable": { 5 | "delay": 30, 6 | "operation": "DescribeDBInstances", 7 | "maxAttempts": 60, 8 | "acceptors": [ 9 | { 10 | "expected": "available", 11 | "matcher": "pathAll", 12 | "state": "success", 13 | "argument": "DBInstances[].DBInstanceStatus" 14 | }, 15 | { 16 | "expected": "deleted", 17 | "matcher": "pathAny", 18 | "state": "failure", 19 | "argument": "DBInstances[].DBInstanceStatus" 20 | }, 21 | { 22 | "expected": "deleting", 23 | "matcher": "pathAny", 24 | "state": "failure", 25 | "argument": "DBInstances[].DBInstanceStatus" 26 | }, 27 | { 28 | "expected": "failed", 29 | "matcher": "pathAny", 30 | "state": "failure", 31 | "argument": "DBInstances[].DBInstanceStatus" 32 | }, 33 | { 34 | "expected": "incompatible-restore", 35 | "matcher": "pathAny", 36 | "state": "failure", 37 | "argument": "DBInstances[].DBInstanceStatus" 38 | }, 39 | { 40 | "expected": "incompatible-parameters", 41 | "matcher": "pathAny", 42 | "state": "failure", 43 | "argument": "DBInstances[].DBInstanceStatus" 44 | }, 45 | { 46 | "expected": "incompatible-parameters", 47 | "matcher": "pathAny", 48 | "state": "failure", 49 | "argument": "DBInstances[].DBInstanceStatus" 50 | }, 51 | { 52 | "expected": "incompatible-restore", 53 | "matcher": "pathAny", 54 | "state": "failure", 55 | "argument": "DBInstances[].DBInstanceStatus" 56 | } 57 | ] 58 | }, 59 | "DBInstanceDeleted": { 60 | "delay": 30, 61 | "operation": "DescribeDBInstances", 62 | "maxAttempts": 60, 63 | "acceptors": [ 64 | { 65 | "expected": "deleted", 66 | "matcher": "pathAll", 67 | "state": "success", 68 | "argument": "DBInstances[].DBInstanceStatus" 69 | }, 70 | { 71 | "expected": "creating", 72 | "matcher": "pathAny", 73 | "state": "failure", 74 | "argument": "DBInstances[].DBInstanceStatus" 75 | }, 76 | { 77 | "expected": "modifying", 78 | "matcher": "pathAny", 79 | "state": "failure", 80 | "argument": "DBInstances[].DBInstanceStatus" 81 | }, 82 | { 83 | "expected": "rebooting", 84 | "matcher": "pathAny", 85 | "state": "failure", 86 | "argument": "DBInstances[].DBInstanceStatus" 87 | }, 88 | { 89 | "expected": "resetting-master-credentials", 90 | "matcher": "pathAny", 91 | "state": "failure", 92 | "argument": "DBInstances[].DBInstanceStatus" 93 | } 94 | ] 95 | } 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/botocore/data/aws/redshift/2012-12-01.paginators.json: -------------------------------------------------------------------------------- 1 | { 2 | "pagination": { 3 | "DescribeClusterParameterGroups": { 4 | "input_token": "Marker", 5 | "output_token": "Marker", 6 | "limit_key": "MaxRecords", 7 | "result_key": "ParameterGroups" 8 | }, 9 | "DescribeClusterParameters": { 10 | "input_token": "Marker", 11 | "output_token": "Marker", 12 | "limit_key": "MaxRecords", 13 | "result_key": "Parameters" 14 | }, 15 | "DescribeClusterSecurityGroups": { 16 | "input_token": "Marker", 17 | "output_token": "Marker", 18 | "limit_key": "MaxRecords", 19 | "result_key": "ClusterSecurityGroups" 20 | }, 21 | "DescribeClusterSnapshots": { 22 | "input_token": "Marker", 23 | "output_token": "Marker", 24 | "limit_key": "MaxRecords", 25 | "result_key": "Snapshots" 26 | }, 27 | "DescribeClusterSubnetGroups": { 28 | "input_token": "Marker", 29 | "output_token": "Marker", 30 | "limit_key": "MaxRecords", 31 | "result_key": "ClusterSubnetGroups" 32 | }, 33 | "DescribeClusterVersions": { 34 | "input_token": "Marker", 35 | "output_token": "Marker", 36 | "limit_key": "MaxRecords", 37 | "result_key": "ClusterVersions" 38 | }, 39 | "DescribeClusters": { 40 | "input_token": "Marker", 41 | "output_token": "Marker", 42 | "limit_key": "MaxRecords", 43 | "result_key": "Clusters" 44 | }, 45 | "DescribeDefaultClusterParameters": { 46 | "input_token": "Marker", 47 | "output_token": "DefaultClusterParameters.Marker", 48 | "limit_key": "MaxRecords", 49 | "result_key": "DefaultClusterParameters.Parameters" 50 | }, 51 | "DescribeEventSubscriptions": { 52 | "input_token": "Marker", 53 | "output_token": "Marker", 54 | "limit_key": "MaxRecords", 55 | "result_key": "EventSubscriptionsList" 56 | }, 57 | "DescribeEvents": { 58 | "input_token": "Marker", 59 | "output_token": "Marker", 60 | "limit_key": "MaxRecords", 61 | "result_key": "Events" 62 | }, 63 | "DescribeHsmClientCertificates": { 64 | "input_token": "Marker", 65 | "output_token": "Marker", 66 | "limit_key": "MaxRecords", 67 | "result_key": "HsmClientCertificates" 68 | }, 69 | "DescribeHsmConfigurations": { 70 | "input_token": "Marker", 71 | "output_token": "Marker", 72 | "limit_key": "MaxRecords", 73 | "result_key": "HsmConfigurations" 74 | }, 75 | "DescribeOrderableClusterOptions": { 76 | "input_token": "Marker", 77 | "output_token": "Marker", 78 | "limit_key": "MaxRecords", 79 | "result_key": "OrderableClusterOptions" 80 | }, 81 | "DescribeReservedNodeOfferings": { 82 | "input_token": "Marker", 83 | "output_token": "Marker", 84 | "limit_key": "MaxRecords", 85 | "result_key": "ReservedNodeOfferings" 86 | }, 87 | "DescribeReservedNodes": { 88 | "input_token": "Marker", 89 | "output_token": "Marker", 90 | "limit_key": "MaxRecords", 91 | "result_key": "ReservedNodes" 92 | } 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/botocore/data/aws/redshift/2012-12-01.waiters.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 2, 3 | "waiters": { 4 | "ClusterAvailable": { 5 | "delay": 60, 6 | "operation": "DescribeClusters", 7 | "maxAttempts": 30, 8 | "acceptors": [ 9 | { 10 | "expected": "available", 11 | "matcher": "pathAll", 12 | "state": "success", 13 | "argument": "Clusters[].ClusterStatus" 14 | }, 15 | { 16 | "expected": "deleting", 17 | "matcher": "pathAny", 18 | "state": "failure", 19 | "argument": "Clusters[].ClusterStatus" 20 | }, 21 | { 22 | "expected": "ClusterNotFound", 23 | "matcher": "error", 24 | "state": "retry" 25 | } 26 | ] 27 | }, 28 | "ClusterDeleted": { 29 | "delay": 60, 30 | "operation": "DescribeClusters", 31 | "maxAttempts": 30, 32 | "acceptors": [ 33 | { 34 | "expected": "ClusterNotFound", 35 | "matcher": "error", 36 | "state": "success" 37 | }, 38 | { 39 | "expected": "creating", 40 | "matcher": "pathAny", 41 | "state": "failure", 42 | "argument": "Clusters[].ClusterStatus" 43 | }, 44 | { 45 | "expected": "rebooting", 46 | "matcher": "pathAny", 47 | "state": "failure", 48 | "argument": "Clusters[].ClusterStatus" 49 | } 50 | ] 51 | }, 52 | "SnapshotAvailable": { 53 | "delay": 15, 54 | "operation": "DescribeClusterSnapshots", 55 | "maxAttempts": 20, 56 | "acceptors": [ 57 | { 58 | "expected": "available", 59 | "matcher": "pathAll", 60 | "state": "success", 61 | "argument": "Snapshots[].Status" 62 | }, 63 | { 64 | "expected": "failed", 65 | "matcher": "pathAny", 66 | "state": "failure", 67 | "argument": "Snapshots[].Status" 68 | }, 69 | { 70 | "expected": "deleted", 71 | "matcher": "pathAny", 72 | "state": "failure", 73 | "argument": "Snapshots[].Status" 74 | } 75 | ] 76 | } 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/botocore/data/aws/route53/2013-04-01.paginators.json: -------------------------------------------------------------------------------- 1 | { 2 | "pagination": { 3 | "ListHealthChecks": { 4 | "input_token": "Marker", 5 | "output_token": "NextMarker", 6 | "more_results": "IsTruncated", 7 | "limit_key": "MaxItems", 8 | "result_key": "HealthChecks" 9 | }, 10 | "ListHostedZones": { 11 | "input_token": "Marker", 12 | "output_token": "NextMarker", 13 | "more_results": "IsTruncated", 14 | "limit_key": "MaxItems", 15 | "result_key": "HostedZones" 16 | }, 17 | "ListResourceRecordSets": { 18 | "more_results": "IsTruncated", 19 | "limit_key": "MaxItems", 20 | "result_key": "ResourceRecordSets", 21 | "input_token": [ 22 | "StartRecordName", 23 | "StartRecordType", 24 | "StartRecordIdentifier" 25 | ], 26 | "output_token": [ 27 | "NextRecordName", 28 | "NextRecordType", 29 | "NextRecordIdentifier" 30 | ] 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/botocore/data/aws/s3/2006-03-01.paginators.json: -------------------------------------------------------------------------------- 1 | { 2 | "pagination": { 3 | "ListMultipartUploads": { 4 | "limit_key": "MaxUploads", 5 | "more_results": "IsTruncated", 6 | "output_token": [ 7 | "NextKeyMarker", 8 | "NextUploadIdMarker" 9 | ], 10 | "input_token": [ 11 | "KeyMarker", 12 | "UploadIdMarker" 13 | ], 14 | "result_key": [ 15 | "Uploads", 16 | "CommonPrefixes" 17 | ] 18 | }, 19 | "ListObjectVersions": { 20 | "more_results": "IsTruncated", 21 | "limit_key": "MaxKeys", 22 | "output_token": [ 23 | "NextKeyMarker", 24 | "NextVersionIdMarker" 25 | ], 26 | "input_token": [ 27 | "KeyMarker", 28 | "VersionIdMarker" 29 | ], 30 | "result_key": [ 31 | "Versions", 32 | "DeleteMarkers", 33 | "CommonPrefixes" 34 | ] 35 | }, 36 | "ListObjects": { 37 | "more_results": "IsTruncated", 38 | "limit_key": "MaxKeys", 39 | "output_token": "NextMarker || Contents[-1].Key", 40 | "input_token": "Marker", 41 | "result_key": [ 42 | "Contents", 43 | "CommonPrefixes" 44 | ] 45 | }, 46 | "ListParts": { 47 | "more_results": "IsTruncated", 48 | "limit_key": "MaxParts", 49 | "output_token": "NextPartNumberMarker", 50 | "input_token": "PartNumberMarker", 51 | "result_key": "Parts", 52 | "non_aggregate_keys": [ 53 | "Initiator", 54 | "Owner", 55 | "StorageClass" 56 | ] 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/botocore/data/aws/s3/2006-03-01.waiters.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 2, 3 | "waiters": { 4 | "BucketExists": { 5 | "delay": 5, 6 | "operation": "HeadBucket", 7 | "maxAttempts": 20, 8 | "acceptors": [ 9 | { 10 | "expected": 200, 11 | "matcher": "status", 12 | "state": "success" 13 | }, 14 | { 15 | "expected": 404, 16 | "matcher": "status", 17 | "state": "retry" 18 | } 19 | ] 20 | }, 21 | "BucketNotExists": { 22 | "delay": 5, 23 | "operation": "HeadBucket", 24 | "maxAttempts": 20, 25 | "acceptors": [ 26 | { 27 | "expected": 404, 28 | "matcher": "status", 29 | "state": "success" 30 | } 31 | ] 32 | }, 33 | "ObjectExists": { 34 | "delay": 5, 35 | "operation": "HeadObject", 36 | "maxAttempts": 20, 37 | "acceptors": [ 38 | { 39 | "expected": 200, 40 | "matcher": "status", 41 | "state": "success" 42 | }, 43 | { 44 | "expected": 404, 45 | "matcher": "status", 46 | "state": "retry" 47 | } 48 | ] 49 | }, 50 | "ObjectNotExists": { 51 | "delay": 5, 52 | "operation": "HeadObject", 53 | "maxAttempts": 20, 54 | "acceptors": [ 55 | { 56 | "expected": 404, 57 | "matcher": "status", 58 | "state": "success" 59 | } 60 | ] 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/botocore/data/aws/sdb/2009-04-15.paginators.json: -------------------------------------------------------------------------------- 1 | { 2 | "pagination": { 3 | "ListDomains": { 4 | "input_token": "NextToken", 5 | "output_token": "NextToken", 6 | "limit_key": "MaxNumberOfDomains", 7 | "result_key": "DomainNames" 8 | }, 9 | "Select": { 10 | "input_token": "NextToken", 11 | "output_token": "NextToken", 12 | "result_key": "Items" 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/botocore/data/aws/ses/2010-12-01.paginators.json: -------------------------------------------------------------------------------- 1 | { 2 | "pagination": { 3 | "ListIdentities": { 4 | "input_token": "NextToken", 5 | "output_token": "NextToken", 6 | "limit_key": "MaxItems", 7 | "result_key": "Identities" 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/botocore/data/aws/ses/2010-12-01.waiters.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 2, 3 | "waiters": { 4 | "IdentityExists": { 5 | "delay": 3, 6 | "operation": "GetIdentityVerificationAttributes", 7 | "maxAttempts": 20, 8 | "acceptors": [ 9 | { 10 | "expected": "Success", 11 | "matcher": "pathAll", 12 | "state": "success", 13 | "argument": "VerificationAttributes.*.VerificationStatus" 14 | } 15 | ] 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/botocore/data/aws/sns/2010-03-31.paginators.json: -------------------------------------------------------------------------------- 1 | { 2 | "pagination": { 3 | "ListEndpointsByPlatformApplication": { 4 | "input_token": "NextToken", 5 | "output_token": "NextToken", 6 | "result_key": "Endpoints" 7 | }, 8 | "ListPlatformApplications": { 9 | "input_token": "NextToken", 10 | "output_token": "NextToken", 11 | "result_key": "PlatformApplications" 12 | }, 13 | "ListSubscriptions": { 14 | "input_token": "NextToken", 15 | "output_token": "NextToken", 16 | "result_key": "Subscriptions" 17 | }, 18 | "ListSubscriptionsByTopic": { 19 | "input_token": "NextToken", 20 | "output_token": "NextToken", 21 | "result_key": "Subscriptions" 22 | }, 23 | "ListTopics": { 24 | "input_token": "NextToken", 25 | "output_token": "NextToken", 26 | "result_key": "Topics" 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/botocore/data/aws/storagegateway/2013-06-30.paginators.json: -------------------------------------------------------------------------------- 1 | { 2 | "pagination": { 3 | "DescribeTapeArchives": { 4 | "input_token": "Marker", 5 | "limit_key": "Limit", 6 | "output_token": "Marker", 7 | "result_key": "TapeArchives" 8 | }, 9 | "DescribeTapeRecoveryPoints": { 10 | "input_token": "Marker", 11 | "limit_key": "Limit", 12 | "output_token": "Marker", 13 | "result_key": "TapeRecoveryPointInfos" 14 | }, 15 | "DescribeTapes": { 16 | "input_token": "Marker", 17 | "limit_key": "Limit", 18 | "output_token": "Marker", 19 | "result_key": "Tapes" 20 | }, 21 | "DescribeVTLDevices": { 22 | "input_token": "Marker", 23 | "limit_key": "Limit", 24 | "output_token": "Marker", 25 | "result_key": "VTLDevices" 26 | }, 27 | "ListGateways": { 28 | "input_token": "Marker", 29 | "limit_key": "Limit", 30 | "output_token": "Marker", 31 | "result_key": "Gateways" 32 | }, 33 | "ListVolumes": { 34 | "input_token": "Marker", 35 | "limit_key": "Limit", 36 | "output_token": "Marker", 37 | "result_key": "VolumeInfos" 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/botocore/data/aws/support/2013-04-15.paginators.json: -------------------------------------------------------------------------------- 1 | { 2 | "pagination": { 3 | "DescribeCases": { 4 | "input_token": "nextToken", 5 | "output_token": "nextToken", 6 | "limit_key": "maxResults", 7 | "result_key": "cases" 8 | }, 9 | "DescribeCommunications": { 10 | "input_token": "nextToken", 11 | "output_token": "nextToken", 12 | "limit_key": "maxResults", 13 | "result_key": "communications" 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/botocore/data/aws/swf/2012-01-25.paginators.json: -------------------------------------------------------------------------------- 1 | { 2 | "pagination": { 3 | "GetWorkflowExecutionHistory": { 4 | "limit_key": "maximumPageSize", 5 | "input_token": "nextPageToken", 6 | "output_token": "nextPageToken", 7 | "result_key": "events" 8 | }, 9 | "ListActivityTypes": { 10 | "limit_key": "maximumPageSize", 11 | "input_token": "nextPageToken", 12 | "output_token": "nextPageToken", 13 | "result_key": "typeInfos" 14 | }, 15 | "ListClosedWorkflowExecutions": { 16 | "limit_key": "maximumPageSize", 17 | "input_token": "nextPageToken", 18 | "output_token": "nextPageToken", 19 | "result_key": "executionInfos" 20 | }, 21 | "ListDomains": { 22 | "limit_key": "maximumPageSize", 23 | "input_token": "nextPageToken", 24 | "output_token": "nextPageToken", 25 | "result_key": "domainInfos" 26 | }, 27 | "ListOpenWorkflowExecutions": { 28 | "limit_key": "maximumPageSize", 29 | "input_token": "nextPageToken", 30 | "output_token": "nextPageToken", 31 | "result_key": "executionInfos" 32 | }, 33 | "ListWorkflowTypes": { 34 | "limit_key": "maximumPageSize", 35 | "input_token": "nextPageToken", 36 | "output_token": "nextPageToken", 37 | "result_key": "typeInfos" 38 | }, 39 | "PollForDecisionTask": { 40 | "limit_key": "maximumPageSize", 41 | "input_token": "nextPageToken", 42 | "output_token": "nextPageToken", 43 | "result_key": "events", 44 | "non_aggregate_keys": [ 45 | "taskToken", 46 | "startedEventId", 47 | "workflowExecution", 48 | "workflowType", 49 | "previousStartedEventId" 50 | ] 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/botocore/provider.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2012-2013 Mitch Garnaat http://garnaat.org/ 2 | # Copyright 2012-2014 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You 5 | # may not use this file except in compliance with the License. A copy of 6 | # the License is located at 7 | # 8 | # http://aws.amazon.com/apache2.0/ 9 | # 10 | # or in the "license" file accompanying this file. This file is 11 | # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 12 | # ANY KIND, either express or implied. See the License for the specific 13 | # language governing permissions and limitations under the License. 14 | 15 | 16 | class Provider(object): 17 | 18 | def __init__(self, session, name): 19 | self.session = session 20 | self.name = name 21 | self._services = None 22 | 23 | def __repr__(self): 24 | return 'Provider(%s)' % self.name 25 | 26 | @property 27 | def services(self): 28 | if self._services is None: 29 | self._services = [self.session.get_service(sn) for 30 | sn in self.session.get_available_services()] 31 | return self._services 32 | 33 | 34 | def get_provider(session, provider_name): 35 | return Provider(session, provider_name) 36 | -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/botocore/regions.py: -------------------------------------------------------------------------------- 1 | # Copyright 2014 Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"). You 4 | # may not use this file except in compliance with the License. A copy of 5 | # the License is located at 6 | # 7 | # http://aws.amazon.com/apache2.0/ 8 | # 9 | # or in the "license" file accompanying this file. This file is 10 | # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 11 | # ANY KIND, either express or implied. See the License for the specific 12 | # language governing permissions and limitations under the License. 13 | """Implements endpoint heuristics. 14 | 15 | This module implements the endpoint heuristics used by the AWS SDKs. 16 | In a nutshell, you give it some input data (a service name, a 17 | region name, and a scheme) and it gives you a complete url. 18 | 19 | """ 20 | from .exceptions import UnknownEndpointError 21 | 22 | 23 | class EndpointResolver(object): 24 | _CONSTRAINT_FUNCS = { 25 | 'startsWith': lambda x, y: str(x).startswith(y), 26 | 'notStartsWith': lambda x, y: not str(x).startswith(y), 27 | 'equals': lambda x, y: x == y, 28 | 'notEquals': lambda x, y: x != y, 29 | 'oneOf': lambda x, y: x in y 30 | } 31 | DEFAULT_SCHEME = 'https' 32 | 33 | def __init__(self, rules): 34 | self._rules = rules 35 | 36 | def get_rules_for_service(self, service_name): 37 | """Return the rules for a given service. 38 | 39 | Note that the list returned is a reference to the actual list of 40 | rules used for the service. This list can be mutated to insert your 41 | own heuristic rules. You can also use a service name of ``_default`` 42 | to get the list of default rules that are applied if no service 43 | name matches. 44 | 45 | """ 46 | return self._rules.get(service_name) 47 | 48 | def construct_endpoint(self, service_name, region_name, **kwargs): 49 | # We take **kwargs so that custom rules can be added that have 50 | # additional constraint keys that we don't know about. 51 | # We also need to fold the names used in the spec into **kwargs 52 | # so we can format the URI later. 53 | kwargs['service'] = service_name 54 | kwargs['region'] = region_name 55 | if 'scheme' not in kwargs: 56 | kwargs['scheme'] = self.DEFAULT_SCHEME 57 | service_rules = self._rules.get(service_name, []) 58 | endpoint = self._match_rules(service_rules, region_name, **kwargs) 59 | if endpoint is None: 60 | # If we didn't find any in the service section, try again 61 | # with the default section. 62 | endpoint = self._match_rules(self._rules.get('_default', []), 63 | region_name, **kwargs) 64 | 65 | if endpoint is None: 66 | raise UnknownEndpointError(service_name=service_name, 67 | region_name=region_name) 68 | return endpoint 69 | 70 | def _match_rules(self, service_rules, region_name, **kwargs): 71 | for rule in service_rules: 72 | if self._matches_rule(rule, region_name, **kwargs): 73 | return {'uri': rule['uri'].format(**kwargs), 74 | 'properties': rule.get('properties', {})} 75 | # If we can't find any rules, then try again with the _default 76 | # section. 77 | 78 | def _matches_rule(self, rule, region_name, **kwargs): 79 | for constraint in rule.get('constraints', []): 80 | if not self._matches_constraint(constraint, **kwargs): 81 | return False 82 | return True 83 | 84 | def _matches_constraint(self, constraint, **kwargs): 85 | # Each constraint consists of an attribute in the first index (e.g., 86 | # "scheme", "region", "service"), an assertion in the second index 87 | # (e.g., "startsWith", "equals", "oneOf"), and a value in the third 88 | # index (e.g., "us-east-1"). 89 | x, func, y = (kwargs[constraint[0]], 90 | self._CONSTRAINT_FUNCS[constraint[1]], 91 | constraint[2]) 92 | return func(x, y) 93 | -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/botocore/response.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2012-2013 Mitch Garnaat http://garnaat.org/ 2 | # Copyright 2012-2014 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You 5 | # may not use this file except in compliance with the License. A copy of 6 | # the License is located at 7 | # 8 | # http://aws.amazon.com/apache2.0/ 9 | # 10 | # or in the "license" file accompanying this file. This file is 11 | # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 12 | # ANY KIND, either express or implied. See the License for the specific 13 | # language governing permissions and limitations under the License. 14 | 15 | import sys 16 | import xml.etree.cElementTree 17 | import logging 18 | 19 | from . import ScalarTypes 20 | from .hooks import first_non_none_response 21 | from .compat import json, set_socket_timeout, XMLParseError 22 | from .exceptions import IncompleteReadError 23 | from . import parsers 24 | 25 | 26 | logger = logging.getLogger(__name__) 27 | 28 | 29 | class StreamingBody(object): 30 | """Wrapper class for an http response body. 31 | 32 | This provides a few additional conveniences that do not exist 33 | in the urllib3 model: 34 | 35 | * Set the timeout on the socket (i.e read() timeouts) 36 | * Auto validation of content length, if the amount of bytes 37 | we read does not match the content length, an exception 38 | is raised. 39 | 40 | """ 41 | def __init__(self, raw_stream, content_length): 42 | self._raw_stream = raw_stream 43 | self._content_length = content_length 44 | self._amount_read = 0 45 | 46 | def set_socket_timeout(self, timeout): 47 | """Set the timeout seconds on the socket.""" 48 | # The problem we're trying to solve is to prevent .read() calls from 49 | # hanging. This can happen in rare cases. What we'd like to ideally 50 | # do is set a timeout on the .read() call so that callers can retry 51 | # the request. 52 | # Unfortunately, this isn't currently possible in requests. 53 | # See: https://github.com/kennethreitz/requests/issues/1803 54 | # So what we're going to do is reach into the guts of the stream and 55 | # grab the socket object, which we can set the timeout on. We're 56 | # putting in a check here so in case this interface goes away, we'll 57 | # know. 58 | try: 59 | # To further complicate things, the way to grab the 60 | # underlying socket object from an HTTPResponse is different 61 | # in py2 and py3. So this code has been pushed to botocore.compat. 62 | set_socket_timeout(self._raw_stream, timeout) 63 | except AttributeError: 64 | logger.error("Cannot access the socket object of " 65 | "a streaming response. It's possible " 66 | "the interface has changed.", exc_info=True) 67 | raise 68 | 69 | def read(self, amt=None): 70 | chunk = self._raw_stream.read(amt) 71 | self._amount_read += len(chunk) 72 | if not chunk or amt is None: 73 | # If the server sends empty contents or 74 | # we ask to read all of the contents, then we know 75 | # we need to verify the content length. 76 | self._verify_content_length() 77 | return chunk 78 | 79 | def _verify_content_length(self): 80 | if self._content_length is not None and \ 81 | self._amount_read != int(self._content_length): 82 | raise IncompleteReadError( 83 | actual_bytes=self._amount_read, 84 | expected_bytes=int(self._content_length)) 85 | 86 | 87 | def _validate_content_length(expected_content_length, body_length): 88 | # See: https://github.com/kennethreitz/requests/issues/1855 89 | # Basically, our http library doesn't do this for us, so we have 90 | # to do this ourself. 91 | if expected_content_length is not None: 92 | if int(expected_content_length) != body_length: 93 | raise IncompleteReadError( 94 | actual_bytes=body_length, 95 | expected_bytes=int(expected_content_length)) 96 | 97 | 98 | def get_response(operation_model, http_response): 99 | protocol = operation_model.metadata['protocol'] 100 | response_dict = { 101 | 'headers': http_response.headers, 102 | 'status_code': http_response.status_code, 103 | } 104 | # TODO: Unfortunately, we have to have error logic here. 105 | # If it looks like an error, in the streaming response case we 106 | # need to actually grab the contents. 107 | if response_dict['status_code'] >= 300: 108 | response_dict['body'] = http_response.content 109 | elif operation_model.has_streaming_output: 110 | response_dict['body'] = StreamingBody( 111 | http_response.raw, response_dict['headers'].get('content-length')) 112 | else: 113 | response_dict['body'] = http_response.content 114 | 115 | parser = parsers.create_parser(protocol) 116 | return http_response, parser.parse(response_dict, 117 | operation_model.output_shape) 118 | -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/botocore/vendored/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amazon-archives/aws-cfn-resource-bridge/4d37be1ee2684ef7dadeb4d273d82573c26b0736/aws/cfn/bridge/vendored/botocore/vendored/__init__.py -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/botocore/vendored/requests/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # __ 4 | # /__) _ _ _ _ _/ _ 5 | # / ( (- (/ (/ (- _) / _) 6 | # / 7 | 8 | """ 9 | requests HTTP library 10 | ~~~~~~~~~~~~~~~~~~~~~ 11 | 12 | Requests is an HTTP library, written in Python, for human beings. Basic GET 13 | usage: 14 | 15 | >>> import requests 16 | >>> r = requests.get('http://python.org') 17 | >>> r.status_code 18 | 200 19 | >>> 'Python is a programming language' in r.content 20 | True 21 | 22 | ... or POST: 23 | 24 | >>> payload = dict(key1='value1', key2='value2') 25 | >>> r = requests.post("http://httpbin.org/post", data=payload) 26 | >>> print(r.text) 27 | { 28 | ... 29 | "form": { 30 | "key2": "value2", 31 | "key1": "value1" 32 | }, 33 | ... 34 | } 35 | 36 | The other HTTP methods are supported - see `requests.api`. Full documentation 37 | is at . 38 | 39 | :copyright: (c) 2013 by Kenneth Reitz. 40 | :license: Apache 2.0, see LICENSE for more details. 41 | 42 | """ 43 | 44 | __title__ = 'requests' 45 | __version__ = '2.0.1' 46 | __build__ = 0x020001 47 | __author__ = 'Kenneth Reitz' 48 | __license__ = 'Apache 2.0' 49 | __copyright__ = 'Copyright 2013 Kenneth Reitz' 50 | 51 | # Attempt to enable urllib3's SNI support, if possible 52 | try: 53 | from .packages.urllib3.contrib import pyopenssl 54 | pyopenssl.inject_into_urllib3() 55 | except ImportError: 56 | pass 57 | 58 | from . import utils 59 | from .models import Request, Response, PreparedRequest 60 | from .api import request, get, head, post, patch, put, delete, options 61 | from .sessions import session, Session 62 | from .status_codes import codes 63 | from .exceptions import ( 64 | RequestException, Timeout, URLRequired, 65 | TooManyRedirects, HTTPError, ConnectionError 66 | ) 67 | 68 | # Set default logging handler to avoid "No handler found" warnings. 69 | import logging 70 | try: # Python 2.7+ 71 | from logging import NullHandler 72 | except ImportError: 73 | class NullHandler(logging.Handler): 74 | def emit(self, record): 75 | pass 76 | 77 | logging.getLogger(__name__).addHandler(NullHandler()) 78 | -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/botocore/vendored/requests/api.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | """ 4 | requests.api 5 | ~~~~~~~~~~~~ 6 | 7 | This module implements the Requests API. 8 | 9 | :copyright: (c) 2012 by Kenneth Reitz. 10 | :license: Apache2, see LICENSE for more details. 11 | 12 | """ 13 | 14 | from . import sessions 15 | 16 | 17 | def request(method, url, **kwargs): 18 | """Constructs and sends a :class:`Request `. 19 | Returns :class:`Response ` object. 20 | 21 | :param method: method for the new :class:`Request` object. 22 | :param url: URL for the new :class:`Request` object. 23 | :param params: (optional) Dictionary or bytes to be sent in the query string for the :class:`Request`. 24 | :param data: (optional) Dictionary, bytes, or file-like object to send in the body of the :class:`Request`. 25 | :param headers: (optional) Dictionary of HTTP Headers to send with the :class:`Request`. 26 | :param cookies: (optional) Dict or CookieJar object to send with the :class:`Request`. 27 | :param files: (optional) Dictionary of 'name': file-like-objects (or {'name': ('filename', fileobj)}) for multipart encoding upload. 28 | :param auth: (optional) Auth tuple to enable Basic/Digest/Custom HTTP Auth. 29 | :param timeout: (optional) Float describing the timeout of the request. 30 | :param allow_redirects: (optional) Boolean. Set to True if POST/PUT/DELETE redirect following is allowed. 31 | :param proxies: (optional) Dictionary mapping protocol to the URL of the proxy. 32 | :param verify: (optional) if ``True``, the SSL cert will be verified. A CA_BUNDLE path can also be provided. 33 | :param stream: (optional) if ``False``, the response content will be immediately downloaded. 34 | :param cert: (optional) if String, path to ssl client cert file (.pem). If Tuple, ('cert', 'key') pair. 35 | 36 | Usage:: 37 | 38 | >>> import requests 39 | >>> req = requests.request('GET', 'http://httpbin.org/get') 40 | 41 | """ 42 | 43 | session = sessions.Session() 44 | return session.request(method=method, url=url, **kwargs) 45 | 46 | 47 | def get(url, **kwargs): 48 | """Sends a GET request. Returns :class:`Response` object. 49 | 50 | :param url: URL for the new :class:`Request` object. 51 | :param \*\*kwargs: Optional arguments that ``request`` takes. 52 | """ 53 | 54 | kwargs.setdefault('allow_redirects', True) 55 | return request('get', url, **kwargs) 56 | 57 | 58 | def options(url, **kwargs): 59 | """Sends a OPTIONS request. Returns :class:`Response` object. 60 | 61 | :param url: URL for the new :class:`Request` object. 62 | :param \*\*kwargs: Optional arguments that ``request`` takes. 63 | """ 64 | 65 | kwargs.setdefault('allow_redirects', True) 66 | return request('options', url, **kwargs) 67 | 68 | 69 | def head(url, **kwargs): 70 | """Sends a HEAD request. Returns :class:`Response` object. 71 | 72 | :param url: URL for the new :class:`Request` object. 73 | :param \*\*kwargs: Optional arguments that ``request`` takes. 74 | """ 75 | 76 | kwargs.setdefault('allow_redirects', False) 77 | return request('head', url, **kwargs) 78 | 79 | 80 | def post(url, data=None, **kwargs): 81 | """Sends a POST request. Returns :class:`Response` object. 82 | 83 | :param url: URL for the new :class:`Request` object. 84 | :param data: (optional) Dictionary, bytes, or file-like object to send in the body of the :class:`Request`. 85 | :param \*\*kwargs: Optional arguments that ``request`` takes. 86 | """ 87 | 88 | return request('post', url, data=data, **kwargs) 89 | 90 | 91 | def put(url, data=None, **kwargs): 92 | """Sends a PUT request. Returns :class:`Response` object. 93 | 94 | :param url: URL for the new :class:`Request` object. 95 | :param data: (optional) Dictionary, bytes, or file-like object to send in the body of the :class:`Request`. 96 | :param \*\*kwargs: Optional arguments that ``request`` takes. 97 | """ 98 | 99 | return request('put', url, data=data, **kwargs) 100 | 101 | 102 | def patch(url, data=None, **kwargs): 103 | """Sends a PATCH request. Returns :class:`Response` object. 104 | 105 | :param url: URL for the new :class:`Request` object. 106 | :param data: (optional) Dictionary, bytes, or file-like object to send in the body of the :class:`Request`. 107 | :param \*\*kwargs: Optional arguments that ``request`` takes. 108 | """ 109 | 110 | return request('patch', url, data=data, **kwargs) 111 | 112 | 113 | def delete(url, **kwargs): 114 | """Sends a DELETE request. Returns :class:`Response` object. 115 | 116 | :param url: URL for the new :class:`Request` object. 117 | :param \*\*kwargs: Optional arguments that ``request`` takes. 118 | """ 119 | 120 | return request('delete', url, **kwargs) 121 | -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/botocore/vendored/requests/certs.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | """ 5 | certs.py 6 | ~~~~~~~~ 7 | 8 | This module returns the preferred default CA certificate bundle. 9 | 10 | If you are packaging Requests, e.g., for a Linux distribution or a managed 11 | environment, you can change the definition of where() to return a separately 12 | packaged CA bundle. 13 | """ 14 | 15 | import os.path 16 | 17 | 18 | def where(): 19 | """Return the preferred certificate bundle.""" 20 | # vendored bundle inside Requests 21 | return os.path.join(os.path.dirname(__file__), 'cacert.pem') 22 | 23 | if __name__ == '__main__': 24 | print(where()) 25 | -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/botocore/vendored/requests/compat.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | """ 4 | pythoncompat 5 | """ 6 | 7 | from .packages import charade as chardet 8 | 9 | import sys 10 | 11 | # ------- 12 | # Pythons 13 | # ------- 14 | 15 | # Syntax sugar. 16 | _ver = sys.version_info 17 | 18 | #: Python 2.x? 19 | is_py2 = (_ver[0] == 2) 20 | 21 | #: Python 3.x? 22 | is_py3 = (_ver[0] == 3) 23 | 24 | #: Python 3.0.x 25 | is_py30 = (is_py3 and _ver[1] == 0) 26 | 27 | #: Python 3.1.x 28 | is_py31 = (is_py3 and _ver[1] == 1) 29 | 30 | #: Python 3.2.x 31 | is_py32 = (is_py3 and _ver[1] == 2) 32 | 33 | #: Python 3.3.x 34 | is_py33 = (is_py3 and _ver[1] == 3) 35 | 36 | #: Python 3.4.x 37 | is_py34 = (is_py3 and _ver[1] == 4) 38 | 39 | #: Python 2.7.x 40 | is_py27 = (is_py2 and _ver[1] == 7) 41 | 42 | #: Python 2.6.x 43 | is_py26 = (is_py2 and _ver[1] == 6) 44 | 45 | #: Python 2.5.x 46 | is_py25 = (is_py2 and _ver[1] == 5) 47 | 48 | #: Python 2.4.x 49 | is_py24 = (is_py2 and _ver[1] == 4) # I'm assuming this is not by choice. 50 | 51 | 52 | # --------- 53 | # Platforms 54 | # --------- 55 | 56 | 57 | # Syntax sugar. 58 | _ver = sys.version.lower() 59 | 60 | is_pypy = ('pypy' in _ver) 61 | is_jython = ('jython' in _ver) 62 | is_ironpython = ('iron' in _ver) 63 | 64 | # Assume CPython, if nothing else. 65 | is_cpython = not any((is_pypy, is_jython, is_ironpython)) 66 | 67 | # Windows-based system. 68 | is_windows = 'win32' in str(sys.platform).lower() 69 | 70 | # Standard Linux 2+ system. 71 | is_linux = ('linux' in str(sys.platform).lower()) 72 | is_osx = ('darwin' in str(sys.platform).lower()) 73 | is_hpux = ('hpux' in str(sys.platform).lower()) # Complete guess. 74 | is_solaris = ('solar==' in str(sys.platform).lower()) # Complete guess. 75 | 76 | try: 77 | import simplejson as json 78 | except ImportError: 79 | import json 80 | 81 | # --------- 82 | # Specifics 83 | # --------- 84 | 85 | if is_py2: 86 | from urllib import quote, unquote, quote_plus, unquote_plus, urlencode, getproxies, proxy_bypass 87 | from urlparse import urlparse, urlunparse, urljoin, urlsplit, urldefrag 88 | from urllib2 import parse_http_list 89 | import cookielib 90 | from Cookie import Morsel 91 | from StringIO import StringIO 92 | from .packages.urllib3.packages.ordered_dict import OrderedDict 93 | from httplib import IncompleteRead 94 | 95 | builtin_str = str 96 | bytes = str 97 | str = unicode 98 | basestring = basestring 99 | numeric_types = (int, long, float) 100 | 101 | 102 | elif is_py3: 103 | from urllib.parse import urlparse, urlunparse, urljoin, urlsplit, urlencode, quote, unquote, quote_plus, unquote_plus, urldefrag 104 | from urllib.request import parse_http_list, getproxies, proxy_bypass 105 | from http import cookiejar as cookielib 106 | from http.cookies import Morsel 107 | from io import StringIO 108 | from collections import OrderedDict 109 | from http.client import IncompleteRead 110 | 111 | builtin_str = str 112 | str = str 113 | bytes = bytes 114 | basestring = (str, bytes) 115 | numeric_types = (int, float) 116 | -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/botocore/vendored/requests/exceptions.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | """ 4 | requests.exceptions 5 | ~~~~~~~~~~~~~~~~~~~ 6 | 7 | This module contains the set of Requests' exceptions. 8 | 9 | """ 10 | 11 | 12 | class RequestException(IOError): 13 | """There was an ambiguous exception that occurred while handling your 14 | request.""" 15 | 16 | 17 | class HTTPError(RequestException): 18 | """An HTTP error occurred.""" 19 | 20 | def __init__(self, *args, **kwargs): 21 | """ Initializes HTTPError with optional `response` object. """ 22 | self.response = kwargs.pop('response', None) 23 | super(HTTPError, self).__init__(*args, **kwargs) 24 | 25 | 26 | class ConnectionError(RequestException): 27 | """A Connection error occurred.""" 28 | 29 | 30 | class ProxyError(ConnectionError): 31 | """A proxy error occurred.""" 32 | 33 | 34 | class SSLError(ConnectionError): 35 | """An SSL error occurred.""" 36 | 37 | 38 | class Timeout(RequestException): 39 | """The request timed out.""" 40 | 41 | 42 | class URLRequired(RequestException): 43 | """A valid URL is required to make a request.""" 44 | 45 | 46 | class TooManyRedirects(RequestException): 47 | """Too many redirects.""" 48 | 49 | 50 | class MissingSchema(RequestException, ValueError): 51 | """The URL schema (e.g. http or https) is missing.""" 52 | 53 | 54 | class InvalidSchema(RequestException, ValueError): 55 | """See defaults.py for valid schemas.""" 56 | 57 | 58 | class InvalidURL(RequestException, ValueError): 59 | """ The URL provided was somehow invalid. """ 60 | 61 | 62 | class ChunkedEncodingError(RequestException): 63 | """The server declared chunked encoding but sent an invalid chunk.""" 64 | -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/botocore/vendored/requests/hooks.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | """ 4 | requests.hooks 5 | ~~~~~~~~~~~~~~ 6 | 7 | This module provides the capabilities for the Requests hooks system. 8 | 9 | Available hooks: 10 | 11 | ``response``: 12 | The response generated from a Request. 13 | 14 | """ 15 | 16 | 17 | HOOKS = ['response'] 18 | 19 | 20 | def default_hooks(): 21 | hooks = {} 22 | for event in HOOKS: 23 | hooks[event] = [] 24 | return hooks 25 | 26 | # TODO: response is the only one 27 | 28 | 29 | def dispatch_hook(key, hooks, hook_data, **kwargs): 30 | """Dispatches a hook dictionary on a given piece of data.""" 31 | 32 | hooks = hooks or dict() 33 | 34 | if key in hooks: 35 | hooks = hooks.get(key) 36 | 37 | if hasattr(hooks, '__call__'): 38 | hooks = [hooks] 39 | 40 | for hook in hooks: 41 | _hook_data = hook(hook_data, **kwargs) 42 | if _hook_data is not None: 43 | hook_data = _hook_data 44 | 45 | return hook_data 46 | -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/botocore/vendored/requests/packages/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | 3 | from . import urllib3 4 | -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/botocore/vendored/requests/packages/charade/__init__.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # This library is free software; you can redistribute it and/or 3 | # modify it under the terms of the GNU Lesser General Public 4 | # License as published by the Free Software Foundation; either 5 | # version 2.1 of the License, or (at your option) any later version. 6 | # 7 | # This library is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 10 | # Lesser General Public License for more details. 11 | # 12 | # You should have received a copy of the GNU Lesser General Public 13 | # License along with this library; if not, write to the Free Software 14 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 15 | # 02110-1301 USA 16 | ######################### END LICENSE BLOCK ######################### 17 | 18 | __version__ = "1.0.3" 19 | from sys import version_info 20 | 21 | 22 | def detect(aBuf): 23 | if ((version_info < (3, 0) and isinstance(aBuf, unicode)) or 24 | (version_info >= (3, 0) and not isinstance(aBuf, bytes))): 25 | raise ValueError('Expected a bytes object, not a unicode object') 26 | 27 | from . import universaldetector 28 | u = universaldetector.UniversalDetector() 29 | u.reset() 30 | u.feed(aBuf) 31 | u.close() 32 | return u.result 33 | 34 | def _description_of(path): 35 | """Return a string describing the probable encoding of a file.""" 36 | from charade.universaldetector import UniversalDetector 37 | 38 | u = UniversalDetector() 39 | for line in open(path, 'rb'): 40 | u.feed(line) 41 | u.close() 42 | result = u.result 43 | if result['encoding']: 44 | return '%s: %s with confidence %s' % (path, 45 | result['encoding'], 46 | result['confidence']) 47 | else: 48 | return '%s: no result' % path 49 | 50 | 51 | def charade_cli(): 52 | """ 53 | Script which takes one or more file paths and reports on their detected 54 | encodings 55 | 56 | Example:: 57 | 58 | % chardetect.py somefile someotherfile 59 | somefile: windows-1252 with confidence 0.5 60 | someotherfile: ascii with confidence 1.0 61 | 62 | """ 63 | from sys import argv 64 | for path in argv[1:]: 65 | print(_description_of(path)) 66 | -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/botocore/vendored/requests/packages/charade/__main__.py: -------------------------------------------------------------------------------- 1 | ''' 2 | support ';python -m charade [file2] ...' package execution syntax (2.7+) 3 | ''' 4 | 5 | from charade import charade_cli 6 | 7 | charade_cli() 8 | -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/botocore/vendored/requests/packages/charade/big5prober.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # The Original Code is Mozilla Communicator client code. 3 | # 4 | # The Initial Developer of the Original Code is 5 | # Netscape Communications Corporation. 6 | # Portions created by the Initial Developer are Copyright (C) 1998 7 | # the Initial Developer. All Rights Reserved. 8 | # 9 | # Contributor(s): 10 | # Mark Pilgrim - port to Python 11 | # 12 | # This library is free software; you can redistribute it and/or 13 | # modify it under the terms of the GNU Lesser General Public 14 | # License as published by the Free Software Foundation; either 15 | # version 2.1 of the License, or (at your option) any later version. 16 | # 17 | # This library is distributed in the hope that it will be useful, 18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 | # Lesser General Public License for more details. 21 | # 22 | # You should have received a copy of the GNU Lesser General Public 23 | # License along with this library; if not, write to the Free Software 24 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 25 | # 02110-1301 USA 26 | ######################### END LICENSE BLOCK ######################### 27 | 28 | from .mbcharsetprober import MultiByteCharSetProber 29 | from .codingstatemachine import CodingStateMachine 30 | from .chardistribution import Big5DistributionAnalysis 31 | from .mbcssm import Big5SMModel 32 | 33 | 34 | class Big5Prober(MultiByteCharSetProber): 35 | def __init__(self): 36 | MultiByteCharSetProber.__init__(self) 37 | self._mCodingSM = CodingStateMachine(Big5SMModel) 38 | self._mDistributionAnalyzer = Big5DistributionAnalysis() 39 | self.reset() 40 | 41 | def get_charset_name(self): 42 | return "Big5" 43 | -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/botocore/vendored/requests/packages/charade/charsetgroupprober.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # The Original Code is Mozilla Communicator client code. 3 | # 4 | # The Initial Developer of the Original Code is 5 | # Netscape Communications Corporation. 6 | # Portions created by the Initial Developer are Copyright (C) 1998 7 | # the Initial Developer. All Rights Reserved. 8 | # 9 | # Contributor(s): 10 | # Mark Pilgrim - port to Python 11 | # 12 | # This library is free software; you can redistribute it and/or 13 | # modify it under the terms of the GNU Lesser General Public 14 | # License as published by the Free Software Foundation; either 15 | # version 2.1 of the License, or (at your option) any later version. 16 | # 17 | # This library is distributed in the hope that it will be useful, 18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 | # Lesser General Public License for more details. 21 | # 22 | # You should have received a copy of the GNU Lesser General Public 23 | # License along with this library; if not, write to the Free Software 24 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 25 | # 02110-1301 USA 26 | ######################### END LICENSE BLOCK ######################### 27 | 28 | from . import constants 29 | import sys 30 | from .charsetprober import CharSetProber 31 | 32 | 33 | class CharSetGroupProber(CharSetProber): 34 | def __init__(self): 35 | CharSetProber.__init__(self) 36 | self._mActiveNum = 0 37 | self._mProbers = [] 38 | self._mBestGuessProber = None 39 | 40 | def reset(self): 41 | CharSetProber.reset(self) 42 | self._mActiveNum = 0 43 | for prober in self._mProbers: 44 | if prober: 45 | prober.reset() 46 | prober.active = True 47 | self._mActiveNum += 1 48 | self._mBestGuessProber = None 49 | 50 | def get_charset_name(self): 51 | if not self._mBestGuessProber: 52 | self.get_confidence() 53 | if not self._mBestGuessProber: 54 | return None 55 | # self._mBestGuessProber = self._mProbers[0] 56 | return self._mBestGuessProber.get_charset_name() 57 | 58 | def feed(self, aBuf): 59 | for prober in self._mProbers: 60 | if not prober: 61 | continue 62 | if not prober.active: 63 | continue 64 | st = prober.feed(aBuf) 65 | if not st: 66 | continue 67 | if st == constants.eFoundIt: 68 | self._mBestGuessProber = prober 69 | return self.get_state() 70 | elif st == constants.eNotMe: 71 | prober.active = False 72 | self._mActiveNum -= 1 73 | if self._mActiveNum <= 0: 74 | self._mState = constants.eNotMe 75 | return self.get_state() 76 | return self.get_state() 77 | 78 | def get_confidence(self): 79 | st = self.get_state() 80 | if st == constants.eFoundIt: 81 | return 0.99 82 | elif st == constants.eNotMe: 83 | return 0.01 84 | bestConf = 0.0 85 | self._mBestGuessProber = None 86 | for prober in self._mProbers: 87 | if not prober: 88 | continue 89 | if not prober.active: 90 | if constants._debug: 91 | sys.stderr.write(prober.get_charset_name() 92 | + ' not active\n') 93 | continue 94 | cf = prober.get_confidence() 95 | if constants._debug: 96 | sys.stderr.write('%s confidence = %s\n' % 97 | (prober.get_charset_name(), cf)) 98 | if bestConf < cf: 99 | bestConf = cf 100 | self._mBestGuessProber = prober 101 | if not self._mBestGuessProber: 102 | return 0.0 103 | return bestConf 104 | # else: 105 | # self._mBestGuessProber = self._mProbers[0] 106 | # return self._mBestGuessProber.get_confidence() 107 | -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/botocore/vendored/requests/packages/charade/charsetprober.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # The Original Code is Mozilla Universal charset detector code. 3 | # 4 | # The Initial Developer of the Original Code is 5 | # Netscape Communications Corporation. 6 | # Portions created by the Initial Developer are Copyright (C) 2001 7 | # the Initial Developer. All Rights Reserved. 8 | # 9 | # Contributor(s): 10 | # Mark Pilgrim - port to Python 11 | # Shy Shalom - original C code 12 | # 13 | # This library is free software; you can redistribute it and/or 14 | # modify it under the terms of the GNU Lesser General Public 15 | # License as published by the Free Software Foundation; either 16 | # version 2.1 of the License, or (at your option) any later version. 17 | # 18 | # This library is distributed in the hope that it will be useful, 19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21 | # Lesser General Public License for more details. 22 | # 23 | # You should have received a copy of the GNU Lesser General Public 24 | # License along with this library; if not, write to the Free Software 25 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 26 | # 02110-1301 USA 27 | ######################### END LICENSE BLOCK ######################### 28 | 29 | from . import constants 30 | import re 31 | 32 | 33 | class CharSetProber: 34 | def __init__(self): 35 | pass 36 | 37 | def reset(self): 38 | self._mState = constants.eDetecting 39 | 40 | def get_charset_name(self): 41 | return None 42 | 43 | def feed(self, aBuf): 44 | pass 45 | 46 | def get_state(self): 47 | return self._mState 48 | 49 | def get_confidence(self): 50 | return 0.0 51 | 52 | def filter_high_bit_only(self, aBuf): 53 | aBuf = re.sub(b'([\x00-\x7F])+', b' ', aBuf) 54 | return aBuf 55 | 56 | def filter_without_english_letters(self, aBuf): 57 | aBuf = re.sub(b'([A-Za-z])+', b' ', aBuf) 58 | return aBuf 59 | 60 | def filter_with_english_letters(self, aBuf): 61 | # TODO 62 | return aBuf 63 | -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/botocore/vendored/requests/packages/charade/codingstatemachine.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # The Original Code is mozilla.org code. 3 | # 4 | # The Initial Developer of the Original Code is 5 | # Netscape Communications Corporation. 6 | # Portions created by the Initial Developer are Copyright (C) 1998 7 | # the Initial Developer. All Rights Reserved. 8 | # 9 | # Contributor(s): 10 | # Mark Pilgrim - port to Python 11 | # 12 | # This library is free software; you can redistribute it and/or 13 | # modify it under the terms of the GNU Lesser General Public 14 | # License as published by the Free Software Foundation; either 15 | # version 2.1 of the License, or (at your option) any later version. 16 | # 17 | # This library is distributed in the hope that it will be useful, 18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 | # Lesser General Public License for more details. 21 | # 22 | # You should have received a copy of the GNU Lesser General Public 23 | # License along with this library; if not, write to the Free Software 24 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 25 | # 02110-1301 USA 26 | ######################### END LICENSE BLOCK ######################### 27 | 28 | from .constants import eStart 29 | from .compat import wrap_ord 30 | 31 | 32 | class CodingStateMachine: 33 | def __init__(self, sm): 34 | self._mModel = sm 35 | self._mCurrentBytePos = 0 36 | self._mCurrentCharLen = 0 37 | self.reset() 38 | 39 | def reset(self): 40 | self._mCurrentState = eStart 41 | 42 | def next_state(self, c): 43 | # for each byte we get its class 44 | # if it is first byte, we also get byte length 45 | # PY3K: aBuf is a byte stream, so c is an int, not a byte 46 | byteCls = self._mModel['classTable'][wrap_ord(c)] 47 | if self._mCurrentState == eStart: 48 | self._mCurrentBytePos = 0 49 | self._mCurrentCharLen = self._mModel['charLenTable'][byteCls] 50 | # from byte's class and stateTable, we get its next state 51 | curr_state = (self._mCurrentState * self._mModel['classFactor'] 52 | + byteCls) 53 | self._mCurrentState = self._mModel['stateTable'][curr_state] 54 | self._mCurrentBytePos += 1 55 | return self._mCurrentState 56 | 57 | def get_current_charlen(self): 58 | return self._mCurrentCharLen 59 | 60 | def get_coding_state_machine(self): 61 | return self._mModel['name'] 62 | -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/botocore/vendored/requests/packages/charade/compat.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # Contributor(s): 3 | # Ian Cordasco - port to Python 4 | # 5 | # This library is free software; you can redistribute it and/or 6 | # modify it under the terms of the GNU Lesser General Public 7 | # License as published by the Free Software Foundation; either 8 | # version 2.1 of the License, or (at your option) any later version. 9 | # 10 | # This library is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | # Lesser General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU Lesser General Public 16 | # License along with this library; if not, write to the Free Software 17 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | # 02110-1301 USA 19 | ######################### END LICENSE BLOCK ######################### 20 | 21 | import sys 22 | 23 | 24 | if sys.version_info < (3, 0): 25 | base_str = (str, unicode) 26 | else: 27 | base_str = (bytes, str) 28 | 29 | 30 | def wrap_ord(a): 31 | if sys.version_info < (3, 0) and isinstance(a, base_str): 32 | return ord(a) 33 | else: 34 | return a 35 | -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/botocore/vendored/requests/packages/charade/constants.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # The Original Code is Mozilla Universal charset detector code. 3 | # 4 | # The Initial Developer of the Original Code is 5 | # Netscape Communications Corporation. 6 | # Portions created by the Initial Developer are Copyright (C) 2001 7 | # the Initial Developer. All Rights Reserved. 8 | # 9 | # Contributor(s): 10 | # Mark Pilgrim - port to Python 11 | # Shy Shalom - original C code 12 | # 13 | # This library is free software; you can redistribute it and/or 14 | # modify it under the terms of the GNU Lesser General Public 15 | # License as published by the Free Software Foundation; either 16 | # version 2.1 of the License, or (at your option) any later version. 17 | # 18 | # This library is distributed in the hope that it will be useful, 19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21 | # Lesser General Public License for more details. 22 | # 23 | # You should have received a copy of the GNU Lesser General Public 24 | # License along with this library; if not, write to the Free Software 25 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 26 | # 02110-1301 USA 27 | ######################### END LICENSE BLOCK ######################### 28 | 29 | _debug = 0 30 | 31 | eDetecting = 0 32 | eFoundIt = 1 33 | eNotMe = 2 34 | 35 | eStart = 0 36 | eError = 1 37 | eItsMe = 2 38 | 39 | SHORTCUT_THRESHOLD = 0.95 40 | -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/botocore/vendored/requests/packages/charade/cp949prober.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # The Original Code is mozilla.org code. 3 | # 4 | # The Initial Developer of the Original Code is 5 | # Netscape Communications Corporation. 6 | # Portions created by the Initial Developer are Copyright (C) 1998 7 | # the Initial Developer. All Rights Reserved. 8 | # 9 | # Contributor(s): 10 | # Mark Pilgrim - port to Python 11 | # 12 | # This library is free software; you can redistribute it and/or 13 | # modify it under the terms of the GNU Lesser General Public 14 | # License as published by the Free Software Foundation; either 15 | # version 2.1 of the License, or (at your option) any later version. 16 | # 17 | # This library is distributed in the hope that it will be useful, 18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 | # Lesser General Public License for more details. 21 | # 22 | # You should have received a copy of the GNU Lesser General Public 23 | # License along with this library; if not, write to the Free Software 24 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 25 | # 02110-1301 USA 26 | ######################### END LICENSE BLOCK ######################### 27 | 28 | from .mbcharsetprober import MultiByteCharSetProber 29 | from .codingstatemachine import CodingStateMachine 30 | from .chardistribution import EUCKRDistributionAnalysis 31 | from .mbcssm import CP949SMModel 32 | 33 | 34 | class CP949Prober(MultiByteCharSetProber): 35 | def __init__(self): 36 | MultiByteCharSetProber.__init__(self) 37 | self._mCodingSM = CodingStateMachine(CP949SMModel) 38 | # NOTE: CP949 is a superset of EUC-KR, so the distribution should be 39 | # not different. 40 | self._mDistributionAnalyzer = EUCKRDistributionAnalysis() 41 | self.reset() 42 | 43 | def get_charset_name(self): 44 | return "CP949" 45 | -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/botocore/vendored/requests/packages/charade/escprober.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # The Original Code is mozilla.org code. 3 | # 4 | # The Initial Developer of the Original Code is 5 | # Netscape Communications Corporation. 6 | # Portions created by the Initial Developer are Copyright (C) 1998 7 | # the Initial Developer. All Rights Reserved. 8 | # 9 | # Contributor(s): 10 | # Mark Pilgrim - port to Python 11 | # 12 | # This library is free software; you can redistribute it and/or 13 | # modify it under the terms of the GNU Lesser General Public 14 | # License as published by the Free Software Foundation; either 15 | # version 2.1 of the License, or (at your option) any later version. 16 | # 17 | # This library is distributed in the hope that it will be useful, 18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 | # Lesser General Public License for more details. 21 | # 22 | # You should have received a copy of the GNU Lesser General Public 23 | # License along with this library; if not, write to the Free Software 24 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 25 | # 02110-1301 USA 26 | ######################### END LICENSE BLOCK ######################### 27 | 28 | from . import constants 29 | from .escsm import (HZSMModel, ISO2022CNSMModel, ISO2022JPSMModel, 30 | ISO2022KRSMModel) 31 | from .charsetprober import CharSetProber 32 | from .codingstatemachine import CodingStateMachine 33 | from .compat import wrap_ord 34 | 35 | 36 | class EscCharSetProber(CharSetProber): 37 | def __init__(self): 38 | CharSetProber.__init__(self) 39 | self._mCodingSM = [ 40 | CodingStateMachine(HZSMModel), 41 | CodingStateMachine(ISO2022CNSMModel), 42 | CodingStateMachine(ISO2022JPSMModel), 43 | CodingStateMachine(ISO2022KRSMModel) 44 | ] 45 | self.reset() 46 | 47 | def reset(self): 48 | CharSetProber.reset(self) 49 | for codingSM in self._mCodingSM: 50 | if not codingSM: 51 | continue 52 | codingSM.active = True 53 | codingSM.reset() 54 | self._mActiveSM = len(self._mCodingSM) 55 | self._mDetectedCharset = None 56 | 57 | def get_charset_name(self): 58 | return self._mDetectedCharset 59 | 60 | def get_confidence(self): 61 | if self._mDetectedCharset: 62 | return 0.99 63 | else: 64 | return 0.00 65 | 66 | def feed(self, aBuf): 67 | for c in aBuf: 68 | # PY3K: aBuf is a byte array, so c is an int, not a byte 69 | for codingSM in self._mCodingSM: 70 | if not codingSM: 71 | continue 72 | if not codingSM.active: 73 | continue 74 | codingState = codingSM.next_state(wrap_ord(c)) 75 | if codingState == constants.eError: 76 | codingSM.active = False 77 | self._mActiveSM -= 1 78 | if self._mActiveSM <= 0: 79 | self._mState = constants.eNotMe 80 | return self.get_state() 81 | elif codingState == constants.eItsMe: 82 | self._mState = constants.eFoundIt 83 | self._mDetectedCharset = codingSM.get_coding_state_machine() # nopep8 84 | return self.get_state() 85 | 86 | return self.get_state() 87 | -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/botocore/vendored/requests/packages/charade/eucjpprober.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # The Original Code is mozilla.org code. 3 | # 4 | # The Initial Developer of the Original Code is 5 | # Netscape Communications Corporation. 6 | # Portions created by the Initial Developer are Copyright (C) 1998 7 | # the Initial Developer. All Rights Reserved. 8 | # 9 | # Contributor(s): 10 | # Mark Pilgrim - port to Python 11 | # 12 | # This library is free software; you can redistribute it and/or 13 | # modify it under the terms of the GNU Lesser General Public 14 | # License as published by the Free Software Foundation; either 15 | # version 2.1 of the License, or (at your option) any later version. 16 | # 17 | # This library is distributed in the hope that it will be useful, 18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 | # Lesser General Public License for more details. 21 | # 22 | # You should have received a copy of the GNU Lesser General Public 23 | # License along with this library; if not, write to the Free Software 24 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 25 | # 02110-1301 USA 26 | ######################### END LICENSE BLOCK ######################### 27 | 28 | import sys 29 | from . import constants 30 | from .mbcharsetprober import MultiByteCharSetProber 31 | from .codingstatemachine import CodingStateMachine 32 | from .chardistribution import EUCJPDistributionAnalysis 33 | from .jpcntx import EUCJPContextAnalysis 34 | from .mbcssm import EUCJPSMModel 35 | 36 | 37 | class EUCJPProber(MultiByteCharSetProber): 38 | def __init__(self): 39 | MultiByteCharSetProber.__init__(self) 40 | self._mCodingSM = CodingStateMachine(EUCJPSMModel) 41 | self._mDistributionAnalyzer = EUCJPDistributionAnalysis() 42 | self._mContextAnalyzer = EUCJPContextAnalysis() 43 | self.reset() 44 | 45 | def reset(self): 46 | MultiByteCharSetProber.reset(self) 47 | self._mContextAnalyzer.reset() 48 | 49 | def get_charset_name(self): 50 | return "EUC-JP" 51 | 52 | def feed(self, aBuf): 53 | aLen = len(aBuf) 54 | for i in range(0, aLen): 55 | # PY3K: aBuf is a byte array, so aBuf[i] is an int, not a byte 56 | codingState = self._mCodingSM.next_state(aBuf[i]) 57 | if codingState == constants.eError: 58 | if constants._debug: 59 | sys.stderr.write(self.get_charset_name() 60 | + ' prober hit error at byte ' + str(i) 61 | + '\n') 62 | self._mState = constants.eNotMe 63 | break 64 | elif codingState == constants.eItsMe: 65 | self._mState = constants.eFoundIt 66 | break 67 | elif codingState == constants.eStart: 68 | charLen = self._mCodingSM.get_current_charlen() 69 | if i == 0: 70 | self._mLastChar[1] = aBuf[0] 71 | self._mContextAnalyzer.feed(self._mLastChar, charLen) 72 | self._mDistributionAnalyzer.feed(self._mLastChar, charLen) 73 | else: 74 | self._mContextAnalyzer.feed(aBuf[i - 1:i + 1], charLen) 75 | self._mDistributionAnalyzer.feed(aBuf[i - 1:i + 1], 76 | charLen) 77 | 78 | self._mLastChar[0] = aBuf[aLen - 1] 79 | 80 | if self.get_state() == constants.eDetecting: 81 | if (self._mContextAnalyzer.got_enough_data() and 82 | (self.get_confidence() > constants.SHORTCUT_THRESHOLD)): 83 | self._mState = constants.eFoundIt 84 | 85 | return self.get_state() 86 | 87 | def get_confidence(self): 88 | contxtCf = self._mContextAnalyzer.get_confidence() 89 | distribCf = self._mDistributionAnalyzer.get_confidence() 90 | return max(contxtCf, distribCf) 91 | -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/botocore/vendored/requests/packages/charade/euckrprober.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # The Original Code is mozilla.org code. 3 | # 4 | # The Initial Developer of the Original Code is 5 | # Netscape Communications Corporation. 6 | # Portions created by the Initial Developer are Copyright (C) 1998 7 | # the Initial Developer. All Rights Reserved. 8 | # 9 | # Contributor(s): 10 | # Mark Pilgrim - port to Python 11 | # 12 | # This library is free software; you can redistribute it and/or 13 | # modify it under the terms of the GNU Lesser General Public 14 | # License as published by the Free Software Foundation; either 15 | # version 2.1 of the License, or (at your option) any later version. 16 | # 17 | # This library is distributed in the hope that it will be useful, 18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 | # Lesser General Public License for more details. 21 | # 22 | # You should have received a copy of the GNU Lesser General Public 23 | # License along with this library; if not, write to the Free Software 24 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 25 | # 02110-1301 USA 26 | ######################### END LICENSE BLOCK ######################### 27 | 28 | from .mbcharsetprober import MultiByteCharSetProber 29 | from .codingstatemachine import CodingStateMachine 30 | from .chardistribution import EUCKRDistributionAnalysis 31 | from .mbcssm import EUCKRSMModel 32 | 33 | 34 | class EUCKRProber(MultiByteCharSetProber): 35 | def __init__(self): 36 | MultiByteCharSetProber.__init__(self) 37 | self._mCodingSM = CodingStateMachine(EUCKRSMModel) 38 | self._mDistributionAnalyzer = EUCKRDistributionAnalysis() 39 | self.reset() 40 | 41 | def get_charset_name(self): 42 | return "EUC-KR" 43 | -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/botocore/vendored/requests/packages/charade/euctwprober.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # The Original Code is mozilla.org code. 3 | # 4 | # The Initial Developer of the Original Code is 5 | # Netscape Communications Corporation. 6 | # Portions created by the Initial Developer are Copyright (C) 1998 7 | # the Initial Developer. All Rights Reserved. 8 | # 9 | # Contributor(s): 10 | # Mark Pilgrim - port to Python 11 | # 12 | # This library is free software; you can redistribute it and/or 13 | # modify it under the terms of the GNU Lesser General Public 14 | # License as published by the Free Software Foundation; either 15 | # version 2.1 of the License, or (at your option) any later version. 16 | # 17 | # This library is distributed in the hope that it will be useful, 18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 | # Lesser General Public License for more details. 21 | # 22 | # You should have received a copy of the GNU Lesser General Public 23 | # License along with this library; if not, write to the Free Software 24 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 25 | # 02110-1301 USA 26 | ######################### END LICENSE BLOCK ######################### 27 | 28 | from .mbcharsetprober import MultiByteCharSetProber 29 | from .codingstatemachine import CodingStateMachine 30 | from .chardistribution import EUCTWDistributionAnalysis 31 | from .mbcssm import EUCTWSMModel 32 | 33 | class EUCTWProber(MultiByteCharSetProber): 34 | def __init__(self): 35 | MultiByteCharSetProber.__init__(self) 36 | self._mCodingSM = CodingStateMachine(EUCTWSMModel) 37 | self._mDistributionAnalyzer = EUCTWDistributionAnalysis() 38 | self.reset() 39 | 40 | def get_charset_name(self): 41 | return "EUC-TW" 42 | -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/botocore/vendored/requests/packages/charade/gb2312prober.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # The Original Code is mozilla.org code. 3 | # 4 | # The Initial Developer of the Original Code is 5 | # Netscape Communications Corporation. 6 | # Portions created by the Initial Developer are Copyright (C) 1998 7 | # the Initial Developer. All Rights Reserved. 8 | # 9 | # Contributor(s): 10 | # Mark Pilgrim - port to Python 11 | # 12 | # This library is free software; you can redistribute it and/or 13 | # modify it under the terms of the GNU Lesser General Public 14 | # License as published by the Free Software Foundation; either 15 | # version 2.1 of the License, or (at your option) any later version. 16 | # 17 | # This library is distributed in the hope that it will be useful, 18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 | # Lesser General Public License for more details. 21 | # 22 | # You should have received a copy of the GNU Lesser General Public 23 | # License along with this library; if not, write to the Free Software 24 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 25 | # 02110-1301 USA 26 | ######################### END LICENSE BLOCK ######################### 27 | 28 | from .mbcharsetprober import MultiByteCharSetProber 29 | from .codingstatemachine import CodingStateMachine 30 | from .chardistribution import GB2312DistributionAnalysis 31 | from .mbcssm import GB2312SMModel 32 | 33 | class GB2312Prober(MultiByteCharSetProber): 34 | def __init__(self): 35 | MultiByteCharSetProber.__init__(self) 36 | self._mCodingSM = CodingStateMachine(GB2312SMModel) 37 | self._mDistributionAnalyzer = GB2312DistributionAnalysis() 38 | self.reset() 39 | 40 | def get_charset_name(self): 41 | return "GB2312" 42 | -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/botocore/vendored/requests/packages/charade/latin1prober.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # The Original Code is Mozilla Universal charset detector code. 3 | # 4 | # The Initial Developer of the Original Code is 5 | # Netscape Communications Corporation. 6 | # Portions created by the Initial Developer are Copyright (C) 2001 7 | # the Initial Developer. All Rights Reserved. 8 | # 9 | # Contributor(s): 10 | # Mark Pilgrim - port to Python 11 | # Shy Shalom - original C code 12 | # 13 | # This library is free software; you can redistribute it and/or 14 | # modify it under the terms of the GNU Lesser General Public 15 | # License as published by the Free Software Foundation; either 16 | # version 2.1 of the License, or (at your option) any later version. 17 | # 18 | # This library is distributed in the hope that it will be useful, 19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21 | # Lesser General Public License for more details. 22 | # 23 | # You should have received a copy of the GNU Lesser General Public 24 | # License along with this library; if not, write to the Free Software 25 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 26 | # 02110-1301 USA 27 | ######################### END LICENSE BLOCK ######################### 28 | 29 | from .charsetprober import CharSetProber 30 | from .constants import eNotMe 31 | from .compat import wrap_ord 32 | 33 | FREQ_CAT_NUM = 4 34 | 35 | UDF = 0 # undefined 36 | OTH = 1 # other 37 | ASC = 2 # ascii capital letter 38 | ASS = 3 # ascii small letter 39 | ACV = 4 # accent capital vowel 40 | ACO = 5 # accent capital other 41 | ASV = 6 # accent small vowel 42 | ASO = 7 # accent small other 43 | CLASS_NUM = 8 # total classes 44 | 45 | Latin1_CharToClass = ( 46 | OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 00 - 07 47 | OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 08 - 0F 48 | OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 10 - 17 49 | OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 18 - 1F 50 | OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 20 - 27 51 | OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 28 - 2F 52 | OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 30 - 37 53 | OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 38 - 3F 54 | OTH, ASC, ASC, ASC, ASC, ASC, ASC, ASC, # 40 - 47 55 | ASC, ASC, ASC, ASC, ASC, ASC, ASC, ASC, # 48 - 4F 56 | ASC, ASC, ASC, ASC, ASC, ASC, ASC, ASC, # 50 - 57 57 | ASC, ASC, ASC, OTH, OTH, OTH, OTH, OTH, # 58 - 5F 58 | OTH, ASS, ASS, ASS, ASS, ASS, ASS, ASS, # 60 - 67 59 | ASS, ASS, ASS, ASS, ASS, ASS, ASS, ASS, # 68 - 6F 60 | ASS, ASS, ASS, ASS, ASS, ASS, ASS, ASS, # 70 - 77 61 | ASS, ASS, ASS, OTH, OTH, OTH, OTH, OTH, # 78 - 7F 62 | OTH, UDF, OTH, ASO, OTH, OTH, OTH, OTH, # 80 - 87 63 | OTH, OTH, ACO, OTH, ACO, UDF, ACO, UDF, # 88 - 8F 64 | UDF, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 90 - 97 65 | OTH, OTH, ASO, OTH, ASO, UDF, ASO, ACO, # 98 - 9F 66 | OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # A0 - A7 67 | OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # A8 - AF 68 | OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # B0 - B7 69 | OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # B8 - BF 70 | ACV, ACV, ACV, ACV, ACV, ACV, ACO, ACO, # C0 - C7 71 | ACV, ACV, ACV, ACV, ACV, ACV, ACV, ACV, # C8 - CF 72 | ACO, ACO, ACV, ACV, ACV, ACV, ACV, OTH, # D0 - D7 73 | ACV, ACV, ACV, ACV, ACV, ACO, ACO, ACO, # D8 - DF 74 | ASV, ASV, ASV, ASV, ASV, ASV, ASO, ASO, # E0 - E7 75 | ASV, ASV, ASV, ASV, ASV, ASV, ASV, ASV, # E8 - EF 76 | ASO, ASO, ASV, ASV, ASV, ASV, ASV, OTH, # F0 - F7 77 | ASV, ASV, ASV, ASV, ASV, ASO, ASO, ASO, # F8 - FF 78 | ) 79 | 80 | # 0 : illegal 81 | # 1 : very unlikely 82 | # 2 : normal 83 | # 3 : very likely 84 | Latin1ClassModel = ( 85 | # UDF OTH ASC ASS ACV ACO ASV ASO 86 | 0, 0, 0, 0, 0, 0, 0, 0, # UDF 87 | 0, 3, 3, 3, 3, 3, 3, 3, # OTH 88 | 0, 3, 3, 3, 3, 3, 3, 3, # ASC 89 | 0, 3, 3, 3, 1, 1, 3, 3, # ASS 90 | 0, 3, 3, 3, 1, 2, 1, 2, # ACV 91 | 0, 3, 3, 3, 3, 3, 3, 3, # ACO 92 | 0, 3, 1, 3, 1, 1, 1, 3, # ASV 93 | 0, 3, 1, 3, 1, 1, 3, 3, # ASO 94 | ) 95 | 96 | 97 | class Latin1Prober(CharSetProber): 98 | def __init__(self): 99 | CharSetProber.__init__(self) 100 | self.reset() 101 | 102 | def reset(self): 103 | self._mLastCharClass = OTH 104 | self._mFreqCounter = [0] * FREQ_CAT_NUM 105 | CharSetProber.reset(self) 106 | 107 | def get_charset_name(self): 108 | return "windows-1252" 109 | 110 | def feed(self, aBuf): 111 | aBuf = self.filter_with_english_letters(aBuf) 112 | for c in aBuf: 113 | charClass = Latin1_CharToClass[wrap_ord(c)] 114 | freq = Latin1ClassModel[(self._mLastCharClass * CLASS_NUM) 115 | + charClass] 116 | if freq == 0: 117 | self._mState = eNotMe 118 | break 119 | self._mFreqCounter[freq] += 1 120 | self._mLastCharClass = charClass 121 | 122 | return self.get_state() 123 | 124 | def get_confidence(self): 125 | if self.get_state() == eNotMe: 126 | return 0.01 127 | 128 | total = sum(self._mFreqCounter) 129 | if total < 0.01: 130 | confidence = 0.0 131 | else: 132 | confidence = ((float(self._mFreqCounter[3]) / total) 133 | - (self._mFreqCounter[1] * 20.0 / total)) 134 | if confidence < 0.0: 135 | confidence = 0.0 136 | # lower the confidence of latin1 so that other more accurate 137 | # detector can take priority. 138 | confidence = confidence * 0.5 139 | return confidence 140 | -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/botocore/vendored/requests/packages/charade/mbcharsetprober.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # The Original Code is Mozilla Universal charset detector code. 3 | # 4 | # The Initial Developer of the Original Code is 5 | # Netscape Communications Corporation. 6 | # Portions created by the Initial Developer are Copyright (C) 2001 7 | # the Initial Developer. All Rights Reserved. 8 | # 9 | # Contributor(s): 10 | # Mark Pilgrim - port to Python 11 | # Shy Shalom - original C code 12 | # Proofpoint, Inc. 13 | # 14 | # This library is free software; you can redistribute it and/or 15 | # modify it under the terms of the GNU Lesser General Public 16 | # License as published by the Free Software Foundation; either 17 | # version 2.1 of the License, or (at your option) any later version. 18 | # 19 | # This library is distributed in the hope that it will be useful, 20 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | # Lesser General Public License for more details. 23 | # 24 | # You should have received a copy of the GNU Lesser General Public 25 | # License along with this library; if not, write to the Free Software 26 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 27 | # 02110-1301 USA 28 | ######################### END LICENSE BLOCK ######################### 29 | 30 | import sys 31 | from . import constants 32 | from .charsetprober import CharSetProber 33 | 34 | 35 | class MultiByteCharSetProber(CharSetProber): 36 | def __init__(self): 37 | CharSetProber.__init__(self) 38 | self._mDistributionAnalyzer = None 39 | self._mCodingSM = None 40 | self._mLastChar = [0, 0] 41 | 42 | def reset(self): 43 | CharSetProber.reset(self) 44 | if self._mCodingSM: 45 | self._mCodingSM.reset() 46 | if self._mDistributionAnalyzer: 47 | self._mDistributionAnalyzer.reset() 48 | self._mLastChar = [0, 0] 49 | 50 | def get_charset_name(self): 51 | pass 52 | 53 | def feed(self, aBuf): 54 | aLen = len(aBuf) 55 | for i in range(0, aLen): 56 | codingState = self._mCodingSM.next_state(aBuf[i]) 57 | if codingState == constants.eError: 58 | if constants._debug: 59 | sys.stderr.write(self.get_charset_name() 60 | + ' prober hit error at byte ' + str(i) 61 | + '\n') 62 | self._mState = constants.eNotMe 63 | break 64 | elif codingState == constants.eItsMe: 65 | self._mState = constants.eFoundIt 66 | break 67 | elif codingState == constants.eStart: 68 | charLen = self._mCodingSM.get_current_charlen() 69 | if i == 0: 70 | self._mLastChar[1] = aBuf[0] 71 | self._mDistributionAnalyzer.feed(self._mLastChar, charLen) 72 | else: 73 | self._mDistributionAnalyzer.feed(aBuf[i - 1:i + 1], 74 | charLen) 75 | 76 | self._mLastChar[0] = aBuf[aLen - 1] 77 | 78 | if self.get_state() == constants.eDetecting: 79 | if (self._mDistributionAnalyzer.got_enough_data() and 80 | (self.get_confidence() > constants.SHORTCUT_THRESHOLD)): 81 | self._mState = constants.eFoundIt 82 | 83 | return self.get_state() 84 | 85 | def get_confidence(self): 86 | return self._mDistributionAnalyzer.get_confidence() 87 | -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/botocore/vendored/requests/packages/charade/mbcsgroupprober.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # The Original Code is Mozilla Universal charset detector code. 3 | # 4 | # The Initial Developer of the Original Code is 5 | # Netscape Communications Corporation. 6 | # Portions created by the Initial Developer are Copyright (C) 2001 7 | # the Initial Developer. All Rights Reserved. 8 | # 9 | # Contributor(s): 10 | # Mark Pilgrim - port to Python 11 | # Shy Shalom - original C code 12 | # Proofpoint, Inc. 13 | # 14 | # This library is free software; you can redistribute it and/or 15 | # modify it under the terms of the GNU Lesser General Public 16 | # License as published by the Free Software Foundation; either 17 | # version 2.1 of the License, or (at your option) any later version. 18 | # 19 | # This library is distributed in the hope that it will be useful, 20 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | # Lesser General Public License for more details. 23 | # 24 | # You should have received a copy of the GNU Lesser General Public 25 | # License along with this library; if not, write to the Free Software 26 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 27 | # 02110-1301 USA 28 | ######################### END LICENSE BLOCK ######################### 29 | 30 | from .charsetgroupprober import CharSetGroupProber 31 | from .utf8prober import UTF8Prober 32 | from .sjisprober import SJISProber 33 | from .eucjpprober import EUCJPProber 34 | from .gb2312prober import GB2312Prober 35 | from .euckrprober import EUCKRProber 36 | from .cp949prober import CP949Prober 37 | from .big5prober import Big5Prober 38 | from .euctwprober import EUCTWProber 39 | 40 | 41 | class MBCSGroupProber(CharSetGroupProber): 42 | def __init__(self): 43 | CharSetGroupProber.__init__(self) 44 | self._mProbers = [ 45 | UTF8Prober(), 46 | SJISProber(), 47 | EUCJPProber(), 48 | GB2312Prober(), 49 | EUCKRProber(), 50 | CP949Prober(), 51 | Big5Prober(), 52 | EUCTWProber() 53 | ] 54 | self.reset() 55 | -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/botocore/vendored/requests/packages/charade/sbcharsetprober.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # The Original Code is Mozilla Universal charset detector code. 3 | # 4 | # The Initial Developer of the Original Code is 5 | # Netscape Communications Corporation. 6 | # Portions created by the Initial Developer are Copyright (C) 2001 7 | # the Initial Developer. All Rights Reserved. 8 | # 9 | # Contributor(s): 10 | # Mark Pilgrim - port to Python 11 | # Shy Shalom - original C code 12 | # 13 | # This library is free software; you can redistribute it and/or 14 | # modify it under the terms of the GNU Lesser General Public 15 | # License as published by the Free Software Foundation; either 16 | # version 2.1 of the License, or (at your option) any later version. 17 | # 18 | # This library is distributed in the hope that it will be useful, 19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21 | # Lesser General Public License for more details. 22 | # 23 | # You should have received a copy of the GNU Lesser General Public 24 | # License along with this library; if not, write to the Free Software 25 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 26 | # 02110-1301 USA 27 | ######################### END LICENSE BLOCK ######################### 28 | 29 | import sys 30 | from . import constants 31 | from .charsetprober import CharSetProber 32 | from .compat import wrap_ord 33 | 34 | SAMPLE_SIZE = 64 35 | SB_ENOUGH_REL_THRESHOLD = 1024 36 | POSITIVE_SHORTCUT_THRESHOLD = 0.95 37 | NEGATIVE_SHORTCUT_THRESHOLD = 0.05 38 | SYMBOL_CAT_ORDER = 250 39 | NUMBER_OF_SEQ_CAT = 4 40 | POSITIVE_CAT = NUMBER_OF_SEQ_CAT - 1 41 | #NEGATIVE_CAT = 0 42 | 43 | 44 | class SingleByteCharSetProber(CharSetProber): 45 | def __init__(self, model, reversed=False, nameProber=None): 46 | CharSetProber.__init__(self) 47 | self._mModel = model 48 | # TRUE if we need to reverse every pair in the model lookup 49 | self._mReversed = reversed 50 | # Optional auxiliary prober for name decision 51 | self._mNameProber = nameProber 52 | self.reset() 53 | 54 | def reset(self): 55 | CharSetProber.reset(self) 56 | # char order of last character 57 | self._mLastOrder = 255 58 | self._mSeqCounters = [0] * NUMBER_OF_SEQ_CAT 59 | self._mTotalSeqs = 0 60 | self._mTotalChar = 0 61 | # characters that fall in our sampling range 62 | self._mFreqChar = 0 63 | 64 | def get_charset_name(self): 65 | if self._mNameProber: 66 | return self._mNameProber.get_charset_name() 67 | else: 68 | return self._mModel['charsetName'] 69 | 70 | def feed(self, aBuf): 71 | if not self._mModel['keepEnglishLetter']: 72 | aBuf = self.filter_without_english_letters(aBuf) 73 | aLen = len(aBuf) 74 | if not aLen: 75 | return self.get_state() 76 | for c in aBuf: 77 | order = self._mModel['charToOrderMap'][wrap_ord(c)] 78 | if order < SYMBOL_CAT_ORDER: 79 | self._mTotalChar += 1 80 | if order < SAMPLE_SIZE: 81 | self._mFreqChar += 1 82 | if self._mLastOrder < SAMPLE_SIZE: 83 | self._mTotalSeqs += 1 84 | if not self._mReversed: 85 | i = (self._mLastOrder * SAMPLE_SIZE) + order 86 | model = self._mModel['precedenceMatrix'][i] 87 | else: # reverse the order of the letters in the lookup 88 | i = (order * SAMPLE_SIZE) + self._mLastOrder 89 | model = self._mModel['precedenceMatrix'][i] 90 | self._mSeqCounters[model] += 1 91 | self._mLastOrder = order 92 | 93 | if self.get_state() == constants.eDetecting: 94 | if self._mTotalSeqs > SB_ENOUGH_REL_THRESHOLD: 95 | cf = self.get_confidence() 96 | if cf > POSITIVE_SHORTCUT_THRESHOLD: 97 | if constants._debug: 98 | sys.stderr.write('%s confidence = %s, we have a' 99 | 'winner\n' % 100 | (self._mModel['charsetName'], cf)) 101 | self._mState = constants.eFoundIt 102 | elif cf < NEGATIVE_SHORTCUT_THRESHOLD: 103 | if constants._debug: 104 | sys.stderr.write('%s confidence = %s, below negative' 105 | 'shortcut threshhold %s\n' % 106 | (self._mModel['charsetName'], cf, 107 | NEGATIVE_SHORTCUT_THRESHOLD)) 108 | self._mState = constants.eNotMe 109 | 110 | return self.get_state() 111 | 112 | def get_confidence(self): 113 | r = 0.01 114 | if self._mTotalSeqs > 0: 115 | r = ((1.0 * self._mSeqCounters[POSITIVE_CAT]) / self._mTotalSeqs 116 | / self._mModel['mTypicalPositiveRatio']) 117 | r = r * self._mFreqChar / self._mTotalChar 118 | if r >= 1.0: 119 | r = 0.99 120 | return r 121 | -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/botocore/vendored/requests/packages/charade/sbcsgroupprober.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # The Original Code is Mozilla Universal charset detector code. 3 | # 4 | # The Initial Developer of the Original Code is 5 | # Netscape Communications Corporation. 6 | # Portions created by the Initial Developer are Copyright (C) 2001 7 | # the Initial Developer. All Rights Reserved. 8 | # 9 | # Contributor(s): 10 | # Mark Pilgrim - port to Python 11 | # Shy Shalom - original C code 12 | # 13 | # This library is free software; you can redistribute it and/or 14 | # modify it under the terms of the GNU Lesser General Public 15 | # License as published by the Free Software Foundation; either 16 | # version 2.1 of the License, or (at your option) any later version. 17 | # 18 | # This library is distributed in the hope that it will be useful, 19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21 | # Lesser General Public License for more details. 22 | # 23 | # You should have received a copy of the GNU Lesser General Public 24 | # License along with this library; if not, write to the Free Software 25 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 26 | # 02110-1301 USA 27 | ######################### END LICENSE BLOCK ######################### 28 | 29 | from .charsetgroupprober import CharSetGroupProber 30 | from .sbcharsetprober import SingleByteCharSetProber 31 | from .langcyrillicmodel import (Win1251CyrillicModel, Koi8rModel, 32 | Latin5CyrillicModel, MacCyrillicModel, 33 | Ibm866Model, Ibm855Model) 34 | from .langgreekmodel import Latin7GreekModel, Win1253GreekModel 35 | from .langbulgarianmodel import Latin5BulgarianModel, Win1251BulgarianModel 36 | from .langhungarianmodel import Latin2HungarianModel, Win1250HungarianModel 37 | from .langthaimodel import TIS620ThaiModel 38 | from .langhebrewmodel import Win1255HebrewModel 39 | from .hebrewprober import HebrewProber 40 | 41 | 42 | class SBCSGroupProber(CharSetGroupProber): 43 | def __init__(self): 44 | CharSetGroupProber.__init__(self) 45 | self._mProbers = [ 46 | SingleByteCharSetProber(Win1251CyrillicModel), 47 | SingleByteCharSetProber(Koi8rModel), 48 | SingleByteCharSetProber(Latin5CyrillicModel), 49 | SingleByteCharSetProber(MacCyrillicModel), 50 | SingleByteCharSetProber(Ibm866Model), 51 | SingleByteCharSetProber(Ibm855Model), 52 | SingleByteCharSetProber(Latin7GreekModel), 53 | SingleByteCharSetProber(Win1253GreekModel), 54 | SingleByteCharSetProber(Latin5BulgarianModel), 55 | SingleByteCharSetProber(Win1251BulgarianModel), 56 | SingleByteCharSetProber(Latin2HungarianModel), 57 | SingleByteCharSetProber(Win1250HungarianModel), 58 | SingleByteCharSetProber(TIS620ThaiModel), 59 | ] 60 | hebrewProber = HebrewProber() 61 | logicalHebrewProber = SingleByteCharSetProber(Win1255HebrewModel, 62 | False, hebrewProber) 63 | visualHebrewProber = SingleByteCharSetProber(Win1255HebrewModel, True, 64 | hebrewProber) 65 | hebrewProber.set_model_probers(logicalHebrewProber, visualHebrewProber) 66 | self._mProbers.extend([hebrewProber, logicalHebrewProber, 67 | visualHebrewProber]) 68 | 69 | self.reset() 70 | -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/botocore/vendored/requests/packages/charade/sjisprober.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # The Original Code is mozilla.org code. 3 | # 4 | # The Initial Developer of the Original Code is 5 | # Netscape Communications Corporation. 6 | # Portions created by the Initial Developer are Copyright (C) 1998 7 | # the Initial Developer. All Rights Reserved. 8 | # 9 | # Contributor(s): 10 | # Mark Pilgrim - port to Python 11 | # 12 | # This library is free software; you can redistribute it and/or 13 | # modify it under the terms of the GNU Lesser General Public 14 | # License as published by the Free Software Foundation; either 15 | # version 2.1 of the License, or (at your option) any later version. 16 | # 17 | # This library is distributed in the hope that it will be useful, 18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 | # Lesser General Public License for more details. 21 | # 22 | # You should have received a copy of the GNU Lesser General Public 23 | # License along with this library; if not, write to the Free Software 24 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 25 | # 02110-1301 USA 26 | ######################### END LICENSE BLOCK ######################### 27 | 28 | import sys 29 | from .mbcharsetprober import MultiByteCharSetProber 30 | from .codingstatemachine import CodingStateMachine 31 | from .chardistribution import SJISDistributionAnalysis 32 | from .jpcntx import SJISContextAnalysis 33 | from .mbcssm import SJISSMModel 34 | from . import constants 35 | 36 | 37 | class SJISProber(MultiByteCharSetProber): 38 | def __init__(self): 39 | MultiByteCharSetProber.__init__(self) 40 | self._mCodingSM = CodingStateMachine(SJISSMModel) 41 | self._mDistributionAnalyzer = SJISDistributionAnalysis() 42 | self._mContextAnalyzer = SJISContextAnalysis() 43 | self.reset() 44 | 45 | def reset(self): 46 | MultiByteCharSetProber.reset(self) 47 | self._mContextAnalyzer.reset() 48 | 49 | def get_charset_name(self): 50 | return "SHIFT_JIS" 51 | 52 | def feed(self, aBuf): 53 | aLen = len(aBuf) 54 | for i in range(0, aLen): 55 | codingState = self._mCodingSM.next_state(aBuf[i]) 56 | if codingState == constants.eError: 57 | if constants._debug: 58 | sys.stderr.write(self.get_charset_name() 59 | + ' prober hit error at byte ' + str(i) 60 | + '\n') 61 | self._mState = constants.eNotMe 62 | break 63 | elif codingState == constants.eItsMe: 64 | self._mState = constants.eFoundIt 65 | break 66 | elif codingState == constants.eStart: 67 | charLen = self._mCodingSM.get_current_charlen() 68 | if i == 0: 69 | self._mLastChar[1] = aBuf[0] 70 | self._mContextAnalyzer.feed(self._mLastChar[2 - charLen:], 71 | charLen) 72 | self._mDistributionAnalyzer.feed(self._mLastChar, charLen) 73 | else: 74 | self._mContextAnalyzer.feed(aBuf[i + 1 - charLen:i + 3 75 | - charLen], charLen) 76 | self._mDistributionAnalyzer.feed(aBuf[i - 1:i + 1], 77 | charLen) 78 | 79 | self._mLastChar[0] = aBuf[aLen - 1] 80 | 81 | if self.get_state() == constants.eDetecting: 82 | if (self._mContextAnalyzer.got_enough_data() and 83 | (self.get_confidence() > constants.SHORTCUT_THRESHOLD)): 84 | self._mState = constants.eFoundIt 85 | 86 | return self.get_state() 87 | 88 | def get_confidence(self): 89 | contxtCf = self._mContextAnalyzer.get_confidence() 90 | distribCf = self._mDistributionAnalyzer.get_confidence() 91 | return max(contxtCf, distribCf) 92 | -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/botocore/vendored/requests/packages/charade/utf8prober.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # The Original Code is mozilla.org code. 3 | # 4 | # The Initial Developer of the Original Code is 5 | # Netscape Communications Corporation. 6 | # Portions created by the Initial Developer are Copyright (C) 1998 7 | # the Initial Developer. All Rights Reserved. 8 | # 9 | # Contributor(s): 10 | # Mark Pilgrim - port to Python 11 | # 12 | # This library is free software; you can redistribute it and/or 13 | # modify it under the terms of the GNU Lesser General Public 14 | # License as published by the Free Software Foundation; either 15 | # version 2.1 of the License, or (at your option) any later version. 16 | # 17 | # This library is distributed in the hope that it will be useful, 18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 | # Lesser General Public License for more details. 21 | # 22 | # You should have received a copy of the GNU Lesser General Public 23 | # License along with this library; if not, write to the Free Software 24 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 25 | # 02110-1301 USA 26 | ######################### END LICENSE BLOCK ######################### 27 | 28 | from . import constants 29 | from .charsetprober import CharSetProber 30 | from .codingstatemachine import CodingStateMachine 31 | from .mbcssm import UTF8SMModel 32 | 33 | ONE_CHAR_PROB = 0.5 34 | 35 | 36 | class UTF8Prober(CharSetProber): 37 | def __init__(self): 38 | CharSetProber.__init__(self) 39 | self._mCodingSM = CodingStateMachine(UTF8SMModel) 40 | self.reset() 41 | 42 | def reset(self): 43 | CharSetProber.reset(self) 44 | self._mCodingSM.reset() 45 | self._mNumOfMBChar = 0 46 | 47 | def get_charset_name(self): 48 | return "utf-8" 49 | 50 | def feed(self, aBuf): 51 | for c in aBuf: 52 | codingState = self._mCodingSM.next_state(c) 53 | if codingState == constants.eError: 54 | self._mState = constants.eNotMe 55 | break 56 | elif codingState == constants.eItsMe: 57 | self._mState = constants.eFoundIt 58 | break 59 | elif codingState == constants.eStart: 60 | if self._mCodingSM.get_current_charlen() >= 2: 61 | self._mNumOfMBChar += 1 62 | 63 | if self.get_state() == constants.eDetecting: 64 | if self.get_confidence() > constants.SHORTCUT_THRESHOLD: 65 | self._mState = constants.eFoundIt 66 | 67 | return self.get_state() 68 | 69 | def get_confidence(self): 70 | unlike = 0.99 71 | if self._mNumOfMBChar < 6: 72 | for i in range(0, self._mNumOfMBChar): 73 | unlike = unlike * ONE_CHAR_PROB 74 | return 1.0 - unlike 75 | else: 76 | return unlike 77 | -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/botocore/vendored/requests/packages/urllib3/__init__.py: -------------------------------------------------------------------------------- 1 | # urllib3/__init__.py 2 | # Copyright 2008-2013 Andrey Petrov and contributors (see CONTRIBUTORS.txt) 3 | # 4 | # This module is part of urllib3 and is released under 5 | # the MIT License: http://www.opensource.org/licenses/mit-license.php 6 | 7 | """ 8 | urllib3 - Thread-safe connection pooling and re-using. 9 | """ 10 | 11 | __author__ = 'Andrey Petrov (andrey.petrov@shazow.net)' 12 | __license__ = 'MIT' 13 | __version__ = 'dev' 14 | 15 | 16 | from .connectionpool import ( 17 | HTTPConnectionPool, 18 | HTTPSConnectionPool, 19 | connection_from_url 20 | ) 21 | 22 | from . import exceptions 23 | from .filepost import encode_multipart_formdata 24 | from .poolmanager import PoolManager, ProxyManager, proxy_from_url 25 | from .response import HTTPResponse 26 | from .util import make_headers, get_host, Timeout 27 | 28 | 29 | # Set default logging handler to avoid "No handler found" warnings. 30 | import logging 31 | try: # Python 2.7+ 32 | from logging import NullHandler 33 | except ImportError: 34 | class NullHandler(logging.Handler): 35 | def emit(self, record): 36 | pass 37 | 38 | logging.getLogger(__name__).addHandler(NullHandler()) 39 | 40 | def add_stderr_logger(level=logging.DEBUG): 41 | """ 42 | Helper for quickly adding a StreamHandler to the logger. Useful for 43 | debugging. 44 | 45 | Returns the handler after adding it. 46 | """ 47 | # This method needs to be in this __init__.py to get the __name__ correct 48 | # even if urllib3 is vendored within another package. 49 | logger = logging.getLogger(__name__) 50 | handler = logging.StreamHandler() 51 | handler.setFormatter(logging.Formatter('%(asctime)s %(levelname)s %(message)s')) 52 | logger.addHandler(handler) 53 | logger.setLevel(level) 54 | logger.debug('Added an stderr logging handler to logger: %s' % __name__) 55 | return handler 56 | 57 | # ... Clean up. 58 | del NullHandler 59 | -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/botocore/vendored/requests/packages/urllib3/_collections.py: -------------------------------------------------------------------------------- 1 | # urllib3/_collections.py 2 | # Copyright 2008-2013 Andrey Petrov and contributors (see CONTRIBUTORS.txt) 3 | # 4 | # This module is part of urllib3 and is released under 5 | # the MIT License: http://www.opensource.org/licenses/mit-license.php 6 | 7 | from collections import MutableMapping 8 | from threading import RLock 9 | 10 | try: # Python 2.7+ 11 | from collections import OrderedDict 12 | except ImportError: 13 | from .packages.ordered_dict import OrderedDict 14 | 15 | 16 | __all__ = ['RecentlyUsedContainer'] 17 | 18 | 19 | _Null = object() 20 | 21 | 22 | class RecentlyUsedContainer(MutableMapping): 23 | """ 24 | Provides a thread-safe dict-like container which maintains up to 25 | ``maxsize`` keys while throwing away the least-recently-used keys beyond 26 | ``maxsize``. 27 | 28 | :param maxsize: 29 | Maximum number of recent elements to retain. 30 | 31 | :param dispose_func: 32 | Every time an item is evicted from the container, 33 | ``dispose_func(value)`` is called. Callback which will get called 34 | """ 35 | 36 | ContainerCls = OrderedDict 37 | 38 | def __init__(self, maxsize=10, dispose_func=None): 39 | self._maxsize = maxsize 40 | self.dispose_func = dispose_func 41 | 42 | self._container = self.ContainerCls() 43 | self.lock = RLock() 44 | 45 | def __getitem__(self, key): 46 | # Re-insert the item, moving it to the end of the eviction line. 47 | with self.lock: 48 | item = self._container.pop(key) 49 | self._container[key] = item 50 | return item 51 | 52 | def __setitem__(self, key, value): 53 | evicted_value = _Null 54 | with self.lock: 55 | # Possibly evict the existing value of 'key' 56 | evicted_value = self._container.get(key, _Null) 57 | self._container[key] = value 58 | 59 | # If we didn't evict an existing value, we might have to evict the 60 | # least recently used item from the beginning of the container. 61 | if len(self._container) > self._maxsize: 62 | _key, evicted_value = self._container.popitem(last=False) 63 | 64 | if self.dispose_func and evicted_value is not _Null: 65 | self.dispose_func(evicted_value) 66 | 67 | def __delitem__(self, key): 68 | with self.lock: 69 | value = self._container.pop(key) 70 | 71 | if self.dispose_func: 72 | self.dispose_func(value) 73 | 74 | def __len__(self): 75 | with self.lock: 76 | return len(self._container) 77 | 78 | def __iter__(self): 79 | raise NotImplementedError('Iteration over this class is unlikely to be threadsafe.') 80 | 81 | def clear(self): 82 | with self.lock: 83 | # Copy pointers to all values, then wipe the mapping 84 | # under Python 2, this copies the list of values twice :-| 85 | values = list(self._container.values()) 86 | self._container.clear() 87 | 88 | if self.dispose_func: 89 | for value in values: 90 | self.dispose_func(value) 91 | 92 | def keys(self): 93 | with self.lock: 94 | return self._container.keys() 95 | -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/botocore/vendored/requests/packages/urllib3/connection.py: -------------------------------------------------------------------------------- 1 | # urllib3/connection.py 2 | # Copyright 2008-2013 Andrey Petrov and contributors (see CONTRIBUTORS.txt) 3 | # 4 | # This module is part of urllib3 and is released under 5 | # the MIT License: http://www.opensource.org/licenses/mit-license.php 6 | 7 | import socket 8 | from socket import timeout as SocketTimeout 9 | 10 | try: # Python 3 11 | from http.client import HTTPConnection, HTTPException 12 | except ImportError: 13 | from httplib import HTTPConnection, HTTPException 14 | 15 | class DummyConnection(object): 16 | "Used to detect a failed ConnectionCls import." 17 | pass 18 | 19 | try: # Compiled with SSL? 20 | ssl = None 21 | HTTPSConnection = DummyConnection 22 | 23 | class BaseSSLError(BaseException): 24 | pass 25 | 26 | try: # Python 3 27 | from http.client import HTTPSConnection 28 | except ImportError: 29 | from httplib import HTTPSConnection 30 | 31 | import ssl 32 | BaseSSLError = ssl.SSLError 33 | 34 | except (ImportError, AttributeError): # Platform-specific: No SSL. 35 | pass 36 | 37 | from .exceptions import ( 38 | ConnectTimeoutError, 39 | ) 40 | from .packages.ssl_match_hostname import match_hostname 41 | from .util import ( 42 | assert_fingerprint, 43 | resolve_cert_reqs, 44 | resolve_ssl_version, 45 | ssl_wrap_socket, 46 | ) 47 | 48 | class VerifiedHTTPSConnection(HTTPSConnection): 49 | """ 50 | Based on httplib.HTTPSConnection but wraps the socket with 51 | SSL certification. 52 | """ 53 | cert_reqs = None 54 | ca_certs = None 55 | ssl_version = None 56 | 57 | def set_cert(self, key_file=None, cert_file=None, 58 | cert_reqs=None, ca_certs=None, 59 | assert_hostname=None, assert_fingerprint=None): 60 | 61 | self.key_file = key_file 62 | self.cert_file = cert_file 63 | self.cert_reqs = cert_reqs 64 | self.ca_certs = ca_certs 65 | self.assert_hostname = assert_hostname 66 | self.assert_fingerprint = assert_fingerprint 67 | 68 | def connect(self): 69 | # Add certificate verification 70 | try: 71 | sock = socket.create_connection( 72 | address=(self.host, self.port), 73 | timeout=self.timeout, 74 | ) 75 | except SocketTimeout: 76 | raise ConnectTimeoutError( 77 | self, "Connection to %s timed out. (connect timeout=%s)" % 78 | (self.host, self.timeout)) 79 | 80 | resolved_cert_reqs = resolve_cert_reqs(self.cert_reqs) 81 | resolved_ssl_version = resolve_ssl_version(self.ssl_version) 82 | 83 | if self._tunnel_host: 84 | self.sock = sock 85 | # Calls self._set_hostport(), so self.host is 86 | # self._tunnel_host below. 87 | self._tunnel() 88 | 89 | # Wrap socket using verification with the root certs in 90 | # trusted_root_certs 91 | self.sock = ssl_wrap_socket(sock, self.key_file, self.cert_file, 92 | cert_reqs=resolved_cert_reqs, 93 | ca_certs=self.ca_certs, 94 | server_hostname=self.host, 95 | ssl_version=resolved_ssl_version) 96 | 97 | if resolved_cert_reqs != ssl.CERT_NONE: 98 | if self.assert_fingerprint: 99 | assert_fingerprint(self.sock.getpeercert(binary_form=True), 100 | self.assert_fingerprint) 101 | elif self.assert_hostname is not False: 102 | match_hostname(self.sock.getpeercert(), 103 | self.assert_hostname or self.host) 104 | 105 | 106 | if ssl: 107 | HTTPSConnection = VerifiedHTTPSConnection 108 | -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/botocore/vendored/requests/packages/urllib3/contrib/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amazon-archives/aws-cfn-resource-bridge/4d37be1ee2684ef7dadeb4d273d82573c26b0736/aws/cfn/bridge/vendored/botocore/vendored/requests/packages/urllib3/contrib/__init__.py -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/botocore/vendored/requests/packages/urllib3/contrib/ntlmpool.py: -------------------------------------------------------------------------------- 1 | # urllib3/contrib/ntlmpool.py 2 | # Copyright 2008-2013 Andrey Petrov and contributors (see CONTRIBUTORS.txt) 3 | # 4 | # This module is part of urllib3 and is released under 5 | # the MIT License: http://www.opensource.org/licenses/mit-license.php 6 | 7 | """ 8 | NTLM authenticating pool, contributed by erikcederstran 9 | 10 | Issue #10, see: http://code.google.com/p/urllib3/issues/detail?id=10 11 | """ 12 | 13 | try: 14 | from http.client import HTTPSConnection 15 | except ImportError: 16 | from httplib import HTTPSConnection 17 | from logging import getLogger 18 | from ntlm import ntlm 19 | 20 | from urllib3 import HTTPSConnectionPool 21 | 22 | 23 | log = getLogger(__name__) 24 | 25 | 26 | class NTLMConnectionPool(HTTPSConnectionPool): 27 | """ 28 | Implements an NTLM authentication version of an urllib3 connection pool 29 | """ 30 | 31 | scheme = 'https' 32 | 33 | def __init__(self, user, pw, authurl, *args, **kwargs): 34 | """ 35 | authurl is a random URL on the server that is protected by NTLM. 36 | user is the Windows user, probably in the DOMAIN\\username format. 37 | pw is the password for the user. 38 | """ 39 | super(NTLMConnectionPool, self).__init__(*args, **kwargs) 40 | self.authurl = authurl 41 | self.rawuser = user 42 | user_parts = user.split('\\', 1) 43 | self.domain = user_parts[0].upper() 44 | self.user = user_parts[1] 45 | self.pw = pw 46 | 47 | def _new_conn(self): 48 | # Performs the NTLM handshake that secures the connection. The socket 49 | # must be kept open while requests are performed. 50 | self.num_connections += 1 51 | log.debug('Starting NTLM HTTPS connection no. %d: https://%s%s' % 52 | (self.num_connections, self.host, self.authurl)) 53 | 54 | headers = {} 55 | headers['Connection'] = 'Keep-Alive' 56 | req_header = 'Authorization' 57 | resp_header = 'www-authenticate' 58 | 59 | conn = HTTPSConnection(host=self.host, port=self.port) 60 | 61 | # Send negotiation message 62 | headers[req_header] = ( 63 | 'NTLM %s' % ntlm.create_NTLM_NEGOTIATE_MESSAGE(self.rawuser)) 64 | log.debug('Request headers: %s' % headers) 65 | conn.request('GET', self.authurl, None, headers) 66 | res = conn.getresponse() 67 | reshdr = dict(res.getheaders()) 68 | log.debug('Response status: %s %s' % (res.status, res.reason)) 69 | log.debug('Response headers: %s' % reshdr) 70 | log.debug('Response data: %s [...]' % res.read(100)) 71 | 72 | # Remove the reference to the socket, so that it can not be closed by 73 | # the response object (we want to keep the socket open) 74 | res.fp = None 75 | 76 | # Server should respond with a challenge message 77 | auth_header_values = reshdr[resp_header].split(', ') 78 | auth_header_value = None 79 | for s in auth_header_values: 80 | if s[:5] == 'NTLM ': 81 | auth_header_value = s[5:] 82 | if auth_header_value is None: 83 | raise Exception('Unexpected %s response header: %s' % 84 | (resp_header, reshdr[resp_header])) 85 | 86 | # Send authentication message 87 | ServerChallenge, NegotiateFlags = \ 88 | ntlm.parse_NTLM_CHALLENGE_MESSAGE(auth_header_value) 89 | auth_msg = ntlm.create_NTLM_AUTHENTICATE_MESSAGE(ServerChallenge, 90 | self.user, 91 | self.domain, 92 | self.pw, 93 | NegotiateFlags) 94 | headers[req_header] = 'NTLM %s' % auth_msg 95 | log.debug('Request headers: %s' % headers) 96 | conn.request('GET', self.authurl, None, headers) 97 | res = conn.getresponse() 98 | log.debug('Response status: %s %s' % (res.status, res.reason)) 99 | log.debug('Response headers: %s' % dict(res.getheaders())) 100 | log.debug('Response data: %s [...]' % res.read()[:100]) 101 | if res.status != 200: 102 | if res.status == 401: 103 | raise Exception('Server rejected request: wrong ' 104 | 'username or password') 105 | raise Exception('Wrong server response: %s %s' % 106 | (res.status, res.reason)) 107 | 108 | res.fp = None 109 | log.debug('Connection established') 110 | return conn 111 | 112 | def urlopen(self, method, url, body=None, headers=None, retries=3, 113 | redirect=True, assert_same_host=True): 114 | if headers is None: 115 | headers = {} 116 | headers['Connection'] = 'Keep-Alive' 117 | return super(NTLMConnectionPool, self).urlopen(method, url, body, 118 | headers, retries, 119 | redirect, 120 | assert_same_host) 121 | -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/botocore/vendored/requests/packages/urllib3/exceptions.py: -------------------------------------------------------------------------------- 1 | # urllib3/exceptions.py 2 | # Copyright 2008-2013 Andrey Petrov and contributors (see CONTRIBUTORS.txt) 3 | # 4 | # This module is part of urllib3 and is released under 5 | # the MIT License: http://www.opensource.org/licenses/mit-license.php 6 | 7 | 8 | ## Base Exceptions 9 | 10 | class HTTPError(Exception): 11 | "Base exception used by this module." 12 | pass 13 | 14 | 15 | class PoolError(HTTPError): 16 | "Base exception for errors caused within a pool." 17 | def __init__(self, pool, message): 18 | self.pool = pool 19 | HTTPError.__init__(self, "%s: %s" % (pool, message)) 20 | 21 | def __reduce__(self): 22 | # For pickling purposes. 23 | return self.__class__, (None, None) 24 | 25 | 26 | class RequestError(PoolError): 27 | "Base exception for PoolErrors that have associated URLs." 28 | def __init__(self, pool, url, message): 29 | self.url = url 30 | PoolError.__init__(self, pool, message) 31 | 32 | def __reduce__(self): 33 | # For pickling purposes. 34 | return self.__class__, (None, self.url, None) 35 | 36 | 37 | class SSLError(HTTPError): 38 | "Raised when SSL certificate fails in an HTTPS connection." 39 | pass 40 | 41 | 42 | class ProxyError(HTTPError): 43 | "Raised when the connection to a proxy fails." 44 | pass 45 | 46 | 47 | class DecodeError(HTTPError): 48 | "Raised when automatic decoding based on Content-Type fails." 49 | pass 50 | 51 | 52 | ## Leaf Exceptions 53 | 54 | class MaxRetryError(RequestError): 55 | "Raised when the maximum number of retries is exceeded." 56 | 57 | def __init__(self, pool, url, reason=None): 58 | self.reason = reason 59 | 60 | message = "Max retries exceeded with url: %s" % url 61 | if reason: 62 | message += " (Caused by %s: %s)" % (type(reason), reason) 63 | else: 64 | message += " (Caused by redirect)" 65 | 66 | RequestError.__init__(self, pool, url, message) 67 | 68 | 69 | class HostChangedError(RequestError): 70 | "Raised when an existing pool gets a request for a foreign host." 71 | 72 | def __init__(self, pool, url, retries=3): 73 | message = "Tried to open a foreign host with url: %s" % url 74 | RequestError.__init__(self, pool, url, message) 75 | self.retries = retries 76 | 77 | 78 | class TimeoutStateError(HTTPError): 79 | """ Raised when passing an invalid state to a timeout """ 80 | pass 81 | 82 | 83 | class TimeoutError(HTTPError): 84 | """ Raised when a socket timeout error occurs. 85 | 86 | Catching this error will catch both :exc:`ReadTimeoutErrors 87 | ` and :exc:`ConnectTimeoutErrors `. 88 | """ 89 | pass 90 | 91 | 92 | class ReadTimeoutError(TimeoutError, RequestError): 93 | "Raised when a socket timeout occurs while receiving data from a server" 94 | pass 95 | 96 | 97 | # This timeout error does not have a URL attached and needs to inherit from the 98 | # base HTTPError 99 | class ConnectTimeoutError(TimeoutError): 100 | "Raised when a socket timeout occurs while connecting to a server" 101 | pass 102 | 103 | 104 | class EmptyPoolError(PoolError): 105 | "Raised when a pool runs out of connections and no more are allowed." 106 | pass 107 | 108 | 109 | class ClosedPoolError(PoolError): 110 | "Raised when a request enters a pool after the pool has been closed." 111 | pass 112 | 113 | 114 | class LocationParseError(ValueError, HTTPError): 115 | "Raised when get_host or similar fails to parse the URL input." 116 | 117 | def __init__(self, location): 118 | message = "Failed to parse: %s" % location 119 | HTTPError.__init__(self, message) 120 | 121 | self.location = location 122 | -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/botocore/vendored/requests/packages/urllib3/filepost.py: -------------------------------------------------------------------------------- 1 | # urllib3/filepost.py 2 | # Copyright 2008-2013 Andrey Petrov and contributors (see CONTRIBUTORS.txt) 3 | # 4 | # This module is part of urllib3 and is released under 5 | # the MIT License: http://www.opensource.org/licenses/mit-license.php 6 | 7 | import codecs 8 | import mimetypes 9 | 10 | from uuid import uuid4 11 | from io import BytesIO 12 | 13 | from .packages import six 14 | from .packages.six import b 15 | from .fields import RequestField 16 | 17 | writer = codecs.lookup('utf-8')[3] 18 | 19 | 20 | def choose_boundary(): 21 | """ 22 | Our embarassingly-simple replacement for mimetools.choose_boundary. 23 | """ 24 | return uuid4().hex 25 | 26 | 27 | def iter_field_objects(fields): 28 | """ 29 | Iterate over fields. 30 | 31 | Supports list of (k, v) tuples and dicts, and lists of 32 | :class:`~urllib3.fields.RequestField`. 33 | 34 | """ 35 | if isinstance(fields, dict): 36 | i = six.iteritems(fields) 37 | else: 38 | i = iter(fields) 39 | 40 | for field in i: 41 | if isinstance(field, RequestField): 42 | yield field 43 | else: 44 | yield RequestField.from_tuples(*field) 45 | 46 | 47 | def iter_fields(fields): 48 | """ 49 | Iterate over fields. 50 | 51 | .. deprecated :: 52 | 53 | The addition of `~urllib3.fields.RequestField` makes this function 54 | obsolete. Instead, use :func:`iter_field_objects`, which returns 55 | `~urllib3.fields.RequestField` objects, instead. 56 | 57 | Supports list of (k, v) tuples and dicts. 58 | 59 | """ 60 | if isinstance(fields, dict): 61 | return ((k, v) for k, v in six.iteritems(fields)) 62 | 63 | return ((k, v) for k, v in fields) 64 | 65 | 66 | def encode_multipart_formdata(fields, boundary=None): 67 | """ 68 | Encode a dictionary of ``fields`` using the multipart/form-data MIME format. 69 | 70 | :param fields: 71 | Dictionary of fields or list of (key, :class:`~urllib3.fields.RequestField`). 72 | 73 | :param boundary: 74 | If not specified, then a random boundary will be generated using 75 | :func:`mimetools.choose_boundary`. 76 | """ 77 | body = BytesIO() 78 | if boundary is None: 79 | boundary = choose_boundary() 80 | 81 | for field in iter_field_objects(fields): 82 | body.write(b('--%s\r\n' % (boundary))) 83 | 84 | writer(body).write(field.render_headers()) 85 | data = field.data 86 | 87 | if isinstance(data, int): 88 | data = str(data) # Backwards compatibility 89 | 90 | if isinstance(data, six.text_type): 91 | writer(body).write(data) 92 | else: 93 | body.write(data) 94 | 95 | body.write(b'\r\n') 96 | 97 | body.write(b('--%s--\r\n' % (boundary))) 98 | 99 | content_type = str('multipart/form-data; boundary=%s' % boundary) 100 | 101 | return body.getvalue(), content_type 102 | -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/botocore/vendored/requests/packages/urllib3/packages/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | 3 | from . import ssl_match_hostname 4 | 5 | -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/botocore/vendored/requests/packages/urllib3/packages/ssl_match_hostname/__init__.py: -------------------------------------------------------------------------------- 1 | """The match_hostname() function from Python 3.2, essential when using SSL.""" 2 | 3 | import re 4 | 5 | __version__ = '3.2.2' 6 | 7 | class CertificateError(ValueError): 8 | pass 9 | 10 | def _dnsname_match(dn, hostname, max_wildcards=1): 11 | """Matching according to RFC 6125, section 6.4.3 12 | 13 | http://tools.ietf.org/html/rfc6125#section-6.4.3 14 | """ 15 | pats = [] 16 | if not dn: 17 | return False 18 | 19 | parts = dn.split(r'.') 20 | leftmost = parts[0] 21 | 22 | wildcards = leftmost.count('*') 23 | if wildcards > max_wildcards: 24 | # Issue #17980: avoid denials of service by refusing more 25 | # than one wildcard per fragment. A survery of established 26 | # policy among SSL implementations showed it to be a 27 | # reasonable choice. 28 | raise CertificateError( 29 | "too many wildcards in certificate DNS name: " + repr(dn)) 30 | 31 | # speed up common case w/o wildcards 32 | if not wildcards: 33 | return dn.lower() == hostname.lower() 34 | 35 | # RFC 6125, section 6.4.3, subitem 1. 36 | # The client SHOULD NOT attempt to match a presented identifier in which 37 | # the wildcard character comprises a label other than the left-most label. 38 | if leftmost == '*': 39 | # When '*' is a fragment by itself, it matches a non-empty dotless 40 | # fragment. 41 | pats.append('[^.]+') 42 | elif leftmost.startswith('xn--') or hostname.startswith('xn--'): 43 | # RFC 6125, section 6.4.3, subitem 3. 44 | # The client SHOULD NOT attempt to match a presented identifier 45 | # where the wildcard character is embedded within an A-label or 46 | # U-label of an internationalized domain name. 47 | pats.append(re.escape(leftmost)) 48 | else: 49 | # Otherwise, '*' matches any dotless string, e.g. www* 50 | pats.append(re.escape(leftmost).replace(r'\*', '[^.]*')) 51 | 52 | # add the remaining fragments, ignore any wildcards 53 | for frag in parts[1:]: 54 | pats.append(re.escape(frag)) 55 | 56 | pat = re.compile(r'\A' + r'\.'.join(pats) + r'\Z', re.IGNORECASE) 57 | return pat.match(hostname) 58 | 59 | 60 | def match_hostname(cert, hostname): 61 | """Verify that *cert* (in decoded format as returned by 62 | SSLSocket.getpeercert()) matches the *hostname*. RFC 2818 and RFC 6125 63 | rules are followed, but IP addresses are not accepted for *hostname*. 64 | 65 | CertificateError is raised on failure. On success, the function 66 | returns nothing. 67 | """ 68 | if not cert: 69 | raise ValueError("empty or no certificate") 70 | dnsnames = [] 71 | san = cert.get('subjectAltName', ()) 72 | for key, value in san: 73 | if key == 'DNS': 74 | if _dnsname_match(value, hostname): 75 | return 76 | dnsnames.append(value) 77 | if not dnsnames: 78 | # The subject is only checked when there is no dNSName entry 79 | # in subjectAltName 80 | for sub in cert.get('subject', ()): 81 | for key, value in sub: 82 | # XXX according to RFC 2818, the most specific Common Name 83 | # must be used. 84 | if key == 'commonName': 85 | if _dnsname_match(value, hostname): 86 | return 87 | dnsnames.append(value) 88 | if len(dnsnames) > 1: 89 | raise CertificateError("hostname %r " 90 | "doesn't match either of %s" 91 | % (hostname, ', '.join(map(repr, dnsnames)))) 92 | elif len(dnsnames) == 1: 93 | raise CertificateError("hostname %r " 94 | "doesn't match %r" 95 | % (hostname, dnsnames[0])) 96 | else: 97 | raise CertificateError("no appropriate commonName or " 98 | "subjectAltName fields were found") 99 | -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/botocore/vendored/requests/status_codes.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from .structures import LookupDict 4 | 5 | _codes = { 6 | 7 | # Informational. 8 | 100: ('continue',), 9 | 101: ('switching_protocols',), 10 | 102: ('processing',), 11 | 103: ('checkpoint',), 12 | 122: ('uri_too_long', 'request_uri_too_long'), 13 | 200: ('ok', 'okay', 'all_ok', 'all_okay', 'all_good', '\\o/', '✓'), 14 | 201: ('created',), 15 | 202: ('accepted',), 16 | 203: ('non_authoritative_info', 'non_authoritative_information'), 17 | 204: ('no_content',), 18 | 205: ('reset_content', 'reset'), 19 | 206: ('partial_content', 'partial'), 20 | 207: ('multi_status', 'multiple_status', 'multi_stati', 'multiple_stati'), 21 | 208: ('already_reported',), 22 | 226: ('im_used',), 23 | 24 | # Redirection. 25 | 300: ('multiple_choices',), 26 | 301: ('moved_permanently', 'moved', '\\o-'), 27 | 302: ('found',), 28 | 303: ('see_other', 'other'), 29 | 304: ('not_modified',), 30 | 305: ('use_proxy',), 31 | 306: ('switch_proxy',), 32 | 307: ('temporary_redirect', 'temporary_moved', 'temporary'), 33 | 308: ('resume_incomplete', 'resume'), 34 | 35 | # Client Error. 36 | 400: ('bad_request', 'bad'), 37 | 401: ('unauthorized',), 38 | 402: ('payment_required', 'payment'), 39 | 403: ('forbidden',), 40 | 404: ('not_found', '-o-'), 41 | 405: ('method_not_allowed', 'not_allowed'), 42 | 406: ('not_acceptable',), 43 | 407: ('proxy_authentication_required', 'proxy_auth', 'proxy_authentication'), 44 | 408: ('request_timeout', 'timeout'), 45 | 409: ('conflict',), 46 | 410: ('gone',), 47 | 411: ('length_required',), 48 | 412: ('precondition_failed', 'precondition'), 49 | 413: ('request_entity_too_large',), 50 | 414: ('request_uri_too_large',), 51 | 415: ('unsupported_media_type', 'unsupported_media', 'media_type'), 52 | 416: ('requested_range_not_satisfiable', 'requested_range', 'range_not_satisfiable'), 53 | 417: ('expectation_failed',), 54 | 418: ('im_a_teapot', 'teapot', 'i_am_a_teapot'), 55 | 422: ('unprocessable_entity', 'unprocessable'), 56 | 423: ('locked',), 57 | 424: ('failed_dependency', 'dependency'), 58 | 425: ('unordered_collection', 'unordered'), 59 | 426: ('upgrade_required', 'upgrade'), 60 | 428: ('precondition_required', 'precondition'), 61 | 429: ('too_many_requests', 'too_many'), 62 | 431: ('header_fields_too_large', 'fields_too_large'), 63 | 444: ('no_response', 'none'), 64 | 449: ('retry_with', 'retry'), 65 | 450: ('blocked_by_windows_parental_controls', 'parental_controls'), 66 | 451: ('unavailable_for_legal_reasons', 'legal_reasons'), 67 | 499: ('client_closed_request',), 68 | 69 | # Server Error. 70 | 500: ('internal_server_error', 'server_error', '/o\\', '✗'), 71 | 501: ('not_implemented',), 72 | 502: ('bad_gateway',), 73 | 503: ('service_unavailable', 'unavailable'), 74 | 504: ('gateway_timeout',), 75 | 505: ('http_version_not_supported', 'http_version'), 76 | 506: ('variant_also_negotiates',), 77 | 507: ('insufficient_storage',), 78 | 509: ('bandwidth_limit_exceeded', 'bandwidth'), 79 | 510: ('not_extended',), 80 | } 81 | 82 | codes = LookupDict(name='status_codes') 83 | 84 | for (code, titles) in list(_codes.items()): 85 | for title in titles: 86 | setattr(codes, title, code) 87 | if not title.startswith('\\'): 88 | setattr(codes, title.upper(), code) 89 | -------------------------------------------------------------------------------- /aws/cfn/bridge/vendored/botocore/vendored/requests/structures.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | """ 4 | requests.structures 5 | ~~~~~~~~~~~~~~~~~~~ 6 | 7 | Data structures that power Requests. 8 | 9 | """ 10 | 11 | import os 12 | import collections 13 | from itertools import islice 14 | 15 | 16 | class IteratorProxy(object): 17 | """docstring for IteratorProxy""" 18 | def __init__(self, i): 19 | self.i = i 20 | # self.i = chain.from_iterable(i) 21 | 22 | def __iter__(self): 23 | return self.i 24 | 25 | def __len__(self): 26 | if hasattr(self.i, '__len__'): 27 | return len(self.i) 28 | if hasattr(self.i, 'len'): 29 | return self.i.len 30 | if hasattr(self.i, 'fileno'): 31 | return os.fstat(self.i.fileno()).st_size 32 | 33 | def read(self, n): 34 | return "".join(islice(self.i, None, n)) 35 | 36 | 37 | class CaseInsensitiveDict(collections.MutableMapping): 38 | """ 39 | A case-insensitive ``dict``-like object. 40 | 41 | Implements all methods and operations of 42 | ``collections.MutableMapping`` as well as dict's ``copy``. Also 43 | provides ``lower_items``. 44 | 45 | All keys are expected to be strings. The structure remembers the 46 | case of the last key to be set, and ``iter(instance)``, 47 | ``keys()``, ``items()``, ``iterkeys()``, and ``iteritems()`` 48 | will contain case-sensitive keys. However, querying and contains 49 | testing is case insensitive: 50 | 51 | cid = CaseInsensitiveDict() 52 | cid['Accept'] = 'application/json' 53 | cid['aCCEPT'] == 'application/json' # True 54 | list(cid) == ['Accept'] # True 55 | 56 | For example, ``headers['content-encoding']`` will return the 57 | value of a ``'Content-Encoding'`` response header, regardless 58 | of how the header name was originally stored. 59 | 60 | If the constructor, ``.update``, or equality comparison 61 | operations are given keys that have equal ``.lower()``s, the 62 | behavior is undefined. 63 | 64 | """ 65 | def __init__(self, data=None, **kwargs): 66 | self._store = dict() 67 | if data is None: 68 | data = {} 69 | self.update(data, **kwargs) 70 | 71 | def __setitem__(self, key, value): 72 | # Use the lowercased key for lookups, but store the actual 73 | # key alongside the value. 74 | self._store[key.lower()] = (key, value) 75 | 76 | def __getitem__(self, key): 77 | return self._store[key.lower()][1] 78 | 79 | def __delitem__(self, key): 80 | del self._store[key.lower()] 81 | 82 | def __iter__(self): 83 | return (casedkey for casedkey, mappedvalue in self._store.values()) 84 | 85 | def __len__(self): 86 | return len(self._store) 87 | 88 | def lower_items(self): 89 | """Like iteritems(), but with all lowercase keys.""" 90 | return ( 91 | (lowerkey, keyval[1]) 92 | for (lowerkey, keyval) 93 | in self._store.items() 94 | ) 95 | 96 | def __eq__(self, other): 97 | if isinstance(other, collections.Mapping): 98 | other = CaseInsensitiveDict(other) 99 | else: 100 | return NotImplemented 101 | # Compare insensitively 102 | return dict(self.lower_items()) == dict(other.lower_items()) 103 | 104 | # Copy is required 105 | def copy(self): 106 | return CaseInsensitiveDict(self._store.values()) 107 | 108 | def __repr__(self): 109 | return '%s(%r)' % (self.__class__.__name__, dict(self.items())) 110 | 111 | 112 | class LookupDict(dict): 113 | """Dictionary lookup object.""" 114 | 115 | def __init__(self, name=None): 116 | self.name = name 117 | super(LookupDict, self).__init__() 118 | 119 | def __repr__(self): 120 | return '' % (self.name) 121 | 122 | def __getitem__(self, key): 123 | # We allow fall-through here, so values default to None 124 | 125 | return self.__dict__.get(key, None) 126 | 127 | def get(self, key, default=None): 128 | return self.__dict__.get(key, default) 129 | -------------------------------------------------------------------------------- /bin/cfn-resource-bridge: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | #============================================================================== 4 | # Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | #============================================================================== 18 | from aws.cfn import bridge 19 | from aws.cfn.bridge.runner import CfnBridge 20 | from aws.cfn.bridge.config import load_resources_from_configuration 21 | 22 | from argparse import ArgumentParser 23 | import logging 24 | import os 25 | import threading 26 | import datetime 27 | import sys 28 | 29 | if os.name == 'nt': 30 | default_confdir = os.path.expandvars('${SystemDrive}\cfn') 31 | else: 32 | default_confdir = '/etc/cfn' 33 | 34 | parser = ArgumentParser(prog='cfn-resource-bridge') 35 | 36 | parser.add_argument("-c", "--config", help="The configuration directory (default: %s)" % default_confdir, 37 | dest="config_path", default=default_confdir) 38 | parser.add_argument("--no-daemon", help="Do not daemonize", dest="no_daemon", action="store_true") 39 | parser.add_argument("-v", "--verbose", help="Enables verbose logging", action="store_true", dest="verbose") 40 | parser.add_argument("-t", "--threads", help="Configure the number of threads to use", type=int, dest="threads") 41 | 42 | options = parser.parse_args() 43 | 44 | 45 | def main(): 46 | # Configure our logger 47 | bridge.configure_logging("DEBUG" if options.verbose else "INFO", filename='cfn-resource-bridge.log') 48 | 49 | # Require there to be a configuration path, default should handle when not specified. 50 | if not options.config_path: 51 | print >> sys.stderr, u"Error: A configuration path must be specified" 52 | parser.print_help(sys.stderr) 53 | sys.exit(1) 54 | 55 | # Ensure that the configuration path really exists, since we expect the config file to be there. 56 | if not os.path.isdir(options.config_path): 57 | print >> sys.stderr, u"Error: Could not find configuration at %s" % options.config_path 58 | sys.exit(1) 59 | 60 | try: 61 | resources = load_resources_from_configuration(options.config_path) 62 | except Exception, ex: 63 | logging.exception("Failed to load configuration") 64 | print >> sys.stderr, u"Error: Failed to load configuration: %s" % str(ex) 65 | sys.exit(1) 66 | 67 | # Construct our bridge 68 | runner = CfnBridge(resources, num_threads=options.threads) 69 | 70 | # Start processing messages 71 | runner.process_messages() 72 | 73 | wait_event = threading.Event() 74 | 75 | # Wait until process is killed 76 | while True: 77 | try: 78 | # do this instead of wait() without timeout 79 | # as for some reason interrupts will not happen unless you wait for a specified time 80 | # (even if the wait is for a long time, the interrupt comes immediately) 81 | wait_event.wait(60) 82 | except KeyboardInterrupt: 83 | sys.exit(0) 84 | 85 | if options.no_daemon: 86 | main() 87 | elif os.name == 'nt': 88 | print >> sys.stderr, u"Error: cfn-resource-bridge cannot be run directly in daemon mode on Windows" 89 | sys.exit(1) 90 | else: 91 | try: 92 | import daemon 93 | except ImportError: 94 | print >> sys.stderr, u"Daemon library was not installed; please install python-daemon" 95 | sys.exit(1) 96 | 97 | try: 98 | from daemon import pidlockfile 99 | except ImportError: 100 | from daemon import pidfile as pidlockfile 101 | 102 | with daemon.DaemonContext(pidfile=pidlockfile.TimeoutPIDLockFile('/var/run/cfn-resource-bridge.pid', 300)): 103 | try: 104 | main() 105 | except Exception, e: 106 | logging.exception("Unhandled exception") 107 | sys.exit(1) 108 | -------------------------------------------------------------------------------- /init/redhat/cfn-resource-bridge: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # cfn-resource-bridge CloudFormation Custom Resource Bridge daemon 4 | # 5 | # chkconfig: - 80 20 6 | # 7 | # description: Runs user-specified actions when a 8 | # CloudFormation event is found 9 | # processname: cfn-resource-bridge 10 | # config: /etc/cfn/cfn-resource-bridge.conf 11 | # pidfile: /var/run/cfn-resource-bridge.pid 12 | # 13 | # source function library 14 | . /etc/rc.d/init.d/functions 15 | 16 | RETVAL=0 17 | 18 | start() { 19 | echo -n $"Starting cfn-resource-bridge: " 20 | daemon /opt/aws/bin/cfn-resource-bridge 21 | RETVAL=$? 22 | echo 23 | [ $RETVAL -eq 0 ] && touch /var/lock/subsys/cfn-resource-bridge 24 | } 25 | 26 | stop() { 27 | echo -n $"Stopping cfn-resource-bridge: " 28 | killproc -p /var/run/cfn-resource-bridge.pid cfn-resource-bridge 29 | echo 30 | [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/cfn-resource-bridge 31 | } 32 | 33 | restart() { 34 | stop 35 | start 36 | } 37 | 38 | case "$1" in 39 | start) 40 | start 41 | ;; 42 | stop) 43 | stop 44 | ;; 45 | restart|force-reload|reload) 46 | restart 47 | ;; 48 | condrestart|try-restart) 49 | [ -f /var/lock/subsys/cfn-resource-bridge ] && restart 50 | ;; 51 | status) 52 | status -p /var/run/cfn-resource-bridge.pid cfn-resource-bridge 53 | RETVAL=$? 54 | ;; 55 | *) 56 | echo $"Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart}" 57 | exit 1 58 | esac 59 | 60 | exit $RETVAL -------------------------------------------------------------------------------- /init/ubuntu/cfn-resource-bridge: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ### BEGIN INIT INFO 4 | # Provides: cfn-resource-bridge 5 | # Required-Start: $local_fs $remote_fs $network $syslog $named 6 | # Required-Stop: $local_fs $remote_fs $network $syslog $named 7 | # Default-Start: 2 3 4 5 8 | # Default-Stop: 0 1 6 9 | # Short-Description: starts CloudFormation cfn-resource-bridge 10 | # Description: starts CloudFormation cfn-resource-bridge 11 | ### END INIT INFO 12 | 13 | PID=/var/run/cfn-resource-bridge.pid 14 | DAEMON=/usr/local/bin/cfn-resource-bridge 15 | 16 | . /lib/lsb/init-functions 17 | 18 | start() { 19 | start-stop-daemon --start --quiet --pidfile $PID --exec $DAEMON --oknodo 20 | } 21 | 22 | stop() { 23 | start-stop-daemon --stop --quiet --pidfile $PID --oknodo 24 | } 25 | 26 | restart() { 27 | stop 28 | start 29 | } 30 | 31 | case "$1" in 32 | start) 33 | log_daemon_msg "Starting cfn-resource-bridge" 34 | start 35 | log_end_msg $? 36 | ;; 37 | stop) 38 | log_daemon_msg "Stopping cfn-resource-bridge" 39 | stop 40 | log_end_msg $? 41 | ;; 42 | restart|force-reload|reload) 43 | restart 44 | ;; 45 | status) 46 | status_of_proc -p $PID "$DAEMON" cfn-resource-bridge 47 | exit $? 48 | ;; 49 | *) 50 | echo $"Usage: $0 {start|stop|status|restart|reload|force-reload}" 51 | exit 1 52 | ;; 53 | esac 54 | 55 | exit 0 -------------------------------------------------------------------------------- /rpm_support/install.sh: -------------------------------------------------------------------------------- 1 | python setup.py install --root=$RPM_BUILD_ROOT --record=INSTALLED_FILES --install-scripts=%{aws_product_path}/bin --install-data=%{aws_product_path} 2 | -------------------------------------------------------------------------------- /rpm_support/postinstall.sh: -------------------------------------------------------------------------------- 1 | # Upgrade- remove old symlink 2 | if [ "$1" = "2" ]; then 3 | %__rm -f %{aws_product_path_link} 4 | # also remove old init script if it exists 5 | if [ -e %{_initrddir}/cfn-resource-bridge ]; then 6 | %__rm -f %{_initrddir}/cfn-resource-bridge 7 | fi 8 | fi 9 | 10 | # Install/Upgrade - Create symlink from versioned 11 | # directory to product name directory if it doesn't exist 12 | if [ ! -e %{aws_product_path_link} ]; then 13 | %__ln_s ./%{aws_product_name_v} %{aws_product_path_link} 14 | fi 15 | 16 | # Create aws bin directory if it doesn't exist: 17 | if [ ! -d %{aws_bin_path} ]; then 18 | %__mkdir %{aws_bin_path} 19 | fi 20 | 21 | for command in %{aws_product_path_link}/bin/*; do 22 | %define command_name $(basename $command) 23 | if [ -e %{aws_bin_path}/%{command_name} ]; then 24 | if [ "$1" = "2" ]; then 25 | # Upgrade- remove old symlinks 26 | %__rm -f %{aws_bin_path}/%{command_name} 27 | fi 28 | fi 29 | if [ ! -h %{aws_bin_path}/%{command_name} ]; then 30 | # Install relative symlink from generic directory to aws shared directory 31 | %__ln_s ../apitools/%{aws_product_name}/bin/%{command_name} %{aws_bin_path}/%{command_name} 32 | fi 33 | done 34 | 35 | # Create link to init script 36 | if [ ! -e %{_initrddir}/cfn-resource-bridge ]; then 37 | %__ln_s %{aws_product_path_link}/init/redhat/cfn-resource-bridge %{_initrddir}/cfn-resource-bridge 38 | fi 39 | 40 | %__chmod 755 %{_initrddir}/cfn-resource-bridge 41 | %__chmod 755 %{aws_product_path_link}/init/redhat/cfn-resource-bridge 42 | -------------------------------------------------------------------------------- /rpm_support/postun.sh: -------------------------------------------------------------------------------- 1 | if [ "$1" = "0" ]; then 2 | if [ ! "$(ls -A %{aws_bin_path})" ]; then 3 | rmdir %{aws_bin_path} 4 | fi 5 | 6 | %__rm -f %{aws_product_path_link} 7 | 8 | if [ ! "$(ls -A %{aws_path}/apitools)" ]; then 9 | rmdir %{aws_path}/apitools 10 | fi 11 | 12 | if [ ! "$(ls -A %{aws_path})" ]; then 13 | rmdir %{aws_path} 14 | fi 15 | fi -------------------------------------------------------------------------------- /rpm_support/prep.sh: -------------------------------------------------------------------------------- 1 | %define aws_product_name cfn-resource-bridge 2 | %define aws_path /opt/aws 3 | %define aws_bin_path %{aws_path}/bin 4 | %define aws_product_name_v %{aws_product_name}-%{version}-%{release} 5 | %define aws_product_path %{aws_path}/apitools/%{aws_product_name_v} 6 | %define aws_product_path_link %{aws_path}/apitools/%{aws_product_name} 7 | 8 | %setup -n %{name}-%{unmangled_version} -------------------------------------------------------------------------------- /rpm_support/preun.sh: -------------------------------------------------------------------------------- 1 | # Uninstall: 2 | if [ "$1" = "0" ]; then 3 | #Clean up the symlinks if it points to this version 4 | if [ "x$(readlink %{aws_product_path_link})" == "x./%{aws_product_name_v}" ]; then 5 | for command in %{aws_bin_path}/cfn*; do 6 | if [ "x$(readlink $command)" == "x../apitools/%{aws_product_name}/bin/$(basename $command)" ]; then 7 | %__rm -f $command 8 | fi 9 | done 10 | fi 11 | fi -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | #============================================================================== 4 | # Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | #============================================================================== 18 | 19 | import sys 20 | 21 | from distutils.core import setup 22 | from aws.cfn import bridge 23 | 24 | name = 'aws-cfn-resource-bridge' 25 | 26 | if sys.version_info[0] == 2 and sys.version_info[1] < 6: 27 | print >> sys.stderr, "Python 2.6+ is required" 28 | sys.exit(1) 29 | 30 | rpm_requires = ['python >= 2.6', 'python-daemon', 'python-six >= 1.1.0', 'python-jmespath >= 0.5.0', 31 | 'python-dateutil >= 2.1'] 32 | dependencies = ['python-daemon>=1.5.2', 'six>=1.1.0', 'jmespath>=0.5.0', 'python-dateutil>=2.1'] 33 | 34 | if sys.version_info[:2] == (2, 6): 35 | # For python2.6 we have to require argparse 36 | rpm_requires.append('python-argparse >= 1.1') 37 | dependencies.append('argparse>=1.1') 38 | 39 | ### Required for botocore. ### 40 | rpm_requires.append('python-ordereddict >= 1.1') 41 | dependencies.append('ordereddict>=1.1') 42 | rpm_requires.append('python-simplejson >= 3.3.0') 43 | dependencies.append('simplejson>=3.3.0') 44 | ### End botocore dependencies ### 45 | 46 | _opts = { 47 | 'build_scripts': {'executable': '/usr/bin/env python'}, 48 | 'bdist_rpm': {'requires': rpm_requires} 49 | } 50 | _data_files = [('share/doc/%s-%s' % (name, bridge.__version__), ['NOTICE.txt', 'LICENSE']), 51 | ('init/redhat', ['init/redhat/cfn-resource-bridge']), 52 | ('init/ubuntu', ['init/ubuntu/cfn-resource-bridge'])] 53 | _package_data = { 54 | 'aws.cfn.bridge.vendored.botocore': ['data/*.json', 'data/aws/*.json', 'data/aws/*/*.json'], 55 | 'aws.cfn.bridge.vendored.botocore.vendored.requests': ['*.pem'] 56 | } 57 | 58 | try: 59 | import py2exe 60 | 61 | _opts['py2exe'] = { 62 | # TODO: Need to update this for this package 63 | 'typelibs': [('{000C1092-0000-0000-C000-000000000046}', 1033, 1, 0), 64 | ('{E34CB9F1-C7F7-424C-BE29-027DCC09363A}', 0, 1, 0)], 65 | 'excludes': ['certifi', 'pyreadline', 'difflib', 'distutils', 'doctest', 'pdb', 'inspect', 'unittest', 66 | 'adodbapi'], 67 | 'includes': ['chardet', 'dbhash', 'dumbdbm'], 68 | 'dll_excludes': ['msvcr71.dll', 'w9xpopen.exe', ''], 69 | 'compressed': True, 70 | 'com_server': [], 71 | 'ctypes_com_server': [], 72 | 'service': ["aws.cfn.bridge.winbridge"], 73 | 'isapi': [], 74 | 'windows': [], 75 | 'zipfile': 'library.zip', 76 | 'console': ['bin/cfn-resource-bridge'] 77 | } 78 | _data_files = [('', ['license/win/NOTICE.txt', 'license/win/LICENSE.rtf', 'aws/cfn/bridge/vendored/botocore/vendored/requests/cacert.pem'])] 79 | except ImportError: 80 | pass 81 | 82 | setup_options = dict( 83 | name=name, 84 | version=bridge.__version__, 85 | description='A custom resource framework for AWS CloudFormation', 86 | long_description=open('README.md').read(), 87 | author='AWS CloudFormation', 88 | url='http://aws.amazon.com/cloudformation/', 89 | license='Apache License 2.0', 90 | scripts=['bin/cfn-resource-bridge'], 91 | classifiers=[], 92 | packages=[ 93 | 'aws', 94 | 'aws.cfn', 95 | 'aws.cfn.bridge', 96 | 'aws.cfn.bridge.vendored', 97 | 'aws.cfn.bridge.vendored.botocore', 98 | 'aws.cfn.bridge.vendored.botocore.vendored', 99 | 'aws.cfn.bridge.vendored.botocore.vendored.requests', 100 | 'aws.cfn.bridge.vendored.botocore.vendored.requests.packages', 101 | 'aws.cfn.bridge.vendored.botocore.vendored.requests.packages.charade', 102 | 'aws.cfn.bridge.vendored.botocore.vendored.requests.packages.urllib3', 103 | 'aws.cfn.bridge.vendored.botocore.vendored.requests.packages.urllib3.contrib', 104 | 'aws.cfn.bridge.vendored.botocore.vendored.requests.packages.urllib3.packages', 105 | 'aws.cfn.bridge.vendored.botocore.vendored.requests.packages.urllib3.packages.ssl_match_hostname', 106 | ], 107 | install_requires=dependencies, 108 | data_files=_data_files, 109 | package_data=_package_data, 110 | options=_opts 111 | ) 112 | 113 | setup(**setup_options) 114 | -------------------------------------------------------------------------------- /tests/__init__.py: -------------------------------------------------------------------------------- 1 | #============================================================================== 2 | # Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | #============================================================================== 16 | import sys 17 | 18 | # Use the backported version of unittest for python 2.6 19 | if sys.version_info[:2] == (2, 6): 20 | import unittest2 as unittest 21 | else: 22 | import unittest 23 | 24 | 25 | def expect_error(error, message=None): 26 | """Simple decorator to make it easier to write tests that expect errors""" 27 | def decorator(func): 28 | def decorated_func(*args, **kwargs): 29 | # To support earlier versions of python, we have to use a try block. 30 | try: 31 | func(*args, **kwargs) 32 | except error, e: 33 | if message: 34 | args[0].assertEqual(e.message, message) 35 | except Exception, e: 36 | args[0].fail(u"Should have failed with %s error and message '%s', but got %s instead" % (error, message, e)) 37 | else: 38 | args[0].fail(u"Should have failed with %s error and message '%s'" % (error, message)) 39 | return decorated_func 40 | return decorator -------------------------------------------------------------------------------- /tests/unit/__init__.py: -------------------------------------------------------------------------------- 1 | #============================================================================== 2 | # Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | #============================================================================== -------------------------------------------------------------------------------- /tests/unit/test_custom_resources.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | #============================================================================== 3 | # Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | #============================================================================== 17 | from tests import unittest, expect_error 18 | 19 | from aws.cfn.bridge.resources import CustomResource 20 | 21 | 22 | class TestCustomResource(unittest.TestCase): 23 | def setUp(self): 24 | self.options = { 25 | 'queue_url': 'https://queue.us-east-1.amazonaws.com', 26 | 'default_action': 'action-default', 27 | } 28 | 29 | def test_expect_queue_to_be_set(self): 30 | resource = CustomResource('name', 'file', self.options) 31 | self.assertEqual(resource.queue_url, 'https://queue.us-east-1.amazonaws.com') 32 | 33 | @expect_error(ValueError, "[name] in 'file' is missing 'queue_url' attribute") 34 | def test_expect_queue_to_be_required(self): 35 | del self.options['queue_url'] 36 | CustomResource('name', 'file', self.options) 37 | 38 | def test_expect_name_to_be_set(self): 39 | resource = CustomResource('name', 'file', self.options) 40 | self.assertEqual(resource.name, 'name') 41 | 42 | def test_expect_source_file_to_be_set(self): 43 | resource = CustomResource('name', 'file', self.options) 44 | self.assertEqual(resource.source_file, 'file') 45 | 46 | def test_expect_region_to_be_parsed(self): 47 | resource = CustomResource('name', 'title', self.options) 48 | self.assertEqual(resource.region, 'us-east-1') 49 | 50 | def test_expect_region_to_be_parsed_from_sqs_url(self): 51 | self.options['queue_url'] = "https://sqs.us-west-1.amazonaws.com" 52 | resource = CustomResource('name', 'title', self.options) 53 | self.assertEqual(resource.region, 'us-west-1') 54 | 55 | def test_expect_region_option_to_override(self): 56 | self.options['region'] = 'fun-region' 57 | resource = CustomResource('name', 'title', self.options) 58 | self.assertEqual(resource.region, 'fun-region') 59 | 60 | def test_expect_region_option_to_set(self): 61 | self.options['queue_url'] = "http://noregion" 62 | self.options['region'] = 'my-region' 63 | resource = CustomResource('name', 'title', self.options) 64 | self.assertEqual(resource.region, 'my-region') 65 | 66 | @expect_error(ValueError, "[name] in 'title' must define 'region' attribute") 67 | def test_expect_region_to_be_required(self): 68 | self.options['queue_url'] = "http://noregion" 69 | CustomResource('name', 'title', self.options) 70 | 71 | def test_expect_default_action_to_be_used(self): 72 | resource = CustomResource('name', 'file', self.options) 73 | self.assertEqual(resource._create_action, 'action-default') 74 | self.assertEqual(resource._update_action, 'action-default') 75 | self.assertEqual(resource._delete_action, 'action-default') 76 | 77 | def test_expect_custom_action_to_override_default(self): 78 | self.options.update({ 79 | 'create_action': 'create', 80 | 'delete_action': 'delete', 81 | 'update_action': 'update' 82 | }) 83 | resource = CustomResource('name', 'file', self.options) 84 | self.assertEquals(resource._create_action, 'create') 85 | self.assertEquals(resource._update_action, 'update') 86 | self.assertEquals(resource._delete_action, 'delete') 87 | 88 | @expect_error(ValueError, "[bad_create] in 'file' must define create_action") 89 | def test_expect_create_action_to_be_required(self): 90 | self.options.update({'create_action': ''}) 91 | CustomResource('bad_create', 'file', self.options) 92 | 93 | @expect_error(ValueError, "[bad_delete] in 'file' must define delete_action") 94 | def test_expect_delete_action_to_be_required(self): 95 | self.options.update({'delete_action': ''}) 96 | CustomResource('bad_delete', 'file', self.options) 97 | 98 | @expect_error(ValueError, "[bad_update] in 'file' must define update_action") 99 | def test_expect_update_action_to_be_required(self): 100 | self.options.update({'update_action': ''}) 101 | CustomResource('bad_update', 'file', self.options) 102 | 103 | if __name__ == "__main__": 104 | unittest.main() 105 | --------------------------------------------------------------------------------