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
This commit is contained in:
Artem Goncharov 2024-10-09 08:27:57 +02:00
parent 507f1ee33b
commit ee8925c71c

View File

@ -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}"