From 14e97bacb17ca33b42e33297f7b6cbf344024f7c Mon Sep 17 00:00:00 2001 From: Alex-Andrei Cioc Date: Sat, 15 Nov 2025 01:18:19 +0200 Subject: [PATCH] feat: Regenerate API using openapi-generator-cli This commit switches to the more stable openapi-generator-cli tool for generation, which also fixes some missing types for fields. Signed-off-by: Alex-Andrei Cioc --- .gitignore | 4 + .openapi-generator-ignore | 7 + .openapi-generator/FILES | 151 + .openapi-generator/VERSION | 1 + .platform-config.yaml | 4 - Makefile | 43 +- config.yaml | 21 + platform.json | 7450 +++++++++++++++++ pyproject.toml | 4 +- templates/model.py.jinja | 2 +- unikraft_cloud_platform/__init__.py | 545 +- unikraft_cloud_platform/api/__init__.py | 11 +- .../api/autoscale/__init__.py | 1 - ...ale_configuration_by_service_group_uuid.py | 189 - .../create_autoscale_configuration_policy.py | 186 - .../create_autoscale_configurations.py | 170 - ...delete_autoscale_configuration_policies.py | 178 - ..._autoscale_configuration_policy_by_name.py | 166 - .../delete_autoscale_configurations.py | 168 - ...le_configurations_by_service_group_uuid.py | 181 - .../get_autoscale_configuration_policies.py | 178 - ..._autoscale_configuration_policy_by_name.py | 170 - .../autoscale/get_autoscale_configurations.py | 168 - ...le_configurations_by_service_group_uuid.py | 157 - unikraft_cloud_platform/api/autoscale_api.py | 2584 ++++++ .../api/certificates/__init__.py | 1 - .../api/certificates/create_certificate.py | 165 - .../delete_certificate_by_uuid.py | 157 - .../api/certificates/delete_certificates.py | 168 - .../certificates/get_certificate_by_uuid.py | 151 - .../api/certificates/get_certificates.py | 186 - .../api/certificates_api.py | 1281 +++ .../api/images/__init__.py | 1 - .../api/images/get_image_by_digest.py | 154 - .../api/images/get_image_by_tag.py | 150 - unikraft_cloud_platform/api/images_api.py | 323 + .../api/instances/__init__.py | 1 - .../api/instances/create_instance.py | 159 - .../api/instances/delete_instance_by_uuid.py | 159 - .../api/instances/delete_instances.py | 170 - .../api/instances/get_instance_by_uuid.py | 172 - .../api/instances/get_instance_logs.py | 167 - .../instances/get_instance_logs_by_uuid.py | 173 - .../api/instances/get_instance_metrics.py | 175 - .../instances/get_instance_metrics_by_uuid.py | 153 - .../api/instances/get_instances.py | 186 - .../api/instances/start_instance_by_uuid.py | 155 - .../api/instances/start_instances.py | 166 - .../api/instances/stop_instance_by_uuid.py | 191 - .../api/instances/stop_instances.py | 166 - .../api/instances/update_instance_by_uuid.py | 177 - .../api/instances/update_instances.py | 163 - .../api/instances/wait_instance_by_uuid.py | 201 - .../api/instances/wait_instances.py | 234 - unikraft_cloud_platform/api/instances_api.py | 3546 ++++++++ .../api/service_groups/__init__.py | 1 - .../service_groups/create_service_group.py | 181 - .../delete_service_group_by_uuid.py | 157 - .../service_groups/delete_service_groups.py | 168 - .../get_service_group_by_uuid.py | 174 - .../api/service_groups/get_service_groups.py | 188 - .../update_service_group_by_uuid.py | 175 - .../service_groups/update_service_groups.py | 164 - unikraft_cloud_platform/api/services_api.py | 1280 +++ .../api/system/__init__.py | 1 - unikraft_cloud_platform/api/system/healthz.py | 126 - unikraft_cloud_platform/api/users/__init__.py | 1 - unikraft_cloud_platform/api/users/get_user.py | 130 - .../api/users/get_user_by_uuid.py | 155 - unikraft_cloud_platform/api/users_api.py | 482 ++ .../api/volumes/__init__.py | 1 - .../api/volumes/attach_volume_by_uuid.py | 181 - .../api/volumes/attach_volumes.py | 175 - .../api/volumes/create_volume.py | 175 - .../api/volumes/delete_volume_by_uuid.py | 159 - .../api/volumes/delete_volumes.py | 170 - .../api/volumes/detach_volume_by_uuid.py | 193 - .../api/volumes/detach_volumes.py | 191 - .../api/volumes/get_volume_by_uuid.py | 176 - .../api/volumes/get_volumes.py | 190 - .../api/volumes/update_volume_by_uuid.py | 173 - .../api/volumes/update_volumes.py | 162 - unikraft_cloud_platform/api/volumes_api.py | 775 ++ unikraft_cloud_platform/api_client.py | 702 ++ unikraft_cloud_platform/api_response.py | 20 + unikraft_cloud_platform/client.py | 260 - unikraft_cloud_platform/configuration.py | 596 ++ unikraft_cloud_platform/errors.py | 16 - unikraft_cloud_platform/exceptions.py | 216 + unikraft_cloud_platform/models/__init__.py | 567 +- .../attach_volume_by_uuid_request_body.py | 73 - .../models/attach_volumes_request.py | 117 - .../attach_volumes_request_instance_id.py | 65 - .../models/attach_volumes_response.py | 120 - ...attach_volumes_response_attached_volume.py | 109 - .../models/attach_volumes_response_data.py | 71 - .../models/autoscale_config.py | 157 + .../models/autoscale_config_master.py | 92 + .../models/autoscale_policy.py | 246 +- .../autoscale_policy_adjustment_type.py | 15 - .../models/autoscale_policy_metric.py | 13 - .../models/autoscale_policy_step.py | 163 +- .../models/body_instance_id.py | 65 - unikraft_cloud_platform/models/certificate.py | 446 +- .../certificate_service_groups_inner.py | 88 + .../models/certificate_state.py | 15 - .../models/certificate_validation.py | 90 + .../configuration_instance_create_args.py | 42 - .../create_autoscale_config200_response.py | 105 + ...reate_autoscale_config200_response_data.py | 105 + ...fig200_response_data_certificates_inner.py | 88 + .../models/create_autoscale_config_request.py | 131 + .../create_autoscale_config_request_master.py | 109 + ...iguration_by_service_group_uuid_request.py | 153 - ...group_uuid_request_instance_create_args.py | 42 - ..._autoscale_configuration_policy_request.py | 77 - ...autoscale_configuration_policy_response.py | 119 - ...cale_configuration_policy_response_data.py | 75 - ...le_configuration_policy_response_policy.py | 109 - ...le_configurations_request_configuration.py | 152 - ...reate_autoscale_configurations_response.py | 117 - ...ations_response_configurations_response.py | 109 - ..._autoscale_configurations_response_data.py | 77 - .../create_autoscale_policy200_response.py | 105 + ...reate_autoscale_policy200_response_data.py | 105 + ...icy200_response_data_certificates_inner.py | 88 + .../models/create_autoscale_policy_request.py | 121 + .../models/create_certificate200_response.py | 105 + .../create_certificate200_response_data.py | 104 + ...ate200_response_data_certificates_inner.py | 88 + .../models/create_certificate_request.py | 173 +- .../models/create_certificate_response.py | 127 - .../create_certificate_response_data.py | 74 - .../models/create_instance200_response.py | 103 + .../models/create_instance_request.py | 470 +- .../models/create_instance_request_domain.py | 73 - .../models/create_instance_request_env.py | 113 +- .../create_instance_request_features_item.py | 13 - .../create_instance_request_restart_policy.py | 15 - .../create_instance_request_scale_to_zero.py | 106 + .../create_instance_request_service_group.py | 172 +- ...nce_request_service_group_domains_inner.py | 99 + .../models/create_instance_request_volume.py | 118 - .../create_instance_request_volumes_inner.py | 108 + .../models/create_instance_response.py | 127 - .../models/create_instance_response_data.py | 71 - .../models/create_service_group_request.py | 138 - .../create_service_group_request_domain.py | 83 - .../models/create_service_group_response.py | 127 - .../create_service_group_response_data.py | 74 - .../models/create_services200_response.py | 103 + .../create_services200_response_data.py | 104 + ...s200_response_data_service_groups_inner.py | 134 + ...data_service_groups_inner_domains_inner.py | 103 + ..._groups_inner_domains_inner_certificate.py | 102 + .../models/create_services_request.py | 103 + .../create_services_request_services_inner.py | 123 + ...es_request_services_inner_domains_inner.py | 105 + ...ervices_inner_domains_inner_certificate.py | 88 + .../models/create_volume_request.py | 57 - .../models/create_volume_response.py | 117 - .../models/create_volume_response_data.py | 71 - .../models/create_volume_response_volume.py | 109 - .../models/create_volumes200_response.py | 103 + .../models/create_volumes200_response_data.py | 100 + ..._volumes200_response_data_volumes_inner.py | 99 + .../models/create_volumes_request_inner.py | 90 + .../delete_autoscale_configs200_response.py | 107 + ...lete_autoscale_configs200_response_data.py | 105 + ...s200_response_data_service_groups_inner.py | 101 + ...autoscale_configuration_policy_response.py | 119 - ...cale_configuration_policy_response_data.py | 75 - ...ation_policy_response_policies_response.py | 92 - ...elete_autoscale_configurations_response.py | 115 - ..._autoscale_configurations_response_data.py | 75 - ...e_configurations_response_service_group.py | 109 - .../delete_autoscale_policies200_response.py | 107 + ...ete_autoscale_policies200_response_data.py | 104 + ...olicies200_response_data_policies_inner.py | 97 + ...ervice_uuid_and_policy_name200_response.py | 107 + ...e_uuid_and_policy_name200_response_data.py | 102 + .../delete_certificate_by_uuid200_response.py | 107 + ...te_certificate_by_uuid200_response_data.py | 104 + .../models/delete_certificates200_response.py | 105 + .../delete_certificates200_response_data.py | 104 + ...tes200_response_data_certificates_inner.py | 99 + .../delete_certificates_request_inner.py | 92 + .../models/delete_certificates_response.py | 130 - .../delete_certificates_response_data.py | 73 - ...rtificates_response_deleted_certificate.py | 111 - .../models/delete_instances200_response.py | 103 + .../delete_instances200_response_data.py | 102 + ...tances200_response_data_instances_inner.py | 125 + .../models/delete_instances_request_inner.py | 92 + .../models/delete_instances_response.py | 130 - .../models/delete_instances_response_data.py | 71 - ...ete_instances_response_deleted_instance.py | 120 - .../models/delete_policy_request.py | 57 - .../models/delete_service_groups_response.py | 130 - .../delete_service_groups_response_data.py | 75 - ...e_groups_response_deleted_service_group.py | 113 - .../models/delete_services200_response.py | 103 + .../delete_services200_response_data.py | 104 + ...s200_response_data_service_groups_inner.py | 99 + .../models/delete_services_request_inner.py | 92 + .../models/delete_volumes200_response.py | 93 + .../models/delete_volumes_request_inner.py | 92 + .../models/delete_volumes_response.py | 115 - .../models/delete_volumes_response_data.py | 71 - .../delete_volumes_response_deleted_volume.py | 109 - .../detach_volume_by_uuid_request_body.py | 68 - .../models/detach_volumes_request.py | 101 - .../detach_volumes_request_instance_id.py | 65 - .../models/detach_volumes_response.py | 115 - .../models/detach_volumes_response_data.py | 71 - ...detach_volumes_response_detached_volume.py | 109 - unikraft_cloud_platform/models/domain.py | 68 - .../get_autosacle_policies200_response.py | 105 + ...get_autosacle_policies200_response_data.py | 98 + .../get_autosacle_policies_request_inner.py | 92 + .../get_autoscale_configs200_response.py | 107 + .../get_autoscale_configs200_response_data.py | 98 + .../get_autoscale_configs_request_inner.py | 92 + ..._autoscale_configuration_policy_request.py | 57 - ...autoscale_configuration_policy_response.py | 117 - ...cale_configuration_policy_response_data.py | 75 - ...uration_policy_response_policy_response.py | 108 - .../get_autoscale_configurations_response.py | 120 - ..._autoscale_configurations_response_data.py | 75 - ...e_configurations_response_service_group.py | 200 - ...utoscale_configurations_response_status.py | 17 - ...ervice_uuid_and_policy_name200_response.py | 107 + ...e_uuid_and_policy_name200_response_data.py | 98 + .../get_certificate_by_uuid200_response.py | 105 + ...et_certificate_by_uuid200_response_data.py | 98 + .../models/get_certificates200_response.py | 103 + .../get_certificates200_response_data.py | 98 + .../get_certificates_default_response.py | 110 + ...tificates_default_response_errors_inner.py | 83 + .../models/get_certificates_request_inner.py | 92 + .../models/get_certificates_response.py | 130 - .../models/get_certificates_response_data.py | 71 - .../models/get_image_response.py | 126 - .../models/get_image_response_data.py | 67 - .../models/get_images200_response.py | 103 + .../models/get_images200_response_data.py | 94 + .../models/get_images_request_inner.py | 111 + .../get_instance_by_uuid200_response.py | 105 + .../get_instance_by_uuid200_response_data.py | 98 + .../models/get_instance_logs200_response.py | 103 + .../get_instance_logs200_response_data.py | 102 + ...e_logs200_response_data_instances_inner.py | 132 + ...response_data_instances_inner_available.py | 89 + ...200_response_data_instances_inner_range.py | 89 + .../get_instance_logs_by_uuid_request_body.py | 65 - .../models/get_instance_logs_request.py | 92 - .../models/get_instance_logs_request_inner.py | 106 + .../models/get_instance_logs_response.py | 130 - .../get_instance_logs_response_available.py | 64 - .../models/get_instance_logs_response_data.py | 74 - ..._instance_logs_response_logged_instance.py | 159 - ...nce_logs_response_logged_instance_state.py | 22 - .../get_instance_logs_response_range.py | 64 - .../get_instance_metrics200_response.py | 105 + .../get_instance_metrics200_response_data.py | 98 + .../get_instance_metrics_request_inner.py | 91 + .../models/get_instance_metrics_response.py | 130 - .../get_instance_metrics_response_data.py | 73 - ...tance_metrics_response_instance_metrics.py | 195 - .../models/get_instances200_response.py | 103 + .../models/get_instances200_response_data.py | 98 + .../models/get_instances_request_inner.py | 92 + .../models/get_instances_response.py | 127 - .../models/get_instances_response_data.py | 71 - .../models/get_quota_by_uuid200_response.py | 103 + .../get_quota_by_uuid200_response_data.py | 98 + .../models/get_quotas200_response.py | 103 + .../models/get_quotas200_response_data.py | 98 + .../models/get_service_by_uuid200_response.py | 103 + .../get_service_by_uuid200_response_data.py | 102 + .../models/get_service_groups_response.py | 130 - .../get_service_groups_response_data.py | 71 - .../models/get_services200_response.py | 103 + .../models/get_services200_response_data.py | 104 + ...s200_response_data_service_groups_inner.py | 186 + ...ta_service_groups_inner_instances_inner.py | 88 + .../models/get_services_request_inner.py | 92 + .../models/get_volumes200_response.py | 103 + .../models/get_volumes200_response_data.py | 98 + .../models/get_volumes_request_inner.py | 92 + .../models/get_volumes_response.py | 120 - .../models/get_volumes_response_data.py | 71 - .../models/healthz_response.py | 127 - .../models/healthz_response_data.py | 69 - .../models/healthz_response_data_services.py | 42 - unikraft_cloud_platform/models/image.py | 369 +- .../models/image_labels.py | 44 - unikraft_cloud_platform/models/instance.py | 959 +-- ...reate_args_instance_create_request_roms.py | 66 - .../models/instance_env.py | 49 - .../models/instance_instance_service_group.py | 114 - .../models/instance_instance_volume.py | 107 - .../models/instance_metrics.py | 160 + .../models/instance_network_interface.py | 122 - .../instance_network_interfaces_inner.py | 135 + .../models/instance_restart.py | 88 + .../models/instance_restart_policy.py | 15 - .../models/instance_scale_to_zero.py | 105 - .../models/instance_scale_to_zero_policy.py | 15 - .../models/instance_service_group.py | 109 + .../instance_service_group_domains_inner.py | 105 + ...service_group_domains_inner_certificate.py | 88 + .../instance_service_group_instance_domain.py | 70 - .../models/instance_snapshot.py | 84 + .../models/instance_state.py | 18 - .../models/name_or_uuid.py | 44 - unikraft_cloud_platform/models/object_.py | 80 - unikraft_cloud_platform/models/quotas.py | 155 - .../models/quotas_limits.py | 118 - .../models/quotas_response.py | 117 - .../models/quotas_response_data.py | 71 - .../models/quotas_stats.py | 119 - .../models/response_error.py | 57 - .../models/response_status.py | 14 - unikraft_cloud_platform/models/service.py | 272 +- .../models/service_group.py | 287 - .../models/service_group_instance.py | 78 - .../models/service_group_template.py | 72 - .../models/service_handlers_item.py | 15 - .../models/service_mapping.py | 103 + .../models/start_instance_response.py | 130 - .../models/start_instance_response_data.py | 71 - ...tart_instance_response_started_instance.py | 127 - .../models/start_instances200_response.py | 103 + .../start_instances200_response_data.py | 102 + ...tances200_response_data_instances_inner.py | 139 + .../models/start_instances_request_inner.py | 92 + .../models/stop_instance_response.py | 130 - .../models/stop_instance_response_data.py | 71 - ...stop_instance_response_stopped_instance.py | 132 - ...esponse_stopped_instance_previous_state.py | 24 - ...nstance_response_stopped_instance_state.py | 20 - .../models/stop_instances_request_id.py | 92 - .../models/stop_instances_request_inner.py | 104 + .../update_instance_by_uuid_request_body.py | 93 - ...update_instance_by_uuid_request_body_op.py | 15 - ...date_instance_by_uuid_request_body_prop.py | 22 - .../models/update_instances_request.py | 114 - .../models/update_instances_request_op.py | 15 - .../models/update_instances_request_prop.py | 22 - .../models/update_instances_response.py | 127 - .../models/update_instances_response_data.py | 71 - ...ate_instances_response_updated_instance.py | 110 - ...date_service_group_by_uuid_request_body.py | 92 - ...e_service_group_by_uuid_request_body_op.py | 17 - ...service_group_by_uuid_request_body_prop.py | 18 - .../update_service_groups_request_item.py | 120 - .../update_service_groups_request_item_op.py | 15 - ...update_service_groups_request_item_prop.py | 16 - .../models/update_service_groups_response.py | 127 - .../update_service_groups_response_data.py | 75 - ...e_groups_response_updated_service_group.py | 112 - .../update_volume_by_uuid_request_body.py | 92 - .../update_volume_by_uuid_request_body_op.py | 15 - ...update_volume_by_uuid_request_body_prop.py | 16 - .../models/update_volumes_request_item.py | 115 - .../models/update_volumes_request_item_op.py | 15 - .../update_volumes_request_item_prop.py | 16 - .../models/update_volumes_response.py | 127 - .../models/update_volumes_response_data.py | 71 - .../update_volumes_response_updated_volume.py | 110 - unikraft_cloud_platform/models/user_quota.py | 99 + .../models/user_quota_limits.py | 119 + .../models/user_quota_used.py | 123 + unikraft_cloud_platform/models/volume.py | 391 +- .../models/volume_attached_to_inner.py | 88 + .../models/volume_instance_id.py | 65 - .../models/volume_mounted_by_inner.py | 91 + .../models/volume_state.py | 19 - .../models/volume_volume_instance_mount.py | 72 - .../models/wait_for_instances200_response.py | 103 + .../wait_for_instances200_response_data.py | 102 + ...tances200_response_data_instances_inner.py | 119 + .../wait_for_instances_request_inner.py | 115 + .../wait_instance_by_uuid_request_body.py | 68 - ...ait_instance_by_uuid_request_body_state.py | 18 - .../models/wait_instance_response.py | 130 - .../models/wait_instance_response_data.py | 71 - .../wait_instance_response_waited_instance.py | 112 - ...instance_response_waited_instance_state.py | 20 - .../models/wait_instances_state.py | 18 - unikraft_cloud_platform/py.typed | 1 - unikraft_cloud_platform/rest.py | 207 + unikraft_cloud_platform/types.py | 54 - 394 files changed, 35136 insertions(+), 26095 deletions(-) create mode 100644 .openapi-generator-ignore create mode 100644 .openapi-generator/FILES create mode 100644 .openapi-generator/VERSION delete mode 100644 .platform-config.yaml create mode 100644 config.yaml create mode 100644 platform.json delete mode 100644 unikraft_cloud_platform/api/autoscale/__init__.py delete mode 100644 unikraft_cloud_platform/api/autoscale/create_autoscale_configuration_by_service_group_uuid.py delete mode 100644 unikraft_cloud_platform/api/autoscale/create_autoscale_configuration_policy.py delete mode 100644 unikraft_cloud_platform/api/autoscale/create_autoscale_configurations.py delete mode 100644 unikraft_cloud_platform/api/autoscale/delete_autoscale_configuration_policies.py delete mode 100644 unikraft_cloud_platform/api/autoscale/delete_autoscale_configuration_policy_by_name.py delete mode 100644 unikraft_cloud_platform/api/autoscale/delete_autoscale_configurations.py delete mode 100644 unikraft_cloud_platform/api/autoscale/delete_autoscale_configurations_by_service_group_uuid.py delete mode 100644 unikraft_cloud_platform/api/autoscale/get_autoscale_configuration_policies.py delete mode 100644 unikraft_cloud_platform/api/autoscale/get_autoscale_configuration_policy_by_name.py delete mode 100644 unikraft_cloud_platform/api/autoscale/get_autoscale_configurations.py delete mode 100644 unikraft_cloud_platform/api/autoscale/get_autoscale_configurations_by_service_group_uuid.py create mode 100644 unikraft_cloud_platform/api/autoscale_api.py delete mode 100644 unikraft_cloud_platform/api/certificates/__init__.py delete mode 100644 unikraft_cloud_platform/api/certificates/create_certificate.py delete mode 100644 unikraft_cloud_platform/api/certificates/delete_certificate_by_uuid.py delete mode 100644 unikraft_cloud_platform/api/certificates/delete_certificates.py delete mode 100644 unikraft_cloud_platform/api/certificates/get_certificate_by_uuid.py delete mode 100644 unikraft_cloud_platform/api/certificates/get_certificates.py create mode 100644 unikraft_cloud_platform/api/certificates_api.py delete mode 100644 unikraft_cloud_platform/api/images/__init__.py delete mode 100644 unikraft_cloud_platform/api/images/get_image_by_digest.py delete mode 100644 unikraft_cloud_platform/api/images/get_image_by_tag.py create mode 100644 unikraft_cloud_platform/api/images_api.py delete mode 100644 unikraft_cloud_platform/api/instances/__init__.py delete mode 100644 unikraft_cloud_platform/api/instances/create_instance.py delete mode 100644 unikraft_cloud_platform/api/instances/delete_instance_by_uuid.py delete mode 100644 unikraft_cloud_platform/api/instances/delete_instances.py delete mode 100644 unikraft_cloud_platform/api/instances/get_instance_by_uuid.py delete mode 100644 unikraft_cloud_platform/api/instances/get_instance_logs.py delete mode 100644 unikraft_cloud_platform/api/instances/get_instance_logs_by_uuid.py delete mode 100644 unikraft_cloud_platform/api/instances/get_instance_metrics.py delete mode 100644 unikraft_cloud_platform/api/instances/get_instance_metrics_by_uuid.py delete mode 100644 unikraft_cloud_platform/api/instances/get_instances.py delete mode 100644 unikraft_cloud_platform/api/instances/start_instance_by_uuid.py delete mode 100644 unikraft_cloud_platform/api/instances/start_instances.py delete mode 100644 unikraft_cloud_platform/api/instances/stop_instance_by_uuid.py delete mode 100644 unikraft_cloud_platform/api/instances/stop_instances.py delete mode 100644 unikraft_cloud_platform/api/instances/update_instance_by_uuid.py delete mode 100644 unikraft_cloud_platform/api/instances/update_instances.py delete mode 100644 unikraft_cloud_platform/api/instances/wait_instance_by_uuid.py delete mode 100644 unikraft_cloud_platform/api/instances/wait_instances.py create mode 100644 unikraft_cloud_platform/api/instances_api.py delete mode 100644 unikraft_cloud_platform/api/service_groups/__init__.py delete mode 100644 unikraft_cloud_platform/api/service_groups/create_service_group.py delete mode 100644 unikraft_cloud_platform/api/service_groups/delete_service_group_by_uuid.py delete mode 100644 unikraft_cloud_platform/api/service_groups/delete_service_groups.py delete mode 100644 unikraft_cloud_platform/api/service_groups/get_service_group_by_uuid.py delete mode 100644 unikraft_cloud_platform/api/service_groups/get_service_groups.py delete mode 100644 unikraft_cloud_platform/api/service_groups/update_service_group_by_uuid.py delete mode 100644 unikraft_cloud_platform/api/service_groups/update_service_groups.py create mode 100644 unikraft_cloud_platform/api/services_api.py delete mode 100644 unikraft_cloud_platform/api/system/__init__.py delete mode 100644 unikraft_cloud_platform/api/system/healthz.py delete mode 100644 unikraft_cloud_platform/api/users/__init__.py delete mode 100644 unikraft_cloud_platform/api/users/get_user.py delete mode 100644 unikraft_cloud_platform/api/users/get_user_by_uuid.py create mode 100644 unikraft_cloud_platform/api/users_api.py delete mode 100644 unikraft_cloud_platform/api/volumes/__init__.py delete mode 100644 unikraft_cloud_platform/api/volumes/attach_volume_by_uuid.py delete mode 100644 unikraft_cloud_platform/api/volumes/attach_volumes.py delete mode 100644 unikraft_cloud_platform/api/volumes/create_volume.py delete mode 100644 unikraft_cloud_platform/api/volumes/delete_volume_by_uuid.py delete mode 100644 unikraft_cloud_platform/api/volumes/delete_volumes.py delete mode 100644 unikraft_cloud_platform/api/volumes/detach_volume_by_uuid.py delete mode 100644 unikraft_cloud_platform/api/volumes/detach_volumes.py delete mode 100644 unikraft_cloud_platform/api/volumes/get_volume_by_uuid.py delete mode 100644 unikraft_cloud_platform/api/volumes/get_volumes.py delete mode 100644 unikraft_cloud_platform/api/volumes/update_volume_by_uuid.py delete mode 100644 unikraft_cloud_platform/api/volumes/update_volumes.py create mode 100644 unikraft_cloud_platform/api/volumes_api.py create mode 100644 unikraft_cloud_platform/api_client.py create mode 100644 unikraft_cloud_platform/api_response.py delete mode 100644 unikraft_cloud_platform/client.py create mode 100644 unikraft_cloud_platform/configuration.py delete mode 100644 unikraft_cloud_platform/errors.py create mode 100644 unikraft_cloud_platform/exceptions.py delete mode 100644 unikraft_cloud_platform/models/attach_volume_by_uuid_request_body.py delete mode 100644 unikraft_cloud_platform/models/attach_volumes_request.py delete mode 100644 unikraft_cloud_platform/models/attach_volumes_request_instance_id.py delete mode 100644 unikraft_cloud_platform/models/attach_volumes_response.py delete mode 100644 unikraft_cloud_platform/models/attach_volumes_response_attached_volume.py delete mode 100644 unikraft_cloud_platform/models/attach_volumes_response_data.py create mode 100644 unikraft_cloud_platform/models/autoscale_config.py create mode 100644 unikraft_cloud_platform/models/autoscale_config_master.py delete mode 100644 unikraft_cloud_platform/models/autoscale_policy_adjustment_type.py delete mode 100644 unikraft_cloud_platform/models/autoscale_policy_metric.py delete mode 100644 unikraft_cloud_platform/models/body_instance_id.py create mode 100644 unikraft_cloud_platform/models/certificate_service_groups_inner.py delete mode 100644 unikraft_cloud_platform/models/certificate_state.py create mode 100644 unikraft_cloud_platform/models/certificate_validation.py delete mode 100644 unikraft_cloud_platform/models/configuration_instance_create_args.py create mode 100644 unikraft_cloud_platform/models/create_autoscale_config200_response.py create mode 100644 unikraft_cloud_platform/models/create_autoscale_config200_response_data.py create mode 100644 unikraft_cloud_platform/models/create_autoscale_config200_response_data_certificates_inner.py create mode 100644 unikraft_cloud_platform/models/create_autoscale_config_request.py create mode 100644 unikraft_cloud_platform/models/create_autoscale_config_request_master.py delete mode 100644 unikraft_cloud_platform/models/create_autoscale_configuration_by_service_group_uuid_request.py delete mode 100644 unikraft_cloud_platform/models/create_autoscale_configuration_by_service_group_uuid_request_instance_create_args.py delete mode 100644 unikraft_cloud_platform/models/create_autoscale_configuration_policy_request.py delete mode 100644 unikraft_cloud_platform/models/create_autoscale_configuration_policy_response.py delete mode 100644 unikraft_cloud_platform/models/create_autoscale_configuration_policy_response_data.py delete mode 100644 unikraft_cloud_platform/models/create_autoscale_configuration_policy_response_policy.py delete mode 100644 unikraft_cloud_platform/models/create_autoscale_configurations_request_configuration.py delete mode 100644 unikraft_cloud_platform/models/create_autoscale_configurations_response.py delete mode 100644 unikraft_cloud_platform/models/create_autoscale_configurations_response_configurations_response.py delete mode 100644 unikraft_cloud_platform/models/create_autoscale_configurations_response_data.py create mode 100644 unikraft_cloud_platform/models/create_autoscale_policy200_response.py create mode 100644 unikraft_cloud_platform/models/create_autoscale_policy200_response_data.py create mode 100644 unikraft_cloud_platform/models/create_autoscale_policy200_response_data_certificates_inner.py create mode 100644 unikraft_cloud_platform/models/create_autoscale_policy_request.py create mode 100644 unikraft_cloud_platform/models/create_certificate200_response.py create mode 100644 unikraft_cloud_platform/models/create_certificate200_response_data.py create mode 100644 unikraft_cloud_platform/models/create_certificate200_response_data_certificates_inner.py delete mode 100644 unikraft_cloud_platform/models/create_certificate_response.py delete mode 100644 unikraft_cloud_platform/models/create_certificate_response_data.py create mode 100644 unikraft_cloud_platform/models/create_instance200_response.py delete mode 100644 unikraft_cloud_platform/models/create_instance_request_domain.py delete mode 100644 unikraft_cloud_platform/models/create_instance_request_features_item.py delete mode 100644 unikraft_cloud_platform/models/create_instance_request_restart_policy.py create mode 100644 unikraft_cloud_platform/models/create_instance_request_scale_to_zero.py create mode 100644 unikraft_cloud_platform/models/create_instance_request_service_group_domains_inner.py delete mode 100644 unikraft_cloud_platform/models/create_instance_request_volume.py create mode 100644 unikraft_cloud_platform/models/create_instance_request_volumes_inner.py delete mode 100644 unikraft_cloud_platform/models/create_instance_response.py delete mode 100644 unikraft_cloud_platform/models/create_instance_response_data.py delete mode 100644 unikraft_cloud_platform/models/create_service_group_request.py delete mode 100644 unikraft_cloud_platform/models/create_service_group_request_domain.py delete mode 100644 unikraft_cloud_platform/models/create_service_group_response.py delete mode 100644 unikraft_cloud_platform/models/create_service_group_response_data.py create mode 100644 unikraft_cloud_platform/models/create_services200_response.py create mode 100644 unikraft_cloud_platform/models/create_services200_response_data.py create mode 100644 unikraft_cloud_platform/models/create_services200_response_data_service_groups_inner.py create mode 100644 unikraft_cloud_platform/models/create_services200_response_data_service_groups_inner_domains_inner.py create mode 100644 unikraft_cloud_platform/models/create_services200_response_data_service_groups_inner_domains_inner_certificate.py create mode 100644 unikraft_cloud_platform/models/create_services_request.py create mode 100644 unikraft_cloud_platform/models/create_services_request_services_inner.py create mode 100644 unikraft_cloud_platform/models/create_services_request_services_inner_domains_inner.py create mode 100644 unikraft_cloud_platform/models/create_services_request_services_inner_domains_inner_certificate.py delete mode 100644 unikraft_cloud_platform/models/create_volume_request.py delete mode 100644 unikraft_cloud_platform/models/create_volume_response.py delete mode 100644 unikraft_cloud_platform/models/create_volume_response_data.py delete mode 100644 unikraft_cloud_platform/models/create_volume_response_volume.py create mode 100644 unikraft_cloud_platform/models/create_volumes200_response.py create mode 100644 unikraft_cloud_platform/models/create_volumes200_response_data.py create mode 100644 unikraft_cloud_platform/models/create_volumes200_response_data_volumes_inner.py create mode 100644 unikraft_cloud_platform/models/create_volumes_request_inner.py create mode 100644 unikraft_cloud_platform/models/delete_autoscale_configs200_response.py create mode 100644 unikraft_cloud_platform/models/delete_autoscale_configs200_response_data.py create mode 100644 unikraft_cloud_platform/models/delete_autoscale_configs200_response_data_service_groups_inner.py delete mode 100644 unikraft_cloud_platform/models/delete_autoscale_configuration_policy_response.py delete mode 100644 unikraft_cloud_platform/models/delete_autoscale_configuration_policy_response_data.py delete mode 100644 unikraft_cloud_platform/models/delete_autoscale_configuration_policy_response_policies_response.py delete mode 100644 unikraft_cloud_platform/models/delete_autoscale_configurations_response.py delete mode 100644 unikraft_cloud_platform/models/delete_autoscale_configurations_response_data.py delete mode 100644 unikraft_cloud_platform/models/delete_autoscale_configurations_response_service_group.py create mode 100644 unikraft_cloud_platform/models/delete_autoscale_policies200_response.py create mode 100644 unikraft_cloud_platform/models/delete_autoscale_policies200_response_data.py create mode 100644 unikraft_cloud_platform/models/delete_autoscale_policies200_response_data_policies_inner.py create mode 100644 unikraft_cloud_platform/models/delete_autoscale_policy_by_service_uuid_and_policy_name200_response.py create mode 100644 unikraft_cloud_platform/models/delete_autoscale_policy_by_service_uuid_and_policy_name200_response_data.py create mode 100644 unikraft_cloud_platform/models/delete_certificate_by_uuid200_response.py create mode 100644 unikraft_cloud_platform/models/delete_certificate_by_uuid200_response_data.py create mode 100644 unikraft_cloud_platform/models/delete_certificates200_response.py create mode 100644 unikraft_cloud_platform/models/delete_certificates200_response_data.py create mode 100644 unikraft_cloud_platform/models/delete_certificates200_response_data_certificates_inner.py create mode 100644 unikraft_cloud_platform/models/delete_certificates_request_inner.py delete mode 100644 unikraft_cloud_platform/models/delete_certificates_response.py delete mode 100644 unikraft_cloud_platform/models/delete_certificates_response_data.py delete mode 100644 unikraft_cloud_platform/models/delete_certificates_response_deleted_certificate.py create mode 100644 unikraft_cloud_platform/models/delete_instances200_response.py create mode 100644 unikraft_cloud_platform/models/delete_instances200_response_data.py create mode 100644 unikraft_cloud_platform/models/delete_instances200_response_data_instances_inner.py create mode 100644 unikraft_cloud_platform/models/delete_instances_request_inner.py delete mode 100644 unikraft_cloud_platform/models/delete_instances_response.py delete mode 100644 unikraft_cloud_platform/models/delete_instances_response_data.py delete mode 100644 unikraft_cloud_platform/models/delete_instances_response_deleted_instance.py delete mode 100644 unikraft_cloud_platform/models/delete_policy_request.py delete mode 100644 unikraft_cloud_platform/models/delete_service_groups_response.py delete mode 100644 unikraft_cloud_platform/models/delete_service_groups_response_data.py delete mode 100644 unikraft_cloud_platform/models/delete_service_groups_response_deleted_service_group.py create mode 100644 unikraft_cloud_platform/models/delete_services200_response.py create mode 100644 unikraft_cloud_platform/models/delete_services200_response_data.py create mode 100644 unikraft_cloud_platform/models/delete_services200_response_data_service_groups_inner.py create mode 100644 unikraft_cloud_platform/models/delete_services_request_inner.py create mode 100644 unikraft_cloud_platform/models/delete_volumes200_response.py create mode 100644 unikraft_cloud_platform/models/delete_volumes_request_inner.py delete mode 100644 unikraft_cloud_platform/models/delete_volumes_response.py delete mode 100644 unikraft_cloud_platform/models/delete_volumes_response_data.py delete mode 100644 unikraft_cloud_platform/models/delete_volumes_response_deleted_volume.py delete mode 100644 unikraft_cloud_platform/models/detach_volume_by_uuid_request_body.py delete mode 100644 unikraft_cloud_platform/models/detach_volumes_request.py delete mode 100644 unikraft_cloud_platform/models/detach_volumes_request_instance_id.py delete mode 100644 unikraft_cloud_platform/models/detach_volumes_response.py delete mode 100644 unikraft_cloud_platform/models/detach_volumes_response_data.py delete mode 100644 unikraft_cloud_platform/models/detach_volumes_response_detached_volume.py delete mode 100644 unikraft_cloud_platform/models/domain.py create mode 100644 unikraft_cloud_platform/models/get_autosacle_policies200_response.py create mode 100644 unikraft_cloud_platform/models/get_autosacle_policies200_response_data.py create mode 100644 unikraft_cloud_platform/models/get_autosacle_policies_request_inner.py create mode 100644 unikraft_cloud_platform/models/get_autoscale_configs200_response.py create mode 100644 unikraft_cloud_platform/models/get_autoscale_configs200_response_data.py create mode 100644 unikraft_cloud_platform/models/get_autoscale_configs_request_inner.py delete mode 100644 unikraft_cloud_platform/models/get_autoscale_configuration_policy_request.py delete mode 100644 unikraft_cloud_platform/models/get_autoscale_configuration_policy_response.py delete mode 100644 unikraft_cloud_platform/models/get_autoscale_configuration_policy_response_data.py delete mode 100644 unikraft_cloud_platform/models/get_autoscale_configuration_policy_response_policy_response.py delete mode 100644 unikraft_cloud_platform/models/get_autoscale_configurations_response.py delete mode 100644 unikraft_cloud_platform/models/get_autoscale_configurations_response_data.py delete mode 100644 unikraft_cloud_platform/models/get_autoscale_configurations_response_service_group.py delete mode 100644 unikraft_cloud_platform/models/get_autoscale_configurations_response_status.py create mode 100644 unikraft_cloud_platform/models/get_autoscale_policy_by_service_uuid_and_policy_name200_response.py create mode 100644 unikraft_cloud_platform/models/get_autoscale_policy_by_service_uuid_and_policy_name200_response_data.py create mode 100644 unikraft_cloud_platform/models/get_certificate_by_uuid200_response.py create mode 100644 unikraft_cloud_platform/models/get_certificate_by_uuid200_response_data.py create mode 100644 unikraft_cloud_platform/models/get_certificates200_response.py create mode 100644 unikraft_cloud_platform/models/get_certificates200_response_data.py create mode 100644 unikraft_cloud_platform/models/get_certificates_default_response.py create mode 100644 unikraft_cloud_platform/models/get_certificates_default_response_errors_inner.py create mode 100644 unikraft_cloud_platform/models/get_certificates_request_inner.py delete mode 100644 unikraft_cloud_platform/models/get_certificates_response.py delete mode 100644 unikraft_cloud_platform/models/get_certificates_response_data.py delete mode 100644 unikraft_cloud_platform/models/get_image_response.py delete mode 100644 unikraft_cloud_platform/models/get_image_response_data.py create mode 100644 unikraft_cloud_platform/models/get_images200_response.py create mode 100644 unikraft_cloud_platform/models/get_images200_response_data.py create mode 100644 unikraft_cloud_platform/models/get_images_request_inner.py create mode 100644 unikraft_cloud_platform/models/get_instance_by_uuid200_response.py create mode 100644 unikraft_cloud_platform/models/get_instance_by_uuid200_response_data.py create mode 100644 unikraft_cloud_platform/models/get_instance_logs200_response.py create mode 100644 unikraft_cloud_platform/models/get_instance_logs200_response_data.py create mode 100644 unikraft_cloud_platform/models/get_instance_logs200_response_data_instances_inner.py create mode 100644 unikraft_cloud_platform/models/get_instance_logs200_response_data_instances_inner_available.py create mode 100644 unikraft_cloud_platform/models/get_instance_logs200_response_data_instances_inner_range.py delete mode 100644 unikraft_cloud_platform/models/get_instance_logs_by_uuid_request_body.py delete mode 100644 unikraft_cloud_platform/models/get_instance_logs_request.py create mode 100644 unikraft_cloud_platform/models/get_instance_logs_request_inner.py delete mode 100644 unikraft_cloud_platform/models/get_instance_logs_response.py delete mode 100644 unikraft_cloud_platform/models/get_instance_logs_response_available.py delete mode 100644 unikraft_cloud_platform/models/get_instance_logs_response_data.py delete mode 100644 unikraft_cloud_platform/models/get_instance_logs_response_logged_instance.py delete mode 100644 unikraft_cloud_platform/models/get_instance_logs_response_logged_instance_state.py delete mode 100644 unikraft_cloud_platform/models/get_instance_logs_response_range.py create mode 100644 unikraft_cloud_platform/models/get_instance_metrics200_response.py create mode 100644 unikraft_cloud_platform/models/get_instance_metrics200_response_data.py create mode 100644 unikraft_cloud_platform/models/get_instance_metrics_request_inner.py delete mode 100644 unikraft_cloud_platform/models/get_instance_metrics_response.py delete mode 100644 unikraft_cloud_platform/models/get_instance_metrics_response_data.py delete mode 100644 unikraft_cloud_platform/models/get_instance_metrics_response_instance_metrics.py create mode 100644 unikraft_cloud_platform/models/get_instances200_response.py create mode 100644 unikraft_cloud_platform/models/get_instances200_response_data.py create mode 100644 unikraft_cloud_platform/models/get_instances_request_inner.py delete mode 100644 unikraft_cloud_platform/models/get_instances_response.py delete mode 100644 unikraft_cloud_platform/models/get_instances_response_data.py create mode 100644 unikraft_cloud_platform/models/get_quota_by_uuid200_response.py create mode 100644 unikraft_cloud_platform/models/get_quota_by_uuid200_response_data.py create mode 100644 unikraft_cloud_platform/models/get_quotas200_response.py create mode 100644 unikraft_cloud_platform/models/get_quotas200_response_data.py create mode 100644 unikraft_cloud_platform/models/get_service_by_uuid200_response.py create mode 100644 unikraft_cloud_platform/models/get_service_by_uuid200_response_data.py delete mode 100644 unikraft_cloud_platform/models/get_service_groups_response.py delete mode 100644 unikraft_cloud_platform/models/get_service_groups_response_data.py create mode 100644 unikraft_cloud_platform/models/get_services200_response.py create mode 100644 unikraft_cloud_platform/models/get_services200_response_data.py create mode 100644 unikraft_cloud_platform/models/get_services200_response_data_service_groups_inner.py create mode 100644 unikraft_cloud_platform/models/get_services200_response_data_service_groups_inner_instances_inner.py create mode 100644 unikraft_cloud_platform/models/get_services_request_inner.py create mode 100644 unikraft_cloud_platform/models/get_volumes200_response.py create mode 100644 unikraft_cloud_platform/models/get_volumes200_response_data.py create mode 100644 unikraft_cloud_platform/models/get_volumes_request_inner.py delete mode 100644 unikraft_cloud_platform/models/get_volumes_response.py delete mode 100644 unikraft_cloud_platform/models/get_volumes_response_data.py delete mode 100644 unikraft_cloud_platform/models/healthz_response.py delete mode 100644 unikraft_cloud_platform/models/healthz_response_data.py delete mode 100644 unikraft_cloud_platform/models/healthz_response_data_services.py delete mode 100644 unikraft_cloud_platform/models/image_labels.py delete mode 100644 unikraft_cloud_platform/models/instance_create_args_instance_create_request_roms.py delete mode 100644 unikraft_cloud_platform/models/instance_env.py delete mode 100644 unikraft_cloud_platform/models/instance_instance_service_group.py delete mode 100644 unikraft_cloud_platform/models/instance_instance_volume.py create mode 100644 unikraft_cloud_platform/models/instance_metrics.py delete mode 100644 unikraft_cloud_platform/models/instance_network_interface.py create mode 100644 unikraft_cloud_platform/models/instance_network_interfaces_inner.py create mode 100644 unikraft_cloud_platform/models/instance_restart.py delete mode 100644 unikraft_cloud_platform/models/instance_restart_policy.py delete mode 100644 unikraft_cloud_platform/models/instance_scale_to_zero.py delete mode 100644 unikraft_cloud_platform/models/instance_scale_to_zero_policy.py create mode 100644 unikraft_cloud_platform/models/instance_service_group.py create mode 100644 unikraft_cloud_platform/models/instance_service_group_domains_inner.py create mode 100644 unikraft_cloud_platform/models/instance_service_group_domains_inner_certificate.py delete mode 100644 unikraft_cloud_platform/models/instance_service_group_instance_domain.py create mode 100644 unikraft_cloud_platform/models/instance_snapshot.py delete mode 100644 unikraft_cloud_platform/models/instance_state.py delete mode 100644 unikraft_cloud_platform/models/name_or_uuid.py delete mode 100644 unikraft_cloud_platform/models/object_.py delete mode 100644 unikraft_cloud_platform/models/quotas.py delete mode 100644 unikraft_cloud_platform/models/quotas_limits.py delete mode 100644 unikraft_cloud_platform/models/quotas_response.py delete mode 100644 unikraft_cloud_platform/models/quotas_response_data.py delete mode 100644 unikraft_cloud_platform/models/quotas_stats.py delete mode 100644 unikraft_cloud_platform/models/response_error.py delete mode 100644 unikraft_cloud_platform/models/response_status.py delete mode 100644 unikraft_cloud_platform/models/service_group.py delete mode 100644 unikraft_cloud_platform/models/service_group_instance.py delete mode 100644 unikraft_cloud_platform/models/service_group_template.py delete mode 100644 unikraft_cloud_platform/models/service_handlers_item.py create mode 100644 unikraft_cloud_platform/models/service_mapping.py delete mode 100644 unikraft_cloud_platform/models/start_instance_response.py delete mode 100644 unikraft_cloud_platform/models/start_instance_response_data.py delete mode 100644 unikraft_cloud_platform/models/start_instance_response_started_instance.py create mode 100644 unikraft_cloud_platform/models/start_instances200_response.py create mode 100644 unikraft_cloud_platform/models/start_instances200_response_data.py create mode 100644 unikraft_cloud_platform/models/start_instances200_response_data_instances_inner.py create mode 100644 unikraft_cloud_platform/models/start_instances_request_inner.py delete mode 100644 unikraft_cloud_platform/models/stop_instance_response.py delete mode 100644 unikraft_cloud_platform/models/stop_instance_response_data.py delete mode 100644 unikraft_cloud_platform/models/stop_instance_response_stopped_instance.py delete mode 100644 unikraft_cloud_platform/models/stop_instance_response_stopped_instance_previous_state.py delete mode 100644 unikraft_cloud_platform/models/stop_instance_response_stopped_instance_state.py delete mode 100644 unikraft_cloud_platform/models/stop_instances_request_id.py create mode 100644 unikraft_cloud_platform/models/stop_instances_request_inner.py delete mode 100644 unikraft_cloud_platform/models/update_instance_by_uuid_request_body.py delete mode 100644 unikraft_cloud_platform/models/update_instance_by_uuid_request_body_op.py delete mode 100644 unikraft_cloud_platform/models/update_instance_by_uuid_request_body_prop.py delete mode 100644 unikraft_cloud_platform/models/update_instances_request.py delete mode 100644 unikraft_cloud_platform/models/update_instances_request_op.py delete mode 100644 unikraft_cloud_platform/models/update_instances_request_prop.py delete mode 100644 unikraft_cloud_platform/models/update_instances_response.py delete mode 100644 unikraft_cloud_platform/models/update_instances_response_data.py delete mode 100644 unikraft_cloud_platform/models/update_instances_response_updated_instance.py delete mode 100644 unikraft_cloud_platform/models/update_service_group_by_uuid_request_body.py delete mode 100644 unikraft_cloud_platform/models/update_service_group_by_uuid_request_body_op.py delete mode 100644 unikraft_cloud_platform/models/update_service_group_by_uuid_request_body_prop.py delete mode 100644 unikraft_cloud_platform/models/update_service_groups_request_item.py delete mode 100644 unikraft_cloud_platform/models/update_service_groups_request_item_op.py delete mode 100644 unikraft_cloud_platform/models/update_service_groups_request_item_prop.py delete mode 100644 unikraft_cloud_platform/models/update_service_groups_response.py delete mode 100644 unikraft_cloud_platform/models/update_service_groups_response_data.py delete mode 100644 unikraft_cloud_platform/models/update_service_groups_response_updated_service_group.py delete mode 100644 unikraft_cloud_platform/models/update_volume_by_uuid_request_body.py delete mode 100644 unikraft_cloud_platform/models/update_volume_by_uuid_request_body_op.py delete mode 100644 unikraft_cloud_platform/models/update_volume_by_uuid_request_body_prop.py delete mode 100644 unikraft_cloud_platform/models/update_volumes_request_item.py delete mode 100644 unikraft_cloud_platform/models/update_volumes_request_item_op.py delete mode 100644 unikraft_cloud_platform/models/update_volumes_request_item_prop.py delete mode 100644 unikraft_cloud_platform/models/update_volumes_response.py delete mode 100644 unikraft_cloud_platform/models/update_volumes_response_data.py delete mode 100644 unikraft_cloud_platform/models/update_volumes_response_updated_volume.py create mode 100644 unikraft_cloud_platform/models/user_quota.py create mode 100644 unikraft_cloud_platform/models/user_quota_limits.py create mode 100644 unikraft_cloud_platform/models/user_quota_used.py create mode 100644 unikraft_cloud_platform/models/volume_attached_to_inner.py delete mode 100644 unikraft_cloud_platform/models/volume_instance_id.py create mode 100644 unikraft_cloud_platform/models/volume_mounted_by_inner.py delete mode 100644 unikraft_cloud_platform/models/volume_state.py delete mode 100644 unikraft_cloud_platform/models/volume_volume_instance_mount.py create mode 100644 unikraft_cloud_platform/models/wait_for_instances200_response.py create mode 100644 unikraft_cloud_platform/models/wait_for_instances200_response_data.py create mode 100644 unikraft_cloud_platform/models/wait_for_instances200_response_data_instances_inner.py create mode 100644 unikraft_cloud_platform/models/wait_for_instances_request_inner.py delete mode 100644 unikraft_cloud_platform/models/wait_instance_by_uuid_request_body.py delete mode 100644 unikraft_cloud_platform/models/wait_instance_by_uuid_request_body_state.py delete mode 100644 unikraft_cloud_platform/models/wait_instance_response.py delete mode 100644 unikraft_cloud_platform/models/wait_instance_response_data.py delete mode 100644 unikraft_cloud_platform/models/wait_instance_response_waited_instance.py delete mode 100644 unikraft_cloud_platform/models/wait_instance_response_waited_instance_state.py delete mode 100644 unikraft_cloud_platform/models/wait_instances_state.py delete mode 100644 unikraft_cloud_platform/py.typed create mode 100644 unikraft_cloud_platform/rest.py delete mode 100644 unikraft_cloud_platform/types.py diff --git a/.gitignore b/.gitignore index 79a2c3d..66d993e 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,7 @@ dmypy.json /coverage.xml /.coverage + +# Artifacts +./platform.yaml +./platform.json diff --git a/.openapi-generator-ignore b/.openapi-generator-ignore new file mode 100644 index 0000000..3ee7ea6 --- /dev/null +++ b/.openapi-generator-ignore @@ -0,0 +1,7 @@ +git_push.sh +.travis.yml +README.md +*_README.md +docs/ +test/ +.gitignore diff --git a/.openapi-generator/FILES b/.openapi-generator/FILES new file mode 100644 index 0000000..d28e710 --- /dev/null +++ b/.openapi-generator/FILES @@ -0,0 +1,151 @@ +unikraft_cloud_platform/__init__.py +unikraft_cloud_platform/api/__init__.py +unikraft_cloud_platform/api/autoscale_api.py +unikraft_cloud_platform/api/certificates_api.py +unikraft_cloud_platform/api/images_api.py +unikraft_cloud_platform/api/instances_api.py +unikraft_cloud_platform/api/services_api.py +unikraft_cloud_platform/api/users_api.py +unikraft_cloud_platform/api/volumes_api.py +unikraft_cloud_platform/api_client.py +unikraft_cloud_platform/api_response.py +unikraft_cloud_platform/configuration.py +unikraft_cloud_platform/exceptions.py +unikraft_cloud_platform/models/__init__.py +unikraft_cloud_platform/models/autoscale_config.py +unikraft_cloud_platform/models/autoscale_config_master.py +unikraft_cloud_platform/models/autoscale_policy.py +unikraft_cloud_platform/models/autoscale_policy_step.py +unikraft_cloud_platform/models/certificate.py +unikraft_cloud_platform/models/certificate_service_groups_inner.py +unikraft_cloud_platform/models/certificate_validation.py +unikraft_cloud_platform/models/create_autoscale_config200_response.py +unikraft_cloud_platform/models/create_autoscale_config200_response_data.py +unikraft_cloud_platform/models/create_autoscale_config200_response_data_certificates_inner.py +unikraft_cloud_platform/models/create_autoscale_config_request.py +unikraft_cloud_platform/models/create_autoscale_config_request_master.py +unikraft_cloud_platform/models/create_autoscale_policy200_response.py +unikraft_cloud_platform/models/create_autoscale_policy200_response_data.py +unikraft_cloud_platform/models/create_autoscale_policy200_response_data_certificates_inner.py +unikraft_cloud_platform/models/create_autoscale_policy_request.py +unikraft_cloud_platform/models/create_certificate200_response.py +unikraft_cloud_platform/models/create_certificate200_response_data.py +unikraft_cloud_platform/models/create_certificate200_response_data_certificates_inner.py +unikraft_cloud_platform/models/create_certificate_request.py +unikraft_cloud_platform/models/create_instance200_response.py +unikraft_cloud_platform/models/create_instance_request.py +unikraft_cloud_platform/models/create_instance_request_env.py +unikraft_cloud_platform/models/create_instance_request_scale_to_zero.py +unikraft_cloud_platform/models/create_instance_request_service_group.py +unikraft_cloud_platform/models/create_instance_request_service_group_domains_inner.py +unikraft_cloud_platform/models/create_instance_request_volumes_inner.py +unikraft_cloud_platform/models/create_services200_response.py +unikraft_cloud_platform/models/create_services200_response_data.py +unikraft_cloud_platform/models/create_services200_response_data_service_groups_inner.py +unikraft_cloud_platform/models/create_services200_response_data_service_groups_inner_domains_inner.py +unikraft_cloud_platform/models/create_services200_response_data_service_groups_inner_domains_inner_certificate.py +unikraft_cloud_platform/models/create_services_request.py +unikraft_cloud_platform/models/create_services_request_services_inner.py +unikraft_cloud_platform/models/create_services_request_services_inner_domains_inner.py +unikraft_cloud_platform/models/create_services_request_services_inner_domains_inner_certificate.py +unikraft_cloud_platform/models/create_volumes200_response.py +unikraft_cloud_platform/models/create_volumes200_response_data.py +unikraft_cloud_platform/models/create_volumes200_response_data_volumes_inner.py +unikraft_cloud_platform/models/create_volumes_request_inner.py +unikraft_cloud_platform/models/delete_autoscale_configs200_response.py +unikraft_cloud_platform/models/delete_autoscale_configs200_response_data.py +unikraft_cloud_platform/models/delete_autoscale_configs200_response_data_service_groups_inner.py +unikraft_cloud_platform/models/delete_autoscale_policies200_response.py +unikraft_cloud_platform/models/delete_autoscale_policies200_response_data.py +unikraft_cloud_platform/models/delete_autoscale_policies200_response_data_policies_inner.py +unikraft_cloud_platform/models/delete_autoscale_policy_by_service_uuid_and_policy_name200_response.py +unikraft_cloud_platform/models/delete_autoscale_policy_by_service_uuid_and_policy_name200_response_data.py +unikraft_cloud_platform/models/delete_certificate_by_uuid200_response.py +unikraft_cloud_platform/models/delete_certificate_by_uuid200_response_data.py +unikraft_cloud_platform/models/delete_certificates200_response.py +unikraft_cloud_platform/models/delete_certificates200_response_data.py +unikraft_cloud_platform/models/delete_certificates200_response_data_certificates_inner.py +unikraft_cloud_platform/models/delete_certificates_request_inner.py +unikraft_cloud_platform/models/delete_instances200_response.py +unikraft_cloud_platform/models/delete_instances200_response_data.py +unikraft_cloud_platform/models/delete_instances200_response_data_instances_inner.py +unikraft_cloud_platform/models/delete_instances_request_inner.py +unikraft_cloud_platform/models/delete_services200_response.py +unikraft_cloud_platform/models/delete_services200_response_data.py +unikraft_cloud_platform/models/delete_services200_response_data_service_groups_inner.py +unikraft_cloud_platform/models/delete_services_request_inner.py +unikraft_cloud_platform/models/delete_volumes200_response.py +unikraft_cloud_platform/models/delete_volumes_request_inner.py +unikraft_cloud_platform/models/get_autosacle_policies200_response.py +unikraft_cloud_platform/models/get_autosacle_policies200_response_data.py +unikraft_cloud_platform/models/get_autosacle_policies_request_inner.py +unikraft_cloud_platform/models/get_autoscale_configs200_response.py +unikraft_cloud_platform/models/get_autoscale_configs200_response_data.py +unikraft_cloud_platform/models/get_autoscale_configs_request_inner.py +unikraft_cloud_platform/models/get_autoscale_policy_by_service_uuid_and_policy_name200_response.py +unikraft_cloud_platform/models/get_autoscale_policy_by_service_uuid_and_policy_name200_response_data.py +unikraft_cloud_platform/models/get_certificate_by_uuid200_response.py +unikraft_cloud_platform/models/get_certificate_by_uuid200_response_data.py +unikraft_cloud_platform/models/get_certificates200_response.py +unikraft_cloud_platform/models/get_certificates200_response_data.py +unikraft_cloud_platform/models/get_certificates_default_response.py +unikraft_cloud_platform/models/get_certificates_default_response_errors_inner.py +unikraft_cloud_platform/models/get_certificates_request_inner.py +unikraft_cloud_platform/models/get_images200_response.py +unikraft_cloud_platform/models/get_images200_response_data.py +unikraft_cloud_platform/models/get_images_request_inner.py +unikraft_cloud_platform/models/get_instance_by_uuid200_response.py +unikraft_cloud_platform/models/get_instance_by_uuid200_response_data.py +unikraft_cloud_platform/models/get_instance_logs200_response.py +unikraft_cloud_platform/models/get_instance_logs200_response_data.py +unikraft_cloud_platform/models/get_instance_logs200_response_data_instances_inner.py +unikraft_cloud_platform/models/get_instance_logs200_response_data_instances_inner_available.py +unikraft_cloud_platform/models/get_instance_logs200_response_data_instances_inner_range.py +unikraft_cloud_platform/models/get_instance_logs_request_inner.py +unikraft_cloud_platform/models/get_instance_metrics200_response.py +unikraft_cloud_platform/models/get_instance_metrics200_response_data.py +unikraft_cloud_platform/models/get_instance_metrics_request_inner.py +unikraft_cloud_platform/models/get_instances200_response.py +unikraft_cloud_platform/models/get_instances200_response_data.py +unikraft_cloud_platform/models/get_instances_request_inner.py +unikraft_cloud_platform/models/get_quota_by_uuid200_response.py +unikraft_cloud_platform/models/get_quota_by_uuid200_response_data.py +unikraft_cloud_platform/models/get_quotas200_response.py +unikraft_cloud_platform/models/get_quotas200_response_data.py +unikraft_cloud_platform/models/get_service_by_uuid200_response.py +unikraft_cloud_platform/models/get_service_by_uuid200_response_data.py +unikraft_cloud_platform/models/get_services200_response.py +unikraft_cloud_platform/models/get_services200_response_data.py +unikraft_cloud_platform/models/get_services200_response_data_service_groups_inner.py +unikraft_cloud_platform/models/get_services200_response_data_service_groups_inner_instances_inner.py +unikraft_cloud_platform/models/get_services_request_inner.py +unikraft_cloud_platform/models/get_volumes200_response.py +unikraft_cloud_platform/models/get_volumes200_response_data.py +unikraft_cloud_platform/models/get_volumes_request_inner.py +unikraft_cloud_platform/models/image.py +unikraft_cloud_platform/models/instance.py +unikraft_cloud_platform/models/instance_metrics.py +unikraft_cloud_platform/models/instance_network_interfaces_inner.py +unikraft_cloud_platform/models/instance_restart.py +unikraft_cloud_platform/models/instance_service_group.py +unikraft_cloud_platform/models/instance_service_group_domains_inner.py +unikraft_cloud_platform/models/instance_service_group_domains_inner_certificate.py +unikraft_cloud_platform/models/instance_snapshot.py +unikraft_cloud_platform/models/service.py +unikraft_cloud_platform/models/service_mapping.py +unikraft_cloud_platform/models/start_instances200_response.py +unikraft_cloud_platform/models/start_instances200_response_data.py +unikraft_cloud_platform/models/start_instances200_response_data_instances_inner.py +unikraft_cloud_platform/models/start_instances_request_inner.py +unikraft_cloud_platform/models/stop_instances_request_inner.py +unikraft_cloud_platform/models/user_quota.py +unikraft_cloud_platform/models/user_quota_limits.py +unikraft_cloud_platform/models/user_quota_used.py +unikraft_cloud_platform/models/volume.py +unikraft_cloud_platform/models/volume_attached_to_inner.py +unikraft_cloud_platform/models/volume_mounted_by_inner.py +unikraft_cloud_platform/models/wait_for_instances200_response.py +unikraft_cloud_platform/models/wait_for_instances200_response_data.py +unikraft_cloud_platform/models/wait_for_instances200_response_data_instances_inner.py +unikraft_cloud_platform/models/wait_for_instances_request_inner.py +unikraft_cloud_platform/rest.py diff --git a/.openapi-generator/VERSION b/.openapi-generator/VERSION new file mode 100644 index 0000000..6328c54 --- /dev/null +++ b/.openapi-generator/VERSION @@ -0,0 +1 @@ +7.17.0 diff --git a/.platform-config.yaml b/.platform-config.yaml deleted file mode 100644 index f29ec1d..0000000 --- a/.platform-config.yaml +++ /dev/null @@ -1,4 +0,0 @@ -project_name_override: unikraft-cloud-platform -package_name_override: unikraft_cloud_platform -literal_enums: true -docstrings_on_attributes: true diff --git a/Makefile b/Makefile index f64efa0..b73c7d7 100644 --- a/Makefile +++ b/Makefile @@ -4,13 +4,15 @@ # You may not use this file except in compliance with the License. # Prelude -WORKDIR ?= $(CURDIR) -Q ?= @ -CHANNEL ?= prod-stable +WORKDIR ?= $(CURDIR) +Q ?= @ +CHANNEL ?= prod-stable # Tools -WGET ?= wget -UV ?= uv +WGET ?= wget +DOCKER ?= docker +OPENAPI_GEN_VERSION ?= v7.17.0 +UV ?= uv .PHONY: all all: generate @@ -19,12 +21,25 @@ all: generate generate: platform .PHONY: platform -platform: - $(Q)rm -rf $(WORKDIR)/unikraft_cloud_platform - $(Q)$(UV) tool run openapi-python-client generate \ - --url https://raw.githubusercontent.com/unikraft-cloud/openapi/$(CHANNEL)/platform.json \ - --config $(WORKDIR)/.platform-config.yaml \ - --custom-template-path $(WORKDIR)/templates \ - --overwrite \ - --output-path $(WORKDIR) \ - --meta uv \ +platform: platform.json + $(Q)rm -rf $(WORKDIR)/unikraft_cloud_platform/ + $(Q)$(DOCKER) run \ + --rm \ + --volume "$(WORKDIR):/local" \ + --user="$(shell id -u):$(shell id -g)" \ + openapitools/openapi-generator-cli:$(OPENAPI_GEN_VERSION) generate \ + --generator-name python \ + --input-spec /local/platform.json \ + --config /local/config.yaml \ + --template-dir /local/templates \ + --output /local \ + --git-repo-id unikraft-cloud \ + --git-user-id python-sdk \ + $(OPENAPI_GENERATOR_EXTRA_OPTIONS) + +platform.json: + $(Q)$(WGET) -O $@ https://raw.githubusercontent.com/unikraft-cloud/openapi/$(CHANNEL)/platform.json + +.PHONY: fmt +fmt: + $(Q)$(UV) format \ No newline at end of file diff --git a/config.yaml b/config.yaml new file mode 100644 index 0000000..beed30e --- /dev/null +++ b/config.yaml @@ -0,0 +1,21 @@ +generatorName: python +packageName: unikraft_cloud_platform +projectName: unikraft-cloud-platform +packageVersion: 0.6.0 +gitRepoId: python-sdk +gitUserId: unikraft-cloud + +additionalProperties: + library: urllib3 + packageName: unikraft_cloud_platform + projectName: unikraft-cloud-platform + packageVersion: 0.6.0 + +globalProperties: + models: "" + apis: "" + modelTests: "false" + modelDocs: "false" + apiTests: "false" + apiDocs: "false" + supportingFiles: __init__.py,configuration.py,api_client.py,exceptions.py,rest.py,api_response.py diff --git a/platform.json b/platform.json new file mode 100644 index 0000000..beb3fc9 --- /dev/null +++ b/platform.json @@ -0,0 +1,7450 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "Unikraft Cloud Platform", + "version": "0.6.0", + "description": "This is the API of the Unikraft Cloud Platform.\n", + "license": { + "name": "UNLICENSED", + "url": "https://unikraft.cloud/company/terms" + }, + "contact": { + "name": "Unikraft Cloud Support", + "email": "info@unikraft.cloud", + "url": "https://unikraft.cloud/contact" + } + }, + "servers": [ + { + "url": "https://api.{metro}.kraft.cloud/v1", + "description": "The Unikraft Cloud Platform API server", + "variables": { + "metro": { + "default": "fra0", + "enum": [ + "fra0", + "sin0", + "dal0", + "was1" + ] + } + } + } + ], + "components": { + "schemas": { + "certificate": { + "type": "object", + "description": "SSL Certificate.\n", + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "failure" + ], + "example": "success", + "description": "The status of the response.\n\nNote: Not when listing all existing certificates.\n" + }, + "uuid": { + "type": "string", + "format": "uuid", + "maxLength": 36, + "example": "471a2a73-36db-4df9-bb63-82a45810e88a", + "description": "The UUID of the certificate.\n" + }, + "name": { + "type": "string", + "format": "basename", + "maxLength": 255, + "example": "my-certificate", + "description": "The name of the certificate.\n" + }, + "created_at": { + "type": "string", + "maxLength": 8388608, + "format": "date-time", + "example": "2021-09-01T12:00:00Z", + "description": "Date and time of creation in ISO8601.\n" + }, + "common_name": { + "type": "string", + "format": "basename", + "maxLength": 255, + "example": "example.com", + "description": "Common name (CN) of the certificate.\n" + }, + "state": { + "type": "string", + "enum": [ + "valid", + "pending", + "error" + ], + "example": "valid", + "description": "Current state of the certificate.\n\nA certificate can be in one of the following states:\n\nState | Description\n----------|------------\n`pending` | The certificate request is pending while the certificate is being requested from the certification authority. During this phase any service using this certificate is not available if this is not a renewal.\n`valid` | The certificate is valid and can be used for services.\n`error` | The certificate request failed after multiple attempts. This can happen, for example, if your DNS configuration is not correct, you run into Let’s Encrypt™ quota limits, or the domain validation process failed for some other reason. There won’t be any further automatic attempts. If you need assistence please contact us via [support@unikraft.cloud](mailto:support@unikraft.cloud).\n" + }, + "validation": { + "type": "object", + "description": "Validation status (only while `pending`).\n", + "properties": { + "attempt": { + "type": "integer", + "format": "int32", + "example": 3, + "minimum": 0, + "maximum": 255, + "description": "Number of validation attempts made.\n" + }, + "next": { + "type": "string", + "maxLength": 8388608, + "format": "date-time", + "example": "2021-09-01T12:00:00Z", + "description": "Date and time of the next validation attempt in ISO8601.\n" + } + } + }, + "subject": { + "type": "string", + "maxLength": 8388608, + "pattern": "^[a-zA-Z]+?=(?:(?![a-zA-Z]+?=.*?).)*$", + "example": "CN=example.com", + "description": "Certificate subject.\n" + }, + "issuer": { + "type": "string", + "maxLength": 8388608, + "pattern": "^([a-zA-Z]+?=(?:(?![a-zA-Z]+?=.*?).)*,*)*$", + "example": "CN=R3,O=Let's Encrypt,C=US", + "description": "Certificate issuer.\n" + }, + "serial_number": { + "type": "string", + "maxLength": 8388608, + "pattern": "^[0-9a-fA-F]{1,64}$", + "example": "1A2B3C4D5E6F7A8B9C0D1E2F3A4B5C6D7E8F", + "description": "Certificate serial number.\n" + }, + "not_before": { + "type": "string", + "maxLength": 8388608, + "format": "date-time", + "example": "2021-09-01T12:00:00Z", + "description": "Date and time of beginning of validity in ISO8601.\n" + }, + "not_after": { + "type": "string", + "maxLength": 8388608, + "format": "date-time", + "example": "2022-09-01T12:00:00Z", + "description": "Expiration date and time in ISO8601.\n" + }, + "service_groups": { + "type": "array", + "maxItems": 253, + "description": "Services using this certificate.\n", + "items": { + "type": "object", + "properties": { + "uuid": { + "type": "string", + "maxLength": 36, + "format": "uuid", + "description": "The UUID of the service.\n", + "example": "471a2a73-36db-4df9-bb63-82a45810e88a" + }, + "name": { + "type": "string", + "maxLength": 255, + "format": "basename", + "description": "The name of the service.\n", + "example": "young-monkey-uq6dxq0u" + } + } + } + } + } + }, + "image": { + "type": "object", + "properties": { + "digest": { + "type": "string", + "maxLength": 8388608, + "example": "my_platform_user/myapp@sha256:c4c2919c4c2919c4c2919f03db26", + "pattern": "^[a-zA-Z_0-9]+[a-zA-Z_0-9]+((:|@sha256:)[a-zA-Z_0-9]+)?$", + "description": "Image digest to uniquely identify this image.\n" + }, + "tags": { + "type": "array", + "maxItems": 253, + "minItems": 0, + "description": "Tags referencing this image.", + "items": { + "type": "string", + "maxLength": 8388608, + "example": "v1", + "pattern": "^[a-zA-Z_0-9]+$" + } + }, + "initrd": { + "type": "boolean", + "example": true, + "description": "Indicates if the image comes with an init ramdisk.\n" + }, + "size_in_bytes": { + "type": "integer", + "format": "int32", + "minimum": 0, + "maximum": 9223372036854775807, + "example": 123456789, + "description": "Total size of the image on disk in bytes including the initrd, if any.\n" + }, + "args": { + "type": "string", + "maxLength": 8388608, + "pattern": "^([a-zA-Z0-9=_-]+ *)*$", + "example": "-c /etc/myapp/myapp.conf", + "description": "Default application arguments of the image.\nDismissed if the instance specifies application arguments.\n" + }, + "kernel_args": { + "type": "string", + "maxLength": 8388608, + "pattern": "^([a-zA-Z0-9=_-]+ *)*$", + "example": "console=ttyS0", + "description": "Unikraft kernel arguments hardcoded into the image.\nPrepended to the kernel arguments set by Unikraft Cloud.\n" + }, + "labels": { + "type": "object", + "maxProperties": 253, + "example": { + "mylabel": "myvalue" + }, + "description": "Key value pairs of image labels (e.g., used as defaults for instance configuration).\n", + "additionalProperties": { + "maxProperties": 253, + "type": "string", + "maxLength": 8388608, + "pattern": "^.+$" + } + } + } + }, + "instance": { + "type": "object", + "description": "An application instance.\n", + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "error" + ], + "example": "success", + "description": "The status of the response.\n\nNote: Not when listing all existing instances.\n" + }, + "uuid": { + "type": "string", + "maxLength": 36, + "format": "uuid", + "example": "471a2a73-36db-4df9-bb63-82a45810e88a", + "description": "The UUID of the instance.\n" + }, + "name": { + "type": "string", + "maxLength": 255, + "format": "basename", + "example": "young-monkey-uq6dxq0u", + "description": "The name of the instance.\nThe instance will receive a DNS entry in your private network of the form `.internal`.\n\nNote: If no name is specified a random name of the form `-X` is auto-generated, where `` is the application name taken from `image` (e.g., `myapp` for `../myapp:latest`) and `X` is a 5 character long random alphanumeric suffix.\n" + }, + "created_at": { + "type": "string", + "maxLength": 8388608, + "format": "date-time", + "example": "2021-09-01T12:00:00Z", + "description": "Date and time of creation in ISO8601.\n" + }, + "state": { + "type": "string", + "enum": [ + "stopped", + "starting", + "running", + "draining", + "stopping", + "standby" + ], + "example": "running", + "description": "An instance can be in one of the following states:\n\nState | Description\n----------|------------\n`stopped` | The instance is not running and does not count against live resource quotas. Connections cannot be established.\n`starting`| The instance is booting up. This usually takes just a few milliseconds.\n`running` | Your application's main entry point has been reached.\n`draining`| The instance is draining connections before shutting down. No new connections can be established.\n`stopping`| The instance is shutting down.\n`standby` | The instance has [scale-to-zero](https://unikraft.cloud/docs/api/v1/autoscale#scaletozero) enabled. The instance is not running, but will be automatically started when there are incoming requests.\n" + }, + "image": { + "type": "string", + "maxLength": 8388608, + "pattern": "^(?:(?=[^:\\/]{1,253})(?!-)[a-zA-Z0-9-]{1,63}(?.fra0.kraft.host`.\n", + "items": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "name": { + "type": "string", + "maxLength": 255, + "format": "hostname", + "example": "my-instance", + "description": "Publicly accessible domain name.\n\nNote: The services published by the service will be accessible under the given domain names.\nIf `name` is a fully-qualified domain name, that is it ends with a dot (`.`), the domain name is taken as-is.\nOtherwise, the metro’s domain name is appended (e.g., `my-project` expands to `my-project.fra0.kraft.host`).\nIf the given domain name is already in use by the current or a different user the operation fails.\nIn addition, certain domain names cannot be used (e.g., `www.fra0.kraft.host`).\n" + }, + "certificate": { + "type": "object", + "oneOf": [ + { + "required": [ + "uuid" + ] + }, + { + "required": [ + "name" + ] + } + ], + "description": "TLS certificate to use for the domain.\n\nNote: Only allowed for FQDNs, not for subdomains.\nSubdomains like `my-project` inherit the wildcard `*..kraft.host` certificate.\nIf you specify an FQDN like `www.example.com`, Unikraft Cloud will automatically pick the certificate with the matching CN or trigger a certificate request (see [here](https://unikraft.cloud/docs/api/v1/certificates)).\n", + "properties": { + "uuid": { + "type": "string", + "maxLength": 36, + "format": "uuid", + "description": "UUID of the certificate", + "example": "471a2a73-36db-4df9-bb63-82a45810e88a" + }, + "name": { + "type": "string", + "maxLength": 255, + "format": "basename", + "description": "Name of the certificate", + "example": "my-certificate" + } + } + } + } + } + } + } + }, + "volumes": { + "type": "array", + "maxItems": 253, + "description": "Description of [volumes](https://unikraft.cloud/docs/api/v1/volumes).\n", + "items": { + "type": "object", + "oneOf": [ + { + "required": [ + "uuid", + "at" + ] + }, + { + "required": [ + "name", + "at" + ] + } + ], + "properties": { + "uuid": { + "type": "string", + "maxLength": 36, + "format": "uuid", + "example": "471a2a73-36db-4df9-bb63-82a45810e88a", + "description": "UUID of an existing volume.\nMust be in `available` [state](https://unikraft.cloud/docs/api/v1/volumes#states).\n" + }, + "name": { + "type": "string", + "maxLength": 255, + "format": "basename", + "example": "my-volume", + "description": "The name of the volume to attach.\n\nNote: You need to specify either `uuid`, `name`, or `size_mb`.\nSpecifying `size_mb` will create a new [volume](https://unikraft.cloud/docs/api/v1/volumes) and attach it to the instance.\nThe volume will receive an auto-generated name.\n" + }, + "at": { + "type": "string", + "maxLength": 8388608, + "pattern": "^(/[ a-zA-Z0-9._-]*)*$", + "example": "/home/user", + "description": "Path of the mountpoint.\nMust be empty.\nAutomatically created if it does not exist.\n" + }, + "readonly": { + "type": "boolean", + "default": false, + "example": false, + "description": "Whether the volume should be mounted read-only.\n" + } + } + } + }, + "network_interfaces": { + "type": "array", + "maxItems": 253, + "description": "List of network interfaces attached to the instance.\n", + "items": { + "type": "object", + "properties": { + "uuid": { + "type": "string", + "maxLength": 36, + "format": "uuid", + "example": "471a2a73-36db-4df9-bb63-82a45810e88a", + "description": "The UUID of the network interface.\n" + }, + "private_ip": { + "type": "string", + "maxLength": 15, + "format": "ipv4", + "example": "172.16.19.23", + "description": "Private IPv4 of network interface.\n" + }, + "mac": { + "type": "string", + "maxLength": 17, + "pattern": "^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$", + "example": "00:00:5e:00:53:01", + "description": "MAC address of the network interface.\n" + }, + "rx_bytes": { + "type": "integer", + "format": "int64", + "example": 123456, + "minimum": 0, + "maximum": 9223372036854775807, + "description": "Amount of bytes received from interface.\n\nNote: Only with `metrics=true` query parameter.\n" + }, + "rx_packets": { + "type": "integer", + "format": "int64", + "example": 123456, + "minimum": 0, + "maximum": 9223372036854775807, + "description": "Count of packets received from interface.\n\nNote: Only with `metrics=true` query parameter.\n" + }, + "tx_bytes": { + "type": "integer", + "format": "int64", + "example": 123456, + "minimum": 0, + "maximum": 9223372036854775807, + "description": "Amount of bytes transmitted over interface.\n\nNote: Only with `metrics=true` query parameter.\n" + }, + "tx_packets": { + "type": "integer", + "format": "int64", + "example": 123456, + "minimum": 0, + "maximum": 9223372036854775807, + "description": "Count of packets transmitted over interface.\n\nNote: Only with `metrics=true` query parameter.\n" + } + } + } + } + } + }, + "instance_metrics": { + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "error" + ], + "example": "success", + "description": "The status of the response.\n" + }, + "uuid": { + "type": "string", + "maxLength": 36, + "format": "uuid", + "example": "471a2a73-36db-4df9-bb63-82a45810e88a", + "description": "The UUID of the instance.\n" + }, + "name": { + "type": "string", + "maxLength": 255, + "format": "basename", + "example": "young-monkey-uq6dxq0u", + "description": "The name of the instance.\n" + }, + "rss_bytes": { + "type": "integer", + "format": "int64", + "example": 123456789, + "minimum": 0, + "maximum": 9223372036854775807, + "description": "Resident set size of the VMM in bytes.\n\nNote: The resident set size (RSS) specifies the amount of physical memory that has been touched by the instance and is currently reserved for the instance on the Unikraft Cloud server.\nThe RSS grows until the instance has touched all memory assigned to it via the `memory_mb` setting and may also exceed this value as supporting services running outside the instance acquire memory.\nThe RSS is different from the current amount of memory allocated by the application, which is likely to fluctuate over the lifetime of the application.\nThe RSS is not a cumulative metric.\nWhen the instance is stopped `rss` goes down to 0.\n" + }, + "cpu_time_ms": { + "type": "integer", + "format": "int64", + "example": 230, + "minimum": 0, + "maximum": 9223372036854775807, + "description": "Consumed CPU time in milliseconds.\n" + }, + "rx_bytes": { + "type": "integer", + "format": "int64", + "example": 431412, + "minimum": 0, + "maximum": 9223372036854775807, + "description": "Total amount of bytes received from network.\n" + }, + "rx_packets": { + "type": "integer", + "format": "int64", + "example": 1233, + "minimum": 0, + "maximum": 9223372036854775807, + "description": "Total count of packets received from network.\n" + }, + "tx_bytes": { + "type": "integer", + "format": "int64", + "example": 432432, + "minimum": 0, + "maximum": 9223372036854775807, + "description": "Total amount of bytes transmitted over network.\n" + }, + "tx_packets": { + "type": "integer", + "format": "int64", + "example": 431412, + "minimum": 0, + "maximum": 9223372036854775807, + "description": "Total count of packets transmitted over network.\n" + }, + "nconns": { + "type": "integer", + "format": "int32", + "example": 2424, + "minimum": 0, + "maximum": 65535, + "description": "Number of currently established inbound connections (non-HTTP).\n" + }, + "nreqs": { + "type": "integer", + "format": "int32", + "example": 1235, + "minimum": 0, + "maximum": 65535, + "description": "Number of in-flight HTTP requests.\n" + }, + "nqueued": { + "type": "integer", + "format": "int32", + "example": 12353, + "minimum": 0, + "maximum": 65535, + "description": "Number of queued inbound connections and HTTP requests.\n" + }, + "ntotal": { + "type": "integer", + "format": "int64", + "example": 43431, + "minimum": 0, + "maximum": 9223372036854775807, + "description": "Total number of inbound connections and HTTP requests handled.\n" + } + } + }, + "service": { + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "error" + ], + "description": "The status of the response.\n" + }, + "uuid": { + "type": "string", + "maxLength": 36, + "format": "uuid", + "description": "The UUID of the service.\n", + "example": "471a2a73-36db-4df9-bb63-82a45810e88a" + }, + "name": { + "type": "string", + "maxLength": 255, + "format": "basename", + "description": "The name of the service.\n", + "example": "my-service" + }, + "created_at": { + "type": "string", + "maxLength": 8388608, + "format": "date-time", + "description": "Date and time of creation in ISO8601.\n", + "example": "2021-01-01T00:00:00Z" + }, + "persistent": { + "type": "boolean", + "description": "Indicates if the service will stay alive even after the last instance detached.\n", + "example": true + }, + "autoscale": { + "type": "boolean", + "description": "Indicates if the service has [autoscale](https://unikraft.cloud/docs/api/v1/autoscale) enabled.\n", + "example": true + }, + "soft_limit": { + "type": "integer", + "format": "int32", + "description": "Per-instance connection [soft limit](https://unikraft.cloud/docs/api/v1/services/#limits).\n", + "example": 1, + "minimum": 1, + "maximum": 65535 + }, + "hard_limit": { + "type": "integer", + "format": "int32", + "description": "Per-instance connection [hard limit](https://unikraft.cloud/docs/api/v1/services/#limits).\n", + "example": 65535, + "minimum": 1, + "maximum": 65535 + }, + "services": { + "type": "array", + "maxItems": 253, + "description": "Description of published network services.\n", + "items": { + "$ref": "#/components/schemas/service_mapping" + } + }, + "domains": { + "type": "array", + "maxItems": 253, + "items": { + "type": "object", + "properties": { + "fqdn": { + "type": "string", + "maxLength": 255, + "format": "hostname", + "description": "Public fully-qualified domain name under which the service is accessible from the Internet.\n", + "example": "my-project.fra0.unikraft.app" + }, + "certificate": { + "$ref": "#/components/schemas/certificate" + } + } + } + }, + "instances": { + "type": "array", + "maxItems": 253, + "description": "Instances attached to this service", + "items": { + "type": "object", + "properties": { + "uuid": { + "type": "string", + "maxLength": 36, + "format": "uuid", + "description": "The UUID of the instance.\n", + "example": "471a2a73-36db-4df9-bb63-82a45810e88a" + }, + "name": { + "type": "string", + "maxLength": 255, + "format": "basename", + "description": "The name of the instance.\n", + "example": "my-instance" + } + } + } + } + } + }, + "service_mapping": { + "type": "object", + "required": [ + "port" + ], + "properties": { + "port": { + "type": "integer", + "format": "int32", + "description": "Public-facing port.\n", + "example": 8080, + "minimum": 1, + "maximum": 65535 + }, + "destination_port": { + "type": "integer", + "format": "int32", + "description": "Application port to which inbound traffic is redirected.\n", + "example": 8080, + "minimum": 1, + "maximum": 65535 + }, + "handlers": { + "type": "array", + "maxItems": 253, + "description": "See [Connection Handlers](https://unikraft.cloud/docs/api/v1/services/#handlers).\n", + "items": { + "type": "string", + "enum": [ + "tls", + "http", + "redirect" + ], + "example": "tls", + "description": "Unikraft Cloud uses connection handlers to decide how to forward connections from the Internet to your application.\nYou configure the handlers for every published service port individually.\nThe following handlers are available:\n\nHandler | Description\n----------|------------\n`tls` | Terminate the TLS connection at the Unikraft Cloud gateway using our wildcard certificate issued for the `kraft.cloud` domain. The gateway forwards the unencrypted traffic to your application\n`http` | Enable HTTP mode on the load balancer to load balance on the level of individual HTTP requests. In this mode, only HTTP connections are accepted. If this option is not set the load balancer works in TCP mode and balances TCP connections\n`redirect`| Redirect traffic from the source port to the destination port\n\nCurrently, there is a set of constraints when publishing ports:\n* Port 80: Must have `http` and must not have `tls` set\n* Port 443: Must have `http` and `tls` set\n* The `redirect` handler can only be set on port 80 (HTTP) to redirect to port 443 (HTTPS)\n* All other ports must have `tls` and must not have `http` set\n" + } + } + } + }, + "autoscale_config": { + "type": "object", + "properties": { + "status": { + "type": "string", + "maxLength": 12, + "description": "`success` on success, `unconfigured` if autoscale is not configured, or `error` if the request failed.\n", + "enum": [ + "success", + "unconfigured", + "failure" + ], + "example": "success" + }, + "uuid": { + "type": "string", + "maxLength": 36, + "format": "uuid", + "example": "471a2a73-36db-4df9-bb63-82a45810e88a", + "description": "The UUID of the service.\n" + }, + "name": { + "type": "string", + "maxLength": 255, + "format": "basename", + "example": "my-service", + "description": "The name of the service.\n" + }, + "enabled": { + "type": "boolean", + "example": true, + "description": "Whether autoscale is enabled.\n" + }, + "min_size": { + "type": "integer", + "format": "int32", + "example": 1, + "minimum": 1, + "maximum": 1, + "description": "Minimum number of instances.\n" + }, + "max_size": { + "type": "integer", + "format": "int32", + "example": 4, + "minimum": 1, + "maximum": 2147483647, + "description": "Maximum number of instances.\nMaximum number is determined by the quota.\n" + }, + "warmup_time_ms": { + "type": "integer", + "format": "int32", + "example": 1000, + "minimum": 1, + "maximum": 2147483647, + "description": "Length of [warmup phase](https://unikraft.cloud/docs/api/v1/autoscale/#warmup-and-cooldown) in milliseconds.\n" + }, + "cooldown_time_ms": { + "type": "integer", + "format": "int32", + "example": 1000, + "minimum": 1, + "maximum": 2147483647, + "description": "Length of [cooldown phase](https://unikraft.cloud/docs/api/v1/autoscale/#warmup-and-cooldown) in milliseconds.\n" + }, + "master": { + "type": "object", + "properties": { + "uuid": { + "type": "string", + "maxLength": 36, + "format": "uuid", + "example": "471a2a73-36db-4df9-bb63-82a45810e88a", + "description": "The UUID of instance to use as [autoscale master](https://unikraft.cloud/docs/api/v1/autoscale/#autoscale-basics).\n" + }, + "name": { + "type": "string", + "maxLength": 255, + "format": "basename", + "example": "my-instance", + "description": "The name of instance to use as [autoscale master](https://unikraft.cloud/docs/api/v1/autoscale/#autoscale-basics).\n" + } + } + }, + "policies": { + "type": "array", + "maxItems": 253, + "items": { + "$ref": "#/components/schemas/autoscale_policy" + } + } + } + }, + "autoscale_policy": { + "type": "object", + "description": "Description of [autoscale policies](https://unikraft.cloud/docs/api/v1/autoscale/#autoscale-policies).\nSee [policy creation endpoint](https://unikraft.cloud/docs/api/v1/autoscale/#policy_create).\n", + "properties": { + "name": { + "type": "string", + "maxLength": 255, + "format": "basename", + "example": "my-policy", + "description": "The name of the policy.\n" + }, + "metric": { + "type": "string", + "default": "cpu", + "enum": [ + "cpu" + ], + "example": "cpu", + "description": "Metric to monitor.\n" + }, + "type": { + "type": "string", + "enum": [ + "step" + ], + "example": "step", + "description": "Type of autoscale policy.\n" + }, + "adjustment_type": { + "type": "string", + "default": "change", + "enum": [ + "change", + "exact", + "percent" + ], + "example": "change", + "description": "Type of adjustment.\n" + }, + "steps": { + "type": "array", + "maxItems": 253, + "items": { + "$ref": "#/components/schemas/autoscale_policy_step" + } + } + } + }, + "autoscale_policy_step": { + "type": "object", + "description": "Step policy.\n\nNote: Only one of `lower_bound` and `upper_bound` can be `null` or not specified.\nSee the description of the step policy for more information on defining steps.\n", + "properties": { + "lower_bound": { + "type": "integer", + "format": "int32", + "example": 0, + "minimum": -2147483647, + "maximum": 2147483647, + "description": "Lower bound of the step range.\nIn dimension of selected metric.\n" + }, + "upper_bound": { + "type": "integer", + "format": "int32", + "example": 100, + "minimum": -2147483647, + "maximum": 2147483647, + "description": "Upper bound of the step range.\nIn dimension of selected metric.\n" + }, + "adjustment": { + "type": "integer", + "format": "int32", + "example": 1, + "minimum": -2147483647, + "maximum": 2147483647, + "description": "Adjustment to take if metric is in range.\n" + } + } + }, + "user_quota": { + "type": "object", + "properties": { + "used": { + "$ref": "#/components/schemas/user_quota_used" + }, + "hard": { + "$ref": "#/components/schemas/user_quota_hard" + }, + "limits": { + "$ref": "#/components/schemas/user_quota_limits" + } + } + }, + "user_quota_used": { + "type": "object", + "description": "Used quota.\n", + "properties": { + "instances": { + "type": "integer", + "format": "int32", + "example": 2, + "minimum": 0, + "maximum": 2147483647, + "description": "Number of created instances.\n" + }, + "live_instances": { + "type": "integer", + "format": "int32", + "example": 1, + "minimum": 0, + "maximum": 2147483647, + "description": "Number of instances that are not in the `stopped` state.\n" + }, + "live_memory_mb": { + "type": "integer", + "format": "int32", + "example": 1024, + "minimum": 0, + "maximum": 2147483647, + "description": "Amount of memory assigned to instances that are not in the `stopped` state in megabytes.\n" + }, + "service_groups": { + "type": "integer", + "format": "int32", + "example": 253, + "minimum": 0, + "maximum": 2147483647, + "description": "Number of services.\n" + }, + "services": { + "type": "integer", + "format": "int32", + "example": 253, + "minimum": 0, + "maximum": 2147483647, + "description": "Number of published network ports over all existing services.\n" + }, + "volumes": { + "type": "integer", + "format": "int32", + "example": 16, + "minimum": 0, + "maximum": 2147483647, + "description": "Number of volumes.\n" + }, + "total_volume_mb": { + "type": "integer", + "format": "int32", + "example": 16384, + "minimum": 0, + "maximum": 1048576, + "description": "Total size of all volumes in megabytes.\n" + } + } + }, + "user_quota_hard": { + "type": "object", + "description": "Hard quota limits.\n", + "instances": { + "type": "integer", + "format": "int32", + "example": 2, + "minimum": 0, + "maximum": 2147483647, + "description": "Number of created instances.\n" + }, + "live_instances": { + "type": "integer", + "format": "int32", + "example": 1, + "minimum": 0, + "maximum": 2147483647, + "description": "Number of instances that are not in the `stopped` state.\n" + }, + "live_memory_mb": { + "type": "integer", + "format": "int32", + "example": 1024, + "minimum": 0, + "maximum": 2147483647, + "description": "Amount of memory assigned to instances that are not in the `stopped` state in megabytes.\n" + }, + "service_groups": { + "type": "integer", + "format": "int32", + "example": 253, + "minimum": 0, + "maximum": 2147483647, + "description": "Number of services.\n" + }, + "services": { + "type": "integer", + "format": "int32", + "example": 253, + "minimum": 0, + "maximum": 2147483647, + "description": "Number of published network ports over all existing services.\n" + }, + "volumes": { + "type": "integer", + "format": "int32", + "example": 16, + "minimum": 0, + "maximum": 2147483647, + "description": "Number of volumes.\n" + }, + "total_volume_mb": { + "type": "integer", + "format": "int32", + "example": 16384, + "minimum": 0, + "maximum": 1048576, + "description": "Total size of all volumes in megabytes.\n" + } + }, + "user_quota_limits": { + "type": "object", + "description": "Additional limits.\n", + "properties": { + "min_memory_mb": { + "type": "integer", + "format": "int32", + "example": 128, + "minimum": 16, + "maximum": 2147483647, + "description": "Minimum amount of memory assigned to live instances in megabytes.\n" + }, + "max_memory_mb": { + "type": "integer", + "format": "int32", + "example": 4096, + "minimum": 4096, + "maximum": 2147483647, + "description": "Maximum amount of memory assigned to live instances in megabytes.\n" + }, + "min_volume_mb": { + "type": "integer", + "format": "int32", + "example": 1, + "minimum": 1, + "maximum": 2147483647, + "description": "Minimum size of a volume in megabytes.\n" + }, + "max_volume_mb": { + "type": "integer", + "format": "int32", + "example": 1024, + "minimum": 1024, + "maximum": 2147483647, + "description": "Maximum size of a volume in megabytes.\n" + }, + "min_autoscale_size": { + "type": "integer", + "format": "int32", + "example": 1, + "minimum": 1, + "maximum": 2147483647, + "description": "Minimum size of an autoscale group\n\nNote: These restrict the `min_size` and `max_size` fields of the [autoscale configuration](https://unikraft.cloud/docs/api/v1/autoscale/#basics).\nIf both values are `1` autoscale is not enabled for your account.\nIf you want to explore autoscale for your services, please contact us via [support@unikraft.cloud](mailto:support@unikraft.cloud).\n" + }, + "max_autoscale_size": { + "type": "integer", + "format": "int32", + "example": 16, + "minimum": 1, + "maximum": 2147483647, + "description": "Maximum size of an autoscale group.\n\nNote: These restrict the `min_size` and `max_size` fields of the [autoscale configuration](https://unikraft.cloud/docs/api/v1/autoscale/#basics).\n" + } + } + }, + "volume": { + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "error" + ], + "example": "success", + "description": "The status of the response.\n\nNote: Not when listing all existing volumes.\n" + }, + "state": { + "type": "string", + "enum": [ + "uninitialized", + "initialized", + "available", + "idle", + "mounted", + "busy", + "error" + ], + "example": "available", + "description": "A volume can be in one of the following states:\n\nState | Description\n----------------|---\n`uninitialized` | The volume is scheduled to be created.\n`initialized` | The volume is currently created and formatted.\n`available` | The volume is healthy and available to be attached to an instance.\n`idle` | The volume is healthy and attached to an instance. It is possible to [detach](https://unikraft.cloud/docs/api/v1/volumes/#detach) it in this state.\n`mounted` | The volume is currently mounted in an instance.\n`busy` | There are maintenance tasks running on the volume.\n`error` | The volume is in an error state that needs inspection by a Unikraft Cloud engineer.\n" + }, + "uuid": { + "type": "string", + "maxLength": 36, + "format": "uuid", + "example": "471a2a73-36db-4df9-bb63-82a45810e88a", + "description": "The UUID of the volume.\n" + }, + "name": { + "type": "string", + "maxLength": 255, + "format": "basename", + "example": "my-volume", + "description": "The name of the volume.\n" + }, + "size_mb": { + "type": "integer", + "format": "int32", + "example": 1024, + "minimum": 1, + "maximum": 1048576, + "description": "Size of the volume in megabytes.\n" + }, + "attached_to": { + "type": "array", + "maxItems": 253, + "description": "List of instances that this volume is attached to.\n", + "items": { + "type": "object", + "properties": { + "uuid": { + "type": "string", + "maxLength": 36, + "format": "uuid", + "example": "471a2a73-36db-4df9-bb63-82a45810e88a", + "description": "The UUID of the instance the volume is attached to.\n" + }, + "name": { + "type": "string", + "maxLength": 255, + "format": "basename", + "example": "my-instance", + "description": "The name of the instance the volume is attached to.\n" + } + } + } + }, + "mounted_by": { + "type": "array", + "maxItems": 253, + "description": "List of instances that have this volume mounted.\n", + "items": { + "type": "object", + "properties": { + "uuid": { + "type": "string", + "maxLength": 36, + "format": "uuid", + "example": "471a2a73-36db-4df9-bb63-82a45810e88a", + "description": "The UUID of the instance.\n" + }, + "name": { + "type": "string", + "maxLength": 255, + "format": "basename", + "example": "my-instance", + "description": "The name of the instance.\n" + }, + "readonly": { + "type": "boolean", + "example": false, + "description": "Whether the volume is mounted read-only or read-write.\n" + } + } + } + }, + "persistent": { + "type": "boolean", + "description": "Indicates if the volume will stay alive when the last instance is deleted that this volume is attached to.\n" + }, + "created_at": { + "type": "string", + "maxLength": 8388608, + "format": "date-time", + "example": "2021-01-01T00:00:00Z", + "description": "Date and time of creation in ISO8601.\n" + } + } + } + }, + "securitySchemes": { + "bearerAuth": { + "description": "Unikraft Cloud personal access token.\n", + "type": "http", + "scheme": "bearer", + "bearerFormat": "base64" + } + }, + "parameters": { + "uuid": { + "name": "uuid", + "in": "path", + "required": true, + "description": "The UUID of the resource.\nThe UUID is a 36-character string that uniquely identifies the resource.\nThe UUID is returned by the API after creating a resource.\n", + "schema": { + "type": "string", + "maxLength": 36, + "format": "uuid", + "example": "471a2a73-36db-4df9-bb63-82a45810e88a" + } + }, + "name": { + "name": "name", + "in": "path", + "required": true, + "description": "The name of the resource.\nThe name is a string that identifies the resource.\nThe name is sometimes returned by the API after creating a resource.\n", + "schema": { + "type": "string", + "maxLength": 255, + "format": "basename" + } + } + } + }, + "paths": { + "/certificates": { + "post": { + "operationId": "create-certificate", + "summary": "Upload a certificate", + "description": "Create a new certificate object and upload an existing certificate chain and private key.\n", + "tags": [ + "certificates" + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "name": { + "type": "string", + "format": "basename", + "maxLength": 255, + "description": "The name of the certificate to upload.\n\nNote: If no name is specified a random name of the form `-X` is auto-generated, where `` is the common name and `X` is a 5 character long random alphanumeric suffix.\nFor wildcard domains the wildcard part is cut off.\n", + "example": "my-certificate" + }, + "cn": { + "type": "string", + "format": "basename", + "maxLength": 255, + "description": "The common name of the certificate.\n", + "example": "example.com" + }, + "chain": { + "type": "string", + "pattern": "^-----BEGIN CERTIFICATE-----.+-----END CERTIFICATE-----", + "maxLength": 8388608, + "description": "The chain of the certificate in PEM format.\n", + "example": "-----BEGIN CERTIFICATE-----MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDQ...-----END CERTIFICATE-----" + }, + "pkey": { + "type": "string", + "pattern": "^-----BEGIN PRIVATE KEY-----.+-----END PRIVATE KEY-----", + "maxLength": 8388608, + "description": "The private key of the certificate in PEM format.\n", + "example": "-----BEGIN PRIVATE KEY-----MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDQ...-----END PRIVATE KEY-----" + } + }, + "required": [ + "cn", + "chain", + "pkey" + ] + } + } + } + }, + "responses": { + "200": { + "description": "Successful response.\n", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "failure" + ], + "description": "The status of the response.\n", + "example": "success" + }, + "data": { + "type": "object", + "properties": { + "certificates": { + "type": "array", + "maxItems": 253, + "items": { + "type": "object", + "properties": { + "uuid": { + "type": "string", + "format": "uuid", + "maxLength": 36, + "description": "UUID of the certificate", + "example": "471a2a73-36db-4df9-bb63-82a45810e88a" + }, + "name": { + "type": "string", + "format": "basename", + "maxLength": 255, + "description": "Name of the certificate", + "example": "my-certificate" + } + } + } + } + } + } + } + } + } + } + }, + "default": { + "description": "Error response.\n", + "content": { + "application/json": { + "schema": { + "type": "object", + "description": "An error response from the Unikraft Cloud Platform API\n", + "required": [ + "status", + "errors" + ], + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "failure" + ], + "description": "The status of the response.\n", + "example": "success" + }, + "errors": { + "type": "array", + "items": { + "type": "object", + "properties": { + "status": { + "type": "integer", + "format": "int32", + "example": 400, + "description": "HTTP status code\n" + } + } + } + }, + "data": { + "type": "object" + } + } + } + } + } + } + } + }, + "delete": { + "operationId": "delete-certificates", + "summary": "Delete one or more certificates", + "description": "Deletes the specified certificate(s).\nFails if the certificate is still attached to a service.\nAfter this call the IDs associated with the certificate are no longer valid.\n", + "tags": [ + "certificates" + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "type": "object", + "properties": { + "uuid": { + "type": "string", + "maxLength": 36, + "format": "uuid", + "example": "471a2a73-36db-4df9-bb63-82a45810e88a", + "description": "The UUID of the certificate to delete.\n\nNote: This property is mutually exclusive with `name` and either `uuid` or `name` are required.\n" + }, + "name": { + "type": "string", + "maxLength": 255, + "format": "basename", + "example": "example.com-4i1j7", + "description": "The name of the certificate to delete.\n\nNote: This property is mutually exclusive with `uuid` and either `uuid` or `name` are required.\n" + } + } + } + } + } + } + }, + "responses": { + "200": { + "description": "Successful response.\n", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "failure" + ], + "description": "The status of the response.\n", + "example": "success" + }, + "data": { + "type": "object", + "properties": { + "certificates": { + "type": "array", + "maxItems": 253, + "items": { + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "error" + ], + "example": "success", + "description": "The status of the response.\n" + }, + "uuid": { + "type": "string", + "maxLength": 36, + "format": "uuid", + "example": "471a2a73-36db-4df9-bb63-82a45810e88a", + "description": "The UUID of the certificate.\n" + }, + "name": { + "type": "string", + "maxLength": 255, + "format": "basename", + "example": "my-certificate", + "description": "The name of the certificate.\n" + } + } + } + } + } + } + } + } + } + } + }, + "default": { + "description": "Error response.\n", + "content": { + "application/json": { + "schema": { + "type": "object", + "description": "An error response from the Unikraft Cloud Platform API\n", + "required": [ + "status", + "errors" + ], + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "failure" + ], + "description": "The status of the response.\n", + "example": "success" + }, + "errors": { + "type": "array", + "items": { + "type": "object", + "properties": { + "status": { + "type": "integer", + "format": "int32", + "example": 400, + "description": "HTTP status code\n" + } + } + } + }, + "data": { + "type": "object" + } + } + } + } + } + } + } + }, + "get": { + "operationId": "get-certificates", + "summary": "Get the status of one or more certificates", + "description": "Returns the current status and the properties of specified certificate(s).\n", + "tags": [ + "certificates" + ], + "parameters": [ + { + "name": "details", + "in": "query", + "required": false, + "schema": { + "default": true, + "type": "boolean" + }, + "description": "Whether to provide detailed status and configuration information.\n", + "example": true + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "type": "object", + "properties": { + "uuid": { + "type": "string", + "maxLength": 36, + "format": "uuid", + "example": "471a2a73-36db-4df9-bb63-82a45810e88a", + "description": "The UUID of the certificate to retrieve.\n\nNote: This property is mutually exclusive with `name` and either `uuid` or `name` are required.\n" + }, + "name": { + "type": "string", + "maxLength": 255, + "format": "basename", + "example": "example.com-4i1j7", + "description": "The name of the certificate to retrieve.\n\nNote: This property is mutually exclusive with `uuid` and either `uuid` or `name` are required.\n" + } + } + } + } + } + } + }, + "responses": { + "200": { + "description": "Successful response.\n", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "failure" + ], + "description": "The status of the response.\n", + "example": "success" + }, + "data": { + "type": "object", + "properties": { + "certificates": { + "type": "array", + "maxItems": 253, + "items": { + "$ref": "#/components/schemas/certificate" + } + } + } + } + } + } + } + } + }, + "default": { + "description": "Error response.\n", + "content": { + "application/json": { + "schema": { + "type": "object", + "description": "An error response from the Unikraft Cloud Platform API\n", + "required": [ + "status", + "errors" + ], + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "failure" + ], + "description": "The status of the response.\n", + "example": "success" + }, + "errors": { + "type": "array", + "items": { + "type": "object", + "properties": { + "status": { + "type": "integer", + "format": "int32", + "example": 400, + "description": "HTTP status code\n" + } + } + } + }, + "data": { + "type": "object" + } + } + } + } + } + } + } + } + }, + "/certificates/{uuid}": { + "parameters": [ + { + "$ref": "#/components/parameters/uuid" + } + ], + "get": { + "operationId": "get-certificate-by-uuid", + "summary": "Get the status of a certificate given its UUID", + "description": "Returns the current status and the properties of a certificate.\n", + "tags": [ + "certificates" + ], + "parameters": [ + { + "name": "details", + "in": "query", + "required": false, + "style": "form", + "schema": { + "type": "boolean", + "default": true + }, + "example": true, + "description": "Whether to provide detailed status and configuration information.\n" + } + ], + "responses": { + "200": { + "description": "Successful response.\n", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "failure" + ], + "description": "The status of the response.\n", + "example": "success" + }, + "data": { + "type": "object", + "properties": { + "certificates": { + "type": "array", + "maxItems": 1, + "items": { + "$ref": "#/components/schemas/certificate" + } + } + } + } + } + } + } + } + }, + "default": { + "description": "Error response.\n", + "content": { + "application/json": { + "schema": { + "type": "object", + "description": "An error response from the Unikraft Cloud Platform API\n", + "required": [ + "status", + "errors" + ], + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "failure" + ], + "description": "The status of the response.\n", + "example": "success" + }, + "errors": { + "type": "array", + "items": { + "type": "object", + "properties": { + "status": { + "type": "integer", + "format": "int32", + "example": 400, + "description": "HTTP status code\n" + } + } + } + }, + "data": { + "type": "object" + } + } + } + } + } + } + } + }, + "delete": { + "operationId": "delete-certificate-by-uuid", + "summary": "Delete a single certificate given its UUID", + "description": "Deletes the specified certificate.\nFails if the certificate is still attached to a service.\nAfter this call the IDs associated with the certificate are no longer valid.\n", + "tags": [ + "certificates" + ], + "responses": { + "200": { + "description": "Successful response.\n", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "failure" + ], + "description": "The status of the response.\n", + "example": "success" + }, + "data": { + "type": "object", + "properties": { + "certificates": { + "type": "array", + "maxItems": 1, + "items": { + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "error" + ], + "example": "success", + "description": "The status of the response.\n" + }, + "uuid": { + "type": "string", + "maxLength": 36, + "format": "uuid", + "example": "471a2a73-36db-4df9-bb63-82a45810e88a", + "description": "The UUID of the certificate.\n" + }, + "name": { + "type": "string", + "maxLength": 255, + "format": "basename", + "example": "my-certificate", + "description": "The name of the certificate.\n" + } + } + } + } + } + } + } + } + } + } + }, + "default": { + "description": "Error response.\n", + "content": { + "application/json": { + "schema": { + "type": "object", + "description": "An error response from the Unikraft Cloud Platform API\n", + "required": [ + "status", + "errors" + ], + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "failure" + ], + "description": "The status of the response.\n", + "example": "success" + }, + "errors": { + "type": "array", + "items": { + "type": "object", + "properties": { + "status": { + "type": "integer", + "format": "int32", + "example": 400, + "description": "HTTP status code\n" + } + } + } + }, + "data": { + "type": "object" + } + } + } + } + } + } + } + } + }, + "/images/list": { + "get": { + "operationId": "get-images", + "summary": "Get list of available images", + "description": "Retrieves all images visible to an account in OCI format.\n", + "tags": [ + "images" + ], + "parameters": [ + { + "name": "namespace", + "in": "query", + "required": false, + "schema": { + "type": "string", + "maxLength": 2048, + "pattern": "^[a-zA-Z0-9_-]+(/[a-zA-Z0-9_-]+)?$" + }, + "example": "my_platform_user/myapp", + "description": "Filter images by namespace.\n\nNote: Set the namespace to your Unikraft Cloud account name to list only your personal images.\nIt can be `official` for listing only the official ones.\nIn addition, the namespace can include the app name.\nFor example, `${UKC_USER}/myapp` to list all your `myapp` images.\n" + }, + { + "name": "tagged", + "in": "query", + "required": false, + "schema": { + "type": "boolean", + "default": false + }, + "example": false, + "description": "Whether to include only tagged images.\n" + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "type": "object", + "oneOf": [ + { + "required": [ + "digest" + ] + }, + { + "required": [ + "tagged" + ] + } + ], + "properties": { + "digest": { + "type": "string", + "maxLength": 255, + "example": "user/app@sha256:caf83482bb0a5b091b8648116a2723118c55efb2835e865d857286d7df9f2999", + "pattern": "^[a-zA-Z_0-9]+[a-zA-Z_0-9]+((:|@sha256:)[a-zA-Z_0-9]+)?$", + "description": "Image digest to lookup.\n" + }, + "tagged": { + "type": "string", + "maxLength": 8388608, + "pattern": "^[a-zA-Z0-9_-]+$", + "example": "user/app:latest", + "description": "Image tag to lookup.\n" + } + } + } + } + } + } + }, + "responses": { + "200": { + "description": "Successful response.\n", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "failure" + ] + }, + "data": { + "type": "object", + "properties": { + "images": { + "type": "array", + "maxItems": 253, + "items": { + "$ref": "#/components/schemas/image" + } + } + } + } + } + } + } + } + }, + "default": { + "description": "Error response.\n", + "content": { + "application/json": { + "schema": { + "type": "object", + "description": "An error response from the Unikraft Cloud Platform API\n", + "required": [ + "status", + "errors" + ], + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "failure" + ], + "description": "The status of the response.\n", + "example": "success" + }, + "errors": { + "type": "array", + "items": { + "type": "object", + "properties": { + "status": { + "type": "integer", + "format": "int32", + "example": 400, + "description": "HTTP status code\n" + } + } + } + }, + "data": { + "type": "object" + } + } + } + } + } + } + } + } + }, + "/instances": { + "post": { + "operationId": "create-instance", + "summary": "Create an instance", + "description": "Creates a new instance of the specified Unikraft Cloud image.\nYou can describe the properties of the new instance such as its startup arguments and amount of memory.\nNote that the instance properties can only be defined during creation.\nThey cannot be changed later.\n", + "tags": [ + "instances" + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "image" + ], + "properties": { + "name": { + "type": "string", + "maxLength": 255, + "format": "basename", + "example": "young-monkey-uq6dxq0u", + "description": "The name of the instance.\nThe instance will receive a DNS entry in your private network of the form `.internal`.\n\nNote: If no name is specified a random name of the form `-X` is auto-generated, where `` is the application name taken from `image` (e.g., `myapp` for `../myapp:latest`) and `X` is a 5 character long random alphanumeric suffix.\n" + }, + "image": { + "type": "string", + "maxLength": 8388608, + "pattern": "^(?:(?=[^:\\/]{1,253})(?!-)[a-zA-Z0-9-]{1,63}(?.internal`.\n\nNote: If no name is specified a random name of the form `-X` is auto-generated, where `` is the application name taken from `image` (e.g., `myapp` for `../myapp:latest`) and `X` is a 5 character long random alphanumeric suffix.\n" + }, + "previous_state": { + "type": "string", + "enum": [ + "stopped", + "starting", + "running", + "draining", + "stopping", + "standby" + ], + "example": "running", + "description": "An instance can be in one of the following states:\n\nState | Description\n----------|------------\n`stopped` | The instance is not running and does not count against live resource quotas. Connections cannot be established.\n`starting`| The instance is booting up. This usually takes just a few milliseconds.\n`running` | Your application's main entry point has been reached.\n`draining`| The instance is draining connections before shutting down. No new connections can be established.\n`stopping`| The instance is shutting down.\n`standby` | The instance has [scale-to-zero](https://unikraft.cloud/docs/api/v1/autoscale#scaletozero) enabled. The instance is not running, but will be automatically started when there are incoming requests.\n" + } + } + } + } + } + } + } + } + } + } + }, + "default": { + "description": "Error response.\n", + "content": { + "application/json": { + "schema": { + "type": "object", + "description": "An error response from the Unikraft Cloud Platform API\n", + "required": [ + "status", + "errors" + ], + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "failure" + ], + "description": "The status of the response.\n", + "example": "success" + }, + "errors": { + "type": "array", + "items": { + "type": "object", + "properties": { + "status": { + "type": "integer", + "format": "int32", + "example": 400, + "description": "HTTP status code\n" + } + } + } + }, + "data": { + "type": "object" + } + } + } + } + } + } + } + } + }, + "/instances/{uuid}": { + "parameters": [ + { + "$ref": "#/components/parameters/uuid" + } + ], + "get": { + "operationId": "get-instance-by-uuid", + "summary": "Get the status of a single instance", + "description": "Returns the current status and the configuration of a particular instance if a UUID or name is specified.\nOtherwise, returns the current status and configuration of all instances.\n", + "tags": [ + "instances" + ], + "parameters": [ + { + "name": "details", + "in": "query", + "required": false, + "style": "form", + "schema": { + "type": "boolean", + "default": true + }, + "example": false, + "description": "Whether to provide detailed status and configuration information.\n" + }, + { + "name": "metrics", + "in": "query", + "required": false, + "style": "form", + "schema": { + "type": "boolean", + "default": false + }, + "example": false, + "description": "Whether to include metrics in the detailed status.\n" + } + ], + "responses": { + "200": { + "description": "Successful response.\n", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "failure" + ], + "description": "The status of the response.\n", + "example": "success" + }, + "data": { + "type": "object", + "properties": { + "instances": { + "type": "array", + "maxItems": 253, + "items": { + "$ref": "#/components/schemas/instance" + } + } + } + } + } + } + } + } + }, + "default": { + "description": "Error response.\n", + "content": { + "application/json": { + "schema": { + "type": "object", + "description": "An error response from the Unikraft Cloud Platform API\n", + "required": [ + "status", + "errors" + ], + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "failure" + ], + "description": "The status of the response.\n", + "example": "success" + }, + "errors": { + "type": "array", + "items": { + "type": "object", + "properties": { + "status": { + "type": "integer", + "format": "int32", + "example": 400, + "description": "HTTP status code\n" + } + } + } + }, + "data": { + "type": "object" + } + } + } + } + } + } + } + }, + "delete": { + "operationId": "delete-instance-by-uuid", + "summary": "Delete a single instance given its UUID", + "description": "Deletes the specified instance.\nAfter this call the IDs associated with the instance are no longer valid.\nA running instance is force stopped.\nIf the instance is an [autoscale master](https://unikraft.cloud/docs/api/v1/autoscale#basics), deleting the instance resets autoscale for the service and deletes all instances created by autoscale.\n", + "tags": [ + "instances" + ], + "responses": { + "200": { + "description": "Successful response.\n", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "failure" + ], + "description": "The status of the response.\n", + "example": "success" + }, + "data": { + "type": "object", + "properties": { + "instances": { + "type": "array", + "maxItems": 253, + "items": { + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "error" + ], + "example": "success", + "description": "The status of the response.\n\nNote: Not when listing all existing instances.\n" + }, + "uuid": { + "type": "string", + "maxLength": 36, + "format": "uuid", + "example": "471a2a73-36db-4df9-bb63-82a45810e88a", + "description": "The UUID of the instance.\n" + }, + "name": { + "type": "string", + "maxLength": 255, + "format": "basename", + "example": "young-monkey-uq6dxq0u", + "description": "The name of the instance.\nThe instance will receive a DNS entry in your private network of the form `.internal`.\n\nNote: If no name is specified a random name of the form `-X` is auto-generated, where `` is the application name taken from `image` (e.g., `myapp` for `../myapp:latest`) and `X` is a 5 character long random alphanumeric suffix.\n" + }, + "previous_state": { + "type": "string", + "enum": [ + "stopped", + "starting", + "running", + "draining", + "stopping", + "standby" + ], + "example": "running", + "description": "An instance can be in one of the following states:\n\nState | Description\n----------|------------\n`stopped` | The instance is not running and does not count against live resource quotas. Connections cannot be established.\n`starting`| The instance is booting up. This usually takes just a few milliseconds.\n`running` | Your application's main entry point has been reached.\n`draining`| The instance is draining connections before shutting down. No new connections can be established.\n`stopping`| The instance is shutting down.\n`standby` | The instance has [scale-to-zero](https://unikraft.cloud/docs/api/v1/autoscale#scaletozero) enabled. The instance is not running, but will be automatically started when there are incoming requests.\n" + } + } + } + } + } + } + } + } + } + } + }, + "default": { + "description": "Error response.\n", + "content": { + "application/json": { + "schema": { + "type": "object", + "description": "An error response from the Unikraft Cloud Platform API\n", + "required": [ + "status", + "errors" + ], + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "failure" + ], + "description": "The status of the response.\n", + "example": "success" + }, + "errors": { + "type": "array", + "items": { + "type": "object", + "properties": { + "status": { + "type": "integer", + "format": "int32", + "example": 400, + "description": "HTTP status code\n" + } + } + } + }, + "data": { + "type": "object" + } + } + } + } + } + } + } + } + }, + "/instances/log": { + "get": { + "operationId": "get-instance-logs", + "summary": "Retrieve logs for one or more instances", + "description": "Returns the log output of the specified instance(s) in base64 encoding.\nNote that the maximum response size is capped.\nThe log output might thus be cut off and require multiple requests to fetch further output.\n", + "tags": [ + "instances" + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "type": "object", + "properties": { + "uuid": { + "type": "string", + "maxLength": 36, + "format": "uuid", + "example": "471a2a73-36db-4df9-bb63-82a45810e88a", + "description": "The UUID of the instance to retrieve logs for.\n\nNote: This property is mutually exclusive with `name` and either `uuid` or `name` are required.\n" + }, + "name": { + "type": "string", + "maxLength": 255, + "format": "basename", + "example": "young-monkey-uq6dxq0u", + "description": "The name of the instance to retrieve logs for.\n\nNote: This property is mutually exclusive with `uuid` and either `uuid` or `name` are required.\n" + }, + "offset": { + "type": "integer", + "format": "int32", + "default": -4096, + "example": -4096, + "minimum": -2147483647, + "maximum": 2147483647, + "description": "The byte offset of the log output to receive.\nA negative sign makes the offset relative to the end of the log.\n" + }, + "limit": { + "type": "integer", + "format": "int32", + "default": 4096, + "example": 4096, + "minimum": 0, + "maximum": 16383, + "description": "The amount of bytes to return at most.\n" + } + } + } + } + } + } + }, + "responses": { + "200": { + "description": "Successful response.\n", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "failure" + ], + "description": "The status of the response.\n", + "example": "success" + }, + "data": { + "type": "object", + "properties": { + "instances": { + "type": "array", + "maxItems": 253, + "items": { + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "error" + ], + "description": "The status of the response.\n", + "example": "success" + }, + "uuid": { + "type": "string", + "maxLength": 36, + "format": "uuid", + "description": "The UUID of the instance.\n", + "example": "471a2a73-36db-4df9-bb63-82a45810e88a" + }, + "name": { + "type": "string", + "maxLength": 255, + "format": "basename", + "description": "The name of the instance.\n", + "example": "young-monkey-uq6dxq0u" + }, + "output": { + "type": "string", + "maxLength": 8388608, + "format": "byte", + "description": "BASE64 encoded log output.\n", + "example": "SGVsbG8gV29ybGQhCg==" + }, + "available": { + "type": "object", + "description": "Description of the log availability.\n", + "properties": { + "start": { + "type": "integer", + "format": "int64", + "description": "The first byte offset that can be retrieved.\n", + "example": 0, + "minimum": 0, + "maximum": 9223372036854775807 + }, + "end": { + "type": "integer", + "format": "int64", + "description": "The last byte offset that can be retrieved.\n", + "example": 42, + "minimum": 0, + "maximum": 9223372036854775807 + } + } + }, + "range": { + "type": "object", + "description": "Description of the range that was returned. Useful for requests with offset relative to end.\n", + "properties": { + "start": { + "type": "integer", + "format": "int64", + "description": "The first retrieved byte.\n", + "example": 0, + "minimum": 0, + "maximum": 9223372036854775807 + }, + "end": { + "type": "integer", + "format": "int64", + "description": "The last retrieved byte.\n", + "example": 42, + "minimum": 0, + "maximum": 9223372036854775807 + } + } + } + } + } + } + } + } + } + } + } + } + }, + "default": { + "description": "Error response.\n", + "content": { + "application/json": { + "schema": { + "type": "object", + "description": "An error response from the Unikraft Cloud Platform API\n", + "required": [ + "status", + "errors" + ], + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "failure" + ], + "description": "The status of the response.\n", + "example": "success" + }, + "errors": { + "type": "array", + "items": { + "type": "object", + "properties": { + "status": { + "type": "integer", + "format": "int32", + "example": 400, + "description": "HTTP status code\n" + } + } + } + }, + "data": { + "type": "object" + } + } + } + } + } + } + } + } + }, + "/instances/{uuid}/log": { + "parameters": [ + { + "$ref": "#/components/parameters/uuid" + } + ], + "get": { + "operationId": "get-instance-logs-by-uuid", + "summary": "Retrieve logs for an instance given its UUID", + "description": "Returns the log output of the specified instance in base64 encoding.\nNote that the maximum response size is capped.\nThe log output might thus be cut off and require multiple requests to fetch further output.\n", + "tags": [ + "instances" + ], + "responses": { + "200": { + "description": "Successful response.\n", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "failure" + ], + "description": "The status of the response.\n", + "example": "success" + }, + "data": { + "type": "object", + "properties": { + "instances": { + "type": "array", + "maxItems": 253, + "items": { + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "error" + ], + "description": "The status of the response.\n", + "example": "success" + }, + "uuid": { + "type": "string", + "maxLength": 36, + "format": "uuid", + "description": "The UUID of the instance.\n", + "example": "471a2a73-36db-4df9-bb63-82a45810e88a" + }, + "name": { + "type": "string", + "maxLength": 255, + "format": "basename", + "description": "The name of the instance.\n", + "example": "young-monkey-uq6dxq0u" + }, + "output": { + "type": "string", + "maxLength": 8388608, + "format": "byte", + "description": "BASE64 encoded log output.\n", + "example": "SGVsbG8gV29ybGQhCg==" + }, + "available": { + "type": "object", + "description": "Description of the log availability.\n", + "properties": { + "start": { + "type": "integer", + "format": "int64", + "description": "The first byte offset that can be retrieved.\n", + "example": 0, + "minimum": 0, + "maximum": 9223372036854775807 + }, + "end": { + "type": "integer", + "format": "int64", + "description": "The last byte offset that can be retrieved.\n", + "example": 42, + "minimum": 0, + "maximum": 9223372036854775807 + } + } + }, + "range": { + "type": "object", + "description": "Description of the range that was returned. Useful for requests with offset relative to end.\n", + "properties": { + "start": { + "type": "integer", + "format": "int64", + "description": "The first retrieved byte.\n", + "example": 0, + "minimum": 0, + "maximum": 9223372036854775807 + }, + "end": { + "type": "integer", + "format": "int64", + "description": "The last retrieved byte.\n", + "example": 42, + "minimum": 0, + "maximum": 9223372036854775807 + } + } + } + } + } + } + } + } + } + } + } + } + }, + "default": { + "description": "Error response.\n", + "content": { + "application/json": { + "schema": { + "type": "object", + "description": "An error response from the Unikraft Cloud Platform API\n", + "required": [ + "status", + "errors" + ], + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "failure" + ], + "description": "The status of the response.\n", + "example": "success" + }, + "errors": { + "type": "array", + "items": { + "type": "object", + "properties": { + "status": { + "type": "integer", + "format": "int32", + "example": 400, + "description": "HTTP status code\n" + } + } + } + }, + "data": { + "type": "object" + } + } + } + } + } + } + } + } + }, + "/instances/metrics": { + "get": { + "operationId": "get-instance-metrics", + "summary": "Get metrics for one or more instances", + "description": "Returns the various instance(s) metrics like CPU time and network traffic statistics.\nCumulative metrics (e.g., used CPU time) are accumulated over instance starts.\nThis endpoint can return either a JSON-encoded response or a response in the Prometheus format.\n", + "tags": [ + "instances" + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "type": "object", + "required": [ + "uuid" + ], + "properties": { + "uuid": { + "type": "string", + "maxLength": 36, + "format": "uuid", + "example": "471a2a73-36db-4df9-bb63-82a45810e88a", + "description": "The UUID of the instance to get the metrics for.\n\nNote: This property is mutually exclusive with `name` and either `uuid` or `name` are required.\n" + }, + "name": { + "type": "string", + "maxLength": 255, + "format": "basename", + "example": "young-monkey-uq6dxq0u", + "description": "The name of the instance to get the metrics for.\n\nNote: This property is mutually exclusive with `uuid` and either `uuid` or `name` are required.\n" + } + } + } + } + } + } + }, + "responses": { + "200": { + "description": "Successful response.\n", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "failure" + ], + "description": "The status of the response.\n", + "example": "success" + }, + "data": { + "type": "object", + "properties": { + "instances": { + "type": "array", + "maxItems": 253, + "items": { + "$ref": "#/components/schemas/instance_metrics" + } + } + } + } + } + } + } + } + }, + "default": { + "description": "Error response.\n", + "content": { + "application/json": { + "schema": { + "type": "object", + "description": "An error response from the Unikraft Cloud Platform API\n", + "required": [ + "status", + "errors" + ], + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "failure" + ], + "description": "The status of the response.\n", + "example": "success" + }, + "errors": { + "type": "array", + "items": { + "type": "object", + "properties": { + "status": { + "type": "integer", + "format": "int32", + "example": 400, + "description": "HTTP status code\n" + } + } + } + }, + "data": { + "type": "object" + } + } + } + } + } + } + } + } + }, + "/instances/{uuid}/metrics": { + "parameters": [ + { + "$ref": "#/components/parameters/uuid" + } + ], + "get": { + "operationId": "get-instance-metrics-by-uuid", + "summary": "Get metrics for an instance given its UUID", + "description": "Returns the various instances metrics like CPU time and network traffic statistics.\nCumulative metrics (e.g., used CPU time) are accumulated over instance starts.\nThis endpoint can return either a JSON-encoded response or a response in the Prometheus format.\n", + "tags": [ + "instances" + ], + "responses": { + "200": { + "description": "Successful response.\n", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "failure" + ], + "description": "The status of the response.\n", + "example": "success" + }, + "data": { + "type": "object", + "properties": { + "instances": { + "type": "array", + "maxItems": 253, + "items": { + "$ref": "#/components/schemas/instance_metrics" + } + } + } + } + } + } + } + } + }, + "default": { + "description": "Error response.\n", + "content": { + "application/json": { + "schema": { + "type": "object", + "description": "An error response from the Unikraft Cloud Platform API\n", + "required": [ + "status", + "errors" + ], + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "failure" + ], + "description": "The status of the response.\n", + "example": "success" + }, + "errors": { + "type": "array", + "items": { + "type": "object", + "properties": { + "status": { + "type": "integer", + "format": "int32", + "example": 400, + "description": "HTTP status code\n" + } + } + } + }, + "data": { + "type": "object" + } + } + } + } + } + } + } + } + }, + "/instances/start": { + "put": { + "operationId": "start-instances", + "summary": "Start one or more instances", + "description": "Starts one or more stopped instance(s).\nDoes nothing for an instance which is already running.\n", + "tags": [ + "instances" + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "type": "object", + "properties": { + "uuid": { + "type": "string", + "maxLength": 36, + "format": "uuid", + "example": "471a2a73-36db-4df9-bb63-82a45810e88a", + "description": "The UUID of the instance to start.\n\nNote: This property is mutually exclusive with `name` and either `uuid` or `name` are required.\n" + }, + "name": { + "type": "string", + "maxLength": 255, + "format": "basename", + "example": "young-monkey-uq6dxq0u", + "description": "The name of the instance to start.\n\nNote: This property is mutually exclusive with `uuid` and either `uuid` or `name` are required.\n" + } + } + } + } + } + } + }, + "responses": { + "200": { + "description": "Successful response.\n", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "failure" + ], + "description": "The status of the response.\n", + "example": "success" + }, + "data": { + "type": "object", + "properties": { + "instances": { + "type": "array", + "maxItems": 253, + "items": { + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "error" + ], + "example": "success", + "description": "The status of the response.\n" + }, + "uuid": { + "type": "string", + "maxLength": 36, + "format": "uuid", + "example": "471a2a73-36db-4df9-bb63-82a45810e88a", + "description": "The UUID of the instance.\n" + }, + "name": { + "type": "string", + "maxLength": 255, + "format": "basename", + "example": "young-monkey-uq6dxq0u", + "description": "The name of the instance.\n" + }, + "state": { + "type": "string", + "enum": [ + "stopped", + "starting", + "running", + "draining", + "stopping", + "standby" + ], + "example": "running", + "description": "An instance can be in one of the following states:\n\nState | Description\n----------|------------\n`stopped` | The instance is not running and does not count against live resource quotas. Connections cannot be established.\n`starting`| The instance is booting up. This usually takes just a few milliseconds.\n`running` | Your application's main entry point has been reached.\n`draining`| The instance is draining connections before shutting down. No new connections can be established.\n`stopping`| The instance is shutting down.\n`standby` | The instance has [scale-to-zero](https://unikraft.cloud/docs/api/v1/autoscale#scaletozero) enabled. The instance is not running, but will be automatically started when there are incoming requests.\n" + }, + "previous_state": { + "type": "string", + "enum": [ + "stopped", + "starting", + "running", + "draining", + "stopping", + "standby" + ], + "example": "running", + "description": "An instance can be in one of the following states:\n\nState | Description\n----------|------------\n`stopped` | The instance is not running and does not count against live resource quotas. Connections cannot be established.\n`starting`| The instance is booting up. This usually takes just a few milliseconds.\n`running` | Your application's main entry point has been reached.\n`draining`| The instance is draining connections before shutting down. No new connections can be established.\n`stopping`| The instance is shutting down.\n`standby` | The instance has [scale-to-zero](https://unikraft.cloud/docs/api/v1/autoscale#scaletozero) enabled. The instance is not running, but will be automatically started when there are incoming requests.\n" + } + } + } + } + } + } + } + } + } + } + }, + "default": { + "description": "Error response.\n", + "content": { + "application/json": { + "schema": { + "type": "object", + "description": "An error response from the Unikraft Cloud Platform API\n", + "required": [ + "status", + "errors" + ], + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "failure" + ], + "description": "The status of the response.\n", + "example": "success" + }, + "errors": { + "type": "array", + "items": { + "type": "object", + "properties": { + "status": { + "type": "integer", + "format": "int32", + "example": 400, + "description": "HTTP status code\n" + } + } + } + }, + "data": { + "type": "object" + } + } + } + } + } + } + } + } + }, + "/instances/{uuid}/start": { + "parameters": [ + { + "$ref": "#/components/parameters/uuid" + } + ], + "put": { + "operationId": "start-instance-by-uuid", + "summary": "Start an instance given its UUID", + "description": "Starts a stopped instance.\nDoes nothing for an instance that is already running.\n", + "tags": [ + "instances" + ], + "parameters": [ + { + "name": "wait_timeout_ms", + "in": "query", + "required": false, + "style": "form", + "explode": false, + "schema": { + "type": "integer", + "format": "int32" + }, + "description": "Timeout to wait for all specified instances to reach running state in milliseconds.\nNo wait performed for `0`.\n" + } + ], + "responses": { + "200": { + "description": "Successful response.\n", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "failure" + ], + "description": "The status of the response.\n", + "example": "success" + }, + "data": { + "type": "object", + "properties": { + "instances": { + "type": "array", + "maxItems": 253, + "items": { + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "error" + ], + "example": "success", + "description": "The status of the response.\n" + }, + "uuid": { + "type": "string", + "maxLength": 36, + "format": "uuid", + "example": "471a2a73-36db-4df9-bb63-82a45810e88a", + "description": "The UUID of the instance.\n" + }, + "name": { + "type": "string", + "maxLength": 255, + "format": "basename", + "example": "young-monkey-uq6dxq0u", + "description": "The name of the instance.\n" + }, + "state": { + "type": "string", + "enum": [ + "stopped", + "starting", + "running", + "draining", + "stopping", + "standby" + ], + "example": "running", + "description": "An instance can be in one of the following states:\n\nState | Description\n----------|------------\n`stopped` | The instance is not running and does not count against live resource quotas. Connections cannot be established.\n`starting`| The instance is booting up. This usually takes just a few milliseconds.\n`running` | Your application's main entry point has been reached.\n`draining`| The instance is draining connections before shutting down. No new connections can be established.\n`stopping`| The instance is shutting down.\n`standby` | The instance has [scale-to-zero](https://unikraft.cloud/docs/api/v1/autoscale#scaletozero) enabled. The instance is not running, but will be automatically started when there are incoming requests.\n" + }, + "previous_state": { + "type": "string", + "enum": [ + "stopped", + "starting", + "running", + "draining", + "stopping", + "standby" + ], + "example": "running", + "description": "An instance can be in one of the following states:\n\nState | Description\n----------|------------\n`stopped` | The instance is not running and does not count against live resource quotas. Connections cannot be established.\n`starting`| The instance is booting up. This usually takes just a few milliseconds.\n`running` | Your application's main entry point has been reached.\n`draining`| The instance is draining connections before shutting down. No new connections can be established.\n`stopping`| The instance is shutting down.\n`standby` | The instance has [scale-to-zero](https://unikraft.cloud/docs/api/v1/autoscale#scaletozero) enabled. The instance is not running, but will be automatically started when there are incoming requests.\n" + } + } + } + } + } + } + } + } + } + } + }, + "default": { + "description": "Error response.\n", + "content": { + "application/json": { + "schema": { + "type": "object", + "description": "An error response from the Unikraft Cloud Platform API\n", + "required": [ + "status", + "errors" + ], + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "failure" + ], + "description": "The status of the response.\n", + "example": "success" + }, + "errors": { + "type": "array", + "items": { + "type": "object", + "properties": { + "status": { + "type": "integer", + "format": "int32", + "example": 400, + "description": "HTTP status code\n" + } + } + } + }, + "data": { + "type": "object" + } + } + } + } + } + } + } + } + }, + "/instances/stop": { + "put": { + "operationId": "stop-instances", + "summary": "Stop one or more instances", + "description": "Stops the specified instance(s), but does not destroy it.\nAll volatile state (e.g., RAM contents) is lost.\nDoes nothing for an instance that is already stopped.\nThe instance can be started again with the [`start`](https://unikraft.cloud/docs/api/v1/instances/#start) endpoint.\n", + "tags": [ + "instances" + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "type": "object", + "properties": { + "uuid": { + "type": "string", + "maxLength": 36, + "format": "uuid", + "example": "471a2a73-36db-4df9-bb63-82a45810e88a", + "description": "The UUID of the instance to get the status for.\n\nNote: This property is mutually exclusive with `name` and either `uuid` or `name` are required.\n" + }, + "name": { + "type": "string", + "maxLength": 255, + "format": "basename", + "example": "young-monkey-uq6dxq0u", + "description": "The name of the instance to get the status for.\n\nNote: This property is mutually exclusive with `uuid` and either `uuid` or `name` are required.\n" + }, + "force": { + "type": "boolean", + "default": false, + "example": false, + "description": "Forces immediate shutdown.\n" + }, + "drain_timeout_ms": { + "type": "integer", + "format": "int32", + "default": 0, + "example": 0, + "minimum": 0, + "maximum": 3600000, + "description": "Timeout for draining connections in milliseconds.\nThe instance does not receive new connections in the draining phase.\nThe instance is stopped when the last connection has been closed or the timeout expired.\n" + } + } + } + } + } + } + }, + "responses": { + "200": { + "description": "Successful response.\n", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "failure" + ], + "description": "The status of the response.\n", + "example": "success" + }, + "data": { + "type": "object", + "properties": { + "instances": { + "type": "array", + "maxItems": 253, + "items": { + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "error" + ], + "example": "success", + "description": "The status of the response.\n" + }, + "uuid": { + "type": "string", + "maxLength": 36, + "format": "uuid", + "example": "471a2a73-36db-4df9-bb63-82a45810e88a", + "description": "The UUID of the instance.\n" + }, + "name": { + "type": "string", + "maxLength": 255, + "format": "basename", + "example": "young-monkey-uq6dxq0u", + "description": "The name of the instance.\n" + }, + "state": { + "type": "string", + "enum": [ + "stopped", + "starting", + "running", + "draining", + "stopping", + "standby" + ], + "example": "running", + "description": "An instance can be in one of the following states:\n\nState | Description\n----------|------------\n`stopped` | The instance is not running and does not count against live resource quotas. Connections cannot be established.\n`starting`| The instance is booting up. This usually takes just a few milliseconds.\n`running` | Your application's main entry point has been reached.\n`draining`| The instance is draining connections before shutting down. No new connections can be established.\n`stopping`| The instance is shutting down.\n`standby` | The instance has [scale-to-zero](https://unikraft.cloud/docs/api/v1/autoscale#scaletozero) enabled. The instance is not running, but will be automatically started when there are incoming requests.\n" + }, + "previous_state": { + "type": "string", + "enum": [ + "stopped", + "starting", + "running", + "draining", + "stopping", + "standby" + ], + "example": "running", + "description": "An instance can be in one of the following states:\n\nState | Description\n----------|------------\n`stopped` | The instance is not running and does not count against live resource quotas. Connections cannot be established.\n`starting`| The instance is booting up. This usually takes just a few milliseconds.\n`running` | Your application's main entry point has been reached.\n`draining`| The instance is draining connections before shutting down. No new connections can be established.\n`stopping`| The instance is shutting down.\n`standby` | The instance has [scale-to-zero](https://unikraft.cloud/docs/api/v1/autoscale#scaletozero) enabled. The instance is not running, but will be automatically started when there are incoming requests.\n" + } + } + } + } + } + } + } + } + } + } + }, + "default": { + "description": "Error response.\n", + "content": { + "application/json": { + "schema": { + "type": "object", + "description": "An error response from the Unikraft Cloud Platform API\n", + "required": [ + "status", + "errors" + ], + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "failure" + ], + "description": "The status of the response.\n", + "example": "success" + }, + "errors": { + "type": "array", + "items": { + "type": "object", + "properties": { + "status": { + "type": "integer", + "format": "int32", + "example": 400, + "description": "HTTP status code\n" + } + } + } + }, + "data": { + "type": "object" + } + } + } + } + } + } + } + } + }, + "/instances/{uuid}/stop": { + "parameters": [ + { + "$ref": "#/components/parameters/uuid" + } + ], + "put": { + "operationId": "stop-instance-by-uuid", + "summary": "Stop a single instance given its UUID", + "description": "Stops the specified instance, but does not destroy it.\nAll volatile state (e.g., RAM contents) is lost.\nDoes nothing for an instance that is already stopped.\nThe instance can be started again with the [`start`](https://unikraft.cloud/docs/api/v1/instances/#start) endpoint.\n", + "tags": [ + "instances" + ], + "parameters": [ + { + "name": "force", + "in": "query", + "style": "form", + "schema": { + "type": "boolean", + "default": false + }, + "example": false, + "description": "Forces immediate shutdown.\n" + }, + { + "name": "drain_timeout_ms", + "in": "query", + "style": "form", + "schema": { + "type": "integer", + "format": "int32", + "default": 0, + "minimum": 0, + "maximum": 3600000 + }, + "example": 0, + "description": "Timeout for draining connections in milliseconds.\nThe instance does not receive new connections in the draining phase.\nThe instance is stopped when the last connection has been closed or the timeout expired.\n" + } + ], + "responses": { + "200": { + "description": "Successful response.\n", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "failure" + ], + "description": "The status of the response.\n", + "example": "success" + }, + "data": { + "type": "object", + "properties": { + "instances": { + "type": "array", + "maxItems": 253, + "items": { + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "error" + ], + "example": "success", + "description": "The status of the response.\n" + }, + "uuid": { + "type": "string", + "maxLength": 36, + "format": "uuid", + "example": "471a2a73-36db-4df9-bb63-82a45810e88a", + "description": "The UUID of the instance.\n" + }, + "name": { + "type": "string", + "maxLength": 255, + "format": "basename", + "example": "young-monkey-uq6dxq0u", + "description": "The name of the instance.\n" + }, + "state": { + "type": "string", + "enum": [ + "stopped", + "starting", + "running", + "draining", + "stopping", + "standby" + ], + "example": "running", + "description": "An instance can be in one of the following states:\n\nState | Description\n----------|------------\n`stopped` | The instance is not running and does not count against live resource quotas. Connections cannot be established.\n`starting`| The instance is booting up. This usually takes just a few milliseconds.\n`running` | Your application's main entry point has been reached.\n`draining`| The instance is draining connections before shutting down. No new connections can be established.\n`stopping`| The instance is shutting down.\n`standby` | The instance has [scale-to-zero](https://unikraft.cloud/docs/api/v1/autoscale#scaletozero) enabled. The instance is not running, but will be automatically started when there are incoming requests.\n" + }, + "previous_state": { + "type": "string", + "enum": [ + "stopped", + "starting", + "running", + "draining", + "stopping", + "standby" + ], + "example": "running", + "description": "An instance can be in one of the following states:\n\nState | Description\n----------|------------\n`stopped` | The instance is not running and does not count against live resource quotas. Connections cannot be established.\n`starting`| The instance is booting up. This usually takes just a few milliseconds.\n`running` | Your application's main entry point has been reached.\n`draining`| The instance is draining connections before shutting down. No new connections can be established.\n`stopping`| The instance is shutting down.\n`standby` | The instance has [scale-to-zero](https://unikraft.cloud/docs/api/v1/autoscale#scaletozero) enabled. The instance is not running, but will be automatically started when there are incoming requests.\n" + } + } + } + } + } + } + } + } + } + } + }, + "default": { + "description": "Error response.\n", + "content": { + "application/json": { + "schema": { + "type": "object", + "description": "An error response from the Unikraft Cloud Platform API\n", + "required": [ + "status", + "errors" + ], + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "failure" + ], + "description": "The status of the response.\n", + "example": "success" + }, + "errors": { + "type": "array", + "items": { + "type": "object", + "properties": { + "status": { + "type": "integer", + "format": "int32", + "example": 400, + "description": "HTTP status code\n" + } + } + } + }, + "data": { + "type": "object" + } + } + } + } + } + } + } + } + }, + "/instances/wait": { + "put": { + "operationId": "wait-for-instances", + "summary": "Wait for one or more instances to reach a desired state", + "description": "Waits until the specified instance(s) have reached the desired state.\nThe request blocks until all waits in the call are satisfied or the request timed out.\n", + "tags": [ + "instances" + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "type": "object", + "properties": { + "uuid": { + "type": "string", + "maxLength": 36, + "format": "uuid", + "example": "471a2a73-36db-4df9-bb63-82a45810e88a", + "description": "The UUID of the instance to get the status for.\n\nNote: This property is mutually exclusive with `name` and either `uuid` or `name` are required.\n" + }, + "name": { + "type": "string", + "maxLength": 255, + "format": "basename", + "example": "young-monkey-uq6dxq0u", + "description": "The name of the instance to get the status for.\n\nNote: This property is mutually exclusive with `uuid` and either `uuid` or `name` are required.\n" + }, + "state": { + "type": "string", + "enum": [ + "stopped", + "starting", + "running", + "draining", + "stopping", + "standby" + ], + "example": "running", + "default": "running", + "description": "State to wait for.\n" + }, + "timeout_ms": { + "type": "integer", + "format": "int32", + "description": "Timeout for the wait in milliseconds.\n", + "default": -1, + "example": 60000, + "minimum": -1, + "maximum": 2147483647 + } + } + } + } + } + } + }, + "responses": { + "200": { + "description": "Successful response.\n", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "failure" + ], + "description": "The status of the response.\n", + "example": "success" + }, + "data": { + "type": "object", + "properties": { + "instances": { + "type": "array", + "maxItems": 253, + "items": { + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "error" + ], + "example": "success", + "description": "The status of the response.\n" + }, + "uuid": { + "type": "string", + "maxLength": 36, + "format": "uuid", + "example": "471a2a73-36db-4df9-bb63-82a45810e88a", + "description": "The UUID of the instance.\n" + }, + "name": { + "type": "string", + "maxLength": 255, + "format": "basename", + "example": "young-monkey-uq6dxq0u", + "description": "The name of the instance.\n" + }, + "state": { + "type": "string", + "enum": [ + "stopped", + "starting", + "running", + "draining", + "stopping", + "standby" + ], + "example": "running", + "default": "running", + "description": "Current state of the instance.\n" + } + } + } + } + } + } + } + } + } + } + }, + "default": { + "description": "Error response.\n", + "content": { + "application/json": { + "schema": { + "type": "object", + "description": "An error response from the Unikraft Cloud Platform API\n", + "required": [ + "status", + "errors" + ], + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "failure" + ], + "description": "The status of the response.\n", + "example": "success" + }, + "errors": { + "type": "array", + "items": { + "type": "object", + "properties": { + "status": { + "type": "integer", + "format": "int32", + "example": 400, + "description": "HTTP status code\n" + } + } + } + }, + "data": { + "type": "object" + } + } + } + } + } + } + } + } + }, + "/services": { + "post": { + "operationId": "create-services", + "summary": "Create a service", + "description": "Creates a new service with the given configuration.\nNote that the service properties like published ports can only be defined during creation.\nThey cannot be changed later.\n", + "tags": [ + "services" + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "services" + ], + "properties": { + "name": { + "type": "string", + "maxLength": 255, + "format": "basename", + "description": "The name of the service\n\nNote: If no name is specified a random name of the form `--` is auto-generated, where `` is an 8 characters long random alphanumeric suffix.\n", + "example": "my-service" + }, + "services": { + "type": "array", + "maxItems": 253, + "items": { + "type": "object", + "required": [ + "port" + ], + "properties": { + "port": { + "type": "integer", + "format": "int32", + "description": "Public-facing port", + "example": 8080, + "minimum": 1, + "maximum": 65535 + }, + "destination_port": { + "type": "integer", + "format": "int32", + "description": "Port that the application listens on.\n\nDefault: Same as `port`\n", + "example": 8080, + "minimum": 1, + "maximum": 65535 + }, + "handlers": { + "type": "array", + "maxItems": 253, + "description": "See [`Connection Handlers`](https://unikraft.cloud/docs/api/v1/services/#handlers).\n", + "items": { + "$ref": "#/components/schemas/service_mapping" + } + }, + "domains": { + "type": "array", + "maxItems": 253, + "description": "Description of domains to associate with the service.\n\nDefault: auto-generated.\nNote: If `name` is specified without also providing a domain, a domain is derived from `name` by appending an 8 characters long random alphanumeric suffix and the metro's domain name.\nFor example, setting the name to `my-project` without also providing a domain results in an auto-generated domain of `my-project-.fra0.kraft.host`.\n", + "items": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "name": { + "type": "string", + "maxLength": 255, + "format": "hostname", + "description": "Publicly accessible domain name\n\nNote: The services published by the service will be accessible under the given domain names.\nIf `name` is a fully-qualified domain name, that is it ends with a dot (`.`), the domain name is taken as-is.\nOtherwise, the metro’s domain name is appended (e.g., `my-project` expands to `my-project.fra0.kraft.host`).\nIf the given domain name is already in use by the current or a different user the operation fails.\nIn addition, certain domain names cannot be used (e.g., `www.fra0.kraft.host`).\n", + "example": "my-domain" + }, + "certificate": { + "type": "object", + "description": "TLS certificate to use for the domain\n\nNote: Only allowed for FQDNs, not for subdomains.\nSubdomains like `my-project` inherit the wildcard `*..kraft.host` certificate.\nIf you specify an FQDN like `www.example.com`, Unikraft Cloud will automatically pick the certificate with the matching CN or trigger a certificate request (see [here](https://unikraft.cloud/docs/api/v1/certificates)).\n", + "properties": { + "uuid": { + "type": "string", + "maxLength": 36, + "format": "uuid", + "description": "The UUID of the certificate.\n", + "example": "471a2a73-36db-4df9-bb63-82a45810e88a" + }, + "name": { + "type": "string", + "maxLength": 255, + "format": "basename", + "description": "The name of the certificate.\n", + "example": "my-certificate" + } + }, + "oneOf": [ + { + "required": [ + "uuid" + ] + }, + { + "required": [ + "name" + ] + } + ] + } + } + } + } + } + } + } + } + } + } + } + }, + "responses": { + "200": { + "description": "Successful response.\n", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "failure" + ], + "description": "The status of the response.\n", + "example": "success" + }, + "data": { + "type": "object", + "properties": { + "service_groups": { + "type": "array", + "maxItems": 253, + "items": { + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "error" + ], + "description": "The status of the response.\n" + }, + "uuid": { + "type": "string", + "maxLength": 36, + "format": "uuid", + "description": "The UUID of the newly created service.\n", + "example": "471a2a73-36db-4df9-bb63-82a45810e88a" + }, + "name": { + "type": "string", + "maxLength": 255, + "format": "basename", + "description": "The name of the newly created service.\n", + "example": "young-monkey-uq6dxq0u" + }, + "soft_limit": { + "type": "integer", + "format": "int32", + "description": "Per-instance connection [soft limit](https://unikraft.cloud/docs/api/v1/services/#limits).\n", + "default": 1, + "example": 100, + "minimum": 1, + "maximum": 65535 + }, + "hard_limit": { + "type": "integer", + "format": "int32", + "description": "Per-instance connection [hard limit](https://unikraft.cloud/docs/api/v1/services/#limits).\n", + "default": 65535, + "example": 1000, + "minimum": 1, + "maximum": 65535 + }, + "domains": { + "type": "array", + "maxItems": 253, + "items": { + "type": "object", + "properties": { + "fqdn": { + "type": "string", + "maxLength": 255, + "format": "hostname", + "description": "Public fully-qualified domain name under which the service is accessible from the Internet.\n", + "example": "my-project.fra0.kraft.host" + }, + "certificate": { + "type": "object", + "description": "TLS certificate used for the domain.\n\nNote: Not for subdomains of `.kraft.host`.\n", + "properties": { + "uuid": { + "type": "string", + "format": "uuid", + "maxLength": 36, + "example": "471a2a73-36db-4df9-bb63-82a45810e88a", + "description": "The UUID of the certificate.\n" + }, + "name": { + "type": "string", + "format": "basename", + "maxLength": 255, + "example": "my-certificate", + "description": "The name of the certificate.\n" + }, + "state": { + "type": "string", + "enum": [ + "valid", + "pending", + "error" + ], + "example": "valid", + "description": "Current state of the certificate.\n\nA certificate can be in one of the following states:\n\nState | Description\n----------|------------\n`pending` | The certificate request is pending while the certificate is being requested from the certification authority. During this phase any service using this certificate is not available if this is not a renewal.\n`valid` | The certificate is valid and can be used for services.\n`error` | The certificate request failed after multiple attempts. This can happen, for example, if your DNS configuration is not correct, you run into Let’s Encrypt™ quota limits, or the domain validation process failed for some other reason. There won’t be any further automatic attempts. If you need assistence please contact us via [support@unikraft.cloud](mailto:support@unikraft.cloud).\n" + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + }, + "default": { + "description": "Error response.\n", + "content": { + "application/json": { + "schema": { + "type": "object", + "description": "An error response from the Unikraft Cloud Platform API\n", + "required": [ + "status", + "errors" + ], + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "failure" + ], + "description": "The status of the response.\n", + "example": "success" + }, + "errors": { + "type": "array", + "items": { + "type": "object", + "properties": { + "status": { + "type": "integer", + "format": "int32", + "example": 400, + "description": "HTTP status code\n" + } + } + } + }, + "data": { + "type": "object" + } + } + } + } + } + } + } + }, + "get": { + "operationId": "get-services", + "summary": "Get the status of one or more services", + "description": "Returns the current status and the configuration of a particular service if a UUID or name is specified.\nOtherwise, returns the current status and configuration of all services.\n", + "tags": [ + "services" + ], + "parameters": [ + { + "name": "details", + "in": "query", + "required": false, + "schema": { + "type": "boolean", + "default": true + }, + "example": true, + "description": "Whether to provide detailed status and configuration information.\n" + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "type": "object", + "properties": { + "uuid": { + "type": "string", + "maxLength": 36, + "format": "uuid", + "example": "471a2a73-36db-4df9-bb63-82a45810e88a", + "description": "The UUID of the service to get the status for.\n\nNote: This property is mutually exclusive with `name` and either `uuid` or `name` are required.\n" + }, + "name": { + "type": "string", + "maxLength": 255, + "format": "basename", + "example": "young-monkey-uq6dxq0u", + "description": "The name of the service to get the status for.\n\nNote: This property is mutually exclusive with `uuid` and either `uuid` or `name` are required.\n" + } + } + } + } + } + } + }, + "responses": { + "200": { + "description": "Successful response.\n", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "failure" + ] + }, + "data": { + "type": "object", + "properties": { + "service_groups": { + "type": "array", + "maxItems": 253, + "items": { + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "error" + ], + "description": "The status of the response.\n" + }, + "uuid": { + "type": "string", + "maxLength": 36, + "format": "uuid", + "description": "The UUID of the service.\n", + "example": "471a2a73-36db-4df9-bb63-82a45810e88a" + }, + "name": { + "type": "string", + "maxLength": 255, + "format": "basename", + "description": "The name of the service.\n", + "example": "my-service" + }, + "created_at": { + "type": "string", + "maxLength": 8388608, + "format": "date-time", + "description": "Date and time of creation in ISO8601.\n", + "example": "2021-01-01T00:00:00Z" + }, + "persistent": { + "type": "boolean", + "description": "Indicates if the service will stay alive even after the last instance detached.\n", + "example": true + }, + "autoscale": { + "type": "boolean", + "description": "Indicates if the service has [autoscale](https://unikraft.cloud/docs/api/v1/autoscale) enabled.\n", + "example": true + }, + "soft_limit": { + "type": "integer", + "format": "int32", + "description": "Per-instance connection [soft limit](https://unikraft.cloud/docs/api/v1/services/#limits).\n", + "example": 1, + "minimum": 1, + "maximum": 65535 + }, + "hard_limit": { + "type": "integer", + "format": "int32", + "description": "Per-instance connection [hard limit](https://unikraft.cloud/docs/api/v1/services/#limits).\n", + "example": 65535, + "minimum": 1, + "maximum": 65535 + }, + "services": { + "type": "array", + "maxItems": 253, + "description": "Description of published network services.\n", + "items": { + "$ref": "#/components/schemas/service_mapping" + } + }, + "domains": { + "type": "array", + "maxItems": 253, + "items": { + "type": "object", + "properties": { + "fqdn": { + "type": "string", + "maxLength": 255, + "format": "hostname", + "description": "Public fully-qualified domain name under which the service is accessible from the Internet.\n", + "example": "my-project.fra0.unikraft.app" + }, + "certificate": { + "$ref": "#/components/schemas/certificate" + } + } + } + }, + "instances": { + "type": "array", + "maxItems": 253, + "description": "Instances attached to this service", + "items": { + "type": "object", + "properties": { + "uuid": { + "type": "string", + "maxLength": 36, + "format": "uuid", + "description": "The UUID of the instance.\n", + "example": "471a2a73-36db-4df9-bb63-82a45810e88a" + }, + "name": { + "type": "string", + "maxLength": 255, + "format": "basename", + "description": "The name of the instance.\n", + "example": "my-instance" + } + } + } + } + } + } + } + } + } + } + } + } + } + }, + "default": { + "description": "Error response.\n", + "content": { + "application/json": { + "schema": { + "type": "object", + "description": "An error response from the Unikraft Cloud Platform API\n", + "required": [ + "status", + "errors" + ], + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "failure" + ], + "description": "The status of the response.\n", + "example": "success" + }, + "errors": { + "type": "array", + "items": { + "type": "object", + "properties": { + "status": { + "type": "integer", + "format": "int32", + "example": 400, + "description": "HTTP status code\n" + } + } + } + }, + "data": { + "type": "object" + } + } + } + } + } + } + } + }, + "delete": { + "operationId": "delete-services", + "summary": "Delete one or more services", + "description": "Deletes the specified service(s).\nFails if there are still instances attached to the service.\nAfter this call the IDs associated with the service are no longer valid and the domain name is released.\n", + "tags": [ + "services" + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "type": "object", + "properties": { + "uuid": { + "type": "string", + "maxLength": 36, + "format": "uuid", + "example": "471a2a73-36db-4df9-bb63-82a45810e88a", + "description": "The UUID of the service to delete.\n\nNote: This property is mutually exclusive with `name` and either `uuid` or `name` are required.\n" + }, + "name": { + "type": "string", + "maxLength": 255, + "format": "basename", + "example": "young-monkey-uq6dxq0u", + "description": "The name of the service to delete.\n\nNote: This property is mutually exclusive with `uuid` and either `uuid` or `name` are required.\n" + } + } + } + } + } + } + }, + "responses": { + "200": { + "description": "Successful response.\n", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "failure" + ] + }, + "data": { + "type": "object", + "properties": { + "service_groups": { + "type": "array", + "maxItems": 253, + "items": { + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "error" + ], + "example": "success", + "description": "The status of the response.\n" + }, + "uuid": { + "type": "string", + "maxLength": 36, + "format": "uuid", + "description": "The UUID of the service.\n", + "example": "471a2a73-36db-4df9-bb63-82a45810e88a" + }, + "name": { + "type": "string", + "maxLength": 255, + "format": "basename", + "description": "The name of the service.\n", + "example": "my-service" + } + } + } + } + } + } + } + } + } + } + }, + "default": { + "description": "Error response.\n", + "content": { + "application/json": { + "schema": { + "type": "object", + "description": "An error response from the Unikraft Cloud Platform API\n", + "required": [ + "status", + "errors" + ], + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "failure" + ], + "description": "The status of the response.\n", + "example": "success" + }, + "errors": { + "type": "array", + "items": { + "type": "object", + "properties": { + "status": { + "type": "integer", + "format": "int32", + "example": 400, + "description": "HTTP status code\n" + } + } + } + }, + "data": { + "type": "object" + } + } + } + } + } + } + } + } + }, + "/services/{uuid}": { + "parameters": [ + { + "$ref": "#/components/parameters/uuid" + } + ], + "get": { + "operationId": "get-service-by-uuid", + "summary": "Get the status of a service given its UUID", + "description": "Returns the current status and the configuration of a particular service if a UUID or name is specified.\nOtherwise, returns the current status and configuration of all services.\n", + "tags": [ + "services" + ], + "parameters": [ + { + "name": "details", + "in": "query", + "required": false, + "schema": { + "type": "boolean", + "default": true + }, + "description": "Whether to provide detailed status and configuration information.\n", + "example": true + } + ], + "responses": { + "200": { + "description": "Successful response.\n", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "failure" + ] + }, + "data": { + "type": "object", + "properties": { + "service_groups": { + "type": "array", + "maxItems": 1, + "items": { + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "error" + ], + "description": "The status of the response.\n" + }, + "uuid": { + "type": "string", + "maxLength": 36, + "format": "uuid", + "description": "The UUID of the service.\n", + "example": "471a2a73-36db-4df9-bb63-82a45810e88a" + }, + "name": { + "type": "string", + "maxLength": 255, + "format": "basename", + "description": "The name of the service.\n", + "example": "my-service" + }, + "created_at": { + "type": "string", + "maxLength": 8388608, + "format": "date-time", + "description": "Date and time of creation in ISO8601.\n", + "example": "2021-01-01T00:00:00Z" + }, + "persistent": { + "type": "boolean", + "description": "Indicates if the service will stay alive even after the last instance detached.\n", + "example": true + }, + "autoscale": { + "type": "boolean", + "description": "Indicates if the service has [autoscale](https://unikraft.cloud/docs/api/v1/autoscale) enabled.\n", + "example": true + }, + "soft_limit": { + "type": "integer", + "format": "int32", + "description": "Per-instance connection [soft limit](https://unikraft.cloud/docs/api/v1/services/#limits).\n", + "example": 1, + "minimum": 1, + "maximum": 65535 + }, + "hard_limit": { + "type": "integer", + "format": "int32", + "description": "Per-instance connection [hard limit](https://unikraft.cloud/docs/api/v1/services/#limits).\n", + "example": 65535, + "minimum": 1, + "maximum": 65535 + }, + "services": { + "type": "array", + "maxItems": 253, + "description": "Description of published network services.\n", + "items": { + "$ref": "#/components/schemas/service_mapping" + } + }, + "domains": { + "type": "array", + "maxItems": 253, + "items": { + "type": "object", + "properties": { + "fqdn": { + "type": "string", + "maxLength": 255, + "format": "hostname", + "description": "Public fully-qualified domain name under which the service is accessible from the Internet.\n", + "example": "my-project.fra0.unikraft.app" + }, + "certificate": { + "$ref": "#/components/schemas/certificate" + } + } + } + }, + "instances": { + "type": "array", + "maxItems": 253, + "description": "Instances attached to this service", + "items": { + "type": "object", + "properties": { + "uuid": { + "type": "string", + "maxLength": 36, + "format": "uuid", + "description": "The UUID of the instance.\n", + "example": "471a2a73-36db-4df9-bb63-82a45810e88a" + }, + "name": { + "type": "string", + "maxLength": 255, + "format": "basename", + "description": "The name of the instance.\n", + "example": "my-instance" + } + } + } + } + } + } + } + } + } + } + } + } + } + }, + "default": { + "description": "Error response.\n", + "content": { + "application/json": { + "schema": { + "type": "object", + "description": "An error response from the Unikraft Cloud Platform API\n", + "required": [ + "status", + "errors" + ], + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "failure" + ], + "description": "The status of the response.\n", + "example": "success" + }, + "errors": { + "type": "array", + "items": { + "type": "object", + "properties": { + "status": { + "type": "integer", + "format": "int32", + "example": 400, + "description": "HTTP status code\n" + } + } + } + }, + "data": { + "type": "object" + } + } + } + } + } + } + } + }, + "delete": { + "operationId": "delete-service-by-uuid", + "summary": "Delete a service given its UUID", + "description": "Deletes the specified service.\nFails if there are still instances attached to the service.\nAfter this call the IDs associated with the service are no longer valid and the domain name is released.\n", + "tags": [ + "services" + ], + "responses": { + "200": { + "description": "Successful response.\n", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "failure" + ] + }, + "data": { + "type": "object", + "properties": { + "service_groups": { + "type": "array", + "maxItems": 253, + "items": { + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "error" + ], + "example": "success", + "description": "The status of the response.\n" + }, + "uuid": { + "type": "string", + "maxLength": 36, + "format": "uuid", + "description": "The UUID of the service.\n", + "example": "471a2a73-36db-4df9-bb63-82a45810e88a" + }, + "name": { + "type": "string", + "maxLength": 255, + "format": "basename", + "description": "The name of the service.\n", + "example": "my-service" + } + } + } + } + } + } + } + } + } + } + }, + "default": { + "description": "Error response.\n", + "content": { + "application/json": { + "schema": { + "type": "object", + "description": "An error response from the Unikraft Cloud Platform API\n", + "required": [ + "status", + "errors" + ], + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "failure" + ], + "description": "The status of the response.\n", + "example": "success" + }, + "errors": { + "type": "array", + "items": { + "type": "object", + "properties": { + "status": { + "type": "integer", + "format": "int32", + "example": 400, + "description": "HTTP status code\n" + } + } + } + }, + "data": { + "type": "object" + } + } + } + } + } + } + } + } + }, + "/services/autoscale": { + "post": { + "operationId": "create-autoscale-config", + "summary": "Create autoscale configuration", + "description": "Creates an autoscale configuration for the specified service.\n", + "tags": [ + "autoscale" + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "properties": { + "uuid": { + "type": "string", + "maxLength": 36, + "format": "uuid", + "example": "471a2a73-36db-4df9-bb63-82a45810e88a", + "description": "The UUID of the service for which to create a configuration.\n\nNote: This property is mutually exclusive with `name` and either `uuid` or `name` are required.\n" + }, + "name": { + "type": "string", + "maxLength": 255, + "format": "hostname", + "example": "my-service", + "description": "The name of the service for which to create a configuration.\n\nNote: This property is mutually exclusive with `name` and either `uuid` or `name` are required.\n" + }, + "min_size": { + "type": "integer", + "format": "int32", + "default": 1, + "example": 1, + "minimum": 1, + "maximum": 1, + "description": "Minimum number of instances.\n" + }, + "max_size": { + "type": "integer", + "format": "int32", + "default": 4, + "example": 4, + "minimum": 1, + "maximum": 2147483647, + "description": "Maximum number of instances.\n" + }, + "warmup_time_ms": { + "type": "integer", + "format": "int32", + "default": 1000, + "example": 1000, + "minimum": 1, + "maximum": 2147483647, + "description": "Length of [warmup phase](https://unikraft.cloud/docs/api/v1/autoscale/#warmup-and-cooldown) in milliseconds.\n" + }, + "cooldown_time_ms": { + "type": "integer", + "format": "int32", + "default": 1000, + "example": 1000, + "minimum": 1, + "maximum": 2147483647, + "description": "Length of [cooldown phase](https://unikraft.cloud/docs/api/v1/autoscale/#warmup-and-cooldown) in milliseconds.\n" + }, + "master": { + "type": "object", + "properties": { + "uuid": { + "type": "string", + "maxLength": 36, + "format": "uuid", + "example": "471a2a73-36db-4df9-bb63-82a45810e88a", + "description": "The UUID of instance to use as [autoscale master](https://unikraft.cloud/docs/api/v1/autoscale/#autoscale-basics).\n" + }, + "name": { + "type": "string", + "maxLength": 255, + "format": "basename", + "description": "The name of instance to use as [autoscale master](https://unikraft.cloud/docs/api/v1/autoscale/#autoscale-basics).\n", + "example": "my-instance" + }, + "policies": { + "type": "array", + "maxItems": 253, + "items": { + "$ref": "#/components/schemas/autoscale_policy" + } + } + } + } + } + } + } + } + }, + "responses": { + "200": { + "description": "Successful response.\n", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "failure" + ], + "description": "The status of the response.\n", + "example": "success" + }, + "data": { + "type": "object", + "properties": { + "certificates": { + "type": "array", + "maxItems": 253, + "items": { + "type": "object", + "properties": { + "uuid": { + "type": "string", + "maxLength": 36, + "format": "uuid", + "example": "471a2a73-36db-4df9-bb63-82a45810e88a", + "description": "The UUID of the certificate.\n" + }, + "name": { + "type": "string", + "maxLength": 255, + "format": "basename", + "example": "my-certificate", + "description": "The name of the certificate.\n" + } + } + } + } + } + } + } + } + } + } + }, + "default": { + "description": "Error response.\n", + "content": { + "application/json": { + "schema": { + "type": "object", + "description": "An error response from the Unikraft Cloud Platform API\n", + "required": [ + "status", + "errors" + ], + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "failure" + ], + "description": "The status of the response.\n", + "example": "success" + }, + "errors": { + "type": "array", + "items": { + "type": "object", + "properties": { + "status": { + "type": "integer", + "format": "int32", + "example": 400, + "description": "HTTP status code\n" + } + } + } + }, + "data": { + "type": "object" + } + } + } + } + } + } + } + }, + "get": { + "operationId": "get-autoscale-configs", + "summary": "Get one or more autoscale configuration", + "description": "Returns the current autoscale configuration of the supplied service(s).\n", + "tags": [ + "autoscale" + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "type": "object", + "properties": { + "uuid": { + "type": "string", + "maxLength": 36, + "format": "uuid", + "example": "471a2a73-36db-4df9-bb63-82a45810e88a", + "description": "The UUID of the service.\n\nNote: This property is mutually exclusive with `name` and either `uuid` or `name` are required.\n" + }, + "name": { + "type": "string", + "maxLength": 255, + "format": "basename", + "example": "young-monkey-uq6dxq0u", + "description": "The name of the service.\n\nNote: This property is mutually exclusive with `uuid` and either `uuid` or `name` are required.\n" + } + } + } + } + } + } + }, + "responses": { + "200": { + "description": "Successful response.\n", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "failure" + ], + "description": "`success` on success, `failure` if the request failed.\n", + "example": "success" + }, + "data": { + "type": "object", + "properties": { + "service_groups": { + "type": "array", + "maxItems": 253, + "items": { + "$ref": "#/components/schemas/autoscale_config" + } + } + } + } + } + } + } + } + }, + "default": { + "description": "Error response.\n", + "content": { + "application/json": { + "schema": { + "type": "object", + "description": "An error response from the Unikraft Cloud Platform API\n", + "required": [ + "status", + "errors" + ], + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "failure" + ], + "description": "The status of the response.\n", + "example": "success" + }, + "errors": { + "type": "array", + "items": { + "type": "object", + "properties": { + "status": { + "type": "integer", + "format": "int32", + "example": 400, + "description": "HTTP status code\n" + } + } + } + }, + "data": { + "type": "object" + } + } + } + } + } + } + } + }, + "delete": { + "operationId": "delete-autoscale-configs", + "summary": "Delete one or more autoscale configurations", + "description": "Deletes the autoscale configuration for the specified service.\nUnikraft Cloud will immediately drain all connections from all instances that have been created by autoscale and delete the instances afterwards.\nThe draining phase is allowed to take at most `cooldown_time_ms` milliseconds after which remaining connections are forcefully closed.\nThe master instance is never deleted.\nHowever, deleting the autoscale configuration causes the master instance to start if it is stopped.\n", + "tags": [ + "autoscale" + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "type": "object", + "properties": { + "uuid": { + "type": "string", + "maxLength": 36, + "format": "uuid", + "example": "471a2a73-36db-4df9-bb63-82a45810e88a", + "description": "The UUID of the service.\n\nNote: This property is mutually exclusive with `name` and either `uuid` or `name` are required.\n" + }, + "name": { + "type": "string", + "maxLength": 255, + "format": "basename", + "example": "young-monkey-uq6dxq0u", + "description": "The name of the service.\n\nNote: This property is mutually exclusive with `uuid` and either `uuid` or `name` are required.\n" + } + } + } + } + } + } + }, + "responses": { + "200": { + "description": "Successful response.\n", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "failure" + ], + "description": "The status of the response.\n", + "example": "success" + }, + "data": { + "type": "object", + "properties": { + "service_groups": { + "type": "array", + "maxItems": 253, + "items": { + "type": "object", + "properties": { + "status": { + "type": "string", + "maxLength": 8388608, + "description": "The status of the response.\n", + "enum": [ + "success", + "failure" + ], + "example": "success" + }, + "uuid": { + "type": "string", + "maxLength": 36, + "format": "uuid", + "description": "The UUID of the service.\n", + "example": "471a2a73-36db-4df9-bb63-82a45810e88a" + }, + "name": { + "type": "string", + "maxLength": 255, + "format": "basename", + "description": "The name of the service.\n", + "example": "my-service" + } + } + } + } + } + } + } + } + } + } + }, + "default": { + "description": "Error response.\n", + "content": { + "application/json": { + "schema": { + "type": "object", + "description": "An error response from the Unikraft Cloud Platform API\n", + "required": [ + "status", + "errors" + ], + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "failure" + ], + "description": "The status of the response.\n", + "example": "success" + }, + "errors": { + "type": "array", + "items": { + "type": "object", + "properties": { + "status": { + "type": "integer", + "format": "int32", + "example": 400, + "description": "HTTP status code\n" + } + } + } + }, + "data": { + "type": "object" + } + } + } + } + } + } + } + } + }, + "/services/{uuid}/autoscale": { + "parameters": [ + { + "$ref": "#/components/parameters/uuid" + } + ], + "get": { + "operationId": "get-autoscale-config-by-service-uuid", + "summary": "Get an autoscale configuration given the service UUID", + "description": "Returns the current autoscale configuration of a service.\n", + "tags": [ + "autoscale" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "failure" + ], + "description": "`success` on success, `failure` if the request failed.\n", + "example": "success" + }, + "data": { + "type": "object", + "properties": { + "service_groups": { + "type": "array", + "maxItems": 253, + "items": { + "$ref": "#/components/schemas/autoscale_config" + } + } + } + } + } + } + } + } + }, + "default": { + "description": "Error response.\n", + "content": { + "application/json": { + "schema": { + "type": "object", + "description": "An error response from the Unikraft Cloud Platform API\n", + "required": [ + "status", + "errors" + ], + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "failure" + ], + "description": "The status of the response.\n", + "example": "success" + }, + "errors": { + "type": "array", + "items": { + "type": "object", + "properties": { + "status": { + "type": "integer", + "format": "int32", + "example": 400, + "description": "HTTP status code\n" + } + } + } + }, + "data": { + "type": "object" + } + } + } + } + } + } + } + }, + "delete": { + "operationId": "delete-autoscale-config-by-uuid", + "summary": "Delete an autoscale configuration given its UUID", + "description": "Deletes the autoscale configuration for the specified service.\nUnikraft Cloud will immediately drain all connections from all instances that have been created by autoscale and delete the instances afterwards.\nThe draining phase is allowed to take at most `cooldown_time_ms` milliseconds after which remaining connections are forcefully closed.\nThe master instance is never deleted.\nHowever, deleting the autoscale configuration causes the master instance to start if it is stopped.\n", + "tags": [ + "autoscale" + ], + "responses": { + "200": { + "description": "Successful response.\n", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "failure" + ], + "description": "The status of the response.\n", + "example": "success" + }, + "data": { + "type": "object", + "properties": { + "service_groups": { + "type": "array", + "maxItems": 253, + "items": { + "type": "object", + "properties": { + "status": { + "type": "string", + "maxLength": 8388608, + "description": "The status of the response.\n", + "enum": [ + "success", + "failure" + ], + "example": "success" + }, + "uuid": { + "type": "string", + "maxLength": 36, + "format": "uuid", + "description": "The UUID of the service.\n", + "example": "471a2a73-36db-4df9-bb63-82a45810e88a" + }, + "name": { + "type": "string", + "maxLength": 255, + "format": "basename", + "description": "The name of the service.\n", + "example": "my-service" + } + } + } + } + } + } + } + } + } + } + }, + "default": { + "description": "Error response.\n", + "content": { + "application/json": { + "schema": { + "type": "object", + "description": "An error response from the Unikraft Cloud Platform API\n", + "required": [ + "status", + "errors" + ], + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "failure" + ], + "description": "The status of the response.\n", + "example": "success" + }, + "errors": { + "type": "array", + "items": { + "type": "object", + "properties": { + "status": { + "type": "integer", + "format": "int32", + "example": 400, + "description": "HTTP status code\n" + } + } + } + }, + "data": { + "type": "object" + } + } + } + } + } + } + } + } + }, + "/services/{uuid}/autoscale/policies": { + "parameters": [ + { + "$ref": "#/components/parameters/uuid" + } + ], + "post": { + "operationId": "create-autoscale-policy", + "summary": "Create an autoscale policy", + "description": "Adds a new autoscale policy to the existing autoscale configuration of the specified service.\n", + "tags": [ + "autoscale" + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "name": { + "type": "string", + "maxLength": 255, + "format": "basename", + "description": "The name of the policy.\n", + "example": "my-policy" + }, + "type": { + "type": "string", + "enum": [ + "step" + ], + "example": "step", + "description": "Type of autoscale policy.\n" + }, + "metric": { + "type": "string", + "default": "cpu", + "enum": [ + "cpu" + ], + "example": "cpu", + "description": "Metric to monitor.\n" + }, + "adjustment_type": { + "type": "string", + "default": "change", + "enum": [ + "change", + "exact", + "percent" + ], + "example": "change", + "description": "Type of adjustment.\n" + }, + "steps": { + "$ref": "#/components/schemas/autoscale_policy_step" + } + }, + "oneOf": [ + { + "required": [ + "name", + "type", + "steps" + ] + } + ] + } + } + } + }, + "responses": { + "200": { + "description": "Successful response.\n", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "failure" + ], + "description": "The status of the response.\n", + "example": "success" + }, + "data": { + "type": "object", + "properties": { + "certificates": { + "type": "array", + "maxItems": 253, + "items": { + "type": "object", + "properties": { + "uuid": { + "type": "string", + "maxLength": 36, + "format": "uuid", + "example": "471a2a73-36db-4df9-bb63-82a45810e88a", + "description": "The UUID of the service.\n" + }, + "name": { + "type": "string", + "maxLength": 255, + "format": "basename", + "example": "my-service", + "description": "The name of the service.\n" + } + } + } + } + } + } + } + } + } + } + }, + "default": { + "description": "Error response.\n", + "content": { + "application/json": { + "schema": { + "type": "object", + "description": "An error response from the Unikraft Cloud Platform API\n", + "required": [ + "status", + "errors" + ], + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "failure" + ], + "description": "The status of the response.\n", + "example": "success" + }, + "errors": { + "type": "array", + "items": { + "type": "object", + "properties": { + "status": { + "type": "integer", + "format": "int32", + "example": 400, + "description": "HTTP status code\n" + } + } + } + }, + "data": { + "type": "object" + } + } + } + } + } + } + } + }, + "get": { + "operationId": "get-autosacle-policies", + "summary": "Get one or more autoscale policies", + "description": "Returns the configuration of the specified autoscale policy.\n", + "tags": [ + "autoscale" + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "type": "object", + "properties": { + "uuid": { + "type": "string", + "maxLength": 36, + "format": "uuid", + "example": "471a2a73-36db-4df9-bb63-82a45810e88a", + "description": "The UUID of the autoscale policy to delete.\n\nNote: This property is mutually exclusive with `name` and either `uuid` or `name` are required.\n" + }, + "name": { + "type": "string", + "maxLength": 255, + "format": "basename", + "example": "scale-out-policy", + "description": "The name of the autoscale policy to delete.\n\nNote: This property is mutually exclusive with `uuid` and either `uuid` or `name` are required.\n" + } + } + } + } + } + } + }, + "responses": { + "200": { + "description": "Successful response.\n", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "failure" + ], + "description": "The status of the response.\n", + "example": "success" + }, + "data": { + "type": "object", + "properties": { + "policies": { + "type": "array", + "maxItems": 253, + "items": { + "$ref": "#/components/schemas/autoscale_policy" + } + } + } + } + } + } + } + } + }, + "default": { + "description": "Error response.\n", + "content": { + "application/json": { + "schema": { + "type": "object", + "description": "An error response from the Unikraft Cloud Platform API\n", + "required": [ + "status", + "errors" + ], + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "failure" + ], + "description": "The status of the response.\n", + "example": "success" + }, + "errors": { + "type": "array", + "items": { + "type": "object", + "properties": { + "status": { + "type": "integer", + "format": "int32", + "example": 400, + "description": "HTTP status code\n" + } + } + } + }, + "data": { + "type": "object" + } + } + } + } + } + } + } + }, + "delete": { + "operationId": "delete-autoscale-policies", + "summary": "Delete one or more autoscale policies", + "description": "Deletes the specified autoscale policies.\n", + "tags": [ + "autoscale" + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "type": "object", + "properties": { + "uuid": { + "type": "string", + "maxLength": 36, + "format": "uuid", + "example": "471a2a73-36db-4df9-bb63-82a45810e88a", + "description": "The UUID of the autoscale policy to delete.\n\nNote: This property is mutually exclusive with `name` and either `uuid` or `name` are required.\n" + }, + "name": { + "type": "string", + "maxLength": 255, + "format": "basename", + "example": "scale-out-policy", + "description": "The name of the autoscale policy to delete.\n\nNote: This property is mutually exclusive with `uuid` and either `uuid` or `name` are required.\n" + } + } + } + } + } + } + }, + "responses": { + "200": { + "description": "Successful response.\n", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "failure" + ], + "description": "The status of the response.\n", + "example": "success" + }, + "data": { + "type": "object", + "properties": { + "policies": { + "type": "array", + "maxItems": 253, + "items": { + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "failure" + ], + "example": "success", + "description": "The status of the response.\n" + }, + "name": { + "type": "string", + "maxLength": 255, + "format": "basename", + "example": "scale-out-policy", + "description": "The name of the policy.\n" + } + } + } + } + } + } + } + } + } + } + }, + "default": { + "description": "Error response.\n", + "content": { + "application/json": { + "schema": { + "type": "object", + "description": "An error response from the Unikraft Cloud Platform API\n", + "required": [ + "status", + "errors" + ], + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "failure" + ], + "description": "The status of the response.\n", + "example": "success" + }, + "errors": { + "type": "array", + "items": { + "type": "object", + "properties": { + "status": { + "type": "integer", + "format": "int32", + "example": 400, + "description": "HTTP status code\n" + } + } + } + }, + "data": { + "type": "object" + } + } + } + } + } + } + } + } + }, + "/services/{uuid}/autoscale/policies/{name}": { + "parameters": [ + { + "$ref": "#/components/parameters/uuid" + }, + { + "$ref": "#/components/parameters/name" + } + ], + "get": { + "operationId": "get-autoscale-policy-by-service-uuid-and-policy-name", + "summary": "Get a single autoscale policy", + "description": "Returns the configuration of the specified autoscale policy.\n", + "tags": [ + "autoscale" + ], + "responses": { + "200": { + "description": "Successful response.\n", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "failure" + ], + "description": "The status of the response.\n", + "example": "success" + }, + "data": { + "type": "object", + "properties": { + "policies": { + "type": "array", + "maxItems": 1, + "items": { + "$ref": "#/components/schemas/autoscale_policy" + } + } + } + } + } + } + } + } + }, + "default": { + "description": "Error response.\n", + "content": { + "application/json": { + "schema": { + "type": "object", + "description": "An error response from the Unikraft Cloud Platform API\n", + "required": [ + "status", + "errors" + ], + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "failure" + ], + "description": "The status of the response.\n", + "example": "success" + }, + "errors": { + "type": "array", + "items": { + "type": "object", + "properties": { + "status": { + "type": "integer", + "format": "int32", + "example": 400, + "description": "HTTP status code\n" + } + } + } + }, + "data": { + "type": "object" + } + } + } + } + } + } + } + }, + "delete": { + "operationId": "delete-autoscale-policy-by-service-uuid-and-policy-name", + "summary": "Delete an autoscale policy given its service uuid and policy name", + "description": "Deletes the specified autoscale policy.\n", + "tags": [ + "autoscale" + ], + "responses": { + "200": { + "description": "Successful response.\n", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "failure" + ], + "description": "The status of the response.\n", + "example": "success" + }, + "data": { + "type": "object", + "properties": { + "policies": { + "type": "array", + "maxItems": 1, + "items": { + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "failure" + ], + "example": "success", + "description": "The status of the response.\n" + }, + "name": { + "type": "string", + "maxLength": 255, + "format": "basename", + "example": "scale-out-policy", + "description": "The name of the policy.\n" + } + } + } + } + } + } + } + } + } + } + }, + "default": { + "description": "Error response.\n", + "content": { + "application/json": { + "schema": { + "type": "object", + "description": "An error response from the Unikraft Cloud Platform API\n", + "required": [ + "status", + "errors" + ], + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "failure" + ], + "description": "The status of the response.\n", + "example": "success" + }, + "errors": { + "type": "array", + "items": { + "type": "object", + "properties": { + "status": { + "type": "integer", + "format": "int32", + "example": 400, + "description": "HTTP status code\n" + } + } + } + }, + "data": { + "type": "object" + } + } + } + } + } + } + } + } + }, + "/users/quotas": { + "get": { + "operationId": "get-quotas", + "summary": "Get quota information for one or more users", + "description": "Lists quota usage and limits of the specified user account.\nLimits are hard limits that cannot be exceeded.\n", + "tags": [ + "users" + ], + "responses": { + "200": { + "description": "Successful response.\n", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "failure" + ] + }, + "data": { + "type": "object", + "properties": { + "quotas": { + "type": "array", + "maxItems": 253, + "items": { + "$ref": "#/components/schemas/user_quota" + } + } + } + } + } + } + } + } + }, + "default": { + "description": "Error response.\n", + "content": { + "application/json": { + "schema": { + "type": "object", + "description": "An error response from the Unikraft Cloud Platform API\n", + "required": [ + "status", + "errors" + ], + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "failure" + ], + "description": "The status of the response.\n", + "example": "success" + }, + "errors": { + "type": "array", + "items": { + "type": "object", + "properties": { + "status": { + "type": "integer", + "format": "int32", + "example": 400, + "description": "HTTP status code\n" + } + } + } + }, + "data": { + "type": "object" + } + } + } + } + } + } + } + } + }, + "/users/{uuid}/quotas": { + "parameters": [ + { + "$ref": "#/components/parameters/uuid" + } + ], + "get": { + "operationId": "get-quota-by-uuid", + "summary": "Get quota information given their UUID", + "description": "Lists quota usage and limits for the provided UUID.\nLimits are hard limits that cannot be exceeded.\n", + "tags": [ + "users" + ], + "responses": { + "200": { + "description": "Successful response.\n", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "failure" + ] + }, + "data": { + "type": "object", + "properties": { + "quotas": { + "type": "array", + "maxItems": 1, + "items": { + "$ref": "#/components/schemas/user_quota" + } + } + } + } + } + } + } + } + }, + "default": { + "description": "Error response.\n", + "content": { + "application/json": { + "schema": { + "type": "object", + "description": "An error response from the Unikraft Cloud Platform API\n", + "required": [ + "status", + "errors" + ], + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "failure" + ], + "description": "The status of the response.\n", + "example": "success" + }, + "errors": { + "type": "array", + "items": { + "type": "object", + "properties": { + "status": { + "type": "integer", + "format": "int32", + "example": 400, + "description": "HTTP status code\n" + } + } + } + }, + "data": { + "type": "object" + } + } + } + } + } + } + } + } + }, + "/volumes": { + "post": { + "operationId": "create-volumes", + "summary": "Create one or more persistent volumes", + "description": "Creates one or more volumes with the given configuration.\nThe volumes are automatically initialized with an empty file system.\nAfter initialization the volumes are in the `available` state and can be attached to an instance with the [`PUT /v1/volumes/attach`](https://unikraft.cloud/docs/api/v1/volumes/#attach) endpoint.\nNote that, the size of a volume cannot be changed after creation.\n", + "tags": [ + "volumes" + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "type": "object", + "required": [ + "size_mb" + ], + "properties": { + "name": { + "type": "string", + "maxLength": 255, + "format": "basename", + "description": "The name of the volume.\n\nNote: If no name is specified a random name of the form `vol-X` is auto-generated, where `X` is a 5 character long random alphanumeric suffix.\n" + }, + "size_mb": { + "type": "integer", + "format": "int32", + "example": 1024, + "minimum": 1, + "maximum": 1048576, + "description": "Size of the volume in megabytes.\n" + } + } + } + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "failure" + ] + }, + "data": { + "type": "object", + "properties": { + "volumes": { + "type": "array", + "maxItems": 253, + "items": { + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "error" + ], + "example": "success" + }, + "uuid": { + "type": "string", + "maxLength": 36, + "format": "uuid", + "description": "The UUID of the volume.\n", + "example": "471a2a73-36db-4df9-bb63-82a45810e88a" + }, + "name": { + "type": "string", + "maxLength": 255, + "format": "basename", + "description": "The name of the volume.\n", + "example": "my-volume" + } + } + } + } + } + } + } + } + } + } + }, + "default": { + "description": "Error response.\n", + "content": { + "application/json": { + "schema": { + "type": "object", + "description": "An error response from the Unikraft Cloud Platform API\n", + "required": [ + "status", + "errors" + ], + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "failure" + ], + "description": "The status of the response.\n", + "example": "success" + }, + "errors": { + "type": "array", + "items": { + "type": "object", + "properties": { + "status": { + "type": "integer", + "format": "int32", + "example": 400, + "description": "HTTP status code\n" + } + } + } + }, + "data": { + "type": "object" + } + } + } + } + } + } + } + }, + "get": { + "operationId": "get-volumes", + "summary": "Get the status of one or more persistent volumes", + "description": "Returns the current status and the configuration of a particular volume if a UUID or name is specified.\nOtherwise, returns the current status and configuration of all volumes.\n", + "tags": [ + "volumes" + ], + "parameters": [ + { + "name": "details", + "in": "query", + "required": false, + "schema": { + "type": "boolean", + "default": true + }, + "description": "Whether to provide detailed status and configuration information.\n" + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "type": "object", + "properties": { + "uuid": { + "type": "string", + "maxLength": 36, + "format": "uuid", + "example": "471a2a73-36db-4df9-bb63-82a45810e88a", + "description": "The UUID of the volume to get the status for.\n\nNote: This property is mutually exclusive with `name` and either `uuid` or `name` are required.\n" + }, + "name": { + "type": "string", + "maxLength": 255, + "format": "basename", + "example": "my-data", + "description": "The name of the volume to get the status for.\n\nNote: This property is mutually exclusive with `uuid` and either `uuid` or `name` are required.\n" + } + } + } + } + } + } + }, + "responses": { + "200": { + "description": "Successful response.\n", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "failure" + ] + }, + "data": { + "type": "object", + "properties": { + "volumes": { + "type": "array", + "maxItems": 253, + "items": { + "$ref": "#/components/schemas/volume" + } + } + } + } + } + } + } + } + }, + "default": { + "description": "Error response.\n", + "content": { + "application/json": { + "schema": { + "type": "object", + "description": "An error response from the Unikraft Cloud Platform API\n", + "required": [ + "status", + "errors" + ], + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "failure" + ], + "description": "The status of the response.\n", + "example": "success" + }, + "errors": { + "type": "array", + "items": { + "type": "object", + "properties": { + "status": { + "type": "integer", + "format": "int32", + "example": 400, + "description": "HTTP status code\n" + } + } + } + }, + "data": { + "type": "object" + } + } + } + } + } + } + } + }, + "delete": { + "operationId": "delete-volumes", + "summary": "Delete one or more persistent volumes", + "description": "Deletes the specified volume(s).\nFails if the volume is still attached to an instance.\nAfter this call the IDs associated with the volume are no longer valid.\n", + "tags": [ + "volumes" + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "type": "object", + "properties": { + "uuid": { + "type": "string", + "maxLength": 36, + "format": "uuid", + "example": "471a2a73-36db-4df9-bb63-82a45810e88a", + "description": "The UUID of the volume to delete.\n\nNote: This property is mutually exclusive with `name` and either `uuid` or `name` are required.\n" + }, + "name": { + "type": "string", + "maxLength": 255, + "format": "basename", + "example": "my-volume", + "description": "The name of the volume to delete.\n\nNote: This property is mutually exclusive with `uuid` and either `uuid` or `name` are required.\n" + } + } + } + } + } + } + }, + "responses": { + "200": { + "description": "Successful response.\n", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "failure" + ] + } + } + } + } + } + }, + "default": { + "description": "Error response.\n", + "content": { + "application/json": { + "schema": { + "type": "object", + "description": "An error response from the Unikraft Cloud Platform API\n", + "required": [ + "status", + "errors" + ], + "properties": { + "status": { + "type": "string", + "enum": [ + "success", + "failure" + ], + "description": "The status of the response.\n", + "example": "success" + }, + "errors": { + "type": "array", + "items": { + "type": "object", + "properties": { + "status": { + "type": "integer", + "format": "int32", + "example": 400, + "description": "HTTP status code\n" + } + } + } + }, + "data": { + "type": "object" + } + } + } + } + } + } + } + } + } + }, + "security": [ + { + "bearerAuth": [] + } + ], + "tags": [ + { + "name": "autoscale", + "description": ":::caution[Limited Access]\nPlease note that autoscale is currently available for selected accounts only.\nIf you wish to explore autoscale for your services, please contact us via support@unikraft.cloud.\n:::\n\nServices allow you to load balance traffic for an Internet-facing service like a webserver by creating multiple instances within the same service.\nWhile you can add or remove instances to a service to scale your service, doing this manually makes it hard to react to changes in service load.\nOn the other hand, always keeping a large number of instances running to cope with bursts is not an option either.\nThis is where autoscale comes into play.\nWith autoscale enabled, Unikraft Cloud takes the heavy lifting of constantly monitoring\nthe load of your service and automatically creates or deletes instances as needed.\n\nTo enable autoscale a typical workflow looks like this:\n\n1) Create a new service with the desired properties (e.g., published ports, DNS name).\n2) Create a new instance of your application and assign it to the service.\nThis instance is going to be the **autoscale master** and cloned by Unikraft Cloud to scale your service.\n3) Create an autoscale configuration for the service and set the instance as master.\nThe configuration allows you to define the metrics and policies based on which Unikraft Cloud performs autoscale.\nIt also specifies the desired minimum and maximum number of instances as well as warmup and cooldown periods.\n\n\n:::note\nAutoscale as well as load balancing in general is currently only available for Internet-facing services\n:::\n\n### Warmup and Cooldown \n\nWhen Unikraft Cloud decides to scale out your service it grants new instances a grace period in which they have time to complete boot, warm up caches and start having an effect on the load level.\nOnly after this **warmup phase**, new instances are contributing to the evaluation of the autoscale metric.\nThis is to let the effects of the new instances on the service stabilize and prevent extensive scale out.\nNote that new instances already receive traffic and serve load while they are still warming up.\n\nConversely, Unikraft Cloud uses a **cooldown phase** to control scale in.\nDuring this phase, instances selected for scale in are given a chance to drain existing connections while already being excluded from the number of active instances in the service.\nNew connections or HTTP requests on existing connections1 are assigned to different instances.\nIf there are still open connections after the cooldown phase, the remaining connections are forcefully closed.\n\n
\n\n1Only if the [http connection handler](/docs/api/v1/services#handlers) has been set.
\n
\n\n### Autoscale Policies \n\nWith autoscale policies you define under which circumstances Unikraft Cloud should scale your service and what metric (e.g., CPU utilization) should be used for the decision.\n\nUnikraft Cloud currently supports the following autoscale policies:\n\n| Policy | Description |\n--|--\n[Step](#step) | Defines concrete adjustments for selected value ranges in the metric\n\nAn autoscale configuration usually comprises multiple policies, for example, to control scale in and scale out in separate policies.\nWhen Unikraft Cloud performs autoscale decisions it always evaluates all policies and does not stop at the first applicable policy.\nIf none of the policies apply, Unikraft Cloud maintains the current number of instances.\n\n:::note\nYou can define up to 8 autoscale policies per service.\n:::\n\n#### Step Policy \n\nA step policy consists of a set of steps that define\n* a lower bound,\n* an upper bound,\n* and an adjustment.\n\nThe lower and upper bounds are always in the dimension of the selected metric.\nA bound can be set to `null` (or not provided at all) to make the step unbounded in the respective direction.\nThe interpretation of the adjustment depends on the how the step policy is configured.\nPositive values increase the number of instances, negative values decrease the number of instances.\n\nAdjustment type | Description\n--|--\n`change` | Relative change in the number of instances (e.g., +2 instances)\n`exact` | Absolute target number of instances in the service (e.g., 10 instances)\n`percent` | Change by percentage of the current number of instances in the service (e.g., +50%)\n\nAn example step policy for scaling out may look like this:\n```json frame=none\n{\n \"name\": \"scale-out-policy\",\n \"type\": \"step\",\n \"metric\": \"cpu\",\n \"adjustment_type\": \"percent\",\n \"steps\": [\n { \"lower_bound\": 500, \"upper_bound\": 700, \"adjustment\": 50 },\n { \"lower_bound\": 700, \"upper_bound\": null, \"adjustment\": 100 }\n ]\n}\n```\nIf the CPU utilization per instance is below 500 millicores, no scaling action happens.\nIf the CPU utilization is between 500 and 700 millicores, the policy instructs Unikraft Cloud to increase the number of instances by 50%.\nIf the CPU utilization exceeds 700 millicores, the number of instances is doubled.\nThus, if the per-instance CPU load is at 600 millicores (i.e., 60%) and the current number of instances in the service is 4, Unikraft Cloud will create 2 additional instances.\n\nThere are a set of rules that steps of the same policy must adhere to:\n\n* The lower bound must be smaller than the upper bound\n* The lower and upper bound cannot be `null` in the same step\n* Steps must not overlap\n* Steps must be sorted in ascending order\n* There must be no gaps between individual steps\n\n:::note\nEach step policy can define up to 4 steps. Use more than one policy if you need more steps.\n:::\n\n### Autoscale Metrics \n\nYou can base autoscale decisions on different metrics.\nCurrently, Unikraft Cloud supports the following metrics:\n\nMetric | Description\n--|--\n`cpu` | Per-instance CPU utilization measured in millicores (e.g., 100 millicores corresponds to 10% CPU utilization)\n" + }, + { + "name": "certificates", + "description": "Unikraft Cloud allows you to host your deployment at subdomains of `.kraft.host` and/or use custom domains (e.g., `example.com`).\n\nFor subdomains, your deployment will use the wildcard TLS certificate of the respective Unikraft Cloud metro.\n\nFor custom domains, you need a TLS certificate specifically generated for your domain.\nUnikraft Cloud automatically configures the correct TLS certificate for you for non-wildcard domains.\nTo specify a custom domain, provide the fully-qualified domain name in [`POST /v1/instances`](/docs/api/v1/instances#create) or [`POST /v1/services`](/docs/api/v1/services#create).\nUnikraft Cloud will check if any of your existing certificates applies to the domain, and if not request one using Let's Encrypt™.\n\nFor wildcard domains you have to supply your own certificate.\nIf you want to use Let's Encrypt™ you can use their DNS-based challenge and upload the resulting certificate to Unikraft Cloud.\n\n### Certificate States \n\nA certificate can be in one of the following states:\n\nState | Description\n----------|---\n`pending` | The certificate request is pending while the certificate is being requested from the certification authority. During this phase any service using this certificate is not available if this is not a renewal\n`valid` | The certificate is valid and can be used by your services\n`error` | The certificate request failed after multiple attempts. This can happen, for example, if your DNS configuration is not correct, you run into Let's Encrypt™ quota limits, or the domain validation process failed for some other reason. There won't be any further automatic attempts. If you need assistence please contact us via support@unikraft.cloud.\n\nThese are reported as certificate `state` by the endpoints.\n" + }, + { + "name": "images", + "description": "On Unikraft Cloud, an image is comprised of your application files and binaries, as well as a highly specialized and performant unikernel or Linux kernel.\nWe store these together as an OCI image and distribute them worldwide using low-latency metro interconnects.\n\nAs images deployed to Unikraft Cloud are lightweight; transport is fast, and distributing new and updated production-ready applications takes only milliseconds to propagate (caveat: clearly if the application itself is large, the overall image will be large as well).\n\n### Image Name Reference\n\nWe follow the [OCI Distribution Specification](https://github.com/opencontainers/image-spec/blob/main/spec.md) for naming and referencing images.\nWhen referencing an image you can either reference it by its tag:\n\n```\n/:\n```\n\nor by its SHA256 checksum:\n\n```\n/@sha256:\n```\n\nWhere `` is the name of your user account, `` is the name of the application you want to start, `` specifies a label applied to this application (e.g., `latest`), and `` represents the digest of a specific version of the image.\n\nSince the latest version of an application may change when an update is pushed, Unikraft Cloud computes a SHA256-based digest of the image to uniquely identify it.\nWhenever you create a new instance from an image, Unikraft Cloud translates the tag to the image's digest and pins the instance to this particular version.\nThat is why [GET /v1/instances](/docs/api/v1/instances#status) reports a digest instead of the tag originally used to create the instance.\n\nApplications under the namespace of your user account can only be accessed by your user and are private to you.\nIn addition to private images, there are official images published by Unikraft Cloud which are accessible by just their name:\n```\n:\n```\n" + }, + { + "name": "instances", + "description": "An *instance* is a Unikraft virtual machine running a single instance of your application.\n\n### Instance States \n\nAn instance can be in one of the following states:\n\nState | Description\n-----------|---\n`stopped` | The instance is not running and does not count against live resource quotas. Connections cannot be established.\n`starting` | The instance is booting up. This usually takes just a few milliseconds.\n`running` | Your application's main entry point has been reached.\n`draining` | The instance is draining connections before shutting down. No new connections can be established.\n`stopping` | The instance is shutting down.\n`standby` | The instance has [scale-to-zero](/docs/api/v1/autoscale#scaletozero) enabled. The instance is not running, but will be automatically started when there are incoming requests.\n\nThese are reported as instance `state` by the endpoints.\n\n### Stop Reason \n\nTo understand why an instance has been stopped or is in the process of shutting down, Unikraft Cloud provides information about the stop reason.\nYou can retrieve this information via the [`GET /v1/instances`](#status) endpoint when an instance is in the `draining`, `stopping`, `stopped` or `standby` state.\n\nThe `stop_reason` contains a bitmask that tells you the origin of the shutdown:\n\nBit | 4 [F] | 3 [U] | 2 [P] | 1 [A] | 0 [K] (LSB)\n------|-------|-------|-------|-------|------------\nDesc. | This was a force stop1 | Stop initiated by user1 | Stop initiated by platform | App exited - `exit_code` available | Kernel exited - `stop_code` available\n\n\n1A forced stop does not give the instance a chance to perform a clean shutdown. Bits 0 [K] and 1 [A] can thus never be set for forced shutdowns. Consequently, there won't be an `exit_code` or `stop_code`.
\n2A stop command originating from the user is travelling through the platform controller. This is why bit 2 [P] will also always be set for user-initiated stops.
\n
\n\nFor example, the `stop_reason` will contain the following values in the given scenarios:\n\nValue | Bitmask | Scenario\n------|-----------------|---\n`28` | `11100`/`FUP--` | Forced user-initiated shutdown.\n`15` | `01111`/`-UPAK` | Regular user-initiated shutdown. The application and kernel have exited. The `exit_code` and `stop_code` indicate if the application and kernel shut down cleanly.\n`13` | `01101`/`-UP-K` | The user initiated a shutdown but the application was forcefully killed by the kernel during shutdown. This can be the case if the image does not support a clean application exit or the application crashed after receiving a termination signal. The `exit_code` won't be present in this scenario.\n`7` | `00111`/`--PAK` | Unikraft Cloud initiated the shutdown, for example, due to [scale-to-zero](/docs/api/v1/autoscale#scaletozero). The application and kernel have exited. The `exit_code` and `stop_code` indicate if the application and kernel shut down cleanly.\n`3` | `00011`/`---AK` | The application exited. The `exit_code` and `stop_code` indicate if the application and kernel shut down cleanly.\n`1` | `00001`/`----K` | The instance likely expierenced a fatal crash and the `stop_code` contains more information about the cause of the crash.\n`0` | `00000`/`-----` | The stop reason is unknown.\n\n:::note\nThere can be a short delay of a few milliseconds between the instance reaching the `stopped` state and the `stop_reason` being updated (or vice versa).\n:::\n\n#### Exit Code\n\nThe application exit code is what the application returns upon leaving its main entry point.\nThe encoding of the `exit_code` is application specific.\nSee the documentation of the application for more details.\nUsually, an `exit_code` of `0` indicates success / no failure.\n\n#### Stop Code\n\nThe `stop_code` is defined by the kernel and has the following encoding irrespective of the application.\n\nBits | 31 - 24 (8 bits) | 23 - 16 (8 bits) | 15 [T] | 14 - 8 (7 bits) | 7 - 0 (8 bits)\n-----|----------------------|------------------|----------------|-----------------|---\nDesc.| reserved1 | `errno` | `shutdown_bit` |`initlvl` | `reason`\n\n\n1Reserved bits are set to 0. Ignore.\n\n\n**Reason**\n`reason` can be any of the following values:\nValue | Symbol | Scenario\n------|------------|---\n`0` | `OK` | Successful shutdown\n`1` | `EXP` | The system detected an invalid state and actively stopped execution to prevent data corruption\n`2` | `MATH` | An arithmetic CPU error (e.g., division by zero)\n`3` | `INVLOP` | Invalid CPU instruction or instruction error (e.g., wrong operand alignment)\n`4` | `PGFAULT` | Page fault - see `errno` for further details\n`5` | `SEGFAULT` | Segmentation fault\n`6` | `HWERR` | Hardware error\n`7` | `SECERR` | Security violation (e.g., violation of memory access protections)\n\nA `reason` of `0` indicates that the instance was shut down cleanly.\nTo detect if the system experienced a crash, all other bits of `stop_code` can be ignored.\n\n**Init Level**\n`initlvl` indicates during which initialization or shutdown phase the instance stopped. A level of `127` indicates that the instance was executing the application when it stopped.\n\n**Shutdown Bit**\n`shutdown_bit` is set when the stop occurred while the system was shutting down.\n\n**Error Number**\n`errno` is a [Linux error code number](https://www.man7.org/linux/man-pages/man3/errno.3.html) that provides more detailed information about the root cause.\n\n:::note\nFor example, an out-of-memory (OOM) situation usually results in a page fault `PGFAULT(4)` with `errno` being `ENOMEM(12)`. Hence, the `stop_code` would be `0x000C7F04=818948` and the `stop_reason` would be `----K(1)` if the stopped occurred during application execution.\n:::\n\n### Restart Policy \n\nWhen an instance stops either because the application exits or the instance crashes, Unikraft Cloud can auto-restart your instance.\nAuto-restarts are performed according to the restart policy configured for a particular instance.\nThe policy can have the following values:\n\nPolicy | Description\n-------------|---\n`never` | Never restart the instance (default).\n`always` | Always restart the instance when the stop is initiated from within the instance (i.e., the application exits or the instance crashes).\n`on-failure` | Only restart the instance if it crashes.\n\nWhen an instance stops, the stop reason and the configured restart policy are evaluated to decide if a restart should be performed.\nUnikraft Cloud uses an exponential back-off delay (immediate, 5s, 10s, 20s, 40s, ..., 5m) to slow down restarts in tight crash loops.\nIf an instance runs without problems for 10s the back-off delay is reset and the restart sequence ends.\n\nThe `restart.attempt` reported in [`GET /v1/instances`](#status) counts the number of restarts performed in the current sequence.\nThe `restart.next_at` field indicates when the next restart will take place if a back-off delay is in effect.\n\nA manual start or stop of the instance aborts the restart sequence and resets the back-off delay.\n\n### Scale-To-Zero \n\nWith conventional cloud platforms you need to keep at least one instance running at all times to be able to respond to incoming requests.\nPerforming a just-in-time cold boot is simply too time-consuming and would create a response latency of multiple seconds.\nThis is not the case with Unikraft Cloud.\nInstances on Unikraft Cloud are able to cold boot within milliseconds, which allows us to perform low-latency scale-to-zero.\n\nTo enable scale-to-zero for an instance it is sufficient to add a `scale_to_zero` configuration block.\nUnikraft Cloud will then put the instance into standby if there is no traffic to your service within the window of a cooldown period.\nWhen there is new traffic coming in, it is automatically started again.\n\nIf you have a heavyweight application that takes long to cold boot or has bad first request latency (e.g., with JIT compilation) consider to enable [stateful scale-to-zero](#scaletozero_stateful).\n\n#### Policy \n\nWith the scale-to-zero policy you define under which circumstances Unikraft Cloud should put your instance into standby.\n\nUnikraft Cloud currently supports the following scale-to-zero policies:\n\nPolicy | Description\n-------|---\n`off` | Scale-to-zero is not enabled. The instance keeps on running until manually stopped\n`on` | Scale-to-zero is enabled. When there are no TCP connections or HTTP requests for the duration of the cooldown time, the instance is put into standby\n`idle` | Same as `on`, but also puts the instance into standby when there are TCP connections established that have been inactive for the duration of the cooldown time. The connections remain established and incoming packets wake up the instance. Scale-to-zero does **not** happen while there are active HTTP requests (i.e., traffic on ports, which have been marked with the `http` [handler](/docs/api/v1/services#handlers))\n\n:::note\nUnikraft Cloud only considers network traffic that is going through its proxy to control scale-to-zero.\nConnections that your application actively establishes to servers on the Internet **and** within Unikraft Cloud bypass the proxy for maximum performance.\nThe instance will thus be put into standby irrespective of the presence of and data sent over such connections.

\n\nSee how you can make Unikraft Cloud cooperate with your application in these scenarios in the [next section](#scaletozero_app).\n:::\n\n#### Application Support for Scale-To-Zero \n\nScale-to-zero can be used without any support from your application.\nHowever, there are cases where making your application aware of scale-to-zero makes sense.\n\n**Background Jobs** For example, you want to run background jobs after your application has responded to a request (e.g., send trace information to a logging server).\nIn this case, you may want to temporarily disable scale-to-zero to make sure your instance is not put to sleep while still performing work.\n\n**Long Request Processing** The same is true if you application can have long request processing times.\nConsider a setup where you use the `idle` policy with plain TCP connections and configure a cooldown time of 10s.\nIf it takes your application 15s to process a request until the first response data is sent, Unikraft Cloud will prematurely scale your instance to zero1.\n\nWhile configuring a longer cooldown time can be a simple solution in some cases, this is not possible if the maximum duration of background jobs or request processing phases is unknown.\nIt also means that you have to compromise between cost efficiency and reliability of your service.\n\nUnikraft Cloud allows your application to temporarily disable scale-to-zero so you can have both a short cooldown phase and reliable operation no matter how long things may take. To control scale-to-zero from within your application, instances on Unikraft Cloud provide a special file-based interface:\n\nFile | Description\n-----------------------------------|---\n`/uk/libukp/scale_to_zero_disable` | Allows to temporarily disable scale-to-zero\n\nThe `scale_to_zero_disable` pseudo file keeps track of the count of concurrent disable requests.\nIf the count is `0`, scale-to-zero is **not** disabled1, any number larger than `0` means scale-to-zero is temporarily disabled.\nUsing a count instead of a boolean value gives multiple independent workers of your application the ability to disable scale-to-zero individually by incrementing and decrementing the count without having to synchronize.\n\nReading the file returns the current count.\nThe value is prefixed with an equals sign (i.e., `=X` with `X` being the current count).\nWriting to the file modifies the count.\nThe following strings are accepted:\n\nString | Description\n-------|---\n`+` | Increment the current count by one\n`-` | Decrement the current count by one\n`=X` | Set the count to `X`\n`+X` | Increment the current count by `X`\n`-X` | Decrement the current count by `X`\n\nAny attempt to write an invalid string to the file returns an `EINVAL` error.\nAny attempt to set a count less than `0` or larger than `2^64` returns an `ERANGE` error.\n\n:::caution\nWriting to the file to disable scale-to-zero does **not** atomically disable scale-to-zero.\nThere can be a short delay (usually a few milliseconds) until changing the value is communicated to the Unikraft Cloud controller which is responsible for making scale-to-zero decisions.\nMake sure to configure a cooldown time large enough to accomodate for potential signal delay.\n:::\n\n\n1This is never the case for ports of your service that have the `http` handler set.
\n2If it is actually enabled depends on the instance configuration.
\n
\n\n#### Stateful Scale-To-Zero \n\nIf your application has a long cold boot phase or suffers from large first response latency, for example, to run JIT compilation and fill caches, using stateful scale-to-zero can dramatically reduce the response time of your service.\nWith stateful scale-to-zero Unikraft Cloud takes a snapshot of the instance state before putting it into standby.\nWhen incoming network traffic triggers a wakeup, the snapshot is loaded and the instance resumes execution where it left off - with caches already warm.\n\nAs the name suggests, stateful scale-to-zero can also be used to enable scale-to-zero for applications that need to keep state for functional correctness, even if cold boot times are no concern.\n\n:::note\nThe time to load an instance snapshot is roughly constant and usually in the order of a few milliseconds.\nThis is what is reported in the various boot time metrics.\nHowever, the actual memory contents is loaded from the snapshot only at first access.\nThis is to reduce response latency by loading only what is really necessary to process the request at hand.\nThis means that the first few requests might take longer until all required memory has been brought back.

\n\nThe time to take an instance snapshot during scale-to-zero depends on the amount of memory touched by the application since it was last started.\n:::\n" + }, + { + "name": "services", + "description": "Unikraft Cloud uses *services* to implement publishing network services and creating load balanced services.\n\nA service has a public DNS name such as `my-project.fra0.kraft.host`.\nIf you do not specify a DNS name when you create a service, Unikraft Cloud generates a random DNS name of the form `young-monkey-uq6dxq0u.fra0.kraft.host`.\nWhen you assign an instance to a service, the instance becomes accessible from the Internet using this DNS name.\nUnikraft Cloud also supports [custom domains](/docs/api/v1/certificates) like `www.example.com` and wildcard domains like `*.example.com`.\n\n:::note\nExcept for unencrypted HTTP traffic on port 80, Unikraft Cloud accepts only TLS connections from the Internet.\nIt uses Server Name Indication (SNI) to forward inbound traffic to your application.\n:::\n\nBy default, a service does not publish any network ports.\nTo allow traffic to pass to the instances in a service, you have to explicitly specify the network ports to publish.\nFor example, if you run a web server you would publish port 443 (HTTPS) and/or port 80 (HTTP).\nYou can also redirect port 80 (HTTP) to port 443 (HTTPS).\n\n### Connection Handlers \n\nUnikraft Cloud uses connection handlers to decide how to forward connections from the Internet to your application.\nYou configure the handlers for every published service port individually.\nThe following handlers are available:\n\nHandler | Description\n-----------|---\n`tls` | Terminate the TLS connection at the Unikraft Cloud gateway using our wildcard certificate issued for the `kraft.cloud` domain. The gateway forwards the unencrypted traffic to your application\n`http` | Enable HTTP mode on the load balancer to load balance on the level of individual HTTP requests. In this mode, only HTTP connections are accepted. If this option is not set the load balancer works in TCP mode and balances TCP connections\n`redirect` | Redirect traffic from the source port to the destination port\n\nCurrently, there is a set of constraints when publishing ports:\n\n- Port 80: *Must* have `http` and *must not* have `tls` set\n- Port 443: *Must* have `http` and `tls` set\n- The `redirect` handler can only be set on port 80 (HTTP) to redirect to port 443 (HTTPS)\n- All other ports *must* have `tls` and *must not* have `http` set\n\n### Load Balancing\n\nLoad balancing in Unikraft Cloud is very easy.\nAs soon as you attach more than one instance to a service, Unikraft Cloud will start balancing traffic between them.\nTherefore, only instances publishing the same ports must be part of the same service.\n\nYou can remove instances from a service at any time.\nUnikraft Cloud will immediately take the instance out of the load balancing.\n\nIf you want to make sure that no existing connections are dropped when stopping an instance, use the draining feature of the [PUT /v1/instances/stop](/docs/api/v1/instances#stop) endpoint.\n\n#### Soft-/Hard Limits \n\nServices have soft and hard limits for the number of concurrent requests and connections.\nThe limits are applied **per instance**.\nFor HTTP services (i.e., the `http` [handler](#handlers) is set) each individual in-flight request is accounted against the limit, but not the underlying TCP connection.\nFor TCP services the individual open connections are counted.\nIn the following, we use the term request to refer to both requests and connections.\n\nThe soft limit is used by the Unikraft Cloud load balancer to decide when to wake up another [standby](/docs/api/v1/instances#states) instance.\nFor example, if the soft limit is set to 5 and the service consists of 2 standby instances, one of the instances receives up to 5 concurrent requests.\nThe 6th parallel requests wakes up the second instance.\nIf there are no more standby instances to wake up, the number of requests assigned to each instance will exceed the soft limit.\nThe load balancer makes sure that when the number of in-flight requests goes down again, instances are put into standby as fast as possible.\n\nThe hard limit defines the maximum number of concurrent requests that an instance can handle.\nThe load balancer will never assign more requests to a single instance.\nIn case there are no other instances available, excess requests fail (i.e., they are blocked and **not queued**).\n\n### Persistence\n\nWhen a service is implicitly created as part of a new instance (see [POST /v1/instances](/docs/api/v1/instances#create)) it exists only as long as its owning instance exists.\n\nIn contrast, services that you explicitly create using the [`POST /v1/services`](#create) endpoint are persistent and are not automatically deleted when the last instance leaves the service.\nYou need to delete them with the [`DELETE /v1/services`](#delete) endpoint.\n\nWhen you attach a second instance to an implicitly created service, Unikraft Cloud re-configures the service to be persistent from that point on.\n" + }, + { + "name": "users", + "description": "Information about user accounts.\n" + }, + { + "name": "volumes", + "description": "Unikraft Cloud allows you create persistent volumes.\n\n### InitRds vs. Volumes\n\nInitrd (initial ramdisk) and actual volumes serve different purposes.\nAn initrd is a file system loaded into memory during the boot process of the instance.\nAny new files created as well as any modifications made to files in the initrd are lost when the instance is stopped.\nIn contrast, a volume is a persistent storage device that keeps data across restarts.\nIn addition, it can be initialized with a set of files with one instance and then be detached and attached to a another one.\n\n### Volume States \n\nA volume can be in one of the following states:\n\nState | Description\n----------------|---\n`uninitialized` | The volume is scheduled to be created\n`initializing` | The volume is currently created and formatted\n`available` | The volume is healthy and available to be [`attached`](#attach) to an instance\n`idle` | The volume is healthy and attached to an instance. It is possible to [`detach`](#detach) it in this state\n`mounted` | The volume is currently mounted in an instance\n`busy` | There are maintenance tasks running on the volume\n`error` | The volume is in an error state that needs inspection by a Unikraft Cloud engineer\n\nThese are reported as volume `state` by the endpoints.\n" + } + ] +} diff --git a/pyproject.toml b/pyproject.toml index 10c5021..a8f8185 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "unikraft-cloud-platform" -version = "v1.0.0" -description = "A client library for accessing Unikraft Cloud Platform API" +version = "0.6.0" +description = "A client library for accessing Unikraft Cloud Platform" authors = [] requires-python = ">=3.9,<4.0" readme = "README.md" diff --git a/templates/model.py.jinja b/templates/model.py.jinja index d792797..84185ef 100644 --- a/templates/model.py.jinja +++ b/templates/model.py.jinja @@ -23,7 +23,7 @@ if TYPE_CHECKING: {% if model.additional_properties %} -{% set additional_property_type = 'Any' if model.additional_properties == True else model.additional_properties.get_type_string(quoted=not model.additional_properties.is_base_type) %} +{% set additional_property_type = 'Any' if model.additional_properties == True else model.additional_properties.get_type_string() %} {% endif %} {% set class_name = model.class_info.name %} diff --git a/unikraft_cloud_platform/__init__.py b/unikraft_cloud_platform/__init__.py index 78b8825..0d4d80b 100644 --- a/unikraft_cloud_platform/__init__.py +++ b/unikraft_cloud_platform/__init__.py @@ -1,8 +1,543 @@ -"""A client library for accessing Unikraft Cloud Platform API""" +# coding: utf-8 -from .client import AuthenticatedClient, Client +# flake8: noqa -__all__ = ( - "AuthenticatedClient", - "Client", +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +__version__ = "0.6.0" + +# Define package exports +__all__ = [ + "AutoscaleApi", + "CertificatesApi", + "ImagesApi", + "InstancesApi", + "ServicesApi", + "UsersApi", + "VolumesApi", + "ApiResponse", + "ApiClient", + "Configuration", + "OpenApiException", + "ApiTypeError", + "ApiValueError", + "ApiKeyError", + "ApiAttributeError", + "ApiException", + "AutoscaleConfig", + "AutoscaleConfigMaster", + "AutoscalePolicy", + "AutoscalePolicyStep", + "Certificate", + "CertificateServiceGroupsInner", + "CertificateValidation", + "CreateAutoscaleConfig200Response", + "CreateAutoscaleConfig200ResponseData", + "CreateAutoscaleConfig200ResponseDataCertificatesInner", + "CreateAutoscaleConfigRequest", + "CreateAutoscaleConfigRequestMaster", + "CreateAutoscalePolicy200Response", + "CreateAutoscalePolicy200ResponseData", + "CreateAutoscalePolicy200ResponseDataCertificatesInner", + "CreateAutoscalePolicyRequest", + "CreateCertificate200Response", + "CreateCertificate200ResponseData", + "CreateCertificate200ResponseDataCertificatesInner", + "CreateCertificateRequest", + "CreateInstance200Response", + "CreateInstanceRequest", + "CreateInstanceRequestEnv", + "CreateInstanceRequestScaleToZero", + "CreateInstanceRequestServiceGroup", + "CreateInstanceRequestServiceGroupDomainsInner", + "CreateInstanceRequestVolumesInner", + "CreateServices200Response", + "CreateServices200ResponseData", + "CreateServices200ResponseDataServiceGroupsInner", + "CreateServices200ResponseDataServiceGroupsInnerDomainsInner", + "CreateServices200ResponseDataServiceGroupsInnerDomainsInnerCertificate", + "CreateServicesRequest", + "CreateServicesRequestServicesInner", + "CreateServicesRequestServicesInnerDomainsInner", + "CreateServicesRequestServicesInnerDomainsInnerCertificate", + "CreateVolumes200Response", + "CreateVolumes200ResponseData", + "CreateVolumes200ResponseDataVolumesInner", + "CreateVolumesRequestInner", + "DeleteAutoscaleConfigs200Response", + "DeleteAutoscaleConfigs200ResponseData", + "DeleteAutoscaleConfigs200ResponseDataServiceGroupsInner", + "DeleteAutoscalePolicies200Response", + "DeleteAutoscalePolicies200ResponseData", + "DeleteAutoscalePolicies200ResponseDataPoliciesInner", + "DeleteAutoscalePolicyByServiceUuidAndPolicyName200Response", + "DeleteAutoscalePolicyByServiceUuidAndPolicyName200ResponseData", + "DeleteCertificateByUuid200Response", + "DeleteCertificateByUuid200ResponseData", + "DeleteCertificates200Response", + "DeleteCertificates200ResponseData", + "DeleteCertificates200ResponseDataCertificatesInner", + "DeleteCertificatesRequestInner", + "DeleteInstances200Response", + "DeleteInstances200ResponseData", + "DeleteInstances200ResponseDataInstancesInner", + "DeleteInstancesRequestInner", + "DeleteServices200Response", + "DeleteServices200ResponseData", + "DeleteServices200ResponseDataServiceGroupsInner", + "DeleteServicesRequestInner", + "DeleteVolumes200Response", + "DeleteVolumesRequestInner", + "GetAutosaclePolicies200Response", + "GetAutosaclePolicies200ResponseData", + "GetAutosaclePoliciesRequestInner", + "GetAutoscaleConfigs200Response", + "GetAutoscaleConfigs200ResponseData", + "GetAutoscaleConfigsRequestInner", + "GetAutoscalePolicyByServiceUuidAndPolicyName200Response", + "GetAutoscalePolicyByServiceUuidAndPolicyName200ResponseData", + "GetCertificateByUuid200Response", + "GetCertificateByUuid200ResponseData", + "GetCertificates200Response", + "GetCertificates200ResponseData", + "GetCertificatesDefaultResponse", + "GetCertificatesDefaultResponseErrorsInner", + "GetCertificatesRequestInner", + "GetImages200Response", + "GetImages200ResponseData", + "GetImagesRequestInner", + "GetInstanceByUuid200Response", + "GetInstanceByUuid200ResponseData", + "GetInstanceLogs200Response", + "GetInstanceLogs200ResponseData", + "GetInstanceLogs200ResponseDataInstancesInner", + "GetInstanceLogs200ResponseDataInstancesInnerAvailable", + "GetInstanceLogs200ResponseDataInstancesInnerRange", + "GetInstanceLogsRequestInner", + "GetInstanceMetrics200Response", + "GetInstanceMetrics200ResponseData", + "GetInstanceMetricsRequestInner", + "GetInstances200Response", + "GetInstances200ResponseData", + "GetInstancesRequestInner", + "GetQuotaByUuid200Response", + "GetQuotaByUuid200ResponseData", + "GetQuotas200Response", + "GetQuotas200ResponseData", + "GetServiceByUuid200Response", + "GetServiceByUuid200ResponseData", + "GetServices200Response", + "GetServices200ResponseData", + "GetServices200ResponseDataServiceGroupsInner", + "GetServices200ResponseDataServiceGroupsInnerInstancesInner", + "GetServicesRequestInner", + "GetVolumes200Response", + "GetVolumes200ResponseData", + "GetVolumesRequestInner", + "Image", + "Instance", + "InstanceMetrics", + "InstanceNetworkInterfacesInner", + "InstanceRestart", + "InstanceServiceGroup", + "InstanceServiceGroupDomainsInner", + "InstanceServiceGroupDomainsInnerCertificate", + "InstanceSnapshot", + "Service", + "ServiceMapping", + "StartInstances200Response", + "StartInstances200ResponseData", + "StartInstances200ResponseDataInstancesInner", + "StartInstancesRequestInner", + "StopInstancesRequestInner", + "UserQuota", + "UserQuotaLimits", + "UserQuotaUsed", + "Volume", + "VolumeAttachedToInner", + "VolumeMountedByInner", + "WaitForInstances200Response", + "WaitForInstances200ResponseData", + "WaitForInstances200ResponseDataInstancesInner", + "WaitForInstancesRequestInner", +] + +# import apis into sdk package +from unikraft_cloud_platform.api.autoscale_api import AutoscaleApi as AutoscaleApi +from unikraft_cloud_platform.api.certificates_api import CertificatesApi as CertificatesApi +from unikraft_cloud_platform.api.images_api import ImagesApi as ImagesApi +from unikraft_cloud_platform.api.instances_api import InstancesApi as InstancesApi +from unikraft_cloud_platform.api.services_api import ServicesApi as ServicesApi +from unikraft_cloud_platform.api.users_api import UsersApi as UsersApi +from unikraft_cloud_platform.api.volumes_api import VolumesApi as VolumesApi + +# import ApiClient +from unikraft_cloud_platform.api_response import ApiResponse as ApiResponse +from unikraft_cloud_platform.api_client import ApiClient as ApiClient +from unikraft_cloud_platform.configuration import Configuration as Configuration +from unikraft_cloud_platform.exceptions import OpenApiException as OpenApiException +from unikraft_cloud_platform.exceptions import ApiTypeError as ApiTypeError +from unikraft_cloud_platform.exceptions import ApiValueError as ApiValueError +from unikraft_cloud_platform.exceptions import ApiKeyError as ApiKeyError +from unikraft_cloud_platform.exceptions import ApiAttributeError as ApiAttributeError +from unikraft_cloud_platform.exceptions import ApiException as ApiException + +# import models into sdk package +from unikraft_cloud_platform.models.autoscale_config import AutoscaleConfig as AutoscaleConfig +from unikraft_cloud_platform.models.autoscale_config_master import AutoscaleConfigMaster as AutoscaleConfigMaster +from unikraft_cloud_platform.models.autoscale_policy import AutoscalePolicy as AutoscalePolicy +from unikraft_cloud_platform.models.autoscale_policy_step import AutoscalePolicyStep as AutoscalePolicyStep +from unikraft_cloud_platform.models.certificate import Certificate as Certificate +from unikraft_cloud_platform.models.certificate_service_groups_inner import ( + CertificateServiceGroupsInner as CertificateServiceGroupsInner, +) +from unikraft_cloud_platform.models.certificate_validation import CertificateValidation as CertificateValidation +from unikraft_cloud_platform.models.create_autoscale_config200_response import ( + CreateAutoscaleConfig200Response as CreateAutoscaleConfig200Response, +) +from unikraft_cloud_platform.models.create_autoscale_config200_response_data import ( + CreateAutoscaleConfig200ResponseData as CreateAutoscaleConfig200ResponseData, +) +from unikraft_cloud_platform.models.create_autoscale_config200_response_data_certificates_inner import ( + CreateAutoscaleConfig200ResponseDataCertificatesInner as CreateAutoscaleConfig200ResponseDataCertificatesInner, +) +from unikraft_cloud_platform.models.create_autoscale_config_request import ( + CreateAutoscaleConfigRequest as CreateAutoscaleConfigRequest, +) +from unikraft_cloud_platform.models.create_autoscale_config_request_master import ( + CreateAutoscaleConfigRequestMaster as CreateAutoscaleConfigRequestMaster, +) +from unikraft_cloud_platform.models.create_autoscale_policy200_response import ( + CreateAutoscalePolicy200Response as CreateAutoscalePolicy200Response, +) +from unikraft_cloud_platform.models.create_autoscale_policy200_response_data import ( + CreateAutoscalePolicy200ResponseData as CreateAutoscalePolicy200ResponseData, +) +from unikraft_cloud_platform.models.create_autoscale_policy200_response_data_certificates_inner import ( + CreateAutoscalePolicy200ResponseDataCertificatesInner as CreateAutoscalePolicy200ResponseDataCertificatesInner, +) +from unikraft_cloud_platform.models.create_autoscale_policy_request import ( + CreateAutoscalePolicyRequest as CreateAutoscalePolicyRequest, +) +from unikraft_cloud_platform.models.create_certificate200_response import ( + CreateCertificate200Response as CreateCertificate200Response, +) +from unikraft_cloud_platform.models.create_certificate200_response_data import ( + CreateCertificate200ResponseData as CreateCertificate200ResponseData, +) +from unikraft_cloud_platform.models.create_certificate200_response_data_certificates_inner import ( + CreateCertificate200ResponseDataCertificatesInner as CreateCertificate200ResponseDataCertificatesInner, +) +from unikraft_cloud_platform.models.create_certificate_request import ( + CreateCertificateRequest as CreateCertificateRequest, +) +from unikraft_cloud_platform.models.create_instance200_response import ( + CreateInstance200Response as CreateInstance200Response, +) +from unikraft_cloud_platform.models.create_instance_request import CreateInstanceRequest as CreateInstanceRequest +from unikraft_cloud_platform.models.create_instance_request_env import ( + CreateInstanceRequestEnv as CreateInstanceRequestEnv, +) +from unikraft_cloud_platform.models.create_instance_request_scale_to_zero import ( + CreateInstanceRequestScaleToZero as CreateInstanceRequestScaleToZero, +) +from unikraft_cloud_platform.models.create_instance_request_service_group import ( + CreateInstanceRequestServiceGroup as CreateInstanceRequestServiceGroup, +) +from unikraft_cloud_platform.models.create_instance_request_service_group_domains_inner import ( + CreateInstanceRequestServiceGroupDomainsInner as CreateInstanceRequestServiceGroupDomainsInner, +) +from unikraft_cloud_platform.models.create_instance_request_volumes_inner import ( + CreateInstanceRequestVolumesInner as CreateInstanceRequestVolumesInner, +) +from unikraft_cloud_platform.models.create_services200_response import ( + CreateServices200Response as CreateServices200Response, +) +from unikraft_cloud_platform.models.create_services200_response_data import ( + CreateServices200ResponseData as CreateServices200ResponseData, +) +from unikraft_cloud_platform.models.create_services200_response_data_service_groups_inner import ( + CreateServices200ResponseDataServiceGroupsInner as CreateServices200ResponseDataServiceGroupsInner, +) +from unikraft_cloud_platform.models.create_services200_response_data_service_groups_inner_domains_inner import ( + CreateServices200ResponseDataServiceGroupsInnerDomainsInner as CreateServices200ResponseDataServiceGroupsInnerDomainsInner, +) +from unikraft_cloud_platform.models.create_services200_response_data_service_groups_inner_domains_inner_certificate import ( + CreateServices200ResponseDataServiceGroupsInnerDomainsInnerCertificate as CreateServices200ResponseDataServiceGroupsInnerDomainsInnerCertificate, +) +from unikraft_cloud_platform.models.create_services_request import CreateServicesRequest as CreateServicesRequest +from unikraft_cloud_platform.models.create_services_request_services_inner import ( + CreateServicesRequestServicesInner as CreateServicesRequestServicesInner, +) +from unikraft_cloud_platform.models.create_services_request_services_inner_domains_inner import ( + CreateServicesRequestServicesInnerDomainsInner as CreateServicesRequestServicesInnerDomainsInner, +) +from unikraft_cloud_platform.models.create_services_request_services_inner_domains_inner_certificate import ( + CreateServicesRequestServicesInnerDomainsInnerCertificate as CreateServicesRequestServicesInnerDomainsInnerCertificate, +) +from unikraft_cloud_platform.models.create_volumes200_response import ( + CreateVolumes200Response as CreateVolumes200Response, +) +from unikraft_cloud_platform.models.create_volumes200_response_data import ( + CreateVolumes200ResponseData as CreateVolumes200ResponseData, +) +from unikraft_cloud_platform.models.create_volumes200_response_data_volumes_inner import ( + CreateVolumes200ResponseDataVolumesInner as CreateVolumes200ResponseDataVolumesInner, +) +from unikraft_cloud_platform.models.create_volumes_request_inner import ( + CreateVolumesRequestInner as CreateVolumesRequestInner, +) +from unikraft_cloud_platform.models.delete_autoscale_configs200_response import ( + DeleteAutoscaleConfigs200Response as DeleteAutoscaleConfigs200Response, +) +from unikraft_cloud_platform.models.delete_autoscale_configs200_response_data import ( + DeleteAutoscaleConfigs200ResponseData as DeleteAutoscaleConfigs200ResponseData, +) +from unikraft_cloud_platform.models.delete_autoscale_configs200_response_data_service_groups_inner import ( + DeleteAutoscaleConfigs200ResponseDataServiceGroupsInner as DeleteAutoscaleConfigs200ResponseDataServiceGroupsInner, +) +from unikraft_cloud_platform.models.delete_autoscale_policies200_response import ( + DeleteAutoscalePolicies200Response as DeleteAutoscalePolicies200Response, +) +from unikraft_cloud_platform.models.delete_autoscale_policies200_response_data import ( + DeleteAutoscalePolicies200ResponseData as DeleteAutoscalePolicies200ResponseData, +) +from unikraft_cloud_platform.models.delete_autoscale_policies200_response_data_policies_inner import ( + DeleteAutoscalePolicies200ResponseDataPoliciesInner as DeleteAutoscalePolicies200ResponseDataPoliciesInner, +) +from unikraft_cloud_platform.models.delete_autoscale_policy_by_service_uuid_and_policy_name200_response import ( + DeleteAutoscalePolicyByServiceUuidAndPolicyName200Response as DeleteAutoscalePolicyByServiceUuidAndPolicyName200Response, +) +from unikraft_cloud_platform.models.delete_autoscale_policy_by_service_uuid_and_policy_name200_response_data import ( + DeleteAutoscalePolicyByServiceUuidAndPolicyName200ResponseData as DeleteAutoscalePolicyByServiceUuidAndPolicyName200ResponseData, +) +from unikraft_cloud_platform.models.delete_certificate_by_uuid200_response import ( + DeleteCertificateByUuid200Response as DeleteCertificateByUuid200Response, +) +from unikraft_cloud_platform.models.delete_certificate_by_uuid200_response_data import ( + DeleteCertificateByUuid200ResponseData as DeleteCertificateByUuid200ResponseData, +) +from unikraft_cloud_platform.models.delete_certificates200_response import ( + DeleteCertificates200Response as DeleteCertificates200Response, +) +from unikraft_cloud_platform.models.delete_certificates200_response_data import ( + DeleteCertificates200ResponseData as DeleteCertificates200ResponseData, +) +from unikraft_cloud_platform.models.delete_certificates200_response_data_certificates_inner import ( + DeleteCertificates200ResponseDataCertificatesInner as DeleteCertificates200ResponseDataCertificatesInner, +) +from unikraft_cloud_platform.models.delete_certificates_request_inner import ( + DeleteCertificatesRequestInner as DeleteCertificatesRequestInner, +) +from unikraft_cloud_platform.models.delete_instances200_response import ( + DeleteInstances200Response as DeleteInstances200Response, +) +from unikraft_cloud_platform.models.delete_instances200_response_data import ( + DeleteInstances200ResponseData as DeleteInstances200ResponseData, +) +from unikraft_cloud_platform.models.delete_instances200_response_data_instances_inner import ( + DeleteInstances200ResponseDataInstancesInner as DeleteInstances200ResponseDataInstancesInner, +) +from unikraft_cloud_platform.models.delete_instances_request_inner import ( + DeleteInstancesRequestInner as DeleteInstancesRequestInner, +) +from unikraft_cloud_platform.models.delete_services200_response import ( + DeleteServices200Response as DeleteServices200Response, +) +from unikraft_cloud_platform.models.delete_services200_response_data import ( + DeleteServices200ResponseData as DeleteServices200ResponseData, +) +from unikraft_cloud_platform.models.delete_services200_response_data_service_groups_inner import ( + DeleteServices200ResponseDataServiceGroupsInner as DeleteServices200ResponseDataServiceGroupsInner, +) +from unikraft_cloud_platform.models.delete_services_request_inner import ( + DeleteServicesRequestInner as DeleteServicesRequestInner, +) +from unikraft_cloud_platform.models.delete_volumes200_response import ( + DeleteVolumes200Response as DeleteVolumes200Response, +) +from unikraft_cloud_platform.models.delete_volumes_request_inner import ( + DeleteVolumesRequestInner as DeleteVolumesRequestInner, +) +from unikraft_cloud_platform.models.get_autosacle_policies200_response import ( + GetAutosaclePolicies200Response as GetAutosaclePolicies200Response, +) +from unikraft_cloud_platform.models.get_autosacle_policies200_response_data import ( + GetAutosaclePolicies200ResponseData as GetAutosaclePolicies200ResponseData, +) +from unikraft_cloud_platform.models.get_autosacle_policies_request_inner import ( + GetAutosaclePoliciesRequestInner as GetAutosaclePoliciesRequestInner, +) +from unikraft_cloud_platform.models.get_autoscale_configs200_response import ( + GetAutoscaleConfigs200Response as GetAutoscaleConfigs200Response, +) +from unikraft_cloud_platform.models.get_autoscale_configs200_response_data import ( + GetAutoscaleConfigs200ResponseData as GetAutoscaleConfigs200ResponseData, +) +from unikraft_cloud_platform.models.get_autoscale_configs_request_inner import ( + GetAutoscaleConfigsRequestInner as GetAutoscaleConfigsRequestInner, +) +from unikraft_cloud_platform.models.get_autoscale_policy_by_service_uuid_and_policy_name200_response import ( + GetAutoscalePolicyByServiceUuidAndPolicyName200Response as GetAutoscalePolicyByServiceUuidAndPolicyName200Response, +) +from unikraft_cloud_platform.models.get_autoscale_policy_by_service_uuid_and_policy_name200_response_data import ( + GetAutoscalePolicyByServiceUuidAndPolicyName200ResponseData as GetAutoscalePolicyByServiceUuidAndPolicyName200ResponseData, +) +from unikraft_cloud_platform.models.get_certificate_by_uuid200_response import ( + GetCertificateByUuid200Response as GetCertificateByUuid200Response, +) +from unikraft_cloud_platform.models.get_certificate_by_uuid200_response_data import ( + GetCertificateByUuid200ResponseData as GetCertificateByUuid200ResponseData, +) +from unikraft_cloud_platform.models.get_certificates200_response import ( + GetCertificates200Response as GetCertificates200Response, +) +from unikraft_cloud_platform.models.get_certificates200_response_data import ( + GetCertificates200ResponseData as GetCertificates200ResponseData, +) +from unikraft_cloud_platform.models.get_certificates_default_response import ( + GetCertificatesDefaultResponse as GetCertificatesDefaultResponse, +) +from unikraft_cloud_platform.models.get_certificates_default_response_errors_inner import ( + GetCertificatesDefaultResponseErrorsInner as GetCertificatesDefaultResponseErrorsInner, +) +from unikraft_cloud_platform.models.get_certificates_request_inner import ( + GetCertificatesRequestInner as GetCertificatesRequestInner, +) +from unikraft_cloud_platform.models.get_images200_response import GetImages200Response as GetImages200Response +from unikraft_cloud_platform.models.get_images200_response_data import ( + GetImages200ResponseData as GetImages200ResponseData, +) +from unikraft_cloud_platform.models.get_images_request_inner import GetImagesRequestInner as GetImagesRequestInner +from unikraft_cloud_platform.models.get_instance_by_uuid200_response import ( + GetInstanceByUuid200Response as GetInstanceByUuid200Response, +) +from unikraft_cloud_platform.models.get_instance_by_uuid200_response_data import ( + GetInstanceByUuid200ResponseData as GetInstanceByUuid200ResponseData, +) +from unikraft_cloud_platform.models.get_instance_logs200_response import ( + GetInstanceLogs200Response as GetInstanceLogs200Response, +) +from unikraft_cloud_platform.models.get_instance_logs200_response_data import ( + GetInstanceLogs200ResponseData as GetInstanceLogs200ResponseData, +) +from unikraft_cloud_platform.models.get_instance_logs200_response_data_instances_inner import ( + GetInstanceLogs200ResponseDataInstancesInner as GetInstanceLogs200ResponseDataInstancesInner, +) +from unikraft_cloud_platform.models.get_instance_logs200_response_data_instances_inner_available import ( + GetInstanceLogs200ResponseDataInstancesInnerAvailable as GetInstanceLogs200ResponseDataInstancesInnerAvailable, +) +from unikraft_cloud_platform.models.get_instance_logs200_response_data_instances_inner_range import ( + GetInstanceLogs200ResponseDataInstancesInnerRange as GetInstanceLogs200ResponseDataInstancesInnerRange, +) +from unikraft_cloud_platform.models.get_instance_logs_request_inner import ( + GetInstanceLogsRequestInner as GetInstanceLogsRequestInner, +) +from unikraft_cloud_platform.models.get_instance_metrics200_response import ( + GetInstanceMetrics200Response as GetInstanceMetrics200Response, +) +from unikraft_cloud_platform.models.get_instance_metrics200_response_data import ( + GetInstanceMetrics200ResponseData as GetInstanceMetrics200ResponseData, +) +from unikraft_cloud_platform.models.get_instance_metrics_request_inner import ( + GetInstanceMetricsRequestInner as GetInstanceMetricsRequestInner, +) +from unikraft_cloud_platform.models.get_instances200_response import GetInstances200Response as GetInstances200Response +from unikraft_cloud_platform.models.get_instances200_response_data import ( + GetInstances200ResponseData as GetInstances200ResponseData, +) +from unikraft_cloud_platform.models.get_instances_request_inner import ( + GetInstancesRequestInner as GetInstancesRequestInner, +) +from unikraft_cloud_platform.models.get_quota_by_uuid200_response import ( + GetQuotaByUuid200Response as GetQuotaByUuid200Response, +) +from unikraft_cloud_platform.models.get_quota_by_uuid200_response_data import ( + GetQuotaByUuid200ResponseData as GetQuotaByUuid200ResponseData, +) +from unikraft_cloud_platform.models.get_quotas200_response import GetQuotas200Response as GetQuotas200Response +from unikraft_cloud_platform.models.get_quotas200_response_data import ( + GetQuotas200ResponseData as GetQuotas200ResponseData, +) +from unikraft_cloud_platform.models.get_service_by_uuid200_response import ( + GetServiceByUuid200Response as GetServiceByUuid200Response, +) +from unikraft_cloud_platform.models.get_service_by_uuid200_response_data import ( + GetServiceByUuid200ResponseData as GetServiceByUuid200ResponseData, +) +from unikraft_cloud_platform.models.get_services200_response import GetServices200Response as GetServices200Response +from unikraft_cloud_platform.models.get_services200_response_data import ( + GetServices200ResponseData as GetServices200ResponseData, +) +from unikraft_cloud_platform.models.get_services200_response_data_service_groups_inner import ( + GetServices200ResponseDataServiceGroupsInner as GetServices200ResponseDataServiceGroupsInner, +) +from unikraft_cloud_platform.models.get_services200_response_data_service_groups_inner_instances_inner import ( + GetServices200ResponseDataServiceGroupsInnerInstancesInner as GetServices200ResponseDataServiceGroupsInnerInstancesInner, +) +from unikraft_cloud_platform.models.get_services_request_inner import GetServicesRequestInner as GetServicesRequestInner +from unikraft_cloud_platform.models.get_volumes200_response import GetVolumes200Response as GetVolumes200Response +from unikraft_cloud_platform.models.get_volumes200_response_data import ( + GetVolumes200ResponseData as GetVolumes200ResponseData, +) +from unikraft_cloud_platform.models.get_volumes_request_inner import GetVolumesRequestInner as GetVolumesRequestInner +from unikraft_cloud_platform.models.image import Image as Image +from unikraft_cloud_platform.models.instance import Instance as Instance +from unikraft_cloud_platform.models.instance_metrics import InstanceMetrics as InstanceMetrics +from unikraft_cloud_platform.models.instance_network_interfaces_inner import ( + InstanceNetworkInterfacesInner as InstanceNetworkInterfacesInner, +) +from unikraft_cloud_platform.models.instance_restart import InstanceRestart as InstanceRestart +from unikraft_cloud_platform.models.instance_service_group import InstanceServiceGroup as InstanceServiceGroup +from unikraft_cloud_platform.models.instance_service_group_domains_inner import ( + InstanceServiceGroupDomainsInner as InstanceServiceGroupDomainsInner, +) +from unikraft_cloud_platform.models.instance_service_group_domains_inner_certificate import ( + InstanceServiceGroupDomainsInnerCertificate as InstanceServiceGroupDomainsInnerCertificate, +) +from unikraft_cloud_platform.models.instance_snapshot import InstanceSnapshot as InstanceSnapshot +from unikraft_cloud_platform.models.service import Service as Service +from unikraft_cloud_platform.models.service_mapping import ServiceMapping as ServiceMapping +from unikraft_cloud_platform.models.start_instances200_response import ( + StartInstances200Response as StartInstances200Response, +) +from unikraft_cloud_platform.models.start_instances200_response_data import ( + StartInstances200ResponseData as StartInstances200ResponseData, +) +from unikraft_cloud_platform.models.start_instances200_response_data_instances_inner import ( + StartInstances200ResponseDataInstancesInner as StartInstances200ResponseDataInstancesInner, +) +from unikraft_cloud_platform.models.start_instances_request_inner import ( + StartInstancesRequestInner as StartInstancesRequestInner, +) +from unikraft_cloud_platform.models.stop_instances_request_inner import ( + StopInstancesRequestInner as StopInstancesRequestInner, +) +from unikraft_cloud_platform.models.user_quota import UserQuota as UserQuota +from unikraft_cloud_platform.models.user_quota_limits import UserQuotaLimits as UserQuotaLimits +from unikraft_cloud_platform.models.user_quota_used import UserQuotaUsed as UserQuotaUsed +from unikraft_cloud_platform.models.volume import Volume as Volume +from unikraft_cloud_platform.models.volume_attached_to_inner import VolumeAttachedToInner as VolumeAttachedToInner +from unikraft_cloud_platform.models.volume_mounted_by_inner import VolumeMountedByInner as VolumeMountedByInner +from unikraft_cloud_platform.models.wait_for_instances200_response import ( + WaitForInstances200Response as WaitForInstances200Response, +) +from unikraft_cloud_platform.models.wait_for_instances200_response_data import ( + WaitForInstances200ResponseData as WaitForInstances200ResponseData, +) +from unikraft_cloud_platform.models.wait_for_instances200_response_data_instances_inner import ( + WaitForInstances200ResponseDataInstancesInner as WaitForInstances200ResponseDataInstancesInner, +) +from unikraft_cloud_platform.models.wait_for_instances_request_inner import ( + WaitForInstancesRequestInner as WaitForInstancesRequestInner, ) diff --git a/unikraft_cloud_platform/api/__init__.py b/unikraft_cloud_platform/api/__init__.py index 81f9fa2..c82c2f4 100644 --- a/unikraft_cloud_platform/api/__init__.py +++ b/unikraft_cloud_platform/api/__init__.py @@ -1 +1,10 @@ -"""Contains methods for accessing the API""" +# flake8: noqa + +# import apis into api package +from unikraft_cloud_platform.api.autoscale_api import AutoscaleApi +from unikraft_cloud_platform.api.certificates_api import CertificatesApi +from unikraft_cloud_platform.api.images_api import ImagesApi +from unikraft_cloud_platform.api.instances_api import InstancesApi +from unikraft_cloud_platform.api.services_api import ServicesApi +from unikraft_cloud_platform.api.users_api import UsersApi +from unikraft_cloud_platform.api.volumes_api import VolumesApi diff --git a/unikraft_cloud_platform/api/autoscale/__init__.py b/unikraft_cloud_platform/api/autoscale/__init__.py deleted file mode 100644 index 2d7c0b2..0000000 --- a/unikraft_cloud_platform/api/autoscale/__init__.py +++ /dev/null @@ -1 +0,0 @@ -"""Contains endpoint functions for accessing the API""" diff --git a/unikraft_cloud_platform/api/autoscale/create_autoscale_configuration_by_service_group_uuid.py b/unikraft_cloud_platform/api/autoscale/create_autoscale_configuration_by_service_group_uuid.py deleted file mode 100644 index 52bfb35..0000000 --- a/unikraft_cloud_platform/api/autoscale/create_autoscale_configuration_by_service_group_uuid.py +++ /dev/null @@ -1,189 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union -from uuid import UUID - -import httpx - -from ...client import AuthenticatedClient, Client -from ...models.create_autoscale_configuration_by_service_group_uuid_request import ( - CreateAutoscaleConfigurationByServiceGroupUUIDRequest, -) -from ...models.create_autoscale_configurations_response import CreateAutoscaleConfigurationsResponse -from ...types import Response - - -def _get_kwargs( - uuid: UUID, - *, - body: CreateAutoscaleConfigurationByServiceGroupUUIDRequest, -) -> dict[str, Any]: - headers: dict[str, Any] = {} - - _kwargs: dict[str, Any] = { - "method": "post", - "url": f"/v1/services/{uuid}/autoscale", - } - - _kwargs["json"] = body.to_dict() - - headers["Content-Type"] = "application/json" - - _kwargs["headers"] = headers - return _kwargs - - -def _parse_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> CreateAutoscaleConfigurationsResponse: - response_default = CreateAutoscaleConfigurationsResponse.from_dict(response.json()) - - return response_default - - -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[CreateAutoscaleConfigurationsResponse]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], - body: CreateAutoscaleConfigurationByServiceGroupUUIDRequest, -) -> Response[CreateAutoscaleConfigurationsResponse]: - """Create Autoscale Configuration by Service Group UUID - - Create an autoscale configuration for the specified service group given - its UUID. - - Args: - uuid (UUID): - body (CreateAutoscaleConfigurationByServiceGroupUUIDRequest): The request message to - create an autoscale configuration for a service group - based on its UUID. - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[CreateAutoscaleConfigurationsResponse] - """ - - kwargs = _get_kwargs( - uuid=uuid, - body=body, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], - body: CreateAutoscaleConfigurationByServiceGroupUUIDRequest, -) -> Optional[CreateAutoscaleConfigurationsResponse]: - """Create Autoscale Configuration by Service Group UUID - - Create an autoscale configuration for the specified service group given - its UUID. - - Args: - uuid (UUID): - body (CreateAutoscaleConfigurationByServiceGroupUUIDRequest): The request message to - create an autoscale configuration for a service group - based on its UUID. - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - CreateAutoscaleConfigurationsResponse - """ - - return sync_detailed( - uuid=uuid, - client=client, - body=body, - ).parsed - - -async def asyncio_detailed( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], - body: CreateAutoscaleConfigurationByServiceGroupUUIDRequest, -) -> Response[CreateAutoscaleConfigurationsResponse]: - """Create Autoscale Configuration by Service Group UUID - - Create an autoscale configuration for the specified service group given - its UUID. - - Args: - uuid (UUID): - body (CreateAutoscaleConfigurationByServiceGroupUUIDRequest): The request message to - create an autoscale configuration for a service group - based on its UUID. - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[CreateAutoscaleConfigurationsResponse] - """ - - kwargs = _get_kwargs( - uuid=uuid, - body=body, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], - body: CreateAutoscaleConfigurationByServiceGroupUUIDRequest, -) -> Optional[CreateAutoscaleConfigurationsResponse]: - """Create Autoscale Configuration by Service Group UUID - - Create an autoscale configuration for the specified service group given - its UUID. - - Args: - uuid (UUID): - body (CreateAutoscaleConfigurationByServiceGroupUUIDRequest): The request message to - create an autoscale configuration for a service group - based on its UUID. - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - CreateAutoscaleConfigurationsResponse - """ - - return ( - await asyncio_detailed( - uuid=uuid, - client=client, - body=body, - ) - ).parsed diff --git a/unikraft_cloud_platform/api/autoscale/create_autoscale_configuration_policy.py b/unikraft_cloud_platform/api/autoscale/create_autoscale_configuration_policy.py deleted file mode 100644 index c7df191..0000000 --- a/unikraft_cloud_platform/api/autoscale/create_autoscale_configuration_policy.py +++ /dev/null @@ -1,186 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx - -from ...client import AuthenticatedClient, Client -from ...models.create_autoscale_configuration_policy_request import CreateAutoscaleConfigurationPolicyRequest -from ...models.create_autoscale_configuration_policy_response import CreateAutoscaleConfigurationPolicyResponse -from ...types import Response - - -def _get_kwargs( - uuid: str, - *, - body: CreateAutoscaleConfigurationPolicyRequest, -) -> dict[str, Any]: - headers: dict[str, Any] = {} - - _kwargs: dict[str, Any] = { - "method": "post", - "url": f"/v1/services/{uuid}/autoscale/policies", - } - - _kwargs["json"] = body.to_dict() - - headers["Content-Type"] = "application/json" - - _kwargs["headers"] = headers - return _kwargs - - -def _parse_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> CreateAutoscaleConfigurationPolicyResponse: - response_default = CreateAutoscaleConfigurationPolicyResponse.from_dict(response.json()) - - return response_default - - -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[CreateAutoscaleConfigurationPolicyResponse]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - uuid: str, - *, - client: Union[AuthenticatedClient, Client], - body: CreateAutoscaleConfigurationPolicyRequest, -) -> Response[CreateAutoscaleConfigurationPolicyResponse]: - """Create Autoscale Configuration Policy - - Add a new autoscale policy to an autoscale configuration given a service - group UUID. - - Args: - uuid (str): - body (CreateAutoscaleConfigurationPolicyRequest): The request message to create an - autoscale configuration policy for a - service. - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[CreateAutoscaleConfigurationPolicyResponse] - """ - - kwargs = _get_kwargs( - uuid=uuid, - body=body, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - uuid: str, - *, - client: Union[AuthenticatedClient, Client], - body: CreateAutoscaleConfigurationPolicyRequest, -) -> Optional[CreateAutoscaleConfigurationPolicyResponse]: - """Create Autoscale Configuration Policy - - Add a new autoscale policy to an autoscale configuration given a service - group UUID. - - Args: - uuid (str): - body (CreateAutoscaleConfigurationPolicyRequest): The request message to create an - autoscale configuration policy for a - service. - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - CreateAutoscaleConfigurationPolicyResponse - """ - - return sync_detailed( - uuid=uuid, - client=client, - body=body, - ).parsed - - -async def asyncio_detailed( - uuid: str, - *, - client: Union[AuthenticatedClient, Client], - body: CreateAutoscaleConfigurationPolicyRequest, -) -> Response[CreateAutoscaleConfigurationPolicyResponse]: - """Create Autoscale Configuration Policy - - Add a new autoscale policy to an autoscale configuration given a service - group UUID. - - Args: - uuid (str): - body (CreateAutoscaleConfigurationPolicyRequest): The request message to create an - autoscale configuration policy for a - service. - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[CreateAutoscaleConfigurationPolicyResponse] - """ - - kwargs = _get_kwargs( - uuid=uuid, - body=body, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - uuid: str, - *, - client: Union[AuthenticatedClient, Client], - body: CreateAutoscaleConfigurationPolicyRequest, -) -> Optional[CreateAutoscaleConfigurationPolicyResponse]: - """Create Autoscale Configuration Policy - - Add a new autoscale policy to an autoscale configuration given a service - group UUID. - - Args: - uuid (str): - body (CreateAutoscaleConfigurationPolicyRequest): The request message to create an - autoscale configuration policy for a - service. - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - CreateAutoscaleConfigurationPolicyResponse - """ - - return ( - await asyncio_detailed( - uuid=uuid, - client=client, - body=body, - ) - ).parsed diff --git a/unikraft_cloud_platform/api/autoscale/create_autoscale_configurations.py b/unikraft_cloud_platform/api/autoscale/create_autoscale_configurations.py deleted file mode 100644 index 7d13edf..0000000 --- a/unikraft_cloud_platform/api/autoscale/create_autoscale_configurations.py +++ /dev/null @@ -1,170 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx - -from ...client import AuthenticatedClient, Client -from ...models.create_autoscale_configurations_request_configuration import ( - CreateAutoscaleConfigurationsRequestConfiguration, -) -from ...models.create_autoscale_configurations_response import CreateAutoscaleConfigurationsResponse -from ...types import Response - - -def _get_kwargs( - *, - body: list["CreateAutoscaleConfigurationsRequestConfiguration"], -) -> dict[str, Any]: - headers: dict[str, Any] = {} - - _kwargs: dict[str, Any] = { - "method": "post", - "url": "/v1/services/autoscale", - } - - _kwargs["json"] = [] - for body_item_data in body: - body_item = body_item_data.to_dict() - _kwargs["json"].append(body_item) - - headers["Content-Type"] = "application/json" - - _kwargs["headers"] = headers - return _kwargs - - -def _parse_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> CreateAutoscaleConfigurationsResponse: - response_default = CreateAutoscaleConfigurationsResponse.from_dict(response.json()) - - return response_default - - -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[CreateAutoscaleConfigurationsResponse]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - *, - client: Union[AuthenticatedClient, Client], - body: list["CreateAutoscaleConfigurationsRequestConfiguration"], -) -> Response[CreateAutoscaleConfigurationsResponse]: - """Create Autoscale Configurations - - Create one or more autoscale configurations for the specified service groups - given their UUIDs or names. - - Args: - body (list['CreateAutoscaleConfigurationsRequestConfiguration']): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[CreateAutoscaleConfigurationsResponse] - """ - - kwargs = _get_kwargs( - body=body, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - *, - client: Union[AuthenticatedClient, Client], - body: list["CreateAutoscaleConfigurationsRequestConfiguration"], -) -> Optional[CreateAutoscaleConfigurationsResponse]: - """Create Autoscale Configurations - - Create one or more autoscale configurations for the specified service groups - given their UUIDs or names. - - Args: - body (list['CreateAutoscaleConfigurationsRequestConfiguration']): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - CreateAutoscaleConfigurationsResponse - """ - - return sync_detailed( - client=client, - body=body, - ).parsed - - -async def asyncio_detailed( - *, - client: Union[AuthenticatedClient, Client], - body: list["CreateAutoscaleConfigurationsRequestConfiguration"], -) -> Response[CreateAutoscaleConfigurationsResponse]: - """Create Autoscale Configurations - - Create one or more autoscale configurations for the specified service groups - given their UUIDs or names. - - Args: - body (list['CreateAutoscaleConfigurationsRequestConfiguration']): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[CreateAutoscaleConfigurationsResponse] - """ - - kwargs = _get_kwargs( - body=body, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - *, - client: Union[AuthenticatedClient, Client], - body: list["CreateAutoscaleConfigurationsRequestConfiguration"], -) -> Optional[CreateAutoscaleConfigurationsResponse]: - """Create Autoscale Configurations - - Create one or more autoscale configurations for the specified service groups - given their UUIDs or names. - - Args: - body (list['CreateAutoscaleConfigurationsRequestConfiguration']): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - CreateAutoscaleConfigurationsResponse - """ - - return ( - await asyncio_detailed( - client=client, - body=body, - ) - ).parsed diff --git a/unikraft_cloud_platform/api/autoscale/delete_autoscale_configuration_policies.py b/unikraft_cloud_platform/api/autoscale/delete_autoscale_configuration_policies.py deleted file mode 100644 index dc16564..0000000 --- a/unikraft_cloud_platform/api/autoscale/delete_autoscale_configuration_policies.py +++ /dev/null @@ -1,178 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx - -from ...client import AuthenticatedClient, Client -from ...models.delete_autoscale_configuration_policy_response import DeleteAutoscaleConfigurationPolicyResponse -from ...models.delete_policy_request import DeletePolicyRequest -from ...types import Response - - -def _get_kwargs( - uuid: str, - *, - body: DeletePolicyRequest, -) -> dict[str, Any]: - headers: dict[str, Any] = {} - - _kwargs: dict[str, Any] = { - "method": "delete", - "url": f"/v1/services/{uuid}/autoscale/policies", - } - - _kwargs["json"] = body.to_dict() - - headers["Content-Type"] = "application/json" - - _kwargs["headers"] = headers - return _kwargs - - -def _parse_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> DeleteAutoscaleConfigurationPolicyResponse: - response_default = DeleteAutoscaleConfigurationPolicyResponse.from_dict(response.json()) - - return response_default - - -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[DeleteAutoscaleConfigurationPolicyResponse]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - uuid: str, - *, - client: Union[AuthenticatedClient, Client], - body: DeletePolicyRequest, -) -> Response[DeleteAutoscaleConfigurationPolicyResponse]: - """Delete Autoscale Configuration Policies - - Delete one or more autoscale policies for a given service group. - - Args: - uuid (str): - body (DeletePolicyRequest): The request message to delete an autoscale configuration - policy by name. - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[DeleteAutoscaleConfigurationPolicyResponse] - """ - - kwargs = _get_kwargs( - uuid=uuid, - body=body, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - uuid: str, - *, - client: Union[AuthenticatedClient, Client], - body: DeletePolicyRequest, -) -> Optional[DeleteAutoscaleConfigurationPolicyResponse]: - """Delete Autoscale Configuration Policies - - Delete one or more autoscale policies for a given service group. - - Args: - uuid (str): - body (DeletePolicyRequest): The request message to delete an autoscale configuration - policy by name. - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - DeleteAutoscaleConfigurationPolicyResponse - """ - - return sync_detailed( - uuid=uuid, - client=client, - body=body, - ).parsed - - -async def asyncio_detailed( - uuid: str, - *, - client: Union[AuthenticatedClient, Client], - body: DeletePolicyRequest, -) -> Response[DeleteAutoscaleConfigurationPolicyResponse]: - """Delete Autoscale Configuration Policies - - Delete one or more autoscale policies for a given service group. - - Args: - uuid (str): - body (DeletePolicyRequest): The request message to delete an autoscale configuration - policy by name. - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[DeleteAutoscaleConfigurationPolicyResponse] - """ - - kwargs = _get_kwargs( - uuid=uuid, - body=body, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - uuid: str, - *, - client: Union[AuthenticatedClient, Client], - body: DeletePolicyRequest, -) -> Optional[DeleteAutoscaleConfigurationPolicyResponse]: - """Delete Autoscale Configuration Policies - - Delete one or more autoscale policies for a given service group. - - Args: - uuid (str): - body (DeletePolicyRequest): The request message to delete an autoscale configuration - policy by name. - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - DeleteAutoscaleConfigurationPolicyResponse - """ - - return ( - await asyncio_detailed( - uuid=uuid, - client=client, - body=body, - ) - ).parsed diff --git a/unikraft_cloud_platform/api/autoscale/delete_autoscale_configuration_policy_by_name.py b/unikraft_cloud_platform/api/autoscale/delete_autoscale_configuration_policy_by_name.py deleted file mode 100644 index dfc9862..0000000 --- a/unikraft_cloud_platform/api/autoscale/delete_autoscale_configuration_policy_by_name.py +++ /dev/null @@ -1,166 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union -from uuid import UUID - -import httpx - -from ...client import AuthenticatedClient, Client -from ...models.delete_autoscale_configuration_policy_response import DeleteAutoscaleConfigurationPolicyResponse -from ...types import Response - - -def _get_kwargs( - uuid: UUID, - name: str, -) -> dict[str, Any]: - _kwargs: dict[str, Any] = { - "method": "delete", - "url": f"/v1/services/{uuid}/autoscale/policies/{name}", - } - - return _kwargs - - -def _parse_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> DeleteAutoscaleConfigurationPolicyResponse: - response_default = DeleteAutoscaleConfigurationPolicyResponse.from_dict(response.json()) - - return response_default - - -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[DeleteAutoscaleConfigurationPolicyResponse]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - uuid: UUID, - name: str, - *, - client: Union[AuthenticatedClient, Client], -) -> Response[DeleteAutoscaleConfigurationPolicyResponse]: - """Delete Autoscale Configuration Policy by Name - - Delete an autoscale policy by name given the service group UUID. - - Args: - uuid (UUID): - name (str): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[DeleteAutoscaleConfigurationPolicyResponse] - """ - - kwargs = _get_kwargs( - uuid=uuid, - name=name, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - uuid: UUID, - name: str, - *, - client: Union[AuthenticatedClient, Client], -) -> Optional[DeleteAutoscaleConfigurationPolicyResponse]: - """Delete Autoscale Configuration Policy by Name - - Delete an autoscale policy by name given the service group UUID. - - Args: - uuid (UUID): - name (str): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - DeleteAutoscaleConfigurationPolicyResponse - """ - - return sync_detailed( - uuid=uuid, - name=name, - client=client, - ).parsed - - -async def asyncio_detailed( - uuid: UUID, - name: str, - *, - client: Union[AuthenticatedClient, Client], -) -> Response[DeleteAutoscaleConfigurationPolicyResponse]: - """Delete Autoscale Configuration Policy by Name - - Delete an autoscale policy by name given the service group UUID. - - Args: - uuid (UUID): - name (str): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[DeleteAutoscaleConfigurationPolicyResponse] - """ - - kwargs = _get_kwargs( - uuid=uuid, - name=name, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - uuid: UUID, - name: str, - *, - client: Union[AuthenticatedClient, Client], -) -> Optional[DeleteAutoscaleConfigurationPolicyResponse]: - """Delete Autoscale Configuration Policy by Name - - Delete an autoscale policy by name given the service group UUID. - - Args: - uuid (UUID): - name (str): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - DeleteAutoscaleConfigurationPolicyResponse - """ - - return ( - await asyncio_detailed( - uuid=uuid, - name=name, - client=client, - ) - ).parsed diff --git a/unikraft_cloud_platform/api/autoscale/delete_autoscale_configurations.py b/unikraft_cloud_platform/api/autoscale/delete_autoscale_configurations.py deleted file mode 100644 index f3f6416..0000000 --- a/unikraft_cloud_platform/api/autoscale/delete_autoscale_configurations.py +++ /dev/null @@ -1,168 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx - -from ...client import AuthenticatedClient, Client -from ...models.delete_autoscale_configurations_response import DeleteAutoscaleConfigurationsResponse -from ...models.name_or_uuid import NameOrUUID -from ...types import Response - - -def _get_kwargs( - *, - body: list["NameOrUUID"], -) -> dict[str, Any]: - headers: dict[str, Any] = {} - - _kwargs: dict[str, Any] = { - "method": "delete", - "url": "/v1/services/autoscale", - } - - _kwargs["json"] = [] - for body_item_data in body: - body_item = body_item_data.to_dict() - _kwargs["json"].append(body_item) - - headers["Content-Type"] = "application/json" - - _kwargs["headers"] = headers - return _kwargs - - -def _parse_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> DeleteAutoscaleConfigurationsResponse: - response_default = DeleteAutoscaleConfigurationsResponse.from_dict(response.json()) - - return response_default - - -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[DeleteAutoscaleConfigurationsResponse]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - *, - client: Union[AuthenticatedClient, Client], - body: list["NameOrUUID"], -) -> Response[DeleteAutoscaleConfigurationsResponse]: - """Delete Autoscale Configurations - - Delete autoscale configuration for a given set of service groups given - their UUIDs or names. - - Args: - body (list['NameOrUUID']): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[DeleteAutoscaleConfigurationsResponse] - """ - - kwargs = _get_kwargs( - body=body, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - *, - client: Union[AuthenticatedClient, Client], - body: list["NameOrUUID"], -) -> Optional[DeleteAutoscaleConfigurationsResponse]: - """Delete Autoscale Configurations - - Delete autoscale configuration for a given set of service groups given - their UUIDs or names. - - Args: - body (list['NameOrUUID']): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - DeleteAutoscaleConfigurationsResponse - """ - - return sync_detailed( - client=client, - body=body, - ).parsed - - -async def asyncio_detailed( - *, - client: Union[AuthenticatedClient, Client], - body: list["NameOrUUID"], -) -> Response[DeleteAutoscaleConfigurationsResponse]: - """Delete Autoscale Configurations - - Delete autoscale configuration for a given set of service groups given - their UUIDs or names. - - Args: - body (list['NameOrUUID']): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[DeleteAutoscaleConfigurationsResponse] - """ - - kwargs = _get_kwargs( - body=body, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - *, - client: Union[AuthenticatedClient, Client], - body: list["NameOrUUID"], -) -> Optional[DeleteAutoscaleConfigurationsResponse]: - """Delete Autoscale Configurations - - Delete autoscale configuration for a given set of service groups given - their UUIDs or names. - - Args: - body (list['NameOrUUID']): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - DeleteAutoscaleConfigurationsResponse - """ - - return ( - await asyncio_detailed( - client=client, - body=body, - ) - ).parsed diff --git a/unikraft_cloud_platform/api/autoscale/delete_autoscale_configurations_by_service_group_uuid.py b/unikraft_cloud_platform/api/autoscale/delete_autoscale_configurations_by_service_group_uuid.py deleted file mode 100644 index 77597f6..0000000 --- a/unikraft_cloud_platform/api/autoscale/delete_autoscale_configurations_by_service_group_uuid.py +++ /dev/null @@ -1,181 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union -from uuid import UUID - -import httpx - -from ...client import AuthenticatedClient, Client -from ...models.delete_autoscale_configurations_response import DeleteAutoscaleConfigurationsResponse -from ...types import Response - - -def _get_kwargs( - uuid: UUID, -) -> dict[str, Any]: - _kwargs: dict[str, Any] = { - "method": "delete", - "url": f"/v1/services/{uuid}/autoscale", - } - - return _kwargs - - -def _parse_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> DeleteAutoscaleConfigurationsResponse: - response_default = DeleteAutoscaleConfigurationsResponse.from_dict(response.json()) - - return response_default - - -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[DeleteAutoscaleConfigurationsResponse]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], -) -> Response[DeleteAutoscaleConfigurationsResponse]: - """Delete Autoscale Configurations by Service Group UUID - - Delete the autoscale configuration for the service group given its UUID. - - Unikraft Cloud will immediately drain all connections from all instances - that have been created by autoscale and delete the instances afterwards. - The draining phase is allowed to take at most `cooldown_time_ms` - milliseconds after which remaining connections are forcefully closed. The - master instance is never deleted. However, deleting the autoscale - configuration causes the master instance to start if it is stopped. - - Args: - uuid (UUID): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[DeleteAutoscaleConfigurationsResponse] - """ - - kwargs = _get_kwargs( - uuid=uuid, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], -) -> Optional[DeleteAutoscaleConfigurationsResponse]: - """Delete Autoscale Configurations by Service Group UUID - - Delete the autoscale configuration for the service group given its UUID. - - Unikraft Cloud will immediately drain all connections from all instances - that have been created by autoscale and delete the instances afterwards. - The draining phase is allowed to take at most `cooldown_time_ms` - milliseconds after which remaining connections are forcefully closed. The - master instance is never deleted. However, deleting the autoscale - configuration causes the master instance to start if it is stopped. - - Args: - uuid (UUID): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - DeleteAutoscaleConfigurationsResponse - """ - - return sync_detailed( - uuid=uuid, - client=client, - ).parsed - - -async def asyncio_detailed( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], -) -> Response[DeleteAutoscaleConfigurationsResponse]: - """Delete Autoscale Configurations by Service Group UUID - - Delete the autoscale configuration for the service group given its UUID. - - Unikraft Cloud will immediately drain all connections from all instances - that have been created by autoscale and delete the instances afterwards. - The draining phase is allowed to take at most `cooldown_time_ms` - milliseconds after which remaining connections are forcefully closed. The - master instance is never deleted. However, deleting the autoscale - configuration causes the master instance to start if it is stopped. - - Args: - uuid (UUID): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[DeleteAutoscaleConfigurationsResponse] - """ - - kwargs = _get_kwargs( - uuid=uuid, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], -) -> Optional[DeleteAutoscaleConfigurationsResponse]: - """Delete Autoscale Configurations by Service Group UUID - - Delete the autoscale configuration for the service group given its UUID. - - Unikraft Cloud will immediately drain all connections from all instances - that have been created by autoscale and delete the instances afterwards. - The draining phase is allowed to take at most `cooldown_time_ms` - milliseconds after which remaining connections are forcefully closed. The - master instance is never deleted. However, deleting the autoscale - configuration causes the master instance to start if it is stopped. - - Args: - uuid (UUID): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - DeleteAutoscaleConfigurationsResponse - """ - - return ( - await asyncio_detailed( - uuid=uuid, - client=client, - ) - ).parsed diff --git a/unikraft_cloud_platform/api/autoscale/get_autoscale_configuration_policies.py b/unikraft_cloud_platform/api/autoscale/get_autoscale_configuration_policies.py deleted file mode 100644 index 192754f..0000000 --- a/unikraft_cloud_platform/api/autoscale/get_autoscale_configuration_policies.py +++ /dev/null @@ -1,178 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx - -from ...client import AuthenticatedClient, Client -from ...models.get_autoscale_configuration_policy_request import GetAutoscaleConfigurationPolicyRequest -from ...models.get_autoscale_configuration_policy_response import GetAutoscaleConfigurationPolicyResponse -from ...types import Response - - -def _get_kwargs( - uuid: str, - *, - body: GetAutoscaleConfigurationPolicyRequest, -) -> dict[str, Any]: - headers: dict[str, Any] = {} - - _kwargs: dict[str, Any] = { - "method": "get", - "url": f"/v1/services/{uuid}/autoscale/policies", - } - - _kwargs["json"] = body.to_dict() - - headers["Content-Type"] = "application/json" - - _kwargs["headers"] = headers - return _kwargs - - -def _parse_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> GetAutoscaleConfigurationPolicyResponse: - response_default = GetAutoscaleConfigurationPolicyResponse.from_dict(response.json()) - - return response_default - - -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[GetAutoscaleConfigurationPolicyResponse]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - uuid: str, - *, - client: Union[AuthenticatedClient, Client], - body: GetAutoscaleConfigurationPolicyRequest, -) -> Response[GetAutoscaleConfigurationPolicyResponse]: - """List Autoscale Configuration Policies - - List the autoscale policies for a given service group given its UUID. - - Args: - uuid (str): - body (GetAutoscaleConfigurationPolicyRequest): The request message to get an autoscale - configuration policy by name. - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[GetAutoscaleConfigurationPolicyResponse] - """ - - kwargs = _get_kwargs( - uuid=uuid, - body=body, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - uuid: str, - *, - client: Union[AuthenticatedClient, Client], - body: GetAutoscaleConfigurationPolicyRequest, -) -> Optional[GetAutoscaleConfigurationPolicyResponse]: - """List Autoscale Configuration Policies - - List the autoscale policies for a given service group given its UUID. - - Args: - uuid (str): - body (GetAutoscaleConfigurationPolicyRequest): The request message to get an autoscale - configuration policy by name. - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - GetAutoscaleConfigurationPolicyResponse - """ - - return sync_detailed( - uuid=uuid, - client=client, - body=body, - ).parsed - - -async def asyncio_detailed( - uuid: str, - *, - client: Union[AuthenticatedClient, Client], - body: GetAutoscaleConfigurationPolicyRequest, -) -> Response[GetAutoscaleConfigurationPolicyResponse]: - """List Autoscale Configuration Policies - - List the autoscale policies for a given service group given its UUID. - - Args: - uuid (str): - body (GetAutoscaleConfigurationPolicyRequest): The request message to get an autoscale - configuration policy by name. - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[GetAutoscaleConfigurationPolicyResponse] - """ - - kwargs = _get_kwargs( - uuid=uuid, - body=body, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - uuid: str, - *, - client: Union[AuthenticatedClient, Client], - body: GetAutoscaleConfigurationPolicyRequest, -) -> Optional[GetAutoscaleConfigurationPolicyResponse]: - """List Autoscale Configuration Policies - - List the autoscale policies for a given service group given its UUID. - - Args: - uuid (str): - body (GetAutoscaleConfigurationPolicyRequest): The request message to get an autoscale - configuration policy by name. - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - GetAutoscaleConfigurationPolicyResponse - """ - - return ( - await asyncio_detailed( - uuid=uuid, - client=client, - body=body, - ) - ).parsed diff --git a/unikraft_cloud_platform/api/autoscale/get_autoscale_configuration_policy_by_name.py b/unikraft_cloud_platform/api/autoscale/get_autoscale_configuration_policy_by_name.py deleted file mode 100644 index b309f80..0000000 --- a/unikraft_cloud_platform/api/autoscale/get_autoscale_configuration_policy_by_name.py +++ /dev/null @@ -1,170 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union -from uuid import UUID - -import httpx - -from ...client import AuthenticatedClient, Client -from ...models.get_autoscale_configuration_policy_response import GetAutoscaleConfigurationPolicyResponse -from ...types import Response - - -def _get_kwargs( - uuid: UUID, - name: str, -) -> dict[str, Any]: - _kwargs: dict[str, Any] = { - "method": "get", - "url": f"/v1/services/{uuid}/autoscale/policies/{name}", - } - - return _kwargs - - -def _parse_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> GetAutoscaleConfigurationPolicyResponse: - response_default = GetAutoscaleConfigurationPolicyResponse.from_dict(response.json()) - - return response_default - - -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[GetAutoscaleConfigurationPolicyResponse]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - uuid: UUID, - name: str, - *, - client: Union[AuthenticatedClient, Client], -) -> Response[GetAutoscaleConfigurationPolicyResponse]: - """Get Autoscale Configuration Policy by Name - - Return the current state and configuration of an autoscale policy given - the service group UUID and the name of the policy. - - Args: - uuid (UUID): - name (str): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[GetAutoscaleConfigurationPolicyResponse] - """ - - kwargs = _get_kwargs( - uuid=uuid, - name=name, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - uuid: UUID, - name: str, - *, - client: Union[AuthenticatedClient, Client], -) -> Optional[GetAutoscaleConfigurationPolicyResponse]: - """Get Autoscale Configuration Policy by Name - - Return the current state and configuration of an autoscale policy given - the service group UUID and the name of the policy. - - Args: - uuid (UUID): - name (str): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - GetAutoscaleConfigurationPolicyResponse - """ - - return sync_detailed( - uuid=uuid, - name=name, - client=client, - ).parsed - - -async def asyncio_detailed( - uuid: UUID, - name: str, - *, - client: Union[AuthenticatedClient, Client], -) -> Response[GetAutoscaleConfigurationPolicyResponse]: - """Get Autoscale Configuration Policy by Name - - Return the current state and configuration of an autoscale policy given - the service group UUID and the name of the policy. - - Args: - uuid (UUID): - name (str): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[GetAutoscaleConfigurationPolicyResponse] - """ - - kwargs = _get_kwargs( - uuid=uuid, - name=name, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - uuid: UUID, - name: str, - *, - client: Union[AuthenticatedClient, Client], -) -> Optional[GetAutoscaleConfigurationPolicyResponse]: - """Get Autoscale Configuration Policy by Name - - Return the current state and configuration of an autoscale policy given - the service group UUID and the name of the policy. - - Args: - uuid (UUID): - name (str): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - GetAutoscaleConfigurationPolicyResponse - """ - - return ( - await asyncio_detailed( - uuid=uuid, - name=name, - client=client, - ) - ).parsed diff --git a/unikraft_cloud_platform/api/autoscale/get_autoscale_configurations.py b/unikraft_cloud_platform/api/autoscale/get_autoscale_configurations.py deleted file mode 100644 index 11e33d1..0000000 --- a/unikraft_cloud_platform/api/autoscale/get_autoscale_configurations.py +++ /dev/null @@ -1,168 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx - -from ...client import AuthenticatedClient, Client -from ...models.get_autoscale_configurations_response import GetAutoscaleConfigurationsResponse -from ...models.name_or_uuid import NameOrUUID -from ...types import Response - - -def _get_kwargs( - *, - body: list["NameOrUUID"], -) -> dict[str, Any]: - headers: dict[str, Any] = {} - - _kwargs: dict[str, Any] = { - "method": "get", - "url": "/v1/services/autoscale", - } - - _kwargs["json"] = [] - for body_item_data in body: - body_item = body_item_data.to_dict() - _kwargs["json"].append(body_item) - - headers["Content-Type"] = "application/json" - - _kwargs["headers"] = headers - return _kwargs - - -def _parse_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> GetAutoscaleConfigurationsResponse: - response_default = GetAutoscaleConfigurationsResponse.from_dict(response.json()) - - return response_default - - -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[GetAutoscaleConfigurationsResponse]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - *, - client: Union[AuthenticatedClient, Client], - body: list["NameOrUUID"], -) -> Response[GetAutoscaleConfigurationsResponse]: - """List Autoscale Configurations - - Return the current states and configurations of autoscale configurations - for a given set of service groups given their UUIDs or names. - - Args: - body (list['NameOrUUID']): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[GetAutoscaleConfigurationsResponse] - """ - - kwargs = _get_kwargs( - body=body, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - *, - client: Union[AuthenticatedClient, Client], - body: list["NameOrUUID"], -) -> Optional[GetAutoscaleConfigurationsResponse]: - """List Autoscale Configurations - - Return the current states and configurations of autoscale configurations - for a given set of service groups given their UUIDs or names. - - Args: - body (list['NameOrUUID']): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - GetAutoscaleConfigurationsResponse - """ - - return sync_detailed( - client=client, - body=body, - ).parsed - - -async def asyncio_detailed( - *, - client: Union[AuthenticatedClient, Client], - body: list["NameOrUUID"], -) -> Response[GetAutoscaleConfigurationsResponse]: - """List Autoscale Configurations - - Return the current states and configurations of autoscale configurations - for a given set of service groups given their UUIDs or names. - - Args: - body (list['NameOrUUID']): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[GetAutoscaleConfigurationsResponse] - """ - - kwargs = _get_kwargs( - body=body, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - *, - client: Union[AuthenticatedClient, Client], - body: list["NameOrUUID"], -) -> Optional[GetAutoscaleConfigurationsResponse]: - """List Autoscale Configurations - - Return the current states and configurations of autoscale configurations - for a given set of service groups given their UUIDs or names. - - Args: - body (list['NameOrUUID']): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - GetAutoscaleConfigurationsResponse - """ - - return ( - await asyncio_detailed( - client=client, - body=body, - ) - ).parsed diff --git a/unikraft_cloud_platform/api/autoscale/get_autoscale_configurations_by_service_group_uuid.py b/unikraft_cloud_platform/api/autoscale/get_autoscale_configurations_by_service_group_uuid.py deleted file mode 100644 index 56bb9bd..0000000 --- a/unikraft_cloud_platform/api/autoscale/get_autoscale_configurations_by_service_group_uuid.py +++ /dev/null @@ -1,157 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union -from uuid import UUID - -import httpx - -from ...client import AuthenticatedClient, Client -from ...models.get_autoscale_configurations_response import GetAutoscaleConfigurationsResponse -from ...types import Response - - -def _get_kwargs( - uuid: UUID, -) -> dict[str, Any]: - _kwargs: dict[str, Any] = { - "method": "get", - "url": f"/v1/services/{uuid}/autoscale", - } - - return _kwargs - - -def _parse_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> GetAutoscaleConfigurationsResponse: - response_default = GetAutoscaleConfigurationsResponse.from_dict(response.json()) - - return response_default - - -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[GetAutoscaleConfigurationsResponse]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], -) -> Response[GetAutoscaleConfigurationsResponse]: - """Get Autoscale Configurations by Service Group UUID - - Return the current states and configurations of autoscale configurations - given a service group UUID. - - Args: - uuid (UUID): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[GetAutoscaleConfigurationsResponse] - """ - - kwargs = _get_kwargs( - uuid=uuid, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], -) -> Optional[GetAutoscaleConfigurationsResponse]: - """Get Autoscale Configurations by Service Group UUID - - Return the current states and configurations of autoscale configurations - given a service group UUID. - - Args: - uuid (UUID): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - GetAutoscaleConfigurationsResponse - """ - - return sync_detailed( - uuid=uuid, - client=client, - ).parsed - - -async def asyncio_detailed( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], -) -> Response[GetAutoscaleConfigurationsResponse]: - """Get Autoscale Configurations by Service Group UUID - - Return the current states and configurations of autoscale configurations - given a service group UUID. - - Args: - uuid (UUID): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[GetAutoscaleConfigurationsResponse] - """ - - kwargs = _get_kwargs( - uuid=uuid, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], -) -> Optional[GetAutoscaleConfigurationsResponse]: - """Get Autoscale Configurations by Service Group UUID - - Return the current states and configurations of autoscale configurations - given a service group UUID. - - Args: - uuid (UUID): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - GetAutoscaleConfigurationsResponse - """ - - return ( - await asyncio_detailed( - uuid=uuid, - client=client, - ) - ).parsed diff --git a/unikraft_cloud_platform/api/autoscale_api.py b/unikraft_cloud_platform/api/autoscale_api.py new file mode 100644 index 0000000..4bbc999 --- /dev/null +++ b/unikraft_cloud_platform/api/autoscale_api.py @@ -0,0 +1,2584 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +import warnings +from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt +from typing import Any, Dict, List, Optional, Tuple, Union +from typing_extensions import Annotated + +from pydantic import Field +from typing import List, Optional +from typing_extensions import Annotated +from uuid import UUID +from unikraft_cloud_platform.models.create_autoscale_config200_response import CreateAutoscaleConfig200Response +from unikraft_cloud_platform.models.create_autoscale_config_request import CreateAutoscaleConfigRequest +from unikraft_cloud_platform.models.create_autoscale_policy200_response import CreateAutoscalePolicy200Response +from unikraft_cloud_platform.models.create_autoscale_policy_request import CreateAutoscalePolicyRequest +from unikraft_cloud_platform.models.delete_autoscale_configs200_response import DeleteAutoscaleConfigs200Response +from unikraft_cloud_platform.models.delete_autoscale_policies200_response import DeleteAutoscalePolicies200Response +from unikraft_cloud_platform.models.delete_autoscale_policy_by_service_uuid_and_policy_name200_response import ( + DeleteAutoscalePolicyByServiceUuidAndPolicyName200Response, +) +from unikraft_cloud_platform.models.get_autosacle_policies200_response import GetAutosaclePolicies200Response +from unikraft_cloud_platform.models.get_autosacle_policies_request_inner import GetAutosaclePoliciesRequestInner +from unikraft_cloud_platform.models.get_autoscale_configs200_response import GetAutoscaleConfigs200Response +from unikraft_cloud_platform.models.get_autoscale_configs_request_inner import GetAutoscaleConfigsRequestInner +from unikraft_cloud_platform.models.get_autoscale_policy_by_service_uuid_and_policy_name200_response import ( + GetAutoscalePolicyByServiceUuidAndPolicyName200Response, +) + +from unikraft_cloud_platform.api_client import ApiClient, RequestSerialized +from unikraft_cloud_platform.api_response import ApiResponse +from unikraft_cloud_platform.rest import RESTResponseType + + +class AutoscaleApi: + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, api_client=None) -> None: + if api_client is None: + api_client = ApiClient.get_default() + self.api_client = api_client + + @validate_call + def create_autoscale_config( + self, + create_autoscale_config_request: CreateAutoscaleConfigRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> CreateAutoscaleConfig200Response: + """Create autoscale configuration + + Creates an autoscale configuration for the specified service. + + :param create_autoscale_config_request: (required) + :type create_autoscale_config_request: CreateAutoscaleConfigRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._create_autoscale_config_serialize( + create_autoscale_config_request=create_autoscale_config_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "CreateAutoscaleConfig200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def create_autoscale_config_with_http_info( + self, + create_autoscale_config_request: CreateAutoscaleConfigRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[CreateAutoscaleConfig200Response]: + """Create autoscale configuration + + Creates an autoscale configuration for the specified service. + + :param create_autoscale_config_request: (required) + :type create_autoscale_config_request: CreateAutoscaleConfigRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._create_autoscale_config_serialize( + create_autoscale_config_request=create_autoscale_config_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "CreateAutoscaleConfig200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def create_autoscale_config_without_preload_content( + self, + create_autoscale_config_request: CreateAutoscaleConfigRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Create autoscale configuration + + Creates an autoscale configuration for the specified service. + + :param create_autoscale_config_request: (required) + :type create_autoscale_config_request: CreateAutoscaleConfigRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._create_autoscale_config_serialize( + create_autoscale_config_request=create_autoscale_config_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "CreateAutoscaleConfig200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _create_autoscale_config_serialize( + self, + create_autoscale_config_request, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if create_autoscale_config_request is not None: + _body_params = create_autoscale_config_request + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params["Content-Type"] = _content_type + else: + _default_content_type = self.api_client.select_header_content_type(["application/json"]) + if _default_content_type is not None: + _header_params["Content-Type"] = _default_content_type + + # authentication setting + _auth_settings: List[str] = ["bearerAuth"] + + return self.api_client.param_serialize( + method="POST", + resource_path="/services/autoscale", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) + + @validate_call + def create_autoscale_policy( + self, + uuid: Annotated[ + UUID, + Field( + description="The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. " + ), + ], + create_autoscale_policy_request: Optional[CreateAutoscalePolicyRequest], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> CreateAutoscalePolicy200Response: + """Create an autoscale policy + + Adds a new autoscale policy to the existing autoscale configuration of the specified service. + + :param uuid: The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. (required) + :type uuid: str + :param create_autoscale_policy_request: (required) + :type create_autoscale_policy_request: CreateAutoscalePolicyRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._create_autoscale_policy_serialize( + uuid=uuid, + create_autoscale_policy_request=create_autoscale_policy_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "CreateAutoscalePolicy200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def create_autoscale_policy_with_http_info( + self, + uuid: Annotated[ + UUID, + Field( + description="The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. " + ), + ], + create_autoscale_policy_request: Optional[CreateAutoscalePolicyRequest], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[CreateAutoscalePolicy200Response]: + """Create an autoscale policy + + Adds a new autoscale policy to the existing autoscale configuration of the specified service. + + :param uuid: The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. (required) + :type uuid: str + :param create_autoscale_policy_request: (required) + :type create_autoscale_policy_request: CreateAutoscalePolicyRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._create_autoscale_policy_serialize( + uuid=uuid, + create_autoscale_policy_request=create_autoscale_policy_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "CreateAutoscalePolicy200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def create_autoscale_policy_without_preload_content( + self, + uuid: Annotated[ + UUID, + Field( + description="The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. " + ), + ], + create_autoscale_policy_request: Optional[CreateAutoscalePolicyRequest], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Create an autoscale policy + + Adds a new autoscale policy to the existing autoscale configuration of the specified service. + + :param uuid: The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. (required) + :type uuid: str + :param create_autoscale_policy_request: (required) + :type create_autoscale_policy_request: CreateAutoscalePolicyRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._create_autoscale_policy_serialize( + uuid=uuid, + create_autoscale_policy_request=create_autoscale_policy_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "CreateAutoscalePolicy200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _create_autoscale_policy_serialize( + self, + uuid, + create_autoscale_policy_request, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if uuid is not None: + _path_params["uuid"] = uuid + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if create_autoscale_policy_request is not None: + _body_params = create_autoscale_policy_request + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params["Content-Type"] = _content_type + else: + _default_content_type = self.api_client.select_header_content_type(["application/json"]) + if _default_content_type is not None: + _header_params["Content-Type"] = _default_content_type + + # authentication setting + _auth_settings: List[str] = ["bearerAuth"] + + return self.api_client.param_serialize( + method="POST", + resource_path="/services/{uuid}/autoscale/policies", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) + + @validate_call + def delete_autoscale_config_by_uuid( + self, + uuid: Annotated[ + UUID, + Field( + description="The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. " + ), + ], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> DeleteAutoscaleConfigs200Response: + """Delete an autoscale configuration given its UUID + + Deletes the autoscale configuration for the specified service. Unikraft Cloud will immediately drain all connections from all instances that have been created by autoscale and delete the instances afterwards. The draining phase is allowed to take at most `cooldown_time_ms` milliseconds after which remaining connections are forcefully closed. The master instance is never deleted. However, deleting the autoscale configuration causes the master instance to start if it is stopped. + + :param uuid: The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. (required) + :type uuid: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._delete_autoscale_config_by_uuid_serialize( + uuid=uuid, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "DeleteAutoscaleConfigs200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def delete_autoscale_config_by_uuid_with_http_info( + self, + uuid: Annotated[ + UUID, + Field( + description="The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. " + ), + ], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[DeleteAutoscaleConfigs200Response]: + """Delete an autoscale configuration given its UUID + + Deletes the autoscale configuration for the specified service. Unikraft Cloud will immediately drain all connections from all instances that have been created by autoscale and delete the instances afterwards. The draining phase is allowed to take at most `cooldown_time_ms` milliseconds after which remaining connections are forcefully closed. The master instance is never deleted. However, deleting the autoscale configuration causes the master instance to start if it is stopped. + + :param uuid: The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. (required) + :type uuid: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._delete_autoscale_config_by_uuid_serialize( + uuid=uuid, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "DeleteAutoscaleConfigs200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def delete_autoscale_config_by_uuid_without_preload_content( + self, + uuid: Annotated[ + UUID, + Field( + description="The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. " + ), + ], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Delete an autoscale configuration given its UUID + + Deletes the autoscale configuration for the specified service. Unikraft Cloud will immediately drain all connections from all instances that have been created by autoscale and delete the instances afterwards. The draining phase is allowed to take at most `cooldown_time_ms` milliseconds after which remaining connections are forcefully closed. The master instance is never deleted. However, deleting the autoscale configuration causes the master instance to start if it is stopped. + + :param uuid: The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. (required) + :type uuid: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._delete_autoscale_config_by_uuid_serialize( + uuid=uuid, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "DeleteAutoscaleConfigs200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _delete_autoscale_config_by_uuid_serialize( + self, + uuid, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if uuid is not None: + _path_params["uuid"] = uuid + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # authentication setting + _auth_settings: List[str] = ["bearerAuth"] + + return self.api_client.param_serialize( + method="DELETE", + resource_path="/services/{uuid}/autoscale", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) + + @validate_call + def delete_autoscale_configs( + self, + get_autoscale_configs_request_inner: Optional[List[GetAutoscaleConfigsRequestInner]] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> DeleteAutoscaleConfigs200Response: + """Delete one or more autoscale configurations + + Deletes the autoscale configuration for the specified service. Unikraft Cloud will immediately drain all connections from all instances that have been created by autoscale and delete the instances afterwards. The draining phase is allowed to take at most `cooldown_time_ms` milliseconds after which remaining connections are forcefully closed. The master instance is never deleted. However, deleting the autoscale configuration causes the master instance to start if it is stopped. + + :param get_autoscale_configs_request_inner: + :type get_autoscale_configs_request_inner: List[GetAutoscaleConfigsRequestInner] + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._delete_autoscale_configs_serialize( + get_autoscale_configs_request_inner=get_autoscale_configs_request_inner, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "DeleteAutoscaleConfigs200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def delete_autoscale_configs_with_http_info( + self, + get_autoscale_configs_request_inner: Optional[List[GetAutoscaleConfigsRequestInner]] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[DeleteAutoscaleConfigs200Response]: + """Delete one or more autoscale configurations + + Deletes the autoscale configuration for the specified service. Unikraft Cloud will immediately drain all connections from all instances that have been created by autoscale and delete the instances afterwards. The draining phase is allowed to take at most `cooldown_time_ms` milliseconds after which remaining connections are forcefully closed. The master instance is never deleted. However, deleting the autoscale configuration causes the master instance to start if it is stopped. + + :param get_autoscale_configs_request_inner: + :type get_autoscale_configs_request_inner: List[GetAutoscaleConfigsRequestInner] + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._delete_autoscale_configs_serialize( + get_autoscale_configs_request_inner=get_autoscale_configs_request_inner, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "DeleteAutoscaleConfigs200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def delete_autoscale_configs_without_preload_content( + self, + get_autoscale_configs_request_inner: Optional[List[GetAutoscaleConfigsRequestInner]] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Delete one or more autoscale configurations + + Deletes the autoscale configuration for the specified service. Unikraft Cloud will immediately drain all connections from all instances that have been created by autoscale and delete the instances afterwards. The draining phase is allowed to take at most `cooldown_time_ms` milliseconds after which remaining connections are forcefully closed. The master instance is never deleted. However, deleting the autoscale configuration causes the master instance to start if it is stopped. + + :param get_autoscale_configs_request_inner: + :type get_autoscale_configs_request_inner: List[GetAutoscaleConfigsRequestInner] + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._delete_autoscale_configs_serialize( + get_autoscale_configs_request_inner=get_autoscale_configs_request_inner, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "DeleteAutoscaleConfigs200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _delete_autoscale_configs_serialize( + self, + get_autoscale_configs_request_inner, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + _host = None + + _collection_formats: Dict[str, str] = { + "GetAutoscaleConfigsRequestInner": "", + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if get_autoscale_configs_request_inner is not None: + _body_params = get_autoscale_configs_request_inner + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params["Content-Type"] = _content_type + else: + _default_content_type = self.api_client.select_header_content_type(["application/json"]) + if _default_content_type is not None: + _header_params["Content-Type"] = _default_content_type + + # authentication setting + _auth_settings: List[str] = ["bearerAuth"] + + return self.api_client.param_serialize( + method="DELETE", + resource_path="/services/autoscale", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) + + @validate_call + def delete_autoscale_policies( + self, + uuid: Annotated[ + UUID, + Field( + description="The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. " + ), + ], + get_autosacle_policies_request_inner: Optional[List[GetAutosaclePoliciesRequestInner]] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> DeleteAutoscalePolicies200Response: + """Delete one or more autoscale policies + + Deletes the specified autoscale policies. + + :param uuid: The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. (required) + :type uuid: str + :param get_autosacle_policies_request_inner: + :type get_autosacle_policies_request_inner: List[GetAutosaclePoliciesRequestInner] + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._delete_autoscale_policies_serialize( + uuid=uuid, + get_autosacle_policies_request_inner=get_autosacle_policies_request_inner, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "DeleteAutoscalePolicies200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def delete_autoscale_policies_with_http_info( + self, + uuid: Annotated[ + UUID, + Field( + description="The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. " + ), + ], + get_autosacle_policies_request_inner: Optional[List[GetAutosaclePoliciesRequestInner]] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[DeleteAutoscalePolicies200Response]: + """Delete one or more autoscale policies + + Deletes the specified autoscale policies. + + :param uuid: The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. (required) + :type uuid: str + :param get_autosacle_policies_request_inner: + :type get_autosacle_policies_request_inner: List[GetAutosaclePoliciesRequestInner] + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._delete_autoscale_policies_serialize( + uuid=uuid, + get_autosacle_policies_request_inner=get_autosacle_policies_request_inner, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "DeleteAutoscalePolicies200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def delete_autoscale_policies_without_preload_content( + self, + uuid: Annotated[ + UUID, + Field( + description="The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. " + ), + ], + get_autosacle_policies_request_inner: Optional[List[GetAutosaclePoliciesRequestInner]] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Delete one or more autoscale policies + + Deletes the specified autoscale policies. + + :param uuid: The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. (required) + :type uuid: str + :param get_autosacle_policies_request_inner: + :type get_autosacle_policies_request_inner: List[GetAutosaclePoliciesRequestInner] + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._delete_autoscale_policies_serialize( + uuid=uuid, + get_autosacle_policies_request_inner=get_autosacle_policies_request_inner, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "DeleteAutoscalePolicies200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _delete_autoscale_policies_serialize( + self, + uuid, + get_autosacle_policies_request_inner, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + _host = None + + _collection_formats: Dict[str, str] = { + "GetAutosaclePoliciesRequestInner": "", + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if uuid is not None: + _path_params["uuid"] = uuid + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if get_autosacle_policies_request_inner is not None: + _body_params = get_autosacle_policies_request_inner + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params["Content-Type"] = _content_type + else: + _default_content_type = self.api_client.select_header_content_type(["application/json"]) + if _default_content_type is not None: + _header_params["Content-Type"] = _default_content_type + + # authentication setting + _auth_settings: List[str] = ["bearerAuth"] + + return self.api_client.param_serialize( + method="DELETE", + resource_path="/services/{uuid}/autoscale/policies", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) + + @validate_call + def delete_autoscale_policy_by_service_uuid_and_policy_name( + self, + uuid: Annotated[ + UUID, + Field( + description="The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. " + ), + ], + name: Annotated[ + str, + Field( + strict=True, + max_length=255, + description="The name of the resource. The name is a string that identifies the resource. The name is sometimes returned by the API after creating a resource. ", + ), + ], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> DeleteAutoscalePolicyByServiceUuidAndPolicyName200Response: + """Delete an autoscale policy given its service uuid and policy name + + Deletes the specified autoscale policy. + + :param uuid: The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. (required) + :type uuid: str + :param name: The name of the resource. The name is a string that identifies the resource. The name is sometimes returned by the API after creating a resource. (required) + :type name: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._delete_autoscale_policy_by_service_uuid_and_policy_name_serialize( + uuid=uuid, + name=name, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "DeleteAutoscalePolicyByServiceUuidAndPolicyName200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def delete_autoscale_policy_by_service_uuid_and_policy_name_with_http_info( + self, + uuid: Annotated[ + UUID, + Field( + description="The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. " + ), + ], + name: Annotated[ + str, + Field( + strict=True, + max_length=255, + description="The name of the resource. The name is a string that identifies the resource. The name is sometimes returned by the API after creating a resource. ", + ), + ], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[DeleteAutoscalePolicyByServiceUuidAndPolicyName200Response]: + """Delete an autoscale policy given its service uuid and policy name + + Deletes the specified autoscale policy. + + :param uuid: The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. (required) + :type uuid: str + :param name: The name of the resource. The name is a string that identifies the resource. The name is sometimes returned by the API after creating a resource. (required) + :type name: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._delete_autoscale_policy_by_service_uuid_and_policy_name_serialize( + uuid=uuid, + name=name, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "DeleteAutoscalePolicyByServiceUuidAndPolicyName200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def delete_autoscale_policy_by_service_uuid_and_policy_name_without_preload_content( + self, + uuid: Annotated[ + UUID, + Field( + description="The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. " + ), + ], + name: Annotated[ + str, + Field( + strict=True, + max_length=255, + description="The name of the resource. The name is a string that identifies the resource. The name is sometimes returned by the API after creating a resource. ", + ), + ], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Delete an autoscale policy given its service uuid and policy name + + Deletes the specified autoscale policy. + + :param uuid: The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. (required) + :type uuid: str + :param name: The name of the resource. The name is a string that identifies the resource. The name is sometimes returned by the API after creating a resource. (required) + :type name: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._delete_autoscale_policy_by_service_uuid_and_policy_name_serialize( + uuid=uuid, + name=name, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "DeleteAutoscalePolicyByServiceUuidAndPolicyName200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _delete_autoscale_policy_by_service_uuid_and_policy_name_serialize( + self, + uuid, + name, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if uuid is not None: + _path_params["uuid"] = uuid + if name is not None: + _path_params["name"] = name + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # authentication setting + _auth_settings: List[str] = ["bearerAuth"] + + return self.api_client.param_serialize( + method="DELETE", + resource_path="/services/{uuid}/autoscale/policies/{name}", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) + + @validate_call + def get_autosacle_policies( + self, + uuid: Annotated[ + UUID, + Field( + description="The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. " + ), + ], + get_autosacle_policies_request_inner: Optional[List[GetAutosaclePoliciesRequestInner]] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> GetAutosaclePolicies200Response: + """Get one or more autoscale policies + + Returns the configuration of the specified autoscale policy. + + :param uuid: The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. (required) + :type uuid: str + :param get_autosacle_policies_request_inner: + :type get_autosacle_policies_request_inner: List[GetAutosaclePoliciesRequestInner] + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_autosacle_policies_serialize( + uuid=uuid, + get_autosacle_policies_request_inner=get_autosacle_policies_request_inner, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "GetAutosaclePolicies200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def get_autosacle_policies_with_http_info( + self, + uuid: Annotated[ + UUID, + Field( + description="The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. " + ), + ], + get_autosacle_policies_request_inner: Optional[List[GetAutosaclePoliciesRequestInner]] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[GetAutosaclePolicies200Response]: + """Get one or more autoscale policies + + Returns the configuration of the specified autoscale policy. + + :param uuid: The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. (required) + :type uuid: str + :param get_autosacle_policies_request_inner: + :type get_autosacle_policies_request_inner: List[GetAutosaclePoliciesRequestInner] + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_autosacle_policies_serialize( + uuid=uuid, + get_autosacle_policies_request_inner=get_autosacle_policies_request_inner, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "GetAutosaclePolicies200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def get_autosacle_policies_without_preload_content( + self, + uuid: Annotated[ + UUID, + Field( + description="The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. " + ), + ], + get_autosacle_policies_request_inner: Optional[List[GetAutosaclePoliciesRequestInner]] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Get one or more autoscale policies + + Returns the configuration of the specified autoscale policy. + + :param uuid: The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. (required) + :type uuid: str + :param get_autosacle_policies_request_inner: + :type get_autosacle_policies_request_inner: List[GetAutosaclePoliciesRequestInner] + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_autosacle_policies_serialize( + uuid=uuid, + get_autosacle_policies_request_inner=get_autosacle_policies_request_inner, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "GetAutosaclePolicies200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _get_autosacle_policies_serialize( + self, + uuid, + get_autosacle_policies_request_inner, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + _host = None + + _collection_formats: Dict[str, str] = { + "GetAutosaclePoliciesRequestInner": "", + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if uuid is not None: + _path_params["uuid"] = uuid + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if get_autosacle_policies_request_inner is not None: + _body_params = get_autosacle_policies_request_inner + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params["Content-Type"] = _content_type + else: + _default_content_type = self.api_client.select_header_content_type(["application/json"]) + if _default_content_type is not None: + _header_params["Content-Type"] = _default_content_type + + # authentication setting + _auth_settings: List[str] = ["bearerAuth"] + + return self.api_client.param_serialize( + method="GET", + resource_path="/services/{uuid}/autoscale/policies", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) + + @validate_call + def get_autoscale_config_by_service_uuid( + self, + uuid: Annotated[ + UUID, + Field( + description="The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. " + ), + ], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> GetAutoscaleConfigs200Response: + """Get an autoscale configuration given the service UUID + + Returns the current autoscale configuration of a service. + + :param uuid: The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. (required) + :type uuid: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_autoscale_config_by_service_uuid_serialize( + uuid=uuid, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "GetAutoscaleConfigs200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def get_autoscale_config_by_service_uuid_with_http_info( + self, + uuid: Annotated[ + UUID, + Field( + description="The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. " + ), + ], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[GetAutoscaleConfigs200Response]: + """Get an autoscale configuration given the service UUID + + Returns the current autoscale configuration of a service. + + :param uuid: The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. (required) + :type uuid: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_autoscale_config_by_service_uuid_serialize( + uuid=uuid, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "GetAutoscaleConfigs200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def get_autoscale_config_by_service_uuid_without_preload_content( + self, + uuid: Annotated[ + UUID, + Field( + description="The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. " + ), + ], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Get an autoscale configuration given the service UUID + + Returns the current autoscale configuration of a service. + + :param uuid: The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. (required) + :type uuid: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_autoscale_config_by_service_uuid_serialize( + uuid=uuid, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "GetAutoscaleConfigs200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _get_autoscale_config_by_service_uuid_serialize( + self, + uuid, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if uuid is not None: + _path_params["uuid"] = uuid + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # authentication setting + _auth_settings: List[str] = ["bearerAuth"] + + return self.api_client.param_serialize( + method="GET", + resource_path="/services/{uuid}/autoscale", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) + + @validate_call + def get_autoscale_configs( + self, + get_autoscale_configs_request_inner: Optional[List[GetAutoscaleConfigsRequestInner]] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> GetAutoscaleConfigs200Response: + """Get one or more autoscale configuration + + Returns the current autoscale configuration of the supplied service(s). + + :param get_autoscale_configs_request_inner: + :type get_autoscale_configs_request_inner: List[GetAutoscaleConfigsRequestInner] + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_autoscale_configs_serialize( + get_autoscale_configs_request_inner=get_autoscale_configs_request_inner, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "GetAutoscaleConfigs200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def get_autoscale_configs_with_http_info( + self, + get_autoscale_configs_request_inner: Optional[List[GetAutoscaleConfigsRequestInner]] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[GetAutoscaleConfigs200Response]: + """Get one or more autoscale configuration + + Returns the current autoscale configuration of the supplied service(s). + + :param get_autoscale_configs_request_inner: + :type get_autoscale_configs_request_inner: List[GetAutoscaleConfigsRequestInner] + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_autoscale_configs_serialize( + get_autoscale_configs_request_inner=get_autoscale_configs_request_inner, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "GetAutoscaleConfigs200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def get_autoscale_configs_without_preload_content( + self, + get_autoscale_configs_request_inner: Optional[List[GetAutoscaleConfigsRequestInner]] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Get one or more autoscale configuration + + Returns the current autoscale configuration of the supplied service(s). + + :param get_autoscale_configs_request_inner: + :type get_autoscale_configs_request_inner: List[GetAutoscaleConfigsRequestInner] + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_autoscale_configs_serialize( + get_autoscale_configs_request_inner=get_autoscale_configs_request_inner, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "GetAutoscaleConfigs200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _get_autoscale_configs_serialize( + self, + get_autoscale_configs_request_inner, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + _host = None + + _collection_formats: Dict[str, str] = { + "GetAutoscaleConfigsRequestInner": "", + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if get_autoscale_configs_request_inner is not None: + _body_params = get_autoscale_configs_request_inner + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params["Content-Type"] = _content_type + else: + _default_content_type = self.api_client.select_header_content_type(["application/json"]) + if _default_content_type is not None: + _header_params["Content-Type"] = _default_content_type + + # authentication setting + _auth_settings: List[str] = ["bearerAuth"] + + return self.api_client.param_serialize( + method="GET", + resource_path="/services/autoscale", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) + + @validate_call + def get_autoscale_policy_by_service_uuid_and_policy_name( + self, + uuid: Annotated[ + UUID, + Field( + description="The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. " + ), + ], + name: Annotated[ + str, + Field( + strict=True, + max_length=255, + description="The name of the resource. The name is a string that identifies the resource. The name is sometimes returned by the API after creating a resource. ", + ), + ], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> GetAutoscalePolicyByServiceUuidAndPolicyName200Response: + """Get a single autoscale policy + + Returns the configuration of the specified autoscale policy. + + :param uuid: The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. (required) + :type uuid: str + :param name: The name of the resource. The name is a string that identifies the resource. The name is sometimes returned by the API after creating a resource. (required) + :type name: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_autoscale_policy_by_service_uuid_and_policy_name_serialize( + uuid=uuid, + name=name, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "GetAutoscalePolicyByServiceUuidAndPolicyName200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def get_autoscale_policy_by_service_uuid_and_policy_name_with_http_info( + self, + uuid: Annotated[ + UUID, + Field( + description="The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. " + ), + ], + name: Annotated[ + str, + Field( + strict=True, + max_length=255, + description="The name of the resource. The name is a string that identifies the resource. The name is sometimes returned by the API after creating a resource. ", + ), + ], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[GetAutoscalePolicyByServiceUuidAndPolicyName200Response]: + """Get a single autoscale policy + + Returns the configuration of the specified autoscale policy. + + :param uuid: The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. (required) + :type uuid: str + :param name: The name of the resource. The name is a string that identifies the resource. The name is sometimes returned by the API after creating a resource. (required) + :type name: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_autoscale_policy_by_service_uuid_and_policy_name_serialize( + uuid=uuid, + name=name, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "GetAutoscalePolicyByServiceUuidAndPolicyName200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def get_autoscale_policy_by_service_uuid_and_policy_name_without_preload_content( + self, + uuid: Annotated[ + UUID, + Field( + description="The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. " + ), + ], + name: Annotated[ + str, + Field( + strict=True, + max_length=255, + description="The name of the resource. The name is a string that identifies the resource. The name is sometimes returned by the API after creating a resource. ", + ), + ], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Get a single autoscale policy + + Returns the configuration of the specified autoscale policy. + + :param uuid: The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. (required) + :type uuid: str + :param name: The name of the resource. The name is a string that identifies the resource. The name is sometimes returned by the API after creating a resource. (required) + :type name: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_autoscale_policy_by_service_uuid_and_policy_name_serialize( + uuid=uuid, + name=name, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "GetAutoscalePolicyByServiceUuidAndPolicyName200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _get_autoscale_policy_by_service_uuid_and_policy_name_serialize( + self, + uuid, + name, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if uuid is not None: + _path_params["uuid"] = uuid + if name is not None: + _path_params["name"] = name + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # authentication setting + _auth_settings: List[str] = ["bearerAuth"] + + return self.api_client.param_serialize( + method="GET", + resource_path="/services/{uuid}/autoscale/policies/{name}", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) diff --git a/unikraft_cloud_platform/api/certificates/__init__.py b/unikraft_cloud_platform/api/certificates/__init__.py deleted file mode 100644 index 2d7c0b2..0000000 --- a/unikraft_cloud_platform/api/certificates/__init__.py +++ /dev/null @@ -1 +0,0 @@ -"""Contains endpoint functions for accessing the API""" diff --git a/unikraft_cloud_platform/api/certificates/create_certificate.py b/unikraft_cloud_platform/api/certificates/create_certificate.py deleted file mode 100644 index 94e0e5c..0000000 --- a/unikraft_cloud_platform/api/certificates/create_certificate.py +++ /dev/null @@ -1,165 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx - -from ...client import AuthenticatedClient, Client -from ...models.create_certificate_request import CreateCertificateRequest -from ...models.create_certificate_response import CreateCertificateResponse -from ...types import Response - - -def _get_kwargs( - *, - body: CreateCertificateRequest, -) -> dict[str, Any]: - headers: dict[str, Any] = {} - - _kwargs: dict[str, Any] = { - "method": "post", - "url": "/v1/certificates", - } - - _kwargs["json"] = body.to_dict() - - headers["Content-Type"] = "application/json" - - _kwargs["headers"] = headers - return _kwargs - - -def _parse_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> CreateCertificateResponse: - response_default = CreateCertificateResponse.from_dict(response.json()) - - return response_default - - -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[CreateCertificateResponse]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - *, - client: Union[AuthenticatedClient, Client], - body: CreateCertificateRequest, -) -> Response[CreateCertificateResponse]: - """Create Certificate - - Upload a new certificate with the given configuration. - - Args: - body (CreateCertificateRequest): The request message for creating/uploading a new - certificate. - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[CreateCertificateResponse] - """ - - kwargs = _get_kwargs( - body=body, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - *, - client: Union[AuthenticatedClient, Client], - body: CreateCertificateRequest, -) -> Optional[CreateCertificateResponse]: - """Create Certificate - - Upload a new certificate with the given configuration. - - Args: - body (CreateCertificateRequest): The request message for creating/uploading a new - certificate. - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - CreateCertificateResponse - """ - - return sync_detailed( - client=client, - body=body, - ).parsed - - -async def asyncio_detailed( - *, - client: Union[AuthenticatedClient, Client], - body: CreateCertificateRequest, -) -> Response[CreateCertificateResponse]: - """Create Certificate - - Upload a new certificate with the given configuration. - - Args: - body (CreateCertificateRequest): The request message for creating/uploading a new - certificate. - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[CreateCertificateResponse] - """ - - kwargs = _get_kwargs( - body=body, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - *, - client: Union[AuthenticatedClient, Client], - body: CreateCertificateRequest, -) -> Optional[CreateCertificateResponse]: - """Create Certificate - - Upload a new certificate with the given configuration. - - Args: - body (CreateCertificateRequest): The request message for creating/uploading a new - certificate. - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - CreateCertificateResponse - """ - - return ( - await asyncio_detailed( - client=client, - body=body, - ) - ).parsed diff --git a/unikraft_cloud_platform/api/certificates/delete_certificate_by_uuid.py b/unikraft_cloud_platform/api/certificates/delete_certificate_by_uuid.py deleted file mode 100644 index c8d9084..0000000 --- a/unikraft_cloud_platform/api/certificates/delete_certificate_by_uuid.py +++ /dev/null @@ -1,157 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union -from uuid import UUID - -import httpx - -from ...client import AuthenticatedClient, Client -from ...models.delete_certificates_response import DeleteCertificatesResponse -from ...types import Response - - -def _get_kwargs( - uuid: UUID, -) -> dict[str, Any]: - _kwargs: dict[str, Any] = { - "method": "delete", - "url": f"/v1/certificates/{uuid}", - } - - return _kwargs - - -def _parse_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> DeleteCertificatesResponse: - response_default = DeleteCertificatesResponse.from_dict(response.json()) - - return response_default - - -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[DeleteCertificatesResponse]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], -) -> Response[DeleteCertificatesResponse]: - """Delete Certificate by UUID - - Delete a specified certificate by its UUID. After this call the UUID of - the certificate are no longer valid. - - Args: - uuid (UUID): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[DeleteCertificatesResponse] - """ - - kwargs = _get_kwargs( - uuid=uuid, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], -) -> Optional[DeleteCertificatesResponse]: - """Delete Certificate by UUID - - Delete a specified certificate by its UUID. After this call the UUID of - the certificate are no longer valid. - - Args: - uuid (UUID): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - DeleteCertificatesResponse - """ - - return sync_detailed( - uuid=uuid, - client=client, - ).parsed - - -async def asyncio_detailed( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], -) -> Response[DeleteCertificatesResponse]: - """Delete Certificate by UUID - - Delete a specified certificate by its UUID. After this call the UUID of - the certificate are no longer valid. - - Args: - uuid (UUID): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[DeleteCertificatesResponse] - """ - - kwargs = _get_kwargs( - uuid=uuid, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], -) -> Optional[DeleteCertificatesResponse]: - """Delete Certificate by UUID - - Delete a specified certificate by its UUID. After this call the UUID of - the certificate are no longer valid. - - Args: - uuid (UUID): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - DeleteCertificatesResponse - """ - - return ( - await asyncio_detailed( - uuid=uuid, - client=client, - ) - ).parsed diff --git a/unikraft_cloud_platform/api/certificates/delete_certificates.py b/unikraft_cloud_platform/api/certificates/delete_certificates.py deleted file mode 100644 index f76b11c..0000000 --- a/unikraft_cloud_platform/api/certificates/delete_certificates.py +++ /dev/null @@ -1,168 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx - -from ...client import AuthenticatedClient, Client -from ...models.delete_certificates_response import DeleteCertificatesResponse -from ...models.name_or_uuid import NameOrUUID -from ...types import Response - - -def _get_kwargs( - *, - body: list["NameOrUUID"], -) -> dict[str, Any]: - headers: dict[str, Any] = {} - - _kwargs: dict[str, Any] = { - "method": "delete", - "url": "/v1/certificates", - } - - _kwargs["json"] = [] - for body_item_data in body: - body_item = body_item_data.to_dict() - _kwargs["json"].append(body_item) - - headers["Content-Type"] = "application/json" - - _kwargs["headers"] = headers - return _kwargs - - -def _parse_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> DeleteCertificatesResponse: - response_default = DeleteCertificatesResponse.from_dict(response.json()) - - return response_default - - -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[DeleteCertificatesResponse]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - *, - client: Union[AuthenticatedClient, Client], - body: list["NameOrUUID"], -) -> Response[DeleteCertificatesResponse]: - """Delete Certificates - - Delete the specified certificate(s). After this call the name of the - certificate(s) are no longer valid. - - Args: - body (list['NameOrUUID']): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[DeleteCertificatesResponse] - """ - - kwargs = _get_kwargs( - body=body, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - *, - client: Union[AuthenticatedClient, Client], - body: list["NameOrUUID"], -) -> Optional[DeleteCertificatesResponse]: - """Delete Certificates - - Delete the specified certificate(s). After this call the name of the - certificate(s) are no longer valid. - - Args: - body (list['NameOrUUID']): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - DeleteCertificatesResponse - """ - - return sync_detailed( - client=client, - body=body, - ).parsed - - -async def asyncio_detailed( - *, - client: Union[AuthenticatedClient, Client], - body: list["NameOrUUID"], -) -> Response[DeleteCertificatesResponse]: - """Delete Certificates - - Delete the specified certificate(s). After this call the name of the - certificate(s) are no longer valid. - - Args: - body (list['NameOrUUID']): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[DeleteCertificatesResponse] - """ - - kwargs = _get_kwargs( - body=body, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - *, - client: Union[AuthenticatedClient, Client], - body: list["NameOrUUID"], -) -> Optional[DeleteCertificatesResponse]: - """Delete Certificates - - Delete the specified certificate(s). After this call the name of the - certificate(s) are no longer valid. - - Args: - body (list['NameOrUUID']): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - DeleteCertificatesResponse - """ - - return ( - await asyncio_detailed( - client=client, - body=body, - ) - ).parsed diff --git a/unikraft_cloud_platform/api/certificates/get_certificate_by_uuid.py b/unikraft_cloud_platform/api/certificates/get_certificate_by_uuid.py deleted file mode 100644 index 687de82..0000000 --- a/unikraft_cloud_platform/api/certificates/get_certificate_by_uuid.py +++ /dev/null @@ -1,151 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union -from uuid import UUID - -import httpx - -from ...client import AuthenticatedClient, Client -from ...models.get_certificates_response import GetCertificatesResponse -from ...types import Response - - -def _get_kwargs( - uuid: UUID, -) -> dict[str, Any]: - _kwargs: dict[str, Any] = { - "method": "get", - "url": f"/v1/certificates/{uuid}", - } - - return _kwargs - - -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> GetCertificatesResponse: - response_default = GetCertificatesResponse.from_dict(response.json()) - - return response_default - - -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[GetCertificatesResponse]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], -) -> Response[GetCertificatesResponse]: - """Get Certificate by UUID - - Get a specified certificate by its UUID. - - Args: - uuid (UUID): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[GetCertificatesResponse] - """ - - kwargs = _get_kwargs( - uuid=uuid, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], -) -> Optional[GetCertificatesResponse]: - """Get Certificate by UUID - - Get a specified certificate by its UUID. - - Args: - uuid (UUID): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - GetCertificatesResponse - """ - - return sync_detailed( - uuid=uuid, - client=client, - ).parsed - - -async def asyncio_detailed( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], -) -> Response[GetCertificatesResponse]: - """Get Certificate by UUID - - Get a specified certificate by its UUID. - - Args: - uuid (UUID): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[GetCertificatesResponse] - """ - - kwargs = _get_kwargs( - uuid=uuid, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], -) -> Optional[GetCertificatesResponse]: - """Get Certificate by UUID - - Get a specified certificate by its UUID. - - Args: - uuid (UUID): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - GetCertificatesResponse - """ - - return ( - await asyncio_detailed( - uuid=uuid, - client=client, - ) - ).parsed diff --git a/unikraft_cloud_platform/api/certificates/get_certificates.py b/unikraft_cloud_platform/api/certificates/get_certificates.py deleted file mode 100644 index f06be25..0000000 --- a/unikraft_cloud_platform/api/certificates/get_certificates.py +++ /dev/null @@ -1,186 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx - -from ...client import AuthenticatedClient, Client -from ...models.get_certificates_response import GetCertificatesResponse -from ...models.name_or_uuid import NameOrUUID -from ...types import UNSET, Response, Unset - - -def _get_kwargs( - *, - body: list["NameOrUUID"], - details: Union[Unset, bool] = UNSET, -) -> dict[str, Any]: - headers: dict[str, Any] = {} - - params: dict[str, Any] = {} - - params["details"] = details - - params = {k: v for k, v in params.items() if v is not UNSET and v is not None} - - _kwargs: dict[str, Any] = { - "method": "get", - "url": "/v1/certificates", - "params": params, - } - - _kwargs["json"] = [] - for body_item_data in body: - body_item = body_item_data.to_dict() - _kwargs["json"].append(body_item) - - headers["Content-Type"] = "application/json" - - _kwargs["headers"] = headers - return _kwargs - - -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> GetCertificatesResponse: - response_default = GetCertificatesResponse.from_dict(response.json()) - - return response_default - - -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[GetCertificatesResponse]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - *, - client: Union[AuthenticatedClient, Client], - body: list["NameOrUUID"], - details: Union[Unset, bool] = UNSET, -) -> Response[GetCertificatesResponse]: - """List Certificates - - Get one or many certificates with their current status and configuration. - It's possible to filter this list by name or UUID. - - Args: - details (Union[Unset, bool]): - body (list['NameOrUUID']): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[GetCertificatesResponse] - """ - - kwargs = _get_kwargs( - body=body, - details=details, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - *, - client: Union[AuthenticatedClient, Client], - body: list["NameOrUUID"], - details: Union[Unset, bool] = UNSET, -) -> Optional[GetCertificatesResponse]: - """List Certificates - - Get one or many certificates with their current status and configuration. - It's possible to filter this list by name or UUID. - - Args: - details (Union[Unset, bool]): - body (list['NameOrUUID']): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - GetCertificatesResponse - """ - - return sync_detailed( - client=client, - body=body, - details=details, - ).parsed - - -async def asyncio_detailed( - *, - client: Union[AuthenticatedClient, Client], - body: list["NameOrUUID"], - details: Union[Unset, bool] = UNSET, -) -> Response[GetCertificatesResponse]: - """List Certificates - - Get one or many certificates with their current status and configuration. - It's possible to filter this list by name or UUID. - - Args: - details (Union[Unset, bool]): - body (list['NameOrUUID']): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[GetCertificatesResponse] - """ - - kwargs = _get_kwargs( - body=body, - details=details, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - *, - client: Union[AuthenticatedClient, Client], - body: list["NameOrUUID"], - details: Union[Unset, bool] = UNSET, -) -> Optional[GetCertificatesResponse]: - """List Certificates - - Get one or many certificates with their current status and configuration. - It's possible to filter this list by name or UUID. - - Args: - details (Union[Unset, bool]): - body (list['NameOrUUID']): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - GetCertificatesResponse - """ - - return ( - await asyncio_detailed( - client=client, - body=body, - details=details, - ) - ).parsed diff --git a/unikraft_cloud_platform/api/certificates_api.py b/unikraft_cloud_platform/api/certificates_api.py new file mode 100644 index 0000000..e7e6392 --- /dev/null +++ b/unikraft_cloud_platform/api/certificates_api.py @@ -0,0 +1,1281 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +import warnings +from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt +from typing import Any, Dict, List, Optional, Tuple, Union +from typing_extensions import Annotated + +from pydantic import Field, StrictBool +from typing import List, Optional +from typing_extensions import Annotated +from uuid import UUID +from unikraft_cloud_platform.models.create_certificate200_response import CreateCertificate200Response +from unikraft_cloud_platform.models.create_certificate_request import CreateCertificateRequest +from unikraft_cloud_platform.models.delete_certificate_by_uuid200_response import DeleteCertificateByUuid200Response +from unikraft_cloud_platform.models.delete_certificates200_response import DeleteCertificates200Response +from unikraft_cloud_platform.models.delete_certificates_request_inner import DeleteCertificatesRequestInner +from unikraft_cloud_platform.models.get_certificate_by_uuid200_response import GetCertificateByUuid200Response +from unikraft_cloud_platform.models.get_certificates200_response import GetCertificates200Response +from unikraft_cloud_platform.models.get_certificates_request_inner import GetCertificatesRequestInner + +from unikraft_cloud_platform.api_client import ApiClient, RequestSerialized +from unikraft_cloud_platform.api_response import ApiResponse +from unikraft_cloud_platform.rest import RESTResponseType + + +class CertificatesApi: + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, api_client=None) -> None: + if api_client is None: + api_client = ApiClient.get_default() + self.api_client = api_client + + @validate_call + def create_certificate( + self, + create_certificate_request: CreateCertificateRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> CreateCertificate200Response: + """Upload a certificate + + Create a new certificate object and upload an existing certificate chain and private key. + + :param create_certificate_request: (required) + :type create_certificate_request: CreateCertificateRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._create_certificate_serialize( + create_certificate_request=create_certificate_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "CreateCertificate200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def create_certificate_with_http_info( + self, + create_certificate_request: CreateCertificateRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[CreateCertificate200Response]: + """Upload a certificate + + Create a new certificate object and upload an existing certificate chain and private key. + + :param create_certificate_request: (required) + :type create_certificate_request: CreateCertificateRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._create_certificate_serialize( + create_certificate_request=create_certificate_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "CreateCertificate200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def create_certificate_without_preload_content( + self, + create_certificate_request: CreateCertificateRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Upload a certificate + + Create a new certificate object and upload an existing certificate chain and private key. + + :param create_certificate_request: (required) + :type create_certificate_request: CreateCertificateRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._create_certificate_serialize( + create_certificate_request=create_certificate_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "CreateCertificate200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _create_certificate_serialize( + self, + create_certificate_request, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if create_certificate_request is not None: + _body_params = create_certificate_request + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params["Content-Type"] = _content_type + else: + _default_content_type = self.api_client.select_header_content_type(["application/json"]) + if _default_content_type is not None: + _header_params["Content-Type"] = _default_content_type + + # authentication setting + _auth_settings: List[str] = ["bearerAuth"] + + return self.api_client.param_serialize( + method="POST", + resource_path="/certificates", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) + + @validate_call + def delete_certificate_by_uuid( + self, + uuid: Annotated[ + UUID, + Field( + description="The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. " + ), + ], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> DeleteCertificateByUuid200Response: + """Delete a single certificate given its UUID + + Deletes the specified certificate. Fails if the certificate is still attached to a service. After this call the IDs associated with the certificate are no longer valid. + + :param uuid: The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. (required) + :type uuid: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._delete_certificate_by_uuid_serialize( + uuid=uuid, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "DeleteCertificateByUuid200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def delete_certificate_by_uuid_with_http_info( + self, + uuid: Annotated[ + UUID, + Field( + description="The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. " + ), + ], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[DeleteCertificateByUuid200Response]: + """Delete a single certificate given its UUID + + Deletes the specified certificate. Fails if the certificate is still attached to a service. After this call the IDs associated with the certificate are no longer valid. + + :param uuid: The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. (required) + :type uuid: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._delete_certificate_by_uuid_serialize( + uuid=uuid, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "DeleteCertificateByUuid200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def delete_certificate_by_uuid_without_preload_content( + self, + uuid: Annotated[ + UUID, + Field( + description="The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. " + ), + ], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Delete a single certificate given its UUID + + Deletes the specified certificate. Fails if the certificate is still attached to a service. After this call the IDs associated with the certificate are no longer valid. + + :param uuid: The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. (required) + :type uuid: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._delete_certificate_by_uuid_serialize( + uuid=uuid, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "DeleteCertificateByUuid200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _delete_certificate_by_uuid_serialize( + self, + uuid, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if uuid is not None: + _path_params["uuid"] = uuid + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # authentication setting + _auth_settings: List[str] = ["bearerAuth"] + + return self.api_client.param_serialize( + method="DELETE", + resource_path="/certificates/{uuid}", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) + + @validate_call + def delete_certificates( + self, + delete_certificates_request_inner: Optional[List[DeleteCertificatesRequestInner]] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> DeleteCertificates200Response: + """Delete one or more certificates + + Deletes the specified certificate(s). Fails if the certificate is still attached to a service. After this call the IDs associated with the certificate are no longer valid. + + :param delete_certificates_request_inner: + :type delete_certificates_request_inner: List[DeleteCertificatesRequestInner] + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._delete_certificates_serialize( + delete_certificates_request_inner=delete_certificates_request_inner, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "DeleteCertificates200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def delete_certificates_with_http_info( + self, + delete_certificates_request_inner: Optional[List[DeleteCertificatesRequestInner]] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[DeleteCertificates200Response]: + """Delete one or more certificates + + Deletes the specified certificate(s). Fails if the certificate is still attached to a service. After this call the IDs associated with the certificate are no longer valid. + + :param delete_certificates_request_inner: + :type delete_certificates_request_inner: List[DeleteCertificatesRequestInner] + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._delete_certificates_serialize( + delete_certificates_request_inner=delete_certificates_request_inner, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "DeleteCertificates200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def delete_certificates_without_preload_content( + self, + delete_certificates_request_inner: Optional[List[DeleteCertificatesRequestInner]] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Delete one or more certificates + + Deletes the specified certificate(s). Fails if the certificate is still attached to a service. After this call the IDs associated with the certificate are no longer valid. + + :param delete_certificates_request_inner: + :type delete_certificates_request_inner: List[DeleteCertificatesRequestInner] + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._delete_certificates_serialize( + delete_certificates_request_inner=delete_certificates_request_inner, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "DeleteCertificates200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _delete_certificates_serialize( + self, + delete_certificates_request_inner, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + _host = None + + _collection_formats: Dict[str, str] = { + "DeleteCertificatesRequestInner": "", + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if delete_certificates_request_inner is not None: + _body_params = delete_certificates_request_inner + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params["Content-Type"] = _content_type + else: + _default_content_type = self.api_client.select_header_content_type(["application/json"]) + if _default_content_type is not None: + _header_params["Content-Type"] = _default_content_type + + # authentication setting + _auth_settings: List[str] = ["bearerAuth"] + + return self.api_client.param_serialize( + method="DELETE", + resource_path="/certificates", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) + + @validate_call + def get_certificate_by_uuid( + self, + uuid: Annotated[ + UUID, + Field( + description="The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. " + ), + ], + details: Annotated[ + Optional[StrictBool], + Field(description="Whether to provide detailed status and configuration information. "), + ] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> GetCertificateByUuid200Response: + """Get the status of a certificate given its UUID + + Returns the current status and the properties of a certificate. + + :param uuid: The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. (required) + :type uuid: str + :param details: Whether to provide detailed status and configuration information. + :type details: bool + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_certificate_by_uuid_serialize( + uuid=uuid, + details=details, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "GetCertificateByUuid200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def get_certificate_by_uuid_with_http_info( + self, + uuid: Annotated[ + UUID, + Field( + description="The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. " + ), + ], + details: Annotated[ + Optional[StrictBool], + Field(description="Whether to provide detailed status and configuration information. "), + ] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[GetCertificateByUuid200Response]: + """Get the status of a certificate given its UUID + + Returns the current status and the properties of a certificate. + + :param uuid: The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. (required) + :type uuid: str + :param details: Whether to provide detailed status and configuration information. + :type details: bool + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_certificate_by_uuid_serialize( + uuid=uuid, + details=details, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "GetCertificateByUuid200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def get_certificate_by_uuid_without_preload_content( + self, + uuid: Annotated[ + UUID, + Field( + description="The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. " + ), + ], + details: Annotated[ + Optional[StrictBool], + Field(description="Whether to provide detailed status and configuration information. "), + ] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Get the status of a certificate given its UUID + + Returns the current status and the properties of a certificate. + + :param uuid: The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. (required) + :type uuid: str + :param details: Whether to provide detailed status and configuration information. + :type details: bool + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_certificate_by_uuid_serialize( + uuid=uuid, + details=details, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "GetCertificateByUuid200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _get_certificate_by_uuid_serialize( + self, + uuid, + details, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if uuid is not None: + _path_params["uuid"] = uuid + # process the query parameters + if details is not None: + _query_params.append(("details", details)) + + # process the header parameters + # process the form parameters + # process the body parameter + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # authentication setting + _auth_settings: List[str] = ["bearerAuth"] + + return self.api_client.param_serialize( + method="GET", + resource_path="/certificates/{uuid}", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) + + @validate_call + def get_certificates( + self, + details: Annotated[ + Optional[StrictBool], + Field(description="Whether to provide detailed status and configuration information. "), + ] = None, + get_certificates_request_inner: Optional[List[GetCertificatesRequestInner]] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> GetCertificates200Response: + """Get the status of one or more certificates + + Returns the current status and the properties of specified certificate(s). + + :param details: Whether to provide detailed status and configuration information. + :type details: bool + :param get_certificates_request_inner: + :type get_certificates_request_inner: List[GetCertificatesRequestInner] + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_certificates_serialize( + details=details, + get_certificates_request_inner=get_certificates_request_inner, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "GetCertificates200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def get_certificates_with_http_info( + self, + details: Annotated[ + Optional[StrictBool], + Field(description="Whether to provide detailed status and configuration information. "), + ] = None, + get_certificates_request_inner: Optional[List[GetCertificatesRequestInner]] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[GetCertificates200Response]: + """Get the status of one or more certificates + + Returns the current status and the properties of specified certificate(s). + + :param details: Whether to provide detailed status and configuration information. + :type details: bool + :param get_certificates_request_inner: + :type get_certificates_request_inner: List[GetCertificatesRequestInner] + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_certificates_serialize( + details=details, + get_certificates_request_inner=get_certificates_request_inner, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "GetCertificates200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def get_certificates_without_preload_content( + self, + details: Annotated[ + Optional[StrictBool], + Field(description="Whether to provide detailed status and configuration information. "), + ] = None, + get_certificates_request_inner: Optional[List[GetCertificatesRequestInner]] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Get the status of one or more certificates + + Returns the current status and the properties of specified certificate(s). + + :param details: Whether to provide detailed status and configuration information. + :type details: bool + :param get_certificates_request_inner: + :type get_certificates_request_inner: List[GetCertificatesRequestInner] + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_certificates_serialize( + details=details, + get_certificates_request_inner=get_certificates_request_inner, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "GetCertificates200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _get_certificates_serialize( + self, + details, + get_certificates_request_inner, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + _host = None + + _collection_formats: Dict[str, str] = { + "GetCertificatesRequestInner": "", + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + if details is not None: + _query_params.append(("details", details)) + + # process the header parameters + # process the form parameters + # process the body parameter + if get_certificates_request_inner is not None: + _body_params = get_certificates_request_inner + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params["Content-Type"] = _content_type + else: + _default_content_type = self.api_client.select_header_content_type(["application/json"]) + if _default_content_type is not None: + _header_params["Content-Type"] = _default_content_type + + # authentication setting + _auth_settings: List[str] = ["bearerAuth"] + + return self.api_client.param_serialize( + method="GET", + resource_path="/certificates", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) diff --git a/unikraft_cloud_platform/api/images/__init__.py b/unikraft_cloud_platform/api/images/__init__.py deleted file mode 100644 index 2d7c0b2..0000000 --- a/unikraft_cloud_platform/api/images/__init__.py +++ /dev/null @@ -1 +0,0 @@ -"""Contains endpoint functions for accessing the API""" diff --git a/unikraft_cloud_platform/api/images/get_image_by_digest.py b/unikraft_cloud_platform/api/images/get_image_by_digest.py deleted file mode 100644 index 500ee1a..0000000 --- a/unikraft_cloud_platform/api/images/get_image_by_digest.py +++ /dev/null @@ -1,154 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx - -from ...client import AuthenticatedClient, Client -from ...models.get_image_response import GetImageResponse -from ...types import Response - - -def _get_kwargs( - digest: str, -) -> dict[str, Any]: - _kwargs: dict[str, Any] = { - "method": "get", - "url": f"/v1/images/digest/{digest}", - } - - return _kwargs - - -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> GetImageResponse: - response_default = GetImageResponse.from_dict(response.json()) - - return response_default - - -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[GetImageResponse]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - digest: str, - *, - client: Union[AuthenticatedClient, Client], -) -> Response[GetImageResponse]: - """Get Image by Digest - - Retrieve an image by its digest. - - Args: - digest (str): Example: - sha256:1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef. - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[GetImageResponse] - """ - - kwargs = _get_kwargs( - digest=digest, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - digest: str, - *, - client: Union[AuthenticatedClient, Client], -) -> Optional[GetImageResponse]: - """Get Image by Digest - - Retrieve an image by its digest. - - Args: - digest (str): Example: - sha256:1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef. - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - GetImageResponse - """ - - return sync_detailed( - digest=digest, - client=client, - ).parsed - - -async def asyncio_detailed( - digest: str, - *, - client: Union[AuthenticatedClient, Client], -) -> Response[GetImageResponse]: - """Get Image by Digest - - Retrieve an image by its digest. - - Args: - digest (str): Example: - sha256:1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef. - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[GetImageResponse] - """ - - kwargs = _get_kwargs( - digest=digest, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - digest: str, - *, - client: Union[AuthenticatedClient, Client], -) -> Optional[GetImageResponse]: - """Get Image by Digest - - Retrieve an image by its digest. - - Args: - digest (str): Example: - sha256:1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef. - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - GetImageResponse - """ - - return ( - await asyncio_detailed( - digest=digest, - client=client, - ) - ).parsed diff --git a/unikraft_cloud_platform/api/images/get_image_by_tag.py b/unikraft_cloud_platform/api/images/get_image_by_tag.py deleted file mode 100644 index c7ffec1..0000000 --- a/unikraft_cloud_platform/api/images/get_image_by_tag.py +++ /dev/null @@ -1,150 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx - -from ...client import AuthenticatedClient, Client -from ...models.get_image_response import GetImageResponse -from ...types import Response - - -def _get_kwargs( - tag: str, -) -> dict[str, Any]: - _kwargs: dict[str, Any] = { - "method": "get", - "url": f"/v1/images/tag/{tag}", - } - - return _kwargs - - -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> GetImageResponse: - response_default = GetImageResponse.from_dict(response.json()) - - return response_default - - -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[GetImageResponse]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - tag: str, - *, - client: Union[AuthenticatedClient, Client], -) -> Response[GetImageResponse]: - """Get Image by Tag - - Retrieve an image by its tag. - - Args: - tag (str): Example: my-image:latest. - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[GetImageResponse] - """ - - kwargs = _get_kwargs( - tag=tag, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - tag: str, - *, - client: Union[AuthenticatedClient, Client], -) -> Optional[GetImageResponse]: - """Get Image by Tag - - Retrieve an image by its tag. - - Args: - tag (str): Example: my-image:latest. - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - GetImageResponse - """ - - return sync_detailed( - tag=tag, - client=client, - ).parsed - - -async def asyncio_detailed( - tag: str, - *, - client: Union[AuthenticatedClient, Client], -) -> Response[GetImageResponse]: - """Get Image by Tag - - Retrieve an image by its tag. - - Args: - tag (str): Example: my-image:latest. - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[GetImageResponse] - """ - - kwargs = _get_kwargs( - tag=tag, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - tag: str, - *, - client: Union[AuthenticatedClient, Client], -) -> Optional[GetImageResponse]: - """Get Image by Tag - - Retrieve an image by its tag. - - Args: - tag (str): Example: my-image:latest. - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - GetImageResponse - """ - - return ( - await asyncio_detailed( - tag=tag, - client=client, - ) - ).parsed diff --git a/unikraft_cloud_platform/api/images_api.py b/unikraft_cloud_platform/api/images_api.py new file mode 100644 index 0000000..a641f76 --- /dev/null +++ b/unikraft_cloud_platform/api/images_api.py @@ -0,0 +1,323 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +import warnings +from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt +from typing import Any, Dict, List, Optional, Tuple, Union +from typing_extensions import Annotated + +from pydantic import Field, StrictBool, field_validator +from typing import List, Optional +from typing_extensions import Annotated +from unikraft_cloud_platform.models.get_images200_response import GetImages200Response +from unikraft_cloud_platform.models.get_images_request_inner import GetImagesRequestInner + +from unikraft_cloud_platform.api_client import ApiClient, RequestSerialized +from unikraft_cloud_platform.api_response import ApiResponse +from unikraft_cloud_platform.rest import RESTResponseType + + +class ImagesApi: + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, api_client=None) -> None: + if api_client is None: + api_client = ApiClient.get_default() + self.api_client = api_client + + @validate_call + def get_images( + self, + namespace: Annotated[ + Optional[Annotated[str, Field(strict=True, max_length=2048)]], + Field( + description="Filter images by namespace. Note: Set the namespace to your Unikraft Cloud account name to list only your personal images. It can be `official` for listing only the official ones. In addition, the namespace can include the app name. For example, `${UKC_USER}/myapp` to list all your `myapp` images. " + ), + ] = None, + tagged: Annotated[Optional[StrictBool], Field(description="Whether to include only tagged images. ")] = None, + get_images_request_inner: Optional[List[Optional[GetImagesRequestInner]]] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> GetImages200Response: + """Get list of available images + + Retrieves all images visible to an account in OCI format. + + :param namespace: Filter images by namespace. Note: Set the namespace to your Unikraft Cloud account name to list only your personal images. It can be `official` for listing only the official ones. In addition, the namespace can include the app name. For example, `${UKC_USER}/myapp` to list all your `myapp` images. + :type namespace: str + :param tagged: Whether to include only tagged images. + :type tagged: bool + :param get_images_request_inner: + :type get_images_request_inner: List[GetImagesRequestInner] + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_images_serialize( + namespace=namespace, + tagged=tagged, + get_images_request_inner=get_images_request_inner, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "GetImages200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def get_images_with_http_info( + self, + namespace: Annotated[ + Optional[Annotated[str, Field(strict=True, max_length=2048)]], + Field( + description="Filter images by namespace. Note: Set the namespace to your Unikraft Cloud account name to list only your personal images. It can be `official` for listing only the official ones. In addition, the namespace can include the app name. For example, `${UKC_USER}/myapp` to list all your `myapp` images. " + ), + ] = None, + tagged: Annotated[Optional[StrictBool], Field(description="Whether to include only tagged images. ")] = None, + get_images_request_inner: Optional[List[Optional[GetImagesRequestInner]]] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[GetImages200Response]: + """Get list of available images + + Retrieves all images visible to an account in OCI format. + + :param namespace: Filter images by namespace. Note: Set the namespace to your Unikraft Cloud account name to list only your personal images. It can be `official` for listing only the official ones. In addition, the namespace can include the app name. For example, `${UKC_USER}/myapp` to list all your `myapp` images. + :type namespace: str + :param tagged: Whether to include only tagged images. + :type tagged: bool + :param get_images_request_inner: + :type get_images_request_inner: List[GetImagesRequestInner] + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_images_serialize( + namespace=namespace, + tagged=tagged, + get_images_request_inner=get_images_request_inner, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "GetImages200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def get_images_without_preload_content( + self, + namespace: Annotated[ + Optional[Annotated[str, Field(strict=True, max_length=2048)]], + Field( + description="Filter images by namespace. Note: Set the namespace to your Unikraft Cloud account name to list only your personal images. It can be `official` for listing only the official ones. In addition, the namespace can include the app name. For example, `${UKC_USER}/myapp` to list all your `myapp` images. " + ), + ] = None, + tagged: Annotated[Optional[StrictBool], Field(description="Whether to include only tagged images. ")] = None, + get_images_request_inner: Optional[List[Optional[GetImagesRequestInner]]] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Get list of available images + + Retrieves all images visible to an account in OCI format. + + :param namespace: Filter images by namespace. Note: Set the namespace to your Unikraft Cloud account name to list only your personal images. It can be `official` for listing only the official ones. In addition, the namespace can include the app name. For example, `${UKC_USER}/myapp` to list all your `myapp` images. + :type namespace: str + :param tagged: Whether to include only tagged images. + :type tagged: bool + :param get_images_request_inner: + :type get_images_request_inner: List[GetImagesRequestInner] + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_images_serialize( + namespace=namespace, + tagged=tagged, + get_images_request_inner=get_images_request_inner, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "GetImages200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _get_images_serialize( + self, + namespace, + tagged, + get_images_request_inner, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + _host = None + + _collection_formats: Dict[str, str] = { + "GetImagesRequestInner": "", + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + if namespace is not None: + _query_params.append(("namespace", namespace)) + + if tagged is not None: + _query_params.append(("tagged", tagged)) + + # process the header parameters + # process the form parameters + # process the body parameter + if get_images_request_inner is not None: + _body_params = get_images_request_inner + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params["Content-Type"] = _content_type + else: + _default_content_type = self.api_client.select_header_content_type(["application/json"]) + if _default_content_type is not None: + _header_params["Content-Type"] = _default_content_type + + # authentication setting + _auth_settings: List[str] = ["bearerAuth"] + + return self.api_client.param_serialize( + method="GET", + resource_path="/images/list", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) diff --git a/unikraft_cloud_platform/api/instances/__init__.py b/unikraft_cloud_platform/api/instances/__init__.py deleted file mode 100644 index 2d7c0b2..0000000 --- a/unikraft_cloud_platform/api/instances/__init__.py +++ /dev/null @@ -1 +0,0 @@ -"""Contains endpoint functions for accessing the API""" diff --git a/unikraft_cloud_platform/api/instances/create_instance.py b/unikraft_cloud_platform/api/instances/create_instance.py deleted file mode 100644 index 874149b..0000000 --- a/unikraft_cloud_platform/api/instances/create_instance.py +++ /dev/null @@ -1,159 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx - -from ...client import AuthenticatedClient, Client -from ...models.create_instance_request import CreateInstanceRequest -from ...models.create_instance_response import CreateInstanceResponse -from ...types import Response - - -def _get_kwargs( - *, - body: CreateInstanceRequest, -) -> dict[str, Any]: - headers: dict[str, Any] = {} - - _kwargs: dict[str, Any] = { - "method": "post", - "url": "/v1/instances", - } - - _kwargs["json"] = body.to_dict() - - headers["Content-Type"] = "application/json" - - _kwargs["headers"] = headers - return _kwargs - - -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> CreateInstanceResponse: - response_default = CreateInstanceResponse.from_dict(response.json()) - - return response_default - - -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[CreateInstanceResponse]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - *, - client: Union[AuthenticatedClient, Client], - body: CreateInstanceRequest, -) -> Response[CreateInstanceResponse]: - """Create Instance - - Create an instance in Unikraft Cloud. - - Args: - body (CreateInstanceRequest): The request message for creating a new instance. - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[CreateInstanceResponse] - """ - - kwargs = _get_kwargs( - body=body, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - *, - client: Union[AuthenticatedClient, Client], - body: CreateInstanceRequest, -) -> Optional[CreateInstanceResponse]: - """Create Instance - - Create an instance in Unikraft Cloud. - - Args: - body (CreateInstanceRequest): The request message for creating a new instance. - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - CreateInstanceResponse - """ - - return sync_detailed( - client=client, - body=body, - ).parsed - - -async def asyncio_detailed( - *, - client: Union[AuthenticatedClient, Client], - body: CreateInstanceRequest, -) -> Response[CreateInstanceResponse]: - """Create Instance - - Create an instance in Unikraft Cloud. - - Args: - body (CreateInstanceRequest): The request message for creating a new instance. - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[CreateInstanceResponse] - """ - - kwargs = _get_kwargs( - body=body, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - *, - client: Union[AuthenticatedClient, Client], - body: CreateInstanceRequest, -) -> Optional[CreateInstanceResponse]: - """Create Instance - - Create an instance in Unikraft Cloud. - - Args: - body (CreateInstanceRequest): The request message for creating a new instance. - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - CreateInstanceResponse - """ - - return ( - await asyncio_detailed( - client=client, - body=body, - ) - ).parsed diff --git a/unikraft_cloud_platform/api/instances/delete_instance_by_uuid.py b/unikraft_cloud_platform/api/instances/delete_instance_by_uuid.py deleted file mode 100644 index 89c66be..0000000 --- a/unikraft_cloud_platform/api/instances/delete_instance_by_uuid.py +++ /dev/null @@ -1,159 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union -from uuid import UUID - -import httpx - -from ...client import AuthenticatedClient, Client -from ...models.delete_instances_response import DeleteInstancesResponse -from ...types import Response - - -def _get_kwargs( - uuid: UUID, -) -> dict[str, Any]: - _kwargs: dict[str, Any] = { - "method": "delete", - "url": f"/v1/instances/{uuid}", - } - - return _kwargs - - -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> DeleteInstancesResponse: - response_default = DeleteInstancesResponse.from_dict(response.json()) - - return response_default - - -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[DeleteInstancesResponse]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], -) -> Response[DeleteInstancesResponse]: - """Delete Instance by UUID - - Delete a specified instance by its UUID. After this call the UUID of the - instance is no longer valid. If the instance is currently running, - it is force-stopped. - - Args: - uuid (UUID): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[DeleteInstancesResponse] - """ - - kwargs = _get_kwargs( - uuid=uuid, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], -) -> Optional[DeleteInstancesResponse]: - """Delete Instance by UUID - - Delete a specified instance by its UUID. After this call the UUID of the - instance is no longer valid. If the instance is currently running, - it is force-stopped. - - Args: - uuid (UUID): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - DeleteInstancesResponse - """ - - return sync_detailed( - uuid=uuid, - client=client, - ).parsed - - -async def asyncio_detailed( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], -) -> Response[DeleteInstancesResponse]: - """Delete Instance by UUID - - Delete a specified instance by its UUID. After this call the UUID of the - instance is no longer valid. If the instance is currently running, - it is force-stopped. - - Args: - uuid (UUID): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[DeleteInstancesResponse] - """ - - kwargs = _get_kwargs( - uuid=uuid, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], -) -> Optional[DeleteInstancesResponse]: - """Delete Instance by UUID - - Delete a specified instance by its UUID. After this call the UUID of the - instance is no longer valid. If the instance is currently running, - it is force-stopped. - - Args: - uuid (UUID): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - DeleteInstancesResponse - """ - - return ( - await asyncio_detailed( - uuid=uuid, - client=client, - ) - ).parsed diff --git a/unikraft_cloud_platform/api/instances/delete_instances.py b/unikraft_cloud_platform/api/instances/delete_instances.py deleted file mode 100644 index 2560350..0000000 --- a/unikraft_cloud_platform/api/instances/delete_instances.py +++ /dev/null @@ -1,170 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx - -from ...client import AuthenticatedClient, Client -from ...models.delete_instances_response import DeleteInstancesResponse -from ...models.name_or_uuid import NameOrUUID -from ...types import Response - - -def _get_kwargs( - *, - body: list["NameOrUUID"], -) -> dict[str, Any]: - headers: dict[str, Any] = {} - - _kwargs: dict[str, Any] = { - "method": "delete", - "url": "/v1/instances", - } - - _kwargs["json"] = [] - for body_item_data in body: - body_item = body_item_data.to_dict() - _kwargs["json"].append(body_item) - - headers["Content-Type"] = "application/json" - - _kwargs["headers"] = headers - return _kwargs - - -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> DeleteInstancesResponse: - response_default = DeleteInstancesResponse.from_dict(response.json()) - - return response_default - - -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[DeleteInstancesResponse]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - *, - client: Union[AuthenticatedClient, Client], - body: list["NameOrUUID"], -) -> Response[DeleteInstancesResponse]: - """Delete Instances - - Delete the specified instance(s) by ID(s) (name or UUID). After this call - the name of the instances are no longer valid. If the instances are - currently running, they are force-stopped. - - Args: - body (list['NameOrUUID']): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[DeleteInstancesResponse] - """ - - kwargs = _get_kwargs( - body=body, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - *, - client: Union[AuthenticatedClient, Client], - body: list["NameOrUUID"], -) -> Optional[DeleteInstancesResponse]: - """Delete Instances - - Delete the specified instance(s) by ID(s) (name or UUID). After this call - the name of the instances are no longer valid. If the instances are - currently running, they are force-stopped. - - Args: - body (list['NameOrUUID']): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - DeleteInstancesResponse - """ - - return sync_detailed( - client=client, - body=body, - ).parsed - - -async def asyncio_detailed( - *, - client: Union[AuthenticatedClient, Client], - body: list["NameOrUUID"], -) -> Response[DeleteInstancesResponse]: - """Delete Instances - - Delete the specified instance(s) by ID(s) (name or UUID). After this call - the name of the instances are no longer valid. If the instances are - currently running, they are force-stopped. - - Args: - body (list['NameOrUUID']): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[DeleteInstancesResponse] - """ - - kwargs = _get_kwargs( - body=body, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - *, - client: Union[AuthenticatedClient, Client], - body: list["NameOrUUID"], -) -> Optional[DeleteInstancesResponse]: - """Delete Instances - - Delete the specified instance(s) by ID(s) (name or UUID). After this call - the name of the instances are no longer valid. If the instances are - currently running, they are force-stopped. - - Args: - body (list['NameOrUUID']): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - DeleteInstancesResponse - """ - - return ( - await asyncio_detailed( - client=client, - body=body, - ) - ).parsed diff --git a/unikraft_cloud_platform/api/instances/get_instance_by_uuid.py b/unikraft_cloud_platform/api/instances/get_instance_by_uuid.py deleted file mode 100644 index 5f00472..0000000 --- a/unikraft_cloud_platform/api/instances/get_instance_by_uuid.py +++ /dev/null @@ -1,172 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union -from uuid import UUID - -import httpx - -from ...client import AuthenticatedClient, Client -from ...models.get_instances_response import GetInstancesResponse -from ...types import UNSET, Response, Unset - - -def _get_kwargs( - uuid: UUID, - *, - details: Union[Unset, bool] = UNSET, -) -> dict[str, Any]: - params: dict[str, Any] = {} - - params["details"] = details - - params = {k: v for k, v in params.items() if v is not UNSET and v is not None} - - _kwargs: dict[str, Any] = { - "method": "get", - "url": f"/v1/instances/{uuid}", - "params": params, - } - - return _kwargs - - -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> GetInstancesResponse: - response_default = GetInstancesResponse.from_dict(response.json()) - - return response_default - - -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[GetInstancesResponse]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], - details: Union[Unset, bool] = UNSET, -) -> Response[GetInstancesResponse]: - """Get Instance by UUID - - Get a single instance by its UUID. - - Args: - uuid (UUID): - details (Union[Unset, bool]): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[GetInstancesResponse] - """ - - kwargs = _get_kwargs( - uuid=uuid, - details=details, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], - details: Union[Unset, bool] = UNSET, -) -> Optional[GetInstancesResponse]: - """Get Instance by UUID - - Get a single instance by its UUID. - - Args: - uuid (UUID): - details (Union[Unset, bool]): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - GetInstancesResponse - """ - - return sync_detailed( - uuid=uuid, - client=client, - details=details, - ).parsed - - -async def asyncio_detailed( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], - details: Union[Unset, bool] = UNSET, -) -> Response[GetInstancesResponse]: - """Get Instance by UUID - - Get a single instance by its UUID. - - Args: - uuid (UUID): - details (Union[Unset, bool]): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[GetInstancesResponse] - """ - - kwargs = _get_kwargs( - uuid=uuid, - details=details, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], - details: Union[Unset, bool] = UNSET, -) -> Optional[GetInstancesResponse]: - """Get Instance by UUID - - Get a single instance by its UUID. - - Args: - uuid (UUID): - details (Union[Unset, bool]): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - GetInstancesResponse - """ - - return ( - await asyncio_detailed( - uuid=uuid, - client=client, - details=details, - ) - ).parsed diff --git a/unikraft_cloud_platform/api/instances/get_instance_logs.py b/unikraft_cloud_platform/api/instances/get_instance_logs.py deleted file mode 100644 index 0fd3856..0000000 --- a/unikraft_cloud_platform/api/instances/get_instance_logs.py +++ /dev/null @@ -1,167 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx - -from ...client import AuthenticatedClient, Client -from ...models.get_instance_logs_request import GetInstanceLogsRequest -from ...models.get_instance_logs_response import GetInstanceLogsResponse -from ...types import Response - - -def _get_kwargs( - *, - body: GetInstanceLogsRequest, -) -> dict[str, Any]: - headers: dict[str, Any] = {} - - _kwargs: dict[str, Any] = { - "method": "get", - "url": "/v1/instances/log", - } - - _kwargs["json"] = body.to_dict() - - headers["Content-Type"] = "application/json" - - _kwargs["headers"] = headers - return _kwargs - - -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> GetInstanceLogsResponse: - response_default = GetInstanceLogsResponse.from_dict(response.json()) - - return response_default - - -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[GetInstanceLogsResponse]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - *, - client: Union[AuthenticatedClient, Client], - body: GetInstanceLogsRequest, -) -> Response[GetInstanceLogsResponse]: - """Get Instances Logs - - Retrieve the logs of one or more instances by ID(s) (name or UUID). - - Args: - body (GetInstanceLogsRequest): The request message for getting the logs of an instance by - their UUID or - name. - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[GetInstanceLogsResponse] - """ - - kwargs = _get_kwargs( - body=body, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - *, - client: Union[AuthenticatedClient, Client], - body: GetInstanceLogsRequest, -) -> Optional[GetInstanceLogsResponse]: - """Get Instances Logs - - Retrieve the logs of one or more instances by ID(s) (name or UUID). - - Args: - body (GetInstanceLogsRequest): The request message for getting the logs of an instance by - their UUID or - name. - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - GetInstanceLogsResponse - """ - - return sync_detailed( - client=client, - body=body, - ).parsed - - -async def asyncio_detailed( - *, - client: Union[AuthenticatedClient, Client], - body: GetInstanceLogsRequest, -) -> Response[GetInstanceLogsResponse]: - """Get Instances Logs - - Retrieve the logs of one or more instances by ID(s) (name or UUID). - - Args: - body (GetInstanceLogsRequest): The request message for getting the logs of an instance by - their UUID or - name. - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[GetInstanceLogsResponse] - """ - - kwargs = _get_kwargs( - body=body, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - *, - client: Union[AuthenticatedClient, Client], - body: GetInstanceLogsRequest, -) -> Optional[GetInstanceLogsResponse]: - """Get Instances Logs - - Retrieve the logs of one or more instances by ID(s) (name or UUID). - - Args: - body (GetInstanceLogsRequest): The request message for getting the logs of an instance by - their UUID or - name. - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - GetInstanceLogsResponse - """ - - return ( - await asyncio_detailed( - client=client, - body=body, - ) - ).parsed diff --git a/unikraft_cloud_platform/api/instances/get_instance_logs_by_uuid.py b/unikraft_cloud_platform/api/instances/get_instance_logs_by_uuid.py deleted file mode 100644 index 38715cf..0000000 --- a/unikraft_cloud_platform/api/instances/get_instance_logs_by_uuid.py +++ /dev/null @@ -1,173 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union -from uuid import UUID - -import httpx - -from ...client import AuthenticatedClient, Client -from ...models.get_instance_logs_by_uuid_request_body import GetInstanceLogsByUUIDRequestBody -from ...models.get_instance_logs_response import GetInstanceLogsResponse -from ...types import Response - - -def _get_kwargs( - uuid: UUID, - *, - body: GetInstanceLogsByUUIDRequestBody, -) -> dict[str, Any]: - headers: dict[str, Any] = {} - - _kwargs: dict[str, Any] = { - "method": "get", - "url": f"/v1/instances/{uuid}/log", - } - - _kwargs["json"] = body.to_dict() - - headers["Content-Type"] = "application/json" - - _kwargs["headers"] = headers - return _kwargs - - -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> GetInstanceLogsResponse: - response_default = GetInstanceLogsResponse.from_dict(response.json()) - - return response_default - - -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[GetInstanceLogsResponse]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], - body: GetInstanceLogsByUUIDRequestBody, -) -> Response[GetInstanceLogsResponse]: - """Get Instance Logs by UUID - - Retrieve the logs of an instance by its UUID. - - Args: - uuid (UUID): Example: 123e4567-e89b-12d3-a456-426614174000. - body (GetInstanceLogsByUUIDRequestBody): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[GetInstanceLogsResponse] - """ - - kwargs = _get_kwargs( - uuid=uuid, - body=body, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], - body: GetInstanceLogsByUUIDRequestBody, -) -> Optional[GetInstanceLogsResponse]: - """Get Instance Logs by UUID - - Retrieve the logs of an instance by its UUID. - - Args: - uuid (UUID): Example: 123e4567-e89b-12d3-a456-426614174000. - body (GetInstanceLogsByUUIDRequestBody): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - GetInstanceLogsResponse - """ - - return sync_detailed( - uuid=uuid, - client=client, - body=body, - ).parsed - - -async def asyncio_detailed( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], - body: GetInstanceLogsByUUIDRequestBody, -) -> Response[GetInstanceLogsResponse]: - """Get Instance Logs by UUID - - Retrieve the logs of an instance by its UUID. - - Args: - uuid (UUID): Example: 123e4567-e89b-12d3-a456-426614174000. - body (GetInstanceLogsByUUIDRequestBody): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[GetInstanceLogsResponse] - """ - - kwargs = _get_kwargs( - uuid=uuid, - body=body, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], - body: GetInstanceLogsByUUIDRequestBody, -) -> Optional[GetInstanceLogsResponse]: - """Get Instance Logs by UUID - - Retrieve the logs of an instance by its UUID. - - Args: - uuid (UUID): Example: 123e4567-e89b-12d3-a456-426614174000. - body (GetInstanceLogsByUUIDRequestBody): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - GetInstanceLogsResponse - """ - - return ( - await asyncio_detailed( - uuid=uuid, - client=client, - body=body, - ) - ).parsed diff --git a/unikraft_cloud_platform/api/instances/get_instance_metrics.py b/unikraft_cloud_platform/api/instances/get_instance_metrics.py deleted file mode 100644 index 52c7906..0000000 --- a/unikraft_cloud_platform/api/instances/get_instance_metrics.py +++ /dev/null @@ -1,175 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx - -from ...client import AuthenticatedClient, Client -from ...models.get_instance_metrics_response import GetInstanceMetricsResponse -from ...types import UNSET, Response, Unset - - -def _get_kwargs( - *, - uuid: Union[Unset, str] = UNSET, - name: Union[Unset, str] = UNSET, -) -> dict[str, Any]: - params: dict[str, Any] = {} - - params["uuid"] = uuid - - params["name"] = name - - params = {k: v for k, v in params.items() if v is not UNSET and v is not None} - - _kwargs: dict[str, Any] = { - "method": "get", - "url": "/v1/instances/metrics", - "params": params, - } - - return _kwargs - - -def _parse_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> GetInstanceMetricsResponse: - response_default = GetInstanceMetricsResponse.from_dict(response.json()) - - return response_default - - -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[GetInstanceMetricsResponse]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - *, - client: Union[AuthenticatedClient, Client], - uuid: Union[Unset, str] = UNSET, - name: Union[Unset, str] = UNSET, -) -> Response[GetInstanceMetricsResponse]: - """Get Instances Metrics - - Get the metrics of an instance by its UUID or name. - - Args: - uuid (Union[Unset, str]): - name (Union[Unset, str]): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[GetInstanceMetricsResponse] - """ - - kwargs = _get_kwargs( - uuid=uuid, - name=name, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - *, - client: Union[AuthenticatedClient, Client], - uuid: Union[Unset, str] = UNSET, - name: Union[Unset, str] = UNSET, -) -> Optional[GetInstanceMetricsResponse]: - """Get Instances Metrics - - Get the metrics of an instance by its UUID or name. - - Args: - uuid (Union[Unset, str]): - name (Union[Unset, str]): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - GetInstanceMetricsResponse - """ - - return sync_detailed( - client=client, - uuid=uuid, - name=name, - ).parsed - - -async def asyncio_detailed( - *, - client: Union[AuthenticatedClient, Client], - uuid: Union[Unset, str] = UNSET, - name: Union[Unset, str] = UNSET, -) -> Response[GetInstanceMetricsResponse]: - """Get Instances Metrics - - Get the metrics of an instance by its UUID or name. - - Args: - uuid (Union[Unset, str]): - name (Union[Unset, str]): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[GetInstanceMetricsResponse] - """ - - kwargs = _get_kwargs( - uuid=uuid, - name=name, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - *, - client: Union[AuthenticatedClient, Client], - uuid: Union[Unset, str] = UNSET, - name: Union[Unset, str] = UNSET, -) -> Optional[GetInstanceMetricsResponse]: - """Get Instances Metrics - - Get the metrics of an instance by its UUID or name. - - Args: - uuid (Union[Unset, str]): - name (Union[Unset, str]): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - GetInstanceMetricsResponse - """ - - return ( - await asyncio_detailed( - client=client, - uuid=uuid, - name=name, - ) - ).parsed diff --git a/unikraft_cloud_platform/api/instances/get_instance_metrics_by_uuid.py b/unikraft_cloud_platform/api/instances/get_instance_metrics_by_uuid.py deleted file mode 100644 index 5594532..0000000 --- a/unikraft_cloud_platform/api/instances/get_instance_metrics_by_uuid.py +++ /dev/null @@ -1,153 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union -from uuid import UUID - -import httpx - -from ...client import AuthenticatedClient, Client -from ...models.get_instance_metrics_response import GetInstanceMetricsResponse -from ...types import Response - - -def _get_kwargs( - uuid: UUID, -) -> dict[str, Any]: - _kwargs: dict[str, Any] = { - "method": "get", - "url": f"/v1/instances/{uuid}/metrics", - } - - return _kwargs - - -def _parse_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> GetInstanceMetricsResponse: - response_default = GetInstanceMetricsResponse.from_dict(response.json()) - - return response_default - - -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[GetInstanceMetricsResponse]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], -) -> Response[GetInstanceMetricsResponse]: - """Get Instance Metrics by UUID - - Get the metrics of an instance by its UUID. - - Args: - uuid (UUID): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[GetInstanceMetricsResponse] - """ - - kwargs = _get_kwargs( - uuid=uuid, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], -) -> Optional[GetInstanceMetricsResponse]: - """Get Instance Metrics by UUID - - Get the metrics of an instance by its UUID. - - Args: - uuid (UUID): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - GetInstanceMetricsResponse - """ - - return sync_detailed( - uuid=uuid, - client=client, - ).parsed - - -async def asyncio_detailed( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], -) -> Response[GetInstanceMetricsResponse]: - """Get Instance Metrics by UUID - - Get the metrics of an instance by its UUID. - - Args: - uuid (UUID): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[GetInstanceMetricsResponse] - """ - - kwargs = _get_kwargs( - uuid=uuid, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], -) -> Optional[GetInstanceMetricsResponse]: - """Get Instance Metrics by UUID - - Get the metrics of an instance by its UUID. - - Args: - uuid (UUID): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - GetInstanceMetricsResponse - """ - - return ( - await asyncio_detailed( - uuid=uuid, - client=client, - ) - ).parsed diff --git a/unikraft_cloud_platform/api/instances/get_instances.py b/unikraft_cloud_platform/api/instances/get_instances.py deleted file mode 100644 index b8d7a89..0000000 --- a/unikraft_cloud_platform/api/instances/get_instances.py +++ /dev/null @@ -1,186 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx - -from ...client import AuthenticatedClient, Client -from ...models.get_instances_response import GetInstancesResponse -from ...models.name_or_uuid import NameOrUUID -from ...types import UNSET, Response, Unset - - -def _get_kwargs( - *, - body: list["NameOrUUID"], - details: Union[Unset, bool] = UNSET, -) -> dict[str, Any]: - headers: dict[str, Any] = {} - - params: dict[str, Any] = {} - - params["details"] = details - - params = {k: v for k, v in params.items() if v is not UNSET and v is not None} - - _kwargs: dict[str, Any] = { - "method": "get", - "url": "/v1/instances", - "params": params, - } - - _kwargs["json"] = [] - for body_item_data in body: - body_item = body_item_data.to_dict() - _kwargs["json"].append(body_item) - - headers["Content-Type"] = "application/json" - - _kwargs["headers"] = headers - return _kwargs - - -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> GetInstancesResponse: - response_default = GetInstancesResponse.from_dict(response.json()) - - return response_default - - -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[GetInstancesResponse]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - *, - client: Union[AuthenticatedClient, Client], - body: list["NameOrUUID"], - details: Union[Unset, bool] = UNSET, -) -> Response[GetInstancesResponse]: - """List Instances - - Get one or many instances with their current status and configuration. - It's possible to filter this list by ID(s) (name or UUID). - - Args: - details (Union[Unset, bool]): - body (list['NameOrUUID']): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[GetInstancesResponse] - """ - - kwargs = _get_kwargs( - body=body, - details=details, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - *, - client: Union[AuthenticatedClient, Client], - body: list["NameOrUUID"], - details: Union[Unset, bool] = UNSET, -) -> Optional[GetInstancesResponse]: - """List Instances - - Get one or many instances with their current status and configuration. - It's possible to filter this list by ID(s) (name or UUID). - - Args: - details (Union[Unset, bool]): - body (list['NameOrUUID']): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - GetInstancesResponse - """ - - return sync_detailed( - client=client, - body=body, - details=details, - ).parsed - - -async def asyncio_detailed( - *, - client: Union[AuthenticatedClient, Client], - body: list["NameOrUUID"], - details: Union[Unset, bool] = UNSET, -) -> Response[GetInstancesResponse]: - """List Instances - - Get one or many instances with their current status and configuration. - It's possible to filter this list by ID(s) (name or UUID). - - Args: - details (Union[Unset, bool]): - body (list['NameOrUUID']): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[GetInstancesResponse] - """ - - kwargs = _get_kwargs( - body=body, - details=details, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - *, - client: Union[AuthenticatedClient, Client], - body: list["NameOrUUID"], - details: Union[Unset, bool] = UNSET, -) -> Optional[GetInstancesResponse]: - """List Instances - - Get one or many instances with their current status and configuration. - It's possible to filter this list by ID(s) (name or UUID). - - Args: - details (Union[Unset, bool]): - body (list['NameOrUUID']): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - GetInstancesResponse - """ - - return ( - await asyncio_detailed( - client=client, - body=body, - details=details, - ) - ).parsed diff --git a/unikraft_cloud_platform/api/instances/start_instance_by_uuid.py b/unikraft_cloud_platform/api/instances/start_instance_by_uuid.py deleted file mode 100644 index 27eccb4..0000000 --- a/unikraft_cloud_platform/api/instances/start_instance_by_uuid.py +++ /dev/null @@ -1,155 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union -from uuid import UUID - -import httpx - -from ...client import AuthenticatedClient, Client -from ...models.start_instance_response import StartInstanceResponse -from ...types import Response - - -def _get_kwargs( - uuid: UUID, -) -> dict[str, Any]: - _kwargs: dict[str, Any] = { - "method": "put", - "url": f"/v1/instances/{uuid}/start", - } - - return _kwargs - - -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> StartInstanceResponse: - response_default = StartInstanceResponse.from_dict(response.json()) - - return response_default - - -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[StartInstanceResponse]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], -) -> Response[StartInstanceResponse]: - """Start Instance by UUID - - Start a previously stopped instance by its UUID or do nothing if the - instance is already running. - - Args: - uuid (UUID): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[StartInstanceResponse] - """ - - kwargs = _get_kwargs( - uuid=uuid, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], -) -> Optional[StartInstanceResponse]: - """Start Instance by UUID - - Start a previously stopped instance by its UUID or do nothing if the - instance is already running. - - Args: - uuid (UUID): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - StartInstanceResponse - """ - - return sync_detailed( - uuid=uuid, - client=client, - ).parsed - - -async def asyncio_detailed( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], -) -> Response[StartInstanceResponse]: - """Start Instance by UUID - - Start a previously stopped instance by its UUID or do nothing if the - instance is already running. - - Args: - uuid (UUID): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[StartInstanceResponse] - """ - - kwargs = _get_kwargs( - uuid=uuid, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], -) -> Optional[StartInstanceResponse]: - """Start Instance by UUID - - Start a previously stopped instance by its UUID or do nothing if the - instance is already running. - - Args: - uuid (UUID): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - StartInstanceResponse - """ - - return ( - await asyncio_detailed( - uuid=uuid, - client=client, - ) - ).parsed diff --git a/unikraft_cloud_platform/api/instances/start_instances.py b/unikraft_cloud_platform/api/instances/start_instances.py deleted file mode 100644 index d8a130d..0000000 --- a/unikraft_cloud_platform/api/instances/start_instances.py +++ /dev/null @@ -1,166 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx - -from ...client import AuthenticatedClient, Client -from ...models.name_or_uuid import NameOrUUID -from ...models.start_instance_response import StartInstanceResponse -from ...types import Response - - -def _get_kwargs( - *, - body: list["NameOrUUID"], -) -> dict[str, Any]: - headers: dict[str, Any] = {} - - _kwargs: dict[str, Any] = { - "method": "put", - "url": "/v1/instances/start", - } - - _kwargs["json"] = [] - for body_item_data in body: - body_item = body_item_data.to_dict() - _kwargs["json"].append(body_item) - - headers["Content-Type"] = "application/json" - - _kwargs["headers"] = headers - return _kwargs - - -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> StartInstanceResponse: - response_default = StartInstanceResponse.from_dict(response.json()) - - return response_default - - -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[StartInstanceResponse]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - *, - client: Union[AuthenticatedClient, Client], - body: list["NameOrUUID"], -) -> Response[StartInstanceResponse]: - """Start Instances - - Start previously stopped instances by ID(s) (name or UUID) or do - nothing if the instances are already running. - - Args: - body (list['NameOrUUID']): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[StartInstanceResponse] - """ - - kwargs = _get_kwargs( - body=body, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - *, - client: Union[AuthenticatedClient, Client], - body: list["NameOrUUID"], -) -> Optional[StartInstanceResponse]: - """Start Instances - - Start previously stopped instances by ID(s) (name or UUID) or do - nothing if the instances are already running. - - Args: - body (list['NameOrUUID']): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - StartInstanceResponse - """ - - return sync_detailed( - client=client, - body=body, - ).parsed - - -async def asyncio_detailed( - *, - client: Union[AuthenticatedClient, Client], - body: list["NameOrUUID"], -) -> Response[StartInstanceResponse]: - """Start Instances - - Start previously stopped instances by ID(s) (name or UUID) or do - nothing if the instances are already running. - - Args: - body (list['NameOrUUID']): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[StartInstanceResponse] - """ - - kwargs = _get_kwargs( - body=body, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - *, - client: Union[AuthenticatedClient, Client], - body: list["NameOrUUID"], -) -> Optional[StartInstanceResponse]: - """Start Instances - - Start previously stopped instances by ID(s) (name or UUID) or do - nothing if the instances are already running. - - Args: - body (list['NameOrUUID']): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - StartInstanceResponse - """ - - return ( - await asyncio_detailed( - client=client, - body=body, - ) - ).parsed diff --git a/unikraft_cloud_platform/api/instances/stop_instance_by_uuid.py b/unikraft_cloud_platform/api/instances/stop_instance_by_uuid.py deleted file mode 100644 index fa89775..0000000 --- a/unikraft_cloud_platform/api/instances/stop_instance_by_uuid.py +++ /dev/null @@ -1,191 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union -from uuid import UUID - -import httpx - -from ...client import AuthenticatedClient, Client -from ...models.stop_instance_response import StopInstanceResponse -from ...types import UNSET, Response, Unset - - -def _get_kwargs( - uuid: UUID, - *, - force: Union[Unset, bool] = UNSET, - drain_timeout_ms: Union[Unset, int] = UNSET, -) -> dict[str, Any]: - params: dict[str, Any] = {} - - params["force"] = force - - params["drain_timeout_ms"] = drain_timeout_ms - - params = {k: v for k, v in params.items() if v is not UNSET and v is not None} - - _kwargs: dict[str, Any] = { - "method": "put", - "url": f"/v1/instances/{uuid}/stop", - "params": params, - } - - return _kwargs - - -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> StopInstanceResponse: - response_default = StopInstanceResponse.from_dict(response.json()) - - return response_default - - -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[StopInstanceResponse]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], - force: Union[Unset, bool] = UNSET, - drain_timeout_ms: Union[Unset, int] = UNSET, -) -> Response[StopInstanceResponse]: - """Stop Instance by UUID - - Stop a running instance by its UUID or do nothing if the instance is - already stopped. - - Args: - uuid (UUID): - force (Union[Unset, bool]): - drain_timeout_ms (Union[Unset, int]): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[StopInstanceResponse] - """ - - kwargs = _get_kwargs( - uuid=uuid, - force=force, - drain_timeout_ms=drain_timeout_ms, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], - force: Union[Unset, bool] = UNSET, - drain_timeout_ms: Union[Unset, int] = UNSET, -) -> Optional[StopInstanceResponse]: - """Stop Instance by UUID - - Stop a running instance by its UUID or do nothing if the instance is - already stopped. - - Args: - uuid (UUID): - force (Union[Unset, bool]): - drain_timeout_ms (Union[Unset, int]): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - StopInstanceResponse - """ - - return sync_detailed( - uuid=uuid, - client=client, - force=force, - drain_timeout_ms=drain_timeout_ms, - ).parsed - - -async def asyncio_detailed( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], - force: Union[Unset, bool] = UNSET, - drain_timeout_ms: Union[Unset, int] = UNSET, -) -> Response[StopInstanceResponse]: - """Stop Instance by UUID - - Stop a running instance by its UUID or do nothing if the instance is - already stopped. - - Args: - uuid (UUID): - force (Union[Unset, bool]): - drain_timeout_ms (Union[Unset, int]): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[StopInstanceResponse] - """ - - kwargs = _get_kwargs( - uuid=uuid, - force=force, - drain_timeout_ms=drain_timeout_ms, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], - force: Union[Unset, bool] = UNSET, - drain_timeout_ms: Union[Unset, int] = UNSET, -) -> Optional[StopInstanceResponse]: - """Stop Instance by UUID - - Stop a running instance by its UUID or do nothing if the instance is - already stopped. - - Args: - uuid (UUID): - force (Union[Unset, bool]): - drain_timeout_ms (Union[Unset, int]): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - StopInstanceResponse - """ - - return ( - await asyncio_detailed( - uuid=uuid, - client=client, - force=force, - drain_timeout_ms=drain_timeout_ms, - ) - ).parsed diff --git a/unikraft_cloud_platform/api/instances/stop_instances.py b/unikraft_cloud_platform/api/instances/stop_instances.py deleted file mode 100644 index 33f9273..0000000 --- a/unikraft_cloud_platform/api/instances/stop_instances.py +++ /dev/null @@ -1,166 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx - -from ...client import AuthenticatedClient, Client -from ...models.stop_instance_response import StopInstanceResponse -from ...models.stop_instances_request_id import StopInstancesRequestID -from ...types import Response - - -def _get_kwargs( - *, - body: list["StopInstancesRequestID"], -) -> dict[str, Any]: - headers: dict[str, Any] = {} - - _kwargs: dict[str, Any] = { - "method": "put", - "url": "/v1/instances/stop", - } - - _kwargs["json"] = [] - for body_item_data in body: - body_item = body_item_data.to_dict() - _kwargs["json"].append(body_item) - - headers["Content-Type"] = "application/json" - - _kwargs["headers"] = headers - return _kwargs - - -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> StopInstanceResponse: - response_default = StopInstanceResponse.from_dict(response.json()) - - return response_default - - -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[StopInstanceResponse]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - *, - client: Union[AuthenticatedClient, Client], - body: list["StopInstancesRequestID"], -) -> Response[StopInstanceResponse]: - """Stop Instances - - Stop one or more running instance by ID(s) (name or UUID) or do - nothing if the instances are already stopped. - - Args: - body (list['StopInstancesRequestID']): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[StopInstanceResponse] - """ - - kwargs = _get_kwargs( - body=body, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - *, - client: Union[AuthenticatedClient, Client], - body: list["StopInstancesRequestID"], -) -> Optional[StopInstanceResponse]: - """Stop Instances - - Stop one or more running instance by ID(s) (name or UUID) or do - nothing if the instances are already stopped. - - Args: - body (list['StopInstancesRequestID']): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - StopInstanceResponse - """ - - return sync_detailed( - client=client, - body=body, - ).parsed - - -async def asyncio_detailed( - *, - client: Union[AuthenticatedClient, Client], - body: list["StopInstancesRequestID"], -) -> Response[StopInstanceResponse]: - """Stop Instances - - Stop one or more running instance by ID(s) (name or UUID) or do - nothing if the instances are already stopped. - - Args: - body (list['StopInstancesRequestID']): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[StopInstanceResponse] - """ - - kwargs = _get_kwargs( - body=body, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - *, - client: Union[AuthenticatedClient, Client], - body: list["StopInstancesRequestID"], -) -> Optional[StopInstanceResponse]: - """Stop Instances - - Stop one or more running instance by ID(s) (name or UUID) or do - nothing if the instances are already stopped. - - Args: - body (list['StopInstancesRequestID']): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - StopInstanceResponse - """ - - return ( - await asyncio_detailed( - client=client, - body=body, - ) - ).parsed diff --git a/unikraft_cloud_platform/api/instances/update_instance_by_uuid.py b/unikraft_cloud_platform/api/instances/update_instance_by_uuid.py deleted file mode 100644 index 50cdd9a..0000000 --- a/unikraft_cloud_platform/api/instances/update_instance_by_uuid.py +++ /dev/null @@ -1,177 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union -from uuid import UUID - -import httpx - -from ...client import AuthenticatedClient, Client -from ...models.update_instance_by_uuid_request_body import UpdateInstanceByUUIDRequestBody -from ...models.update_instances_response import UpdateInstancesResponse -from ...types import Response - - -def _get_kwargs( - uuid: UUID, - *, - body: UpdateInstanceByUUIDRequestBody, -) -> dict[str, Any]: - headers: dict[str, Any] = {} - - _kwargs: dict[str, Any] = { - "method": "patch", - "url": f"/v1/instances/{uuid}", - } - - _kwargs["json"] = body.to_dict() - - headers["Content-Type"] = "application/json" - - _kwargs["headers"] = headers - return _kwargs - - -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> UpdateInstancesResponse: - response_default = UpdateInstancesResponse.from_dict(response.json()) - - return response_default - - -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[UpdateInstancesResponse]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], - body: UpdateInstanceByUUIDRequestBody, -) -> Response[UpdateInstancesResponse]: - """Update Instance by UUID - - Update (modify) an instance by its UUID. The instance must be in a stopped - state for most update operations. - - Args: - uuid (UUID): Example: 123e4567-e89b-12d3-a456-426614174000. - body (UpdateInstanceByUUIDRequestBody): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[UpdateInstancesResponse] - """ - - kwargs = _get_kwargs( - uuid=uuid, - body=body, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], - body: UpdateInstanceByUUIDRequestBody, -) -> Optional[UpdateInstancesResponse]: - """Update Instance by UUID - - Update (modify) an instance by its UUID. The instance must be in a stopped - state for most update operations. - - Args: - uuid (UUID): Example: 123e4567-e89b-12d3-a456-426614174000. - body (UpdateInstanceByUUIDRequestBody): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - UpdateInstancesResponse - """ - - return sync_detailed( - uuid=uuid, - client=client, - body=body, - ).parsed - - -async def asyncio_detailed( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], - body: UpdateInstanceByUUIDRequestBody, -) -> Response[UpdateInstancesResponse]: - """Update Instance by UUID - - Update (modify) an instance by its UUID. The instance must be in a stopped - state for most update operations. - - Args: - uuid (UUID): Example: 123e4567-e89b-12d3-a456-426614174000. - body (UpdateInstanceByUUIDRequestBody): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[UpdateInstancesResponse] - """ - - kwargs = _get_kwargs( - uuid=uuid, - body=body, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], - body: UpdateInstanceByUUIDRequestBody, -) -> Optional[UpdateInstancesResponse]: - """Update Instance by UUID - - Update (modify) an instance by its UUID. The instance must be in a stopped - state for most update operations. - - Args: - uuid (UUID): Example: 123e4567-e89b-12d3-a456-426614174000. - body (UpdateInstanceByUUIDRequestBody): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - UpdateInstancesResponse - """ - - return ( - await asyncio_detailed( - uuid=uuid, - client=client, - body=body, - ) - ).parsed diff --git a/unikraft_cloud_platform/api/instances/update_instances.py b/unikraft_cloud_platform/api/instances/update_instances.py deleted file mode 100644 index 0a9e43b..0000000 --- a/unikraft_cloud_platform/api/instances/update_instances.py +++ /dev/null @@ -1,163 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx - -from ...client import AuthenticatedClient, Client -from ...models.update_instances_request import UpdateInstancesRequest -from ...models.update_instances_response import UpdateInstancesResponse -from ...types import Response - - -def _get_kwargs( - *, - body: UpdateInstancesRequest, -) -> dict[str, Any]: - headers: dict[str, Any] = {} - - _kwargs: dict[str, Any] = { - "method": "patch", - "url": "/v1/instances", - } - - _kwargs["json"] = body.to_dict() - - headers["Content-Type"] = "application/json" - - _kwargs["headers"] = headers - return _kwargs - - -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> UpdateInstancesResponse: - response_default = UpdateInstancesResponse.from_dict(response.json()) - - return response_default - - -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[UpdateInstancesResponse]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - *, - client: Union[AuthenticatedClient, Client], - body: UpdateInstancesRequest, -) -> Response[UpdateInstancesResponse]: - """Update Instances - - Update (modify) one or more instances by ID(s) (name or UUID). The - instances must be in a stopped state for most update operations. - - Args: - body (UpdateInstancesRequest): The request message for updating one or more instances. - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[UpdateInstancesResponse] - """ - - kwargs = _get_kwargs( - body=body, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - *, - client: Union[AuthenticatedClient, Client], - body: UpdateInstancesRequest, -) -> Optional[UpdateInstancesResponse]: - """Update Instances - - Update (modify) one or more instances by ID(s) (name or UUID). The - instances must be in a stopped state for most update operations. - - Args: - body (UpdateInstancesRequest): The request message for updating one or more instances. - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - UpdateInstancesResponse - """ - - return sync_detailed( - client=client, - body=body, - ).parsed - - -async def asyncio_detailed( - *, - client: Union[AuthenticatedClient, Client], - body: UpdateInstancesRequest, -) -> Response[UpdateInstancesResponse]: - """Update Instances - - Update (modify) one or more instances by ID(s) (name or UUID). The - instances must be in a stopped state for most update operations. - - Args: - body (UpdateInstancesRequest): The request message for updating one or more instances. - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[UpdateInstancesResponse] - """ - - kwargs = _get_kwargs( - body=body, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - *, - client: Union[AuthenticatedClient, Client], - body: UpdateInstancesRequest, -) -> Optional[UpdateInstancesResponse]: - """Update Instances - - Update (modify) one or more instances by ID(s) (name or UUID). The - instances must be in a stopped state for most update operations. - - Args: - body (UpdateInstancesRequest): The request message for updating one or more instances. - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - UpdateInstancesResponse - """ - - return ( - await asyncio_detailed( - client=client, - body=body, - ) - ).parsed diff --git a/unikraft_cloud_platform/api/instances/wait_instance_by_uuid.py b/unikraft_cloud_platform/api/instances/wait_instance_by_uuid.py deleted file mode 100644 index cf83ceb..0000000 --- a/unikraft_cloud_platform/api/instances/wait_instance_by_uuid.py +++ /dev/null @@ -1,201 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union -from uuid import UUID - -import httpx - -from ...client import AuthenticatedClient, Client -from ...models.wait_instance_by_uuid_request_body import WaitInstanceByUUIDRequestBody -from ...models.wait_instance_response import WaitInstanceResponse -from ...types import Response - - -def _get_kwargs( - uuid: UUID, - *, - body: WaitInstanceByUUIDRequestBody, -) -> dict[str, Any]: - headers: dict[str, Any] = {} - - _kwargs: dict[str, Any] = { - "method": "get", - "url": f"/v1/instances/{uuid}/wait", - } - - _kwargs["json"] = body.to_dict() - - headers["Content-Type"] = "application/json" - - _kwargs["headers"] = headers - return _kwargs - - -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> WaitInstanceResponse: - response_default = WaitInstanceResponse.from_dict(response.json()) - - return response_default - - -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[WaitInstanceResponse]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], - body: WaitInstanceByUUIDRequestBody, -) -> Response[WaitInstanceResponse]: - """Wait for Instance State by UUID - - Wait for an instance to reach a certain state, by its UUID. - - If the instance is already in the desired state, the request will return - immediately. If the instance is not in the desired state, the request will - block until the instance reaches the desired state or the timeout is - reached. If the timeout is reached, the request will fail with an error. - If the timeout is -1, the request will block indefinitely until the - instance reaches the desired state. - - Args: - uuid (UUID): Example: 123e4567-e89b-12d3-a456-426614174000. - body (WaitInstanceByUUIDRequestBody): Wait parameters. - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[WaitInstanceResponse] - """ - - kwargs = _get_kwargs( - uuid=uuid, - body=body, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], - body: WaitInstanceByUUIDRequestBody, -) -> Optional[WaitInstanceResponse]: - """Wait for Instance State by UUID - - Wait for an instance to reach a certain state, by its UUID. - - If the instance is already in the desired state, the request will return - immediately. If the instance is not in the desired state, the request will - block until the instance reaches the desired state or the timeout is - reached. If the timeout is reached, the request will fail with an error. - If the timeout is -1, the request will block indefinitely until the - instance reaches the desired state. - - Args: - uuid (UUID): Example: 123e4567-e89b-12d3-a456-426614174000. - body (WaitInstanceByUUIDRequestBody): Wait parameters. - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - WaitInstanceResponse - """ - - return sync_detailed( - uuid=uuid, - client=client, - body=body, - ).parsed - - -async def asyncio_detailed( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], - body: WaitInstanceByUUIDRequestBody, -) -> Response[WaitInstanceResponse]: - """Wait for Instance State by UUID - - Wait for an instance to reach a certain state, by its UUID. - - If the instance is already in the desired state, the request will return - immediately. If the instance is not in the desired state, the request will - block until the instance reaches the desired state or the timeout is - reached. If the timeout is reached, the request will fail with an error. - If the timeout is -1, the request will block indefinitely until the - instance reaches the desired state. - - Args: - uuid (UUID): Example: 123e4567-e89b-12d3-a456-426614174000. - body (WaitInstanceByUUIDRequestBody): Wait parameters. - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[WaitInstanceResponse] - """ - - kwargs = _get_kwargs( - uuid=uuid, - body=body, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], - body: WaitInstanceByUUIDRequestBody, -) -> Optional[WaitInstanceResponse]: - """Wait for Instance State by UUID - - Wait for an instance to reach a certain state, by its UUID. - - If the instance is already in the desired state, the request will return - immediately. If the instance is not in the desired state, the request will - block until the instance reaches the desired state or the timeout is - reached. If the timeout is reached, the request will fail with an error. - If the timeout is -1, the request will block indefinitely until the - instance reaches the desired state. - - Args: - uuid (UUID): Example: 123e4567-e89b-12d3-a456-426614174000. - body (WaitInstanceByUUIDRequestBody): Wait parameters. - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - WaitInstanceResponse - """ - - return ( - await asyncio_detailed( - uuid=uuid, - client=client, - body=body, - ) - ).parsed diff --git a/unikraft_cloud_platform/api/instances/wait_instances.py b/unikraft_cloud_platform/api/instances/wait_instances.py deleted file mode 100644 index 4bab969..0000000 --- a/unikraft_cloud_platform/api/instances/wait_instances.py +++ /dev/null @@ -1,234 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx - -from ...client import AuthenticatedClient, Client -from ...models.name_or_uuid import NameOrUUID -from ...models.wait_instance_response import WaitInstanceResponse -from ...models.wait_instances_state import WaitInstancesState -from ...types import UNSET, Response, Unset - - -def _get_kwargs( - *, - body: list["NameOrUUID"], - state: Union[Unset, WaitInstancesState] = UNSET, - timeout_ms: Union[Unset, int] = UNSET, -) -> dict[str, Any]: - headers: dict[str, Any] = {} - - params: dict[str, Any] = {} - - json_state: Union[Unset, str] = UNSET - if not isinstance(state, Unset): - json_state = state - - params["state"] = json_state - - params["timeout_ms"] = timeout_ms - - params = {k: v for k, v in params.items() if v is not UNSET and v is not None} - - _kwargs: dict[str, Any] = { - "method": "get", - "url": "/v1/instances/wait", - "params": params, - } - - _kwargs["json"] = [] - for body_item_data in body: - body_item = body_item_data.to_dict() - _kwargs["json"].append(body_item) - - headers["Content-Type"] = "application/json" - - _kwargs["headers"] = headers - return _kwargs - - -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> WaitInstanceResponse: - response_default = WaitInstanceResponse.from_dict(response.json()) - - return response_default - - -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[WaitInstanceResponse]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - *, - client: Union[AuthenticatedClient, Client], - body: list["NameOrUUID"], - state: Union[Unset, WaitInstancesState] = UNSET, - timeout_ms: Union[Unset, int] = UNSET, -) -> Response[WaitInstanceResponse]: - """Wait for Instances States - - Wait for one or more instances to reach certain states by ID(s) - (name or UUID). - - If the instances are already in the desired states, the request will return - immediately. If the instances are not in the desired state, the request will - block until the instances reach the desired state or the timeout is - reached. If the timeout is reached, the request will fail with an error. - If the timeout is -1, the request will block indefinitely until the - instances reach the desired states. - - Args: - state (Union[Unset, WaitInstancesState]): - timeout_ms (Union[Unset, int]): - body (list['NameOrUUID']): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[WaitInstanceResponse] - """ - - kwargs = _get_kwargs( - body=body, - state=state, - timeout_ms=timeout_ms, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - *, - client: Union[AuthenticatedClient, Client], - body: list["NameOrUUID"], - state: Union[Unset, WaitInstancesState] = UNSET, - timeout_ms: Union[Unset, int] = UNSET, -) -> Optional[WaitInstanceResponse]: - """Wait for Instances States - - Wait for one or more instances to reach certain states by ID(s) - (name or UUID). - - If the instances are already in the desired states, the request will return - immediately. If the instances are not in the desired state, the request will - block until the instances reach the desired state or the timeout is - reached. If the timeout is reached, the request will fail with an error. - If the timeout is -1, the request will block indefinitely until the - instances reach the desired states. - - Args: - state (Union[Unset, WaitInstancesState]): - timeout_ms (Union[Unset, int]): - body (list['NameOrUUID']): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - WaitInstanceResponse - """ - - return sync_detailed( - client=client, - body=body, - state=state, - timeout_ms=timeout_ms, - ).parsed - - -async def asyncio_detailed( - *, - client: Union[AuthenticatedClient, Client], - body: list["NameOrUUID"], - state: Union[Unset, WaitInstancesState] = UNSET, - timeout_ms: Union[Unset, int] = UNSET, -) -> Response[WaitInstanceResponse]: - """Wait for Instances States - - Wait for one or more instances to reach certain states by ID(s) - (name or UUID). - - If the instances are already in the desired states, the request will return - immediately. If the instances are not in the desired state, the request will - block until the instances reach the desired state or the timeout is - reached. If the timeout is reached, the request will fail with an error. - If the timeout is -1, the request will block indefinitely until the - instances reach the desired states. - - Args: - state (Union[Unset, WaitInstancesState]): - timeout_ms (Union[Unset, int]): - body (list['NameOrUUID']): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[WaitInstanceResponse] - """ - - kwargs = _get_kwargs( - body=body, - state=state, - timeout_ms=timeout_ms, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - *, - client: Union[AuthenticatedClient, Client], - body: list["NameOrUUID"], - state: Union[Unset, WaitInstancesState] = UNSET, - timeout_ms: Union[Unset, int] = UNSET, -) -> Optional[WaitInstanceResponse]: - """Wait for Instances States - - Wait for one or more instances to reach certain states by ID(s) - (name or UUID). - - If the instances are already in the desired states, the request will return - immediately. If the instances are not in the desired state, the request will - block until the instances reach the desired state or the timeout is - reached. If the timeout is reached, the request will fail with an error. - If the timeout is -1, the request will block indefinitely until the - instances reach the desired states. - - Args: - state (Union[Unset, WaitInstancesState]): - timeout_ms (Union[Unset, int]): - body (list['NameOrUUID']): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - WaitInstanceResponse - """ - - return ( - await asyncio_detailed( - client=client, - body=body, - state=state, - timeout_ms=timeout_ms, - ) - ).parsed diff --git a/unikraft_cloud_platform/api/instances_api.py b/unikraft_cloud_platform/api/instances_api.py new file mode 100644 index 0000000..352730c --- /dev/null +++ b/unikraft_cloud_platform/api/instances_api.py @@ -0,0 +1,3546 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +import warnings +from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt +from typing import Any, Dict, List, Optional, Tuple, Union +from typing_extensions import Annotated + +from pydantic import Field, StrictBool, StrictInt +from typing import List, Optional +from typing_extensions import Annotated +from uuid import UUID +from unikraft_cloud_platform.models.create_instance200_response import CreateInstance200Response +from unikraft_cloud_platform.models.create_instance_request import CreateInstanceRequest +from unikraft_cloud_platform.models.delete_instances200_response import DeleteInstances200Response +from unikraft_cloud_platform.models.delete_instances_request_inner import DeleteInstancesRequestInner +from unikraft_cloud_platform.models.get_instance_by_uuid200_response import GetInstanceByUuid200Response +from unikraft_cloud_platform.models.get_instance_logs200_response import GetInstanceLogs200Response +from unikraft_cloud_platform.models.get_instance_logs_request_inner import GetInstanceLogsRequestInner +from unikraft_cloud_platform.models.get_instance_metrics200_response import GetInstanceMetrics200Response +from unikraft_cloud_platform.models.get_instance_metrics_request_inner import GetInstanceMetricsRequestInner +from unikraft_cloud_platform.models.get_instances200_response import GetInstances200Response +from unikraft_cloud_platform.models.get_instances_request_inner import GetInstancesRequestInner +from unikraft_cloud_platform.models.start_instances200_response import StartInstances200Response +from unikraft_cloud_platform.models.start_instances_request_inner import StartInstancesRequestInner +from unikraft_cloud_platform.models.stop_instances_request_inner import StopInstancesRequestInner +from unikraft_cloud_platform.models.wait_for_instances200_response import WaitForInstances200Response +from unikraft_cloud_platform.models.wait_for_instances_request_inner import WaitForInstancesRequestInner + +from unikraft_cloud_platform.api_client import ApiClient, RequestSerialized +from unikraft_cloud_platform.api_response import ApiResponse +from unikraft_cloud_platform.rest import RESTResponseType + + +class InstancesApi: + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, api_client=None) -> None: + if api_client is None: + api_client = ApiClient.get_default() + self.api_client = api_client + + @validate_call + def create_instance( + self, + create_instance_request: CreateInstanceRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> CreateInstance200Response: + """Create an instance + + Creates a new instance of the specified Unikraft Cloud image. You can describe the properties of the new instance such as its startup arguments and amount of memory. Note that the instance properties can only be defined during creation. They cannot be changed later. + + :param create_instance_request: (required) + :type create_instance_request: CreateInstanceRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._create_instance_serialize( + create_instance_request=create_instance_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "CreateInstance200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def create_instance_with_http_info( + self, + create_instance_request: CreateInstanceRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[CreateInstance200Response]: + """Create an instance + + Creates a new instance of the specified Unikraft Cloud image. You can describe the properties of the new instance such as its startup arguments and amount of memory. Note that the instance properties can only be defined during creation. They cannot be changed later. + + :param create_instance_request: (required) + :type create_instance_request: CreateInstanceRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._create_instance_serialize( + create_instance_request=create_instance_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "CreateInstance200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def create_instance_without_preload_content( + self, + create_instance_request: CreateInstanceRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Create an instance + + Creates a new instance of the specified Unikraft Cloud image. You can describe the properties of the new instance such as its startup arguments and amount of memory. Note that the instance properties can only be defined during creation. They cannot be changed later. + + :param create_instance_request: (required) + :type create_instance_request: CreateInstanceRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._create_instance_serialize( + create_instance_request=create_instance_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "CreateInstance200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _create_instance_serialize( + self, + create_instance_request, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if create_instance_request is not None: + _body_params = create_instance_request + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params["Content-Type"] = _content_type + else: + _default_content_type = self.api_client.select_header_content_type(["application/json"]) + if _default_content_type is not None: + _header_params["Content-Type"] = _default_content_type + + # authentication setting + _auth_settings: List[str] = ["bearerAuth"] + + return self.api_client.param_serialize( + method="POST", + resource_path="/instances", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) + + @validate_call + def delete_instance_by_uuid( + self, + uuid: Annotated[ + UUID, + Field( + description="The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. " + ), + ], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> DeleteInstances200Response: + """Delete a single instance given its UUID + + Deletes the specified instance. After this call the IDs associated with the instance are no longer valid. A running instance is force stopped. If the instance is an [autoscale master](https://unikraft.cloud/docs/api/v1/autoscale#basics), deleting the instance resets autoscale for the service and deletes all instances created by autoscale. + + :param uuid: The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. (required) + :type uuid: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._delete_instance_by_uuid_serialize( + uuid=uuid, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "DeleteInstances200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def delete_instance_by_uuid_with_http_info( + self, + uuid: Annotated[ + UUID, + Field( + description="The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. " + ), + ], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[DeleteInstances200Response]: + """Delete a single instance given its UUID + + Deletes the specified instance. After this call the IDs associated with the instance are no longer valid. A running instance is force stopped. If the instance is an [autoscale master](https://unikraft.cloud/docs/api/v1/autoscale#basics), deleting the instance resets autoscale for the service and deletes all instances created by autoscale. + + :param uuid: The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. (required) + :type uuid: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._delete_instance_by_uuid_serialize( + uuid=uuid, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "DeleteInstances200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def delete_instance_by_uuid_without_preload_content( + self, + uuid: Annotated[ + UUID, + Field( + description="The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. " + ), + ], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Delete a single instance given its UUID + + Deletes the specified instance. After this call the IDs associated with the instance are no longer valid. A running instance is force stopped. If the instance is an [autoscale master](https://unikraft.cloud/docs/api/v1/autoscale#basics), deleting the instance resets autoscale for the service and deletes all instances created by autoscale. + + :param uuid: The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. (required) + :type uuid: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._delete_instance_by_uuid_serialize( + uuid=uuid, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "DeleteInstances200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _delete_instance_by_uuid_serialize( + self, + uuid, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if uuid is not None: + _path_params["uuid"] = uuid + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # authentication setting + _auth_settings: List[str] = ["bearerAuth"] + + return self.api_client.param_serialize( + method="DELETE", + resource_path="/instances/{uuid}", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) + + @validate_call + def delete_instances( + self, + delete_instances_request_inner: Optional[List[DeleteInstancesRequestInner]] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> DeleteInstances200Response: + """Delete one or more instances + + Deletes the specified instance(s). After this call the IDs associated with the instance are no longer valid. A running instance is force stopped. If the instance is an [autoscale master](https://unikraft.cloud/docs/api/v1/autoscale#basics), deleting the instance resets autoscale for the service and deletes all instances created by autoscale. + + :param delete_instances_request_inner: + :type delete_instances_request_inner: List[DeleteInstancesRequestInner] + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._delete_instances_serialize( + delete_instances_request_inner=delete_instances_request_inner, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "DeleteInstances200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def delete_instances_with_http_info( + self, + delete_instances_request_inner: Optional[List[DeleteInstancesRequestInner]] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[DeleteInstances200Response]: + """Delete one or more instances + + Deletes the specified instance(s). After this call the IDs associated with the instance are no longer valid. A running instance is force stopped. If the instance is an [autoscale master](https://unikraft.cloud/docs/api/v1/autoscale#basics), deleting the instance resets autoscale for the service and deletes all instances created by autoscale. + + :param delete_instances_request_inner: + :type delete_instances_request_inner: List[DeleteInstancesRequestInner] + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._delete_instances_serialize( + delete_instances_request_inner=delete_instances_request_inner, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "DeleteInstances200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def delete_instances_without_preload_content( + self, + delete_instances_request_inner: Optional[List[DeleteInstancesRequestInner]] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Delete one or more instances + + Deletes the specified instance(s). After this call the IDs associated with the instance are no longer valid. A running instance is force stopped. If the instance is an [autoscale master](https://unikraft.cloud/docs/api/v1/autoscale#basics), deleting the instance resets autoscale for the service and deletes all instances created by autoscale. + + :param delete_instances_request_inner: + :type delete_instances_request_inner: List[DeleteInstancesRequestInner] + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._delete_instances_serialize( + delete_instances_request_inner=delete_instances_request_inner, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "DeleteInstances200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _delete_instances_serialize( + self, + delete_instances_request_inner, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + _host = None + + _collection_formats: Dict[str, str] = { + "DeleteInstancesRequestInner": "", + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if delete_instances_request_inner is not None: + _body_params = delete_instances_request_inner + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params["Content-Type"] = _content_type + else: + _default_content_type = self.api_client.select_header_content_type(["application/json"]) + if _default_content_type is not None: + _header_params["Content-Type"] = _default_content_type + + # authentication setting + _auth_settings: List[str] = ["bearerAuth"] + + return self.api_client.param_serialize( + method="DELETE", + resource_path="/instances", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) + + @validate_call + def get_instance_by_uuid( + self, + uuid: Annotated[ + UUID, + Field( + description="The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. " + ), + ], + details: Annotated[ + Optional[StrictBool], + Field(description="Whether to provide detailed status and configuration information. "), + ] = None, + metrics: Annotated[ + Optional[StrictBool], Field(description="Whether to include metrics in the detailed status. ") + ] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> GetInstanceByUuid200Response: + """Get the status of a single instance + + Returns the current status and the configuration of a particular instance if a UUID or name is specified. Otherwise, returns the current status and configuration of all instances. + + :param uuid: The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. (required) + :type uuid: str + :param details: Whether to provide detailed status and configuration information. + :type details: bool + :param metrics: Whether to include metrics in the detailed status. + :type metrics: bool + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_instance_by_uuid_serialize( + uuid=uuid, + details=details, + metrics=metrics, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "GetInstanceByUuid200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def get_instance_by_uuid_with_http_info( + self, + uuid: Annotated[ + UUID, + Field( + description="The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. " + ), + ], + details: Annotated[ + Optional[StrictBool], + Field(description="Whether to provide detailed status and configuration information. "), + ] = None, + metrics: Annotated[ + Optional[StrictBool], Field(description="Whether to include metrics in the detailed status. ") + ] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[GetInstanceByUuid200Response]: + """Get the status of a single instance + + Returns the current status and the configuration of a particular instance if a UUID or name is specified. Otherwise, returns the current status and configuration of all instances. + + :param uuid: The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. (required) + :type uuid: str + :param details: Whether to provide detailed status and configuration information. + :type details: bool + :param metrics: Whether to include metrics in the detailed status. + :type metrics: bool + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_instance_by_uuid_serialize( + uuid=uuid, + details=details, + metrics=metrics, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "GetInstanceByUuid200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def get_instance_by_uuid_without_preload_content( + self, + uuid: Annotated[ + UUID, + Field( + description="The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. " + ), + ], + details: Annotated[ + Optional[StrictBool], + Field(description="Whether to provide detailed status and configuration information. "), + ] = None, + metrics: Annotated[ + Optional[StrictBool], Field(description="Whether to include metrics in the detailed status. ") + ] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Get the status of a single instance + + Returns the current status and the configuration of a particular instance if a UUID or name is specified. Otherwise, returns the current status and configuration of all instances. + + :param uuid: The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. (required) + :type uuid: str + :param details: Whether to provide detailed status and configuration information. + :type details: bool + :param metrics: Whether to include metrics in the detailed status. + :type metrics: bool + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_instance_by_uuid_serialize( + uuid=uuid, + details=details, + metrics=metrics, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "GetInstanceByUuid200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _get_instance_by_uuid_serialize( + self, + uuid, + details, + metrics, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if uuid is not None: + _path_params["uuid"] = uuid + # process the query parameters + if details is not None: + _query_params.append(("details", details)) + + if metrics is not None: + _query_params.append(("metrics", metrics)) + + # process the header parameters + # process the form parameters + # process the body parameter + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # authentication setting + _auth_settings: List[str] = ["bearerAuth"] + + return self.api_client.param_serialize( + method="GET", + resource_path="/instances/{uuid}", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) + + @validate_call + def get_instance_logs( + self, + get_instance_logs_request_inner: Optional[List[GetInstanceLogsRequestInner]] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> GetInstanceLogs200Response: + """Retrieve logs for one or more instances + + Returns the log output of the specified instance(s) in base64 encoding. Note that the maximum response size is capped. The log output might thus be cut off and require multiple requests to fetch further output. + + :param get_instance_logs_request_inner: + :type get_instance_logs_request_inner: List[GetInstanceLogsRequestInner] + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_instance_logs_serialize( + get_instance_logs_request_inner=get_instance_logs_request_inner, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "GetInstanceLogs200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def get_instance_logs_with_http_info( + self, + get_instance_logs_request_inner: Optional[List[GetInstanceLogsRequestInner]] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[GetInstanceLogs200Response]: + """Retrieve logs for one or more instances + + Returns the log output of the specified instance(s) in base64 encoding. Note that the maximum response size is capped. The log output might thus be cut off and require multiple requests to fetch further output. + + :param get_instance_logs_request_inner: + :type get_instance_logs_request_inner: List[GetInstanceLogsRequestInner] + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_instance_logs_serialize( + get_instance_logs_request_inner=get_instance_logs_request_inner, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "GetInstanceLogs200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def get_instance_logs_without_preload_content( + self, + get_instance_logs_request_inner: Optional[List[GetInstanceLogsRequestInner]] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Retrieve logs for one or more instances + + Returns the log output of the specified instance(s) in base64 encoding. Note that the maximum response size is capped. The log output might thus be cut off and require multiple requests to fetch further output. + + :param get_instance_logs_request_inner: + :type get_instance_logs_request_inner: List[GetInstanceLogsRequestInner] + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_instance_logs_serialize( + get_instance_logs_request_inner=get_instance_logs_request_inner, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "GetInstanceLogs200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _get_instance_logs_serialize( + self, + get_instance_logs_request_inner, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + _host = None + + _collection_formats: Dict[str, str] = { + "GetInstanceLogsRequestInner": "", + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if get_instance_logs_request_inner is not None: + _body_params = get_instance_logs_request_inner + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params["Content-Type"] = _content_type + else: + _default_content_type = self.api_client.select_header_content_type(["application/json"]) + if _default_content_type is not None: + _header_params["Content-Type"] = _default_content_type + + # authentication setting + _auth_settings: List[str] = ["bearerAuth"] + + return self.api_client.param_serialize( + method="GET", + resource_path="/instances/log", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) + + @validate_call + def get_instance_logs_by_uuid( + self, + uuid: Annotated[ + UUID, + Field( + description="The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. " + ), + ], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> GetInstanceLogs200Response: + """Retrieve logs for an instance given its UUID + + Returns the log output of the specified instance in base64 encoding. Note that the maximum response size is capped. The log output might thus be cut off and require multiple requests to fetch further output. + + :param uuid: The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. (required) + :type uuid: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_instance_logs_by_uuid_serialize( + uuid=uuid, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "GetInstanceLogs200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def get_instance_logs_by_uuid_with_http_info( + self, + uuid: Annotated[ + UUID, + Field( + description="The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. " + ), + ], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[GetInstanceLogs200Response]: + """Retrieve logs for an instance given its UUID + + Returns the log output of the specified instance in base64 encoding. Note that the maximum response size is capped. The log output might thus be cut off and require multiple requests to fetch further output. + + :param uuid: The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. (required) + :type uuid: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_instance_logs_by_uuid_serialize( + uuid=uuid, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "GetInstanceLogs200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def get_instance_logs_by_uuid_without_preload_content( + self, + uuid: Annotated[ + UUID, + Field( + description="The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. " + ), + ], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Retrieve logs for an instance given its UUID + + Returns the log output of the specified instance in base64 encoding. Note that the maximum response size is capped. The log output might thus be cut off and require multiple requests to fetch further output. + + :param uuid: The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. (required) + :type uuid: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_instance_logs_by_uuid_serialize( + uuid=uuid, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "GetInstanceLogs200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _get_instance_logs_by_uuid_serialize( + self, + uuid, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if uuid is not None: + _path_params["uuid"] = uuid + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # authentication setting + _auth_settings: List[str] = ["bearerAuth"] + + return self.api_client.param_serialize( + method="GET", + resource_path="/instances/{uuid}/log", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) + + @validate_call + def get_instance_metrics( + self, + get_instance_metrics_request_inner: Optional[List[GetInstanceMetricsRequestInner]] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> GetInstanceMetrics200Response: + """Get metrics for one or more instances + + Returns the various instance(s) metrics like CPU time and network traffic statistics. Cumulative metrics (e.g., used CPU time) are accumulated over instance starts. This endpoint can return either a JSON-encoded response or a response in the Prometheus format. + + :param get_instance_metrics_request_inner: + :type get_instance_metrics_request_inner: List[GetInstanceMetricsRequestInner] + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_instance_metrics_serialize( + get_instance_metrics_request_inner=get_instance_metrics_request_inner, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "GetInstanceMetrics200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def get_instance_metrics_with_http_info( + self, + get_instance_metrics_request_inner: Optional[List[GetInstanceMetricsRequestInner]] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[GetInstanceMetrics200Response]: + """Get metrics for one or more instances + + Returns the various instance(s) metrics like CPU time and network traffic statistics. Cumulative metrics (e.g., used CPU time) are accumulated over instance starts. This endpoint can return either a JSON-encoded response or a response in the Prometheus format. + + :param get_instance_metrics_request_inner: + :type get_instance_metrics_request_inner: List[GetInstanceMetricsRequestInner] + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_instance_metrics_serialize( + get_instance_metrics_request_inner=get_instance_metrics_request_inner, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "GetInstanceMetrics200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def get_instance_metrics_without_preload_content( + self, + get_instance_metrics_request_inner: Optional[List[GetInstanceMetricsRequestInner]] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Get metrics for one or more instances + + Returns the various instance(s) metrics like CPU time and network traffic statistics. Cumulative metrics (e.g., used CPU time) are accumulated over instance starts. This endpoint can return either a JSON-encoded response or a response in the Prometheus format. + + :param get_instance_metrics_request_inner: + :type get_instance_metrics_request_inner: List[GetInstanceMetricsRequestInner] + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_instance_metrics_serialize( + get_instance_metrics_request_inner=get_instance_metrics_request_inner, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "GetInstanceMetrics200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _get_instance_metrics_serialize( + self, + get_instance_metrics_request_inner, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + _host = None + + _collection_formats: Dict[str, str] = { + "GetInstanceMetricsRequestInner": "", + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if get_instance_metrics_request_inner is not None: + _body_params = get_instance_metrics_request_inner + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params["Content-Type"] = _content_type + else: + _default_content_type = self.api_client.select_header_content_type(["application/json"]) + if _default_content_type is not None: + _header_params["Content-Type"] = _default_content_type + + # authentication setting + _auth_settings: List[str] = ["bearerAuth"] + + return self.api_client.param_serialize( + method="GET", + resource_path="/instances/metrics", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) + + @validate_call + def get_instance_metrics_by_uuid( + self, + uuid: Annotated[ + UUID, + Field( + description="The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. " + ), + ], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> GetInstanceMetrics200Response: + """Get metrics for an instance given its UUID + + Returns the various instances metrics like CPU time and network traffic statistics. Cumulative metrics (e.g., used CPU time) are accumulated over instance starts. This endpoint can return either a JSON-encoded response or a response in the Prometheus format. + + :param uuid: The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. (required) + :type uuid: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_instance_metrics_by_uuid_serialize( + uuid=uuid, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "GetInstanceMetrics200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def get_instance_metrics_by_uuid_with_http_info( + self, + uuid: Annotated[ + UUID, + Field( + description="The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. " + ), + ], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[GetInstanceMetrics200Response]: + """Get metrics for an instance given its UUID + + Returns the various instances metrics like CPU time and network traffic statistics. Cumulative metrics (e.g., used CPU time) are accumulated over instance starts. This endpoint can return either a JSON-encoded response or a response in the Prometheus format. + + :param uuid: The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. (required) + :type uuid: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_instance_metrics_by_uuid_serialize( + uuid=uuid, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "GetInstanceMetrics200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def get_instance_metrics_by_uuid_without_preload_content( + self, + uuid: Annotated[ + UUID, + Field( + description="The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. " + ), + ], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Get metrics for an instance given its UUID + + Returns the various instances metrics like CPU time and network traffic statistics. Cumulative metrics (e.g., used CPU time) are accumulated over instance starts. This endpoint can return either a JSON-encoded response or a response in the Prometheus format. + + :param uuid: The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. (required) + :type uuid: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_instance_metrics_by_uuid_serialize( + uuid=uuid, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "GetInstanceMetrics200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _get_instance_metrics_by_uuid_serialize( + self, + uuid, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if uuid is not None: + _path_params["uuid"] = uuid + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # authentication setting + _auth_settings: List[str] = ["bearerAuth"] + + return self.api_client.param_serialize( + method="GET", + resource_path="/instances/{uuid}/metrics", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) + + @validate_call + def get_instances( + self, + details: Annotated[ + Optional[StrictBool], + Field(description="Whether to provide detailed status and configuration information. "), + ] = None, + metrics: Annotated[ + Optional[StrictBool], Field(description="Whether to include metrics in the detailed status. ") + ] = None, + get_instances_request_inner: Optional[List[GetInstancesRequestInner]] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> GetInstances200Response: + """Get the status of one or more instances + + Returns the current status and the configuration of a particular instance(s) if a UUID or name is specified. Otherwise, returns the current status and configuration of all instances. + + :param details: Whether to provide detailed status and configuration information. + :type details: bool + :param metrics: Whether to include metrics in the detailed status. + :type metrics: bool + :param get_instances_request_inner: + :type get_instances_request_inner: List[GetInstancesRequestInner] + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_instances_serialize( + details=details, + metrics=metrics, + get_instances_request_inner=get_instances_request_inner, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "GetInstances200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def get_instances_with_http_info( + self, + details: Annotated[ + Optional[StrictBool], + Field(description="Whether to provide detailed status and configuration information. "), + ] = None, + metrics: Annotated[ + Optional[StrictBool], Field(description="Whether to include metrics in the detailed status. ") + ] = None, + get_instances_request_inner: Optional[List[GetInstancesRequestInner]] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[GetInstances200Response]: + """Get the status of one or more instances + + Returns the current status and the configuration of a particular instance(s) if a UUID or name is specified. Otherwise, returns the current status and configuration of all instances. + + :param details: Whether to provide detailed status and configuration information. + :type details: bool + :param metrics: Whether to include metrics in the detailed status. + :type metrics: bool + :param get_instances_request_inner: + :type get_instances_request_inner: List[GetInstancesRequestInner] + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_instances_serialize( + details=details, + metrics=metrics, + get_instances_request_inner=get_instances_request_inner, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "GetInstances200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def get_instances_without_preload_content( + self, + details: Annotated[ + Optional[StrictBool], + Field(description="Whether to provide detailed status and configuration information. "), + ] = None, + metrics: Annotated[ + Optional[StrictBool], Field(description="Whether to include metrics in the detailed status. ") + ] = None, + get_instances_request_inner: Optional[List[GetInstancesRequestInner]] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Get the status of one or more instances + + Returns the current status and the configuration of a particular instance(s) if a UUID or name is specified. Otherwise, returns the current status and configuration of all instances. + + :param details: Whether to provide detailed status and configuration information. + :type details: bool + :param metrics: Whether to include metrics in the detailed status. + :type metrics: bool + :param get_instances_request_inner: + :type get_instances_request_inner: List[GetInstancesRequestInner] + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_instances_serialize( + details=details, + metrics=metrics, + get_instances_request_inner=get_instances_request_inner, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "GetInstances200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _get_instances_serialize( + self, + details, + metrics, + get_instances_request_inner, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + _host = None + + _collection_formats: Dict[str, str] = { + "GetInstancesRequestInner": "", + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + if details is not None: + _query_params.append(("details", details)) + + if metrics is not None: + _query_params.append(("metrics", metrics)) + + # process the header parameters + # process the form parameters + # process the body parameter + if get_instances_request_inner is not None: + _body_params = get_instances_request_inner + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params["Content-Type"] = _content_type + else: + _default_content_type = self.api_client.select_header_content_type(["application/json"]) + if _default_content_type is not None: + _header_params["Content-Type"] = _default_content_type + + # authentication setting + _auth_settings: List[str] = ["bearerAuth"] + + return self.api_client.param_serialize( + method="GET", + resource_path="/instances", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) + + @validate_call + def start_instance_by_uuid( + self, + uuid: Annotated[ + UUID, + Field( + description="The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. " + ), + ], + wait_timeout_ms: Annotated[ + Optional[StrictInt], + Field( + description="Timeout to wait for all specified instances to reach running state in milliseconds. No wait performed for `0`. " + ), + ] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> StartInstances200Response: + """Start an instance given its UUID + + Starts a stopped instance. Does nothing for an instance that is already running. + + :param uuid: The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. (required) + :type uuid: str + :param wait_timeout_ms: Timeout to wait for all specified instances to reach running state in milliseconds. No wait performed for `0`. + :type wait_timeout_ms: int + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._start_instance_by_uuid_serialize( + uuid=uuid, + wait_timeout_ms=wait_timeout_ms, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "StartInstances200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def start_instance_by_uuid_with_http_info( + self, + uuid: Annotated[ + UUID, + Field( + description="The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. " + ), + ], + wait_timeout_ms: Annotated[ + Optional[StrictInt], + Field( + description="Timeout to wait for all specified instances to reach running state in milliseconds. No wait performed for `0`. " + ), + ] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[StartInstances200Response]: + """Start an instance given its UUID + + Starts a stopped instance. Does nothing for an instance that is already running. + + :param uuid: The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. (required) + :type uuid: str + :param wait_timeout_ms: Timeout to wait for all specified instances to reach running state in milliseconds. No wait performed for `0`. + :type wait_timeout_ms: int + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._start_instance_by_uuid_serialize( + uuid=uuid, + wait_timeout_ms=wait_timeout_ms, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "StartInstances200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def start_instance_by_uuid_without_preload_content( + self, + uuid: Annotated[ + UUID, + Field( + description="The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. " + ), + ], + wait_timeout_ms: Annotated[ + Optional[StrictInt], + Field( + description="Timeout to wait for all specified instances to reach running state in milliseconds. No wait performed for `0`. " + ), + ] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Start an instance given its UUID + + Starts a stopped instance. Does nothing for an instance that is already running. + + :param uuid: The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. (required) + :type uuid: str + :param wait_timeout_ms: Timeout to wait for all specified instances to reach running state in milliseconds. No wait performed for `0`. + :type wait_timeout_ms: int + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._start_instance_by_uuid_serialize( + uuid=uuid, + wait_timeout_ms=wait_timeout_ms, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "StartInstances200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _start_instance_by_uuid_serialize( + self, + uuid, + wait_timeout_ms, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if uuid is not None: + _path_params["uuid"] = uuid + # process the query parameters + if wait_timeout_ms is not None: + _query_params.append(("wait_timeout_ms", wait_timeout_ms)) + + # process the header parameters + # process the form parameters + # process the body parameter + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # authentication setting + _auth_settings: List[str] = ["bearerAuth"] + + return self.api_client.param_serialize( + method="PUT", + resource_path="/instances/{uuid}/start", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) + + @validate_call + def start_instances( + self, + start_instances_request_inner: Optional[List[StartInstancesRequestInner]] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> StartInstances200Response: + """Start one or more instances + + Starts one or more stopped instance(s). Does nothing for an instance which is already running. + + :param start_instances_request_inner: + :type start_instances_request_inner: List[StartInstancesRequestInner] + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._start_instances_serialize( + start_instances_request_inner=start_instances_request_inner, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "StartInstances200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def start_instances_with_http_info( + self, + start_instances_request_inner: Optional[List[StartInstancesRequestInner]] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[StartInstances200Response]: + """Start one or more instances + + Starts one or more stopped instance(s). Does nothing for an instance which is already running. + + :param start_instances_request_inner: + :type start_instances_request_inner: List[StartInstancesRequestInner] + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._start_instances_serialize( + start_instances_request_inner=start_instances_request_inner, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "StartInstances200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def start_instances_without_preload_content( + self, + start_instances_request_inner: Optional[List[StartInstancesRequestInner]] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Start one or more instances + + Starts one or more stopped instance(s). Does nothing for an instance which is already running. + + :param start_instances_request_inner: + :type start_instances_request_inner: List[StartInstancesRequestInner] + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._start_instances_serialize( + start_instances_request_inner=start_instances_request_inner, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "StartInstances200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _start_instances_serialize( + self, + start_instances_request_inner, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + _host = None + + _collection_formats: Dict[str, str] = { + "StartInstancesRequestInner": "", + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if start_instances_request_inner is not None: + _body_params = start_instances_request_inner + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params["Content-Type"] = _content_type + else: + _default_content_type = self.api_client.select_header_content_type(["application/json"]) + if _default_content_type is not None: + _header_params["Content-Type"] = _default_content_type + + # authentication setting + _auth_settings: List[str] = ["bearerAuth"] + + return self.api_client.param_serialize( + method="PUT", + resource_path="/instances/start", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) + + @validate_call + def stop_instance_by_uuid( + self, + uuid: Annotated[ + UUID, + Field( + description="The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. " + ), + ], + force: Annotated[Optional[StrictBool], Field(description="Forces immediate shutdown. ")] = None, + drain_timeout_ms: Annotated[ + Optional[Annotated[int, Field(le=3600000, strict=True, ge=0)]], + Field( + description="Timeout for draining connections in milliseconds. The instance does not receive new connections in the draining phase. The instance is stopped when the last connection has been closed or the timeout expired. " + ), + ] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> StartInstances200Response: + """Stop a single instance given its UUID + + Stops the specified instance, but does not destroy it. All volatile state (e.g., RAM contents) is lost. Does nothing for an instance that is already stopped. The instance can be started again with the [`start`](https://unikraft.cloud/docs/api/v1/instances/#start) endpoint. + + :param uuid: The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. (required) + :type uuid: str + :param force: Forces immediate shutdown. + :type force: bool + :param drain_timeout_ms: Timeout for draining connections in milliseconds. The instance does not receive new connections in the draining phase. The instance is stopped when the last connection has been closed or the timeout expired. + :type drain_timeout_ms: int + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._stop_instance_by_uuid_serialize( + uuid=uuid, + force=force, + drain_timeout_ms=drain_timeout_ms, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "StartInstances200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def stop_instance_by_uuid_with_http_info( + self, + uuid: Annotated[ + UUID, + Field( + description="The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. " + ), + ], + force: Annotated[Optional[StrictBool], Field(description="Forces immediate shutdown. ")] = None, + drain_timeout_ms: Annotated[ + Optional[Annotated[int, Field(le=3600000, strict=True, ge=0)]], + Field( + description="Timeout for draining connections in milliseconds. The instance does not receive new connections in the draining phase. The instance is stopped when the last connection has been closed or the timeout expired. " + ), + ] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[StartInstances200Response]: + """Stop a single instance given its UUID + + Stops the specified instance, but does not destroy it. All volatile state (e.g., RAM contents) is lost. Does nothing for an instance that is already stopped. The instance can be started again with the [`start`](https://unikraft.cloud/docs/api/v1/instances/#start) endpoint. + + :param uuid: The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. (required) + :type uuid: str + :param force: Forces immediate shutdown. + :type force: bool + :param drain_timeout_ms: Timeout for draining connections in milliseconds. The instance does not receive new connections in the draining phase. The instance is stopped when the last connection has been closed or the timeout expired. + :type drain_timeout_ms: int + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._stop_instance_by_uuid_serialize( + uuid=uuid, + force=force, + drain_timeout_ms=drain_timeout_ms, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "StartInstances200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def stop_instance_by_uuid_without_preload_content( + self, + uuid: Annotated[ + UUID, + Field( + description="The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. " + ), + ], + force: Annotated[Optional[StrictBool], Field(description="Forces immediate shutdown. ")] = None, + drain_timeout_ms: Annotated[ + Optional[Annotated[int, Field(le=3600000, strict=True, ge=0)]], + Field( + description="Timeout for draining connections in milliseconds. The instance does not receive new connections in the draining phase. The instance is stopped when the last connection has been closed or the timeout expired. " + ), + ] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Stop a single instance given its UUID + + Stops the specified instance, but does not destroy it. All volatile state (e.g., RAM contents) is lost. Does nothing for an instance that is already stopped. The instance can be started again with the [`start`](https://unikraft.cloud/docs/api/v1/instances/#start) endpoint. + + :param uuid: The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. (required) + :type uuid: str + :param force: Forces immediate shutdown. + :type force: bool + :param drain_timeout_ms: Timeout for draining connections in milliseconds. The instance does not receive new connections in the draining phase. The instance is stopped when the last connection has been closed or the timeout expired. + :type drain_timeout_ms: int + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._stop_instance_by_uuid_serialize( + uuid=uuid, + force=force, + drain_timeout_ms=drain_timeout_ms, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "StartInstances200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _stop_instance_by_uuid_serialize( + self, + uuid, + force, + drain_timeout_ms, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if uuid is not None: + _path_params["uuid"] = uuid + # process the query parameters + if force is not None: + _query_params.append(("force", force)) + + if drain_timeout_ms is not None: + _query_params.append(("drain_timeout_ms", drain_timeout_ms)) + + # process the header parameters + # process the form parameters + # process the body parameter + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # authentication setting + _auth_settings: List[str] = ["bearerAuth"] + + return self.api_client.param_serialize( + method="PUT", + resource_path="/instances/{uuid}/stop", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) + + @validate_call + def stop_instances( + self, + stop_instances_request_inner: Optional[List[StopInstancesRequestInner]] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> StartInstances200Response: + """Stop one or more instances + + Stops the specified instance(s), but does not destroy it. All volatile state (e.g., RAM contents) is lost. Does nothing for an instance that is already stopped. The instance can be started again with the [`start`](https://unikraft.cloud/docs/api/v1/instances/#start) endpoint. + + :param stop_instances_request_inner: + :type stop_instances_request_inner: List[StopInstancesRequestInner] + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._stop_instances_serialize( + stop_instances_request_inner=stop_instances_request_inner, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "StartInstances200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def stop_instances_with_http_info( + self, + stop_instances_request_inner: Optional[List[StopInstancesRequestInner]] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[StartInstances200Response]: + """Stop one or more instances + + Stops the specified instance(s), but does not destroy it. All volatile state (e.g., RAM contents) is lost. Does nothing for an instance that is already stopped. The instance can be started again with the [`start`](https://unikraft.cloud/docs/api/v1/instances/#start) endpoint. + + :param stop_instances_request_inner: + :type stop_instances_request_inner: List[StopInstancesRequestInner] + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._stop_instances_serialize( + stop_instances_request_inner=stop_instances_request_inner, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "StartInstances200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def stop_instances_without_preload_content( + self, + stop_instances_request_inner: Optional[List[StopInstancesRequestInner]] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Stop one or more instances + + Stops the specified instance(s), but does not destroy it. All volatile state (e.g., RAM contents) is lost. Does nothing for an instance that is already stopped. The instance can be started again with the [`start`](https://unikraft.cloud/docs/api/v1/instances/#start) endpoint. + + :param stop_instances_request_inner: + :type stop_instances_request_inner: List[StopInstancesRequestInner] + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._stop_instances_serialize( + stop_instances_request_inner=stop_instances_request_inner, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "StartInstances200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _stop_instances_serialize( + self, + stop_instances_request_inner, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + _host = None + + _collection_formats: Dict[str, str] = { + "StopInstancesRequestInner": "", + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if stop_instances_request_inner is not None: + _body_params = stop_instances_request_inner + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params["Content-Type"] = _content_type + else: + _default_content_type = self.api_client.select_header_content_type(["application/json"]) + if _default_content_type is not None: + _header_params["Content-Type"] = _default_content_type + + # authentication setting + _auth_settings: List[str] = ["bearerAuth"] + + return self.api_client.param_serialize( + method="PUT", + resource_path="/instances/stop", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) + + @validate_call + def wait_for_instances( + self, + wait_for_instances_request_inner: Optional[List[WaitForInstancesRequestInner]] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> WaitForInstances200Response: + """Wait for one or more instances to reach a desired state + + Waits until the specified instance(s) have reached the desired state. The request blocks until all waits in the call are satisfied or the request timed out. + + :param wait_for_instances_request_inner: + :type wait_for_instances_request_inner: List[WaitForInstancesRequestInner] + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._wait_for_instances_serialize( + wait_for_instances_request_inner=wait_for_instances_request_inner, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "WaitForInstances200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def wait_for_instances_with_http_info( + self, + wait_for_instances_request_inner: Optional[List[WaitForInstancesRequestInner]] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[WaitForInstances200Response]: + """Wait for one or more instances to reach a desired state + + Waits until the specified instance(s) have reached the desired state. The request blocks until all waits in the call are satisfied or the request timed out. + + :param wait_for_instances_request_inner: + :type wait_for_instances_request_inner: List[WaitForInstancesRequestInner] + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._wait_for_instances_serialize( + wait_for_instances_request_inner=wait_for_instances_request_inner, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "WaitForInstances200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def wait_for_instances_without_preload_content( + self, + wait_for_instances_request_inner: Optional[List[WaitForInstancesRequestInner]] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Wait for one or more instances to reach a desired state + + Waits until the specified instance(s) have reached the desired state. The request blocks until all waits in the call are satisfied or the request timed out. + + :param wait_for_instances_request_inner: + :type wait_for_instances_request_inner: List[WaitForInstancesRequestInner] + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._wait_for_instances_serialize( + wait_for_instances_request_inner=wait_for_instances_request_inner, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "WaitForInstances200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _wait_for_instances_serialize( + self, + wait_for_instances_request_inner, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + _host = None + + _collection_formats: Dict[str, str] = { + "WaitForInstancesRequestInner": "", + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if wait_for_instances_request_inner is not None: + _body_params = wait_for_instances_request_inner + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params["Content-Type"] = _content_type + else: + _default_content_type = self.api_client.select_header_content_type(["application/json"]) + if _default_content_type is not None: + _header_params["Content-Type"] = _default_content_type + + # authentication setting + _auth_settings: List[str] = ["bearerAuth"] + + return self.api_client.param_serialize( + method="PUT", + resource_path="/instances/wait", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) diff --git a/unikraft_cloud_platform/api/service_groups/__init__.py b/unikraft_cloud_platform/api/service_groups/__init__.py deleted file mode 100644 index 2d7c0b2..0000000 --- a/unikraft_cloud_platform/api/service_groups/__init__.py +++ /dev/null @@ -1 +0,0 @@ -"""Contains endpoint functions for accessing the API""" diff --git a/unikraft_cloud_platform/api/service_groups/create_service_group.py b/unikraft_cloud_platform/api/service_groups/create_service_group.py deleted file mode 100644 index 9bea32e..0000000 --- a/unikraft_cloud_platform/api/service_groups/create_service_group.py +++ /dev/null @@ -1,181 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx - -from ...client import AuthenticatedClient, Client -from ...models.create_service_group_request import CreateServiceGroupRequest -from ...models.create_service_group_response import CreateServiceGroupResponse -from ...types import Response - - -def _get_kwargs( - *, - body: CreateServiceGroupRequest, -) -> dict[str, Any]: - headers: dict[str, Any] = {} - - _kwargs: dict[str, Any] = { - "method": "post", - "url": "/v1/services", - } - - _kwargs["json"] = body.to_dict() - - headers["Content-Type"] = "application/json" - - _kwargs["headers"] = headers - return _kwargs - - -def _parse_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> CreateServiceGroupResponse: - response_default = CreateServiceGroupResponse.from_dict(response.json()) - - return response_default - - -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[CreateServiceGroupResponse]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - *, - client: Union[AuthenticatedClient, Client], - body: CreateServiceGroupRequest, -) -> Response[CreateServiceGroupResponse]: - """Create Service Group - - Create a new service with the given configuration. - - Note that the service properties like published ports can only be defined - during creation. They cannot be changed later. Each port in a service can - specify a list of handlers that determine how traffic arriving at the port - is handled. See Connection Handlers for a complete overview. - - Args: - body (CreateServiceGroupRequest): The request message for creating a new service group. - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[CreateServiceGroupResponse] - """ - - kwargs = _get_kwargs( - body=body, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - *, - client: Union[AuthenticatedClient, Client], - body: CreateServiceGroupRequest, -) -> Optional[CreateServiceGroupResponse]: - """Create Service Group - - Create a new service with the given configuration. - - Note that the service properties like published ports can only be defined - during creation. They cannot be changed later. Each port in a service can - specify a list of handlers that determine how traffic arriving at the port - is handled. See Connection Handlers for a complete overview. - - Args: - body (CreateServiceGroupRequest): The request message for creating a new service group. - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - CreateServiceGroupResponse - """ - - return sync_detailed( - client=client, - body=body, - ).parsed - - -async def asyncio_detailed( - *, - client: Union[AuthenticatedClient, Client], - body: CreateServiceGroupRequest, -) -> Response[CreateServiceGroupResponse]: - """Create Service Group - - Create a new service with the given configuration. - - Note that the service properties like published ports can only be defined - during creation. They cannot be changed later. Each port in a service can - specify a list of handlers that determine how traffic arriving at the port - is handled. See Connection Handlers for a complete overview. - - Args: - body (CreateServiceGroupRequest): The request message for creating a new service group. - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[CreateServiceGroupResponse] - """ - - kwargs = _get_kwargs( - body=body, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - *, - client: Union[AuthenticatedClient, Client], - body: CreateServiceGroupRequest, -) -> Optional[CreateServiceGroupResponse]: - """Create Service Group - - Create a new service with the given configuration. - - Note that the service properties like published ports can only be defined - during creation. They cannot be changed later. Each port in a service can - specify a list of handlers that determine how traffic arriving at the port - is handled. See Connection Handlers for a complete overview. - - Args: - body (CreateServiceGroupRequest): The request message for creating a new service group. - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - CreateServiceGroupResponse - """ - - return ( - await asyncio_detailed( - client=client, - body=body, - ) - ).parsed diff --git a/unikraft_cloud_platform/api/service_groups/delete_service_group_by_uuid.py b/unikraft_cloud_platform/api/service_groups/delete_service_group_by_uuid.py deleted file mode 100644 index 70f428b..0000000 --- a/unikraft_cloud_platform/api/service_groups/delete_service_group_by_uuid.py +++ /dev/null @@ -1,157 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union -from uuid import UUID - -import httpx - -from ...client import AuthenticatedClient, Client -from ...models.delete_service_groups_response import DeleteServiceGroupsResponse -from ...types import Response - - -def _get_kwargs( - uuid: UUID, -) -> dict[str, Any]: - _kwargs: dict[str, Any] = { - "method": "delete", - "url": f"/v1/services/{uuid}", - } - - return _kwargs - - -def _parse_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> DeleteServiceGroupsResponse: - response_default = DeleteServiceGroupsResponse.from_dict(response.json()) - - return response_default - - -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[DeleteServiceGroupsResponse]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], -) -> Response[DeleteServiceGroupsResponse]: - """Delete Service Group by UUID - - Delete a specified service group by its UUID. After this call the UUID of - the service group is no longer valid. - - Args: - uuid (UUID): Example: 12345678-90ab-cdef-1234-567890abcdef. - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[DeleteServiceGroupsResponse] - """ - - kwargs = _get_kwargs( - uuid=uuid, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], -) -> Optional[DeleteServiceGroupsResponse]: - """Delete Service Group by UUID - - Delete a specified service group by its UUID. After this call the UUID of - the service group is no longer valid. - - Args: - uuid (UUID): Example: 12345678-90ab-cdef-1234-567890abcdef. - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - DeleteServiceGroupsResponse - """ - - return sync_detailed( - uuid=uuid, - client=client, - ).parsed - - -async def asyncio_detailed( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], -) -> Response[DeleteServiceGroupsResponse]: - """Delete Service Group by UUID - - Delete a specified service group by its UUID. After this call the UUID of - the service group is no longer valid. - - Args: - uuid (UUID): Example: 12345678-90ab-cdef-1234-567890abcdef. - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[DeleteServiceGroupsResponse] - """ - - kwargs = _get_kwargs( - uuid=uuid, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], -) -> Optional[DeleteServiceGroupsResponse]: - """Delete Service Group by UUID - - Delete a specified service group by its UUID. After this call the UUID of - the service group is no longer valid. - - Args: - uuid (UUID): Example: 12345678-90ab-cdef-1234-567890abcdef. - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - DeleteServiceGroupsResponse - """ - - return ( - await asyncio_detailed( - uuid=uuid, - client=client, - ) - ).parsed diff --git a/unikraft_cloud_platform/api/service_groups/delete_service_groups.py b/unikraft_cloud_platform/api/service_groups/delete_service_groups.py deleted file mode 100644 index a945722..0000000 --- a/unikraft_cloud_platform/api/service_groups/delete_service_groups.py +++ /dev/null @@ -1,168 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx - -from ...client import AuthenticatedClient, Client -from ...models.delete_service_groups_response import DeleteServiceGroupsResponse -from ...models.name_or_uuid import NameOrUUID -from ...types import Response - - -def _get_kwargs( - *, - body: list["NameOrUUID"], -) -> dict[str, Any]: - headers: dict[str, Any] = {} - - _kwargs: dict[str, Any] = { - "method": "delete", - "url": "/v1/services", - } - - _kwargs["json"] = [] - for body_item_data in body: - body_item = body_item_data.to_dict() - _kwargs["json"].append(body_item) - - headers["Content-Type"] = "application/json" - - _kwargs["headers"] = headers - return _kwargs - - -def _parse_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> DeleteServiceGroupsResponse: - response_default = DeleteServiceGroupsResponse.from_dict(response.json()) - - return response_default - - -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[DeleteServiceGroupsResponse]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - *, - client: Union[AuthenticatedClient, Client], - body: list["NameOrUUID"], -) -> Response[DeleteServiceGroupsResponse]: - """Delete Service Groups - - Delete the specified service group(s). After this call the name of the - service group(s) are no longer valid. - - Args: - body (list['NameOrUUID']): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[DeleteServiceGroupsResponse] - """ - - kwargs = _get_kwargs( - body=body, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - *, - client: Union[AuthenticatedClient, Client], - body: list["NameOrUUID"], -) -> Optional[DeleteServiceGroupsResponse]: - """Delete Service Groups - - Delete the specified service group(s). After this call the name of the - service group(s) are no longer valid. - - Args: - body (list['NameOrUUID']): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - DeleteServiceGroupsResponse - """ - - return sync_detailed( - client=client, - body=body, - ).parsed - - -async def asyncio_detailed( - *, - client: Union[AuthenticatedClient, Client], - body: list["NameOrUUID"], -) -> Response[DeleteServiceGroupsResponse]: - """Delete Service Groups - - Delete the specified service group(s). After this call the name of the - service group(s) are no longer valid. - - Args: - body (list['NameOrUUID']): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[DeleteServiceGroupsResponse] - """ - - kwargs = _get_kwargs( - body=body, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - *, - client: Union[AuthenticatedClient, Client], - body: list["NameOrUUID"], -) -> Optional[DeleteServiceGroupsResponse]: - """Delete Service Groups - - Delete the specified service group(s). After this call the name of the - service group(s) are no longer valid. - - Args: - body (list['NameOrUUID']): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - DeleteServiceGroupsResponse - """ - - return ( - await asyncio_detailed( - client=client, - body=body, - ) - ).parsed diff --git a/unikraft_cloud_platform/api/service_groups/get_service_group_by_uuid.py b/unikraft_cloud_platform/api/service_groups/get_service_group_by_uuid.py deleted file mode 100644 index 31ce8da..0000000 --- a/unikraft_cloud_platform/api/service_groups/get_service_group_by_uuid.py +++ /dev/null @@ -1,174 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union -from uuid import UUID - -import httpx - -from ...client import AuthenticatedClient, Client -from ...models.get_service_groups_response import GetServiceGroupsResponse -from ...types import UNSET, Response, Unset - - -def _get_kwargs( - uuid: UUID, - *, - details: Union[Unset, bool] = UNSET, -) -> dict[str, Any]: - params: dict[str, Any] = {} - - params["details"] = details - - params = {k: v for k, v in params.items() if v is not UNSET and v is not None} - - _kwargs: dict[str, Any] = { - "method": "get", - "url": f"/v1/services/{uuid}", - "params": params, - } - - return _kwargs - - -def _parse_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> GetServiceGroupsResponse: - response_default = GetServiceGroupsResponse.from_dict(response.json()) - - return response_default - - -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[GetServiceGroupsResponse]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], - details: Union[Unset, bool] = UNSET, -) -> Response[GetServiceGroupsResponse]: - """Get Service Group by UUID - - Get a specified service group by its UUID. - - Args: - uuid (UUID): Example: 12345678-90ab-cdef-1234-567890abcdef. - details (Union[Unset, bool]): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[GetServiceGroupsResponse] - """ - - kwargs = _get_kwargs( - uuid=uuid, - details=details, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], - details: Union[Unset, bool] = UNSET, -) -> Optional[GetServiceGroupsResponse]: - """Get Service Group by UUID - - Get a specified service group by its UUID. - - Args: - uuid (UUID): Example: 12345678-90ab-cdef-1234-567890abcdef. - details (Union[Unset, bool]): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - GetServiceGroupsResponse - """ - - return sync_detailed( - uuid=uuid, - client=client, - details=details, - ).parsed - - -async def asyncio_detailed( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], - details: Union[Unset, bool] = UNSET, -) -> Response[GetServiceGroupsResponse]: - """Get Service Group by UUID - - Get a specified service group by its UUID. - - Args: - uuid (UUID): Example: 12345678-90ab-cdef-1234-567890abcdef. - details (Union[Unset, bool]): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[GetServiceGroupsResponse] - """ - - kwargs = _get_kwargs( - uuid=uuid, - details=details, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], - details: Union[Unset, bool] = UNSET, -) -> Optional[GetServiceGroupsResponse]: - """Get Service Group by UUID - - Get a specified service group by its UUID. - - Args: - uuid (UUID): Example: 12345678-90ab-cdef-1234-567890abcdef. - details (Union[Unset, bool]): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - GetServiceGroupsResponse - """ - - return ( - await asyncio_detailed( - uuid=uuid, - client=client, - details=details, - ) - ).parsed diff --git a/unikraft_cloud_platform/api/service_groups/get_service_groups.py b/unikraft_cloud_platform/api/service_groups/get_service_groups.py deleted file mode 100644 index e2ebdc4..0000000 --- a/unikraft_cloud_platform/api/service_groups/get_service_groups.py +++ /dev/null @@ -1,188 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx - -from ...client import AuthenticatedClient, Client -from ...models.get_service_groups_response import GetServiceGroupsResponse -from ...models.name_or_uuid import NameOrUUID -from ...types import UNSET, Response, Unset - - -def _get_kwargs( - *, - body: list["NameOrUUID"], - details: Union[Unset, bool] = UNSET, -) -> dict[str, Any]: - headers: dict[str, Any] = {} - - params: dict[str, Any] = {} - - params["details"] = details - - params = {k: v for k, v in params.items() if v is not UNSET and v is not None} - - _kwargs: dict[str, Any] = { - "method": "get", - "url": "/v1/services", - "params": params, - } - - _kwargs["json"] = [] - for body_item_data in body: - body_item = body_item_data.to_dict() - _kwargs["json"].append(body_item) - - headers["Content-Type"] = "application/json" - - _kwargs["headers"] = headers - return _kwargs - - -def _parse_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> GetServiceGroupsResponse: - response_default = GetServiceGroupsResponse.from_dict(response.json()) - - return response_default - - -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[GetServiceGroupsResponse]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - *, - client: Union[AuthenticatedClient, Client], - body: list["NameOrUUID"], - details: Union[Unset, bool] = UNSET, -) -> Response[GetServiceGroupsResponse]: - """List Service Groups - - Get one or many service groups with their current status and configuration. - It's possible to filter this list by name or UUID. - - Args: - details (Union[Unset, bool]): - body (list['NameOrUUID']): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[GetServiceGroupsResponse] - """ - - kwargs = _get_kwargs( - body=body, - details=details, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - *, - client: Union[AuthenticatedClient, Client], - body: list["NameOrUUID"], - details: Union[Unset, bool] = UNSET, -) -> Optional[GetServiceGroupsResponse]: - """List Service Groups - - Get one or many service groups with their current status and configuration. - It's possible to filter this list by name or UUID. - - Args: - details (Union[Unset, bool]): - body (list['NameOrUUID']): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - GetServiceGroupsResponse - """ - - return sync_detailed( - client=client, - body=body, - details=details, - ).parsed - - -async def asyncio_detailed( - *, - client: Union[AuthenticatedClient, Client], - body: list["NameOrUUID"], - details: Union[Unset, bool] = UNSET, -) -> Response[GetServiceGroupsResponse]: - """List Service Groups - - Get one or many service groups with their current status and configuration. - It's possible to filter this list by name or UUID. - - Args: - details (Union[Unset, bool]): - body (list['NameOrUUID']): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[GetServiceGroupsResponse] - """ - - kwargs = _get_kwargs( - body=body, - details=details, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - *, - client: Union[AuthenticatedClient, Client], - body: list["NameOrUUID"], - details: Union[Unset, bool] = UNSET, -) -> Optional[GetServiceGroupsResponse]: - """List Service Groups - - Get one or many service groups with their current status and configuration. - It's possible to filter this list by name or UUID. - - Args: - details (Union[Unset, bool]): - body (list['NameOrUUID']): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - GetServiceGroupsResponse - """ - - return ( - await asyncio_detailed( - client=client, - body=body, - details=details, - ) - ).parsed diff --git a/unikraft_cloud_platform/api/service_groups/update_service_group_by_uuid.py b/unikraft_cloud_platform/api/service_groups/update_service_group_by_uuid.py deleted file mode 100644 index 000d869..0000000 --- a/unikraft_cloud_platform/api/service_groups/update_service_group_by_uuid.py +++ /dev/null @@ -1,175 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union -from uuid import UUID - -import httpx - -from ...client import AuthenticatedClient, Client -from ...models.update_service_group_by_uuid_request_body import UpdateServiceGroupByUUIDRequestBody -from ...models.update_service_groups_response import UpdateServiceGroupsResponse -from ...types import Response - - -def _get_kwargs( - uuid: UUID, - *, - body: UpdateServiceGroupByUUIDRequestBody, -) -> dict[str, Any]: - headers: dict[str, Any] = {} - - _kwargs: dict[str, Any] = { - "method": "patch", - "url": f"/v1/services/{uuid}", - } - - _kwargs["json"] = body.to_dict() - - headers["Content-Type"] = "application/json" - - _kwargs["headers"] = headers - return _kwargs - - -def _parse_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> UpdateServiceGroupsResponse: - response_default = UpdateServiceGroupsResponse.from_dict(response.json()) - - return response_default - - -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[UpdateServiceGroupsResponse]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], - body: UpdateServiceGroupByUUIDRequestBody, -) -> Response[UpdateServiceGroupsResponse]: - """Update Service Group by UUID - - Update a service group by its UUID. - - Args: - uuid (UUID): Example: 123e4567-e89b-12d3-a456-426614174000. - body (UpdateServiceGroupByUUIDRequestBody): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[UpdateServiceGroupsResponse] - """ - - kwargs = _get_kwargs( - uuid=uuid, - body=body, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], - body: UpdateServiceGroupByUUIDRequestBody, -) -> Optional[UpdateServiceGroupsResponse]: - """Update Service Group by UUID - - Update a service group by its UUID. - - Args: - uuid (UUID): Example: 123e4567-e89b-12d3-a456-426614174000. - body (UpdateServiceGroupByUUIDRequestBody): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - UpdateServiceGroupsResponse - """ - - return sync_detailed( - uuid=uuid, - client=client, - body=body, - ).parsed - - -async def asyncio_detailed( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], - body: UpdateServiceGroupByUUIDRequestBody, -) -> Response[UpdateServiceGroupsResponse]: - """Update Service Group by UUID - - Update a service group by its UUID. - - Args: - uuid (UUID): Example: 123e4567-e89b-12d3-a456-426614174000. - body (UpdateServiceGroupByUUIDRequestBody): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[UpdateServiceGroupsResponse] - """ - - kwargs = _get_kwargs( - uuid=uuid, - body=body, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], - body: UpdateServiceGroupByUUIDRequestBody, -) -> Optional[UpdateServiceGroupsResponse]: - """Update Service Group by UUID - - Update a service group by its UUID. - - Args: - uuid (UUID): Example: 123e4567-e89b-12d3-a456-426614174000. - body (UpdateServiceGroupByUUIDRequestBody): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - UpdateServiceGroupsResponse - """ - - return ( - await asyncio_detailed( - uuid=uuid, - client=client, - body=body, - ) - ).parsed diff --git a/unikraft_cloud_platform/api/service_groups/update_service_groups.py b/unikraft_cloud_platform/api/service_groups/update_service_groups.py deleted file mode 100644 index 7d65aa2..0000000 --- a/unikraft_cloud_platform/api/service_groups/update_service_groups.py +++ /dev/null @@ -1,164 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx - -from ...client import AuthenticatedClient, Client -from ...models.update_service_groups_request_item import UpdateServiceGroupsRequestItem -from ...models.update_service_groups_response import UpdateServiceGroupsResponse -from ...types import Response - - -def _get_kwargs( - *, - body: list["UpdateServiceGroupsRequestItem"], -) -> dict[str, Any]: - headers: dict[str, Any] = {} - - _kwargs: dict[str, Any] = { - "method": "patch", - "url": "/v1/services", - } - - _kwargs["json"] = [] - for body_item_data in body: - body_item = body_item_data.to_dict() - _kwargs["json"].append(body_item) - - headers["Content-Type"] = "application/json" - - _kwargs["headers"] = headers - return _kwargs - - -def _parse_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> UpdateServiceGroupsResponse: - response_default = UpdateServiceGroupsResponse.from_dict(response.json()) - - return response_default - - -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[UpdateServiceGroupsResponse]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - *, - client: Union[AuthenticatedClient, Client], - body: list["UpdateServiceGroupsRequestItem"], -) -> Response[UpdateServiceGroupsResponse]: - """Update Service Groups - - Update one or more service groups. - - Args: - body (list['UpdateServiceGroupsRequestItem']): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[UpdateServiceGroupsResponse] - """ - - kwargs = _get_kwargs( - body=body, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - *, - client: Union[AuthenticatedClient, Client], - body: list["UpdateServiceGroupsRequestItem"], -) -> Optional[UpdateServiceGroupsResponse]: - """Update Service Groups - - Update one or more service groups. - - Args: - body (list['UpdateServiceGroupsRequestItem']): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - UpdateServiceGroupsResponse - """ - - return sync_detailed( - client=client, - body=body, - ).parsed - - -async def asyncio_detailed( - *, - client: Union[AuthenticatedClient, Client], - body: list["UpdateServiceGroupsRequestItem"], -) -> Response[UpdateServiceGroupsResponse]: - """Update Service Groups - - Update one or more service groups. - - Args: - body (list['UpdateServiceGroupsRequestItem']): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[UpdateServiceGroupsResponse] - """ - - kwargs = _get_kwargs( - body=body, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - *, - client: Union[AuthenticatedClient, Client], - body: list["UpdateServiceGroupsRequestItem"], -) -> Optional[UpdateServiceGroupsResponse]: - """Update Service Groups - - Update one or more service groups. - - Args: - body (list['UpdateServiceGroupsRequestItem']): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - UpdateServiceGroupsResponse - """ - - return ( - await asyncio_detailed( - client=client, - body=body, - ) - ).parsed diff --git a/unikraft_cloud_platform/api/services_api.py b/unikraft_cloud_platform/api/services_api.py new file mode 100644 index 0000000..2cc5aaf --- /dev/null +++ b/unikraft_cloud_platform/api/services_api.py @@ -0,0 +1,1280 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +import warnings +from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt +from typing import Any, Dict, List, Optional, Tuple, Union +from typing_extensions import Annotated + +from pydantic import Field, StrictBool +from typing import List, Optional +from typing_extensions import Annotated +from uuid import UUID +from unikraft_cloud_platform.models.create_services200_response import CreateServices200Response +from unikraft_cloud_platform.models.create_services_request import CreateServicesRequest +from unikraft_cloud_platform.models.delete_services200_response import DeleteServices200Response +from unikraft_cloud_platform.models.delete_services_request_inner import DeleteServicesRequestInner +from unikraft_cloud_platform.models.get_service_by_uuid200_response import GetServiceByUuid200Response +from unikraft_cloud_platform.models.get_services200_response import GetServices200Response +from unikraft_cloud_platform.models.get_services_request_inner import GetServicesRequestInner + +from unikraft_cloud_platform.api_client import ApiClient, RequestSerialized +from unikraft_cloud_platform.api_response import ApiResponse +from unikraft_cloud_platform.rest import RESTResponseType + + +class ServicesApi: + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, api_client=None) -> None: + if api_client is None: + api_client = ApiClient.get_default() + self.api_client = api_client + + @validate_call + def create_services( + self, + create_services_request: CreateServicesRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> CreateServices200Response: + """Create a service + + Creates a new service with the given configuration. Note that the service properties like published ports can only be defined during creation. They cannot be changed later. + + :param create_services_request: (required) + :type create_services_request: CreateServicesRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._create_services_serialize( + create_services_request=create_services_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "CreateServices200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def create_services_with_http_info( + self, + create_services_request: CreateServicesRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[CreateServices200Response]: + """Create a service + + Creates a new service with the given configuration. Note that the service properties like published ports can only be defined during creation. They cannot be changed later. + + :param create_services_request: (required) + :type create_services_request: CreateServicesRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._create_services_serialize( + create_services_request=create_services_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "CreateServices200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def create_services_without_preload_content( + self, + create_services_request: CreateServicesRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Create a service + + Creates a new service with the given configuration. Note that the service properties like published ports can only be defined during creation. They cannot be changed later. + + :param create_services_request: (required) + :type create_services_request: CreateServicesRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._create_services_serialize( + create_services_request=create_services_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "CreateServices200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _create_services_serialize( + self, + create_services_request, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if create_services_request is not None: + _body_params = create_services_request + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params["Content-Type"] = _content_type + else: + _default_content_type = self.api_client.select_header_content_type(["application/json"]) + if _default_content_type is not None: + _header_params["Content-Type"] = _default_content_type + + # authentication setting + _auth_settings: List[str] = ["bearerAuth"] + + return self.api_client.param_serialize( + method="POST", + resource_path="/services", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) + + @validate_call + def delete_service_by_uuid( + self, + uuid: Annotated[ + UUID, + Field( + description="The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. " + ), + ], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> DeleteServices200Response: + """Delete a service given its UUID + + Deletes the specified service. Fails if there are still instances attached to the service. After this call the IDs associated with the service are no longer valid and the domain name is released. + + :param uuid: The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. (required) + :type uuid: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._delete_service_by_uuid_serialize( + uuid=uuid, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "DeleteServices200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def delete_service_by_uuid_with_http_info( + self, + uuid: Annotated[ + UUID, + Field( + description="The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. " + ), + ], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[DeleteServices200Response]: + """Delete a service given its UUID + + Deletes the specified service. Fails if there are still instances attached to the service. After this call the IDs associated with the service are no longer valid and the domain name is released. + + :param uuid: The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. (required) + :type uuid: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._delete_service_by_uuid_serialize( + uuid=uuid, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "DeleteServices200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def delete_service_by_uuid_without_preload_content( + self, + uuid: Annotated[ + UUID, + Field( + description="The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. " + ), + ], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Delete a service given its UUID + + Deletes the specified service. Fails if there are still instances attached to the service. After this call the IDs associated with the service are no longer valid and the domain name is released. + + :param uuid: The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. (required) + :type uuid: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._delete_service_by_uuid_serialize( + uuid=uuid, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "DeleteServices200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _delete_service_by_uuid_serialize( + self, + uuid, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if uuid is not None: + _path_params["uuid"] = uuid + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # authentication setting + _auth_settings: List[str] = ["bearerAuth"] + + return self.api_client.param_serialize( + method="DELETE", + resource_path="/services/{uuid}", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) + + @validate_call + def delete_services( + self, + delete_services_request_inner: Optional[List[DeleteServicesRequestInner]] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> DeleteServices200Response: + """Delete one or more services + + Deletes the specified service(s). Fails if there are still instances attached to the service. After this call the IDs associated with the service are no longer valid and the domain name is released. + + :param delete_services_request_inner: + :type delete_services_request_inner: List[DeleteServicesRequestInner] + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._delete_services_serialize( + delete_services_request_inner=delete_services_request_inner, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "DeleteServices200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def delete_services_with_http_info( + self, + delete_services_request_inner: Optional[List[DeleteServicesRequestInner]] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[DeleteServices200Response]: + """Delete one or more services + + Deletes the specified service(s). Fails if there are still instances attached to the service. After this call the IDs associated with the service are no longer valid and the domain name is released. + + :param delete_services_request_inner: + :type delete_services_request_inner: List[DeleteServicesRequestInner] + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._delete_services_serialize( + delete_services_request_inner=delete_services_request_inner, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "DeleteServices200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def delete_services_without_preload_content( + self, + delete_services_request_inner: Optional[List[DeleteServicesRequestInner]] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Delete one or more services + + Deletes the specified service(s). Fails if there are still instances attached to the service. After this call the IDs associated with the service are no longer valid and the domain name is released. + + :param delete_services_request_inner: + :type delete_services_request_inner: List[DeleteServicesRequestInner] + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._delete_services_serialize( + delete_services_request_inner=delete_services_request_inner, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "DeleteServices200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _delete_services_serialize( + self, + delete_services_request_inner, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + _host = None + + _collection_formats: Dict[str, str] = { + "DeleteServicesRequestInner": "", + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if delete_services_request_inner is not None: + _body_params = delete_services_request_inner + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params["Content-Type"] = _content_type + else: + _default_content_type = self.api_client.select_header_content_type(["application/json"]) + if _default_content_type is not None: + _header_params["Content-Type"] = _default_content_type + + # authentication setting + _auth_settings: List[str] = ["bearerAuth"] + + return self.api_client.param_serialize( + method="DELETE", + resource_path="/services", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) + + @validate_call + def get_service_by_uuid( + self, + uuid: Annotated[ + UUID, + Field( + description="The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. " + ), + ], + details: Annotated[ + Optional[StrictBool], + Field(description="Whether to provide detailed status and configuration information. "), + ] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> GetServiceByUuid200Response: + """Get the status of a service given its UUID + + Returns the current status and the configuration of a particular service if a UUID or name is specified. Otherwise, returns the current status and configuration of all services. + + :param uuid: The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. (required) + :type uuid: str + :param details: Whether to provide detailed status and configuration information. + :type details: bool + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_service_by_uuid_serialize( + uuid=uuid, + details=details, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "GetServiceByUuid200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def get_service_by_uuid_with_http_info( + self, + uuid: Annotated[ + UUID, + Field( + description="The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. " + ), + ], + details: Annotated[ + Optional[StrictBool], + Field(description="Whether to provide detailed status and configuration information. "), + ] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[GetServiceByUuid200Response]: + """Get the status of a service given its UUID + + Returns the current status and the configuration of a particular service if a UUID or name is specified. Otherwise, returns the current status and configuration of all services. + + :param uuid: The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. (required) + :type uuid: str + :param details: Whether to provide detailed status and configuration information. + :type details: bool + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_service_by_uuid_serialize( + uuid=uuid, + details=details, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "GetServiceByUuid200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def get_service_by_uuid_without_preload_content( + self, + uuid: Annotated[ + UUID, + Field( + description="The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. " + ), + ], + details: Annotated[ + Optional[StrictBool], + Field(description="Whether to provide detailed status and configuration information. "), + ] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Get the status of a service given its UUID + + Returns the current status and the configuration of a particular service if a UUID or name is specified. Otherwise, returns the current status and configuration of all services. + + :param uuid: The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. (required) + :type uuid: str + :param details: Whether to provide detailed status and configuration information. + :type details: bool + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_service_by_uuid_serialize( + uuid=uuid, + details=details, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "GetServiceByUuid200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _get_service_by_uuid_serialize( + self, + uuid, + details, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if uuid is not None: + _path_params["uuid"] = uuid + # process the query parameters + if details is not None: + _query_params.append(("details", details)) + + # process the header parameters + # process the form parameters + # process the body parameter + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # authentication setting + _auth_settings: List[str] = ["bearerAuth"] + + return self.api_client.param_serialize( + method="GET", + resource_path="/services/{uuid}", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) + + @validate_call + def get_services( + self, + details: Annotated[ + Optional[StrictBool], + Field(description="Whether to provide detailed status and configuration information. "), + ] = None, + get_services_request_inner: Optional[List[GetServicesRequestInner]] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> GetServices200Response: + """Get the status of one or more services + + Returns the current status and the configuration of a particular service if a UUID or name is specified. Otherwise, returns the current status and configuration of all services. + + :param details: Whether to provide detailed status and configuration information. + :type details: bool + :param get_services_request_inner: + :type get_services_request_inner: List[GetServicesRequestInner] + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_services_serialize( + details=details, + get_services_request_inner=get_services_request_inner, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "GetServices200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def get_services_with_http_info( + self, + details: Annotated[ + Optional[StrictBool], + Field(description="Whether to provide detailed status and configuration information. "), + ] = None, + get_services_request_inner: Optional[List[GetServicesRequestInner]] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[GetServices200Response]: + """Get the status of one or more services + + Returns the current status and the configuration of a particular service if a UUID or name is specified. Otherwise, returns the current status and configuration of all services. + + :param details: Whether to provide detailed status and configuration information. + :type details: bool + :param get_services_request_inner: + :type get_services_request_inner: List[GetServicesRequestInner] + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_services_serialize( + details=details, + get_services_request_inner=get_services_request_inner, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "GetServices200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def get_services_without_preload_content( + self, + details: Annotated[ + Optional[StrictBool], + Field(description="Whether to provide detailed status and configuration information. "), + ] = None, + get_services_request_inner: Optional[List[GetServicesRequestInner]] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Get the status of one or more services + + Returns the current status and the configuration of a particular service if a UUID or name is specified. Otherwise, returns the current status and configuration of all services. + + :param details: Whether to provide detailed status and configuration information. + :type details: bool + :param get_services_request_inner: + :type get_services_request_inner: List[GetServicesRequestInner] + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_services_serialize( + details=details, + get_services_request_inner=get_services_request_inner, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "GetServices200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _get_services_serialize( + self, + details, + get_services_request_inner, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + _host = None + + _collection_formats: Dict[str, str] = { + "GetServicesRequestInner": "", + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + if details is not None: + _query_params.append(("details", details)) + + # process the header parameters + # process the form parameters + # process the body parameter + if get_services_request_inner is not None: + _body_params = get_services_request_inner + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params["Content-Type"] = _content_type + else: + _default_content_type = self.api_client.select_header_content_type(["application/json"]) + if _default_content_type is not None: + _header_params["Content-Type"] = _default_content_type + + # authentication setting + _auth_settings: List[str] = ["bearerAuth"] + + return self.api_client.param_serialize( + method="GET", + resource_path="/services", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) diff --git a/unikraft_cloud_platform/api/system/__init__.py b/unikraft_cloud_platform/api/system/__init__.py deleted file mode 100644 index 2d7c0b2..0000000 --- a/unikraft_cloud_platform/api/system/__init__.py +++ /dev/null @@ -1 +0,0 @@ -"""Contains endpoint functions for accessing the API""" diff --git a/unikraft_cloud_platform/api/system/healthz.py b/unikraft_cloud_platform/api/system/healthz.py deleted file mode 100644 index 5267859..0000000 --- a/unikraft_cloud_platform/api/system/healthz.py +++ /dev/null @@ -1,126 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx - -from ...client import AuthenticatedClient, Client -from ...models.healthz_response import HealthzResponse -from ...types import Response - - -def _get_kwargs() -> dict[str, Any]: - _kwargs: dict[str, Any] = { - "method": "get", - "url": "/v1/healthz", - } - - return _kwargs - - -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> HealthzResponse: - response_default = HealthzResponse.from_dict(response.json()) - - return response_default - - -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[HealthzResponse]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - *, - client: Union[AuthenticatedClient, Client], -) -> Response[HealthzResponse]: - """Health Check - - Return the status of a full-system health check of the platform. - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[HealthzResponse] - """ - - kwargs = _get_kwargs() - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - *, - client: Union[AuthenticatedClient, Client], -) -> Optional[HealthzResponse]: - """Health Check - - Return the status of a full-system health check of the platform. - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - HealthzResponse - """ - - return sync_detailed( - client=client, - ).parsed - - -async def asyncio_detailed( - *, - client: Union[AuthenticatedClient, Client], -) -> Response[HealthzResponse]: - """Health Check - - Return the status of a full-system health check of the platform. - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[HealthzResponse] - """ - - kwargs = _get_kwargs() - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - *, - client: Union[AuthenticatedClient, Client], -) -> Optional[HealthzResponse]: - """Health Check - - Return the status of a full-system health check of the platform. - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - HealthzResponse - """ - - return ( - await asyncio_detailed( - client=client, - ) - ).parsed diff --git a/unikraft_cloud_platform/api/users/__init__.py b/unikraft_cloud_platform/api/users/__init__.py deleted file mode 100644 index 2d7c0b2..0000000 --- a/unikraft_cloud_platform/api/users/__init__.py +++ /dev/null @@ -1 +0,0 @@ -"""Contains endpoint functions for accessing the API""" diff --git a/unikraft_cloud_platform/api/users/get_user.py b/unikraft_cloud_platform/api/users/get_user.py deleted file mode 100644 index 731a58a..0000000 --- a/unikraft_cloud_platform/api/users/get_user.py +++ /dev/null @@ -1,130 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx - -from ...client import AuthenticatedClient, Client -from ...models.quotas_response import QuotasResponse -from ...types import Response - - -def _get_kwargs() -> dict[str, Any]: - _kwargs: dict[str, Any] = { - "method": "get", - "url": "/v1/users/quotas", - } - - return _kwargs - - -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> QuotasResponse: - response_default = QuotasResponse.from_dict(response.json()) - - return response_default - - -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[QuotasResponse]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - *, - client: Union[AuthenticatedClient, Client], -) -> Response[QuotasResponse]: - """Get Current User Quotas - - List quota usage and limits of your user account. - Limits are hard limits that cannot be exceeded. - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[QuotasResponse] - """ - - kwargs = _get_kwargs() - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - *, - client: Union[AuthenticatedClient, Client], -) -> Optional[QuotasResponse]: - """Get Current User Quotas - - List quota usage and limits of your user account. - Limits are hard limits that cannot be exceeded. - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - QuotasResponse - """ - - return sync_detailed( - client=client, - ).parsed - - -async def asyncio_detailed( - *, - client: Union[AuthenticatedClient, Client], -) -> Response[QuotasResponse]: - """Get Current User Quotas - - List quota usage and limits of your user account. - Limits are hard limits that cannot be exceeded. - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[QuotasResponse] - """ - - kwargs = _get_kwargs() - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - *, - client: Union[AuthenticatedClient, Client], -) -> Optional[QuotasResponse]: - """Get Current User Quotas - - List quota usage and limits of your user account. - Limits are hard limits that cannot be exceeded. - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - QuotasResponse - """ - - return ( - await asyncio_detailed( - client=client, - ) - ).parsed diff --git a/unikraft_cloud_platform/api/users/get_user_by_uuid.py b/unikraft_cloud_platform/api/users/get_user_by_uuid.py deleted file mode 100644 index 4a9e637..0000000 --- a/unikraft_cloud_platform/api/users/get_user_by_uuid.py +++ /dev/null @@ -1,155 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union -from uuid import UUID - -import httpx - -from ...client import AuthenticatedClient, Client -from ...models.quotas_response import QuotasResponse -from ...types import Response - - -def _get_kwargs( - uuid: UUID, -) -> dict[str, Any]: - _kwargs: dict[str, Any] = { - "method": "get", - "url": f"/v1/users/{uuid}/quotas", - } - - return _kwargs - - -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> QuotasResponse: - response_default = QuotasResponse.from_dict(response.json()) - - return response_default - - -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[QuotasResponse]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], -) -> Response[QuotasResponse]: - """Get User Quotas by UUID - - List quota usage and limits of a user account by UUID. - Limits are hard limits that cannot be exceeded. - - Args: - uuid (UUID): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[QuotasResponse] - """ - - kwargs = _get_kwargs( - uuid=uuid, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], -) -> Optional[QuotasResponse]: - """Get User Quotas by UUID - - List quota usage and limits of a user account by UUID. - Limits are hard limits that cannot be exceeded. - - Args: - uuid (UUID): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - QuotasResponse - """ - - return sync_detailed( - uuid=uuid, - client=client, - ).parsed - - -async def asyncio_detailed( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], -) -> Response[QuotasResponse]: - """Get User Quotas by UUID - - List quota usage and limits of a user account by UUID. - Limits are hard limits that cannot be exceeded. - - Args: - uuid (UUID): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[QuotasResponse] - """ - - kwargs = _get_kwargs( - uuid=uuid, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], -) -> Optional[QuotasResponse]: - """Get User Quotas by UUID - - List quota usage and limits of a user account by UUID. - Limits are hard limits that cannot be exceeded. - - Args: - uuid (UUID): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - QuotasResponse - """ - - return ( - await asyncio_detailed( - uuid=uuid, - client=client, - ) - ).parsed diff --git a/unikraft_cloud_platform/api/users_api.py b/unikraft_cloud_platform/api/users_api.py new file mode 100644 index 0000000..070f4ef --- /dev/null +++ b/unikraft_cloud_platform/api/users_api.py @@ -0,0 +1,482 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +import warnings +from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt +from typing import Any, Dict, List, Optional, Tuple, Union +from typing_extensions import Annotated + +from pydantic import Field +from typing_extensions import Annotated +from uuid import UUID +from unikraft_cloud_platform.models.get_quota_by_uuid200_response import GetQuotaByUuid200Response +from unikraft_cloud_platform.models.get_quotas200_response import GetQuotas200Response + +from unikraft_cloud_platform.api_client import ApiClient, RequestSerialized +from unikraft_cloud_platform.api_response import ApiResponse +from unikraft_cloud_platform.rest import RESTResponseType + + +class UsersApi: + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, api_client=None) -> None: + if api_client is None: + api_client = ApiClient.get_default() + self.api_client = api_client + + @validate_call + def get_quota_by_uuid( + self, + uuid: Annotated[ + UUID, + Field( + description="The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. " + ), + ], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> GetQuotaByUuid200Response: + """Get quota information given their UUID + + Lists quota usage and limits for the provided UUID. Limits are hard limits that cannot be exceeded. + + :param uuid: The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. (required) + :type uuid: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_quota_by_uuid_serialize( + uuid=uuid, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "GetQuotaByUuid200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def get_quota_by_uuid_with_http_info( + self, + uuid: Annotated[ + UUID, + Field( + description="The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. " + ), + ], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[GetQuotaByUuid200Response]: + """Get quota information given their UUID + + Lists quota usage and limits for the provided UUID. Limits are hard limits that cannot be exceeded. + + :param uuid: The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. (required) + :type uuid: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_quota_by_uuid_serialize( + uuid=uuid, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "GetQuotaByUuid200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def get_quota_by_uuid_without_preload_content( + self, + uuid: Annotated[ + UUID, + Field( + description="The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. " + ), + ], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Get quota information given their UUID + + Lists quota usage and limits for the provided UUID. Limits are hard limits that cannot be exceeded. + + :param uuid: The UUID of the resource. The UUID is a 36-character string that uniquely identifies the resource. The UUID is returned by the API after creating a resource. (required) + :type uuid: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_quota_by_uuid_serialize( + uuid=uuid, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "GetQuotaByUuid200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _get_quota_by_uuid_serialize( + self, + uuid, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if uuid is not None: + _path_params["uuid"] = uuid + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # authentication setting + _auth_settings: List[str] = ["bearerAuth"] + + return self.api_client.param_serialize( + method="GET", + resource_path="/users/{uuid}/quotas", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) + + @validate_call + def get_quotas( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> GetQuotas200Response: + """Get quota information for one or more users + + Lists quota usage and limits of the specified user account. Limits are hard limits that cannot be exceeded. + + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_quotas_serialize( + _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "GetQuotas200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def get_quotas_with_http_info( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[GetQuotas200Response]: + """Get quota information for one or more users + + Lists quota usage and limits of the specified user account. Limits are hard limits that cannot be exceeded. + + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_quotas_serialize( + _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "GetQuotas200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def get_quotas_without_preload_content( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Get quota information for one or more users + + Lists quota usage and limits of the specified user account. Limits are hard limits that cannot be exceeded. + + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_quotas_serialize( + _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "GetQuotas200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _get_quotas_serialize( + self, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # authentication setting + _auth_settings: List[str] = ["bearerAuth"] + + return self.api_client.param_serialize( + method="GET", + resource_path="/users/quotas", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) diff --git a/unikraft_cloud_platform/api/volumes/__init__.py b/unikraft_cloud_platform/api/volumes/__init__.py deleted file mode 100644 index 2d7c0b2..0000000 --- a/unikraft_cloud_platform/api/volumes/__init__.py +++ /dev/null @@ -1 +0,0 @@ -"""Contains endpoint functions for accessing the API""" diff --git a/unikraft_cloud_platform/api/volumes/attach_volume_by_uuid.py b/unikraft_cloud_platform/api/volumes/attach_volume_by_uuid.py deleted file mode 100644 index f6012da..0000000 --- a/unikraft_cloud_platform/api/volumes/attach_volume_by_uuid.py +++ /dev/null @@ -1,181 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union -from uuid import UUID - -import httpx - -from ...client import AuthenticatedClient, Client -from ...models.attach_volume_by_uuid_request_body import AttachVolumeByUUIDRequestBody -from ...models.attach_volumes_response import AttachVolumesResponse -from ...types import Response - - -def _get_kwargs( - uuid: UUID, - *, - body: AttachVolumeByUUIDRequestBody, -) -> dict[str, Any]: - headers: dict[str, Any] = {} - - _kwargs: dict[str, Any] = { - "method": "put", - "url": f"/v1/volumes/{uuid}/attach", - } - - _kwargs["json"] = body.to_dict() - - headers["Content-Type"] = "application/json" - - _kwargs["headers"] = headers - return _kwargs - - -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> AttachVolumesResponse: - response_default = AttachVolumesResponse.from_dict(response.json()) - - return response_default - - -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[AttachVolumesResponse]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], - body: AttachVolumeByUUIDRequestBody, -) -> Response[AttachVolumesResponse]: - """Attach Volume by UUID - - Attach a volume by UUID to an instance so that the volume is mounted when - the instance starts. The volume needs to be in `available` state and the - instance must be in `stopped` state. - - Args: - uuid (UUID): Example: c1d2e3f4-5678-90ab-cdef-1234567890ab. - body (AttachVolumeByUUIDRequestBody): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[AttachVolumesResponse] - """ - - kwargs = _get_kwargs( - uuid=uuid, - body=body, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], - body: AttachVolumeByUUIDRequestBody, -) -> Optional[AttachVolumesResponse]: - """Attach Volume by UUID - - Attach a volume by UUID to an instance so that the volume is mounted when - the instance starts. The volume needs to be in `available` state and the - instance must be in `stopped` state. - - Args: - uuid (UUID): Example: c1d2e3f4-5678-90ab-cdef-1234567890ab. - body (AttachVolumeByUUIDRequestBody): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - AttachVolumesResponse - """ - - return sync_detailed( - uuid=uuid, - client=client, - body=body, - ).parsed - - -async def asyncio_detailed( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], - body: AttachVolumeByUUIDRequestBody, -) -> Response[AttachVolumesResponse]: - """Attach Volume by UUID - - Attach a volume by UUID to an instance so that the volume is mounted when - the instance starts. The volume needs to be in `available` state and the - instance must be in `stopped` state. - - Args: - uuid (UUID): Example: c1d2e3f4-5678-90ab-cdef-1234567890ab. - body (AttachVolumeByUUIDRequestBody): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[AttachVolumesResponse] - """ - - kwargs = _get_kwargs( - uuid=uuid, - body=body, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], - body: AttachVolumeByUUIDRequestBody, -) -> Optional[AttachVolumesResponse]: - """Attach Volume by UUID - - Attach a volume by UUID to an instance so that the volume is mounted when - the instance starts. The volume needs to be in `available` state and the - instance must be in `stopped` state. - - Args: - uuid (UUID): Example: c1d2e3f4-5678-90ab-cdef-1234567890ab. - body (AttachVolumeByUUIDRequestBody): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - AttachVolumesResponse - """ - - return ( - await asyncio_detailed( - uuid=uuid, - client=client, - body=body, - ) - ).parsed diff --git a/unikraft_cloud_platform/api/volumes/attach_volumes.py b/unikraft_cloud_platform/api/volumes/attach_volumes.py deleted file mode 100644 index 4a3e2b3..0000000 --- a/unikraft_cloud_platform/api/volumes/attach_volumes.py +++ /dev/null @@ -1,175 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx - -from ...client import AuthenticatedClient, Client -from ...models.attach_volumes_request import AttachVolumesRequest -from ...models.attach_volumes_response import AttachVolumesResponse -from ...types import Response - - -def _get_kwargs( - *, - body: AttachVolumesRequest, -) -> dict[str, Any]: - headers: dict[str, Any] = {} - - _kwargs: dict[str, Any] = { - "method": "put", - "url": "/v1/volumes/attach", - } - - _kwargs["json"] = body.to_dict() - - headers["Content-Type"] = "application/json" - - _kwargs["headers"] = headers - return _kwargs - - -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> AttachVolumesResponse: - response_default = AttachVolumesResponse.from_dict(response.json()) - - return response_default - - -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[AttachVolumesResponse]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - *, - client: Union[AuthenticatedClient, Client], - body: AttachVolumesRequest, -) -> Response[AttachVolumesResponse]: - """Attach Volumes - - Attach one or more volumes specified by ID(s) (name or UUID) to instances - so that the volumes are mounted when the instances start. The volumes need - to be in `available` state and the instances must be in `stopped` state. - - Args: - body (AttachVolumesRequest): The request message for attaching one or more volume(s) to - instances by - their UUID(s) or name(s). - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[AttachVolumesResponse] - """ - - kwargs = _get_kwargs( - body=body, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - *, - client: Union[AuthenticatedClient, Client], - body: AttachVolumesRequest, -) -> Optional[AttachVolumesResponse]: - """Attach Volumes - - Attach one or more volumes specified by ID(s) (name or UUID) to instances - so that the volumes are mounted when the instances start. The volumes need - to be in `available` state and the instances must be in `stopped` state. - - Args: - body (AttachVolumesRequest): The request message for attaching one or more volume(s) to - instances by - their UUID(s) or name(s). - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - AttachVolumesResponse - """ - - return sync_detailed( - client=client, - body=body, - ).parsed - - -async def asyncio_detailed( - *, - client: Union[AuthenticatedClient, Client], - body: AttachVolumesRequest, -) -> Response[AttachVolumesResponse]: - """Attach Volumes - - Attach one or more volumes specified by ID(s) (name or UUID) to instances - so that the volumes are mounted when the instances start. The volumes need - to be in `available` state and the instances must be in `stopped` state. - - Args: - body (AttachVolumesRequest): The request message for attaching one or more volume(s) to - instances by - their UUID(s) or name(s). - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[AttachVolumesResponse] - """ - - kwargs = _get_kwargs( - body=body, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - *, - client: Union[AuthenticatedClient, Client], - body: AttachVolumesRequest, -) -> Optional[AttachVolumesResponse]: - """Attach Volumes - - Attach one or more volumes specified by ID(s) (name or UUID) to instances - so that the volumes are mounted when the instances start. The volumes need - to be in `available` state and the instances must be in `stopped` state. - - Args: - body (AttachVolumesRequest): The request message for attaching one or more volume(s) to - instances by - their UUID(s) or name(s). - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - AttachVolumesResponse - """ - - return ( - await asyncio_detailed( - client=client, - body=body, - ) - ).parsed diff --git a/unikraft_cloud_platform/api/volumes/create_volume.py b/unikraft_cloud_platform/api/volumes/create_volume.py deleted file mode 100644 index 218a20f..0000000 --- a/unikraft_cloud_platform/api/volumes/create_volume.py +++ /dev/null @@ -1,175 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx - -from ...client import AuthenticatedClient, Client -from ...models.create_volume_request import CreateVolumeRequest -from ...models.create_volume_response import CreateVolumeResponse -from ...types import Response - - -def _get_kwargs( - *, - body: CreateVolumeRequest, -) -> dict[str, Any]: - headers: dict[str, Any] = {} - - _kwargs: dict[str, Any] = { - "method": "post", - "url": "/v1/volumes", - } - - _kwargs["json"] = body.to_dict() - - headers["Content-Type"] = "application/json" - - _kwargs["headers"] = headers - return _kwargs - - -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> CreateVolumeResponse: - response_default = CreateVolumeResponse.from_dict(response.json()) - - return response_default - - -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[CreateVolumeResponse]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - *, - client: Union[AuthenticatedClient, Client], - body: CreateVolumeRequest, -) -> Response[CreateVolumeResponse]: - """Create Volume - - Create a volume given the specified configuration parameters. - The volume is automatically initialized with an empty file system. - After initialization, the volume is in the `available` state and can be - attached to an instance with the `PUT /v1/volumes/attach` endpoint. - Note that, the size of a volume cannot be changed after creation. - - Args: - body (CreateVolumeRequest): The request message for creating a volume. - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[CreateVolumeResponse] - """ - - kwargs = _get_kwargs( - body=body, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - *, - client: Union[AuthenticatedClient, Client], - body: CreateVolumeRequest, -) -> Optional[CreateVolumeResponse]: - """Create Volume - - Create a volume given the specified configuration parameters. - The volume is automatically initialized with an empty file system. - After initialization, the volume is in the `available` state and can be - attached to an instance with the `PUT /v1/volumes/attach` endpoint. - Note that, the size of a volume cannot be changed after creation. - - Args: - body (CreateVolumeRequest): The request message for creating a volume. - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - CreateVolumeResponse - """ - - return sync_detailed( - client=client, - body=body, - ).parsed - - -async def asyncio_detailed( - *, - client: Union[AuthenticatedClient, Client], - body: CreateVolumeRequest, -) -> Response[CreateVolumeResponse]: - """Create Volume - - Create a volume given the specified configuration parameters. - The volume is automatically initialized with an empty file system. - After initialization, the volume is in the `available` state and can be - attached to an instance with the `PUT /v1/volumes/attach` endpoint. - Note that, the size of a volume cannot be changed after creation. - - Args: - body (CreateVolumeRequest): The request message for creating a volume. - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[CreateVolumeResponse] - """ - - kwargs = _get_kwargs( - body=body, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - *, - client: Union[AuthenticatedClient, Client], - body: CreateVolumeRequest, -) -> Optional[CreateVolumeResponse]: - """Create Volume - - Create a volume given the specified configuration parameters. - The volume is automatically initialized with an empty file system. - After initialization, the volume is in the `available` state and can be - attached to an instance with the `PUT /v1/volumes/attach` endpoint. - Note that, the size of a volume cannot be changed after creation. - - Args: - body (CreateVolumeRequest): The request message for creating a volume. - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - CreateVolumeResponse - """ - - return ( - await asyncio_detailed( - client=client, - body=body, - ) - ).parsed diff --git a/unikraft_cloud_platform/api/volumes/delete_volume_by_uuid.py b/unikraft_cloud_platform/api/volumes/delete_volume_by_uuid.py deleted file mode 100644 index c657750..0000000 --- a/unikraft_cloud_platform/api/volumes/delete_volume_by_uuid.py +++ /dev/null @@ -1,159 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union -from uuid import UUID - -import httpx - -from ...client import AuthenticatedClient, Client -from ...models.delete_volumes_response import DeleteVolumesResponse -from ...types import Response - - -def _get_kwargs( - uuid: UUID, -) -> dict[str, Any]: - _kwargs: dict[str, Any] = { - "method": "delete", - "url": f"/v1/volumes/{uuid}", - } - - return _kwargs - - -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> DeleteVolumesResponse: - response_default = DeleteVolumesResponse.from_dict(response.json()) - - return response_default - - -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[DeleteVolumesResponse]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], -) -> Response[DeleteVolumesResponse]: - """Delete Volume by UUID - - Delete the specified volume by its UUID. If the volume is still attached - to an instance, the operation fails. After this call, the IDs associated - with the volume are no longer valid. - - Args: - uuid (UUID): Example: c1d2e3f4-5678-90ab-cdef-1234567890ab. - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[DeleteVolumesResponse] - """ - - kwargs = _get_kwargs( - uuid=uuid, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], -) -> Optional[DeleteVolumesResponse]: - """Delete Volume by UUID - - Delete the specified volume by its UUID. If the volume is still attached - to an instance, the operation fails. After this call, the IDs associated - with the volume are no longer valid. - - Args: - uuid (UUID): Example: c1d2e3f4-5678-90ab-cdef-1234567890ab. - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - DeleteVolumesResponse - """ - - return sync_detailed( - uuid=uuid, - client=client, - ).parsed - - -async def asyncio_detailed( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], -) -> Response[DeleteVolumesResponse]: - """Delete Volume by UUID - - Delete the specified volume by its UUID. If the volume is still attached - to an instance, the operation fails. After this call, the IDs associated - with the volume are no longer valid. - - Args: - uuid (UUID): Example: c1d2e3f4-5678-90ab-cdef-1234567890ab. - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[DeleteVolumesResponse] - """ - - kwargs = _get_kwargs( - uuid=uuid, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], -) -> Optional[DeleteVolumesResponse]: - """Delete Volume by UUID - - Delete the specified volume by its UUID. If the volume is still attached - to an instance, the operation fails. After this call, the IDs associated - with the volume are no longer valid. - - Args: - uuid (UUID): Example: c1d2e3f4-5678-90ab-cdef-1234567890ab. - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - DeleteVolumesResponse - """ - - return ( - await asyncio_detailed( - uuid=uuid, - client=client, - ) - ).parsed diff --git a/unikraft_cloud_platform/api/volumes/delete_volumes.py b/unikraft_cloud_platform/api/volumes/delete_volumes.py deleted file mode 100644 index 34d5b88..0000000 --- a/unikraft_cloud_platform/api/volumes/delete_volumes.py +++ /dev/null @@ -1,170 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx - -from ...client import AuthenticatedClient, Client -from ...models.delete_volumes_response import DeleteVolumesResponse -from ...models.name_or_uuid import NameOrUUID -from ...types import Response - - -def _get_kwargs( - *, - body: list["NameOrUUID"], -) -> dict[str, Any]: - headers: dict[str, Any] = {} - - _kwargs: dict[str, Any] = { - "method": "delete", - "url": "/v1/volumes", - } - - _kwargs["json"] = [] - for body_item_data in body: - body_item = body_item_data.to_dict() - _kwargs["json"].append(body_item) - - headers["Content-Type"] = "application/json" - - _kwargs["headers"] = headers - return _kwargs - - -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> DeleteVolumesResponse: - response_default = DeleteVolumesResponse.from_dict(response.json()) - - return response_default - - -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[DeleteVolumesResponse]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - *, - client: Union[AuthenticatedClient, Client], - body: list["NameOrUUID"], -) -> Response[DeleteVolumesResponse]: - """Delete Volumes - - Delete one or more volumes by their UUID(s) or name(s). If the volumes are - still attached to an instance, the operation fails. After this call, the - IDs associated with the volumes are no longer valid. - - Args: - body (list['NameOrUUID']): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[DeleteVolumesResponse] - """ - - kwargs = _get_kwargs( - body=body, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - *, - client: Union[AuthenticatedClient, Client], - body: list["NameOrUUID"], -) -> Optional[DeleteVolumesResponse]: - """Delete Volumes - - Delete one or more volumes by their UUID(s) or name(s). If the volumes are - still attached to an instance, the operation fails. After this call, the - IDs associated with the volumes are no longer valid. - - Args: - body (list['NameOrUUID']): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - DeleteVolumesResponse - """ - - return sync_detailed( - client=client, - body=body, - ).parsed - - -async def asyncio_detailed( - *, - client: Union[AuthenticatedClient, Client], - body: list["NameOrUUID"], -) -> Response[DeleteVolumesResponse]: - """Delete Volumes - - Delete one or more volumes by their UUID(s) or name(s). If the volumes are - still attached to an instance, the operation fails. After this call, the - IDs associated with the volumes are no longer valid. - - Args: - body (list['NameOrUUID']): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[DeleteVolumesResponse] - """ - - kwargs = _get_kwargs( - body=body, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - *, - client: Union[AuthenticatedClient, Client], - body: list["NameOrUUID"], -) -> Optional[DeleteVolumesResponse]: - """Delete Volumes - - Delete one or more volumes by their UUID(s) or name(s). If the volumes are - still attached to an instance, the operation fails. After this call, the - IDs associated with the volumes are no longer valid. - - Args: - body (list['NameOrUUID']): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - DeleteVolumesResponse - """ - - return ( - await asyncio_detailed( - client=client, - body=body, - ) - ).parsed diff --git a/unikraft_cloud_platform/api/volumes/detach_volume_by_uuid.py b/unikraft_cloud_platform/api/volumes/detach_volume_by_uuid.py deleted file mode 100644 index f780aa7..0000000 --- a/unikraft_cloud_platform/api/volumes/detach_volume_by_uuid.py +++ /dev/null @@ -1,193 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union -from uuid import UUID - -import httpx - -from ...client import AuthenticatedClient, Client -from ...models.detach_volume_by_uuid_request_body import DetachVolumeByUUIDRequestBody -from ...models.detach_volumes_response import DetachVolumesResponse -from ...types import Response - - -def _get_kwargs( - uuid: UUID, - *, - body: DetachVolumeByUUIDRequestBody, -) -> dict[str, Any]: - headers: dict[str, Any] = {} - - _kwargs: dict[str, Any] = { - "method": "put", - "url": f"/v1/volumes/{uuid}/detach", - } - - _kwargs["json"] = body.to_dict() - - headers["Content-Type"] = "application/json" - - _kwargs["headers"] = headers - return _kwargs - - -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> DetachVolumesResponse: - response_default = DetachVolumesResponse.from_dict(response.json()) - - return response_default - - -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[DetachVolumesResponse]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], - body: DetachVolumeByUUIDRequestBody, -) -> Response[DetachVolumesResponse]: - """Detach Volume by UUID - - Detaches a volume by UUID from instances. If no particular instance is - specified the volume is detached from all instances. The instances from - which to detach must not have the volume mounted. The API returns an error - for each instance from which it was unable to detach the volume. If the - volume has been created together with an instance, detaching the volume - will make it persistent (i.e., it survives the deletion of the instance). - - Args: - uuid (UUID): Example: c1d2e3f4-5678-90ab-cdef-1234567890ab. - body (DetachVolumeByUUIDRequestBody): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[DetachVolumesResponse] - """ - - kwargs = _get_kwargs( - uuid=uuid, - body=body, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], - body: DetachVolumeByUUIDRequestBody, -) -> Optional[DetachVolumesResponse]: - """Detach Volume by UUID - - Detaches a volume by UUID from instances. If no particular instance is - specified the volume is detached from all instances. The instances from - which to detach must not have the volume mounted. The API returns an error - for each instance from which it was unable to detach the volume. If the - volume has been created together with an instance, detaching the volume - will make it persistent (i.e., it survives the deletion of the instance). - - Args: - uuid (UUID): Example: c1d2e3f4-5678-90ab-cdef-1234567890ab. - body (DetachVolumeByUUIDRequestBody): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - DetachVolumesResponse - """ - - return sync_detailed( - uuid=uuid, - client=client, - body=body, - ).parsed - - -async def asyncio_detailed( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], - body: DetachVolumeByUUIDRequestBody, -) -> Response[DetachVolumesResponse]: - """Detach Volume by UUID - - Detaches a volume by UUID from instances. If no particular instance is - specified the volume is detached from all instances. The instances from - which to detach must not have the volume mounted. The API returns an error - for each instance from which it was unable to detach the volume. If the - volume has been created together with an instance, detaching the volume - will make it persistent (i.e., it survives the deletion of the instance). - - Args: - uuid (UUID): Example: c1d2e3f4-5678-90ab-cdef-1234567890ab. - body (DetachVolumeByUUIDRequestBody): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[DetachVolumesResponse] - """ - - kwargs = _get_kwargs( - uuid=uuid, - body=body, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], - body: DetachVolumeByUUIDRequestBody, -) -> Optional[DetachVolumesResponse]: - """Detach Volume by UUID - - Detaches a volume by UUID from instances. If no particular instance is - specified the volume is detached from all instances. The instances from - which to detach must not have the volume mounted. The API returns an error - for each instance from which it was unable to detach the volume. If the - volume has been created together with an instance, detaching the volume - will make it persistent (i.e., it survives the deletion of the instance). - - Args: - uuid (UUID): Example: c1d2e3f4-5678-90ab-cdef-1234567890ab. - body (DetachVolumeByUUIDRequestBody): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - DetachVolumesResponse - """ - - return ( - await asyncio_detailed( - uuid=uuid, - client=client, - body=body, - ) - ).parsed diff --git a/unikraft_cloud_platform/api/volumes/detach_volumes.py b/unikraft_cloud_platform/api/volumes/detach_volumes.py deleted file mode 100644 index f805f2e..0000000 --- a/unikraft_cloud_platform/api/volumes/detach_volumes.py +++ /dev/null @@ -1,191 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx - -from ...client import AuthenticatedClient, Client -from ...models.detach_volumes_request import DetachVolumesRequest -from ...models.detach_volumes_response import DetachVolumesResponse -from ...types import Response - - -def _get_kwargs( - *, - body: DetachVolumesRequest, -) -> dict[str, Any]: - headers: dict[str, Any] = {} - - _kwargs: dict[str, Any] = { - "method": "put", - "url": "/v1/volumes/detach", - } - - _kwargs["json"] = body.to_dict() - - headers["Content-Type"] = "application/json" - - _kwargs["headers"] = headers - return _kwargs - - -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> DetachVolumesResponse: - response_default = DetachVolumesResponse.from_dict(response.json()) - - return response_default - - -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[DetachVolumesResponse]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - *, - client: Union[AuthenticatedClient, Client], - body: DetachVolumesRequest, -) -> Response[DetachVolumesResponse]: - """Detach Volumes - - Detach volumes specified by ID(s) (name or UUID) from instances. If no - particular instance is specified the volume is detached from all instances. - The instances from which to detach must not have the volumes mounted. The - API returns an error for each instance from which it was unable to detach - the volume. If the volume has been created together with an instance, - detaching the volume will make it persistent (i.e., it survives the - deletion of the instance). - - Args: - body (DetachVolumesRequest): The request message for detaching one or more volume(s) from - instances by - their UUID(s) or name(s). - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[DetachVolumesResponse] - """ - - kwargs = _get_kwargs( - body=body, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - *, - client: Union[AuthenticatedClient, Client], - body: DetachVolumesRequest, -) -> Optional[DetachVolumesResponse]: - """Detach Volumes - - Detach volumes specified by ID(s) (name or UUID) from instances. If no - particular instance is specified the volume is detached from all instances. - The instances from which to detach must not have the volumes mounted. The - API returns an error for each instance from which it was unable to detach - the volume. If the volume has been created together with an instance, - detaching the volume will make it persistent (i.e., it survives the - deletion of the instance). - - Args: - body (DetachVolumesRequest): The request message for detaching one or more volume(s) from - instances by - their UUID(s) or name(s). - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - DetachVolumesResponse - """ - - return sync_detailed( - client=client, - body=body, - ).parsed - - -async def asyncio_detailed( - *, - client: Union[AuthenticatedClient, Client], - body: DetachVolumesRequest, -) -> Response[DetachVolumesResponse]: - """Detach Volumes - - Detach volumes specified by ID(s) (name or UUID) from instances. If no - particular instance is specified the volume is detached from all instances. - The instances from which to detach must not have the volumes mounted. The - API returns an error for each instance from which it was unable to detach - the volume. If the volume has been created together with an instance, - detaching the volume will make it persistent (i.e., it survives the - deletion of the instance). - - Args: - body (DetachVolumesRequest): The request message for detaching one or more volume(s) from - instances by - their UUID(s) or name(s). - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[DetachVolumesResponse] - """ - - kwargs = _get_kwargs( - body=body, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - *, - client: Union[AuthenticatedClient, Client], - body: DetachVolumesRequest, -) -> Optional[DetachVolumesResponse]: - """Detach Volumes - - Detach volumes specified by ID(s) (name or UUID) from instances. If no - particular instance is specified the volume is detached from all instances. - The instances from which to detach must not have the volumes mounted. The - API returns an error for each instance from which it was unable to detach - the volume. If the volume has been created together with an instance, - detaching the volume will make it persistent (i.e., it survives the - deletion of the instance). - - Args: - body (DetachVolumesRequest): The request message for detaching one or more volume(s) from - instances by - their UUID(s) or name(s). - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - DetachVolumesResponse - """ - - return ( - await asyncio_detailed( - client=client, - body=body, - ) - ).parsed diff --git a/unikraft_cloud_platform/api/volumes/get_volume_by_uuid.py b/unikraft_cloud_platform/api/volumes/get_volume_by_uuid.py deleted file mode 100644 index 29e56f9..0000000 --- a/unikraft_cloud_platform/api/volumes/get_volume_by_uuid.py +++ /dev/null @@ -1,176 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union -from uuid import UUID - -import httpx - -from ...client import AuthenticatedClient, Client -from ...models.get_volumes_response import GetVolumesResponse -from ...types import UNSET, Response, Unset - - -def _get_kwargs( - uuid: UUID, - *, - details: Union[Unset, bool] = UNSET, -) -> dict[str, Any]: - params: dict[str, Any] = {} - - params["details"] = details - - params = {k: v for k, v in params.items() if v is not UNSET and v is not None} - - _kwargs: dict[str, Any] = { - "method": "get", - "url": f"/v1/volumes/{uuid}", - "params": params, - } - - return _kwargs - - -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> GetVolumesResponse: - response_default = GetVolumesResponse.from_dict(response.json()) - - return response_default - - -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[GetVolumesResponse]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], - details: Union[Unset, bool] = UNSET, -) -> Response[GetVolumesResponse]: - """Get Volume by UUID - - Return the current status and the configuration of a particular volume by - its UUID. - - Args: - uuid (UUID): Example: c1d2e3f4-5678-90ab-cdef-1234567890ab. - details (Union[Unset, bool]): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[GetVolumesResponse] - """ - - kwargs = _get_kwargs( - uuid=uuid, - details=details, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], - details: Union[Unset, bool] = UNSET, -) -> Optional[GetVolumesResponse]: - """Get Volume by UUID - - Return the current status and the configuration of a particular volume by - its UUID. - - Args: - uuid (UUID): Example: c1d2e3f4-5678-90ab-cdef-1234567890ab. - details (Union[Unset, bool]): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - GetVolumesResponse - """ - - return sync_detailed( - uuid=uuid, - client=client, - details=details, - ).parsed - - -async def asyncio_detailed( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], - details: Union[Unset, bool] = UNSET, -) -> Response[GetVolumesResponse]: - """Get Volume by UUID - - Return the current status and the configuration of a particular volume by - its UUID. - - Args: - uuid (UUID): Example: c1d2e3f4-5678-90ab-cdef-1234567890ab. - details (Union[Unset, bool]): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[GetVolumesResponse] - """ - - kwargs = _get_kwargs( - uuid=uuid, - details=details, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], - details: Union[Unset, bool] = UNSET, -) -> Optional[GetVolumesResponse]: - """Get Volume by UUID - - Return the current status and the configuration of a particular volume by - its UUID. - - Args: - uuid (UUID): Example: c1d2e3f4-5678-90ab-cdef-1234567890ab. - details (Union[Unset, bool]): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - GetVolumesResponse - """ - - return ( - await asyncio_detailed( - uuid=uuid, - client=client, - details=details, - ) - ).parsed diff --git a/unikraft_cloud_platform/api/volumes/get_volumes.py b/unikraft_cloud_platform/api/volumes/get_volumes.py deleted file mode 100644 index a53beea..0000000 --- a/unikraft_cloud_platform/api/volumes/get_volumes.py +++ /dev/null @@ -1,190 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx - -from ...client import AuthenticatedClient, Client -from ...models.get_volumes_response import GetVolumesResponse -from ...models.name_or_uuid import NameOrUUID -from ...types import UNSET, Response, Unset - - -def _get_kwargs( - *, - body: list["NameOrUUID"], - details: Union[Unset, bool] = UNSET, -) -> dict[str, Any]: - headers: dict[str, Any] = {} - - params: dict[str, Any] = {} - - params["details"] = details - - params = {k: v for k, v in params.items() if v is not UNSET and v is not None} - - _kwargs: dict[str, Any] = { - "method": "get", - "url": "/v1/volumes", - "params": params, - } - - _kwargs["json"] = [] - for body_item_data in body: - body_item = body_item_data.to_dict() - _kwargs["json"].append(body_item) - - headers["Content-Type"] = "application/json" - - _kwargs["headers"] = headers - return _kwargs - - -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> GetVolumesResponse: - response_default = GetVolumesResponse.from_dict(response.json()) - - return response_default - - -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[GetVolumesResponse]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - *, - client: Union[AuthenticatedClient, Client], - body: list["NameOrUUID"], - details: Union[Unset, bool] = UNSET, -) -> Response[GetVolumesResponse]: - """List Volumes - - Return the current status and the configuration of one or more volumes - specified by either UUID(s) or name(s). If no identifier is provided, - all volumes are returned. - - Args: - details (Union[Unset, bool]): - body (list['NameOrUUID']): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[GetVolumesResponse] - """ - - kwargs = _get_kwargs( - body=body, - details=details, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - *, - client: Union[AuthenticatedClient, Client], - body: list["NameOrUUID"], - details: Union[Unset, bool] = UNSET, -) -> Optional[GetVolumesResponse]: - """List Volumes - - Return the current status and the configuration of one or more volumes - specified by either UUID(s) or name(s). If no identifier is provided, - all volumes are returned. - - Args: - details (Union[Unset, bool]): - body (list['NameOrUUID']): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - GetVolumesResponse - """ - - return sync_detailed( - client=client, - body=body, - details=details, - ).parsed - - -async def asyncio_detailed( - *, - client: Union[AuthenticatedClient, Client], - body: list["NameOrUUID"], - details: Union[Unset, bool] = UNSET, -) -> Response[GetVolumesResponse]: - """List Volumes - - Return the current status and the configuration of one or more volumes - specified by either UUID(s) or name(s). If no identifier is provided, - all volumes are returned. - - Args: - details (Union[Unset, bool]): - body (list['NameOrUUID']): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[GetVolumesResponse] - """ - - kwargs = _get_kwargs( - body=body, - details=details, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - *, - client: Union[AuthenticatedClient, Client], - body: list["NameOrUUID"], - details: Union[Unset, bool] = UNSET, -) -> Optional[GetVolumesResponse]: - """List Volumes - - Return the current status and the configuration of one or more volumes - specified by either UUID(s) or name(s). If no identifier is provided, - all volumes are returned. - - Args: - details (Union[Unset, bool]): - body (list['NameOrUUID']): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - GetVolumesResponse - """ - - return ( - await asyncio_detailed( - client=client, - body=body, - details=details, - ) - ).parsed diff --git a/unikraft_cloud_platform/api/volumes/update_volume_by_uuid.py b/unikraft_cloud_platform/api/volumes/update_volume_by_uuid.py deleted file mode 100644 index 5ff074e..0000000 --- a/unikraft_cloud_platform/api/volumes/update_volume_by_uuid.py +++ /dev/null @@ -1,173 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union -from uuid import UUID - -import httpx - -from ...client import AuthenticatedClient, Client -from ...models.update_volume_by_uuid_request_body import UpdateVolumeByUUIDRequestBody -from ...models.update_volumes_response import UpdateVolumesResponse -from ...types import Response - - -def _get_kwargs( - uuid: UUID, - *, - body: UpdateVolumeByUUIDRequestBody, -) -> dict[str, Any]: - headers: dict[str, Any] = {} - - _kwargs: dict[str, Any] = { - "method": "patch", - "url": f"/v1/volumes/{uuid}", - } - - _kwargs["json"] = body.to_dict() - - headers["Content-Type"] = "application/json" - - _kwargs["headers"] = headers - return _kwargs - - -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> UpdateVolumesResponse: - response_default = UpdateVolumesResponse.from_dict(response.json()) - - return response_default - - -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[UpdateVolumesResponse]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], - body: UpdateVolumeByUUIDRequestBody, -) -> Response[UpdateVolumesResponse]: - """Update Volume by UUID - - Update the specified volume by its UUID. - - Args: - uuid (UUID): Example: 123e4567-e89b-12d3-a456-426614174000. - body (UpdateVolumeByUUIDRequestBody): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[UpdateVolumesResponse] - """ - - kwargs = _get_kwargs( - uuid=uuid, - body=body, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], - body: UpdateVolumeByUUIDRequestBody, -) -> Optional[UpdateVolumesResponse]: - """Update Volume by UUID - - Update the specified volume by its UUID. - - Args: - uuid (UUID): Example: 123e4567-e89b-12d3-a456-426614174000. - body (UpdateVolumeByUUIDRequestBody): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - UpdateVolumesResponse - """ - - return sync_detailed( - uuid=uuid, - client=client, - body=body, - ).parsed - - -async def asyncio_detailed( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], - body: UpdateVolumeByUUIDRequestBody, -) -> Response[UpdateVolumesResponse]: - """Update Volume by UUID - - Update the specified volume by its UUID. - - Args: - uuid (UUID): Example: 123e4567-e89b-12d3-a456-426614174000. - body (UpdateVolumeByUUIDRequestBody): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[UpdateVolumesResponse] - """ - - kwargs = _get_kwargs( - uuid=uuid, - body=body, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - uuid: UUID, - *, - client: Union[AuthenticatedClient, Client], - body: UpdateVolumeByUUIDRequestBody, -) -> Optional[UpdateVolumesResponse]: - """Update Volume by UUID - - Update the specified volume by its UUID. - - Args: - uuid (UUID): Example: 123e4567-e89b-12d3-a456-426614174000. - body (UpdateVolumeByUUIDRequestBody): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - UpdateVolumesResponse - """ - - return ( - await asyncio_detailed( - uuid=uuid, - client=client, - body=body, - ) - ).parsed diff --git a/unikraft_cloud_platform/api/volumes/update_volumes.py b/unikraft_cloud_platform/api/volumes/update_volumes.py deleted file mode 100644 index 0c8dc73..0000000 --- a/unikraft_cloud_platform/api/volumes/update_volumes.py +++ /dev/null @@ -1,162 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx - -from ...client import AuthenticatedClient, Client -from ...models.update_volumes_request_item import UpdateVolumesRequestItem -from ...models.update_volumes_response import UpdateVolumesResponse -from ...types import Response - - -def _get_kwargs( - *, - body: list["UpdateVolumesRequestItem"], -) -> dict[str, Any]: - headers: dict[str, Any] = {} - - _kwargs: dict[str, Any] = { - "method": "patch", - "url": "/v1/volumes", - } - - _kwargs["json"] = [] - for body_item_data in body: - body_item = body_item_data.to_dict() - _kwargs["json"].append(body_item) - - headers["Content-Type"] = "application/json" - - _kwargs["headers"] = headers - return _kwargs - - -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> UpdateVolumesResponse: - response_default = UpdateVolumesResponse.from_dict(response.json()) - - return response_default - - -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[UpdateVolumesResponse]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - *, - client: Union[AuthenticatedClient, Client], - body: list["UpdateVolumesRequestItem"], -) -> Response[UpdateVolumesResponse]: - """Update Volumes - - Update one or more volumes specified by either UUID(s) or name(s). - - Args: - body (list['UpdateVolumesRequestItem']): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[UpdateVolumesResponse] - """ - - kwargs = _get_kwargs( - body=body, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - *, - client: Union[AuthenticatedClient, Client], - body: list["UpdateVolumesRequestItem"], -) -> Optional[UpdateVolumesResponse]: - """Update Volumes - - Update one or more volumes specified by either UUID(s) or name(s). - - Args: - body (list['UpdateVolumesRequestItem']): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - UpdateVolumesResponse - """ - - return sync_detailed( - client=client, - body=body, - ).parsed - - -async def asyncio_detailed( - *, - client: Union[AuthenticatedClient, Client], - body: list["UpdateVolumesRequestItem"], -) -> Response[UpdateVolumesResponse]: - """Update Volumes - - Update one or more volumes specified by either UUID(s) or name(s). - - Args: - body (list['UpdateVolumesRequestItem']): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[UpdateVolumesResponse] - """ - - kwargs = _get_kwargs( - body=body, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - *, - client: Union[AuthenticatedClient, Client], - body: list["UpdateVolumesRequestItem"], -) -> Optional[UpdateVolumesResponse]: - """Update Volumes - - Update one or more volumes specified by either UUID(s) or name(s). - - Args: - body (list['UpdateVolumesRequestItem']): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - UpdateVolumesResponse - """ - - return ( - await asyncio_detailed( - client=client, - body=body, - ) - ).parsed diff --git a/unikraft_cloud_platform/api/volumes_api.py b/unikraft_cloud_platform/api/volumes_api.py new file mode 100644 index 0000000..68ad2cb --- /dev/null +++ b/unikraft_cloud_platform/api/volumes_api.py @@ -0,0 +1,775 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +import warnings +from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt +from typing import Any, Dict, List, Optional, Tuple, Union +from typing_extensions import Annotated + +from pydantic import Field, StrictBool +from typing import List, Optional +from typing_extensions import Annotated +from unikraft_cloud_platform.models.create_volumes200_response import CreateVolumes200Response +from unikraft_cloud_platform.models.create_volumes_request_inner import CreateVolumesRequestInner +from unikraft_cloud_platform.models.delete_volumes200_response import DeleteVolumes200Response +from unikraft_cloud_platform.models.delete_volumes_request_inner import DeleteVolumesRequestInner +from unikraft_cloud_platform.models.get_volumes200_response import GetVolumes200Response +from unikraft_cloud_platform.models.get_volumes_request_inner import GetVolumesRequestInner + +from unikraft_cloud_platform.api_client import ApiClient, RequestSerialized +from unikraft_cloud_platform.api_response import ApiResponse +from unikraft_cloud_platform.rest import RESTResponseType + + +class VolumesApi: + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, api_client=None) -> None: + if api_client is None: + api_client = ApiClient.get_default() + self.api_client = api_client + + @validate_call + def create_volumes( + self, + create_volumes_request_inner: List[CreateVolumesRequestInner], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> CreateVolumes200Response: + """Create one or more persistent volumes + + Creates one or more volumes with the given configuration. The volumes are automatically initialized with an empty file system. After initialization the volumes are in the `available` state and can be attached to an instance with the [`PUT /v1/volumes/attach`](https://unikraft.cloud/docs/api/v1/volumes/#attach) endpoint. Note that, the size of a volume cannot be changed after creation. + + :param create_volumes_request_inner: (required) + :type create_volumes_request_inner: List[CreateVolumesRequestInner] + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._create_volumes_serialize( + create_volumes_request_inner=create_volumes_request_inner, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "CreateVolumes200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def create_volumes_with_http_info( + self, + create_volumes_request_inner: List[CreateVolumesRequestInner], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[CreateVolumes200Response]: + """Create one or more persistent volumes + + Creates one or more volumes with the given configuration. The volumes are automatically initialized with an empty file system. After initialization the volumes are in the `available` state and can be attached to an instance with the [`PUT /v1/volumes/attach`](https://unikraft.cloud/docs/api/v1/volumes/#attach) endpoint. Note that, the size of a volume cannot be changed after creation. + + :param create_volumes_request_inner: (required) + :type create_volumes_request_inner: List[CreateVolumesRequestInner] + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._create_volumes_serialize( + create_volumes_request_inner=create_volumes_request_inner, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "CreateVolumes200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def create_volumes_without_preload_content( + self, + create_volumes_request_inner: List[CreateVolumesRequestInner], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Create one or more persistent volumes + + Creates one or more volumes with the given configuration. The volumes are automatically initialized with an empty file system. After initialization the volumes are in the `available` state and can be attached to an instance with the [`PUT /v1/volumes/attach`](https://unikraft.cloud/docs/api/v1/volumes/#attach) endpoint. Note that, the size of a volume cannot be changed after creation. + + :param create_volumes_request_inner: (required) + :type create_volumes_request_inner: List[CreateVolumesRequestInner] + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._create_volumes_serialize( + create_volumes_request_inner=create_volumes_request_inner, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "CreateVolumes200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _create_volumes_serialize( + self, + create_volumes_request_inner, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + _host = None + + _collection_formats: Dict[str, str] = { + "CreateVolumesRequestInner": "", + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if create_volumes_request_inner is not None: + _body_params = create_volumes_request_inner + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params["Content-Type"] = _content_type + else: + _default_content_type = self.api_client.select_header_content_type(["application/json"]) + if _default_content_type is not None: + _header_params["Content-Type"] = _default_content_type + + # authentication setting + _auth_settings: List[str] = ["bearerAuth"] + + return self.api_client.param_serialize( + method="POST", + resource_path="/volumes", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) + + @validate_call + def delete_volumes( + self, + delete_volumes_request_inner: Optional[List[DeleteVolumesRequestInner]] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> DeleteVolumes200Response: + """Delete one or more persistent volumes + + Deletes the specified volume(s). Fails if the volume is still attached to an instance. After this call the IDs associated with the volume are no longer valid. + + :param delete_volumes_request_inner: + :type delete_volumes_request_inner: List[DeleteVolumesRequestInner] + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._delete_volumes_serialize( + delete_volumes_request_inner=delete_volumes_request_inner, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "DeleteVolumes200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def delete_volumes_with_http_info( + self, + delete_volumes_request_inner: Optional[List[DeleteVolumesRequestInner]] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[DeleteVolumes200Response]: + """Delete one or more persistent volumes + + Deletes the specified volume(s). Fails if the volume is still attached to an instance. After this call the IDs associated with the volume are no longer valid. + + :param delete_volumes_request_inner: + :type delete_volumes_request_inner: List[DeleteVolumesRequestInner] + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._delete_volumes_serialize( + delete_volumes_request_inner=delete_volumes_request_inner, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "DeleteVolumes200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def delete_volumes_without_preload_content( + self, + delete_volumes_request_inner: Optional[List[DeleteVolumesRequestInner]] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Delete one or more persistent volumes + + Deletes the specified volume(s). Fails if the volume is still attached to an instance. After this call the IDs associated with the volume are no longer valid. + + :param delete_volumes_request_inner: + :type delete_volumes_request_inner: List[DeleteVolumesRequestInner] + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._delete_volumes_serialize( + delete_volumes_request_inner=delete_volumes_request_inner, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "DeleteVolumes200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _delete_volumes_serialize( + self, + delete_volumes_request_inner, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + _host = None + + _collection_formats: Dict[str, str] = { + "DeleteVolumesRequestInner": "", + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if delete_volumes_request_inner is not None: + _body_params = delete_volumes_request_inner + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params["Content-Type"] = _content_type + else: + _default_content_type = self.api_client.select_header_content_type(["application/json"]) + if _default_content_type is not None: + _header_params["Content-Type"] = _default_content_type + + # authentication setting + _auth_settings: List[str] = ["bearerAuth"] + + return self.api_client.param_serialize( + method="DELETE", + resource_path="/volumes", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) + + @validate_call + def get_volumes( + self, + details: Annotated[ + Optional[StrictBool], + Field(description="Whether to provide detailed status and configuration information. "), + ] = None, + get_volumes_request_inner: Optional[List[GetVolumesRequestInner]] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> GetVolumes200Response: + """Get the status of one or more persistent volumes + + Returns the current status and the configuration of a particular volume if a UUID or name is specified. Otherwise, returns the current status and configuration of all volumes. + + :param details: Whether to provide detailed status and configuration information. + :type details: bool + :param get_volumes_request_inner: + :type get_volumes_request_inner: List[GetVolumesRequestInner] + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_volumes_serialize( + details=details, + get_volumes_request_inner=get_volumes_request_inner, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "GetVolumes200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def get_volumes_with_http_info( + self, + details: Annotated[ + Optional[StrictBool], + Field(description="Whether to provide detailed status and configuration information. "), + ] = None, + get_volumes_request_inner: Optional[List[GetVolumesRequestInner]] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[GetVolumes200Response]: + """Get the status of one or more persistent volumes + + Returns the current status and the configuration of a particular volume if a UUID or name is specified. Otherwise, returns the current status and configuration of all volumes. + + :param details: Whether to provide detailed status and configuration information. + :type details: bool + :param get_volumes_request_inner: + :type get_volumes_request_inner: List[GetVolumesRequestInner] + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_volumes_serialize( + details=details, + get_volumes_request_inner=get_volumes_request_inner, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "GetVolumes200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def get_volumes_without_preload_content( + self, + details: Annotated[ + Optional[StrictBool], + Field(description="Whether to provide detailed status and configuration information. "), + ] = None, + get_volumes_request_inner: Optional[List[GetVolumesRequestInner]] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Get the status of one or more persistent volumes + + Returns the current status and the configuration of a particular volume if a UUID or name is specified. Otherwise, returns the current status and configuration of all volumes. + + :param details: Whether to provide detailed status and configuration information. + :type details: bool + :param get_volumes_request_inner: + :type get_volumes_request_inner: List[GetVolumesRequestInner] + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_volumes_serialize( + details=details, + get_volumes_request_inner=get_volumes_request_inner, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "GetVolumes200Response", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _get_volumes_serialize( + self, + details, + get_volumes_request_inner, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + _host = None + + _collection_formats: Dict[str, str] = { + "GetVolumesRequestInner": "", + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + if details is not None: + _query_params.append(("details", details)) + + # process the header parameters + # process the form parameters + # process the body parameter + if get_volumes_request_inner is not None: + _body_params = get_volumes_request_inner + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params["Content-Type"] = _content_type + else: + _default_content_type = self.api_client.select_header_content_type(["application/json"]) + if _default_content_type is not None: + _header_params["Content-Type"] = _default_content_type + + # authentication setting + _auth_settings: List[str] = ["bearerAuth"] + + return self.api_client.param_serialize( + method="GET", + resource_path="/volumes", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) diff --git a/unikraft_cloud_platform/api_client.py b/unikraft_cloud_platform/api_client.py new file mode 100644 index 0000000..9c83931 --- /dev/null +++ b/unikraft_cloud_platform/api_client.py @@ -0,0 +1,702 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +import datetime +from dateutil.parser import parse +from enum import Enum +import decimal +import json +import mimetypes +import os +import re +import tempfile +import uuid + +from urllib.parse import quote +from typing import Tuple, Optional, List, Dict, Union +from pydantic import SecretStr + +from unikraft_cloud_platform.configuration import Configuration +from unikraft_cloud_platform.api_response import ApiResponse, T as ApiResponseT +import unikraft_cloud_platform.models +from unikraft_cloud_platform import rest +from unikraft_cloud_platform.exceptions import ( + ApiValueError, + ApiException, + BadRequestException, + UnauthorizedException, + ForbiddenException, + NotFoundException, + ServiceException, +) + +RequestSerialized = Tuple[str, str, Dict[str, str], Optional[str], List[str]] + + +class ApiClient: + """Generic API client for OpenAPI client library builds. + + OpenAPI generic API client. This client handles the client- + server communication, and is invariant across implementations. Specifics of + the methods and models for each application are generated from the OpenAPI + templates. + + :param configuration: .Configuration object for this client + :param header_name: a header to pass when making calls to the API. + :param header_value: a header value to pass when making calls to + the API. + :param cookie: a cookie to include in the header when making calls + to the API + """ + + PRIMITIVE_TYPES = (float, bool, bytes, str, int) + NATIVE_TYPES_MAPPING = { + "int": int, + "long": int, # TODO remove as only py3 is supported? + "float": float, + "str": str, + "bool": bool, + "date": datetime.date, + "datetime": datetime.datetime, + "decimal": decimal.Decimal, + "object": object, + } + _pool = None + + def __init__(self, configuration=None, header_name=None, header_value=None, cookie=None) -> None: + # use default configuration if none is provided + if configuration is None: + configuration = Configuration.get_default() + self.configuration = configuration + + self.rest_client = rest.RESTClientObject(configuration) + self.default_headers = {} + if header_name is not None: + self.default_headers[header_name] = header_value + self.cookie = cookie + # Set default User-Agent. + self.user_agent = "OpenAPI-Generator/0.6.0/python" + self.client_side_validation = configuration.client_side_validation + + def __enter__(self): + return self + + def __exit__(self, exc_type, exc_value, traceback): + pass + + @property + def user_agent(self): + """User agent for this API client""" + return self.default_headers["User-Agent"] + + @user_agent.setter + def user_agent(self, value): + self.default_headers["User-Agent"] = value + + def set_default_header(self, header_name, header_value): + self.default_headers[header_name] = header_value + + _default = None + + @classmethod + def get_default(cls): + """Return new instance of ApiClient. + + This method returns newly created, based on default constructor, + object of ApiClient class or returns a copy of default + ApiClient. + + :return: The ApiClient object. + """ + if cls._default is None: + cls._default = ApiClient() + return cls._default + + @classmethod + def set_default(cls, default): + """Set default instance of ApiClient. + + It stores default ApiClient. + + :param default: object of ApiClient. + """ + cls._default = default + + def param_serialize( + self, + method, + resource_path, + path_params=None, + query_params=None, + header_params=None, + body=None, + post_params=None, + files=None, + auth_settings=None, + collection_formats=None, + _host=None, + _request_auth=None, + ) -> RequestSerialized: + """Builds the HTTP request params needed by the request. + :param method: Method to call. + :param resource_path: Path to method endpoint. + :param path_params: Path parameters in the url. + :param query_params: Query parameters in the url. + :param header_params: Header parameters to be + placed in the request header. + :param body: Request body. + :param post_params dict: Request post form parameters, + for `application/x-www-form-urlencoded`, `multipart/form-data`. + :param auth_settings list: Auth Settings names for the request. + :param files dict: key -> filename, value -> filepath, + for `multipart/form-data`. + :param collection_formats: dict of collection formats for path, query, + header, and post parameters. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :return: tuple of form (path, http_method, query_params, header_params, + body, post_params, files) + """ + + config = self.configuration + + # header parameters + header_params = header_params or {} + header_params.update(self.default_headers) + if self.cookie: + header_params["Cookie"] = self.cookie + if header_params: + header_params = self.sanitize_for_serialization(header_params) + header_params = dict(self.parameters_to_tuples(header_params, collection_formats)) + + # path parameters + if path_params: + path_params = self.sanitize_for_serialization(path_params) + path_params = self.parameters_to_tuples(path_params, collection_formats) + for k, v in path_params: + # specified safe chars, encode everything + resource_path = resource_path.replace("{%s}" % k, quote(str(v), safe=config.safe_chars_for_path_param)) + + # post parameters + if post_params or files: + post_params = post_params if post_params else [] + post_params = self.sanitize_for_serialization(post_params) + post_params = self.parameters_to_tuples(post_params, collection_formats) + if files: + post_params.extend(self.files_parameters(files)) + + # auth setting + self.update_params_for_auth( + header_params, query_params, auth_settings, resource_path, method, body, request_auth=_request_auth + ) + + # body + if body: + body = self.sanitize_for_serialization(body) + + # request url + if _host is None or self.configuration.ignore_operation_servers: + url = self.configuration.host + resource_path + else: + # use server/host defined in path or operation instead + url = _host + resource_path + + # query parameters + if query_params: + query_params = self.sanitize_for_serialization(query_params) + url_query = self.parameters_to_url_query(query_params, collection_formats) + url += "?" + url_query + + return method, url, header_params, body, post_params + + def call_api( + self, method, url, header_params=None, body=None, post_params=None, _request_timeout=None + ) -> rest.RESTResponse: + """Makes the HTTP request (synchronous) + :param method: Method to call. + :param url: Path to method endpoint. + :param header_params: Header parameters to be + placed in the request header. + :param body: Request body. + :param post_params dict: Request post form parameters, + for `application/x-www-form-urlencoded`, `multipart/form-data`. + :param _request_timeout: timeout setting for this request. + :return: RESTResponse + """ + + try: + # perform request and return response + response_data = self.rest_client.request( + method, + url, + headers=header_params, + body=body, + post_params=post_params, + _request_timeout=_request_timeout, + ) + + except ApiException as e: + raise e + + return response_data + + def response_deserialize( + self, response_data: rest.RESTResponse, response_types_map: Optional[Dict[str, ApiResponseT]] = None + ) -> ApiResponse[ApiResponseT]: + """Deserializes response into an object. + :param response_data: RESTResponse object to be deserialized. + :param response_types_map: dict of response types. + :return: ApiResponse + """ + + msg = "RESTResponse.read() must be called before passing it to response_deserialize()" + assert response_data.data is not None, msg + + response_type = response_types_map.get(str(response_data.status), None) + if not response_type and isinstance(response_data.status, int) and 100 <= response_data.status <= 599: + # if not found, look for '1XX', '2XX', etc. + response_type = response_types_map.get(str(response_data.status)[0] + "XX", None) + + # deserialize response data + response_text = None + return_data = None + try: + if response_type == "bytearray": + return_data = response_data.data + elif response_type == "file": + return_data = self.__deserialize_file(response_data) + elif response_type is not None: + match = None + content_type = response_data.getheader("content-type") + if content_type is not None: + match = re.search(r"charset=([a-zA-Z\-\d]+)[\s;]?", content_type) + encoding = match.group(1) if match else "utf-8" + response_text = response_data.data.decode(encoding) + return_data = self.deserialize(response_text, response_type, content_type) + finally: + if not 200 <= response_data.status <= 299: + raise ApiException.from_response( + http_resp=response_data, + body=response_text, + data=return_data, + ) + + return ApiResponse( + status_code=response_data.status, + data=return_data, + headers=response_data.getheaders(), + raw_data=response_data.data, + ) + + def sanitize_for_serialization(self, obj): + """Builds a JSON POST object. + + If obj is None, return None. + If obj is SecretStr, return obj.get_secret_value() + If obj is str, int, long, float, bool, return directly. + If obj is datetime.datetime, datetime.date + convert to string in iso8601 format. + If obj is decimal.Decimal return string representation. + If obj is list, sanitize each element in the list. + If obj is dict, return the dict. + If obj is OpenAPI model, return the properties dict. + + :param obj: The data to serialize. + :return: The serialized form of data. + """ + if obj is None: + return None + elif isinstance(obj, Enum): + return obj.value + elif isinstance(obj, SecretStr): + return obj.get_secret_value() + elif isinstance(obj, self.PRIMITIVE_TYPES): + return obj + elif isinstance(obj, uuid.UUID): + return str(obj) + elif isinstance(obj, list): + return [self.sanitize_for_serialization(sub_obj) for sub_obj in obj] + elif isinstance(obj, tuple): + return tuple(self.sanitize_for_serialization(sub_obj) for sub_obj in obj) + elif isinstance(obj, (datetime.datetime, datetime.date)): + return obj.isoformat() + elif isinstance(obj, decimal.Decimal): + return str(obj) + + elif isinstance(obj, dict): + obj_dict = obj + else: + # Convert model obj to dict except + # attributes `openapi_types`, `attribute_map` + # and attributes which value is not None. + # Convert attribute name to json key in + # model definition for request. + if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): + obj_dict = obj.to_dict() + else: + obj_dict = obj.__dict__ + + if isinstance(obj_dict, list): + # here we handle instances that can either be a list or something else, and only became a real list by calling to_dict() + return self.sanitize_for_serialization(obj_dict) + + return {key: self.sanitize_for_serialization(val) for key, val in obj_dict.items()} + + def deserialize(self, response_text: str, response_type: str, content_type: Optional[str]): + """Deserializes response into an object. + + :param response: RESTResponse object to be deserialized. + :param response_type: class literal for + deserialized object, or string of class name. + :param content_type: content type of response. + + :return: deserialized object. + """ + + # fetch data from response object + if content_type is None: + try: + data = json.loads(response_text) + except ValueError: + data = response_text + elif re.match(r"^application/(json|[\w!#$&.+\-^_]+\+json)\s*(;|$)", content_type, re.IGNORECASE): + if response_text == "": + data = "" + else: + data = json.loads(response_text) + elif re.match(r"^text\/[a-z.+-]+\s*(;|$)", content_type, re.IGNORECASE): + data = response_text + else: + raise ApiException(status=0, reason="Unsupported content type: {0}".format(content_type)) + + return self.__deserialize(data, response_type) + + def __deserialize(self, data, klass): + """Deserializes dict, list, str into an object. + + :param data: dict, list or str. + :param klass: class literal, or string of class name. + + :return: object. + """ + if data is None: + return None + + if isinstance(klass, str): + if klass.startswith("List["): + m = re.match(r"List\[(.*)]", klass) + assert m is not None, "Malformed List type definition" + sub_kls = m.group(1) + return [self.__deserialize(sub_data, sub_kls) for sub_data in data] + + if klass.startswith("Dict["): + m = re.match(r"Dict\[([^,]*), (.*)]", klass) + assert m is not None, "Malformed Dict type definition" + sub_kls = m.group(2) + return {k: self.__deserialize(v, sub_kls) for k, v in data.items()} + + # convert str to class + if klass in self.NATIVE_TYPES_MAPPING: + klass = self.NATIVE_TYPES_MAPPING[klass] + else: + klass = getattr(unikraft_cloud_platform.models, klass) + + if klass in self.PRIMITIVE_TYPES: + return self.__deserialize_primitive(data, klass) + elif klass is object: + return self.__deserialize_object(data) + elif klass is datetime.date: + return self.__deserialize_date(data) + elif klass is datetime.datetime: + return self.__deserialize_datetime(data) + elif klass is decimal.Decimal: + return decimal.Decimal(data) + elif issubclass(klass, Enum): + return self.__deserialize_enum(data, klass) + else: + return self.__deserialize_model(data, klass) + + def parameters_to_tuples(self, params, collection_formats): + """Get parameters as list of tuples, formatting collections. + + :param params: Parameters as dict or list of two-tuples + :param dict collection_formats: Parameter collection formats + :return: Parameters as list of tuples, collections formatted + """ + new_params: List[Tuple[str, str]] = [] + if collection_formats is None: + collection_formats = {} + for k, v in params.items() if isinstance(params, dict) else params: + if k in collection_formats: + collection_format = collection_formats[k] + if collection_format == "multi": + new_params.extend((k, value) for value in v) + else: + if collection_format == "ssv": + delimiter = " " + elif collection_format == "tsv": + delimiter = "\t" + elif collection_format == "pipes": + delimiter = "|" + else: # csv is the default + delimiter = "," + new_params.append((k, delimiter.join(str(value) for value in v))) + else: + new_params.append((k, v)) + return new_params + + def parameters_to_url_query(self, params, collection_formats): + """Get parameters as list of tuples, formatting collections. + + :param params: Parameters as dict or list of two-tuples + :param dict collection_formats: Parameter collection formats + :return: URL query string (e.g. a=Hello%20World&b=123) + """ + new_params: List[Tuple[str, str]] = [] + if collection_formats is None: + collection_formats = {} + for k, v in params.items() if isinstance(params, dict) else params: + if isinstance(v, bool): + v = str(v).lower() + if isinstance(v, (int, float)): + v = str(v) + if isinstance(v, dict): + v = json.dumps(v) + + if k in collection_formats: + collection_format = collection_formats[k] + if collection_format == "multi": + new_params.extend((k, quote(str(value))) for value in v) + else: + if collection_format == "ssv": + delimiter = " " + elif collection_format == "tsv": + delimiter = "\t" + elif collection_format == "pipes": + delimiter = "|" + else: # csv is the default + delimiter = "," + new_params.append((k, delimiter.join(quote(str(value)) for value in v))) + else: + new_params.append((k, quote(str(v)))) + + return "&".join(["=".join(map(str, item)) for item in new_params]) + + def files_parameters( + self, + files: Dict[str, Union[str, bytes, List[str], List[bytes], Tuple[str, bytes]]], + ): + """Builds form parameters. + + :param files: File parameters. + :return: Form parameters with files. + """ + params = [] + for k, v in files.items(): + if isinstance(v, str): + with open(v, "rb") as f: + filename = os.path.basename(f.name) + filedata = f.read() + elif isinstance(v, bytes): + filename = k + filedata = v + elif isinstance(v, tuple): + filename, filedata = v + elif isinstance(v, list): + for file_param in v: + params.extend(self.files_parameters({k: file_param})) + continue + else: + raise ValueError("Unsupported file value") + mimetype = mimetypes.guess_type(filename)[0] or "application/octet-stream" + params.append(tuple([k, tuple([filename, filedata, mimetype])])) + return params + + def select_header_accept(self, accepts: List[str]) -> Optional[str]: + """Returns `Accept` based on an array of accepts provided. + + :param accepts: List of headers. + :return: Accept (e.g. application/json). + """ + if not accepts: + return None + + for accept in accepts: + if re.search("json", accept, re.IGNORECASE): + return accept + + return accepts[0] + + def select_header_content_type(self, content_types): + """Returns `Content-Type` based on an array of content_types provided. + + :param content_types: List of content-types. + :return: Content-Type (e.g. application/json). + """ + if not content_types: + return None + + for content_type in content_types: + if re.search("json", content_type, re.IGNORECASE): + return content_type + + return content_types[0] + + def update_params_for_auth( + self, headers, queries, auth_settings, resource_path, method, body, request_auth=None + ) -> None: + """Updates header and query params based on authentication setting. + + :param headers: Header parameters dict to be updated. + :param queries: Query parameters tuple list to be updated. + :param auth_settings: Authentication setting identifiers list. + :resource_path: A string representation of the HTTP request resource path. + :method: A string representation of the HTTP request method. + :body: A object representing the body of the HTTP request. + The object type is the return value of sanitize_for_serialization(). + :param request_auth: if set, the provided settings will + override the token in the configuration. + """ + if not auth_settings: + return + + if request_auth: + self._apply_auth_params(headers, queries, resource_path, method, body, request_auth) + else: + for auth in auth_settings: + auth_setting = self.configuration.auth_settings().get(auth) + if auth_setting: + self._apply_auth_params(headers, queries, resource_path, method, body, auth_setting) + + def _apply_auth_params(self, headers, queries, resource_path, method, body, auth_setting) -> None: + """Updates the request parameters based on a single auth_setting + + :param headers: Header parameters dict to be updated. + :param queries: Query parameters tuple list to be updated. + :resource_path: A string representation of the HTTP request resource path. + :method: A string representation of the HTTP request method. + :body: A object representing the body of the HTTP request. + The object type is the return value of sanitize_for_serialization(). + :param auth_setting: auth settings for the endpoint + """ + if auth_setting["in"] == "cookie": + headers["Cookie"] = auth_setting["value"] + elif auth_setting["in"] == "header": + if auth_setting["type"] != "http-signature": + headers[auth_setting["key"]] = auth_setting["value"] + elif auth_setting["in"] == "query": + queries.append((auth_setting["key"], auth_setting["value"])) + else: + raise ApiValueError("Authentication token must be in `query` or `header`") + + def __deserialize_file(self, response): + """Deserializes body to file + + Saves response body into a file in a temporary folder, + using the filename from the `Content-Disposition` header if provided. + + handle file downloading + save response body into a tmp file and return the instance + + :param response: RESTResponse. + :return: file path. + """ + fd, path = tempfile.mkstemp(dir=self.configuration.temp_folder_path) + os.close(fd) + os.remove(path) + + content_disposition = response.getheader("Content-Disposition") + if content_disposition: + m = re.search(r'filename=[\'"]?([^\'"\s]+)[\'"]?', content_disposition) + assert m is not None, "Unexpected 'content-disposition' header value" + filename = m.group(1) + path = os.path.join(os.path.dirname(path), filename) + + with open(path, "wb") as f: + f.write(response.data) + + return path + + def __deserialize_primitive(self, data, klass): + """Deserializes string to primitive type. + + :param data: str. + :param klass: class literal. + + :return: int, long, float, str, bool. + """ + try: + return klass(data) + except UnicodeEncodeError: + return str(data) + except TypeError: + return data + + def __deserialize_object(self, value): + """Return an original value. + + :return: object. + """ + return value + + def __deserialize_date(self, string): + """Deserializes string to date. + + :param string: str. + :return: date. + """ + try: + return parse(string).date() + except ImportError: + return string + except ValueError: + raise rest.ApiException(status=0, reason="Failed to parse `{0}` as date object".format(string)) + + def __deserialize_datetime(self, string): + """Deserializes string to datetime. + + The string should be in iso8601 datetime format. + + :param string: str. + :return: datetime. + """ + try: + return parse(string) + except ImportError: + return string + except ValueError: + raise rest.ApiException(status=0, reason=("Failed to parse `{0}` as datetime object".format(string))) + + def __deserialize_enum(self, data, klass): + """Deserializes primitive type to enum. + + :param data: primitive type. + :param klass: class literal. + :return: enum value. + """ + try: + return klass(data) + except ValueError: + raise rest.ApiException(status=0, reason=("Failed to parse `{0}` as `{1}`".format(data, klass))) + + def __deserialize_model(self, data, klass): + """Deserializes list or dict to model. + + :param data: dict, list. + :param klass: class literal. + :return: model object. + """ + + return klass.from_dict(data) diff --git a/unikraft_cloud_platform/api_response.py b/unikraft_cloud_platform/api_response.py new file mode 100644 index 0000000..1ce1372 --- /dev/null +++ b/unikraft_cloud_platform/api_response.py @@ -0,0 +1,20 @@ +"""API response object.""" + +from __future__ import annotations +from typing import Optional, Generic, Mapping, TypeVar +from pydantic import Field, StrictInt, StrictBytes, BaseModel + +T = TypeVar("T") + + +class ApiResponse(BaseModel, Generic[T]): + """ + API response object + """ + + status_code: StrictInt = Field(description="HTTP status code") + headers: Optional[Mapping[str, str]] = Field(None, description="HTTP headers") + data: T = Field(description="Deserialized data given the data type") + raw_data: StrictBytes = Field(description="Raw data (HTTP response body)") + + model_config = {"arbitrary_types_allowed": True} diff --git a/unikraft_cloud_platform/client.py b/unikraft_cloud_platform/client.py deleted file mode 100644 index e05334a..0000000 --- a/unikraft_cloud_platform/client.py +++ /dev/null @@ -1,260 +0,0 @@ -import ssl -from typing import Any, Optional, Union - -import httpx -from attrs import define, evolve, field - - -@define -class Client: - """A class for keeping track of data related to the API - - The following are accepted as keyword arguments and will be used to construct httpx Clients internally: - - ``base_url``: The base URL for the API, all requests are made to a relative path to this URL - - ``cookies``: A dictionary of cookies to be sent with every request - - ``headers``: A dictionary of headers to be sent with every request - - ``timeout``: The maximum amount of a time a request can take. API functions will raise - httpx.TimeoutException if this is exceeded. - - ``verify_ssl``: Whether or not to verify the SSL certificate of the API server. This should be True in production, - but can be set to False for testing purposes. - - ``follow_redirects``: Whether or not to follow redirects. Default value is False. - - ``httpx_args``: A dictionary of additional arguments to be passed to the ``httpx.Client`` and ``httpx.AsyncClient`` constructor. - - """ - - raise_on_unexpected_status: bool = field(default=False, kw_only=True) - """Whether or not to raise an errors.UnexpectedStatus if the API returns a status code that was not documented in the source OpenAPI document. Can also be provided as a keyword argument to the constructor.""" - _base_url: str = field(alias="base_url") - _cookies: dict[str, str] = field(factory=dict, kw_only=True, alias="cookies") - _headers: dict[str, str] = field(factory=dict, kw_only=True, alias="headers") - _timeout: Optional[httpx.Timeout] = field(default=None, kw_only=True, alias="timeout") - _verify_ssl: Union[str, bool, ssl.SSLContext] = field(default=True, kw_only=True, alias="verify_ssl") - _follow_redirects: bool = field(default=False, kw_only=True, alias="follow_redirects") - _httpx_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args") - _client: Optional[httpx.Client] = field(default=None, init=False) - _async_client: Optional[httpx.AsyncClient] = field(default=None, init=False) - - def with_headers(self, headers: dict[str, str]) -> "Client": - """Get a new client matching this one with additional headers""" - if self._client is not None: - self._client.headers.update(headers) - if self._async_client is not None: - self._async_client.headers.update(headers) - return evolve(self, headers={**self._headers, **headers}) - - def with_cookies(self, cookies: dict[str, str]) -> "Client": - """Get a new client matching this one with additional cookies""" - if self._client is not None: - self._client.cookies.update(cookies) - if self._async_client is not None: - self._async_client.cookies.update(cookies) - return evolve(self, cookies={**self._cookies, **cookies}) - - def with_timeout(self, timeout: httpx.Timeout) -> "Client": - """Get a new client matching this one with a new timeout (in seconds)""" - if self._client is not None: - self._client.timeout = timeout - if self._async_client is not None: - self._async_client.timeout = timeout - return evolve(self, timeout=timeout) - - def set_httpx_client(self, client: httpx.Client) -> "Client": - """Manually set the underlying httpx.Client - - **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout. - """ - self._client = client - return self - - def get_httpx_client(self) -> httpx.Client: - """Get the underlying httpx.Client, constructing a new one if not previously set""" - if self._client is None: - self._client = httpx.Client( - base_url=self._base_url, - cookies=self._cookies, - headers=self._headers, - timeout=self._timeout, - verify=self._verify_ssl, - follow_redirects=self._follow_redirects, - **self._httpx_args, - ) - return self._client - - def __enter__(self) -> "Client": - """Enter a context manager for self.client—you cannot enter twice (see httpx docs)""" - self.get_httpx_client().__enter__() - return self - - def __exit__(self, *args: Any, **kwargs: Any) -> None: - """Exit a context manager for internal httpx.Client (see httpx docs)""" - self.get_httpx_client().__exit__(*args, **kwargs) - - def set_async_httpx_client(self, async_client: httpx.AsyncClient) -> "Client": - """Manually the underlying httpx.AsyncClient - - **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout. - """ - self._async_client = async_client - return self - - def get_async_httpx_client(self) -> httpx.AsyncClient: - """Get the underlying httpx.AsyncClient, constructing a new one if not previously set""" - if self._async_client is None: - self._async_client = httpx.AsyncClient( - base_url=self._base_url, - cookies=self._cookies, - headers=self._headers, - timeout=self._timeout, - verify=self._verify_ssl, - follow_redirects=self._follow_redirects, - **self._httpx_args, - ) - return self._async_client - - async def __aenter__(self) -> "Client": - """Enter a context manager for underlying httpx.AsyncClient—you cannot enter twice (see httpx docs)""" - await self.get_async_httpx_client().__aenter__() - return self - - async def __aexit__(self, *args: Any, **kwargs: Any) -> None: - """Exit a context manager for underlying httpx.AsyncClient (see httpx docs)""" - await self.get_async_httpx_client().__aexit__(*args, **kwargs) - - -@define -class AuthenticatedClient: - """A Client which has been authenticated for use on secured endpoints - - The following are accepted as keyword arguments and will be used to construct httpx Clients internally: - - ``base_url``: The base URL for the API, all requests are made to a relative path to this URL - - ``cookies``: A dictionary of cookies to be sent with every request - - ``headers``: A dictionary of headers to be sent with every request - - ``timeout``: The maximum amount of a time a request can take. API functions will raise - httpx.TimeoutException if this is exceeded. - - ``verify_ssl``: Whether or not to verify the SSL certificate of the API server. This should be True in production, - but can be set to False for testing purposes. - - ``follow_redirects``: Whether or not to follow redirects. Default value is False. - - ``httpx_args``: A dictionary of additional arguments to be passed to the ``httpx.Client`` and ``httpx.AsyncClient`` constructor. - - """ - - raise_on_unexpected_status: bool = field(default=False, kw_only=True) - """Whether or not to raise an errors.UnexpectedStatus if the API returns a status code that was not documented in the source OpenAPI document. Can also be provided as a keyword argument to the constructor.""" - _base_url: str = field(alias="base_url") - _cookies: dict[str, str] = field(factory=dict, kw_only=True, alias="cookies") - _headers: dict[str, str] = field(factory=dict, kw_only=True, alias="headers") - _timeout: Optional[httpx.Timeout] = field(default=None, kw_only=True, alias="timeout") - _verify_ssl: Union[str, bool, ssl.SSLContext] = field(default=True, kw_only=True, alias="verify_ssl") - _follow_redirects: bool = field(default=False, kw_only=True, alias="follow_redirects") - _httpx_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args") - _client: Optional[httpx.Client] = field(default=None, init=False) - _async_client: Optional[httpx.AsyncClient] = field(default=None, init=False) - - token: str - """The token to use for authentication""" - prefix: str = "Bearer" - """The prefix to use for the Authorization header""" - auth_header_name: str = "Authorization" - """The name of the Authorization header""" - - def with_headers(self, headers: dict[str, str]) -> "AuthenticatedClient": - """Get a new client matching this one with additional headers""" - if self._client is not None: - self._client.headers.update(headers) - if self._async_client is not None: - self._async_client.headers.update(headers) - return evolve(self, headers={**self._headers, **headers}) - - def with_cookies(self, cookies: dict[str, str]) -> "AuthenticatedClient": - """Get a new client matching this one with additional cookies""" - if self._client is not None: - self._client.cookies.update(cookies) - if self._async_client is not None: - self._async_client.cookies.update(cookies) - return evolve(self, cookies={**self._cookies, **cookies}) - - def with_timeout(self, timeout: httpx.Timeout) -> "AuthenticatedClient": - """Get a new client matching this one with a new timeout (in seconds)""" - if self._client is not None: - self._client.timeout = timeout - if self._async_client is not None: - self._async_client.timeout = timeout - return evolve(self, timeout=timeout) - - def set_httpx_client(self, client: httpx.Client) -> "AuthenticatedClient": - """Manually set the underlying httpx.Client - - **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout. - """ - self._client = client - return self - - def get_httpx_client(self) -> httpx.Client: - """Get the underlying httpx.Client, constructing a new one if not previously set""" - if self._client is None: - self._headers[self.auth_header_name] = f"{self.prefix} {self.token}" if self.prefix else self.token - self._client = httpx.Client( - base_url=self._base_url, - cookies=self._cookies, - headers=self._headers, - timeout=self._timeout, - verify=self._verify_ssl, - follow_redirects=self._follow_redirects, - **self._httpx_args, - ) - return self._client - - def __enter__(self) -> "AuthenticatedClient": - """Enter a context manager for self.client—you cannot enter twice (see httpx docs)""" - self.get_httpx_client().__enter__() - return self - - def __exit__(self, *args: Any, **kwargs: Any) -> None: - """Exit a context manager for internal httpx.Client (see httpx docs)""" - self.get_httpx_client().__exit__(*args, **kwargs) - - def set_async_httpx_client(self, async_client: httpx.AsyncClient) -> "AuthenticatedClient": - """Manually the underlying httpx.AsyncClient - - **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout. - """ - self._async_client = async_client - return self - - def get_async_httpx_client(self) -> httpx.AsyncClient: - """Get the underlying httpx.AsyncClient, constructing a new one if not previously set""" - if self._async_client is None: - self._headers[self.auth_header_name] = f"{self.prefix} {self.token}" if self.prefix else self.token - self._async_client = httpx.AsyncClient( - base_url=self._base_url, - cookies=self._cookies, - headers=self._headers, - timeout=self._timeout, - verify=self._verify_ssl, - follow_redirects=self._follow_redirects, - **self._httpx_args, - ) - return self._async_client - - async def __aenter__(self) -> "AuthenticatedClient": - """Enter a context manager for underlying httpx.AsyncClient—you cannot enter twice (see httpx docs)""" - await self.get_async_httpx_client().__aenter__() - return self - - async def __aexit__(self, *args: Any, **kwargs: Any) -> None: - """Exit a context manager for underlying httpx.AsyncClient (see httpx docs)""" - await self.get_async_httpx_client().__aexit__(*args, **kwargs) diff --git a/unikraft_cloud_platform/configuration.py b/unikraft_cloud_platform/configuration.py new file mode 100644 index 0000000..28b2594 --- /dev/null +++ b/unikraft_cloud_platform/configuration.py @@ -0,0 +1,596 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +import copy +import http.client as httplib +import logging +from logging import FileHandler +import multiprocessing +import sys +from typing import Any, ClassVar, Dict, List, Literal, Optional, TypedDict, Union +from typing_extensions import NotRequired, Self + +import urllib3 + + +JSON_SCHEMA_VALIDATION_KEYWORDS = { + "multipleOf", + "maximum", + "exclusiveMaximum", + "minimum", + "exclusiveMinimum", + "maxLength", + "minLength", + "pattern", + "maxItems", + "minItems", +} + +ServerVariablesT = Dict[str, str] + +GenericAuthSetting = TypedDict( + "GenericAuthSetting", + { + "type": str, + "in": str, + "key": str, + "value": str, + }, +) + + +OAuth2AuthSetting = TypedDict( + "OAuth2AuthSetting", + { + "type": Literal["oauth2"], + "in": Literal["header"], + "key": Literal["Authorization"], + "value": str, + }, +) + + +APIKeyAuthSetting = TypedDict( + "APIKeyAuthSetting", + { + "type": Literal["api_key"], + "in": str, + "key": str, + "value": Optional[str], + }, +) + + +BasicAuthSetting = TypedDict( + "BasicAuthSetting", + { + "type": Literal["basic"], + "in": Literal["header"], + "key": Literal["Authorization"], + "value": Optional[str], + }, +) + + +BearerFormatAuthSetting = TypedDict( + "BearerFormatAuthSetting", + { + "type": Literal["bearer"], + "in": Literal["header"], + "format": Literal["JWT"], + "key": Literal["Authorization"], + "value": str, + }, +) + + +BearerAuthSetting = TypedDict( + "BearerAuthSetting", + { + "type": Literal["bearer"], + "in": Literal["header"], + "key": Literal["Authorization"], + "value": str, + }, +) + + +HTTPSignatureAuthSetting = TypedDict( + "HTTPSignatureAuthSetting", + { + "type": Literal["http-signature"], + "in": Literal["header"], + "key": Literal["Authorization"], + "value": None, + }, +) + + +AuthSettings = TypedDict( + "AuthSettings", + { + "bearerAuth": BearerFormatAuthSetting, + }, + total=False, +) + + +class HostSettingVariable(TypedDict): + description: str + default_value: str + enum_values: List[str] + + +class HostSetting(TypedDict): + url: str + description: str + variables: NotRequired[Dict[str, HostSettingVariable]] + + +class Configuration: + """This class contains various settings of the API client. + + :param host: Base url. + :param ignore_operation_servers + Boolean to ignore operation servers for the API client. + Config will use `host` as the base url regardless of the operation servers. + :param api_key: Dict to store API key(s). + Each entry in the dict specifies an API key. + The dict key is the name of the security scheme in the OAS specification. + The dict value is the API key secret. + :param api_key_prefix: Dict to store API prefix (e.g. Bearer). + The dict key is the name of the security scheme in the OAS specification. + The dict value is an API key prefix when generating the auth data. + :param username: Username for HTTP basic authentication. + :param password: Password for HTTP basic authentication. + :param access_token: Access token. + :param server_index: Index to servers configuration. + :param server_variables: Mapping with string values to replace variables in + templated server configuration. The validation of enums is performed for + variables with defined enum values before. + :param server_operation_index: Mapping from operation ID to an index to server + configuration. + :param server_operation_variables: Mapping from operation ID to a mapping with + string values to replace variables in templated server configuration. + The validation of enums is performed for variables with defined enum + values before. + :param ssl_ca_cert: str - the path to a file of concatenated CA certificates + in PEM format. + :param retries: Number of retries for API requests. + :param ca_cert_data: verify the peer using concatenated CA certificate data + in PEM (str) or DER (bytes) format. + :param cert_file: the path to a client certificate file, for mTLS. + :param key_file: the path to a client key file, for mTLS. + + :Example: + """ + + _default: ClassVar[Optional[Self]] = None + + def __init__( + self, + host: Optional[str] = None, + api_key: Optional[Dict[str, str]] = None, + api_key_prefix: Optional[Dict[str, str]] = None, + username: Optional[str] = None, + password: Optional[str] = None, + access_token: Optional[str] = None, + server_index: Optional[int] = None, + server_variables: Optional[ServerVariablesT] = None, + server_operation_index: Optional[Dict[int, int]] = None, + server_operation_variables: Optional[Dict[int, ServerVariablesT]] = None, + ignore_operation_servers: bool = False, + ssl_ca_cert: Optional[str] = None, + retries: Optional[int] = None, + ca_cert_data: Optional[Union[str, bytes]] = None, + cert_file: Optional[str] = None, + key_file: Optional[str] = None, + *, + debug: Optional[bool] = None, + ) -> None: + """Constructor""" + self._base_path = "https://api.fra0.kraft.cloud/v1" if host is None else host + """Default Base url + """ + self.server_index = 0 if server_index is None and host is None else server_index + self.server_operation_index = server_operation_index or {} + """Default server index + """ + self.server_variables = server_variables or {} + self.server_operation_variables = server_operation_variables or {} + """Default server variables + """ + self.ignore_operation_servers = ignore_operation_servers + """Ignore operation servers + """ + self.temp_folder_path = None + """Temp file folder for downloading files + """ + # Authentication Settings + self.api_key = {} + if api_key: + self.api_key = api_key + """dict to store API key(s) + """ + self.api_key_prefix = {} + if api_key_prefix: + self.api_key_prefix = api_key_prefix + """dict to store API prefix (e.g. Bearer) + """ + self.refresh_api_key_hook = None + """function hook to refresh API key if expired + """ + self.username = username + """Username for HTTP basic authentication + """ + self.password = password + """Password for HTTP basic authentication + """ + self.access_token = access_token + """Access token + """ + self.logger = {} + """Logging Settings + """ + self.logger["package_logger"] = logging.getLogger("unikraft_cloud_platform") + self.logger["urllib3_logger"] = logging.getLogger("urllib3") + self.logger_format = "%(asctime)s %(levelname)s %(message)s" + """Log format + """ + self.logger_stream_handler = None + """Log stream handler + """ + self.logger_file_handler: Optional[FileHandler] = None + """Log file handler + """ + self.logger_file = None + """Debug file location + """ + if debug is not None: + self.debug = debug + else: + self.__debug = False + """Debug switch + """ + + self.verify_ssl = True + """SSL/TLS verification + Set this to false to skip verifying SSL certificate when calling API + from https server. + """ + self.ssl_ca_cert = ssl_ca_cert + """Set this to customize the certificate file to verify the peer. + """ + self.ca_cert_data = ca_cert_data + """Set this to verify the peer using PEM (str) or DER (bytes) + certificate data. + """ + self.cert_file = cert_file + """client certificate file + """ + self.key_file = key_file + """client key file + """ + self.assert_hostname = None + """Set this to True/False to enable/disable SSL hostname verification. + """ + self.tls_server_name = None + """SSL/TLS Server Name Indication (SNI) + Set this to the SNI value expected by the server. + """ + + self.connection_pool_maxsize = multiprocessing.cpu_count() * 5 + """urllib3 connection pool's maximum number of connections saved + per pool. urllib3 uses 1 connection as default value, but this is + not the best value when you are making a lot of possibly parallel + requests to the same host, which is often the case here. + cpu_count * 5 is used as default value to increase performance. + """ + + self.proxy: Optional[str] = None + """Proxy URL + """ + self.proxy_headers = None + """Proxy headers + """ + self.safe_chars_for_path_param = "" + """Safe chars for path_param + """ + self.retries = retries + """Adding retries to override urllib3 default value 3 + """ + # Enable client side validation + self.client_side_validation = True + + self.socket_options = None + """Options to pass down to the underlying urllib3 socket + """ + + self.datetime_format = "%Y-%m-%dT%H:%M:%S.%f%z" + """datetime format + """ + + self.date_format = "%Y-%m-%d" + """date format + """ + + def __deepcopy__(self, memo: Dict[int, Any]) -> Self: + cls = self.__class__ + result = cls.__new__(cls) + memo[id(self)] = result + for k, v in self.__dict__.items(): + if k not in ("logger", "logger_file_handler"): + setattr(result, k, copy.deepcopy(v, memo)) + # shallow copy of loggers + result.logger = copy.copy(self.logger) + # use setters to configure loggers + result.logger_file = self.logger_file + result.debug = self.debug + return result + + def __setattr__(self, name: str, value: Any) -> None: + object.__setattr__(self, name, value) + + @classmethod + def set_default(cls, default: Optional[Self]) -> None: + """Set default instance of configuration. + + It stores default configuration, which can be + returned by get_default_copy method. + + :param default: object of Configuration + """ + cls._default = default + + @classmethod + def get_default_copy(cls) -> Self: + """Deprecated. Please use `get_default` instead. + + Deprecated. Please use `get_default` instead. + + :return: The configuration object. + """ + return cls.get_default() + + @classmethod + def get_default(cls) -> Self: + """Return the default configuration. + + This method returns newly created, based on default constructor, + object of Configuration class or returns a copy of default + configuration. + + :return: The configuration object. + """ + if cls._default is None: + cls._default = cls() + return cls._default + + @property + def logger_file(self) -> Optional[str]: + """The logger file. + + If the logger_file is None, then add stream handler and remove file + handler. Otherwise, add file handler and remove stream handler. + + :param value: The logger_file path. + :type: str + """ + return self.__logger_file + + @logger_file.setter + def logger_file(self, value: Optional[str]) -> None: + """The logger file. + + If the logger_file is None, then add stream handler and remove file + handler. Otherwise, add file handler and remove stream handler. + + :param value: The logger_file path. + :type: str + """ + self.__logger_file = value + if self.__logger_file: + # If set logging file, + # then add file handler and remove stream handler. + self.logger_file_handler = logging.FileHandler(self.__logger_file) + self.logger_file_handler.setFormatter(self.logger_formatter) + for _, logger in self.logger.items(): + logger.addHandler(self.logger_file_handler) + + @property + def debug(self) -> bool: + """Debug status + + :param value: The debug status, True or False. + :type: bool + """ + return self.__debug + + @debug.setter + def debug(self, value: bool) -> None: + """Debug status + + :param value: The debug status, True or False. + :type: bool + """ + self.__debug = value + if self.__debug: + # if debug status is True, turn on debug logging + for _, logger in self.logger.items(): + logger.setLevel(logging.DEBUG) + # turn on httplib debug + httplib.HTTPConnection.debuglevel = 1 + else: + # if debug status is False, turn off debug logging, + # setting log level to default `logging.WARNING` + for _, logger in self.logger.items(): + logger.setLevel(logging.WARNING) + # turn off httplib debug + httplib.HTTPConnection.debuglevel = 0 + + @property + def logger_format(self) -> str: + """The logger format. + + The logger_formatter will be updated when sets logger_format. + + :param value: The format string. + :type: str + """ + return self.__logger_format + + @logger_format.setter + def logger_format(self, value: str) -> None: + """The logger format. + + The logger_formatter will be updated when sets logger_format. + + :param value: The format string. + :type: str + """ + self.__logger_format = value + self.logger_formatter = logging.Formatter(self.__logger_format) + + def get_api_key_with_prefix(self, identifier: str, alias: Optional[str] = None) -> Optional[str]: + """Gets API key (with prefix if set). + + :param identifier: The identifier of apiKey. + :param alias: The alternative identifier of apiKey. + :return: The token for api key authentication. + """ + if self.refresh_api_key_hook is not None: + self.refresh_api_key_hook(self) + key = self.api_key.get(identifier, self.api_key.get(alias) if alias is not None else None) + if key: + prefix = self.api_key_prefix.get(identifier) + if prefix: + return "%s %s" % (prefix, key) + else: + return key + + return None + + def get_basic_auth_token(self) -> Optional[str]: + """Gets HTTP basic authentication header (string). + + :return: The token for basic HTTP authentication. + """ + username = "" + if self.username is not None: + username = self.username + password = "" + if self.password is not None: + password = self.password + return urllib3.util.make_headers(basic_auth=username + ":" + password).get("authorization") + + def auth_settings(self) -> AuthSettings: + """Gets Auth Settings dict for api client. + + :return: The Auth Settings information dict. + """ + auth: AuthSettings = {} + if self.access_token is not None: + auth["bearerAuth"] = { + "type": "bearer", + "in": "header", + "format": "base64", + "key": "Authorization", + "value": "Bearer " + self.access_token, + } + return auth + + def to_debug_report(self) -> str: + """Gets the essential information for debugging. + + :return: The report for debugging. + """ + return ( + "Python SDK Debug Report:\n" + "OS: {env}\n" + "Python Version: {pyversion}\n" + "Version of the API: 0.6.0\n" + "SDK Package Version: 0.6.0".format(env=sys.platform, pyversion=sys.version) + ) + + def get_host_settings(self) -> List[HostSetting]: + """Gets an array of host settings + + :return: An array of host settings + """ + return [ + { + "url": "https://api.{metro}.kraft.cloud/v1", + "description": "The Unikraft Cloud Platform API server", + "variables": { + "metro": { + "description": "No description provided", + "default_value": "fra0", + "enum_values": ["fra0", "sin0", "dal0", "was1"], + } + }, + } + ] + + def get_host_from_settings( + self, + index: Optional[int], + variables: Optional[ServerVariablesT] = None, + servers: Optional[List[HostSetting]] = None, + ) -> str: + """Gets host URL based on the index and variables + :param index: array index of the host settings + :param variables: hash of variable and the corresponding value + :param servers: an array of host settings or None + :return: URL based on host settings + """ + if index is None: + return self._base_path + + variables = {} if variables is None else variables + servers = self.get_host_settings() if servers is None else servers + + try: + server = servers[index] + except IndexError: + raise ValueError( + "Invalid index {0} when selecting the host settings. Must be less than {1}".format(index, len(servers)) + ) + + url = server["url"] + + # go through variables and replace placeholders + for variable_name, variable in server.get("variables", {}).items(): + used_value = variables.get(variable_name, variable["default_value"]) + + if "enum_values" in variable and used_value not in variable["enum_values"]: + raise ValueError( + "The variable `{0}` in the host URL has invalid value {1}. Must be {2}.".format( + variable_name, variables[variable_name], variable["enum_values"] + ) + ) + + url = url.replace("{" + variable_name + "}", used_value) + + return url + + @property + def host(self) -> str: + """Return generated host.""" + return self.get_host_from_settings(self.server_index, variables=self.server_variables) + + @host.setter + def host(self, value: str) -> None: + """Fix base path.""" + self._base_path = value + self.server_index = None diff --git a/unikraft_cloud_platform/errors.py b/unikraft_cloud_platform/errors.py deleted file mode 100644 index 5f92e76..0000000 --- a/unikraft_cloud_platform/errors.py +++ /dev/null @@ -1,16 +0,0 @@ -"""Contains shared errors types that can be raised from API functions""" - - -class UnexpectedStatus(Exception): - """Raised by api functions when the response status an undocumented status and Client.raise_on_unexpected_status is True""" - - def __init__(self, status_code: int, content: bytes): - self.status_code = status_code - self.content = content - - super().__init__( - f"Unexpected status code: {status_code}\n\nResponse content:\n{content.decode(errors='ignore')}" - ) - - -__all__ = ["UnexpectedStatus"] diff --git a/unikraft_cloud_platform/exceptions.py b/unikraft_cloud_platform/exceptions.py new file mode 100644 index 0000000..b5ff293 --- /dev/null +++ b/unikraft_cloud_platform/exceptions.py @@ -0,0 +1,216 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from typing import Any, Optional +from typing_extensions import Self + + +class OpenApiException(Exception): + """The base exception class for all OpenAPIExceptions""" + + +class ApiTypeError(OpenApiException, TypeError): + def __init__(self, msg, path_to_item=None, valid_classes=None, key_type=None) -> None: + """Raises an exception for TypeErrors + + Args: + msg (str): the exception message + + Keyword Args: + path_to_item (list): a list of keys an indices to get to the + current_item + None if unset + valid_classes (tuple): the primitive classes that current item + should be an instance of + None if unset + key_type (bool): False if our value is a value in a dict + True if it is a key in a dict + False if our item is an item in a list + None if unset + """ + self.path_to_item = path_to_item + self.valid_classes = valid_classes + self.key_type = key_type + full_msg = msg + if path_to_item: + full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) + super(ApiTypeError, self).__init__(full_msg) + + +class ApiValueError(OpenApiException, ValueError): + def __init__(self, msg, path_to_item=None) -> None: + """ + Args: + msg (str): the exception message + + Keyword Args: + path_to_item (list) the path to the exception in the + received_data dict. None if unset + """ + + self.path_to_item = path_to_item + full_msg = msg + if path_to_item: + full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) + super(ApiValueError, self).__init__(full_msg) + + +class ApiAttributeError(OpenApiException, AttributeError): + def __init__(self, msg, path_to_item=None) -> None: + """ + Raised when an attribute reference or assignment fails. + + Args: + msg (str): the exception message + + Keyword Args: + path_to_item (None/list) the path to the exception in the + received_data dict + """ + self.path_to_item = path_to_item + full_msg = msg + if path_to_item: + full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) + super(ApiAttributeError, self).__init__(full_msg) + + +class ApiKeyError(OpenApiException, KeyError): + def __init__(self, msg, path_to_item=None) -> None: + """ + Args: + msg (str): the exception message + + Keyword Args: + path_to_item (None/list) the path to the exception in the + received_data dict + """ + self.path_to_item = path_to_item + full_msg = msg + if path_to_item: + full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) + super(ApiKeyError, self).__init__(full_msg) + + +class ApiException(OpenApiException): + def __init__( + self, + status=None, + reason=None, + http_resp=None, + *, + body: Optional[str] = None, + data: Optional[Any] = None, + ) -> None: + self.status = status + self.reason = reason + self.body = body + self.data = data + self.headers = None + + if http_resp: + if self.status is None: + self.status = http_resp.status + if self.reason is None: + self.reason = http_resp.reason + if self.body is None: + try: + self.body = http_resp.data.decode("utf-8") + except Exception: + pass + self.headers = http_resp.getheaders() + + @classmethod + def from_response( + cls, + *, + http_resp, + body: Optional[str], + data: Optional[Any], + ) -> Self: + if http_resp.status == 400: + raise BadRequestException(http_resp=http_resp, body=body, data=data) + + if http_resp.status == 401: + raise UnauthorizedException(http_resp=http_resp, body=body, data=data) + + if http_resp.status == 403: + raise ForbiddenException(http_resp=http_resp, body=body, data=data) + + if http_resp.status == 404: + raise NotFoundException(http_resp=http_resp, body=body, data=data) + + # Added new conditions for 409 and 422 + if http_resp.status == 409: + raise ConflictException(http_resp=http_resp, body=body, data=data) + + if http_resp.status == 422: + raise UnprocessableEntityException(http_resp=http_resp, body=body, data=data) + + if 500 <= http_resp.status <= 599: + raise ServiceException(http_resp=http_resp, body=body, data=data) + raise ApiException(http_resp=http_resp, body=body, data=data) + + def __str__(self): + """Custom error messages for exception""" + error_message = "({0})\nReason: {1}\n".format(self.status, self.reason) + if self.headers: + error_message += "HTTP response headers: {0}\n".format(self.headers) + + if self.data or self.body: + error_message += "HTTP response body: {0}\n".format(self.data or self.body) + + return error_message + + +class BadRequestException(ApiException): + pass + + +class NotFoundException(ApiException): + pass + + +class UnauthorizedException(ApiException): + pass + + +class ForbiddenException(ApiException): + pass + + +class ServiceException(ApiException): + pass + + +class ConflictException(ApiException): + """Exception for HTTP 409 Conflict.""" + + pass + + +class UnprocessableEntityException(ApiException): + """Exception for HTTP 422 Unprocessable Entity.""" + + pass + + +def render_path(path_to_item): + """Returns a string representation of a path""" + result = "" + for pth in path_to_item: + if isinstance(pth, int): + result += "[{0}]".format(pth) + else: + result += "['{0}']".format(pth) + return result diff --git a/unikraft_cloud_platform/models/__init__.py b/unikraft_cloud_platform/models/__init__.py index 3f54983..3944512 100644 --- a/unikraft_cloud_platform/models/__init__.py +++ b/unikraft_cloud_platform/models/__init__.py @@ -1,367 +1,214 @@ -"""Contains all the data models used in inputs/outputs""" +# coding: utf-8 -from .attach_volume_by_uuid_request_body import AttachVolumeByUUIDRequestBody -from .attach_volumes_request import AttachVolumesRequest -from .attach_volumes_request_instance_id import AttachVolumesRequestInstanceID -from .attach_volumes_response import AttachVolumesResponse -from .attach_volumes_response_attached_volume import AttachVolumesResponseAttachedVolume -from .attach_volumes_response_data import AttachVolumesResponseData -from .autoscale_policy import AutoscalePolicy -from .autoscale_policy_adjustment_type import AutoscalePolicyAdjustmentType -from .autoscale_policy_metric import AutoscalePolicyMetric -from .autoscale_policy_step import AutoscalePolicyStep -from .body_instance_id import BodyInstanceID -from .certificate import Certificate -from .certificate_state import CertificateState -from .configuration_instance_create_args import ConfigurationInstanceCreateArgs -from .create_autoscale_configuration_by_service_group_uuid_request import ( - CreateAutoscaleConfigurationByServiceGroupUUIDRequest, +# flake8: noqa +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +# import models into model package +from unikraft_cloud_platform.models.autoscale_config import AutoscaleConfig +from unikraft_cloud_platform.models.autoscale_config_master import AutoscaleConfigMaster +from unikraft_cloud_platform.models.autoscale_policy import AutoscalePolicy +from unikraft_cloud_platform.models.autoscale_policy_step import AutoscalePolicyStep +from unikraft_cloud_platform.models.certificate import Certificate +from unikraft_cloud_platform.models.certificate_service_groups_inner import CertificateServiceGroupsInner +from unikraft_cloud_platform.models.certificate_validation import CertificateValidation +from unikraft_cloud_platform.models.create_autoscale_config200_response import CreateAutoscaleConfig200Response +from unikraft_cloud_platform.models.create_autoscale_config200_response_data import CreateAutoscaleConfig200ResponseData +from unikraft_cloud_platform.models.create_autoscale_config200_response_data_certificates_inner import ( + CreateAutoscaleConfig200ResponseDataCertificatesInner, ) -from .create_autoscale_configuration_by_service_group_uuid_request_instance_create_args import ( - CreateAutoscaleConfigurationByServiceGroupUUIDRequestInstanceCreateArgs, +from unikraft_cloud_platform.models.create_autoscale_config_request import CreateAutoscaleConfigRequest +from unikraft_cloud_platform.models.create_autoscale_config_request_master import CreateAutoscaleConfigRequestMaster +from unikraft_cloud_platform.models.create_autoscale_policy200_response import CreateAutoscalePolicy200Response +from unikraft_cloud_platform.models.create_autoscale_policy200_response_data import CreateAutoscalePolicy200ResponseData +from unikraft_cloud_platform.models.create_autoscale_policy200_response_data_certificates_inner import ( + CreateAutoscalePolicy200ResponseDataCertificatesInner, ) -from .create_autoscale_configuration_policy_request import CreateAutoscaleConfigurationPolicyRequest -from .create_autoscale_configuration_policy_response import CreateAutoscaleConfigurationPolicyResponse -from .create_autoscale_configuration_policy_response_data import CreateAutoscaleConfigurationPolicyResponseData -from .create_autoscale_configuration_policy_response_policy import CreateAutoscaleConfigurationPolicyResponsePolicy -from .create_autoscale_configurations_request_configuration import CreateAutoscaleConfigurationsRequestConfiguration -from .create_autoscale_configurations_response import CreateAutoscaleConfigurationsResponse -from .create_autoscale_configurations_response_configurations_response import ( - CreateAutoscaleConfigurationsResponseConfigurationsResponse, +from unikraft_cloud_platform.models.create_autoscale_policy_request import CreateAutoscalePolicyRequest +from unikraft_cloud_platform.models.create_certificate200_response import CreateCertificate200Response +from unikraft_cloud_platform.models.create_certificate200_response_data import CreateCertificate200ResponseData +from unikraft_cloud_platform.models.create_certificate200_response_data_certificates_inner import ( + CreateCertificate200ResponseDataCertificatesInner, ) -from .create_autoscale_configurations_response_data import CreateAutoscaleConfigurationsResponseData -from .create_certificate_request import CreateCertificateRequest -from .create_certificate_response import CreateCertificateResponse -from .create_certificate_response_data import CreateCertificateResponseData -from .create_instance_request import CreateInstanceRequest -from .create_instance_request_domain import CreateInstanceRequestDomain -from .create_instance_request_env import CreateInstanceRequestEnv -from .create_instance_request_features_item import CreateInstanceRequestFeaturesItem -from .create_instance_request_restart_policy import CreateInstanceRequestRestartPolicy -from .create_instance_request_service_group import CreateInstanceRequestServiceGroup -from .create_instance_request_volume import CreateInstanceRequestVolume -from .create_instance_response import CreateInstanceResponse -from .create_instance_response_data import CreateInstanceResponseData -from .create_service_group_request import CreateServiceGroupRequest -from .create_service_group_request_domain import CreateServiceGroupRequestDomain -from .create_service_group_response import CreateServiceGroupResponse -from .create_service_group_response_data import CreateServiceGroupResponseData -from .create_volume_request import CreateVolumeRequest -from .create_volume_response import CreateVolumeResponse -from .create_volume_response_data import CreateVolumeResponseData -from .create_volume_response_volume import CreateVolumeResponseVolume -from .delete_autoscale_configuration_policy_response import DeleteAutoscaleConfigurationPolicyResponse -from .delete_autoscale_configuration_policy_response_data import DeleteAutoscaleConfigurationPolicyResponseData -from .delete_autoscale_configuration_policy_response_policies_response import ( - DeleteAutoscaleConfigurationPolicyResponsePoliciesResponse, +from unikraft_cloud_platform.models.create_certificate_request import CreateCertificateRequest +from unikraft_cloud_platform.models.create_instance200_response import CreateInstance200Response +from unikraft_cloud_platform.models.create_instance_request import CreateInstanceRequest +from unikraft_cloud_platform.models.create_instance_request_env import CreateInstanceRequestEnv +from unikraft_cloud_platform.models.create_instance_request_scale_to_zero import CreateInstanceRequestScaleToZero +from unikraft_cloud_platform.models.create_instance_request_service_group import CreateInstanceRequestServiceGroup +from unikraft_cloud_platform.models.create_instance_request_service_group_domains_inner import ( + CreateInstanceRequestServiceGroupDomainsInner, ) -from .delete_autoscale_configurations_response import DeleteAutoscaleConfigurationsResponse -from .delete_autoscale_configurations_response_data import DeleteAutoscaleConfigurationsResponseData -from .delete_autoscale_configurations_response_service_group import DeleteAutoscaleConfigurationsResponseServiceGroup -from .delete_certificates_response import DeleteCertificatesResponse -from .delete_certificates_response_data import DeleteCertificatesResponseData -from .delete_certificates_response_deleted_certificate import DeleteCertificatesResponseDeletedCertificate -from .delete_instances_response import DeleteInstancesResponse -from .delete_instances_response_data import DeleteInstancesResponseData -from .delete_instances_response_deleted_instance import DeleteInstancesResponseDeletedInstance -from .delete_policy_request import DeletePolicyRequest -from .delete_service_groups_response import DeleteServiceGroupsResponse -from .delete_service_groups_response_data import DeleteServiceGroupsResponseData -from .delete_service_groups_response_deleted_service_group import DeleteServiceGroupsResponseDeletedServiceGroup -from .delete_volumes_response import DeleteVolumesResponse -from .delete_volumes_response_data import DeleteVolumesResponseData -from .delete_volumes_response_deleted_volume import DeleteVolumesResponseDeletedVolume -from .detach_volume_by_uuid_request_body import DetachVolumeByUUIDRequestBody -from .detach_volumes_request import DetachVolumesRequest -from .detach_volumes_request_instance_id import DetachVolumesRequestInstanceID -from .detach_volumes_response import DetachVolumesResponse -from .detach_volumes_response_data import DetachVolumesResponseData -from .detach_volumes_response_detached_volume import DetachVolumesResponseDetachedVolume -from .domain import Domain -from .get_autoscale_configuration_policy_request import GetAutoscaleConfigurationPolicyRequest -from .get_autoscale_configuration_policy_response import GetAutoscaleConfigurationPolicyResponse -from .get_autoscale_configuration_policy_response_data import GetAutoscaleConfigurationPolicyResponseData -from .get_autoscale_configuration_policy_response_policy_response import ( - GetAutoscaleConfigurationPolicyResponsePolicyResponse, +from unikraft_cloud_platform.models.create_instance_request_volumes_inner import CreateInstanceRequestVolumesInner +from unikraft_cloud_platform.models.create_services200_response import CreateServices200Response +from unikraft_cloud_platform.models.create_services200_response_data import CreateServices200ResponseData +from unikraft_cloud_platform.models.create_services200_response_data_service_groups_inner import ( + CreateServices200ResponseDataServiceGroupsInner, ) -from .get_autoscale_configurations_response import GetAutoscaleConfigurationsResponse -from .get_autoscale_configurations_response_data import GetAutoscaleConfigurationsResponseData -from .get_autoscale_configurations_response_service_group import GetAutoscaleConfigurationsResponseServiceGroup -from .get_autoscale_configurations_response_status import GetAutoscaleConfigurationsResponseStatus -from .get_certificates_response import GetCertificatesResponse -from .get_certificates_response_data import GetCertificatesResponseData -from .get_image_response import GetImageResponse -from .get_image_response_data import GetImageResponseData -from .get_instance_logs_by_uuid_request_body import GetInstanceLogsByUUIDRequestBody -from .get_instance_logs_request import GetInstanceLogsRequest -from .get_instance_logs_response import GetInstanceLogsResponse -from .get_instance_logs_response_available import GetInstanceLogsResponseAvailable -from .get_instance_logs_response_data import GetInstanceLogsResponseData -from .get_instance_logs_response_logged_instance import GetInstanceLogsResponseLoggedInstance -from .get_instance_logs_response_logged_instance_state import GetInstanceLogsResponseLoggedInstanceState -from .get_instance_logs_response_range import GetInstanceLogsResponseRange -from .get_instance_metrics_response import GetInstanceMetricsResponse -from .get_instance_metrics_response_data import GetInstanceMetricsResponseData -from .get_instance_metrics_response_instance_metrics import GetInstanceMetricsResponseInstanceMetrics -from .get_instances_response import GetInstancesResponse -from .get_instances_response_data import GetInstancesResponseData -from .get_service_groups_response import GetServiceGroupsResponse -from .get_service_groups_response_data import GetServiceGroupsResponseData -from .get_volumes_response import GetVolumesResponse -from .get_volumes_response_data import GetVolumesResponseData -from .healthz_response import HealthzResponse -from .healthz_response_data import HealthzResponseData -from .healthz_response_data_services import HealthzResponseDataServices -from .image import Image -from .image_labels import ImageLabels -from .instance import Instance -from .instance_create_args_instance_create_request_roms import InstanceCreateArgsInstanceCreateRequestRoms -from .instance_env import InstanceEnv -from .instance_instance_service_group import InstanceInstanceServiceGroup -from .instance_instance_volume import InstanceInstanceVolume -from .instance_network_interface import InstanceNetworkInterface -from .instance_restart_policy import InstanceRestartPolicy -from .instance_scale_to_zero import InstanceScaleToZero -from .instance_scale_to_zero_policy import InstanceScaleToZeroPolicy -from .instance_service_group_instance_domain import InstanceServiceGroupInstanceDomain -from .instance_state import InstanceState -from .name_or_uuid import NameOrUUID -from .object_ import Object -from .quotas import Quotas -from .quotas_limits import QuotasLimits -from .quotas_response import QuotasResponse -from .quotas_response_data import QuotasResponseData -from .quotas_stats import QuotasStats -from .response_error import ResponseError -from .response_status import ResponseStatus -from .service import Service -from .service_group import ServiceGroup -from .service_group_instance import ServiceGroupInstance -from .service_group_template import ServiceGroupTemplate -from .service_handlers_item import ServiceHandlersItem -from .start_instance_response import StartInstanceResponse -from .start_instance_response_data import StartInstanceResponseData -from .start_instance_response_started_instance import StartInstanceResponseStartedInstance -from .stop_instance_response import StopInstanceResponse -from .stop_instance_response_data import StopInstanceResponseData -from .stop_instance_response_stopped_instance import StopInstanceResponseStoppedInstance -from .stop_instance_response_stopped_instance_previous_state import StopInstanceResponseStoppedInstancePreviousState -from .stop_instance_response_stopped_instance_state import StopInstanceResponseStoppedInstanceState -from .stop_instances_request_id import StopInstancesRequestID -from .update_instance_by_uuid_request_body import UpdateInstanceByUUIDRequestBody -from .update_instance_by_uuid_request_body_op import UpdateInstanceByUUIDRequestBodyOp -from .update_instance_by_uuid_request_body_prop import UpdateInstanceByUUIDRequestBodyProp -from .update_instances_request import UpdateInstancesRequest -from .update_instances_request_op import UpdateInstancesRequestOp -from .update_instances_request_prop import UpdateInstancesRequestProp -from .update_instances_response import UpdateInstancesResponse -from .update_instances_response_data import UpdateInstancesResponseData -from .update_instances_response_updated_instance import UpdateInstancesResponseUpdatedInstance -from .update_service_group_by_uuid_request_body import UpdateServiceGroupByUUIDRequestBody -from .update_service_group_by_uuid_request_body_op import UpdateServiceGroupByUUIDRequestBodyOp -from .update_service_group_by_uuid_request_body_prop import UpdateServiceGroupByUUIDRequestBodyProp -from .update_service_groups_request_item import UpdateServiceGroupsRequestItem -from .update_service_groups_request_item_op import UpdateServiceGroupsRequestItemOp -from .update_service_groups_request_item_prop import UpdateServiceGroupsRequestItemProp -from .update_service_groups_response import UpdateServiceGroupsResponse -from .update_service_groups_response_data import UpdateServiceGroupsResponseData -from .update_service_groups_response_updated_service_group import UpdateServiceGroupsResponseUpdatedServiceGroup -from .update_volume_by_uuid_request_body import UpdateVolumeByUUIDRequestBody -from .update_volume_by_uuid_request_body_op import UpdateVolumeByUUIDRequestBodyOp -from .update_volume_by_uuid_request_body_prop import UpdateVolumeByUUIDRequestBodyProp -from .update_volumes_request_item import UpdateVolumesRequestItem -from .update_volumes_request_item_op import UpdateVolumesRequestItemOp -from .update_volumes_request_item_prop import UpdateVolumesRequestItemProp -from .update_volumes_response import UpdateVolumesResponse -from .update_volumes_response_data import UpdateVolumesResponseData -from .update_volumes_response_updated_volume import UpdateVolumesResponseUpdatedVolume -from .volume import Volume -from .volume_instance_id import VolumeInstanceID -from .volume_state import VolumeState -from .volume_volume_instance_mount import VolumeVolumeInstanceMount -from .wait_instance_by_uuid_request_body import WaitInstanceByUUIDRequestBody -from .wait_instance_by_uuid_request_body_state import WaitInstanceByUUIDRequestBodyState -from .wait_instance_response import WaitInstanceResponse -from .wait_instance_response_data import WaitInstanceResponseData -from .wait_instance_response_waited_instance import WaitInstanceResponseWaitedInstance -from .wait_instance_response_waited_instance_state import WaitInstanceResponseWaitedInstanceState -from .wait_instances_state import WaitInstancesState - -__all__ = ( - "AttachVolumeByUUIDRequestBody", - "AttachVolumesRequest", - "AttachVolumesRequestInstanceID", - "AttachVolumesResponse", - "AttachVolumesResponseAttachedVolume", - "AttachVolumesResponseData", - "AutoscalePolicy", - "AutoscalePolicyAdjustmentType", - "AutoscalePolicyMetric", - "AutoscalePolicyStep", - "BodyInstanceID", - "Certificate", - "CertificateState", - "ConfigurationInstanceCreateArgs", - "CreateAutoscaleConfigurationByServiceGroupUUIDRequest", - "CreateAutoscaleConfigurationByServiceGroupUUIDRequestInstanceCreateArgs", - "CreateAutoscaleConfigurationPolicyRequest", - "CreateAutoscaleConfigurationPolicyResponse", - "CreateAutoscaleConfigurationPolicyResponseData", - "CreateAutoscaleConfigurationPolicyResponsePolicy", - "CreateAutoscaleConfigurationsRequestConfiguration", - "CreateAutoscaleConfigurationsResponse", - "CreateAutoscaleConfigurationsResponseConfigurationsResponse", - "CreateAutoscaleConfigurationsResponseData", - "CreateCertificateRequest", - "CreateCertificateResponse", - "CreateCertificateResponseData", - "CreateInstanceRequest", - "CreateInstanceRequestDomain", - "CreateInstanceRequestEnv", - "CreateInstanceRequestFeaturesItem", - "CreateInstanceRequestRestartPolicy", - "CreateInstanceRequestServiceGroup", - "CreateInstanceRequestVolume", - "CreateInstanceResponse", - "CreateInstanceResponseData", - "CreateServiceGroupRequest", - "CreateServiceGroupRequestDomain", - "CreateServiceGroupResponse", - "CreateServiceGroupResponseData", - "CreateVolumeRequest", - "CreateVolumeResponse", - "CreateVolumeResponseData", - "CreateVolumeResponseVolume", - "DeleteAutoscaleConfigurationPolicyResponse", - "DeleteAutoscaleConfigurationPolicyResponseData", - "DeleteAutoscaleConfigurationPolicyResponsePoliciesResponse", - "DeleteAutoscaleConfigurationsResponse", - "DeleteAutoscaleConfigurationsResponseData", - "DeleteAutoscaleConfigurationsResponseServiceGroup", - "DeleteCertificatesResponse", - "DeleteCertificatesResponseData", - "DeleteCertificatesResponseDeletedCertificate", - "DeleteInstancesResponse", - "DeleteInstancesResponseData", - "DeleteInstancesResponseDeletedInstance", - "DeletePolicyRequest", - "DeleteServiceGroupsResponse", - "DeleteServiceGroupsResponseData", - "DeleteServiceGroupsResponseDeletedServiceGroup", - "DeleteVolumesResponse", - "DeleteVolumesResponseData", - "DeleteVolumesResponseDeletedVolume", - "DetachVolumeByUUIDRequestBody", - "DetachVolumesRequest", - "DetachVolumesRequestInstanceID", - "DetachVolumesResponse", - "DetachVolumesResponseData", - "DetachVolumesResponseDetachedVolume", - "Domain", - "GetAutoscaleConfigurationPolicyRequest", - "GetAutoscaleConfigurationPolicyResponse", - "GetAutoscaleConfigurationPolicyResponseData", - "GetAutoscaleConfigurationPolicyResponsePolicyResponse", - "GetAutoscaleConfigurationsResponse", - "GetAutoscaleConfigurationsResponseData", - "GetAutoscaleConfigurationsResponseServiceGroup", - "GetAutoscaleConfigurationsResponseStatus", - "GetCertificatesResponse", - "GetCertificatesResponseData", - "GetImageResponse", - "GetImageResponseData", - "GetInstanceLogsByUUIDRequestBody", - "GetInstanceLogsRequest", - "GetInstanceLogsResponse", - "GetInstanceLogsResponseAvailable", - "GetInstanceLogsResponseData", - "GetInstanceLogsResponseLoggedInstance", - "GetInstanceLogsResponseLoggedInstanceState", - "GetInstanceLogsResponseRange", - "GetInstanceMetricsResponse", - "GetInstanceMetricsResponseData", - "GetInstanceMetricsResponseInstanceMetrics", - "GetInstancesResponse", - "GetInstancesResponseData", - "GetServiceGroupsResponse", - "GetServiceGroupsResponseData", - "GetVolumesResponse", - "GetVolumesResponseData", - "HealthzResponse", - "HealthzResponseData", - "HealthzResponseDataServices", - "Image", - "ImageLabels", - "Instance", - "InstanceCreateArgsInstanceCreateRequestRoms", - "InstanceEnv", - "InstanceInstanceServiceGroup", - "InstanceInstanceVolume", - "InstanceNetworkInterface", - "InstanceRestartPolicy", - "InstanceScaleToZero", - "InstanceScaleToZeroPolicy", - "InstanceServiceGroupInstanceDomain", - "InstanceState", - "NameOrUUID", - "Object", - "Quotas", - "QuotasLimits", - "QuotasResponse", - "QuotasResponseData", - "QuotasStats", - "ResponseError", - "ResponseStatus", - "Service", - "ServiceGroup", - "ServiceGroupInstance", - "ServiceGroupTemplate", - "ServiceHandlersItem", - "StartInstanceResponse", - "StartInstanceResponseData", - "StartInstanceResponseStartedInstance", - "StopInstanceResponse", - "StopInstanceResponseData", - "StopInstanceResponseStoppedInstance", - "StopInstanceResponseStoppedInstancePreviousState", - "StopInstanceResponseStoppedInstanceState", - "StopInstancesRequestID", - "UpdateInstanceByUUIDRequestBody", - "UpdateInstanceByUUIDRequestBodyOp", - "UpdateInstanceByUUIDRequestBodyProp", - "UpdateInstancesRequest", - "UpdateInstancesRequestOp", - "UpdateInstancesRequestProp", - "UpdateInstancesResponse", - "UpdateInstancesResponseData", - "UpdateInstancesResponseUpdatedInstance", - "UpdateServiceGroupByUUIDRequestBody", - "UpdateServiceGroupByUUIDRequestBodyOp", - "UpdateServiceGroupByUUIDRequestBodyProp", - "UpdateServiceGroupsRequestItem", - "UpdateServiceGroupsRequestItemOp", - "UpdateServiceGroupsRequestItemProp", - "UpdateServiceGroupsResponse", - "UpdateServiceGroupsResponseData", - "UpdateServiceGroupsResponseUpdatedServiceGroup", - "UpdateVolumeByUUIDRequestBody", - "UpdateVolumeByUUIDRequestBodyOp", - "UpdateVolumeByUUIDRequestBodyProp", - "UpdateVolumesRequestItem", - "UpdateVolumesRequestItemOp", - "UpdateVolumesRequestItemProp", - "UpdateVolumesResponse", - "UpdateVolumesResponseData", - "UpdateVolumesResponseUpdatedVolume", - "Volume", - "VolumeInstanceID", - "VolumeState", - "VolumeVolumeInstanceMount", - "WaitInstanceByUUIDRequestBody", - "WaitInstanceByUUIDRequestBodyState", - "WaitInstanceResponse", - "WaitInstanceResponseData", - "WaitInstanceResponseWaitedInstance", - "WaitInstanceResponseWaitedInstanceState", - "WaitInstancesState", +from unikraft_cloud_platform.models.create_services200_response_data_service_groups_inner_domains_inner import ( + CreateServices200ResponseDataServiceGroupsInnerDomainsInner, +) +from unikraft_cloud_platform.models.create_services200_response_data_service_groups_inner_domains_inner_certificate import ( + CreateServices200ResponseDataServiceGroupsInnerDomainsInnerCertificate, +) +from unikraft_cloud_platform.models.create_services_request import CreateServicesRequest +from unikraft_cloud_platform.models.create_services_request_services_inner import CreateServicesRequestServicesInner +from unikraft_cloud_platform.models.create_services_request_services_inner_domains_inner import ( + CreateServicesRequestServicesInnerDomainsInner, +) +from unikraft_cloud_platform.models.create_services_request_services_inner_domains_inner_certificate import ( + CreateServicesRequestServicesInnerDomainsInnerCertificate, +) +from unikraft_cloud_platform.models.create_volumes200_response import CreateVolumes200Response +from unikraft_cloud_platform.models.create_volumes200_response_data import CreateVolumes200ResponseData +from unikraft_cloud_platform.models.create_volumes200_response_data_volumes_inner import ( + CreateVolumes200ResponseDataVolumesInner, +) +from unikraft_cloud_platform.models.create_volumes_request_inner import CreateVolumesRequestInner +from unikraft_cloud_platform.models.delete_autoscale_configs200_response import DeleteAutoscaleConfigs200Response +from unikraft_cloud_platform.models.delete_autoscale_configs200_response_data import ( + DeleteAutoscaleConfigs200ResponseData, +) +from unikraft_cloud_platform.models.delete_autoscale_configs200_response_data_service_groups_inner import ( + DeleteAutoscaleConfigs200ResponseDataServiceGroupsInner, +) +from unikraft_cloud_platform.models.delete_autoscale_policies200_response import DeleteAutoscalePolicies200Response +from unikraft_cloud_platform.models.delete_autoscale_policies200_response_data import ( + DeleteAutoscalePolicies200ResponseData, +) +from unikraft_cloud_platform.models.delete_autoscale_policies200_response_data_policies_inner import ( + DeleteAutoscalePolicies200ResponseDataPoliciesInner, +) +from unikraft_cloud_platform.models.delete_autoscale_policy_by_service_uuid_and_policy_name200_response import ( + DeleteAutoscalePolicyByServiceUuidAndPolicyName200Response, +) +from unikraft_cloud_platform.models.delete_autoscale_policy_by_service_uuid_and_policy_name200_response_data import ( + DeleteAutoscalePolicyByServiceUuidAndPolicyName200ResponseData, +) +from unikraft_cloud_platform.models.delete_certificate_by_uuid200_response import DeleteCertificateByUuid200Response +from unikraft_cloud_platform.models.delete_certificate_by_uuid200_response_data import ( + DeleteCertificateByUuid200ResponseData, +) +from unikraft_cloud_platform.models.delete_certificates200_response import DeleteCertificates200Response +from unikraft_cloud_platform.models.delete_certificates200_response_data import DeleteCertificates200ResponseData +from unikraft_cloud_platform.models.delete_certificates200_response_data_certificates_inner import ( + DeleteCertificates200ResponseDataCertificatesInner, +) +from unikraft_cloud_platform.models.delete_certificates_request_inner import DeleteCertificatesRequestInner +from unikraft_cloud_platform.models.delete_instances200_response import DeleteInstances200Response +from unikraft_cloud_platform.models.delete_instances200_response_data import DeleteInstances200ResponseData +from unikraft_cloud_platform.models.delete_instances200_response_data_instances_inner import ( + DeleteInstances200ResponseDataInstancesInner, +) +from unikraft_cloud_platform.models.delete_instances_request_inner import DeleteInstancesRequestInner +from unikraft_cloud_platform.models.delete_services200_response import DeleteServices200Response +from unikraft_cloud_platform.models.delete_services200_response_data import DeleteServices200ResponseData +from unikraft_cloud_platform.models.delete_services200_response_data_service_groups_inner import ( + DeleteServices200ResponseDataServiceGroupsInner, +) +from unikraft_cloud_platform.models.delete_services_request_inner import DeleteServicesRequestInner +from unikraft_cloud_platform.models.delete_volumes200_response import DeleteVolumes200Response +from unikraft_cloud_platform.models.delete_volumes_request_inner import DeleteVolumesRequestInner +from unikraft_cloud_platform.models.get_autosacle_policies200_response import GetAutosaclePolicies200Response +from unikraft_cloud_platform.models.get_autosacle_policies200_response_data import GetAutosaclePolicies200ResponseData +from unikraft_cloud_platform.models.get_autosacle_policies_request_inner import GetAutosaclePoliciesRequestInner +from unikraft_cloud_platform.models.get_autoscale_configs200_response import GetAutoscaleConfigs200Response +from unikraft_cloud_platform.models.get_autoscale_configs200_response_data import GetAutoscaleConfigs200ResponseData +from unikraft_cloud_platform.models.get_autoscale_configs_request_inner import GetAutoscaleConfigsRequestInner +from unikraft_cloud_platform.models.get_autoscale_policy_by_service_uuid_and_policy_name200_response import ( + GetAutoscalePolicyByServiceUuidAndPolicyName200Response, +) +from unikraft_cloud_platform.models.get_autoscale_policy_by_service_uuid_and_policy_name200_response_data import ( + GetAutoscalePolicyByServiceUuidAndPolicyName200ResponseData, +) +from unikraft_cloud_platform.models.get_certificate_by_uuid200_response import GetCertificateByUuid200Response +from unikraft_cloud_platform.models.get_certificate_by_uuid200_response_data import GetCertificateByUuid200ResponseData +from unikraft_cloud_platform.models.get_certificates200_response import GetCertificates200Response +from unikraft_cloud_platform.models.get_certificates200_response_data import GetCertificates200ResponseData +from unikraft_cloud_platform.models.get_certificates_default_response import GetCertificatesDefaultResponse +from unikraft_cloud_platform.models.get_certificates_default_response_errors_inner import ( + GetCertificatesDefaultResponseErrorsInner, +) +from unikraft_cloud_platform.models.get_certificates_request_inner import GetCertificatesRequestInner +from unikraft_cloud_platform.models.get_images200_response import GetImages200Response +from unikraft_cloud_platform.models.get_images200_response_data import GetImages200ResponseData +from unikraft_cloud_platform.models.get_images_request_inner import GetImagesRequestInner +from unikraft_cloud_platform.models.get_instance_by_uuid200_response import GetInstanceByUuid200Response +from unikraft_cloud_platform.models.get_instance_by_uuid200_response_data import GetInstanceByUuid200ResponseData +from unikraft_cloud_platform.models.get_instance_logs200_response import GetInstanceLogs200Response +from unikraft_cloud_platform.models.get_instance_logs200_response_data import GetInstanceLogs200ResponseData +from unikraft_cloud_platform.models.get_instance_logs200_response_data_instances_inner import ( + GetInstanceLogs200ResponseDataInstancesInner, +) +from unikraft_cloud_platform.models.get_instance_logs200_response_data_instances_inner_available import ( + GetInstanceLogs200ResponseDataInstancesInnerAvailable, +) +from unikraft_cloud_platform.models.get_instance_logs200_response_data_instances_inner_range import ( + GetInstanceLogs200ResponseDataInstancesInnerRange, +) +from unikraft_cloud_platform.models.get_instance_logs_request_inner import GetInstanceLogsRequestInner +from unikraft_cloud_platform.models.get_instance_metrics200_response import GetInstanceMetrics200Response +from unikraft_cloud_platform.models.get_instance_metrics200_response_data import GetInstanceMetrics200ResponseData +from unikraft_cloud_platform.models.get_instance_metrics_request_inner import GetInstanceMetricsRequestInner +from unikraft_cloud_platform.models.get_instances200_response import GetInstances200Response +from unikraft_cloud_platform.models.get_instances200_response_data import GetInstances200ResponseData +from unikraft_cloud_platform.models.get_instances_request_inner import GetInstancesRequestInner +from unikraft_cloud_platform.models.get_quota_by_uuid200_response import GetQuotaByUuid200Response +from unikraft_cloud_platform.models.get_quota_by_uuid200_response_data import GetQuotaByUuid200ResponseData +from unikraft_cloud_platform.models.get_quotas200_response import GetQuotas200Response +from unikraft_cloud_platform.models.get_quotas200_response_data import GetQuotas200ResponseData +from unikraft_cloud_platform.models.get_service_by_uuid200_response import GetServiceByUuid200Response +from unikraft_cloud_platform.models.get_service_by_uuid200_response_data import GetServiceByUuid200ResponseData +from unikraft_cloud_platform.models.get_services200_response import GetServices200Response +from unikraft_cloud_platform.models.get_services200_response_data import GetServices200ResponseData +from unikraft_cloud_platform.models.get_services200_response_data_service_groups_inner import ( + GetServices200ResponseDataServiceGroupsInner, +) +from unikraft_cloud_platform.models.get_services200_response_data_service_groups_inner_instances_inner import ( + GetServices200ResponseDataServiceGroupsInnerInstancesInner, +) +from unikraft_cloud_platform.models.get_services_request_inner import GetServicesRequestInner +from unikraft_cloud_platform.models.get_volumes200_response import GetVolumes200Response +from unikraft_cloud_platform.models.get_volumes200_response_data import GetVolumes200ResponseData +from unikraft_cloud_platform.models.get_volumes_request_inner import GetVolumesRequestInner +from unikraft_cloud_platform.models.image import Image +from unikraft_cloud_platform.models.instance import Instance +from unikraft_cloud_platform.models.instance_metrics import InstanceMetrics +from unikraft_cloud_platform.models.instance_network_interfaces_inner import InstanceNetworkInterfacesInner +from unikraft_cloud_platform.models.instance_restart import InstanceRestart +from unikraft_cloud_platform.models.instance_service_group import InstanceServiceGroup +from unikraft_cloud_platform.models.instance_service_group_domains_inner import InstanceServiceGroupDomainsInner +from unikraft_cloud_platform.models.instance_service_group_domains_inner_certificate import ( + InstanceServiceGroupDomainsInnerCertificate, +) +from unikraft_cloud_platform.models.instance_snapshot import InstanceSnapshot +from unikraft_cloud_platform.models.service import Service +from unikraft_cloud_platform.models.service_mapping import ServiceMapping +from unikraft_cloud_platform.models.start_instances200_response import StartInstances200Response +from unikraft_cloud_platform.models.start_instances200_response_data import StartInstances200ResponseData +from unikraft_cloud_platform.models.start_instances200_response_data_instances_inner import ( + StartInstances200ResponseDataInstancesInner, +) +from unikraft_cloud_platform.models.start_instances_request_inner import StartInstancesRequestInner +from unikraft_cloud_platform.models.stop_instances_request_inner import StopInstancesRequestInner +from unikraft_cloud_platform.models.user_quota import UserQuota +from unikraft_cloud_platform.models.user_quota_limits import UserQuotaLimits +from unikraft_cloud_platform.models.user_quota_used import UserQuotaUsed +from unikraft_cloud_platform.models.volume import Volume +from unikraft_cloud_platform.models.volume_attached_to_inner import VolumeAttachedToInner +from unikraft_cloud_platform.models.volume_mounted_by_inner import VolumeMountedByInner +from unikraft_cloud_platform.models.wait_for_instances200_response import WaitForInstances200Response +from unikraft_cloud_platform.models.wait_for_instances200_response_data import WaitForInstances200ResponseData +from unikraft_cloud_platform.models.wait_for_instances200_response_data_instances_inner import ( + WaitForInstances200ResponseDataInstancesInner, ) +from unikraft_cloud_platform.models.wait_for_instances_request_inner import WaitForInstancesRequestInner diff --git a/unikraft_cloud_platform/models/attach_volume_by_uuid_request_body.py b/unikraft_cloud_platform/models/attach_volume_by_uuid_request_body.py deleted file mode 100644 index 3b690a8..0000000 --- a/unikraft_cloud_platform/models/attach_volume_by_uuid_request_body.py +++ /dev/null @@ -1,73 +0,0 @@ -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -if TYPE_CHECKING: - from ..models.body_instance_id import BodyInstanceID - - -T = TypeVar("T", bound="AttachVolumeByUUIDRequestBody") - - -@_attrs_define -class AttachVolumeByUUIDRequestBody: - attach_to: "BodyInstanceID" - """ Reference to the instance to detach the volume from. """ - at: str - """ Path of the mountpoint. - - The path must be absolute, not contain `.` and `..` components, and not - contain colons (`:`). The path must point to an empty directory. If the - directory does not exist, it is created. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - attach_to = self.attach_to.to_dict() - - at = self.at - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update( - { - "attach_to": attach_to, - "at": at, - } - ) - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.body_instance_id import BodyInstanceID - - d = dict(src_dict) - attach_to = BodyInstanceID.from_dict(d.pop("attach_to")) - - at = d.pop("at") - - attach_volume_by_uuid_request_body = cls( - attach_to=attach_to, - at=at, - ) - - attach_volume_by_uuid_request_body.additional_properties = d - return attach_volume_by_uuid_request_body - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/attach_volumes_request.py b/unikraft_cloud_platform/models/attach_volumes_request.py deleted file mode 100644 index b403cc1..0000000 --- a/unikraft_cloud_platform/models/attach_volumes_request.py +++ /dev/null @@ -1,117 +0,0 @@ -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union -from uuid import UUID - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.attach_volumes_request_instance_id import AttachVolumesRequestInstanceID - - -T = TypeVar("T", bound="AttachVolumesRequest") - - -@_attrs_define -class AttachVolumesRequest: - """The request message for attaching one or more volume(s) to instances by - their UUID(s) or name(s). - - """ - - attach_to: "AttachVolumesRequestInstanceID" - """ Reference to the instance to attach the volume to. """ - at: str - """ Path of the mountpoint. - - The path must be absolute, not contain `.` and `..` components, and not - contain colons (`:`). The path must point to an empty directory. If the - directory does not exist, it is created. """ - uuid: Union[Unset, UUID] = UNSET - """ The UUID of the volume to attach. Mutually exclusive with name. - Exactly one of uuid or name must be provided. """ - name: Union[Unset, str] = UNSET - """ The name of the volume to attach. Mutually exclusive with UUID. - Exactly one of uuid or name must be provided. """ - readonly: Union[Unset, bool] = UNSET - """ Whether the volume should be mounted read-only. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - attach_to = self.attach_to.to_dict() - - at = self.at - - uuid: Union[Unset, str] = UNSET - if not isinstance(self.uuid, Unset): - uuid = str(self.uuid) - - name = self.name - - readonly = self.readonly - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update( - { - "attach_to": attach_to, - "at": at, - } - ) - if uuid is not UNSET: - field_dict["uuid"] = uuid - if name is not UNSET: - field_dict["name"] = name - if readonly is not UNSET: - field_dict["readonly"] = readonly - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.attach_volumes_request_instance_id import AttachVolumesRequestInstanceID - - d = dict(src_dict) - attach_to = AttachVolumesRequestInstanceID.from_dict(d.pop("attach_to")) - - at = d.pop("at") - - _uuid = d.pop("uuid", UNSET) - uuid: Union[Unset, UUID] - if isinstance(_uuid, Unset): - uuid = UNSET - else: - uuid = UUID(_uuid) - - name = d.pop("name", UNSET) - - readonly = d.pop("readonly", UNSET) - - attach_volumes_request = cls( - attach_to=attach_to, - at=at, - uuid=uuid, - name=name, - readonly=readonly, - ) - - attach_volumes_request.additional_properties = d - return attach_volumes_request - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/attach_volumes_request_instance_id.py b/unikraft_cloud_platform/models/attach_volumes_request_instance_id.py deleted file mode 100644 index 3e2ebfc..0000000 --- a/unikraft_cloud_platform/models/attach_volumes_request_instance_id.py +++ /dev/null @@ -1,65 +0,0 @@ -from collections.abc import Mapping -from typing import Any, TypeVar, Union -from uuid import UUID - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -T = TypeVar("T", bound="AttachVolumesRequestInstanceID") - - -@_attrs_define -class AttachVolumesRequestInstanceID: - """Reference to the instance to attach the volume to.""" - - uuid: Union[Unset, UUID] = UNSET - """ The UUID of the instance that the volume is attached to. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - uuid: Union[Unset, str] = UNSET - if not isinstance(self.uuid, Unset): - uuid = str(self.uuid) - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if uuid is not UNSET: - field_dict["uuid"] = uuid - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - d = dict(src_dict) - _uuid = d.pop("uuid", UNSET) - uuid: Union[Unset, UUID] - if isinstance(_uuid, Unset): - uuid = UNSET - else: - uuid = UUID(_uuid) - - attach_volumes_request_instance_id = cls( - uuid=uuid, - ) - - attach_volumes_request_instance_id.additional_properties = d - return attach_volumes_request_instance_id - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/attach_volumes_response.py b/unikraft_cloud_platform/models/attach_volumes_response.py deleted file mode 100644 index a3bec5b..0000000 --- a/unikraft_cloud_platform/models/attach_volumes_response.py +++ /dev/null @@ -1,120 +0,0 @@ -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..models.response_status import ResponseStatus, check_response_status -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.attach_volumes_response_data import AttachVolumesResponseData - from ..models.response_error import ResponseError - - -T = TypeVar("T", bound="AttachVolumesResponse") - - -@_attrs_define -class AttachVolumesResponse: - """The response message for attaching one or more volume(s) given their - UUID(s) or name(s). - - """ - - status: Union[Unset, ResponseStatus] = UNSET - """ The response status of an API request. """ - data: Union[Unset, "AttachVolumesResponseData"] = UNSET - errors: Union[Unset, list["ResponseError"]] = UNSET - """ A list of errors which may have occurred during the request. """ - op_time_us: Union[Unset, int] = UNSET - """ The operation time in microseconds. This is the time it took to process - the request and generate the response. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - status: Union[Unset, str] = UNSET - if not isinstance(self.status, Unset): - status = self.status - - data: Union[Unset, dict[str, Any]] = UNSET - if not isinstance(self.data, Unset): - data = self.data.to_dict() - - errors: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.errors, Unset): - errors = [] - for errors_item_data in self.errors: - errors_item = errors_item_data.to_dict() - errors.append(errors_item) - - op_time_us = self.op_time_us - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if status is not UNSET: - field_dict["status"] = status - if data is not UNSET: - field_dict["data"] = data - if errors is not UNSET: - field_dict["errors"] = errors - if op_time_us is not UNSET: - field_dict["op_time_us"] = op_time_us - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.attach_volumes_response_data import AttachVolumesResponseData - from ..models.response_error import ResponseError - - d = dict(src_dict) - _status = d.pop("status", UNSET) - status: Union[Unset, ResponseStatus] - if isinstance(_status, Unset): - status = UNSET - else: - status = check_response_status(_status) - - _data = d.pop("data", UNSET) - data: Union[Unset, AttachVolumesResponseData] - if isinstance(_data, Unset): - data = UNSET - else: - data = AttachVolumesResponseData.from_dict(_data) - - errors = [] - _errors = d.pop("errors", UNSET) - for errors_item_data in _errors or []: - errors_item = ResponseError.from_dict(errors_item_data) - - errors.append(errors_item) - - op_time_us = d.pop("op_time_us", UNSET) - - attach_volumes_response = cls( - status=status, - data=data, - errors=errors, - op_time_us=op_time_us, - ) - - attach_volumes_response.additional_properties = d - return attach_volumes_response - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/attach_volumes_response_attached_volume.py b/unikraft_cloud_platform/models/attach_volumes_response_attached_volume.py deleted file mode 100644 index 28c4760..0000000 --- a/unikraft_cloud_platform/models/attach_volumes_response_attached_volume.py +++ /dev/null @@ -1,109 +0,0 @@ -from collections.abc import Mapping -from typing import Any, TypeVar, Union -from uuid import UUID - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..models.response_status import ResponseStatus, check_response_status -from ..types import UNSET, Unset - -T = TypeVar("T", bound="AttachVolumesResponseAttachedVolume") - - -@_attrs_define -class AttachVolumesResponseAttachedVolume: - status: Union[Unset, ResponseStatus] = UNSET - """ The response status of an API request. """ - uuid: Union[Unset, UUID] = UNSET - """ The UUID of the volume that was attached. """ - name: Union[Unset, str] = UNSET - """ The name of the volume that was attached. """ - message: Union[Unset, str] = UNSET - """ An optional message providing additional information about the status. - This field is useful when the status is not `success`. """ - error: Union[Unset, int] = UNSET - """ An optional error code providing additional information about the status. - This field is useful when the status is not `success`. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - status: Union[Unset, str] = UNSET - if not isinstance(self.status, Unset): - status = self.status - - uuid: Union[Unset, str] = UNSET - if not isinstance(self.uuid, Unset): - uuid = str(self.uuid) - - name = self.name - - message = self.message - - error = self.error - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if status is not UNSET: - field_dict["status"] = status - if uuid is not UNSET: - field_dict["uuid"] = uuid - if name is not UNSET: - field_dict["name"] = name - if message is not UNSET: - field_dict["message"] = message - if error is not UNSET: - field_dict["error"] = error - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - d = dict(src_dict) - _status = d.pop("status", UNSET) - status: Union[Unset, ResponseStatus] - if isinstance(_status, Unset): - status = UNSET - else: - status = check_response_status(_status) - - _uuid = d.pop("uuid", UNSET) - uuid: Union[Unset, UUID] - if isinstance(_uuid, Unset): - uuid = UNSET - else: - uuid = UUID(_uuid) - - name = d.pop("name", UNSET) - - message = d.pop("message", UNSET) - - error = d.pop("error", UNSET) - - attach_volumes_response_attached_volume = cls( - status=status, - uuid=uuid, - name=name, - message=message, - error=error, - ) - - attach_volumes_response_attached_volume.additional_properties = d - return attach_volumes_response_attached_volume - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/attach_volumes_response_data.py b/unikraft_cloud_platform/models/attach_volumes_response_data.py deleted file mode 100644 index 214b807..0000000 --- a/unikraft_cloud_platform/models/attach_volumes_response_data.py +++ /dev/null @@ -1,71 +0,0 @@ -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.attach_volumes_response_attached_volume import AttachVolumesResponseAttachedVolume - - -T = TypeVar("T", bound="AttachVolumesResponseData") - - -@_attrs_define -class AttachVolumesResponseData: - volumes: Union[Unset, list["AttachVolumesResponseAttachedVolume"]] = UNSET - """ The volume(s) which were attached by the request. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - volumes: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.volumes, Unset): - volumes = [] - for volumes_item_data in self.volumes: - volumes_item = volumes_item_data.to_dict() - volumes.append(volumes_item) - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if volumes is not UNSET: - field_dict["volumes"] = volumes - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.attach_volumes_response_attached_volume import AttachVolumesResponseAttachedVolume - - d = dict(src_dict) - volumes = [] - _volumes = d.pop("volumes", UNSET) - for volumes_item_data in _volumes or []: - volumes_item = AttachVolumesResponseAttachedVolume.from_dict(volumes_item_data) - - volumes.append(volumes_item) - - attach_volumes_response_data = cls( - volumes=volumes, - ) - - attach_volumes_response_data.additional_properties = d - return attach_volumes_response_data - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/autoscale_config.py b/unikraft_cloud_platform/models/autoscale_config.py new file mode 100644 index 0000000..f14e0ef --- /dev/null +++ b/unikraft_cloud_platform/models/autoscale_config.py @@ -0,0 +1,157 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictBool, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from uuid import UUID +from unikraft_cloud_platform.models.autoscale_config_master import AutoscaleConfigMaster +from unikraft_cloud_platform.models.autoscale_policy import AutoscalePolicy +from typing import Optional, Set +from typing_extensions import Self + + +class AutoscaleConfig(BaseModel): + """ + AutoscaleConfig + """ # noqa: E501 + + status: Optional[Annotated[str, Field(strict=True, max_length=12)]] = Field( + default=None, + description="`success` on success, `unconfigured` if autoscale is not configured, or `error` if the request failed. ", + ) + uuid: Optional[UUID] = Field(default=None, description="The UUID of the service. ") + name: Optional[Annotated[str, Field(strict=True, max_length=255)]] = Field( + default=None, description="The name of the service. " + ) + enabled: Optional[StrictBool] = Field(default=None, description="Whether autoscale is enabled. ") + min_size: Optional[Annotated[int, Field(le=1, strict=True, ge=1)]] = Field( + default=None, description="Minimum number of instances. " + ) + max_size: Optional[Annotated[int, Field(le=2147483647, strict=True, ge=1)]] = Field( + default=None, description="Maximum number of instances. Maximum number is determined by the quota. " + ) + warmup_time_ms: Optional[Annotated[int, Field(le=2147483647, strict=True, ge=1)]] = Field( + default=None, + description="Length of [warmup phase](https://unikraft.cloud/docs/api/v1/autoscale/#warmup-and-cooldown) in milliseconds. ", + ) + cooldown_time_ms: Optional[Annotated[int, Field(le=2147483647, strict=True, ge=1)]] = Field( + default=None, + description="Length of [cooldown phase](https://unikraft.cloud/docs/api/v1/autoscale/#warmup-and-cooldown) in milliseconds. ", + ) + master: Optional[AutoscaleConfigMaster] = None + policies: Optional[Annotated[List[AutoscalePolicy], Field(max_length=253)]] = None + __properties: ClassVar[List[str]] = [ + "status", + "uuid", + "name", + "enabled", + "min_size", + "max_size", + "warmup_time_ms", + "cooldown_time_ms", + "master", + "policies", + ] + + @field_validator("status") + def status_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(["success", "unconfigured", "failure"]): + raise ValueError("must be one of enum values ('success', 'unconfigured', 'failure')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of AutoscaleConfig from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of master + if self.master: + _dict["master"] = self.master.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in policies (list) + _items = [] + if self.policies: + for _item_policies in self.policies: + if _item_policies: + _items.append(_item_policies.to_dict()) + _dict["policies"] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of AutoscaleConfig from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "status": obj.get("status"), + "uuid": obj.get("uuid"), + "name": obj.get("name"), + "enabled": obj.get("enabled"), + "min_size": obj.get("min_size"), + "max_size": obj.get("max_size"), + "warmup_time_ms": obj.get("warmup_time_ms"), + "cooldown_time_ms": obj.get("cooldown_time_ms"), + "master": AutoscaleConfigMaster.from_dict(obj["master"]) if obj.get("master") is not None else None, + "policies": [AutoscalePolicy.from_dict(_item) for _item in obj["policies"]] + if obj.get("policies") is not None + else None, + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/autoscale_config_master.py b/unikraft_cloud_platform/models/autoscale_config_master.py new file mode 100644 index 0000000..c45ea48 --- /dev/null +++ b/unikraft_cloud_platform/models/autoscale_config_master.py @@ -0,0 +1,92 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from uuid import UUID +from typing import Optional, Set +from typing_extensions import Self + + +class AutoscaleConfigMaster(BaseModel): + """ + AutoscaleConfigMaster + """ # noqa: E501 + + uuid: Optional[UUID] = Field( + default=None, + description="The UUID of instance to use as [autoscale master](https://unikraft.cloud/docs/api/v1/autoscale/#autoscale-basics). ", + ) + name: Optional[Annotated[str, Field(strict=True, max_length=255)]] = Field( + default=None, + description="The name of instance to use as [autoscale master](https://unikraft.cloud/docs/api/v1/autoscale/#autoscale-basics). ", + ) + __properties: ClassVar[List[str]] = ["uuid", "name"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of AutoscaleConfigMaster from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of AutoscaleConfigMaster from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({"uuid": obj.get("uuid"), "name": obj.get("name")}) + return _obj diff --git a/unikraft_cloud_platform/models/autoscale_policy.py b/unikraft_cloud_platform/models/autoscale_policy.py index e70098f..ee146b5 100644 --- a/unikraft_cloud_platform/models/autoscale_policy.py +++ b/unikraft_cloud_platform/models/autoscale_policy.py @@ -1,134 +1,138 @@ -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union +# coding: utf-8 -from attrs import define as _attrs_define -from attrs import field as _attrs_field +""" +Unikraft Cloud Platform -from ..models.autoscale_policy_adjustment_type import ( - AutoscalePolicyAdjustmentType, - check_autoscale_policy_adjustment_type, -) -from ..models.autoscale_policy_metric import AutoscalePolicyMetric, check_autoscale_policy_metric -from ..types import UNSET, Unset +This is the API of the Unikraft Cloud Platform. -if TYPE_CHECKING: - from ..models.autoscale_policy_step import AutoscalePolicyStep +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) +Do not edit the class manually. +""" # noqa: E501 -T = TypeVar("T", bound="AutoscalePolicy") +from __future__ import annotations +import pprint +import re # noqa: F401 +import json +from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from unikraft_cloud_platform.models.autoscale_policy_step import AutoscalePolicyStep +from typing import Optional, Set +from typing_extensions import Self -@_attrs_define -class AutoscalePolicy: - """AutoscalePolicy defines the autoscale policy for a service. - Right now it contains fields from both the `ondemand` and `step` policies. - They are marked both as optional, so only one of them should be set at a - time. This is a current limitation of the API design. +class AutoscalePolicy(BaseModel): """ - - name: Union[Unset, str] = UNSET - """ The name of the policy. """ - enabled: Union[Unset, bool] = UNSET - """ If the policy is enabled. """ - metric: Union[Unset, AutoscalePolicyMetric] = UNSET - """ Metric to use for the step policy. """ - adjustment_type: Union[Unset, AutoscalePolicyAdjustmentType] = UNSET - """ The type of adjustment to be made in the step policy. """ - steps: Union[Unset, list["AutoscalePolicyStep"]] = UNSET - """ The steps for the step policy. - Each step defines an adjustment value and optional bounds. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - name = self.name - - enabled = self.enabled - - metric: Union[Unset, str] = UNSET - if not isinstance(self.metric, Unset): - metric = self.metric - - adjustment_type: Union[Unset, str] = UNSET - if not isinstance(self.adjustment_type, Unset): - adjustment_type = self.adjustment_type - - steps: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.steps, Unset): - steps = [] - for steps_item_data in self.steps: - steps_item = steps_item_data.to_dict() - steps.append(steps_item) - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if name is not UNSET: - field_dict["name"] = name - if enabled is not UNSET: - field_dict["enabled"] = enabled - if metric is not UNSET: - field_dict["metric"] = metric - if adjustment_type is not UNSET: - field_dict["adjustment_type"] = adjustment_type - if steps is not UNSET: - field_dict["steps"] = steps - - return field_dict + Description of [autoscale policies](https://unikraft.cloud/docs/api/v1/autoscale/#autoscale-policies). See [policy creation endpoint](https://unikraft.cloud/docs/api/v1/autoscale/#policy_create). + """ # noqa: E501 + + name: Optional[Annotated[str, Field(strict=True, max_length=255)]] = Field( + default=None, description="The name of the policy. " + ) + metric: Optional[StrictStr] = Field(default="cpu", description="Metric to monitor. ") + type: Optional[StrictStr] = Field(default=None, description="Type of autoscale policy. ") + adjustment_type: Optional[StrictStr] = Field(default="change", description="Type of adjustment. ") + steps: Optional[Annotated[List[AutoscalePolicyStep], Field(max_length=253)]] = None + __properties: ClassVar[List[str]] = ["name", "metric", "type", "adjustment_type", "steps"] + + @field_validator("metric") + def metric_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(["cpu"]): + raise ValueError("must be one of enum values ('cpu')") + return value + + @field_validator("type") + def type_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(["step"]): + raise ValueError("must be one of enum values ('step')") + return value + + @field_validator("adjustment_type") + def adjustment_type_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(["change", "exact", "percent"]): + raise ValueError("must be one of enum values ('change', 'exact', 'percent')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.autoscale_policy_step import AutoscalePolicyStep - - d = dict(src_dict) - name = d.pop("name", UNSET) - - enabled = d.pop("enabled", UNSET) - - _metric = d.pop("metric", UNSET) - metric: Union[Unset, AutoscalePolicyMetric] - if isinstance(_metric, Unset): - metric = UNSET - else: - metric = check_autoscale_policy_metric(_metric) - - _adjustment_type = d.pop("adjustment_type", UNSET) - adjustment_type: Union[Unset, AutoscalePolicyAdjustmentType] - if isinstance(_adjustment_type, Unset): - adjustment_type = UNSET - else: - adjustment_type = check_autoscale_policy_adjustment_type(_adjustment_type) - - steps = [] - _steps = d.pop("steps", UNSET) - for steps_item_data in _steps or []: - steps_item = AutoscalePolicyStep.from_dict(steps_item_data) - - steps.append(steps_item) - - autoscale_policy = cls( - name=name, - enabled=enabled, - metric=metric, - adjustment_type=adjustment_type, - steps=steps, + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of AutoscalePolicy from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, ) + # override the default output from pydantic by calling `to_dict()` of each item in steps (list) + _items = [] + if self.steps: + for _item_steps in self.steps: + if _item_steps: + _items.append(_item_steps.to_dict()) + _dict["steps"] = _items + return _dict - autoscale_policy.additional_properties = d - return autoscale_policy - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of AutoscalePolicy from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "name": obj.get("name"), + "metric": obj.get("metric") if obj.get("metric") is not None else "cpu", + "type": obj.get("type"), + "adjustment_type": obj.get("adjustment_type") if obj.get("adjustment_type") is not None else "change", + "steps": [AutoscalePolicyStep.from_dict(_item) for _item in obj["steps"]] + if obj.get("steps") is not None + else None, + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/autoscale_policy_adjustment_type.py b/unikraft_cloud_platform/models/autoscale_policy_adjustment_type.py deleted file mode 100644 index 7d06724..0000000 --- a/unikraft_cloud_platform/models/autoscale_policy_adjustment_type.py +++ /dev/null @@ -1,15 +0,0 @@ -from typing import Literal, cast - -AutoscalePolicyAdjustmentType = Literal["change", "exact", "percentage"] - -AUTOSCALE_POLICY_ADJUSTMENT_TYPE_VALUES: set[AutoscalePolicyAdjustmentType] = { - "change", - "exact", - "percentage", -} - - -def check_autoscale_policy_adjustment_type(value: str) -> AutoscalePolicyAdjustmentType: - if value in AUTOSCALE_POLICY_ADJUSTMENT_TYPE_VALUES: - return cast(AutoscalePolicyAdjustmentType, value) - raise TypeError(f"Unexpected value {value!r}. Expected one of {AUTOSCALE_POLICY_ADJUSTMENT_TYPE_VALUES!r}") diff --git a/unikraft_cloud_platform/models/autoscale_policy_metric.py b/unikraft_cloud_platform/models/autoscale_policy_metric.py deleted file mode 100644 index 4a11e8f..0000000 --- a/unikraft_cloud_platform/models/autoscale_policy_metric.py +++ /dev/null @@ -1,13 +0,0 @@ -from typing import Literal, cast - -AutoscalePolicyMetric = Literal["cpu"] - -AUTOSCALE_POLICY_METRIC_VALUES: set[AutoscalePolicyMetric] = { - "cpu", -} - - -def check_autoscale_policy_metric(value: str) -> AutoscalePolicyMetric: - if value in AUTOSCALE_POLICY_METRIC_VALUES: - return cast(AutoscalePolicyMetric, value) - raise TypeError(f"Unexpected value {value!r}. Expected one of {AUTOSCALE_POLICY_METRIC_VALUES!r}") diff --git a/unikraft_cloud_platform/models/autoscale_policy_step.py b/unikraft_cloud_platform/models/autoscale_policy_step.py index 4399e7e..4d10786 100644 --- a/unikraft_cloud_platform/models/autoscale_policy_step.py +++ b/unikraft_cloud_platform/models/autoscale_policy_step.py @@ -1,73 +1,98 @@ -from collections.abc import Mapping -from typing import Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -T = TypeVar("T", bound="AutoscalePolicyStep") - - -@_attrs_define -class AutoscalePolicyStep: - adjustment: Union[Unset, int] = UNSET - """ The adjustment value for the step. """ - lower_bound: Union[Unset, int] = UNSET - """ Lower bound for the step. """ - upper_bound: Union[Unset, int] = UNSET - """ Upper bound for the step. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - adjustment = self.adjustment - - lower_bound = self.lower_bound - - upper_bound = self.upper_bound - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if adjustment is not UNSET: - field_dict["adjustment"] = adjustment - if lower_bound is not UNSET: - field_dict["lower_bound"] = lower_bound - if upper_bound is not UNSET: - field_dict["upper_bound"] = upper_bound - - return field_dict +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from typing import Optional, Set +from typing_extensions import Self + + +class AutoscalePolicyStep(BaseModel): + """ + Step policy. Note: Only one of `lower_bound` and `upper_bound` can be `null` or not specified. See the description of the step policy for more information on defining steps. + """ # noqa: E501 + + lower_bound: Optional[Annotated[int, Field(le=2147483647, strict=True, ge=-2147483647)]] = Field( + default=None, description="Lower bound of the step range. In dimension of selected metric. " + ) + upper_bound: Optional[Annotated[int, Field(le=2147483647, strict=True, ge=-2147483647)]] = Field( + default=None, description="Upper bound of the step range. In dimension of selected metric. " + ) + adjustment: Optional[Annotated[int, Field(le=2147483647, strict=True, ge=-2147483647)]] = Field( + default=None, description="Adjustment to take if metric is in range. " + ) + __properties: ClassVar[List[str]] = ["lower_bound", "upper_bound", "adjustment"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - d = dict(src_dict) - adjustment = d.pop("adjustment", UNSET) - - lower_bound = d.pop("lower_bound", UNSET) - - upper_bound = d.pop("upper_bound", UNSET) - - autoscale_policy_step = cls( - adjustment=adjustment, - lower_bound=lower_bound, - upper_bound=upper_bound, + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of AutoscalePolicyStep from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, ) + return _dict - autoscale_policy_step.additional_properties = d - return autoscale_policy_step - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of AutoscalePolicyStep from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "lower_bound": obj.get("lower_bound"), + "upper_bound": obj.get("upper_bound"), + "adjustment": obj.get("adjustment"), + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/body_instance_id.py b/unikraft_cloud_platform/models/body_instance_id.py deleted file mode 100644 index 9480797..0000000 --- a/unikraft_cloud_platform/models/body_instance_id.py +++ /dev/null @@ -1,65 +0,0 @@ -from collections.abc import Mapping -from typing import Any, TypeVar, Union -from uuid import UUID - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -T = TypeVar("T", bound="BodyInstanceID") - - -@_attrs_define -class BodyInstanceID: - """Reference to the instance to detach the volume from.""" - - uuid: Union[Unset, UUID] = UNSET - """ The UUID of the instance that the volume is detached from. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - uuid: Union[Unset, str] = UNSET - if not isinstance(self.uuid, Unset): - uuid = str(self.uuid) - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if uuid is not UNSET: - field_dict["uuid"] = uuid - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - d = dict(src_dict) - _uuid = d.pop("uuid", UNSET) - uuid: Union[Unset, UUID] - if isinstance(_uuid, Unset): - uuid = UNSET - else: - uuid = UUID(_uuid) - - body_instance_id = cls( - uuid=uuid, - ) - - body_instance_id.additional_properties = d - return body_instance_id - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/certificate.py b/unikraft_cloud_platform/models/certificate.py index 2795fe8..6cb8f5c 100644 --- a/unikraft_cloud_platform/models/certificate.py +++ b/unikraft_cloud_platform/models/certificate.py @@ -1,249 +1,213 @@ -import datetime -from collections.abc import Mapping -from typing import Any, TypeVar, Union -from uuid import UUID +# coding: utf-8 -from attrs import define as _attrs_define -from attrs import field as _attrs_field -from dateutil.parser import isoparse - -from ..models.certificate_state import CertificateState, check_certificate_state -from ..models.response_status import ResponseStatus, check_response_status -from ..types import UNSET, Unset - -T = TypeVar("T", bound="Certificate") - - -@_attrs_define -class Certificate: - uuid: Union[Unset, UUID] = UNSET - """ The UUID of the certificate. - - This is a unique identifier for the certificate that is generated when the - certificate is created. The UUID is used to reference the certificate in - API calls and can be used to identify the certificate in all API calls that - require an identifier. """ - name: Union[Unset, str] = UNSET - """ The name of the certificate. - - This is a human-readable name that can be used to identify the certificate. - The name must be unique within the context of your account. The name can - also be used to identify the certificate in API calls. """ - created_at: Union[Unset, datetime.datetime] = UNSET - """ The time the certificate was created. """ - common_name: Union[Unset, str] = UNSET - """ The common name (CN) field from the certificate's subject. - - This is typically the primary domain name that the certificate is issued - for. It represents the main identity that the certificate validates. """ - subject: Union[Unset, str] = UNSET - """ The complete subject distinguished name (DN) of the certificate. - - This contains the full subject information from the certificate, including - the common name, organization, organizational unit, locality, state, and - country. The subject identifies the entity that the certificate is issued to. """ - issuer: Union[Unset, str] = UNSET - """ The complete issuer distinguished name (DN) of the certificate. - - This identifies the Certificate Authority (CA) that issued the certificate. - It contains information about the CA including its common name, organization, - and country. """ - serial_number: Union[Unset, str] = UNSET - """ The unique serial number assigned to the certificate by the issuing CA. - - This is a unique identifier within the scope of the issuing CA that can be - used to identify and track the certificate. Serial numbers are typically - represented as hexadecimal strings. """ - not_before: Union[Unset, datetime.datetime] = UNSET - """ The date and time when the certificate becomes valid. - - The certificate should not be trusted before this date. This timestamp - marks the beginning of the certificate's validity period. """ - not_after: Union[Unset, datetime.datetime] = UNSET - """ The date and time when the certificate expires. - - The certificate should not be trusted after this date. This timestamp - marks the end of the certificate's validity period. Certificates should - be renewed before this date to maintain service availability. """ - state: Union[Unset, CertificateState] = UNSET - """ The current state of the certificate. - - This indicates whether the certificate is pending issuance, valid and - ready for use, or in an error state. See CertificateState enum for - detailed state descriptions. """ - status: Union[Unset, ResponseStatus] = UNSET - """ The response status of an API request. """ - message: Union[Unset, str] = UNSET - """ An optional message providing additional information about the status. - This field is only set when this message object is used as a response - message, and is useful when the status is not `success`. """ - error: Union[Unset, int] = UNSET - """ An optional error code providing additional information about the status. - This field is only set when this message object is used as a response - message, and is useful when the status is not `success`. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - uuid: Union[Unset, str] = UNSET - if not isinstance(self.uuid, Unset): - uuid = str(self.uuid) - - name = self.name - - created_at: Union[Unset, str] = UNSET - if not isinstance(self.created_at, Unset): - created_at = self.created_at.isoformat() - - common_name = self.common_name - - subject = self.subject - - issuer = self.issuer - - serial_number = self.serial_number - - not_before: Union[Unset, str] = UNSET - if not isinstance(self.not_before, Unset): - not_before = self.not_before.isoformat() - - not_after: Union[Unset, str] = UNSET - if not isinstance(self.not_after, Unset): - not_after = self.not_after.isoformat() - - state: Union[Unset, str] = UNSET - if not isinstance(self.state, Unset): - state = self.state - - status: Union[Unset, str] = UNSET - if not isinstance(self.status, Unset): - status = self.status - - message = self.message - - error = self.error - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if uuid is not UNSET: - field_dict["uuid"] = uuid - if name is not UNSET: - field_dict["name"] = name - if created_at is not UNSET: - field_dict["created_at"] = created_at - if common_name is not UNSET: - field_dict["common_name"] = common_name - if subject is not UNSET: - field_dict["subject"] = subject - if issuer is not UNSET: - field_dict["issuer"] = issuer - if serial_number is not UNSET: - field_dict["serial_number"] = serial_number - if not_before is not UNSET: - field_dict["not_before"] = not_before - if not_after is not UNSET: - field_dict["not_after"] = not_after - if state is not UNSET: - field_dict["state"] = state - if status is not UNSET: - field_dict["status"] = status - if message is not UNSET: - field_dict["message"] = message - if error is not UNSET: - field_dict["error"] = error - - return field_dict +""" +Unikraft Cloud Platform - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - d = dict(src_dict) - _uuid = d.pop("uuid", UNSET) - uuid: Union[Unset, UUID] - if isinstance(_uuid, Unset): - uuid = UNSET - else: - uuid = UUID(_uuid) - - name = d.pop("name", UNSET) - - _created_at = d.pop("created_at", UNSET) - created_at: Union[Unset, datetime.datetime] - if isinstance(_created_at, Unset): - created_at = UNSET - else: - created_at = isoparse(_created_at) - - common_name = d.pop("common_name", UNSET) - - subject = d.pop("subject", UNSET) - - issuer = d.pop("issuer", UNSET) - - serial_number = d.pop("serial_number", UNSET) - - _not_before = d.pop("not_before", UNSET) - not_before: Union[Unset, datetime.datetime] - if isinstance(_not_before, Unset): - not_before = UNSET - else: - not_before = isoparse(_not_before) - - _not_after = d.pop("not_after", UNSET) - not_after: Union[Unset, datetime.datetime] - if isinstance(_not_after, Unset): - not_after = UNSET - else: - not_after = isoparse(_not_after) - - _state = d.pop("state", UNSET) - state: Union[Unset, CertificateState] - if isinstance(_state, Unset): - state = UNSET - else: - state = check_certificate_state(_state) - - _status = d.pop("status", UNSET) - status: Union[Unset, ResponseStatus] - if isinstance(_status, Unset): - status = UNSET - else: - status = check_response_status(_status) - - message = d.pop("message", UNSET) - - error = d.pop("error", UNSET) - - certificate = cls( - uuid=uuid, - name=name, - created_at=created_at, - common_name=common_name, - subject=subject, - issuer=issuer, - serial_number=serial_number, - not_before=not_before, - not_after=not_after, - state=state, - status=status, - message=message, - error=error, - ) +This is the API of the Unikraft Cloud Platform. - certificate.additional_properties = d - return certificate +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) +Do not edit the class manually. +""" # noqa: E501 - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] +from __future__ import annotations +import pprint +import re # noqa: F401 +import json - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value +from datetime import datetime +from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from uuid import UUID +from unikraft_cloud_platform.models.certificate_service_groups_inner import CertificateServiceGroupsInner +from unikraft_cloud_platform.models.certificate_validation import CertificateValidation +from typing import Optional, Set +from typing_extensions import Self + + +class Certificate(BaseModel): + """ + SSL Certificate. + """ # noqa: E501 + + status: Optional[StrictStr] = Field( + default=None, description="The status of the response. Note: Not when listing all existing certificates. " + ) + uuid: Optional[UUID] = Field(default=None, description="The UUID of the certificate. ") + name: Optional[Annotated[str, Field(strict=True, max_length=255)]] = Field( + default=None, description="The name of the certificate. " + ) + created_at: Optional[datetime] = Field(default=None, description="Date and time of creation in ISO8601. ") + common_name: Optional[Annotated[str, Field(strict=True, max_length=255)]] = Field( + default=None, description="Common name (CN) of the certificate. " + ) + state: Optional[StrictStr] = Field( + default=None, + description="Current state of the certificate. A certificate can be in one of the following states: State | Description ----------|------------ `pending` | The certificate request is pending while the certificate is being requested from the certification authority. During this phase any service using this certificate is not available if this is not a renewal. `valid` | The certificate is valid and can be used for services. `error` | The certificate request failed after multiple attempts. This can happen, for example, if your DNS configuration is not correct, you run into Let’s Encrypt™ quota limits, or the domain validation process failed for some other reason. There won’t be any further automatic attempts. If you need assistence please contact us via [support@unikraft.cloud](mailto:support@unikraft.cloud). ", + ) + validation: Optional[CertificateValidation] = None + subject: Optional[Annotated[str, Field(strict=True, max_length=8388608)]] = Field( + default=None, description="Certificate subject. " + ) + issuer: Optional[Annotated[str, Field(strict=True, max_length=8388608)]] = Field( + default=None, description="Certificate issuer. " + ) + serial_number: Optional[Annotated[str, Field(strict=True, max_length=8388608)]] = Field( + default=None, description="Certificate serial number. " + ) + not_before: Optional[datetime] = Field( + default=None, description="Date and time of beginning of validity in ISO8601. " + ) + not_after: Optional[datetime] = Field(default=None, description="Expiration date and time in ISO8601. ") + service_groups: Optional[Annotated[List[CertificateServiceGroupsInner], Field(max_length=253)]] = Field( + default=None, description="Services using this certificate. " + ) + __properties: ClassVar[List[str]] = [ + "status", + "uuid", + "name", + "created_at", + "common_name", + "state", + "validation", + "subject", + "issuer", + "serial_number", + "not_before", + "not_after", + "service_groups", + ] + + @field_validator("status") + def status_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(["success", "failure"]): + raise ValueError("must be one of enum values ('success', 'failure')") + return value + + @field_validator("state") + def state_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(["valid", "pending", "error"]): + raise ValueError("must be one of enum values ('valid', 'pending', 'error')") + return value + + @field_validator("subject") + def subject_validate_regular_expression(cls, value): + """Validates the regular expression""" + if value is None: + return value + + if not re.match(r"^[a-zA-Z]+?=(?:(?![a-zA-Z]+?=.*?).)*$", value): + raise ValueError(r"must validate the regular expression /^[a-zA-Z]+?=(?:(?![a-zA-Z]+?=.*?).)*$/") + return value + + @field_validator("issuer") + def issuer_validate_regular_expression(cls, value): + """Validates the regular expression""" + if value is None: + return value + + if not re.match(r"^([a-zA-Z]+?=(?:(?![a-zA-Z]+?=.*?).)*,*)*$", value): + raise ValueError(r"must validate the regular expression /^([a-zA-Z]+?=(?:(?![a-zA-Z]+?=.*?).)*,*)*$/") + return value + + @field_validator("serial_number") + def serial_number_validate_regular_expression(cls, value): + """Validates the regular expression""" + if value is None: + return value + + if not re.match(r"^[0-9a-fA-F]{1,64}$", value): + raise ValueError(r"must validate the regular expression /^[0-9a-fA-F]{1,64}$/") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of Certificate from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of validation + if self.validation: + _dict["validation"] = self.validation.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in service_groups (list) + _items = [] + if self.service_groups: + for _item_service_groups in self.service_groups: + if _item_service_groups: + _items.append(_item_service_groups.to_dict()) + _dict["service_groups"] = _items + return _dict - def __contains__(self, key: str) -> bool: - return key in self.additional_properties + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of Certificate from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "status": obj.get("status"), + "uuid": obj.get("uuid"), + "name": obj.get("name"), + "created_at": obj.get("created_at"), + "common_name": obj.get("common_name"), + "state": obj.get("state"), + "validation": CertificateValidation.from_dict(obj["validation"]) + if obj.get("validation") is not None + else None, + "subject": obj.get("subject"), + "issuer": obj.get("issuer"), + "serial_number": obj.get("serial_number"), + "not_before": obj.get("not_before"), + "not_after": obj.get("not_after"), + "service_groups": [CertificateServiceGroupsInner.from_dict(_item) for _item in obj["service_groups"]] + if obj.get("service_groups") is not None + else None, + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/certificate_service_groups_inner.py b/unikraft_cloud_platform/models/certificate_service_groups_inner.py new file mode 100644 index 0000000..5aa00d5 --- /dev/null +++ b/unikraft_cloud_platform/models/certificate_service_groups_inner.py @@ -0,0 +1,88 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from uuid import UUID +from typing import Optional, Set +from typing_extensions import Self + + +class CertificateServiceGroupsInner(BaseModel): + """ + CertificateServiceGroupsInner + """ # noqa: E501 + + uuid: Optional[UUID] = Field(default=None, description="The UUID of the service. ") + name: Optional[Annotated[str, Field(strict=True, max_length=255)]] = Field( + default=None, description="The name of the service. " + ) + __properties: ClassVar[List[str]] = ["uuid", "name"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of CertificateServiceGroupsInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of CertificateServiceGroupsInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({"uuid": obj.get("uuid"), "name": obj.get("name")}) + return _obj diff --git a/unikraft_cloud_platform/models/certificate_state.py b/unikraft_cloud_platform/models/certificate_state.py deleted file mode 100644 index 46f8337..0000000 --- a/unikraft_cloud_platform/models/certificate_state.py +++ /dev/null @@ -1,15 +0,0 @@ -from typing import Literal, cast - -CertificateState = Literal["error", "pending", "valid"] - -CERTIFICATE_STATE_VALUES: set[CertificateState] = { - "error", - "pending", - "valid", -} - - -def check_certificate_state(value: str) -> CertificateState: - if value in CERTIFICATE_STATE_VALUES: - return cast(CertificateState, value) - raise TypeError(f"Unexpected value {value!r}. Expected one of {CERTIFICATE_STATE_VALUES!r}") diff --git a/unikraft_cloud_platform/models/certificate_validation.py b/unikraft_cloud_platform/models/certificate_validation.py new file mode 100644 index 0000000..a4852ed --- /dev/null +++ b/unikraft_cloud_platform/models/certificate_validation.py @@ -0,0 +1,90 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from datetime import datetime +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from typing import Optional, Set +from typing_extensions import Self + + +class CertificateValidation(BaseModel): + """ + Validation status (only while `pending`). + """ # noqa: E501 + + attempt: Optional[Annotated[int, Field(le=255, strict=True, ge=0)]] = Field( + default=None, description="Number of validation attempts made. " + ) + next: Optional[datetime] = Field( + default=None, description="Date and time of the next validation attempt in ISO8601. " + ) + __properties: ClassVar[List[str]] = ["attempt", "next"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of CertificateValidation from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of CertificateValidation from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({"attempt": obj.get("attempt"), "next": obj.get("next")}) + return _obj diff --git a/unikraft_cloud_platform/models/configuration_instance_create_args.py b/unikraft_cloud_platform/models/configuration_instance_create_args.py deleted file mode 100644 index fd1ee33..0000000 --- a/unikraft_cloud_platform/models/configuration_instance_create_args.py +++ /dev/null @@ -1,42 +0,0 @@ -from collections.abc import Mapping -from typing import Any, TypeVar - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -T = TypeVar("T", bound="ConfigurationInstanceCreateArgs") - - -@_attrs_define -class ConfigurationInstanceCreateArgs: - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - d = dict(src_dict) - configuration_instance_create_args = cls() - - configuration_instance_create_args.additional_properties = d - return configuration_instance_create_args - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/create_autoscale_config200_response.py b/unikraft_cloud_platform/models/create_autoscale_config200_response.py new file mode 100644 index 0000000..81a6d2e --- /dev/null +++ b/unikraft_cloud_platform/models/create_autoscale_config200_response.py @@ -0,0 +1,105 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from unikraft_cloud_platform.models.create_autoscale_config200_response_data import CreateAutoscaleConfig200ResponseData +from typing import Optional, Set +from typing_extensions import Self + + +class CreateAutoscaleConfig200Response(BaseModel): + """ + CreateAutoscaleConfig200Response + """ # noqa: E501 + + status: Optional[StrictStr] = Field(default=None, description="The status of the response. ") + data: Optional[CreateAutoscaleConfig200ResponseData] = None + __properties: ClassVar[List[str]] = ["status", "data"] + + @field_validator("status") + def status_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(["success", "failure"]): + raise ValueError("must be one of enum values ('success', 'failure')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of CreateAutoscaleConfig200Response from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of data + if self.data: + _dict["data"] = self.data.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of CreateAutoscaleConfig200Response from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "status": obj.get("status"), + "data": CreateAutoscaleConfig200ResponseData.from_dict(obj["data"]) + if obj.get("data") is not None + else None, + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/create_autoscale_config200_response_data.py b/unikraft_cloud_platform/models/create_autoscale_config200_response_data.py new file mode 100644 index 0000000..267032e --- /dev/null +++ b/unikraft_cloud_platform/models/create_autoscale_config200_response_data.py @@ -0,0 +1,105 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from unikraft_cloud_platform.models.create_autoscale_config200_response_data_certificates_inner import ( + CreateAutoscaleConfig200ResponseDataCertificatesInner, +) +from typing import Optional, Set +from typing_extensions import Self + + +class CreateAutoscaleConfig200ResponseData(BaseModel): + """ + CreateAutoscaleConfig200ResponseData + """ # noqa: E501 + + certificates: Optional[ + Annotated[List[CreateAutoscaleConfig200ResponseDataCertificatesInner], Field(max_length=253)] + ] = None + __properties: ClassVar[List[str]] = ["certificates"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of CreateAutoscaleConfig200ResponseData from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in certificates (list) + _items = [] + if self.certificates: + for _item_certificates in self.certificates: + if _item_certificates: + _items.append(_item_certificates.to_dict()) + _dict["certificates"] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of CreateAutoscaleConfig200ResponseData from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "certificates": [ + CreateAutoscaleConfig200ResponseDataCertificatesInner.from_dict(_item) + for _item in obj["certificates"] + ] + if obj.get("certificates") is not None + else None + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/create_autoscale_config200_response_data_certificates_inner.py b/unikraft_cloud_platform/models/create_autoscale_config200_response_data_certificates_inner.py new file mode 100644 index 0000000..f3a998f --- /dev/null +++ b/unikraft_cloud_platform/models/create_autoscale_config200_response_data_certificates_inner.py @@ -0,0 +1,88 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from uuid import UUID +from typing import Optional, Set +from typing_extensions import Self + + +class CreateAutoscaleConfig200ResponseDataCertificatesInner(BaseModel): + """ + CreateAutoscaleConfig200ResponseDataCertificatesInner + """ # noqa: E501 + + uuid: Optional[UUID] = Field(default=None, description="The UUID of the certificate. ") + name: Optional[Annotated[str, Field(strict=True, max_length=255)]] = Field( + default=None, description="The name of the certificate. " + ) + __properties: ClassVar[List[str]] = ["uuid", "name"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of CreateAutoscaleConfig200ResponseDataCertificatesInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of CreateAutoscaleConfig200ResponseDataCertificatesInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({"uuid": obj.get("uuid"), "name": obj.get("name")}) + return _obj diff --git a/unikraft_cloud_platform/models/create_autoscale_config_request.py b/unikraft_cloud_platform/models/create_autoscale_config_request.py new file mode 100644 index 0000000..c9231ba --- /dev/null +++ b/unikraft_cloud_platform/models/create_autoscale_config_request.py @@ -0,0 +1,131 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from uuid import UUID +from unikraft_cloud_platform.models.create_autoscale_config_request_master import CreateAutoscaleConfigRequestMaster +from typing import Optional, Set +from typing_extensions import Self + + +class CreateAutoscaleConfigRequest(BaseModel): + """ + CreateAutoscaleConfigRequest + """ # noqa: E501 + + uuid: Optional[UUID] = Field( + default=None, + description="The UUID of the service for which to create a configuration. Note: This property is mutually exclusive with `name` and either `uuid` or `name` are required. ", + ) + name: Optional[Annotated[str, Field(strict=True, max_length=255)]] = Field( + default=None, + description="The name of the service for which to create a configuration. Note: This property is mutually exclusive with `name` and either `uuid` or `name` are required. ", + ) + min_size: Optional[Annotated[int, Field(le=1, strict=True, ge=1)]] = Field( + default=1, description="Minimum number of instances. " + ) + max_size: Optional[Annotated[int, Field(le=2147483647, strict=True, ge=1)]] = Field( + default=4, description="Maximum number of instances. " + ) + warmup_time_ms: Optional[Annotated[int, Field(le=2147483647, strict=True, ge=1)]] = Field( + default=1000, + description="Length of [warmup phase](https://unikraft.cloud/docs/api/v1/autoscale/#warmup-and-cooldown) in milliseconds. ", + ) + cooldown_time_ms: Optional[Annotated[int, Field(le=2147483647, strict=True, ge=1)]] = Field( + default=1000, + description="Length of [cooldown phase](https://unikraft.cloud/docs/api/v1/autoscale/#warmup-and-cooldown) in milliseconds. ", + ) + master: Optional[CreateAutoscaleConfigRequestMaster] = None + __properties: ClassVar[List[str]] = [ + "uuid", + "name", + "min_size", + "max_size", + "warmup_time_ms", + "cooldown_time_ms", + "master", + ] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of CreateAutoscaleConfigRequest from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of master + if self.master: + _dict["master"] = self.master.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of CreateAutoscaleConfigRequest from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "uuid": obj.get("uuid"), + "name": obj.get("name"), + "min_size": obj.get("min_size") if obj.get("min_size") is not None else 1, + "max_size": obj.get("max_size") if obj.get("max_size") is not None else 4, + "warmup_time_ms": obj.get("warmup_time_ms") if obj.get("warmup_time_ms") is not None else 1000, + "cooldown_time_ms": obj.get("cooldown_time_ms") if obj.get("cooldown_time_ms") is not None else 1000, + "master": CreateAutoscaleConfigRequestMaster.from_dict(obj["master"]) + if obj.get("master") is not None + else None, + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/create_autoscale_config_request_master.py b/unikraft_cloud_platform/models/create_autoscale_config_request_master.py new file mode 100644 index 0000000..d530d53 --- /dev/null +++ b/unikraft_cloud_platform/models/create_autoscale_config_request_master.py @@ -0,0 +1,109 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from uuid import UUID +from unikraft_cloud_platform.models.autoscale_policy import AutoscalePolicy +from typing import Optional, Set +from typing_extensions import Self + + +class CreateAutoscaleConfigRequestMaster(BaseModel): + """ + CreateAutoscaleConfigRequestMaster + """ # noqa: E501 + + uuid: Optional[UUID] = Field( + default=None, + description="The UUID of instance to use as [autoscale master](https://unikraft.cloud/docs/api/v1/autoscale/#autoscale-basics). ", + ) + name: Optional[Annotated[str, Field(strict=True, max_length=255)]] = Field( + default=None, + description="The name of instance to use as [autoscale master](https://unikraft.cloud/docs/api/v1/autoscale/#autoscale-basics). ", + ) + policies: Optional[Annotated[List[AutoscalePolicy], Field(max_length=253)]] = None + __properties: ClassVar[List[str]] = ["uuid", "name", "policies"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of CreateAutoscaleConfigRequestMaster from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in policies (list) + _items = [] + if self.policies: + for _item_policies in self.policies: + if _item_policies: + _items.append(_item_policies.to_dict()) + _dict["policies"] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of CreateAutoscaleConfigRequestMaster from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "uuid": obj.get("uuid"), + "name": obj.get("name"), + "policies": [AutoscalePolicy.from_dict(_item) for _item in obj["policies"]] + if obj.get("policies") is not None + else None, + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/create_autoscale_configuration_by_service_group_uuid_request.py b/unikraft_cloud_platform/models/create_autoscale_configuration_by_service_group_uuid_request.py deleted file mode 100644 index 19db08a..0000000 --- a/unikraft_cloud_platform/models/create_autoscale_configuration_by_service_group_uuid_request.py +++ /dev/null @@ -1,153 +0,0 @@ -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union -from uuid import UUID - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.autoscale_policy import AutoscalePolicy - from ..models.create_autoscale_configuration_by_service_group_uuid_request_instance_create_args import ( - CreateAutoscaleConfigurationByServiceGroupUUIDRequestInstanceCreateArgs, - ) - - -T = TypeVar("T", bound="CreateAutoscaleConfigurationByServiceGroupUUIDRequest") - - -@_attrs_define -class CreateAutoscaleConfigurationByServiceGroupUUIDRequest: - """The request message to create an autoscale configuration for a service group - based on its UUID. - - """ - - uuid: Union[Unset, UUID] = UNSET - """ The UUID of the service to create a configuration for. - Mutually exclusive with name. """ - min_size: Union[Unset, int] = UNSET - """ The minimum number of instances to keep running. """ - max_size: Union[Unset, int] = UNSET - """ The maximum number of instances to keep running. """ - warmup_time_ms: Union[Unset, int] = UNSET - """ The warmup time in milliseconds for new instances. """ - cooldown_time_ms: Union[Unset, int] = UNSET - """ The cooldown time in milliseconds for the autoscale configuration. """ - create_args: Union[Unset, "CreateAutoscaleConfigurationByServiceGroupUUIDRequestInstanceCreateArgs"] = UNSET - policies: Union[Unset, list["AutoscalePolicy"]] = UNSET - """ The policies to apply to the autoscale configuration. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - uuid: Union[Unset, str] = UNSET - if not isinstance(self.uuid, Unset): - uuid = str(self.uuid) - - min_size = self.min_size - - max_size = self.max_size - - warmup_time_ms = self.warmup_time_ms - - cooldown_time_ms = self.cooldown_time_ms - - create_args: Union[Unset, dict[str, Any]] = UNSET - if not isinstance(self.create_args, Unset): - create_args = self.create_args.to_dict() - - policies: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.policies, Unset): - policies = [] - for policies_item_data in self.policies: - policies_item = policies_item_data.to_dict() - policies.append(policies_item) - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if uuid is not UNSET: - field_dict["uuid"] = uuid - if min_size is not UNSET: - field_dict["min_size"] = min_size - if max_size is not UNSET: - field_dict["max_size"] = max_size - if warmup_time_ms is not UNSET: - field_dict["warmup_time_ms"] = warmup_time_ms - if cooldown_time_ms is not UNSET: - field_dict["cooldown_time_ms"] = cooldown_time_ms - if create_args is not UNSET: - field_dict["create_args"] = create_args - if policies is not UNSET: - field_dict["policies"] = policies - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.autoscale_policy import AutoscalePolicy - from ..models.create_autoscale_configuration_by_service_group_uuid_request_instance_create_args import ( - CreateAutoscaleConfigurationByServiceGroupUUIDRequestInstanceCreateArgs, - ) - - d = dict(src_dict) - _uuid = d.pop("uuid", UNSET) - uuid: Union[Unset, UUID] - if isinstance(_uuid, Unset): - uuid = UNSET - else: - uuid = UUID(_uuid) - - min_size = d.pop("min_size", UNSET) - - max_size = d.pop("max_size", UNSET) - - warmup_time_ms = d.pop("warmup_time_ms", UNSET) - - cooldown_time_ms = d.pop("cooldown_time_ms", UNSET) - - _create_args = d.pop("create_args", UNSET) - create_args: Union[Unset, CreateAutoscaleConfigurationByServiceGroupUUIDRequestInstanceCreateArgs] - if isinstance(_create_args, Unset): - create_args = UNSET - else: - create_args = CreateAutoscaleConfigurationByServiceGroupUUIDRequestInstanceCreateArgs.from_dict( - _create_args - ) - - policies = [] - _policies = d.pop("policies", UNSET) - for policies_item_data in _policies or []: - policies_item = AutoscalePolicy.from_dict(policies_item_data) - - policies.append(policies_item) - - create_autoscale_configuration_by_service_group_uuid_request = cls( - uuid=uuid, - min_size=min_size, - max_size=max_size, - warmup_time_ms=warmup_time_ms, - cooldown_time_ms=cooldown_time_ms, - create_args=create_args, - policies=policies, - ) - - create_autoscale_configuration_by_service_group_uuid_request.additional_properties = d - return create_autoscale_configuration_by_service_group_uuid_request - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/create_autoscale_configuration_by_service_group_uuid_request_instance_create_args.py b/unikraft_cloud_platform/models/create_autoscale_configuration_by_service_group_uuid_request_instance_create_args.py deleted file mode 100644 index d5b6e09..0000000 --- a/unikraft_cloud_platform/models/create_autoscale_configuration_by_service_group_uuid_request_instance_create_args.py +++ /dev/null @@ -1,42 +0,0 @@ -from collections.abc import Mapping -from typing import Any, TypeVar - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -T = TypeVar("T", bound="CreateAutoscaleConfigurationByServiceGroupUUIDRequestInstanceCreateArgs") - - -@_attrs_define -class CreateAutoscaleConfigurationByServiceGroupUUIDRequestInstanceCreateArgs: - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - d = dict(src_dict) - create_autoscale_configuration_by_service_group_uuid_request_instance_create_args = cls() - - create_autoscale_configuration_by_service_group_uuid_request_instance_create_args.additional_properties = d - return create_autoscale_configuration_by_service_group_uuid_request_instance_create_args - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/create_autoscale_configuration_policy_request.py b/unikraft_cloud_platform/models/create_autoscale_configuration_policy_request.py deleted file mode 100644 index 92af0a7..0000000 --- a/unikraft_cloud_platform/models/create_autoscale_configuration_policy_request.py +++ /dev/null @@ -1,77 +0,0 @@ -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -if TYPE_CHECKING: - from ..models.autoscale_policy import AutoscalePolicy - - -T = TypeVar("T", bound="CreateAutoscaleConfigurationPolicyRequest") - - -@_attrs_define -class CreateAutoscaleConfigurationPolicyRequest: - """The request message to create an autoscale configuration policy for a - service. - - """ - - name: str - """ The Name of the service to add a policy to. """ - type_: "AutoscalePolicy" - """ AutoscalePolicy defines the autoscale policy for a service. - Right now it contains fields from both the `ondemand` and `step` policies. - They are marked both as optional, so only one of them should be set at a - time. This is a current limitation of the API design. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - name = self.name - - type_ = self.type_.to_dict() - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update( - { - "name": name, - "type": type_, - } - ) - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.autoscale_policy import AutoscalePolicy - - d = dict(src_dict) - name = d.pop("name") - - type_ = AutoscalePolicy.from_dict(d.pop("type")) - - create_autoscale_configuration_policy_request = cls( - name=name, - type_=type_, - ) - - create_autoscale_configuration_policy_request.additional_properties = d - return create_autoscale_configuration_policy_request - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/create_autoscale_configuration_policy_response.py b/unikraft_cloud_platform/models/create_autoscale_configuration_policy_response.py deleted file mode 100644 index 7132471..0000000 --- a/unikraft_cloud_platform/models/create_autoscale_configuration_policy_response.py +++ /dev/null @@ -1,119 +0,0 @@ -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..models.response_status import ResponseStatus, check_response_status -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.create_autoscale_configuration_policy_response_data import ( - CreateAutoscaleConfigurationPolicyResponseData, - ) - from ..models.response_error import ResponseError - - -T = TypeVar("T", bound="CreateAutoscaleConfigurationPolicyResponse") - - -@_attrs_define -class CreateAutoscaleConfigurationPolicyResponse: - status: Union[Unset, ResponseStatus] = UNSET - """ The response status of an API request. """ - data: Union[Unset, "CreateAutoscaleConfigurationPolicyResponseData"] = UNSET - errors: Union[Unset, list["ResponseError"]] = UNSET - """ A list of errors which may have occurred during the request. """ - op_time_us: Union[Unset, int] = UNSET - """ The operation time in microseconds. This is the time it took to process - the request and generate the response. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - status: Union[Unset, str] = UNSET - if not isinstance(self.status, Unset): - status = self.status - - data: Union[Unset, dict[str, Any]] = UNSET - if not isinstance(self.data, Unset): - data = self.data.to_dict() - - errors: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.errors, Unset): - errors = [] - for errors_item_data in self.errors: - errors_item = errors_item_data.to_dict() - errors.append(errors_item) - - op_time_us = self.op_time_us - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if status is not UNSET: - field_dict["status"] = status - if data is not UNSET: - field_dict["data"] = data - if errors is not UNSET: - field_dict["errors"] = errors - if op_time_us is not UNSET: - field_dict["op_time_us"] = op_time_us - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.create_autoscale_configuration_policy_response_data import ( - CreateAutoscaleConfigurationPolicyResponseData, - ) - from ..models.response_error import ResponseError - - d = dict(src_dict) - _status = d.pop("status", UNSET) - status: Union[Unset, ResponseStatus] - if isinstance(_status, Unset): - status = UNSET - else: - status = check_response_status(_status) - - _data = d.pop("data", UNSET) - data: Union[Unset, CreateAutoscaleConfigurationPolicyResponseData] - if isinstance(_data, Unset): - data = UNSET - else: - data = CreateAutoscaleConfigurationPolicyResponseData.from_dict(_data) - - errors = [] - _errors = d.pop("errors", UNSET) - for errors_item_data in _errors or []: - errors_item = ResponseError.from_dict(errors_item_data) - - errors.append(errors_item) - - op_time_us = d.pop("op_time_us", UNSET) - - create_autoscale_configuration_policy_response = cls( - status=status, - data=data, - errors=errors, - op_time_us=op_time_us, - ) - - create_autoscale_configuration_policy_response.additional_properties = d - return create_autoscale_configuration_policy_response - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/create_autoscale_configuration_policy_response_data.py b/unikraft_cloud_platform/models/create_autoscale_configuration_policy_response_data.py deleted file mode 100644 index 37d928d..0000000 --- a/unikraft_cloud_platform/models/create_autoscale_configuration_policy_response_data.py +++ /dev/null @@ -1,75 +0,0 @@ -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.create_autoscale_configuration_policy_response_policy import ( - CreateAutoscaleConfigurationPolicyResponsePolicy, - ) - - -T = TypeVar("T", bound="CreateAutoscaleConfigurationPolicyResponseData") - - -@_attrs_define -class CreateAutoscaleConfigurationPolicyResponseData: - policies: Union[Unset, list["CreateAutoscaleConfigurationPolicyResponsePolicy"]] = UNSET - """ The policies which were added by the request. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - policies: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.policies, Unset): - policies = [] - for policies_item_data in self.policies: - policies_item = policies_item_data.to_dict() - policies.append(policies_item) - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if policies is not UNSET: - field_dict["policies"] = policies - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.create_autoscale_configuration_policy_response_policy import ( - CreateAutoscaleConfigurationPolicyResponsePolicy, - ) - - d = dict(src_dict) - policies = [] - _policies = d.pop("policies", UNSET) - for policies_item_data in _policies or []: - policies_item = CreateAutoscaleConfigurationPolicyResponsePolicy.from_dict(policies_item_data) - - policies.append(policies_item) - - create_autoscale_configuration_policy_response_data = cls( - policies=policies, - ) - - create_autoscale_configuration_policy_response_data.additional_properties = d - return create_autoscale_configuration_policy_response_data - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/create_autoscale_configuration_policy_response_policy.py b/unikraft_cloud_platform/models/create_autoscale_configuration_policy_response_policy.py deleted file mode 100644 index 39a048e..0000000 --- a/unikraft_cloud_platform/models/create_autoscale_configuration_policy_response_policy.py +++ /dev/null @@ -1,109 +0,0 @@ -from collections.abc import Mapping -from typing import Any, TypeVar, Union -from uuid import UUID - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..models.response_status import ResponseStatus, check_response_status -from ..types import UNSET, Unset - -T = TypeVar("T", bound="CreateAutoscaleConfigurationPolicyResponsePolicy") - - -@_attrs_define -class CreateAutoscaleConfigurationPolicyResponsePolicy: - status: Union[Unset, ResponseStatus] = UNSET - """ The response status of an API request. """ - uuid: Union[Unset, UUID] = UNSET - """ The UUID of the service of the added policy. """ - name: Union[Unset, str] = UNSET - """ The name of the service of the added policy. """ - message: Union[Unset, str] = UNSET - """ An optional message providing additional information about the status. - This field is useful when the status is not `success`. """ - error: Union[Unset, int] = UNSET - """ An optional error code providing additional information about the status. - This field is useful when the status is not `success`. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - status: Union[Unset, str] = UNSET - if not isinstance(self.status, Unset): - status = self.status - - uuid: Union[Unset, str] = UNSET - if not isinstance(self.uuid, Unset): - uuid = str(self.uuid) - - name = self.name - - message = self.message - - error = self.error - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if status is not UNSET: - field_dict["status"] = status - if uuid is not UNSET: - field_dict["uuid"] = uuid - if name is not UNSET: - field_dict["name"] = name - if message is not UNSET: - field_dict["message"] = message - if error is not UNSET: - field_dict["error"] = error - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - d = dict(src_dict) - _status = d.pop("status", UNSET) - status: Union[Unset, ResponseStatus] - if isinstance(_status, Unset): - status = UNSET - else: - status = check_response_status(_status) - - _uuid = d.pop("uuid", UNSET) - uuid: Union[Unset, UUID] - if isinstance(_uuid, Unset): - uuid = UNSET - else: - uuid = UUID(_uuid) - - name = d.pop("name", UNSET) - - message = d.pop("message", UNSET) - - error = d.pop("error", UNSET) - - create_autoscale_configuration_policy_response_policy = cls( - status=status, - uuid=uuid, - name=name, - message=message, - error=error, - ) - - create_autoscale_configuration_policy_response_policy.additional_properties = d - return create_autoscale_configuration_policy_response_policy - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/create_autoscale_configurations_request_configuration.py b/unikraft_cloud_platform/models/create_autoscale_configurations_request_configuration.py deleted file mode 100644 index e3d8f89..0000000 --- a/unikraft_cloud_platform/models/create_autoscale_configurations_request_configuration.py +++ /dev/null @@ -1,152 +0,0 @@ -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union -from uuid import UUID - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.autoscale_policy import AutoscalePolicy - from ..models.configuration_instance_create_args import ConfigurationInstanceCreateArgs - - -T = TypeVar("T", bound="CreateAutoscaleConfigurationsRequestConfiguration") - - -@_attrs_define -class CreateAutoscaleConfigurationsRequestConfiguration: - uuid: Union[Unset, UUID] = UNSET - """ The UUID of the service to create a configuration for. - Mutually exclusive with name. """ - name: Union[Unset, str] = UNSET - """ The name of the service to create a configuration for. - Mutually exclusive with UUID. """ - min_size: Union[Unset, int] = UNSET - """ The minimum number of instances to keep running. """ - max_size: Union[Unset, int] = UNSET - """ The maximum number of instances to keep running. """ - warmup_time_ms: Union[Unset, int] = UNSET - """ The warmup time in milliseconds for new instances. """ - cooldown_time_ms: Union[Unset, int] = UNSET - """ The cooldown time in milliseconds for the autoscale configuration. """ - create_args: Union[Unset, "ConfigurationInstanceCreateArgs"] = UNSET - policies: Union[Unset, list["AutoscalePolicy"]] = UNSET - """ The policies to apply to the autoscale configuration. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - uuid: Union[Unset, str] = UNSET - if not isinstance(self.uuid, Unset): - uuid = str(self.uuid) - - name = self.name - - min_size = self.min_size - - max_size = self.max_size - - warmup_time_ms = self.warmup_time_ms - - cooldown_time_ms = self.cooldown_time_ms - - create_args: Union[Unset, dict[str, Any]] = UNSET - if not isinstance(self.create_args, Unset): - create_args = self.create_args.to_dict() - - policies: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.policies, Unset): - policies = [] - for policies_item_data in self.policies: - policies_item = policies_item_data.to_dict() - policies.append(policies_item) - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if uuid is not UNSET: - field_dict["uuid"] = uuid - if name is not UNSET: - field_dict["name"] = name - if min_size is not UNSET: - field_dict["min_size"] = min_size - if max_size is not UNSET: - field_dict["max_size"] = max_size - if warmup_time_ms is not UNSET: - field_dict["warmup_time_ms"] = warmup_time_ms - if cooldown_time_ms is not UNSET: - field_dict["cooldown_time_ms"] = cooldown_time_ms - if create_args is not UNSET: - field_dict["create_args"] = create_args - if policies is not UNSET: - field_dict["policies"] = policies - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.autoscale_policy import AutoscalePolicy - from ..models.configuration_instance_create_args import ConfigurationInstanceCreateArgs - - d = dict(src_dict) - _uuid = d.pop("uuid", UNSET) - uuid: Union[Unset, UUID] - if isinstance(_uuid, Unset): - uuid = UNSET - else: - uuid = UUID(_uuid) - - name = d.pop("name", UNSET) - - min_size = d.pop("min_size", UNSET) - - max_size = d.pop("max_size", UNSET) - - warmup_time_ms = d.pop("warmup_time_ms", UNSET) - - cooldown_time_ms = d.pop("cooldown_time_ms", UNSET) - - _create_args = d.pop("create_args", UNSET) - create_args: Union[Unset, ConfigurationInstanceCreateArgs] - if isinstance(_create_args, Unset): - create_args = UNSET - else: - create_args = ConfigurationInstanceCreateArgs.from_dict(_create_args) - - policies = [] - _policies = d.pop("policies", UNSET) - for policies_item_data in _policies or []: - policies_item = AutoscalePolicy.from_dict(policies_item_data) - - policies.append(policies_item) - - create_autoscale_configurations_request_configuration = cls( - uuid=uuid, - name=name, - min_size=min_size, - max_size=max_size, - warmup_time_ms=warmup_time_ms, - cooldown_time_ms=cooldown_time_ms, - create_args=create_args, - policies=policies, - ) - - create_autoscale_configurations_request_configuration.additional_properties = d - return create_autoscale_configurations_request_configuration - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/create_autoscale_configurations_response.py b/unikraft_cloud_platform/models/create_autoscale_configurations_response.py deleted file mode 100644 index eaf8e91..0000000 --- a/unikraft_cloud_platform/models/create_autoscale_configurations_response.py +++ /dev/null @@ -1,117 +0,0 @@ -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..models.response_status import ResponseStatus, check_response_status -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.create_autoscale_configurations_response_data import CreateAutoscaleConfigurationsResponseData - from ..models.response_error import ResponseError - - -T = TypeVar("T", bound="CreateAutoscaleConfigurationsResponse") - - -@_attrs_define -class CreateAutoscaleConfigurationsResponse: - """The response to a CreateAutoscaleConfigurationRequest.""" - - status: Union[Unset, ResponseStatus] = UNSET - """ The response status of an API request. """ - data: Union[Unset, "CreateAutoscaleConfigurationsResponseData"] = UNSET - errors: Union[Unset, list["ResponseError"]] = UNSET - """ A list of errors which may have occurred during the request. """ - op_time_us: Union[Unset, int] = UNSET - """ The operation time in microseconds. This is the time it took to process - the request and generate the response. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - status: Union[Unset, str] = UNSET - if not isinstance(self.status, Unset): - status = self.status - - data: Union[Unset, dict[str, Any]] = UNSET - if not isinstance(self.data, Unset): - data = self.data.to_dict() - - errors: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.errors, Unset): - errors = [] - for errors_item_data in self.errors: - errors_item = errors_item_data.to_dict() - errors.append(errors_item) - - op_time_us = self.op_time_us - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if status is not UNSET: - field_dict["status"] = status - if data is not UNSET: - field_dict["data"] = data - if errors is not UNSET: - field_dict["errors"] = errors - if op_time_us is not UNSET: - field_dict["op_time_us"] = op_time_us - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.create_autoscale_configurations_response_data import CreateAutoscaleConfigurationsResponseData - from ..models.response_error import ResponseError - - d = dict(src_dict) - _status = d.pop("status", UNSET) - status: Union[Unset, ResponseStatus] - if isinstance(_status, Unset): - status = UNSET - else: - status = check_response_status(_status) - - _data = d.pop("data", UNSET) - data: Union[Unset, CreateAutoscaleConfigurationsResponseData] - if isinstance(_data, Unset): - data = UNSET - else: - data = CreateAutoscaleConfigurationsResponseData.from_dict(_data) - - errors = [] - _errors = d.pop("errors", UNSET) - for errors_item_data in _errors or []: - errors_item = ResponseError.from_dict(errors_item_data) - - errors.append(errors_item) - - op_time_us = d.pop("op_time_us", UNSET) - - create_autoscale_configurations_response = cls( - status=status, - data=data, - errors=errors, - op_time_us=op_time_us, - ) - - create_autoscale_configurations_response.additional_properties = d - return create_autoscale_configurations_response - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/create_autoscale_configurations_response_configurations_response.py b/unikraft_cloud_platform/models/create_autoscale_configurations_response_configurations_response.py deleted file mode 100644 index 79dd0d3..0000000 --- a/unikraft_cloud_platform/models/create_autoscale_configurations_response_configurations_response.py +++ /dev/null @@ -1,109 +0,0 @@ -from collections.abc import Mapping -from typing import Any, TypeVar, Union -from uuid import UUID - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..models.response_status import ResponseStatus, check_response_status -from ..types import UNSET, Unset - -T = TypeVar("T", bound="CreateAutoscaleConfigurationsResponseConfigurationsResponse") - - -@_attrs_define -class CreateAutoscaleConfigurationsResponseConfigurationsResponse: - status: Union[Unset, ResponseStatus] = UNSET - """ The response status of an API request. """ - uuid: Union[Unset, UUID] = UNSET - """ The UUID of the service where the configuration was created. """ - name: Union[Unset, str] = UNSET - """ The name of the service where the configuration was created. """ - message: Union[Unset, str] = UNSET - """ An optional message providing additional information about the status. - This field is useful when the status is not `success`. """ - error: Union[Unset, int] = UNSET - """ An optional error code providing additional information about the status. - This field is useful when the status is not `success`. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - status: Union[Unset, str] = UNSET - if not isinstance(self.status, Unset): - status = self.status - - uuid: Union[Unset, str] = UNSET - if not isinstance(self.uuid, Unset): - uuid = str(self.uuid) - - name = self.name - - message = self.message - - error = self.error - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if status is not UNSET: - field_dict["status"] = status - if uuid is not UNSET: - field_dict["uuid"] = uuid - if name is not UNSET: - field_dict["name"] = name - if message is not UNSET: - field_dict["message"] = message - if error is not UNSET: - field_dict["error"] = error - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - d = dict(src_dict) - _status = d.pop("status", UNSET) - status: Union[Unset, ResponseStatus] - if isinstance(_status, Unset): - status = UNSET - else: - status = check_response_status(_status) - - _uuid = d.pop("uuid", UNSET) - uuid: Union[Unset, UUID] - if isinstance(_uuid, Unset): - uuid = UNSET - else: - uuid = UUID(_uuid) - - name = d.pop("name", UNSET) - - message = d.pop("message", UNSET) - - error = d.pop("error", UNSET) - - create_autoscale_configurations_response_configurations_response = cls( - status=status, - uuid=uuid, - name=name, - message=message, - error=error, - ) - - create_autoscale_configurations_response_configurations_response.additional_properties = d - return create_autoscale_configurations_response_configurations_response - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/create_autoscale_configurations_response_data.py b/unikraft_cloud_platform/models/create_autoscale_configurations_response_data.py deleted file mode 100644 index ff31fe1..0000000 --- a/unikraft_cloud_platform/models/create_autoscale_configurations_response_data.py +++ /dev/null @@ -1,77 +0,0 @@ -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.create_autoscale_configurations_response_configurations_response import ( - CreateAutoscaleConfigurationsResponseConfigurationsResponse, - ) - - -T = TypeVar("T", bound="CreateAutoscaleConfigurationsResponseData") - - -@_attrs_define -class CreateAutoscaleConfigurationsResponseData: - service_groups: Union[Unset, list["CreateAutoscaleConfigurationsResponseConfigurationsResponse"]] = UNSET - """ The configuration(s) which were created by the request. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - service_groups: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.service_groups, Unset): - service_groups = [] - for service_groups_item_data in self.service_groups: - service_groups_item = service_groups_item_data.to_dict() - service_groups.append(service_groups_item) - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if service_groups is not UNSET: - field_dict["service_groups"] = service_groups - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.create_autoscale_configurations_response_configurations_response import ( - CreateAutoscaleConfigurationsResponseConfigurationsResponse, - ) - - d = dict(src_dict) - service_groups = [] - _service_groups = d.pop("service_groups", UNSET) - for service_groups_item_data in _service_groups or []: - service_groups_item = CreateAutoscaleConfigurationsResponseConfigurationsResponse.from_dict( - service_groups_item_data - ) - - service_groups.append(service_groups_item) - - create_autoscale_configurations_response_data = cls( - service_groups=service_groups, - ) - - create_autoscale_configurations_response_data.additional_properties = d - return create_autoscale_configurations_response_data - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/create_autoscale_policy200_response.py b/unikraft_cloud_platform/models/create_autoscale_policy200_response.py new file mode 100644 index 0000000..7790c51 --- /dev/null +++ b/unikraft_cloud_platform/models/create_autoscale_policy200_response.py @@ -0,0 +1,105 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from unikraft_cloud_platform.models.create_autoscale_policy200_response_data import CreateAutoscalePolicy200ResponseData +from typing import Optional, Set +from typing_extensions import Self + + +class CreateAutoscalePolicy200Response(BaseModel): + """ + CreateAutoscalePolicy200Response + """ # noqa: E501 + + status: Optional[StrictStr] = Field(default=None, description="The status of the response. ") + data: Optional[CreateAutoscalePolicy200ResponseData] = None + __properties: ClassVar[List[str]] = ["status", "data"] + + @field_validator("status") + def status_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(["success", "failure"]): + raise ValueError("must be one of enum values ('success', 'failure')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of CreateAutoscalePolicy200Response from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of data + if self.data: + _dict["data"] = self.data.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of CreateAutoscalePolicy200Response from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "status": obj.get("status"), + "data": CreateAutoscalePolicy200ResponseData.from_dict(obj["data"]) + if obj.get("data") is not None + else None, + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/create_autoscale_policy200_response_data.py b/unikraft_cloud_platform/models/create_autoscale_policy200_response_data.py new file mode 100644 index 0000000..b58666d --- /dev/null +++ b/unikraft_cloud_platform/models/create_autoscale_policy200_response_data.py @@ -0,0 +1,105 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from unikraft_cloud_platform.models.create_autoscale_policy200_response_data_certificates_inner import ( + CreateAutoscalePolicy200ResponseDataCertificatesInner, +) +from typing import Optional, Set +from typing_extensions import Self + + +class CreateAutoscalePolicy200ResponseData(BaseModel): + """ + CreateAutoscalePolicy200ResponseData + """ # noqa: E501 + + certificates: Optional[ + Annotated[List[CreateAutoscalePolicy200ResponseDataCertificatesInner], Field(max_length=253)] + ] = None + __properties: ClassVar[List[str]] = ["certificates"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of CreateAutoscalePolicy200ResponseData from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in certificates (list) + _items = [] + if self.certificates: + for _item_certificates in self.certificates: + if _item_certificates: + _items.append(_item_certificates.to_dict()) + _dict["certificates"] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of CreateAutoscalePolicy200ResponseData from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "certificates": [ + CreateAutoscalePolicy200ResponseDataCertificatesInner.from_dict(_item) + for _item in obj["certificates"] + ] + if obj.get("certificates") is not None + else None + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/create_autoscale_policy200_response_data_certificates_inner.py b/unikraft_cloud_platform/models/create_autoscale_policy200_response_data_certificates_inner.py new file mode 100644 index 0000000..405a280 --- /dev/null +++ b/unikraft_cloud_platform/models/create_autoscale_policy200_response_data_certificates_inner.py @@ -0,0 +1,88 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from uuid import UUID +from typing import Optional, Set +from typing_extensions import Self + + +class CreateAutoscalePolicy200ResponseDataCertificatesInner(BaseModel): + """ + CreateAutoscalePolicy200ResponseDataCertificatesInner + """ # noqa: E501 + + uuid: Optional[UUID] = Field(default=None, description="The UUID of the service. ") + name: Optional[Annotated[str, Field(strict=True, max_length=255)]] = Field( + default=None, description="The name of the service. " + ) + __properties: ClassVar[List[str]] = ["uuid", "name"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of CreateAutoscalePolicy200ResponseDataCertificatesInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of CreateAutoscalePolicy200ResponseDataCertificatesInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({"uuid": obj.get("uuid"), "name": obj.get("name")}) + return _obj diff --git a/unikraft_cloud_platform/models/create_autoscale_policy_request.py b/unikraft_cloud_platform/models/create_autoscale_policy_request.py new file mode 100644 index 0000000..97520ed --- /dev/null +++ b/unikraft_cloud_platform/models/create_autoscale_policy_request.py @@ -0,0 +1,121 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from unikraft_cloud_platform.models.autoscale_policy_step import AutoscalePolicyStep +from typing import Optional, Set +from typing_extensions import Self + + +class CreateAutoscalePolicyRequest(BaseModel): + """ + CreateAutoscalePolicyRequest + """ # noqa: E501 + + name: Optional[Annotated[str, Field(strict=True, max_length=255)]] = Field( + default=None, description="The name of the policy. " + ) + type: Optional[StrictStr] = Field(default=None, description="Type of autoscale policy. ") + metric: Optional[StrictStr] = Field(default="cpu", description="Metric to monitor. ") + adjustment_type: Optional[StrictStr] = Field(default="change", description="Type of adjustment. ") + steps: Optional[AutoscalePolicyStep] = None + __properties: ClassVar[List[str]] = [] + + @field_validator("type") + def type_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(["step"]): + raise ValueError("must be one of enum values ('step')") + return value + + @field_validator("metric") + def metric_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(["cpu"]): + raise ValueError("must be one of enum values ('cpu')") + return value + + @field_validator("adjustment_type") + def adjustment_type_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(["change", "exact", "percent"]): + raise ValueError("must be one of enum values ('change', 'exact', 'percent')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of CreateAutoscalePolicyRequest from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of CreateAutoscalePolicyRequest from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({}) + return _obj diff --git a/unikraft_cloud_platform/models/create_certificate200_response.py b/unikraft_cloud_platform/models/create_certificate200_response.py new file mode 100644 index 0000000..8556f1f --- /dev/null +++ b/unikraft_cloud_platform/models/create_certificate200_response.py @@ -0,0 +1,105 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from unikraft_cloud_platform.models.create_certificate200_response_data import CreateCertificate200ResponseData +from typing import Optional, Set +from typing_extensions import Self + + +class CreateCertificate200Response(BaseModel): + """ + CreateCertificate200Response + """ # noqa: E501 + + status: Optional[StrictStr] = Field(default=None, description="The status of the response. ") + data: Optional[CreateCertificate200ResponseData] = None + __properties: ClassVar[List[str]] = ["status", "data"] + + @field_validator("status") + def status_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(["success", "failure"]): + raise ValueError("must be one of enum values ('success', 'failure')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of CreateCertificate200Response from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of data + if self.data: + _dict["data"] = self.data.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of CreateCertificate200Response from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "status": obj.get("status"), + "data": CreateCertificate200ResponseData.from_dict(obj["data"]) + if obj.get("data") is not None + else None, + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/create_certificate200_response_data.py b/unikraft_cloud_platform/models/create_certificate200_response_data.py new file mode 100644 index 0000000..c4d29a8 --- /dev/null +++ b/unikraft_cloud_platform/models/create_certificate200_response_data.py @@ -0,0 +1,104 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from unikraft_cloud_platform.models.create_certificate200_response_data_certificates_inner import ( + CreateCertificate200ResponseDataCertificatesInner, +) +from typing import Optional, Set +from typing_extensions import Self + + +class CreateCertificate200ResponseData(BaseModel): + """ + CreateCertificate200ResponseData + """ # noqa: E501 + + certificates: Optional[ + Annotated[List[CreateCertificate200ResponseDataCertificatesInner], Field(max_length=253)] + ] = None + __properties: ClassVar[List[str]] = ["certificates"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of CreateCertificate200ResponseData from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in certificates (list) + _items = [] + if self.certificates: + for _item_certificates in self.certificates: + if _item_certificates: + _items.append(_item_certificates.to_dict()) + _dict["certificates"] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of CreateCertificate200ResponseData from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "certificates": [ + CreateCertificate200ResponseDataCertificatesInner.from_dict(_item) for _item in obj["certificates"] + ] + if obj.get("certificates") is not None + else None + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/create_certificate200_response_data_certificates_inner.py b/unikraft_cloud_platform/models/create_certificate200_response_data_certificates_inner.py new file mode 100644 index 0000000..c9d3bdd --- /dev/null +++ b/unikraft_cloud_platform/models/create_certificate200_response_data_certificates_inner.py @@ -0,0 +1,88 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from uuid import UUID +from typing import Optional, Set +from typing_extensions import Self + + +class CreateCertificate200ResponseDataCertificatesInner(BaseModel): + """ + CreateCertificate200ResponseDataCertificatesInner + """ # noqa: E501 + + uuid: Optional[UUID] = Field(default=None, description="UUID of the certificate") + name: Optional[Annotated[str, Field(strict=True, max_length=255)]] = Field( + default=None, description="Name of the certificate" + ) + __properties: ClassVar[List[str]] = ["uuid", "name"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of CreateCertificate200ResponseDataCertificatesInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of CreateCertificate200ResponseDataCertificatesInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({"uuid": obj.get("uuid"), "name": obj.get("name")}) + return _obj diff --git a/unikraft_cloud_platform/models/create_certificate_request.py b/unikraft_cloud_platform/models/create_certificate_request.py index 634f2da..a8b1947 100644 --- a/unikraft_cloud_platform/models/create_certificate_request.py +++ b/unikraft_cloud_platform/models/create_certificate_request.py @@ -1,73 +1,114 @@ -from collections.abc import Mapping -from typing import Any, TypeVar +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from typing import Optional, Set +from typing_extensions import Self + + +class CreateCertificateRequest(BaseModel): + """ + CreateCertificateRequest + """ # noqa: E501 + + name: Optional[Annotated[str, Field(strict=True, max_length=255)]] = Field( + default=None, + description="The name of the certificate to upload. Note: If no name is specified a random name of the form `-X` is auto-generated, where `` is the common name and `X` is a 5 character long random alphanumeric suffix. For wildcard domains the wildcard part is cut off. ", + ) + cn: Annotated[str, Field(strict=True, max_length=255)] = Field(description="The common name of the certificate. ") + chain: Annotated[str, Field(strict=True, max_length=8388608)] = Field( + description="The chain of the certificate in PEM format. " + ) + pkey: Annotated[str, Field(strict=True, max_length=8388608)] = Field( + description="The private key of the certificate in PEM format. " + ) + __properties: ClassVar[List[str]] = ["name", "cn", "chain", "pkey"] + + @field_validator("chain") + def chain_validate_regular_expression(cls, value): + """Validates the regular expression""" + if not re.match(r"^-----BEGIN CERTIFICATE-----.+-----END CERTIFICATE-----", value): + raise ValueError( + r"must validate the regular expression /^-----BEGIN CERTIFICATE-----.+-----END CERTIFICATE-----/" + ) + return value + + @field_validator("pkey") + def pkey_validate_regular_expression(cls, value): + """Validates the regular expression""" + if not re.match(r"^-----BEGIN PRIVATE KEY-----.+-----END PRIVATE KEY-----", value): + raise ValueError( + r"must validate the regular expression /^-----BEGIN PRIVATE KEY-----.+-----END PRIVATE KEY-----/" + ) + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -T = TypeVar("T", bound="CreateCertificateRequest") - - -@_attrs_define -class CreateCertificateRequest: - """The request message for creating/uploading a new certificate.""" - - cn: str - """ The common name (CN) of the certificate. """ - chain: str - """ The chain of the certificate. """ - pkey: str - """ The private key of the certificate. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - cn = self.cn - - chain = self.chain - - pkey = self.pkey - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update( - { - "cn": cn, - "chain": chain, - "pkey": pkey, - } + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of CreateCertificateRequest from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, ) - - return field_dict + return _dict @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - d = dict(src_dict) - cn = d.pop("cn") - - chain = d.pop("chain") + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of CreateCertificateRequest from a dict""" + if obj is None: + return None - pkey = d.pop("pkey") + if not isinstance(obj, dict): + return cls.model_validate(obj) - create_certificate_request = cls( - cn=cn, - chain=chain, - pkey=pkey, + _obj = cls.model_validate( + {"name": obj.get("name"), "cn": obj.get("cn"), "chain": obj.get("chain"), "pkey": obj.get("pkey")} ) - - create_certificate_request.additional_properties = d - return create_certificate_request - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties + return _obj diff --git a/unikraft_cloud_platform/models/create_certificate_response.py b/unikraft_cloud_platform/models/create_certificate_response.py deleted file mode 100644 index 071135c..0000000 --- a/unikraft_cloud_platform/models/create_certificate_response.py +++ /dev/null @@ -1,127 +0,0 @@ -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..models.response_status import ResponseStatus, check_response_status -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.create_certificate_response_data import CreateCertificateResponseData - from ..models.response_error import ResponseError - - -T = TypeVar("T", bound="CreateCertificateResponse") - - -@_attrs_define -class CreateCertificateResponse: - """The response message for creating of a certificate.""" - - status: Union[Unset, ResponseStatus] = UNSET - """ The response status of an API request. """ - message: Union[Unset, str] = UNSET - """ An optional message providing additional information about the status. - This field is useful when the status is not `success`. """ - data: Union[Unset, "CreateCertificateResponseData"] = UNSET - errors: Union[Unset, list["ResponseError"]] = UNSET - """ A list of errors which may have occurred during the request. """ - op_time_us: Union[Unset, int] = UNSET - """ The operation time in microseconds. This is the time it took to process - the request and generate the response. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - status: Union[Unset, str] = UNSET - if not isinstance(self.status, Unset): - status = self.status - - message = self.message - - data: Union[Unset, dict[str, Any]] = UNSET - if not isinstance(self.data, Unset): - data = self.data.to_dict() - - errors: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.errors, Unset): - errors = [] - for errors_item_data in self.errors: - errors_item = errors_item_data.to_dict() - errors.append(errors_item) - - op_time_us = self.op_time_us - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if status is not UNSET: - field_dict["status"] = status - if message is not UNSET: - field_dict["message"] = message - if data is not UNSET: - field_dict["data"] = data - if errors is not UNSET: - field_dict["errors"] = errors - if op_time_us is not UNSET: - field_dict["op_time_us"] = op_time_us - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.create_certificate_response_data import CreateCertificateResponseData - from ..models.response_error import ResponseError - - d = dict(src_dict) - _status = d.pop("status", UNSET) - status: Union[Unset, ResponseStatus] - if isinstance(_status, Unset): - status = UNSET - else: - status = check_response_status(_status) - - message = d.pop("message", UNSET) - - _data = d.pop("data", UNSET) - data: Union[Unset, CreateCertificateResponseData] - if isinstance(_data, Unset): - data = UNSET - else: - data = CreateCertificateResponseData.from_dict(_data) - - errors = [] - _errors = d.pop("errors", UNSET) - for errors_item_data in _errors or []: - errors_item = ResponseError.from_dict(errors_item_data) - - errors.append(errors_item) - - op_time_us = d.pop("op_time_us", UNSET) - - create_certificate_response = cls( - status=status, - message=message, - data=data, - errors=errors, - op_time_us=op_time_us, - ) - - create_certificate_response.additional_properties = d - return create_certificate_response - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/create_certificate_response_data.py b/unikraft_cloud_platform/models/create_certificate_response_data.py deleted file mode 100644 index 2a2c8ba..0000000 --- a/unikraft_cloud_platform/models/create_certificate_response_data.py +++ /dev/null @@ -1,74 +0,0 @@ -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.certificate import Certificate - - -T = TypeVar("T", bound="CreateCertificateResponseData") - - -@_attrs_define -class CreateCertificateResponseData: - certificates: Union[Unset, list["Certificate"]] = UNSET - """ The certificate which was created by this request. - - Note: only one certificate can be specified in the request, so this - will always contain a single entry. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - certificates: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.certificates, Unset): - certificates = [] - for certificates_item_data in self.certificates: - certificates_item = certificates_item_data.to_dict() - certificates.append(certificates_item) - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if certificates is not UNSET: - field_dict["certificates"] = certificates - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.certificate import Certificate - - d = dict(src_dict) - certificates = [] - _certificates = d.pop("certificates", UNSET) - for certificates_item_data in _certificates or []: - certificates_item = Certificate.from_dict(certificates_item_data) - - certificates.append(certificates_item) - - create_certificate_response_data = cls( - certificates=certificates, - ) - - create_certificate_response_data.additional_properties = d - return create_certificate_response_data - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/create_instance200_response.py b/unikraft_cloud_platform/models/create_instance200_response.py new file mode 100644 index 0000000..c9fe414 --- /dev/null +++ b/unikraft_cloud_platform/models/create_instance200_response.py @@ -0,0 +1,103 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from unikraft_cloud_platform.models.instance import Instance +from typing import Optional, Set +from typing_extensions import Self + + +class CreateInstance200Response(BaseModel): + """ + CreateInstance200Response + """ # noqa: E501 + + status: Optional[StrictStr] = Field(default=None, description="The status of the response. ") + data: Optional[Instance] = None + __properties: ClassVar[List[str]] = ["status", "data"] + + @field_validator("status") + def status_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(["success", "failure"]): + raise ValueError("must be one of enum values ('success', 'failure')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of CreateInstance200Response from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of data + if self.data: + _dict["data"] = self.data.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of CreateInstance200Response from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "status": obj.get("status"), + "data": Instance.from_dict(obj["data"]) if obj.get("data") is not None else None, + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/create_instance_request.py b/unikraft_cloud_platform/models/create_instance_request.py index b5119fe..e074ea5 100644 --- a/unikraft_cloud_platform/models/create_instance_request.py +++ b/unikraft_cloud_platform/models/create_instance_request.py @@ -1,270 +1,214 @@ -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union, cast +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from unikraft_cloud_platform.models.create_instance_request_env import CreateInstanceRequestEnv +from unikraft_cloud_platform.models.create_instance_request_scale_to_zero import CreateInstanceRequestScaleToZero +from unikraft_cloud_platform.models.create_instance_request_service_group import CreateInstanceRequestServiceGroup +from unikraft_cloud_platform.models.create_instance_request_volumes_inner import CreateInstanceRequestVolumesInner +from typing import Optional, Set +from typing_extensions import Self + + +class CreateInstanceRequest(BaseModel): + """ + CreateInstanceRequest + """ # noqa: E501 + + name: Optional[Annotated[str, Field(strict=True, max_length=255)]] = Field( + default=None, + description="The name of the instance. The instance will receive a DNS entry in your private network of the form `.internal`. Note: If no name is specified a random name of the form `-X` is auto-generated, where `` is the application name taken from `image` (e.g., `myapp` for `../myapp:latest`) and `X` is a 5 character long random alphanumeric suffix. ", + ) + image: Annotated[str, Field(strict=True, max_length=8388608)] = Field( + description="Digest of the image that the instance uses. Note: The image tag (e.g., `latest`) is translated by Unikraft Cloud to the image digest that was assigned the tag at the time of instance creation. The image is pinned to this particular version. " + ) + args: Optional[Annotated[List[Annotated[str, Field(strict=True, max_length=8388608)]], Field(max_length=253)]] = ( + Field(default=None, description="Application arguments. ") + ) + env: Optional[CreateInstanceRequestEnv] = None + memory_mb: Optional[Annotated[int, Field(le=4096, strict=True, ge=16)]] = Field( + default=None, description="Amount of memory assigned to the instance in megabytes. " + ) + restart_policy: Optional[StrictStr] = Field( + default="never", + description="When an instance stops either because the application exits or the instance crashes, Unikraft Cloud can auto-restart your instance. Auto-restarts are performed according to the restart policy configured for a particular instance. The policy can have the following values: Policy | Description -------------|------------ `always` | Always restart the instance when the stop is initiated from within the instance (i.e., the application exits or the instance crashes). `on-failure` | Only restart the instance if it crashes. `never` | Never restart the instance (default). ", + ) + scale_to_zero: Optional[CreateInstanceRequestScaleToZero] = None + volumes: Optional[Annotated[List[Optional[CreateInstanceRequestVolumesInner]], Field(max_length=253)]] = Field( + default=None, description="Description of [volumes](https://unikraft.cloud/docs/api/v1/volumes). " + ) + service_group: Optional[CreateInstanceRequestServiceGroup] = None + autostart: Optional[StrictBool] = Field( + default=False, description="Autostart behavior. If `true` the instance will start immediately after creation. " + ) + replicas: Optional[Annotated[int, Field(le=253, strict=True, ge=0)]] = Field( + default=0, description="Number of instance replicas to create with these properties. " + ) + wait_timeout_ms: Optional[Annotated[int, Field(le=2147483647, strict=True, ge=0)]] = Field( + default=0, + description="Timeout to wait for all new instances to reach running state in milliseconds. No wait performed for `0` Note: Only valid if `autostart` is `true`. The maximum timeout may vary. Use `-1` for the largest possible value. ", + ) + features: Optional[Annotated[List[StrictStr], Field(max_length=253)]] = Field( + default=None, + description="Set of features to enable for the instance (see [below](https://unikraft.cloud/docs/api/v1/instances/#features)). ", + ) + __properties: ClassVar[List[str]] = [ + "name", + "image", + "args", + "env", + "memory_mb", + "restart_policy", + "scale_to_zero", + "volumes", + "service_group", + "autostart", + "replicas", + "wait_timeout_ms", + "features", + ] + + @field_validator("image") + def image_validate_regular_expression(cls, value): + """Validates the regular expression""" + if not re.match( + r"^(?:(?=[^:\/]{1,253})(?!-)[a-zA-Z0-9-]{1,63}(? str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..models.create_instance_request_features_item import ( - CreateInstanceRequestFeaturesItem, - check_create_instance_request_features_item, -) -from ..models.create_instance_request_restart_policy import ( - CreateInstanceRequestRestartPolicy, - check_create_instance_request_restart_policy, -) -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.create_instance_request_env import CreateInstanceRequestEnv - from ..models.create_instance_request_service_group import CreateInstanceRequestServiceGroup - from ..models.create_instance_request_volume import CreateInstanceRequestVolume - from ..models.instance_scale_to_zero import InstanceScaleToZero - - -T = TypeVar("T", bound="CreateInstanceRequest") - - -@_attrs_define -class CreateInstanceRequest: - """The request message for creating a new instance.""" - - image: str - """ The image to use for the instance. """ - name: Union[Unset, str] = UNSET - """ (Optional). The name of the instance. - - If not provided, a random name will be generated. The name must be unique. """ - args: Union[Unset, list[str]] = UNSET - """ (Optional). The arguments to pass to the instance when it starts. """ - env: Union[Unset, "CreateInstanceRequestEnv"] = UNSET - """ (Optional). Environment variables to set for the instance. """ - memory_mb: Union[Unset, int] = UNSET - """ (Optional). Memory in MB to allocate for the instance. Default is 128. """ - service_group: Union[Unset, "CreateInstanceRequestServiceGroup"] = UNSET - """ The service group configuration when creating an instance. - - If no existing (persistent) service group is specified via its identifier, - a new (ephemeral) service group can be created by specifying the services - it should expose. A service defines the configuration settings of an - exposed port by the instance. A service is a combination of a public port, - an internal port, and a set of handlers that define how the service will - handle incoming connections. """ - volumes: Union[Unset, list["CreateInstanceRequestVolume"]] = UNSET - """ Volumes to attach to the instance. - - This list can contain both existing and new volumes to create as part of - the instance creation. Existing volumes can be referenced by their name or - UUID. New volumes can be created by specifying a name, size in MiB, and - mount point in the instance. The mount point is the directory in the - instance where the volume will be mounted. """ - autostart: Union[Unset, bool] = UNSET - """ Whether the instance should start automatically on creation. """ - replicas: Union[Unset, int] = UNSET - """ Number of replicas for the instance. """ - restart_policy: Union[Unset, CreateInstanceRequestRestartPolicy] = UNSET - """ Restart policy for the instance. This defines how the instance should - behave when it stops or crashes. """ - scale_to_zero: Union[Unset, "InstanceScaleToZero"] = UNSET - """ Scale-to-zero defines the configuration for scaling the instance to zero. - When an instance is scaled-to-zero it can be either stopped (and fully - shutdown) or paused wherein the state of the instance is preserved (e.g., RAM - contents) and the instance can be resumed later without losing its state, - i.e. "stateful". """ - vcpus: Union[Unset, int] = UNSET - """ Number of vCPUs to allocate for the instance. """ - wait_timeout_ms: Union[Unset, int] = UNSET - """ Timeout to wait for all new instances to reach running state in - milliseconds. If you autostart your new instance, you can wait for it to - finish starting with a blocking API call if you specify a wait timeout - greater than zero. No wait performed for a value of 0. """ - features: Union[Unset, list[CreateInstanceRequestFeaturesItem]] = UNSET - """ Features to enable for the instance. Features are specific - configurations or capabilities that can be enabled for the instance. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - image = self.image - - name = self.name - - args: Union[Unset, list[str]] = UNSET - if not isinstance(self.args, Unset): - args = self.args - - env: Union[Unset, dict[str, Any]] = UNSET - if not isinstance(self.env, Unset): - env = self.env.to_dict() - - memory_mb = self.memory_mb - - service_group: Union[Unset, dict[str, Any]] = UNSET - if not isinstance(self.service_group, Unset): - service_group = self.service_group.to_dict() - - volumes: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.volumes, Unset): - volumes = [] - for volumes_item_data in self.volumes: - volumes_item = volumes_item_data.to_dict() - volumes.append(volumes_item) - - autostart = self.autostart - - replicas = self.replicas - - restart_policy: Union[Unset, str] = UNSET - if not isinstance(self.restart_policy, Unset): - restart_policy = self.restart_policy - - scale_to_zero: Union[Unset, dict[str, Any]] = UNSET - if not isinstance(self.scale_to_zero, Unset): - scale_to_zero = self.scale_to_zero.to_dict() - - vcpus = self.vcpus - - wait_timeout_ms = self.wait_timeout_ms - - features: Union[Unset, list[str]] = UNSET - if not isinstance(self.features, Unset): - features = [] - for features_item_data in self.features: - features_item: str = features_item_data - features.append(features_item) - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update( - { - "image": image, - } + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of CreateInstanceRequest from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, ) - if name is not UNSET: - field_dict["name"] = name - if args is not UNSET: - field_dict["args"] = args - if env is not UNSET: - field_dict["env"] = env - if memory_mb is not UNSET: - field_dict["memory_mb"] = memory_mb - if service_group is not UNSET: - field_dict["service_group"] = service_group - if volumes is not UNSET: - field_dict["volumes"] = volumes - if autostart is not UNSET: - field_dict["autostart"] = autostart - if replicas is not UNSET: - field_dict["replicas"] = replicas - if restart_policy is not UNSET: - field_dict["restart_policy"] = restart_policy - if scale_to_zero is not UNSET: - field_dict["scale_to_zero"] = scale_to_zero - if vcpus is not UNSET: - field_dict["vcpus"] = vcpus - if wait_timeout_ms is not UNSET: - field_dict["wait_timeout_ms"] = wait_timeout_ms - if features is not UNSET: - field_dict["features"] = features - - return field_dict + # override the default output from pydantic by calling `to_dict()` of env + if self.env: + _dict["env"] = self.env.to_dict() + # override the default output from pydantic by calling `to_dict()` of scale_to_zero + if self.scale_to_zero: + _dict["scale_to_zero"] = self.scale_to_zero.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in volumes (list) + _items = [] + if self.volumes: + for _item_volumes in self.volumes: + if _item_volumes: + _items.append(_item_volumes.to_dict()) + _dict["volumes"] = _items + # override the default output from pydantic by calling `to_dict()` of service_group + if self.service_group: + _dict["service_group"] = self.service_group.to_dict() + # set to None if service_group (nullable) is None + # and model_fields_set contains the field + if self.service_group is None and "service_group" in self.model_fields_set: + _dict["service_group"] = None + + return _dict @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.create_instance_request_env import CreateInstanceRequestEnv - from ..models.create_instance_request_service_group import CreateInstanceRequestServiceGroup - from ..models.create_instance_request_volume import CreateInstanceRequestVolume - from ..models.instance_scale_to_zero import InstanceScaleToZero - - d = dict(src_dict) - image = d.pop("image") - - name = d.pop("name", UNSET) - - args = cast(list[str], d.pop("args", UNSET)) - - _env = d.pop("env", UNSET) - env: Union[Unset, CreateInstanceRequestEnv] - if isinstance(_env, Unset): - env = UNSET - else: - env = CreateInstanceRequestEnv.from_dict(_env) - - memory_mb = d.pop("memory_mb", UNSET) - - _service_group = d.pop("service_group", UNSET) - service_group: Union[Unset, CreateInstanceRequestServiceGroup] - if isinstance(_service_group, Unset): - service_group = UNSET - else: - service_group = CreateInstanceRequestServiceGroup.from_dict(_service_group) - - volumes = [] - _volumes = d.pop("volumes", UNSET) - for volumes_item_data in _volumes or []: - volumes_item = CreateInstanceRequestVolume.from_dict(volumes_item_data) - - volumes.append(volumes_item) - - autostart = d.pop("autostart", UNSET) - - replicas = d.pop("replicas", UNSET) + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of CreateInstanceRequest from a dict""" + if obj is None: + return None - _restart_policy = d.pop("restart_policy", UNSET) - restart_policy: Union[Unset, CreateInstanceRequestRestartPolicy] - if isinstance(_restart_policy, Unset): - restart_policy = UNSET - else: - restart_policy = check_create_instance_request_restart_policy(_restart_policy) + if not isinstance(obj, dict): + return cls.model_validate(obj) - _scale_to_zero = d.pop("scale_to_zero", UNSET) - scale_to_zero: Union[Unset, InstanceScaleToZero] - if isinstance(_scale_to_zero, Unset): - scale_to_zero = UNSET - else: - scale_to_zero = InstanceScaleToZero.from_dict(_scale_to_zero) - - vcpus = d.pop("vcpus", UNSET) - - wait_timeout_ms = d.pop("wait_timeout_ms", UNSET) - - features = [] - _features = d.pop("features", UNSET) - for features_item_data in _features or []: - features_item = check_create_instance_request_features_item(features_item_data) - - features.append(features_item) - - create_instance_request = cls( - image=image, - name=name, - args=args, - env=env, - memory_mb=memory_mb, - service_group=service_group, - volumes=volumes, - autostart=autostart, - replicas=replicas, - restart_policy=restart_policy, - scale_to_zero=scale_to_zero, - vcpus=vcpus, - wait_timeout_ms=wait_timeout_ms, - features=features, + _obj = cls.model_validate( + { + "name": obj.get("name"), + "image": obj.get("image"), + "args": obj.get("args"), + "env": CreateInstanceRequestEnv.from_dict(obj["env"]) if obj.get("env") is not None else None, + "memory_mb": obj.get("memory_mb"), + "restart_policy": obj.get("restart_policy") if obj.get("restart_policy") is not None else "never", + "scale_to_zero": CreateInstanceRequestScaleToZero.from_dict(obj["scale_to_zero"]) + if obj.get("scale_to_zero") is not None + else None, + "volumes": [CreateInstanceRequestVolumesInner.from_dict(_item) for _item in obj["volumes"]] + if obj.get("volumes") is not None + else None, + "service_group": CreateInstanceRequestServiceGroup.from_dict(obj["service_group"]) + if obj.get("service_group") is not None + else None, + "autostart": obj.get("autostart") if obj.get("autostart") is not None else False, + "replicas": obj.get("replicas") if obj.get("replicas") is not None else 0, + "wait_timeout_ms": obj.get("wait_timeout_ms") if obj.get("wait_timeout_ms") is not None else 0, + "features": obj.get("features"), + } ) - - create_instance_request.additional_properties = d - return create_instance_request - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties + return _obj diff --git a/unikraft_cloud_platform/models/create_instance_request_domain.py b/unikraft_cloud_platform/models/create_instance_request_domain.py deleted file mode 100644 index 119d3e3..0000000 --- a/unikraft_cloud_platform/models/create_instance_request_domain.py +++ /dev/null @@ -1,73 +0,0 @@ -from collections.abc import Mapping -from typing import Any, TypeVar - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -T = TypeVar("T", bound="CreateInstanceRequestDomain") - - -@_attrs_define -class CreateInstanceRequestDomain: - """The domain configuration for the service group. - - A domain defines a publicly accessible domain name for the instance. If - the domain name ends with a period `.`, it must be a valid Fully Qualified - Domain Name (FQDN), otherwise it will become a subdomain of the target - metro. The domain can be associated with an existing certificate by - specifying the certificate's name or UUID. If no certificate is specified - and a FQDN is provided, Unikraft Cloud will automatically generate a new - certificate for the domain based on Let's Encrypt and seek to accomplish a - DNS-01 challenge. - - """ - - name: str - """ Publicly accessible domain name. - - If this name ends in a period `.` it must be a valid Full Qualified - Domain Name (FQDN), e.g. `example.com.`; otherwise it will become a - subdomain of the target metro, e.g. `example` becomes - `example.fra0.unikraft.app`. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - name = self.name - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update( - { - "name": name, - } - ) - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - d = dict(src_dict) - name = d.pop("name") - - create_instance_request_domain = cls( - name=name, - ) - - create_instance_request_domain.additional_properties = d - return create_instance_request_domain - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/create_instance_request_env.py b/unikraft_cloud_platform/models/create_instance_request_env.py index ec14296..870c420 100644 --- a/unikraft_cloud_platform/models/create_instance_request_env.py +++ b/unikraft_cloud_platform/models/create_instance_request_env.py @@ -1,49 +1,96 @@ -from collections.abc import Mapping -from typing import Any, TypeVar +# coding: utf-8 -from attrs import define as _attrs_define -from attrs import field as _attrs_field +""" +Unikraft Cloud Platform -T = TypeVar("T", bound="CreateInstanceRequestEnv") +This is the API of the Unikraft Cloud Platform. +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) -@_attrs_define -class CreateInstanceRequestEnv: - """(Optional). Environment variables to set for the instance. +Do not edit the class manually. +""" # noqa: E501 - Example: - {'ENV_VAR1': 'value1', 'ENV_VAR2': 'value2'} +from __future__ import annotations +import pprint +import re # noqa: F401 +import json - """ - - additional_properties: dict[str, str] = _attrs_field(init=False, factory=dict) +from pydantic import BaseModel, ConfigDict, Field, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from typing import Optional, Set +from typing_extensions import Self - def to_dict(self) -> dict[str, Any]: - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - return field_dict +class CreateInstanceRequestEnv(BaseModel): + """ + Key/value pairs to be set as environment variables at boot time. Values must be strings. + """ # noqa: E501 + + additional_properties: Optional[Annotated[str, Field(strict=True, max_length=8388608)]] = Field( + default=None, alias="additionalProperties" + ) + __properties: ClassVar[List[str]] = ["additionalProperties"] + + @field_validator("additional_properties") + def additional_properties_validate_regular_expression(cls, value): + """Validates the regular expression""" + if value is None: + return value + + if not re.match(r"^.+$", value): + raise ValueError(r"must validate the regular expression /^.+$/") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - d = dict(src_dict) - create_instance_request_env = cls() + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of CreateInstanceRequestEnv from a JSON string""" + return cls.from_dict(json.loads(json_str)) - create_instance_request_env.additional_properties = d - return create_instance_request_env + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: - def __getitem__(self, key: str) -> str: - return self.additional_properties[key] + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) - def __setitem__(self, key: str, value: str) -> None: - self.additional_properties[key] = value + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of CreateInstanceRequestEnv from a dict""" + if obj is None: + return None - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] + if not isinstance(obj, dict): + return cls.model_validate(obj) - def __contains__(self, key: str) -> bool: - return key in self.additional_properties + _obj = cls.model_validate({"additionalProperties": obj.get("additionalProperties")}) + return _obj diff --git a/unikraft_cloud_platform/models/create_instance_request_features_item.py b/unikraft_cloud_platform/models/create_instance_request_features_item.py deleted file mode 100644 index 80be3dc..0000000 --- a/unikraft_cloud_platform/models/create_instance_request_features_item.py +++ /dev/null @@ -1,13 +0,0 @@ -from typing import Literal, cast - -CreateInstanceRequestFeaturesItem = Literal["delete_on_stop"] - -CREATE_INSTANCE_REQUEST_FEATURES_ITEM_VALUES: set[CreateInstanceRequestFeaturesItem] = { - "delete_on_stop", -} - - -def check_create_instance_request_features_item(value: str) -> CreateInstanceRequestFeaturesItem: - if value in CREATE_INSTANCE_REQUEST_FEATURES_ITEM_VALUES: - return cast(CreateInstanceRequestFeaturesItem, value) - raise TypeError(f"Unexpected value {value!r}. Expected one of {CREATE_INSTANCE_REQUEST_FEATURES_ITEM_VALUES!r}") diff --git a/unikraft_cloud_platform/models/create_instance_request_restart_policy.py b/unikraft_cloud_platform/models/create_instance_request_restart_policy.py deleted file mode 100644 index 2aeb28e..0000000 --- a/unikraft_cloud_platform/models/create_instance_request_restart_policy.py +++ /dev/null @@ -1,15 +0,0 @@ -from typing import Literal, cast - -CreateInstanceRequestRestartPolicy = Literal["always", "never", "on_failure"] - -CREATE_INSTANCE_REQUEST_RESTART_POLICY_VALUES: set[CreateInstanceRequestRestartPolicy] = { - "always", - "never", - "on_failure", -} - - -def check_create_instance_request_restart_policy(value: str) -> CreateInstanceRequestRestartPolicy: - if value in CREATE_INSTANCE_REQUEST_RESTART_POLICY_VALUES: - return cast(CreateInstanceRequestRestartPolicy, value) - raise TypeError(f"Unexpected value {value!r}. Expected one of {CREATE_INSTANCE_REQUEST_RESTART_POLICY_VALUES!r}") diff --git a/unikraft_cloud_platform/models/create_instance_request_scale_to_zero.py b/unikraft_cloud_platform/models/create_instance_request_scale_to_zero.py new file mode 100644 index 0000000..c02e84f --- /dev/null +++ b/unikraft_cloud_platform/models/create_instance_request_scale_to_zero.py @@ -0,0 +1,106 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from typing import Optional, Set +from typing_extensions import Self + + +class CreateInstanceRequestScaleToZero(BaseModel): + """ + With conventional cloud platforms you need to keep at least one instance running at all times to be able to respond to incoming requests. Performing a just-in-time cold boot is simply too time-consuming and would create a response latency of multiple seconds. This is not the case with Unikraft Cloud. Instances on Unikraft Cloud are able to cold boot within milliseconds, which allows us to perform low-latency scale-to-zero. To enable scale-to-zero for an instance it is sufficient to add a `scale_to_zero` configuration block. Unikraft Cloud will then put the instance into standby if there is no traffic to your service within the window of a cooldown period. When there is new traffic coming in, it is automatically started again. If you have a heavyweight application that takes long to cold boot or has bad first request latency (e.g., with JIT compilation) consider to enable [stateful scale-to-zero](https://unikraft.cloud/docs/api/v1/instances/#scaletozero_stateful). + """ # noqa: E501 + + policy: StrictStr = Field( + description="With the scale-to-zero policy you define under which circumstances Unikraft Cloud should put your instance into standby. Unikraft Cloud currently supports the following scale-to-zero policies: Policy | Description -------|------------ `on` | Scale-to-zero is enabled. When there are no TCP connections or HTTP requests for the duration of the cooldown time, the instance is put into standby `off` | Scale-to-zero is not enabled. The instance keep on running until manually stopped `idle` | Same as `on`, but also puts the instance into standby when there are TCP connections established that have been inactive for the duration of the cooldown time. The connections remain established and incoming packets wake up the instance. Scale-to-zero does not happen while there are active HTTP requests (i.e., traffic on ports, which have been marked with the `http` handler as described [here](https://unikraft.cloud/docs/api/v1/services#handlers)) " + ) + stateful: Optional[StrictBool] = Field( + default=False, + description="Whether to use [stateful](https://unikraft.cloud/docs/api/v1/instances/#scaletozero_stateful) scale-to-zero. ", + ) + cooldown_time_ms: Optional[Annotated[int, Field(le=86400000, strict=True, ge=0)]] = Field( + default=1000, description="Cooldown time in milliseconds. " + ) + __properties: ClassVar[List[str]] = ["policy", "stateful", "cooldown_time_ms"] + + @field_validator("policy") + def policy_validate_enum(cls, value): + """Validates the enum""" + if value not in set(["on", "off", "idle"]): + raise ValueError("must be one of enum values ('on', 'off', 'idle')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of CreateInstanceRequestScaleToZero from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of CreateInstanceRequestScaleToZero from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "policy": obj.get("policy"), + "stateful": obj.get("stateful") if obj.get("stateful") is not None else False, + "cooldown_time_ms": obj.get("cooldown_time_ms") if obj.get("cooldown_time_ms") is not None else 1000, + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/create_instance_request_service_group.py b/unikraft_cloud_platform/models/create_instance_request_service_group.py index 4956b0e..8ab5c79 100644 --- a/unikraft_cloud_platform/models/create_instance_request_service_group.py +++ b/unikraft_cloud_platform/models/create_instance_request_service_group.py @@ -1,108 +1,94 @@ -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union +# coding: utf-8 -from attrs import define as _attrs_define -from attrs import field as _attrs_field +""" +Unikraft Cloud Platform -from ..types import UNSET, Unset +This is the API of the Unikraft Cloud Platform. -if TYPE_CHECKING: - from ..models.create_instance_request_domain import CreateInstanceRequestDomain - from ..models.service import Service +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) +Do not edit the class manually. +""" # noqa: E501 -T = TypeVar("T", bound="CreateInstanceRequestServiceGroup") +from __future__ import annotations +import pprint +import re # noqa: F401 +import json +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from uuid import UUID +from unikraft_cloud_platform.models.create_instance_request_service_group_domains_inner import ( + CreateInstanceRequestServiceGroupDomainsInner, +) +from unikraft_cloud_platform.models.service_mapping import ServiceMapping +from typing import Optional, Set +from typing_extensions import Self -@_attrs_define -class CreateInstanceRequestServiceGroup: - """The service group configuration when creating an instance. - - If no existing (persistent) service group is specified via its identifier, - a new (ephemeral) service group can be created by specifying the services - it should expose. A service defines the configuration settings of an - exposed port by the instance. A service is a combination of a public port, - an internal port, and a set of handlers that define how the service will - handle incoming connections. +class CreateInstanceRequestServiceGroup(BaseModel): """ - - domains: Union[Unset, list["CreateInstanceRequestDomain"]] = UNSET - """ Similarly, if no existing (persistent) service group is specified via its - identifier, a new (ephemeral) service group can be created. In addition - to the services it must expose, you can specify which domains it should - use too. """ - services: Union[Unset, list["Service"]] = UNSET - """ If no existing service identifier is provided, one or more new - (ephemeral, non-persistent) service(s) can be created with the following - definitions. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - domains: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.domains, Unset): - domains = [] - for domains_item_data in self.domains: - domains_item = domains_item_data.to_dict() - domains.append(domains_item) - - services: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.services, Unset): - services = [] - for services_item_data in self.services: - services_item = services_item_data.to_dict() - services.append(services_item) - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if domains is not UNSET: - field_dict["domains"] = domains - if services is not UNSET: - field_dict["services"] = services - - return field_dict + Description of published [services](https://unikraft.cloud/docs/api/v1/services). + """ # noqa: E501 + + name: Optional[Annotated[str, Field(strict=True, max_length=255)]] = Field( + default=None, description="The name of the service. " + ) + uuid: Optional[UUID] = Field(default=None, description="The UUID of the service. ") + domains: Optional[Annotated[List[CreateInstanceRequestServiceGroupDomainsInner], Field(max_length=253)]] = None + services: Optional[ServiceMapping] = None + __properties: ClassVar[List[str]] = [] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.create_instance_request_domain import CreateInstanceRequestDomain - from ..models.service import Service - - d = dict(src_dict) - domains = [] - _domains = d.pop("domains", UNSET) - for domains_item_data in _domains or []: - domains_item = CreateInstanceRequestDomain.from_dict(domains_item_data) - - domains.append(domains_item) - - services = [] - _services = d.pop("services", UNSET) - for services_item_data in _services or []: - services_item = Service.from_dict(services_item_data) - - services.append(services_item) - - create_instance_request_service_group = cls( - domains=domains, - services=services, + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of CreateInstanceRequestServiceGroup from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, ) + return _dict - create_instance_request_service_group.additional_properties = d - return create_instance_request_service_group - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of CreateInstanceRequestServiceGroup from a dict""" + if obj is None: + return None - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] + if not isinstance(obj, dict): + return cls.model_validate(obj) - def __contains__(self, key: str) -> bool: - return key in self.additional_properties + _obj = cls.model_validate({}) + return _obj diff --git a/unikraft_cloud_platform/models/create_instance_request_service_group_domains_inner.py b/unikraft_cloud_platform/models/create_instance_request_service_group_domains_inner.py new file mode 100644 index 0000000..087b2ff --- /dev/null +++ b/unikraft_cloud_platform/models/create_instance_request_service_group_domains_inner.py @@ -0,0 +1,99 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from unikraft_cloud_platform.models.certificate import Certificate +from typing import Optional, Set +from typing_extensions import Self + + +class CreateInstanceRequestServiceGroupDomainsInner(BaseModel): + """ + CreateInstanceRequestServiceGroupDomainsInner + """ # noqa: E501 + + fqdn: Optional[Annotated[str, Field(strict=True, max_length=255)]] = Field( + default=None, + description="Public fully-qualified domain name under which the service is accessible from the Internet. ", + ) + certificate: Optional[Certificate] = None + __properties: ClassVar[List[str]] = ["fqdn", "certificate"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of CreateInstanceRequestServiceGroupDomainsInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of certificate + if self.certificate: + _dict["certificate"] = self.certificate.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of CreateInstanceRequestServiceGroupDomainsInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "fqdn": obj.get("fqdn"), + "certificate": Certificate.from_dict(obj["certificate"]) + if obj.get("certificate") is not None + else None, + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/create_instance_request_volume.py b/unikraft_cloud_platform/models/create_instance_request_volume.py deleted file mode 100644 index 5dab540..0000000 --- a/unikraft_cloud_platform/models/create_instance_request_volume.py +++ /dev/null @@ -1,118 +0,0 @@ -from collections.abc import Mapping -from typing import Any, TypeVar, Union -from uuid import UUID - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -T = TypeVar("T", bound="CreateInstanceRequestVolume") - - -@_attrs_define -class CreateInstanceRequestVolume: - """A volume defines a storage volume that can be attached to the instance.""" - - at: str - """ The mount point for the volume in the instance. """ - uuid: Union[Unset, UUID] = UNSET - """ The UUID of an existing volume. - - If this is the only specified field, then it will look up an existing - volume by this UUID. """ - name: Union[Unset, str] = UNSET - """ The name of the volume. - - If this is the only specified field, then it will look up an existing - volume by this name. If the volume does not exist, the request will - fail. If a new volume is intended to be created, then this field must be - specified along with the size in MiB and the mount point in the instance. """ - size_mb: Union[Unset, int] = UNSET - """ The size of the volume when creating a new volume. - - When creating a new volume as part of the instance create request, - specify the size of the volume in MiB. """ - read_only: Union[Unset, bool] = UNSET - """ Whether the volume is read-only. - - If this field is set to true, the volume will be mounted as read-only in - the instance. This field is optional and defaults to false and is only - applicable when using an existing volume. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - at = self.at - - uuid: Union[Unset, str] = UNSET - if not isinstance(self.uuid, Unset): - uuid = str(self.uuid) - - name = self.name - - size_mb = self.size_mb - - read_only = self.read_only - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update( - { - "at": at, - } - ) - if uuid is not UNSET: - field_dict["uuid"] = uuid - if name is not UNSET: - field_dict["name"] = name - if size_mb is not UNSET: - field_dict["size_mb"] = size_mb - if read_only is not UNSET: - field_dict["read_only"] = read_only - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - d = dict(src_dict) - at = d.pop("at") - - _uuid = d.pop("uuid", UNSET) - uuid: Union[Unset, UUID] - if isinstance(_uuid, Unset): - uuid = UNSET - else: - uuid = UUID(_uuid) - - name = d.pop("name", UNSET) - - size_mb = d.pop("size_mb", UNSET) - - read_only = d.pop("read_only", UNSET) - - create_instance_request_volume = cls( - at=at, - uuid=uuid, - name=name, - size_mb=size_mb, - read_only=read_only, - ) - - create_instance_request_volume.additional_properties = d - return create_instance_request_volume - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/create_instance_request_volumes_inner.py b/unikraft_cloud_platform/models/create_instance_request_volumes_inner.py new file mode 100644 index 0000000..20b2b04 --- /dev/null +++ b/unikraft_cloud_platform/models/create_instance_request_volumes_inner.py @@ -0,0 +1,108 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictBool, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from uuid import UUID +from typing import Optional, Set +from typing_extensions import Self + + +class CreateInstanceRequestVolumesInner(BaseModel): + """ + CreateInstanceRequestVolumesInner + """ # noqa: E501 + + uuid: Optional[UUID] = Field( + default=None, + description="UUID of an existing volume. Must be in `available` [state](https://unikraft.cloud/docs/api/v1/volumes#states). ", + ) + name: Optional[Annotated[str, Field(strict=True, max_length=255)]] = Field( + default=None, + description="The name of the volume to attach. Note: You need to specify either `uuid`, `name`, or `size_mb`. Specifying `size_mb` will create a new [volume](https://unikraft.cloud/docs/api/v1/volumes) and attach it to the instance. The volume will receive an auto-generated name. ", + ) + at: Optional[Annotated[str, Field(strict=True, max_length=8388608)]] = Field( + default=None, description="Path of the mountpoint. Must be empty. Automatically created if it does not exist. " + ) + readonly: Optional[StrictBool] = Field( + default=False, description="Whether the volume should be mounted read-only. " + ) + __properties: ClassVar[List[str]] = [] + + @field_validator("at") + def at_validate_regular_expression(cls, value): + """Validates the regular expression""" + if value is None: + return value + + if not re.match(r"^(\/[ a-zA-Z0-9._-]*)*$", value): + raise ValueError(r"must validate the regular expression /^(\/[ a-zA-Z0-9._-]*)*$/") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of CreateInstanceRequestVolumesInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of CreateInstanceRequestVolumesInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({}) + return _obj diff --git a/unikraft_cloud_platform/models/create_instance_response.py b/unikraft_cloud_platform/models/create_instance_response.py deleted file mode 100644 index 3838b1d..0000000 --- a/unikraft_cloud_platform/models/create_instance_response.py +++ /dev/null @@ -1,127 +0,0 @@ -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..models.response_status import ResponseStatus, check_response_status -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.create_instance_response_data import CreateInstanceResponseData - from ..models.response_error import ResponseError - - -T = TypeVar("T", bound="CreateInstanceResponse") - - -@_attrs_define -class CreateInstanceResponse: - """The response message for creating a new instance.""" - - status: Union[Unset, ResponseStatus] = UNSET - """ The response status of an API request. """ - message: Union[Unset, str] = UNSET - """ An optional message providing additional information about the status. - This field is useful when the status is not `success`. """ - data: Union[Unset, "CreateInstanceResponseData"] = UNSET - errors: Union[Unset, list["ResponseError"]] = UNSET - """ A list of errors which may have occurred during the request. """ - op_time_us: Union[Unset, int] = UNSET - """ The operation time in microseconds. This is the time it took to process - the request and generate the response. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - status: Union[Unset, str] = UNSET - if not isinstance(self.status, Unset): - status = self.status - - message = self.message - - data: Union[Unset, dict[str, Any]] = UNSET - if not isinstance(self.data, Unset): - data = self.data.to_dict() - - errors: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.errors, Unset): - errors = [] - for errors_item_data in self.errors: - errors_item = errors_item_data.to_dict() - errors.append(errors_item) - - op_time_us = self.op_time_us - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if status is not UNSET: - field_dict["status"] = status - if message is not UNSET: - field_dict["message"] = message - if data is not UNSET: - field_dict["data"] = data - if errors is not UNSET: - field_dict["errors"] = errors - if op_time_us is not UNSET: - field_dict["op_time_us"] = op_time_us - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.create_instance_response_data import CreateInstanceResponseData - from ..models.response_error import ResponseError - - d = dict(src_dict) - _status = d.pop("status", UNSET) - status: Union[Unset, ResponseStatus] - if isinstance(_status, Unset): - status = UNSET - else: - status = check_response_status(_status) - - message = d.pop("message", UNSET) - - _data = d.pop("data", UNSET) - data: Union[Unset, CreateInstanceResponseData] - if isinstance(_data, Unset): - data = UNSET - else: - data = CreateInstanceResponseData.from_dict(_data) - - errors = [] - _errors = d.pop("errors", UNSET) - for errors_item_data in _errors or []: - errors_item = ResponseError.from_dict(errors_item_data) - - errors.append(errors_item) - - op_time_us = d.pop("op_time_us", UNSET) - - create_instance_response = cls( - status=status, - message=message, - data=data, - errors=errors, - op_time_us=op_time_us, - ) - - create_instance_response.additional_properties = d - return create_instance_response - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/create_instance_response_data.py b/unikraft_cloud_platform/models/create_instance_response_data.py deleted file mode 100644 index 52429eb..0000000 --- a/unikraft_cloud_platform/models/create_instance_response_data.py +++ /dev/null @@ -1,71 +0,0 @@ -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.instance import Instance - - -T = TypeVar("T", bound="CreateInstanceResponseData") - - -@_attrs_define -class CreateInstanceResponseData: - instances: Union[Unset, list["Instance"]] = UNSET - """ The instance that was created in this request. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - instances: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.instances, Unset): - instances = [] - for instances_item_data in self.instances: - instances_item = instances_item_data.to_dict() - instances.append(instances_item) - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if instances is not UNSET: - field_dict["instances"] = instances - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.instance import Instance - - d = dict(src_dict) - instances = [] - _instances = d.pop("instances", UNSET) - for instances_item_data in _instances or []: - instances_item = Instance.from_dict(instances_item_data) - - instances.append(instances_item) - - create_instance_response_data = cls( - instances=instances, - ) - - create_instance_response_data.additional_properties = d - return create_instance_response_data - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/create_service_group_request.py b/unikraft_cloud_platform/models/create_service_group_request.py deleted file mode 100644 index 179486f..0000000 --- a/unikraft_cloud_platform/models/create_service_group_request.py +++ /dev/null @@ -1,138 +0,0 @@ -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.create_service_group_request_domain import CreateServiceGroupRequestDomain - from ..models.service import Service - - -T = TypeVar("T", bound="CreateServiceGroupRequest") - - -@_attrs_define -class CreateServiceGroupRequest: - """The request message for creating a new service group.""" - - name: Union[Unset, str] = UNSET - """ Name of the service group. This is a human-readable name that can be used - to identify the service group. The name must be unique within the context - of your account. If no name is specified, a random name is generated for - you. The name can also be used to identify the service group in API calls. """ - services: Union[Unset, list["Service"]] = UNSET - """ Description of exposed services. """ - domains: Union[Unset, list["CreateServiceGroupRequestDomain"]] = UNSET - """ Description of domains associated with the service group. """ - soft_limit: Union[Unset, int] = UNSET - """ The soft limit is used by the Unikraft Cloud load balancer to decide when - to wake up another standby instance. - - For example, if the soft limit is set to 5 and the service consists of 2 - standby instances, one of the instances receives up to 5 concurrent - requests. The 6th parallel requests wakes up the second instance. If - there are no more standby instances to wake up, the number of requests - assigned to each instance will exceed the soft limit. The load balancer - makes sure that when the number of in-flight requests goes down again, - instances are put into standby as fast as possible. """ - hard_limit: Union[Unset, int] = UNSET - """ The hard limit defines the maximum number of concurrent requests that an - instance assigned to the this service can handle. - - The load balancer will never assign more requests to a single instance. In - case there are no other instances available, excess requests fail (i.e., - they are blocked and not queued). """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - name = self.name - - services: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.services, Unset): - services = [] - for services_item_data in self.services: - services_item = services_item_data.to_dict() - services.append(services_item) - - domains: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.domains, Unset): - domains = [] - for domains_item_data in self.domains: - domains_item = domains_item_data.to_dict() - domains.append(domains_item) - - soft_limit = self.soft_limit - - hard_limit = self.hard_limit - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if name is not UNSET: - field_dict["name"] = name - if services is not UNSET: - field_dict["services"] = services - if domains is not UNSET: - field_dict["domains"] = domains - if soft_limit is not UNSET: - field_dict["soft_limit"] = soft_limit - if hard_limit is not UNSET: - field_dict["hard_limit"] = hard_limit - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.create_service_group_request_domain import CreateServiceGroupRequestDomain - from ..models.service import Service - - d = dict(src_dict) - name = d.pop("name", UNSET) - - services = [] - _services = d.pop("services", UNSET) - for services_item_data in _services or []: - services_item = Service.from_dict(services_item_data) - - services.append(services_item) - - domains = [] - _domains = d.pop("domains", UNSET) - for domains_item_data in _domains or []: - domains_item = CreateServiceGroupRequestDomain.from_dict(domains_item_data) - - domains.append(domains_item) - - soft_limit = d.pop("soft_limit", UNSET) - - hard_limit = d.pop("hard_limit", UNSET) - - create_service_group_request = cls( - name=name, - services=services, - domains=domains, - soft_limit=soft_limit, - hard_limit=hard_limit, - ) - - create_service_group_request.additional_properties = d - return create_service_group_request - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/create_service_group_request_domain.py b/unikraft_cloud_platform/models/create_service_group_request_domain.py deleted file mode 100644 index e5e238d..0000000 --- a/unikraft_cloud_platform/models/create_service_group_request_domain.py +++ /dev/null @@ -1,83 +0,0 @@ -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.name_or_uuid import NameOrUUID - - -T = TypeVar("T", bound="CreateServiceGroupRequestDomain") - - -@_attrs_define -class CreateServiceGroupRequestDomain: - """A domain name""" - - name: str - """ Publicly accessible domain name. If this name ends in a period `.` it must - be a valid Full Qualified Domain Name (FQDN), otherwise it will become a - subdomain of the target metro. """ - certificate: Union[Unset, "NameOrUUID"] = UNSET - """ An identifier for a resource. Either a name or a UUID. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - name = self.name - - certificate: Union[Unset, dict[str, Any]] = UNSET - if not isinstance(self.certificate, Unset): - certificate = self.certificate.to_dict() - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update( - { - "name": name, - } - ) - if certificate is not UNSET: - field_dict["certificate"] = certificate - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.name_or_uuid import NameOrUUID - - d = dict(src_dict) - name = d.pop("name") - - _certificate = d.pop("certificate", UNSET) - certificate: Union[Unset, NameOrUUID] - if isinstance(_certificate, Unset): - certificate = UNSET - else: - certificate = NameOrUUID.from_dict(_certificate) - - create_service_group_request_domain = cls( - name=name, - certificate=certificate, - ) - - create_service_group_request_domain.additional_properties = d - return create_service_group_request_domain - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/create_service_group_response.py b/unikraft_cloud_platform/models/create_service_group_response.py deleted file mode 100644 index b0481d7..0000000 --- a/unikraft_cloud_platform/models/create_service_group_response.py +++ /dev/null @@ -1,127 +0,0 @@ -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..models.response_status import ResponseStatus, check_response_status -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.create_service_group_response_data import CreateServiceGroupResponseData - from ..models.response_error import ResponseError - - -T = TypeVar("T", bound="CreateServiceGroupResponse") - - -@_attrs_define -class CreateServiceGroupResponse: - """The response message for creating of a service group.""" - - status: Union[Unset, ResponseStatus] = UNSET - """ The response status of an API request. """ - message: Union[Unset, str] = UNSET - """ An optional message providing additional information about the status. - This field is useful when the status is not `success`. """ - data: Union[Unset, "CreateServiceGroupResponseData"] = UNSET - errors: Union[Unset, list["ResponseError"]] = UNSET - """ A list of errors which may have occurred during the request. """ - op_time_us: Union[Unset, int] = UNSET - """ The operation time in microseconds. This is the time it took to process - the request and generate the response. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - status: Union[Unset, str] = UNSET - if not isinstance(self.status, Unset): - status = self.status - - message = self.message - - data: Union[Unset, dict[str, Any]] = UNSET - if not isinstance(self.data, Unset): - data = self.data.to_dict() - - errors: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.errors, Unset): - errors = [] - for errors_item_data in self.errors: - errors_item = errors_item_data.to_dict() - errors.append(errors_item) - - op_time_us = self.op_time_us - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if status is not UNSET: - field_dict["status"] = status - if message is not UNSET: - field_dict["message"] = message - if data is not UNSET: - field_dict["data"] = data - if errors is not UNSET: - field_dict["errors"] = errors - if op_time_us is not UNSET: - field_dict["op_time_us"] = op_time_us - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.create_service_group_response_data import CreateServiceGroupResponseData - from ..models.response_error import ResponseError - - d = dict(src_dict) - _status = d.pop("status", UNSET) - status: Union[Unset, ResponseStatus] - if isinstance(_status, Unset): - status = UNSET - else: - status = check_response_status(_status) - - message = d.pop("message", UNSET) - - _data = d.pop("data", UNSET) - data: Union[Unset, CreateServiceGroupResponseData] - if isinstance(_data, Unset): - data = UNSET - else: - data = CreateServiceGroupResponseData.from_dict(_data) - - errors = [] - _errors = d.pop("errors", UNSET) - for errors_item_data in _errors or []: - errors_item = ResponseError.from_dict(errors_item_data) - - errors.append(errors_item) - - op_time_us = d.pop("op_time_us", UNSET) - - create_service_group_response = cls( - status=status, - message=message, - data=data, - errors=errors, - op_time_us=op_time_us, - ) - - create_service_group_response.additional_properties = d - return create_service_group_response - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/create_service_group_response_data.py b/unikraft_cloud_platform/models/create_service_group_response_data.py deleted file mode 100644 index 879bf2c..0000000 --- a/unikraft_cloud_platform/models/create_service_group_response_data.py +++ /dev/null @@ -1,74 +0,0 @@ -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.service_group import ServiceGroup - - -T = TypeVar("T", bound="CreateServiceGroupResponseData") - - -@_attrs_define -class CreateServiceGroupResponseData: - service_groups: Union[Unset, list["ServiceGroup"]] = UNSET - """ The service group which was created by this request. - - Note: only one service group can be specified in the request, so this - will always contain a single entry. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - service_groups: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.service_groups, Unset): - service_groups = [] - for service_groups_item_data in self.service_groups: - service_groups_item = service_groups_item_data.to_dict() - service_groups.append(service_groups_item) - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if service_groups is not UNSET: - field_dict["service_groups"] = service_groups - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.service_group import ServiceGroup - - d = dict(src_dict) - service_groups = [] - _service_groups = d.pop("service_groups", UNSET) - for service_groups_item_data in _service_groups or []: - service_groups_item = ServiceGroup.from_dict(service_groups_item_data) - - service_groups.append(service_groups_item) - - create_service_group_response_data = cls( - service_groups=service_groups, - ) - - create_service_group_response_data.additional_properties = d - return create_service_group_response_data - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/create_services200_response.py b/unikraft_cloud_platform/models/create_services200_response.py new file mode 100644 index 0000000..dcb8238 --- /dev/null +++ b/unikraft_cloud_platform/models/create_services200_response.py @@ -0,0 +1,103 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from unikraft_cloud_platform.models.create_services200_response_data import CreateServices200ResponseData +from typing import Optional, Set +from typing_extensions import Self + + +class CreateServices200Response(BaseModel): + """ + CreateServices200Response + """ # noqa: E501 + + status: Optional[StrictStr] = Field(default=None, description="The status of the response. ") + data: Optional[CreateServices200ResponseData] = None + __properties: ClassVar[List[str]] = ["status", "data"] + + @field_validator("status") + def status_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(["success", "failure"]): + raise ValueError("must be one of enum values ('success', 'failure')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of CreateServices200Response from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of data + if self.data: + _dict["data"] = self.data.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of CreateServices200Response from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "status": obj.get("status"), + "data": CreateServices200ResponseData.from_dict(obj["data"]) if obj.get("data") is not None else None, + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/create_services200_response_data.py b/unikraft_cloud_platform/models/create_services200_response_data.py new file mode 100644 index 0000000..cde7b51 --- /dev/null +++ b/unikraft_cloud_platform/models/create_services200_response_data.py @@ -0,0 +1,104 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from unikraft_cloud_platform.models.create_services200_response_data_service_groups_inner import ( + CreateServices200ResponseDataServiceGroupsInner, +) +from typing import Optional, Set +from typing_extensions import Self + + +class CreateServices200ResponseData(BaseModel): + """ + CreateServices200ResponseData + """ # noqa: E501 + + service_groups: Optional[ + Annotated[List[CreateServices200ResponseDataServiceGroupsInner], Field(max_length=253)] + ] = None + __properties: ClassVar[List[str]] = ["service_groups"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of CreateServices200ResponseData from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in service_groups (list) + _items = [] + if self.service_groups: + for _item_service_groups in self.service_groups: + if _item_service_groups: + _items.append(_item_service_groups.to_dict()) + _dict["service_groups"] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of CreateServices200ResponseData from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "service_groups": [ + CreateServices200ResponseDataServiceGroupsInner.from_dict(_item) for _item in obj["service_groups"] + ] + if obj.get("service_groups") is not None + else None + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/create_services200_response_data_service_groups_inner.py b/unikraft_cloud_platform/models/create_services200_response_data_service_groups_inner.py new file mode 100644 index 0000000..7acc06d --- /dev/null +++ b/unikraft_cloud_platform/models/create_services200_response_data_service_groups_inner.py @@ -0,0 +1,134 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from uuid import UUID +from unikraft_cloud_platform.models.create_services200_response_data_service_groups_inner_domains_inner import ( + CreateServices200ResponseDataServiceGroupsInnerDomainsInner, +) +from typing import Optional, Set +from typing_extensions import Self + + +class CreateServices200ResponseDataServiceGroupsInner(BaseModel): + """ + CreateServices200ResponseDataServiceGroupsInner + """ # noqa: E501 + + status: Optional[StrictStr] = Field(default=None, description="The status of the response. ") + uuid: Optional[UUID] = Field(default=None, description="The UUID of the newly created service. ") + name: Optional[Annotated[str, Field(strict=True, max_length=255)]] = Field( + default=None, description="The name of the newly created service. " + ) + soft_limit: Optional[Annotated[int, Field(le=65535, strict=True, ge=1)]] = Field( + default=1, + description="Per-instance connection [soft limit](https://unikraft.cloud/docs/api/v1/services/#limits). ", + ) + hard_limit: Optional[Annotated[int, Field(le=65535, strict=True, ge=1)]] = Field( + default=65535, + description="Per-instance connection [hard limit](https://unikraft.cloud/docs/api/v1/services/#limits). ", + ) + domains: Optional[ + Annotated[List[CreateServices200ResponseDataServiceGroupsInnerDomainsInner], Field(max_length=253)] + ] = None + __properties: ClassVar[List[str]] = ["status", "uuid", "name", "soft_limit", "hard_limit", "domains"] + + @field_validator("status") + def status_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(["success", "error"]): + raise ValueError("must be one of enum values ('success', 'error')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of CreateServices200ResponseDataServiceGroupsInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in domains (list) + _items = [] + if self.domains: + for _item_domains in self.domains: + if _item_domains: + _items.append(_item_domains.to_dict()) + _dict["domains"] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of CreateServices200ResponseDataServiceGroupsInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "status": obj.get("status"), + "uuid": obj.get("uuid"), + "name": obj.get("name"), + "soft_limit": obj.get("soft_limit") if obj.get("soft_limit") is not None else 1, + "hard_limit": obj.get("hard_limit") if obj.get("hard_limit") is not None else 65535, + "domains": [ + CreateServices200ResponseDataServiceGroupsInnerDomainsInner.from_dict(_item) + for _item in obj["domains"] + ] + if obj.get("domains") is not None + else None, + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/create_services200_response_data_service_groups_inner_domains_inner.py b/unikraft_cloud_platform/models/create_services200_response_data_service_groups_inner_domains_inner.py new file mode 100644 index 0000000..bc85aa0 --- /dev/null +++ b/unikraft_cloud_platform/models/create_services200_response_data_service_groups_inner_domains_inner.py @@ -0,0 +1,103 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from unikraft_cloud_platform.models.create_services200_response_data_service_groups_inner_domains_inner_certificate import ( + CreateServices200ResponseDataServiceGroupsInnerDomainsInnerCertificate, +) +from typing import Optional, Set +from typing_extensions import Self + + +class CreateServices200ResponseDataServiceGroupsInnerDomainsInner(BaseModel): + """ + CreateServices200ResponseDataServiceGroupsInnerDomainsInner + """ # noqa: E501 + + fqdn: Optional[Annotated[str, Field(strict=True, max_length=255)]] = Field( + default=None, + description="Public fully-qualified domain name under which the service is accessible from the Internet. ", + ) + certificate: Optional[CreateServices200ResponseDataServiceGroupsInnerDomainsInnerCertificate] = None + __properties: ClassVar[List[str]] = ["fqdn", "certificate"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of CreateServices200ResponseDataServiceGroupsInnerDomainsInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of certificate + if self.certificate: + _dict["certificate"] = self.certificate.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of CreateServices200ResponseDataServiceGroupsInnerDomainsInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "fqdn": obj.get("fqdn"), + "certificate": CreateServices200ResponseDataServiceGroupsInnerDomainsInnerCertificate.from_dict( + obj["certificate"] + ) + if obj.get("certificate") is not None + else None, + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/create_services200_response_data_service_groups_inner_domains_inner_certificate.py b/unikraft_cloud_platform/models/create_services200_response_data_service_groups_inner_domains_inner_certificate.py new file mode 100644 index 0000000..065f2a5 --- /dev/null +++ b/unikraft_cloud_platform/models/create_services200_response_data_service_groups_inner_domains_inner_certificate.py @@ -0,0 +1,102 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from uuid import UUID +from typing import Optional, Set +from typing_extensions import Self + + +class CreateServices200ResponseDataServiceGroupsInnerDomainsInnerCertificate(BaseModel): + """ + TLS certificate used for the domain. Note: Not for subdomains of `.kraft.host`. + """ # noqa: E501 + + uuid: Optional[UUID] = Field(default=None, description="The UUID of the certificate. ") + name: Optional[Annotated[str, Field(strict=True, max_length=255)]] = Field( + default=None, description="The name of the certificate. " + ) + state: Optional[StrictStr] = Field( + default=None, + description="Current state of the certificate. A certificate can be in one of the following states: State | Description ----------|------------ `pending` | The certificate request is pending while the certificate is being requested from the certification authority. During this phase any service using this certificate is not available if this is not a renewal. `valid` | The certificate is valid and can be used for services. `error` | The certificate request failed after multiple attempts. This can happen, for example, if your DNS configuration is not correct, you run into Let’s Encrypt™ quota limits, or the domain validation process failed for some other reason. There won’t be any further automatic attempts. If you need assistence please contact us via [support@unikraft.cloud](mailto:support@unikraft.cloud). ", + ) + __properties: ClassVar[List[str]] = ["uuid", "name", "state"] + + @field_validator("state") + def state_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(["valid", "pending", "error"]): + raise ValueError("must be one of enum values ('valid', 'pending', 'error')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of CreateServices200ResponseDataServiceGroupsInnerDomainsInnerCertificate from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of CreateServices200ResponseDataServiceGroupsInnerDomainsInnerCertificate from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({"uuid": obj.get("uuid"), "name": obj.get("name"), "state": obj.get("state")}) + return _obj diff --git a/unikraft_cloud_platform/models/create_services_request.py b/unikraft_cloud_platform/models/create_services_request.py new file mode 100644 index 0000000..b31243b --- /dev/null +++ b/unikraft_cloud_platform/models/create_services_request.py @@ -0,0 +1,103 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from unikraft_cloud_platform.models.create_services_request_services_inner import CreateServicesRequestServicesInner +from typing import Optional, Set +from typing_extensions import Self + + +class CreateServicesRequest(BaseModel): + """ + CreateServicesRequest + """ # noqa: E501 + + name: Optional[Annotated[str, Field(strict=True, max_length=255)]] = Field( + default=None, + description="The name of the service Note: If no name is specified a random name of the form `--` is auto-generated, where `` is an 8 characters long random alphanumeric suffix. ", + ) + services: Annotated[List[CreateServicesRequestServicesInner], Field(max_length=253)] + __properties: ClassVar[List[str]] = ["name", "services"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of CreateServicesRequest from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in services (list) + _items = [] + if self.services: + for _item_services in self.services: + if _item_services: + _items.append(_item_services.to_dict()) + _dict["services"] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of CreateServicesRequest from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "name": obj.get("name"), + "services": [CreateServicesRequestServicesInner.from_dict(_item) for _item in obj["services"]] + if obj.get("services") is not None + else None, + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/create_services_request_services_inner.py b/unikraft_cloud_platform/models/create_services_request_services_inner.py new file mode 100644 index 0000000..0df451e --- /dev/null +++ b/unikraft_cloud_platform/models/create_services_request_services_inner.py @@ -0,0 +1,123 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from unikraft_cloud_platform.models.create_services_request_services_inner_domains_inner import ( + CreateServicesRequestServicesInnerDomainsInner, +) +from unikraft_cloud_platform.models.service_mapping import ServiceMapping +from typing import Optional, Set +from typing_extensions import Self + + +class CreateServicesRequestServicesInner(BaseModel): + """ + CreateServicesRequestServicesInner + """ # noqa: E501 + + port: Annotated[int, Field(le=65535, strict=True, ge=1)] = Field(description="Public-facing port") + destination_port: Optional[Annotated[int, Field(le=65535, strict=True, ge=1)]] = Field( + default=None, description="Port that the application listens on. Default: Same as `port` " + ) + handlers: Optional[Annotated[List[ServiceMapping], Field(max_length=253)]] = Field( + default=None, description="See [`Connection Handlers`](https://unikraft.cloud/docs/api/v1/services/#handlers). " + ) + domains: Optional[Annotated[List[CreateServicesRequestServicesInnerDomainsInner], Field(max_length=253)]] = Field( + default=None, + description="Description of domains to associate with the service. Default: auto-generated. Note: If `name` is specified without also providing a domain, a domain is derived from `name` by appending an 8 characters long random alphanumeric suffix and the metro's domain name. For example, setting the name to `my-project` without also providing a domain results in an auto-generated domain of `my-project-.fra0.kraft.host`. ", + ) + __properties: ClassVar[List[str]] = ["port", "destination_port", "handlers", "domains"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of CreateServicesRequestServicesInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in handlers (list) + _items = [] + if self.handlers: + for _item_handlers in self.handlers: + if _item_handlers: + _items.append(_item_handlers.to_dict()) + _dict["handlers"] = _items + # override the default output from pydantic by calling `to_dict()` of each item in domains (list) + _items = [] + if self.domains: + for _item_domains in self.domains: + if _item_domains: + _items.append(_item_domains.to_dict()) + _dict["domains"] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of CreateServicesRequestServicesInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "port": obj.get("port"), + "destination_port": obj.get("destination_port"), + "handlers": [ServiceMapping.from_dict(_item) for _item in obj["handlers"]] + if obj.get("handlers") is not None + else None, + "domains": [CreateServicesRequestServicesInnerDomainsInner.from_dict(_item) for _item in obj["domains"]] + if obj.get("domains") is not None + else None, + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/create_services_request_services_inner_domains_inner.py b/unikraft_cloud_platform/models/create_services_request_services_inner_domains_inner.py new file mode 100644 index 0000000..76bcbf0 --- /dev/null +++ b/unikraft_cloud_platform/models/create_services_request_services_inner_domains_inner.py @@ -0,0 +1,105 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from unikraft_cloud_platform.models.create_services_request_services_inner_domains_inner_certificate import ( + CreateServicesRequestServicesInnerDomainsInnerCertificate, +) +from typing import Optional, Set +from typing_extensions import Self + + +class CreateServicesRequestServicesInnerDomainsInner(BaseModel): + """ + CreateServicesRequestServicesInnerDomainsInner + """ # noqa: E501 + + name: Annotated[str, Field(strict=True, max_length=255)] = Field( + description="Publicly accessible domain name Note: The services published by the service will be accessible under the given domain names. If `name` is a fully-qualified domain name, that is it ends with a dot (`.`), the domain name is taken as-is. Otherwise, the metro’s domain name is appended (e.g., `my-project` expands to `my-project.fra0.kraft.host`). If the given domain name is already in use by the current or a different user the operation fails. In addition, certain domain names cannot be used (e.g., `www.fra0.kraft.host`). " + ) + certificate: Optional[CreateServicesRequestServicesInnerDomainsInnerCertificate] = None + __properties: ClassVar[List[str]] = ["name", "certificate"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of CreateServicesRequestServicesInnerDomainsInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of certificate + if self.certificate: + _dict["certificate"] = self.certificate.to_dict() + # set to None if certificate (nullable) is None + # and model_fields_set contains the field + if self.certificate is None and "certificate" in self.model_fields_set: + _dict["certificate"] = None + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of CreateServicesRequestServicesInnerDomainsInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "name": obj.get("name"), + "certificate": CreateServicesRequestServicesInnerDomainsInnerCertificate.from_dict(obj["certificate"]) + if obj.get("certificate") is not None + else None, + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/create_services_request_services_inner_domains_inner_certificate.py b/unikraft_cloud_platform/models/create_services_request_services_inner_domains_inner_certificate.py new file mode 100644 index 0000000..fa986ee --- /dev/null +++ b/unikraft_cloud_platform/models/create_services_request_services_inner_domains_inner_certificate.py @@ -0,0 +1,88 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from uuid import UUID +from typing import Optional, Set +from typing_extensions import Self + + +class CreateServicesRequestServicesInnerDomainsInnerCertificate(BaseModel): + """ + TLS certificate to use for the domain Note: Only allowed for FQDNs, not for subdomains. Subdomains like `my-project` inherit the wildcard `*..kraft.host` certificate. If you specify an FQDN like `www.example.com`, Unikraft Cloud will automatically pick the certificate with the matching CN or trigger a certificate request (see [here](https://unikraft.cloud/docs/api/v1/certificates)). + """ # noqa: E501 + + uuid: Optional[UUID] = Field(default=None, description="The UUID of the certificate. ") + name: Optional[Annotated[str, Field(strict=True, max_length=255)]] = Field( + default=None, description="The name of the certificate. " + ) + __properties: ClassVar[List[str]] = [] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of CreateServicesRequestServicesInnerDomainsInnerCertificate from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of CreateServicesRequestServicesInnerDomainsInnerCertificate from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({}) + return _obj diff --git a/unikraft_cloud_platform/models/create_volume_request.py b/unikraft_cloud_platform/models/create_volume_request.py deleted file mode 100644 index 3a758ee..0000000 --- a/unikraft_cloud_platform/models/create_volume_request.py +++ /dev/null @@ -1,57 +0,0 @@ -from collections.abc import Mapping -from typing import Any, TypeVar - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -T = TypeVar("T", bound="CreateVolumeRequest") - - -@_attrs_define -class CreateVolumeRequest: - """The request message for creating a volume.""" - - size_mb: int - """ The size of the volume in megabytes. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - size_mb = self.size_mb - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update( - { - "size_mb": size_mb, - } - ) - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - d = dict(src_dict) - size_mb = d.pop("size_mb") - - create_volume_request = cls( - size_mb=size_mb, - ) - - create_volume_request.additional_properties = d - return create_volume_request - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/create_volume_response.py b/unikraft_cloud_platform/models/create_volume_response.py deleted file mode 100644 index 86ab273..0000000 --- a/unikraft_cloud_platform/models/create_volume_response.py +++ /dev/null @@ -1,117 +0,0 @@ -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..models.response_status import ResponseStatus, check_response_status -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.create_volume_response_data import CreateVolumeResponseData - from ..models.response_error import ResponseError - - -T = TypeVar("T", bound="CreateVolumeResponse") - - -@_attrs_define -class CreateVolumeResponse: - """The response message for creating of a volume.""" - - status: Union[Unset, ResponseStatus] = UNSET - """ The response status of an API request. """ - data: Union[Unset, "CreateVolumeResponseData"] = UNSET - errors: Union[Unset, list["ResponseError"]] = UNSET - """ A list of errors which may have occurred during the request. """ - op_time_us: Union[Unset, int] = UNSET - """ The operation time in microseconds. This is the time it took to process - the request and generate the response. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - status: Union[Unset, str] = UNSET - if not isinstance(self.status, Unset): - status = self.status - - data: Union[Unset, dict[str, Any]] = UNSET - if not isinstance(self.data, Unset): - data = self.data.to_dict() - - errors: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.errors, Unset): - errors = [] - for errors_item_data in self.errors: - errors_item = errors_item_data.to_dict() - errors.append(errors_item) - - op_time_us = self.op_time_us - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if status is not UNSET: - field_dict["status"] = status - if data is not UNSET: - field_dict["data"] = data - if errors is not UNSET: - field_dict["errors"] = errors - if op_time_us is not UNSET: - field_dict["op_time_us"] = op_time_us - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.create_volume_response_data import CreateVolumeResponseData - from ..models.response_error import ResponseError - - d = dict(src_dict) - _status = d.pop("status", UNSET) - status: Union[Unset, ResponseStatus] - if isinstance(_status, Unset): - status = UNSET - else: - status = check_response_status(_status) - - _data = d.pop("data", UNSET) - data: Union[Unset, CreateVolumeResponseData] - if isinstance(_data, Unset): - data = UNSET - else: - data = CreateVolumeResponseData.from_dict(_data) - - errors = [] - _errors = d.pop("errors", UNSET) - for errors_item_data in _errors or []: - errors_item = ResponseError.from_dict(errors_item_data) - - errors.append(errors_item) - - op_time_us = d.pop("op_time_us", UNSET) - - create_volume_response = cls( - status=status, - data=data, - errors=errors, - op_time_us=op_time_us, - ) - - create_volume_response.additional_properties = d - return create_volume_response - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/create_volume_response_data.py b/unikraft_cloud_platform/models/create_volume_response_data.py deleted file mode 100644 index d0304fe..0000000 --- a/unikraft_cloud_platform/models/create_volume_response_data.py +++ /dev/null @@ -1,71 +0,0 @@ -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.create_volume_response_volume import CreateVolumeResponseVolume - - -T = TypeVar("T", bound="CreateVolumeResponseData") - - -@_attrs_define -class CreateVolumeResponseData: - volumes: Union[Unset, list["CreateVolumeResponseVolume"]] = UNSET - """ The volume(s) which were created by the request. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - volumes: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.volumes, Unset): - volumes = [] - for volumes_item_data in self.volumes: - volumes_item = volumes_item_data.to_dict() - volumes.append(volumes_item) - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if volumes is not UNSET: - field_dict["volumes"] = volumes - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.create_volume_response_volume import CreateVolumeResponseVolume - - d = dict(src_dict) - volumes = [] - _volumes = d.pop("volumes", UNSET) - for volumes_item_data in _volumes or []: - volumes_item = CreateVolumeResponseVolume.from_dict(volumes_item_data) - - volumes.append(volumes_item) - - create_volume_response_data = cls( - volumes=volumes, - ) - - create_volume_response_data.additional_properties = d - return create_volume_response_data - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/create_volume_response_volume.py b/unikraft_cloud_platform/models/create_volume_response_volume.py deleted file mode 100644 index 3bae3e3..0000000 --- a/unikraft_cloud_platform/models/create_volume_response_volume.py +++ /dev/null @@ -1,109 +0,0 @@ -from collections.abc import Mapping -from typing import Any, TypeVar, Union -from uuid import UUID - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..models.response_status import ResponseStatus, check_response_status -from ..types import UNSET, Unset - -T = TypeVar("T", bound="CreateVolumeResponseVolume") - - -@_attrs_define -class CreateVolumeResponseVolume: - status: Union[Unset, ResponseStatus] = UNSET - """ The response status of an API request. """ - uuid: Union[Unset, UUID] = UNSET - """ UUID of the newly created volume. """ - name: Union[Unset, str] = UNSET - """ The name of the newly created volume. """ - message: Union[Unset, str] = UNSET - """ An optional message providing additional information about the status. - This field is useful when the status is not `success`. """ - error: Union[Unset, int] = UNSET - """ An optional error code providing additional information about the status. - This field is useful when the status is not `success`. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - status: Union[Unset, str] = UNSET - if not isinstance(self.status, Unset): - status = self.status - - uuid: Union[Unset, str] = UNSET - if not isinstance(self.uuid, Unset): - uuid = str(self.uuid) - - name = self.name - - message = self.message - - error = self.error - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if status is not UNSET: - field_dict["status"] = status - if uuid is not UNSET: - field_dict["uuid"] = uuid - if name is not UNSET: - field_dict["name"] = name - if message is not UNSET: - field_dict["message"] = message - if error is not UNSET: - field_dict["error"] = error - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - d = dict(src_dict) - _status = d.pop("status", UNSET) - status: Union[Unset, ResponseStatus] - if isinstance(_status, Unset): - status = UNSET - else: - status = check_response_status(_status) - - _uuid = d.pop("uuid", UNSET) - uuid: Union[Unset, UUID] - if isinstance(_uuid, Unset): - uuid = UNSET - else: - uuid = UUID(_uuid) - - name = d.pop("name", UNSET) - - message = d.pop("message", UNSET) - - error = d.pop("error", UNSET) - - create_volume_response_volume = cls( - status=status, - uuid=uuid, - name=name, - message=message, - error=error, - ) - - create_volume_response_volume.additional_properties = d - return create_volume_response_volume - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/create_volumes200_response.py b/unikraft_cloud_platform/models/create_volumes200_response.py new file mode 100644 index 0000000..41b8195 --- /dev/null +++ b/unikraft_cloud_platform/models/create_volumes200_response.py @@ -0,0 +1,103 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from unikraft_cloud_platform.models.create_volumes200_response_data import CreateVolumes200ResponseData +from typing import Optional, Set +from typing_extensions import Self + + +class CreateVolumes200Response(BaseModel): + """ + CreateVolumes200Response + """ # noqa: E501 + + status: Optional[StrictStr] = None + data: Optional[CreateVolumes200ResponseData] = None + __properties: ClassVar[List[str]] = ["status", "data"] + + @field_validator("status") + def status_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(["success", "failure"]): + raise ValueError("must be one of enum values ('success', 'failure')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of CreateVolumes200Response from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of data + if self.data: + _dict["data"] = self.data.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of CreateVolumes200Response from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "status": obj.get("status"), + "data": CreateVolumes200ResponseData.from_dict(obj["data"]) if obj.get("data") is not None else None, + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/create_volumes200_response_data.py b/unikraft_cloud_platform/models/create_volumes200_response_data.py new file mode 100644 index 0000000..cb587bb --- /dev/null +++ b/unikraft_cloud_platform/models/create_volumes200_response_data.py @@ -0,0 +1,100 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from unikraft_cloud_platform.models.create_volumes200_response_data_volumes_inner import ( + CreateVolumes200ResponseDataVolumesInner, +) +from typing import Optional, Set +from typing_extensions import Self + + +class CreateVolumes200ResponseData(BaseModel): + """ + CreateVolumes200ResponseData + """ # noqa: E501 + + volumes: Optional[Annotated[List[CreateVolumes200ResponseDataVolumesInner], Field(max_length=253)]] = None + __properties: ClassVar[List[str]] = ["volumes"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of CreateVolumes200ResponseData from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in volumes (list) + _items = [] + if self.volumes: + for _item_volumes in self.volumes: + if _item_volumes: + _items.append(_item_volumes.to_dict()) + _dict["volumes"] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of CreateVolumes200ResponseData from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "volumes": [CreateVolumes200ResponseDataVolumesInner.from_dict(_item) for _item in obj["volumes"]] + if obj.get("volumes") is not None + else None + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/create_volumes200_response_data_volumes_inner.py b/unikraft_cloud_platform/models/create_volumes200_response_data_volumes_inner.py new file mode 100644 index 0000000..0a5b2a1 --- /dev/null +++ b/unikraft_cloud_platform/models/create_volumes200_response_data_volumes_inner.py @@ -0,0 +1,99 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from uuid import UUID +from typing import Optional, Set +from typing_extensions import Self + + +class CreateVolumes200ResponseDataVolumesInner(BaseModel): + """ + CreateVolumes200ResponseDataVolumesInner + """ # noqa: E501 + + status: Optional[StrictStr] = None + uuid: Optional[UUID] = Field(default=None, description="The UUID of the volume. ") + name: Optional[Annotated[str, Field(strict=True, max_length=255)]] = Field( + default=None, description="The name of the volume. " + ) + __properties: ClassVar[List[str]] = ["status", "uuid", "name"] + + @field_validator("status") + def status_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(["success", "error"]): + raise ValueError("must be one of enum values ('success', 'error')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of CreateVolumes200ResponseDataVolumesInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of CreateVolumes200ResponseDataVolumesInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({"status": obj.get("status"), "uuid": obj.get("uuid"), "name": obj.get("name")}) + return _obj diff --git a/unikraft_cloud_platform/models/create_volumes_request_inner.py b/unikraft_cloud_platform/models/create_volumes_request_inner.py new file mode 100644 index 0000000..7bcb716 --- /dev/null +++ b/unikraft_cloud_platform/models/create_volumes_request_inner.py @@ -0,0 +1,90 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from typing import Optional, Set +from typing_extensions import Self + + +class CreateVolumesRequestInner(BaseModel): + """ + CreateVolumesRequestInner + """ # noqa: E501 + + name: Optional[Annotated[str, Field(strict=True, max_length=255)]] = Field( + default=None, + description="The name of the volume. Note: If no name is specified a random name of the form `vol-X` is auto-generated, where `X` is a 5 character long random alphanumeric suffix. ", + ) + size_mb: Annotated[int, Field(le=1048576, strict=True, ge=1)] = Field( + description="Size of the volume in megabytes. " + ) + __properties: ClassVar[List[str]] = ["name", "size_mb"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of CreateVolumesRequestInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of CreateVolumesRequestInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({"name": obj.get("name"), "size_mb": obj.get("size_mb")}) + return _obj diff --git a/unikraft_cloud_platform/models/delete_autoscale_configs200_response.py b/unikraft_cloud_platform/models/delete_autoscale_configs200_response.py new file mode 100644 index 0000000..1b7630d --- /dev/null +++ b/unikraft_cloud_platform/models/delete_autoscale_configs200_response.py @@ -0,0 +1,107 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from unikraft_cloud_platform.models.delete_autoscale_configs200_response_data import ( + DeleteAutoscaleConfigs200ResponseData, +) +from typing import Optional, Set +from typing_extensions import Self + + +class DeleteAutoscaleConfigs200Response(BaseModel): + """ + DeleteAutoscaleConfigs200Response + """ # noqa: E501 + + status: Optional[StrictStr] = Field(default=None, description="The status of the response. ") + data: Optional[DeleteAutoscaleConfigs200ResponseData] = None + __properties: ClassVar[List[str]] = ["status", "data"] + + @field_validator("status") + def status_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(["success", "failure"]): + raise ValueError("must be one of enum values ('success', 'failure')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of DeleteAutoscaleConfigs200Response from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of data + if self.data: + _dict["data"] = self.data.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of DeleteAutoscaleConfigs200Response from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "status": obj.get("status"), + "data": DeleteAutoscaleConfigs200ResponseData.from_dict(obj["data"]) + if obj.get("data") is not None + else None, + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/delete_autoscale_configs200_response_data.py b/unikraft_cloud_platform/models/delete_autoscale_configs200_response_data.py new file mode 100644 index 0000000..e43031d --- /dev/null +++ b/unikraft_cloud_platform/models/delete_autoscale_configs200_response_data.py @@ -0,0 +1,105 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from unikraft_cloud_platform.models.delete_autoscale_configs200_response_data_service_groups_inner import ( + DeleteAutoscaleConfigs200ResponseDataServiceGroupsInner, +) +from typing import Optional, Set +from typing_extensions import Self + + +class DeleteAutoscaleConfigs200ResponseData(BaseModel): + """ + DeleteAutoscaleConfigs200ResponseData + """ # noqa: E501 + + service_groups: Optional[ + Annotated[List[DeleteAutoscaleConfigs200ResponseDataServiceGroupsInner], Field(max_length=253)] + ] = None + __properties: ClassVar[List[str]] = ["service_groups"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of DeleteAutoscaleConfigs200ResponseData from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in service_groups (list) + _items = [] + if self.service_groups: + for _item_service_groups in self.service_groups: + if _item_service_groups: + _items.append(_item_service_groups.to_dict()) + _dict["service_groups"] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of DeleteAutoscaleConfigs200ResponseData from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "service_groups": [ + DeleteAutoscaleConfigs200ResponseDataServiceGroupsInner.from_dict(_item) + for _item in obj["service_groups"] + ] + if obj.get("service_groups") is not None + else None + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/delete_autoscale_configs200_response_data_service_groups_inner.py b/unikraft_cloud_platform/models/delete_autoscale_configs200_response_data_service_groups_inner.py new file mode 100644 index 0000000..03d78ed --- /dev/null +++ b/unikraft_cloud_platform/models/delete_autoscale_configs200_response_data_service_groups_inner.py @@ -0,0 +1,101 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from uuid import UUID +from typing import Optional, Set +from typing_extensions import Self + + +class DeleteAutoscaleConfigs200ResponseDataServiceGroupsInner(BaseModel): + """ + DeleteAutoscaleConfigs200ResponseDataServiceGroupsInner + """ # noqa: E501 + + status: Optional[Annotated[str, Field(strict=True, max_length=8388608)]] = Field( + default=None, description="The status of the response. " + ) + uuid: Optional[UUID] = Field(default=None, description="The UUID of the service. ") + name: Optional[Annotated[str, Field(strict=True, max_length=255)]] = Field( + default=None, description="The name of the service. " + ) + __properties: ClassVar[List[str]] = ["status", "uuid", "name"] + + @field_validator("status") + def status_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(["success", "failure"]): + raise ValueError("must be one of enum values ('success', 'failure')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of DeleteAutoscaleConfigs200ResponseDataServiceGroupsInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of DeleteAutoscaleConfigs200ResponseDataServiceGroupsInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({"status": obj.get("status"), "uuid": obj.get("uuid"), "name": obj.get("name")}) + return _obj diff --git a/unikraft_cloud_platform/models/delete_autoscale_configuration_policy_response.py b/unikraft_cloud_platform/models/delete_autoscale_configuration_policy_response.py deleted file mode 100644 index 7ec1304..0000000 --- a/unikraft_cloud_platform/models/delete_autoscale_configuration_policy_response.py +++ /dev/null @@ -1,119 +0,0 @@ -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..models.response_status import ResponseStatus, check_response_status -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.delete_autoscale_configuration_policy_response_data import ( - DeleteAutoscaleConfigurationPolicyResponseData, - ) - from ..models.response_error import ResponseError - - -T = TypeVar("T", bound="DeleteAutoscaleConfigurationPolicyResponse") - - -@_attrs_define -class DeleteAutoscaleConfigurationPolicyResponse: - status: Union[Unset, ResponseStatus] = UNSET - """ The response status of an API request. """ - data: Union[Unset, "DeleteAutoscaleConfigurationPolicyResponseData"] = UNSET - errors: Union[Unset, list["ResponseError"]] = UNSET - """ A list of errors which may have occurred during the request. """ - op_time_us: Union[Unset, int] = UNSET - """ The operation time in microseconds. This is the time it took to process - the request and generate the response. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - status: Union[Unset, str] = UNSET - if not isinstance(self.status, Unset): - status = self.status - - data: Union[Unset, dict[str, Any]] = UNSET - if not isinstance(self.data, Unset): - data = self.data.to_dict() - - errors: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.errors, Unset): - errors = [] - for errors_item_data in self.errors: - errors_item = errors_item_data.to_dict() - errors.append(errors_item) - - op_time_us = self.op_time_us - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if status is not UNSET: - field_dict["status"] = status - if data is not UNSET: - field_dict["data"] = data - if errors is not UNSET: - field_dict["errors"] = errors - if op_time_us is not UNSET: - field_dict["op_time_us"] = op_time_us - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.delete_autoscale_configuration_policy_response_data import ( - DeleteAutoscaleConfigurationPolicyResponseData, - ) - from ..models.response_error import ResponseError - - d = dict(src_dict) - _status = d.pop("status", UNSET) - status: Union[Unset, ResponseStatus] - if isinstance(_status, Unset): - status = UNSET - else: - status = check_response_status(_status) - - _data = d.pop("data", UNSET) - data: Union[Unset, DeleteAutoscaleConfigurationPolicyResponseData] - if isinstance(_data, Unset): - data = UNSET - else: - data = DeleteAutoscaleConfigurationPolicyResponseData.from_dict(_data) - - errors = [] - _errors = d.pop("errors", UNSET) - for errors_item_data in _errors or []: - errors_item = ResponseError.from_dict(errors_item_data) - - errors.append(errors_item) - - op_time_us = d.pop("op_time_us", UNSET) - - delete_autoscale_configuration_policy_response = cls( - status=status, - data=data, - errors=errors, - op_time_us=op_time_us, - ) - - delete_autoscale_configuration_policy_response.additional_properties = d - return delete_autoscale_configuration_policy_response - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/delete_autoscale_configuration_policy_response_data.py b/unikraft_cloud_platform/models/delete_autoscale_configuration_policy_response_data.py deleted file mode 100644 index f1713f2..0000000 --- a/unikraft_cloud_platform/models/delete_autoscale_configuration_policy_response_data.py +++ /dev/null @@ -1,75 +0,0 @@ -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.delete_autoscale_configuration_policy_response_policies_response import ( - DeleteAutoscaleConfigurationPolicyResponsePoliciesResponse, - ) - - -T = TypeVar("T", bound="DeleteAutoscaleConfigurationPolicyResponseData") - - -@_attrs_define -class DeleteAutoscaleConfigurationPolicyResponseData: - policies: Union[Unset, list["DeleteAutoscaleConfigurationPolicyResponsePoliciesResponse"]] = UNSET - """ The policies which were deleted by the request. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - policies: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.policies, Unset): - policies = [] - for policies_item_data in self.policies: - policies_item = policies_item_data.to_dict() - policies.append(policies_item) - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if policies is not UNSET: - field_dict["policies"] = policies - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.delete_autoscale_configuration_policy_response_policies_response import ( - DeleteAutoscaleConfigurationPolicyResponsePoliciesResponse, - ) - - d = dict(src_dict) - policies = [] - _policies = d.pop("policies", UNSET) - for policies_item_data in _policies or []: - policies_item = DeleteAutoscaleConfigurationPolicyResponsePoliciesResponse.from_dict(policies_item_data) - - policies.append(policies_item) - - delete_autoscale_configuration_policy_response_data = cls( - policies=policies, - ) - - delete_autoscale_configuration_policy_response_data.additional_properties = d - return delete_autoscale_configuration_policy_response_data - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/delete_autoscale_configuration_policy_response_policies_response.py b/unikraft_cloud_platform/models/delete_autoscale_configuration_policy_response_policies_response.py deleted file mode 100644 index fa85fe6..0000000 --- a/unikraft_cloud_platform/models/delete_autoscale_configuration_policy_response_policies_response.py +++ /dev/null @@ -1,92 +0,0 @@ -from collections.abc import Mapping -from typing import Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..models.response_status import ResponseStatus, check_response_status -from ..types import UNSET, Unset - -T = TypeVar("T", bound="DeleteAutoscaleConfigurationPolicyResponsePoliciesResponse") - - -@_attrs_define -class DeleteAutoscaleConfigurationPolicyResponsePoliciesResponse: - status: Union[Unset, ResponseStatus] = UNSET - """ The response status of an API request. """ - name: Union[Unset, str] = UNSET - """ The name of the service of the deleted policy. """ - message: Union[Unset, str] = UNSET - """ An optional message providing additional information about the status. - This field is useful when the status is not `success`. """ - error: Union[Unset, int] = UNSET - """ An optional error code providing additional information about the status. - This field is useful when the status is not `success`. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - status: Union[Unset, str] = UNSET - if not isinstance(self.status, Unset): - status = self.status - - name = self.name - - message = self.message - - error = self.error - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if status is not UNSET: - field_dict["status"] = status - if name is not UNSET: - field_dict["name"] = name - if message is not UNSET: - field_dict["message"] = message - if error is not UNSET: - field_dict["error"] = error - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - d = dict(src_dict) - _status = d.pop("status", UNSET) - status: Union[Unset, ResponseStatus] - if isinstance(_status, Unset): - status = UNSET - else: - status = check_response_status(_status) - - name = d.pop("name", UNSET) - - message = d.pop("message", UNSET) - - error = d.pop("error", UNSET) - - delete_autoscale_configuration_policy_response_policies_response = cls( - status=status, - name=name, - message=message, - error=error, - ) - - delete_autoscale_configuration_policy_response_policies_response.additional_properties = d - return delete_autoscale_configuration_policy_response_policies_response - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/delete_autoscale_configurations_response.py b/unikraft_cloud_platform/models/delete_autoscale_configurations_response.py deleted file mode 100644 index aecf793..0000000 --- a/unikraft_cloud_platform/models/delete_autoscale_configurations_response.py +++ /dev/null @@ -1,115 +0,0 @@ -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..models.response_status import ResponseStatus, check_response_status -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.delete_autoscale_configurations_response_data import DeleteAutoscaleConfigurationsResponseData - from ..models.response_error import ResponseError - - -T = TypeVar("T", bound="DeleteAutoscaleConfigurationsResponse") - - -@_attrs_define -class DeleteAutoscaleConfigurationsResponse: - status: Union[Unset, ResponseStatus] = UNSET - """ The response status of an API request. """ - data: Union[Unset, "DeleteAutoscaleConfigurationsResponseData"] = UNSET - errors: Union[Unset, list["ResponseError"]] = UNSET - """ A list of errors which may have occurred during the request. """ - op_time_us: Union[Unset, int] = UNSET - """ The operation time in microseconds. This is the time it took to process - the request and generate the response. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - status: Union[Unset, str] = UNSET - if not isinstance(self.status, Unset): - status = self.status - - data: Union[Unset, dict[str, Any]] = UNSET - if not isinstance(self.data, Unset): - data = self.data.to_dict() - - errors: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.errors, Unset): - errors = [] - for errors_item_data in self.errors: - errors_item = errors_item_data.to_dict() - errors.append(errors_item) - - op_time_us = self.op_time_us - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if status is not UNSET: - field_dict["status"] = status - if data is not UNSET: - field_dict["data"] = data - if errors is not UNSET: - field_dict["errors"] = errors - if op_time_us is not UNSET: - field_dict["op_time_us"] = op_time_us - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.delete_autoscale_configurations_response_data import DeleteAutoscaleConfigurationsResponseData - from ..models.response_error import ResponseError - - d = dict(src_dict) - _status = d.pop("status", UNSET) - status: Union[Unset, ResponseStatus] - if isinstance(_status, Unset): - status = UNSET - else: - status = check_response_status(_status) - - _data = d.pop("data", UNSET) - data: Union[Unset, DeleteAutoscaleConfigurationsResponseData] - if isinstance(_data, Unset): - data = UNSET - else: - data = DeleteAutoscaleConfigurationsResponseData.from_dict(_data) - - errors = [] - _errors = d.pop("errors", UNSET) - for errors_item_data in _errors or []: - errors_item = ResponseError.from_dict(errors_item_data) - - errors.append(errors_item) - - op_time_us = d.pop("op_time_us", UNSET) - - delete_autoscale_configurations_response = cls( - status=status, - data=data, - errors=errors, - op_time_us=op_time_us, - ) - - delete_autoscale_configurations_response.additional_properties = d - return delete_autoscale_configurations_response - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/delete_autoscale_configurations_response_data.py b/unikraft_cloud_platform/models/delete_autoscale_configurations_response_data.py deleted file mode 100644 index b0bb054..0000000 --- a/unikraft_cloud_platform/models/delete_autoscale_configurations_response_data.py +++ /dev/null @@ -1,75 +0,0 @@ -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.delete_autoscale_configurations_response_service_group import ( - DeleteAutoscaleConfigurationsResponseServiceGroup, - ) - - -T = TypeVar("T", bound="DeleteAutoscaleConfigurationsResponseData") - - -@_attrs_define -class DeleteAutoscaleConfigurationsResponseData: - service_groups: Union[Unset, list["DeleteAutoscaleConfigurationsResponseServiceGroup"]] = UNSET - """ The configuration(s) which were deleted by the request. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - service_groups: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.service_groups, Unset): - service_groups = [] - for service_groups_item_data in self.service_groups: - service_groups_item = service_groups_item_data.to_dict() - service_groups.append(service_groups_item) - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if service_groups is not UNSET: - field_dict["service_groups"] = service_groups - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.delete_autoscale_configurations_response_service_group import ( - DeleteAutoscaleConfigurationsResponseServiceGroup, - ) - - d = dict(src_dict) - service_groups = [] - _service_groups = d.pop("service_groups", UNSET) - for service_groups_item_data in _service_groups or []: - service_groups_item = DeleteAutoscaleConfigurationsResponseServiceGroup.from_dict(service_groups_item_data) - - service_groups.append(service_groups_item) - - delete_autoscale_configurations_response_data = cls( - service_groups=service_groups, - ) - - delete_autoscale_configurations_response_data.additional_properties = d - return delete_autoscale_configurations_response_data - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/delete_autoscale_configurations_response_service_group.py b/unikraft_cloud_platform/models/delete_autoscale_configurations_response_service_group.py deleted file mode 100644 index d205d85..0000000 --- a/unikraft_cloud_platform/models/delete_autoscale_configurations_response_service_group.py +++ /dev/null @@ -1,109 +0,0 @@ -from collections.abc import Mapping -from typing import Any, TypeVar, Union -from uuid import UUID - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..models.response_status import ResponseStatus, check_response_status -from ..types import UNSET, Unset - -T = TypeVar("T", bound="DeleteAutoscaleConfigurationsResponseServiceGroup") - - -@_attrs_define -class DeleteAutoscaleConfigurationsResponseServiceGroup: - status: Union[Unset, ResponseStatus] = UNSET - """ The response status of an API request. """ - uuid: Union[Unset, UUID] = UNSET - """ The UUID of the service where the configuration was deleted. """ - name: Union[Unset, str] = UNSET - """ The name of the service where the configuration was deleted. """ - message: Union[Unset, str] = UNSET - """ An optional message providing additional information about the status. - This field is useful when the status is not `success`. """ - error: Union[Unset, int] = UNSET - """ An optional error code providing additional information about the status. - This field is useful when the status is not `success`. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - status: Union[Unset, str] = UNSET - if not isinstance(self.status, Unset): - status = self.status - - uuid: Union[Unset, str] = UNSET - if not isinstance(self.uuid, Unset): - uuid = str(self.uuid) - - name = self.name - - message = self.message - - error = self.error - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if status is not UNSET: - field_dict["status"] = status - if uuid is not UNSET: - field_dict["uuid"] = uuid - if name is not UNSET: - field_dict["name"] = name - if message is not UNSET: - field_dict["message"] = message - if error is not UNSET: - field_dict["error"] = error - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - d = dict(src_dict) - _status = d.pop("status", UNSET) - status: Union[Unset, ResponseStatus] - if isinstance(_status, Unset): - status = UNSET - else: - status = check_response_status(_status) - - _uuid = d.pop("uuid", UNSET) - uuid: Union[Unset, UUID] - if isinstance(_uuid, Unset): - uuid = UNSET - else: - uuid = UUID(_uuid) - - name = d.pop("name", UNSET) - - message = d.pop("message", UNSET) - - error = d.pop("error", UNSET) - - delete_autoscale_configurations_response_service_group = cls( - status=status, - uuid=uuid, - name=name, - message=message, - error=error, - ) - - delete_autoscale_configurations_response_service_group.additional_properties = d - return delete_autoscale_configurations_response_service_group - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/delete_autoscale_policies200_response.py b/unikraft_cloud_platform/models/delete_autoscale_policies200_response.py new file mode 100644 index 0000000..64e9f12 --- /dev/null +++ b/unikraft_cloud_platform/models/delete_autoscale_policies200_response.py @@ -0,0 +1,107 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from unikraft_cloud_platform.models.delete_autoscale_policies200_response_data import ( + DeleteAutoscalePolicies200ResponseData, +) +from typing import Optional, Set +from typing_extensions import Self + + +class DeleteAutoscalePolicies200Response(BaseModel): + """ + DeleteAutoscalePolicies200Response + """ # noqa: E501 + + status: Optional[StrictStr] = Field(default=None, description="The status of the response. ") + data: Optional[DeleteAutoscalePolicies200ResponseData] = None + __properties: ClassVar[List[str]] = ["status", "data"] + + @field_validator("status") + def status_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(["success", "failure"]): + raise ValueError("must be one of enum values ('success', 'failure')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of DeleteAutoscalePolicies200Response from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of data + if self.data: + _dict["data"] = self.data.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of DeleteAutoscalePolicies200Response from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "status": obj.get("status"), + "data": DeleteAutoscalePolicies200ResponseData.from_dict(obj["data"]) + if obj.get("data") is not None + else None, + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/delete_autoscale_policies200_response_data.py b/unikraft_cloud_platform/models/delete_autoscale_policies200_response_data.py new file mode 100644 index 0000000..bf8e9ea --- /dev/null +++ b/unikraft_cloud_platform/models/delete_autoscale_policies200_response_data.py @@ -0,0 +1,104 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from unikraft_cloud_platform.models.delete_autoscale_policies200_response_data_policies_inner import ( + DeleteAutoscalePolicies200ResponseDataPoliciesInner, +) +from typing import Optional, Set +from typing_extensions import Self + + +class DeleteAutoscalePolicies200ResponseData(BaseModel): + """ + DeleteAutoscalePolicies200ResponseData + """ # noqa: E501 + + policies: Optional[Annotated[List[DeleteAutoscalePolicies200ResponseDataPoliciesInner], Field(max_length=253)]] = ( + None + ) + __properties: ClassVar[List[str]] = ["policies"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of DeleteAutoscalePolicies200ResponseData from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in policies (list) + _items = [] + if self.policies: + for _item_policies in self.policies: + if _item_policies: + _items.append(_item_policies.to_dict()) + _dict["policies"] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of DeleteAutoscalePolicies200ResponseData from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "policies": [ + DeleteAutoscalePolicies200ResponseDataPoliciesInner.from_dict(_item) for _item in obj["policies"] + ] + if obj.get("policies") is not None + else None + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/delete_autoscale_policies200_response_data_policies_inner.py b/unikraft_cloud_platform/models/delete_autoscale_policies200_response_data_policies_inner.py new file mode 100644 index 0000000..6629549 --- /dev/null +++ b/unikraft_cloud_platform/models/delete_autoscale_policies200_response_data_policies_inner.py @@ -0,0 +1,97 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from typing import Optional, Set +from typing_extensions import Self + + +class DeleteAutoscalePolicies200ResponseDataPoliciesInner(BaseModel): + """ + DeleteAutoscalePolicies200ResponseDataPoliciesInner + """ # noqa: E501 + + status: Optional[StrictStr] = Field(default=None, description="The status of the response. ") + name: Optional[Annotated[str, Field(strict=True, max_length=255)]] = Field( + default=None, description="The name of the policy. " + ) + __properties: ClassVar[List[str]] = ["status", "name"] + + @field_validator("status") + def status_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(["success", "failure"]): + raise ValueError("must be one of enum values ('success', 'failure')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of DeleteAutoscalePolicies200ResponseDataPoliciesInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of DeleteAutoscalePolicies200ResponseDataPoliciesInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({"status": obj.get("status"), "name": obj.get("name")}) + return _obj diff --git a/unikraft_cloud_platform/models/delete_autoscale_policy_by_service_uuid_and_policy_name200_response.py b/unikraft_cloud_platform/models/delete_autoscale_policy_by_service_uuid_and_policy_name200_response.py new file mode 100644 index 0000000..72f1d05 --- /dev/null +++ b/unikraft_cloud_platform/models/delete_autoscale_policy_by_service_uuid_and_policy_name200_response.py @@ -0,0 +1,107 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from unikraft_cloud_platform.models.delete_autoscale_policy_by_service_uuid_and_policy_name200_response_data import ( + DeleteAutoscalePolicyByServiceUuidAndPolicyName200ResponseData, +) +from typing import Optional, Set +from typing_extensions import Self + + +class DeleteAutoscalePolicyByServiceUuidAndPolicyName200Response(BaseModel): + """ + DeleteAutoscalePolicyByServiceUuidAndPolicyName200Response + """ # noqa: E501 + + status: Optional[StrictStr] = Field(default=None, description="The status of the response. ") + data: Optional[DeleteAutoscalePolicyByServiceUuidAndPolicyName200ResponseData] = None + __properties: ClassVar[List[str]] = ["status", "data"] + + @field_validator("status") + def status_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(["success", "failure"]): + raise ValueError("must be one of enum values ('success', 'failure')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of DeleteAutoscalePolicyByServiceUuidAndPolicyName200Response from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of data + if self.data: + _dict["data"] = self.data.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of DeleteAutoscalePolicyByServiceUuidAndPolicyName200Response from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "status": obj.get("status"), + "data": DeleteAutoscalePolicyByServiceUuidAndPolicyName200ResponseData.from_dict(obj["data"]) + if obj.get("data") is not None + else None, + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/delete_autoscale_policy_by_service_uuid_and_policy_name200_response_data.py b/unikraft_cloud_platform/models/delete_autoscale_policy_by_service_uuid_and_policy_name200_response_data.py new file mode 100644 index 0000000..8c33e54 --- /dev/null +++ b/unikraft_cloud_platform/models/delete_autoscale_policy_by_service_uuid_and_policy_name200_response_data.py @@ -0,0 +1,102 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from unikraft_cloud_platform.models.delete_autoscale_policies200_response_data_policies_inner import ( + DeleteAutoscalePolicies200ResponseDataPoliciesInner, +) +from typing import Optional, Set +from typing_extensions import Self + + +class DeleteAutoscalePolicyByServiceUuidAndPolicyName200ResponseData(BaseModel): + """ + DeleteAutoscalePolicyByServiceUuidAndPolicyName200ResponseData + """ # noqa: E501 + + policies: Optional[Annotated[List[DeleteAutoscalePolicies200ResponseDataPoliciesInner], Field(max_length=1)]] = None + __properties: ClassVar[List[str]] = ["policies"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of DeleteAutoscalePolicyByServiceUuidAndPolicyName200ResponseData from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in policies (list) + _items = [] + if self.policies: + for _item_policies in self.policies: + if _item_policies: + _items.append(_item_policies.to_dict()) + _dict["policies"] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of DeleteAutoscalePolicyByServiceUuidAndPolicyName200ResponseData from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "policies": [ + DeleteAutoscalePolicies200ResponseDataPoliciesInner.from_dict(_item) for _item in obj["policies"] + ] + if obj.get("policies") is not None + else None + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/delete_certificate_by_uuid200_response.py b/unikraft_cloud_platform/models/delete_certificate_by_uuid200_response.py new file mode 100644 index 0000000..53e6a80 --- /dev/null +++ b/unikraft_cloud_platform/models/delete_certificate_by_uuid200_response.py @@ -0,0 +1,107 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from unikraft_cloud_platform.models.delete_certificate_by_uuid200_response_data import ( + DeleteCertificateByUuid200ResponseData, +) +from typing import Optional, Set +from typing_extensions import Self + + +class DeleteCertificateByUuid200Response(BaseModel): + """ + DeleteCertificateByUuid200Response + """ # noqa: E501 + + status: Optional[StrictStr] = Field(default=None, description="The status of the response. ") + data: Optional[DeleteCertificateByUuid200ResponseData] = None + __properties: ClassVar[List[str]] = ["status", "data"] + + @field_validator("status") + def status_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(["success", "failure"]): + raise ValueError("must be one of enum values ('success', 'failure')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of DeleteCertificateByUuid200Response from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of data + if self.data: + _dict["data"] = self.data.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of DeleteCertificateByUuid200Response from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "status": obj.get("status"), + "data": DeleteCertificateByUuid200ResponseData.from_dict(obj["data"]) + if obj.get("data") is not None + else None, + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/delete_certificate_by_uuid200_response_data.py b/unikraft_cloud_platform/models/delete_certificate_by_uuid200_response_data.py new file mode 100644 index 0000000..36fe8b3 --- /dev/null +++ b/unikraft_cloud_platform/models/delete_certificate_by_uuid200_response_data.py @@ -0,0 +1,104 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from unikraft_cloud_platform.models.delete_certificates200_response_data_certificates_inner import ( + DeleteCertificates200ResponseDataCertificatesInner, +) +from typing import Optional, Set +from typing_extensions import Self + + +class DeleteCertificateByUuid200ResponseData(BaseModel): + """ + DeleteCertificateByUuid200ResponseData + """ # noqa: E501 + + certificates: Optional[Annotated[List[DeleteCertificates200ResponseDataCertificatesInner], Field(max_length=1)]] = ( + None + ) + __properties: ClassVar[List[str]] = ["certificates"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of DeleteCertificateByUuid200ResponseData from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in certificates (list) + _items = [] + if self.certificates: + for _item_certificates in self.certificates: + if _item_certificates: + _items.append(_item_certificates.to_dict()) + _dict["certificates"] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of DeleteCertificateByUuid200ResponseData from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "certificates": [ + DeleteCertificates200ResponseDataCertificatesInner.from_dict(_item) for _item in obj["certificates"] + ] + if obj.get("certificates") is not None + else None + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/delete_certificates200_response.py b/unikraft_cloud_platform/models/delete_certificates200_response.py new file mode 100644 index 0000000..682ae37 --- /dev/null +++ b/unikraft_cloud_platform/models/delete_certificates200_response.py @@ -0,0 +1,105 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from unikraft_cloud_platform.models.delete_certificates200_response_data import DeleteCertificates200ResponseData +from typing import Optional, Set +from typing_extensions import Self + + +class DeleteCertificates200Response(BaseModel): + """ + DeleteCertificates200Response + """ # noqa: E501 + + status: Optional[StrictStr] = Field(default=None, description="The status of the response. ") + data: Optional[DeleteCertificates200ResponseData] = None + __properties: ClassVar[List[str]] = ["status", "data"] + + @field_validator("status") + def status_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(["success", "failure"]): + raise ValueError("must be one of enum values ('success', 'failure')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of DeleteCertificates200Response from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of data + if self.data: + _dict["data"] = self.data.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of DeleteCertificates200Response from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "status": obj.get("status"), + "data": DeleteCertificates200ResponseData.from_dict(obj["data"]) + if obj.get("data") is not None + else None, + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/delete_certificates200_response_data.py b/unikraft_cloud_platform/models/delete_certificates200_response_data.py new file mode 100644 index 0000000..32024f1 --- /dev/null +++ b/unikraft_cloud_platform/models/delete_certificates200_response_data.py @@ -0,0 +1,104 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from unikraft_cloud_platform.models.delete_certificates200_response_data_certificates_inner import ( + DeleteCertificates200ResponseDataCertificatesInner, +) +from typing import Optional, Set +from typing_extensions import Self + + +class DeleteCertificates200ResponseData(BaseModel): + """ + DeleteCertificates200ResponseData + """ # noqa: E501 + + certificates: Optional[ + Annotated[List[DeleteCertificates200ResponseDataCertificatesInner], Field(max_length=253)] + ] = None + __properties: ClassVar[List[str]] = ["certificates"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of DeleteCertificates200ResponseData from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in certificates (list) + _items = [] + if self.certificates: + for _item_certificates in self.certificates: + if _item_certificates: + _items.append(_item_certificates.to_dict()) + _dict["certificates"] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of DeleteCertificates200ResponseData from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "certificates": [ + DeleteCertificates200ResponseDataCertificatesInner.from_dict(_item) for _item in obj["certificates"] + ] + if obj.get("certificates") is not None + else None + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/delete_certificates200_response_data_certificates_inner.py b/unikraft_cloud_platform/models/delete_certificates200_response_data_certificates_inner.py new file mode 100644 index 0000000..c329280 --- /dev/null +++ b/unikraft_cloud_platform/models/delete_certificates200_response_data_certificates_inner.py @@ -0,0 +1,99 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from uuid import UUID +from typing import Optional, Set +from typing_extensions import Self + + +class DeleteCertificates200ResponseDataCertificatesInner(BaseModel): + """ + DeleteCertificates200ResponseDataCertificatesInner + """ # noqa: E501 + + status: Optional[StrictStr] = Field(default=None, description="The status of the response. ") + uuid: Optional[UUID] = Field(default=None, description="The UUID of the certificate. ") + name: Optional[Annotated[str, Field(strict=True, max_length=255)]] = Field( + default=None, description="The name of the certificate. " + ) + __properties: ClassVar[List[str]] = ["status", "uuid", "name"] + + @field_validator("status") + def status_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(["success", "error"]): + raise ValueError("must be one of enum values ('success', 'error')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of DeleteCertificates200ResponseDataCertificatesInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of DeleteCertificates200ResponseDataCertificatesInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({"status": obj.get("status"), "uuid": obj.get("uuid"), "name": obj.get("name")}) + return _obj diff --git a/unikraft_cloud_platform/models/delete_certificates_request_inner.py b/unikraft_cloud_platform/models/delete_certificates_request_inner.py new file mode 100644 index 0000000..59f1541 --- /dev/null +++ b/unikraft_cloud_platform/models/delete_certificates_request_inner.py @@ -0,0 +1,92 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from uuid import UUID +from typing import Optional, Set +from typing_extensions import Self + + +class DeleteCertificatesRequestInner(BaseModel): + """ + DeleteCertificatesRequestInner + """ # noqa: E501 + + uuid: Optional[UUID] = Field( + default=None, + description="The UUID of the certificate to delete. Note: This property is mutually exclusive with `name` and either `uuid` or `name` are required. ", + ) + name: Optional[Annotated[str, Field(strict=True, max_length=255)]] = Field( + default=None, + description="The name of the certificate to delete. Note: This property is mutually exclusive with `uuid` and either `uuid` or `name` are required. ", + ) + __properties: ClassVar[List[str]] = ["uuid", "name"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of DeleteCertificatesRequestInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of DeleteCertificatesRequestInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({"uuid": obj.get("uuid"), "name": obj.get("name")}) + return _obj diff --git a/unikraft_cloud_platform/models/delete_certificates_response.py b/unikraft_cloud_platform/models/delete_certificates_response.py deleted file mode 100644 index 86fc83c..0000000 --- a/unikraft_cloud_platform/models/delete_certificates_response.py +++ /dev/null @@ -1,130 +0,0 @@ -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..models.response_status import ResponseStatus, check_response_status -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.delete_certificates_response_data import DeleteCertificatesResponseData - from ..models.response_error import ResponseError - - -T = TypeVar("T", bound="DeleteCertificatesResponse") - - -@_attrs_define -class DeleteCertificatesResponse: - """The response message for deleting of one or more certificate(s) given their - UUID(s) or name(s). - - """ - - status: Union[Unset, ResponseStatus] = UNSET - """ The response status of an API request. """ - message: Union[Unset, str] = UNSET - """ An optional message providing additional information about the status. - This field is useful when the status is not `success`. """ - data: Union[Unset, "DeleteCertificatesResponseData"] = UNSET - errors: Union[Unset, list["ResponseError"]] = UNSET - """ A list of errors which may have occurred during the request. """ - op_time_us: Union[Unset, int] = UNSET - """ The operation time in microseconds. This is the time it took to process - the request and generate the response. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - status: Union[Unset, str] = UNSET - if not isinstance(self.status, Unset): - status = self.status - - message = self.message - - data: Union[Unset, dict[str, Any]] = UNSET - if not isinstance(self.data, Unset): - data = self.data.to_dict() - - errors: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.errors, Unset): - errors = [] - for errors_item_data in self.errors: - errors_item = errors_item_data.to_dict() - errors.append(errors_item) - - op_time_us = self.op_time_us - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if status is not UNSET: - field_dict["status"] = status - if message is not UNSET: - field_dict["message"] = message - if data is not UNSET: - field_dict["data"] = data - if errors is not UNSET: - field_dict["errors"] = errors - if op_time_us is not UNSET: - field_dict["op_time_us"] = op_time_us - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.delete_certificates_response_data import DeleteCertificatesResponseData - from ..models.response_error import ResponseError - - d = dict(src_dict) - _status = d.pop("status", UNSET) - status: Union[Unset, ResponseStatus] - if isinstance(_status, Unset): - status = UNSET - else: - status = check_response_status(_status) - - message = d.pop("message", UNSET) - - _data = d.pop("data", UNSET) - data: Union[Unset, DeleteCertificatesResponseData] - if isinstance(_data, Unset): - data = UNSET - else: - data = DeleteCertificatesResponseData.from_dict(_data) - - errors = [] - _errors = d.pop("errors", UNSET) - for errors_item_data in _errors or []: - errors_item = ResponseError.from_dict(errors_item_data) - - errors.append(errors_item) - - op_time_us = d.pop("op_time_us", UNSET) - - delete_certificates_response = cls( - status=status, - message=message, - data=data, - errors=errors, - op_time_us=op_time_us, - ) - - delete_certificates_response.additional_properties = d - return delete_certificates_response - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/delete_certificates_response_data.py b/unikraft_cloud_platform/models/delete_certificates_response_data.py deleted file mode 100644 index 9d2fe38..0000000 --- a/unikraft_cloud_platform/models/delete_certificates_response_data.py +++ /dev/null @@ -1,73 +0,0 @@ -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.delete_certificates_response_deleted_certificate import DeleteCertificatesResponseDeletedCertificate - - -T = TypeVar("T", bound="DeleteCertificatesResponseData") - - -@_attrs_define -class DeleteCertificatesResponseData: - certificates: Union[Unset, list["DeleteCertificatesResponseDeletedCertificate"]] = UNSET - """ The certificate(s) which were deleted by the request. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - certificates: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.certificates, Unset): - certificates = [] - for certificates_item_data in self.certificates: - certificates_item = certificates_item_data.to_dict() - certificates.append(certificates_item) - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if certificates is not UNSET: - field_dict["certificates"] = certificates - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.delete_certificates_response_deleted_certificate import ( - DeleteCertificatesResponseDeletedCertificate, - ) - - d = dict(src_dict) - certificates = [] - _certificates = d.pop("certificates", UNSET) - for certificates_item_data in _certificates or []: - certificates_item = DeleteCertificatesResponseDeletedCertificate.from_dict(certificates_item_data) - - certificates.append(certificates_item) - - delete_certificates_response_data = cls( - certificates=certificates, - ) - - delete_certificates_response_data.additional_properties = d - return delete_certificates_response_data - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/delete_certificates_response_deleted_certificate.py b/unikraft_cloud_platform/models/delete_certificates_response_deleted_certificate.py deleted file mode 100644 index cea344b..0000000 --- a/unikraft_cloud_platform/models/delete_certificates_response_deleted_certificate.py +++ /dev/null @@ -1,111 +0,0 @@ -from collections.abc import Mapping -from typing import Any, TypeVar, Union -from uuid import UUID - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..models.response_status import ResponseStatus, check_response_status -from ..types import UNSET, Unset - -T = TypeVar("T", bound="DeleteCertificatesResponseDeletedCertificate") - - -@_attrs_define -class DeleteCertificatesResponseDeletedCertificate: - """Details of the certificate which was deleted by this request.""" - - status: Union[Unset, ResponseStatus] = UNSET - """ The response status of an API request. """ - uuid: Union[Unset, UUID] = UNSET - """ The UUID of the certificate which was deleted. """ - name: Union[Unset, str] = UNSET - """ The name of the certificate which was deleted. """ - message: Union[Unset, str] = UNSET - """ An optional message providing additional information about the status. - This field is useful when the status is not `success`. """ - error: Union[Unset, int] = UNSET - """ An optional error code providing additional information about the status. - This field is useful when the status is not `success`. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - status: Union[Unset, str] = UNSET - if not isinstance(self.status, Unset): - status = self.status - - uuid: Union[Unset, str] = UNSET - if not isinstance(self.uuid, Unset): - uuid = str(self.uuid) - - name = self.name - - message = self.message - - error = self.error - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if status is not UNSET: - field_dict["status"] = status - if uuid is not UNSET: - field_dict["uuid"] = uuid - if name is not UNSET: - field_dict["name"] = name - if message is not UNSET: - field_dict["message"] = message - if error is not UNSET: - field_dict["error"] = error - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - d = dict(src_dict) - _status = d.pop("status", UNSET) - status: Union[Unset, ResponseStatus] - if isinstance(_status, Unset): - status = UNSET - else: - status = check_response_status(_status) - - _uuid = d.pop("uuid", UNSET) - uuid: Union[Unset, UUID] - if isinstance(_uuid, Unset): - uuid = UNSET - else: - uuid = UUID(_uuid) - - name = d.pop("name", UNSET) - - message = d.pop("message", UNSET) - - error = d.pop("error", UNSET) - - delete_certificates_response_deleted_certificate = cls( - status=status, - uuid=uuid, - name=name, - message=message, - error=error, - ) - - delete_certificates_response_deleted_certificate.additional_properties = d - return delete_certificates_response_deleted_certificate - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/delete_instances200_response.py b/unikraft_cloud_platform/models/delete_instances200_response.py new file mode 100644 index 0000000..6f9c901 --- /dev/null +++ b/unikraft_cloud_platform/models/delete_instances200_response.py @@ -0,0 +1,103 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from unikraft_cloud_platform.models.delete_instances200_response_data import DeleteInstances200ResponseData +from typing import Optional, Set +from typing_extensions import Self + + +class DeleteInstances200Response(BaseModel): + """ + DeleteInstances200Response + """ # noqa: E501 + + status: Optional[StrictStr] = Field(default=None, description="The status of the response. ") + data: Optional[DeleteInstances200ResponseData] = None + __properties: ClassVar[List[str]] = ["status", "data"] + + @field_validator("status") + def status_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(["success", "failure"]): + raise ValueError("must be one of enum values ('success', 'failure')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of DeleteInstances200Response from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of data + if self.data: + _dict["data"] = self.data.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of DeleteInstances200Response from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "status": obj.get("status"), + "data": DeleteInstances200ResponseData.from_dict(obj["data"]) if obj.get("data") is not None else None, + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/delete_instances200_response_data.py b/unikraft_cloud_platform/models/delete_instances200_response_data.py new file mode 100644 index 0000000..bf72dd4 --- /dev/null +++ b/unikraft_cloud_platform/models/delete_instances200_response_data.py @@ -0,0 +1,102 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from unikraft_cloud_platform.models.delete_instances200_response_data_instances_inner import ( + DeleteInstances200ResponseDataInstancesInner, +) +from typing import Optional, Set +from typing_extensions import Self + + +class DeleteInstances200ResponseData(BaseModel): + """ + DeleteInstances200ResponseData + """ # noqa: E501 + + instances: Optional[Annotated[List[DeleteInstances200ResponseDataInstancesInner], Field(max_length=253)]] = None + __properties: ClassVar[List[str]] = ["instances"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of DeleteInstances200ResponseData from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in instances (list) + _items = [] + if self.instances: + for _item_instances in self.instances: + if _item_instances: + _items.append(_item_instances.to_dict()) + _dict["instances"] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of DeleteInstances200ResponseData from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "instances": [ + DeleteInstances200ResponseDataInstancesInner.from_dict(_item) for _item in obj["instances"] + ] + if obj.get("instances") is not None + else None + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/delete_instances200_response_data_instances_inner.py b/unikraft_cloud_platform/models/delete_instances200_response_data_instances_inner.py new file mode 100644 index 0000000..6763753 --- /dev/null +++ b/unikraft_cloud_platform/models/delete_instances200_response_data_instances_inner.py @@ -0,0 +1,125 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from uuid import UUID +from typing import Optional, Set +from typing_extensions import Self + + +class DeleteInstances200ResponseDataInstancesInner(BaseModel): + """ + DeleteInstances200ResponseDataInstancesInner + """ # noqa: E501 + + status: Optional[StrictStr] = Field( + default=None, description="The status of the response. Note: Not when listing all existing instances. " + ) + uuid: Optional[UUID] = Field(default=None, description="The UUID of the instance. ") + name: Optional[Annotated[str, Field(strict=True, max_length=255)]] = Field( + default=None, + description="The name of the instance. The instance will receive a DNS entry in your private network of the form `.internal`. Note: If no name is specified a random name of the form `-X` is auto-generated, where `` is the application name taken from `image` (e.g., `myapp` for `../myapp:latest`) and `X` is a 5 character long random alphanumeric suffix. ", + ) + previous_state: Optional[StrictStr] = Field( + default=None, + description="An instance can be in one of the following states: State | Description ----------|------------ `stopped` | The instance is not running and does not count against live resource quotas. Connections cannot be established. `starting`| The instance is booting up. This usually takes just a few milliseconds. `running` | Your application's main entry point has been reached. `draining`| The instance is draining connections before shutting down. No new connections can be established. `stopping`| The instance is shutting down. `standby` | The instance has [scale-to-zero](https://unikraft.cloud/docs/api/v1/autoscale#scaletozero) enabled. The instance is not running, but will be automatically started when there are incoming requests. ", + ) + __properties: ClassVar[List[str]] = ["status", "uuid", "name", "previous_state"] + + @field_validator("status") + def status_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(["success", "error"]): + raise ValueError("must be one of enum values ('success', 'error')") + return value + + @field_validator("previous_state") + def previous_state_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(["stopped", "starting", "running", "draining", "stopping", "standby"]): + raise ValueError( + "must be one of enum values ('stopped', 'starting', 'running', 'draining', 'stopping', 'standby')" + ) + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of DeleteInstances200ResponseDataInstancesInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of DeleteInstances200ResponseDataInstancesInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "status": obj.get("status"), + "uuid": obj.get("uuid"), + "name": obj.get("name"), + "previous_state": obj.get("previous_state"), + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/delete_instances_request_inner.py b/unikraft_cloud_platform/models/delete_instances_request_inner.py new file mode 100644 index 0000000..7677583 --- /dev/null +++ b/unikraft_cloud_platform/models/delete_instances_request_inner.py @@ -0,0 +1,92 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from uuid import UUID +from typing import Optional, Set +from typing_extensions import Self + + +class DeleteInstancesRequestInner(BaseModel): + """ + DeleteInstancesRequestInner + """ # noqa: E501 + + uuid: Optional[UUID] = Field( + default=None, + description="The UUID of the instance to delete. Note: This property is mutually exclusive with `name` and either `uuid` or `name` are required. ", + ) + name: Optional[Annotated[str, Field(strict=True, max_length=255)]] = Field( + default=None, + description="The name of the instance to delete. Note: This property is mutually exclusive with `uuid` and either `uuid` or `name` are required. ", + ) + __properties: ClassVar[List[str]] = ["uuid", "name"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of DeleteInstancesRequestInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of DeleteInstancesRequestInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({"uuid": obj.get("uuid"), "name": obj.get("name")}) + return _obj diff --git a/unikraft_cloud_platform/models/delete_instances_response.py b/unikraft_cloud_platform/models/delete_instances_response.py deleted file mode 100644 index b9184f8..0000000 --- a/unikraft_cloud_platform/models/delete_instances_response.py +++ /dev/null @@ -1,130 +0,0 @@ -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..models.response_status import ResponseStatus, check_response_status -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.delete_instances_response_data import DeleteInstancesResponseData - from ..models.response_error import ResponseError - - -T = TypeVar("T", bound="DeleteInstancesResponse") - - -@_attrs_define -class DeleteInstancesResponse: - """The response message for deleting one or more instance(s) given their UUID(s) - or name(s). - - """ - - status: Union[Unset, ResponseStatus] = UNSET - """ The response status of an API request. """ - message: Union[Unset, str] = UNSET - """ An optional message providing additional information about the status. - This field is useful when the status is not `success`. """ - data: Union[Unset, "DeleteInstancesResponseData"] = UNSET - errors: Union[Unset, list["ResponseError"]] = UNSET - """ A list of errors which may have occurred during the request. """ - op_time_us: Union[Unset, int] = UNSET - """ The operation time in microseconds. This is the time it took to process - the request and generate the response. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - status: Union[Unset, str] = UNSET - if not isinstance(self.status, Unset): - status = self.status - - message = self.message - - data: Union[Unset, dict[str, Any]] = UNSET - if not isinstance(self.data, Unset): - data = self.data.to_dict() - - errors: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.errors, Unset): - errors = [] - for errors_item_data in self.errors: - errors_item = errors_item_data.to_dict() - errors.append(errors_item) - - op_time_us = self.op_time_us - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if status is not UNSET: - field_dict["status"] = status - if message is not UNSET: - field_dict["message"] = message - if data is not UNSET: - field_dict["data"] = data - if errors is not UNSET: - field_dict["errors"] = errors - if op_time_us is not UNSET: - field_dict["op_time_us"] = op_time_us - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.delete_instances_response_data import DeleteInstancesResponseData - from ..models.response_error import ResponseError - - d = dict(src_dict) - _status = d.pop("status", UNSET) - status: Union[Unset, ResponseStatus] - if isinstance(_status, Unset): - status = UNSET - else: - status = check_response_status(_status) - - message = d.pop("message", UNSET) - - _data = d.pop("data", UNSET) - data: Union[Unset, DeleteInstancesResponseData] - if isinstance(_data, Unset): - data = UNSET - else: - data = DeleteInstancesResponseData.from_dict(_data) - - errors = [] - _errors = d.pop("errors", UNSET) - for errors_item_data in _errors or []: - errors_item = ResponseError.from_dict(errors_item_data) - - errors.append(errors_item) - - op_time_us = d.pop("op_time_us", UNSET) - - delete_instances_response = cls( - status=status, - message=message, - data=data, - errors=errors, - op_time_us=op_time_us, - ) - - delete_instances_response.additional_properties = d - return delete_instances_response - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/delete_instances_response_data.py b/unikraft_cloud_platform/models/delete_instances_response_data.py deleted file mode 100644 index d11fcf8..0000000 --- a/unikraft_cloud_platform/models/delete_instances_response_data.py +++ /dev/null @@ -1,71 +0,0 @@ -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.delete_instances_response_deleted_instance import DeleteInstancesResponseDeletedInstance - - -T = TypeVar("T", bound="DeleteInstancesResponseData") - - -@_attrs_define -class DeleteInstancesResponseData: - instances: Union[Unset, list["DeleteInstancesResponseDeletedInstance"]] = UNSET - """ The instance(s) which were deleted by the request. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - instances: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.instances, Unset): - instances = [] - for instances_item_data in self.instances: - instances_item = instances_item_data.to_dict() - instances.append(instances_item) - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if instances is not UNSET: - field_dict["instances"] = instances - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.delete_instances_response_deleted_instance import DeleteInstancesResponseDeletedInstance - - d = dict(src_dict) - instances = [] - _instances = d.pop("instances", UNSET) - for instances_item_data in _instances or []: - instances_item = DeleteInstancesResponseDeletedInstance.from_dict(instances_item_data) - - instances.append(instances_item) - - delete_instances_response_data = cls( - instances=instances, - ) - - delete_instances_response_data.additional_properties = d - return delete_instances_response_data - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/delete_instances_response_deleted_instance.py b/unikraft_cloud_platform/models/delete_instances_response_deleted_instance.py deleted file mode 100644 index 2bb5e55..0000000 --- a/unikraft_cloud_platform/models/delete_instances_response_deleted_instance.py +++ /dev/null @@ -1,120 +0,0 @@ -from collections.abc import Mapping -from typing import Any, TypeVar, Union -from uuid import UUID - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..models.response_status import ResponseStatus, check_response_status -from ..types import UNSET, Unset - -T = TypeVar("T", bound="DeleteInstancesResponseDeletedInstance") - - -@_attrs_define -class DeleteInstancesResponseDeletedInstance: - """Details of the instance which was deleted by this request.""" - - status: Union[Unset, ResponseStatus] = UNSET - """ The response status of an API request. """ - uuid: Union[Unset, UUID] = UNSET - """ The UUID of the instance which was deleted. """ - name: Union[Unset, str] = UNSET - """ The name of the instance which was deleted. """ - previous_state: Union[Unset, str] = UNSET - """ The previous state of the instance before it was deleted. """ - message: Union[Unset, str] = UNSET - """ An optional message providing additional information about the status. - This field is useful when the status is not `success`. """ - error: Union[Unset, int] = UNSET - """ An optional error code providing additional information about the status. - This field is useful when the status is not `success`. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - status: Union[Unset, str] = UNSET - if not isinstance(self.status, Unset): - status = self.status - - uuid: Union[Unset, str] = UNSET - if not isinstance(self.uuid, Unset): - uuid = str(self.uuid) - - name = self.name - - previous_state = self.previous_state - - message = self.message - - error = self.error - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if status is not UNSET: - field_dict["status"] = status - if uuid is not UNSET: - field_dict["uuid"] = uuid - if name is not UNSET: - field_dict["name"] = name - if previous_state is not UNSET: - field_dict["previous_state"] = previous_state - if message is not UNSET: - field_dict["message"] = message - if error is not UNSET: - field_dict["error"] = error - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - d = dict(src_dict) - _status = d.pop("status", UNSET) - status: Union[Unset, ResponseStatus] - if isinstance(_status, Unset): - status = UNSET - else: - status = check_response_status(_status) - - _uuid = d.pop("uuid", UNSET) - uuid: Union[Unset, UUID] - if isinstance(_uuid, Unset): - uuid = UNSET - else: - uuid = UUID(_uuid) - - name = d.pop("name", UNSET) - - previous_state = d.pop("previous_state", UNSET) - - message = d.pop("message", UNSET) - - error = d.pop("error", UNSET) - - delete_instances_response_deleted_instance = cls( - status=status, - uuid=uuid, - name=name, - previous_state=previous_state, - message=message, - error=error, - ) - - delete_instances_response_deleted_instance.additional_properties = d - return delete_instances_response_deleted_instance - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/delete_policy_request.py b/unikraft_cloud_platform/models/delete_policy_request.py deleted file mode 100644 index 9ee4102..0000000 --- a/unikraft_cloud_platform/models/delete_policy_request.py +++ /dev/null @@ -1,57 +0,0 @@ -from collections.abc import Mapping -from typing import Any, TypeVar - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -T = TypeVar("T", bound="DeletePolicyRequest") - - -@_attrs_define -class DeletePolicyRequest: - """The request message to delete an autoscale configuration policy by name.""" - - name: str - """ The Name of the policy to delete. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - name = self.name - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update( - { - "name": name, - } - ) - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - d = dict(src_dict) - name = d.pop("name") - - delete_policy_request = cls( - name=name, - ) - - delete_policy_request.additional_properties = d - return delete_policy_request - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/delete_service_groups_response.py b/unikraft_cloud_platform/models/delete_service_groups_response.py deleted file mode 100644 index 1762d26..0000000 --- a/unikraft_cloud_platform/models/delete_service_groups_response.py +++ /dev/null @@ -1,130 +0,0 @@ -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..models.response_status import ResponseStatus, check_response_status -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.delete_service_groups_response_data import DeleteServiceGroupsResponseData - from ..models.response_error import ResponseError - - -T = TypeVar("T", bound="DeleteServiceGroupsResponse") - - -@_attrs_define -class DeleteServiceGroupsResponse: - """The response message for deleting of one or more service group(s) given their - UUID(s) or name(s). - - """ - - status: Union[Unset, ResponseStatus] = UNSET - """ The response status of an API request. """ - message: Union[Unset, str] = UNSET - """ An optional message providing additional information about the status. - This field is useful when the status is not `success`. """ - data: Union[Unset, "DeleteServiceGroupsResponseData"] = UNSET - errors: Union[Unset, list["ResponseError"]] = UNSET - """ A list of errors which may have occurred during the request. """ - op_time_us: Union[Unset, int] = UNSET - """ The operation time in microseconds. This is the time it took to process - the request and generate the response. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - status: Union[Unset, str] = UNSET - if not isinstance(self.status, Unset): - status = self.status - - message = self.message - - data: Union[Unset, dict[str, Any]] = UNSET - if not isinstance(self.data, Unset): - data = self.data.to_dict() - - errors: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.errors, Unset): - errors = [] - for errors_item_data in self.errors: - errors_item = errors_item_data.to_dict() - errors.append(errors_item) - - op_time_us = self.op_time_us - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if status is not UNSET: - field_dict["status"] = status - if message is not UNSET: - field_dict["message"] = message - if data is not UNSET: - field_dict["data"] = data - if errors is not UNSET: - field_dict["errors"] = errors - if op_time_us is not UNSET: - field_dict["op_time_us"] = op_time_us - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.delete_service_groups_response_data import DeleteServiceGroupsResponseData - from ..models.response_error import ResponseError - - d = dict(src_dict) - _status = d.pop("status", UNSET) - status: Union[Unset, ResponseStatus] - if isinstance(_status, Unset): - status = UNSET - else: - status = check_response_status(_status) - - message = d.pop("message", UNSET) - - _data = d.pop("data", UNSET) - data: Union[Unset, DeleteServiceGroupsResponseData] - if isinstance(_data, Unset): - data = UNSET - else: - data = DeleteServiceGroupsResponseData.from_dict(_data) - - errors = [] - _errors = d.pop("errors", UNSET) - for errors_item_data in _errors or []: - errors_item = ResponseError.from_dict(errors_item_data) - - errors.append(errors_item) - - op_time_us = d.pop("op_time_us", UNSET) - - delete_service_groups_response = cls( - status=status, - message=message, - data=data, - errors=errors, - op_time_us=op_time_us, - ) - - delete_service_groups_response.additional_properties = d - return delete_service_groups_response - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/delete_service_groups_response_data.py b/unikraft_cloud_platform/models/delete_service_groups_response_data.py deleted file mode 100644 index aba07d8..0000000 --- a/unikraft_cloud_platform/models/delete_service_groups_response_data.py +++ /dev/null @@ -1,75 +0,0 @@ -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.delete_service_groups_response_deleted_service_group import ( - DeleteServiceGroupsResponseDeletedServiceGroup, - ) - - -T = TypeVar("T", bound="DeleteServiceGroupsResponseData") - - -@_attrs_define -class DeleteServiceGroupsResponseData: - service_groups: Union[Unset, list["DeleteServiceGroupsResponseDeletedServiceGroup"]] = UNSET - """ The service group(s) which were deleted by the request. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - service_groups: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.service_groups, Unset): - service_groups = [] - for service_groups_item_data in self.service_groups: - service_groups_item = service_groups_item_data.to_dict() - service_groups.append(service_groups_item) - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if service_groups is not UNSET: - field_dict["service_groups"] = service_groups - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.delete_service_groups_response_deleted_service_group import ( - DeleteServiceGroupsResponseDeletedServiceGroup, - ) - - d = dict(src_dict) - service_groups = [] - _service_groups = d.pop("service_groups", UNSET) - for service_groups_item_data in _service_groups or []: - service_groups_item = DeleteServiceGroupsResponseDeletedServiceGroup.from_dict(service_groups_item_data) - - service_groups.append(service_groups_item) - - delete_service_groups_response_data = cls( - service_groups=service_groups, - ) - - delete_service_groups_response_data.additional_properties = d - return delete_service_groups_response_data - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/delete_service_groups_response_deleted_service_group.py b/unikraft_cloud_platform/models/delete_service_groups_response_deleted_service_group.py deleted file mode 100644 index a1f342c..0000000 --- a/unikraft_cloud_platform/models/delete_service_groups_response_deleted_service_group.py +++ /dev/null @@ -1,113 +0,0 @@ -from collections.abc import Mapping -from typing import Any, TypeVar, Union -from uuid import UUID - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..models.response_status import ResponseStatus, check_response_status -from ..types import UNSET, Unset - -T = TypeVar("T", bound="DeleteServiceGroupsResponseDeletedServiceGroup") - - -@_attrs_define -class DeleteServiceGroupsResponseDeletedServiceGroup: - """Details of the service group which was deleted by this request.""" - - status: Union[Unset, ResponseStatus] = UNSET - """ The response status of an API request. """ - uuid: Union[Unset, UUID] = UNSET - """ The UUID of the service group which was deleted. """ - name: Union[Unset, str] = UNSET - """ The name of the service group which was deleted. """ - message: Union[Unset, str] = UNSET - """ An optional message providing additional information about the status. - This field is only set when this message object is used as a response - message, and is useful when the status is not `success`. """ - error: Union[Unset, int] = UNSET - """ An optional error code providing additional information about the status. - This field is only set when this message object is used as a response - message, and is useful when the status is not `success`. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - status: Union[Unset, str] = UNSET - if not isinstance(self.status, Unset): - status = self.status - - uuid: Union[Unset, str] = UNSET - if not isinstance(self.uuid, Unset): - uuid = str(self.uuid) - - name = self.name - - message = self.message - - error = self.error - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if status is not UNSET: - field_dict["status"] = status - if uuid is not UNSET: - field_dict["uuid"] = uuid - if name is not UNSET: - field_dict["name"] = name - if message is not UNSET: - field_dict["message"] = message - if error is not UNSET: - field_dict["error"] = error - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - d = dict(src_dict) - _status = d.pop("status", UNSET) - status: Union[Unset, ResponseStatus] - if isinstance(_status, Unset): - status = UNSET - else: - status = check_response_status(_status) - - _uuid = d.pop("uuid", UNSET) - uuid: Union[Unset, UUID] - if isinstance(_uuid, Unset): - uuid = UNSET - else: - uuid = UUID(_uuid) - - name = d.pop("name", UNSET) - - message = d.pop("message", UNSET) - - error = d.pop("error", UNSET) - - delete_service_groups_response_deleted_service_group = cls( - status=status, - uuid=uuid, - name=name, - message=message, - error=error, - ) - - delete_service_groups_response_deleted_service_group.additional_properties = d - return delete_service_groups_response_deleted_service_group - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/delete_services200_response.py b/unikraft_cloud_platform/models/delete_services200_response.py new file mode 100644 index 0000000..9d29801 --- /dev/null +++ b/unikraft_cloud_platform/models/delete_services200_response.py @@ -0,0 +1,103 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from unikraft_cloud_platform.models.delete_services200_response_data import DeleteServices200ResponseData +from typing import Optional, Set +from typing_extensions import Self + + +class DeleteServices200Response(BaseModel): + """ + DeleteServices200Response + """ # noqa: E501 + + status: Optional[StrictStr] = None + data: Optional[DeleteServices200ResponseData] = None + __properties: ClassVar[List[str]] = ["status", "data"] + + @field_validator("status") + def status_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(["success", "failure"]): + raise ValueError("must be one of enum values ('success', 'failure')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of DeleteServices200Response from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of data + if self.data: + _dict["data"] = self.data.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of DeleteServices200Response from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "status": obj.get("status"), + "data": DeleteServices200ResponseData.from_dict(obj["data"]) if obj.get("data") is not None else None, + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/delete_services200_response_data.py b/unikraft_cloud_platform/models/delete_services200_response_data.py new file mode 100644 index 0000000..1b414d3 --- /dev/null +++ b/unikraft_cloud_platform/models/delete_services200_response_data.py @@ -0,0 +1,104 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from unikraft_cloud_platform.models.delete_services200_response_data_service_groups_inner import ( + DeleteServices200ResponseDataServiceGroupsInner, +) +from typing import Optional, Set +from typing_extensions import Self + + +class DeleteServices200ResponseData(BaseModel): + """ + DeleteServices200ResponseData + """ # noqa: E501 + + service_groups: Optional[ + Annotated[List[DeleteServices200ResponseDataServiceGroupsInner], Field(max_length=253)] + ] = None + __properties: ClassVar[List[str]] = ["service_groups"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of DeleteServices200ResponseData from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in service_groups (list) + _items = [] + if self.service_groups: + for _item_service_groups in self.service_groups: + if _item_service_groups: + _items.append(_item_service_groups.to_dict()) + _dict["service_groups"] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of DeleteServices200ResponseData from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "service_groups": [ + DeleteServices200ResponseDataServiceGroupsInner.from_dict(_item) for _item in obj["service_groups"] + ] + if obj.get("service_groups") is not None + else None + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/delete_services200_response_data_service_groups_inner.py b/unikraft_cloud_platform/models/delete_services200_response_data_service_groups_inner.py new file mode 100644 index 0000000..d003645 --- /dev/null +++ b/unikraft_cloud_platform/models/delete_services200_response_data_service_groups_inner.py @@ -0,0 +1,99 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from uuid import UUID +from typing import Optional, Set +from typing_extensions import Self + + +class DeleteServices200ResponseDataServiceGroupsInner(BaseModel): + """ + DeleteServices200ResponseDataServiceGroupsInner + """ # noqa: E501 + + status: Optional[StrictStr] = Field(default=None, description="The status of the response. ") + uuid: Optional[UUID] = Field(default=None, description="The UUID of the service. ") + name: Optional[Annotated[str, Field(strict=True, max_length=255)]] = Field( + default=None, description="The name of the service. " + ) + __properties: ClassVar[List[str]] = ["status", "uuid", "name"] + + @field_validator("status") + def status_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(["success", "error"]): + raise ValueError("must be one of enum values ('success', 'error')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of DeleteServices200ResponseDataServiceGroupsInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of DeleteServices200ResponseDataServiceGroupsInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({"status": obj.get("status"), "uuid": obj.get("uuid"), "name": obj.get("name")}) + return _obj diff --git a/unikraft_cloud_platform/models/delete_services_request_inner.py b/unikraft_cloud_platform/models/delete_services_request_inner.py new file mode 100644 index 0000000..c26f58c --- /dev/null +++ b/unikraft_cloud_platform/models/delete_services_request_inner.py @@ -0,0 +1,92 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from uuid import UUID +from typing import Optional, Set +from typing_extensions import Self + + +class DeleteServicesRequestInner(BaseModel): + """ + DeleteServicesRequestInner + """ # noqa: E501 + + uuid: Optional[UUID] = Field( + default=None, + description="The UUID of the service to delete. Note: This property is mutually exclusive with `name` and either `uuid` or `name` are required. ", + ) + name: Optional[Annotated[str, Field(strict=True, max_length=255)]] = Field( + default=None, + description="The name of the service to delete. Note: This property is mutually exclusive with `uuid` and either `uuid` or `name` are required. ", + ) + __properties: ClassVar[List[str]] = ["uuid", "name"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of DeleteServicesRequestInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of DeleteServicesRequestInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({"uuid": obj.get("uuid"), "name": obj.get("name")}) + return _obj diff --git a/unikraft_cloud_platform/models/delete_volumes200_response.py b/unikraft_cloud_platform/models/delete_volumes200_response.py new file mode 100644 index 0000000..6ca78d5 --- /dev/null +++ b/unikraft_cloud_platform/models/delete_volumes200_response.py @@ -0,0 +1,93 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from typing import Optional, Set +from typing_extensions import Self + + +class DeleteVolumes200Response(BaseModel): + """ + DeleteVolumes200Response + """ # noqa: E501 + + status: Optional[StrictStr] = None + __properties: ClassVar[List[str]] = ["status"] + + @field_validator("status") + def status_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(["success", "failure"]): + raise ValueError("must be one of enum values ('success', 'failure')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of DeleteVolumes200Response from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of DeleteVolumes200Response from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({"status": obj.get("status")}) + return _obj diff --git a/unikraft_cloud_platform/models/delete_volumes_request_inner.py b/unikraft_cloud_platform/models/delete_volumes_request_inner.py new file mode 100644 index 0000000..66ec7b4 --- /dev/null +++ b/unikraft_cloud_platform/models/delete_volumes_request_inner.py @@ -0,0 +1,92 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from uuid import UUID +from typing import Optional, Set +from typing_extensions import Self + + +class DeleteVolumesRequestInner(BaseModel): + """ + DeleteVolumesRequestInner + """ # noqa: E501 + + uuid: Optional[UUID] = Field( + default=None, + description="The UUID of the volume to delete. Note: This property is mutually exclusive with `name` and either `uuid` or `name` are required. ", + ) + name: Optional[Annotated[str, Field(strict=True, max_length=255)]] = Field( + default=None, + description="The name of the volume to delete. Note: This property is mutually exclusive with `uuid` and either `uuid` or `name` are required. ", + ) + __properties: ClassVar[List[str]] = ["uuid", "name"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of DeleteVolumesRequestInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of DeleteVolumesRequestInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({"uuid": obj.get("uuid"), "name": obj.get("name")}) + return _obj diff --git a/unikraft_cloud_platform/models/delete_volumes_response.py b/unikraft_cloud_platform/models/delete_volumes_response.py deleted file mode 100644 index 3a59feb..0000000 --- a/unikraft_cloud_platform/models/delete_volumes_response.py +++ /dev/null @@ -1,115 +0,0 @@ -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..models.response_status import ResponseStatus, check_response_status -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.delete_volumes_response_data import DeleteVolumesResponseData - from ..models.response_error import ResponseError - - -T = TypeVar("T", bound="DeleteVolumesResponse") - - -@_attrs_define -class DeleteVolumesResponse: - status: Union[Unset, ResponseStatus] = UNSET - """ The response status of an API request. """ - data: Union[Unset, "DeleteVolumesResponseData"] = UNSET - errors: Union[Unset, list["ResponseError"]] = UNSET - """ A list of errors which may have occurred during the request. """ - op_time_us: Union[Unset, int] = UNSET - """ The operation time in microseconds. This is the time it took to process - the request and generate the response. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - status: Union[Unset, str] = UNSET - if not isinstance(self.status, Unset): - status = self.status - - data: Union[Unset, dict[str, Any]] = UNSET - if not isinstance(self.data, Unset): - data = self.data.to_dict() - - errors: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.errors, Unset): - errors = [] - for errors_item_data in self.errors: - errors_item = errors_item_data.to_dict() - errors.append(errors_item) - - op_time_us = self.op_time_us - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if status is not UNSET: - field_dict["status"] = status - if data is not UNSET: - field_dict["data"] = data - if errors is not UNSET: - field_dict["errors"] = errors - if op_time_us is not UNSET: - field_dict["op_time_us"] = op_time_us - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.delete_volumes_response_data import DeleteVolumesResponseData - from ..models.response_error import ResponseError - - d = dict(src_dict) - _status = d.pop("status", UNSET) - status: Union[Unset, ResponseStatus] - if isinstance(_status, Unset): - status = UNSET - else: - status = check_response_status(_status) - - _data = d.pop("data", UNSET) - data: Union[Unset, DeleteVolumesResponseData] - if isinstance(_data, Unset): - data = UNSET - else: - data = DeleteVolumesResponseData.from_dict(_data) - - errors = [] - _errors = d.pop("errors", UNSET) - for errors_item_data in _errors or []: - errors_item = ResponseError.from_dict(errors_item_data) - - errors.append(errors_item) - - op_time_us = d.pop("op_time_us", UNSET) - - delete_volumes_response = cls( - status=status, - data=data, - errors=errors, - op_time_us=op_time_us, - ) - - delete_volumes_response.additional_properties = d - return delete_volumes_response - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/delete_volumes_response_data.py b/unikraft_cloud_platform/models/delete_volumes_response_data.py deleted file mode 100644 index 81caeb1..0000000 --- a/unikraft_cloud_platform/models/delete_volumes_response_data.py +++ /dev/null @@ -1,71 +0,0 @@ -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.delete_volumes_response_deleted_volume import DeleteVolumesResponseDeletedVolume - - -T = TypeVar("T", bound="DeleteVolumesResponseData") - - -@_attrs_define -class DeleteVolumesResponseData: - volumes: Union[Unset, list["DeleteVolumesResponseDeletedVolume"]] = UNSET - """ The volume(s) which were deleted by the request. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - volumes: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.volumes, Unset): - volumes = [] - for volumes_item_data in self.volumes: - volumes_item = volumes_item_data.to_dict() - volumes.append(volumes_item) - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if volumes is not UNSET: - field_dict["volumes"] = volumes - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.delete_volumes_response_deleted_volume import DeleteVolumesResponseDeletedVolume - - d = dict(src_dict) - volumes = [] - _volumes = d.pop("volumes", UNSET) - for volumes_item_data in _volumes or []: - volumes_item = DeleteVolumesResponseDeletedVolume.from_dict(volumes_item_data) - - volumes.append(volumes_item) - - delete_volumes_response_data = cls( - volumes=volumes, - ) - - delete_volumes_response_data.additional_properties = d - return delete_volumes_response_data - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/delete_volumes_response_deleted_volume.py b/unikraft_cloud_platform/models/delete_volumes_response_deleted_volume.py deleted file mode 100644 index 6abdaad..0000000 --- a/unikraft_cloud_platform/models/delete_volumes_response_deleted_volume.py +++ /dev/null @@ -1,109 +0,0 @@ -from collections.abc import Mapping -from typing import Any, TypeVar, Union -from uuid import UUID - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..models.response_status import ResponseStatus, check_response_status -from ..types import UNSET, Unset - -T = TypeVar("T", bound="DeleteVolumesResponseDeletedVolume") - - -@_attrs_define -class DeleteVolumesResponseDeletedVolume: - status: Union[Unset, ResponseStatus] = UNSET - """ The response status of an API request. """ - uuid: Union[Unset, UUID] = UNSET - """ The UUID of the volume that was deleted. """ - name: Union[Unset, str] = UNSET - """ The name of the volume that was deleted. """ - message: Union[Unset, str] = UNSET - """ An optional message providing additional information about the status. - This field is useful when the status is not `success`. """ - error: Union[Unset, int] = UNSET - """ An optional error code providing additional information about the status. - This field is useful when the status is not `success`. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - status: Union[Unset, str] = UNSET - if not isinstance(self.status, Unset): - status = self.status - - uuid: Union[Unset, str] = UNSET - if not isinstance(self.uuid, Unset): - uuid = str(self.uuid) - - name = self.name - - message = self.message - - error = self.error - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if status is not UNSET: - field_dict["status"] = status - if uuid is not UNSET: - field_dict["uuid"] = uuid - if name is not UNSET: - field_dict["name"] = name - if message is not UNSET: - field_dict["message"] = message - if error is not UNSET: - field_dict["error"] = error - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - d = dict(src_dict) - _status = d.pop("status", UNSET) - status: Union[Unset, ResponseStatus] - if isinstance(_status, Unset): - status = UNSET - else: - status = check_response_status(_status) - - _uuid = d.pop("uuid", UNSET) - uuid: Union[Unset, UUID] - if isinstance(_uuid, Unset): - uuid = UNSET - else: - uuid = UUID(_uuid) - - name = d.pop("name", UNSET) - - message = d.pop("message", UNSET) - - error = d.pop("error", UNSET) - - delete_volumes_response_deleted_volume = cls( - status=status, - uuid=uuid, - name=name, - message=message, - error=error, - ) - - delete_volumes_response_deleted_volume.additional_properties = d - return delete_volumes_response_deleted_volume - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/detach_volume_by_uuid_request_body.py b/unikraft_cloud_platform/models/detach_volume_by_uuid_request_body.py deleted file mode 100644 index 66e7711..0000000 --- a/unikraft_cloud_platform/models/detach_volume_by_uuid_request_body.py +++ /dev/null @@ -1,68 +0,0 @@ -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.body_instance_id import BodyInstanceID - - -T = TypeVar("T", bound="DetachVolumeByUUIDRequestBody") - - -@_attrs_define -class DetachVolumeByUUIDRequestBody: - from_: Union[Unset, "BodyInstanceID"] = UNSET - """ Reference to the instance to detach the volume from. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - from_: Union[Unset, dict[str, Any]] = UNSET - if not isinstance(self.from_, Unset): - from_ = self.from_.to_dict() - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if from_ is not UNSET: - field_dict["from"] = from_ - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.body_instance_id import BodyInstanceID - - d = dict(src_dict) - _from_ = d.pop("from", UNSET) - from_: Union[Unset, BodyInstanceID] - if isinstance(_from_, Unset): - from_ = UNSET - else: - from_ = BodyInstanceID.from_dict(_from_) - - detach_volume_by_uuid_request_body = cls( - from_=from_, - ) - - detach_volume_by_uuid_request_body.additional_properties = d - return detach_volume_by_uuid_request_body - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/detach_volumes_request.py b/unikraft_cloud_platform/models/detach_volumes_request.py deleted file mode 100644 index 42739e3..0000000 --- a/unikraft_cloud_platform/models/detach_volumes_request.py +++ /dev/null @@ -1,101 +0,0 @@ -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union -from uuid import UUID - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.detach_volumes_request_instance_id import DetachVolumesRequestInstanceID - - -T = TypeVar("T", bound="DetachVolumesRequest") - - -@_attrs_define -class DetachVolumesRequest: - """The request message for detaching one or more volume(s) from instances by - their UUID(s) or name(s). - - """ - - uuid: Union[Unset, UUID] = UNSET - """ The UUID of the volume to detach. Mutually exclusive with name. - Exactly one of uuid or name must be provided. """ - name: Union[Unset, str] = UNSET - """ The name of the volume to detach. Mutually exclusive with UUID. - Exactly one of uuid or name must be provided. """ - from_: Union[Unset, "DetachVolumesRequestInstanceID"] = UNSET - """ Reference to the instance to detach the volume from. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - uuid: Union[Unset, str] = UNSET - if not isinstance(self.uuid, Unset): - uuid = str(self.uuid) - - name = self.name - - from_: Union[Unset, dict[str, Any]] = UNSET - if not isinstance(self.from_, Unset): - from_ = self.from_.to_dict() - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if uuid is not UNSET: - field_dict["uuid"] = uuid - if name is not UNSET: - field_dict["name"] = name - if from_ is not UNSET: - field_dict["from"] = from_ - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.detach_volumes_request_instance_id import DetachVolumesRequestInstanceID - - d = dict(src_dict) - _uuid = d.pop("uuid", UNSET) - uuid: Union[Unset, UUID] - if isinstance(_uuid, Unset): - uuid = UNSET - else: - uuid = UUID(_uuid) - - name = d.pop("name", UNSET) - - _from_ = d.pop("from", UNSET) - from_: Union[Unset, DetachVolumesRequestInstanceID] - if isinstance(_from_, Unset): - from_ = UNSET - else: - from_ = DetachVolumesRequestInstanceID.from_dict(_from_) - - detach_volumes_request = cls( - uuid=uuid, - name=name, - from_=from_, - ) - - detach_volumes_request.additional_properties = d - return detach_volumes_request - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/detach_volumes_request_instance_id.py b/unikraft_cloud_platform/models/detach_volumes_request_instance_id.py deleted file mode 100644 index 67442ee..0000000 --- a/unikraft_cloud_platform/models/detach_volumes_request_instance_id.py +++ /dev/null @@ -1,65 +0,0 @@ -from collections.abc import Mapping -from typing import Any, TypeVar, Union -from uuid import UUID - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -T = TypeVar("T", bound="DetachVolumesRequestInstanceID") - - -@_attrs_define -class DetachVolumesRequestInstanceID: - """Reference to the instance to detach the volume from.""" - - uuid: Union[Unset, UUID] = UNSET - """ The UUID of the instance that the volume is detached from. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - uuid: Union[Unset, str] = UNSET - if not isinstance(self.uuid, Unset): - uuid = str(self.uuid) - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if uuid is not UNSET: - field_dict["uuid"] = uuid - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - d = dict(src_dict) - _uuid = d.pop("uuid", UNSET) - uuid: Union[Unset, UUID] - if isinstance(_uuid, Unset): - uuid = UNSET - else: - uuid = UUID(_uuid) - - detach_volumes_request_instance_id = cls( - uuid=uuid, - ) - - detach_volumes_request_instance_id.additional_properties = d - return detach_volumes_request_instance_id - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/detach_volumes_response.py b/unikraft_cloud_platform/models/detach_volumes_response.py deleted file mode 100644 index e18da89..0000000 --- a/unikraft_cloud_platform/models/detach_volumes_response.py +++ /dev/null @@ -1,115 +0,0 @@ -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..models.response_status import ResponseStatus, check_response_status -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.detach_volumes_response_data import DetachVolumesResponseData - from ..models.response_error import ResponseError - - -T = TypeVar("T", bound="DetachVolumesResponse") - - -@_attrs_define -class DetachVolumesResponse: - status: Union[Unset, ResponseStatus] = UNSET - """ The response status of an API request. """ - data: Union[Unset, "DetachVolumesResponseData"] = UNSET - errors: Union[Unset, list["ResponseError"]] = UNSET - """ A list of errors which may have occurred during the request. """ - op_time_us: Union[Unset, int] = UNSET - """ The operation time in microseconds. This is the time it took to process - the request and generate the response. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - status: Union[Unset, str] = UNSET - if not isinstance(self.status, Unset): - status = self.status - - data: Union[Unset, dict[str, Any]] = UNSET - if not isinstance(self.data, Unset): - data = self.data.to_dict() - - errors: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.errors, Unset): - errors = [] - for errors_item_data in self.errors: - errors_item = errors_item_data.to_dict() - errors.append(errors_item) - - op_time_us = self.op_time_us - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if status is not UNSET: - field_dict["status"] = status - if data is not UNSET: - field_dict["data"] = data - if errors is not UNSET: - field_dict["errors"] = errors - if op_time_us is not UNSET: - field_dict["op_time_us"] = op_time_us - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.detach_volumes_response_data import DetachVolumesResponseData - from ..models.response_error import ResponseError - - d = dict(src_dict) - _status = d.pop("status", UNSET) - status: Union[Unset, ResponseStatus] - if isinstance(_status, Unset): - status = UNSET - else: - status = check_response_status(_status) - - _data = d.pop("data", UNSET) - data: Union[Unset, DetachVolumesResponseData] - if isinstance(_data, Unset): - data = UNSET - else: - data = DetachVolumesResponseData.from_dict(_data) - - errors = [] - _errors = d.pop("errors", UNSET) - for errors_item_data in _errors or []: - errors_item = ResponseError.from_dict(errors_item_data) - - errors.append(errors_item) - - op_time_us = d.pop("op_time_us", UNSET) - - detach_volumes_response = cls( - status=status, - data=data, - errors=errors, - op_time_us=op_time_us, - ) - - detach_volumes_response.additional_properties = d - return detach_volumes_response - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/detach_volumes_response_data.py b/unikraft_cloud_platform/models/detach_volumes_response_data.py deleted file mode 100644 index ab0634b..0000000 --- a/unikraft_cloud_platform/models/detach_volumes_response_data.py +++ /dev/null @@ -1,71 +0,0 @@ -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.detach_volumes_response_detached_volume import DetachVolumesResponseDetachedVolume - - -T = TypeVar("T", bound="DetachVolumesResponseData") - - -@_attrs_define -class DetachVolumesResponseData: - volumes: Union[Unset, list["DetachVolumesResponseDetachedVolume"]] = UNSET - """ The volume(s) which were detached by the request. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - volumes: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.volumes, Unset): - volumes = [] - for volumes_item_data in self.volumes: - volumes_item = volumes_item_data.to_dict() - volumes.append(volumes_item) - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if volumes is not UNSET: - field_dict["volumes"] = volumes - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.detach_volumes_response_detached_volume import DetachVolumesResponseDetachedVolume - - d = dict(src_dict) - volumes = [] - _volumes = d.pop("volumes", UNSET) - for volumes_item_data in _volumes or []: - volumes_item = DetachVolumesResponseDetachedVolume.from_dict(volumes_item_data) - - volumes.append(volumes_item) - - detach_volumes_response_data = cls( - volumes=volumes, - ) - - detach_volumes_response_data.additional_properties = d - return detach_volumes_response_data - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/detach_volumes_response_detached_volume.py b/unikraft_cloud_platform/models/detach_volumes_response_detached_volume.py deleted file mode 100644 index 7efdaa9..0000000 --- a/unikraft_cloud_platform/models/detach_volumes_response_detached_volume.py +++ /dev/null @@ -1,109 +0,0 @@ -from collections.abc import Mapping -from typing import Any, TypeVar, Union -from uuid import UUID - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..models.response_status import ResponseStatus, check_response_status -from ..types import UNSET, Unset - -T = TypeVar("T", bound="DetachVolumesResponseDetachedVolume") - - -@_attrs_define -class DetachVolumesResponseDetachedVolume: - status: Union[Unset, ResponseStatus] = UNSET - """ The response status of an API request. """ - uuid: Union[Unset, UUID] = UNSET - """ The UUID of the volume that was detached. """ - name: Union[Unset, str] = UNSET - """ The name of the volume that was detached. """ - message: Union[Unset, str] = UNSET - """ An optional message providing additional information about the status. - This field is useful when the status is not `success`. """ - error: Union[Unset, int] = UNSET - """ An optional error code providing additional information about the status. - This field is useful when the status is not `success`. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - status: Union[Unset, str] = UNSET - if not isinstance(self.status, Unset): - status = self.status - - uuid: Union[Unset, str] = UNSET - if not isinstance(self.uuid, Unset): - uuid = str(self.uuid) - - name = self.name - - message = self.message - - error = self.error - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if status is not UNSET: - field_dict["status"] = status - if uuid is not UNSET: - field_dict["uuid"] = uuid - if name is not UNSET: - field_dict["name"] = name - if message is not UNSET: - field_dict["message"] = message - if error is not UNSET: - field_dict["error"] = error - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - d = dict(src_dict) - _status = d.pop("status", UNSET) - status: Union[Unset, ResponseStatus] - if isinstance(_status, Unset): - status = UNSET - else: - status = check_response_status(_status) - - _uuid = d.pop("uuid", UNSET) - uuid: Union[Unset, UUID] - if isinstance(_uuid, Unset): - uuid = UNSET - else: - uuid = UUID(_uuid) - - name = d.pop("name", UNSET) - - message = d.pop("message", UNSET) - - error = d.pop("error", UNSET) - - detach_volumes_response_detached_volume = cls( - status=status, - uuid=uuid, - name=name, - message=message, - error=error, - ) - - detach_volumes_response_detached_volume.additional_properties = d - return detach_volumes_response_detached_volume - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/domain.py b/unikraft_cloud_platform/models/domain.py deleted file mode 100644 index f078994..0000000 --- a/unikraft_cloud_platform/models/domain.py +++ /dev/null @@ -1,68 +0,0 @@ -from collections.abc import Mapping -from typing import Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -T = TypeVar("T", bound="Domain") - - -@_attrs_define -class Domain: - """A domain name. - - Domain names are completely specified with all labels in the hierarchy of the - DNS, having no parts omitted. The domain can be associated with an existing - certificate by specifying the certificate's name or UUID. If no certificate - is specified and a FQDN is provided, Unikraft Cloud will automatically - generate a new certificate for the domain based on Let's Encrypt and seek to - accomplish a DNS-01 challenge. - - """ - - fqdn: Union[Unset, str] = UNSET - """ Publicly accessible domain name. If this name ends in a period `.` it must - be a valid Full Qualified Domain Name (FQDN), otherwise it will become a - subdomain of the target metro. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - fqdn = self.fqdn - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if fqdn is not UNSET: - field_dict["fqdn"] = fqdn - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - d = dict(src_dict) - fqdn = d.pop("fqdn", UNSET) - - domain = cls( - fqdn=fqdn, - ) - - domain.additional_properties = d - return domain - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/get_autosacle_policies200_response.py b/unikraft_cloud_platform/models/get_autosacle_policies200_response.py new file mode 100644 index 0000000..fb65d6d --- /dev/null +++ b/unikraft_cloud_platform/models/get_autosacle_policies200_response.py @@ -0,0 +1,105 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from unikraft_cloud_platform.models.get_autosacle_policies200_response_data import GetAutosaclePolicies200ResponseData +from typing import Optional, Set +from typing_extensions import Self + + +class GetAutosaclePolicies200Response(BaseModel): + """ + GetAutosaclePolicies200Response + """ # noqa: E501 + + status: Optional[StrictStr] = Field(default=None, description="The status of the response. ") + data: Optional[GetAutosaclePolicies200ResponseData] = None + __properties: ClassVar[List[str]] = ["status", "data"] + + @field_validator("status") + def status_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(["success", "failure"]): + raise ValueError("must be one of enum values ('success', 'failure')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of GetAutosaclePolicies200Response from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of data + if self.data: + _dict["data"] = self.data.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of GetAutosaclePolicies200Response from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "status": obj.get("status"), + "data": GetAutosaclePolicies200ResponseData.from_dict(obj["data"]) + if obj.get("data") is not None + else None, + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/get_autosacle_policies200_response_data.py b/unikraft_cloud_platform/models/get_autosacle_policies200_response_data.py new file mode 100644 index 0000000..b029b73 --- /dev/null +++ b/unikraft_cloud_platform/models/get_autosacle_policies200_response_data.py @@ -0,0 +1,98 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from unikraft_cloud_platform.models.autoscale_policy import AutoscalePolicy +from typing import Optional, Set +from typing_extensions import Self + + +class GetAutosaclePolicies200ResponseData(BaseModel): + """ + GetAutosaclePolicies200ResponseData + """ # noqa: E501 + + policies: Optional[Annotated[List[AutoscalePolicy], Field(max_length=253)]] = None + __properties: ClassVar[List[str]] = ["policies"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of GetAutosaclePolicies200ResponseData from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in policies (list) + _items = [] + if self.policies: + for _item_policies in self.policies: + if _item_policies: + _items.append(_item_policies.to_dict()) + _dict["policies"] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of GetAutosaclePolicies200ResponseData from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "policies": [AutoscalePolicy.from_dict(_item) for _item in obj["policies"]] + if obj.get("policies") is not None + else None + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/get_autosacle_policies_request_inner.py b/unikraft_cloud_platform/models/get_autosacle_policies_request_inner.py new file mode 100644 index 0000000..8601710 --- /dev/null +++ b/unikraft_cloud_platform/models/get_autosacle_policies_request_inner.py @@ -0,0 +1,92 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from uuid import UUID +from typing import Optional, Set +from typing_extensions import Self + + +class GetAutosaclePoliciesRequestInner(BaseModel): + """ + GetAutosaclePoliciesRequestInner + """ # noqa: E501 + + uuid: Optional[UUID] = Field( + default=None, + description="The UUID of the autoscale policy to delete. Note: This property is mutually exclusive with `name` and either `uuid` or `name` are required. ", + ) + name: Optional[Annotated[str, Field(strict=True, max_length=255)]] = Field( + default=None, + description="The name of the autoscale policy to delete. Note: This property is mutually exclusive with `uuid` and either `uuid` or `name` are required. ", + ) + __properties: ClassVar[List[str]] = ["uuid", "name"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of GetAutosaclePoliciesRequestInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of GetAutosaclePoliciesRequestInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({"uuid": obj.get("uuid"), "name": obj.get("name")}) + return _obj diff --git a/unikraft_cloud_platform/models/get_autoscale_configs200_response.py b/unikraft_cloud_platform/models/get_autoscale_configs200_response.py new file mode 100644 index 0000000..ae46ce5 --- /dev/null +++ b/unikraft_cloud_platform/models/get_autoscale_configs200_response.py @@ -0,0 +1,107 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from unikraft_cloud_platform.models.get_autoscale_configs200_response_data import GetAutoscaleConfigs200ResponseData +from typing import Optional, Set +from typing_extensions import Self + + +class GetAutoscaleConfigs200Response(BaseModel): + """ + GetAutoscaleConfigs200Response + """ # noqa: E501 + + status: Optional[StrictStr] = Field( + default=None, description="`success` on success, `failure` if the request failed. " + ) + data: Optional[GetAutoscaleConfigs200ResponseData] = None + __properties: ClassVar[List[str]] = ["status", "data"] + + @field_validator("status") + def status_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(["success", "failure"]): + raise ValueError("must be one of enum values ('success', 'failure')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of GetAutoscaleConfigs200Response from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of data + if self.data: + _dict["data"] = self.data.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of GetAutoscaleConfigs200Response from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "status": obj.get("status"), + "data": GetAutoscaleConfigs200ResponseData.from_dict(obj["data"]) + if obj.get("data") is not None + else None, + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/get_autoscale_configs200_response_data.py b/unikraft_cloud_platform/models/get_autoscale_configs200_response_data.py new file mode 100644 index 0000000..a6f7c01 --- /dev/null +++ b/unikraft_cloud_platform/models/get_autoscale_configs200_response_data.py @@ -0,0 +1,98 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from unikraft_cloud_platform.models.autoscale_config import AutoscaleConfig +from typing import Optional, Set +from typing_extensions import Self + + +class GetAutoscaleConfigs200ResponseData(BaseModel): + """ + GetAutoscaleConfigs200ResponseData + """ # noqa: E501 + + service_groups: Optional[Annotated[List[AutoscaleConfig], Field(max_length=253)]] = None + __properties: ClassVar[List[str]] = ["service_groups"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of GetAutoscaleConfigs200ResponseData from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in service_groups (list) + _items = [] + if self.service_groups: + for _item_service_groups in self.service_groups: + if _item_service_groups: + _items.append(_item_service_groups.to_dict()) + _dict["service_groups"] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of GetAutoscaleConfigs200ResponseData from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "service_groups": [AutoscaleConfig.from_dict(_item) for _item in obj["service_groups"]] + if obj.get("service_groups") is not None + else None + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/get_autoscale_configs_request_inner.py b/unikraft_cloud_platform/models/get_autoscale_configs_request_inner.py new file mode 100644 index 0000000..be0ca94 --- /dev/null +++ b/unikraft_cloud_platform/models/get_autoscale_configs_request_inner.py @@ -0,0 +1,92 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from uuid import UUID +from typing import Optional, Set +from typing_extensions import Self + + +class GetAutoscaleConfigsRequestInner(BaseModel): + """ + GetAutoscaleConfigsRequestInner + """ # noqa: E501 + + uuid: Optional[UUID] = Field( + default=None, + description="The UUID of the service. Note: This property is mutually exclusive with `name` and either `uuid` or `name` are required. ", + ) + name: Optional[Annotated[str, Field(strict=True, max_length=255)]] = Field( + default=None, + description="The name of the service. Note: This property is mutually exclusive with `uuid` and either `uuid` or `name` are required. ", + ) + __properties: ClassVar[List[str]] = ["uuid", "name"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of GetAutoscaleConfigsRequestInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of GetAutoscaleConfigsRequestInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({"uuid": obj.get("uuid"), "name": obj.get("name")}) + return _obj diff --git a/unikraft_cloud_platform/models/get_autoscale_configuration_policy_request.py b/unikraft_cloud_platform/models/get_autoscale_configuration_policy_request.py deleted file mode 100644 index c99c14f..0000000 --- a/unikraft_cloud_platform/models/get_autoscale_configuration_policy_request.py +++ /dev/null @@ -1,57 +0,0 @@ -from collections.abc import Mapping -from typing import Any, TypeVar - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -T = TypeVar("T", bound="GetAutoscaleConfigurationPolicyRequest") - - -@_attrs_define -class GetAutoscaleConfigurationPolicyRequest: - """The request message to get an autoscale configuration policy by name.""" - - name: str - """ The Name of the policy to get. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - name = self.name - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update( - { - "name": name, - } - ) - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - d = dict(src_dict) - name = d.pop("name") - - get_autoscale_configuration_policy_request = cls( - name=name, - ) - - get_autoscale_configuration_policy_request.additional_properties = d - return get_autoscale_configuration_policy_request - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/get_autoscale_configuration_policy_response.py b/unikraft_cloud_platform/models/get_autoscale_configuration_policy_response.py deleted file mode 100644 index 8b75a78..0000000 --- a/unikraft_cloud_platform/models/get_autoscale_configuration_policy_response.py +++ /dev/null @@ -1,117 +0,0 @@ -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..models.response_status import ResponseStatus, check_response_status -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.get_autoscale_configuration_policy_response_data import GetAutoscaleConfigurationPolicyResponseData - from ..models.response_error import ResponseError - - -T = TypeVar("T", bound="GetAutoscaleConfigurationPolicyResponse") - - -@_attrs_define -class GetAutoscaleConfigurationPolicyResponse: - status: Union[Unset, ResponseStatus] = UNSET - """ The response status of an API request. """ - data: Union[Unset, "GetAutoscaleConfigurationPolicyResponseData"] = UNSET - errors: Union[Unset, list["ResponseError"]] = UNSET - """ A list of errors which may have occurred during the request. """ - op_time_us: Union[Unset, int] = UNSET - """ The operation time in microseconds. This is the time it took to process - the request and generate the response. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - status: Union[Unset, str] = UNSET - if not isinstance(self.status, Unset): - status = self.status - - data: Union[Unset, dict[str, Any]] = UNSET - if not isinstance(self.data, Unset): - data = self.data.to_dict() - - errors: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.errors, Unset): - errors = [] - for errors_item_data in self.errors: - errors_item = errors_item_data.to_dict() - errors.append(errors_item) - - op_time_us = self.op_time_us - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if status is not UNSET: - field_dict["status"] = status - if data is not UNSET: - field_dict["data"] = data - if errors is not UNSET: - field_dict["errors"] = errors - if op_time_us is not UNSET: - field_dict["op_time_us"] = op_time_us - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.get_autoscale_configuration_policy_response_data import ( - GetAutoscaleConfigurationPolicyResponseData, - ) - from ..models.response_error import ResponseError - - d = dict(src_dict) - _status = d.pop("status", UNSET) - status: Union[Unset, ResponseStatus] - if isinstance(_status, Unset): - status = UNSET - else: - status = check_response_status(_status) - - _data = d.pop("data", UNSET) - data: Union[Unset, GetAutoscaleConfigurationPolicyResponseData] - if isinstance(_data, Unset): - data = UNSET - else: - data = GetAutoscaleConfigurationPolicyResponseData.from_dict(_data) - - errors = [] - _errors = d.pop("errors", UNSET) - for errors_item_data in _errors or []: - errors_item = ResponseError.from_dict(errors_item_data) - - errors.append(errors_item) - - op_time_us = d.pop("op_time_us", UNSET) - - get_autoscale_configuration_policy_response = cls( - status=status, - data=data, - errors=errors, - op_time_us=op_time_us, - ) - - get_autoscale_configuration_policy_response.additional_properties = d - return get_autoscale_configuration_policy_response - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/get_autoscale_configuration_policy_response_data.py b/unikraft_cloud_platform/models/get_autoscale_configuration_policy_response_data.py deleted file mode 100644 index c5be0eb..0000000 --- a/unikraft_cloud_platform/models/get_autoscale_configuration_policy_response_data.py +++ /dev/null @@ -1,75 +0,0 @@ -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.get_autoscale_configuration_policy_response_policy_response import ( - GetAutoscaleConfigurationPolicyResponsePolicyResponse, - ) - - -T = TypeVar("T", bound="GetAutoscaleConfigurationPolicyResponseData") - - -@_attrs_define -class GetAutoscaleConfigurationPolicyResponseData: - policies: Union[Unset, list["GetAutoscaleConfigurationPolicyResponsePolicyResponse"]] = UNSET - """ The policy which was retrieved by the request. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - policies: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.policies, Unset): - policies = [] - for policies_item_data in self.policies: - policies_item = policies_item_data.to_dict() - policies.append(policies_item) - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if policies is not UNSET: - field_dict["policies"] = policies - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.get_autoscale_configuration_policy_response_policy_response import ( - GetAutoscaleConfigurationPolicyResponsePolicyResponse, - ) - - d = dict(src_dict) - policies = [] - _policies = d.pop("policies", UNSET) - for policies_item_data in _policies or []: - policies_item = GetAutoscaleConfigurationPolicyResponsePolicyResponse.from_dict(policies_item_data) - - policies.append(policies_item) - - get_autoscale_configuration_policy_response_data = cls( - policies=policies, - ) - - get_autoscale_configuration_policy_response_data.additional_properties = d - return get_autoscale_configuration_policy_response_data - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/get_autoscale_configuration_policy_response_policy_response.py b/unikraft_cloud_platform/models/get_autoscale_configuration_policy_response_policy_response.py deleted file mode 100644 index bb8c048..0000000 --- a/unikraft_cloud_platform/models/get_autoscale_configuration_policy_response_policy_response.py +++ /dev/null @@ -1,108 +0,0 @@ -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..models.response_status import ResponseStatus, check_response_status -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.autoscale_policy import AutoscalePolicy - - -T = TypeVar("T", bound="GetAutoscaleConfigurationPolicyResponsePolicyResponse") - - -@_attrs_define -class GetAutoscaleConfigurationPolicyResponsePolicyResponse: - status: Union[Unset, ResponseStatus] = UNSET - """ The response status of an API request. """ - policy: Union[Unset, "AutoscalePolicy"] = UNSET - """ AutoscalePolicy defines the autoscale policy for a service. - Right now it contains fields from both the `ondemand` and `step` policies. - They are marked both as optional, so only one of them should be set at a - time. This is a current limitation of the API design. """ - message: Union[Unset, str] = UNSET - """ An optional message providing additional information about the status. - This field is useful when the status is not `success`. """ - error: Union[Unset, int] = UNSET - """ An optional error code providing additional information about the status. - This field is useful when the status is not `success`. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - status: Union[Unset, str] = UNSET - if not isinstance(self.status, Unset): - status = self.status - - policy: Union[Unset, dict[str, Any]] = UNSET - if not isinstance(self.policy, Unset): - policy = self.policy.to_dict() - - message = self.message - - error = self.error - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if status is not UNSET: - field_dict["status"] = status - if policy is not UNSET: - field_dict["policy"] = policy - if message is not UNSET: - field_dict["message"] = message - if error is not UNSET: - field_dict["error"] = error - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.autoscale_policy import AutoscalePolicy - - d = dict(src_dict) - _status = d.pop("status", UNSET) - status: Union[Unset, ResponseStatus] - if isinstance(_status, Unset): - status = UNSET - else: - status = check_response_status(_status) - - _policy = d.pop("policy", UNSET) - policy: Union[Unset, AutoscalePolicy] - if isinstance(_policy, Unset): - policy = UNSET - else: - policy = AutoscalePolicy.from_dict(_policy) - - message = d.pop("message", UNSET) - - error = d.pop("error", UNSET) - - get_autoscale_configuration_policy_response_policy_response = cls( - status=status, - policy=policy, - message=message, - error=error, - ) - - get_autoscale_configuration_policy_response_policy_response.additional_properties = d - return get_autoscale_configuration_policy_response_policy_response - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/get_autoscale_configurations_response.py b/unikraft_cloud_platform/models/get_autoscale_configurations_response.py deleted file mode 100644 index e3db6e5..0000000 --- a/unikraft_cloud_platform/models/get_autoscale_configurations_response.py +++ /dev/null @@ -1,120 +0,0 @@ -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..models.get_autoscale_configurations_response_status import ( - GetAutoscaleConfigurationsResponseStatus, - check_get_autoscale_configurations_response_status, -) -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.get_autoscale_configurations_response_data import GetAutoscaleConfigurationsResponseData - from ..models.response_error import ResponseError - - -T = TypeVar("T", bound="GetAutoscaleConfigurationsResponse") - - -@_attrs_define -class GetAutoscaleConfigurationsResponse: - """The response message for a GetAutoscaleConfigurationsRequest.""" - - status: Union[Unset, GetAutoscaleConfigurationsResponseStatus] = UNSET - """ The status of the response. """ - data: Union[Unset, "GetAutoscaleConfigurationsResponseData"] = UNSET - errors: Union[Unset, list["ResponseError"]] = UNSET - """ A list of errors which may have occurred during the request. """ - op_time_us: Union[Unset, int] = UNSET - """ The operation time in microseconds. This is the time it took to process - the request and generate the response. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - status: Union[Unset, str] = UNSET - if not isinstance(self.status, Unset): - status = self.status - - data: Union[Unset, dict[str, Any]] = UNSET - if not isinstance(self.data, Unset): - data = self.data.to_dict() - - errors: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.errors, Unset): - errors = [] - for errors_item_data in self.errors: - errors_item = errors_item_data.to_dict() - errors.append(errors_item) - - op_time_us = self.op_time_us - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if status is not UNSET: - field_dict["status"] = status - if data is not UNSET: - field_dict["data"] = data - if errors is not UNSET: - field_dict["errors"] = errors - if op_time_us is not UNSET: - field_dict["op_time_us"] = op_time_us - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.get_autoscale_configurations_response_data import GetAutoscaleConfigurationsResponseData - from ..models.response_error import ResponseError - - d = dict(src_dict) - _status = d.pop("status", UNSET) - status: Union[Unset, GetAutoscaleConfigurationsResponseStatus] - if isinstance(_status, Unset): - status = UNSET - else: - status = check_get_autoscale_configurations_response_status(_status) - - _data = d.pop("data", UNSET) - data: Union[Unset, GetAutoscaleConfigurationsResponseData] - if isinstance(_data, Unset): - data = UNSET - else: - data = GetAutoscaleConfigurationsResponseData.from_dict(_data) - - errors = [] - _errors = d.pop("errors", UNSET) - for errors_item_data in _errors or []: - errors_item = ResponseError.from_dict(errors_item_data) - - errors.append(errors_item) - - op_time_us = d.pop("op_time_us", UNSET) - - get_autoscale_configurations_response = cls( - status=status, - data=data, - errors=errors, - op_time_us=op_time_us, - ) - - get_autoscale_configurations_response.additional_properties = d - return get_autoscale_configurations_response - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/get_autoscale_configurations_response_data.py b/unikraft_cloud_platform/models/get_autoscale_configurations_response_data.py deleted file mode 100644 index 4a87bc0..0000000 --- a/unikraft_cloud_platform/models/get_autoscale_configurations_response_data.py +++ /dev/null @@ -1,75 +0,0 @@ -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.get_autoscale_configurations_response_service_group import ( - GetAutoscaleConfigurationsResponseServiceGroup, - ) - - -T = TypeVar("T", bound="GetAutoscaleConfigurationsResponseData") - - -@_attrs_define -class GetAutoscaleConfigurationsResponseData: - service_groups: Union[Unset, list["GetAutoscaleConfigurationsResponseServiceGroup"]] = UNSET - """ The configuration(s) which were retrieved by the request. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - service_groups: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.service_groups, Unset): - service_groups = [] - for service_groups_item_data in self.service_groups: - service_groups_item = service_groups_item_data.to_dict() - service_groups.append(service_groups_item) - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if service_groups is not UNSET: - field_dict["service_groups"] = service_groups - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.get_autoscale_configurations_response_service_group import ( - GetAutoscaleConfigurationsResponseServiceGroup, - ) - - d = dict(src_dict) - service_groups = [] - _service_groups = d.pop("service_groups", UNSET) - for service_groups_item_data in _service_groups or []: - service_groups_item = GetAutoscaleConfigurationsResponseServiceGroup.from_dict(service_groups_item_data) - - service_groups.append(service_groups_item) - - get_autoscale_configurations_response_data = cls( - service_groups=service_groups, - ) - - get_autoscale_configurations_response_data.additional_properties = d - return get_autoscale_configurations_response_data - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/get_autoscale_configurations_response_service_group.py b/unikraft_cloud_platform/models/get_autoscale_configurations_response_service_group.py deleted file mode 100644 index ff34c0c..0000000 --- a/unikraft_cloud_platform/models/get_autoscale_configurations_response_service_group.py +++ /dev/null @@ -1,200 +0,0 @@ -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union -from uuid import UUID - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..models.response_status import ResponseStatus, check_response_status -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.autoscale_policy import AutoscalePolicy - from ..models.service_group_template import ServiceGroupTemplate - - -T = TypeVar("T", bound="GetAutoscaleConfigurationsResponseServiceGroup") - - -@_attrs_define -class GetAutoscaleConfigurationsResponseServiceGroup: - status: Union[Unset, ResponseStatus] = UNSET - """ The response status of an API request. """ - uuid: Union[Unset, UUID] = UNSET - """ The UUID of the service where the configuration was created. """ - name: Union[Unset, str] = UNSET - """ The name of the service where the configuration was created. """ - enabled: Union[Unset, bool] = UNSET - """ If the autoscale configuration is enabled. """ - min_size: Union[Unset, int] = UNSET - """ The minimum number of instances to keep running. - Only if enabled is true. """ - max_size: Union[Unset, int] = UNSET - """ The maximum number of instances to keep running. - Only if enabled is true. """ - warmup_time_ms: Union[Unset, int] = UNSET - """ The warmup time in seconds for new instances. - Only if enabled is true. """ - cooldown_time_ms: Union[Unset, int] = UNSET - """ The cooldown time in seconds for the autoscale configuration. - Only if enabled is true. """ - template: Union[Unset, "ServiceGroupTemplate"] = UNSET - policies: Union[Unset, list["AutoscalePolicy"]] = UNSET - """ The policies applied to the autoscale configuration. """ - message: Union[Unset, str] = UNSET - """ An optional message providing additional information about the status. - This field is useful when the status is not `success`. """ - error: Union[Unset, int] = UNSET - """ An optional error code providing additional information about the status. - This field is useful when the status is not `success`. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - status: Union[Unset, str] = UNSET - if not isinstance(self.status, Unset): - status = self.status - - uuid: Union[Unset, str] = UNSET - if not isinstance(self.uuid, Unset): - uuid = str(self.uuid) - - name = self.name - - enabled = self.enabled - - min_size = self.min_size - - max_size = self.max_size - - warmup_time_ms = self.warmup_time_ms - - cooldown_time_ms = self.cooldown_time_ms - - template: Union[Unset, dict[str, Any]] = UNSET - if not isinstance(self.template, Unset): - template = self.template.to_dict() - - policies: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.policies, Unset): - policies = [] - for policies_item_data in self.policies: - policies_item = policies_item_data.to_dict() - policies.append(policies_item) - - message = self.message - - error = self.error - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if status is not UNSET: - field_dict["status"] = status - if uuid is not UNSET: - field_dict["uuid"] = uuid - if name is not UNSET: - field_dict["name"] = name - if enabled is not UNSET: - field_dict["enabled"] = enabled - if min_size is not UNSET: - field_dict["min_size"] = min_size - if max_size is not UNSET: - field_dict["max_size"] = max_size - if warmup_time_ms is not UNSET: - field_dict["warmup_time_ms"] = warmup_time_ms - if cooldown_time_ms is not UNSET: - field_dict["cooldown_time_ms"] = cooldown_time_ms - if template is not UNSET: - field_dict["template"] = template - if policies is not UNSET: - field_dict["policies"] = policies - if message is not UNSET: - field_dict["message"] = message - if error is not UNSET: - field_dict["error"] = error - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.autoscale_policy import AutoscalePolicy - from ..models.service_group_template import ServiceGroupTemplate - - d = dict(src_dict) - _status = d.pop("status", UNSET) - status: Union[Unset, ResponseStatus] - if isinstance(_status, Unset): - status = UNSET - else: - status = check_response_status(_status) - - _uuid = d.pop("uuid", UNSET) - uuid: Union[Unset, UUID] - if isinstance(_uuid, Unset): - uuid = UNSET - else: - uuid = UUID(_uuid) - - name = d.pop("name", UNSET) - - enabled = d.pop("enabled", UNSET) - - min_size = d.pop("min_size", UNSET) - - max_size = d.pop("max_size", UNSET) - - warmup_time_ms = d.pop("warmup_time_ms", UNSET) - - cooldown_time_ms = d.pop("cooldown_time_ms", UNSET) - - _template = d.pop("template", UNSET) - template: Union[Unset, ServiceGroupTemplate] - if isinstance(_template, Unset): - template = UNSET - else: - template = ServiceGroupTemplate.from_dict(_template) - - policies = [] - _policies = d.pop("policies", UNSET) - for policies_item_data in _policies or []: - policies_item = AutoscalePolicy.from_dict(policies_item_data) - - policies.append(policies_item) - - message = d.pop("message", UNSET) - - error = d.pop("error", UNSET) - - get_autoscale_configurations_response_service_group = cls( - status=status, - uuid=uuid, - name=name, - enabled=enabled, - min_size=min_size, - max_size=max_size, - warmup_time_ms=warmup_time_ms, - cooldown_time_ms=cooldown_time_ms, - template=template, - policies=policies, - message=message, - error=error, - ) - - get_autoscale_configurations_response_service_group.additional_properties = d - return get_autoscale_configurations_response_service_group - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/get_autoscale_configurations_response_status.py b/unikraft_cloud_platform/models/get_autoscale_configurations_response_status.py deleted file mode 100644 index 98944cf..0000000 --- a/unikraft_cloud_platform/models/get_autoscale_configurations_response_status.py +++ /dev/null @@ -1,17 +0,0 @@ -from typing import Literal, cast - -GetAutoscaleConfigurationsResponseStatus = Literal["error", "success", "unconfigured"] - -GET_AUTOSCALE_CONFIGURATIONS_RESPONSE_STATUS_VALUES: set[GetAutoscaleConfigurationsResponseStatus] = { - "error", - "success", - "unconfigured", -} - - -def check_get_autoscale_configurations_response_status(value: str) -> GetAutoscaleConfigurationsResponseStatus: - if value in GET_AUTOSCALE_CONFIGURATIONS_RESPONSE_STATUS_VALUES: - return cast(GetAutoscaleConfigurationsResponseStatus, value) - raise TypeError( - f"Unexpected value {value!r}. Expected one of {GET_AUTOSCALE_CONFIGURATIONS_RESPONSE_STATUS_VALUES!r}" - ) diff --git a/unikraft_cloud_platform/models/get_autoscale_policy_by_service_uuid_and_policy_name200_response.py b/unikraft_cloud_platform/models/get_autoscale_policy_by_service_uuid_and_policy_name200_response.py new file mode 100644 index 0000000..3a1ed1f --- /dev/null +++ b/unikraft_cloud_platform/models/get_autoscale_policy_by_service_uuid_and_policy_name200_response.py @@ -0,0 +1,107 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from unikraft_cloud_platform.models.get_autoscale_policy_by_service_uuid_and_policy_name200_response_data import ( + GetAutoscalePolicyByServiceUuidAndPolicyName200ResponseData, +) +from typing import Optional, Set +from typing_extensions import Self + + +class GetAutoscalePolicyByServiceUuidAndPolicyName200Response(BaseModel): + """ + GetAutoscalePolicyByServiceUuidAndPolicyName200Response + """ # noqa: E501 + + status: Optional[StrictStr] = Field(default=None, description="The status of the response. ") + data: Optional[GetAutoscalePolicyByServiceUuidAndPolicyName200ResponseData] = None + __properties: ClassVar[List[str]] = ["status", "data"] + + @field_validator("status") + def status_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(["success", "failure"]): + raise ValueError("must be one of enum values ('success', 'failure')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of GetAutoscalePolicyByServiceUuidAndPolicyName200Response from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of data + if self.data: + _dict["data"] = self.data.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of GetAutoscalePolicyByServiceUuidAndPolicyName200Response from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "status": obj.get("status"), + "data": GetAutoscalePolicyByServiceUuidAndPolicyName200ResponseData.from_dict(obj["data"]) + if obj.get("data") is not None + else None, + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/get_autoscale_policy_by_service_uuid_and_policy_name200_response_data.py b/unikraft_cloud_platform/models/get_autoscale_policy_by_service_uuid_and_policy_name200_response_data.py new file mode 100644 index 0000000..51e9166 --- /dev/null +++ b/unikraft_cloud_platform/models/get_autoscale_policy_by_service_uuid_and_policy_name200_response_data.py @@ -0,0 +1,98 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from unikraft_cloud_platform.models.autoscale_policy import AutoscalePolicy +from typing import Optional, Set +from typing_extensions import Self + + +class GetAutoscalePolicyByServiceUuidAndPolicyName200ResponseData(BaseModel): + """ + GetAutoscalePolicyByServiceUuidAndPolicyName200ResponseData + """ # noqa: E501 + + policies: Optional[Annotated[List[AutoscalePolicy], Field(max_length=1)]] = None + __properties: ClassVar[List[str]] = ["policies"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of GetAutoscalePolicyByServiceUuidAndPolicyName200ResponseData from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in policies (list) + _items = [] + if self.policies: + for _item_policies in self.policies: + if _item_policies: + _items.append(_item_policies.to_dict()) + _dict["policies"] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of GetAutoscalePolicyByServiceUuidAndPolicyName200ResponseData from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "policies": [AutoscalePolicy.from_dict(_item) for _item in obj["policies"]] + if obj.get("policies") is not None + else None + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/get_certificate_by_uuid200_response.py b/unikraft_cloud_platform/models/get_certificate_by_uuid200_response.py new file mode 100644 index 0000000..214c82a --- /dev/null +++ b/unikraft_cloud_platform/models/get_certificate_by_uuid200_response.py @@ -0,0 +1,105 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from unikraft_cloud_platform.models.get_certificate_by_uuid200_response_data import GetCertificateByUuid200ResponseData +from typing import Optional, Set +from typing_extensions import Self + + +class GetCertificateByUuid200Response(BaseModel): + """ + GetCertificateByUuid200Response + """ # noqa: E501 + + status: Optional[StrictStr] = Field(default=None, description="The status of the response. ") + data: Optional[GetCertificateByUuid200ResponseData] = None + __properties: ClassVar[List[str]] = ["status", "data"] + + @field_validator("status") + def status_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(["success", "failure"]): + raise ValueError("must be one of enum values ('success', 'failure')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of GetCertificateByUuid200Response from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of data + if self.data: + _dict["data"] = self.data.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of GetCertificateByUuid200Response from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "status": obj.get("status"), + "data": GetCertificateByUuid200ResponseData.from_dict(obj["data"]) + if obj.get("data") is not None + else None, + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/get_certificate_by_uuid200_response_data.py b/unikraft_cloud_platform/models/get_certificate_by_uuid200_response_data.py new file mode 100644 index 0000000..717c549 --- /dev/null +++ b/unikraft_cloud_platform/models/get_certificate_by_uuid200_response_data.py @@ -0,0 +1,98 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from unikraft_cloud_platform.models.certificate import Certificate +from typing import Optional, Set +from typing_extensions import Self + + +class GetCertificateByUuid200ResponseData(BaseModel): + """ + GetCertificateByUuid200ResponseData + """ # noqa: E501 + + certificates: Optional[Annotated[List[Certificate], Field(max_length=1)]] = None + __properties: ClassVar[List[str]] = ["certificates"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of GetCertificateByUuid200ResponseData from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in certificates (list) + _items = [] + if self.certificates: + for _item_certificates in self.certificates: + if _item_certificates: + _items.append(_item_certificates.to_dict()) + _dict["certificates"] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of GetCertificateByUuid200ResponseData from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "certificates": [Certificate.from_dict(_item) for _item in obj["certificates"]] + if obj.get("certificates") is not None + else None + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/get_certificates200_response.py b/unikraft_cloud_platform/models/get_certificates200_response.py new file mode 100644 index 0000000..90d6e78 --- /dev/null +++ b/unikraft_cloud_platform/models/get_certificates200_response.py @@ -0,0 +1,103 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from unikraft_cloud_platform.models.get_certificates200_response_data import GetCertificates200ResponseData +from typing import Optional, Set +from typing_extensions import Self + + +class GetCertificates200Response(BaseModel): + """ + GetCertificates200Response + """ # noqa: E501 + + status: Optional[StrictStr] = Field(default=None, description="The status of the response. ") + data: Optional[GetCertificates200ResponseData] = None + __properties: ClassVar[List[str]] = ["status", "data"] + + @field_validator("status") + def status_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(["success", "failure"]): + raise ValueError("must be one of enum values ('success', 'failure')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of GetCertificates200Response from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of data + if self.data: + _dict["data"] = self.data.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of GetCertificates200Response from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "status": obj.get("status"), + "data": GetCertificates200ResponseData.from_dict(obj["data"]) if obj.get("data") is not None else None, + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/get_certificates200_response_data.py b/unikraft_cloud_platform/models/get_certificates200_response_data.py new file mode 100644 index 0000000..46a4f60 --- /dev/null +++ b/unikraft_cloud_platform/models/get_certificates200_response_data.py @@ -0,0 +1,98 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from unikraft_cloud_platform.models.certificate import Certificate +from typing import Optional, Set +from typing_extensions import Self + + +class GetCertificates200ResponseData(BaseModel): + """ + GetCertificates200ResponseData + """ # noqa: E501 + + certificates: Optional[Annotated[List[Certificate], Field(max_length=253)]] = None + __properties: ClassVar[List[str]] = ["certificates"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of GetCertificates200ResponseData from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in certificates (list) + _items = [] + if self.certificates: + for _item_certificates in self.certificates: + if _item_certificates: + _items.append(_item_certificates.to_dict()) + _dict["certificates"] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of GetCertificates200ResponseData from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "certificates": [Certificate.from_dict(_item) for _item in obj["certificates"]] + if obj.get("certificates") is not None + else None + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/get_certificates_default_response.py b/unikraft_cloud_platform/models/get_certificates_default_response.py new file mode 100644 index 0000000..b0dc549 --- /dev/null +++ b/unikraft_cloud_platform/models/get_certificates_default_response.py @@ -0,0 +1,110 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from unikraft_cloud_platform.models.get_certificates_default_response_errors_inner import ( + GetCertificatesDefaultResponseErrorsInner, +) +from typing import Optional, Set +from typing_extensions import Self + + +class GetCertificatesDefaultResponse(BaseModel): + """ + An error response from the Unikraft Cloud Platform API + """ # noqa: E501 + + status: StrictStr = Field(description="The status of the response. ") + errors: List[GetCertificatesDefaultResponseErrorsInner] + data: Optional[Dict[str, Any]] = None + __properties: ClassVar[List[str]] = ["status", "errors", "data"] + + @field_validator("status") + def status_validate_enum(cls, value): + """Validates the enum""" + if value not in set(["success", "failure"]): + raise ValueError("must be one of enum values ('success', 'failure')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of GetCertificatesDefaultResponse from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in errors (list) + _items = [] + if self.errors: + for _item_errors in self.errors: + if _item_errors: + _items.append(_item_errors.to_dict()) + _dict["errors"] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of GetCertificatesDefaultResponse from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "status": obj.get("status"), + "errors": [GetCertificatesDefaultResponseErrorsInner.from_dict(_item) for _item in obj["errors"]] + if obj.get("errors") is not None + else None, + "data": obj.get("data"), + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/get_certificates_default_response_errors_inner.py b/unikraft_cloud_platform/models/get_certificates_default_response_errors_inner.py new file mode 100644 index 0000000..3611b7e --- /dev/null +++ b/unikraft_cloud_platform/models/get_certificates_default_response_errors_inner.py @@ -0,0 +1,83 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictInt +from typing import Any, ClassVar, Dict, List, Optional +from typing import Optional, Set +from typing_extensions import Self + + +class GetCertificatesDefaultResponseErrorsInner(BaseModel): + """ + GetCertificatesDefaultResponseErrorsInner + """ # noqa: E501 + + status: Optional[StrictInt] = Field(default=None, description="HTTP status code ") + __properties: ClassVar[List[str]] = ["status"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of GetCertificatesDefaultResponseErrorsInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of GetCertificatesDefaultResponseErrorsInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({"status": obj.get("status")}) + return _obj diff --git a/unikraft_cloud_platform/models/get_certificates_request_inner.py b/unikraft_cloud_platform/models/get_certificates_request_inner.py new file mode 100644 index 0000000..6c13153 --- /dev/null +++ b/unikraft_cloud_platform/models/get_certificates_request_inner.py @@ -0,0 +1,92 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from uuid import UUID +from typing import Optional, Set +from typing_extensions import Self + + +class GetCertificatesRequestInner(BaseModel): + """ + GetCertificatesRequestInner + """ # noqa: E501 + + uuid: Optional[UUID] = Field( + default=None, + description="The UUID of the certificate to retrieve. Note: This property is mutually exclusive with `name` and either `uuid` or `name` are required. ", + ) + name: Optional[Annotated[str, Field(strict=True, max_length=255)]] = Field( + default=None, + description="The name of the certificate to retrieve. Note: This property is mutually exclusive with `uuid` and either `uuid` or `name` are required. ", + ) + __properties: ClassVar[List[str]] = ["uuid", "name"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of GetCertificatesRequestInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of GetCertificatesRequestInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({"uuid": obj.get("uuid"), "name": obj.get("name")}) + return _obj diff --git a/unikraft_cloud_platform/models/get_certificates_response.py b/unikraft_cloud_platform/models/get_certificates_response.py deleted file mode 100644 index ce6d4cc..0000000 --- a/unikraft_cloud_platform/models/get_certificates_response.py +++ /dev/null @@ -1,130 +0,0 @@ -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..models.response_status import ResponseStatus, check_response_status -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.get_certificates_response_data import GetCertificatesResponseData - from ..models.response_error import ResponseError - - -T = TypeVar("T", bound="GetCertificatesResponse") - - -@_attrs_define -class GetCertificatesResponse: - """The response message for getting one or more certificate(s) given their - UUID(s) or name(s). - - """ - - status: Union[Unset, ResponseStatus] = UNSET - """ The response status of an API request. """ - message: Union[Unset, str] = UNSET - """ An optional message providing additional information about the status. - This field is useful when the status is not `success`. """ - data: Union[Unset, "GetCertificatesResponseData"] = UNSET - errors: Union[Unset, list["ResponseError"]] = UNSET - """ A list of errors which may have occurred during the request. """ - op_time_us: Union[Unset, int] = UNSET - """ The operation time in microseconds. This is the time it took to process - the request and generate the response. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - status: Union[Unset, str] = UNSET - if not isinstance(self.status, Unset): - status = self.status - - message = self.message - - data: Union[Unset, dict[str, Any]] = UNSET - if not isinstance(self.data, Unset): - data = self.data.to_dict() - - errors: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.errors, Unset): - errors = [] - for errors_item_data in self.errors: - errors_item = errors_item_data.to_dict() - errors.append(errors_item) - - op_time_us = self.op_time_us - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if status is not UNSET: - field_dict["status"] = status - if message is not UNSET: - field_dict["message"] = message - if data is not UNSET: - field_dict["data"] = data - if errors is not UNSET: - field_dict["errors"] = errors - if op_time_us is not UNSET: - field_dict["op_time_us"] = op_time_us - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.get_certificates_response_data import GetCertificatesResponseData - from ..models.response_error import ResponseError - - d = dict(src_dict) - _status = d.pop("status", UNSET) - status: Union[Unset, ResponseStatus] - if isinstance(_status, Unset): - status = UNSET - else: - status = check_response_status(_status) - - message = d.pop("message", UNSET) - - _data = d.pop("data", UNSET) - data: Union[Unset, GetCertificatesResponseData] - if isinstance(_data, Unset): - data = UNSET - else: - data = GetCertificatesResponseData.from_dict(_data) - - errors = [] - _errors = d.pop("errors", UNSET) - for errors_item_data in _errors or []: - errors_item = ResponseError.from_dict(errors_item_data) - - errors.append(errors_item) - - op_time_us = d.pop("op_time_us", UNSET) - - get_certificates_response = cls( - status=status, - message=message, - data=data, - errors=errors, - op_time_us=op_time_us, - ) - - get_certificates_response.additional_properties = d - return get_certificates_response - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/get_certificates_response_data.py b/unikraft_cloud_platform/models/get_certificates_response_data.py deleted file mode 100644 index 84fff5a..0000000 --- a/unikraft_cloud_platform/models/get_certificates_response_data.py +++ /dev/null @@ -1,71 +0,0 @@ -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.certificate import Certificate - - -T = TypeVar("T", bound="GetCertificatesResponseData") - - -@_attrs_define -class GetCertificatesResponseData: - certificates: Union[Unset, list["Certificate"]] = UNSET - """ The certificate(s) which were retrieved by the request. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - certificates: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.certificates, Unset): - certificates = [] - for certificates_item_data in self.certificates: - certificates_item = certificates_item_data.to_dict() - certificates.append(certificates_item) - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if certificates is not UNSET: - field_dict["certificates"] = certificates - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.certificate import Certificate - - d = dict(src_dict) - certificates = [] - _certificates = d.pop("certificates", UNSET) - for certificates_item_data in _certificates or []: - certificates_item = Certificate.from_dict(certificates_item_data) - - certificates.append(certificates_item) - - get_certificates_response_data = cls( - certificates=certificates, - ) - - get_certificates_response_data.additional_properties = d - return get_certificates_response_data - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/get_image_response.py b/unikraft_cloud_platform/models/get_image_response.py deleted file mode 100644 index 2cf6af0..0000000 --- a/unikraft_cloud_platform/models/get_image_response.py +++ /dev/null @@ -1,126 +0,0 @@ -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..models.response_status import ResponseStatus, check_response_status -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.get_image_response_data import GetImageResponseData - from ..models.response_error import ResponseError - - -T = TypeVar("T", bound="GetImageResponse") - - -@_attrs_define -class GetImageResponse: - """The response message for retrieving a single image.""" - - status: Union[Unset, ResponseStatus] = UNSET - """ The response status of an API request. """ - message: Union[Unset, str] = UNSET - """ An optional message providing additional information about the response. """ - data: Union[Unset, "GetImageResponseData"] = UNSET - errors: Union[Unset, list["ResponseError"]] = UNSET - """ A list of errors which may have occurred during the request. """ - op_time_us: Union[Unset, int] = UNSET - """ The operation time in microseconds. This is the time it took to process - the request and generate the response. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - status: Union[Unset, str] = UNSET - if not isinstance(self.status, Unset): - status = self.status - - message = self.message - - data: Union[Unset, dict[str, Any]] = UNSET - if not isinstance(self.data, Unset): - data = self.data.to_dict() - - errors: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.errors, Unset): - errors = [] - for errors_item_data in self.errors: - errors_item = errors_item_data.to_dict() - errors.append(errors_item) - - op_time_us = self.op_time_us - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if status is not UNSET: - field_dict["status"] = status - if message is not UNSET: - field_dict["message"] = message - if data is not UNSET: - field_dict["data"] = data - if errors is not UNSET: - field_dict["errors"] = errors - if op_time_us is not UNSET: - field_dict["op_time_us"] = op_time_us - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.get_image_response_data import GetImageResponseData - from ..models.response_error import ResponseError - - d = dict(src_dict) - _status = d.pop("status", UNSET) - status: Union[Unset, ResponseStatus] - if isinstance(_status, Unset): - status = UNSET - else: - status = check_response_status(_status) - - message = d.pop("message", UNSET) - - _data = d.pop("data", UNSET) - data: Union[Unset, GetImageResponseData] - if isinstance(_data, Unset): - data = UNSET - else: - data = GetImageResponseData.from_dict(_data) - - errors = [] - _errors = d.pop("errors", UNSET) - for errors_item_data in _errors or []: - errors_item = ResponseError.from_dict(errors_item_data) - - errors.append(errors_item) - - op_time_us = d.pop("op_time_us", UNSET) - - get_image_response = cls( - status=status, - message=message, - data=data, - errors=errors, - op_time_us=op_time_us, - ) - - get_image_response.additional_properties = d - return get_image_response - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/get_image_response_data.py b/unikraft_cloud_platform/models/get_image_response_data.py deleted file mode 100644 index 70e21cb..0000000 --- a/unikraft_cloud_platform/models/get_image_response_data.py +++ /dev/null @@ -1,67 +0,0 @@ -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.image import Image - - -T = TypeVar("T", bound="GetImageResponseData") - - -@_attrs_define -class GetImageResponseData: - image: Union[Unset, "Image"] = UNSET - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - image: Union[Unset, dict[str, Any]] = UNSET - if not isinstance(self.image, Unset): - image = self.image.to_dict() - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if image is not UNSET: - field_dict["image"] = image - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.image import Image - - d = dict(src_dict) - _image = d.pop("image", UNSET) - image: Union[Unset, Image] - if isinstance(_image, Unset): - image = UNSET - else: - image = Image.from_dict(_image) - - get_image_response_data = cls( - image=image, - ) - - get_image_response_data.additional_properties = d - return get_image_response_data - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/get_images200_response.py b/unikraft_cloud_platform/models/get_images200_response.py new file mode 100644 index 0000000..6c57ba8 --- /dev/null +++ b/unikraft_cloud_platform/models/get_images200_response.py @@ -0,0 +1,103 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from unikraft_cloud_platform.models.get_images200_response_data import GetImages200ResponseData +from typing import Optional, Set +from typing_extensions import Self + + +class GetImages200Response(BaseModel): + """ + GetImages200Response + """ # noqa: E501 + + status: Optional[StrictStr] = None + data: Optional[GetImages200ResponseData] = None + __properties: ClassVar[List[str]] = ["status", "data"] + + @field_validator("status") + def status_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(["success", "failure"]): + raise ValueError("must be one of enum values ('success', 'failure')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of GetImages200Response from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of data + if self.data: + _dict["data"] = self.data.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of GetImages200Response from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "status": obj.get("status"), + "data": GetImages200ResponseData.from_dict(obj["data"]) if obj.get("data") is not None else None, + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/get_images200_response_data.py b/unikraft_cloud_platform/models/get_images200_response_data.py new file mode 100644 index 0000000..43f7778 --- /dev/null +++ b/unikraft_cloud_platform/models/get_images200_response_data.py @@ -0,0 +1,94 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from unikraft_cloud_platform.models.image import Image +from typing import Optional, Set +from typing_extensions import Self + + +class GetImages200ResponseData(BaseModel): + """ + GetImages200ResponseData + """ # noqa: E501 + + images: Optional[Annotated[List[Image], Field(max_length=253)]] = None + __properties: ClassVar[List[str]] = ["images"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of GetImages200ResponseData from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in images (list) + _items = [] + if self.images: + for _item_images in self.images: + if _item_images: + _items.append(_item_images.to_dict()) + _dict["images"] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of GetImages200ResponseData from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + {"images": [Image.from_dict(_item) for _item in obj["images"]] if obj.get("images") is not None else None} + ) + return _obj diff --git a/unikraft_cloud_platform/models/get_images_request_inner.py b/unikraft_cloud_platform/models/get_images_request_inner.py new file mode 100644 index 0000000..87b8d48 --- /dev/null +++ b/unikraft_cloud_platform/models/get_images_request_inner.py @@ -0,0 +1,111 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from typing import Optional, Set +from typing_extensions import Self + + +class GetImagesRequestInner(BaseModel): + """ + GetImagesRequestInner + """ # noqa: E501 + + digest: Optional[Annotated[str, Field(strict=True, max_length=255)]] = Field( + default=None, description="Image digest to lookup. " + ) + tagged: Optional[Annotated[str, Field(strict=True, max_length=8388608)]] = Field( + default=None, description="Image tag to lookup. " + ) + __properties: ClassVar[List[str]] = [] + + @field_validator("digest") + def digest_validate_regular_expression(cls, value): + """Validates the regular expression""" + if value is None: + return value + + if not re.match(r"^[a-zA-Z_0-9]+[a-zA-Z_0-9]+((:|@sha256:)[a-zA-Z_0-9]+)?$", value): + raise ValueError( + r"must validate the regular expression /^[a-zA-Z_0-9]+[a-zA-Z_0-9]+((:|@sha256:)[a-zA-Z_0-9]+)?$/" + ) + return value + + @field_validator("tagged") + def tagged_validate_regular_expression(cls, value): + """Validates the regular expression""" + if value is None: + return value + + if not re.match(r"^[a-zA-Z0-9_-]+$", value): + raise ValueError(r"must validate the regular expression /^[a-zA-Z0-9_-]+$/") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of GetImagesRequestInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of GetImagesRequestInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({}) + return _obj diff --git a/unikraft_cloud_platform/models/get_instance_by_uuid200_response.py b/unikraft_cloud_platform/models/get_instance_by_uuid200_response.py new file mode 100644 index 0000000..809fa18 --- /dev/null +++ b/unikraft_cloud_platform/models/get_instance_by_uuid200_response.py @@ -0,0 +1,105 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from unikraft_cloud_platform.models.get_instance_by_uuid200_response_data import GetInstanceByUuid200ResponseData +from typing import Optional, Set +from typing_extensions import Self + + +class GetInstanceByUuid200Response(BaseModel): + """ + GetInstanceByUuid200Response + """ # noqa: E501 + + status: Optional[StrictStr] = Field(default=None, description="The status of the response. ") + data: Optional[GetInstanceByUuid200ResponseData] = None + __properties: ClassVar[List[str]] = ["status", "data"] + + @field_validator("status") + def status_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(["success", "failure"]): + raise ValueError("must be one of enum values ('success', 'failure')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of GetInstanceByUuid200Response from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of data + if self.data: + _dict["data"] = self.data.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of GetInstanceByUuid200Response from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "status": obj.get("status"), + "data": GetInstanceByUuid200ResponseData.from_dict(obj["data"]) + if obj.get("data") is not None + else None, + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/get_instance_by_uuid200_response_data.py b/unikraft_cloud_platform/models/get_instance_by_uuid200_response_data.py new file mode 100644 index 0000000..baa0f60 --- /dev/null +++ b/unikraft_cloud_platform/models/get_instance_by_uuid200_response_data.py @@ -0,0 +1,98 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from unikraft_cloud_platform.models.instance import Instance +from typing import Optional, Set +from typing_extensions import Self + + +class GetInstanceByUuid200ResponseData(BaseModel): + """ + GetInstanceByUuid200ResponseData + """ # noqa: E501 + + instances: Optional[Annotated[List[Instance], Field(max_length=253)]] = None + __properties: ClassVar[List[str]] = ["instances"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of GetInstanceByUuid200ResponseData from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in instances (list) + _items = [] + if self.instances: + for _item_instances in self.instances: + if _item_instances: + _items.append(_item_instances.to_dict()) + _dict["instances"] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of GetInstanceByUuid200ResponseData from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "instances": [Instance.from_dict(_item) for _item in obj["instances"]] + if obj.get("instances") is not None + else None + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/get_instance_logs200_response.py b/unikraft_cloud_platform/models/get_instance_logs200_response.py new file mode 100644 index 0000000..0651067 --- /dev/null +++ b/unikraft_cloud_platform/models/get_instance_logs200_response.py @@ -0,0 +1,103 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from unikraft_cloud_platform.models.get_instance_logs200_response_data import GetInstanceLogs200ResponseData +from typing import Optional, Set +from typing_extensions import Self + + +class GetInstanceLogs200Response(BaseModel): + """ + GetInstanceLogs200Response + """ # noqa: E501 + + status: Optional[StrictStr] = Field(default=None, description="The status of the response. ") + data: Optional[GetInstanceLogs200ResponseData] = None + __properties: ClassVar[List[str]] = ["status", "data"] + + @field_validator("status") + def status_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(["success", "failure"]): + raise ValueError("must be one of enum values ('success', 'failure')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of GetInstanceLogs200Response from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of data + if self.data: + _dict["data"] = self.data.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of GetInstanceLogs200Response from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "status": obj.get("status"), + "data": GetInstanceLogs200ResponseData.from_dict(obj["data"]) if obj.get("data") is not None else None, + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/get_instance_logs200_response_data.py b/unikraft_cloud_platform/models/get_instance_logs200_response_data.py new file mode 100644 index 0000000..ef4809c --- /dev/null +++ b/unikraft_cloud_platform/models/get_instance_logs200_response_data.py @@ -0,0 +1,102 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from unikraft_cloud_platform.models.get_instance_logs200_response_data_instances_inner import ( + GetInstanceLogs200ResponseDataInstancesInner, +) +from typing import Optional, Set +from typing_extensions import Self + + +class GetInstanceLogs200ResponseData(BaseModel): + """ + GetInstanceLogs200ResponseData + """ # noqa: E501 + + instances: Optional[Annotated[List[GetInstanceLogs200ResponseDataInstancesInner], Field(max_length=253)]] = None + __properties: ClassVar[List[str]] = ["instances"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of GetInstanceLogs200ResponseData from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in instances (list) + _items = [] + if self.instances: + for _item_instances in self.instances: + if _item_instances: + _items.append(_item_instances.to_dict()) + _dict["instances"] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of GetInstanceLogs200ResponseData from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "instances": [ + GetInstanceLogs200ResponseDataInstancesInner.from_dict(_item) for _item in obj["instances"] + ] + if obj.get("instances") is not None + else None + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/get_instance_logs200_response_data_instances_inner.py b/unikraft_cloud_platform/models/get_instance_logs200_response_data_instances_inner.py new file mode 100644 index 0000000..07c0060 --- /dev/null +++ b/unikraft_cloud_platform/models/get_instance_logs200_response_data_instances_inner.py @@ -0,0 +1,132 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional, Union +from typing_extensions import Annotated +from uuid import UUID +from unikraft_cloud_platform.models.get_instance_logs200_response_data_instances_inner_available import ( + GetInstanceLogs200ResponseDataInstancesInnerAvailable, +) +from unikraft_cloud_platform.models.get_instance_logs200_response_data_instances_inner_range import ( + GetInstanceLogs200ResponseDataInstancesInnerRange, +) +from typing import Optional, Set +from typing_extensions import Self + + +class GetInstanceLogs200ResponseDataInstancesInner(BaseModel): + """ + GetInstanceLogs200ResponseDataInstancesInner + """ # noqa: E501 + + status: Optional[StrictStr] = Field(default=None, description="The status of the response. ") + uuid: Optional[UUID] = Field(default=None, description="The UUID of the instance. ") + name: Optional[Annotated[str, Field(strict=True, max_length=255)]] = Field( + default=None, description="The name of the instance. " + ) + output: Optional[ + Union[ + Annotated[bytes, Field(strict=True, max_length=8388608)], + Annotated[str, Field(strict=True, max_length=8388608)], + ] + ] = Field(default=None, description="BASE64 encoded log output. ") + available: Optional[GetInstanceLogs200ResponseDataInstancesInnerAvailable] = None + range: Optional[GetInstanceLogs200ResponseDataInstancesInnerRange] = None + __properties: ClassVar[List[str]] = ["status", "uuid", "name", "output", "available", "range"] + + @field_validator("status") + def status_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(["success", "error"]): + raise ValueError("must be one of enum values ('success', 'error')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of GetInstanceLogs200ResponseDataInstancesInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of available + if self.available: + _dict["available"] = self.available.to_dict() + # override the default output from pydantic by calling `to_dict()` of range + if self.range: + _dict["range"] = self.range.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of GetInstanceLogs200ResponseDataInstancesInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "status": obj.get("status"), + "uuid": obj.get("uuid"), + "name": obj.get("name"), + "output": obj.get("output"), + "available": GetInstanceLogs200ResponseDataInstancesInnerAvailable.from_dict(obj["available"]) + if obj.get("available") is not None + else None, + "range": GetInstanceLogs200ResponseDataInstancesInnerRange.from_dict(obj["range"]) + if obj.get("range") is not None + else None, + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/get_instance_logs200_response_data_instances_inner_available.py b/unikraft_cloud_platform/models/get_instance_logs200_response_data_instances_inner_available.py new file mode 100644 index 0000000..b21957d --- /dev/null +++ b/unikraft_cloud_platform/models/get_instance_logs200_response_data_instances_inner_available.py @@ -0,0 +1,89 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from typing import Optional, Set +from typing_extensions import Self + + +class GetInstanceLogs200ResponseDataInstancesInnerAvailable(BaseModel): + """ + Description of the log availability. + """ # noqa: E501 + + start: Optional[Annotated[int, Field(le=9223372036854775807, strict=True, ge=0)]] = Field( + default=None, description="The first byte offset that can be retrieved. " + ) + end: Optional[Annotated[int, Field(le=9223372036854775807, strict=True, ge=0)]] = Field( + default=None, description="The last byte offset that can be retrieved. " + ) + __properties: ClassVar[List[str]] = ["start", "end"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of GetInstanceLogs200ResponseDataInstancesInnerAvailable from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of GetInstanceLogs200ResponseDataInstancesInnerAvailable from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({"start": obj.get("start"), "end": obj.get("end")}) + return _obj diff --git a/unikraft_cloud_platform/models/get_instance_logs200_response_data_instances_inner_range.py b/unikraft_cloud_platform/models/get_instance_logs200_response_data_instances_inner_range.py new file mode 100644 index 0000000..b3705f6 --- /dev/null +++ b/unikraft_cloud_platform/models/get_instance_logs200_response_data_instances_inner_range.py @@ -0,0 +1,89 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from typing import Optional, Set +from typing_extensions import Self + + +class GetInstanceLogs200ResponseDataInstancesInnerRange(BaseModel): + """ + Description of the range that was returned. Useful for requests with offset relative to end. + """ # noqa: E501 + + start: Optional[Annotated[int, Field(le=9223372036854775807, strict=True, ge=0)]] = Field( + default=None, description="The first retrieved byte. " + ) + end: Optional[Annotated[int, Field(le=9223372036854775807, strict=True, ge=0)]] = Field( + default=None, description="The last retrieved byte. " + ) + __properties: ClassVar[List[str]] = ["start", "end"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of GetInstanceLogs200ResponseDataInstancesInnerRange from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of GetInstanceLogs200ResponseDataInstancesInnerRange from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({"start": obj.get("start"), "end": obj.get("end")}) + return _obj diff --git a/unikraft_cloud_platform/models/get_instance_logs_by_uuid_request_body.py b/unikraft_cloud_platform/models/get_instance_logs_by_uuid_request_body.py deleted file mode 100644 index af80aa1..0000000 --- a/unikraft_cloud_platform/models/get_instance_logs_by_uuid_request_body.py +++ /dev/null @@ -1,65 +0,0 @@ -from collections.abc import Mapping -from typing import Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -T = TypeVar("T", bound="GetInstanceLogsByUUIDRequestBody") - - -@_attrs_define -class GetInstanceLogsByUUIDRequestBody: - offset: Union[Unset, int] = UNSET - """ The byte offset of the log output to receive. A negative sign makes the - offset relative to the end of the log. """ - limit: Union[Unset, int] = UNSET - """ The amount of bytes to return at most. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - offset = self.offset - - limit = self.limit - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if offset is not UNSET: - field_dict["offset"] = offset - if limit is not UNSET: - field_dict["limit"] = limit - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - d = dict(src_dict) - offset = d.pop("offset", UNSET) - - limit = d.pop("limit", UNSET) - - get_instance_logs_by_uuid_request_body = cls( - offset=offset, - limit=limit, - ) - - get_instance_logs_by_uuid_request_body.additional_properties = d - return get_instance_logs_by_uuid_request_body - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/get_instance_logs_request.py b/unikraft_cloud_platform/models/get_instance_logs_request.py deleted file mode 100644 index 4b1d1e0..0000000 --- a/unikraft_cloud_platform/models/get_instance_logs_request.py +++ /dev/null @@ -1,92 +0,0 @@ -from collections.abc import Mapping -from typing import Any, TypeVar, Union -from uuid import UUID - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -T = TypeVar("T", bound="GetInstanceLogsRequest") - - -@_attrs_define -class GetInstanceLogsRequest: - """The request message for getting the logs of an instance by their UUID or - name. - - """ - - uuid: UUID - """ The UUID of the instance to retrieve logs for. Mutually exclusive with - name. """ - name: str - """ The name of the instance to retrieve logs for. Mutually exclusive with - UUID. """ - offset: Union[Unset, int] = UNSET - """ The byte offset of the log output to receive. A negative sign makes the - offset relative to the end of the log. """ - limit: Union[Unset, int] = UNSET - """ The amount of bytes to return at most. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - uuid = str(self.uuid) - - name = self.name - - offset = self.offset - - limit = self.limit - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update( - { - "uuid": uuid, - "name": name, - } - ) - if offset is not UNSET: - field_dict["offset"] = offset - if limit is not UNSET: - field_dict["limit"] = limit - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - d = dict(src_dict) - uuid = UUID(d.pop("uuid")) - - name = d.pop("name") - - offset = d.pop("offset", UNSET) - - limit = d.pop("limit", UNSET) - - get_instance_logs_request = cls( - uuid=uuid, - name=name, - offset=offset, - limit=limit, - ) - - get_instance_logs_request.additional_properties = d - return get_instance_logs_request - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/get_instance_logs_request_inner.py b/unikraft_cloud_platform/models/get_instance_logs_request_inner.py new file mode 100644 index 0000000..ff2cb55 --- /dev/null +++ b/unikraft_cloud_platform/models/get_instance_logs_request_inner.py @@ -0,0 +1,106 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from uuid import UUID +from typing import Optional, Set +from typing_extensions import Self + + +class GetInstanceLogsRequestInner(BaseModel): + """ + GetInstanceLogsRequestInner + """ # noqa: E501 + + uuid: Optional[UUID] = Field( + default=None, + description="The UUID of the instance to retrieve logs for. Note: This property is mutually exclusive with `name` and either `uuid` or `name` are required. ", + ) + name: Optional[Annotated[str, Field(strict=True, max_length=255)]] = Field( + default=None, + description="The name of the instance to retrieve logs for. Note: This property is mutually exclusive with `uuid` and either `uuid` or `name` are required. ", + ) + offset: Optional[Annotated[int, Field(le=2147483647, strict=True, ge=-2147483647)]] = Field( + default=-4096, + description="The byte offset of the log output to receive. A negative sign makes the offset relative to the end of the log. ", + ) + limit: Optional[Annotated[int, Field(le=16383, strict=True, ge=0)]] = Field( + default=4096, description="The amount of bytes to return at most. " + ) + __properties: ClassVar[List[str]] = ["uuid", "name", "offset", "limit"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of GetInstanceLogsRequestInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of GetInstanceLogsRequestInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "uuid": obj.get("uuid"), + "name": obj.get("name"), + "offset": obj.get("offset") if obj.get("offset") is not None else -4096, + "limit": obj.get("limit") if obj.get("limit") is not None else 4096, + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/get_instance_logs_response.py b/unikraft_cloud_platform/models/get_instance_logs_response.py deleted file mode 100644 index 66ab84b..0000000 --- a/unikraft_cloud_platform/models/get_instance_logs_response.py +++ /dev/null @@ -1,130 +0,0 @@ -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..models.response_status import ResponseStatus, check_response_status -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.get_instance_logs_response_data import GetInstanceLogsResponseData - from ..models.response_error import ResponseError - - -T = TypeVar("T", bound="GetInstanceLogsResponse") - - -@_attrs_define -class GetInstanceLogsResponse: - """The response message for getting the logs of an instance given its UUID(s) or - name(s). - - """ - - status: Union[Unset, ResponseStatus] = UNSET - """ The response status of an API request. """ - message: Union[Unset, str] = UNSET - """ An optional message providing additional information about the status. - This field is useful when the status is not `success`. """ - data: Union[Unset, "GetInstanceLogsResponseData"] = UNSET - errors: Union[Unset, list["ResponseError"]] = UNSET - """ A list of errors which may have occurred during the request. """ - op_time_us: Union[Unset, int] = UNSET - """ The operation time in microseconds. This is the time it took to process - the request and generate the response. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - status: Union[Unset, str] = UNSET - if not isinstance(self.status, Unset): - status = self.status - - message = self.message - - data: Union[Unset, dict[str, Any]] = UNSET - if not isinstance(self.data, Unset): - data = self.data.to_dict() - - errors: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.errors, Unset): - errors = [] - for errors_item_data in self.errors: - errors_item = errors_item_data.to_dict() - errors.append(errors_item) - - op_time_us = self.op_time_us - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if status is not UNSET: - field_dict["status"] = status - if message is not UNSET: - field_dict["message"] = message - if data is not UNSET: - field_dict["data"] = data - if errors is not UNSET: - field_dict["errors"] = errors - if op_time_us is not UNSET: - field_dict["op_time_us"] = op_time_us - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.get_instance_logs_response_data import GetInstanceLogsResponseData - from ..models.response_error import ResponseError - - d = dict(src_dict) - _status = d.pop("status", UNSET) - status: Union[Unset, ResponseStatus] - if isinstance(_status, Unset): - status = UNSET - else: - status = check_response_status(_status) - - message = d.pop("message", UNSET) - - _data = d.pop("data", UNSET) - data: Union[Unset, GetInstanceLogsResponseData] - if isinstance(_data, Unset): - data = UNSET - else: - data = GetInstanceLogsResponseData.from_dict(_data) - - errors = [] - _errors = d.pop("errors", UNSET) - for errors_item_data in _errors or []: - errors_item = ResponseError.from_dict(errors_item_data) - - errors.append(errors_item) - - op_time_us = d.pop("op_time_us", UNSET) - - get_instance_logs_response = cls( - status=status, - message=message, - data=data, - errors=errors, - op_time_us=op_time_us, - ) - - get_instance_logs_response.additional_properties = d - return get_instance_logs_response - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/get_instance_logs_response_available.py b/unikraft_cloud_platform/models/get_instance_logs_response_available.py deleted file mode 100644 index f4d87da..0000000 --- a/unikraft_cloud_platform/models/get_instance_logs_response_available.py +++ /dev/null @@ -1,64 +0,0 @@ -from collections.abc import Mapping -from typing import Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -T = TypeVar("T", bound="GetInstanceLogsResponseAvailable") - - -@_attrs_define -class GetInstanceLogsResponseAvailable: - start: Union[Unset, int] = UNSET - """ The first byte offset that can be retrieved. """ - end: Union[Unset, int] = UNSET - """ The last byte offset that can be retrieved. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - start = self.start - - end = self.end - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if start is not UNSET: - field_dict["start"] = start - if end is not UNSET: - field_dict["end"] = end - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - d = dict(src_dict) - start = d.pop("start", UNSET) - - end = d.pop("end", UNSET) - - get_instance_logs_response_available = cls( - start=start, - end=end, - ) - - get_instance_logs_response_available.additional_properties = d - return get_instance_logs_response_available - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/get_instance_logs_response_data.py b/unikraft_cloud_platform/models/get_instance_logs_response_data.py deleted file mode 100644 index 8362beb..0000000 --- a/unikraft_cloud_platform/models/get_instance_logs_response_data.py +++ /dev/null @@ -1,74 +0,0 @@ -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.get_instance_logs_response_logged_instance import GetInstanceLogsResponseLoggedInstance - - -T = TypeVar("T", bound="GetInstanceLogsResponseData") - - -@_attrs_define -class GetInstanceLogsResponseData: - instances: Union[Unset, list["GetInstanceLogsResponseLoggedInstance"]] = UNSET - """ The instance which this requested waited on. - - Note: only one instance can be specified in the request, so this will - always contain a single entry. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - instances: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.instances, Unset): - instances = [] - for instances_item_data in self.instances: - instances_item = instances_item_data.to_dict() - instances.append(instances_item) - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if instances is not UNSET: - field_dict["instances"] = instances - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.get_instance_logs_response_logged_instance import GetInstanceLogsResponseLoggedInstance - - d = dict(src_dict) - instances = [] - _instances = d.pop("instances", UNSET) - for instances_item_data in _instances or []: - instances_item = GetInstanceLogsResponseLoggedInstance.from_dict(instances_item_data) - - instances.append(instances_item) - - get_instance_logs_response_data = cls( - instances=instances, - ) - - get_instance_logs_response_data.additional_properties = d - return get_instance_logs_response_data - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/get_instance_logs_response_logged_instance.py b/unikraft_cloud_platform/models/get_instance_logs_response_logged_instance.py deleted file mode 100644 index ce61012..0000000 --- a/unikraft_cloud_platform/models/get_instance_logs_response_logged_instance.py +++ /dev/null @@ -1,159 +0,0 @@ -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union -from uuid import UUID - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..models.get_instance_logs_response_logged_instance_state import ( - GetInstanceLogsResponseLoggedInstanceState, - check_get_instance_logs_response_logged_instance_state, -) -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.get_instance_logs_response_available import GetInstanceLogsResponseAvailable - from ..models.get_instance_logs_response_range import GetInstanceLogsResponseRange - - -T = TypeVar("T", bound="GetInstanceLogsResponseLoggedInstance") - - -@_attrs_define -class GetInstanceLogsResponseLoggedInstance: - uuid: Union[Unset, UUID] = UNSET - """ The UUID of the instance. """ - name: Union[Unset, str] = UNSET - """ The name of the instance. """ - output: Union[Unset, str] = UNSET - """ Base64 encoded log output of the instance. """ - available: Union[Unset, "GetInstanceLogsResponseAvailable"] = UNSET - range_: Union[Unset, "GetInstanceLogsResponseRange"] = UNSET - state: Union[Unset, GetInstanceLogsResponseLoggedInstanceState] = UNSET - """ State of the instance when the logs were retrieved. """ - message: Union[Unset, str] = UNSET - """ An optional message providing additional information about the status. - This field is useful when the status is not `success`. """ - error: Union[Unset, int] = UNSET - """ An optional error code providing additional information about the status. - This field is useful when the status is not `success`. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - uuid: Union[Unset, str] = UNSET - if not isinstance(self.uuid, Unset): - uuid = str(self.uuid) - - name = self.name - - output = self.output - - available: Union[Unset, dict[str, Any]] = UNSET - if not isinstance(self.available, Unset): - available = self.available.to_dict() - - range_: Union[Unset, dict[str, Any]] = UNSET - if not isinstance(self.range_, Unset): - range_ = self.range_.to_dict() - - state: Union[Unset, str] = UNSET - if not isinstance(self.state, Unset): - state = self.state - - message = self.message - - error = self.error - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if uuid is not UNSET: - field_dict["uuid"] = uuid - if name is not UNSET: - field_dict["name"] = name - if output is not UNSET: - field_dict["output"] = output - if available is not UNSET: - field_dict["available"] = available - if range_ is not UNSET: - field_dict["range"] = range_ - if state is not UNSET: - field_dict["state"] = state - if message is not UNSET: - field_dict["message"] = message - if error is not UNSET: - field_dict["error"] = error - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.get_instance_logs_response_available import GetInstanceLogsResponseAvailable - from ..models.get_instance_logs_response_range import GetInstanceLogsResponseRange - - d = dict(src_dict) - _uuid = d.pop("uuid", UNSET) - uuid: Union[Unset, UUID] - if isinstance(_uuid, Unset): - uuid = UNSET - else: - uuid = UUID(_uuid) - - name = d.pop("name", UNSET) - - output = d.pop("output", UNSET) - - _available = d.pop("available", UNSET) - available: Union[Unset, GetInstanceLogsResponseAvailable] - if isinstance(_available, Unset): - available = UNSET - else: - available = GetInstanceLogsResponseAvailable.from_dict(_available) - - _range_ = d.pop("range", UNSET) - range_: Union[Unset, GetInstanceLogsResponseRange] - if isinstance(_range_, Unset): - range_ = UNSET - else: - range_ = GetInstanceLogsResponseRange.from_dict(_range_) - - _state = d.pop("state", UNSET) - state: Union[Unset, GetInstanceLogsResponseLoggedInstanceState] - if isinstance(_state, Unset): - state = UNSET - else: - state = check_get_instance_logs_response_logged_instance_state(_state) - - message = d.pop("message", UNSET) - - error = d.pop("error", UNSET) - - get_instance_logs_response_logged_instance = cls( - uuid=uuid, - name=name, - output=output, - available=available, - range_=range_, - state=state, - message=message, - error=error, - ) - - get_instance_logs_response_logged_instance.additional_properties = d - return get_instance_logs_response_logged_instance - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/get_instance_logs_response_logged_instance_state.py b/unikraft_cloud_platform/models/get_instance_logs_response_logged_instance_state.py deleted file mode 100644 index 673de0f..0000000 --- a/unikraft_cloud_platform/models/get_instance_logs_response_logged_instance_state.py +++ /dev/null @@ -1,22 +0,0 @@ -from typing import Literal, cast - -GetInstanceLogsResponseLoggedInstanceState = Literal[ - "draining", "running", "standby", "starting", "stopped", "stopping" -] - -GET_INSTANCE_LOGS_RESPONSE_LOGGED_INSTANCE_STATE_VALUES: set[GetInstanceLogsResponseLoggedInstanceState] = { - "draining", - "running", - "standby", - "starting", - "stopped", - "stopping", -} - - -def check_get_instance_logs_response_logged_instance_state(value: str) -> GetInstanceLogsResponseLoggedInstanceState: - if value in GET_INSTANCE_LOGS_RESPONSE_LOGGED_INSTANCE_STATE_VALUES: - return cast(GetInstanceLogsResponseLoggedInstanceState, value) - raise TypeError( - f"Unexpected value {value!r}. Expected one of {GET_INSTANCE_LOGS_RESPONSE_LOGGED_INSTANCE_STATE_VALUES!r}" - ) diff --git a/unikraft_cloud_platform/models/get_instance_logs_response_range.py b/unikraft_cloud_platform/models/get_instance_logs_response_range.py deleted file mode 100644 index ce7e106..0000000 --- a/unikraft_cloud_platform/models/get_instance_logs_response_range.py +++ /dev/null @@ -1,64 +0,0 @@ -from collections.abc import Mapping -from typing import Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -T = TypeVar("T", bound="GetInstanceLogsResponseRange") - - -@_attrs_define -class GetInstanceLogsResponseRange: - start: Union[Unset, int] = UNSET - """ The first retrieved byte. """ - end: Union[Unset, int] = UNSET - """ The last retrieved byte. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - start = self.start - - end = self.end - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if start is not UNSET: - field_dict["start"] = start - if end is not UNSET: - field_dict["end"] = end - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - d = dict(src_dict) - start = d.pop("start", UNSET) - - end = d.pop("end", UNSET) - - get_instance_logs_response_range = cls( - start=start, - end=end, - ) - - get_instance_logs_response_range.additional_properties = d - return get_instance_logs_response_range - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/get_instance_metrics200_response.py b/unikraft_cloud_platform/models/get_instance_metrics200_response.py new file mode 100644 index 0000000..1b61cc2 --- /dev/null +++ b/unikraft_cloud_platform/models/get_instance_metrics200_response.py @@ -0,0 +1,105 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from unikraft_cloud_platform.models.get_instance_metrics200_response_data import GetInstanceMetrics200ResponseData +from typing import Optional, Set +from typing_extensions import Self + + +class GetInstanceMetrics200Response(BaseModel): + """ + GetInstanceMetrics200Response + """ # noqa: E501 + + status: Optional[StrictStr] = Field(default=None, description="The status of the response. ") + data: Optional[GetInstanceMetrics200ResponseData] = None + __properties: ClassVar[List[str]] = ["status", "data"] + + @field_validator("status") + def status_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(["success", "failure"]): + raise ValueError("must be one of enum values ('success', 'failure')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of GetInstanceMetrics200Response from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of data + if self.data: + _dict["data"] = self.data.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of GetInstanceMetrics200Response from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "status": obj.get("status"), + "data": GetInstanceMetrics200ResponseData.from_dict(obj["data"]) + if obj.get("data") is not None + else None, + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/get_instance_metrics200_response_data.py b/unikraft_cloud_platform/models/get_instance_metrics200_response_data.py new file mode 100644 index 0000000..ffcde97 --- /dev/null +++ b/unikraft_cloud_platform/models/get_instance_metrics200_response_data.py @@ -0,0 +1,98 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from unikraft_cloud_platform.models.instance_metrics import InstanceMetrics +from typing import Optional, Set +from typing_extensions import Self + + +class GetInstanceMetrics200ResponseData(BaseModel): + """ + GetInstanceMetrics200ResponseData + """ # noqa: E501 + + instances: Optional[Annotated[List[InstanceMetrics], Field(max_length=253)]] = None + __properties: ClassVar[List[str]] = ["instances"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of GetInstanceMetrics200ResponseData from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in instances (list) + _items = [] + if self.instances: + for _item_instances in self.instances: + if _item_instances: + _items.append(_item_instances.to_dict()) + _dict["instances"] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of GetInstanceMetrics200ResponseData from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "instances": [InstanceMetrics.from_dict(_item) for _item in obj["instances"]] + if obj.get("instances") is not None + else None + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/get_instance_metrics_request_inner.py b/unikraft_cloud_platform/models/get_instance_metrics_request_inner.py new file mode 100644 index 0000000..31d8bd4 --- /dev/null +++ b/unikraft_cloud_platform/models/get_instance_metrics_request_inner.py @@ -0,0 +1,91 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from uuid import UUID +from typing import Optional, Set +from typing_extensions import Self + + +class GetInstanceMetricsRequestInner(BaseModel): + """ + GetInstanceMetricsRequestInner + """ # noqa: E501 + + uuid: UUID = Field( + description="The UUID of the instance to get the metrics for. Note: This property is mutually exclusive with `name` and either `uuid` or `name` are required. " + ) + name: Optional[Annotated[str, Field(strict=True, max_length=255)]] = Field( + default=None, + description="The name of the instance to get the metrics for. Note: This property is mutually exclusive with `uuid` and either `uuid` or `name` are required. ", + ) + __properties: ClassVar[List[str]] = ["uuid", "name"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of GetInstanceMetricsRequestInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of GetInstanceMetricsRequestInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({"uuid": obj.get("uuid"), "name": obj.get("name")}) + return _obj diff --git a/unikraft_cloud_platform/models/get_instance_metrics_response.py b/unikraft_cloud_platform/models/get_instance_metrics_response.py deleted file mode 100644 index 27df394..0000000 --- a/unikraft_cloud_platform/models/get_instance_metrics_response.py +++ /dev/null @@ -1,130 +0,0 @@ -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..models.response_status import ResponseStatus, check_response_status -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.get_instance_metrics_response_data import GetInstanceMetricsResponseData - from ..models.response_error import ResponseError - - -T = TypeVar("T", bound="GetInstanceMetricsResponse") - - -@_attrs_define -class GetInstanceMetricsResponse: - """The response message for getting the metrics of one or more instance(s) - given their UUID(s) or name(s). - - """ - - status: Union[Unset, ResponseStatus] = UNSET - """ The response status of an API request. """ - message: Union[Unset, str] = UNSET - """ An optional message providing additional information about the status. - This field is useful when the status is not `success`. """ - data: Union[Unset, "GetInstanceMetricsResponseData"] = UNSET - errors: Union[Unset, list["ResponseError"]] = UNSET - """ A list of errors which may have occurred during the request. """ - op_time_us: Union[Unset, int] = UNSET - """ The operation time in microseconds. This is the time it took to process - the request and generate the response. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - status: Union[Unset, str] = UNSET - if not isinstance(self.status, Unset): - status = self.status - - message = self.message - - data: Union[Unset, dict[str, Any]] = UNSET - if not isinstance(self.data, Unset): - data = self.data.to_dict() - - errors: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.errors, Unset): - errors = [] - for errors_item_data in self.errors: - errors_item = errors_item_data.to_dict() - errors.append(errors_item) - - op_time_us = self.op_time_us - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if status is not UNSET: - field_dict["status"] = status - if message is not UNSET: - field_dict["message"] = message - if data is not UNSET: - field_dict["data"] = data - if errors is not UNSET: - field_dict["errors"] = errors - if op_time_us is not UNSET: - field_dict["op_time_us"] = op_time_us - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.get_instance_metrics_response_data import GetInstanceMetricsResponseData - from ..models.response_error import ResponseError - - d = dict(src_dict) - _status = d.pop("status", UNSET) - status: Union[Unset, ResponseStatus] - if isinstance(_status, Unset): - status = UNSET - else: - status = check_response_status(_status) - - message = d.pop("message", UNSET) - - _data = d.pop("data", UNSET) - data: Union[Unset, GetInstanceMetricsResponseData] - if isinstance(_data, Unset): - data = UNSET - else: - data = GetInstanceMetricsResponseData.from_dict(_data) - - errors = [] - _errors = d.pop("errors", UNSET) - for errors_item_data in _errors or []: - errors_item = ResponseError.from_dict(errors_item_data) - - errors.append(errors_item) - - op_time_us = d.pop("op_time_us", UNSET) - - get_instance_metrics_response = cls( - status=status, - message=message, - data=data, - errors=errors, - op_time_us=op_time_us, - ) - - get_instance_metrics_response.additional_properties = d - return get_instance_metrics_response - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/get_instance_metrics_response_data.py b/unikraft_cloud_platform/models/get_instance_metrics_response_data.py deleted file mode 100644 index e697f0d..0000000 --- a/unikraft_cloud_platform/models/get_instance_metrics_response_data.py +++ /dev/null @@ -1,73 +0,0 @@ -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.get_instance_metrics_response_instance_metrics import GetInstanceMetricsResponseInstanceMetrics - - -T = TypeVar("T", bound="GetInstanceMetricsResponseData") - - -@_attrs_define -class GetInstanceMetricsResponseData: - instances: Union[Unset, list["GetInstanceMetricsResponseInstanceMetrics"]] = UNSET - """ The instance which this requested metrics for. Note: only one instance - can be specified in the request, so this will always contain a single - entry. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - instances: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.instances, Unset): - instances = [] - for instances_item_data in self.instances: - instances_item = instances_item_data.to_dict() - instances.append(instances_item) - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if instances is not UNSET: - field_dict["instances"] = instances - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.get_instance_metrics_response_instance_metrics import GetInstanceMetricsResponseInstanceMetrics - - d = dict(src_dict) - instances = [] - _instances = d.pop("instances", UNSET) - for instances_item_data in _instances or []: - instances_item = GetInstanceMetricsResponseInstanceMetrics.from_dict(instances_item_data) - - instances.append(instances_item) - - get_instance_metrics_response_data = cls( - instances=instances, - ) - - get_instance_metrics_response_data.additional_properties = d - return get_instance_metrics_response_data - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/get_instance_metrics_response_instance_metrics.py b/unikraft_cloud_platform/models/get_instance_metrics_response_instance_metrics.py deleted file mode 100644 index c7b5e88..0000000 --- a/unikraft_cloud_platform/models/get_instance_metrics_response_instance_metrics.py +++ /dev/null @@ -1,195 +0,0 @@ -from collections.abc import Mapping -from typing import Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -T = TypeVar("T", bound="GetInstanceMetricsResponseInstanceMetrics") - - -@_attrs_define -class GetInstanceMetricsResponseInstanceMetrics: - rss_bytes: Union[Unset, int] = UNSET - """ Resident set size of the VMM in bytes. - - The resident set size (RSS) specifies the amount of physical memory that - has been touched by the instance and is currently reserved for the - instance on the Unikraft Cloud server. The RSS grows until the instance - has touched all memory assigned to it via the memory_mb setting and may - also exceed this value as supporting services running outside the - instance acquire memory. The RSS is different from the current amount of - memory allocated by the application, which is likely to fluctuate over - the lifetime of the application. The RSS is not a cumulative metric. - When the instance is stopped rss goes down to 0. """ - cpu_time_ms: Union[Unset, int] = UNSET - """ Consumed CPU time in milliseconds. """ - boot_time_us: Union[Unset, int] = UNSET - """ The boot time of the instance in microseconds. We take a pragmatic - approach is to define the boot time. We calculate this as the difference - in time between the moment the virtualization toolstack is invoked to - respond to a VM boot request and the moment the OS starts executing user - code (i.e., the end of the guest OS boot process). This is essentially the - time that a user would experience in a deployment, minus the application - initialization time, which we leave out since it is independent from the - OS. """ - net_time_us: Union[Unset, int] = UNSET - """ This is the time it took for the user-level application to start listening - on a non-localhost port measured in microseconds. This is the time from - when the instance started until it reasonably ready to start responding to - network requests. This is useful for measuring the time it takes for the - instance to become operationally ready. """ - rx_bytes: Union[Unset, int] = UNSET - """ Total amount of bytes received from network. """ - rx_packets: Union[Unset, int] = UNSET - """ Total count of packets received from network. """ - tx_bytes: Union[Unset, int] = UNSET - """ Total amount of bytes transmitted over network. """ - tx_packets: Union[Unset, int] = UNSET - """ Total count of packets transmitted over network. """ - nconns: Union[Unset, int] = UNSET - """ Number of currently established inbound connections (non-HTTP). """ - nreqs: Union[Unset, int] = UNSET - """ Number of in-flight HTTP requests. """ - nqueued: Union[Unset, int] = UNSET - """ Number of queued inbound connections and HTTP requests. """ - ntotal: Union[Unset, int] = UNSET - """ Total number of inbound connections and HTTP requests handled. """ - message: Union[Unset, str] = UNSET - """ An optional message providing additional information about the status. - This field is useful when the status is not `success`. """ - error: Union[Unset, int] = UNSET - """ An optional error code providing additional information about the status. - This field is useful when the status is not `success`. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - rss_bytes = self.rss_bytes - - cpu_time_ms = self.cpu_time_ms - - boot_time_us = self.boot_time_us - - net_time_us = self.net_time_us - - rx_bytes = self.rx_bytes - - rx_packets = self.rx_packets - - tx_bytes = self.tx_bytes - - tx_packets = self.tx_packets - - nconns = self.nconns - - nreqs = self.nreqs - - nqueued = self.nqueued - - ntotal = self.ntotal - - message = self.message - - error = self.error - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if rss_bytes is not UNSET: - field_dict["rss_bytes"] = rss_bytes - if cpu_time_ms is not UNSET: - field_dict["cpu_time_ms"] = cpu_time_ms - if boot_time_us is not UNSET: - field_dict["boot_time_us"] = boot_time_us - if net_time_us is not UNSET: - field_dict["net_time_us"] = net_time_us - if rx_bytes is not UNSET: - field_dict["rx_bytes"] = rx_bytes - if rx_packets is not UNSET: - field_dict["rx_packets"] = rx_packets - if tx_bytes is not UNSET: - field_dict["tx_bytes"] = tx_bytes - if tx_packets is not UNSET: - field_dict["tx_packets"] = tx_packets - if nconns is not UNSET: - field_dict["nconns"] = nconns - if nreqs is not UNSET: - field_dict["nreqs"] = nreqs - if nqueued is not UNSET: - field_dict["nqueued"] = nqueued - if ntotal is not UNSET: - field_dict["ntotal"] = ntotal - if message is not UNSET: - field_dict["message"] = message - if error is not UNSET: - field_dict["error"] = error - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - d = dict(src_dict) - rss_bytes = d.pop("rss_bytes", UNSET) - - cpu_time_ms = d.pop("cpu_time_ms", UNSET) - - boot_time_us = d.pop("boot_time_us", UNSET) - - net_time_us = d.pop("net_time_us", UNSET) - - rx_bytes = d.pop("rx_bytes", UNSET) - - rx_packets = d.pop("rx_packets", UNSET) - - tx_bytes = d.pop("tx_bytes", UNSET) - - tx_packets = d.pop("tx_packets", UNSET) - - nconns = d.pop("nconns", UNSET) - - nreqs = d.pop("nreqs", UNSET) - - nqueued = d.pop("nqueued", UNSET) - - ntotal = d.pop("ntotal", UNSET) - - message = d.pop("message", UNSET) - - error = d.pop("error", UNSET) - - get_instance_metrics_response_instance_metrics = cls( - rss_bytes=rss_bytes, - cpu_time_ms=cpu_time_ms, - boot_time_us=boot_time_us, - net_time_us=net_time_us, - rx_bytes=rx_bytes, - rx_packets=rx_packets, - tx_bytes=tx_bytes, - tx_packets=tx_packets, - nconns=nconns, - nreqs=nreqs, - nqueued=nqueued, - ntotal=ntotal, - message=message, - error=error, - ) - - get_instance_metrics_response_instance_metrics.additional_properties = d - return get_instance_metrics_response_instance_metrics - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/get_instances200_response.py b/unikraft_cloud_platform/models/get_instances200_response.py new file mode 100644 index 0000000..546d395 --- /dev/null +++ b/unikraft_cloud_platform/models/get_instances200_response.py @@ -0,0 +1,103 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from unikraft_cloud_platform.models.get_instances200_response_data import GetInstances200ResponseData +from typing import Optional, Set +from typing_extensions import Self + + +class GetInstances200Response(BaseModel): + """ + GetInstances200Response + """ # noqa: E501 + + status: Optional[StrictStr] = Field(default=None, description="The status of the response. ") + data: Optional[GetInstances200ResponseData] = None + __properties: ClassVar[List[str]] = ["status", "data"] + + @field_validator("status") + def status_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(["success", "failure"]): + raise ValueError("must be one of enum values ('success', 'failure')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of GetInstances200Response from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of data + if self.data: + _dict["data"] = self.data.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of GetInstances200Response from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "status": obj.get("status"), + "data": GetInstances200ResponseData.from_dict(obj["data"]) if obj.get("data") is not None else None, + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/get_instances200_response_data.py b/unikraft_cloud_platform/models/get_instances200_response_data.py new file mode 100644 index 0000000..6e3faa8 --- /dev/null +++ b/unikraft_cloud_platform/models/get_instances200_response_data.py @@ -0,0 +1,98 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from unikraft_cloud_platform.models.instance import Instance +from typing import Optional, Set +from typing_extensions import Self + + +class GetInstances200ResponseData(BaseModel): + """ + GetInstances200ResponseData + """ # noqa: E501 + + instances: Optional[Annotated[List[Instance], Field(max_length=1)]] = None + __properties: ClassVar[List[str]] = ["instances"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of GetInstances200ResponseData from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in instances (list) + _items = [] + if self.instances: + for _item_instances in self.instances: + if _item_instances: + _items.append(_item_instances.to_dict()) + _dict["instances"] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of GetInstances200ResponseData from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "instances": [Instance.from_dict(_item) for _item in obj["instances"]] + if obj.get("instances") is not None + else None + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/get_instances_request_inner.py b/unikraft_cloud_platform/models/get_instances_request_inner.py new file mode 100644 index 0000000..08153aa --- /dev/null +++ b/unikraft_cloud_platform/models/get_instances_request_inner.py @@ -0,0 +1,92 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from uuid import UUID +from typing import Optional, Set +from typing_extensions import Self + + +class GetInstancesRequestInner(BaseModel): + """ + GetInstancesRequestInner + """ # noqa: E501 + + uuid: Optional[UUID] = Field( + default=None, + description="The UUID of the instance to get the status for. Note: This property is mutually exclusive with `name` and either `uuid` or `name` are required. ", + ) + name: Optional[Annotated[str, Field(strict=True, max_length=255)]] = Field( + default=None, + description="The name of the instance to get the status for. Note: This property is mutually exclusive with `uuid` and either `uuid` or `name` are required. ", + ) + __properties: ClassVar[List[str]] = ["uuid", "name"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of GetInstancesRequestInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of GetInstancesRequestInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({"uuid": obj.get("uuid"), "name": obj.get("name")}) + return _obj diff --git a/unikraft_cloud_platform/models/get_instances_response.py b/unikraft_cloud_platform/models/get_instances_response.py deleted file mode 100644 index ce4ba30..0000000 --- a/unikraft_cloud_platform/models/get_instances_response.py +++ /dev/null @@ -1,127 +0,0 @@ -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..models.response_status import ResponseStatus, check_response_status -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.get_instances_response_data import GetInstancesResponseData - from ..models.response_error import ResponseError - - -T = TypeVar("T", bound="GetInstancesResponse") - - -@_attrs_define -class GetInstancesResponse: - """The response after retrieving an instance by its name or UUID.""" - - status: Union[Unset, ResponseStatus] = UNSET - """ The response status of an API request. """ - message: Union[Unset, str] = UNSET - """ An optional message providing additional information about the status. - This field is useful when the status is not `success`. """ - data: Union[Unset, "GetInstancesResponseData"] = UNSET - errors: Union[Unset, list["ResponseError"]] = UNSET - """ A list of errors which may have occurred during the request. """ - op_time_us: Union[Unset, int] = UNSET - """ The operation time in microseconds. This is the time it took to process - the request and generate the response. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - status: Union[Unset, str] = UNSET - if not isinstance(self.status, Unset): - status = self.status - - message = self.message - - data: Union[Unset, dict[str, Any]] = UNSET - if not isinstance(self.data, Unset): - data = self.data.to_dict() - - errors: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.errors, Unset): - errors = [] - for errors_item_data in self.errors: - errors_item = errors_item_data.to_dict() - errors.append(errors_item) - - op_time_us = self.op_time_us - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if status is not UNSET: - field_dict["status"] = status - if message is not UNSET: - field_dict["message"] = message - if data is not UNSET: - field_dict["data"] = data - if errors is not UNSET: - field_dict["errors"] = errors - if op_time_us is not UNSET: - field_dict["op_time_us"] = op_time_us - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.get_instances_response_data import GetInstancesResponseData - from ..models.response_error import ResponseError - - d = dict(src_dict) - _status = d.pop("status", UNSET) - status: Union[Unset, ResponseStatus] - if isinstance(_status, Unset): - status = UNSET - else: - status = check_response_status(_status) - - message = d.pop("message", UNSET) - - _data = d.pop("data", UNSET) - data: Union[Unset, GetInstancesResponseData] - if isinstance(_data, Unset): - data = UNSET - else: - data = GetInstancesResponseData.from_dict(_data) - - errors = [] - _errors = d.pop("errors", UNSET) - for errors_item_data in _errors or []: - errors_item = ResponseError.from_dict(errors_item_data) - - errors.append(errors_item) - - op_time_us = d.pop("op_time_us", UNSET) - - get_instances_response = cls( - status=status, - message=message, - data=data, - errors=errors, - op_time_us=op_time_us, - ) - - get_instances_response.additional_properties = d - return get_instances_response - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/get_instances_response_data.py b/unikraft_cloud_platform/models/get_instances_response_data.py deleted file mode 100644 index 407bfa2..0000000 --- a/unikraft_cloud_platform/models/get_instances_response_data.py +++ /dev/null @@ -1,71 +0,0 @@ -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.instance import Instance - - -T = TypeVar("T", bound="GetInstancesResponseData") - - -@_attrs_define -class GetInstancesResponseData: - instances: Union[Unset, list["Instance"]] = UNSET - """ The instance(s) that were retrieved by the request. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - instances: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.instances, Unset): - instances = [] - for instances_item_data in self.instances: - instances_item = instances_item_data.to_dict() - instances.append(instances_item) - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if instances is not UNSET: - field_dict["instances"] = instances - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.instance import Instance - - d = dict(src_dict) - instances = [] - _instances = d.pop("instances", UNSET) - for instances_item_data in _instances or []: - instances_item = Instance.from_dict(instances_item_data) - - instances.append(instances_item) - - get_instances_response_data = cls( - instances=instances, - ) - - get_instances_response_data.additional_properties = d - return get_instances_response_data - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/get_quota_by_uuid200_response.py b/unikraft_cloud_platform/models/get_quota_by_uuid200_response.py new file mode 100644 index 0000000..5c35b52 --- /dev/null +++ b/unikraft_cloud_platform/models/get_quota_by_uuid200_response.py @@ -0,0 +1,103 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from unikraft_cloud_platform.models.get_quota_by_uuid200_response_data import GetQuotaByUuid200ResponseData +from typing import Optional, Set +from typing_extensions import Self + + +class GetQuotaByUuid200Response(BaseModel): + """ + GetQuotaByUuid200Response + """ # noqa: E501 + + status: Optional[StrictStr] = None + data: Optional[GetQuotaByUuid200ResponseData] = None + __properties: ClassVar[List[str]] = ["status", "data"] + + @field_validator("status") + def status_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(["success", "failure"]): + raise ValueError("must be one of enum values ('success', 'failure')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of GetQuotaByUuid200Response from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of data + if self.data: + _dict["data"] = self.data.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of GetQuotaByUuid200Response from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "status": obj.get("status"), + "data": GetQuotaByUuid200ResponseData.from_dict(obj["data"]) if obj.get("data") is not None else None, + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/get_quota_by_uuid200_response_data.py b/unikraft_cloud_platform/models/get_quota_by_uuid200_response_data.py new file mode 100644 index 0000000..e85d662 --- /dev/null +++ b/unikraft_cloud_platform/models/get_quota_by_uuid200_response_data.py @@ -0,0 +1,98 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from unikraft_cloud_platform.models.user_quota import UserQuota +from typing import Optional, Set +from typing_extensions import Self + + +class GetQuotaByUuid200ResponseData(BaseModel): + """ + GetQuotaByUuid200ResponseData + """ # noqa: E501 + + quotas: Optional[Annotated[List[UserQuota], Field(max_length=1)]] = None + __properties: ClassVar[List[str]] = ["quotas"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of GetQuotaByUuid200ResponseData from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in quotas (list) + _items = [] + if self.quotas: + for _item_quotas in self.quotas: + if _item_quotas: + _items.append(_item_quotas.to_dict()) + _dict["quotas"] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of GetQuotaByUuid200ResponseData from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "quotas": [UserQuota.from_dict(_item) for _item in obj["quotas"]] + if obj.get("quotas") is not None + else None + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/get_quotas200_response.py b/unikraft_cloud_platform/models/get_quotas200_response.py new file mode 100644 index 0000000..9f4f66a --- /dev/null +++ b/unikraft_cloud_platform/models/get_quotas200_response.py @@ -0,0 +1,103 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from unikraft_cloud_platform.models.get_quotas200_response_data import GetQuotas200ResponseData +from typing import Optional, Set +from typing_extensions import Self + + +class GetQuotas200Response(BaseModel): + """ + GetQuotas200Response + """ # noqa: E501 + + status: Optional[StrictStr] = None + data: Optional[GetQuotas200ResponseData] = None + __properties: ClassVar[List[str]] = ["status", "data"] + + @field_validator("status") + def status_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(["success", "failure"]): + raise ValueError("must be one of enum values ('success', 'failure')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of GetQuotas200Response from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of data + if self.data: + _dict["data"] = self.data.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of GetQuotas200Response from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "status": obj.get("status"), + "data": GetQuotas200ResponseData.from_dict(obj["data"]) if obj.get("data") is not None else None, + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/get_quotas200_response_data.py b/unikraft_cloud_platform/models/get_quotas200_response_data.py new file mode 100644 index 0000000..7af4c3c --- /dev/null +++ b/unikraft_cloud_platform/models/get_quotas200_response_data.py @@ -0,0 +1,98 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from unikraft_cloud_platform.models.user_quota import UserQuota +from typing import Optional, Set +from typing_extensions import Self + + +class GetQuotas200ResponseData(BaseModel): + """ + GetQuotas200ResponseData + """ # noqa: E501 + + quotas: Optional[Annotated[List[UserQuota], Field(max_length=253)]] = None + __properties: ClassVar[List[str]] = ["quotas"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of GetQuotas200ResponseData from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in quotas (list) + _items = [] + if self.quotas: + for _item_quotas in self.quotas: + if _item_quotas: + _items.append(_item_quotas.to_dict()) + _dict["quotas"] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of GetQuotas200ResponseData from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "quotas": [UserQuota.from_dict(_item) for _item in obj["quotas"]] + if obj.get("quotas") is not None + else None + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/get_service_by_uuid200_response.py b/unikraft_cloud_platform/models/get_service_by_uuid200_response.py new file mode 100644 index 0000000..56da29e --- /dev/null +++ b/unikraft_cloud_platform/models/get_service_by_uuid200_response.py @@ -0,0 +1,103 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from unikraft_cloud_platform.models.get_service_by_uuid200_response_data import GetServiceByUuid200ResponseData +from typing import Optional, Set +from typing_extensions import Self + + +class GetServiceByUuid200Response(BaseModel): + """ + GetServiceByUuid200Response + """ # noqa: E501 + + status: Optional[StrictStr] = None + data: Optional[GetServiceByUuid200ResponseData] = None + __properties: ClassVar[List[str]] = ["status", "data"] + + @field_validator("status") + def status_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(["success", "failure"]): + raise ValueError("must be one of enum values ('success', 'failure')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of GetServiceByUuid200Response from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of data + if self.data: + _dict["data"] = self.data.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of GetServiceByUuid200Response from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "status": obj.get("status"), + "data": GetServiceByUuid200ResponseData.from_dict(obj["data"]) if obj.get("data") is not None else None, + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/get_service_by_uuid200_response_data.py b/unikraft_cloud_platform/models/get_service_by_uuid200_response_data.py new file mode 100644 index 0000000..2478948 --- /dev/null +++ b/unikraft_cloud_platform/models/get_service_by_uuid200_response_data.py @@ -0,0 +1,102 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from unikraft_cloud_platform.models.get_services200_response_data_service_groups_inner import ( + GetServices200ResponseDataServiceGroupsInner, +) +from typing import Optional, Set +from typing_extensions import Self + + +class GetServiceByUuid200ResponseData(BaseModel): + """ + GetServiceByUuid200ResponseData + """ # noqa: E501 + + service_groups: Optional[Annotated[List[GetServices200ResponseDataServiceGroupsInner], Field(max_length=1)]] = None + __properties: ClassVar[List[str]] = ["service_groups"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of GetServiceByUuid200ResponseData from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in service_groups (list) + _items = [] + if self.service_groups: + for _item_service_groups in self.service_groups: + if _item_service_groups: + _items.append(_item_service_groups.to_dict()) + _dict["service_groups"] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of GetServiceByUuid200ResponseData from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "service_groups": [ + GetServices200ResponseDataServiceGroupsInner.from_dict(_item) for _item in obj["service_groups"] + ] + if obj.get("service_groups") is not None + else None + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/get_service_groups_response.py b/unikraft_cloud_platform/models/get_service_groups_response.py deleted file mode 100644 index 7508a96..0000000 --- a/unikraft_cloud_platform/models/get_service_groups_response.py +++ /dev/null @@ -1,130 +0,0 @@ -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..models.response_status import ResponseStatus, check_response_status -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.get_service_groups_response_data import GetServiceGroupsResponseData - from ..models.response_error import ResponseError - - -T = TypeVar("T", bound="GetServiceGroupsResponse") - - -@_attrs_define -class GetServiceGroupsResponse: - """The response message for getting one or more service group(s) given their - UUID(s) or name(s). - - """ - - status: Union[Unset, ResponseStatus] = UNSET - """ The response status of an API request. """ - message: Union[Unset, str] = UNSET - """ An optional message providing additional information about the status. - This field is useful when the status is not `success`. """ - data: Union[Unset, "GetServiceGroupsResponseData"] = UNSET - errors: Union[Unset, list["ResponseError"]] = UNSET - """ A list of errors which may have occurred during the request. """ - op_time_us: Union[Unset, int] = UNSET - """ The operation time in microseconds. This is the time it took to process - the request and generate the response. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - status: Union[Unset, str] = UNSET - if not isinstance(self.status, Unset): - status = self.status - - message = self.message - - data: Union[Unset, dict[str, Any]] = UNSET - if not isinstance(self.data, Unset): - data = self.data.to_dict() - - errors: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.errors, Unset): - errors = [] - for errors_item_data in self.errors: - errors_item = errors_item_data.to_dict() - errors.append(errors_item) - - op_time_us = self.op_time_us - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if status is not UNSET: - field_dict["status"] = status - if message is not UNSET: - field_dict["message"] = message - if data is not UNSET: - field_dict["data"] = data - if errors is not UNSET: - field_dict["errors"] = errors - if op_time_us is not UNSET: - field_dict["op_time_us"] = op_time_us - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.get_service_groups_response_data import GetServiceGroupsResponseData - from ..models.response_error import ResponseError - - d = dict(src_dict) - _status = d.pop("status", UNSET) - status: Union[Unset, ResponseStatus] - if isinstance(_status, Unset): - status = UNSET - else: - status = check_response_status(_status) - - message = d.pop("message", UNSET) - - _data = d.pop("data", UNSET) - data: Union[Unset, GetServiceGroupsResponseData] - if isinstance(_data, Unset): - data = UNSET - else: - data = GetServiceGroupsResponseData.from_dict(_data) - - errors = [] - _errors = d.pop("errors", UNSET) - for errors_item_data in _errors or []: - errors_item = ResponseError.from_dict(errors_item_data) - - errors.append(errors_item) - - op_time_us = d.pop("op_time_us", UNSET) - - get_service_groups_response = cls( - status=status, - message=message, - data=data, - errors=errors, - op_time_us=op_time_us, - ) - - get_service_groups_response.additional_properties = d - return get_service_groups_response - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/get_service_groups_response_data.py b/unikraft_cloud_platform/models/get_service_groups_response_data.py deleted file mode 100644 index 6893a81..0000000 --- a/unikraft_cloud_platform/models/get_service_groups_response_data.py +++ /dev/null @@ -1,71 +0,0 @@ -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.service_group import ServiceGroup - - -T = TypeVar("T", bound="GetServiceGroupsResponseData") - - -@_attrs_define -class GetServiceGroupsResponseData: - service_groups: Union[Unset, list["ServiceGroup"]] = UNSET - """ The service group(s) which were retrieved by the request. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - service_groups: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.service_groups, Unset): - service_groups = [] - for service_groups_item_data in self.service_groups: - service_groups_item = service_groups_item_data.to_dict() - service_groups.append(service_groups_item) - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if service_groups is not UNSET: - field_dict["service_groups"] = service_groups - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.service_group import ServiceGroup - - d = dict(src_dict) - service_groups = [] - _service_groups = d.pop("service_groups", UNSET) - for service_groups_item_data in _service_groups or []: - service_groups_item = ServiceGroup.from_dict(service_groups_item_data) - - service_groups.append(service_groups_item) - - get_service_groups_response_data = cls( - service_groups=service_groups, - ) - - get_service_groups_response_data.additional_properties = d - return get_service_groups_response_data - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/get_services200_response.py b/unikraft_cloud_platform/models/get_services200_response.py new file mode 100644 index 0000000..4be0798 --- /dev/null +++ b/unikraft_cloud_platform/models/get_services200_response.py @@ -0,0 +1,103 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from unikraft_cloud_platform.models.get_services200_response_data import GetServices200ResponseData +from typing import Optional, Set +from typing_extensions import Self + + +class GetServices200Response(BaseModel): + """ + GetServices200Response + """ # noqa: E501 + + status: Optional[StrictStr] = None + data: Optional[GetServices200ResponseData] = None + __properties: ClassVar[List[str]] = ["status", "data"] + + @field_validator("status") + def status_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(["success", "failure"]): + raise ValueError("must be one of enum values ('success', 'failure')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of GetServices200Response from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of data + if self.data: + _dict["data"] = self.data.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of GetServices200Response from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "status": obj.get("status"), + "data": GetServices200ResponseData.from_dict(obj["data"]) if obj.get("data") is not None else None, + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/get_services200_response_data.py b/unikraft_cloud_platform/models/get_services200_response_data.py new file mode 100644 index 0000000..cf2772c --- /dev/null +++ b/unikraft_cloud_platform/models/get_services200_response_data.py @@ -0,0 +1,104 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from unikraft_cloud_platform.models.get_services200_response_data_service_groups_inner import ( + GetServices200ResponseDataServiceGroupsInner, +) +from typing import Optional, Set +from typing_extensions import Self + + +class GetServices200ResponseData(BaseModel): + """ + GetServices200ResponseData + """ # noqa: E501 + + service_groups: Optional[Annotated[List[GetServices200ResponseDataServiceGroupsInner], Field(max_length=253)]] = ( + None + ) + __properties: ClassVar[List[str]] = ["service_groups"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of GetServices200ResponseData from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in service_groups (list) + _items = [] + if self.service_groups: + for _item_service_groups in self.service_groups: + if _item_service_groups: + _items.append(_item_service_groups.to_dict()) + _dict["service_groups"] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of GetServices200ResponseData from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "service_groups": [ + GetServices200ResponseDataServiceGroupsInner.from_dict(_item) for _item in obj["service_groups"] + ] + if obj.get("service_groups") is not None + else None + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/get_services200_response_data_service_groups_inner.py b/unikraft_cloud_platform/models/get_services200_response_data_service_groups_inner.py new file mode 100644 index 0000000..28fd992 --- /dev/null +++ b/unikraft_cloud_platform/models/get_services200_response_data_service_groups_inner.py @@ -0,0 +1,186 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from datetime import datetime +from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from uuid import UUID +from unikraft_cloud_platform.models.create_instance_request_service_group_domains_inner import ( + CreateInstanceRequestServiceGroupDomainsInner, +) +from unikraft_cloud_platform.models.get_services200_response_data_service_groups_inner_instances_inner import ( + GetServices200ResponseDataServiceGroupsInnerInstancesInner, +) +from unikraft_cloud_platform.models.service_mapping import ServiceMapping +from typing import Optional, Set +from typing_extensions import Self + + +class GetServices200ResponseDataServiceGroupsInner(BaseModel): + """ + GetServices200ResponseDataServiceGroupsInner + """ # noqa: E501 + + status: Optional[StrictStr] = Field(default=None, description="The status of the response. ") + uuid: Optional[UUID] = Field(default=None, description="The UUID of the service. ") + name: Optional[Annotated[str, Field(strict=True, max_length=255)]] = Field( + default=None, description="The name of the service. " + ) + created_at: Optional[datetime] = Field(default=None, description="Date and time of creation in ISO8601. ") + persistent: Optional[StrictBool] = Field( + default=None, description="Indicates if the service will stay alive even after the last instance detached. " + ) + autoscale: Optional[StrictBool] = Field( + default=None, + description="Indicates if the service has [autoscale](https://unikraft.cloud/docs/api/v1/autoscale) enabled. ", + ) + soft_limit: Optional[Annotated[int, Field(le=65535, strict=True, ge=1)]] = Field( + default=None, + description="Per-instance connection [soft limit](https://unikraft.cloud/docs/api/v1/services/#limits). ", + ) + hard_limit: Optional[Annotated[int, Field(le=65535, strict=True, ge=1)]] = Field( + default=None, + description="Per-instance connection [hard limit](https://unikraft.cloud/docs/api/v1/services/#limits). ", + ) + services: Optional[Annotated[List[ServiceMapping], Field(max_length=253)]] = Field( + default=None, description="Description of published network services. " + ) + domains: Optional[Annotated[List[CreateInstanceRequestServiceGroupDomainsInner], Field(max_length=253)]] = None + instances: Optional[ + Annotated[List[GetServices200ResponseDataServiceGroupsInnerInstancesInner], Field(max_length=253)] + ] = Field(default=None, description="Instances attached to this service") + __properties: ClassVar[List[str]] = [ + "status", + "uuid", + "name", + "created_at", + "persistent", + "autoscale", + "soft_limit", + "hard_limit", + "services", + "domains", + "instances", + ] + + @field_validator("status") + def status_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(["success", "error"]): + raise ValueError("must be one of enum values ('success', 'error')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of GetServices200ResponseDataServiceGroupsInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in services (list) + _items = [] + if self.services: + for _item_services in self.services: + if _item_services: + _items.append(_item_services.to_dict()) + _dict["services"] = _items + # override the default output from pydantic by calling `to_dict()` of each item in domains (list) + _items = [] + if self.domains: + for _item_domains in self.domains: + if _item_domains: + _items.append(_item_domains.to_dict()) + _dict["domains"] = _items + # override the default output from pydantic by calling `to_dict()` of each item in instances (list) + _items = [] + if self.instances: + for _item_instances in self.instances: + if _item_instances: + _items.append(_item_instances.to_dict()) + _dict["instances"] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of GetServices200ResponseDataServiceGroupsInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "status": obj.get("status"), + "uuid": obj.get("uuid"), + "name": obj.get("name"), + "created_at": obj.get("created_at"), + "persistent": obj.get("persistent"), + "autoscale": obj.get("autoscale"), + "soft_limit": obj.get("soft_limit"), + "hard_limit": obj.get("hard_limit"), + "services": [ServiceMapping.from_dict(_item) for _item in obj["services"]] + if obj.get("services") is not None + else None, + "domains": [CreateInstanceRequestServiceGroupDomainsInner.from_dict(_item) for _item in obj["domains"]] + if obj.get("domains") is not None + else None, + "instances": [ + GetServices200ResponseDataServiceGroupsInnerInstancesInner.from_dict(_item) + for _item in obj["instances"] + ] + if obj.get("instances") is not None + else None, + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/get_services200_response_data_service_groups_inner_instances_inner.py b/unikraft_cloud_platform/models/get_services200_response_data_service_groups_inner_instances_inner.py new file mode 100644 index 0000000..93b52d6 --- /dev/null +++ b/unikraft_cloud_platform/models/get_services200_response_data_service_groups_inner_instances_inner.py @@ -0,0 +1,88 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from uuid import UUID +from typing import Optional, Set +from typing_extensions import Self + + +class GetServices200ResponseDataServiceGroupsInnerInstancesInner(BaseModel): + """ + GetServices200ResponseDataServiceGroupsInnerInstancesInner + """ # noqa: E501 + + uuid: Optional[UUID] = Field(default=None, description="The UUID of the instance. ") + name: Optional[Annotated[str, Field(strict=True, max_length=255)]] = Field( + default=None, description="The name of the instance. " + ) + __properties: ClassVar[List[str]] = ["uuid", "name"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of GetServices200ResponseDataServiceGroupsInnerInstancesInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of GetServices200ResponseDataServiceGroupsInnerInstancesInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({"uuid": obj.get("uuid"), "name": obj.get("name")}) + return _obj diff --git a/unikraft_cloud_platform/models/get_services_request_inner.py b/unikraft_cloud_platform/models/get_services_request_inner.py new file mode 100644 index 0000000..cc006ee --- /dev/null +++ b/unikraft_cloud_platform/models/get_services_request_inner.py @@ -0,0 +1,92 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from uuid import UUID +from typing import Optional, Set +from typing_extensions import Self + + +class GetServicesRequestInner(BaseModel): + """ + GetServicesRequestInner + """ # noqa: E501 + + uuid: Optional[UUID] = Field( + default=None, + description="The UUID of the service to get the status for. Note: This property is mutually exclusive with `name` and either `uuid` or `name` are required. ", + ) + name: Optional[Annotated[str, Field(strict=True, max_length=255)]] = Field( + default=None, + description="The name of the service to get the status for. Note: This property is mutually exclusive with `uuid` and either `uuid` or `name` are required. ", + ) + __properties: ClassVar[List[str]] = ["uuid", "name"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of GetServicesRequestInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of GetServicesRequestInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({"uuid": obj.get("uuid"), "name": obj.get("name")}) + return _obj diff --git a/unikraft_cloud_platform/models/get_volumes200_response.py b/unikraft_cloud_platform/models/get_volumes200_response.py new file mode 100644 index 0000000..de5a071 --- /dev/null +++ b/unikraft_cloud_platform/models/get_volumes200_response.py @@ -0,0 +1,103 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from unikraft_cloud_platform.models.get_volumes200_response_data import GetVolumes200ResponseData +from typing import Optional, Set +from typing_extensions import Self + + +class GetVolumes200Response(BaseModel): + """ + GetVolumes200Response + """ # noqa: E501 + + status: Optional[StrictStr] = None + data: Optional[GetVolumes200ResponseData] = None + __properties: ClassVar[List[str]] = ["status", "data"] + + @field_validator("status") + def status_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(["success", "failure"]): + raise ValueError("must be one of enum values ('success', 'failure')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of GetVolumes200Response from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of data + if self.data: + _dict["data"] = self.data.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of GetVolumes200Response from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "status": obj.get("status"), + "data": GetVolumes200ResponseData.from_dict(obj["data"]) if obj.get("data") is not None else None, + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/get_volumes200_response_data.py b/unikraft_cloud_platform/models/get_volumes200_response_data.py new file mode 100644 index 0000000..60039da --- /dev/null +++ b/unikraft_cloud_platform/models/get_volumes200_response_data.py @@ -0,0 +1,98 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from unikraft_cloud_platform.models.volume import Volume +from typing import Optional, Set +from typing_extensions import Self + + +class GetVolumes200ResponseData(BaseModel): + """ + GetVolumes200ResponseData + """ # noqa: E501 + + volumes: Optional[Annotated[List[Volume], Field(max_length=253)]] = None + __properties: ClassVar[List[str]] = ["volumes"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of GetVolumes200ResponseData from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in volumes (list) + _items = [] + if self.volumes: + for _item_volumes in self.volumes: + if _item_volumes: + _items.append(_item_volumes.to_dict()) + _dict["volumes"] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of GetVolumes200ResponseData from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "volumes": [Volume.from_dict(_item) for _item in obj["volumes"]] + if obj.get("volumes") is not None + else None + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/get_volumes_request_inner.py b/unikraft_cloud_platform/models/get_volumes_request_inner.py new file mode 100644 index 0000000..8ecbaec --- /dev/null +++ b/unikraft_cloud_platform/models/get_volumes_request_inner.py @@ -0,0 +1,92 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from uuid import UUID +from typing import Optional, Set +from typing_extensions import Self + + +class GetVolumesRequestInner(BaseModel): + """ + GetVolumesRequestInner + """ # noqa: E501 + + uuid: Optional[UUID] = Field( + default=None, + description="The UUID of the volume to get the status for. Note: This property is mutually exclusive with `name` and either `uuid` or `name` are required. ", + ) + name: Optional[Annotated[str, Field(strict=True, max_length=255)]] = Field( + default=None, + description="The name of the volume to get the status for. Note: This property is mutually exclusive with `uuid` and either `uuid` or `name` are required. ", + ) + __properties: ClassVar[List[str]] = ["uuid", "name"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of GetVolumesRequestInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of GetVolumesRequestInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({"uuid": obj.get("uuid"), "name": obj.get("name")}) + return _obj diff --git a/unikraft_cloud_platform/models/get_volumes_response.py b/unikraft_cloud_platform/models/get_volumes_response.py deleted file mode 100644 index bc5aab1..0000000 --- a/unikraft_cloud_platform/models/get_volumes_response.py +++ /dev/null @@ -1,120 +0,0 @@ -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..models.response_status import ResponseStatus, check_response_status -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.get_volumes_response_data import GetVolumesResponseData - from ..models.response_error import ResponseError - - -T = TypeVar("T", bound="GetVolumesResponse") - - -@_attrs_define -class GetVolumesResponse: - """The response message for getting one or more volume(s) given their - UUID(s) or name(s). - - """ - - status: Union[Unset, ResponseStatus] = UNSET - """ The response status of an API request. """ - data: Union[Unset, "GetVolumesResponseData"] = UNSET - errors: Union[Unset, list["ResponseError"]] = UNSET - """ A list of errors which may have occurred during the request. """ - op_time_us: Union[Unset, int] = UNSET - """ The operation time in microseconds. This is the time it took to process - the request and generate the response. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - status: Union[Unset, str] = UNSET - if not isinstance(self.status, Unset): - status = self.status - - data: Union[Unset, dict[str, Any]] = UNSET - if not isinstance(self.data, Unset): - data = self.data.to_dict() - - errors: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.errors, Unset): - errors = [] - for errors_item_data in self.errors: - errors_item = errors_item_data.to_dict() - errors.append(errors_item) - - op_time_us = self.op_time_us - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if status is not UNSET: - field_dict["status"] = status - if data is not UNSET: - field_dict["data"] = data - if errors is not UNSET: - field_dict["errors"] = errors - if op_time_us is not UNSET: - field_dict["op_time_us"] = op_time_us - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.get_volumes_response_data import GetVolumesResponseData - from ..models.response_error import ResponseError - - d = dict(src_dict) - _status = d.pop("status", UNSET) - status: Union[Unset, ResponseStatus] - if isinstance(_status, Unset): - status = UNSET - else: - status = check_response_status(_status) - - _data = d.pop("data", UNSET) - data: Union[Unset, GetVolumesResponseData] - if isinstance(_data, Unset): - data = UNSET - else: - data = GetVolumesResponseData.from_dict(_data) - - errors = [] - _errors = d.pop("errors", UNSET) - for errors_item_data in _errors or []: - errors_item = ResponseError.from_dict(errors_item_data) - - errors.append(errors_item) - - op_time_us = d.pop("op_time_us", UNSET) - - get_volumes_response = cls( - status=status, - data=data, - errors=errors, - op_time_us=op_time_us, - ) - - get_volumes_response.additional_properties = d - return get_volumes_response - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/get_volumes_response_data.py b/unikraft_cloud_platform/models/get_volumes_response_data.py deleted file mode 100644 index 1c17923..0000000 --- a/unikraft_cloud_platform/models/get_volumes_response_data.py +++ /dev/null @@ -1,71 +0,0 @@ -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.volume import Volume - - -T = TypeVar("T", bound="GetVolumesResponseData") - - -@_attrs_define -class GetVolumesResponseData: - volumes: Union[Unset, list["Volume"]] = UNSET - """ The volume(s) which were retrieved by the request. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - volumes: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.volumes, Unset): - volumes = [] - for volumes_item_data in self.volumes: - volumes_item = volumes_item_data.to_dict() - volumes.append(volumes_item) - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if volumes is not UNSET: - field_dict["volumes"] = volumes - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.volume import Volume - - d = dict(src_dict) - volumes = [] - _volumes = d.pop("volumes", UNSET) - for volumes_item_data in _volumes or []: - volumes_item = Volume.from_dict(volumes_item_data) - - volumes.append(volumes_item) - - get_volumes_response_data = cls( - volumes=volumes, - ) - - get_volumes_response_data.additional_properties = d - return get_volumes_response_data - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/healthz_response.py b/unikraft_cloud_platform/models/healthz_response.py deleted file mode 100644 index d0ffa29..0000000 --- a/unikraft_cloud_platform/models/healthz_response.py +++ /dev/null @@ -1,127 +0,0 @@ -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..models.response_status import ResponseStatus, check_response_status -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.healthz_response_data import HealthzResponseData - from ..models.response_error import ResponseError - - -T = TypeVar("T", bound="HealthzResponse") - - -@_attrs_define -class HealthzResponse: - """The response message for a health check of the platform.""" - - status: Union[Unset, ResponseStatus] = UNSET - """ The response status of an API request. """ - message: Union[Unset, str] = UNSET - """ An optional message providing additional information about the response. """ - errors: Union[Unset, list["ResponseError"]] = UNSET - """ A list of errors which may have occurred during the request. """ - data: Union[Unset, "HealthzResponseData"] = UNSET - """ For now, no additional data is returned by the health check. """ - op_time_us: Union[Unset, int] = UNSET - """ The operation time in microseconds. This is the time it took to process - the request and generate the response. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - status: Union[Unset, str] = UNSET - if not isinstance(self.status, Unset): - status = self.status - - message = self.message - - errors: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.errors, Unset): - errors = [] - for errors_item_data in self.errors: - errors_item = errors_item_data.to_dict() - errors.append(errors_item) - - data: Union[Unset, dict[str, Any]] = UNSET - if not isinstance(self.data, Unset): - data = self.data.to_dict() - - op_time_us = self.op_time_us - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if status is not UNSET: - field_dict["status"] = status - if message is not UNSET: - field_dict["message"] = message - if errors is not UNSET: - field_dict["errors"] = errors - if data is not UNSET: - field_dict["data"] = data - if op_time_us is not UNSET: - field_dict["op_time_us"] = op_time_us - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.healthz_response_data import HealthzResponseData - from ..models.response_error import ResponseError - - d = dict(src_dict) - _status = d.pop("status", UNSET) - status: Union[Unset, ResponseStatus] - if isinstance(_status, Unset): - status = UNSET - else: - status = check_response_status(_status) - - message = d.pop("message", UNSET) - - errors = [] - _errors = d.pop("errors", UNSET) - for errors_item_data in _errors or []: - errors_item = ResponseError.from_dict(errors_item_data) - - errors.append(errors_item) - - _data = d.pop("data", UNSET) - data: Union[Unset, HealthzResponseData] - if isinstance(_data, Unset): - data = UNSET - else: - data = HealthzResponseData.from_dict(_data) - - op_time_us = d.pop("op_time_us", UNSET) - - healthz_response = cls( - status=status, - message=message, - errors=errors, - data=data, - op_time_us=op_time_us, - ) - - healthz_response.additional_properties = d - return healthz_response - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/healthz_response_data.py b/unikraft_cloud_platform/models/healthz_response_data.py deleted file mode 100644 index f42c467..0000000 --- a/unikraft_cloud_platform/models/healthz_response_data.py +++ /dev/null @@ -1,69 +0,0 @@ -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.healthz_response_data_services import HealthzResponseDataServices - - -T = TypeVar("T", bound="HealthzResponseData") - - -@_attrs_define -class HealthzResponseData: - """For now, no additional data is returned by the health check.""" - - services: Union[Unset, "HealthzResponseDataServices"] = UNSET - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - services: Union[Unset, dict[str, Any]] = UNSET - if not isinstance(self.services, Unset): - services = self.services.to_dict() - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if services is not UNSET: - field_dict["services"] = services - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.healthz_response_data_services import HealthzResponseDataServices - - d = dict(src_dict) - _services = d.pop("services", UNSET) - services: Union[Unset, HealthzResponseDataServices] - if isinstance(_services, Unset): - services = UNSET - else: - services = HealthzResponseDataServices.from_dict(_services) - - healthz_response_data = cls( - services=services, - ) - - healthz_response_data.additional_properties = d - return healthz_response_data - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/healthz_response_data_services.py b/unikraft_cloud_platform/models/healthz_response_data_services.py deleted file mode 100644 index 676afe4..0000000 --- a/unikraft_cloud_platform/models/healthz_response_data_services.py +++ /dev/null @@ -1,42 +0,0 @@ -from collections.abc import Mapping -from typing import Any, TypeVar - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -T = TypeVar("T", bound="HealthzResponseDataServices") - - -@_attrs_define -class HealthzResponseDataServices: - additional_properties: dict[str, str] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - d = dict(src_dict) - healthz_response_data_services = cls() - - healthz_response_data_services.additional_properties = d - return healthz_response_data_services - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> str: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: str) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/image.py b/unikraft_cloud_platform/models/image.py index 72e77c9..4dd047c 100644 --- a/unikraft_cloud_platform/models/image.py +++ b/unikraft_cloud_platform/models/image.py @@ -1,228 +1,149 @@ -import datetime -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union, cast - -from attrs import define as _attrs_define -from attrs import field as _attrs_field -from dateutil.parser import isoparse - -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.image_labels import ImageLabels - from ..models.object_ import Object - - -T = TypeVar("T", bound="Image") - - -@_attrs_define -class Image: - tag: Union[Unset, str] = UNSET - """ The canonical name of the image is known as the "tag". """ - digest: Union[Unset, str] = UNSET - """ The digest of the image is a unique identifier of the image manifest which - is a string representation including the hashing algorithm and the hash - value separated by a colon. """ - description: Union[Unset, str] = UNSET - """ A description of the image. """ - created_at: Union[Unset, datetime.datetime] = UNSET - """ When the image was created. """ - arch: Union[Unset, str] = UNSET - """ The architecture of the image. """ - entrypoint: Union[Unset, list[str]] = UNSET - """ The entrypoint of the image is the command that is run when the image is - started. """ - cmd: Union[Unset, list[str]] = UNSET - """ The command to run when the image is started. """ - env: Union[Unset, list[str]] = UNSET - """ The environment variables to set when the image is started. """ - ports: Union[Unset, list[str]] = UNSET - """ Documented port mappings for the image. """ - volumes: Union[Unset, list[str]] = UNSET - """ Documented volumes for the image. """ - labels: Union[Unset, "ImageLabels"] = UNSET - """ Labels are key-value pairs. """ - workdir: Union[Unset, str] = UNSET - """ The working directory for the image is the directory that is set as the - current working directory when the image is started. """ - kernel: Union[Unset, "Object"] = UNSET - """ An object is a single component of an image which is external and can be - uniquely identified by its digest. """ - auxiliary_roms: Union[Unset, list["Object"]] = UNSET - """ List of auxiliary ROMs that are used by the image. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - tag = self.tag - - digest = self.digest - - description = self.description - - created_at: Union[Unset, str] = UNSET - if not isinstance(self.created_at, Unset): - created_at = self.created_at.isoformat() - - arch = self.arch - - entrypoint: Union[Unset, list[str]] = UNSET - if not isinstance(self.entrypoint, Unset): - entrypoint = self.entrypoint - - cmd: Union[Unset, list[str]] = UNSET - if not isinstance(self.cmd, Unset): - cmd = self.cmd - - env: Union[Unset, list[str]] = UNSET - if not isinstance(self.env, Unset): - env = self.env - - ports: Union[Unset, list[str]] = UNSET - if not isinstance(self.ports, Unset): - ports = self.ports - - volumes: Union[Unset, list[str]] = UNSET - if not isinstance(self.volumes, Unset): - volumes = self.volumes - - labels: Union[Unset, dict[str, Any]] = UNSET - if not isinstance(self.labels, Unset): - labels = self.labels.to_dict() - - workdir = self.workdir - - kernel: Union[Unset, dict[str, Any]] = UNSET - if not isinstance(self.kernel, Unset): - kernel = self.kernel.to_dict() - - auxiliary_roms: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.auxiliary_roms, Unset): - auxiliary_roms = [] - for auxiliary_roms_item_data in self.auxiliary_roms: - auxiliary_roms_item = auxiliary_roms_item_data.to_dict() - auxiliary_roms.append(auxiliary_roms_item) - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if tag is not UNSET: - field_dict["tag"] = tag - if digest is not UNSET: - field_dict["digest"] = digest - if description is not UNSET: - field_dict["description"] = description - if created_at is not UNSET: - field_dict["created_at"] = created_at - if arch is not UNSET: - field_dict["arch"] = arch - if entrypoint is not UNSET: - field_dict["entrypoint"] = entrypoint - if cmd is not UNSET: - field_dict["cmd"] = cmd - if env is not UNSET: - field_dict["env"] = env - if ports is not UNSET: - field_dict["ports"] = ports - if volumes is not UNSET: - field_dict["volumes"] = volumes - if labels is not UNSET: - field_dict["labels"] = labels - if workdir is not UNSET: - field_dict["workdir"] = workdir - if kernel is not UNSET: - field_dict["kernel"] = kernel - if auxiliary_roms is not UNSET: - field_dict["auxiliary_roms"] = auxiliary_roms - - return field_dict +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictBool, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from typing import Optional, Set +from typing_extensions import Self + + +class Image(BaseModel): + """ + Image + """ # noqa: E501 + + digest: Optional[Annotated[str, Field(strict=True, max_length=8388608)]] = Field( + default=None, description="Image digest to uniquely identify this image. " + ) + tags: Optional[ + Annotated[List[Annotated[str, Field(strict=True, max_length=8388608)]], Field(min_length=0, max_length=253)] + ] = Field(default=None, description="Tags referencing this image.") + initrd: Optional[StrictBool] = Field( + default=None, description="Indicates if the image comes with an init ramdisk. " + ) + size_in_bytes: Optional[Annotated[int, Field(le=9223372036854775807, strict=True, ge=0)]] = Field( + default=None, description="Total size of the image on disk in bytes including the initrd, if any. " + ) + args: Optional[Annotated[str, Field(strict=True, max_length=8388608)]] = Field( + default=None, + description="Default application arguments of the image. Dismissed if the instance specifies application arguments. ", + ) + kernel_args: Optional[Annotated[str, Field(strict=True, max_length=8388608)]] = Field( + default=None, + description="Unikraft kernel arguments hardcoded into the image. Prepended to the kernel arguments set by Unikraft Cloud. ", + ) + labels: Optional[Dict[str, Annotated[str, Field(strict=True, max_length=8388608)]]] = Field( + default=None, + description="Key value pairs of image labels (e.g., used as defaults for instance configuration). ", + ) + __properties: ClassVar[List[str]] = ["digest", "tags", "initrd", "size_in_bytes", "args", "kernel_args", "labels"] + + @field_validator("digest") + def digest_validate_regular_expression(cls, value): + """Validates the regular expression""" + if value is None: + return value + + if not re.match(r"^[a-zA-Z_0-9]+[a-zA-Z_0-9]+((:|@sha256:)[a-zA-Z_0-9]+)?$", value): + raise ValueError( + r"must validate the regular expression /^[a-zA-Z_0-9]+[a-zA-Z_0-9]+((:|@sha256:)[a-zA-Z_0-9]+)?$/" + ) + return value + + @field_validator("args") + def args_validate_regular_expression(cls, value): + """Validates the regular expression""" + if value is None: + return value + + if not re.match(r"^([a-zA-Z0-9=_-]+ *)*$", value): + raise ValueError(r"must validate the regular expression /^([a-zA-Z0-9=_-]+ *)*$/") + return value + + @field_validator("kernel_args") + def kernel_args_validate_regular_expression(cls, value): + """Validates the regular expression""" + if value is None: + return value + + if not re.match(r"^([a-zA-Z0-9=_-]+ *)*$", value): + raise ValueError(r"must validate the regular expression /^([a-zA-Z0-9=_-]+ *)*$/") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.image_labels import ImageLabels - from ..models.object_ import Object - - d = dict(src_dict) - tag = d.pop("tag", UNSET) - - digest = d.pop("digest", UNSET) - - description = d.pop("description", UNSET) - - _created_at = d.pop("created_at", UNSET) - created_at: Union[Unset, datetime.datetime] - if isinstance(_created_at, Unset): - created_at = UNSET - else: - created_at = isoparse(_created_at) - - arch = d.pop("arch", UNSET) - - entrypoint = cast(list[str], d.pop("entrypoint", UNSET)) - - cmd = cast(list[str], d.pop("cmd", UNSET)) - - env = cast(list[str], d.pop("env", UNSET)) - - ports = cast(list[str], d.pop("ports", UNSET)) - - volumes = cast(list[str], d.pop("volumes", UNSET)) - - _labels = d.pop("labels", UNSET) - labels: Union[Unset, ImageLabels] - if isinstance(_labels, Unset): - labels = UNSET - else: - labels = ImageLabels.from_dict(_labels) - - workdir = d.pop("workdir", UNSET) - - _kernel = d.pop("kernel", UNSET) - kernel: Union[Unset, Object] - if isinstance(_kernel, Unset): - kernel = UNSET - else: - kernel = Object.from_dict(_kernel) - - auxiliary_roms = [] - _auxiliary_roms = d.pop("auxiliary_roms", UNSET) - for auxiliary_roms_item_data in _auxiliary_roms or []: - auxiliary_roms_item = Object.from_dict(auxiliary_roms_item_data) - - auxiliary_roms.append(auxiliary_roms_item) - - image = cls( - tag=tag, - digest=digest, - description=description, - created_at=created_at, - arch=arch, - entrypoint=entrypoint, - cmd=cmd, - env=env, - ports=ports, - volumes=volumes, - labels=labels, - workdir=workdir, - kernel=kernel, - auxiliary_roms=auxiliary_roms, + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of Image from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, ) + return _dict - image.additional_properties = d - return image - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of Image from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "digest": obj.get("digest"), + "tags": obj.get("tags"), + "initrd": obj.get("initrd"), + "size_in_bytes": obj.get("size_in_bytes"), + "args": obj.get("args"), + "kernel_args": obj.get("kernel_args"), + "labels": obj.get("labels"), + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/image_labels.py b/unikraft_cloud_platform/models/image_labels.py deleted file mode 100644 index 053ab09..0000000 --- a/unikraft_cloud_platform/models/image_labels.py +++ /dev/null @@ -1,44 +0,0 @@ -from collections.abc import Mapping -from typing import Any, TypeVar - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -T = TypeVar("T", bound="ImageLabels") - - -@_attrs_define -class ImageLabels: - """Labels are key-value pairs.""" - - additional_properties: dict[str, str] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - d = dict(src_dict) - image_labels = cls() - - image_labels.additional_properties = d - return image_labels - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> str: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: str) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/instance.py b/unikraft_cloud_platform/models/instance.py index b38f322..a8926fe 100644 --- a/unikraft_cloud_platform/models/instance.py +++ b/unikraft_cloud_platform/models/instance.py @@ -1,603 +1,376 @@ -import datetime -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union, cast -from uuid import UUID - -from attrs import define as _attrs_define -from attrs import field as _attrs_field -from dateutil.parser import isoparse - -from ..models.instance_restart_policy import InstanceRestartPolicy, check_instance_restart_policy -from ..models.instance_state import InstanceState, check_instance_state -from ..models.response_status import ResponseStatus, check_response_status -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.instance_env import InstanceEnv - from ..models.instance_instance_service_group import InstanceInstanceServiceGroup - from ..models.instance_instance_volume import InstanceInstanceVolume - from ..models.instance_network_interface import InstanceNetworkInterface - from ..models.instance_scale_to_zero import InstanceScaleToZero - - -T = TypeVar("T", bound="Instance") - - -@_attrs_define -class Instance: - """An instance is a unikernel virtual machine running an application.""" - - uuid: Union[Unset, UUID] = UNSET - """ The UUID of the instance. - - This is a unique identifier for the instance that is generated when the - instance is created. The UUID is used to reference the instance in API - calls and can be used to identify the instance in all API calls that - require an instance identifier. """ - name: Union[Unset, str] = UNSET - """ The name of the instance. - - This is a human-readable name that can be used to identify the instance. - The name must be unique within the context of your account. The name can - also be used to identify the instance in API calls. """ - created_at: Union[Unset, datetime.datetime] = UNSET - """ The time the instance was created. """ - state: Union[Unset, InstanceState] = UNSET - """ The state of the instance. This indicates the current state of the - instance, such as whether it is running, stopped, or in an error state. """ - private_fqdn: Union[Unset, str] = UNSET - """ The internal hostname of the instance. This address can be used privately - within the Unikraft Cloud network to access the instance. It is not - accessible from the public Internet. """ - image: Union[Unset, str] = UNSET - """ The image used to create the instance. This is a reference to the - Unikraft image that was used to create the instance. """ - memory_mb: Union[Unset, int] = UNSET - """ The amount of memory in megabytes allocated for the instance. This is the - total amount of memory that is available to the instance for its - operations. """ - vcpus: Union[Unset, int] = UNSET - """ The number of vCPUs allocated for the instance. This is the total - number of virtual CPUs that are available to the instance for its - operations. """ - args: Union[Unset, list[str]] = UNSET - """ The arguments passed to the instance when it was started. This is a - list of command-line arguments that were provided to the instance at - startup. These arguments can be used to configure the behavior of the - instance and its applications. """ - env: Union[Unset, "InstanceEnv"] = UNSET - """ Environment variables set for the instance. """ - start_count: Union[Unset, int] = UNSET - """ The total number of times the instance has been started. This is a counter - that increments each time the instance is started, regardless of whether it - was manually stopped or restarted. This can be useful for tracking the - usage of the instance over time and/or for debugging purposes. """ - restart_count: Union[Unset, int] = UNSET - """ The total number of times the instance has been restarted. This is a counter - that increments each time the instance has been restarted. This can be - useful for tracking the usage of the instance over time and/or for - debugging purposes. """ - started_at: Union[Unset, datetime.datetime] = UNSET - """ The time the instance was started. This is the timestamp when the - instance was last started. """ - stopped_at: Union[Unset, datetime.datetime] = UNSET - """ The time the instance was stopped. This is the timestamp when the - instance was last stopped. If the instance is currently running, this - field will be empty. """ - uptime_ms: Union[Unset, int] = UNSET - """ The total amount of time the instance has been running in milliseconds. """ - vmm_start_time_us: Union[Unset, int] = UNSET - """ (Developer-only). The time taken between the main controller and the - beginning of execution of the VMM (Virtual Machine Monitor) measured in - microseconds. This field is primarily used for debugging and performance - analysis purposes. """ - vmm_load_time_us: Union[Unset, int] = UNSET - """ (Developer-only). The time it took the VMM (Virtual Machine Monitor) to - load the instance's kernel and initramfs into VM memory measured in - microseconds. This field is primarily used for debugging and performance - analysis purposes. """ - vmm_ready_time_us: Union[Unset, int] = UNSET - """ (Developer-only). The time taken for the VMM (Virtual Machine Monitor) to - become ready to execute the instance measured in microseconds. This is the - time from when the VMM started until it was ready to execute the instance's - code. This field is primarily used for debugging and performance analysis - purposes. """ - boot_time_us: Union[Unset, int] = UNSET - """ The boot time of the instance in microseconds. We take a pragmatic - approach is to define the boot time. We calculate this as the difference - in time between the moment the virtualization toolstack is invoked to - respond to a VM boot request and the moment the OS starts executing user - code (i.e., the end of the guest OS boot process). This is essentially the - time that a user would experience in a deployment, minus the application - initialization time, which we leave out since it is independent from the - OS. """ - net_time_us: Union[Unset, int] = UNSET - """ This is the time it took for the user-level application to start listening - on a non-localhost port measured in microseconds. This is the time from - when the instance started until it reasonably ready to start responding to - network requests. This is useful for measuring the time it takes for the - instance to become operationally ready. """ - stop_reason: Union[Unset, int] = UNSET - """ The instance stop reason. - - Provides reason as to why an instance is stopped or in the process of - shutting down. The stop reason is a bitmask that tells you the origin of - the shutdown: - - | Bit | 4 | 3 | 2 | 1 | 0 (LSB) | - |---------|------------|------------|------------|------------|--------------| - | Purpose | [F]orced | [U]ser | [P]latform | [A]pp | [K]ernel | - - - **Forced**: This was a force stop. A forced stop does not give the - instance a chance to perform a clean shutdown. Bits 0 - (Kernel) and 1 (App) can thus never be set for forced - shutdowns. Consequently, there won't be an `exit_code` or - `stop_code`. - - **User**: Stop initiated by user, e.g. via an API call. - - **Platform**: Stop initiated by platform, e.g. an autoscale policy. - - **App**: The Application exited. The `exit_code` field will be set. - - **Kernel**: The kernel exited. The `stop_code` field will be set. - - For example, the stop reason will contain the following values in the given - scenarios: - - | Value | Bitmask | Aliases | Scenario | - |-------|---------|---------|----------| - | 28 | `11100` | `FUP--` | Forced user-initiated shutdown. | - | 15 | `01111` | `-UPAK` | Regular user-initiated shutdown. The application and kernel have exited. The - exit_code and stop_code indicate if the application and kernel shut down cleanly. | - | 13 | `01101` | `-UP-K` | The user initiated a shutdown but the application was forcefully killed by the - kernel during shutdown. This can be the case if the image does not support a clean application exit or the - application crashed after receiving a termination signal. The exit_code won’t be present in this scenario. | - | 7 | `00111` | `--PAK` | Unikraft Cloud initiated the shutdown, for example, due to scale-to-zero. The - application and kernel have exited. The exit_code and stop_code indicate if the application and kernel shut down - cleanly. | - | 3 | `00011` | `---AK` | The application exited. The exit_code and stop_code indicate if the application - and kernel shut down cleanly. | - | 1 | `00001` | `----K` | The instance likely expierenced a fatal crash and the stop_code contains more - information about the cause of the crash. | - | 0 | `00000` | `-----` | The stop reason is unknown. | """ - exit_code: Union[Unset, int] = UNSET - """ The application exit code. - - This is the code which the application returns upon leaving its main entry - point. The encoding of the exit code is application specific. See the - documentation of the application for more details. Usually, an exit code - of `0` indicates success / no failure. """ - stop_code: Union[Unset, int] = UNSET - """ The kernel stop code. - - This value encodes multiple details about the stop irrespective of the - application. - - ``` - MSB LSB - ┌──────────────┬──────────┬──────────┬───────────┬────────┐ - │ 31 ────── 24 │ 23 ── 16 │ 15 │ 14 ──── 8 │ 7 ── 0 │ - ├──────────────┼──────────┼──────────┼───────────┼────────┤ - │ reserved[^1] │ errno │ shutdown │ initlevel │ reason │ - └──────────────┴──────────┴──────────┴───────────┴────────┘ - ``` - - - **errno**: The application errno, using Linux's errno.h values. - (Optional, can be 0.) - - **shutdown**: Whether the shutdown originated from the inittable (0) or - from the termtable (1). - - **initlevel**: The initlevel at the time of the stop. - - **reason**: The reason for the stop. See `StopCodeReason`. - - [^1]: Reserved for future use. """ - restart_policy: Union[Unset, InstanceRestartPolicy] = UNSET - """ The restart configuration for the instance. - - When an instance stops either because the application exits or the instance - crashes, Unikraft Cloud can auto-restart your instance. Auto-restarts are - performed according to the restart policy configured for a particular - instance. - - The policy can have the following values: - - | Policy | Description | - |--------------|-------------| - | `never` | Never restart the instance (default). | - | `always` | Always restart the instance when the stop is initiated from within the instance (i.e., the - application exits or the instance crashes). | - | `on-failure` | Only restart the instance if it crashes. | - - When an instance stops, the stop reason and the configured restart policy - are evaluated to decide if a restart should be performed. Unikraft Cloud - uses an exponential back-off delay (immediate, 5s, 10s, 20s, 40s, ..., 5m) - to slow down restarts in tight crash loops. If an instance runs without - problems for 10s the back-off delay is reset and the restart sequence ends. - - The `restart.attempt` attribute reported in counts the number of restarts - performed in the current sequence. The `restart.next_at` field indicates - when the next restart will take place if a back-off delay is in effect. - - A manual start or stop of the instance aborts the restart sequence and - resets the back-off delay. """ - scale_to_zero: Union[Unset, "InstanceScaleToZero"] = UNSET - """ Scale-to-zero defines the configuration for scaling the instance to zero. - When an instance is scaled-to-zero it can be either stopped (and fully - shutdown) or paused wherein the state of the instance is preserved (e.g., RAM - contents) and the instance can be resumed later without losing its state, - i.e. "stateful". """ - volumes: Union[Unset, list["InstanceInstanceVolume"]] = UNSET - """ The list of volumes attached to the instance. """ - service_group: Union[Unset, "InstanceInstanceServiceGroup"] = UNSET - """ The service group configuration for the instance. - - This is a reference to the service group that the instance is part of. The - service group defines the services (e.g. ports, connection handling) that - the instance exposes and how they are configured. """ - network_interfaces: Union[Unset, list["InstanceNetworkInterface"]] = UNSET - """ The network interfaces of the instance. """ - tags: Union[Unset, list[str]] = UNSET - """ The tags associated with the instance. """ - status: Union[Unset, ResponseStatus] = UNSET - """ The response status of an API request. """ - message: Union[Unset, str] = UNSET - """ An optional message providing additional information about the status. - This field is only set when this message object is used as a response - message, and is useful when the status is not `success`. """ - error: Union[Unset, int] = UNSET - """ An optional error code providing additional information about the status. - This field is only set when this message object is used as a response - message, and is useful when the status is not `success`. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - uuid: Union[Unset, str] = UNSET - if not isinstance(self.uuid, Unset): - uuid = str(self.uuid) - - name = self.name - - created_at: Union[Unset, str] = UNSET - if not isinstance(self.created_at, Unset): - created_at = self.created_at.isoformat() - - state: Union[Unset, str] = UNSET - if not isinstance(self.state, Unset): - state = self.state - - private_fqdn = self.private_fqdn - - image = self.image - - memory_mb = self.memory_mb - - vcpus = self.vcpus - - args: Union[Unset, list[str]] = UNSET - if not isinstance(self.args, Unset): - args = self.args - - env: Union[Unset, dict[str, Any]] = UNSET - if not isinstance(self.env, Unset): - env = self.env.to_dict() - - start_count = self.start_count - - restart_count = self.restart_count - - started_at: Union[Unset, str] = UNSET - if not isinstance(self.started_at, Unset): - started_at = self.started_at.isoformat() - - stopped_at: Union[Unset, str] = UNSET - if not isinstance(self.stopped_at, Unset): - stopped_at = self.stopped_at.isoformat() - - uptime_ms = self.uptime_ms - - vmm_start_time_us = self.vmm_start_time_us - - vmm_load_time_us = self.vmm_load_time_us - - vmm_ready_time_us = self.vmm_ready_time_us - - boot_time_us = self.boot_time_us - - net_time_us = self.net_time_us - - stop_reason = self.stop_reason - - exit_code = self.exit_code +# coding: utf-8 - stop_code = self.stop_code +""" +Unikraft Cloud Platform - restart_policy: Union[Unset, str] = UNSET - if not isinstance(self.restart_policy, Unset): - restart_policy = self.restart_policy +This is the API of the Unikraft Cloud Platform. - scale_to_zero: Union[Unset, dict[str, Any]] = UNSET - if not isinstance(self.scale_to_zero, Unset): - scale_to_zero = self.scale_to_zero.to_dict() +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) - volumes: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.volumes, Unset): - volumes = [] - for volumes_item_data in self.volumes: - volumes_item = volumes_item_data.to_dict() - volumes.append(volumes_item) +Do not edit the class manually. +""" # noqa: E501 - service_group: Union[Unset, dict[str, Any]] = UNSET - if not isinstance(self.service_group, Unset): - service_group = self.service_group.to_dict() +from __future__ import annotations +import pprint +import re # noqa: F401 +import json - network_interfaces: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.network_interfaces, Unset): - network_interfaces = [] - for network_interfaces_item_data in self.network_interfaces: - network_interfaces_item = network_interfaces_item_data.to_dict() - network_interfaces.append(network_interfaces_item) - - tags: Union[Unset, list[str]] = UNSET - if not isinstance(self.tags, Unset): - tags = self.tags - - status: Union[Unset, str] = UNSET - if not isinstance(self.status, Unset): - status = self.status - - message = self.message - - error = self.error - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if uuid is not UNSET: - field_dict["uuid"] = uuid - if name is not UNSET: - field_dict["name"] = name - if created_at is not UNSET: - field_dict["created_at"] = created_at - if state is not UNSET: - field_dict["state"] = state - if private_fqdn is not UNSET: - field_dict["private_fqdn"] = private_fqdn - if image is not UNSET: - field_dict["image"] = image - if memory_mb is not UNSET: - field_dict["memory_mb"] = memory_mb - if vcpus is not UNSET: - field_dict["vcpus"] = vcpus - if args is not UNSET: - field_dict["args"] = args - if env is not UNSET: - field_dict["env"] = env - if start_count is not UNSET: - field_dict["start_count"] = start_count - if restart_count is not UNSET: - field_dict["restart_count"] = restart_count - if started_at is not UNSET: - field_dict["started_at"] = started_at - if stopped_at is not UNSET: - field_dict["stopped_at"] = stopped_at - if uptime_ms is not UNSET: - field_dict["uptime_ms"] = uptime_ms - if vmm_start_time_us is not UNSET: - field_dict["vmm_start_time_us"] = vmm_start_time_us - if vmm_load_time_us is not UNSET: - field_dict["vmm_load_time_us"] = vmm_load_time_us - if vmm_ready_time_us is not UNSET: - field_dict["vmm_ready_time_us"] = vmm_ready_time_us - if boot_time_us is not UNSET: - field_dict["boot_time_us"] = boot_time_us - if net_time_us is not UNSET: - field_dict["net_time_us"] = net_time_us - if stop_reason is not UNSET: - field_dict["stop_reason"] = stop_reason - if exit_code is not UNSET: - field_dict["exit_code"] = exit_code - if stop_code is not UNSET: - field_dict["stop_code"] = stop_code - if restart_policy is not UNSET: - field_dict["restart_policy"] = restart_policy - if scale_to_zero is not UNSET: - field_dict["scale_to_zero"] = scale_to_zero - if volumes is not UNSET: - field_dict["volumes"] = volumes - if service_group is not UNSET: - field_dict["service_group"] = service_group - if network_interfaces is not UNSET: - field_dict["network_interfaces"] = network_interfaces - if tags is not UNSET: - field_dict["tags"] = tags - if status is not UNSET: - field_dict["status"] = status - if message is not UNSET: - field_dict["message"] = message - if error is not UNSET: - field_dict["error"] = error - - return field_dict +from datetime import datetime +from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from uuid import UUID +from unikraft_cloud_platform.models.create_instance_request_env import CreateInstanceRequestEnv +from unikraft_cloud_platform.models.create_instance_request_scale_to_zero import CreateInstanceRequestScaleToZero +from unikraft_cloud_platform.models.create_instance_request_volumes_inner import CreateInstanceRequestVolumesInner +from unikraft_cloud_platform.models.instance_network_interfaces_inner import InstanceNetworkInterfacesInner +from unikraft_cloud_platform.models.instance_restart import InstanceRestart +from unikraft_cloud_platform.models.instance_service_group import InstanceServiceGroup +from unikraft_cloud_platform.models.instance_snapshot import InstanceSnapshot +from typing import Optional, Set +from typing_extensions import Self + + +class Instance(BaseModel): + """ + An application instance. + """ # noqa: E501 + + status: Optional[StrictStr] = Field( + default=None, description="The status of the response. Note: Not when listing all existing instances. " + ) + uuid: Optional[UUID] = Field(default=None, description="The UUID of the instance. ") + name: Optional[Annotated[str, Field(strict=True, max_length=255)]] = Field( + default=None, + description="The name of the instance. The instance will receive a DNS entry in your private network of the form `.internal`. Note: If no name is specified a random name of the form `-X` is auto-generated, where `` is the application name taken from `image` (e.g., `myapp` for `../myapp:latest`) and `X` is a 5 character long random alphanumeric suffix. ", + ) + created_at: Optional[datetime] = Field(default=None, description="Date and time of creation in ISO8601. ") + state: Optional[StrictStr] = Field( + default=None, + description="An instance can be in one of the following states: State | Description ----------|------------ `stopped` | The instance is not running and does not count against live resource quotas. Connections cannot be established. `starting`| The instance is booting up. This usually takes just a few milliseconds. `running` | Your application's main entry point has been reached. `draining`| The instance is draining connections before shutting down. No new connections can be established. `stopping`| The instance is shutting down. `standby` | The instance has [scale-to-zero](https://unikraft.cloud/docs/api/v1/autoscale#scaletozero) enabled. The instance is not running, but will be automatically started when there are incoming requests. ", + ) + image: Optional[Annotated[str, Field(strict=True, max_length=8388608)]] = Field( + default=None, + description="Digest of the image that the instance uses. Note: The image tag (e.g., `latest`) is translated by Unikraft Cloud to the image digest that was assigned the tag at the time of instance creation. The image is pinned to this particular version. ", + ) + memory_mb: Optional[Annotated[int, Field(le=4096, strict=True, ge=16)]] = Field( + default=None, description="Amount of memory assigned to the instance in megabytes. " + ) + args: Optional[Annotated[List[Annotated[str, Field(strict=True, max_length=8388608)]], Field(max_length=253)]] = ( + Field(default=None, description="Application arguments. ") + ) + env: Optional[CreateInstanceRequestEnv] = None + start_count: Optional[Annotated[int, Field(le=4294967295, strict=True, ge=0)]] = Field( + default=None, description="Total number of times the instance has been started. " + ) + started_at: Optional[datetime] = Field(default=None, description="Date and time of last start in ISO8601. ") + stopped_at: Optional[datetime] = Field(default=None, description="If stopped, date and time of stop in ISO8601. ") + uptime_ms: Optional[Annotated[int, Field(le=9223372036854775807, strict=True, ge=0)]] = Field( + default=None, description="Total uptime in milliseconds. " + ) + rss_bytes: Optional[Annotated[int, Field(le=9223372036854775807, strict=True, ge=0)]] = Field( + default=None, + description="Resident set size (RSS) of the VMM in bytes (see [here](https://unikraft.cloud/docs/api/v1/instances/#metrics) for remarks on RSS). Note: Only with `metrics=true` query parameter. ", + ) + cpu_time_ms: Optional[Annotated[int, Field(le=9223372036854775807, strict=True, ge=0)]] = Field( + default=None, + description="Total consumed CPU time in milliseconds. Note: Only with `metrics=true` query parameter. ", + ) + nconns: Optional[Annotated[int, Field(le=65535, strict=True, ge=0)]] = Field( + default=None, + description="Number of currently established inbound connections (non-HTTP). Note: Only with `metrics=true` query parameter. ", + ) + nreqs: Optional[Annotated[int, Field(le=65535, strict=True, ge=0)]] = Field( + default=None, description="Number of in-flight HTTP requests. Note: Only with `metrics=true` query parameter. " + ) + nqueued: Optional[Annotated[int, Field(le=65535, strict=True, ge=0)]] = Field( + default=None, + description="Number of queued inbound connections and HTTP requests. Note: Only with `metrics=true` query parameter. ", + ) + ntotal: Optional[Annotated[int, Field(le=9223372036854775807, strict=True, ge=0)]] = Field( + default=None, + description="Total number of inbound connections and HTTP requests handled. Note: Only with `metrics=true` query parameter. ", + ) + vmm_start_time_us: Optional[Annotated[int, Field(le=4294967295, strict=True, ge=0)]] = Field( + default=None, + description="Time from start of instance to VMM process start in microseconds. Note: Only with Unikraft Cloud developer permissions. ", + ) + vmm_load_time_us: Optional[Annotated[int, Field(le=4294967295, strict=True, ge=0)]] = Field( + default=None, + description="Time from start of instance to finish loading of initrd and kernel into instance in microseconds. Note: Only with Unikraft Cloud developer permissions. ", + ) + vmm_ready_time_us: Optional[Annotated[int, Field(le=4294967295, strict=True, ge=0)]] = Field( + default=None, + description="Time from start of instance to entering instance execution in microseconds. Note: Only with Unikraft Cloud developer permissions. ", + ) + boot_time_us: Optional[Annotated[int, Field(le=4294967295, strict=True, ge=0)]] = Field( + default=None, description="Time from start of instance to finish booting of Unikraft in microseconds. " + ) + net_time_us: Optional[Annotated[int, Field(le=4294967295, strict=True, ge=0)]] = Field( + default=None, + description="Time from start of instance to first listen socket in microseconds. Note: Only with Unikraft Cloud developer permissions. ", + ) + stop_reason: Optional[Annotated[int, Field(le=255, strict=True, ge=0)]] = Field( + default=None, + description="Reason for ongoing or current stop (see [here](https://unikraft.cloud/docs/api/v1/instances/#stopreason)). ", + ) + exit_code: Optional[Annotated[int, Field(le=255, strict=True, ge=0)]] = Field( + default=None, description="Exit code of the application. " + ) + stop_code: Optional[Annotated[int, Field(le=4294967295, strict=True, ge=0)]] = Field( + default=None, + description="Stop code of the kernel (see [here](https://unikraft.cloud/docs/api/v1/instances/#stopreason)). ", + ) + restart_policy: Optional[StrictStr] = Field( + default="never", + description="When an instance stops either because the application exits or the instance crashes, Unikraft Cloud can auto-restart your instance. Auto-restarts are performed according to the restart policy configured for a particular instance. The policy can have the following values: Policy | Description -------------|------------ `always` | Always restart the instance when the stop is initiated from within the instance (i.e., the application exits or the instance crashes). `on-failure` | Only restart the instance if it crashes. `never` | Never restart the instance (default). ", + ) + restart: Optional[InstanceRestart] = None + restart_count: Optional[Annotated[int, Field(le=4294967295, strict=True, ge=0)]] = Field( + default=None, description="Total number of times the instance has been restarted by restart policy. " + ) + scale_to_zero: Optional[CreateInstanceRequestScaleToZero] = None + snapshot: Optional[InstanceSnapshot] = None + private_fqdn: Optional[Annotated[str, Field(strict=True, max_length=8388608)]] = Field( + default=None, + description="Fully-qualified domain name under which the instance is accessible in the private network. ", + ) + private_ip: Optional[Annotated[str, Field(strict=True, max_length=15)]] = Field( + default=None, + description="Private IPv4 of the instance for communication between instances of the same user. This is equivalent to the IPv4 address of the first network interface. ", + ) + service_group: Optional[InstanceServiceGroup] = None + volumes: Optional[Annotated[List[Optional[CreateInstanceRequestVolumesInner]], Field(max_length=253)]] = Field( + default=None, description="Description of [volumes](https://unikraft.cloud/docs/api/v1/volumes). " + ) + network_interfaces: Optional[Annotated[List[InstanceNetworkInterfacesInner], Field(max_length=253)]] = Field( + default=None, description="List of network interfaces attached to the instance. " + ) + __properties: ClassVar[List[str]] = [ + "status", + "uuid", + "name", + "created_at", + "state", + "image", + "memory_mb", + "args", + "env", + "start_count", + "started_at", + "stopped_at", + "uptime_ms", + "rss_bytes", + "cpu_time_ms", + "nconns", + "nreqs", + "nqueued", + "ntotal", + "vmm_start_time_us", + "vmm_load_time_us", + "vmm_ready_time_us", + "boot_time_us", + "net_time_us", + "stop_reason", + "exit_code", + "stop_code", + "restart_policy", + "restart", + "restart_count", + "scale_to_zero", + "snapshot", + "private_fqdn", + "private_ip", + "service_group", + "volumes", + "network_interfaces", + ] + + @field_validator("status") + def status_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(["success", "error"]): + raise ValueError("must be one of enum values ('success', 'error')") + return value + + @field_validator("state") + def state_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(["stopped", "starting", "running", "draining", "stopping", "standby"]): + raise ValueError( + "must be one of enum values ('stopped', 'starting', 'running', 'draining', 'stopping', 'standby')" + ) + return value + + @field_validator("image") + def image_validate_regular_expression(cls, value): + """Validates the regular expression""" + if value is None: + return value + + if not re.match( + r"^(?:(?=[^:\/]{1,253})(?!-)[a-zA-Z0-9-]{1,63}(? str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.instance_env import InstanceEnv - from ..models.instance_instance_service_group import InstanceInstanceServiceGroup - from ..models.instance_instance_volume import InstanceInstanceVolume - from ..models.instance_network_interface import InstanceNetworkInterface - from ..models.instance_scale_to_zero import InstanceScaleToZero - - d = dict(src_dict) - _uuid = d.pop("uuid", UNSET) - uuid: Union[Unset, UUID] - if isinstance(_uuid, Unset): - uuid = UNSET - else: - uuid = UUID(_uuid) - - name = d.pop("name", UNSET) - - _created_at = d.pop("created_at", UNSET) - created_at: Union[Unset, datetime.datetime] - if isinstance(_created_at, Unset): - created_at = UNSET - else: - created_at = isoparse(_created_at) - - _state = d.pop("state", UNSET) - state: Union[Unset, InstanceState] - if isinstance(_state, Unset): - state = UNSET - else: - state = check_instance_state(_state) - - private_fqdn = d.pop("private_fqdn", UNSET) - - image = d.pop("image", UNSET) - - memory_mb = d.pop("memory_mb", UNSET) - - vcpus = d.pop("vcpus", UNSET) - - args = cast(list[str], d.pop("args", UNSET)) - - _env = d.pop("env", UNSET) - env: Union[Unset, InstanceEnv] - if isinstance(_env, Unset): - env = UNSET - else: - env = InstanceEnv.from_dict(_env) - - start_count = d.pop("start_count", UNSET) - - restart_count = d.pop("restart_count", UNSET) - - _started_at = d.pop("started_at", UNSET) - started_at: Union[Unset, datetime.datetime] - if isinstance(_started_at, Unset): - started_at = UNSET - else: - started_at = isoparse(_started_at) - - _stopped_at = d.pop("stopped_at", UNSET) - stopped_at: Union[Unset, datetime.datetime] - if isinstance(_stopped_at, Unset): - stopped_at = UNSET - else: - stopped_at = isoparse(_stopped_at) - - uptime_ms = d.pop("uptime_ms", UNSET) - - vmm_start_time_us = d.pop("vmm_start_time_us", UNSET) - - vmm_load_time_us = d.pop("vmm_load_time_us", UNSET) - - vmm_ready_time_us = d.pop("vmm_ready_time_us", UNSET) - - boot_time_us = d.pop("boot_time_us", UNSET) - - net_time_us = d.pop("net_time_us", UNSET) - - stop_reason = d.pop("stop_reason", UNSET) - - exit_code = d.pop("exit_code", UNSET) - - stop_code = d.pop("stop_code", UNSET) - - _restart_policy = d.pop("restart_policy", UNSET) - restart_policy: Union[Unset, InstanceRestartPolicy] - if isinstance(_restart_policy, Unset): - restart_policy = UNSET - else: - restart_policy = check_instance_restart_policy(_restart_policy) - - _scale_to_zero = d.pop("scale_to_zero", UNSET) - scale_to_zero: Union[Unset, InstanceScaleToZero] - if isinstance(_scale_to_zero, Unset): - scale_to_zero = UNSET - else: - scale_to_zero = InstanceScaleToZero.from_dict(_scale_to_zero) - - volumes = [] - _volumes = d.pop("volumes", UNSET) - for volumes_item_data in _volumes or []: - volumes_item = InstanceInstanceVolume.from_dict(volumes_item_data) - - volumes.append(volumes_item) - - _service_group = d.pop("service_group", UNSET) - service_group: Union[Unset, InstanceInstanceServiceGroup] - if isinstance(_service_group, Unset): - service_group = UNSET - else: - service_group = InstanceInstanceServiceGroup.from_dict(_service_group) - - network_interfaces = [] - _network_interfaces = d.pop("network_interfaces", UNSET) - for network_interfaces_item_data in _network_interfaces or []: - network_interfaces_item = InstanceNetworkInterface.from_dict(network_interfaces_item_data) - - network_interfaces.append(network_interfaces_item) - - tags = cast(list[str], d.pop("tags", UNSET)) - - _status = d.pop("status", UNSET) - status: Union[Unset, ResponseStatus] - if isinstance(_status, Unset): - status = UNSET - else: - status = check_response_status(_status) - - message = d.pop("message", UNSET) - - error = d.pop("error", UNSET) - - instance = cls( - uuid=uuid, - name=name, - created_at=created_at, - state=state, - private_fqdn=private_fqdn, - image=image, - memory_mb=memory_mb, - vcpus=vcpus, - args=args, - env=env, - start_count=start_count, - restart_count=restart_count, - started_at=started_at, - stopped_at=stopped_at, - uptime_ms=uptime_ms, - vmm_start_time_us=vmm_start_time_us, - vmm_load_time_us=vmm_load_time_us, - vmm_ready_time_us=vmm_ready_time_us, - boot_time_us=boot_time_us, - net_time_us=net_time_us, - stop_reason=stop_reason, - exit_code=exit_code, - stop_code=stop_code, - restart_policy=restart_policy, - scale_to_zero=scale_to_zero, - volumes=volumes, - service_group=service_group, - network_interfaces=network_interfaces, - tags=tags, - status=status, - message=message, - error=error, + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of Instance from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, ) + # override the default output from pydantic by calling `to_dict()` of env + if self.env: + _dict["env"] = self.env.to_dict() + # override the default output from pydantic by calling `to_dict()` of restart + if self.restart: + _dict["restart"] = self.restart.to_dict() + # override the default output from pydantic by calling `to_dict()` of scale_to_zero + if self.scale_to_zero: + _dict["scale_to_zero"] = self.scale_to_zero.to_dict() + # override the default output from pydantic by calling `to_dict()` of snapshot + if self.snapshot: + _dict["snapshot"] = self.snapshot.to_dict() + # override the default output from pydantic by calling `to_dict()` of service_group + if self.service_group: + _dict["service_group"] = self.service_group.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in volumes (list) + _items = [] + if self.volumes: + for _item_volumes in self.volumes: + if _item_volumes: + _items.append(_item_volumes.to_dict()) + _dict["volumes"] = _items + # override the default output from pydantic by calling `to_dict()` of each item in network_interfaces (list) + _items = [] + if self.network_interfaces: + for _item_network_interfaces in self.network_interfaces: + if _item_network_interfaces: + _items.append(_item_network_interfaces.to_dict()) + _dict["network_interfaces"] = _items + return _dict - instance.additional_properties = d - return instance - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of Instance from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "status": obj.get("status"), + "uuid": obj.get("uuid"), + "name": obj.get("name"), + "created_at": obj.get("created_at"), + "state": obj.get("state"), + "image": obj.get("image"), + "memory_mb": obj.get("memory_mb"), + "args": obj.get("args"), + "env": CreateInstanceRequestEnv.from_dict(obj["env"]) if obj.get("env") is not None else None, + "start_count": obj.get("start_count"), + "started_at": obj.get("started_at"), + "stopped_at": obj.get("stopped_at"), + "uptime_ms": obj.get("uptime_ms"), + "rss_bytes": obj.get("rss_bytes"), + "cpu_time_ms": obj.get("cpu_time_ms"), + "nconns": obj.get("nconns"), + "nreqs": obj.get("nreqs"), + "nqueued": obj.get("nqueued"), + "ntotal": obj.get("ntotal"), + "vmm_start_time_us": obj.get("vmm_start_time_us"), + "vmm_load_time_us": obj.get("vmm_load_time_us"), + "vmm_ready_time_us": obj.get("vmm_ready_time_us"), + "boot_time_us": obj.get("boot_time_us"), + "net_time_us": obj.get("net_time_us"), + "stop_reason": obj.get("stop_reason"), + "exit_code": obj.get("exit_code"), + "stop_code": obj.get("stop_code"), + "restart_policy": obj.get("restart_policy") if obj.get("restart_policy") is not None else "never", + "restart": InstanceRestart.from_dict(obj["restart"]) if obj.get("restart") is not None else None, + "restart_count": obj.get("restart_count"), + "scale_to_zero": CreateInstanceRequestScaleToZero.from_dict(obj["scale_to_zero"]) + if obj.get("scale_to_zero") is not None + else None, + "snapshot": InstanceSnapshot.from_dict(obj["snapshot"]) if obj.get("snapshot") is not None else None, + "private_fqdn": obj.get("private_fqdn"), + "private_ip": obj.get("private_ip"), + "service_group": InstanceServiceGroup.from_dict(obj["service_group"]) + if obj.get("service_group") is not None + else None, + "volumes": [CreateInstanceRequestVolumesInner.from_dict(_item) for _item in obj["volumes"]] + if obj.get("volumes") is not None + else None, + "network_interfaces": [ + InstanceNetworkInterfacesInner.from_dict(_item) for _item in obj["network_interfaces"] + ] + if obj.get("network_interfaces") is not None + else None, + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/instance_create_args_instance_create_request_roms.py b/unikraft_cloud_platform/models/instance_create_args_instance_create_request_roms.py deleted file mode 100644 index 10d43d0..0000000 --- a/unikraft_cloud_platform/models/instance_create_args_instance_create_request_roms.py +++ /dev/null @@ -1,66 +0,0 @@ -from collections.abc import Mapping -from typing import Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -T = TypeVar("T", bound="InstanceCreateArgsInstanceCreateRequestRoms") - - -@_attrs_define -class InstanceCreateArgsInstanceCreateRequestRoms: - image: str - """ The image of the ROM to use for the autoscale configuration. """ - name: Union[Unset, str] = UNSET - """ The name of the ROM to use for the autoscale configuration. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - image = self.image - - name = self.name - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update( - { - "image": image, - } - ) - if name is not UNSET: - field_dict["name"] = name - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - d = dict(src_dict) - image = d.pop("image") - - name = d.pop("name", UNSET) - - instance_create_args_instance_create_request_roms = cls( - image=image, - name=name, - ) - - instance_create_args_instance_create_request_roms.additional_properties = d - return instance_create_args_instance_create_request_roms - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/instance_env.py b/unikraft_cloud_platform/models/instance_env.py deleted file mode 100644 index eeb282a..0000000 --- a/unikraft_cloud_platform/models/instance_env.py +++ /dev/null @@ -1,49 +0,0 @@ -from collections.abc import Mapping -from typing import Any, TypeVar - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -T = TypeVar("T", bound="InstanceEnv") - - -@_attrs_define -class InstanceEnv: - """Environment variables set for the instance. - - Example: - {'ENV_VAR': 'value'} - - """ - - additional_properties: dict[str, str] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - d = dict(src_dict) - instance_env = cls() - - instance_env.additional_properties = d - return instance_env - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> str: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: str) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/instance_instance_service_group.py b/unikraft_cloud_platform/models/instance_instance_service_group.py deleted file mode 100644 index c339be2..0000000 --- a/unikraft_cloud_platform/models/instance_instance_service_group.py +++ /dev/null @@ -1,114 +0,0 @@ -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union -from uuid import UUID - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.instance_service_group_instance_domain import InstanceServiceGroupInstanceDomain - - -T = TypeVar("T", bound="InstanceInstanceServiceGroup") - - -@_attrs_define -class InstanceInstanceServiceGroup: - """The service group configuration for the instance. - - This is a reference to the service group that the instance is part of. The - service group defines the services (e.g. ports, connection handling) that - the instance exposes and how they are configured. - - """ - - uuid: Union[Unset, UUID] = UNSET - """ The UUID of the service group. - - This is a unique identifier for the service group that is generated when - the service is created. The UUID is used to reference the service group - in API calls and can be used to identify the service in all API calls - that require an service identifier. """ - name: Union[Unset, str] = UNSET - """ The name of the service group. - - This is a human-readable name that can be used to identify the service - group. The name is unique within the context of your account. The name - can also be used to identify the service group in API calls. """ - domains: Union[Unset, list["InstanceServiceGroupInstanceDomain"]] = UNSET - """ The domain configuration for the service group. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - uuid: Union[Unset, str] = UNSET - if not isinstance(self.uuid, Unset): - uuid = str(self.uuid) - - name = self.name - - domains: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.domains, Unset): - domains = [] - for domains_item_data in self.domains: - domains_item = domains_item_data.to_dict() - domains.append(domains_item) - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if uuid is not UNSET: - field_dict["uuid"] = uuid - if name is not UNSET: - field_dict["name"] = name - if domains is not UNSET: - field_dict["domains"] = domains - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.instance_service_group_instance_domain import InstanceServiceGroupInstanceDomain - - d = dict(src_dict) - _uuid = d.pop("uuid", UNSET) - uuid: Union[Unset, UUID] - if isinstance(_uuid, Unset): - uuid = UNSET - else: - uuid = UUID(_uuid) - - name = d.pop("name", UNSET) - - domains = [] - _domains = d.pop("domains", UNSET) - for domains_item_data in _domains or []: - domains_item = InstanceServiceGroupInstanceDomain.from_dict(domains_item_data) - - domains.append(domains_item) - - instance_instance_service_group = cls( - uuid=uuid, - name=name, - domains=domains, - ) - - instance_instance_service_group.additional_properties = d - return instance_instance_service_group - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/instance_instance_volume.py b/unikraft_cloud_platform/models/instance_instance_volume.py deleted file mode 100644 index 78482cb..0000000 --- a/unikraft_cloud_platform/models/instance_instance_volume.py +++ /dev/null @@ -1,107 +0,0 @@ -from collections.abc import Mapping -from typing import Any, TypeVar, Union -from uuid import UUID - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -T = TypeVar("T", bound="InstanceInstanceVolume") - - -@_attrs_define -class InstanceInstanceVolume: - """A volume defines a storage which can be attached to the instance. - - Volumes can be used to store persistent data which should remain available - even if the instance is stopped or restarted. - - """ - - uuid: Union[Unset, UUID] = UNSET - """ The UUID of the volume. - - This is a unique identifier for the volume that is generated when the - volume is created. The UUID is used to reference the volume in API calls - and can be used to identify the volume in all API calls that require a - volume identifier. """ - name: Union[Unset, str] = UNSET - """ The name of the volume. - - This is a human-readable name that can be used to identify the volume. - The name must be unique within the context of your account. The name can - also be used to identify the volume in API calls. """ - at: Union[Unset, str] = UNSET - """ The mount point of the volume in the instance. This is the directory in - the instance where the volume will be mounted. """ - read_only: Union[Unset, bool] = UNSET - """ Whether the volume is read-only or not. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - uuid: Union[Unset, str] = UNSET - if not isinstance(self.uuid, Unset): - uuid = str(self.uuid) - - name = self.name - - at = self.at - - read_only = self.read_only - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if uuid is not UNSET: - field_dict["uuid"] = uuid - if name is not UNSET: - field_dict["name"] = name - if at is not UNSET: - field_dict["at"] = at - if read_only is not UNSET: - field_dict["read_only"] = read_only - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - d = dict(src_dict) - _uuid = d.pop("uuid", UNSET) - uuid: Union[Unset, UUID] - if isinstance(_uuid, Unset): - uuid = UNSET - else: - uuid = UUID(_uuid) - - name = d.pop("name", UNSET) - - at = d.pop("at", UNSET) - - read_only = d.pop("read_only", UNSET) - - instance_instance_volume = cls( - uuid=uuid, - name=name, - at=at, - read_only=read_only, - ) - - instance_instance_volume.additional_properties = d - return instance_instance_volume - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/instance_metrics.py b/unikraft_cloud_platform/models/instance_metrics.py new file mode 100644 index 0000000..d1eca95 --- /dev/null +++ b/unikraft_cloud_platform/models/instance_metrics.py @@ -0,0 +1,160 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from uuid import UUID +from typing import Optional, Set +from typing_extensions import Self + + +class InstanceMetrics(BaseModel): + """ + InstanceMetrics + """ # noqa: E501 + + status: Optional[StrictStr] = Field(default=None, description="The status of the response. ") + uuid: Optional[UUID] = Field(default=None, description="The UUID of the instance. ") + name: Optional[Annotated[str, Field(strict=True, max_length=255)]] = Field( + default=None, description="The name of the instance. " + ) + rss_bytes: Optional[Annotated[int, Field(le=9223372036854775807, strict=True, ge=0)]] = Field( + default=None, + description="Resident set size of the VMM in bytes. Note: The resident set size (RSS) specifies the amount of physical memory that has been touched by the instance and is currently reserved for the instance on the Unikraft Cloud server. The RSS grows until the instance has touched all memory assigned to it via the `memory_mb` setting and may also exceed this value as supporting services running outside the instance acquire memory. The RSS is different from the current amount of memory allocated by the application, which is likely to fluctuate over the lifetime of the application. The RSS is not a cumulative metric. When the instance is stopped `rss` goes down to 0. ", + ) + cpu_time_ms: Optional[Annotated[int, Field(le=9223372036854775807, strict=True, ge=0)]] = Field( + default=None, description="Consumed CPU time in milliseconds. " + ) + rx_bytes: Optional[Annotated[int, Field(le=9223372036854775807, strict=True, ge=0)]] = Field( + default=None, description="Total amount of bytes received from network. " + ) + rx_packets: Optional[Annotated[int, Field(le=9223372036854775807, strict=True, ge=0)]] = Field( + default=None, description="Total count of packets received from network. " + ) + tx_bytes: Optional[Annotated[int, Field(le=9223372036854775807, strict=True, ge=0)]] = Field( + default=None, description="Total amount of bytes transmitted over network. " + ) + tx_packets: Optional[Annotated[int, Field(le=9223372036854775807, strict=True, ge=0)]] = Field( + default=None, description="Total count of packets transmitted over network. " + ) + nconns: Optional[Annotated[int, Field(le=65535, strict=True, ge=0)]] = Field( + default=None, description="Number of currently established inbound connections (non-HTTP). " + ) + nreqs: Optional[Annotated[int, Field(le=65535, strict=True, ge=0)]] = Field( + default=None, description="Number of in-flight HTTP requests. " + ) + nqueued: Optional[Annotated[int, Field(le=65535, strict=True, ge=0)]] = Field( + default=None, description="Number of queued inbound connections and HTTP requests. " + ) + ntotal: Optional[Annotated[int, Field(le=9223372036854775807, strict=True, ge=0)]] = Field( + default=None, description="Total number of inbound connections and HTTP requests handled. " + ) + __properties: ClassVar[List[str]] = [ + "status", + "uuid", + "name", + "rss_bytes", + "cpu_time_ms", + "rx_bytes", + "rx_packets", + "tx_bytes", + "tx_packets", + "nconns", + "nreqs", + "nqueued", + "ntotal", + ] + + @field_validator("status") + def status_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(["success", "error"]): + raise ValueError("must be one of enum values ('success', 'error')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of InstanceMetrics from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of InstanceMetrics from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "status": obj.get("status"), + "uuid": obj.get("uuid"), + "name": obj.get("name"), + "rss_bytes": obj.get("rss_bytes"), + "cpu_time_ms": obj.get("cpu_time_ms"), + "rx_bytes": obj.get("rx_bytes"), + "rx_packets": obj.get("rx_packets"), + "tx_bytes": obj.get("tx_bytes"), + "tx_packets": obj.get("tx_packets"), + "nconns": obj.get("nconns"), + "nreqs": obj.get("nreqs"), + "nqueued": obj.get("nqueued"), + "ntotal": obj.get("ntotal"), + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/instance_network_interface.py b/unikraft_cloud_platform/models/instance_network_interface.py deleted file mode 100644 index c1108fa..0000000 --- a/unikraft_cloud_platform/models/instance_network_interface.py +++ /dev/null @@ -1,122 +0,0 @@ -from collections.abc import Mapping -from typing import Any, TypeVar, Union -from uuid import UUID - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -T = TypeVar("T", bound="InstanceNetworkInterface") - - -@_attrs_define -class InstanceNetworkInterface: - """An instance network interface.""" - - uuid: Union[Unset, UUID] = UNSET - """ The UUID of the network interface. This is a unique identifier for the - network interface that is generated when the instance is created. """ - private_ip: Union[Unset, str] = UNSET - """ The private IP address of the network interface. This is the internal IP - address that is used for communication between instances within the same - network. """ - mac: Union[Unset, str] = UNSET - """ The MAC address of the network interface. """ - rx_bytes: Union[Unset, int] = UNSET - """ Amount of bytes received from interface. """ - rx_packets: Union[Unset, int] = UNSET - """ Count of packets received from interface """ - tx_bytes: Union[Unset, int] = UNSET - """ Amount of bytes sent to interface. """ - tx_packets: Union[Unset, int] = UNSET - """ Count of packets sent to interface """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - uuid: Union[Unset, str] = UNSET - if not isinstance(self.uuid, Unset): - uuid = str(self.uuid) - - private_ip = self.private_ip - - mac = self.mac - - rx_bytes = self.rx_bytes - - rx_packets = self.rx_packets - - tx_bytes = self.tx_bytes - - tx_packets = self.tx_packets - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if uuid is not UNSET: - field_dict["uuid"] = uuid - if private_ip is not UNSET: - field_dict["private_ip"] = private_ip - if mac is not UNSET: - field_dict["mac"] = mac - if rx_bytes is not UNSET: - field_dict["rx_bytes"] = rx_bytes - if rx_packets is not UNSET: - field_dict["rx_packets"] = rx_packets - if tx_bytes is not UNSET: - field_dict["tx_bytes"] = tx_bytes - if tx_packets is not UNSET: - field_dict["tx_packets"] = tx_packets - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - d = dict(src_dict) - _uuid = d.pop("uuid", UNSET) - uuid: Union[Unset, UUID] - if isinstance(_uuid, Unset): - uuid = UNSET - else: - uuid = UUID(_uuid) - - private_ip = d.pop("private_ip", UNSET) - - mac = d.pop("mac", UNSET) - - rx_bytes = d.pop("rx_bytes", UNSET) - - rx_packets = d.pop("rx_packets", UNSET) - - tx_bytes = d.pop("tx_bytes", UNSET) - - tx_packets = d.pop("tx_packets", UNSET) - - instance_network_interface = cls( - uuid=uuid, - private_ip=private_ip, - mac=mac, - rx_bytes=rx_bytes, - rx_packets=rx_packets, - tx_bytes=tx_bytes, - tx_packets=tx_packets, - ) - - instance_network_interface.additional_properties = d - return instance_network_interface - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/instance_network_interfaces_inner.py b/unikraft_cloud_platform/models/instance_network_interfaces_inner.py new file mode 100644 index 0000000..3e18c04 --- /dev/null +++ b/unikraft_cloud_platform/models/instance_network_interfaces_inner.py @@ -0,0 +1,135 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from uuid import UUID +from typing import Optional, Set +from typing_extensions import Self + + +class InstanceNetworkInterfacesInner(BaseModel): + """ + InstanceNetworkInterfacesInner + """ # noqa: E501 + + uuid: Optional[UUID] = Field(default=None, description="The UUID of the network interface. ") + private_ip: Optional[Annotated[str, Field(strict=True, max_length=15)]] = Field( + default=None, description="Private IPv4 of network interface. " + ) + mac: Optional[Annotated[str, Field(strict=True, max_length=17)]] = Field( + default=None, description="MAC address of the network interface. " + ) + rx_bytes: Optional[Annotated[int, Field(le=9223372036854775807, strict=True, ge=0)]] = Field( + default=None, + description="Amount of bytes received from interface. Note: Only with `metrics=true` query parameter. ", + ) + rx_packets: Optional[Annotated[int, Field(le=9223372036854775807, strict=True, ge=0)]] = Field( + default=None, + description="Count of packets received from interface. Note: Only with `metrics=true` query parameter. ", + ) + tx_bytes: Optional[Annotated[int, Field(le=9223372036854775807, strict=True, ge=0)]] = Field( + default=None, + description="Amount of bytes transmitted over interface. Note: Only with `metrics=true` query parameter. ", + ) + tx_packets: Optional[Annotated[int, Field(le=9223372036854775807, strict=True, ge=0)]] = Field( + default=None, + description="Count of packets transmitted over interface. Note: Only with `metrics=true` query parameter. ", + ) + __properties: ClassVar[List[str]] = [ + "uuid", + "private_ip", + "mac", + "rx_bytes", + "rx_packets", + "tx_bytes", + "tx_packets", + ] + + @field_validator("mac") + def mac_validate_regular_expression(cls, value): + """Validates the regular expression""" + if value is None: + return value + + if not re.match(r"^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$", value): + raise ValueError(r"must validate the regular expression /^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of InstanceNetworkInterfacesInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of InstanceNetworkInterfacesInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "uuid": obj.get("uuid"), + "private_ip": obj.get("private_ip"), + "mac": obj.get("mac"), + "rx_bytes": obj.get("rx_bytes"), + "rx_packets": obj.get("rx_packets"), + "tx_bytes": obj.get("tx_bytes"), + "tx_packets": obj.get("tx_packets"), + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/instance_restart.py b/unikraft_cloud_platform/models/instance_restart.py new file mode 100644 index 0000000..340da97 --- /dev/null +++ b/unikraft_cloud_platform/models/instance_restart.py @@ -0,0 +1,88 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from datetime import datetime +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from typing import Optional, Set +from typing_extensions import Self + + +class InstanceRestart(BaseModel): + """ + Information about [auto-restarts](https://unikraft.cloud/docs/api/v1/instances/#restart). + """ # noqa: E501 + + attempt: Optional[Annotated[int, Field(le=65535, strict=True, ge=0)]] = Field( + default=None, description="Number of restarts performed in the current restart sequence. " + ) + next_at: Optional[datetime] = Field(default=None, description="Date and time of next restart attempt in ISO8601. ") + __properties: ClassVar[List[str]] = ["attempt", "next_at"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of InstanceRestart from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of InstanceRestart from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({"attempt": obj.get("attempt"), "next_at": obj.get("next_at")}) + return _obj diff --git a/unikraft_cloud_platform/models/instance_restart_policy.py b/unikraft_cloud_platform/models/instance_restart_policy.py deleted file mode 100644 index d1c9544..0000000 --- a/unikraft_cloud_platform/models/instance_restart_policy.py +++ /dev/null @@ -1,15 +0,0 @@ -from typing import Literal, cast - -InstanceRestartPolicy = Literal["always", "never", "on_failure"] - -INSTANCE_RESTART_POLICY_VALUES: set[InstanceRestartPolicy] = { - "always", - "never", - "on_failure", -} - - -def check_instance_restart_policy(value: str) -> InstanceRestartPolicy: - if value in INSTANCE_RESTART_POLICY_VALUES: - return cast(InstanceRestartPolicy, value) - raise TypeError(f"Unexpected value {value!r}. Expected one of {INSTANCE_RESTART_POLICY_VALUES!r}") diff --git a/unikraft_cloud_platform/models/instance_scale_to_zero.py b/unikraft_cloud_platform/models/instance_scale_to_zero.py deleted file mode 100644 index 352f817..0000000 --- a/unikraft_cloud_platform/models/instance_scale_to_zero.py +++ /dev/null @@ -1,105 +0,0 @@ -from collections.abc import Mapping -from typing import Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..models.instance_scale_to_zero_policy import InstanceScaleToZeroPolicy, check_instance_scale_to_zero_policy -from ..types import UNSET, Unset - -T = TypeVar("T", bound="InstanceScaleToZero") - - -@_attrs_define -class InstanceScaleToZero: - """Scale-to-zero defines the configuration for scaling the instance to zero. - When an instance is scaled-to-zero it can be either stopped (and fully - shutdown) or paused wherein the state of the instance is preserved (e.g., RAM - contents) and the instance can be resumed later without losing its state, - i.e. "stateful". - - """ - - enabled: Union[Unset, bool] = UNSET - """ Indicates whether scale-to-zero is enabled for the instance. """ - policy: Union[Unset, InstanceScaleToZeroPolicy] = UNSET - """ The specific policy to use for scaling the instance to zero. """ - stateful: Union[Unset, bool] = UNSET - """ Whether the instance should be stateful when scaled to zero. If set to - true, the instance will retain its state (e.g., RAM contents) when scaled - to zero. This is useful for instances that need to maintain their state - across scale-to-zero operations. If set to false, the instance will lose - its state when scaled to zero, and it will be restarted from scratch when - scaled back up. """ - cooldown_time_ms: Union[Unset, int] = UNSET - """ The cooldown time in milliseconds before the instance can be scaled to - zero again. This is useful to prevent rapid scaling to zero and back up, - which can lead to performance issues or resource exhaustion. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - enabled = self.enabled - - policy: Union[Unset, str] = UNSET - if not isinstance(self.policy, Unset): - policy = self.policy - - stateful = self.stateful - - cooldown_time_ms = self.cooldown_time_ms - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if enabled is not UNSET: - field_dict["enabled"] = enabled - if policy is not UNSET: - field_dict["policy"] = policy - if stateful is not UNSET: - field_dict["stateful"] = stateful - if cooldown_time_ms is not UNSET: - field_dict["cooldown_time_ms"] = cooldown_time_ms - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - d = dict(src_dict) - enabled = d.pop("enabled", UNSET) - - _policy = d.pop("policy", UNSET) - policy: Union[Unset, InstanceScaleToZeroPolicy] - if isinstance(_policy, Unset): - policy = UNSET - else: - policy = check_instance_scale_to_zero_policy(_policy) - - stateful = d.pop("stateful", UNSET) - - cooldown_time_ms = d.pop("cooldown_time_ms", UNSET) - - instance_scale_to_zero = cls( - enabled=enabled, - policy=policy, - stateful=stateful, - cooldown_time_ms=cooldown_time_ms, - ) - - instance_scale_to_zero.additional_properties = d - return instance_scale_to_zero - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/instance_scale_to_zero_policy.py b/unikraft_cloud_platform/models/instance_scale_to_zero_policy.py deleted file mode 100644 index d7f22a9..0000000 --- a/unikraft_cloud_platform/models/instance_scale_to_zero_policy.py +++ /dev/null @@ -1,15 +0,0 @@ -from typing import Literal, cast - -InstanceScaleToZeroPolicy = Literal["idle", "off", "on"] - -INSTANCE_SCALE_TO_ZERO_POLICY_VALUES: set[InstanceScaleToZeroPolicy] = { - "idle", - "off", - "on", -} - - -def check_instance_scale_to_zero_policy(value: str) -> InstanceScaleToZeroPolicy: - if value in INSTANCE_SCALE_TO_ZERO_POLICY_VALUES: - return cast(InstanceScaleToZeroPolicy, value) - raise TypeError(f"Unexpected value {value!r}. Expected one of {INSTANCE_SCALE_TO_ZERO_POLICY_VALUES!r}") diff --git a/unikraft_cloud_platform/models/instance_service_group.py b/unikraft_cloud_platform/models/instance_service_group.py new file mode 100644 index 0000000..5f784fe --- /dev/null +++ b/unikraft_cloud_platform/models/instance_service_group.py @@ -0,0 +1,109 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from uuid import UUID +from unikraft_cloud_platform.models.instance_service_group_domains_inner import InstanceServiceGroupDomainsInner +from typing import Optional, Set +from typing_extensions import Self + + +class InstanceServiceGroup(BaseModel): + """ + Description of the service that the instance is part of. Note: Only if attached to a service. + """ # noqa: E501 + + name: Optional[Annotated[str, Field(strict=True, max_length=255)]] = Field( + default=None, + description="The name of an existing service. Note: You need to specify either an existing [service](https://unikraft.cloud/docs/api/v1/services) via `uuid` or `name`, or provide a description of a new service. If a description for a new service is provided, the service is created and the instance attached. The service will receive an auto-generated name. Specifying an empty `service_group` object creates a new service with no services published. ", + ) + uuid: Optional[UUID] = Field(default=None, description="UUID of an existing service. ") + domains: Optional[Annotated[List[InstanceServiceGroupDomainsInner], Field(max_length=253)]] = Field( + default=None, + description="Description of domains to associate with the service. Default: auto-generated Note: If `name` is specified without also providing a domain, a domain is derived from `name` by appending an 8 characters long random alphanumeric suffix and the metro's domain name. For example, setting the name to `my-project` without also providing a domain results in an auto-generated domain of `my-project-.fra0.kraft.host`. ", + ) + __properties: ClassVar[List[str]] = ["name", "uuid", "domains"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of InstanceServiceGroup from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in domains (list) + _items = [] + if self.domains: + for _item_domains in self.domains: + if _item_domains: + _items.append(_item_domains.to_dict()) + _dict["domains"] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of InstanceServiceGroup from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "name": obj.get("name"), + "uuid": obj.get("uuid"), + "domains": [InstanceServiceGroupDomainsInner.from_dict(_item) for _item in obj["domains"]] + if obj.get("domains") is not None + else None, + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/instance_service_group_domains_inner.py b/unikraft_cloud_platform/models/instance_service_group_domains_inner.py new file mode 100644 index 0000000..47bc1c6 --- /dev/null +++ b/unikraft_cloud_platform/models/instance_service_group_domains_inner.py @@ -0,0 +1,105 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from unikraft_cloud_platform.models.instance_service_group_domains_inner_certificate import ( + InstanceServiceGroupDomainsInnerCertificate, +) +from typing import Optional, Set +from typing_extensions import Self + + +class InstanceServiceGroupDomainsInner(BaseModel): + """ + InstanceServiceGroupDomainsInner + """ # noqa: E501 + + name: Annotated[str, Field(strict=True, max_length=255)] = Field( + description="Publicly accessible domain name. Note: The services published by the service will be accessible under the given domain names. If `name` is a fully-qualified domain name, that is it ends with a dot (`.`), the domain name is taken as-is. Otherwise, the metro’s domain name is appended (e.g., `my-project` expands to `my-project.fra0.kraft.host`). If the given domain name is already in use by the current or a different user the operation fails. In addition, certain domain names cannot be used (e.g., `www.fra0.kraft.host`). " + ) + certificate: Optional[InstanceServiceGroupDomainsInnerCertificate] = None + __properties: ClassVar[List[str]] = ["name", "certificate"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of InstanceServiceGroupDomainsInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of certificate + if self.certificate: + _dict["certificate"] = self.certificate.to_dict() + # set to None if certificate (nullable) is None + # and model_fields_set contains the field + if self.certificate is None and "certificate" in self.model_fields_set: + _dict["certificate"] = None + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of InstanceServiceGroupDomainsInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "name": obj.get("name"), + "certificate": InstanceServiceGroupDomainsInnerCertificate.from_dict(obj["certificate"]) + if obj.get("certificate") is not None + else None, + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/instance_service_group_domains_inner_certificate.py b/unikraft_cloud_platform/models/instance_service_group_domains_inner_certificate.py new file mode 100644 index 0000000..c6c8b20 --- /dev/null +++ b/unikraft_cloud_platform/models/instance_service_group_domains_inner_certificate.py @@ -0,0 +1,88 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from uuid import UUID +from typing import Optional, Set +from typing_extensions import Self + + +class InstanceServiceGroupDomainsInnerCertificate(BaseModel): + """ + TLS certificate to use for the domain. Note: Only allowed for FQDNs, not for subdomains. Subdomains like `my-project` inherit the wildcard `*..kraft.host` certificate. If you specify an FQDN like `www.example.com`, Unikraft Cloud will automatically pick the certificate with the matching CN or trigger a certificate request (see [here](https://unikraft.cloud/docs/api/v1/certificates)). + """ # noqa: E501 + + uuid: Optional[UUID] = Field(default=None, description="UUID of the certificate") + name: Optional[Annotated[str, Field(strict=True, max_length=255)]] = Field( + default=None, description="Name of the certificate" + ) + __properties: ClassVar[List[str]] = [] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of InstanceServiceGroupDomainsInnerCertificate from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of InstanceServiceGroupDomainsInnerCertificate from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({}) + return _obj diff --git a/unikraft_cloud_platform/models/instance_service_group_instance_domain.py b/unikraft_cloud_platform/models/instance_service_group_instance_domain.py deleted file mode 100644 index 64e8a7c..0000000 --- a/unikraft_cloud_platform/models/instance_service_group_instance_domain.py +++ /dev/null @@ -1,70 +0,0 @@ -from collections.abc import Mapping -from typing import Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -T = TypeVar("T", bound="InstanceServiceGroupInstanceDomain") - - -@_attrs_define -class InstanceServiceGroupInstanceDomain: - """The domain configuration for the service group. - - Domain names are completely specified with all labels in the hierarchy of - the DNS, having no parts omitted. The domain can be associated with an - existing certificate by specifying the certificate's name or UUID. If no - certificate is specified and a FQDN is provided, Unikraft Cloud will - automatically generate a new certificate for the domain based on Let's - Encrypt and seek to accomplish a DNS-01 challenge. - - """ - - fqdn: Union[Unset, str] = UNSET - """ Publicly accessible domain name. - - If this name ends in a period `.` it must be a valid Full Qualified - Domain Name (FQDN), otherwise it will become a subdomain of the target - metro. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - fqdn = self.fqdn - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if fqdn is not UNSET: - field_dict["fqdn"] = fqdn - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - d = dict(src_dict) - fqdn = d.pop("fqdn", UNSET) - - instance_service_group_instance_domain = cls( - fqdn=fqdn, - ) - - instance_service_group_instance_domain.additional_properties = d - return instance_service_group_instance_domain - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/instance_snapshot.py b/unikraft_cloud_platform/models/instance_snapshot.py new file mode 100644 index 0000000..0da4602 --- /dev/null +++ b/unikraft_cloud_platform/models/instance_snapshot.py @@ -0,0 +1,84 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from uuid import UUID +from typing import Optional, Set +from typing_extensions import Self + + +class InstanceSnapshot(BaseModel): + """ + InstanceSnapshot + """ # noqa: E501 + + uuid: Optional[UUID] = Field(default=None, description="The UUID of the snapshot. ") + __properties: ClassVar[List[str]] = ["uuid"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of InstanceSnapshot from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of InstanceSnapshot from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({"uuid": obj.get("uuid")}) + return _obj diff --git a/unikraft_cloud_platform/models/instance_state.py b/unikraft_cloud_platform/models/instance_state.py deleted file mode 100644 index 05afb7a..0000000 --- a/unikraft_cloud_platform/models/instance_state.py +++ /dev/null @@ -1,18 +0,0 @@ -from typing import Literal, cast - -InstanceState = Literal["draining", "running", "standby", "starting", "stopped", "stopping"] - -INSTANCE_STATE_VALUES: set[InstanceState] = { - "draining", - "running", - "standby", - "starting", - "stopped", - "stopping", -} - - -def check_instance_state(value: str) -> InstanceState: - if value in INSTANCE_STATE_VALUES: - return cast(InstanceState, value) - raise TypeError(f"Unexpected value {value!r}. Expected one of {INSTANCE_STATE_VALUES!r}") diff --git a/unikraft_cloud_platform/models/name_or_uuid.py b/unikraft_cloud_platform/models/name_or_uuid.py deleted file mode 100644 index 99cda9d..0000000 --- a/unikraft_cloud_platform/models/name_or_uuid.py +++ /dev/null @@ -1,44 +0,0 @@ -from collections.abc import Mapping -from typing import Any, TypeVar - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -T = TypeVar("T", bound="NameOrUUID") - - -@_attrs_define -class NameOrUUID: - """An identifier for a resource. Either a name or a UUID.""" - - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - d = dict(src_dict) - name_or_uuid = cls() - - name_or_uuid.additional_properties = d - return name_or_uuid - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/object_.py b/unikraft_cloud_platform/models/object_.py deleted file mode 100644 index 3c92526..0000000 --- a/unikraft_cloud_platform/models/object_.py +++ /dev/null @@ -1,80 +0,0 @@ -from collections.abc import Mapping -from typing import Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -T = TypeVar("T", bound="Object") - - -@_attrs_define -class Object: - """An object is a single component of an image which is external and can be - uniquely identified by its digest. - - """ - - digest: Union[Unset, str] = UNSET - """ The digest is a string representation including the hashing - algorithm and the hash value separated by a colon. """ - media_type: Union[Unset, str] = UNSET - """ The media type of the layer is a string that identifies the type of - content that the layer contains. """ - size: Union[Unset, int] = UNSET - """ The size of the layer in bytes. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - digest = self.digest - - media_type = self.media_type - - size = self.size - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if digest is not UNSET: - field_dict["digest"] = digest - if media_type is not UNSET: - field_dict["media_type"] = media_type - if size is not UNSET: - field_dict["size"] = size - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - d = dict(src_dict) - digest = d.pop("digest", UNSET) - - media_type = d.pop("media_type", UNSET) - - size = d.pop("size", UNSET) - - object_ = cls( - digest=digest, - media_type=media_type, - size=size, - ) - - object_.additional_properties = d - return object_ - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/quotas.py b/unikraft_cloud_platform/models/quotas.py deleted file mode 100644 index 6ab0771..0000000 --- a/unikraft_cloud_platform/models/quotas.py +++ /dev/null @@ -1,155 +0,0 @@ -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union -from uuid import UUID - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..models.response_status import ResponseStatus, check_response_status -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.quotas_limits import QuotasLimits - from ..models.quotas_stats import QuotasStats - - -T = TypeVar("T", bound="Quotas") - - -@_attrs_define -class Quotas: - uuid: Union[Unset, UUID] = UNSET - """ The UUID of the quota. """ - used: Union[Unset, "QuotasStats"] = UNSET - hard: Union[Unset, "QuotasStats"] = UNSET - limits: Union[Unset, "QuotasLimits"] = UNSET - status: Union[Unset, ResponseStatus] = UNSET - """ The response status of an API request. """ - message: Union[Unset, str] = UNSET - """ An optional message providing additional information about the status. - This field is only set when this message object is used as a response - message, and is useful when the status is not `success`. """ - error: Union[Unset, int] = UNSET - """ An optional error code providing additional information about the status. - This field is only set when this message object is used as a response - message, and is useful when the status is not `success`. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - uuid: Union[Unset, str] = UNSET - if not isinstance(self.uuid, Unset): - uuid = str(self.uuid) - - used: Union[Unset, dict[str, Any]] = UNSET - if not isinstance(self.used, Unset): - used = self.used.to_dict() - - hard: Union[Unset, dict[str, Any]] = UNSET - if not isinstance(self.hard, Unset): - hard = self.hard.to_dict() - - limits: Union[Unset, dict[str, Any]] = UNSET - if not isinstance(self.limits, Unset): - limits = self.limits.to_dict() - - status: Union[Unset, str] = UNSET - if not isinstance(self.status, Unset): - status = self.status - - message = self.message - - error = self.error - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if uuid is not UNSET: - field_dict["uuid"] = uuid - if used is not UNSET: - field_dict["used"] = used - if hard is not UNSET: - field_dict["hard"] = hard - if limits is not UNSET: - field_dict["limits"] = limits - if status is not UNSET: - field_dict["status"] = status - if message is not UNSET: - field_dict["message"] = message - if error is not UNSET: - field_dict["error"] = error - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.quotas_limits import QuotasLimits - from ..models.quotas_stats import QuotasStats - - d = dict(src_dict) - _uuid = d.pop("uuid", UNSET) - uuid: Union[Unset, UUID] - if isinstance(_uuid, Unset): - uuid = UNSET - else: - uuid = UUID(_uuid) - - _used = d.pop("used", UNSET) - used: Union[Unset, QuotasStats] - if isinstance(_used, Unset): - used = UNSET - else: - used = QuotasStats.from_dict(_used) - - _hard = d.pop("hard", UNSET) - hard: Union[Unset, QuotasStats] - if isinstance(_hard, Unset): - hard = UNSET - else: - hard = QuotasStats.from_dict(_hard) - - _limits = d.pop("limits", UNSET) - limits: Union[Unset, QuotasLimits] - if isinstance(_limits, Unset): - limits = UNSET - else: - limits = QuotasLimits.from_dict(_limits) - - _status = d.pop("status", UNSET) - status: Union[Unset, ResponseStatus] - if isinstance(_status, Unset): - status = UNSET - else: - status = check_response_status(_status) - - message = d.pop("message", UNSET) - - error = d.pop("error", UNSET) - - quotas = cls( - uuid=uuid, - used=used, - hard=hard, - limits=limits, - status=status, - message=message, - error=error, - ) - - quotas.additional_properties = d - return quotas - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/quotas_limits.py b/unikraft_cloud_platform/models/quotas_limits.py deleted file mode 100644 index c289b35..0000000 --- a/unikraft_cloud_platform/models/quotas_limits.py +++ /dev/null @@ -1,118 +0,0 @@ -from collections.abc import Mapping -from typing import Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -T = TypeVar("T", bound="QuotasLimits") - - -@_attrs_define -class QuotasLimits: - min_memory_mb: Union[Unset, int] = UNSET - """ Minimum amount of memory assigned to live instances in megabytes """ - max_memory_mb: Union[Unset, int] = UNSET - """ Maximum amount of memory assigned to live instances in megabytes """ - min_volume_mb: Union[Unset, int] = UNSET - """ Minimum size of a volume in megabytes """ - max_volume_mb: Union[Unset, int] = UNSET - """ Maximum size of a volume in megabytes """ - min_autoscale_size: Union[Unset, int] = UNSET - """ Minimum size of an autoscale group """ - max_autoscale_size: Union[Unset, int] = UNSET - """ Maximum size of an autoscale group """ - min_vcpus: Union[Unset, int] = UNSET - """ Minimum number of vCPUs """ - max_vcpus: Union[Unset, int] = UNSET - """ Maximum number of vCPUs """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - min_memory_mb = self.min_memory_mb - - max_memory_mb = self.max_memory_mb - - min_volume_mb = self.min_volume_mb - - max_volume_mb = self.max_volume_mb - - min_autoscale_size = self.min_autoscale_size - - max_autoscale_size = self.max_autoscale_size - - min_vcpus = self.min_vcpus - - max_vcpus = self.max_vcpus - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if min_memory_mb is not UNSET: - field_dict["min_memory_mb"] = min_memory_mb - if max_memory_mb is not UNSET: - field_dict["max_memory_mb"] = max_memory_mb - if min_volume_mb is not UNSET: - field_dict["min_volume_mb"] = min_volume_mb - if max_volume_mb is not UNSET: - field_dict["max_volume_mb"] = max_volume_mb - if min_autoscale_size is not UNSET: - field_dict["min_autoscale_size"] = min_autoscale_size - if max_autoscale_size is not UNSET: - field_dict["max_autoscale_size"] = max_autoscale_size - if min_vcpus is not UNSET: - field_dict["min_vcpus"] = min_vcpus - if max_vcpus is not UNSET: - field_dict["max_vcpus"] = max_vcpus - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - d = dict(src_dict) - min_memory_mb = d.pop("min_memory_mb", UNSET) - - max_memory_mb = d.pop("max_memory_mb", UNSET) - - min_volume_mb = d.pop("min_volume_mb", UNSET) - - max_volume_mb = d.pop("max_volume_mb", UNSET) - - min_autoscale_size = d.pop("min_autoscale_size", UNSET) - - max_autoscale_size = d.pop("max_autoscale_size", UNSET) - - min_vcpus = d.pop("min_vcpus", UNSET) - - max_vcpus = d.pop("max_vcpus", UNSET) - - quotas_limits = cls( - min_memory_mb=min_memory_mb, - max_memory_mb=max_memory_mb, - min_volume_mb=min_volume_mb, - max_volume_mb=max_volume_mb, - min_autoscale_size=min_autoscale_size, - max_autoscale_size=max_autoscale_size, - min_vcpus=min_vcpus, - max_vcpus=max_vcpus, - ) - - quotas_limits.additional_properties = d - return quotas_limits - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/quotas_response.py b/unikraft_cloud_platform/models/quotas_response.py deleted file mode 100644 index 4630f4f..0000000 --- a/unikraft_cloud_platform/models/quotas_response.py +++ /dev/null @@ -1,117 +0,0 @@ -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..models.response_status import ResponseStatus, check_response_status -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.quotas_response_data import QuotasResponseData - from ..models.response_error import ResponseError - - -T = TypeVar("T", bound="QuotasResponse") - - -@_attrs_define -class QuotasResponse: - """The response message for getting the quota of a user given their UUID.""" - - status: Union[Unset, ResponseStatus] = UNSET - """ The response status of an API request. """ - data: Union[Unset, "QuotasResponseData"] = UNSET - errors: Union[Unset, list["ResponseError"]] = UNSET - """ A list of errors which may have occurred during the request. """ - op_time_us: Union[Unset, int] = UNSET - """ The operation time in microseconds. This is the time it took to process - the request and generate the response. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - status: Union[Unset, str] = UNSET - if not isinstance(self.status, Unset): - status = self.status - - data: Union[Unset, dict[str, Any]] = UNSET - if not isinstance(self.data, Unset): - data = self.data.to_dict() - - errors: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.errors, Unset): - errors = [] - for errors_item_data in self.errors: - errors_item = errors_item_data.to_dict() - errors.append(errors_item) - - op_time_us = self.op_time_us - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if status is not UNSET: - field_dict["status"] = status - if data is not UNSET: - field_dict["data"] = data - if errors is not UNSET: - field_dict["errors"] = errors - if op_time_us is not UNSET: - field_dict["op_time_us"] = op_time_us - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.quotas_response_data import QuotasResponseData - from ..models.response_error import ResponseError - - d = dict(src_dict) - _status = d.pop("status", UNSET) - status: Union[Unset, ResponseStatus] - if isinstance(_status, Unset): - status = UNSET - else: - status = check_response_status(_status) - - _data = d.pop("data", UNSET) - data: Union[Unset, QuotasResponseData] - if isinstance(_data, Unset): - data = UNSET - else: - data = QuotasResponseData.from_dict(_data) - - errors = [] - _errors = d.pop("errors", UNSET) - for errors_item_data in _errors or []: - errors_item = ResponseError.from_dict(errors_item_data) - - errors.append(errors_item) - - op_time_us = d.pop("op_time_us", UNSET) - - quotas_response = cls( - status=status, - data=data, - errors=errors, - op_time_us=op_time_us, - ) - - quotas_response.additional_properties = d - return quotas_response - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/quotas_response_data.py b/unikraft_cloud_platform/models/quotas_response_data.py deleted file mode 100644 index 380da98..0000000 --- a/unikraft_cloud_platform/models/quotas_response_data.py +++ /dev/null @@ -1,71 +0,0 @@ -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.quotas import Quotas - - -T = TypeVar("T", bound="QuotasResponseData") - - -@_attrs_define -class QuotasResponseData: - quotas: Union[Unset, list["Quotas"]] = UNSET - """ The quota(s) which were retrieved by the request. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - quotas: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.quotas, Unset): - quotas = [] - for quotas_item_data in self.quotas: - quotas_item = quotas_item_data.to_dict() - quotas.append(quotas_item) - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if quotas is not UNSET: - field_dict["quotas"] = quotas - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.quotas import Quotas - - d = dict(src_dict) - quotas = [] - _quotas = d.pop("quotas", UNSET) - for quotas_item_data in _quotas or []: - quotas_item = Quotas.from_dict(quotas_item_data) - - quotas.append(quotas_item) - - quotas_response_data = cls( - quotas=quotas, - ) - - quotas_response_data.additional_properties = d - return quotas_response_data - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/quotas_stats.py b/unikraft_cloud_platform/models/quotas_stats.py deleted file mode 100644 index c3af9e7..0000000 --- a/unikraft_cloud_platform/models/quotas_stats.py +++ /dev/null @@ -1,119 +0,0 @@ -from collections.abc import Mapping -from typing import Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -T = TypeVar("T", bound="QuotasStats") - - -@_attrs_define -class QuotasStats: - instances: Union[Unset, int] = UNSET - """ Number of instances """ - live_instances: Union[Unset, int] = UNSET - """ Number of instances that are not in the `stopped` state """ - live_vcpus: Union[Unset, int] = UNSET - """ Number of vCPUs """ - live_memory_mb: Union[Unset, int] = UNSET - """ Amount of memory assigned to instances that are not in the `stopped` - state in megabytes """ - service_groups: Union[Unset, int] = UNSET - """ Number of services """ - services: Union[Unset, int] = UNSET - """ Number of published network ports over all existing services """ - volumes: Union[Unset, int] = UNSET - """ Number of volumes """ - total_volume_mb: Union[Unset, int] = UNSET - """ Total size of all volumes in megabytes """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - instances = self.instances - - live_instances = self.live_instances - - live_vcpus = self.live_vcpus - - live_memory_mb = self.live_memory_mb - - service_groups = self.service_groups - - services = self.services - - volumes = self.volumes - - total_volume_mb = self.total_volume_mb - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if instances is not UNSET: - field_dict["instances"] = instances - if live_instances is not UNSET: - field_dict["live_instances"] = live_instances - if live_vcpus is not UNSET: - field_dict["live_vcpus"] = live_vcpus - if live_memory_mb is not UNSET: - field_dict["live_memory_mb"] = live_memory_mb - if service_groups is not UNSET: - field_dict["service_groups"] = service_groups - if services is not UNSET: - field_dict["services"] = services - if volumes is not UNSET: - field_dict["volumes"] = volumes - if total_volume_mb is not UNSET: - field_dict["total_volume_mb"] = total_volume_mb - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - d = dict(src_dict) - instances = d.pop("instances", UNSET) - - live_instances = d.pop("live_instances", UNSET) - - live_vcpus = d.pop("live_vcpus", UNSET) - - live_memory_mb = d.pop("live_memory_mb", UNSET) - - service_groups = d.pop("service_groups", UNSET) - - services = d.pop("services", UNSET) - - volumes = d.pop("volumes", UNSET) - - total_volume_mb = d.pop("total_volume_mb", UNSET) - - quotas_stats = cls( - instances=instances, - live_instances=live_instances, - live_vcpus=live_vcpus, - live_memory_mb=live_memory_mb, - service_groups=service_groups, - services=services, - volumes=volumes, - total_volume_mb=total_volume_mb, - ) - - quotas_stats.additional_properties = d - return quotas_stats - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/response_error.py b/unikraft_cloud_platform/models/response_error.py deleted file mode 100644 index 62f7867..0000000 --- a/unikraft_cloud_platform/models/response_error.py +++ /dev/null @@ -1,57 +0,0 @@ -from collections.abc import Mapping -from typing import Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -T = TypeVar("T", bound="ResponseError") - - -@_attrs_define -class ResponseError: - """The error response message for an API request.""" - - status: Union[Unset, int] = UNSET - """ The HTTP status code of the error. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - status = self.status - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if status is not UNSET: - field_dict["status"] = status - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - d = dict(src_dict) - status = d.pop("status", UNSET) - - response_error = cls( - status=status, - ) - - response_error.additional_properties = d - return response_error - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/response_status.py b/unikraft_cloud_platform/models/response_status.py deleted file mode 100644 index 0aff987..0000000 --- a/unikraft_cloud_platform/models/response_status.py +++ /dev/null @@ -1,14 +0,0 @@ -from typing import Literal, cast - -ResponseStatus = Literal["error", "success"] - -RESPONSE_STATUS_VALUES: set[ResponseStatus] = { - "error", - "success", -} - - -def check_response_status(value: str) -> ResponseStatus: - if value in RESPONSE_STATUS_VALUES: - return cast(ResponseStatus, value) - raise TypeError(f"Unexpected value {value!r}. Expected one of {RESPONSE_STATUS_VALUES!r}") diff --git a/unikraft_cloud_platform/models/service.py b/unikraft_cloud_platform/models/service.py index 2feed90..f2b2852 100644 --- a/unikraft_cloud_platform/models/service.py +++ b/unikraft_cloud_platform/models/service.py @@ -1,102 +1,186 @@ -from collections.abc import Mapping -from typing import Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..models.service_handlers_item import ServiceHandlersItem, check_service_handlers_item -from ..types import UNSET, Unset - -T = TypeVar("T", bound="Service") - - -@_attrs_define -class Service: - """A service connects a public-facing port to an internal destination port on - which an application instance listens on. Additional handlers can be defined - for each published port in order to define how the service will handle - incoming connections and forward traffic from the Internet to your - application. For example, a service can be configured to terminate TLS - connections, redirect HTTP traffic, or enable HTTP mode for load balancing. - +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from datetime import datetime +from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from uuid import UUID +from unikraft_cloud_platform.models.create_instance_request_service_group_domains_inner import ( + CreateInstanceRequestServiceGroupDomainsInner, +) +from unikraft_cloud_platform.models.get_services200_response_data_service_groups_inner_instances_inner import ( + GetServices200ResponseDataServiceGroupsInnerInstancesInner, +) +from unikraft_cloud_platform.models.service_mapping import ServiceMapping +from typing import Optional, Set +from typing_extensions import Self + + +class Service(BaseModel): """ + Service + """ # noqa: E501 + + status: Optional[StrictStr] = Field(default=None, description="The status of the response. ") + uuid: Optional[UUID] = Field(default=None, description="The UUID of the service. ") + name: Optional[Annotated[str, Field(strict=True, max_length=255)]] = Field( + default=None, description="The name of the service. " + ) + created_at: Optional[datetime] = Field(default=None, description="Date and time of creation in ISO8601. ") + persistent: Optional[StrictBool] = Field( + default=None, description="Indicates if the service will stay alive even after the last instance detached. " + ) + autoscale: Optional[StrictBool] = Field( + default=None, + description="Indicates if the service has [autoscale](https://unikraft.cloud/docs/api/v1/autoscale) enabled. ", + ) + soft_limit: Optional[Annotated[int, Field(le=65535, strict=True, ge=1)]] = Field( + default=None, + description="Per-instance connection [soft limit](https://unikraft.cloud/docs/api/v1/services/#limits). ", + ) + hard_limit: Optional[Annotated[int, Field(le=65535, strict=True, ge=1)]] = Field( + default=None, + description="Per-instance connection [hard limit](https://unikraft.cloud/docs/api/v1/services/#limits). ", + ) + services: Optional[Annotated[List[ServiceMapping], Field(max_length=253)]] = Field( + default=None, description="Description of published network services. " + ) + domains: Optional[Annotated[List[CreateInstanceRequestServiceGroupDomainsInner], Field(max_length=253)]] = None + instances: Optional[ + Annotated[List[GetServices200ResponseDataServiceGroupsInnerInstancesInner], Field(max_length=253)] + ] = Field(default=None, description="Instances attached to this service") + __properties: ClassVar[List[str]] = [ + "status", + "uuid", + "name", + "created_at", + "persistent", + "autoscale", + "soft_limit", + "hard_limit", + "services", + "domains", + "instances", + ] + + @field_validator("status") + def status_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(["success", "error"]): + raise ValueError("must be one of enum values ('success', 'error')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) - port: int - """ This is the public-facing port that the service will be accessible from - on the Internet. """ - destination_port: Union[Unset, int] = UNSET - """ The port number that the instance is listening on. This is the internal - port which Unikraft Cloud will forward traffic to. """ - handlers: Union[Unset, list[ServiceHandlersItem]] = UNSET - """ Connection handlers to use for the service. Handlers define how the - service will handle incoming connections and forward traffic from the - Internet to your application. For example, a service can be configured - to terminate TLS connections, redirect HTTP traffic, or enable HTTP mode - for load balancing. You configure the handlers for every published - service port individually. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - port = self.port - - destination_port = self.destination_port - - handlers: Union[Unset, list[str]] = UNSET - if not isinstance(self.handlers, Unset): - handlers = [] - for handlers_item_data in self.handlers: - handlers_item: str = handlers_item_data - handlers.append(handlers_item) - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update( - { - "port": port, - } + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of Service from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, ) - if destination_port is not UNSET: - field_dict["destination_port"] = destination_port - if handlers is not UNSET: - field_dict["handlers"] = handlers - - return field_dict + # override the default output from pydantic by calling `to_dict()` of each item in services (list) + _items = [] + if self.services: + for _item_services in self.services: + if _item_services: + _items.append(_item_services.to_dict()) + _dict["services"] = _items + # override the default output from pydantic by calling `to_dict()` of each item in domains (list) + _items = [] + if self.domains: + for _item_domains in self.domains: + if _item_domains: + _items.append(_item_domains.to_dict()) + _dict["domains"] = _items + # override the default output from pydantic by calling `to_dict()` of each item in instances (list) + _items = [] + if self.instances: + for _item_instances in self.instances: + if _item_instances: + _items.append(_item_instances.to_dict()) + _dict["instances"] = _items + return _dict @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - d = dict(src_dict) - port = d.pop("port") + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of Service from a dict""" + if obj is None: + return None - destination_port = d.pop("destination_port", UNSET) + if not isinstance(obj, dict): + return cls.model_validate(obj) - handlers = [] - _handlers = d.pop("handlers", UNSET) - for handlers_item_data in _handlers or []: - handlers_item = check_service_handlers_item(handlers_item_data) - - handlers.append(handlers_item) - - service = cls( - port=port, - destination_port=destination_port, - handlers=handlers, + _obj = cls.model_validate( + { + "status": obj.get("status"), + "uuid": obj.get("uuid"), + "name": obj.get("name"), + "created_at": obj.get("created_at"), + "persistent": obj.get("persistent"), + "autoscale": obj.get("autoscale"), + "soft_limit": obj.get("soft_limit"), + "hard_limit": obj.get("hard_limit"), + "services": [ServiceMapping.from_dict(_item) for _item in obj["services"]] + if obj.get("services") is not None + else None, + "domains": [CreateInstanceRequestServiceGroupDomainsInner.from_dict(_item) for _item in obj["domains"]] + if obj.get("domains") is not None + else None, + "instances": [ + GetServices200ResponseDataServiceGroupsInnerInstancesInner.from_dict(_item) + for _item in obj["instances"] + ] + if obj.get("instances") is not None + else None, + } ) - - service.additional_properties = d - return service - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties + return _obj diff --git a/unikraft_cloud_platform/models/service_group.py b/unikraft_cloud_platform/models/service_group.py deleted file mode 100644 index d73ecbf..0000000 --- a/unikraft_cloud_platform/models/service_group.py +++ /dev/null @@ -1,287 +0,0 @@ -import datetime -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union -from uuid import UUID - -from attrs import define as _attrs_define -from attrs import field as _attrs_field -from dateutil.parser import isoparse - -from ..models.response_status import ResponseStatus, check_response_status -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.domain import Domain - from ..models.service import Service - from ..models.service_group_instance import ServiceGroupInstance - - -T = TypeVar("T", bound="ServiceGroup") - - -@_attrs_define -class ServiceGroup: - """A service group on Unikraft Cloud is used to describe how your application - exposes its functionality to the outside world. Once defined, assigning an - instance to the service will make it accessible from the Internet. - - An application, running as an instance, may expose one or more ports, e.g. it - listens on port 80 because your application exposes a HTTP web service. This, - along with a set of additional metadata defines how the "service" is - configured and accessed. For example, a service may be configured to use - TLS, or be bound to a specific domain name. - - When an instance is assigned to a service group, it immediately becomes - accessible over the Internet on the exposed public port, using the set DNS - name, and is routed to the set destination port. - - Note: If you do not specify a DNS name when you create a service and you - indicate that the application exposes some ports, Unikraft Cloud will - generates a random DNS name for you. Unikraft Cloud also supports custom - domains like www.example.com and wildcard domains like *.example.com. - - """ - - uuid: Union[Unset, UUID] = UNSET - """ The UUID of the service group. - - This is a unique identifier for the service group that is generated when - the service group is created. The UUID is used to reference the service in - API calls and can be used to identify the service group in all API calls - that require an identifier. """ - name: Union[Unset, str] = UNSET - """ The name of the service group. - - This is a human-readable name that can be used to identify the service - group. The name must be unique within the context of your account. The - name can also be used to identify the service in API calls. """ - created_at: Union[Unset, datetime.datetime] = UNSET - """ The time the service was created. """ - persistent: Union[Unset, bool] = UNSET - """ Indicates if the service will stay remain even after the last instance - detached. If this is set to false, the service will be deleted when the - last instance detached from it. If this is set to true, the service will - remain and can be reused by other instances. This is useful if you want to - keep the service configuration, e.g., the published ports, handlers, and - domains, even if there are no instances assigned to it. """ - autoscale: Union[Unset, bool] = UNSET - """ Indicates if the service has autoscale enabled. See the associated - autoscale documentation for more information about how to set this up. - Autoscale policies can be set up after the service has been created. """ - soft_limit: Union[Unset, int] = UNSET - """ The soft limit is used by the Unikraft Cloud load balancer to decide when - to wake up another standby instance. For example, if the soft limit is set - to 5 and the service consists of 2 standby instances, one of the instances - receives up to 5 concurrent requests. The 6th parallel requests wakes up - the second instance. If there are no more standby instances to wake up, - the number of requests assigned to each instance will exceed the soft - limit. The load balancer makes sure that when the number of in-flight - requests goes down again, instances are put into standby as fast as - possible. """ - hard_limit: Union[Unset, int] = UNSET - """ The hard limit defines the maximum number of concurrent requests that an - instance assigned to the this service can handle. The load balancer will - never assign more requests to a single instance. In case there are no - other instances available, excess requests fail (i.e., they are blocked and - not queued). """ - services: Union[Unset, list["Service"]] = UNSET - """ List of published network ports for this service and the destination port - to which Unikraft Cloud will forward traffic to. Additional handlers can - be defined for each published port in order to define how the service will - handle incoming connections and forward traffic from the Internet to your - application. For example, a service can be configured to terminate TLS - connections, redirect HTTP traffic, or enable HTTP mode for load balancing. """ - domains: Union[Unset, list["Domain"]] = UNSET - """ List of domains associated with the service. Domains are used to access - the service over the Internet. """ - instances: Union[Unset, list["ServiceGroupInstance"]] = UNSET - """ List of instances assigned to the service. """ - status: Union[Unset, ResponseStatus] = UNSET - """ The response status of an API request. """ - message: Union[Unset, str] = UNSET - """ An optional message providing additional information about the status. - This field is only set when this message object is used as a response - message, and is useful when the status is not `success`. """ - error: Union[Unset, int] = UNSET - """ An optional error code providing additional information about the status. - This field is only set when this message object is used as a response - message, and is useful when the status is not `success`. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - uuid: Union[Unset, str] = UNSET - if not isinstance(self.uuid, Unset): - uuid = str(self.uuid) - - name = self.name - - created_at: Union[Unset, str] = UNSET - if not isinstance(self.created_at, Unset): - created_at = self.created_at.isoformat() - - persistent = self.persistent - - autoscale = self.autoscale - - soft_limit = self.soft_limit - - hard_limit = self.hard_limit - - services: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.services, Unset): - services = [] - for services_item_data in self.services: - services_item = services_item_data.to_dict() - services.append(services_item) - - domains: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.domains, Unset): - domains = [] - for domains_item_data in self.domains: - domains_item = domains_item_data.to_dict() - domains.append(domains_item) - - instances: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.instances, Unset): - instances = [] - for instances_item_data in self.instances: - instances_item = instances_item_data.to_dict() - instances.append(instances_item) - - status: Union[Unset, str] = UNSET - if not isinstance(self.status, Unset): - status = self.status - - message = self.message - - error = self.error - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if uuid is not UNSET: - field_dict["uuid"] = uuid - if name is not UNSET: - field_dict["name"] = name - if created_at is not UNSET: - field_dict["created_at"] = created_at - if persistent is not UNSET: - field_dict["persistent"] = persistent - if autoscale is not UNSET: - field_dict["autoscale"] = autoscale - if soft_limit is not UNSET: - field_dict["soft_limit"] = soft_limit - if hard_limit is not UNSET: - field_dict["hard_limit"] = hard_limit - if services is not UNSET: - field_dict["services"] = services - if domains is not UNSET: - field_dict["domains"] = domains - if instances is not UNSET: - field_dict["instances"] = instances - if status is not UNSET: - field_dict["status"] = status - if message is not UNSET: - field_dict["message"] = message - if error is not UNSET: - field_dict["error"] = error - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.domain import Domain - from ..models.service import Service - from ..models.service_group_instance import ServiceGroupInstance - - d = dict(src_dict) - _uuid = d.pop("uuid", UNSET) - uuid: Union[Unset, UUID] - if isinstance(_uuid, Unset): - uuid = UNSET - else: - uuid = UUID(_uuid) - - name = d.pop("name", UNSET) - - _created_at = d.pop("created_at", UNSET) - created_at: Union[Unset, datetime.datetime] - if isinstance(_created_at, Unset): - created_at = UNSET - else: - created_at = isoparse(_created_at) - - persistent = d.pop("persistent", UNSET) - - autoscale = d.pop("autoscale", UNSET) - - soft_limit = d.pop("soft_limit", UNSET) - - hard_limit = d.pop("hard_limit", UNSET) - - services = [] - _services = d.pop("services", UNSET) - for services_item_data in _services or []: - services_item = Service.from_dict(services_item_data) - - services.append(services_item) - - domains = [] - _domains = d.pop("domains", UNSET) - for domains_item_data in _domains or []: - domains_item = Domain.from_dict(domains_item_data) - - domains.append(domains_item) - - instances = [] - _instances = d.pop("instances", UNSET) - for instances_item_data in _instances or []: - instances_item = ServiceGroupInstance.from_dict(instances_item_data) - - instances.append(instances_item) - - _status = d.pop("status", UNSET) - status: Union[Unset, ResponseStatus] - if isinstance(_status, Unset): - status = UNSET - else: - status = check_response_status(_status) - - message = d.pop("message", UNSET) - - error = d.pop("error", UNSET) - - service_group = cls( - uuid=uuid, - name=name, - created_at=created_at, - persistent=persistent, - autoscale=autoscale, - soft_limit=soft_limit, - hard_limit=hard_limit, - services=services, - domains=domains, - instances=instances, - status=status, - message=message, - error=error, - ) - - service_group.additional_properties = d - return service_group - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/service_group_instance.py b/unikraft_cloud_platform/models/service_group_instance.py deleted file mode 100644 index 8886666..0000000 --- a/unikraft_cloud_platform/models/service_group_instance.py +++ /dev/null @@ -1,78 +0,0 @@ -from collections.abc import Mapping -from typing import Any, TypeVar, Union -from uuid import UUID - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -T = TypeVar("T", bound="ServiceGroupInstance") - - -@_attrs_define -class ServiceGroupInstance: - uuid: Union[Unset, UUID] = UNSET - """ The UUID of the instance. This is a unique identifier for the instance - that is generated when the instance is created. The UUID is used to - reference the instance in API calls and can be used to identify the - instance in all API calls that require an instance identifier. """ - name: Union[Unset, str] = UNSET - """ The name of the instance. This is a human-readable name that can be used - to identify the instance. The name must be unique within the context of - your account. If no name is specified, a random name is generated for - you. The name can also be used to identify the instance in API calls. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - uuid: Union[Unset, str] = UNSET - if not isinstance(self.uuid, Unset): - uuid = str(self.uuid) - - name = self.name - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if uuid is not UNSET: - field_dict["uuid"] = uuid - if name is not UNSET: - field_dict["name"] = name - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - d = dict(src_dict) - _uuid = d.pop("uuid", UNSET) - uuid: Union[Unset, UUID] - if isinstance(_uuid, Unset): - uuid = UNSET - else: - uuid = UUID(_uuid) - - name = d.pop("name", UNSET) - - service_group_instance = cls( - uuid=uuid, - name=name, - ) - - service_group_instance.additional_properties = d - return service_group_instance - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/service_group_template.py b/unikraft_cloud_platform/models/service_group_template.py deleted file mode 100644 index 27dbf05..0000000 --- a/unikraft_cloud_platform/models/service_group_template.py +++ /dev/null @@ -1,72 +0,0 @@ -from collections.abc import Mapping -from typing import Any, TypeVar, Union -from uuid import UUID - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -T = TypeVar("T", bound="ServiceGroupTemplate") - - -@_attrs_define -class ServiceGroupTemplate: - name: Union[Unset, str] = UNSET - """ The name of the template used for the autoscale configuration. """ - uuid: Union[Unset, UUID] = UNSET - """ The UUID of the template used for the autoscale configuration. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - name = self.name - - uuid: Union[Unset, str] = UNSET - if not isinstance(self.uuid, Unset): - uuid = str(self.uuid) - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if name is not UNSET: - field_dict["name"] = name - if uuid is not UNSET: - field_dict["uuid"] = uuid - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - d = dict(src_dict) - name = d.pop("name", UNSET) - - _uuid = d.pop("uuid", UNSET) - uuid: Union[Unset, UUID] - if isinstance(_uuid, Unset): - uuid = UNSET - else: - uuid = UUID(_uuid) - - service_group_template = cls( - name=name, - uuid=uuid, - ) - - service_group_template.additional_properties = d - return service_group_template - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/service_handlers_item.py b/unikraft_cloud_platform/models/service_handlers_item.py deleted file mode 100644 index c3ac1aa..0000000 --- a/unikraft_cloud_platform/models/service_handlers_item.py +++ /dev/null @@ -1,15 +0,0 @@ -from typing import Literal, cast - -ServiceHandlersItem = Literal["http", "redirect", "tls"] - -SERVICE_HANDLERS_ITEM_VALUES: set[ServiceHandlersItem] = { - "http", - "redirect", - "tls", -} - - -def check_service_handlers_item(value: str) -> ServiceHandlersItem: - if value in SERVICE_HANDLERS_ITEM_VALUES: - return cast(ServiceHandlersItem, value) - raise TypeError(f"Unexpected value {value!r}. Expected one of {SERVICE_HANDLERS_ITEM_VALUES!r}") diff --git a/unikraft_cloud_platform/models/service_mapping.py b/unikraft_cloud_platform/models/service_mapping.py new file mode 100644 index 0000000..bcbce6a --- /dev/null +++ b/unikraft_cloud_platform/models/service_mapping.py @@ -0,0 +1,103 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from typing import Optional, Set +from typing_extensions import Self + + +class ServiceMapping(BaseModel): + """ + ServiceMapping + """ # noqa: E501 + + port: Annotated[int, Field(le=65535, strict=True, ge=1)] = Field(description="Public-facing port. ") + destination_port: Optional[Annotated[int, Field(le=65535, strict=True, ge=1)]] = Field( + default=None, description="Application port to which inbound traffic is redirected. " + ) + handlers: Optional[Annotated[List[StrictStr], Field(max_length=253)]] = Field( + default=None, description="See [Connection Handlers](https://unikraft.cloud/docs/api/v1/services/#handlers). " + ) + __properties: ClassVar[List[str]] = ["port", "destination_port", "handlers"] + + @field_validator("handlers") + def handlers_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + for i in value: + if i not in set(["tls", "http", "redirect"]): + raise ValueError("each list item must be one of ('tls', 'http', 'redirect')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of ServiceMapping from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of ServiceMapping from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + {"port": obj.get("port"), "destination_port": obj.get("destination_port"), "handlers": obj.get("handlers")} + ) + return _obj diff --git a/unikraft_cloud_platform/models/start_instance_response.py b/unikraft_cloud_platform/models/start_instance_response.py deleted file mode 100644 index bac6a23..0000000 --- a/unikraft_cloud_platform/models/start_instance_response.py +++ /dev/null @@ -1,130 +0,0 @@ -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..models.response_status import ResponseStatus, check_response_status -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.response_error import ResponseError - from ..models.start_instance_response_data import StartInstanceResponseData - - -T = TypeVar("T", bound="StartInstanceResponse") - - -@_attrs_define -class StartInstanceResponse: - """The response message for starting one or more instance(s) given their UUID(s) - or name(s). - - """ - - status: Union[Unset, ResponseStatus] = UNSET - """ The response status of an API request. """ - message: Union[Unset, str] = UNSET - """ An optional message providing additional information about the status. - This field is useful when the status is not `success`. """ - data: Union[Unset, "StartInstanceResponseData"] = UNSET - errors: Union[Unset, list["ResponseError"]] = UNSET - """ A list of errors which may have occurred during the request. """ - op_time_us: Union[Unset, int] = UNSET - """ The operation time in microseconds. This is the time it took to process - the request and generate the response. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - status: Union[Unset, str] = UNSET - if not isinstance(self.status, Unset): - status = self.status - - message = self.message - - data: Union[Unset, dict[str, Any]] = UNSET - if not isinstance(self.data, Unset): - data = self.data.to_dict() - - errors: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.errors, Unset): - errors = [] - for errors_item_data in self.errors: - errors_item = errors_item_data.to_dict() - errors.append(errors_item) - - op_time_us = self.op_time_us - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if status is not UNSET: - field_dict["status"] = status - if message is not UNSET: - field_dict["message"] = message - if data is not UNSET: - field_dict["data"] = data - if errors is not UNSET: - field_dict["errors"] = errors - if op_time_us is not UNSET: - field_dict["op_time_us"] = op_time_us - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.response_error import ResponseError - from ..models.start_instance_response_data import StartInstanceResponseData - - d = dict(src_dict) - _status = d.pop("status", UNSET) - status: Union[Unset, ResponseStatus] - if isinstance(_status, Unset): - status = UNSET - else: - status = check_response_status(_status) - - message = d.pop("message", UNSET) - - _data = d.pop("data", UNSET) - data: Union[Unset, StartInstanceResponseData] - if isinstance(_data, Unset): - data = UNSET - else: - data = StartInstanceResponseData.from_dict(_data) - - errors = [] - _errors = d.pop("errors", UNSET) - for errors_item_data in _errors or []: - errors_item = ResponseError.from_dict(errors_item_data) - - errors.append(errors_item) - - op_time_us = d.pop("op_time_us", UNSET) - - start_instance_response = cls( - status=status, - message=message, - data=data, - errors=errors, - op_time_us=op_time_us, - ) - - start_instance_response.additional_properties = d - return start_instance_response - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/start_instance_response_data.py b/unikraft_cloud_platform/models/start_instance_response_data.py deleted file mode 100644 index 8e2c2ce..0000000 --- a/unikraft_cloud_platform/models/start_instance_response_data.py +++ /dev/null @@ -1,71 +0,0 @@ -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.start_instance_response_started_instance import StartInstanceResponseStartedInstance - - -T = TypeVar("T", bound="StartInstanceResponseData") - - -@_attrs_define -class StartInstanceResponseData: - instances: Union[Unset, list["StartInstanceResponseStartedInstance"]] = UNSET - """ The instance(s) which were started by the request. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - instances: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.instances, Unset): - instances = [] - for instances_item_data in self.instances: - instances_item = instances_item_data.to_dict() - instances.append(instances_item) - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if instances is not UNSET: - field_dict["instances"] = instances - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.start_instance_response_started_instance import StartInstanceResponseStartedInstance - - d = dict(src_dict) - instances = [] - _instances = d.pop("instances", UNSET) - for instances_item_data in _instances or []: - instances_item = StartInstanceResponseStartedInstance.from_dict(instances_item_data) - - instances.append(instances_item) - - start_instance_response_data = cls( - instances=instances, - ) - - start_instance_response_data.additional_properties = d - return start_instance_response_data - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/start_instance_response_started_instance.py b/unikraft_cloud_platform/models/start_instance_response_started_instance.py deleted file mode 100644 index 10295b9..0000000 --- a/unikraft_cloud_platform/models/start_instance_response_started_instance.py +++ /dev/null @@ -1,127 +0,0 @@ -from collections.abc import Mapping -from typing import Any, TypeVar, Union -from uuid import UUID - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..models.response_status import ResponseStatus, check_response_status -from ..types import UNSET, Unset - -T = TypeVar("T", bound="StartInstanceResponseStartedInstance") - - -@_attrs_define -class StartInstanceResponseStartedInstance: - status: Union[Unset, ResponseStatus] = UNSET - """ The response status of an API request. """ - uuid: Union[Unset, UUID] = UNSET - """ The UUID of the instance which was deleted. """ - name: Union[Unset, str] = UNSET - """ The name of the instance which was deleted. """ - state: Union[Unset, str] = UNSET - """ The current state of the instance after this request. """ - previous_state: Union[Unset, str] = UNSET - """ The previous state of the instance before it was deleted. """ - message: Union[Unset, str] = UNSET - """ An optional message providing additional information about the status. - This field is useful when the status is not `success`. """ - error: Union[Unset, int] = UNSET - """ An optional error code providing additional information about the status. - This field is useful when the status is not `success`. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - status: Union[Unset, str] = UNSET - if not isinstance(self.status, Unset): - status = self.status - - uuid: Union[Unset, str] = UNSET - if not isinstance(self.uuid, Unset): - uuid = str(self.uuid) - - name = self.name - - state = self.state - - previous_state = self.previous_state - - message = self.message - - error = self.error - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if status is not UNSET: - field_dict["status"] = status - if uuid is not UNSET: - field_dict["uuid"] = uuid - if name is not UNSET: - field_dict["name"] = name - if state is not UNSET: - field_dict["state"] = state - if previous_state is not UNSET: - field_dict["previous_state"] = previous_state - if message is not UNSET: - field_dict["message"] = message - if error is not UNSET: - field_dict["error"] = error - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - d = dict(src_dict) - _status = d.pop("status", UNSET) - status: Union[Unset, ResponseStatus] - if isinstance(_status, Unset): - status = UNSET - else: - status = check_response_status(_status) - - _uuid = d.pop("uuid", UNSET) - uuid: Union[Unset, UUID] - if isinstance(_uuid, Unset): - uuid = UNSET - else: - uuid = UUID(_uuid) - - name = d.pop("name", UNSET) - - state = d.pop("state", UNSET) - - previous_state = d.pop("previous_state", UNSET) - - message = d.pop("message", UNSET) - - error = d.pop("error", UNSET) - - start_instance_response_started_instance = cls( - status=status, - uuid=uuid, - name=name, - state=state, - previous_state=previous_state, - message=message, - error=error, - ) - - start_instance_response_started_instance.additional_properties = d - return start_instance_response_started_instance - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/start_instances200_response.py b/unikraft_cloud_platform/models/start_instances200_response.py new file mode 100644 index 0000000..80cf92a --- /dev/null +++ b/unikraft_cloud_platform/models/start_instances200_response.py @@ -0,0 +1,103 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from unikraft_cloud_platform.models.start_instances200_response_data import StartInstances200ResponseData +from typing import Optional, Set +from typing_extensions import Self + + +class StartInstances200Response(BaseModel): + """ + StartInstances200Response + """ # noqa: E501 + + status: Optional[StrictStr] = Field(default=None, description="The status of the response. ") + data: Optional[StartInstances200ResponseData] = None + __properties: ClassVar[List[str]] = ["status", "data"] + + @field_validator("status") + def status_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(["success", "failure"]): + raise ValueError("must be one of enum values ('success', 'failure')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of StartInstances200Response from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of data + if self.data: + _dict["data"] = self.data.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of StartInstances200Response from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "status": obj.get("status"), + "data": StartInstances200ResponseData.from_dict(obj["data"]) if obj.get("data") is not None else None, + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/start_instances200_response_data.py b/unikraft_cloud_platform/models/start_instances200_response_data.py new file mode 100644 index 0000000..c49491b --- /dev/null +++ b/unikraft_cloud_platform/models/start_instances200_response_data.py @@ -0,0 +1,102 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from unikraft_cloud_platform.models.start_instances200_response_data_instances_inner import ( + StartInstances200ResponseDataInstancesInner, +) +from typing import Optional, Set +from typing_extensions import Self + + +class StartInstances200ResponseData(BaseModel): + """ + StartInstances200ResponseData + """ # noqa: E501 + + instances: Optional[Annotated[List[StartInstances200ResponseDataInstancesInner], Field(max_length=253)]] = None + __properties: ClassVar[List[str]] = ["instances"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of StartInstances200ResponseData from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in instances (list) + _items = [] + if self.instances: + for _item_instances in self.instances: + if _item_instances: + _items.append(_item_instances.to_dict()) + _dict["instances"] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of StartInstances200ResponseData from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "instances": [ + StartInstances200ResponseDataInstancesInner.from_dict(_item) for _item in obj["instances"] + ] + if obj.get("instances") is not None + else None + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/start_instances200_response_data_instances_inner.py b/unikraft_cloud_platform/models/start_instances200_response_data_instances_inner.py new file mode 100644 index 0000000..7ae2184 --- /dev/null +++ b/unikraft_cloud_platform/models/start_instances200_response_data_instances_inner.py @@ -0,0 +1,139 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from uuid import UUID +from typing import Optional, Set +from typing_extensions import Self + + +class StartInstances200ResponseDataInstancesInner(BaseModel): + """ + StartInstances200ResponseDataInstancesInner + """ # noqa: E501 + + status: Optional[StrictStr] = Field(default=None, description="The status of the response. ") + uuid: Optional[UUID] = Field(default=None, description="The UUID of the instance. ") + name: Optional[Annotated[str, Field(strict=True, max_length=255)]] = Field( + default=None, description="The name of the instance. " + ) + state: Optional[StrictStr] = Field( + default=None, + description="An instance can be in one of the following states: State | Description ----------|------------ `stopped` | The instance is not running and does not count against live resource quotas. Connections cannot be established. `starting`| The instance is booting up. This usually takes just a few milliseconds. `running` | Your application's main entry point has been reached. `draining`| The instance is draining connections before shutting down. No new connections can be established. `stopping`| The instance is shutting down. `standby` | The instance has [scale-to-zero](https://unikraft.cloud/docs/api/v1/autoscale#scaletozero) enabled. The instance is not running, but will be automatically started when there are incoming requests. ", + ) + previous_state: Optional[StrictStr] = Field( + default=None, + description="An instance can be in one of the following states: State | Description ----------|------------ `stopped` | The instance is not running and does not count against live resource quotas. Connections cannot be established. `starting`| The instance is booting up. This usually takes just a few milliseconds. `running` | Your application's main entry point has been reached. `draining`| The instance is draining connections before shutting down. No new connections can be established. `stopping`| The instance is shutting down. `standby` | The instance has [scale-to-zero](https://unikraft.cloud/docs/api/v1/autoscale#scaletozero) enabled. The instance is not running, but will be automatically started when there are incoming requests. ", + ) + __properties: ClassVar[List[str]] = ["status", "uuid", "name", "state", "previous_state"] + + @field_validator("status") + def status_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(["success", "error"]): + raise ValueError("must be one of enum values ('success', 'error')") + return value + + @field_validator("state") + def state_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(["stopped", "starting", "running", "draining", "stopping", "standby"]): + raise ValueError( + "must be one of enum values ('stopped', 'starting', 'running', 'draining', 'stopping', 'standby')" + ) + return value + + @field_validator("previous_state") + def previous_state_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(["stopped", "starting", "running", "draining", "stopping", "standby"]): + raise ValueError( + "must be one of enum values ('stopped', 'starting', 'running', 'draining', 'stopping', 'standby')" + ) + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of StartInstances200ResponseDataInstancesInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of StartInstances200ResponseDataInstancesInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "status": obj.get("status"), + "uuid": obj.get("uuid"), + "name": obj.get("name"), + "state": obj.get("state"), + "previous_state": obj.get("previous_state"), + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/start_instances_request_inner.py b/unikraft_cloud_platform/models/start_instances_request_inner.py new file mode 100644 index 0000000..1c8df4f --- /dev/null +++ b/unikraft_cloud_platform/models/start_instances_request_inner.py @@ -0,0 +1,92 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from uuid import UUID +from typing import Optional, Set +from typing_extensions import Self + + +class StartInstancesRequestInner(BaseModel): + """ + StartInstancesRequestInner + """ # noqa: E501 + + uuid: Optional[UUID] = Field( + default=None, + description="The UUID of the instance to start. Note: This property is mutually exclusive with `name` and either `uuid` or `name` are required. ", + ) + name: Optional[Annotated[str, Field(strict=True, max_length=255)]] = Field( + default=None, + description="The name of the instance to start. Note: This property is mutually exclusive with `uuid` and either `uuid` or `name` are required. ", + ) + __properties: ClassVar[List[str]] = ["uuid", "name"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of StartInstancesRequestInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of StartInstancesRequestInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({"uuid": obj.get("uuid"), "name": obj.get("name")}) + return _obj diff --git a/unikraft_cloud_platform/models/stop_instance_response.py b/unikraft_cloud_platform/models/stop_instance_response.py deleted file mode 100644 index aedf688..0000000 --- a/unikraft_cloud_platform/models/stop_instance_response.py +++ /dev/null @@ -1,130 +0,0 @@ -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..models.response_status import ResponseStatus, check_response_status -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.response_error import ResponseError - from ..models.stop_instance_response_data import StopInstanceResponseData - - -T = TypeVar("T", bound="StopInstanceResponse") - - -@_attrs_define -class StopInstanceResponse: - """The response message for stopping one or more instance(s) given their UUID(s) - or name(s). - - """ - - status: Union[Unset, ResponseStatus] = UNSET - """ The response status of an API request. """ - message: Union[Unset, str] = UNSET - """ An optional message providing additional information about the status. - This field is useful when the status is not `success`. """ - data: Union[Unset, "StopInstanceResponseData"] = UNSET - errors: Union[Unset, list["ResponseError"]] = UNSET - """ A list of errors which may have occurred during the request. """ - op_time_us: Union[Unset, int] = UNSET - """ The operation time in microseconds. This is the time it took to process - the request and generate the response. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - status: Union[Unset, str] = UNSET - if not isinstance(self.status, Unset): - status = self.status - - message = self.message - - data: Union[Unset, dict[str, Any]] = UNSET - if not isinstance(self.data, Unset): - data = self.data.to_dict() - - errors: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.errors, Unset): - errors = [] - for errors_item_data in self.errors: - errors_item = errors_item_data.to_dict() - errors.append(errors_item) - - op_time_us = self.op_time_us - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if status is not UNSET: - field_dict["status"] = status - if message is not UNSET: - field_dict["message"] = message - if data is not UNSET: - field_dict["data"] = data - if errors is not UNSET: - field_dict["errors"] = errors - if op_time_us is not UNSET: - field_dict["op_time_us"] = op_time_us - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.response_error import ResponseError - from ..models.stop_instance_response_data import StopInstanceResponseData - - d = dict(src_dict) - _status = d.pop("status", UNSET) - status: Union[Unset, ResponseStatus] - if isinstance(_status, Unset): - status = UNSET - else: - status = check_response_status(_status) - - message = d.pop("message", UNSET) - - _data = d.pop("data", UNSET) - data: Union[Unset, StopInstanceResponseData] - if isinstance(_data, Unset): - data = UNSET - else: - data = StopInstanceResponseData.from_dict(_data) - - errors = [] - _errors = d.pop("errors", UNSET) - for errors_item_data in _errors or []: - errors_item = ResponseError.from_dict(errors_item_data) - - errors.append(errors_item) - - op_time_us = d.pop("op_time_us", UNSET) - - stop_instance_response = cls( - status=status, - message=message, - data=data, - errors=errors, - op_time_us=op_time_us, - ) - - stop_instance_response.additional_properties = d - return stop_instance_response - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/stop_instance_response_data.py b/unikraft_cloud_platform/models/stop_instance_response_data.py deleted file mode 100644 index 6ff1b50..0000000 --- a/unikraft_cloud_platform/models/stop_instance_response_data.py +++ /dev/null @@ -1,71 +0,0 @@ -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.stop_instance_response_stopped_instance import StopInstanceResponseStoppedInstance - - -T = TypeVar("T", bound="StopInstanceResponseData") - - -@_attrs_define -class StopInstanceResponseData: - instances: Union[Unset, list["StopInstanceResponseStoppedInstance"]] = UNSET - """ The instance(s) which were stopped by the request. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - instances: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.instances, Unset): - instances = [] - for instances_item_data in self.instances: - instances_item = instances_item_data.to_dict() - instances.append(instances_item) - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if instances is not UNSET: - field_dict["instances"] = instances - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.stop_instance_response_stopped_instance import StopInstanceResponseStoppedInstance - - d = dict(src_dict) - instances = [] - _instances = d.pop("instances", UNSET) - for instances_item_data in _instances or []: - instances_item = StopInstanceResponseStoppedInstance.from_dict(instances_item_data) - - instances.append(instances_item) - - stop_instance_response_data = cls( - instances=instances, - ) - - stop_instance_response_data.additional_properties = d - return stop_instance_response_data - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/stop_instance_response_stopped_instance.py b/unikraft_cloud_platform/models/stop_instance_response_stopped_instance.py deleted file mode 100644 index bfe210e..0000000 --- a/unikraft_cloud_platform/models/stop_instance_response_stopped_instance.py +++ /dev/null @@ -1,132 +0,0 @@ -from collections.abc import Mapping -from typing import Any, TypeVar, Union -from uuid import UUID - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..models.stop_instance_response_stopped_instance_previous_state import ( - StopInstanceResponseStoppedInstancePreviousState, - check_stop_instance_response_stopped_instance_previous_state, -) -from ..models.stop_instance_response_stopped_instance_state import ( - StopInstanceResponseStoppedInstanceState, - check_stop_instance_response_stopped_instance_state, -) -from ..types import UNSET, Unset - -T = TypeVar("T", bound="StopInstanceResponseStoppedInstance") - - -@_attrs_define -class StopInstanceResponseStoppedInstance: - uuid: Union[Unset, UUID] = UNSET - """ The UUID of the instance. """ - name: Union[Unset, str] = UNSET - """ The name of the instance. """ - state: Union[Unset, StopInstanceResponseStoppedInstanceState] = UNSET - """ The current state of the instance. """ - previous_state: Union[Unset, StopInstanceResponseStoppedInstancePreviousState] = UNSET - """ The previous state of the instance before the stop operation was invoked. """ - message: Union[Unset, str] = UNSET - """ An optional message providing additional information about the status. - This field is useful when the status is not `success`. """ - error: Union[Unset, int] = UNSET - """ An optional error code providing additional information about the status. - This field is useful when the status is not `success`. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - uuid: Union[Unset, str] = UNSET - if not isinstance(self.uuid, Unset): - uuid = str(self.uuid) - - name = self.name - - state: Union[Unset, str] = UNSET - if not isinstance(self.state, Unset): - state = self.state - - previous_state: Union[Unset, str] = UNSET - if not isinstance(self.previous_state, Unset): - previous_state = self.previous_state - - message = self.message - - error = self.error - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if uuid is not UNSET: - field_dict["uuid"] = uuid - if name is not UNSET: - field_dict["name"] = name - if state is not UNSET: - field_dict["state"] = state - if previous_state is not UNSET: - field_dict["previous_state"] = previous_state - if message is not UNSET: - field_dict["message"] = message - if error is not UNSET: - field_dict["error"] = error - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - d = dict(src_dict) - _uuid = d.pop("uuid", UNSET) - uuid: Union[Unset, UUID] - if isinstance(_uuid, Unset): - uuid = UNSET - else: - uuid = UUID(_uuid) - - name = d.pop("name", UNSET) - - _state = d.pop("state", UNSET) - state: Union[Unset, StopInstanceResponseStoppedInstanceState] - if isinstance(_state, Unset): - state = UNSET - else: - state = check_stop_instance_response_stopped_instance_state(_state) - - _previous_state = d.pop("previous_state", UNSET) - previous_state: Union[Unset, StopInstanceResponseStoppedInstancePreviousState] - if isinstance(_previous_state, Unset): - previous_state = UNSET - else: - previous_state = check_stop_instance_response_stopped_instance_previous_state(_previous_state) - - message = d.pop("message", UNSET) - - error = d.pop("error", UNSET) - - stop_instance_response_stopped_instance = cls( - uuid=uuid, - name=name, - state=state, - previous_state=previous_state, - message=message, - error=error, - ) - - stop_instance_response_stopped_instance.additional_properties = d - return stop_instance_response_stopped_instance - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/stop_instance_response_stopped_instance_previous_state.py b/unikraft_cloud_platform/models/stop_instance_response_stopped_instance_previous_state.py deleted file mode 100644 index c7bba85..0000000 --- a/unikraft_cloud_platform/models/stop_instance_response_stopped_instance_previous_state.py +++ /dev/null @@ -1,24 +0,0 @@ -from typing import Literal, cast - -StopInstanceResponseStoppedInstancePreviousState = Literal[ - "draining", "running", "standby", "starting", "stopped", "stopping" -] - -STOP_INSTANCE_RESPONSE_STOPPED_INSTANCE_PREVIOUS_STATE_VALUES: set[StopInstanceResponseStoppedInstancePreviousState] = { - "draining", - "running", - "standby", - "starting", - "stopped", - "stopping", -} - - -def check_stop_instance_response_stopped_instance_previous_state( - value: str, -) -> StopInstanceResponseStoppedInstancePreviousState: - if value in STOP_INSTANCE_RESPONSE_STOPPED_INSTANCE_PREVIOUS_STATE_VALUES: - return cast(StopInstanceResponseStoppedInstancePreviousState, value) - raise TypeError( - f"Unexpected value {value!r}. Expected one of {STOP_INSTANCE_RESPONSE_STOPPED_INSTANCE_PREVIOUS_STATE_VALUES!r}" - ) diff --git a/unikraft_cloud_platform/models/stop_instance_response_stopped_instance_state.py b/unikraft_cloud_platform/models/stop_instance_response_stopped_instance_state.py deleted file mode 100644 index c98a2f2..0000000 --- a/unikraft_cloud_platform/models/stop_instance_response_stopped_instance_state.py +++ /dev/null @@ -1,20 +0,0 @@ -from typing import Literal, cast - -StopInstanceResponseStoppedInstanceState = Literal["draining", "running", "standby", "starting", "stopped", "stopping"] - -STOP_INSTANCE_RESPONSE_STOPPED_INSTANCE_STATE_VALUES: set[StopInstanceResponseStoppedInstanceState] = { - "draining", - "running", - "standby", - "starting", - "stopped", - "stopping", -} - - -def check_stop_instance_response_stopped_instance_state(value: str) -> StopInstanceResponseStoppedInstanceState: - if value in STOP_INSTANCE_RESPONSE_STOPPED_INSTANCE_STATE_VALUES: - return cast(StopInstanceResponseStoppedInstanceState, value) - raise TypeError( - f"Unexpected value {value!r}. Expected one of {STOP_INSTANCE_RESPONSE_STOPPED_INSTANCE_STATE_VALUES!r}" - ) diff --git a/unikraft_cloud_platform/models/stop_instances_request_id.py b/unikraft_cloud_platform/models/stop_instances_request_id.py deleted file mode 100644 index 621f2e5..0000000 --- a/unikraft_cloud_platform/models/stop_instances_request_id.py +++ /dev/null @@ -1,92 +0,0 @@ -from collections.abc import Mapping -from typing import Any, TypeVar, Union -from uuid import UUID - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -T = TypeVar("T", bound="StopInstancesRequestID") - - -@_attrs_define -class StopInstancesRequestID: - """An identifier for the instance(s) to start.""" - - uuid: UUID - """ The UUID of the instance to stop. Mutually exclusive with name. """ - name: str - """ The name of the instance to stop. Mutually exclusive with UUID. """ - force: Union[Unset, bool] = UNSET - """ Whether to immediately force stop the instance. """ - drain_timeout_ms: Union[Unset, int] = UNSET - """ Timeout for draining connections in milliseconds. The instance does not - receive new connections in the draining phase. The instance is stopped - when the last connection has been closed or the timeout expired. The - maximum timeout may vary. Use -1 for the largest possible value. - - Note: This endpoint does not block. Use the wait endpoint for the - instance to reach the stopped state. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - uuid = str(self.uuid) - - name = self.name - - force = self.force - - drain_timeout_ms = self.drain_timeout_ms - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update( - { - "uuid": uuid, - "name": name, - } - ) - if force is not UNSET: - field_dict["force"] = force - if drain_timeout_ms is not UNSET: - field_dict["drain_timeout_ms"] = drain_timeout_ms - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - d = dict(src_dict) - uuid = UUID(d.pop("uuid")) - - name = d.pop("name") - - force = d.pop("force", UNSET) - - drain_timeout_ms = d.pop("drain_timeout_ms", UNSET) - - stop_instances_request_id = cls( - uuid=uuid, - name=name, - force=force, - drain_timeout_ms=drain_timeout_ms, - ) - - stop_instances_request_id.additional_properties = d - return stop_instances_request_id - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/stop_instances_request_inner.py b/unikraft_cloud_platform/models/stop_instances_request_inner.py new file mode 100644 index 0000000..310dbc9 --- /dev/null +++ b/unikraft_cloud_platform/models/stop_instances_request_inner.py @@ -0,0 +1,104 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictBool +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from uuid import UUID +from typing import Optional, Set +from typing_extensions import Self + + +class StopInstancesRequestInner(BaseModel): + """ + StopInstancesRequestInner + """ # noqa: E501 + + uuid: Optional[UUID] = Field( + default=None, + description="The UUID of the instance to get the status for. Note: This property is mutually exclusive with `name` and either `uuid` or `name` are required. ", + ) + name: Optional[Annotated[str, Field(strict=True, max_length=255)]] = Field( + default=None, + description="The name of the instance to get the status for. Note: This property is mutually exclusive with `uuid` and either `uuid` or `name` are required. ", + ) + force: Optional[StrictBool] = Field(default=False, description="Forces immediate shutdown. ") + drain_timeout_ms: Optional[Annotated[int, Field(le=3600000, strict=True, ge=0)]] = Field( + default=0, + description="Timeout for draining connections in milliseconds. The instance does not receive new connections in the draining phase. The instance is stopped when the last connection has been closed or the timeout expired. ", + ) + __properties: ClassVar[List[str]] = ["uuid", "name", "force", "drain_timeout_ms"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of StopInstancesRequestInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of StopInstancesRequestInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "uuid": obj.get("uuid"), + "name": obj.get("name"), + "force": obj.get("force") if obj.get("force") is not None else False, + "drain_timeout_ms": obj.get("drain_timeout_ms") if obj.get("drain_timeout_ms") is not None else 0, + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/update_instance_by_uuid_request_body.py b/unikraft_cloud_platform/models/update_instance_by_uuid_request_body.py deleted file mode 100644 index 80c4abb..0000000 --- a/unikraft_cloud_platform/models/update_instance_by_uuid_request_body.py +++ /dev/null @@ -1,93 +0,0 @@ -from collections.abc import Mapping -from typing import Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..models.update_instance_by_uuid_request_body_op import ( - UpdateInstanceByUUIDRequestBodyOp, - check_update_instance_by_uuid_request_body_op, -) -from ..models.update_instance_by_uuid_request_body_prop import ( - UpdateInstanceByUUIDRequestBodyProp, - check_update_instance_by_uuid_request_body_prop, -) -from ..types import UNSET, Unset - -T = TypeVar("T", bound="UpdateInstanceByUUIDRequestBody") - - -@_attrs_define -class UpdateInstanceByUUIDRequestBody: - prop: UpdateInstanceByUUIDRequestBodyProp - """ The property to modify. """ - op: UpdateInstanceByUUIDRequestBodyOp - """ The operation to perform on the property. """ - id: Union[Unset, str] = UNSET - """ (Optional). A client-provided identifier for tracking this operation in - the response. """ - value: Union[Unset, Any] = UNSET - """ Represents a dynamically typed value which can be either null, a number, a string, a boolean, a recursive - struct value, or a list of values. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - prop: str = self.prop - - op: str = self.op - - id = self.id - - value = self.value - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update( - { - "prop": prop, - "op": op, - } - ) - if id is not UNSET: - field_dict["id"] = id - if value is not UNSET: - field_dict["value"] = value - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - d = dict(src_dict) - prop = check_update_instance_by_uuid_request_body_prop(d.pop("prop")) - - op = check_update_instance_by_uuid_request_body_op(d.pop("op")) - - id = d.pop("id", UNSET) - - value = d.pop("value", UNSET) - - update_instance_by_uuid_request_body = cls( - prop=prop, - op=op, - id=id, - value=value, - ) - - update_instance_by_uuid_request_body.additional_properties = d - return update_instance_by_uuid_request_body - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/update_instance_by_uuid_request_body_op.py b/unikraft_cloud_platform/models/update_instance_by_uuid_request_body_op.py deleted file mode 100644 index b2a74e8..0000000 --- a/unikraft_cloud_platform/models/update_instance_by_uuid_request_body_op.py +++ /dev/null @@ -1,15 +0,0 @@ -from typing import Literal, cast - -UpdateInstanceByUUIDRequestBodyOp = Literal["add", "del", "set"] - -UPDATE_INSTANCE_BY_UUID_REQUEST_BODY_OP_VALUES: set[UpdateInstanceByUUIDRequestBodyOp] = { - "add", - "del", - "set", -} - - -def check_update_instance_by_uuid_request_body_op(value: str) -> UpdateInstanceByUUIDRequestBodyOp: - if value in UPDATE_INSTANCE_BY_UUID_REQUEST_BODY_OP_VALUES: - return cast(UpdateInstanceByUUIDRequestBodyOp, value) - raise TypeError(f"Unexpected value {value!r}. Expected one of {UPDATE_INSTANCE_BY_UUID_REQUEST_BODY_OP_VALUES!r}") diff --git a/unikraft_cloud_platform/models/update_instance_by_uuid_request_body_prop.py b/unikraft_cloud_platform/models/update_instance_by_uuid_request_body_prop.py deleted file mode 100644 index ffdd35e..0000000 --- a/unikraft_cloud_platform/models/update_instance_by_uuid_request_body_prop.py +++ /dev/null @@ -1,22 +0,0 @@ -from typing import Literal, cast - -UpdateInstanceByUUIDRequestBodyProp = Literal[ - "args", "delete_lock", "env", "image", "memory_mb", "scale_to_zero", "tags", "vcpus" -] - -UPDATE_INSTANCE_BY_UUID_REQUEST_BODY_PROP_VALUES: set[UpdateInstanceByUUIDRequestBodyProp] = { - "args", - "delete_lock", - "env", - "image", - "memory_mb", - "scale_to_zero", - "tags", - "vcpus", -} - - -def check_update_instance_by_uuid_request_body_prop(value: str) -> UpdateInstanceByUUIDRequestBodyProp: - if value in UPDATE_INSTANCE_BY_UUID_REQUEST_BODY_PROP_VALUES: - return cast(UpdateInstanceByUUIDRequestBodyProp, value) - raise TypeError(f"Unexpected value {value!r}. Expected one of {UPDATE_INSTANCE_BY_UUID_REQUEST_BODY_PROP_VALUES!r}") diff --git a/unikraft_cloud_platform/models/update_instances_request.py b/unikraft_cloud_platform/models/update_instances_request.py deleted file mode 100644 index d50deda..0000000 --- a/unikraft_cloud_platform/models/update_instances_request.py +++ /dev/null @@ -1,114 +0,0 @@ -from collections.abc import Mapping -from typing import Any, TypeVar, Union -from uuid import UUID - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..models.update_instances_request_op import UpdateInstancesRequestOp, check_update_instances_request_op -from ..models.update_instances_request_prop import UpdateInstancesRequestProp, check_update_instances_request_prop -from ..types import UNSET, Unset - -T = TypeVar("T", bound="UpdateInstancesRequest") - - -@_attrs_define -class UpdateInstancesRequest: - """The request message for updating one or more instances.""" - - prop: UpdateInstancesRequestProp - """ The property to modify. """ - op: UpdateInstancesRequestOp - """ The operation to perform on the property. """ - id: Union[Unset, str] = UNSET - """ (Optional). A client-provided identifier for tracking this operation in the response. """ - uuid: Union[Unset, UUID] = UNSET - """ The UUID of the instance to update. Mutually exclusive with name. """ - name: Union[Unset, str] = UNSET - """ The name of the instance to update. Mutually exclusive with UUID. """ - value: Union[Unset, Any] = UNSET - """ Represents a dynamically typed value which can be either null, a number, a string, a boolean, a recursive - struct value, or a list of values. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - prop: str = self.prop - - op: str = self.op - - id = self.id - - uuid: Union[Unset, str] = UNSET - if not isinstance(self.uuid, Unset): - uuid = str(self.uuid) - - name = self.name - - value = self.value - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update( - { - "prop": prop, - "op": op, - } - ) - if id is not UNSET: - field_dict["id"] = id - if uuid is not UNSET: - field_dict["uuid"] = uuid - if name is not UNSET: - field_dict["name"] = name - if value is not UNSET: - field_dict["value"] = value - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - d = dict(src_dict) - prop = check_update_instances_request_prop(d.pop("prop")) - - op = check_update_instances_request_op(d.pop("op")) - - id = d.pop("id", UNSET) - - _uuid = d.pop("uuid", UNSET) - uuid: Union[Unset, UUID] - if isinstance(_uuid, Unset): - uuid = UNSET - else: - uuid = UUID(_uuid) - - name = d.pop("name", UNSET) - - value = d.pop("value", UNSET) - - update_instances_request = cls( - prop=prop, - op=op, - id=id, - uuid=uuid, - name=name, - value=value, - ) - - update_instances_request.additional_properties = d - return update_instances_request - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/update_instances_request_op.py b/unikraft_cloud_platform/models/update_instances_request_op.py deleted file mode 100644 index a7e6705..0000000 --- a/unikraft_cloud_platform/models/update_instances_request_op.py +++ /dev/null @@ -1,15 +0,0 @@ -from typing import Literal, cast - -UpdateInstancesRequestOp = Literal["add", "del", "set"] - -UPDATE_INSTANCES_REQUEST_OP_VALUES: set[UpdateInstancesRequestOp] = { - "add", - "del", - "set", -} - - -def check_update_instances_request_op(value: str) -> UpdateInstancesRequestOp: - if value in UPDATE_INSTANCES_REQUEST_OP_VALUES: - return cast(UpdateInstancesRequestOp, value) - raise TypeError(f"Unexpected value {value!r}. Expected one of {UPDATE_INSTANCES_REQUEST_OP_VALUES!r}") diff --git a/unikraft_cloud_platform/models/update_instances_request_prop.py b/unikraft_cloud_platform/models/update_instances_request_prop.py deleted file mode 100644 index 8f19d18..0000000 --- a/unikraft_cloud_platform/models/update_instances_request_prop.py +++ /dev/null @@ -1,22 +0,0 @@ -from typing import Literal, cast - -UpdateInstancesRequestProp = Literal[ - "args", "delete_lock", "env", "image", "memory_mb", "scale_to_zero", "tags", "vcpus" -] - -UPDATE_INSTANCES_REQUEST_PROP_VALUES: set[UpdateInstancesRequestProp] = { - "args", - "delete_lock", - "env", - "image", - "memory_mb", - "scale_to_zero", - "tags", - "vcpus", -} - - -def check_update_instances_request_prop(value: str) -> UpdateInstancesRequestProp: - if value in UPDATE_INSTANCES_REQUEST_PROP_VALUES: - return cast(UpdateInstancesRequestProp, value) - raise TypeError(f"Unexpected value {value!r}. Expected one of {UPDATE_INSTANCES_REQUEST_PROP_VALUES!r}") diff --git a/unikraft_cloud_platform/models/update_instances_response.py b/unikraft_cloud_platform/models/update_instances_response.py deleted file mode 100644 index 5b16729..0000000 --- a/unikraft_cloud_platform/models/update_instances_response.py +++ /dev/null @@ -1,127 +0,0 @@ -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..models.response_status import ResponseStatus, check_response_status -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.response_error import ResponseError - from ..models.update_instances_response_data import UpdateInstancesResponseData - - -T = TypeVar("T", bound="UpdateInstancesResponse") - - -@_attrs_define -class UpdateInstancesResponse: - """The response message for updating one or more instances.""" - - status: Union[Unset, ResponseStatus] = UNSET - """ The response status of an API request. """ - message: Union[Unset, str] = UNSET - """ An optional message providing additional information about the status. - This field is useful when the status is not `success`. """ - data: Union[Unset, "UpdateInstancesResponseData"] = UNSET - errors: Union[Unset, list["ResponseError"]] = UNSET - """ A list of errors which may have occurred during the request. """ - op_time_us: Union[Unset, int] = UNSET - """ The operation time in microseconds. This is the time it took to process - the request and generate the response. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - status: Union[Unset, str] = UNSET - if not isinstance(self.status, Unset): - status = self.status - - message = self.message - - data: Union[Unset, dict[str, Any]] = UNSET - if not isinstance(self.data, Unset): - data = self.data.to_dict() - - errors: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.errors, Unset): - errors = [] - for errors_item_data in self.errors: - errors_item = errors_item_data.to_dict() - errors.append(errors_item) - - op_time_us = self.op_time_us - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if status is not UNSET: - field_dict["status"] = status - if message is not UNSET: - field_dict["message"] = message - if data is not UNSET: - field_dict["data"] = data - if errors is not UNSET: - field_dict["errors"] = errors - if op_time_us is not UNSET: - field_dict["op_time_us"] = op_time_us - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.response_error import ResponseError - from ..models.update_instances_response_data import UpdateInstancesResponseData - - d = dict(src_dict) - _status = d.pop("status", UNSET) - status: Union[Unset, ResponseStatus] - if isinstance(_status, Unset): - status = UNSET - else: - status = check_response_status(_status) - - message = d.pop("message", UNSET) - - _data = d.pop("data", UNSET) - data: Union[Unset, UpdateInstancesResponseData] - if isinstance(_data, Unset): - data = UNSET - else: - data = UpdateInstancesResponseData.from_dict(_data) - - errors = [] - _errors = d.pop("errors", UNSET) - for errors_item_data in _errors or []: - errors_item = ResponseError.from_dict(errors_item_data) - - errors.append(errors_item) - - op_time_us = d.pop("op_time_us", UNSET) - - update_instances_response = cls( - status=status, - message=message, - data=data, - errors=errors, - op_time_us=op_time_us, - ) - - update_instances_response.additional_properties = d - return update_instances_response - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/update_instances_response_data.py b/unikraft_cloud_platform/models/update_instances_response_data.py deleted file mode 100644 index 68d2278..0000000 --- a/unikraft_cloud_platform/models/update_instances_response_data.py +++ /dev/null @@ -1,71 +0,0 @@ -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.update_instances_response_updated_instance import UpdateInstancesResponseUpdatedInstance - - -T = TypeVar("T", bound="UpdateInstancesResponseData") - - -@_attrs_define -class UpdateInstancesResponseData: - instances: Union[Unset, list["UpdateInstancesResponseUpdatedInstance"]] = UNSET - """ List of instances that were processed during the update operation. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - instances: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.instances, Unset): - instances = [] - for instances_item_data in self.instances: - instances_item = instances_item_data.to_dict() - instances.append(instances_item) - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if instances is not UNSET: - field_dict["instances"] = instances - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.update_instances_response_updated_instance import UpdateInstancesResponseUpdatedInstance - - d = dict(src_dict) - instances = [] - _instances = d.pop("instances", UNSET) - for instances_item_data in _instances or []: - instances_item = UpdateInstancesResponseUpdatedInstance.from_dict(instances_item_data) - - instances.append(instances_item) - - update_instances_response_data = cls( - instances=instances, - ) - - update_instances_response_data.additional_properties = d - return update_instances_response_data - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/update_instances_response_updated_instance.py b/unikraft_cloud_platform/models/update_instances_response_updated_instance.py deleted file mode 100644 index 1b3b839..0000000 --- a/unikraft_cloud_platform/models/update_instances_response_updated_instance.py +++ /dev/null @@ -1,110 +0,0 @@ -from collections.abc import Mapping -from typing import Any, TypeVar, Union -from uuid import UUID - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -T = TypeVar("T", bound="UpdateInstancesResponseUpdatedInstance") - - -@_attrs_define -class UpdateInstancesResponseUpdatedInstance: - uuid: Union[Unset, UUID] = UNSET - """ The UUID of the instance that was updated. """ - name: Union[Unset, str] = UNSET - """ The name of the instance that was updated. """ - status: Union[Unset, str] = UNSET - """ The status of this particular instance update operation. """ - id: Union[Unset, str] = UNSET - """ (Optional). The client-provided ID from the request. """ - message: Union[Unset, str] = UNSET - """ An optional message providing additional information about the status. - This field is useful when the status is not `success`. """ - error: Union[Unset, int] = UNSET - """ An optional error code providing additional information about the status. - This field is useful when the status is not `success`. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - uuid: Union[Unset, str] = UNSET - if not isinstance(self.uuid, Unset): - uuid = str(self.uuid) - - name = self.name - - status = self.status - - id = self.id - - message = self.message - - error = self.error - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if uuid is not UNSET: - field_dict["uuid"] = uuid - if name is not UNSET: - field_dict["name"] = name - if status is not UNSET: - field_dict["status"] = status - if id is not UNSET: - field_dict["id"] = id - if message is not UNSET: - field_dict["message"] = message - if error is not UNSET: - field_dict["error"] = error - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - d = dict(src_dict) - _uuid = d.pop("uuid", UNSET) - uuid: Union[Unset, UUID] - if isinstance(_uuid, Unset): - uuid = UNSET - else: - uuid = UUID(_uuid) - - name = d.pop("name", UNSET) - - status = d.pop("status", UNSET) - - id = d.pop("id", UNSET) - - message = d.pop("message", UNSET) - - error = d.pop("error", UNSET) - - update_instances_response_updated_instance = cls( - uuid=uuid, - name=name, - status=status, - id=id, - message=message, - error=error, - ) - - update_instances_response_updated_instance.additional_properties = d - return update_instances_response_updated_instance - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/update_service_group_by_uuid_request_body.py b/unikraft_cloud_platform/models/update_service_group_by_uuid_request_body.py deleted file mode 100644 index ebf8b82..0000000 --- a/unikraft_cloud_platform/models/update_service_group_by_uuid_request_body.py +++ /dev/null @@ -1,92 +0,0 @@ -from collections.abc import Mapping -from typing import Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..models.update_service_group_by_uuid_request_body_op import ( - UpdateServiceGroupByUUIDRequestBodyOp, - check_update_service_group_by_uuid_request_body_op, -) -from ..models.update_service_group_by_uuid_request_body_prop import ( - UpdateServiceGroupByUUIDRequestBodyProp, - check_update_service_group_by_uuid_request_body_prop, -) -from ..types import UNSET, Unset - -T = TypeVar("T", bound="UpdateServiceGroupByUUIDRequestBody") - - -@_attrs_define -class UpdateServiceGroupByUUIDRequestBody: - prop: UpdateServiceGroupByUUIDRequestBodyProp - """ The property to modify. """ - op: UpdateServiceGroupByUUIDRequestBodyOp - """ The operation to perform. """ - id: Union[Unset, str] = UNSET - """ (Optional). A client-provided identifier for tracking this operation in the response. """ - value: Union[Unset, Any] = UNSET - """ Represents a dynamically typed value which can be either null, a number, a string, a boolean, a recursive - struct value, or a list of values. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - prop: str = self.prop - - op: str = self.op - - id = self.id - - value = self.value - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update( - { - "prop": prop, - "op": op, - } - ) - if id is not UNSET: - field_dict["id"] = id - if value is not UNSET: - field_dict["value"] = value - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - d = dict(src_dict) - prop = check_update_service_group_by_uuid_request_body_prop(d.pop("prop")) - - op = check_update_service_group_by_uuid_request_body_op(d.pop("op")) - - id = d.pop("id", UNSET) - - value = d.pop("value", UNSET) - - update_service_group_by_uuid_request_body = cls( - prop=prop, - op=op, - id=id, - value=value, - ) - - update_service_group_by_uuid_request_body.additional_properties = d - return update_service_group_by_uuid_request_body - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/update_service_group_by_uuid_request_body_op.py b/unikraft_cloud_platform/models/update_service_group_by_uuid_request_body_op.py deleted file mode 100644 index d9ad288..0000000 --- a/unikraft_cloud_platform/models/update_service_group_by_uuid_request_body_op.py +++ /dev/null @@ -1,17 +0,0 @@ -from typing import Literal, cast - -UpdateServiceGroupByUUIDRequestBodyOp = Literal["add", "del", "set"] - -UPDATE_SERVICE_GROUP_BY_UUID_REQUEST_BODY_OP_VALUES: set[UpdateServiceGroupByUUIDRequestBodyOp] = { - "add", - "del", - "set", -} - - -def check_update_service_group_by_uuid_request_body_op(value: str) -> UpdateServiceGroupByUUIDRequestBodyOp: - if value in UPDATE_SERVICE_GROUP_BY_UUID_REQUEST_BODY_OP_VALUES: - return cast(UpdateServiceGroupByUUIDRequestBodyOp, value) - raise TypeError( - f"Unexpected value {value!r}. Expected one of {UPDATE_SERVICE_GROUP_BY_UUID_REQUEST_BODY_OP_VALUES!r}" - ) diff --git a/unikraft_cloud_platform/models/update_service_group_by_uuid_request_body_prop.py b/unikraft_cloud_platform/models/update_service_group_by_uuid_request_body_prop.py deleted file mode 100644 index 2dc76e3..0000000 --- a/unikraft_cloud_platform/models/update_service_group_by_uuid_request_body_prop.py +++ /dev/null @@ -1,18 +0,0 @@ -from typing import Literal, cast - -UpdateServiceGroupByUUIDRequestBodyProp = Literal["domains", "hard_limit", "services", "soft_limit"] - -UPDATE_SERVICE_GROUP_BY_UUID_REQUEST_BODY_PROP_VALUES: set[UpdateServiceGroupByUUIDRequestBodyProp] = { - "domains", - "hard_limit", - "services", - "soft_limit", -} - - -def check_update_service_group_by_uuid_request_body_prop(value: str) -> UpdateServiceGroupByUUIDRequestBodyProp: - if value in UPDATE_SERVICE_GROUP_BY_UUID_REQUEST_BODY_PROP_VALUES: - return cast(UpdateServiceGroupByUUIDRequestBodyProp, value) - raise TypeError( - f"Unexpected value {value!r}. Expected one of {UPDATE_SERVICE_GROUP_BY_UUID_REQUEST_BODY_PROP_VALUES!r}" - ) diff --git a/unikraft_cloud_platform/models/update_service_groups_request_item.py b/unikraft_cloud_platform/models/update_service_groups_request_item.py deleted file mode 100644 index 687f85c..0000000 --- a/unikraft_cloud_platform/models/update_service_groups_request_item.py +++ /dev/null @@ -1,120 +0,0 @@ -from collections.abc import Mapping -from typing import Any, TypeVar, Union -from uuid import UUID - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..models.update_service_groups_request_item_op import ( - UpdateServiceGroupsRequestItemOp, - check_update_service_groups_request_item_op, -) -from ..models.update_service_groups_request_item_prop import ( - UpdateServiceGroupsRequestItemProp, - check_update_service_groups_request_item_prop, -) -from ..types import UNSET, Unset - -T = TypeVar("T", bound="UpdateServiceGroupsRequestItem") - - -@_attrs_define -class UpdateServiceGroupsRequestItem: - """A single update operation to be applied to a service group""" - - prop: UpdateServiceGroupsRequestItemProp - """ The property to modify. """ - op: UpdateServiceGroupsRequestItemOp - """ The operation to perform. """ - id: Union[Unset, str] = UNSET - """ (Optional). A client-provided identifier for tracking this operation in the response. """ - uuid: Union[Unset, UUID] = UNSET - """ The UUID of the service group to update. Mutually exclusive with name. """ - name: Union[Unset, str] = UNSET - """ The name of the service group to update. Mutually exclusive with UUID. """ - value: Union[Unset, Any] = UNSET - """ Represents a dynamically typed value which can be either null, a number, a string, a boolean, a recursive - struct value, or a list of values. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - prop: str = self.prop - - op: str = self.op - - id = self.id - - uuid: Union[Unset, str] = UNSET - if not isinstance(self.uuid, Unset): - uuid = str(self.uuid) - - name = self.name - - value = self.value - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update( - { - "prop": prop, - "op": op, - } - ) - if id is not UNSET: - field_dict["id"] = id - if uuid is not UNSET: - field_dict["uuid"] = uuid - if name is not UNSET: - field_dict["name"] = name - if value is not UNSET: - field_dict["value"] = value - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - d = dict(src_dict) - prop = check_update_service_groups_request_item_prop(d.pop("prop")) - - op = check_update_service_groups_request_item_op(d.pop("op")) - - id = d.pop("id", UNSET) - - _uuid = d.pop("uuid", UNSET) - uuid: Union[Unset, UUID] - if isinstance(_uuid, Unset): - uuid = UNSET - else: - uuid = UUID(_uuid) - - name = d.pop("name", UNSET) - - value = d.pop("value", UNSET) - - update_service_groups_request_item = cls( - prop=prop, - op=op, - id=id, - uuid=uuid, - name=name, - value=value, - ) - - update_service_groups_request_item.additional_properties = d - return update_service_groups_request_item - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/update_service_groups_request_item_op.py b/unikraft_cloud_platform/models/update_service_groups_request_item_op.py deleted file mode 100644 index 2dfa22e..0000000 --- a/unikraft_cloud_platform/models/update_service_groups_request_item_op.py +++ /dev/null @@ -1,15 +0,0 @@ -from typing import Literal, cast - -UpdateServiceGroupsRequestItemOp = Literal["add", "del", "set"] - -UPDATE_SERVICE_GROUPS_REQUEST_ITEM_OP_VALUES: set[UpdateServiceGroupsRequestItemOp] = { - "add", - "del", - "set", -} - - -def check_update_service_groups_request_item_op(value: str) -> UpdateServiceGroupsRequestItemOp: - if value in UPDATE_SERVICE_GROUPS_REQUEST_ITEM_OP_VALUES: - return cast(UpdateServiceGroupsRequestItemOp, value) - raise TypeError(f"Unexpected value {value!r}. Expected one of {UPDATE_SERVICE_GROUPS_REQUEST_ITEM_OP_VALUES!r}") diff --git a/unikraft_cloud_platform/models/update_service_groups_request_item_prop.py b/unikraft_cloud_platform/models/update_service_groups_request_item_prop.py deleted file mode 100644 index ad77204..0000000 --- a/unikraft_cloud_platform/models/update_service_groups_request_item_prop.py +++ /dev/null @@ -1,16 +0,0 @@ -from typing import Literal, cast - -UpdateServiceGroupsRequestItemProp = Literal["domains", "hard_limit", "services", "soft_limit"] - -UPDATE_SERVICE_GROUPS_REQUEST_ITEM_PROP_VALUES: set[UpdateServiceGroupsRequestItemProp] = { - "domains", - "hard_limit", - "services", - "soft_limit", -} - - -def check_update_service_groups_request_item_prop(value: str) -> UpdateServiceGroupsRequestItemProp: - if value in UPDATE_SERVICE_GROUPS_REQUEST_ITEM_PROP_VALUES: - return cast(UpdateServiceGroupsRequestItemProp, value) - raise TypeError(f"Unexpected value {value!r}. Expected one of {UPDATE_SERVICE_GROUPS_REQUEST_ITEM_PROP_VALUES!r}") diff --git a/unikraft_cloud_platform/models/update_service_groups_response.py b/unikraft_cloud_platform/models/update_service_groups_response.py deleted file mode 100644 index 38831a6..0000000 --- a/unikraft_cloud_platform/models/update_service_groups_response.py +++ /dev/null @@ -1,127 +0,0 @@ -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..models.response_status import ResponseStatus, check_response_status -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.response_error import ResponseError - from ..models.update_service_groups_response_data import UpdateServiceGroupsResponseData - - -T = TypeVar("T", bound="UpdateServiceGroupsResponse") - - -@_attrs_define -class UpdateServiceGroupsResponse: - """The response message for updating one or more service groups.""" - - status: Union[Unset, ResponseStatus] = UNSET - """ The response status of an API request. """ - message: Union[Unset, str] = UNSET - """ An optional message providing additional information about the status. - This field is useful when the status is not `success`. """ - data: Union[Unset, "UpdateServiceGroupsResponseData"] = UNSET - errors: Union[Unset, list["ResponseError"]] = UNSET - """ A list of errors which may have occurred during the request. """ - op_time_us: Union[Unset, int] = UNSET - """ The operation time in microseconds. This is the time it took to process - the request and generate the response. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - status: Union[Unset, str] = UNSET - if not isinstance(self.status, Unset): - status = self.status - - message = self.message - - data: Union[Unset, dict[str, Any]] = UNSET - if not isinstance(self.data, Unset): - data = self.data.to_dict() - - errors: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.errors, Unset): - errors = [] - for errors_item_data in self.errors: - errors_item = errors_item_data.to_dict() - errors.append(errors_item) - - op_time_us = self.op_time_us - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if status is not UNSET: - field_dict["status"] = status - if message is not UNSET: - field_dict["message"] = message - if data is not UNSET: - field_dict["data"] = data - if errors is not UNSET: - field_dict["errors"] = errors - if op_time_us is not UNSET: - field_dict["op_time_us"] = op_time_us - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.response_error import ResponseError - from ..models.update_service_groups_response_data import UpdateServiceGroupsResponseData - - d = dict(src_dict) - _status = d.pop("status", UNSET) - status: Union[Unset, ResponseStatus] - if isinstance(_status, Unset): - status = UNSET - else: - status = check_response_status(_status) - - message = d.pop("message", UNSET) - - _data = d.pop("data", UNSET) - data: Union[Unset, UpdateServiceGroupsResponseData] - if isinstance(_data, Unset): - data = UNSET - else: - data = UpdateServiceGroupsResponseData.from_dict(_data) - - errors = [] - _errors = d.pop("errors", UNSET) - for errors_item_data in _errors or []: - errors_item = ResponseError.from_dict(errors_item_data) - - errors.append(errors_item) - - op_time_us = d.pop("op_time_us", UNSET) - - update_service_groups_response = cls( - status=status, - message=message, - data=data, - errors=errors, - op_time_us=op_time_us, - ) - - update_service_groups_response.additional_properties = d - return update_service_groups_response - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/update_service_groups_response_data.py b/unikraft_cloud_platform/models/update_service_groups_response_data.py deleted file mode 100644 index 9c1df26..0000000 --- a/unikraft_cloud_platform/models/update_service_groups_response_data.py +++ /dev/null @@ -1,75 +0,0 @@ -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.update_service_groups_response_updated_service_group import ( - UpdateServiceGroupsResponseUpdatedServiceGroup, - ) - - -T = TypeVar("T", bound="UpdateServiceGroupsResponseData") - - -@_attrs_define -class UpdateServiceGroupsResponseData: - service_groups: Union[Unset, list["UpdateServiceGroupsResponseUpdatedServiceGroup"]] = UNSET - """ List of service groups that were processed during the update operation. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - service_groups: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.service_groups, Unset): - service_groups = [] - for service_groups_item_data in self.service_groups: - service_groups_item = service_groups_item_data.to_dict() - service_groups.append(service_groups_item) - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if service_groups is not UNSET: - field_dict["service_groups"] = service_groups - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.update_service_groups_response_updated_service_group import ( - UpdateServiceGroupsResponseUpdatedServiceGroup, - ) - - d = dict(src_dict) - service_groups = [] - _service_groups = d.pop("service_groups", UNSET) - for service_groups_item_data in _service_groups or []: - service_groups_item = UpdateServiceGroupsResponseUpdatedServiceGroup.from_dict(service_groups_item_data) - - service_groups.append(service_groups_item) - - update_service_groups_response_data = cls( - service_groups=service_groups, - ) - - update_service_groups_response_data.additional_properties = d - return update_service_groups_response_data - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/update_service_groups_response_updated_service_group.py b/unikraft_cloud_platform/models/update_service_groups_response_updated_service_group.py deleted file mode 100644 index e34f5e2..0000000 --- a/unikraft_cloud_platform/models/update_service_groups_response_updated_service_group.py +++ /dev/null @@ -1,112 +0,0 @@ -from collections.abc import Mapping -from typing import Any, TypeVar, Union -from uuid import UUID - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -T = TypeVar("T", bound="UpdateServiceGroupsResponseUpdatedServiceGroup") - - -@_attrs_define -class UpdateServiceGroupsResponseUpdatedServiceGroup: - uuid: Union[Unset, UUID] = UNSET - """ The UUID of the service group that was updated. """ - name: Union[Unset, str] = UNSET - """ The name of the service group that was updated. """ - status: Union[Unset, str] = UNSET - """ The status of this particular service group update operation. """ - id: Union[Unset, str] = UNSET - """ (Optional). The client-provided ID from the request. """ - message: Union[Unset, str] = UNSET - """ An optional message providing additional information about the status. - This field is only set when this message object is used as a response - message, and is useful when the status is not `success`. """ - error: Union[Unset, int] = UNSET - """ An optional error code providing additional information about the status. - This field is only set when this message object is used as a response - message, and is useful when the status is not `success`. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - uuid: Union[Unset, str] = UNSET - if not isinstance(self.uuid, Unset): - uuid = str(self.uuid) - - name = self.name - - status = self.status - - id = self.id - - message = self.message - - error = self.error - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if uuid is not UNSET: - field_dict["uuid"] = uuid - if name is not UNSET: - field_dict["name"] = name - if status is not UNSET: - field_dict["status"] = status - if id is not UNSET: - field_dict["id"] = id - if message is not UNSET: - field_dict["message"] = message - if error is not UNSET: - field_dict["error"] = error - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - d = dict(src_dict) - _uuid = d.pop("uuid", UNSET) - uuid: Union[Unset, UUID] - if isinstance(_uuid, Unset): - uuid = UNSET - else: - uuid = UUID(_uuid) - - name = d.pop("name", UNSET) - - status = d.pop("status", UNSET) - - id = d.pop("id", UNSET) - - message = d.pop("message", UNSET) - - error = d.pop("error", UNSET) - - update_service_groups_response_updated_service_group = cls( - uuid=uuid, - name=name, - status=status, - id=id, - message=message, - error=error, - ) - - update_service_groups_response_updated_service_group.additional_properties = d - return update_service_groups_response_updated_service_group - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/update_volume_by_uuid_request_body.py b/unikraft_cloud_platform/models/update_volume_by_uuid_request_body.py deleted file mode 100644 index b0fd599..0000000 --- a/unikraft_cloud_platform/models/update_volume_by_uuid_request_body.py +++ /dev/null @@ -1,92 +0,0 @@ -from collections.abc import Mapping -from typing import Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..models.update_volume_by_uuid_request_body_op import ( - UpdateVolumeByUUIDRequestBodyOp, - check_update_volume_by_uuid_request_body_op, -) -from ..models.update_volume_by_uuid_request_body_prop import ( - UpdateVolumeByUUIDRequestBodyProp, - check_update_volume_by_uuid_request_body_prop, -) -from ..types import UNSET, Unset - -T = TypeVar("T", bound="UpdateVolumeByUUIDRequestBody") - - -@_attrs_define -class UpdateVolumeByUUIDRequestBody: - prop: UpdateVolumeByUUIDRequestBodyProp - """ The property to modify. """ - op: UpdateVolumeByUUIDRequestBodyOp - """ The operation to perform. """ - id: Union[Unset, str] = UNSET - """ (Optional). A client-provided identifier for tracking this operation in the response. """ - value: Union[Unset, Any] = UNSET - """ Represents a dynamically typed value which can be either null, a number, a string, a boolean, a recursive - struct value, or a list of values. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - prop: str = self.prop - - op: str = self.op - - id = self.id - - value = self.value - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update( - { - "prop": prop, - "op": op, - } - ) - if id is not UNSET: - field_dict["id"] = id - if value is not UNSET: - field_dict["value"] = value - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - d = dict(src_dict) - prop = check_update_volume_by_uuid_request_body_prop(d.pop("prop")) - - op = check_update_volume_by_uuid_request_body_op(d.pop("op")) - - id = d.pop("id", UNSET) - - value = d.pop("value", UNSET) - - update_volume_by_uuid_request_body = cls( - prop=prop, - op=op, - id=id, - value=value, - ) - - update_volume_by_uuid_request_body.additional_properties = d - return update_volume_by_uuid_request_body - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/update_volume_by_uuid_request_body_op.py b/unikraft_cloud_platform/models/update_volume_by_uuid_request_body_op.py deleted file mode 100644 index 0936b5d..0000000 --- a/unikraft_cloud_platform/models/update_volume_by_uuid_request_body_op.py +++ /dev/null @@ -1,15 +0,0 @@ -from typing import Literal, cast - -UpdateVolumeByUUIDRequestBodyOp = Literal["add", "del", "set"] - -UPDATE_VOLUME_BY_UUID_REQUEST_BODY_OP_VALUES: set[UpdateVolumeByUUIDRequestBodyOp] = { - "add", - "del", - "set", -} - - -def check_update_volume_by_uuid_request_body_op(value: str) -> UpdateVolumeByUUIDRequestBodyOp: - if value in UPDATE_VOLUME_BY_UUID_REQUEST_BODY_OP_VALUES: - return cast(UpdateVolumeByUUIDRequestBodyOp, value) - raise TypeError(f"Unexpected value {value!r}. Expected one of {UPDATE_VOLUME_BY_UUID_REQUEST_BODY_OP_VALUES!r}") diff --git a/unikraft_cloud_platform/models/update_volume_by_uuid_request_body_prop.py b/unikraft_cloud_platform/models/update_volume_by_uuid_request_body_prop.py deleted file mode 100644 index 8a3ce1a..0000000 --- a/unikraft_cloud_platform/models/update_volume_by_uuid_request_body_prop.py +++ /dev/null @@ -1,16 +0,0 @@ -from typing import Literal, cast - -UpdateVolumeByUUIDRequestBodyProp = Literal["delete_lock", "quota_policy", "size_mb", "tags"] - -UPDATE_VOLUME_BY_UUID_REQUEST_BODY_PROP_VALUES: set[UpdateVolumeByUUIDRequestBodyProp] = { - "delete_lock", - "quota_policy", - "size_mb", - "tags", -} - - -def check_update_volume_by_uuid_request_body_prop(value: str) -> UpdateVolumeByUUIDRequestBodyProp: - if value in UPDATE_VOLUME_BY_UUID_REQUEST_BODY_PROP_VALUES: - return cast(UpdateVolumeByUUIDRequestBodyProp, value) - raise TypeError(f"Unexpected value {value!r}. Expected one of {UPDATE_VOLUME_BY_UUID_REQUEST_BODY_PROP_VALUES!r}") diff --git a/unikraft_cloud_platform/models/update_volumes_request_item.py b/unikraft_cloud_platform/models/update_volumes_request_item.py deleted file mode 100644 index 3cb2778..0000000 --- a/unikraft_cloud_platform/models/update_volumes_request_item.py +++ /dev/null @@ -1,115 +0,0 @@ -from collections.abc import Mapping -from typing import Any, TypeVar, Union -from uuid import UUID - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..models.update_volumes_request_item_op import UpdateVolumesRequestItemOp, check_update_volumes_request_item_op -from ..models.update_volumes_request_item_prop import ( - UpdateVolumesRequestItemProp, - check_update_volumes_request_item_prop, -) -from ..types import UNSET, Unset - -T = TypeVar("T", bound="UpdateVolumesRequestItem") - - -@_attrs_define -class UpdateVolumesRequestItem: - prop: UpdateVolumesRequestItemProp - """ The property to modify. """ - op: UpdateVolumesRequestItemOp - """ The operation to perform. """ - id: Union[Unset, str] = UNSET - """ (Optional). A client-provided identifier for tracking this operation in the response. """ - uuid: Union[Unset, UUID] = UNSET - """ The UUID of the volume to update. Mutually exclusive with name. """ - name: Union[Unset, str] = UNSET - """ The name of the volume to update. Mutually exclusive with UUID. """ - value: Union[Unset, Any] = UNSET - """ Represents a dynamically typed value which can be either null, a number, a string, a boolean, a recursive - struct value, or a list of values. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - prop: str = self.prop - - op: str = self.op - - id = self.id - - uuid: Union[Unset, str] = UNSET - if not isinstance(self.uuid, Unset): - uuid = str(self.uuid) - - name = self.name - - value = self.value - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update( - { - "prop": prop, - "op": op, - } - ) - if id is not UNSET: - field_dict["id"] = id - if uuid is not UNSET: - field_dict["uuid"] = uuid - if name is not UNSET: - field_dict["name"] = name - if value is not UNSET: - field_dict["value"] = value - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - d = dict(src_dict) - prop = check_update_volumes_request_item_prop(d.pop("prop")) - - op = check_update_volumes_request_item_op(d.pop("op")) - - id = d.pop("id", UNSET) - - _uuid = d.pop("uuid", UNSET) - uuid: Union[Unset, UUID] - if isinstance(_uuid, Unset): - uuid = UNSET - else: - uuid = UUID(_uuid) - - name = d.pop("name", UNSET) - - value = d.pop("value", UNSET) - - update_volumes_request_item = cls( - prop=prop, - op=op, - id=id, - uuid=uuid, - name=name, - value=value, - ) - - update_volumes_request_item.additional_properties = d - return update_volumes_request_item - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/update_volumes_request_item_op.py b/unikraft_cloud_platform/models/update_volumes_request_item_op.py deleted file mode 100644 index 73c5383..0000000 --- a/unikraft_cloud_platform/models/update_volumes_request_item_op.py +++ /dev/null @@ -1,15 +0,0 @@ -from typing import Literal, cast - -UpdateVolumesRequestItemOp = Literal["add", "del", "set"] - -UPDATE_VOLUMES_REQUEST_ITEM_OP_VALUES: set[UpdateVolumesRequestItemOp] = { - "add", - "del", - "set", -} - - -def check_update_volumes_request_item_op(value: str) -> UpdateVolumesRequestItemOp: - if value in UPDATE_VOLUMES_REQUEST_ITEM_OP_VALUES: - return cast(UpdateVolumesRequestItemOp, value) - raise TypeError(f"Unexpected value {value!r}. Expected one of {UPDATE_VOLUMES_REQUEST_ITEM_OP_VALUES!r}") diff --git a/unikraft_cloud_platform/models/update_volumes_request_item_prop.py b/unikraft_cloud_platform/models/update_volumes_request_item_prop.py deleted file mode 100644 index 68b89f7..0000000 --- a/unikraft_cloud_platform/models/update_volumes_request_item_prop.py +++ /dev/null @@ -1,16 +0,0 @@ -from typing import Literal, cast - -UpdateVolumesRequestItemProp = Literal["delete_lock", "quota_policy", "size_mb", "tags"] - -UPDATE_VOLUMES_REQUEST_ITEM_PROP_VALUES: set[UpdateVolumesRequestItemProp] = { - "delete_lock", - "quota_policy", - "size_mb", - "tags", -} - - -def check_update_volumes_request_item_prop(value: str) -> UpdateVolumesRequestItemProp: - if value in UPDATE_VOLUMES_REQUEST_ITEM_PROP_VALUES: - return cast(UpdateVolumesRequestItemProp, value) - raise TypeError(f"Unexpected value {value!r}. Expected one of {UPDATE_VOLUMES_REQUEST_ITEM_PROP_VALUES!r}") diff --git a/unikraft_cloud_platform/models/update_volumes_response.py b/unikraft_cloud_platform/models/update_volumes_response.py deleted file mode 100644 index 34fd011..0000000 --- a/unikraft_cloud_platform/models/update_volumes_response.py +++ /dev/null @@ -1,127 +0,0 @@ -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..models.response_status import ResponseStatus, check_response_status -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.response_error import ResponseError - from ..models.update_volumes_response_data import UpdateVolumesResponseData - - -T = TypeVar("T", bound="UpdateVolumesResponse") - - -@_attrs_define -class UpdateVolumesResponse: - """The response message for updating one or more volume(s).""" - - status: Union[Unset, ResponseStatus] = UNSET - """ The response status of an API request. """ - message: Union[Unset, str] = UNSET - """ An optional message providing additional information about the status. - This field is useful when the status is not `success`. """ - data: Union[Unset, "UpdateVolumesResponseData"] = UNSET - errors: Union[Unset, list["ResponseError"]] = UNSET - """ A list of errors which may have occurred during the request. """ - op_time_us: Union[Unset, int] = UNSET - """ The operation time in microseconds. This is the time it took to process - the request and generate the response. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - status: Union[Unset, str] = UNSET - if not isinstance(self.status, Unset): - status = self.status - - message = self.message - - data: Union[Unset, dict[str, Any]] = UNSET - if not isinstance(self.data, Unset): - data = self.data.to_dict() - - errors: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.errors, Unset): - errors = [] - for errors_item_data in self.errors: - errors_item = errors_item_data.to_dict() - errors.append(errors_item) - - op_time_us = self.op_time_us - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if status is not UNSET: - field_dict["status"] = status - if message is not UNSET: - field_dict["message"] = message - if data is not UNSET: - field_dict["data"] = data - if errors is not UNSET: - field_dict["errors"] = errors - if op_time_us is not UNSET: - field_dict["op_time_us"] = op_time_us - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.response_error import ResponseError - from ..models.update_volumes_response_data import UpdateVolumesResponseData - - d = dict(src_dict) - _status = d.pop("status", UNSET) - status: Union[Unset, ResponseStatus] - if isinstance(_status, Unset): - status = UNSET - else: - status = check_response_status(_status) - - message = d.pop("message", UNSET) - - _data = d.pop("data", UNSET) - data: Union[Unset, UpdateVolumesResponseData] - if isinstance(_data, Unset): - data = UNSET - else: - data = UpdateVolumesResponseData.from_dict(_data) - - errors = [] - _errors = d.pop("errors", UNSET) - for errors_item_data in _errors or []: - errors_item = ResponseError.from_dict(errors_item_data) - - errors.append(errors_item) - - op_time_us = d.pop("op_time_us", UNSET) - - update_volumes_response = cls( - status=status, - message=message, - data=data, - errors=errors, - op_time_us=op_time_us, - ) - - update_volumes_response.additional_properties = d - return update_volumes_response - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/update_volumes_response_data.py b/unikraft_cloud_platform/models/update_volumes_response_data.py deleted file mode 100644 index 44bb17c..0000000 --- a/unikraft_cloud_platform/models/update_volumes_response_data.py +++ /dev/null @@ -1,71 +0,0 @@ -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.update_volumes_response_updated_volume import UpdateVolumesResponseUpdatedVolume - - -T = TypeVar("T", bound="UpdateVolumesResponseData") - - -@_attrs_define -class UpdateVolumesResponseData: - volumes: Union[Unset, list["UpdateVolumesResponseUpdatedVolume"]] = UNSET - """ List of volumes that were processed during the update operation. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - volumes: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.volumes, Unset): - volumes = [] - for volumes_item_data in self.volumes: - volumes_item = volumes_item_data.to_dict() - volumes.append(volumes_item) - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if volumes is not UNSET: - field_dict["volumes"] = volumes - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.update_volumes_response_updated_volume import UpdateVolumesResponseUpdatedVolume - - d = dict(src_dict) - volumes = [] - _volumes = d.pop("volumes", UNSET) - for volumes_item_data in _volumes or []: - volumes_item = UpdateVolumesResponseUpdatedVolume.from_dict(volumes_item_data) - - volumes.append(volumes_item) - - update_volumes_response_data = cls( - volumes=volumes, - ) - - update_volumes_response_data.additional_properties = d - return update_volumes_response_data - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/update_volumes_response_updated_volume.py b/unikraft_cloud_platform/models/update_volumes_response_updated_volume.py deleted file mode 100644 index d444369..0000000 --- a/unikraft_cloud_platform/models/update_volumes_response_updated_volume.py +++ /dev/null @@ -1,110 +0,0 @@ -from collections.abc import Mapping -from typing import Any, TypeVar, Union -from uuid import UUID - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -T = TypeVar("T", bound="UpdateVolumesResponseUpdatedVolume") - - -@_attrs_define -class UpdateVolumesResponseUpdatedVolume: - uuid: Union[Unset, UUID] = UNSET - """ The UUID of the volume that was updated. """ - name: Union[Unset, str] = UNSET - """ The name of the service group that was updated. """ - status: Union[Unset, str] = UNSET - """ The status of this particular volume update operation. """ - id: Union[Unset, str] = UNSET - """ (Optional). The client-provided ID from the request. """ - message: Union[Unset, str] = UNSET - """ An optional message providing additional information about the status. - This field is useful when the status is not `success`. """ - error: Union[Unset, int] = UNSET - """ An optional error code providing additional information about the status. - This field is useful when the status is not `success`. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - uuid: Union[Unset, str] = UNSET - if not isinstance(self.uuid, Unset): - uuid = str(self.uuid) - - name = self.name - - status = self.status - - id = self.id - - message = self.message - - error = self.error - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if uuid is not UNSET: - field_dict["uuid"] = uuid - if name is not UNSET: - field_dict["name"] = name - if status is not UNSET: - field_dict["status"] = status - if id is not UNSET: - field_dict["id"] = id - if message is not UNSET: - field_dict["message"] = message - if error is not UNSET: - field_dict["error"] = error - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - d = dict(src_dict) - _uuid = d.pop("uuid", UNSET) - uuid: Union[Unset, UUID] - if isinstance(_uuid, Unset): - uuid = UNSET - else: - uuid = UUID(_uuid) - - name = d.pop("name", UNSET) - - status = d.pop("status", UNSET) - - id = d.pop("id", UNSET) - - message = d.pop("message", UNSET) - - error = d.pop("error", UNSET) - - update_volumes_response_updated_volume = cls( - uuid=uuid, - name=name, - status=status, - id=id, - message=message, - error=error, - ) - - update_volumes_response_updated_volume.additional_properties = d - return update_volumes_response_updated_volume - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/user_quota.py b/unikraft_cloud_platform/models/user_quota.py new file mode 100644 index 0000000..d378e06 --- /dev/null +++ b/unikraft_cloud_platform/models/user_quota.py @@ -0,0 +1,99 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from unikraft_cloud_platform.models.user_quota_limits import UserQuotaLimits +from unikraft_cloud_platform.models.user_quota_used import UserQuotaUsed +from typing import Optional, Set +from typing_extensions import Self + + +class UserQuota(BaseModel): + """ + UserQuota + """ # noqa: E501 + + used: Optional[UserQuotaUsed] = None + hard: Optional[Dict[str, Any]] = Field(default=None, description="Hard quota limits. ") + limits: Optional[UserQuotaLimits] = None + __properties: ClassVar[List[str]] = ["used", "hard", "limits"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of UserQuota from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of used + if self.used: + _dict["used"] = self.used.to_dict() + # override the default output from pydantic by calling `to_dict()` of limits + if self.limits: + _dict["limits"] = self.limits.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of UserQuota from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "used": UserQuotaUsed.from_dict(obj["used"]) if obj.get("used") is not None else None, + "hard": obj.get("hard"), + "limits": UserQuotaLimits.from_dict(obj["limits"]) if obj.get("limits") is not None else None, + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/user_quota_limits.py b/unikraft_cloud_platform/models/user_quota_limits.py new file mode 100644 index 0000000..6e98f9e --- /dev/null +++ b/unikraft_cloud_platform/models/user_quota_limits.py @@ -0,0 +1,119 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from typing import Optional, Set +from typing_extensions import Self + + +class UserQuotaLimits(BaseModel): + """ + Additional limits. + """ # noqa: E501 + + min_memory_mb: Optional[Annotated[int, Field(le=2147483647, strict=True, ge=16)]] = Field( + default=None, description="Minimum amount of memory assigned to live instances in megabytes. " + ) + max_memory_mb: Optional[Annotated[int, Field(le=2147483647, strict=True, ge=4096)]] = Field( + default=None, description="Maximum amount of memory assigned to live instances in megabytes. " + ) + min_volume_mb: Optional[Annotated[int, Field(le=2147483647, strict=True, ge=1)]] = Field( + default=None, description="Minimum size of a volume in megabytes. " + ) + max_volume_mb: Optional[Annotated[int, Field(le=2147483647, strict=True, ge=1024)]] = Field( + default=None, description="Maximum size of a volume in megabytes. " + ) + min_autoscale_size: Optional[Annotated[int, Field(le=2147483647, strict=True, ge=1)]] = Field( + default=None, + description="Minimum size of an autoscale group Note: These restrict the `min_size` and `max_size` fields of the [autoscale configuration](https://unikraft.cloud/docs/api/v1/autoscale/#basics). If both values are `1` autoscale is not enabled for your account. If you want to explore autoscale for your services, please contact us via [support@unikraft.cloud](mailto:support@unikraft.cloud). ", + ) + max_autoscale_size: Optional[Annotated[int, Field(le=2147483647, strict=True, ge=1)]] = Field( + default=None, + description="Maximum size of an autoscale group. Note: These restrict the `min_size` and `max_size` fields of the [autoscale configuration](https://unikraft.cloud/docs/api/v1/autoscale/#basics). ", + ) + __properties: ClassVar[List[str]] = [ + "min_memory_mb", + "max_memory_mb", + "min_volume_mb", + "max_volume_mb", + "min_autoscale_size", + "max_autoscale_size", + ] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of UserQuotaLimits from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of UserQuotaLimits from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "min_memory_mb": obj.get("min_memory_mb"), + "max_memory_mb": obj.get("max_memory_mb"), + "min_volume_mb": obj.get("min_volume_mb"), + "max_volume_mb": obj.get("max_volume_mb"), + "min_autoscale_size": obj.get("min_autoscale_size"), + "max_autoscale_size": obj.get("max_autoscale_size"), + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/user_quota_used.py b/unikraft_cloud_platform/models/user_quota_used.py new file mode 100644 index 0000000..82d16a7 --- /dev/null +++ b/unikraft_cloud_platform/models/user_quota_used.py @@ -0,0 +1,123 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from typing import Optional, Set +from typing_extensions import Self + + +class UserQuotaUsed(BaseModel): + """ + Used quota. + """ # noqa: E501 + + instances: Optional[Annotated[int, Field(le=2147483647, strict=True, ge=0)]] = Field( + default=None, description="Number of created instances. " + ) + live_instances: Optional[Annotated[int, Field(le=2147483647, strict=True, ge=0)]] = Field( + default=None, description="Number of instances that are not in the `stopped` state. " + ) + live_memory_mb: Optional[Annotated[int, Field(le=2147483647, strict=True, ge=0)]] = Field( + default=None, + description="Amount of memory assigned to instances that are not in the `stopped` state in megabytes. ", + ) + service_groups: Optional[Annotated[int, Field(le=2147483647, strict=True, ge=0)]] = Field( + default=None, description="Number of services. " + ) + services: Optional[Annotated[int, Field(le=2147483647, strict=True, ge=0)]] = Field( + default=None, description="Number of published network ports over all existing services. " + ) + volumes: Optional[Annotated[int, Field(le=2147483647, strict=True, ge=0)]] = Field( + default=None, description="Number of volumes. " + ) + total_volume_mb: Optional[Annotated[int, Field(le=1048576, strict=True, ge=0)]] = Field( + default=None, description="Total size of all volumes in megabytes. " + ) + __properties: ClassVar[List[str]] = [ + "instances", + "live_instances", + "live_memory_mb", + "service_groups", + "services", + "volumes", + "total_volume_mb", + ] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of UserQuotaUsed from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of UserQuotaUsed from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "instances": obj.get("instances"), + "live_instances": obj.get("live_instances"), + "live_memory_mb": obj.get("live_memory_mb"), + "service_groups": obj.get("service_groups"), + "services": obj.get("services"), + "volumes": obj.get("volumes"), + "total_volume_mb": obj.get("total_volume_mb"), + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/volume.py b/unikraft_cloud_platform/models/volume.py index ba1f878..89d0a71 100644 --- a/unikraft_cloud_platform/models/volume.py +++ b/unikraft_cloud_platform/models/volume.py @@ -1,233 +1,174 @@ -import datetime -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union, cast -from uuid import UUID +# coding: utf-8 -from attrs import define as _attrs_define -from attrs import field as _attrs_field -from dateutil.parser import isoparse - -from ..models.response_status import ResponseStatus, check_response_status -from ..models.volume_state import VolumeState, check_volume_state -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.volume_instance_id import VolumeInstanceID - from ..models.volume_volume_instance_mount import VolumeVolumeInstanceMount - - -T = TypeVar("T", bound="Volume") - - -@_attrs_define -class Volume: - """A volume represents a storage device that can be attached to an instance.""" - - uuid: Union[Unset, UUID] = UNSET - """ The UUID of the volume. - - This is a unique identifier for the volume that is generated when the - volume is created. The UUID is used to reference the volume in - API calls and can be used to identify the volume in all API calls that - require an identifier. """ - name: Union[Unset, str] = UNSET - """ The name of the volume. - - This is a human-readable name that can be used to identify the volume. - The name must be unique within the context of your account. The name can - also be used to identify the volume in API calls. """ - created_at: Union[Unset, datetime.datetime] = UNSET - """ The time the volume was created. """ - state: Union[Unset, VolumeState] = UNSET - """ Current state of the volume. """ - size_mb: Union[Unset, int] = UNSET - """ The size of the volume in megabytes. """ - persistent: Union[Unset, bool] = UNSET - """ Indicates if the volume will stay alive when the last instance is deleted - that this volume is attached to. """ - attached_to: Union[Unset, list["VolumeInstanceID"]] = UNSET - """ List of instances that this volume is attached to. """ - mounted_by: Union[Unset, list["VolumeVolumeInstanceMount"]] = UNSET - """ List of instances that have this volume mounted. """ - tags: Union[Unset, list[str]] = UNSET - """ The tags associated with the volume. """ - status: Union[Unset, ResponseStatus] = UNSET - """ The response status of an API request. """ - message: Union[Unset, str] = UNSET - """ An optional message providing additional information about the status. - This field is only set when this message object is used as a response - message, and is useful when the status is not `success`. """ - error: Union[Unset, int] = UNSET - """ An optional error code providing additional information about the status. - This field is only set when this message object is used as a response - message, and is useful when the status is not `success`. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - uuid: Union[Unset, str] = UNSET - if not isinstance(self.uuid, Unset): - uuid = str(self.uuid) - - name = self.name - - created_at: Union[Unset, str] = UNSET - if not isinstance(self.created_at, Unset): - created_at = self.created_at.isoformat() - - state: Union[Unset, str] = UNSET - if not isinstance(self.state, Unset): - state = self.state - - size_mb = self.size_mb - - persistent = self.persistent - - attached_to: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.attached_to, Unset): - attached_to = [] - for attached_to_item_data in self.attached_to: - attached_to_item = attached_to_item_data.to_dict() - attached_to.append(attached_to_item) - - mounted_by: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.mounted_by, Unset): - mounted_by = [] - for mounted_by_item_data in self.mounted_by: - mounted_by_item = mounted_by_item_data.to_dict() - mounted_by.append(mounted_by_item) - - tags: Union[Unset, list[str]] = UNSET - if not isinstance(self.tags, Unset): - tags = self.tags - - status: Union[Unset, str] = UNSET - if not isinstance(self.status, Unset): - status = self.status - - message = self.message - - error = self.error - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if uuid is not UNSET: - field_dict["uuid"] = uuid - if name is not UNSET: - field_dict["name"] = name - if created_at is not UNSET: - field_dict["created_at"] = created_at - if state is not UNSET: - field_dict["state"] = state - if size_mb is not UNSET: - field_dict["size_mb"] = size_mb - if persistent is not UNSET: - field_dict["persistent"] = persistent - if attached_to is not UNSET: - field_dict["attached_to"] = attached_to - if mounted_by is not UNSET: - field_dict["mounted_by"] = mounted_by - if tags is not UNSET: - field_dict["tags"] = tags - if status is not UNSET: - field_dict["status"] = status - if message is not UNSET: - field_dict["message"] = message - if error is not UNSET: - field_dict["error"] = error - - return field_dict +""" +Unikraft Cloud Platform - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.volume_instance_id import VolumeInstanceID - from ..models.volume_volume_instance_mount import VolumeVolumeInstanceMount - - d = dict(src_dict) - _uuid = d.pop("uuid", UNSET) - uuid: Union[Unset, UUID] - if isinstance(_uuid, Unset): - uuid = UNSET - else: - uuid = UUID(_uuid) - - name = d.pop("name", UNSET) - - _created_at = d.pop("created_at", UNSET) - created_at: Union[Unset, datetime.datetime] - if isinstance(_created_at, Unset): - created_at = UNSET - else: - created_at = isoparse(_created_at) - - _state = d.pop("state", UNSET) - state: Union[Unset, VolumeState] - if isinstance(_state, Unset): - state = UNSET - else: - state = check_volume_state(_state) - - size_mb = d.pop("size_mb", UNSET) - - persistent = d.pop("persistent", UNSET) - - attached_to = [] - _attached_to = d.pop("attached_to", UNSET) - for attached_to_item_data in _attached_to or []: - attached_to_item = VolumeInstanceID.from_dict(attached_to_item_data) - - attached_to.append(attached_to_item) - - mounted_by = [] - _mounted_by = d.pop("mounted_by", UNSET) - for mounted_by_item_data in _mounted_by or []: - mounted_by_item = VolumeVolumeInstanceMount.from_dict(mounted_by_item_data) - - mounted_by.append(mounted_by_item) - - tags = cast(list[str], d.pop("tags", UNSET)) - - _status = d.pop("status", UNSET) - status: Union[Unset, ResponseStatus] - if isinstance(_status, Unset): - status = UNSET - else: - status = check_response_status(_status) - - message = d.pop("message", UNSET) - - error = d.pop("error", UNSET) - - volume = cls( - uuid=uuid, - name=name, - created_at=created_at, - state=state, - size_mb=size_mb, - persistent=persistent, - attached_to=attached_to, - mounted_by=mounted_by, - tags=tags, - status=status, - message=message, - error=error, - ) +This is the API of the Unikraft Cloud Platform. - volume.additional_properties = d - return volume +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) +Do not edit the class manually. +""" # noqa: E501 - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] +from __future__ import annotations +import pprint +import re # noqa: F401 +import json - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value +from datetime import datetime +from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from uuid import UUID +from unikraft_cloud_platform.models.volume_attached_to_inner import VolumeAttachedToInner +from unikraft_cloud_platform.models.volume_mounted_by_inner import VolumeMountedByInner +from typing import Optional, Set +from typing_extensions import Self + + +class Volume(BaseModel): + """ + Volume + """ # noqa: E501 + + status: Optional[StrictStr] = Field( + default=None, description="The status of the response. Note: Not when listing all existing volumes. " + ) + state: Optional[StrictStr] = Field( + default=None, + description="A volume can be in one of the following states: State | Description ----------------|--- `uninitialized` | The volume is scheduled to be created. `initialized` | The volume is currently created and formatted. `available` | The volume is healthy and available to be attached to an instance. `idle` | The volume is healthy and attached to an instance. It is possible to [detach](https://unikraft.cloud/docs/api/v1/volumes/#detach) it in this state. `mounted` | The volume is currently mounted in an instance. `busy` | There are maintenance tasks running on the volume. `error` | The volume is in an error state that needs inspection by a Unikraft Cloud engineer. ", + ) + uuid: Optional[UUID] = Field(default=None, description="The UUID of the volume. ") + name: Optional[Annotated[str, Field(strict=True, max_length=255)]] = Field( + default=None, description="The name of the volume. " + ) + size_mb: Optional[Annotated[int, Field(le=1048576, strict=True, ge=1)]] = Field( + default=None, description="Size of the volume in megabytes. " + ) + attached_to: Optional[Annotated[List[VolumeAttachedToInner], Field(max_length=253)]] = Field( + default=None, description="List of instances that this volume is attached to. " + ) + mounted_by: Optional[Annotated[List[VolumeMountedByInner], Field(max_length=253)]] = Field( + default=None, description="List of instances that have this volume mounted. " + ) + persistent: Optional[StrictBool] = Field( + default=None, + description="Indicates if the volume will stay alive when the last instance is deleted that this volume is attached to. ", + ) + created_at: Optional[datetime] = Field(default=None, description="Date and time of creation in ISO8601. ") + __properties: ClassVar[List[str]] = [ + "status", + "state", + "uuid", + "name", + "size_mb", + "attached_to", + "mounted_by", + "persistent", + "created_at", + ] + + @field_validator("status") + def status_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(["success", "error"]): + raise ValueError("must be one of enum values ('success', 'error')") + return value + + @field_validator("state") + def state_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(["uninitialized", "initialized", "available", "idle", "mounted", "busy", "error"]): + raise ValueError( + "must be one of enum values ('uninitialized', 'initialized', 'available', 'idle', 'mounted', 'busy', 'error')" + ) + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of Volume from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in attached_to (list) + _items = [] + if self.attached_to: + for _item_attached_to in self.attached_to: + if _item_attached_to: + _items.append(_item_attached_to.to_dict()) + _dict["attached_to"] = _items + # override the default output from pydantic by calling `to_dict()` of each item in mounted_by (list) + _items = [] + if self.mounted_by: + for _item_mounted_by in self.mounted_by: + if _item_mounted_by: + _items.append(_item_mounted_by.to_dict()) + _dict["mounted_by"] = _items + return _dict - def __contains__(self, key: str) -> bool: - return key in self.additional_properties + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of Volume from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "status": obj.get("status"), + "state": obj.get("state"), + "uuid": obj.get("uuid"), + "name": obj.get("name"), + "size_mb": obj.get("size_mb"), + "attached_to": [VolumeAttachedToInner.from_dict(_item) for _item in obj["attached_to"]] + if obj.get("attached_to") is not None + else None, + "mounted_by": [VolumeMountedByInner.from_dict(_item) for _item in obj["mounted_by"]] + if obj.get("mounted_by") is not None + else None, + "persistent": obj.get("persistent"), + "created_at": obj.get("created_at"), + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/volume_attached_to_inner.py b/unikraft_cloud_platform/models/volume_attached_to_inner.py new file mode 100644 index 0000000..12db949 --- /dev/null +++ b/unikraft_cloud_platform/models/volume_attached_to_inner.py @@ -0,0 +1,88 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from uuid import UUID +from typing import Optional, Set +from typing_extensions import Self + + +class VolumeAttachedToInner(BaseModel): + """ + VolumeAttachedToInner + """ # noqa: E501 + + uuid: Optional[UUID] = Field(default=None, description="The UUID of the instance the volume is attached to. ") + name: Optional[Annotated[str, Field(strict=True, max_length=255)]] = Field( + default=None, description="The name of the instance the volume is attached to. " + ) + __properties: ClassVar[List[str]] = ["uuid", "name"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of VolumeAttachedToInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of VolumeAttachedToInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({"uuid": obj.get("uuid"), "name": obj.get("name")}) + return _obj diff --git a/unikraft_cloud_platform/models/volume_instance_id.py b/unikraft_cloud_platform/models/volume_instance_id.py deleted file mode 100644 index cc19ed9..0000000 --- a/unikraft_cloud_platform/models/volume_instance_id.py +++ /dev/null @@ -1,65 +0,0 @@ -from collections.abc import Mapping -from typing import Any, TypeVar, Union -from uuid import UUID - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -T = TypeVar("T", bound="VolumeInstanceID") - - -@_attrs_define -class VolumeInstanceID: - """Reference to the instance to attach the volume to.""" - - uuid: Union[Unset, UUID] = UNSET - """ The UUID of the instance that the volume is attached to. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - uuid: Union[Unset, str] = UNSET - if not isinstance(self.uuid, Unset): - uuid = str(self.uuid) - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if uuid is not UNSET: - field_dict["uuid"] = uuid - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - d = dict(src_dict) - _uuid = d.pop("uuid", UNSET) - uuid: Union[Unset, UUID] - if isinstance(_uuid, Unset): - uuid = UNSET - else: - uuid = UUID(_uuid) - - volume_instance_id = cls( - uuid=uuid, - ) - - volume_instance_id.additional_properties = d - return volume_instance_id - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/volume_mounted_by_inner.py b/unikraft_cloud_platform/models/volume_mounted_by_inner.py new file mode 100644 index 0000000..3eb6016 --- /dev/null +++ b/unikraft_cloud_platform/models/volume_mounted_by_inner.py @@ -0,0 +1,91 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictBool +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from uuid import UUID +from typing import Optional, Set +from typing_extensions import Self + + +class VolumeMountedByInner(BaseModel): + """ + VolumeMountedByInner + """ # noqa: E501 + + uuid: Optional[UUID] = Field(default=None, description="The UUID of the instance. ") + name: Optional[Annotated[str, Field(strict=True, max_length=255)]] = Field( + default=None, description="The name of the instance. " + ) + readonly: Optional[StrictBool] = Field( + default=None, description="Whether the volume is mounted read-only or read-write. " + ) + __properties: ClassVar[List[str]] = ["uuid", "name", "readonly"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of VolumeMountedByInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of VolumeMountedByInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({"uuid": obj.get("uuid"), "name": obj.get("name"), "readonly": obj.get("readonly")}) + return _obj diff --git a/unikraft_cloud_platform/models/volume_state.py b/unikraft_cloud_platform/models/volume_state.py deleted file mode 100644 index 6ccfa1e..0000000 --- a/unikraft_cloud_platform/models/volume_state.py +++ /dev/null @@ -1,19 +0,0 @@ -from typing import Literal, cast - -VolumeState = Literal["available", "busy", "error", "idle", "initializing", "mounted", "uninitialized"] - -VOLUME_STATE_VALUES: set[VolumeState] = { - "available", - "busy", - "error", - "idle", - "initializing", - "mounted", - "uninitialized", -} - - -def check_volume_state(value: str) -> VolumeState: - if value in VOLUME_STATE_VALUES: - return cast(VolumeState, value) - raise TypeError(f"Unexpected value {value!r}. Expected one of {VOLUME_STATE_VALUES!r}") diff --git a/unikraft_cloud_platform/models/volume_volume_instance_mount.py b/unikraft_cloud_platform/models/volume_volume_instance_mount.py deleted file mode 100644 index 4b7fab6..0000000 --- a/unikraft_cloud_platform/models/volume_volume_instance_mount.py +++ /dev/null @@ -1,72 +0,0 @@ -from collections.abc import Mapping -from typing import Any, TypeVar, Union -from uuid import UUID - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -T = TypeVar("T", bound="VolumeVolumeInstanceMount") - - -@_attrs_define -class VolumeVolumeInstanceMount: - uuid: Union[Unset, UUID] = UNSET - """ The UUID of the instance that the volume is mounted in. """ - read_only: Union[Unset, bool] = UNSET - """ Whether the volume is mounted read-only or read-write. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - uuid: Union[Unset, str] = UNSET - if not isinstance(self.uuid, Unset): - uuid = str(self.uuid) - - read_only = self.read_only - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if uuid is not UNSET: - field_dict["uuid"] = uuid - if read_only is not UNSET: - field_dict["read_only"] = read_only - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - d = dict(src_dict) - _uuid = d.pop("uuid", UNSET) - uuid: Union[Unset, UUID] - if isinstance(_uuid, Unset): - uuid = UNSET - else: - uuid = UUID(_uuid) - - read_only = d.pop("read_only", UNSET) - - volume_volume_instance_mount = cls( - uuid=uuid, - read_only=read_only, - ) - - volume_volume_instance_mount.additional_properties = d - return volume_volume_instance_mount - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/wait_for_instances200_response.py b/unikraft_cloud_platform/models/wait_for_instances200_response.py new file mode 100644 index 0000000..7f58766 --- /dev/null +++ b/unikraft_cloud_platform/models/wait_for_instances200_response.py @@ -0,0 +1,103 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from unikraft_cloud_platform.models.wait_for_instances200_response_data import WaitForInstances200ResponseData +from typing import Optional, Set +from typing_extensions import Self + + +class WaitForInstances200Response(BaseModel): + """ + WaitForInstances200Response + """ # noqa: E501 + + status: Optional[StrictStr] = Field(default=None, description="The status of the response. ") + data: Optional[WaitForInstances200ResponseData] = None + __properties: ClassVar[List[str]] = ["status", "data"] + + @field_validator("status") + def status_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(["success", "failure"]): + raise ValueError("must be one of enum values ('success', 'failure')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of WaitForInstances200Response from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of data + if self.data: + _dict["data"] = self.data.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of WaitForInstances200Response from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "status": obj.get("status"), + "data": WaitForInstances200ResponseData.from_dict(obj["data"]) if obj.get("data") is not None else None, + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/wait_for_instances200_response_data.py b/unikraft_cloud_platform/models/wait_for_instances200_response_data.py new file mode 100644 index 0000000..c7cead8 --- /dev/null +++ b/unikraft_cloud_platform/models/wait_for_instances200_response_data.py @@ -0,0 +1,102 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from unikraft_cloud_platform.models.wait_for_instances200_response_data_instances_inner import ( + WaitForInstances200ResponseDataInstancesInner, +) +from typing import Optional, Set +from typing_extensions import Self + + +class WaitForInstances200ResponseData(BaseModel): + """ + WaitForInstances200ResponseData + """ # noqa: E501 + + instances: Optional[Annotated[List[WaitForInstances200ResponseDataInstancesInner], Field(max_length=253)]] = None + __properties: ClassVar[List[str]] = ["instances"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of WaitForInstances200ResponseData from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in instances (list) + _items = [] + if self.instances: + for _item_instances in self.instances: + if _item_instances: + _items.append(_item_instances.to_dict()) + _dict["instances"] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of WaitForInstances200ResponseData from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "instances": [ + WaitForInstances200ResponseDataInstancesInner.from_dict(_item) for _item in obj["instances"] + ] + if obj.get("instances") is not None + else None + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/wait_for_instances200_response_data_instances_inner.py b/unikraft_cloud_platform/models/wait_for_instances200_response_data_instances_inner.py new file mode 100644 index 0000000..155144f --- /dev/null +++ b/unikraft_cloud_platform/models/wait_for_instances200_response_data_instances_inner.py @@ -0,0 +1,119 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from uuid import UUID +from typing import Optional, Set +from typing_extensions import Self + + +class WaitForInstances200ResponseDataInstancesInner(BaseModel): + """ + WaitForInstances200ResponseDataInstancesInner + """ # noqa: E501 + + status: Optional[StrictStr] = Field(default=None, description="The status of the response. ") + uuid: Optional[UUID] = Field(default=None, description="The UUID of the instance. ") + name: Optional[Annotated[str, Field(strict=True, max_length=255)]] = Field( + default=None, description="The name of the instance. " + ) + state: Optional[StrictStr] = Field(default="running", description="Current state of the instance. ") + __properties: ClassVar[List[str]] = ["status", "uuid", "name", "state"] + + @field_validator("status") + def status_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(["success", "error"]): + raise ValueError("must be one of enum values ('success', 'error')") + return value + + @field_validator("state") + def state_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(["stopped", "starting", "running", "draining", "stopping", "standby"]): + raise ValueError( + "must be one of enum values ('stopped', 'starting', 'running', 'draining', 'stopping', 'standby')" + ) + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of WaitForInstances200ResponseDataInstancesInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of WaitForInstances200ResponseDataInstancesInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "status": obj.get("status"), + "uuid": obj.get("uuid"), + "name": obj.get("name"), + "state": obj.get("state") if obj.get("state") is not None else "running", + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/wait_for_instances_request_inner.py b/unikraft_cloud_platform/models/wait_for_instances_request_inner.py new file mode 100644 index 0000000..75e9292 --- /dev/null +++ b/unikraft_cloud_platform/models/wait_for_instances_request_inner.py @@ -0,0 +1,115 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from uuid import UUID +from typing import Optional, Set +from typing_extensions import Self + + +class WaitForInstancesRequestInner(BaseModel): + """ + WaitForInstancesRequestInner + """ # noqa: E501 + + uuid: Optional[UUID] = Field( + default=None, + description="The UUID of the instance to get the status for. Note: This property is mutually exclusive with `name` and either `uuid` or `name` are required. ", + ) + name: Optional[Annotated[str, Field(strict=True, max_length=255)]] = Field( + default=None, + description="The name of the instance to get the status for. Note: This property is mutually exclusive with `uuid` and either `uuid` or `name` are required. ", + ) + state: Optional[StrictStr] = Field(default="running", description="State to wait for. ") + timeout_ms: Optional[Annotated[int, Field(le=2147483647, strict=True, ge=-1)]] = Field( + default=-1, description="Timeout for the wait in milliseconds. " + ) + __properties: ClassVar[List[str]] = ["uuid", "name", "state", "timeout_ms"] + + @field_validator("state") + def state_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(["stopped", "starting", "running", "draining", "stopping", "standby"]): + raise ValueError( + "must be one of enum values ('stopped', 'starting', 'running', 'draining', 'stopping', 'standby')" + ) + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of WaitForInstancesRequestInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of WaitForInstancesRequestInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "uuid": obj.get("uuid"), + "name": obj.get("name"), + "state": obj.get("state") if obj.get("state") is not None else "running", + "timeout_ms": obj.get("timeout_ms") if obj.get("timeout_ms") is not None else -1, + } + ) + return _obj diff --git a/unikraft_cloud_platform/models/wait_instance_by_uuid_request_body.py b/unikraft_cloud_platform/models/wait_instance_by_uuid_request_body.py deleted file mode 100644 index 5f160df..0000000 --- a/unikraft_cloud_platform/models/wait_instance_by_uuid_request_body.py +++ /dev/null @@ -1,68 +0,0 @@ -from collections.abc import Mapping -from typing import Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..models.wait_instance_by_uuid_request_body_state import ( - WaitInstanceByUUIDRequestBodyState, - check_wait_instance_by_uuid_request_body_state, -) -from ..types import UNSET, Unset - -T = TypeVar("T", bound="WaitInstanceByUUIDRequestBody") - - -@_attrs_define -class WaitInstanceByUUIDRequestBody: - """Wait parameters.""" - - state: Union[Unset, WaitInstanceByUUIDRequestBodyState] = UNSET - """ The desired state to wait for. Default is `running`. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - state: Union[Unset, str] = UNSET - if not isinstance(self.state, Unset): - state = self.state - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if state is not UNSET: - field_dict["state"] = state - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - d = dict(src_dict) - _state = d.pop("state", UNSET) - state: Union[Unset, WaitInstanceByUUIDRequestBodyState] - if isinstance(_state, Unset): - state = UNSET - else: - state = check_wait_instance_by_uuid_request_body_state(_state) - - wait_instance_by_uuid_request_body = cls( - state=state, - ) - - wait_instance_by_uuid_request_body.additional_properties = d - return wait_instance_by_uuid_request_body - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/wait_instance_by_uuid_request_body_state.py b/unikraft_cloud_platform/models/wait_instance_by_uuid_request_body_state.py deleted file mode 100644 index 0fcfeda..0000000 --- a/unikraft_cloud_platform/models/wait_instance_by_uuid_request_body_state.py +++ /dev/null @@ -1,18 +0,0 @@ -from typing import Literal, cast - -WaitInstanceByUUIDRequestBodyState = Literal["draining", "running", "standby", "starting", "stopped", "stopping"] - -WAIT_INSTANCE_BY_UUID_REQUEST_BODY_STATE_VALUES: set[WaitInstanceByUUIDRequestBodyState] = { - "draining", - "running", - "standby", - "starting", - "stopped", - "stopping", -} - - -def check_wait_instance_by_uuid_request_body_state(value: str) -> WaitInstanceByUUIDRequestBodyState: - if value in WAIT_INSTANCE_BY_UUID_REQUEST_BODY_STATE_VALUES: - return cast(WaitInstanceByUUIDRequestBodyState, value) - raise TypeError(f"Unexpected value {value!r}. Expected one of {WAIT_INSTANCE_BY_UUID_REQUEST_BODY_STATE_VALUES!r}") diff --git a/unikraft_cloud_platform/models/wait_instance_response.py b/unikraft_cloud_platform/models/wait_instance_response.py deleted file mode 100644 index ae79aa2..0000000 --- a/unikraft_cloud_platform/models/wait_instance_response.py +++ /dev/null @@ -1,130 +0,0 @@ -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..models.response_status import ResponseStatus, check_response_status -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.response_error import ResponseError - from ..models.wait_instance_response_data import WaitInstanceResponseData - - -T = TypeVar("T", bound="WaitInstanceResponse") - - -@_attrs_define -class WaitInstanceResponse: - """The response message for waiting for one or more instance(s) to reach a - certain state given their UUID(s) or name(s). - - """ - - status: Union[Unset, ResponseStatus] = UNSET - """ The response status of an API request. """ - message: Union[Unset, str] = UNSET - """ An optional message providing additional information about the status. - This field is useful when the status is not `success`. """ - data: Union[Unset, "WaitInstanceResponseData"] = UNSET - errors: Union[Unset, list["ResponseError"]] = UNSET - """ A list of errors which may have occurred during the request. """ - op_time_us: Union[Unset, int] = UNSET - """ The operation time in microseconds. This is the time it took to process - the request and generate the response. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - status: Union[Unset, str] = UNSET - if not isinstance(self.status, Unset): - status = self.status - - message = self.message - - data: Union[Unset, dict[str, Any]] = UNSET - if not isinstance(self.data, Unset): - data = self.data.to_dict() - - errors: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.errors, Unset): - errors = [] - for errors_item_data in self.errors: - errors_item = errors_item_data.to_dict() - errors.append(errors_item) - - op_time_us = self.op_time_us - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if status is not UNSET: - field_dict["status"] = status - if message is not UNSET: - field_dict["message"] = message - if data is not UNSET: - field_dict["data"] = data - if errors is not UNSET: - field_dict["errors"] = errors - if op_time_us is not UNSET: - field_dict["op_time_us"] = op_time_us - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.response_error import ResponseError - from ..models.wait_instance_response_data import WaitInstanceResponseData - - d = dict(src_dict) - _status = d.pop("status", UNSET) - status: Union[Unset, ResponseStatus] - if isinstance(_status, Unset): - status = UNSET - else: - status = check_response_status(_status) - - message = d.pop("message", UNSET) - - _data = d.pop("data", UNSET) - data: Union[Unset, WaitInstanceResponseData] - if isinstance(_data, Unset): - data = UNSET - else: - data = WaitInstanceResponseData.from_dict(_data) - - errors = [] - _errors = d.pop("errors", UNSET) - for errors_item_data in _errors or []: - errors_item = ResponseError.from_dict(errors_item_data) - - errors.append(errors_item) - - op_time_us = d.pop("op_time_us", UNSET) - - wait_instance_response = cls( - status=status, - message=message, - data=data, - errors=errors, - op_time_us=op_time_us, - ) - - wait_instance_response.additional_properties = d - return wait_instance_response - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/wait_instance_response_data.py b/unikraft_cloud_platform/models/wait_instance_response_data.py deleted file mode 100644 index 6e0b08a..0000000 --- a/unikraft_cloud_platform/models/wait_instance_response_data.py +++ /dev/null @@ -1,71 +0,0 @@ -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.wait_instance_response_waited_instance import WaitInstanceResponseWaitedInstance - - -T = TypeVar("T", bound="WaitInstanceResponseData") - - -@_attrs_define -class WaitInstanceResponseData: - instances: Union[Unset, list["WaitInstanceResponseWaitedInstance"]] = UNSET - """ The instance(s) which this requested waited on. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - instances: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.instances, Unset): - instances = [] - for instances_item_data in self.instances: - instances_item = instances_item_data.to_dict() - instances.append(instances_item) - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if instances is not UNSET: - field_dict["instances"] = instances - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.wait_instance_response_waited_instance import WaitInstanceResponseWaitedInstance - - d = dict(src_dict) - instances = [] - _instances = d.pop("instances", UNSET) - for instances_item_data in _instances or []: - instances_item = WaitInstanceResponseWaitedInstance.from_dict(instances_item_data) - - instances.append(instances_item) - - wait_instance_response_data = cls( - instances=instances, - ) - - wait_instance_response_data.additional_properties = d - return wait_instance_response_data - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/wait_instance_response_waited_instance.py b/unikraft_cloud_platform/models/wait_instance_response_waited_instance.py deleted file mode 100644 index 67a0cf0..0000000 --- a/unikraft_cloud_platform/models/wait_instance_response_waited_instance.py +++ /dev/null @@ -1,112 +0,0 @@ -from collections.abc import Mapping -from typing import Any, TypeVar, Union -from uuid import UUID - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..models.wait_instance_response_waited_instance_state import ( - WaitInstanceResponseWaitedInstanceState, - check_wait_instance_response_waited_instance_state, -) -from ..types import UNSET, Unset - -T = TypeVar("T", bound="WaitInstanceResponseWaitedInstance") - - -@_attrs_define -class WaitInstanceResponseWaitedInstance: - uuid: Union[Unset, UUID] = UNSET - """ The UUID of the instance. """ - name: Union[Unset, str] = UNSET - """ The name of the instance. """ - state: Union[Unset, WaitInstanceResponseWaitedInstanceState] = UNSET - """ The current state of the instance. """ - message: Union[Unset, str] = UNSET - """ An optional message providing additional information about the status. - This field is useful when the status is not `success`. """ - error: Union[Unset, int] = UNSET - """ An optional error code providing additional information about the status. - This field is useful when the status is not `success`. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - uuid: Union[Unset, str] = UNSET - if not isinstance(self.uuid, Unset): - uuid = str(self.uuid) - - name = self.name - - state: Union[Unset, str] = UNSET - if not isinstance(self.state, Unset): - state = self.state - - message = self.message - - error = self.error - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if uuid is not UNSET: - field_dict["uuid"] = uuid - if name is not UNSET: - field_dict["name"] = name - if state is not UNSET: - field_dict["state"] = state - if message is not UNSET: - field_dict["message"] = message - if error is not UNSET: - field_dict["error"] = error - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - d = dict(src_dict) - _uuid = d.pop("uuid", UNSET) - uuid: Union[Unset, UUID] - if isinstance(_uuid, Unset): - uuid = UNSET - else: - uuid = UUID(_uuid) - - name = d.pop("name", UNSET) - - _state = d.pop("state", UNSET) - state: Union[Unset, WaitInstanceResponseWaitedInstanceState] - if isinstance(_state, Unset): - state = UNSET - else: - state = check_wait_instance_response_waited_instance_state(_state) - - message = d.pop("message", UNSET) - - error = d.pop("error", UNSET) - - wait_instance_response_waited_instance = cls( - uuid=uuid, - name=name, - state=state, - message=message, - error=error, - ) - - wait_instance_response_waited_instance.additional_properties = d - return wait_instance_response_waited_instance - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/unikraft_cloud_platform/models/wait_instance_response_waited_instance_state.py b/unikraft_cloud_platform/models/wait_instance_response_waited_instance_state.py deleted file mode 100644 index ea338b6..0000000 --- a/unikraft_cloud_platform/models/wait_instance_response_waited_instance_state.py +++ /dev/null @@ -1,20 +0,0 @@ -from typing import Literal, cast - -WaitInstanceResponseWaitedInstanceState = Literal["draining", "running", "standby", "starting", "stopped", "stopping"] - -WAIT_INSTANCE_RESPONSE_WAITED_INSTANCE_STATE_VALUES: set[WaitInstanceResponseWaitedInstanceState] = { - "draining", - "running", - "standby", - "starting", - "stopped", - "stopping", -} - - -def check_wait_instance_response_waited_instance_state(value: str) -> WaitInstanceResponseWaitedInstanceState: - if value in WAIT_INSTANCE_RESPONSE_WAITED_INSTANCE_STATE_VALUES: - return cast(WaitInstanceResponseWaitedInstanceState, value) - raise TypeError( - f"Unexpected value {value!r}. Expected one of {WAIT_INSTANCE_RESPONSE_WAITED_INSTANCE_STATE_VALUES!r}" - ) diff --git a/unikraft_cloud_platform/models/wait_instances_state.py b/unikraft_cloud_platform/models/wait_instances_state.py deleted file mode 100644 index 7a24c3b..0000000 --- a/unikraft_cloud_platform/models/wait_instances_state.py +++ /dev/null @@ -1,18 +0,0 @@ -from typing import Literal, cast - -WaitInstancesState = Literal["draining", "running", "standby", "starting", "stopped", "stopping"] - -WAIT_INSTANCES_STATE_VALUES: set[WaitInstancesState] = { - "draining", - "running", - "standby", - "starting", - "stopped", - "stopping", -} - - -def check_wait_instances_state(value: str) -> WaitInstancesState: - if value in WAIT_INSTANCES_STATE_VALUES: - return cast(WaitInstancesState, value) - raise TypeError(f"Unexpected value {value!r}. Expected one of {WAIT_INSTANCES_STATE_VALUES!r}") diff --git a/unikraft_cloud_platform/py.typed b/unikraft_cloud_platform/py.typed deleted file mode 100644 index 1aad327..0000000 --- a/unikraft_cloud_platform/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561 \ No newline at end of file diff --git a/unikraft_cloud_platform/rest.py b/unikraft_cloud_platform/rest.py new file mode 100644 index 0000000..ea895b2 --- /dev/null +++ b/unikraft_cloud_platform/rest.py @@ -0,0 +1,207 @@ +# coding: utf-8 + +""" +Unikraft Cloud Platform + +This is the API of the Unikraft Cloud Platform. + +The version of the OpenAPI document: 0.6.0 +Contact: info@unikraft.cloud +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +import io +import json +import re +import ssl + +import urllib3 + +from unikraft_cloud_platform.exceptions import ApiException, ApiValueError + +SUPPORTED_SOCKS_PROXIES = {"socks5", "socks5h", "socks4", "socks4a"} +RESTResponseType = urllib3.HTTPResponse + + +def is_socks_proxy_url(url): + if url is None: + return False + split_section = url.split("://") + if len(split_section) < 2: + return False + else: + return split_section[0].lower() in SUPPORTED_SOCKS_PROXIES + + +class RESTResponse(io.IOBase): + def __init__(self, resp) -> None: + self.response = resp + self.status = resp.status + self.reason = resp.reason + self.data = None + + def read(self): + if self.data is None: + self.data = self.response.data + return self.data + + def getheaders(self): + """Returns a dictionary of the response headers.""" + return self.response.headers + + def getheader(self, name, default=None): + """Returns a given response header.""" + return self.response.headers.get(name, default) + + +class RESTClientObject: + def __init__(self, configuration) -> None: + # urllib3.PoolManager will pass all kw parameters to connectionpool + # https://github.com/shazow/urllib3/blob/f9409436f83aeb79fbaf090181cd81b784f1b8ce/urllib3/poolmanager.py#L75 # noqa: E501 + # https://github.com/shazow/urllib3/blob/f9409436f83aeb79fbaf090181cd81b784f1b8ce/urllib3/connectionpool.py#L680 # noqa: E501 + # Custom SSL certificates and client certificates: http://urllib3.readthedocs.io/en/latest/advanced-usage.html # noqa: E501 + + # cert_reqs + if configuration.verify_ssl: + cert_reqs = ssl.CERT_REQUIRED + else: + cert_reqs = ssl.CERT_NONE + + pool_args = { + "cert_reqs": cert_reqs, + "ca_certs": configuration.ssl_ca_cert, + "cert_file": configuration.cert_file, + "key_file": configuration.key_file, + "ca_cert_data": configuration.ca_cert_data, + } + if configuration.assert_hostname is not None: + pool_args["assert_hostname"] = configuration.assert_hostname + + if configuration.retries is not None: + pool_args["retries"] = configuration.retries + + if configuration.tls_server_name: + pool_args["server_hostname"] = configuration.tls_server_name + + if configuration.socket_options is not None: + pool_args["socket_options"] = configuration.socket_options + + if configuration.connection_pool_maxsize is not None: + pool_args["maxsize"] = configuration.connection_pool_maxsize + + # https pool manager + self.pool_manager: urllib3.PoolManager + + if configuration.proxy: + if is_socks_proxy_url(configuration.proxy): + from urllib3.contrib.socks import SOCKSProxyManager + + pool_args["proxy_url"] = configuration.proxy + pool_args["headers"] = configuration.proxy_headers + self.pool_manager = SOCKSProxyManager(**pool_args) + else: + pool_args["proxy_url"] = configuration.proxy + pool_args["proxy_headers"] = configuration.proxy_headers + self.pool_manager = urllib3.ProxyManager(**pool_args) + else: + self.pool_manager = urllib3.PoolManager(**pool_args) + + def request(self, method, url, headers=None, body=None, post_params=None, _request_timeout=None): + """Perform requests. + + :param method: http request method + :param url: http request url + :param headers: http request headers + :param body: request json body, for `application/json` + :param post_params: request post parameters, + `application/x-www-form-urlencoded` + and `multipart/form-data` + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + """ + method = method.upper() + assert method in ["GET", "HEAD", "DELETE", "POST", "PUT", "PATCH", "OPTIONS"] + + if post_params and body: + raise ApiValueError("body parameter cannot be used with post_params parameter.") + + post_params = post_params or {} + headers = headers or {} + + timeout = None + if _request_timeout: + if isinstance(_request_timeout, (int, float)): + timeout = urllib3.Timeout(total=_request_timeout) + elif isinstance(_request_timeout, tuple) and len(_request_timeout) == 2: + timeout = urllib3.Timeout(connect=_request_timeout[0], read=_request_timeout[1]) + + try: + # For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE` + if method in ["POST", "PUT", "PATCH", "OPTIONS", "DELETE"]: + # no content type provided or payload is json + content_type = headers.get("Content-Type") + if not content_type or re.search("json", content_type, re.IGNORECASE): + request_body = None + if body is not None: + request_body = json.dumps(body) + r = self.pool_manager.request( + method, url, body=request_body, timeout=timeout, headers=headers, preload_content=False + ) + elif content_type == "application/x-www-form-urlencoded": + r = self.pool_manager.request( + method, + url, + fields=post_params, + encode_multipart=False, + timeout=timeout, + headers=headers, + preload_content=False, + ) + elif content_type == "multipart/form-data": + # must del headers['Content-Type'], or the correct + # Content-Type which generated by urllib3 will be + # overwritten. + del headers["Content-Type"] + # Ensures that dict objects are serialized + post_params = [(a, json.dumps(b)) if isinstance(b, dict) else (a, b) for a, b in post_params] + r = self.pool_manager.request( + method, + url, + fields=post_params, + encode_multipart=True, + timeout=timeout, + headers=headers, + preload_content=False, + ) + # Pass a `string` parameter directly in the body to support + # other content types than JSON when `body` argument is + # provided in serialized form. + elif isinstance(body, str) or isinstance(body, bytes): + r = self.pool_manager.request( + method, url, body=body, timeout=timeout, headers=headers, preload_content=False + ) + elif headers["Content-Type"].startswith("text/") and isinstance(body, bool): + request_body = "true" if body else "false" + r = self.pool_manager.request( + method, url, body=request_body, preload_content=False, timeout=timeout, headers=headers + ) + else: + # Cannot generate the request from given parameters + msg = """Cannot prepare a request message for provided + arguments. Please check that your arguments match + declared content type.""" + raise ApiException(status=0, reason=msg) + # For `GET`, `HEAD` + else: + r = self.pool_manager.request( + method, url, fields={}, timeout=timeout, headers=headers, preload_content=False + ) + except urllib3.exceptions.SSLError as e: + msg = "\n".join([type(e).__name__, str(e)]) + raise ApiException(status=0, reason=msg) + + return RESTResponse(r) diff --git a/unikraft_cloud_platform/types.py b/unikraft_cloud_platform/types.py deleted file mode 100644 index 1b96ca4..0000000 --- a/unikraft_cloud_platform/types.py +++ /dev/null @@ -1,54 +0,0 @@ -"""Contains some shared types for properties""" - -from collections.abc import Mapping, MutableMapping -from http import HTTPStatus -from typing import IO, BinaryIO, Generic, Literal, Optional, TypeVar, Union - -from attrs import define - - -class Unset: - def __bool__(self) -> Literal[False]: - return False - - -UNSET: Unset = Unset() - -# The types that `httpx.Client(files=)` can accept, copied from that library. -FileContent = Union[IO[bytes], bytes, str] -FileTypes = Union[ - # (filename, file (or bytes), content_type) - tuple[Optional[str], FileContent, Optional[str]], - # (filename, file (or bytes), content_type, headers) - tuple[Optional[str], FileContent, Optional[str], Mapping[str, str]], -] -RequestFiles = list[tuple[str, FileTypes]] - - -@define -class File: - """Contains information for file uploads""" - - payload: BinaryIO - file_name: Optional[str] = None - mime_type: Optional[str] = None - - def to_tuple(self) -> FileTypes: - """Return a tuple representation that httpx will accept for multipart/form-data""" - return self.file_name, self.payload, self.mime_type - - -T = TypeVar("T") - - -@define -class Response(Generic[T]): - """A response from an endpoint""" - - status_code: HTTPStatus - content: bytes - headers: MutableMapping[str, str] - parsed: Optional[T] - - -__all__ = ["UNSET", "File", "FileTypes", "RequestFiles", "Response", "Unset"]