From e306626db0666be1732a2403b010794e23c9bc28 Mon Sep 17 00:00:00 2001 From: Artem Goncharov Date: Fri, 6 Dec 2024 09:16:40 +0100 Subject: [PATCH] Prepare remaining keystone schemas query parameters start being duplicated due to the different naming convention used from the extracted decorators and the ones hardcoded. Adapt hardcoded names to be hopefully properly identified using openapi construction. Change-Id: Ifd6f120c7dd43323528e93c1d4216ede7525ebae --- .../openapi/keystone_schemas/endpoint.py | 6 +- .../openapi/keystone_schemas/federation.py | 4 +- .../openapi/keystone_schemas/group.py | 4 +- .../openapi/keystone_schemas/project.py | 149 ------------------ .../openapi/keystone_schemas/region.py | 2 +- .../openapi/keystone_schemas/role.py | 20 +-- .../openapi/keystone_schemas/service.py | 2 +- 7 files changed, 19 insertions(+), 168 deletions(-) delete mode 100644 codegenerator/openapi/keystone_schemas/project.py diff --git a/codegenerator/openapi/keystone_schemas/endpoint.py b/codegenerator/openapi/keystone_schemas/endpoint.py index 02390e8..8bb027e 100644 --- a/codegenerator/openapi/keystone_schemas/endpoint.py +++ b/codegenerator/openapi/keystone_schemas/endpoint.py @@ -70,19 +70,19 @@ ENDPOINTS_SCHEMA: dict[str, Any] = { } ENDPOINTS_LIST_PARAMETERS = { - "endpoint_service_id": { + "endpoints_service_id": { "in": "query", "name": "service_id", "description": "Filters the response by a service ID.", "schema": {"type": "string", "format": "uuid"}, }, - "endpoint_region_id": { + "endpoints_region_id": { "in": "query", "name": "region", "description": "Filters the response by a region ID.", "schema": {"type": "string", "format": "uuid"}, }, - "endpoint_interface": { + "endpoints_interface": { "in": "query", "name": "interface", "description": "Filters the response by an interface.", diff --git a/codegenerator/openapi/keystone_schemas/federation.py b/codegenerator/openapi/keystone_schemas/federation.py index 048da41..a421b39 100644 --- a/codegenerator/openapi/keystone_schemas/federation.py +++ b/codegenerator/openapi/keystone_schemas/federation.py @@ -84,13 +84,13 @@ IDENTITY_PROVIDERS_SCHEMA: dict[str, Any] = { } IDENTITY_PROVIDERS_LIST_PARAMETERS: dict[str, Any] = { - "idp_id": { + "idps_id": { "in": "query", "name": "id", "description": "Filter for Identity Providers’ ID attribute", "schema": {"type": "string"}, }, - "idp_enabled": { + "idps_enabled": { "in": "query", "name": "enabled", "description": "Filter for Identity Providers’ enabled attribute", diff --git a/codegenerator/openapi/keystone_schemas/group.py b/codegenerator/openapi/keystone_schemas/group.py index cf6490d..04df840 100644 --- a/codegenerator/openapi/keystone_schemas/group.py +++ b/codegenerator/openapi/keystone_schemas/group.py @@ -38,7 +38,7 @@ GROUPS_SCHEMA: dict[str, Any] = { } GROUPS_LIST_PARAMETERS: dict[str, Any] = { - "group_domain_id": { + "groups_domain_id": { "in": "query", "name": "domain_id", "description": "Filters the response by a domain ID.", @@ -47,7 +47,7 @@ GROUPS_LIST_PARAMETERS: dict[str, Any] = { } GROUP_USERS_LIST_PARAMETERS: dict[str, Any] = { - "group_user_password_expires_at": { + "group_users_password_expires_at": { "in": "query", "name": "password_expires_at", "description": "Filter results based on which user passwords have expired. The query should include an operator and a timestamp with a colon (:) separating the two, for example: `password_expires_at={operator}:{timestamp}`.\nValid operators are: `lt`, `lte`, `gt`, `gte`, `eq`, and `neq`.\nValid timestamps are of the form: YYYY-MM-DDTHH:mm:ssZ.", diff --git a/codegenerator/openapi/keystone_schemas/project.py b/codegenerator/openapi/keystone_schemas/project.py deleted file mode 100644 index 9892cda..0000000 --- a/codegenerator/openapi/keystone_schemas/project.py +++ /dev/null @@ -1,149 +0,0 @@ -# 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 typing import Any -# -# from keystone.resource import schema as ks_schema -# -# from codegenerator.common.schema import TypeSchema -# from codegenerator.common.schema import ParameterSchema -# from codegenerator.openapi.keystone_schemas import common -# -# -# PROJECT_SCHEMA: dict[str, Any] = { -# "type": "object", -# "properties": { -# "id": {"type": "string", "format": "uuid", "readOnly": True}, -# **ks_schema._project_properties, -# }, -# "additionalProperties": True, -# } -# -# PROJECT_CONTAINER_SCHEMA: dict[str, Any] = { -# "type": "object", -# "properties": { -# "project": { -# "type": "object", -# "properties": { -# "id": {"type": "string", "format": "uuid", "readOnly": True}, -# **ks_schema._project_properties, -# }, -# "additionalProperties": True, -# } -# }, -# } -# -# PROJECTS_SCHEMA: dict[str, Any] = { -# "type": "object", -# "properties": {"projects": {"type": "array", "items": PROJECT_SCHEMA}}, -# } -# -# PROJECT_LIST_PARAMETERS = { -# "project_domain_id": { -# "in": "query", -# "name": "domain_id", -# "description": "Filters the response by a domain ID.", -# "schema": {"type": "string", "format": "uuid"}, -# }, -# "project_enabled": { -# "in": "query", -# "name": "enabled", -# "description": "If set to true, then only enabled projects will be returned. Any value other than 0 (including no value) will be interpreted as true.", -# "schema": {"type": "boolean"}, -# }, -# "project_is_domain": { -# "in": "query", -# "name": "is_domain", -# "description": "If this is specified as true, then only projects acting as a domain are included. Otherwise, only projects that are not acting as a domain are included.", -# "schema": {"type": "boolean"}, -# "x-openstack": {"min-ver": "3.6"}, -# }, -# "project_name": { -# "in": "query", -# "name": "name", -# "description": "Filters the response by a resource name.", -# "schema": {"type": "string"}, -# }, -# "project_parent_id": { -# "in": "query", -# "name": "parent_id", -# "description": "Filters the response by a parent ID.", -# "schema": {"type": "string", "format": "uuid"}, -# "x-openstack": {"min-ver": "3.4"}, -# }, -# } -# -# -# def _post_process_operation_hook( -# openapi_spec, operation_spec, path: str | None = None -# ): -# """Hook to allow service specific generator to modify details""" -# operationId = operation_spec.operationId -# if operationId == "projects:get": -# for key, val in PROJECT_LIST_PARAMETERS.items(): -# openapi_spec.components.parameters.setdefault( -# key, ParameterSchema(**val) -# ) -# ref = f"#/components/parameters/{key}" -# if ref not in [x.ref for x in operation_spec.parameters]: -# operation_spec.parameters.append(ParameterSchema(ref=ref)) -# -# -# def _get_schema_ref( -# openapi_spec, name, description=None, schema_def=None, action_name=None -# ) -> tuple[str | None, str | None, bool]: -# mime_type: str = "application/json" -# ref: str -# # Projects -# if name in [ -# "ProjectsPostRequest", -# "ProjectsPostResponse", -# "ProjectPatchRequest", -# "ProjectPatchResponse", -# "ProjectGetResponse", -# ]: -# openapi_spec.components.schemas.setdefault( -# "Project", TypeSchema(**PROJECT_CONTAINER_SCHEMA) -# ) -# ref = "#/components/schemas/Project" -# elif name == "ProjectsGetResponse": -# openapi_spec.components.schemas.setdefault( -# name, TypeSchema(**PROJECTS_SCHEMA) -# ) -# ref = f"#/components/schemas/{name}" -# -# # Project Tags -# elif name == "ProjectsTagPutRequest": -# openapi_spec.components.schemas.setdefault( -# name, TypeSchema(**ks_schema.project_tag_create) -# ) -# ref = f"#/components/schemas/{name}" -# elif name == "ProjectsTagsPutRequest": -# openapi_spec.components.schemas.setdefault( -# name, TypeSchema(**ks_schema.project_tags_update) -# ) -# ref = f"#/components/schemas/{name}" -# elif name == "ProjectsTagsGetResponse": -# openapi_spec.components.schemas.setdefault( -# name, TypeSchema(**common.TAGS_SCHEMA) -# ) -# ref = f"#/components/schemas/{name}" -# elif name == "ProjectsTagsPutResponse": -# openapi_spec.components.schemas.setdefault( -# name, TypeSchema(**common.TAGS_SCHEMA) -# ) -# ref = f"#/components/schemas/{name}" -# -# else: -# return (None, None, False) -# -# return (ref, mime_type, True) diff --git a/codegenerator/openapi/keystone_schemas/region.py b/codegenerator/openapi/keystone_schemas/region.py index abc0d9c..9c08e0b 100644 --- a/codegenerator/openapi/keystone_schemas/region.py +++ b/codegenerator/openapi/keystone_schemas/region.py @@ -47,7 +47,7 @@ REGIONS_SCHEMA: dict[str, Any] = { } REGIONS_LIST_PARAMETERS = { - "region_parent_region_id": { + "regions_parent_region_id": { "in": "query", "name": "parent_region_id", "description": "Filters the response by a parent region, by ID.", diff --git a/codegenerator/openapi/keystone_schemas/role.py b/codegenerator/openapi/keystone_schemas/role.py index fcbcb18..5097157 100644 --- a/codegenerator/openapi/keystone_schemas/role.py +++ b/codegenerator/openapi/keystone_schemas/role.py @@ -103,7 +103,7 @@ ROLES_INFO_SCHEMA: dict[str, Any] = { # Role list specific query parameters ROLE_LIST_PARAMETERS: dict[str, Any] = { - "role_domain_id": { + "roles_domain_id": { "in": "query", "name": "domain_id", "description": "Filters the response by a domain ID.", @@ -219,37 +219,37 @@ ROLE_ASSIGNMENTS_SCHEMA: dict[str, Any] = { #: Role assignment query parameters common for LIST and HEAD ROLE_ASSIGNMENTS_QUERY_PARAMETERS: dict[str, Any] = { - "role_assignment_group_id": { + "role_assignments_group_id": { "in": "query", "name": "group.id", "description": "Filters the response by a group ID.", "schema": {"type": "string", "format": "uuid"}, }, - "role_assignment_role_id": { + "role_assignments_role_id": { "in": "query", "name": "role.id", "description": "Filters the response by a role ID.", "schema": {"type": "string", "format": "uuid"}, }, - "role_assignment_user_id": { + "role_assignments_user_id": { "in": "query", "name": "user.id", "description": "Filters the response by a user ID.", "schema": {"type": "string", "format": "uuid"}, }, - "role_assignment_scope_domain_id": { + "role_assignments_scope_domain_id": { "in": "query", "name": "scope.domain.id", "description": "Filters the response by a domain ID.", "schema": {"type": "string", "format": "uuid"}, }, - "role_assignment_scope_project_id": { + "role_assignments_scope_project_id": { "in": "query", "name": "scope.project.id", "description": "Filters the response by a project ID.", "schema": {"type": "string", "format": "uuid"}, }, - "role_assignment_inherit": { + "role_assignments_inherit": { "in": "query", "name": "scope.OS-INHERIT:inherited_to", "description": "Filters based on role assignments that are inherited. The only value of inherited_to that is currently supported is projects.", @@ -259,7 +259,7 @@ ROLE_ASSIGNMENTS_QUERY_PARAMETERS: dict[str, Any] = { # Role assignments list specific query parameters ROLE_ASSIGNMENT_LIST_PARAMETERS: dict[str, Any] = { - "role_assignment_effective": { + "role_assignments_effective": { "in": "query", "name": "effective", "description": "Returns the effective assignments, including any assignments gained by virtue of group membership.", @@ -267,7 +267,7 @@ ROLE_ASSIGNMENT_LIST_PARAMETERS: dict[str, Any] = { "allowEmptyValue": True, "x-openstack": {"is-flag": True}, }, - "role_assignment_include_names": { + "role_assignments_include_names": { "in": "query", "name": "include_names", "description": "If set, then the names of any entities returned will be include as well as their IDs. Any value other than 0 (including no value) will be interpreted as true.", @@ -275,7 +275,7 @@ ROLE_ASSIGNMENT_LIST_PARAMETERS: dict[str, Any] = { "allowEmptyValue": True, "x-openstack": {"min-ver": "3.6", "is-flag": True}, }, - "role_assignment_include_subtree": { + "role_assignments_include_subtree": { "in": "query", "name": "include_subtree", "description": "If set, then relevant assignments in the project hierarchy below the project specified in the scope.project_id query parameter are also included in the response. Any value other than 0 (including no value) for include_subtree will be interpreted as true.", diff --git a/codegenerator/openapi/keystone_schemas/service.py b/codegenerator/openapi/keystone_schemas/service.py index fc41518..f30bc05 100644 --- a/codegenerator/openapi/keystone_schemas/service.py +++ b/codegenerator/openapi/keystone_schemas/service.py @@ -52,7 +52,7 @@ SERVICES_SCHEMA: dict[str, Any] = { } SERVICES_LIST_PARAMETERS = { - "service_type": { + "services_type": { "in": "query", "name": "service", "description": "Filters the response by a domain ID.",