1 # Copyright (c) 2017 Cable Television Laboratories, Inc. ("CableLabs")
2 # and others. All rights reserved.
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at:
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
17 class UserConfig(object):
19 Class for holding user configurations
21 def __init__(self, **kwargs):
25 :param name: the user's name (required)
26 :param password: the user's password (required)
27 :param project_name: the user's primary project name (optional)
28 :param domain_name: the user's domain name (default='Default'). For v3
30 :param email: the user's email address (optional)
31 :param enabled: denotes whether or not the user is enabled
33 :param roles: dict where key is the role's name and value is the name
34 of the project to associate with the role (optional)
37 self.name = kwargs.get('name')
38 self.password = kwargs.get('password')
39 self.project_name = kwargs.get('project_name')
40 self.email = kwargs.get('email')
41 self.domain_name = kwargs.get('domain_name', 'Default')
42 self.enabled = kwargs.get('enabled', True)
43 self.roles = kwargs.get('roles', dict())
45 if not self.name or not self.password:
46 raise UserConfigException(
47 'The attributes name and password are required for '
50 if not isinstance(self.enabled, bool):
51 raise UserConfigException(
52 'The attribute enabled must be of type boolean')
55 class UserConfigException(Exception):
57 Raised when there is a problem with the values set in the UserConfig