"Fossies" - the Fresh Open Source Software Archive

Member "glance-19.0.0/glance/api/v2/model/metadef_property_type.py" (16 Oct 2019, 2354 Bytes) of package /linux/misc/openstack/glance-19.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 "metadef_property_type.py" see the Fossies "Dox" file reference documentation.

    1 # Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
    2 #
    3 # Licensed under the Apache License, Version 2.0 (the "License");
    4 # you may not use this file except in compliance with the License.
    5 # You may obtain a copy of the License at
    6 #
    7 #    http://www.apache.org/licenses/LICENSE-2.0
    8 #
    9 # Unless required by applicable law or agreed to in writing, software
   10 # distributed under the License is distributed on an "AS IS" BASIS,
   11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
   12 # implied.
   13 # See the License for the specific language governing permissions and
   14 # limitations under the License.
   15 
   16 import wsme
   17 from wsme import types
   18 
   19 from glance.api.v2.model.metadef_property_item_type import ItemType
   20 from glance.common.wsme_utils import WSMEModelTransformer
   21 
   22 
   23 class PropertyType(types.Base, WSMEModelTransformer):
   24     # When used in collection of PropertyTypes, name is a dictionary key
   25     # and not included as separate field.
   26     name = wsme.wsattr(types.text, mandatory=False)
   27 
   28     type = wsme.wsattr(types.text, mandatory=True)
   29     title = wsme.wsattr(types.text, mandatory=True)
   30     description = wsme.wsattr(types.text, mandatory=False)
   31     operators = wsme.wsattr([types.text], mandatory=False)
   32     default = wsme.wsattr(types.bytes, mandatory=False)
   33     readonly = wsme.wsattr(bool, mandatory=False)
   34 
   35     # fields for type = string
   36     minimum = wsme.wsattr(int, mandatory=False)
   37     maximum = wsme.wsattr(int, mandatory=False)
   38     enum = wsme.wsattr([types.text], mandatory=False)
   39     pattern = wsme.wsattr(types.text, mandatory=False)
   40 
   41     # fields for type = integer, number
   42     minLength = wsme.wsattr(int, mandatory=False)
   43     maxLength = wsme.wsattr(int, mandatory=False)
   44     confidential = wsme.wsattr(bool, mandatory=False)
   45 
   46     # fields for type = array
   47     items = wsme.wsattr(ItemType, mandatory=False)
   48     uniqueItems = wsme.wsattr(bool, mandatory=False)
   49     minItems = wsme.wsattr(int, mandatory=False)
   50     maxItems = wsme.wsattr(int, mandatory=False)
   51     additionalItems = wsme.wsattr(bool, mandatory=False)
   52 
   53     def __init__(self, **kwargs):
   54         super(PropertyType, self).__init__(**kwargs)
   55 
   56 
   57 class PropertyTypes(types.Base, WSMEModelTransformer):
   58     properties = wsme.wsattr({types.text: PropertyType}, mandatory=False)
   59 
   60     def __init__(self, **kwargs):
   61         super(PropertyTypes, self).__init__(**kwargs)