We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
ec2 run-instances ignores count in its json input
When preparing a reservation with `aws ec2 run-instances --cli-input-json JSONBLOB` the `MinCount` and `MaxCount` parameters are ignored and overwritten by the value 1. The equivalent reservation using command line options and esp. the `--count` option functions as expected.

How to reproduce:

``` shell
jsonblob()
{
   cat <<'EOF'
{
  "DryRun": false,
  "ImageId": "ami-XXXXXXXX",
  "MinCount": 3,
  "MaxCount": 3,
  "SubnetId": "subnet-XXXXXXXX",
  "UserData": "IyEvYmluL3NoCnNodXRkb3duIC1QICsyCg==",
  "InstanceInitiatedShutdownBehavior": "terminate",
  "InstanceType": "t2.small"
}
EOF
}
aws --debug ec2 run-instances --cli-input-json "$(jsonblob)"
```

(The user data is a script terminating the instance after a few minutes.)

The output contains the line

```
2015-09-23 16:49:09,762 - MainThread - botocore.endpoint - DEBUG - Making request for <botocore.model.OperationModel object at 0xXXXXXXXXXX> (verify_ssl=True) with params: {'body': {u'UserData': u'SXlFdlltbHVMM05vQ25Ob2RYUmtiM2R1SUMxUUlDc3lDZz09', u'DryRun': 'false', u'InstanceInitiatedShutdownBehavior': u'terminate', u'ImageId': u'ami-XXXXXXXX', u'SubnetId': u'subnet-XXXXXXXX', 'Version': u'2015-04-15', 'MaxCount': 1, 'Action': u'RunInstances', 'MinCount': 1, u'InstanceType': u't2.small'}, 'url': u'https://ec2.us-east-1.amazonaws.com/', 'headers': {'User-Agent': 'aws-cli/1.7.32 Python/2.7.10 Darwin/14.5.0'}, 'query_string': '', 'url_path': '/', 'method': u'POST'}
```

This demonstrates that the parameters `MaxCount` and `MinCount` in the JSON input are ignored.

---

