Add placement RP allocation and traits schemas
Change-Id: Ifd95748430564cc1bbfff4874e77cb1ed5b6a104
This commit is contained in:
@@ -76,6 +76,44 @@ ALLOCATION_POST_REQUEST_SCHEMA: dict[str, Any] = {
|
||||
"x-openstack": {"discriminator": "microversion"},
|
||||
}
|
||||
|
||||
ALLOCATION_RP_RESPONSE_SCHEMA: dict[str, Any] = {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"allocations": {
|
||||
"type": "object",
|
||||
"minProperties": 0,
|
||||
"patternProperties": {
|
||||
"^[0-9a-fA-F-]{36}$": {
|
||||
"type": "object",
|
||||
"description": "A dictionary of allocation records keyed by consumer uuid.",
|
||||
"properties": {
|
||||
"resources": {
|
||||
"type": "object",
|
||||
"description": "A dictionary of resource records keyed by resource class name.",
|
||||
"minProperties": 1,
|
||||
"patternProperties": {
|
||||
"^[A-Z0-9_]+$": {
|
||||
"type": "integer",
|
||||
"minimum": 1,
|
||||
}
|
||||
},
|
||||
"additionalProperties": False,
|
||||
},
|
||||
"required": ["resources"],
|
||||
"additionalProperties": False,
|
||||
},
|
||||
"additionalProperties": False,
|
||||
}
|
||||
},
|
||||
},
|
||||
"resource_provider_generation": {
|
||||
"type": "integer",
|
||||
"description": "A consistent view marker that assists with the management of concurrent resource provider updates.",
|
||||
},
|
||||
},
|
||||
"required": ["allocations", "resource_provider_generation"],
|
||||
}
|
||||
|
||||
|
||||
def _get_schema_ref(
|
||||
openapi_spec, name, description=None, schema_def=None, action_name=None
|
||||
@@ -99,6 +137,14 @@ def _get_schema_ref(
|
||||
name, TypeSchema(**ALLOCATION_UPDATE_REQUEST_SCHEMA)
|
||||
)
|
||||
ref = f"#/components/schemas/{name}"
|
||||
elif (
|
||||
name
|
||||
== "Resource_ProvidersAllocationsList_For_Resource_ProviderResponse"
|
||||
):
|
||||
openapi_spec.components.schemas.setdefault(
|
||||
name, TypeSchema(**ALLOCATION_RP_RESPONSE_SCHEMA)
|
||||
)
|
||||
ref = f"#/components/schemas/{name}"
|
||||
elif name == "AllocationSet_Allocations_For_ConsumerResponse":
|
||||
return (None, None, True)
|
||||
|
||||
|
||||
@@ -46,6 +46,23 @@ TRAIT_LIST_PARAMETERS: dict[str, Any] = {
|
||||
},
|
||||
}
|
||||
|
||||
RP_TRAITS_SCHEMA: dict[str, Any] = {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"traits": {
|
||||
"type": "array",
|
||||
"items": {"type": "string", "minLength": 1, "maxLength": 255},
|
||||
"description": "A list of resource_class objects.",
|
||||
},
|
||||
"resource_provider_generation": {
|
||||
"type": "integer",
|
||||
"description": "A consistent view marker that assists with the management of concurrent resource provider updates.",
|
||||
},
|
||||
},
|
||||
"required": ["traits", "resource_provider_generation"],
|
||||
"additionalProperties": False,
|
||||
}
|
||||
|
||||
|
||||
def _post_process_operation_hook(
|
||||
openapi_spec, operation_spec, path: str | None = None
|
||||
@@ -82,6 +99,15 @@ def _get_schema_ref(
|
||||
]:
|
||||
# Traits have no bodies
|
||||
return (None, None, True)
|
||||
elif name in [
|
||||
"Resource_ProvidersTraitsList_Traits_For_Resource_ProviderResponse",
|
||||
"Resource_ProvidersTraitsUpdate_Traits_For_Resource_ProviderRequest",
|
||||
"Resource_ProvidersTraitsUpdate_Traits_For_Resource_ProviderResponse",
|
||||
]:
|
||||
openapi_spec.components.schemas.setdefault(
|
||||
name, TypeSchema(**TRAITS_SCHEMA)
|
||||
)
|
||||
ref = f"#/components/schemas/{name}"
|
||||
|
||||
else:
|
||||
return (None, None, False)
|
||||
|
||||
Reference in New Issue
Block a user