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",
]:
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":
path_resource_names = ["domain", "config"]
elif path == "/v3/domains/{domain_id}/config/{group}":

View File

@@ -171,7 +171,10 @@ class MetadataGenerator(BaseGenerator):
operation_key = "create"
elif method == "delete":
operation_key = "delete"
elif path.endswith("/detail"):
elif (
path.endswith("/detail")
and resource_name != "quota_set"
):
if method == "get":
operation_key = "list_detailed"
# elif path.endswith("/default"):
@@ -210,6 +213,19 @@ class MetadataGenerator(BaseGenerator):
and method == "get"
):
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 (
args.service_type == "load-balancer"
and len(path_elements) > 1
@@ -262,6 +278,19 @@ class MetadataGenerator(BaseGenerator):
]
):
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 (
len(
[
@@ -654,7 +683,11 @@ def get_operation_type_by_key(operation_key):
elif operation_key == "patch":
return "set"
elif operation_key == "default":
return "get"
return "show"
elif operation_key == "defaults":
return "show"
elif operation_key == "details":
return "show"
elif operation_key == "download":
return "download"
elif operation_key == "upload":
@@ -866,6 +899,12 @@ def post_process_compute_operation(
"rust-cli"
].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 operation_name == "update":
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] = {
"type": "object",
"description": "Data structure that contains both absolute limits within a deployment.",
"properties": {
"absolute": {
"limits": {
"type": "object",
"description": "Data structure that contains both absolute limits within a deployment.",
"properties": {
"maxServerGroupMembers": {
"type": "integer",
"description": "The number of allowed members for each server group.",
},
"maxServerGroups": {
"type": "integer",
"description": "The number of allowed server groups for each tenant.",
},
"maxServerMetamaxServerMeta": {
"type": "integer",
"description": "The number of allowed metadata items for each server.",
},
"maxTotalCores": {
"type": "integer",
"description": "The number of allowed server cores for each tenant.",
},
"maxTotalInstances": {
"type": "integer",
"description": "The number of allowed servers for each tenant.",
},
"maxTotalKeypairs": {
"type": "integer",
"description": "The number of allowed key pairs for each user.",
},
"maxTotalRAMSize": {
"type": "integer",
"description": "The amount of allowed server RAM, in MiB, for each tenant.",
},
"totalCoresUsed": {
"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.",
},
"totalInstancesUsed": {
"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.",
},
"totalRAMUsed": {
"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.",
},
"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.",
"absolute": {
"type": "object",
"description": "Name/value pairs that set quota limits within a deployment and Name/value pairs of resource usage.",
"properties": {
"maxServerGroupMembers": {
"type": "integer",
"description": "The number of allowed members for each server group.",
},
"maxServerGroups": {
"type": "integer",
"description": "The number of allowed server groups for each tenant.",
},
"maxServerMetamaxServerMeta": {
"type": "integer",
"description": "The number of allowed metadata items for each server.",
},
"maxTotalCores": {
"type": "integer",
"description": "The number of allowed server cores for each tenant.",
},
"maxTotalInstances": {
"type": "integer",
"description": "The number of allowed servers for each tenant.",
},
"maxTotalKeypairs": {
"type": "integer",
"description": "The number of allowed key pairs for each user.",
},
"maxTotalRAMSize": {
"type": "integer",
"description": "The amount of allowed server RAM, in MiB, for each tenant.",
},
"totalCoresUsed": {
"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.",
},
"totalInstancesUsed": {
"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.",
},
"totalRAMUsed": {
"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.",
},
"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
api_version: v2
operations:
get:
list:
operation_id: limits:get
operation_type: get
operation_type: list
targets:
rust-sdk:
module_name: get
module_name: list
response_key: limits
rust-cli:
module_name: get
sdk_mod_name: get
cli_full_command: limit get
module_name: list
sdk_mod_name: list
operation_type: show
response_key: limits
cli_full_command: limit list
compute.aggregate:
spec_file: wrk/openapi_specs/compute/v2.yaml
api_version: v2
@@ -738,30 +741,26 @@ resources:
module_name: delete
sdk_mod_name: delete
cli_full_command: quota-set delete
list_detailed:
details:
operation_id: os-quota-sets/id/detail:get
operation_type: list
operation_type: show
targets:
rust-sdk:
module_name: list_detailed
module_name: details
rust-cli:
module_name: list
sdk_mod_name: list_detailed
cli_full_command: quota-set list
compute.quota_set/default:
spec_file: wrk/openapi_specs/compute/v2.yaml
api_version: v2
operations:
get:
module_name: details
sdk_mod_name: details
cli_full_command: quota-set details
defaults:
operation_id: os-quota-sets/id/defaults:get
operation_type: get
operation_type: show
targets:
rust-sdk:
module_name: get
module_name: defaults
rust-cli:
module_name: get
sdk_mod_name: get
cli_full_command: quota-set default get
module_name: defaults
sdk_mod_name: defaults
cli_full_command: quota-set defaults
compute.server_external_event:
spec_file: wrk/openapi_specs/compute/v2.yaml
api_version: v2

View File

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