yakumo.keystone.v3.credential

Package yakumo :: Package keystone :: Package v3 :: Module credential |
[hide private]
[frames] | no frames]

# Source Code for Module yakumo.keystone.v3.credential

     1  # Copyright 2014-2017 by Akira Yoshiyama <akirayoshiyama@gmail.com>.
     2  # All Rights Reserved.
     3  #
     4  #    Licensed under the Apache License, Version 2.0 (the "License"); you may
     5  #    not use this file except in compliance with the License. You may obtain
     6  #    a copy of the License at
     7  #
     8  #         http://www.apache.org/licenses/LICENSE-2.0
     9  #
    10  #    Unless required by applicable law or agreed to in writing, software
    11  #    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
    12  #    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
    13  #    License for the specific language governing permissions and limitations
    14  #    under the License.
    15
    16  """
    17  Resource class and its manager for credentials in Identity V3 API
    18  """
    19
    20  from yakumo import base
    21  from yakumo.constant import UNDEF
    22  from yakumo import mapper
    23
    24
    25  ATTRIBUTE_MAPPING = [
    26      ('id', 'id', mapper.Noop),
    27      ('type', 'type', mapper.Noop),
    28      ('blob', 'blob', mapper.JSON),
    29      ('user', 'user_id', mapper.Resource('keystone.user')),
    30      ('project', 'project_id', mapper.Resource('keystone.project')),
    31  ]
    32
    33
    34 -class Resource(base.Resource):
    35      """resource class for credentials on Identity V3 API"""
    36
    37 -    def update(self, type=UNDEF, blob=UNDEF, user=UNDEF, project=UNDEF):
    38          """
    39          Update properties of a credential
    40
    41          @keyword type: Credential type
    42          @type type: str
    43          @keyword blob: Blob
    44          @type blob: str
    45          @keyword user: User
    46          @type user: yakumo.keystone.v3.user.Resource
    47          @keyword project: Project
    48          @type project: yakumo.keystone.v3.project.Resource
    49          @rtype: None
    50          """
    51          super(Resource, self).update(
    52              type=type,
    53              blob=blob,
    54              user=user,
    55              project=project)
    56
    57
    58 -class Manager(base.Manager):
    59      """manager class for credentials on Identity V3 API"""
    60
    61      resource_class = Resource
    62      service_type = 'identity'
    63      _attr_mapping = ATTRIBUTE_MAPPING
    64      _json_resource_key = 'credential'
    65      _json_resources_key = 'credentials'
    66      _update_method = 'patch'
    67      _url_resource_path = '/credentials'
    68
    69 -    def create(self, type=UNDEF, blob=UNDEF, user=UNDEF, project=UNDEF):
    70          """
    71          Register a credential
    72
    73          @keyword type: Credential type
    74          @type type: str
    75          @keyword blob: Blob
    76          @type blob: str
    77          @keyword user: User
    78          @type user: yakumo.keystone.v3.user.Resource
    79          @keyword project: Project
    80          @type project: yakumo.keystone.v3.project.Resource
    81          @return: Created credential
    82          @rtype: yakumo.keystone.v3.creadential.Resource
    83          """
    84          return super(Manager, self).create(
    85              type=type,
    86              blob=blob,
    87              user=user,
    88              project=project)
    89