diff --git a/api-ref/source/v2/samples/tag/tag-create-request.json b/api-ref/source/v2/samples/tag/tag-create-request.json new file mode 100644 index 000000000..f047e8e6f --- /dev/null +++ b/api-ref/source/v2/samples/tag/tag-create-request.json @@ -0,0 +1,6 @@ +{ + "tags": [ + "red", + "blue" + ] +} diff --git a/api-ref/source/v2/tags.inc b/api-ref/source/v2/tags.inc index a8532b268..a53dc72ef 100644 --- a/api-ref/source/v2/tags.inc +++ b/api-ref/source/v2/tags.inc @@ -17,6 +17,32 @@ standard attributes. This includes networks, ports, subnets, subnet pools, floating IPs, routers, security groups, security group rules, QoS policies and trunks. +Create tags +=========== + +.. rest_method:: POST /v2.0/{resource_type}/{resource_id}/tags + +Creates multiple tags for a resource. + +Normal response codes: 200 + +Error response codes: 400, 401, 403 + +Request +------- + +.. rest_parameters:: parameters.yaml + + - resource_type: resource_type + - resource_id: resource_id + - tags: tags + +Request Example +--------------- + +.. literalinclude:: samples/tag/tag-create-request.json + :language: javascript + Replace all tags ================ diff --git a/neutron_lib/api/definitions/__init__.py b/neutron_lib/api/definitions/__init__.py index 851fbf533..dc82d0076 100644 --- a/neutron_lib/api/definitions/__init__.py +++ b/neutron_lib/api/definitions/__init__.py @@ -154,6 +154,7 @@ from neutron_lib.api.definitions import subnet_service_types from neutron_lib.api.definitions import subnetpool from neutron_lib.api.definitions import subnetpool_prefix_ops from neutron_lib.api.definitions import taas +from neutron_lib.api.definitions import tag_creation from neutron_lib.api.definitions import tag_ports_during_bulk_creation from neutron_lib.api.definitions import tap_mirror from neutron_lib.api.definitions import trunk @@ -311,6 +312,7 @@ _ALL_API_DEFINITIONS = { subnetpool, subnetpool_prefix_ops, taas, + tag_creation, tag_ports_during_bulk_creation, tap_mirror, trunk, diff --git a/neutron_lib/api/definitions/base.py b/neutron_lib/api/definitions/base.py index 2f86f1f0c..b317f1421 100644 --- a/neutron_lib/api/definitions/base.py +++ b/neutron_lib/api/definitions/base.py @@ -175,6 +175,7 @@ KNOWN_EXTENSIONS = ( 'subnet-segmentid-enforce', 'subnet-segmentid-writable', 'tag', + 'tag-creation', 'trunk', 'trunk-details', # Add here list of extensions with pointers to the project repo, e.g. diff --git a/neutron_lib/api/definitions/tag_creation.py b/neutron_lib/api/definitions/tag_creation.py new file mode 100644 index 000000000..81a12c186 --- /dev/null +++ b/neutron_lib/api/definitions/tag_creation.py @@ -0,0 +1,28 @@ +# Copyright 2024 Red Hat, Inc. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +ALIAS = 'tag-creation' +IS_SHIM_EXTENSION = True +IS_STANDARD_ATTR_EXTENSION = False +NAME = 'Tag creation extension' +DESCRIPTION = 'Allow to create multiple tags for a resource' +UPDATED_TIMESTAMP = '2024-23-07T10:00:00-00:00' +RESOURCE_ATTRIBUTE_MAP = {} +SUB_RESOURCE_ATTRIBUTE_MAP = {} +ACTION_MAP = {} +REQUIRED_EXTENSIONS = [] +OPTIONAL_EXTENSIONS = [] +ACTION_STATUS = {} diff --git a/neutron_lib/tests/unit/api/definitions/test_tag_creation.py b/neutron_lib/tests/unit/api/definitions/test_tag_creation.py new file mode 100644 index 000000000..9f71444eb --- /dev/null +++ b/neutron_lib/tests/unit/api/definitions/test_tag_creation.py @@ -0,0 +1,21 @@ +# Copyright 2024 Red Hat, Inc. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from neutron_lib.api.definitions import tag_creation +from neutron_lib.tests.unit.api.definitions import base + + +class TagCreationDefinitionTestCase(base.DefinitionBaseTestCase): + extension_module = tag_creation diff --git a/releasenotes/notes/tag-creation-1ba476d17e3de502.yaml b/releasenotes/notes/tag-creation-1ba476d17e3de502.yaml new file mode 100644 index 000000000..1d3a05613 --- /dev/null +++ b/releasenotes/notes/tag-creation-1ba476d17e3de502.yaml @@ -0,0 +1,5 @@ +--- +features: + - The ``tag-creation`` shim extension API definition enables the creation + of multiple tags for a single resource using a ``POST`` request. The value + of the tags is passed as an argument of the call.