``` console
% pip show awscli

---
Metadata-Version: 1.1
Name: awscli
Version: 1.7.32
Summary: Universal Command Line Environment for AWS.
Home-page: http://aws.amazon.com/cli/
Author: Mitch Garnaat
Author-email: garnaat@amazon.com
License: Apache License 2.0
Location: /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
Requires: botocore, bcdoc, colorama, docutils, rsa
```


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `awscli/handlers.py`
Content:
```
1 # Copyright 2013 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 """Builtin CLI extensions.
14 
15 This is a collection of built in CLI extensions that can be automatically
16 registered with the event system.
17 
18 """
19 from awscli.argprocess import ParamShorthand
20 from awscli.argprocess import uri_param
21 from awscli.errorhandler import ErrorHandler
22 from awscli.customizations.streamingoutputarg import add_streaming_output_arg
23 from awscli.customizations.addexamples import add_examples
24 from awscli.customizations.removals import register_removals
25 from awscli.customizations.ec2addcount import ec2_add_count
26 from awscli.customizations.paginate import register_pagination
27 from awscli.customizations.ec2decryptpassword import ec2_add_priv_launch_key
28 from awscli.customizations.ec2secgroupsimplify import register_secgroup
29 from awscli.customizations.preview import register_preview_commands
30 from awscli.customizations.ec2bundleinstance import register_bundleinstance
31 from awscli.customizations.s3.s3 import s3_plugin_initialize
32 from awscli.customizations.ec2runinstances import register_runinstances
33 from awscli.customizations.rds import register_rds_modify_split
34 from awscli.customizations.putmetricdata import register_put_metric_data
35 from awscli.customizations.sessendemail import register_ses_send_email
36 from awscli.customizations.iamvirtmfa import IAMVMFAWrapper
37 from awscli.customizations.argrename import register_arg_renames
38 from awscli.customizations.configure import register_configure_cmd
39 from awscli.customizations.cloudtrail import initialize as cloudtrail_init
40 from awscli.customizations.toplevelbool import register_bool_params
41 from awscli.customizations.ec2protocolarg import register_protocol_args
42 from awscli.customizations import datapipeline
43 from awscli.customizations.globalargs import register_parse_global_args
44 from awscli.customizations.cloudsearch import initialize as cloudsearch_init
45 from awscli.customizations.emr.emr import emr_initialize
46 from awscli.customizations.cloudsearchdomain import register_cloudsearchdomain
47 from awscli.customizations.s3endpoint import register_s3_endpoint
48 from awscli.customizations.s3errormsg import register_s3_error_msg
49 from awscli.customizations.cliinputjson import register_cli_input_json
50 from awscli.customizations.generatecliskeleton import \
51     register_generate_cli_skeleton
52 from awscli.customizations.assumerole import register_assume_role_provider
53 from awscli.customizations.waiters import register_add_waiters
54 from awscli.customizations.codedeploy.codedeploy import initialize as \
55     codedeploy_init
56 from awscli.customizations.configservice.subscribe import register_subscribe
57 from awscli.customizations.configservice.getstatus import register_get_status
58 from awscli.customizations.configservice.rename_cmd import \
59     register_rename_config
60 from awscli.customizations.configservice.putconfigurationrecorder import \
61     register_modify_put_configuration_recorder
62 from awscli.customizations.scalarparse import register_scalar_parser
63 from awscli.customizations.opsworks import initialize as opsworks_init
64 from awscli.customizations.awslambda import register_lambda_create_function
65 from awscli.customizations.kms import register_fix_kms_create_grant_docs
66 from awscli.customizations.route53 import register_create_hosted_zone_doc_fix
67 from awscli.customizations.codecommit import initialize as codecommit_init
68 from awscli.customizations.iot_data import register_custom_endpoint_note
69 
70 
71 def awscli_initialize(event_handlers):
72     event_handlers.register('load-cli-arg', uri_param)
73     param_shorthand = ParamShorthand()
74     event_handlers.register('process-cli-arg', param_shorthand)
75     # The s3 error mesage needs to registered before the
76     # generic error handler.
77     register_s3_error_msg(event_handlers)
78     error_handler = ErrorHandler()
79     event_handlers.register('after-call', error_handler,
80                             unique_id='awscli-error-handler')
81 #    # The following will get fired for every option we are
82 #    # documenting.  It will attempt to add an example_fn on to
83 #    # the parameter object if the parameter supports shorthand
84 #    # syntax.  The documentation event handlers will then use
85 #    # the examplefn to generate the sample shorthand syntax
86 #    # in the docs.  Registering here should ensure that this
87 #    # handler gets called first but it still feels a bit brittle.
88 #    event_handlers.register('doc-option-example.*.*.*',
89 #                            param_shorthand.add_example_fn)
90     event_handlers.register('doc-examples.*.*',
91                             add_examples)
92     register_cli_input_json(event_handlers)
93     event_handlers.register('building-argument-table.*',
94                             add_streaming_output_arg)
95     event_handlers.register('building-argument-table.ec2.run-instances',
96                             ec2_add_count)
97     event_handlers.register('building-argument-table.ec2.get-password-data',
98                             ec2_add_priv_launch_key)
99     register_parse_global_args(event_handlers)
100     register_pagination(event_handlers)
101     register_secgroup(event_handlers)
102     register_bundleinstance(event_handlers)
103     s3_plugin_initialize(event_handlers)
104     register_runinstances(event_handlers)
105     register_removals(event_handlers)
106     register_preview_commands(event_handlers)
107     register_rds_modify_split(event_handlers)
108     register_put_metric_data(event_handlers)
109     register_ses_send_email(event_handlers)
110     IAMVMFAWrapper(event_handlers)
111     register_arg_renames(event_handlers)
112     register_configure_cmd(event_handlers)
113     cloudtrail_init(event_handlers)
114     register_bool_params(event_handlers)
115     register_protocol_args(event_handlers)
116     datapipeline.register_customizations(event_handlers)
117     cloudsearch_init(event_handlers)
118     emr_initialize(event_handlers)
119     register_cloudsearchdomain(event_handlers)
120     register_s3_endpoint(event_handlers)
121     register_generate_cli_skeleton(event_handlers)
122     register_assume_role_provider(event_handlers)
123     register_add_waiters(event_handlers)
124     codedeploy_init(event_handlers)
125     register_subscribe(event_handlers)
126     register_get_status(event_handlers)
127     register_rename_config(event_handlers)
128     register_scalar_parser(event_handlers)
129     opsworks_init(event_handlers)
130     register_lambda_create_function(event_handlers)
131     register_fix_kms_create_grant_docs(event_handlers)
132     register_create_hosted_zone_doc_fix(event_handlers)
133     register_modify_put_configuration_recorder(event_handlers)
134     codecommit_init(event_handlers)
135     register_custom_endpoint_note(event_handlers)
136
```

