def delete(self, request, tenant_id, id): """Destroys the credential with the given id.""" try: self._plugin.delete_credential(tenant_id, id) return exc.HTTPOk() except exception.CredentialNotFound as exp: return faults.Fault(faults.CredentialNotFound(exp))
def show(self, request, tenant_id, id): """Returns credential details for the given credential id.""" try: credential = self._plugin.get_credential_details(tenant_id, id) builder = credential_view.get_view_builder(request) #build response with details result = builder.build(credential, True) return dict(credentials=result) except exception.CredentialNotFound as exp: return faults.Fault(faults.CredentialNotFound(exp))
def update(self, request, tenant_id, id): """Updates the name for the credential with the given id.""" try: body = self._deserialize(request.body, request.get_content_type()) req_body = self._prepare_request_body( body, self._credential_ops_param_list) req_params = req_body[self._resource_name] except exc.HTTPError as exp: return faults.Fault(exp) try: credential = self._plugin.rename_credential( tenant_id, id, req_params['credential_name']) builder = credential_view.get_view_builder(request) result = builder.build(credential, True) return dict(credentials=result) except exception.CredentialNotFound as exp: return faults.Fault(faults.CredentialNotFound(exp))
def update(self, request, tenant_id, id): """ Updates the name for the credential with the given id """ try: req_params = \ self._parse_request_params(request, self._credential_ops_param_list) except exc.HTTPError as exp: return faults.Fault(exp) try: credential = self._plugin.\ rename_credential(tenant_id, id, req_params['credential_name']) builder = credential_view.get_view_builder(request) result = builder.build(credential, True) return dict(credentials=result) except exception.CredentialNotFound as exp: return faults.Fault(faults.CredentialNotFound(exp))