def update(self, secret_ref, payload=None): """Update an existing Secret in Barbican :param str secret_ref: Full HATEOAS reference to a Secret, or a UUID :param str payload: New payload to add to secret :raises barbicanclient.exceptions.HTTPAuthError: 401 Responses :raises barbicanclient.exceptions.HTTPClientError: 4xx Responses :raises barbicanclient.exceptions.HTTPServerError: 5xx Responses """ base.validate_ref_and_return_uuid(secret_ref, 'Secret') if not secret_ref: raise ValueError('secret_ref is required.') if type(payload) is six.binary_type: headers = {'content-type': "application/octet-stream"} elif type(payload) is six.text_type: headers = {'content-type': "text/plain"} else: raise exceptions.PayloadException("Invalid Payload Type") uuid_ref = base.calculate_uuid_ref(secret_ref, self._entity) self._api.put(uuid_ref, headers=headers, data=payload)
def delete(self): """Deletes the Secret from Barbican""" if self._secret_ref: uuid_ref = base.calculate_uuid_ref(self._secret_ref, self._entity) self._api.delete(uuid_ref) self._secret_ref = None else: raise LookupError("Secret is not yet stored.")
def delete(self): """Deletes the Secret from Barbican""" if self._secret_ref: uuid_ref = base.calculate_uuid_ref(self._secret_ref, self._entity) self._api.delete(uuid_ref) self._secret_ref = None else: raise LookupError("Secret is not yet stored.")
def delete(self, order_ref): """Delete an Order from Barbican :param order_ref: Full HATEOAS reference to an Order, or a UUID """ if not order_ref: raise ValueError('order_ref is required.') uuid_ref = base.calculate_uuid_ref(order_ref, self._entity) self._api.delete(uuid_ref)
def _fill_lazy_properties(self): if self._ca_ref and not self._plugin_name: uuid_ref = base.calculate_uuid_ref(self._ca_ref, self._entity) result = self._api.get(uuid_ref) self._fill_from_data(meta=result.get('meta'), expiration=result.get('expiration'), plugin_name=result.get('plugin_name'), plugin_ca_id=result.get('plugin_ca_id'), created=result.get('created'), updated=result.get('updated'), status=result.get('status'))
def delete(self): """Delete container from Barbican""" if self._container_ref: uuid_ref = base.calculate_uuid_ref(self._container_ref, self._entity) self._api.delete(uuid_ref) self._container_ref = None self._status = None self._created = None self._updated = None else: raise LookupError("Secret is not yet stored.")
def delete(self, container_ref): """Delete a Container from Barbican :param container_ref: Full HATEOAS reference to a Container, or a UUID :raises barbicanclient.exceptions.HTTPAuthError: 401 Responses :raises barbicanclient.exceptions.HTTPClientError: 4xx Responses :raises barbicanclient.exceptions.HTTPServerError: 5xx Responses """ if not container_ref: raise ValueError('container_ref is required.') uuid_ref = base.calculate_uuid_ref(container_ref, self._entity) self._api.delete(uuid_ref)
def delete(self): """Delete container from Barbican""" if self._container_ref: uuid_ref = base.calculate_uuid_ref(self._container_ref, self._entity) self._api.delete(uuid_ref) self._container_ref = None self._status = None self._created = None self._updated = None else: raise LookupError("Secret is not yet stored.")
def delete(self, container_ref): """Delete a Container from Barbican :param container_ref: Full HATEOAS reference to a Container, or a UUID :raises barbicanclient.exceptions.HTTPAuthError: 401 Responses :raises barbicanclient.exceptions.HTTPClientError: 4xx Responses :raises barbicanclient.exceptions.HTTPServerError: 5xx Responses """ if not container_ref: raise ValueError('container_ref is required.') uuid_ref = base.calculate_uuid_ref(container_ref, self._entity) self._api.delete(uuid_ref)
def delete(self, secret_ref): """Delete a Secret from Barbican :param secret_ref: Full HATEOAS reference to a Secret, or a UUID :raises barbicanclient.exceptions.HTTPAuthError: 401 Responses :raises barbicanclient.exceptions.HTTPClientError: 4xx Responses :raises barbicanclient.exceptions.HTTPServerError: 5xx Responses """ base.validate_ref_and_return_uuid(secret_ref, 'Secret') if not secret_ref: raise ValueError('secret_ref is required.') uuid_ref = base.calculate_uuid_ref(secret_ref, self._entity) self._api.delete(uuid_ref)
def _fill_lazy_properties(self): if self._ca_ref and not self._plugin_name: uuid_ref = base.calculate_uuid_ref(self._ca_ref, self._entity) result = self._api.get(uuid_ref) self._fill_from_data( meta=result.get('meta'), expiration=result.get('expiration'), plugin_name=result.get('plugin_name'), plugin_ca_id=result.get('plugin_ca_id'), created=result.get('created'), updated=result.get('updated'), status=result.get('status') )
def delete(self, secret_ref): """Delete a Secret from Barbican :param secret_ref: Full HATEOAS reference to a Secret, or a UUID :raises barbicanclient.exceptions.HTTPAuthError: 401 Responses :raises barbicanclient.exceptions.HTTPClientError: 4xx Responses :raises barbicanclient.exceptions.HTTPServerError: 5xx Responses """ base.validate_ref_and_return_uuid(secret_ref, 'Secret') if not secret_ref: raise ValueError('secret_ref is required.') uuid_ref = base.calculate_uuid_ref(secret_ref, self._entity) self._api.delete(uuid_ref)
def get(self, container_ref): """Retrieve an existing Container from Barbican :param container_ref: Full HATEOAS reference to a Container, or a UUID :returns: Container object or a subclass of the appropriate type """ LOG.debug( 'Getting container - Container href: {0}'.format(container_ref)) uuid_ref = base.calculate_uuid_ref(container_ref, self._entity) try: response = self._api.get(uuid_ref) except AttributeError: raise LookupError( 'Container {0} could not be found.'.format(container_ref)) return self._generate_typed_container(response)
def get(self, container_ref): """Retrieve an existing Container from Barbican :param container_ref: Full HATEOAS reference to a Container, or a UUID :returns: Container object or a subclass of the appropriate type """ LOG.debug('Getting container - Container href: {0}' .format(container_ref)) uuid_ref = base.calculate_uuid_ref(container_ref, self._entity) try: response = self._api.get(uuid_ref) except AttributeError: raise LookupError('Container {0} could not be found.' .format(container_ref)) return self._generate_typed_container(response)
def _fetch_payload(self): if not self.payload_content_type and not self.content_types: raise ValueError('Secret has no encrypted data to decrypt.') elif not self.payload_content_type: raise ValueError("Must specify decrypt content-type as " "secret does not specify a 'default' " "content-type.") headers = {'Accept': self.payload_content_type} uuid_ref = base.calculate_uuid_ref(self._secret_ref, self._entity) payload_url = uuid_ref + '/payload' payload = self._api._get_raw(payload_url, headers=headers) if self.payload_content_type == u'text/plain': self._payload = payload.decode('UTF-8') else: self._payload = payload
def update(self): """Updates the secret in Barbican.""" if not self.payload: raise exceptions.PayloadException("Invalid or Missing Payload") if not self.secret_ref: raise LookupError("Secret is not yet stored.") if type(self.payload) is six.binary_type: headers = {'content-type': "application/octet-stream"} elif type(self.payload) is six.text_type: headers = {'content-type': "text/plain"} else: raise exceptions.PayloadException("Invalid Payload Type") uuid_ref = base.calculate_uuid_ref(self._secret_ref, self._entity) self._api.put(uuid_ref, headers=headers, data=self.payload)
def get(self, order_ref): """Retrieve an existing Order from Barbican :param order_ref: Full HATEOAS reference to an Order, or a UUID :returns: An instance of the appropriate subtype of Order :raises barbicanclient.exceptions.HTTPAuthError: 401 Responses :raises barbicanclient.exceptions.HTTPClientError: 4xx Responses :raises barbicanclient.exceptions.HTTPServerError: 5xx Responses """ LOG.debug("Getting order - Order href: {0}".format(order_ref)) uuid_ref = base.calculate_uuid_ref(order_ref, self._entity) try: response = self._api.get(uuid_ref) except AttributeError: raise LookupError( 'Order {0} could not be found.'.format(order_ref)) return self._create_typed_order(response)
def _reload(self): if not self._container_ref: raise AttributeError("container_ref not set, cannot reload data.") LOG.debug('Getting container - Container href: {0}'.format( self._container_ref)) uuid_ref = base.calculate_uuid_ref(self._container_ref, self._entity) try: response = self._api.get(uuid_ref) except AttributeError: raise LookupError('Container {0} could not be found.'.format( self._container_ref)) self._name = response.get('name') self._consumers = response.get('consumers', []) created = response.get('created') updated = response.get('updated') self._created = parse_isotime(created) if created else None self._updated = parse_isotime(updated) if updated else None self._status = response.get('status')
def _fill_lazy_properties(self): if self._secret_ref and not self._name: uuid_ref = base.calculate_uuid_ref(self._secret_ref, self._entity) result = self._api.get(uuid_ref) self._fill_from_data( name=result.get('name'), expiration=result.get('expiration'), algorithm=result.get('algorithm'), bit_length=result.get('bit_length'), secret_type=result.get('secret_type'), mode=result.get('mode'), payload_content_type=result.get('payload_content_type'), payload_content_encoding=result.get( 'payload_content_encoding'), created=result.get('created'), updated=result.get('updated'), content_types=result.get('content_types'), status=result.get('status'))
def _reload(self): if not self._container_ref: raise AttributeError("container_ref not set, cannot reload data.") LOG.debug('Getting container - Container href: {0}' .format(self._container_ref)) uuid_ref = base.calculate_uuid_ref(self._container_ref, self._entity) try: response = self._api.get(uuid_ref) except AttributeError: raise LookupError('Container {0} could not be found.' .format(self._container_ref)) self._name = response.get('name') self._consumers = response.get('consumers', []) created = response.get('created') updated = response.get('updated') self._created = parse_isotime(created) if created else None self._updated = parse_isotime(updated) if updated else None self._status = response.get('status')
def update(self): """Updates the secret in Barbican.""" if not self.payload: raise exceptions.PayloadException("Invalid or Missing Payload") if not self.secret_ref: raise LookupError("Secret is not yet stored.") if type(self.payload) is six.binary_type: headers = {'content-type': "application/octet-stream"} elif type(self.payload) is six.text_type: headers = {'content-type': "text/plain"} else: raise exceptions.PayloadException("Invalid Payload Type") uuid_ref = base.calculate_uuid_ref(self._secret_ref, self._entity) self._api.put(uuid_ref, headers=headers, data=self.payload)
def _fill_lazy_properties(self): if self._secret_ref and not self._name: uuid_ref = base.calculate_uuid_ref(self._secret_ref, self._entity) result = self._api.get(uuid_ref) self._fill_from_data( name=result.get('name'), expiration=result.get('expiration'), algorithm=result.get('algorithm'), bit_length=result.get('bit_length'), secret_type=result.get('secret_type'), mode=result.get('mode'), payload_content_type=result.get('payload_content_type'), payload_content_encoding=result.get( 'payload_content_encoding' ), created=result.get('created'), updated=result.get('updated'), content_types=result.get('content_types'), status=result.get('status') )