def create_order_w_payload(self, name, payload_content_type, algorithm, bit_length, mode, expiration, payload_content_encoding, payload): """ POST http://.../v1/{tenant_id}/orders/{order_uuid} Creates an order to generate a secret with plain text. This is separate from the create_order method because it is used for negative testing only and is expected to fail. """ remote_url = self._get_base_url() secret = Secret(name=name, payload_content_type=payload_content_type, payload_content_encoding=payload_content_encoding, expiration=expiration, algorithm=algorithm, bit_length=bit_length, mode=mode, payload=payload) req_obj = Order(secret=secret) resp = self.request('POST', remote_url, request_entity=req_obj, response_entity_type=OrderRef) return resp
def create_secret(self, name=None, expiration=None, algorithm=None, bit_length=None, mode=None, payload=None, payload_content_type=None, payload_content_encoding=None): """ POST http://.../v1/{tenant_id}/secrets Allows a user to create a new secret """ remote_url = '{base}/secrets'.format(base=self._get_base_url()) req_obj = Secret(name=name, payload_content_type=payload_content_type, payload_content_encoding=payload_content_encoding, expiration=expiration, algorithm=algorithm, bit_length=bit_length, mode=mode, payload=payload) resp = self.request('POST', remote_url, request_entity=req_obj, response_entity_type=SecretRef) return resp
def create_order(self, name, algorithm, bit_length, mode, expiration, order_type, payload_content_type, payload_content_encoding, headers=None): """ POST http://.../v1/orders/{order_uuid} Creates an order to generate a secret """ remote_url = self._get_base_url() secret = Secret(name=name, payload_content_type=payload_content_type, payload_content_encoding=payload_content_encoding, expiration=expiration, algorithm=algorithm, bit_length=bit_length, mode=mode) req_obj = Order(meta=secret, order_type=order_type) resp = self.request('POST', remote_url, request_entity=req_obj, response_entity_type=OrderRef, headers=headers) return resp
def _dict_to_obj(cls, json_dict): args = { 'order_ref': json_dict.get('order_ref'), 'status': json_dict.get('status'), 'secret_href': json_dict.get('secret_ref'), 'secret': Secret._dict_to_obj(json_dict.get('secret')) } return Order(**args)
def _dict_to_obj(cls, json_dict): args = { 'order_ref': json_dict.get('order_ref'), 'status': json_dict.get('status'), 'secret_href': json_dict.get('secret_ref'), 'secret': Secret._dict_to_obj(json_dict.get('secret')) } return Order(**args)
def create_order(self, name, payload_content_type, algorithm, bit_length, cypher_type, expiration, payload_content_encoding): """ POST http://.../v1/{tenant_id}/orders/{order_uuid} Creates an order to generate a secret """ remote_url = self._get_base_url() secret = Secret(name=name, payload_content_type=payload_content_type, payload_content_encoding=payload_content_encoding, expiration=expiration, algorithm=algorithm, bit_length=bit_length, cypher_type=cypher_type) req_obj = Order(secret=secret) resp = self.request('POST', remote_url, request_entity=req_obj, response_entity_type=OrderRef) return resp