Fix network.quota-set and compute.limits schemas

Change-Id: Icf413ab5b3c6fa2ea44e20c0598fa6fa834052e4
This commit is contained in:
Artem Goncharov
2024-08-13 13:34:56 +02:00
parent 7931cdee83
commit 3ff379b595
5 changed files with 139 additions and 95 deletions

View File

@@ -505,6 +505,14 @@ def get_resource_names_from_url(path: str):
"delete_key", "delete_key",
]: ]:
path_resource_names = ["qos_spec"] path_resource_names = ["qos_spec"]
if path_resource_names == ["quota", "default"]:
path_resource_names = ["quota"]
if path_resource_names == ["quota", "details"]:
path_resource_names = ["quota"]
if path_resource_names == ["quota_set", "default"]:
path_resource_names = ["quota_set"]
if path_resource_names == ["quota_set", "detail"]:
path_resource_names = ["quota_set"]
if path == "/v3/domains/{domain_id}/config": if path == "/v3/domains/{domain_id}/config":
path_resource_names = ["domain", "config"] path_resource_names = ["domain", "config"]
elif path == "/v3/domains/{domain_id}/config/{group}": elif path == "/v3/domains/{domain_id}/config/{group}":

View File

@@ -171,7 +171,10 @@ class MetadataGenerator(BaseGenerator):
operation_key = "create" operation_key = "create"
elif method == "delete": elif method == "delete":
operation_key = "delete" operation_key = "delete"
elif path.endswith("/detail"): elif (
path.endswith("/detail")
and resource_name != "quota_set"
):
if method == "get": if method == "get":
operation_key = "list_detailed" operation_key = "list_detailed"
# elif path.endswith("/default"): # elif path.endswith("/default"):
@@ -210,6 +213,19 @@ class MetadataGenerator(BaseGenerator):
and method == "get" and method == "get"
): ):
operation_key = "list" operation_key = "list"
elif (
args.service_type == "compute"
and resource_name == "quota_set"
and path.endswith("defaults")
):
operation_key = "defaults"
elif (
args.service_type == "compute"
and resource_name == "quota_set"
and path.endswith("detail")
):
# normalize "details" name
operation_key = "details"
elif ( elif (
args.service_type == "load-balancer" args.service_type == "load-balancer"
and len(path_elements) > 1 and len(path_elements) > 1
@@ -262,6 +278,19 @@ class MetadataGenerator(BaseGenerator):
] ]
): ):
operation_key = path_elements[-1] operation_key = path_elements[-1]
elif (
args.service_type == "network"
and "quota" in path
and path.endswith("/default")
):
# normalize "defaults" name
operation_key = "defaults"
elif (
args.service_type == "network"
and "quota" in path
and path.endswith("/details")
):
operation_key = "details"
elif ( elif (
len( len(
[ [
@@ -654,7 +683,11 @@ def get_operation_type_by_key(operation_key):
elif operation_key == "patch": elif operation_key == "patch":
return "set" return "set"
elif operation_key == "default": elif operation_key == "default":
return "get" return "show"
elif operation_key == "defaults":
return "show"
elif operation_key == "details":
return "show"
elif operation_key == "download": elif operation_key == "download":
return "download" return "download"
elif operation_key == "upload": elif operation_key == "upload":
@@ -866,6 +899,12 @@ def post_process_compute_operation(
"rust-cli" "rust-cli"
].cli_full_command.replace("remove-tenant-access", "access remove") ].cli_full_command.replace("remove-tenant-access", "access remove")
if resource_name == "limit":
# Limits API return object and not a list
operation.targets["rust-cli"].operation_type = "show"
operation.targets["rust-cli"].response_key = "limits"
operation.targets["rust-sdk"].response_key = "limits"
if "/tag" in resource_name: if "/tag" in resource_name:
if operation_name == "update": if operation_name == "update":
operation.targets["rust-cli"].cli_full_command = operation.targets[ operation.targets["rust-cli"].cli_full_command = operation.targets[

View File

@@ -217,58 +217,64 @@ FLAVOR_ACCESSES_SCHEMA: dict[str, Any] = {
LIMITS_SCHEMA: dict[str, Any] = { LIMITS_SCHEMA: dict[str, Any] = {
"type": "object", "type": "object",
"description": "Data structure that contains both absolute limits within a deployment.",
"properties": { "properties": {
"absolute": { "limits": {
"type": "object", "type": "object",
"description": "Data structure that contains both absolute limits within a deployment.",
"properties": { "properties": {
"maxServerGroupMembers": { "absolute": {
"type": "integer", "type": "object",
"description": "The number of allowed members for each server group.", "description": "Name/value pairs that set quota limits within a deployment and Name/value pairs of resource usage.",
}, "properties": {
"maxServerGroups": { "maxServerGroupMembers": {
"type": "integer", "type": "integer",
"description": "The number of allowed server groups for each tenant.", "description": "The number of allowed members for each server group.",
}, },
"maxServerMetamaxServerMeta": { "maxServerGroups": {
"type": "integer", "type": "integer",
"description": "The number of allowed metadata items for each server.", "description": "The number of allowed server groups for each tenant.",
}, },
"maxTotalCores": { "maxServerMetamaxServerMeta": {
"type": "integer", "type": "integer",
"description": "The number of allowed server cores for each tenant.", "description": "The number of allowed metadata items for each server.",
}, },
"maxTotalInstances": { "maxTotalCores": {
"type": "integer", "type": "integer",
"description": "The number of allowed servers for each tenant.", "description": "The number of allowed server cores for each tenant.",
}, },
"maxTotalKeypairs": { "maxTotalInstances": {
"type": "integer", "type": "integer",
"description": "The number of allowed key pairs for each user.", "description": "The number of allowed servers for each tenant.",
}, },
"maxTotalRAMSize": { "maxTotalKeypairs": {
"type": "integer", "type": "integer",
"description": "The amount of allowed server RAM, in MiB, for each tenant.", "description": "The number of allowed key pairs for each user.",
}, },
"totalCoresUsed": { "maxTotalRAMSize": {
"type": "integer", "type": "integer",
"description": "The number of used server cores in each tenant. If reserved query parameter is specified and it is not 0, the number of reserved server cores are also included.", "description": "The amount of allowed server RAM, in MiB, for each tenant.",
}, },
"totalInstancesUsed": { "totalCoresUsed": {
"type": "integer", "type": "integer",
"description": "The number of servers in each tenant. If reserved query parameter is specified and it is not 0, the number of reserved servers are also included.", "description": "The number of used server cores in each tenant. If reserved query parameter is specified and it is not 0, the number of reserved server cores are also included.",
}, },
"totalRAMUsed": { "totalInstancesUsed": {
"type": "integer", "type": "integer",
"description": "The amount of used server RAM in each tenant. If reserved query parameter is specified and it is not 0, the amount of reserved server RAM is also included.", "description": "The number of servers in each tenant. If reserved query parameter is specified and it is not 0, the number of reserved servers are also included.",
}, },
"totalServerGroupsUsed": { "totalRAMUsed": {
"type": "integer", "type": "integer",
"description": "The number of used server groups in each tenant. If reserved query parameter is specified and it is not 0, the number of reserved server groups are also included.", "description": "The amount of used server RAM in each tenant. If reserved query parameter is specified and it is not 0, the amount of reserved server RAM is also included.",
},
"totalServerGroupsUsed": {
"type": "integer",
"description": "The number of used server groups in each tenant. If reserved query parameter is specified and it is not 0, the number of reserved server groups are also included.",
},
},
"additionalProperties": {"type": "integer"},
}, },
}, },
"additionalProperties": {"type": "integer"}, }
},
}, },
} }

View File

@@ -219,16 +219,19 @@ resources:
spec_file: wrk/openapi_specs/compute/v2.yaml spec_file: wrk/openapi_specs/compute/v2.yaml
api_version: v2 api_version: v2
operations: operations:
get: list:
operation_id: limits:get operation_id: limits:get
operation_type: get operation_type: list
targets: targets:
rust-sdk: rust-sdk:
module_name: get module_name: list
response_key: limits
rust-cli: rust-cli:
module_name: get module_name: list
sdk_mod_name: get sdk_mod_name: list
cli_full_command: limit get operation_type: show
response_key: limits
cli_full_command: limit list
compute.aggregate: compute.aggregate:
spec_file: wrk/openapi_specs/compute/v2.yaml spec_file: wrk/openapi_specs/compute/v2.yaml
api_version: v2 api_version: v2
@@ -738,30 +741,26 @@ resources:
module_name: delete module_name: delete
sdk_mod_name: delete sdk_mod_name: delete
cli_full_command: quota-set delete cli_full_command: quota-set delete
list_detailed: details:
operation_id: os-quota-sets/id/detail:get operation_id: os-quota-sets/id/detail:get
operation_type: list operation_type: show
targets: targets:
rust-sdk: rust-sdk:
module_name: list_detailed module_name: details
rust-cli: rust-cli:
module_name: list module_name: details
sdk_mod_name: list_detailed sdk_mod_name: details
cli_full_command: quota-set list cli_full_command: quota-set details
compute.quota_set/default: defaults:
spec_file: wrk/openapi_specs/compute/v2.yaml
api_version: v2
operations:
get:
operation_id: os-quota-sets/id/defaults:get operation_id: os-quota-sets/id/defaults:get
operation_type: get operation_type: show
targets: targets:
rust-sdk: rust-sdk:
module_name: get module_name: defaults
rust-cli: rust-cli:
module_name: get module_name: defaults
sdk_mod_name: get sdk_mod_name: defaults
cli_full_command: quota-set default get cli_full_command: quota-set defaults
compute.server_external_event: compute.server_external_event:
spec_file: wrk/openapi_specs/compute/v2.yaml spec_file: wrk/openapi_specs/compute/v2.yaml
api_version: v2 api_version: v2

View File

@@ -2342,6 +2342,16 @@ resources:
module_name: list module_name: list
sdk_mod_name: list sdk_mod_name: list
cli_full_command: quota list cli_full_command: quota list
defaults:
operation_id: quotas/id/default:get
operation_type: show
targets:
rust-sdk:
module_name: defaults
rust-cli:
module_name: defaults
sdk_mod_name: defaults
cli_full_command: quota defaults
show: show:
operation_id: quotas/id:get operation_id: quotas/id:get
operation_type: show operation_type: show
@@ -2372,34 +2382,16 @@ resources:
module_name: delete module_name: delete
sdk_mod_name: delete sdk_mod_name: delete
cli_full_command: quota delete cli_full_command: quota delete
network.quota/default: details:
spec_file: wrk/openapi_specs/network/v2.yaml
api_version: v2
operations:
get:
operation_id: quotas/id/default:get
operation_type: get
targets:
rust-sdk:
module_name: get
rust-cli:
module_name: get
sdk_mod_name: get
cli_full_command: quota default get
network.quota/details:
spec_file: wrk/openapi_specs/network/v2.yaml
api_version: v2
operations:
get:
operation_id: quotas/id/details:get operation_id: quotas/id/details:get
operation_type: get operation_type: show
targets: targets:
rust-sdk: rust-sdk:
module_name: get module_name: details
rust-cli: rust-cli:
module_name: get module_name: details
sdk_mod_name: get sdk_mod_name: details
cli_full_command: quota details get cli_full_command: quota details
network.rbac_policy: network.rbac_policy:
spec_file: wrk/openapi_specs/network/v2.yaml spec_file: wrk/openapi_specs/network/v2.yaml
api_version: v2 api_version: v2