From df065d731e4a825295bc1edfb7bd21ea2ec856c1 Mon Sep 17 00:00:00 2001 From: Artem Goncharov Date: Thu, 17 Jul 2025 16:17:58 +0200 Subject: [PATCH] Add header query params to dns list operations All dns list/get operations support `x-auth-all-projects` and `x-auth-sudo-project-id` headers, which can be used by admins. Change-Id: Ic5a7cd6c0312a6ac28d895c290924621943e598a Signed-off-by: Artem Goncharov --- codegenerator/openapi/designate_schemas.py | 70 +++++++++++++--------- 1 file changed, 43 insertions(+), 27 deletions(-) diff --git a/codegenerator/openapi/designate_schemas.py b/codegenerator/openapi/designate_schemas.py index 097ceca..4776ab6 100644 --- a/codegenerator/openapi/designate_schemas.py +++ b/codegenerator/openapi/designate_schemas.py @@ -10,7 +10,6 @@ # License for the specific language governing permissions and limitations # under the License. # -import copy from typing import Any @@ -401,10 +400,6 @@ NAMESERVER_SCHEMA: dict[str, Any] = { "readOnly": True, "properties": {"self": {"type": "string", "format": "uri"}}, }, - "links": { - "type": "object", - "properties": {"self": {"type": "string", "format": "uri"}}, - }, }, "additionalProperties": False, } @@ -541,15 +536,12 @@ RECORDSETS_SCHEMA: dict[str, Any] = { "readOnly": True, "properties": {"self": {"type": "string", "format": "uri"}}, }, - "links": { - "type": "object", - "properties": {"self": {"type": "string", "format": "uri"}}, - }, }, "additionalProperties": False, } -ZONE_RECORDSETS_LIST_PARAMETERS: dict[str, Any] = { + +COMMON_SUDO_LIST_PARAMETERS: dict[str, Any] = { "x-auth-all-projects": { "in": "header", "name": "x-auth-all-projects", @@ -562,6 +554,10 @@ ZONE_RECORDSETS_LIST_PARAMETERS: dict[str, Any] = { "description": "This allows a user to impersonate another project", "schema": {"type": "string"}, }, +} + + +ZONE_RECORDSETS_LIST_PARAMETERS: dict[str, Any] = { "limit": { "in": "query", "name": "limit", @@ -706,20 +702,6 @@ PTR_RECORDS_SCHEMA: dict[str, Any] = { "additionalProperties": False, } -PTR_RECORDS_LIST_PARAMETERS: dict[str, Any] = { - "x-auth-all-projects": { - "in": "header", - "name": "x-auth-all-projects", - "description": "If enabled this will show results from all projects in Designate", - "schema": {"type": "bool"}, - }, - "x-auth-sudo-project-id": { - "in": "header", - "name": "x-auth-sudo-project-id", - "description": "This allows a user to impersonate another project", - "schema": {"type": "string"}, - }, -} LIMITS_SCHEMA: dict[str, Any] = { "type": "object", @@ -765,7 +747,7 @@ QUOTAS_SCHEMA: dict[str, Any] = { "api_export_size": {"type": "integer"}, "recordset_records": {"type": "integer"}, "zone_records": {"type": "integer"}, - "zone_recorsets": {"type": "integer"}, + "zone_recordsets": {"type": "integer"}, "zones": {"type": "integer"}, }, } @@ -808,8 +790,42 @@ def _post_process_operation_hook( ref = f"#/components/parameters/{key}" if ref not in [x.ref for x in operation_spec.parameters]: operation_spec.parameters.append(ParameterSchema(ref=ref)) - elif operationId == "reverse/floatingips:get": - for key, val in PTR_RECORDS_LIST_PARAMETERS.items(): + if operationId in [ + "limits:get", + "reverse/floatingips:get", + "reverse/floatingips/fip_key:get", + "tlds/tld_id:get", + "tlds:get", + "zones/zone_id:get", + "zones:get", + "zones/zone_id/recordsets/recordset_id:get", + "zones/zone_id/recordsets:get", + "zones/tasks/transfer_accepts:get", + "zones/tasks/transfer_accepts/transfer_accept_id:get", + "zones/tasks/transfer_requests/zone_transfer_request_id:get", + "zones/tasks/transfer_requests:get", + "zones/tasks/imports:get", + "zones/tasks/imports/import_id:get", + "zones/tasks/exports:get", + "zones/tasks/exports/export_id:get", + "zones/tasks/exports/export_id/export:get", + "zones/zone_id/nameservers:get", + "zones/zone_id/shares/zone_share_id:get", + "zones/zone_id/shares:get", + "blacklists/blacklist_id:get", + "blacklists:get", + "pools/pool_id:get", + "pools:get", + "service_statuses:get", + "service_statuses/service_id:get", + "tsigkeys/tsigkey_id:get", + "tsigkeys:get", + "recordsets:get", + "recordsets/recordset_id:get", + "quotas/project_id:get", + "quotas:get", + ]: + for key, val in COMMON_SUDO_LIST_PARAMETERS.items(): openapi_spec.components.parameters.setdefault( key, ParameterSchema(**val) )