Skip to content

Commit

Permalink
Merge pull request aws#2974 from joguSD/idempotent-tokens
Browse files Browse the repository at this point in the history
Make idempotency tokens not required
  • Loading branch information
joguSD authored Nov 22, 2017
2 parents 03ae4f9 + 4462ef9 commit ad92906
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changes/next-release/enhancement-Arguments-58814.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"category": "Arguments",
"description": "Idempotency tokens are no longer marked as a required argument.",
"type": "enhancement"
}
3 changes: 2 additions & 1 deletion awscli/clidriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,8 @@ def _create_argument_table(self):
cli_arg_name = xform_name(arg_name, '-')
arg_class = self.ARG_TYPES.get(arg_shape.type_name,
self.DEFAULT_ARG_CLASS)
is_required = arg_name in required_arguments
is_token = arg_shape.metadata.get('idempotencyToken', False)
is_required = arg_name in required_arguments and not is_token
event_emitter = self._session.get_component('event_emitter')
arg_object = arg_class(
name=cli_arg_name,
Expand Down
35 changes: 35 additions & 0 deletions tests/unit/test_clidriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,15 @@
"input":{"shape":"ListObjectsRequest"},
"output":{"shape":"ListObjectsOutput"},
},
"IdempotentOperation":{
"name":"IdempotentOperation",
"http":{
"method":"GET",
"requestUri":"/{Bucket}"
},
"input":{"shape":"IdempotentOperationRequest"},
"output":{"shape":"ListObjectsOutput"},
},
},
"shapes":{
"ListObjectsOutput":{
Expand All @@ -134,6 +143,16 @@
"shape":"NextMarker",
},
"Contents":{"shape":"Contents"},
},
},
"IdempotentOperationRequest":{
"type":"structure",
"required": "token",
"members":{
"token":{
"shape":"Token",
"idempotencyToken": True,
},
}
},
"ListObjectsRequest":{
Expand Down Expand Up @@ -163,6 +182,7 @@
"IsTruncated":{"type":"boolean"},
"NextMarker":{"type":"string"},
"Contents":{"type":"string"},
"Token":{"type":"string"},
}
}

Expand Down Expand Up @@ -671,6 +691,10 @@ def test_help_blurb_in_unknown_argument_error_message(self):
self.driver.main(['s3api', 'list-objects', '--help'])
self.assertIn(HELP_BLURB, self.stderr.getvalue())

def test_idempotency_token_is_not_required_in_help_text(self):
with self.assertRaises(SystemExit):
self.driver.main(['servicecatalog', 'create-constraint'])
self.assertNotIn('--idempotency-token', self.stderr.getvalue())

class TestHowClientIsCreated(BaseAWSCommandParamsTest):
def setUp(self):
Expand Down Expand Up @@ -898,6 +922,17 @@ def test_deprecated_operation(self):
None)
self.assertTrue(getattr(cmd, '_UNDOCUMENTED'))

def test_idempotency_token_is_not_required(self):
session = FakeSession()
name = 'IdempotentOperation'
service_model = session.get_service_model('s3')
operation_model = service_model.operation_model(name)
cmd = ServiceOperation(name, None, None, operation_model, session)
arg_table = cmd.arg_table
token_argument = arg_table.get('token')
self.assertFalse(token_argument.required,
'Idempotency tokens should not be required')


if __name__ == '__main__':
unittest.main()

0 comments on commit ad92906

Please sign in to comment.