Path: `awscli/customizations/ec2addcount.py`
Content:
```
1 # Copyright 2013 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 import logging
14 
15 from botocore import model
16 
17 from awscli.arguments import BaseCLIArgument
18 
19 
20 logger = logging.getLogger(__name__)
21 
22 
23 HELP = """
24 <p>Number of instances to launch. If a single number is provided, it
25 is assumed to be the minimum to launch (defaults to 1).  If a range is
26 provided in the form <code>min:max</code> then the first number is
27 interpreted as the minimum number of instances to launch and the second
28 is interpreted as the maximum number of instances to launch.</p>"""
29 
30 
31 def ec2_add_count(argument_table, **kwargs):
32     argument_table['count'] = CountArgument('count')
33     del argument_table['min-count']
34     del argument_table['max-count']
35 
36 
37 class CountArgument(BaseCLIArgument):
38 
39     def __init__(self, name):
40         self.argument_model = model.Shape('CountArgument', {'type': 'string'})
41         self._name = name
42         self._required = False
43 
44     @property
45     def cli_name(self):
46         return '--' + self._name
47 
48     @property
49     def cli_type_name(self):
50         return 'string'
51 
52     @property
53     def required(self):
54         return self._required
55 
56     @required.setter
57     def required(self, value):
58         self._required = value
59 
60     @property
61     def documentation(self):
62         return HELP
63 
64     def add_to_parser(self, parser):
65         parser.add_argument(self.cli_name, metavar=self.py_name,
66                             help='Number of instances to launch',
67                             default='1')
68 
69     def add_to_params(self, parameters, value):
70         try:
71             if ':' in value:
72                 minstr, maxstr = value.split(':')
73             else:
74                 minstr, maxstr = (value, value)
75             parameters['MinCount'] = int(minstr)
76             parameters['MaxCount'] = int(maxstr)
77         except:
78             msg = ('count parameter should be of '
79                    'form min[:max] (e.g. 1 or 1:10)')
80             raise ValueError(msg)
81
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/awscli/customizations/ec2addcount.py b/awscli/customizations/ec2addcount.py
--- a/awscli/customizations/ec2addcount.py
+++ b/awscli/customizations/ec2addcount.py
@@ -20,12 +20,20 @@
 logger = logging.getLogger(__name__)
 
 
+DEFAULT = 1
 HELP = """
 <p>Number of instances to launch. If a single number is provided, it
-is assumed to be the minimum to launch (defaults to 1).  If a range is
+is assumed to be the minimum to launch (defaults to %d).  If a range is
 provided in the form <code>min:max</code> then the first number is
 interpreted as the minimum number of instances to launch and the second
-is interpreted as the maximum number of instances to launch.</p>"""
+is interpreted as the maximum number of instances to launch.</p>""" % DEFAULT
+
+
+def register_count_events(event_handler):
+    event_handler.register(
+        'building-argument-table.ec2.run-instances', ec2_add_count)
+    event_handler.register(
+        'before-parameter-build.ec2.RunInstances', set_default_count)
 
 
 def ec2_add_count(argument_table, **kwargs):
@@ -34,6 +42,11 @@
     del argument_table['max-count']
 
 
+def set_default_count(params, **kwargs):
+    params.setdefault('MaxCount', DEFAULT)
+    params.setdefault('MinCount', DEFAULT)
+
+
 class CountArgument(BaseCLIArgument):
 
     def __init__(self, name):
@@ -62,11 +75,14 @@
         return HELP
 
     def add_to_parser(self, parser):
+        # We do NOT set default value here. It will be set later by event hook.
         parser.add_argument(self.cli_name, metavar=self.py_name,
-                            help='Number of instances to launch',
-                            default='1')
+                            help='Number of instances to launch')
 
     def add_to_params(self, parameters, value):
+        if value is None:
+            # NO-OP if value is not explicitly set by user
+            return
         try:
             if ':' in value:
                 minstr, maxstr = value.split(':')
diff --git a/awscli/handlers.py b/awscli/handlers.py
--- a/awscli/handlers.py
+++ b/awscli/handlers.py
@@ -22,7 +22,7 @@
 from awscli.customizations.streamingoutputarg import add_streaming_output_arg
 from awscli.customizations.addexamples import add_examples
 from awscli.customizations.removals import register_removals
-from awscli.customizations.ec2addcount import ec2_add_count
+from awscli.customizations.ec2addcount import register_count_events
 from awscli.customizations.paginate import register_pagination
 from awscli.customizations.ec2decryptpassword import ec2_add_priv_launch_key
 from awscli.customizations.ec2secgroupsimplify import register_secgroup
@@ -92,8 +92,7 @@
     register_cli_input_json(event_handlers)
     event_handlers.register('building-argument-table.*',
                             add_streaming_output_arg)
-    event_handlers.register('building-argument-table.ec2.run-instances',
-                            ec2_add_count)
+    register_count_events(event_handlers)
     event_handlers.register('building-argument-table.ec2.get-password-data',
                             ec2_add_priv_launch_key)
     register_parse_global_args(event_handlers)

{"golden_diff": "diff --git a/awscli/customizations/ec2addcount.py b/awscli/customizations/ec2addcount.py\n--- a/awscli/customizations/ec2addcount.py\n+++ b/awscli/customizations/ec2addcount.py\n@@ -20,12 +20,20 @@\n logger = logging.getLogger(__name__)\n \n \n+DEFAULT = 1\n HELP = \"\"\"\n <p>Number of instances to launch. If a single number is provided, it\n-is assumed to be the minimum to launch (defaults to 1).  If a range is\n+is assumed to be the minimum to launch (defaults to %d).  If a range is\n provided in the form <code>min:max</code> then the first number is\n interpreted as the minimum number of instances to launch and the second\n-is interpreted as the maximum number of instances to launch.</p>\"\"\"\n+is interpreted as the maximum number of instances to launch.</p>\"\"\" % DEFAULT\n+\n+\n+def register_count_events(event_handler):\n+    event_handler.register(\n+        'building-argument-table.ec2.run-instances', ec2_add_count)\n+    event_handler.register(\n+        'before-parameter-build.ec2.RunInstances', set_default_count)\n \n \n def ec2_add_count(argument_table, **kwargs):\n@@ -34,6 +42,11 @@\n     del argument_table['max-count']\n \n \n+def set_default_count(params, **kwargs):\n+    params.setdefault('MaxCount', DEFAULT)\n+    params.setdefault('MinCount', DEFAULT)\n+\n+\n class CountArgument(BaseCLIArgument):\n \n     def __init__(self, name):\n@@ -62,11 +75,14 @@\n         return HELP\n \n     def add_to_parser(self, parser):\n+        # We do NOT set default value here. It will be set later by event hook.\n         parser.add_argument(self.cli_name, metavar=self.py_name,\n-                            help='Number of instances to launch',\n-                            default='1')\n+                            help='Number of instances to launch')\n \n     def add_to_params(self, parameters, value):\n+        if value is None:\n+            # NO-OP if value is not explicitly set by user\n+            return\n         try:\n             if ':' in value:\n                 minstr, maxstr = value.split(':')\ndiff --git a/awscli/handlers.py b/awscli/handlers.py\n--- a/awscli/handlers.py\n+++ b/awscli/handlers.py\n@@ -22,7 +22,7 @@\n from awscli.customizations.streamingoutputarg import add_streaming_output_arg\n from awscli.customizations.addexamples import add_examples\n from awscli.customizations.removals import register_removals\n-from awscli.customizations.ec2addcount import ec2_add_count\n+from awscli.customizations.ec2addcount import register_count_events\n from awscli.customizations.paginate import register_pagination\n from awscli.customizations.ec2decryptpassword import ec2_add_priv_launch_key\n from awscli.customizations.ec2secgroupsimplify import register_secgroup\n@@ -92,8 +92,7 @@\n     register_cli_input_json(event_handlers)\n     event_handlers.register('building-argument-table.*',\n                             add_streaming_output_arg)\n-    event_handlers.register('building-argument-table.ec2.run-instances',\n-                            ec2_add_count)\n+    register_count_events(event_handlers)\n     event_handlers.register('building-argument-table.ec2.get-password-data',\n                             ec2_add_priv_launch_key)\n     register_parse_global_args(event_handlers)\n", "issue": "ec2 run-instances ignores count in its json input\nWhen preparing a reservation with `aws ec2 run-instances --cli-input-json JSONBLOB` the `MinCount` and `MaxCount` parameters are ignored and overwritten by the value 1. The equivalent reservation using command line options and esp. the `--count` option functions as expected.\n\nHow to reproduce:\n\n``` shell\njsonblob()\n{\n   cat <<'EOF'\n{\n  \"DryRun\": false,\n  \"ImageId\": \"ami-XXXXXXXX\",\n  \"MinCount\": 3,\n  \"MaxCount\": 3,\n  \"SubnetId\": \"subnet-XXXXXXXX\",\n  \"UserData\": \"IyEvYmluL3NoCnNodXRkb3duIC1QICsyCg==\",\n  \"InstanceInitiatedShutdownBehavior\": \"terminate\",\n  \"InstanceType\": \"t2.small\"\n}\nEOF\n}\naws --debug ec2 run-instances --cli-input-json \"$(jsonblob)\"\n```\n\n(The user data is a script terminating the instance after a few minutes.)\n\nThe output contains the line\n\n```\n2015-09-23 16:49:09,762 - MainThread - botocore.endpoint - DEBUG - Making request for <botocore.model.OperationModel object at 0xXXXXXXXXXX> (verify_ssl=True) with params: {'body': {u'UserData': u'SXlFdlltbHVMM05vQ25Ob2RYUmtiM2R1SUMxUUlDc3lDZz09', u'DryRun': 'false', u'InstanceInitiatedShutdownBehavior': u'terminate', u'ImageId': u'ami-XXXXXXXX', u'SubnetId': u'subnet-XXXXXXXX', 'Version': u'2015-04-15', 'MaxCount': 1, 'Action': u'RunInstances', 'MinCount': 1, u'InstanceType': u't2.small'}, 'url': u'https://ec2.us-east-1.amazonaws.com/', 'headers': {'User-Agent': 'aws-cli/1.7.32 Python/2.7.10 Darwin/14.5.0'}, 'query_string': '', 'url_path': '/', 'method': u'POST'}\n```\n\nThis demonstrates that the parameters `MaxCount` and `MinCount` in the JSON input are ignored.\n\n---\n\n``` console\n% pip show awscli\n\n---\nMetadata-Version: 1.1\nName: awscli\nVersion: 1.7.32\nSummary: Universal Command Line Environment for AWS.\nHome-page: http://aws.amazon.com/cli/\nAuthor: Mitch Garnaat\nAuthor-email: garnaat@amazon.com\nLicense: Apache License 2.0\nLocation: /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages\nRequires: botocore, bcdoc, colorama, docutils, rsa\n```\n\n", "before_files": [{"content": "# Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\"). You\n# may not use this file except in compliance with the License. A copy of\n# the License is located at\n#\n#     http://aws.amazon.com/apache2.0/\n#\n# or in the \"license\" file accompanying this file. This file is\n# distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF\n# ANY KIND, either express or implied. See the License for the specific\n# language governing permissions and limitations under the License.\n\"\"\"Builtin CLI extensions.\n\nThis is a collection of built in CLI extensions that can be automatically\nregistered with the event system.\n\n\"\"\"\nfrom awscli.argprocess import ParamShorthand\nfrom awscli.argprocess import uri_param\nfrom awscli.errorhandler import ErrorHandler\nfrom awscli.customizations.streamingoutputarg import add_streaming_output_arg\nfrom awscli.customizations.addexamples import add_examples\nfrom awscli.customizations.removals import register_removals\nfrom awscli.customizations.ec2addcount import ec2_add_count\nfrom awscli.customizations.paginate import register_pagination\nfrom awscli.customizations.ec2decryptpassword import ec2_add_priv_launch_key\nfrom awscli.customizations.ec2secgroupsimplify import register_secgroup\nfrom awscli.customizations.preview import register_preview_commands\nfrom awscli.customizations.ec2bundleinstance import register_bundleinstance\nfrom awscli.customizations.s3.s3 import s3_plugin_initialize\nfrom awscli.customizations.ec2runinstances import register_runinstances\nfrom awscli.customizations.rds import register_rds_modify_split\nfrom awscli.customizations.putmetricdata import register_put_metric_data\nfrom awscli.customizations.sessendemail import register_ses_send_email\nfrom awscli.customizations.iamvirtmfa import IAMVMFAWrapper\nfrom awscli.customizations.argrename import register_arg_renames\nfrom awscli.customizations.configure import register_configure_cmd\nfrom awscli.customizations.cloudtrail import initialize as cloudtrail_init\nfrom awscli.customizations.toplevelbool import register_bool_params\nfrom awscli.customizations.ec2protocolarg import register_protocol_args\nfrom awscli.customizations import datapipeline\nfrom awscli.customizations.globalargs import register_parse_global_args\nfrom awscli.customizations.cloudsearch import initialize as cloudsearch_init\nfrom awscli.customizations.emr.emr import emr_initialize\nfrom awscli.customizations.cloudsearchdomain import register_cloudsearchdomain\nfrom awscli.customizations.s3endpoint import register_s3_endpoint\nfrom awscli.customizations.s3errormsg import register_s3_error_msg\nfrom awscli.customizations.cliinputjson import register_cli_input_json\nfrom awscli.customizations.generatecliskeleton import \\\n    register_generate_cli_skeleton\nfrom awscli.customizations.assumerole import register_assume_role_provider\nfrom awscli.customizations.waiters import register_add_waiters\nfrom awscli.customizations.codedeploy.codedeploy import initialize as \\\n    codedeploy_init\nfrom awscli.customizations.configservice.subscribe import register_subscribe\nfrom awscli.customizations.configservice.getstatus import register_get_status\nfrom awscli.customizations.configservice.rename_cmd import \\\n    register_rename_config\nfrom awscli.customizations.configservice.putconfigurationrecorder import \\\n    register_modify_put_configuration_recorder\nfrom awscli.customizations.scalarparse import register_scalar_parser\nfrom awscli.customizations.opsworks import initialize as opsworks_init\nfrom awscli.customizations.awslambda import register_lambda_create_function\nfrom awscli.customizations.kms import register_fix_kms_create_grant_docs\nfrom awscli.customizations.route53 import register_create_hosted_zone_doc_fix\nfrom awscli.customizations.codecommit import initialize as codecommit_init\nfrom awscli.customizations.iot_data import register_custom_endpoint_note\n\n\ndef awscli_initialize(event_handlers):\n    event_handlers.register('load-cli-arg', uri_param)\n    param_shorthand = ParamShorthand()\n    event_handlers.register('process-cli-arg', param_shorthand)\n    # The s3 error mesage needs to registered before the\n    # generic error handler.\n    register_s3_error_msg(event_handlers)\n    error_handler = ErrorHandler()\n    event_handlers.register('after-call', error_handler,\n                            unique_id='awscli-error-handler')\n#    # The following will get fired for every option we are\n#    # documenting.  It will attempt to add an example_fn on to\n#    # the parameter object if the parameter supports shorthand\n#    # syntax.  The documentation event handlers will then use\n#    # the examplefn to generate the sample shorthand syntax\n#    # in the docs.  Registering here should ensure that this\n#    # handler gets called first but it still feels a bit brittle.\n#    event_handlers.register('doc-option-example.*.*.*',\n#                            param_shorthand.add_example_fn)\n    event_handlers.register('doc-examples.*.*',\n                            add_examples)\n    register_cli_input_json(event_handlers)\n    event_handlers.register('building-argument-table.*',\n                            add_streaming_output_arg)\n    event_handlers.register('building-argument-table.ec2.run-instances',\n                            ec2_add_count)\n    event_handlers.register('building-argument-table.ec2.get-password-data',\n                            ec2_add_priv_launch_key)\n    register_parse_global_args(event_handlers)\n    register_pagination(event_handlers)\n    register_secgroup(event_handlers)\n    register_bundleinstance(event_handlers)\n    s3_plugin_initialize(event_handlers)\n    register_runinstances(event_handlers)\n    register_removals(event_handlers)\n    register_preview_commands(event_handlers)\n    register_rds_modify_split(event_handlers)\n    register_put_metric_data(event_handlers)\n    register_ses_send_email(event_handlers)\n    IAMVMFAWrapper(event_handlers)\n    register_arg_renames(event_handlers)\n    register_configure_cmd(event_handlers)\n    cloudtrail_init(event_handlers)\n    register_bool_params(event_handlers)\n    register_protocol_args(event_handlers)\n    datapipeline.register_customizations(event_handlers)\n    cloudsearch_init(event_handlers)\n    emr_initialize(event_handlers)\n    register_cloudsearchdomain(event_handlers)\n    register_s3_endpoint(event_handlers)\n    register_generate_cli_skeleton(event_handlers)\n    register_assume_role_provider(event_handlers)\n    register_add_waiters(event_handlers)\n    codedeploy_init(event_handlers)\n    register_subscribe(event_handlers)\n    register_get_status(event_handlers)\n    register_rename_config(event_handlers)\n    register_scalar_parser(event_handlers)\n    opsworks_init(event_handlers)\n    register_lambda_create_function(event_handlers)\n    register_fix_kms_create_grant_docs(event_handlers)\n    register_create_hosted_zone_doc_fix(event_handlers)\n    register_modify_put_configuration_recorder(event_handlers)\n    codecommit_init(event_handlers)\n    register_custom_endpoint_note(event_handlers)\n", "path": "awscli/handlers.py"}, {"content": "# Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\"). You\n# may not use this file except in compliance with the License. A copy of\n# the License is located at\n#\n#     http://aws.amazon.com/apache2.0/\n#\n# or in the \"license\" file accompanying this file. This file is\n# distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF\n# ANY KIND, either express or implied. See the License for the specific\n# language governing permissions and limitations under the License.\nimport logging\n\nfrom botocore import model\n\nfrom awscli.arguments import BaseCLIArgument\n\n\nlogger = logging.getLogger(__name__)\n\n\nHELP = \"\"\"\n<p>Number of instances to launch. If a single number is provided, it\nis assumed to be the minimum to launch (defaults to 1).  If a range is\nprovided in the form <code>min:max</code> then the first number is\ninterpreted as the minimum number of instances to launch and the second\nis interpreted as the maximum number of instances to launch.</p>\"\"\"\n\n\ndef ec2_add_count(argument_table, **kwargs):\n    argument_table['count'] = CountArgument('count')\n    del argument_table['min-count']\n    del argument_table['max-count']\n\n\nclass CountArgument(BaseCLIArgument):\n\n    def __init__(self, name):\n        self.argument_model = model.Shape('CountArgument', {'type': 'string'})\n        self._name = name\n        self._required = False\n\n    @property\n    def cli_name(self):\n        return '--' + self._name\n\n    @property\n    def cli_type_name(self):\n        return 'string'\n\n    @property\n    def required(self):\n        return self._required\n\n    @required.setter\n    def required(self, value):\n        self._required = value\n\n    @property\n    def documentation(self):\n        return HELP\n\n    def add_to_parser(self, parser):\n        parser.add_argument(self.cli_name, metavar=self.py_name,\n                            help='Number of instances to launch',\n                            default='1')\n\n    def add_to_params(self, parameters, value):\n        try:\n            if ':' in value:\n                minstr, maxstr = value.split(':')\n            else:\n                minstr, maxstr = (value, value)\n            parameters['MinCount'] = int(minstr)\n            parameters['MaxCount'] = int(maxstr)\n        except:\n            msg = ('count parameter should be of '\n                   'form min[:max] (e.g. 1 or 1:10)')\n            raise ValueError(msg)\n", "path": "awscli/customizations/ec2addcount.py"}], "after_files": [{"content": "# Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\"). You\n# may not use this file except in compliance with the License. A copy of\n# the License is located at\n#\n#     http://aws.amazon.com/apache2.0/\n#\n# or in the \"license\" file accompanying this file. This file is\n# distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF\n# ANY KIND, either express or implied. See the License for the specific\n# language governing permissions and limitations under the License.\n\"\"\"Builtin CLI extensions.\n\nThis is a collection of built in CLI extensions that can be automatically\nregistered with the event system.\n\n\"\"\"\nfrom awscli.argprocess import ParamShorthand\nfrom awscli.argprocess import uri_param\nfrom awscli.errorhandler import ErrorHandler\nfrom awscli.customizations.streamingoutputarg import add_streaming_output_arg\nfrom awscli.customizations.addexamples import add_examples\nfrom awscli.customizations.removals import register_removals\nfrom awscli.customizations.ec2addcount import register_count_events\nfrom awscli.customizations.paginate import register_pagination\nfrom awscli.customizations.ec2decryptpassword import ec2_add_priv_launch_key\nfrom awscli.customizations.ec2secgroupsimplify import register_secgroup\nfrom awscli.customizations.preview import register_preview_commands\nfrom awscli.customizations.ec2bundleinstance import register_bundleinstance\nfrom awscli.customizations.s3.s3 import s3_plugin_initialize\nfrom awscli.customizations.ec2runinstances import register_runinstances\nfrom awscli.customizations.rds import register_rds_modify_split\nfrom awscli.customizations.putmetricdata import register_put_metric_data\nfrom awscli.customizations.sessendemail import register_ses_send_email\nfrom awscli.customizations.iamvirtmfa import IAMVMFAWrapper\nfrom awscli.customizations.argrename import register_arg_renames\nfrom awscli.customizations.configure import register_configure_cmd\nfrom awscli.customizations.cloudtrail import initialize as cloudtrail_init\nfrom awscli.customizations.toplevelbool import register_bool_params\nfrom awscli.customizations.ec2protocolarg import register_protocol_args\nfrom awscli.customizations import datapipeline\nfrom awscli.customizations.globalargs import register_parse_global_args\nfrom awscli.customizations.cloudsearch import initialize as cloudsearch_init\nfrom awscli.customizations.emr.emr import emr_initialize\nfrom awscli.customizations.cloudsearchdomain import register_cloudsearchdomain\nfrom awscli.customizations.s3endpoint import register_s3_endpoint\nfrom awscli.customizations.s3errormsg import register_s3_error_msg\nfrom awscli.customizations.cliinputjson import register_cli_input_json\nfrom awscli.customizations.generatecliskeleton import \\\n    register_generate_cli_skeleton\nfrom awscli.customizations.assumerole import register_assume_role_provider\nfrom awscli.customizations.waiters import register_add_waiters\nfrom awscli.customizations.codedeploy.codedeploy import initialize as \\\n    codedeploy_init\nfrom awscli.customizations.configservice.subscribe import register_subscribe\nfrom awscli.customizations.configservice.getstatus import register_get_status\nfrom awscli.customizations.configservice.rename_cmd import \\\n    register_rename_config\nfrom awscli.customizations.configservice.putconfigurationrecorder import \\\n    register_modify_put_configuration_recorder\nfrom awscli.customizations.scalarparse import register_scalar_parser\nfrom awscli.customizations.opsworks import initialize as opsworks_init\nfrom awscli.customizations.awslambda import register_lambda_create_function\nfrom awscli.customizations.kms import register_fix_kms_create_grant_docs\nfrom awscli.customizations.route53 import register_create_hosted_zone_doc_fix\nfrom awscli.customizations.codecommit import initialize as codecommit_init\nfrom awscli.customizations.iot_data import register_custom_endpoint_note\n\n\ndef awscli_initialize(event_handlers):\n    event_handlers.register('load-cli-arg', uri_param)\n    param_shorthand = ParamShorthand()\n    event_handlers.register('process-cli-arg', param_shorthand)\n    # The s3 error mesage needs to registered before the\n    # generic error handler.\n    register_s3_error_msg(event_handlers)\n    error_handler = ErrorHandler()\n    event_handlers.register('after-call', error_handler,\n                            unique_id='awscli-error-handler')\n#    # The following will get fired for every option we are\n#    # documenting.  It will attempt to add an example_fn on to\n#    # the parameter object if the parameter supports shorthand\n#    # syntax.  The documentation event handlers will then use\n#    # the examplefn to generate the sample shorthand syntax\n#    # in the docs.  Registering here should ensure that this\n#    # handler gets called first but it still feels a bit brittle.\n#    event_handlers.register('doc-option-example.*.*.*',\n#                            param_shorthand.add_example_fn)\n    event_handlers.register('doc-examples.*.*',\n                            add_examples)\n    register_cli_input_json(event_handlers)\n    event_handlers.register('building-argument-table.*',\n                            add_streaming_output_arg)\n    register_count_events(event_handlers)\n    event_handlers.register('building-argument-table.ec2.get-password-data',\n                            ec2_add_priv_launch_key)\n    register_parse_global_args(event_handlers)\n    register_pagination(event_handlers)\n    register_secgroup(event_handlers)\n    register_bundleinstance(event_handlers)\n    s3_plugin_initialize(event_handlers)\n    register_runinstances(event_handlers)\n    register_removals(event_handlers)\n    register_preview_commands(event_handlers)\n    register_rds_modify_split(event_handlers)\n    register_put_metric_data(event_handlers)\n    register_ses_send_email(event_handlers)\n    IAMVMFAWrapper(event_handlers)\n    register_arg_renames(event_handlers)\n    register_configure_cmd(event_handlers)\n    cloudtrail_init(event_handlers)\n    register_bool_params(event_handlers)\n    register_protocol_args(event_handlers)\n    datapipeline.register_customizations(event_handlers)\n    cloudsearch_init(event_handlers)\n    emr_initialize(event_handlers)\n    register_cloudsearchdomain(event_handlers)\n    register_s3_endpoint(event_handlers)\n    register_generate_cli_skeleton(event_handlers)\n    register_assume_role_provider(event_handlers)\n    register_add_waiters(event_handlers)\n    codedeploy_init(event_handlers)\n    register_subscribe(event_handlers)\n    register_get_status(event_handlers)\n    register_rename_config(event_handlers)\n    register_scalar_parser(event_handlers)\n    opsworks_init(event_handlers)\n    register_lambda_create_function(event_handlers)\n    register_fix_kms_create_grant_docs(event_handlers)\n    register_create_hosted_zone_doc_fix(event_handlers)\n    register_modify_put_configuration_recorder(event_handlers)\n    codecommit_init(event_handlers)\n    register_custom_endpoint_note(event_handlers)\n", "path": "awscli/handlers.py"}, {"content": "# Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\"). You\n# may not use this file except in compliance with the License. A copy of\n# the License is located at\n#\n#     http://aws.amazon.com/apache2.0/\n#\n# or in the \"license\" file accompanying this file. This file is\n# distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF\n# ANY KIND, either express or implied. See the License for the specific\n# language governing permissions and limitations under the License.\nimport logging\n\nfrom botocore import model\n\nfrom awscli.arguments import BaseCLIArgument\n\n\nlogger = logging.getLogger(__name__)\n\n\nDEFAULT = 1\nHELP = \"\"\"\n<p>Number of instances to launch. If a single number is provided, it\nis assumed to be the minimum to launch (defaults to %d).  If a range is\nprovided in the form <code>min:max</code> then the first number is\ninterpreted as the minimum number of instances to launch and the second\nis interpreted as the maximum number of instances to launch.</p>\"\"\" % DEFAULT\n\n\ndef register_count_events(event_handler):\n    event_handler.register(\n        'building-argument-table.ec2.run-instances', ec2_add_count)\n    event_handler.register(\n        'before-parameter-build.ec2.RunInstances', set_default_count)\n\n\ndef ec2_add_count(argument_table, **kwargs):\n    argument_table['count'] = CountArgument('count')\n    del argument_table['min-count']\n    del argument_table['max-count']\n\n\ndef set_default_count(params, **kwargs):\n    params.setdefault('MaxCount', DEFAULT)\n    params.setdefault('MinCount', DEFAULT)\n\n\nclass CountArgument(BaseCLIArgument):\n\n    def __init__(self, name):\n        self.argument_model = model.Shape('CountArgument', {'type': 'string'})\n        self._name = name\n        self._required = False\n\n    @property\n    def cli_name(self):\n        return '--' + self._name\n\n    @property\n    def cli_type_name(self):\n        return 'string'\n\n    @property\n    def required(self):\n        return self._required\n\n    @required.setter\n    def required(self, value):\n        self._required = value\n\n    @property\n    def documentation(self):\n        return HELP\n\n    def add_to_parser(self, parser):\n        # We do NOT set default value here. It will be set later by event hook.\n        parser.add_argument(self.cli_name, metavar=self.py_name,\n                            help='Number of instances to launch')\n\n    def add_to_params(self, parameters, value):\n        if value is None:\n            # NO-OP if value is not explicitly set by user\n            return\n        try:\n            if ':' in value:\n                minstr, maxstr = value.split(':')\n            else:\n                minstr, maxstr = (value, value)\n            parameters['MinCount'] = int(minstr)\n            parameters['MaxCount'] = int(maxstr)\n        except:\n            msg = ('count parameter should be of '\n                   'form min[:max] (e.g. 1 or 1:10)')\n            raise ValueError(msg)\n", "path": "awscli/customizations/ec2addcount.py"}]}