Merge "Workaround BS quota api path issues"
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
# under the License.
|
||||
#
|
||||
from multiprocessing import Process
|
||||
from itertools import chain
|
||||
from pathlib import Path
|
||||
|
||||
from ruamel.yaml.scalarstring import LiteralScalarString
|
||||
@@ -177,6 +178,8 @@ class CinderV3Generator(OpenStackServerSourceBase):
|
||||
|
||||
self._process_route(route, openapi_spec, ver_prefix="/v3")
|
||||
|
||||
self._post_process(openapi_spec)
|
||||
|
||||
self._sanitize_param_ver_info(openapi_spec, self.min_api_version)
|
||||
|
||||
if args.api_ref_src:
|
||||
@@ -208,6 +211,120 @@ class CinderV3Generator(OpenStackServerSourceBase):
|
||||
if path and ("/consistencygroups" in path or "/cgsnapshots" in path):
|
||||
operation_spec.deprecated = True
|
||||
|
||||
def _post_process(self, openapi_spec):
|
||||
"""Repair urls and url parametes"""
|
||||
for path in [
|
||||
"/v3/{project_id}/os-quota-sets/{id}",
|
||||
"/v3/{project_id}/os-quota-sets/{id}/defaults",
|
||||
]:
|
||||
new_path = path.replace("{project_id}", "{admin_project_id}")
|
||||
openapi_spec.paths[new_path] = openapi_spec.paths.pop(path)
|
||||
for par in [
|
||||
openapi_spec.components.parameters[x.ref.split("/")[-1]]
|
||||
for x in openapi_spec.paths[new_path].parameters
|
||||
if x.ref
|
||||
]:
|
||||
if par.location == "path" and par.name == "project_id":
|
||||
par.name = "admin_project_id"
|
||||
par.description = "The admin project id attribute"
|
||||
for path in [
|
||||
"/v3/{admin_project_id}/os-quota-sets/{id}",
|
||||
"/v3/{admin_project_id}/os-quota-sets/{id}/defaults",
|
||||
"/v3/os-quota-sets/{id}",
|
||||
"/v3/os-quota-sets/{id}/defaults",
|
||||
]:
|
||||
new_path = path.replace("{id}", "{project_id}")
|
||||
openapi_spec.paths[new_path] = openapi_spec.paths.pop(path)
|
||||
for par in [
|
||||
openapi_spec.components.parameters[x.ref.split("/")[-1]]
|
||||
for x in openapi_spec.paths[new_path].parameters
|
||||
if x.ref
|
||||
]:
|
||||
if par.location == "path" and par.name == "id":
|
||||
par.name = "project_id"
|
||||
par.description = "The quota-set project_id attribute"
|
||||
if not par.openstack:
|
||||
par.openstack = {}
|
||||
par.openstack["resource_link"] = "identity/v3/project.id"
|
||||
for path in [
|
||||
"/v3/{admin_project_id}/os-quota-sets/{project_id}",
|
||||
"/v3/os-quota-sets/{project_id}",
|
||||
]:
|
||||
path_spec = openapi_spec.paths[path]
|
||||
path_spec.get.description = (
|
||||
"""Show quota for a particular tenant"""
|
||||
)
|
||||
path_spec.get.summary = """Show quota for a particular tenant"""
|
||||
path_spec.get.parameters.append(
|
||||
ParameterSchema(
|
||||
ref="#/components/parameters/os_quota_sets_usage"
|
||||
)
|
||||
)
|
||||
path_spec.put.description = (
|
||||
"""Update quota for a particular tenant"""
|
||||
)
|
||||
path_spec.put.summary = """Update quota for a particular tenant"""
|
||||
path_spec.delete.description = (
|
||||
"""Delete quota for a particular tenant"""
|
||||
)
|
||||
path_spec.delete.summary = (
|
||||
"""Delete quota for a particular tenant"""
|
||||
)
|
||||
openapi_spec.components.parameters["os_quota_sets_usage"] = (
|
||||
ParameterSchema(
|
||||
location="query",
|
||||
name="usage",
|
||||
type_schema=TypeSchema(type="boolean"),
|
||||
description="Show project’s quota usage information. Default is false.",
|
||||
)
|
||||
)
|
||||
for path in [
|
||||
"/v3/{project_id}/os-quota-class-sets/{id}",
|
||||
"/v3/os-quota-class-sets/{id}",
|
||||
]:
|
||||
new_path = path.replace(
|
||||
"{project_id}", "{admin_project_id}"
|
||||
).replace("{id}", "{name}")
|
||||
openapi_spec.paths[new_path] = openapi_spec.paths.pop(path)
|
||||
for par in [
|
||||
openapi_spec.components.parameters[x.ref.split("/")[-1]]
|
||||
for x in openapi_spec.paths[new_path].parameters
|
||||
if x.ref
|
||||
]:
|
||||
if par.location == "path" and par.name == "id":
|
||||
par.name = "name"
|
||||
elif par.location == "path" and par.name == "project_id":
|
||||
par.name = "admin_project_id"
|
||||
path_spec = openapi_spec.paths[new_path]
|
||||
path_spec.get.description = "Show quota classes for a project"
|
||||
path_spec.get.summary = "Show quota classes for a project"
|
||||
path_spec.put.description = "Update quota classes for a project"
|
||||
path_spec.put.summary = "Update quota classes for a project"
|
||||
for path in ["/v3/{project_id}/os-hosts", "/v3/os-hosts"]:
|
||||
new_path = path.replace("{project_id}", "{admin_project_id}")
|
||||
openapi_spec.paths[new_path] = openapi_spec.paths.pop(path)
|
||||
path_spec = openapi_spec.paths[new_path]
|
||||
path_spec.get.description = "List all hosts for a project"
|
||||
path_spec.get.summary = "List all hosts for a project"
|
||||
for path in ["/v3/{project_id}/os-hosts/{id}", "/v3/os-hosts/{id}"]:
|
||||
new_path = path.replace(
|
||||
"{project_id}", "{admin_project_id}"
|
||||
).replace("{id}", "{host_name}")
|
||||
openapi_spec.paths[new_path] = openapi_spec.paths.pop(path)
|
||||
|
||||
for par in [
|
||||
openapi_spec.components.parameters[x.ref.split("/")[-1]]
|
||||
for x in openapi_spec.paths[new_path].parameters
|
||||
if x.ref
|
||||
]:
|
||||
if par.location == "path" and par.name == "id":
|
||||
par.name = "host_name"
|
||||
elif par.location == "path" and par.name == "project_id":
|
||||
par.name = "admin_project_id"
|
||||
path_spec = openapi_spec.paths[new_path]
|
||||
path_spec.get.description = "Show Host Details for a project"
|
||||
path_spec.get.summary = "Show quota classes for a project"
|
||||
|
||||
def _get_schema_ref(
|
||||
self,
|
||||
openapi_spec,
|
||||
|
||||
Reference in New Issue
Block a user