From 6dfa4666dc77b798df2d5a6ad61127b3403dcfca Mon Sep 17 00:00:00 2001 From: Artem Goncharov Date: Thu, 27 Feb 2025 18:16:17 +0100 Subject: [PATCH] Add required to compute service responses Change-Id: I582de51d89c3bce431b6aec574d8ef8e3405919d --- codegenerator/openapi/nova_schemas.py | 46 +++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/codegenerator/openapi/nova_schemas.py b/codegenerator/openapi/nova_schemas.py index 3d252f6..e048a82 100644 --- a/codegenerator/openapi/nova_schemas.py +++ b/codegenerator/openapi/nova_schemas.py @@ -173,6 +173,7 @@ VOLUME_SNAPSHOT_SCHEMA: dict[str, Any] = { "description": "The source volume ID.", }, }, + "required": ["id", "volumeId"], } }, } @@ -196,6 +197,7 @@ AZ_SCHEMA: dict[str, Any] = { }, "hosts": {"type": "null", "description": "It is always null."}, }, + "required": ["zoneName", "zoneState"], } AZ_DETAIL_SCHEMA: dict[str, Any] = copy.deepcopy(AZ_SCHEMA) @@ -231,6 +233,7 @@ AZ_LIST_SCHEMA: dict[str, Any] = { "items": copy.deepcopy(AZ_SCHEMA), } }, + "required": ["availabilityZoneInfo"], } AZ_LIST_DETAIL_SCHEMA: dict[str, Any] = { "type": "object", @@ -241,6 +244,7 @@ AZ_LIST_DETAIL_SCHEMA: dict[str, Any] = { "items": copy.deepcopy(AZ_DETAIL_SCHEMA), } }, + "required": ["availabilityZoneInfo"], } CONSOLE_SCHEMA: dict[str, Any] = { @@ -269,6 +273,7 @@ CONSOLE_SCHEMA: dict[str, Any] = { "required": ["instance_uuid", "port"], } }, + "required": ["console"], } REMOTE_CONSOLE_SCHEMA: dict[str, Any] = { @@ -299,8 +304,10 @@ REMOTE_CONSOLE_SCHEMA: dict[str, Any] = { "description": "The URL is used to connect the console.", }, }, + "required": ["protocol", "type", "url"], } }, + "required": ["remote_console"], } HYPERVISOR_SHORT_SCHEMA: dict[str, Any] = { @@ -342,9 +349,11 @@ HYPERVISOR_SHORT_SCHEMA: dict[str, Any] = { "description": "The server name.", }, }, + "required": ["uuid", "name"], }, }, }, + "required": ["id", "hypervisor_hostname", "state", "servers"], } HYPERVISOR_SCHEMA: dict[str, Any] = { @@ -483,6 +492,7 @@ HYPERVISOR_LIST_SCHEMA: dict[str, Any] = { }, "hypervisor_links": LINKS_SCHEMA, }, + "required": ["hypervisors"], } HYPERVISOR_LIST_DETAIL_SCHEMA: dict[str, Any] = { @@ -495,6 +505,7 @@ HYPERVISOR_LIST_DETAIL_SCHEMA: dict[str, Any] = { }, "hypervisor_links": LINKS_SCHEMA, }, + "required": ["hypervisors"], } INSTANCE_USAGE_AUDIT_SCHEMA: dict[str, Any] = { @@ -590,6 +601,7 @@ KEYPAIR_SHORT_SCHEMA: dict[str, Any] = { "x-openstack": {"min-ver": "2.2"}, }, }, + "required": ["name", "type", "fingerprint", "public_key"], } KEYPAIR_LIST_SCHEMA: dict[str, Any] = { @@ -605,6 +617,7 @@ KEYPAIR_LIST_SCHEMA: dict[str, Any] = { }, "keypairs_links": copy.deepcopy(LINKS_SCHEMA), }, + "required": ["keypairs"], } KEYPAIR_SCHEMA: dict[str, Any] = { @@ -637,12 +650,14 @@ KEYPAIR_SCHEMA: dict[str, Any] = { "id": {"type": "integer", "description": "The keypair ID."}, **copy.deepcopy(KEYPAIR_SHORT_SCHEMA["properties"]), }, + "required": ["name", "id", "user_id", "type", "fingerprint", "public_key"], } KEYPAIR_CONTAINER_SCHEMA: dict[str, Any] = { "type": "object", "description": "Keypair object", "properties": {"keypair": KEYPAIR_SCHEMA}, + "required": ["keypair"], } KEYPAIR_CREATED_SCHEMA: dict[str, Any] = copy.deepcopy( @@ -973,8 +988,10 @@ QUOTA_SET_DETAIL_CONTAINER_SCHEMA: dict[str, Any] = { "x-openstack": {"max-ver": "2.35"}, }, }, + "required": ["id"], } }, + "required": ["quota_set"], } # TODO(gtema): class set props are not quota_set props, but for now keep this way QUOTA_CLASS_SET_SCHEMA: dict[str, Any] = { @@ -987,6 +1004,7 @@ QUOTA_CLASS_SET_SCHEMA: dict[str, Any] = { }, **quota_sets.quota_resources, }, + "required": ["id"], } QUOTA_CLASS_SET_CONTAINER_SCHEMA: dict[str, Any] = { @@ -1031,9 +1049,11 @@ EXTERNAL_EVENTS_SCHEMA: dict[str, Any] = { "description": "A string value that identifies the event.", }, }, + "required": ["name", "server_uuid", "status"], }, } }, + "required": ["events"], } SERVER_GROUP_POLICIES = [ @@ -1099,6 +1119,7 @@ SERVER_GROUP_SCHEMA: dict[str, Any] = { "x-openstack": {"min-ver": "2.13"}, }, }, + "required": ["id", "user_id", "name", "policy", "project_id"], } SERVER_GROUP_LIST_SCHEMA: dict[str, Any] = { @@ -1110,10 +1131,12 @@ SERVER_GROUP_LIST_SCHEMA: dict[str, Any] = { "items": SERVER_GROUP_SCHEMA, } }, + "required": ["server_groups"], } SERVER_GROUP_CONTAINER_SCHEMA: dict[str, Any] = { "type": "object", "properties": {"server_group": SERVER_GROUP_SCHEMA}, + "required": ["server_group"], } SERVICE_SCHEMA: dict[str, Any] = { @@ -1158,6 +1181,7 @@ SERVICE_SCHEMA: dict[str, Any] = { "readOnly": True, }, }, + "required": ["zone", "id", "host", "state", "status"], } SERVICE_CONTAINER_SCHEMA: dict[str, Any] = { @@ -1304,6 +1328,7 @@ SERVER_SHORT_SCHEMA: dict[str, Any] = { "description": "Server name.", }, }, + "required": ["id", "name"], } SERVER_ADDRESSES_SCHEMA: dict[str, Any] = { "type": "object", @@ -1628,6 +1653,7 @@ SERVER_SCHEMA: dict[str, Any] = { "description": "The VM state of this server.", }, }, + "required": ["id", "name", "flavor", "image"], } SERVER_CONTAINER_SCHEMA: dict[str, Any] = { @@ -1693,6 +1719,7 @@ SERVER_CREATED_SCHEMA: dict[str, Any] = { }, "links": LINKS_SCHEMA, }, + "required": ["id"], } }, }, @@ -1704,6 +1731,7 @@ SERVER_CREATED_SCHEMA: dict[str, Any] = { "description": "The reservation id for the server. This is an id that can be useful in tracking groups of servers created with multiple create, that will all have the same reservation_id.", } }, + "required": ["reservation_id"], }, ] } @@ -1726,11 +1754,13 @@ SERVER_ACTION_NEW_ADMINPASS_SCHEMA: dict[str, Any] = { "description": "An administrative password to access moved instance. If you set enable_instance_password configuration option to False, the API wouldn’t return the adminPass field in response.", } }, + "required": ["adminPass"], } SERVER_ACTION_GET_CONSOLE_OUTPUT_SCHEMA: dict[str, Any] = { "type": "object", "description": "The console output as a string. Control characters will be escaped to create a valid JSON string.", "properties": {"output": {"type": "string"}}, + "required": ["output"], } SERVER_ACTION_REMOTE_CONSOLE_SCHEMA: dict[str, Any] = { "type": "object", @@ -1749,8 +1779,10 @@ SERVER_ACTION_REMOTE_CONSOLE_SCHEMA: dict[str, Any] = { "description": "The URL used to connect to the console.", }, }, + "required": ["type", "url"], } }, + "required": ["console"], } SERVER_DIAGNOSTICS_SCHEMA: dict[str, Any] = { "type": "object", @@ -1856,12 +1888,14 @@ SERVER_DIAGNOSTICS_SCHEMA: dict[str, Any] = { "x-openstack": {"min-ver": "2.48"}, }, }, + "required": ["id", "name"], } SERVER_METADATA_LIST_SCHEMA: dict[str, Any] = { "type": "object", "description": "Metadata key and value pairs. The maximum size for each metadata key and value pair is 255 bytes.", "properties": {"metadata": parameter_types.metadata}, + "required": ["metadata"], } SERVER_METADATA_ITEM_SCHEMA: dict[str, Any] = { "type": "object", @@ -1917,6 +1951,7 @@ SERVER_INSTANCE_ACTION_SCHEMA: dict[str, Any] = { "x-openstack": {"min-ver": "2.84"}, }, }, + "required": ["event", "start-time"], }, "description": "Events", }, @@ -1948,10 +1983,12 @@ SERVER_INSTANCE_ACTION_SCHEMA: dict[str, Any] = { "x-openstack": {"min-ver": "2.58"}, }, }, + "required": ["action", "events", "request_id", "user_id", "project_id"], } SERVER_INSTANCE_ACTION_CONTAINER_SCHEMA: dict[str, Any] = { "type": "object", "properties": {"instanceAction": SERVER_INSTANCE_ACTION_SCHEMA}, + "required": ["instanceAction"], } SERVER_INSTANCE_ACTION_LIST_SCHEMA: dict[str, Any] = { "type": "object", @@ -1963,6 +2000,7 @@ SERVER_INSTANCE_ACTION_LIST_SCHEMA: dict[str, Any] = { }, "links": LINKS_SCHEMA, }, + "required": ["instanceActions"], } INTERFACE_ATTACHMENT_SCHEMA: dict[str, Any] = { @@ -2008,6 +2046,7 @@ INTERFACE_ATTACHMENT_SCHEMA: dict[str, Any] = { "x-openstack": {"min-ver": "2.70"}, }, }, + "required": ["fixed_ips"], } INTERFACE_ATTACHMENT_CONTAINER_SCHEMA: dict[str, Any] = { "type": "object", @@ -2082,6 +2121,7 @@ SERVER_SECURITY_GROUPS_LIST_SCHEMA: dict[str, Any] = { }, }, }, + "required": ["id", "name"], }, } }, @@ -2134,10 +2174,12 @@ VOLUME_ATTACHMENT_SCHEMA: dict[str, Any] = { "x-openstack": {"min-ver": "2.89"}, }, }, + "reuired": ["id", "serverId", "volumeId", "device"], } VOLUME_ATTACHMENT_CONTAINER_SCHEMA: dict[str, Any] = { "type": "object", "properties": {"volumeAttachment": VOLUME_ATTACHMENT_SCHEMA}, + "required": ["volumeAttachment"], } VOLUME_ATTACHMENT_LIST_SCHEMA: dict[str, Any] = { @@ -2148,6 +2190,7 @@ VOLUME_ATTACHMENT_LIST_SCHEMA: dict[str, Any] = { "items": VOLUME_ATTACHMENT_SCHEMA, } }, + "required": ["volumeAttachments"], } EXTENSION_SCHEMA: dict[str, Any] = { @@ -2174,12 +2217,14 @@ EXTENSION_SCHEMA: dict[str, Any] = { "description": "The date and time when the resource was updated.", }, }, + "required": ["name", "alias"], } EXTENSION_CONTAINER_SCHEMA: dict[str, Any] = { "type": "object", "description": "An extension object.", "properties": {"extension": copy.deepcopy(EXTENSION_SCHEMA)}, + "required": ["extension"], } EXTENSION_LIST_SCHEMA: dict[str, Any] = { @@ -2191,4 +2236,5 @@ EXTENSION_LIST_SCHEMA: dict[str, Any] = { "items": copy.deepcopy(EXTENSION_SCHEMA), } }, + "required": ["extensions"], }