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

Source Code for Module yakumo.keystone.v2.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 V2 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      ('username', 'username', mapper.Noop), 
 29      ('password', 'password', mapper.Noop), 
 30      ('email', 'email', mapper.Noop), 
 31      ('project', 'project_id', mapper.Resource('keystone.project')), 
 32      ('is_enabled', 'enabled', mapper.Noop), 
 33  ] 
 34   
 35   
36 -class Resource(base.Resource):
37 """resource class for users on Identity V2 API""" 38
39 - def update(self, name=UNDEF, username=UNDEF, password=UNDEF, email=UNDEF, 40 project=UNDEF, is_enabled=UNDEF):
41 """ 42 update properties of a user 43 44 @keyword name: User account 45 @type name: str 46 @keyword username: Full name 47 @type username: str 48 @keyword password: Password 49 @type password: str 50 @keyword email: E-mail address 51 @type email: str 52 @keyword project: Project 53 @type project: yakumo.keystone.v2.project.Resource 54 @keyword is_enabled: Whether the user is enabled or not 55 @type is_enabled: str 56 @rtype: None 57 """ 58 super(Resource, self).update( 59 name=name, 60 username=username, 61 password=password, 62 email=email, 63 project=project, 64 is_enabled=is_enabled)
65 66
67 -class Manager(base.Manager):
68 """manager class for users on Identity V2 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 _url_resource_path = '/users' 76
77 - def create(self, name=UNDEF, username=UNDEF, password=UNDEF, email=UNDEF, 78 project=UNDEF, is_enabled=UNDEF):
79 """ 80 Register a user 81 82 @keyword name: User account 83 @type name: str 84 @keyword username: Full name 85 @type username: str 86 @keyword password: Password 87 @type password: str 88 @keyword email: E-mail address 89 @type email: str 90 @keyword project: Project 91 @type project: yakumo.keystone.v2.project.Resource 92 @keyword is_enabled: Whether the user is enabled or not 93 @type is_enabled: str 94 @return: Created user 95 @rtype: yakumo.keystone.v2.user.Resource 96 """ 97 return super(Manager, self).create( 98 name=name, 99 username=username, 100 password=password, 101 email=email, 102 project=project, 103 is_enabled=is_enabled)
104