def _items(self, request, tenant_id, is_detail):
     """Returns a list of credentials."""
     credentials = self._plugin.get_all_credentials(tenant_id)
     builder = credential_view.get_view_builder(request)
     result = [builder.build(credential, is_detail)['credential']
               for credential in credentials]
     return dict(credentials=result)
Exemple #2
0
 def _items(self, request, tenant_id, is_detail):
     """Returns a list of credentials."""
     credentials = self._plugin.get_all_credentials(tenant_id)
     builder = credential_view.get_view_builder(request)
     result = [
         builder.build(credential, is_detail)['credential']
         for credential in credentials
     ]
     return dict(credentials=result)
 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))
Exemple #4
0
 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))
Exemple #5
0
    def create(self, request, tenant_id):
        """Creates a new credential for a given tenant."""
        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)
        credential = self._plugin.create_credential(
            tenant_id, req_params['credential_name'], req_params['user_name'],
            req_params['password'])
        builder = credential_view.get_view_builder(request)
        result = builder.build(credential)
        return dict(credentials=result)
    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 create(self, request, tenant_id):
        """Creates a new credential for a given tenant."""
        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)
        credential = self._plugin.create_credential(
            tenant_id,
            req_params['credential_name'],
            req_params['user_name'],
            req_params['password'])
        builder = credential_view.get_view_builder(request)
        result = builder.build(credential)
        return dict(credentials=result)
Exemple #8
0
    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))