Modify default behaviors and the create_order signature
This commit is contained in:
@@ -322,6 +322,8 @@ class Connection(object):
|
||||
|
||||
def create_order(self,
|
||||
name=None,
|
||||
payload_content_type='application/octet-stream',
|
||||
payload_content_encoding='base64',
|
||||
algorithm='aes',
|
||||
bit_length=256,
|
||||
cypher_type='cbc',
|
||||
@@ -340,9 +342,13 @@ class Connection(object):
|
||||
LOG.debug("href: {0}".format(href))
|
||||
order_dict = {'secret': {}}
|
||||
order_dict['secret']['name'] = name
|
||||
|
||||
order_dict['secret'][
|
||||
'payload_content_type'] = 'application/octet-stream'
|
||||
order_dict['secret']['payload_content_encoding'] = 'base64'
|
||||
'payload_content_type'] = payload_content_type
|
||||
|
||||
order_dict['secret'][
|
||||
'payload_content_encoding'] = payload_content_encoding
|
||||
|
||||
order_dict['secret']['algorithm'] = algorithm
|
||||
order_dict['secret']['bit_length'] = bit_length
|
||||
order_dict['secret']['cypher_type'] = cypher_type
|
||||
|
||||
@@ -63,18 +63,13 @@ class Keep:
|
||||
'e a payload_content_type (only used for se'
|
||||
'crets)')
|
||||
create_parser.add_argument('--payload_content_type', '-t',
|
||||
default='text/plain',
|
||||
help='the type/format of the provided '
|
||||
'secret data; "text/plain" is assumed to be'
|
||||
' UTF-8; required when --payload is su'
|
||||
'pplied (only used for secrets; orders are '
|
||||
'assumed to be of type "application/octet-s'
|
||||
'tream") (default: %(default)s)')
|
||||
'pplied and when creating orders')
|
||||
create_parser.add_argument('--payload_content_encoding', '-d',
|
||||
default='base64',
|
||||
help='required if --payload_content_type is'
|
||||
' "application/octet-stream" (default: %(de'
|
||||
'fault)s)')
|
||||
' "application/octet-stream"')
|
||||
|
||||
create_parser.add_argument('--expiration', '-e', help='the expiration '
|
||||
'time for the secret in ISO 8601 format')
|
||||
@@ -132,6 +127,8 @@ class Keep:
|
||||
print secret
|
||||
else:
|
||||
order = self.conn.create_order(args.name,
|
||||
args.payload_content_type,
|
||||
args.payload_content_encoding,
|
||||
args.algorithm,
|
||||
args.bit_length,
|
||||
args.cypher_type,
|
||||
|
||||
@@ -10,16 +10,11 @@ class Order(object):
|
||||
connection object for subtasks.
|
||||
"""
|
||||
self.connection = connection
|
||||
self.status = order_dict.get('status')
|
||||
self.secret = order_dict.get('secret')
|
||||
self.secret = order_dict['secret']
|
||||
self.order_ref = order_dict['order_ref']
|
||||
self.created = parse_isotime(order_dict['created'])
|
||||
self.secret_ref = order_dict.get('secret_ref')
|
||||
self.order_ref = order_dict.get('order_ref')
|
||||
self.created = parse_isotime(order_dict.get('created'))
|
||||
|
||||
if order_dict.get('expiration') is not None:
|
||||
self.expiration = parse_isotime(order_dict['expiration'])
|
||||
else:
|
||||
self.expiration = None
|
||||
self.status = order_dict.get('status')
|
||||
|
||||
if order_dict.get('updated') is not None:
|
||||
self.updated = parse_isotime(order_dict['updated'])
|
||||
|
||||
@@ -15,16 +15,16 @@ class Secret(object):
|
||||
"""
|
||||
self.connection = connection
|
||||
self.secret_ref = secret_dict['secret_ref']
|
||||
self.created = parse_isotime(secret_dict.get('created'))
|
||||
self.created = parse_isotime(secret_dict['created'])
|
||||
self.status = secret_dict.get('status')
|
||||
|
||||
self.algorithm = secret_dict.get('algorithm')
|
||||
self.bit_length = secret_dict.get('bit_length')
|
||||
self.algorithm = secret_dict['algorithm']
|
||||
self.bit_length = secret_dict['bit_length']
|
||||
self.payload_content_type = secret_dict.get('payload_content_type')
|
||||
self.payload_content_encoding = secret_dict.get(
|
||||
'payload_content_encoding')
|
||||
self.payload_content_encoding = secret_dict.get('payload_content_encoding')
|
||||
|
||||
self.cypher_type = secret_dict['cypher_type']
|
||||
self.name = secret_dict.get('name')
|
||||
self.cypher_type = secret_dict.get('cypher_type')
|
||||
|
||||
if secret_dict.get('expiration') is not None:
|
||||
self.expiration = parse_isotime(secret_dict['expiration'])
|
||||
@@ -48,11 +48,14 @@ class Secret(object):
|
||||
" name: {2}\n"
|
||||
" created: {3}\n"
|
||||
" status: {4}\n"
|
||||
" bit length: {5}\n"
|
||||
" algorithm: {6}\n"
|
||||
" cypher type: {7}\n"
|
||||
" expiration: {8}\n"
|
||||
" payload content type: {5}\n"
|
||||
" payload content encoding: {6}\n"
|
||||
" bit length: {7}\n"
|
||||
" algorithm: {8}\n"
|
||||
" cypher type: {9}\n"
|
||||
" expiration: {10}\n"
|
||||
.format(self.id, self.secret_ref, self.name, self.created,
|
||||
self.status, self.bit_length, self.algorithm,
|
||||
self.cypher_type, self.expiration)
|
||||
self.status, self.payload_content_type,
|
||||
self.payload_content_encoding, self.bit_length,
|
||||
self.algorithm, self.cypher_type, self.expiration)
|
||||
)
|
||||
|
||||
@@ -153,6 +153,8 @@ class WhenTestingConnection(unittest.TestCase):
|
||||
order = client.Order(self.connection, body)
|
||||
self.request.return_value.content = json.dumps(body)
|
||||
created = self.connection.create_order(name='test_secret',
|
||||
payload_content_type='application/octet-stream',
|
||||
payload_content_encoding='base64',
|
||||
algorithm='aes',
|
||||
bit_length=256,
|
||||
cypher_type='cbc')
|
||||
|
||||
Reference in New Issue
Block a user