From ee8925c71c6cfce4ebd341a47d0f9ea1a27fe18f Mon Sep 17 00:00:00 2001 From: Artem Goncharov Date: Wed, 9 Oct 2024 08:27:57 +0200 Subject: [PATCH] Fix dns schema mapping names some schemas were accidentially plural causing mismatch. In addition to that recordset was missing records attribute (missed in the current api-ref) and zone/recordset supports only limited set of updatable attributes. Change-Id: I51b3a93caa1fc8804e40493636bde537a58950a3 --- codegenerator/openapi/designate_schemas.py | 64 ++++++++++++++++++++-- 1 file changed, 59 insertions(+), 5 deletions(-) diff --git a/codegenerator/openapi/designate_schemas.py b/codegenerator/openapi/designate_schemas.py index 9fcc072..d5c6523 100644 --- a/codegenerator/openapi/designate_schemas.py +++ b/codegenerator/openapi/designate_schemas.py @@ -168,6 +168,27 @@ ZONE_SCHEMA: dict[str, Any] = { "additionalProperties": False, } +ZONE_UPDATE_REQUEST_SCHEMA: dict[str, Any] = { + "type": "object", + "description": "DNS Zone", + "properties": { + "email": { + "type": "string", + "format": "uuid", + "description": "e-mail for the zone. Used in SOA records for the zone", + }, + "ttl": { + "type": "integer", + "description": "TTL (Time to Live) for the zone.", + }, + "description": { + "type": "string", + "description": "Description for this zone", + }, + }, + "additionalProperties": False, +} + ZONES_SCHEMA: dict[str, Any] = { "type": "object", @@ -420,7 +441,6 @@ RECORDSET_SCHEMA: dict[str, Any] = { }, "name": { "type": "string", - "format": "uuid", "description": "DNS Name for the recordset", }, "ttl": { @@ -459,6 +479,11 @@ RECORDSET_SCHEMA: dict[str, Any] = { "enum": RECORDSET_TYPES, "description": "They RRTYPE of the recordset.", }, + "records": { + "type": "array", + "items": {"type": "string"}, + "description": "A list of data for this recordset. Each item will be a separate record in Designate These items should conform to the DNS spec for the record type - e.g. A records must be IPv4 addresses, CNAME records must be a hostname.", + }, "version": { "type": "integer", "readOnly": True, @@ -485,6 +510,27 @@ RECORDSET_SCHEMA: dict[str, Any] = { "additionalProperties": False, } +RECORDSET_UPDATE_REQUEST_SCHEMA: dict[str, Any] = { + "type": "object", + "description": "Zone Record object", + "properties": { + "ttl": { + "type": "integer", + "description": "TTL (Time to Live) for the recordset.", + }, + "description": { + "type": "string", + "description": "Description for this recordset", + }, + "records": { + "type": "array", + "items": {"type": "string"}, + "description": "A list of data for this recordset. Each item will be a separate record in Designate These items should conform to the DNS spec for the record type - e.g. A records must be IPv4 addresses, CNAME records must be a hostname.", + }, + }, + "additionalProperties": False, +} + RECORDSETS_SCHEMA: dict[str, Any] = { "type": "object", @@ -781,11 +827,15 @@ def _get_schema_ref( "ZoneShowResponse", "ZonesCreateRequest", "ZonesCreateResponse", - "ZonesUpdateRequest", - "ZonesUpdateResponse", + "ZoneUpdateResponse", ]: openapi_spec.components.schemas[name] = TypeSchema(**ZONE_SCHEMA) ref = f"#/components/schemas/{name}" + if name in ["ZoneUpdateRequest"]: + openapi_spec.components.schemas[name] = TypeSchema( + **ZONE_UPDATE_REQUEST_SCHEMA + ) + ref = f"#/components/schemas/{name}" elif name in ["ZonesListResponse"]: openapi_spec.components.schemas[name] = TypeSchema(**ZONES_SCHEMA) ref = f"#/components/schemas/{name}" @@ -793,11 +843,15 @@ def _get_schema_ref( "ZonesRecordsetShowResponse", "ZonesRecordsetsCreateRequest", "ZonesRecordsetsCreateResponse", - "ZonesRecordsetsUpdateRequest", - "ZonesRecordsetsUpdateResponse", + "ZonesRecordsetUpdateResponse", ]: openapi_spec.components.schemas[name] = TypeSchema(**RECORDSET_SCHEMA) ref = f"#/components/schemas/{name}" + elif name in ["ZonesRecordsetUpdateRequest"]: + openapi_spec.components.schemas[name] = TypeSchema( + **RECORDSET_UPDATE_REQUEST_SCHEMA + ) + ref = f"#/components/schemas/{name}" elif name in ["ZonesRecordsetsListResponse", "RecordsetsListResponse"]: openapi_spec.components.schemas[name] = TypeSchema(**RECORDSETS_SCHEMA) ref = f"#/components/schemas/{name}"