"Fossies" - the Fresh Open Source Software Archive

Member "keystone-18.0.0/keystone/common/validation/parameter_types.py" (14 Oct 2020, 2085 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 "parameter_types.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 """Common parameter types for validating a request reference."""
   13 
   14 boolean = {
   15     'type': 'boolean',
   16     'enum': [True, False]
   17 }
   18 
   19 # NOTE(lbragstad): Be mindful of this pattern as it might require changes
   20 # once this is used on user names, LDAP-based user names specifically since
   21 # commas aren't allowed in the following pattern. Here we are only going to
   22 # check the length of the name and ensure that it's a string. Right now we are
   23 # not going to validate on a naming pattern for issues with
   24 # internationalization.
   25 name = {
   26     'type': 'string',
   27     'minLength': 1,
   28     'maxLength': 255,
   29     'pattern': r'[\S]+'
   30 }
   31 
   32 external_id_string = {
   33     'type': 'string',
   34     'minLength': 1,
   35     'maxLength': 64
   36 }
   37 
   38 id_string = {
   39     'type': 'string',
   40     'minLength': 1,
   41     'maxLength': 64,
   42     # TODO(lbragstad): Find a way to make this configurable such that the end
   43     # user chooses how much control they want over id_strings with a regex
   44     'pattern': r'^[a-zA-Z0-9-]+$'
   45 }
   46 
   47 mapping_id_string = {
   48     'type': 'string',
   49     'minLength': 1,
   50     'maxLength': 64,
   51     'pattern': '^[a-zA-Z0-9-_]+$'
   52 }
   53 
   54 description = {
   55     'type': 'string'
   56 }
   57 
   58 url = {
   59     'type': 'string',
   60     'minLength': 0,
   61     'maxLength': 225,
   62     # NOTE(edmondsw): we could do more to validate per various RFCs, but
   63     # decision was made to err on the side of leniency. The following is based
   64     # on rfc1738 section 2.1
   65     'pattern': '^[a-zA-Z0-9+.-]+:.+'
   66 }
   67 
   68 email = {
   69     'type': 'string',
   70     'format': 'email'
   71 }
   72 
   73 integer_min0 = {
   74     'type': 'integer',
   75     'minimum': 0
   76 }