Debian Codegraph @

neutron_lib/api/definitions/segment.py

raw
1 # Copyright (c) 2016 Hewlett Packard Enterprise Development Company, L.P.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License"); you may
4 # not use this file except in compliance with the License. You may obtain
5 # 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, WITHOUT
11 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12 # License for the specific language governing permissions and limitations
13 # under the License.
14
15 import typing
16
17 from neutron_lib.api import converters
18 from neutron_lib.api.definitions import provider_net
19 from neutron_lib.api.definitions import subnet
20 from neutron_lib import constants
21 from neutron_lib.db import constants as db_constants
22
23
24 SEGMENT_ID = 'segment_id'
25 NETWORK_TYPE = 'network_type'
26 PHYSICAL_NETWORK = 'physical_network'
27 SEGMENTATION_ID = 'segmentation_id'
28 NAME_LEN = db_constants.NAME_FIELD_SIZE
29 DESC_LEN = db_constants.DESCRIPTION_FIELD_SIZE
30
31 ALIAS = 'segment'
32 IS_SHIM_EXTENSION = False
33 IS_STANDARD_ATTR_EXTENSION = False
34 NAME = 'Segment'
35 API_PREFIX = ''
36 DESCRIPTION = 'Segments extension.'
37 UPDATED_TIMESTAMP = '2016-02-24T17:00:00-00:00'
38 RESOURCE_NAME = 'segment'
39 COLLECTION_NAME = RESOURCE_NAME + 's'
40 RESOURCE_ATTRIBUTE_MAP: dict[str, typing.Any] = {
41 COLLECTION_NAME: {
42 'id': {
43 'allow_post': False,
44 'allow_put': False,
45 'validate': {
46 'type:uuid': None
47 },
48 'is_filter': True,
49 'is_sort_key': True,
50 'is_visible': True,
51 'primary_key': True
52 },
53 'tenant_id': {
54 'allow_post': True,
55 'allow_put': False,
56 'validate': {
57 'type:string': db_constants.PROJECT_ID_FIELD_SIZE
58 },
59 'is_visible': False},
60 'network_id': {
61 'allow_post': True,
62 'allow_put': False,
63 'validate': {
64 'type:uuid': None
65 },
66 'is_filter': True,
67 'is_sort_key': True,
68 'is_visible': True
69 },
70 PHYSICAL_NETWORK: {
71 'allow_post': True,
72 'allow_put': False,
73 'default': constants.ATTR_NOT_SPECIFIED,
74 'validate': {
75 'type:string': provider_net.PHYSICAL_NETWORK_MAX_LEN
76 },
77 'is_filter': True,
78 'is_sort_key': True,
79 'is_visible': True
80 },
81 NETWORK_TYPE: {
82 'allow_post': True,
83 'allow_put': False,
84 'validate': {
85 'type:string': provider_net.NETWORK_TYPE_MAX_LEN
86 },
87 'is_filter': True,
88 'is_sort_key': True,
89 'is_visible': True
90 },
91 SEGMENTATION_ID: {
92 'allow_post': True,
93 'allow_put': False,
94 'default': constants.ATTR_NOT_SPECIFIED,
95 'convert_to': converters.convert_to_int,
96 'is_sort_key': True,
97 'is_visible': True
98 },
99 'name': {
100 'allow_post': True,
101 'allow_put': True,
102 'default': constants.ATTR_NOT_SPECIFIED,
103 'validate': {
104 'type:string_or_none': NAME_LEN
105 },
106 'is_filter': True,
107 'is_sort_key': True,
108 'is_visible': True
109 }
110 },
111 subnet.COLLECTION_NAME: {
112 SEGMENT_ID: {
113 'allow_post': True,
114 'allow_put': False,
115 'default': None,
116 'validate': {
117 'type:uuid_or_none': None
118 },
119 'is_filter': True,
120 'is_sort_key': True,
121 'is_visible': True
122 }
123 }
124 }
125 SUB_RESOURCE_ATTRIBUTE_MAP = {}
126 ACTION_MAP = {}
127 REQUIRED_EXTENSIONS = [
128 'standard-attr-description'
129 ]
130 OPTIONAL_EXTENSIONS = [
131 # Use string instead of constant to avoid circulated import
132 'standard-attr-segment'
133 ]
134 ACTION_STATUS = {}