"Fossies" - the Fresh Open Source Software Archive

Member "keystone-18.0.0/keystone/resource/schema.py" (14 Oct 2020, 3286 Bytes) of package /linux/misc/openstack/keystone-18.0.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. For more information about "schema.py" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 17.0.0_vs_18.0.0.

    1 # Licensed under the Apache License, Version 2.0 (the "License"); you may
    2 # not use this file except in compliance with the License. You may obtain
    3 # a copy of the License at
    4 #
    5 # http://www.apache.org/licenses/LICENSE-2.0
    6 #
    7 # Unless required by applicable law or agreed to in writing, software
    8 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
    9 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
   10 # License for the specific language governing permissions and limitations
   11 # under the License.
   12 
   13 from keystone.common import validation
   14 from keystone.common.validation import parameter_types
   15 from keystone.resource.backends import resource_options as ro
   16 
   17 _name_properties = {
   18     'type': 'string',
   19     'minLength': 1,
   20     'maxLength': 64,
   21     'pattern': r'[\S]+'
   22 }
   23 
   24 _project_tag_name_properties = {
   25     'type': 'string',
   26     'minLength': 1,
   27     'maxLength': 255,
   28     # NOTE(gagehugo) This pattern is for tags which follows the
   29     # guidelines as set by the API-WG, which matches anything that
   30     # does not contain a '/' or ','.
   31     # https://specs.openstack.org/openstack/api-wg/guidelines/tags.html
   32     'pattern': '^[^,/]*$'
   33 }
   34 
   35 _project_tags_list_properties = {
   36     'type': 'array',
   37     'items': _project_tag_name_properties,
   38     'required': [],
   39     'maxItems': 80,
   40     'uniqueItems': True
   41 }
   42 
   43 _project_properties = {
   44     'description': validation.nullable(parameter_types.description),
   45     # NOTE(htruta): domain_id is nullable for projects acting as a domain.
   46     'domain_id': validation.nullable(parameter_types.id_string),
   47     'enabled': parameter_types.boolean,
   48     'is_domain': parameter_types.boolean,
   49     'parent_id': validation.nullable(parameter_types.id_string),
   50     'name': _name_properties,
   51     'tags': _project_tags_list_properties,
   52     'options': ro.PROJECT_OPTIONS_REGISTRY.json_schema
   53 }
   54 
   55 # This is for updating a single project tag via the URL
   56 project_tag_create = _project_tag_name_properties
   57 
   58 # This is for updaing a project with a list of tags
   59 project_tags_update = _project_tags_list_properties
   60 
   61 project_create = {
   62     'type': 'object',
   63     'properties': _project_properties,
   64     # NOTE(lbragstad): A project name is the only parameter required for
   65     # project creation according to the Identity V3 API. We should think
   66     # about using the maxProperties validator here, and in update.
   67     'required': ['name'],
   68     'additionalProperties': True
   69 }
   70 
   71 project_update = {
   72     'type': 'object',
   73     'properties': _project_properties,
   74     # NOTE(lbragstad): Make sure at least one property is being updated
   75     'minProperties': 1,
   76     'additionalProperties': True
   77 }
   78 
   79 _domain_properties = {
   80     'description': validation.nullable(parameter_types.description),
   81     'enabled': parameter_types.boolean,
   82     'name': _name_properties,
   83     'tags': project_tags_update
   84 }
   85 
   86 domain_create = {
   87     'type': 'object',
   88     'properties': _domain_properties,
   89     # TODO(lbragstad): According to the V3 API spec, name isn't required but
   90     # the current implementation in assignment.controller:DomainV3 requires a
   91     # name for the domain.
   92     'required': ['name'],
   93     'additionalProperties': True
   94 }
   95 
   96 domain_update = {
   97     'type': 'object',
   98     'properties': _domain_properties,
   99     'minProperties': 1,
  100     'additionalProperties': True
  101 }