From e575c6fe7de430f2f34847263bdef88789f50ce5 Mon Sep 17 00:00:00 2001
From: Artem Goncharov <artem.goncharov@gmail.com>
Date: Wed, 2 Oct 2024 18:15:59 +0200
Subject: [PATCH] Start building DNS bindings

Change-Id: I62888041ce2cf8d2c4dd27beeda6d04f94f1cbd6
---
 codegenerator/common/__init__.py           |  4 ++++
 codegenerator/openapi/base.py              |  4 +++-
 codegenerator/openapi/designate.py         |  6 +++++
 codegenerator/openapi/designate_schemas.py |  1 +
 metadata/dns_metadata.yaml                 | 28 ++--------------------
 zuul.d/rust.yaml                           |  5 ++++
 6 files changed, 21 insertions(+), 27 deletions(-)

diff --git a/codegenerator/common/__init__.py b/codegenerator/common/__init__.py
index 1287919..67a24c6 100644
--- a/codegenerator/common/__init__.py
+++ b/codegenerator/common/__init__.py
@@ -452,6 +452,8 @@ def get_resource_names_from_url(path: str):
                 part = el[0:-3] + "y"
             elif el[-4:] == "sses":
                 part = el[0:-2]
+            elif el.endswith("statuses"):
+                part = el[0:-2]
             elif (
                 el[-1] == "s"
                 and el[-3:] != "dns"
@@ -571,6 +573,8 @@ def get_rust_service_type_from_str(xtype: str):
             return "BlockStorage"
         case "compute":
             return "Compute"
+        case "dns":
+            return "Dns"
         case "identity":
             return "Identity"
         case "image":
diff --git a/codegenerator/openapi/base.py b/codegenerator/openapi/base.py
index b205734..e74958a 100644
--- a/codegenerator/openapi/base.py
+++ b/codegenerator/openapi/base.py
@@ -263,7 +263,9 @@ class OpenStackServerSourceBase:
             rn = path_resource_names[-1]
             if rn.endswith("ies"):
                 rn = rn.replace("ies", "y")
-            if rn.endswith("sses"):
+            elif rn.endswith("sses"):
+                rn = rn[:-2]
+            elif rn.endswith("statuses"):
                 rn = rn[:-2]
             else:
                 rn = rn.rstrip("s")
diff --git a/codegenerator/openapi/designate.py b/codegenerator/openapi/designate.py
index 5d44d30..20659b2 100644
--- a/codegenerator/openapi/designate.py
+++ b/codegenerator/openapi/designate.py
@@ -237,6 +237,12 @@ class DesignateGenerator(OpenStackServerSourceBase):
             ):
                 # returns 405 in Designate anyway
                 continue
+            if route.routepath in [
+                "/v2/service_status",
+                "/v2/service_status/{service_id}",
+            ]:
+                # backwards compatibility for mistake
+                continue
             self._process_route(route, openapi_spec, framework="pecan")
 
         if args.api_ref_src:
diff --git a/codegenerator/openapi/designate_schemas.py b/codegenerator/openapi/designate_schemas.py
index 819a385..1a57da8 100644
--- a/codegenerator/openapi/designate_schemas.py
+++ b/codegenerator/openapi/designate_schemas.py
@@ -181,6 +181,7 @@ RECORDSET_SCHEMA: dict[str, Any] = {
         "zone_id": {
             "type": "string",
             "format": "uuid",
+            "readOnly": True,
             "description": "ID for the zone that contains this recordset",
         },
         "zone_name": {
diff --git a/metadata/dns_metadata.yaml b/metadata/dns_metadata.yaml
index d06250c..2fc42b9 100644
--- a/metadata/dns_metadata.yaml
+++ b/metadata/dns_metadata.yaml
@@ -614,37 +614,13 @@ resources:
             module_name: create
             sdk_mod_name: create
             cli_full_command: pool create
-  dns.service_statuse:
+  dns.service_status:
     spec_file: wrk/openapi_specs/dns/v2.1.yaml
     api_version: v2
     operations:
       list:
         operation_id: service_statuses:get
         operation_type: list
-        targets:
-          rust-sdk:
-            module_name: list
-          rust-cli:
-            module_name: list
-            sdk_mod_name: list
-            cli_full_command: service-statuse list
-      show:
-        operation_id: service_statuses/service_id:get
-        operation_type: show
-        targets:
-          rust-sdk:
-            module_name: get
-          rust-cli:
-            module_name: show
-            sdk_mod_name: get
-            cli_full_command: service-statuse show
-  dns.service_status:
-    spec_file: wrk/openapi_specs/dns/v2.1.yaml
-    api_version: v2
-    operations:
-      list:
-        operation_id: service_status:get
-        operation_type: list
         targets:
           rust-sdk:
             module_name: list
@@ -653,7 +629,7 @@ resources:
             sdk_mod_name: list
             cli_full_command: service-status list
       show:
-        operation_id: service_status/service_id:get
+        operation_id: service_statuses/service_id:get
         operation_type: show
         targets:
           rust-sdk:
diff --git a/zuul.d/rust.yaml b/zuul.d/rust.yaml
index ee1ede3..7594ec9 100644
--- a/zuul.d/rust.yaml
+++ b/zuul.d/rust.yaml
@@ -18,6 +18,9 @@
         - service: "compute"
           metadata: "metadata/compute_metadata.yaml"
           targets: ["rust-sdk", "rust-cli"]
+        - service: "dns"
+          metadata: "metadata/dns_metadata.yaml"
+          targets: ["rust-sdk", "rust-cli"]
         - service: "identity"
           metadata: "metadata/identity_metadata.yaml"
           targets: ["rust-sdk", "rust-cli"]
@@ -51,6 +54,8 @@
         soft: true
       - name: codegenerator-openapi-compute-tips-with-api-ref
         soft: true
+      - name: codegenerator-openapi-dns-tips-with-api-ref
+        soft: true
       - name: codegenerator-openapi-identity-tips-with-api-ref
         soft: true
       - name: codegenerator-openapi-image-tips-with-api-ref