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

Source Code for Module yakumo.keystone.v3.user

  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 users 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      ('name', 'name', mapper.Noop), 
 28      ('password', 'password', mapper.Noop), 
 29      ('email', 'email', mapper.Noop), 
 30      ('project', 'default_project_id', mapper.Resource('keystone.project')), 
 31      ('domain', 'domain_id', mapper.Resource('keystone.domain')), 
 32      ('is_enabled', 'enabled', mapper.Noop), 
 33  ] 
 34   
 35   
36 -class Resource(base.Resource):
37 """resource class for users on Identity V3 API""" 38
39 - def update(self, name=UNDEF, password=UNDEF, email=UNDEF, project=UNDEF, 40 domain=UNDEF, is_enabled=UNDEF):
41 """ 42 Update properties of a user 43 44 @keyword name: User name 45 @type name: str 46 @keyword password: Password 47 @type password: str 48 @keyword email: E-mail address 49 @type email: str 50 @keyword project: Project 51 @type project: yakumo.keystone.v3.project.Resource 52 @keyword domain: Domain 53 @type domain: yakumo.keystone.v3.domain.Resource 54 @keyword is_enabled: Whether the user is enabled or not 55 @type is_enabled: bool 56 @rtype: None 57 """ 58 super(Resource, self).update( 59 name=name, 60 password=password, 61 email=email, 62 project=project, 63 domain=domain, 64 is_enabled=is_enabled)
65 66
67 -class Manager(base.Manager):
68 """manager class for users on Identity V3 API""" 69 70 resource_class = Resource 71 service_type = 'identity' 72 _attr_mapping = ATTRIBUTE_MAPPING 73 _json_resource_key = 'user' 74 _json_resources_key = 'users' 75 _update_method = 'patch' 76 _url_resource_path = '/users' 77
78 - def create(self, name=UNDEF, password=UNDEF, email=UNDEF, project=UNDEF, 79 domain=UNDEF, is_enabled=UNDEF):
80 """ 81 Register a user 82 83 @keyword name: User name 84 @type name: str 85 @keyword password: Password 86 @type password: str 87 @keyword email: E-mail address 88 @type email: str 89 @keyword project: Project 90 @type project: yakumo.keystone.v3.project.Resource 91 @keyword domain: Domain 92 @type domain: yakumo.keystone.v3.domain.Resource 93 @keyword is_enabled: Whether the user is enabled or not 94 @type is_enabled: bool 95 @return: Created user 96 @rtype: yakumo.keystone.v3.user.Resource 97 """ 98 return super(Manager, self).create( 99 name=name, 100 password=password, 101 email=email, 102 project=project, 103 domain=domain, 104 is_enabled=is_enabled)
105