diff --git a/.github/workflows/actionlint.yaml b/.github/workflows/actionlint.yaml new file mode 100644 index 0000000..b0f05fa --- /dev/null +++ b/.github/workflows/actionlint.yaml @@ -0,0 +1,26 @@ +name: actionlint + +on: + pull_request: + branches: [prod-staging] + paths: + - '.github/workflows/**' + +# Automatically cancel in-progress actions on the same branch +concurrency: + group: ${{ github.workflow }}-${{ github.event_name == 'pull_request_target' && github.head_ref || github.ref }} + cancel-in-progress: true + +jobs: + actionlint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Install action linter + run: | + mkdir -p "$HOME"/.local/bin + curl -sL https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash | bash -s -- latest "$HOME"/.local/bin + + - name: Check that all workflows are valid + run: actionlint -verbose diff --git a/.github/workflows/check-pr.yaml b/.github/workflows/check-pr.yaml new file mode 100644 index 0000000..47ea46d --- /dev/null +++ b/.github/workflows/check-pr.yaml @@ -0,0 +1,81 @@ +name: check/pr + +on: + pull_request: + types: [ opened, synchronize, reopened ] + branches: [ prod-staging ] + +permissions: + contents: read + +jobs: + commits: + runs-on: ubuntu-latest + steps: + - name: format + if: always() + uses: taskmedia/action-conventional-commits@v1.1.20 + with: + types: "build|ci|docs|feat|fix|perf|refactor|style|test|revert|chore|sync" + token: ${{ secrets.GH_PAT }} + + - name: length + if: ${{ github.actor != 'dependabot' && github.actor != 'dependabot[bot]' }} + uses: gsactions/commit-message-checker@v2 + with: + pattern: '((^(?=(?:.|\n)*(?:^|\n)\[\d\]: .{69,}(?:$|\n)(?:.|\n)*)(?:.|\n)*$)|(^(?!(?:.|\n)*(?:^|\n).{74,}(?:$|\n)(?:.|\n)*)(?:.|\n)*$))' + flags: '' + error: 'The maximum line length of 74 characters is exceeded.' + excludeDescription: 'true' + excludeTitle: 'true' + checkAllCommitMessages: 'true' + accessToken: ${{ secrets.GH_PAT }} + + - name: signed-off-by + if: always() + uses: gsactions/commit-message-checker@v2 + with: + pattern: '^Signed-off-by: .+ \<.+\@.+\..+\>$' + error: 'Signed-off-by line is missing.' + excludeDescription: 'true' + excludeTitle: 'true' + checkAllCommitMessages: 'true' + accessToken: ${{ secrets.GH_PAT }} + + pr: + runs-on: ubuntu-latest + steps: + - name: title-format + if: always() + uses: gsactions/commit-message-checker@v2 + with: + pattern: '^(build|ci|docs|feat|fix|perf|refactor|style|test|revert|chore|sync)(\([\w\-\_\d]+\))?!?: ' + error: 'The PR title must follow the conventional commits format.' + excludeDescription: 'true' + excludeTitle: 'false' + checkAllCommitMessages: 'false' + accessToken: ${{ secrets.GH_PAT }} + + - name: title-length + if: ${{ github.actor != 'dependabot' && github.actor != 'dependabot[bot]' }} + uses: gsactions/commit-message-checker@v2 + with: + pattern: '^(?!.{75,}).*' + flags: '' + error: 'The maximum line length of 75 characters is exceeded.' + excludeDescription: 'true' + excludeTitle: 'false' + checkAllCommitMessages: 'false' + accessToken: ${{ secrets.GH_PAT }} + + - name: description + if: ${{ github.actor != 'dependabot' && github.actor != 'dependabot[bot]' }} + uses: gsactions/commit-message-checker@v2 + with: + pattern: '^\S+( \S+)*$' + error: 'The PR description must not be empty.' + flags: 'gm' + excludeDescription: 'false' + excludeTitle: 'true' + checkAllCommitMessages: 'false' + accessToken: ${{ secrets.GH_PAT }} diff --git a/.github/workflows/release-stable.yaml b/.github/workflows/release-stable.yaml new file mode 100644 index 0000000..b4f2226 --- /dev/null +++ b/.github/workflows/release-stable.yaml @@ -0,0 +1,31 @@ +name: release-stable + +on: + push: + branches: [prod-staging] + +permissions: + deployments: write + contents: read + +jobs: + release: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + with: + ref: prod-stable + + - name: Reset promotion branch + run: | + git fetch origin prod-staging:prod-staging + git reset --hard prod-staging + + - name: Create pull request + uses: peter-evans/create-pull-request@v6 + with: + token: ${{ secrets.GH_PAT }} + base: prod-stable + title: "release: Merge latest prod-staging changes to prod-stable" + branch: prod-staging diff --git a/.github/workflows/sync.yaml b/.github/workflows/sync.yaml new file mode 100644 index 0000000..11d07a2 --- /dev/null +++ b/.github/workflows/sync.yaml @@ -0,0 +1,60 @@ +name: sync + +on: + workflow_dispatch: + inputs: + channel: + default: prod-stable + description: | + The name of the release channel. + One of: [prod-stable, prod-staging] + +# Automatically cancel in-progress actions on the same branch +concurrency: + group: ${{ github.workflow }}-${{ github.event_name == 'pull_request_target' && github.head_ref || github.ref }} + cancel-in-progress: true + +permissions: + contents: write + +jobs: + sync: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ inputs.channel }} + + - name: Install uv + uses: astral-sh/setup-uv@v7 + + - name: Generate + shell: bash + env: + CHANNEL: ${{ inputs.channel }} + run: | + make generate + + - name: Show diff + shell: bash + run: | + git diff + + - name: Generate branch ID + id: id + run: | + BRANCH="sync/$(date +'%Y%m%d%H%M%S')" + echo "name=${BRANCH}" >>"${GITHUB_OUTPUT}" + + - name: Create pull request + uses: peter-evans/create-pull-request@v6 + with: + token: ${{ secrets.GH_PAT }} + base: ${{ inputs.channel }} + commit-message: "sync: Update Python SDK from OpenAPI spec" + title: "sync: Update Python SDK from OpenAPI spec" + branch: ${{ steps.id.outputs.name }} + committer: Unikraft Bot + author: Unikraft Bot + add-paths: controlplane,platform + signoff: true diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..79a2c3d --- /dev/null +++ b/.gitignore @@ -0,0 +1,23 @@ +__pycache__/ +build/ +dist/ +*.egg-info/ +.pytest_cache/ + +# pyenv +.python-version + +# Environments +.env +.venv + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# JetBrains +.idea/ + +/coverage.xml +/.coverage diff --git a/.platform-config.yaml b/.platform-config.yaml new file mode 100644 index 0000000..f29ec1d --- /dev/null +++ b/.platform-config.yaml @@ -0,0 +1,4 @@ +project_name_override: unikraft-cloud-platform +package_name_override: unikraft_cloud_platform +literal_enums: true +docstrings_on_attributes: true diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..ec0f333 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,28 @@ +BSD 3-Clause License + +Copyright (c) 2025, Unikraft GmbH. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..f64efa0 --- /dev/null +++ b/Makefile @@ -0,0 +1,30 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright (c) 2025, Unikraft GmbH. +# Licensed under the BSD-3-Clause License (the "License"). +# You may not use this file except in compliance with the License. + +# Prelude +WORKDIR ?= $(CURDIR) +Q ?= @ +CHANNEL ?= prod-stable + +# Tools +WGET ?= wget +UV ?= uv + +.PHONY: all +all: generate + +.PHONY: 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 \ diff --git a/README.md b/README.md new file mode 100644 index 0000000..cf1b086 --- /dev/null +++ b/README.md @@ -0,0 +1,95 @@ +# Unikraft Cloud Python SDK + +This repository contains an auto-generated Go SDK which interfaces with +[Unikraft Cloud](https://unikraft.cloud) based on the public +[OpenAPI](https://github.com/unikraft-cloud/openapi) specification. + +> **Get started with Unikraft Cloud Today** +> +> Sign up at https://console.unikraft.cloud/signup + +## Quickstart + +```python +#!/usr/bin/env python3 +""" +List Instances Example + +This example demonstrates how to use the Unikraft Cloud Platform SDK to list instances. + +Usage: + python list_instances.py + +Environment Variables: + UKC_TOKEN: Your Unikraft Cloud API token (required) + UKC_METRO: The metro URL (optional, defaults to fra0.kraft.cloud) + +Example: + export UKC_TOKEN="your-api-token-here" + export UKC_METRO="https://api.fra0.kraft.cloud" + python list_instances.py +""" + +import os +import sys +from unikraft_cloud_platform import AuthenticatedClient +from unikraft_cloud_platform.models import Instance +from unikraft_cloud_platform.models.get_instances_response import GetInstancesResponse +from unikraft_cloud_platform.api.instances import get_instances +from unikraft_cloud_platform.types import Response + + +def main(): + # Read configuration from environment variables + token = os.getenv("UKC_TOKEN") + base_url = os.getenv("UKC_METRO", "https://api.fra0.kraft.cloud") + + if not token: + print("Error: UKC_TOKEN environment variable is required", file=sys.stderr) + print("Please set your API token: export UKC_TOKEN='your-token-here'", file=sys.stderr) + sys.exit(1) + + client = AuthenticatedClient( + base_url=base_url, + token=token, + ) + + # List all instances (empty body means get all instances) + with client as client: + response: Response[GetInstancesResponse] = get_instances.sync_detailed( + client=client, + body=[], # Empty list to get all instances + details=True + ) + + # Check if the request was successful + if response.status_code == 200 and response.parsed: + instances_response = response.parsed + + # Check if we have data and instances + if instances_response.data and instances_response.data.instances: + print(f"Found {len(instances_response.data.instances)} instances:") + print("-" * 50) + + for instance in instances_response.data.instances: + print(f"Name: {instance.name}") + print(f"UUID: {instance.uuid}") + print(f"State: {instance.state}") + print(f"Created: {instance.created_at}") + if instance.private_fqdn: + print(f"Private FQDN: {instance.private_fqdn}") + print("-" * 50) + else: + print("No instances found.") + else: + print(f"Failed to retrieve instances. Status code: {response.status_code}") + if response.parsed and response.parsed.message: + print(f"Error message: {response.parsed.message}") + if response.parsed and response.parsed.errors: + for error in response.parsed.errors: + print(f"Error: {error}") + + +if __name__ == "__main__": + main() +``` diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..10c5021 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,26 @@ +[project] +name = "unikraft-cloud-platform" +version = "v1.0.0" +description = "A client library for accessing Unikraft Cloud Platform API" +authors = [] +requires-python = ">=3.9,<4.0" +readme = "README.md" +dependencies = [ + "httpx>=0.23.0,<0.29.0", + "attrs>=22.2.0", + "python-dateutil>=2.8.0,<3", +] + +[tool.uv.build-backend] +module-name = "unikraft_cloud_platform" +module-root = "" + +[build-system] +requires = ["uv_build>=0.8.0,<0.9.0"] +build-backend = "uv_build" + +[tool.ruff] +line-length = 120 + +[tool.ruff.lint] +select = ["F", "I", "UP"] diff --git a/templates/.gitignore.jinja b/templates/.gitignore.jinja new file mode 100644 index 0000000..79a2c3d --- /dev/null +++ b/templates/.gitignore.jinja @@ -0,0 +1,23 @@ +__pycache__/ +build/ +dist/ +*.egg-info/ +.pytest_cache/ + +# pyenv +.python-version + +# Environments +.env +.venv + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# JetBrains +.idea/ + +/coverage.xml +/.coverage diff --git a/templates/README.md.jinja b/templates/README.md.jinja new file mode 100644 index 0000000..cf1b086 --- /dev/null +++ b/templates/README.md.jinja @@ -0,0 +1,95 @@ +# Unikraft Cloud Python SDK + +This repository contains an auto-generated Go SDK which interfaces with +[Unikraft Cloud](https://unikraft.cloud) based on the public +[OpenAPI](https://github.com/unikraft-cloud/openapi) specification. + +> **Get started with Unikraft Cloud Today** +> +> Sign up at https://console.unikraft.cloud/signup + +## Quickstart + +```python +#!/usr/bin/env python3 +""" +List Instances Example + +This example demonstrates how to use the Unikraft Cloud Platform SDK to list instances. + +Usage: + python list_instances.py + +Environment Variables: + UKC_TOKEN: Your Unikraft Cloud API token (required) + UKC_METRO: The metro URL (optional, defaults to fra0.kraft.cloud) + +Example: + export UKC_TOKEN="your-api-token-here" + export UKC_METRO="https://api.fra0.kraft.cloud" + python list_instances.py +""" + +import os +import sys +from unikraft_cloud_platform import AuthenticatedClient +from unikraft_cloud_platform.models import Instance +from unikraft_cloud_platform.models.get_instances_response import GetInstancesResponse +from unikraft_cloud_platform.api.instances import get_instances +from unikraft_cloud_platform.types import Response + + +def main(): + # Read configuration from environment variables + token = os.getenv("UKC_TOKEN") + base_url = os.getenv("UKC_METRO", "https://api.fra0.kraft.cloud") + + if not token: + print("Error: UKC_TOKEN environment variable is required", file=sys.stderr) + print("Please set your API token: export UKC_TOKEN='your-token-here'", file=sys.stderr) + sys.exit(1) + + client = AuthenticatedClient( + base_url=base_url, + token=token, + ) + + # List all instances (empty body means get all instances) + with client as client: + response: Response[GetInstancesResponse] = get_instances.sync_detailed( + client=client, + body=[], # Empty list to get all instances + details=True + ) + + # Check if the request was successful + if response.status_code == 200 and response.parsed: + instances_response = response.parsed + + # Check if we have data and instances + if instances_response.data and instances_response.data.instances: + print(f"Found {len(instances_response.data.instances)} instances:") + print("-" * 50) + + for instance in instances_response.data.instances: + print(f"Name: {instance.name}") + print(f"UUID: {instance.uuid}") + print(f"State: {instance.state}") + print(f"Created: {instance.created_at}") + if instance.private_fqdn: + print(f"Private FQDN: {instance.private_fqdn}") + print("-" * 50) + else: + print("No instances found.") + else: + print(f"Failed to retrieve instances. Status code: {response.status_code}") + if response.parsed and response.parsed.message: + print(f"Error message: {response.parsed.message}") + if response.parsed and response.parsed.errors: + for error in response.parsed.errors: + print(f"Error: {error}") + + +if __name__ == "__main__": + main() +``` diff --git a/templates/api_init.py.jinja b/templates/api_init.py.jinja new file mode 100644 index 0000000..dc035f4 --- /dev/null +++ b/templates/api_init.py.jinja @@ -0,0 +1 @@ +""" Contains methods for accessing the API """ diff --git a/templates/client.py.jinja b/templates/client.py.jinja new file mode 100644 index 0000000..cf0301a --- /dev/null +++ b/templates/client.py.jinja @@ -0,0 +1,191 @@ +import ssl +from typing import Any, Union, Optional + +from attrs import define, field, evolve +import httpx + + +{% set attrs_info = { + "raise_on_unexpected_status": namespace( + type="bool", + default="field(default=False, kw_only=True)", + docstring="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." + ), + "token": namespace(type="str", default="", docstring="The token to use for authentication"), + "prefix": namespace(type="str", default='"Bearer"', docstring="The prefix to use for the Authorization header"), + "auth_header_name": namespace(type="str", default='"Authorization"', docstring="The name of the Authorization header"), +} %} + +{% macro attr_in_class_docstring(name) %} +{{ name }}: {{ attrs_info[name].docstring }} +{%- endmacro %} + +{% macro declare_attr(name) %} +{% set attr = attrs_info[name] %} +{{ name }}: {{ attr.type }}{% if attr.default %} = {{ attr.default }}{% endif %} +{% if attr.docstring and config.docstrings_on_attributes +%} +"""{{ attr.docstring }}""" +{%- endif %} +{% endmacro %} + +@define +class Client: + """A class for keeping track of data related to the API + +{% macro httpx_args_docstring() %} + 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. +{% endmacro %} +{{ httpx_args_docstring() }} +{% if not config.docstrings_on_attributes %} + + Attributes: + {{ attr_in_class_docstring("raise_on_unexpected_status") | wordwrap(101) | indent(12) }} +{% endif %} + """ +{% macro attributes() %} + {{ declare_attr("raise_on_unexpected_status") | indent(4) }} + _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) +{% endmacro %}{{ attributes() }} +{% macro builders(self) %} + def with_headers(self, headers: dict[str, str]) -> "{{ self }}": + """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]) -> "{{ self }}": + """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) -> "{{ self }}": + """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) +{% endmacro %}{{ builders("Client") }} +{% macro httpx_stuff(name, custom_constructor=None) %} + def set_httpx_client(self, client: httpx.Client) -> "{{ name }}": + """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: + {% if custom_constructor %} + {{ custom_constructor | indent(12) }} + {% endif %} + 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) -> "{{ name }}": + """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) -> "{{ name }}": + """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: + {% if custom_constructor %} + {{ custom_constructor | indent(12) }} + {% endif %} + 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) -> "{{ name }}": + """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) +{% endmacro %}{{ httpx_stuff("Client") }} + +@define +class AuthenticatedClient: + """A Client which has been authenticated for use on secured endpoints + +{{ httpx_args_docstring() }} +{% if not config.docstrings_on_attributes %} + + Attributes: + {{ attr_in_class_docstring("raise_on_unexpected_status") | wordwrap(101) | indent(12) }} + {{ attr_in_class_docstring("token") | indent(8) }} + {{ attr_in_class_docstring("prefix") | indent(8) }} + {{ attr_in_class_docstring("auth_header_name") | indent(8) }} +{% endif %} + """ + +{{ attributes() }} + {{ declare_attr("token") | indent(4) }} + {{ declare_attr("prefix") | indent(4) }} + {{ declare_attr("auth_header_name") | indent(4) }} + +{{ builders("AuthenticatedClient") }} +{{ httpx_stuff("AuthenticatedClient", "self._headers[self.auth_header_name] = f\"{self.prefix} {self.token}\" if self.prefix else self.token") }} diff --git a/templates/endpoint_init.py.jinja b/templates/endpoint_init.py.jinja new file mode 100644 index 0000000..c9921b5 --- /dev/null +++ b/templates/endpoint_init.py.jinja @@ -0,0 +1 @@ +""" Contains endpoint functions for accessing the API """ diff --git a/templates/endpoint_macros.py.jinja b/templates/endpoint_macros.py.jinja new file mode 100644 index 0000000..9f0ea6b --- /dev/null +++ b/templates/endpoint_macros.py.jinja @@ -0,0 +1,201 @@ +{% from "property_templates/helpers.jinja" import guarded_statement %} +{% from "helpers.jinja" import safe_docstring %} + +{% macro header_params(endpoint) %} +{% if endpoint.header_parameters or endpoint.bodies | length > 0 %} +headers: dict[str, Any] = {} +{% if endpoint.header_parameters %} + {% for parameter in endpoint.header_parameters %} + {% import "property_templates/" + parameter.template as param_template %} + {% if param_template.transform_header %} + {% set expression = param_template.transform_header(parameter.python_name) %} + {% else %} + {% set expression = parameter.python_name %} + {% endif %} + {% set statement = 'headers["' + parameter.name + '"]' + " = " + expression %} +{{ guarded_statement(parameter, parameter.python_name, statement) }} + {% endfor %} +{% endif %} +{% endif %} +{% endmacro %} + +{% macro cookie_params(endpoint) %} +{% if endpoint.cookie_parameters %} +cookies = {} + {% for parameter in endpoint.cookie_parameters %} + {% if parameter.required %} +cookies["{{ parameter.name}}"] = {{ parameter.python_name }} + {% else %} +if {{ parameter.python_name }} is not UNSET: + cookies["{{ parameter.name}}"] = {{ parameter.python_name }} + {% endif %} + + {% endfor %} +{% endif %} +{% endmacro %} + + +{% macro query_params(endpoint) %} +{% if endpoint.query_parameters %} +params: dict[str, Any] = {} + +{% for property in endpoint.query_parameters %} + {% set destination = property.python_name %} + {% import "property_templates/" + property.template as prop_template %} + {% if prop_template.transform %} + {% set destination = "json_" + property.python_name %} +{{ prop_template.transform(property, property.python_name, destination) }} + {% endif %} + {%- if not property.json_is_dict %} +params["{{ property.name }}"] = {{ destination }} + {% else %} +{{ guarded_statement(property, destination, "params.update(" + destination + ")") }} + {% endif %} + +{% endfor %} + +params = {k: v for k, v in params.items() if v is not UNSET and v is not None} +{% endif %} +{% endmacro %} + +{% macro body_to_kwarg(body) %} +{% if body.body_type == "data" %} +_kwargs["data"] = body.to_dict() +{% elif body.body_type == "files"%} +{{ multipart_body(body) }} +{% elif body.body_type == "json" %} +{{ json_body(body) }} +{% elif body.body_type == "content" %} +_kwargs["content"] = body.payload +{% endif %} +{% endmacro %} + +{% macro json_body(body) %} +{% set property = body.prop %} +{% import "property_templates/" + property.template as prop_template %} +{% if prop_template.transform %} +{{ prop_template.transform(property, property.python_name, "_kwargs[\"json\"]") }} +{% else %} +_kwargs["json"] = {{ property.python_name }} +{% endif %} +{% endmacro %} + +{% macro multipart_body(body) %} +{% set property = body.prop %} +{% import "property_templates/" + property.template as prop_template %} +{% if prop_template.transform_multipart_body %} +{{ prop_template.transform_multipart_body(property) }} +{% endif %} +{% endmacro %} + +{# The all the kwargs passed into an endpoint (and variants thereof)) #} +{% macro arguments(endpoint, include_client=True) %} +{# path parameters #} +{% for parameter in endpoint.path_parameters %} +{{ parameter.to_string() }}, +{% endfor %} +{% if include_client or ((endpoint.list_all_parameters() | length) > (endpoint.path_parameters | length)) %} +*, +{% endif %} +{# Proper client based on whether or not the endpoint requires authentication #} +{% if include_client %} +{% if endpoint.requires_security %} +client: AuthenticatedClient, +{% else %} +client: Union[AuthenticatedClient, Client], +{% endif %} +{% endif %} +{# Any allowed bodies #} +{% if endpoint.bodies | length == 1 %} +body: {{ endpoint.bodies[0].prop.get_type_string() }}, +{% elif endpoint.bodies | length > 1 %} +body: Union[ + {% for body in endpoint.bodies %} + {{ body.prop.get_type_string() }}, + {% endfor %} +], +{% endif %} +{# query parameters #} +{% for parameter in endpoint.query_parameters %} +{{ parameter.to_string() }}, +{% endfor %} +{% for parameter in endpoint.header_parameters %} +{{ parameter.to_string() }}, +{% endfor %} +{# cookie parameters #} +{% for parameter in endpoint.cookie_parameters %} +{{ parameter.to_string() }}, +{% endfor %} +{% endmacro %} + +{# Just lists all kwargs to endpoints as name=name for passing to other functions #} +{% macro kwargs(endpoint, include_client=True) %} +{% for parameter in endpoint.path_parameters %} +{{ parameter.python_name }}={{ parameter.python_name }}, +{% endfor %} +{% if include_client %} +client=client, +{% endif %} +{% if endpoint.bodies | length > 0 %} +body=body, +{% endif %} +{% for parameter in endpoint.query_parameters %} +{{ parameter.python_name }}={{ parameter.python_name }}, +{% endfor %} +{% for parameter in endpoint.header_parameters %} +{{ parameter.python_name }}={{ parameter.python_name }}, +{% endfor %} +{% for parameter in endpoint.cookie_parameters %} +{{ parameter.python_name }}={{ parameter.python_name }}, +{% endfor %} +{% endmacro %} + +{% macro docstring_content(endpoint, return_string, is_detailed) %} +{% if endpoint.summary %}{{ endpoint.summary | wordwrap(100)}} + +{% endif -%} +{%- if endpoint.description %} {{ endpoint.description | wordwrap(100) }} + +{% endif %} +{% if not endpoint.summary and not endpoint.description %} +{# Leave extra space so that Args or Returns isn't at the top #} + +{% endif %} +{% set all_parameters = endpoint.list_all_parameters() %} +{% if all_parameters %} +Args: + {% for parameter in all_parameters %} + {{ parameter.to_docstring() | wordwrap(90) | indent(8) }} + {% endfor %} + +{% endif %} +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: +{% if is_detailed %} + Response[{{ return_string }}] +{% else %} + {{ return_string }} +{% endif %} +{% endmacro %} + +{% macro docstring(endpoint, return_string, is_detailed) %} +{{ safe_docstring(docstring_content(endpoint, return_string, is_detailed)) }} +{% endmacro %} + +{% macro parse_response(parsed_responses, response) %} +{% if parsed_responses %}{% import "property_templates/" + response.prop.template as prop_template %} +{% if prop_template.construct %} +{{ prop_template.construct(response.prop, response.source.attribute) }} +{% elif response.source.return_type == response.prop.get_type_string() %} +{{ response.prop.python_name }} = {{ response.source.attribute }} +{% else %} +{{ response.prop.python_name }} = cast({{ response.prop.get_type_string() }}, {{ response.source.attribute }}) +{% endif %} +return {{ response.prop.python_name }} +{% else %} +return None +{% endif %} +{% endmacro %} diff --git a/templates/endpoint_module.py.jinja b/templates/endpoint_module.py.jinja new file mode 100644 index 0000000..a7b82df --- /dev/null +++ b/templates/endpoint_module.py.jinja @@ -0,0 +1,153 @@ +from http import HTTPStatus +from typing import Any, Optional, Union, cast + +import httpx + +from ...client import AuthenticatedClient, Client +from ...types import Response, UNSET +from ... import errors + +{% for relative in endpoint.relative_imports | sort %} +{{ relative }} +{% endfor %} + +{% from "endpoint_macros.py.jinja" import header_params, cookie_params, query_params, + arguments, client, kwargs, parse_response, docstring, body_to_kwarg %} + +{% set return_string = endpoint.response_type() %} +{% set parsed_responses = (endpoint.responses | length > 0) and return_string != "Any" %} + +def _get_kwargs( + {{ arguments(endpoint, include_client=False) | indent(4) }} +) -> dict[str, Any]: + {{ header_params(endpoint) | indent(4) }} + + {{ cookie_params(endpoint) | indent(4) }} + + {{ query_params(endpoint) | indent(4) }} + + _kwargs: dict[str, Any] = { + "method": "{{ endpoint.method }}", + {% if endpoint.path_parameters %} + "url": "{{ endpoint.path }}".format( + {%- for parameter in endpoint.path_parameters -%} + {{parameter.python_name}}={{parameter.python_name}}, + {%- endfor -%} + ), + {% else %} + "url": "{{ endpoint.path }}", + {% endif %} + {% if endpoint.query_parameters %} + "params": params, + {% endif %} + {% if endpoint.cookie_parameters %} + "cookies": cookies, + {% endif %} + } + +{% if endpoint.bodies | length > 1 %} +{% for body in endpoint.bodies %} + if isinstance(body, {{body.prop.get_type_string() }}): + {{ body_to_kwarg(body) | indent(8) }} + headers["Content-Type"] = "{{ body.content_type }}" +{% endfor %} +{% elif endpoint.bodies | length == 1 %} +{% set body = endpoint.bodies[0] %} + {{ body_to_kwarg(body) | indent(4) }} + {% if body.content_type != "multipart/form-data" %}{# Need httpx to set the boundary automatically #} + headers["Content-Type"] = "{{ body.content_type }}" + {% endif %} +{% endif %} + +{% if endpoint.header_parameters or endpoint.bodies | length > 0 %} + _kwargs["headers"] = headers +{% endif %} + return _kwargs + +{% if endpoint.responses.default %} + {% set return_type = return_string %} +{% else %} + {% set return_type = "Optional[" + return_string + "]" %} +{% endif %} + + +def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> {{return_type}}: + {% for response in endpoint.responses.patterns %} + {% set code_range = response.status_code.range %} + {% if code_range[0] == code_range[1] %} + if response.status_code == {{ code_range[0] }}: + {% else %} + if {{ code_range[0] }} <= response.status_code <= {{ code_range[1] }}: + {% endif %} + {{ parse_response(parsed_responses, response) | indent(8) }} + {% endfor %} + {% if endpoint.responses.default %} + {{ parse_response(parsed_responses, endpoint.responses.default) | indent(4) }} + {% else %} + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + {% endif %} + + +def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[{{ return_string }}]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + {{ arguments(endpoint) | indent(4) }} +) -> Response[{{ return_string }}]: + {{ docstring(endpoint, return_string, is_detailed=true) | indent(4) }} + + kwargs = _get_kwargs( + {{ kwargs(endpoint, include_client=False) }} + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + +{% if parsed_responses %} +def sync( + {{ arguments(endpoint) | indent(4) }} +) -> Optional[{{ return_string }}]: + {{ docstring(endpoint, return_string, is_detailed=false) | indent(4) }} + + return sync_detailed( + {{ kwargs(endpoint) }} + ).parsed +{% endif %} + +async def asyncio_detailed( + {{ arguments(endpoint) | indent(4) }} +) -> Response[{{ return_string }}]: + {{ docstring(endpoint, return_string, is_detailed=true) | indent(4) }} + + kwargs = _get_kwargs( + {{ kwargs(endpoint, include_client=False) }} + ) + + response = await client.get_async_httpx_client().request( + **kwargs + ) + + return _build_response(client=client, response=response) + +{% if parsed_responses %} +async def asyncio( + {{ arguments(endpoint) | indent(4) }} +) -> Optional[{{ return_string }}]: + {{ docstring(endpoint, return_string, is_detailed=false) | indent(4) }} + + return (await asyncio_detailed( + {{ kwargs(endpoint) }} + )).parsed +{% endif %} diff --git a/templates/errors.py.jinja b/templates/errors.py.jinja new file mode 100644 index 0000000..b912123 --- /dev/null +++ b/templates/errors.py.jinja @@ -0,0 +1,14 @@ +""" 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/templates/helpers.jinja b/templates/helpers.jinja new file mode 100644 index 0000000..fd5c3ec --- /dev/null +++ b/templates/helpers.jinja @@ -0,0 +1,10 @@ +{% macro safe_docstring(content, omit_if_empty=False) %} +{# This macro returns the provided content as a docstring, set to a raw string if it contains a backslash #} +{% if (not omit_if_empty) or (content | trim) %} +{% if '\\' in content -%} +r""" {{ content }} """ +{%- else -%} +""" {{ content }} """ +{%- endif -%} +{% endif %} +{% endmacro %} \ No newline at end of file diff --git a/templates/int_enum.py.jinja b/templates/int_enum.py.jinja new file mode 100644 index 0000000..a508f1c --- /dev/null +++ b/templates/int_enum.py.jinja @@ -0,0 +1,9 @@ +from enum import IntEnum + +class {{ enum.class_info.name }}(IntEnum): + {% for key, value in enum.values.items() %} + {{ key }} = {{ value }} + {% endfor %} + + def __str__(self) -> str: + return str(self.value) diff --git a/templates/literal_enum.py.jinja b/templates/literal_enum.py.jinja new file mode 100644 index 0000000..72207ef --- /dev/null +++ b/templates/literal_enum.py.jinja @@ -0,0 +1,10 @@ +from typing import Literal, cast + +{{ enum.class_info.name }} = Literal{{ "%r" | format(enum.values|list|sort) }} + +{{ enum.get_class_name_snake_case() | upper }}_VALUES: set[{{ enum.class_info.name }}] = { {% for v in enum.values|list|sort %}{{"%r"|format(v)}}, {% endfor %} } + +def check_{{ enum.get_class_name_snake_case() }}(value: {{ enum.get_instance_type_string() }}) -> {{ enum.class_info.name}}: + if value in {{ enum.get_class_name_snake_case() | upper }}_VALUES: + return cast({{enum.class_info.name}}, value) + raise TypeError(f"Unexpected value {value!r}. Expected one of {{"{"}}{{ enum.get_class_name_snake_case() | upper }}_VALUES!r}") diff --git a/templates/model.py.jinja b/templates/model.py.jinja new file mode 100644 index 0000000..84185ef --- /dev/null +++ b/templates/model.py.jinja @@ -0,0 +1,238 @@ +from collections.abc import Mapping +from typing import Any, TypeVar, Optional, BinaryIO, TextIO, TYPE_CHECKING, Generator + +from attrs import define as _attrs_define +from attrs import field as _attrs_field +{% if model.is_multipart_body %} +import json +from .. import types +{% endif %} + +from ..types import UNSET, Unset + +{% for relative in model.relative_imports | sort %} +{{ relative }} +{% endfor %} + +{% for lazy_import in model.lazy_imports %} +{% if loop.first %} +if TYPE_CHECKING: +{% endif %} + {{ lazy_import }} +{% endfor %} + + +{% if model.additional_properties %} +{% 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 %} +{% set module_name = model.class_info.module_name %} + +{% from "helpers.jinja" import safe_docstring %} + +T = TypeVar("T", bound="{{ class_name }}") + +{% macro class_docstring_content(model) %} + {% if model.title %}{{ model.title | wordwrap(116) }} + + {% endif -%} + {%- if model.description %}{{ model.description | wordwrap(116) }} + + {% endif %} + {% if not model.title and not model.description %} + {# Leave extra space so that a section doesn't start on the first line #} + + {% endif %} + {% if model.example %} + Example: + {{ model.example | string | wordwrap(112) | indent(12) }} + + {% endif %} + {% if (not config.docstrings_on_attributes) and (model.required_properties or model.optional_properties) %} + Attributes: + {% for property in model.required_properties + model.optional_properties %} + {{ property.to_docstring() | wordwrap(112) | indent(12) }} + {% endfor %}{% endif %} +{% endmacro %} + +{% macro declare_property(property) %} +{%- if config.docstrings_on_attributes and property.description -%} +{{ property.to_string() }} +{{ safe_docstring(property.description, omit_if_empty=True) | wordwrap(112) }} +{%- else -%} +{{ property.to_string() }} +{%- endif -%} +{% endmacro %} + +@_attrs_define +class {{ class_name }}: + {{ safe_docstring(class_docstring_content(model), omit_if_empty=config.docstrings_on_attributes) | indent(4) }} + + {% for property in model.required_properties + model.optional_properties %} + {% if property.default is none and property.required %} + {{ declare_property(property) | indent(4) }} + {% endif %} + {% endfor %} + {% for property in model.required_properties + model.optional_properties %} + {% if property.default is not none or not property.required %} + {{ declare_property(property) | indent(4) }} + {% endif %} + {% endfor %} + {% if model.additional_properties %} + additional_properties: dict[str, {{ additional_property_type }}] = _attrs_field(init=False, factory=dict) + {% endif %} + +{% macro _transform_property(property, content) %} +{% import "property_templates/" + property.template as prop_template %} +{%- if prop_template.transform -%} +{{ prop_template.transform(property=property, source=content, destination=property.python_name) }} +{%- else -%} +{{ property.python_name }} = {{ content }} +{%- endif -%} +{% endmacro %} + +{% macro multipart(property, source, destination) %} +{% import "property_templates/" + property.template as prop_template %} +{% if not property.required %} +if not isinstance({{source}}, Unset): + {{ prop_template.multipart(property, source, destination) | indent(4) }} +{% else %} +{{ prop_template.multipart(property, source, destination) }} +{% endif %} +{% endmacro %} + +{% macro _prepare_field_dict() %} +field_dict: dict[str, Any] = {} +{% if model.additional_properties %} +{% import "property_templates/" + model.additional_properties.template as prop_template %} +{% if prop_template.transform %} +for prop_name, prop in self.additional_properties.items(): + {{ prop_template.transform(model.additional_properties, "prop", "field_dict[prop_name]", declare_type=false) | indent(4) }} +{% else %} +field_dict.update(self.additional_properties) +{%- endif -%} +{%- endif -%} +{% endmacro %} + +{% macro _to_dict() %} +{% for property in model.required_properties + model.optional_properties -%} +{{ _transform_property(property, "self." + property.python_name) }} + +{% endfor %} + +{{ _prepare_field_dict() }} +{% if model.required_properties | length > 0 or model.optional_properties | length > 0 %} +field_dict.update({ + {% for property in model.required_properties + model.optional_properties %} + {% if property.required %} + "{{ property.name }}": {{ property.python_name }}, + {% endif %} + {% endfor %} +}) +{% endif %} +{% for property in model.optional_properties %} +{% if not property.required %} +if {{ property.python_name }} is not UNSET: + field_dict["{{ property.name }}"] = {{ property.python_name }} +{% endif %} +{% endfor %} + +return field_dict +{% endmacro %} + + def to_dict(self) -> dict[str, Any]: + {% for lazy_import in model.lazy_imports %} + {{ lazy_import }} + {% endfor %} + {{ _to_dict() | indent(8) }} + +{% if model.is_multipart_body %} + def to_multipart(self) -> types.RequestFiles: + files: types.RequestFiles = [] + + {% for property in model.required_properties + model.optional_properties %} + {% set destination = "\"" + property.name + "\"" %} + {{ multipart(property, "self." + property.python_name, destination) | indent(8) }} + + {% endfor %} + + {% if model.additional_properties %} + for prop_name, prop in self.additional_properties.items(): + {{ multipart(model.additional_properties, "prop", "prop_name") | indent(4) }} + {% endif %} + + return files + +{% endif %} + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + {% for lazy_import in model.lazy_imports %} + {{ lazy_import }} + {% endfor %} +{% if (model.required_properties or model.optional_properties or model.additional_properties) %} + d = dict(src_dict) +{% for property in model.required_properties + model.optional_properties %} + {% if property.required %} + {% set property_source = 'd.pop("' + property.name + '")' %} + {% else %} + {% set property_source = 'd.pop("' + property.name + '", UNSET)' %} + {% endif %} + {% import "property_templates/" + property.template as prop_template %} + {% if prop_template.construct %} + {{ prop_template.construct(property, property_source) | indent(8) }} + {% else %} + {{ property.python_name }} = {{ property_source }} + {% endif %} + +{% endfor %} +{% endif %} + {{ module_name }} = cls( +{% for property in model.required_properties + model.optional_properties %} + {{ property.python_name }}={{ property.python_name }}, +{% endfor %} + ) + +{% if model.additional_properties %} + {% if model.additional_properties.template %}{# Can be a bool instead of an object #} + {% import "property_templates/" + model.additional_properties.template as prop_template %} + +{% if model.additional_properties.lazy_imports %} + {% for lazy_import in model.additional_properties.lazy_imports %} + {{ lazy_import }} + {% endfor %} +{% endif %} + {% else %} + {% set prop_template = None %} + {% endif %} + {% if prop_template and prop_template.construct %} + additional_properties = {} + for prop_name, prop_dict in d.items(): + {{ prop_template.construct(model.additional_properties, "prop_dict") | indent(12) }} + additional_properties[prop_name] = {{ model.additional_properties.python_name }} + + {{ module_name }}.additional_properties = additional_properties + {% else %} + {{ module_name }}.additional_properties = d + {% endif %} +{% endif %} + return {{ module_name }} + + {% if model.additional_properties %} + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> {{ additional_property_type }}: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: {{ additional_property_type }}) -> 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 + {% endif %} diff --git a/templates/models_init.py.jinja b/templates/models_init.py.jinja new file mode 100644 index 0000000..7379e86 --- /dev/null +++ b/templates/models_init.py.jinja @@ -0,0 +1,13 @@ +""" Contains all the data models used in inputs/outputs """ + +{% for import in imports | sort %} +{{ import }} +{% endfor %} + +{% if imports %} +__all__ = ( + {% for all in alls | sort %} + "{{ all }}", + {% endfor %} +) +{% endif %} diff --git a/templates/package_init.py.jinja b/templates/package_init.py.jinja new file mode 100644 index 0000000..ecf60e7 --- /dev/null +++ b/templates/package_init.py.jinja @@ -0,0 +1,9 @@ +{% from "helpers.jinja" import safe_docstring %} + +{{ safe_docstring(package_description) }} +from .client import AuthenticatedClient, Client + +__all__ = ( + "AuthenticatedClient", + "Client", +) diff --git a/templates/property_templates/any_property.py.jinja b/templates/property_templates/any_property.py.jinja new file mode 100644 index 0000000..ad3f195 --- /dev/null +++ b/templates/property_templates/any_property.py.jinja @@ -0,0 +1,3 @@ +{% macro multipart(property, source, name) %} +files.append(({{ name }}, (None, str({{source}}).encode(), "text/plain"))) +{% endmacro %} \ No newline at end of file diff --git a/templates/property_templates/boolean_property.py.jinja b/templates/property_templates/boolean_property.py.jinja new file mode 100644 index 0000000..e2c3392 --- /dev/null +++ b/templates/property_templates/boolean_property.py.jinja @@ -0,0 +1,7 @@ +{% macro transform_header(source) %} +"true" if {{ source }} else "false" +{% endmacro %} + +{% macro multipart(property, source, name) %} +files.append(({{ name }}, (None, str({{source}}).encode(), "text/plain"))) +{% endmacro %} diff --git a/templates/property_templates/const_property.py.jinja b/templates/property_templates/const_property.py.jinja new file mode 100644 index 0000000..d348de0 --- /dev/null +++ b/templates/property_templates/const_property.py.jinja @@ -0,0 +1,9 @@ +{% macro construct(property, source) %} +{{ property.python_name }} = cast({{ property.get_type_string() }} , {{ source }}) +if {{ property.python_name }} != {{ property.value.python_code }}{% if not property.required %}and not isinstance({{ property.python_name }}, Unset){% endif %}: + raise ValueError(f"{{ property.name }} must match const {{ property.value.python_code }}, got '{{'{' + property.python_name + '}' }}'") +{%- endmacro %} + +{% macro multipart(property, source, name) %} +files.append(({{ name }}, (None, {{ source }}, "text/plain"))) +{% endmacro %} diff --git a/templates/property_templates/date_property.py.jinja b/templates/property_templates/date_property.py.jinja new file mode 100644 index 0000000..3ca8fae --- /dev/null +++ b/templates/property_templates/date_property.py.jinja @@ -0,0 +1,31 @@ +{% macro construct_function(property, source) %} +isoparse({{ source }}).date() +{% endmacro %} + +{% from "property_templates/property_macros.py.jinja" import construct_template %} + +{% macro construct(property, source) %} +{{ construct_template(construct_function, property, source) }} +{% endmacro %} + +{% macro check_type_for_construct(property, source) %}isinstance({{ source }}, str){% endmacro %} + +{% macro transform(property, source, destination, declare_type=True) %} +{% set transformed = source + ".isoformat()" %} +{% if property.required %} +{{ destination }} = {{ transformed }} +{%- else %} +{% if declare_type %} +{% set type_annotation = property.get_type_string(json=True) %} +{{ destination }}: {{ type_annotation }} = UNSET +{% else %} +{{ destination }} = UNSET +{% endif %} +if not isinstance({{ source }}, Unset): + {{ destination }} = {{ transformed }} +{%- endif %} +{% endmacro %} + +{% macro multipart(property, source, name) %} +files.append(({{ name }}, (None, {{ source }}.isoformat().encode(), "text/plain"))) +{% endmacro %} diff --git a/templates/property_templates/datetime_property.py.jinja b/templates/property_templates/datetime_property.py.jinja new file mode 100644 index 0000000..bf7e601 --- /dev/null +++ b/templates/property_templates/datetime_property.py.jinja @@ -0,0 +1,31 @@ +{% macro construct_function(property, source) %} +isoparse({{ source }}) +{% endmacro %} + +{% from "property_templates/property_macros.py.jinja" import construct_template %} + +{% macro construct(property, source) %} +{{ construct_template(construct_function, property, source) }} +{% endmacro %} + +{% macro check_type_for_construct(property, source) %}isinstance({{ source }}, str){% endmacro %} + +{% macro transform(property, source, destination, declare_type=True) %} +{% set transformed = source + ".isoformat()" %} +{% if property.required %} +{{ destination }} = {{ transformed }} +{%- else %} +{% if declare_type %} +{% set type_annotation = property.get_type_string(json=True) %} +{{ destination }}: {{ type_annotation }} = UNSET +{% else %} +{{ destination }} = UNSET +{% endif %} +if not isinstance({{ source }}, Unset): + {{ destination }} = {{ transformed }} +{%- endif %} +{% endmacro %} + +{% macro multipart(property, source, name) %} +files.append(({{ name }}, (None, {{ source }}.isoformat().encode(), "text/plain"))) +{% endmacro %} diff --git a/templates/property_templates/enum_property.py.jinja b/templates/property_templates/enum_property.py.jinja new file mode 100644 index 0000000..af8ca6e --- /dev/null +++ b/templates/property_templates/enum_property.py.jinja @@ -0,0 +1,31 @@ +{% macro construct_function(property, source) %} +{{ property.class_info.name }}({{ source }}) +{% endmacro %} + +{% from "property_templates/property_macros.py.jinja" import construct_template %} + +{% macro construct(property, source) %} +{{ construct_template(construct_function, property, source) }} +{% endmacro %} + +{% macro check_type_for_construct(property, source) %}isinstance({{ source }}, {{ property.value_type.__name__ }}){% endmacro %} + +{% macro transform(property, source, destination, declare_type=True) %} +{% set transformed = source + ".value" %} +{% set type_string = property.get_type_string(json=True) %} +{% if property.required %} +{{ destination }} = {{ transformed }} +{%- else %} +{{ destination }}{% if declare_type %}: {{ type_string }}{% endif %} = UNSET +if not isinstance({{ source }}, Unset): + {{ destination }} = {{ transformed }} +{% endif %} +{% endmacro %} + +{% macro multipart(property, source, name) %} +files.append(({{ name }}, (None, str({{ source }}.value).encode(), "text/plain"))) +{% endmacro %} + +{% macro transform_header(source) %} +str({{ source }}) +{% endmacro %} diff --git a/templates/property_templates/file_property.py.jinja b/templates/property_templates/file_property.py.jinja new file mode 100644 index 0000000..b08a13b --- /dev/null +++ b/templates/property_templates/file_property.py.jinja @@ -0,0 +1,27 @@ +{% macro construct_function(property, source) %} +File( + payload = BytesIO({{ source }}) +) +{% endmacro %} + +{% from "property_templates/property_macros.py.jinja" import construct_template %} + +{% macro construct(property, source) %} +{{ construct_template(construct_function, property, source) }} +{% endmacro %} + +{% macro check_type_for_construct(property, source) %}isinstance({{ source }}, bytes){% endmacro %} + +{% macro transform(property, source, destination, declare_type=True) %} +{% if property.required %} +{{ destination }} = {{ source }}.to_tuple() +{% else %} +{{ destination }}{% if declare_type %}: {{ property.get_type_string(json=True) }}{% endif %} = UNSET +if not isinstance({{ source }}, Unset): + {{ destination }} = {{ source }}.to_tuple() +{% endif %} +{% endmacro %} + +{% macro multipart(property, source, name) %} +files.append(({{ name }}, {{ source }}.to_tuple())) +{% endmacro %} diff --git a/templates/property_templates/float_property.py.jinja b/templates/property_templates/float_property.py.jinja new file mode 100644 index 0000000..dc982cb --- /dev/null +++ b/templates/property_templates/float_property.py.jinja @@ -0,0 +1,7 @@ +{% macro transform_header(source) %} +str({{ source }}) +{% endmacro %} + +{% macro multipart(property, source, name) %} +files.append(({{ name }}, (None, str({{source}}).encode(), "text/plain"))) +{% endmacro %} diff --git a/templates/property_templates/helpers.jinja b/templates/property_templates/helpers.jinja new file mode 100644 index 0000000..3f238f6 --- /dev/null +++ b/templates/property_templates/helpers.jinja @@ -0,0 +1,10 @@ +{% macro guarded_statement(property, source, statement) %} +{# If the property can be UNSET or None, this macro returns the provided statement guarded by an if which will check + for those invalid values. Otherwise, it returns the statement unmodified. #} +{% if property.required %} +{{ statement }} +{% else %} +if not isinstance({{ source }}, Unset): + {{ statement }} +{% endif %} +{% endmacro %} diff --git a/templates/property_templates/int_property.py.jinja b/templates/property_templates/int_property.py.jinja new file mode 100644 index 0000000..dc982cb --- /dev/null +++ b/templates/property_templates/int_property.py.jinja @@ -0,0 +1,7 @@ +{% macro transform_header(source) %} +str({{ source }}) +{% endmacro %} + +{% macro multipart(property, source, name) %} +files.append(({{ name }}, (None, str({{source}}).encode(), "text/plain"))) +{% endmacro %} diff --git a/templates/property_templates/list_property.py.jinja b/templates/property_templates/list_property.py.jinja new file mode 100644 index 0000000..785d0b6 --- /dev/null +++ b/templates/property_templates/list_property.py.jinja @@ -0,0 +1,54 @@ +{% macro construct(property, source) %} +{% set inner_property = property.inner_property %} +{% import "property_templates/" + inner_property.template as inner_template %} +{% if inner_template.construct %} +{% set inner_source = inner_property.python_name + "_data" %} +{{ property.python_name }} = [] +_{{ property.python_name }} = {{ source }} +{% if property.required %} +for {{ inner_source }} in (_{{ property.python_name }}): +{% else %} +for {{ inner_source }} in (_{{ property.python_name }} or []): +{% endif %} + {{ inner_template.construct(inner_property, inner_source) | indent(4) }} + {{ property.python_name }}.append({{ inner_property.python_name }}) +{% else %} +{{ property.python_name }} = cast({{ property.get_type_string(no_optional=True) }}, {{ source }}) +{% endif %} +{% endmacro %} + +{% macro _transform(property, source, destination, transform_method) %} +{% set inner_property = property.inner_property %} +{% import "property_templates/" + inner_property.template as inner_template %} +{% if inner_template.transform %} +{% set inner_source = inner_property.python_name + "_data" %} +{{ destination }} = [] +for {{ inner_source }} in {{ source }}: + {{ inner_template.transform(inner_property, inner_source, inner_property.python_name, transform_method) | indent(4) }} + {{ destination }}.append({{ inner_property.python_name }}) +{% else %} +{{ destination }} = {{ source }} +{% endif %} +{% endmacro %} + +{% macro check_type_for_construct(property, source) %}isinstance({{ source }}, list){% endmacro %} + +{% macro transform(property, source, destination, declare_type=True) %} +{% set inner_property = property.inner_property %} +{% set type_string = property.get_type_string(json=True) %} +{% if property.required %} +{{ _transform(property, source, destination, "to_dict") }} +{% else %} +{{ destination }}{% if declare_type %}: {{ type_string }}{% endif %} = UNSET +if not isinstance({{ source }}, Unset): + {{ _transform(property, source, destination, "to_dict") | indent(4)}} +{% endif %} +{% endmacro %} + +{% macro multipart(property, source, destination) %} +{% set inner_property = property.inner_property %} +{% import "property_templates/" + inner_property.template as inner_template %} +{% set inner_source = inner_property.python_name + "_element" %} +for {{ inner_source }} in {{ source }}: + {{ inner_template.multipart(inner_property, inner_source, destination) | indent(4) }} +{% endmacro %} diff --git a/templates/property_templates/literal_enum_property.py.jinja b/templates/property_templates/literal_enum_property.py.jinja new file mode 100644 index 0000000..2cc4558 --- /dev/null +++ b/templates/property_templates/literal_enum_property.py.jinja @@ -0,0 +1,30 @@ +{% macro construct_function(property, source) %} +check_{{ property.get_class_name_snake_case() }}({{ source }}) +{% endmacro %} + +{% from "property_templates/property_macros.py.jinja" import construct_template %} + +{% macro construct(property, source) %} +{{ construct_template(construct_function, property, source) }} +{% endmacro %} + +{% macro check_type_for_construct(property, source) %}isinstance({{ source }}, {{ property.get_instance_type_string() }}){% endmacro %} + +{% macro transform(property, source, destination, declare_type=True) %} +{% set type_string = property.get_type_string(json=True) %} +{% if property.required %} +{{ destination }}{% if declare_type %}: {{ type_string }}{% endif %} = {{ source }} +{%- else %} +{{ destination }}{% if declare_type %}: {{ type_string }}{% endif %} = UNSET +if not isinstance({{ source }}, Unset): + {{ destination }} = {{ source }} +{% endif %} +{% endmacro %} + +{% macro multipart(property, source, name) %} +files.append(({{ name }}, (None, str({{ source }}).encode(), "text/plain"))) +{% endmacro %} + +{% macro transform_header(source) %} +str({{ source }}) +{% endmacro %} diff --git a/templates/property_templates/model_property.py.jinja b/templates/property_templates/model_property.py.jinja new file mode 100644 index 0000000..d1a4b5d --- /dev/null +++ b/templates/property_templates/model_property.py.jinja @@ -0,0 +1,37 @@ +{% macro construct_function(property, source) %} +{{ property.class_info.name }}.from_dict({{ source }}) +{% endmacro %} + +{% from "property_templates/property_macros.py.jinja" import construct_template %} + +{% macro construct(property, source) %} +{{ construct_template(construct_function, property, source) }} +{% endmacro %} + +{% macro check_type_for_construct(property, source) %}isinstance({{ source }}, dict){% endmacro %} + +{% macro transform(property, source, destination, declare_type=True) %} +{% set transformed = source + ".to_dict()" %} +{% set type_string = property.get_type_string(json=True) %} +{% if property.required %} +{{ destination }} = {{ transformed }} +{%- else %} +{{ destination }}{% if declare_type %}: {{ type_string }}{% endif %} = UNSET +if not isinstance({{ source }}, Unset): + {{ destination }} = {{ transformed }} +{%- endif %} +{% endmacro %} + +{% macro transform_multipart_body(property) %} +{% set transformed = property.python_name + ".to_multipart()" %} +{% if property.required %} +_kwargs["files"] = {{ transformed }} +{%- else %} +if not isinstance({{ property.python_name }}, Unset): + _kwargs["files"] = {{ transformed }} +{%- endif %} +{% endmacro %} + +{% macro multipart(property, source, name) %} +files.append(({{ name }}, (None, json.dumps( {{source}}.to_dict()).encode(), "application/json"))) +{% endmacro %} diff --git a/templates/property_templates/property_macros.py.jinja b/templates/property_templates/property_macros.py.jinja new file mode 100644 index 0000000..52e1d41 --- /dev/null +++ b/templates/property_templates/property_macros.py.jinja @@ -0,0 +1,14 @@ +{% macro construct_template(construct_function, property, source) %} +{% if property.required %} +{{ property.python_name }} = {{ construct_function(property, source) }} +{% else %}{# Must be non-required #} +_{{ property.python_name }} = {{ source }} +{{ property.python_name }}: {{ property.get_type_string() }} + {% if not property.required %} +if isinstance(_{{ property.python_name }}, Unset): + {{ property.python_name }} = UNSET + {% endif %} +else: + {{ property.python_name }} = {{ construct_function(property, "_" + property.python_name) }} +{% endif %} +{% endmacro %} diff --git a/templates/property_templates/union_property.py.jinja b/templates/property_templates/union_property.py.jinja new file mode 100644 index 0000000..09b6e6e --- /dev/null +++ b/templates/property_templates/union_property.py.jinja @@ -0,0 +1,102 @@ +{% macro construct(property, source) %} +def _parse_{{ property.python_name }}(data: object) -> {{ property.get_type_string() }}: + {% if "None" in property.get_type_strings_in_union(json=True) %} + if data is None: + return data + {% endif %} + {% if "Unset" in property.get_type_strings_in_union(json=True) %} + if isinstance(data, Unset): + return data + {% endif %} + {% set ns = namespace(contains_unmodified_properties = false) %} + {% for inner_property in property.inner_properties %} + {% import "property_templates/" + inner_property.template as inner_template %} + {% if not inner_template.construct %} + {% set ns.contains_unmodified_properties = true %} + {% continue %} + {% endif %} + {% if inner_template.check_type_for_construct and (not loop.last or ns.contains_unmodified_properties) %} + try: + if not {{ inner_template.check_type_for_construct(inner_property, "data") }}: + raise TypeError() + {{ inner_template.construct(inner_property, "data") | indent(8) }} + return {{ inner_property.python_name }} + except: # noqa: E722 + pass + {% else %}{# Don't do try/except for the last one nor any properties with no type checking #} + {% if inner_template.check_type_for_construct %} + if not {{ inner_template.check_type_for_construct(inner_property, "data") }}: + raise TypeError() + {% endif %} + {{ inner_template.construct(inner_property, "data") | indent(4) }} + return {{ inner_property.python_name }} + {% endif %} + {% endfor %} + {% if ns.contains_unmodified_properties %} + return cast({{ property.get_type_string() }}, data) + {% endif %} + +{{ property.python_name }} = _parse_{{ property.python_name }}({{ source }}) +{% endmacro %} + +{% macro transform(property, source, destination, declare_type=True) %} +{% set ns = namespace(contains_properties_without_transform = false, contains_modified_properties = not property.required, has_if = false) %} +{% if declare_type %}{{ destination }}: {{ property.get_type_string(json=True) }}{% endif %} + +{% if not property.required %} +if isinstance({{ source }}, Unset): + {{ destination }} = UNSET + {% set ns.has_if = true %} +{% endif %} +{% for inner_property in property.inner_properties %} + {% import "property_templates/" + inner_property.template as inner_template %} + {% if not inner_template.transform %} + {% set ns.contains_properties_without_transform = true %} + {% continue %} + {% else %} + {% set ns.contains_modified_properties = true %} + {% endif %} + {% if not ns.has_if %} +if isinstance({{ source }}, {{ inner_property.get_instance_type_string() }}): + {% set ns.has_if = true %} + {% elif not loop.last or ns.contains_properties_without_transform %} +elif isinstance({{ source }}, {{ inner_property.get_instance_type_string() }}): + {% else %} +else: + {% endif %} + {{ inner_template.transform(inner_property, source, destination, declare_type=False) | indent(4) }} +{% endfor %} +{% if ns.contains_properties_without_transform and ns.contains_modified_properties %} +else: + {{ destination }} = {{ source }} +{%- elif ns.contains_properties_without_transform %} +{{ destination }} = {{ source }} +{%- endif %} +{% endmacro %} + + +{% macro instance_check(inner_property, source) %} +{% if inner_property.get_instance_type_string() == "None" %} +if {{ source }} is None: +{% else %} +if isinstance({{ source }}, {{ inner_property.get_instance_type_string() }}): +{% endif %} +{% endmacro %} + +{% macro multipart(property, source, destination) %} +{% set ns = namespace(has_if = false) %} +{% for inner_property in property.inner_properties %} +{% if not ns.has_if %} +{{ instance_check(inner_property, source) }} +{% set ns.has_if = true %} +{% elif not loop.last %} + +el{{ instance_check(inner_property, source) }} +{% else %} + +else: +{% endif %} +{% import "property_templates/" + inner_property.template as inner_template %} + {{ inner_template.multipart(inner_property, source, destination) | indent(4) | trim }} +{%- endfor -%} +{% endmacro %} diff --git a/templates/property_templates/uuid_property.py.jinja b/templates/property_templates/uuid_property.py.jinja new file mode 100644 index 0000000..3a6ce46 --- /dev/null +++ b/templates/property_templates/uuid_property.py.jinja @@ -0,0 +1,31 @@ +{% macro construct_function(property, source) %} +UUID({{ source }}) +{% endmacro %} + +{% from "property_templates/property_macros.py.jinja" import construct_template %} + +{% macro construct(property, source) %} +{{ construct_template(construct_function, property, source) }} +{% endmacro %} + +{% macro check_type_for_construct(property, source) %}isinstance({{ source }}, str){% endmacro %} + +{% macro transform(property, source, destination, declare_type=True) %} +{% set transformed = "str(" + source + ")" %} +{% if property.required %} +{{ destination }} = {{ transformed }} +{%- else %} +{% if declare_type %} +{% set type_annotation = property.get_type_string(json=True) %} +{{ destination }}: {{ type_annotation }} = UNSET +{% else %} +{{ destination }} = UNSET +{% endif %} +if not isinstance({{ source }}, Unset): + {{ destination }} = {{ transformed }} +{%- endif %} +{% endmacro %} + +{% macro multipart(property, source, name) %} +files.append(({{ name }}, (None, str({{ source }}), "text/plain")) +{% endmacro %} diff --git a/templates/pyproject.toml.jinja b/templates/pyproject.toml.jinja new file mode 100644 index 0000000..9f21f80 --- /dev/null +++ b/templates/pyproject.toml.jinja @@ -0,0 +1,9 @@ +{% if meta == "poetry" %} +{% include "pyproject_poetry.toml.jinja" %} +{% elif meta == "pdm" %} +{% include "pyproject_pdm.toml.jinja" %} +{% elif meta == "uv" %} +{% include "pyproject_uv.toml.jinja" %} +{% endif %} + +{% include "pyproject_ruff.toml.jinja" %} diff --git a/templates/pyproject_pdm.toml.jinja b/templates/pyproject_pdm.toml.jinja new file mode 100644 index 0000000..82b50ea --- /dev/null +++ b/templates/pyproject_pdm.toml.jinja @@ -0,0 +1,19 @@ +[project] +name = "{{ project_name }}" +version = "{{ package_version }}" +description = "{{ package_description }}" +authors = [] +readme = "README.md" +requires-python = ">=3.9,<4.0" +dependencies = [ + "httpx>=0.23.0,<0.29.0", + "attrs>=22.2.0", + "python-dateutil>=2.8.0", +] + +[tool.pdm] +distribution = true + +[build-system] +requires = ["pdm-backend"] +build-backend = "pdm.backend" diff --git a/templates/pyproject_poetry.toml.jinja b/templates/pyproject_poetry.toml.jinja new file mode 100644 index 0000000..6a057b0 --- /dev/null +++ b/templates/pyproject_poetry.toml.jinja @@ -0,0 +1,20 @@ +[tool.poetry] +name = "{{ project_name }}" +version = "{{ package_version }}" +description = "{{ package_description }}" +authors = [] +readme = "README.md" +packages = [ + { include = "{{ package_name }}" }, +] +include = ["{{ package_name }}/py.typed"] + +[tool.poetry.dependencies] +python = "^3.9" +httpx = ">=0.23.0,<0.29.0" +attrs = ">=22.2.0" +python-dateutil = "^2.8.0" + +[build-system] +requires = ["poetry-core>=2.0.0,<3.0.0"] +build-backend = "poetry.core.masonry.api" diff --git a/templates/pyproject_ruff.toml.jinja b/templates/pyproject_ruff.toml.jinja new file mode 100644 index 0000000..c2e4ce2 --- /dev/null +++ b/templates/pyproject_ruff.toml.jinja @@ -0,0 +1,5 @@ +[tool.ruff] +line-length = 120 + +[tool.ruff.lint] +select = ["F", "I", "UP"] diff --git a/templates/pyproject_uv.toml.jinja b/templates/pyproject_uv.toml.jinja new file mode 100644 index 0000000..ca0ef53 --- /dev/null +++ b/templates/pyproject_uv.toml.jinja @@ -0,0 +1,20 @@ +[project] +name = "{{ project_name }}" +version = "{{ package_version }}" +description = "{{ package_description }}" +authors = [] +requires-python = ">=3.9,<4.0" +readme = "README.md" +dependencies = [ + "httpx>=0.23.0,<0.29.0", + "attrs>=22.2.0", + "python-dateutil>=2.8.0,<3", +] + +[tool.uv.build-backend] +module-name = "{{ package_name }}" +module-root = "" + +[build-system] +requires = ["uv_build>=0.8.0,<0.9.0"] +build-backend = "uv_build" diff --git a/templates/setup.py.jinja b/templates/setup.py.jinja new file mode 100644 index 0000000..68a6dcf --- /dev/null +++ b/templates/setup.py.jinja @@ -0,0 +1,18 @@ +import pathlib + +from setuptools import find_packages, setup + +here = pathlib.Path(__file__).parent.resolve() +long_description = (here / "README.md").read_text(encoding="utf-8") + +setup( + name="{{ project_name }}", + version="{{ package_version }}", + description="{{ package_description }}", + long_description=long_description, + long_description_content_type="text/markdown", + packages=find_packages(), + python_requires=">=3.9, <4", + install_requires=["httpx >= 0.23.0, < 0.29.0", "attrs >= 22.2.0", "python-dateutil >= 2.8.0, < 3"], + package_data={"{{ package_name }}": ["py.typed"]}, +) diff --git a/templates/str_enum.py.jinja b/templates/str_enum.py.jinja new file mode 100644 index 0000000..e0da5ed --- /dev/null +++ b/templates/str_enum.py.jinja @@ -0,0 +1,9 @@ +from enum import Enum + +class {{ enum.class_info.name }}(str, Enum): + {% for key, value in enum.values|dictsort(true) %} + {{ key }} = "{{ value }}" + {% endfor %} + + def __str__(self) -> str: + return str(self.value) diff --git a/templates/types.py.jinja b/templates/types.py.jinja new file mode 100644 index 0000000..2330892 --- /dev/null +++ b/templates/types.py.jinja @@ -0,0 +1,53 @@ +""" Contains some shared types for properties """ + +from collections.abc import Mapping, MutableMapping +from http import HTTPStatus +from typing import BinaryIO, Generic, Optional, TypeVar, Literal, Union, IO + +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"] diff --git a/unikraft_cloud_platform/__init__.py b/unikraft_cloud_platform/__init__.py new file mode 100644 index 0000000..78b8825 --- /dev/null +++ b/unikraft_cloud_platform/__init__.py @@ -0,0 +1,8 @@ +"""A client library for accessing Unikraft Cloud Platform API""" + +from .client import AuthenticatedClient, Client + +__all__ = ( + "AuthenticatedClient", + "Client", +) diff --git a/unikraft_cloud_platform/api/__init__.py b/unikraft_cloud_platform/api/__init__.py new file mode 100644 index 0000000..81f9fa2 --- /dev/null +++ b/unikraft_cloud_platform/api/__init__.py @@ -0,0 +1 @@ +"""Contains methods for accessing the API""" diff --git a/unikraft_cloud_platform/api/autoscale/__init__.py b/unikraft_cloud_platform/api/autoscale/__init__.py new file mode 100644 index 0000000..2d7c0b2 --- /dev/null +++ b/unikraft_cloud_platform/api/autoscale/__init__.py @@ -0,0 +1 @@ +"""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 new file mode 100644 index 0000000..52bfb35 --- /dev/null +++ b/unikraft_cloud_platform/api/autoscale/create_autoscale_configuration_by_service_group_uuid.py @@ -0,0 +1,189 @@ +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 new file mode 100644 index 0000000..c7df191 --- /dev/null +++ b/unikraft_cloud_platform/api/autoscale/create_autoscale_configuration_policy.py @@ -0,0 +1,186 @@ +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 new file mode 100644 index 0000000..7d13edf --- /dev/null +++ b/unikraft_cloud_platform/api/autoscale/create_autoscale_configurations.py @@ -0,0 +1,170 @@ +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 new file mode 100644 index 0000000..dc16564 --- /dev/null +++ b/unikraft_cloud_platform/api/autoscale/delete_autoscale_configuration_policies.py @@ -0,0 +1,178 @@ +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 new file mode 100644 index 0000000..dfc9862 --- /dev/null +++ b/unikraft_cloud_platform/api/autoscale/delete_autoscale_configuration_policy_by_name.py @@ -0,0 +1,166 @@ +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 new file mode 100644 index 0000000..f3f6416 --- /dev/null +++ b/unikraft_cloud_platform/api/autoscale/delete_autoscale_configurations.py @@ -0,0 +1,168 @@ +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 new file mode 100644 index 0000000..77597f6 --- /dev/null +++ b/unikraft_cloud_platform/api/autoscale/delete_autoscale_configurations_by_service_group_uuid.py @@ -0,0 +1,181 @@ +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 new file mode 100644 index 0000000..192754f --- /dev/null +++ b/unikraft_cloud_platform/api/autoscale/get_autoscale_configuration_policies.py @@ -0,0 +1,178 @@ +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 new file mode 100644 index 0000000..b309f80 --- /dev/null +++ b/unikraft_cloud_platform/api/autoscale/get_autoscale_configuration_policy_by_name.py @@ -0,0 +1,170 @@ +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 new file mode 100644 index 0000000..11e33d1 --- /dev/null +++ b/unikraft_cloud_platform/api/autoscale/get_autoscale_configurations.py @@ -0,0 +1,168 @@ +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 new file mode 100644 index 0000000..56bb9bd --- /dev/null +++ b/unikraft_cloud_platform/api/autoscale/get_autoscale_configurations_by_service_group_uuid.py @@ -0,0 +1,157 @@ +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/certificates/__init__.py b/unikraft_cloud_platform/api/certificates/__init__.py new file mode 100644 index 0000000..2d7c0b2 --- /dev/null +++ b/unikraft_cloud_platform/api/certificates/__init__.py @@ -0,0 +1 @@ +"""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 new file mode 100644 index 0000000..94e0e5c --- /dev/null +++ b/unikraft_cloud_platform/api/certificates/create_certificate.py @@ -0,0 +1,165 @@ +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 new file mode 100644 index 0000000..c8d9084 --- /dev/null +++ b/unikraft_cloud_platform/api/certificates/delete_certificate_by_uuid.py @@ -0,0 +1,157 @@ +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 new file mode 100644 index 0000000..f76b11c --- /dev/null +++ b/unikraft_cloud_platform/api/certificates/delete_certificates.py @@ -0,0 +1,168 @@ +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 new file mode 100644 index 0000000..687de82 --- /dev/null +++ b/unikraft_cloud_platform/api/certificates/get_certificate_by_uuid.py @@ -0,0 +1,151 @@ +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 new file mode 100644 index 0000000..f06be25 --- /dev/null +++ b/unikraft_cloud_platform/api/certificates/get_certificates.py @@ -0,0 +1,186 @@ +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/images/__init__.py b/unikraft_cloud_platform/api/images/__init__.py new file mode 100644 index 0000000..2d7c0b2 --- /dev/null +++ b/unikraft_cloud_platform/api/images/__init__.py @@ -0,0 +1 @@ +"""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 new file mode 100644 index 0000000..500ee1a --- /dev/null +++ b/unikraft_cloud_platform/api/images/get_image_by_digest.py @@ -0,0 +1,154 @@ +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 new file mode 100644 index 0000000..c7ffec1 --- /dev/null +++ b/unikraft_cloud_platform/api/images/get_image_by_tag.py @@ -0,0 +1,150 @@ +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/instances/__init__.py b/unikraft_cloud_platform/api/instances/__init__.py new file mode 100644 index 0000000..2d7c0b2 --- /dev/null +++ b/unikraft_cloud_platform/api/instances/__init__.py @@ -0,0 +1 @@ +"""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 new file mode 100644 index 0000000..874149b --- /dev/null +++ b/unikraft_cloud_platform/api/instances/create_instance.py @@ -0,0 +1,159 @@ +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 new file mode 100644 index 0000000..89c66be --- /dev/null +++ b/unikraft_cloud_platform/api/instances/delete_instance_by_uuid.py @@ -0,0 +1,159 @@ +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 new file mode 100644 index 0000000..2560350 --- /dev/null +++ b/unikraft_cloud_platform/api/instances/delete_instances.py @@ -0,0 +1,170 @@ +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 new file mode 100644 index 0000000..5f00472 --- /dev/null +++ b/unikraft_cloud_platform/api/instances/get_instance_by_uuid.py @@ -0,0 +1,172 @@ +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 new file mode 100644 index 0000000..0fd3856 --- /dev/null +++ b/unikraft_cloud_platform/api/instances/get_instance_logs.py @@ -0,0 +1,167 @@ +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 new file mode 100644 index 0000000..38715cf --- /dev/null +++ b/unikraft_cloud_platform/api/instances/get_instance_logs_by_uuid.py @@ -0,0 +1,173 @@ +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 new file mode 100644 index 0000000..52c7906 --- /dev/null +++ b/unikraft_cloud_platform/api/instances/get_instance_metrics.py @@ -0,0 +1,175 @@ +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 new file mode 100644 index 0000000..5594532 --- /dev/null +++ b/unikraft_cloud_platform/api/instances/get_instance_metrics_by_uuid.py @@ -0,0 +1,153 @@ +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 new file mode 100644 index 0000000..b8d7a89 --- /dev/null +++ b/unikraft_cloud_platform/api/instances/get_instances.py @@ -0,0 +1,186 @@ +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 new file mode 100644 index 0000000..27eccb4 --- /dev/null +++ b/unikraft_cloud_platform/api/instances/start_instance_by_uuid.py @@ -0,0 +1,155 @@ +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 new file mode 100644 index 0000000..d8a130d --- /dev/null +++ b/unikraft_cloud_platform/api/instances/start_instances.py @@ -0,0 +1,166 @@ +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 new file mode 100644 index 0000000..fa89775 --- /dev/null +++ b/unikraft_cloud_platform/api/instances/stop_instance_by_uuid.py @@ -0,0 +1,191 @@ +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 new file mode 100644 index 0000000..33f9273 --- /dev/null +++ b/unikraft_cloud_platform/api/instances/stop_instances.py @@ -0,0 +1,166 @@ +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 new file mode 100644 index 0000000..50cdd9a --- /dev/null +++ b/unikraft_cloud_platform/api/instances/update_instance_by_uuid.py @@ -0,0 +1,177 @@ +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 new file mode 100644 index 0000000..0a9e43b --- /dev/null +++ b/unikraft_cloud_platform/api/instances/update_instances.py @@ -0,0 +1,163 @@ +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 new file mode 100644 index 0000000..cf83ceb --- /dev/null +++ b/unikraft_cloud_platform/api/instances/wait_instance_by_uuid.py @@ -0,0 +1,201 @@ +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 new file mode 100644 index 0000000..4bab969 --- /dev/null +++ b/unikraft_cloud_platform/api/instances/wait_instances.py @@ -0,0 +1,234 @@ +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/service_groups/__init__.py b/unikraft_cloud_platform/api/service_groups/__init__.py new file mode 100644 index 0000000..2d7c0b2 --- /dev/null +++ b/unikraft_cloud_platform/api/service_groups/__init__.py @@ -0,0 +1 @@ +"""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 new file mode 100644 index 0000000..9bea32e --- /dev/null +++ b/unikraft_cloud_platform/api/service_groups/create_service_group.py @@ -0,0 +1,181 @@ +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 new file mode 100644 index 0000000..70f428b --- /dev/null +++ b/unikraft_cloud_platform/api/service_groups/delete_service_group_by_uuid.py @@ -0,0 +1,157 @@ +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 new file mode 100644 index 0000000..a945722 --- /dev/null +++ b/unikraft_cloud_platform/api/service_groups/delete_service_groups.py @@ -0,0 +1,168 @@ +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 new file mode 100644 index 0000000..31ce8da --- /dev/null +++ b/unikraft_cloud_platform/api/service_groups/get_service_group_by_uuid.py @@ -0,0 +1,174 @@ +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 new file mode 100644 index 0000000..e2ebdc4 --- /dev/null +++ b/unikraft_cloud_platform/api/service_groups/get_service_groups.py @@ -0,0 +1,188 @@ +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 new file mode 100644 index 0000000..000d869 --- /dev/null +++ b/unikraft_cloud_platform/api/service_groups/update_service_group_by_uuid.py @@ -0,0 +1,175 @@ +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 new file mode 100644 index 0000000..7d65aa2 --- /dev/null +++ b/unikraft_cloud_platform/api/service_groups/update_service_groups.py @@ -0,0 +1,164 @@ +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/system/__init__.py b/unikraft_cloud_platform/api/system/__init__.py new file mode 100644 index 0000000..2d7c0b2 --- /dev/null +++ b/unikraft_cloud_platform/api/system/__init__.py @@ -0,0 +1 @@ +"""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 new file mode 100644 index 0000000..5267859 --- /dev/null +++ b/unikraft_cloud_platform/api/system/healthz.py @@ -0,0 +1,126 @@ +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 new file mode 100644 index 0000000..2d7c0b2 --- /dev/null +++ b/unikraft_cloud_platform/api/users/__init__.py @@ -0,0 +1 @@ +"""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 new file mode 100644 index 0000000..731a58a --- /dev/null +++ b/unikraft_cloud_platform/api/users/get_user.py @@ -0,0 +1,130 @@ +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 new file mode 100644 index 0000000..4a9e637 --- /dev/null +++ b/unikraft_cloud_platform/api/users/get_user_by_uuid.py @@ -0,0 +1,155 @@ +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/volumes/__init__.py b/unikraft_cloud_platform/api/volumes/__init__.py new file mode 100644 index 0000000..2d7c0b2 --- /dev/null +++ b/unikraft_cloud_platform/api/volumes/__init__.py @@ -0,0 +1 @@ +"""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 new file mode 100644 index 0000000..f6012da --- /dev/null +++ b/unikraft_cloud_platform/api/volumes/attach_volume_by_uuid.py @@ -0,0 +1,181 @@ +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 new file mode 100644 index 0000000..4a3e2b3 --- /dev/null +++ b/unikraft_cloud_platform/api/volumes/attach_volumes.py @@ -0,0 +1,175 @@ +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 new file mode 100644 index 0000000..218a20f --- /dev/null +++ b/unikraft_cloud_platform/api/volumes/create_volume.py @@ -0,0 +1,175 @@ +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 new file mode 100644 index 0000000..c657750 --- /dev/null +++ b/unikraft_cloud_platform/api/volumes/delete_volume_by_uuid.py @@ -0,0 +1,159 @@ +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 new file mode 100644 index 0000000..34d5b88 --- /dev/null +++ b/unikraft_cloud_platform/api/volumes/delete_volumes.py @@ -0,0 +1,170 @@ +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 new file mode 100644 index 0000000..f780aa7 --- /dev/null +++ b/unikraft_cloud_platform/api/volumes/detach_volume_by_uuid.py @@ -0,0 +1,193 @@ +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 new file mode 100644 index 0000000..f805f2e --- /dev/null +++ b/unikraft_cloud_platform/api/volumes/detach_volumes.py @@ -0,0 +1,191 @@ +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 new file mode 100644 index 0000000..29e56f9 --- /dev/null +++ b/unikraft_cloud_platform/api/volumes/get_volume_by_uuid.py @@ -0,0 +1,176 @@ +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 new file mode 100644 index 0000000..a53beea --- /dev/null +++ b/unikraft_cloud_platform/api/volumes/get_volumes.py @@ -0,0 +1,190 @@ +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 new file mode 100644 index 0000000..5ff074e --- /dev/null +++ b/unikraft_cloud_platform/api/volumes/update_volume_by_uuid.py @@ -0,0 +1,173 @@ +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 new file mode 100644 index 0000000..0c8dc73 --- /dev/null +++ b/unikraft_cloud_platform/api/volumes/update_volumes.py @@ -0,0 +1,162 @@ +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/client.py b/unikraft_cloud_platform/client.py new file mode 100644 index 0000000..e05334a --- /dev/null +++ b/unikraft_cloud_platform/client.py @@ -0,0 +1,260 @@ +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/errors.py b/unikraft_cloud_platform/errors.py new file mode 100644 index 0000000..5f92e76 --- /dev/null +++ b/unikraft_cloud_platform/errors.py @@ -0,0 +1,16 @@ +"""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/models/__init__.py b/unikraft_cloud_platform/models/__init__.py new file mode 100644 index 0000000..3f54983 --- /dev/null +++ b/unikraft_cloud_platform/models/__init__.py @@ -0,0 +1,367 @@ +"""Contains all the data models used in inputs/outputs""" + +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, +) +from .create_autoscale_configuration_by_service_group_uuid_request_instance_create_args import ( + CreateAutoscaleConfigurationByServiceGroupUUIDRequestInstanceCreateArgs, +) +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 .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 .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 .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", +) 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 new file mode 100644 index 0000000..3b690a8 --- /dev/null +++ b/unikraft_cloud_platform/models/attach_volume_by_uuid_request_body.py @@ -0,0 +1,73 @@ +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 new file mode 100644 index 0000000..b403cc1 --- /dev/null +++ b/unikraft_cloud_platform/models/attach_volumes_request.py @@ -0,0 +1,117 @@ +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 new file mode 100644 index 0000000..3e2ebfc --- /dev/null +++ b/unikraft_cloud_platform/models/attach_volumes_request_instance_id.py @@ -0,0 +1,65 @@ +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 new file mode 100644 index 0000000..a3bec5b --- /dev/null +++ b/unikraft_cloud_platform/models/attach_volumes_response.py @@ -0,0 +1,120 @@ +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 new file mode 100644 index 0000000..28c4760 --- /dev/null +++ b/unikraft_cloud_platform/models/attach_volumes_response_attached_volume.py @@ -0,0 +1,109 @@ +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 new file mode 100644 index 0000000..214b807 --- /dev/null +++ b/unikraft_cloud_platform/models/attach_volumes_response_data.py @@ -0,0 +1,71 @@ +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_policy.py b/unikraft_cloud_platform/models/autoscale_policy.py new file mode 100644 index 0000000..e70098f --- /dev/null +++ b/unikraft_cloud_platform/models/autoscale_policy.py @@ -0,0 +1,134 @@ +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.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 + +if TYPE_CHECKING: + from ..models.autoscale_policy_step import AutoscalePolicyStep + + +T = TypeVar("T", bound="AutoscalePolicy") + + +@_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. + + """ + + 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 + + @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, + ) + + 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 diff --git a/unikraft_cloud_platform/models/autoscale_policy_adjustment_type.py b/unikraft_cloud_platform/models/autoscale_policy_adjustment_type.py new file mode 100644 index 0000000..7d06724 --- /dev/null +++ b/unikraft_cloud_platform/models/autoscale_policy_adjustment_type.py @@ -0,0 +1,15 @@ +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 new file mode 100644 index 0000000..4a11e8f --- /dev/null +++ b/unikraft_cloud_platform/models/autoscale_policy_metric.py @@ -0,0 +1,13 @@ +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 new file mode 100644 index 0000000..4399e7e --- /dev/null +++ b/unikraft_cloud_platform/models/autoscale_policy_step.py @@ -0,0 +1,73 @@ +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 + + @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, + ) + + 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 diff --git a/unikraft_cloud_platform/models/body_instance_id.py b/unikraft_cloud_platform/models/body_instance_id.py new file mode 100644 index 0000000..9480797 --- /dev/null +++ b/unikraft_cloud_platform/models/body_instance_id.py @@ -0,0 +1,65 @@ +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 new file mode 100644 index 0000000..2795fe8 --- /dev/null +++ b/unikraft_cloud_platform/models/certificate.py @@ -0,0 +1,249 @@ +import datetime +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 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 + + @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, + ) + + certificate.additional_properties = d + return 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/certificate_state.py b/unikraft_cloud_platform/models/certificate_state.py new file mode 100644 index 0000000..46f8337 --- /dev/null +++ b/unikraft_cloud_platform/models/certificate_state.py @@ -0,0 +1,15 @@ +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/configuration_instance_create_args.py b/unikraft_cloud_platform/models/configuration_instance_create_args.py new file mode 100644 index 0000000..fd1ee33 --- /dev/null +++ b/unikraft_cloud_platform/models/configuration_instance_create_args.py @@ -0,0 +1,42 @@ +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_configuration_by_service_group_uuid_request.py b/unikraft_cloud_platform/models/create_autoscale_configuration_by_service_group_uuid_request.py new file mode 100644 index 0000000..19db08a --- /dev/null +++ b/unikraft_cloud_platform/models/create_autoscale_configuration_by_service_group_uuid_request.py @@ -0,0 +1,153 @@ +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 new file mode 100644 index 0000000..d5b6e09 --- /dev/null +++ b/unikraft_cloud_platform/models/create_autoscale_configuration_by_service_group_uuid_request_instance_create_args.py @@ -0,0 +1,42 @@ +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 new file mode 100644 index 0000000..92af0a7 --- /dev/null +++ b/unikraft_cloud_platform/models/create_autoscale_configuration_policy_request.py @@ -0,0 +1,77 @@ +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 new file mode 100644 index 0000000..7132471 --- /dev/null +++ b/unikraft_cloud_platform/models/create_autoscale_configuration_policy_response.py @@ -0,0 +1,119 @@ +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 new file mode 100644 index 0000000..37d928d --- /dev/null +++ b/unikraft_cloud_platform/models/create_autoscale_configuration_policy_response_data.py @@ -0,0 +1,75 @@ +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 new file mode 100644 index 0000000..39a048e --- /dev/null +++ b/unikraft_cloud_platform/models/create_autoscale_configuration_policy_response_policy.py @@ -0,0 +1,109 @@ +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 new file mode 100644 index 0000000..e3d8f89 --- /dev/null +++ b/unikraft_cloud_platform/models/create_autoscale_configurations_request_configuration.py @@ -0,0 +1,152 @@ +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 new file mode 100644 index 0000000..eaf8e91 --- /dev/null +++ b/unikraft_cloud_platform/models/create_autoscale_configurations_response.py @@ -0,0 +1,117 @@ +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 new file mode 100644 index 0000000..79dd0d3 --- /dev/null +++ b/unikraft_cloud_platform/models/create_autoscale_configurations_response_configurations_response.py @@ -0,0 +1,109 @@ +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 new file mode 100644 index 0000000..ff31fe1 --- /dev/null +++ b/unikraft_cloud_platform/models/create_autoscale_configurations_response_data.py @@ -0,0 +1,77 @@ +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_certificate_request.py b/unikraft_cloud_platform/models/create_certificate_request.py new file mode 100644 index 0000000..634f2da --- /dev/null +++ b/unikraft_cloud_platform/models/create_certificate_request.py @@ -0,0 +1,73 @@ +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="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, + } + ) + + return field_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") + + pkey = d.pop("pkey") + + create_certificate_request = cls( + cn=cn, + chain=chain, + pkey=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 diff --git a/unikraft_cloud_platform/models/create_certificate_response.py b/unikraft_cloud_platform/models/create_certificate_response.py new file mode 100644 index 0000000..071135c --- /dev/null +++ b/unikraft_cloud_platform/models/create_certificate_response.py @@ -0,0 +1,127 @@ +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 new file mode 100644 index 0000000..2a2c8ba --- /dev/null +++ b/unikraft_cloud_platform/models/create_certificate_response_data.py @@ -0,0 +1,74 @@ +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_instance_request.py b/unikraft_cloud_platform/models/create_instance_request.py new file mode 100644 index 0000000..b5119fe --- /dev/null +++ b/unikraft_cloud_platform/models/create_instance_request.py @@ -0,0 +1,270 @@ +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 ..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, + } + ) + 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 + + @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) + + _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) + + _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, + ) + + 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 diff --git a/unikraft_cloud_platform/models/create_instance_request_domain.py b/unikraft_cloud_platform/models/create_instance_request_domain.py new file mode 100644 index 0000000..119d3e3 --- /dev/null +++ b/unikraft_cloud_platform/models/create_instance_request_domain.py @@ -0,0 +1,73 @@ +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 new file mode 100644 index 0000000..ec14296 --- /dev/null +++ b/unikraft_cloud_platform/models/create_instance_request_env.py @@ -0,0 +1,49 @@ +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="CreateInstanceRequestEnv") + + +@_attrs_define +class CreateInstanceRequestEnv: + """(Optional). Environment variables to set for the instance. + + Example: + {'ENV_VAR1': 'value1', 'ENV_VAR2': 'value2'} + + """ + + 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) + create_instance_request_env = cls() + + create_instance_request_env.additional_properties = d + return create_instance_request_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/create_instance_request_features_item.py b/unikraft_cloud_platform/models/create_instance_request_features_item.py new file mode 100644 index 0000000..80be3dc --- /dev/null +++ b/unikraft_cloud_platform/models/create_instance_request_features_item.py @@ -0,0 +1,13 @@ +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 new file mode 100644 index 0000000..2aeb28e --- /dev/null +++ b/unikraft_cloud_platform/models/create_instance_request_restart_policy.py @@ -0,0 +1,15 @@ +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_service_group.py b/unikraft_cloud_platform/models/create_instance_request_service_group.py new file mode 100644 index 0000000..4956b0e --- /dev/null +++ b/unikraft_cloud_platform/models/create_instance_request_service_group.py @@ -0,0 +1,108 @@ +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_instance_request_domain import CreateInstanceRequestDomain + from ..models.service import Service + + +T = TypeVar("T", bound="CreateInstanceRequestServiceGroup") + + +@_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. + + """ + + 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 + + @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, + ) + + 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 + + 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_volume.py b/unikraft_cloud_platform/models/create_instance_request_volume.py new file mode 100644 index 0000000..5dab540 --- /dev/null +++ b/unikraft_cloud_platform/models/create_instance_request_volume.py @@ -0,0 +1,118 @@ +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_response.py b/unikraft_cloud_platform/models/create_instance_response.py new file mode 100644 index 0000000..3838b1d --- /dev/null +++ b/unikraft_cloud_platform/models/create_instance_response.py @@ -0,0 +1,127 @@ +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 new file mode 100644 index 0000000..52429eb --- /dev/null +++ b/unikraft_cloud_platform/models/create_instance_response_data.py @@ -0,0 +1,71 @@ +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 new file mode 100644 index 0000000..179486f --- /dev/null +++ b/unikraft_cloud_platform/models/create_service_group_request.py @@ -0,0 +1,138 @@ +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 new file mode 100644 index 0000000..e5e238d --- /dev/null +++ b/unikraft_cloud_platform/models/create_service_group_request_domain.py @@ -0,0 +1,83 @@ +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 new file mode 100644 index 0000000..b0481d7 --- /dev/null +++ b/unikraft_cloud_platform/models/create_service_group_response.py @@ -0,0 +1,127 @@ +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 new file mode 100644 index 0000000..879bf2c --- /dev/null +++ b/unikraft_cloud_platform/models/create_service_group_response_data.py @@ -0,0 +1,74 @@ +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_volume_request.py b/unikraft_cloud_platform/models/create_volume_request.py new file mode 100644 index 0000000..3a758ee --- /dev/null +++ b/unikraft_cloud_platform/models/create_volume_request.py @@ -0,0 +1,57 @@ +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 new file mode 100644 index 0000000..86ab273 --- /dev/null +++ b/unikraft_cloud_platform/models/create_volume_response.py @@ -0,0 +1,117 @@ +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 new file mode 100644 index 0000000..d0304fe --- /dev/null +++ b/unikraft_cloud_platform/models/create_volume_response_data.py @@ -0,0 +1,71 @@ +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 new file mode 100644 index 0000000..3bae3e3 --- /dev/null +++ b/unikraft_cloud_platform/models/create_volume_response_volume.py @@ -0,0 +1,109 @@ +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/delete_autoscale_configuration_policy_response.py b/unikraft_cloud_platform/models/delete_autoscale_configuration_policy_response.py new file mode 100644 index 0000000..7ec1304 --- /dev/null +++ b/unikraft_cloud_platform/models/delete_autoscale_configuration_policy_response.py @@ -0,0 +1,119 @@ +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 new file mode 100644 index 0000000..f1713f2 --- /dev/null +++ b/unikraft_cloud_platform/models/delete_autoscale_configuration_policy_response_data.py @@ -0,0 +1,75 @@ +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 new file mode 100644 index 0000000..fa85fe6 --- /dev/null +++ b/unikraft_cloud_platform/models/delete_autoscale_configuration_policy_response_policies_response.py @@ -0,0 +1,92 @@ +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 new file mode 100644 index 0000000..aecf793 --- /dev/null +++ b/unikraft_cloud_platform/models/delete_autoscale_configurations_response.py @@ -0,0 +1,115 @@ +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 new file mode 100644 index 0000000..b0bb054 --- /dev/null +++ b/unikraft_cloud_platform/models/delete_autoscale_configurations_response_data.py @@ -0,0 +1,75 @@ +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 new file mode 100644 index 0000000..d205d85 --- /dev/null +++ b/unikraft_cloud_platform/models/delete_autoscale_configurations_response_service_group.py @@ -0,0 +1,109 @@ +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_certificates_response.py b/unikraft_cloud_platform/models/delete_certificates_response.py new file mode 100644 index 0000000..86fc83c --- /dev/null +++ b/unikraft_cloud_platform/models/delete_certificates_response.py @@ -0,0 +1,130 @@ +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 new file mode 100644 index 0000000..9d2fe38 --- /dev/null +++ b/unikraft_cloud_platform/models/delete_certificates_response_data.py @@ -0,0 +1,73 @@ +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 new file mode 100644 index 0000000..cea344b --- /dev/null +++ b/unikraft_cloud_platform/models/delete_certificates_response_deleted_certificate.py @@ -0,0 +1,111 @@ +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_instances_response.py b/unikraft_cloud_platform/models/delete_instances_response.py new file mode 100644 index 0000000..b9184f8 --- /dev/null +++ b/unikraft_cloud_platform/models/delete_instances_response.py @@ -0,0 +1,130 @@ +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 new file mode 100644 index 0000000..d11fcf8 --- /dev/null +++ b/unikraft_cloud_platform/models/delete_instances_response_data.py @@ -0,0 +1,71 @@ +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 new file mode 100644 index 0000000..2bb5e55 --- /dev/null +++ b/unikraft_cloud_platform/models/delete_instances_response_deleted_instance.py @@ -0,0 +1,120 @@ +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 new file mode 100644 index 0000000..9ee4102 --- /dev/null +++ b/unikraft_cloud_platform/models/delete_policy_request.py @@ -0,0 +1,57 @@ +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 new file mode 100644 index 0000000..1762d26 --- /dev/null +++ b/unikraft_cloud_platform/models/delete_service_groups_response.py @@ -0,0 +1,130 @@ +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 new file mode 100644 index 0000000..aba07d8 --- /dev/null +++ b/unikraft_cloud_platform/models/delete_service_groups_response_data.py @@ -0,0 +1,75 @@ +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 new file mode 100644 index 0000000..a1f342c --- /dev/null +++ b/unikraft_cloud_platform/models/delete_service_groups_response_deleted_service_group.py @@ -0,0 +1,113 @@ +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_volumes_response.py b/unikraft_cloud_platform/models/delete_volumes_response.py new file mode 100644 index 0000000..3a59feb --- /dev/null +++ b/unikraft_cloud_platform/models/delete_volumes_response.py @@ -0,0 +1,115 @@ +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 new file mode 100644 index 0000000..81caeb1 --- /dev/null +++ b/unikraft_cloud_platform/models/delete_volumes_response_data.py @@ -0,0 +1,71 @@ +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 new file mode 100644 index 0000000..6abdaad --- /dev/null +++ b/unikraft_cloud_platform/models/delete_volumes_response_deleted_volume.py @@ -0,0 +1,109 @@ +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 new file mode 100644 index 0000000..66e7711 --- /dev/null +++ b/unikraft_cloud_platform/models/detach_volume_by_uuid_request_body.py @@ -0,0 +1,68 @@ +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 new file mode 100644 index 0000000..42739e3 --- /dev/null +++ b/unikraft_cloud_platform/models/detach_volumes_request.py @@ -0,0 +1,101 @@ +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 new file mode 100644 index 0000000..67442ee --- /dev/null +++ b/unikraft_cloud_platform/models/detach_volumes_request_instance_id.py @@ -0,0 +1,65 @@ +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 new file mode 100644 index 0000000..e18da89 --- /dev/null +++ b/unikraft_cloud_platform/models/detach_volumes_response.py @@ -0,0 +1,115 @@ +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 new file mode 100644 index 0000000..ab0634b --- /dev/null +++ b/unikraft_cloud_platform/models/detach_volumes_response_data.py @@ -0,0 +1,71 @@ +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 new file mode 100644 index 0000000..7efdaa9 --- /dev/null +++ b/unikraft_cloud_platform/models/detach_volumes_response_detached_volume.py @@ -0,0 +1,109 @@ +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 new file mode 100644 index 0000000..f078994 --- /dev/null +++ b/unikraft_cloud_platform/models/domain.py @@ -0,0 +1,68 @@ +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_autoscale_configuration_policy_request.py b/unikraft_cloud_platform/models/get_autoscale_configuration_policy_request.py new file mode 100644 index 0000000..c99c14f --- /dev/null +++ b/unikraft_cloud_platform/models/get_autoscale_configuration_policy_request.py @@ -0,0 +1,57 @@ +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 new file mode 100644 index 0000000..8b75a78 --- /dev/null +++ b/unikraft_cloud_platform/models/get_autoscale_configuration_policy_response.py @@ -0,0 +1,117 @@ +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 new file mode 100644 index 0000000..c5be0eb --- /dev/null +++ b/unikraft_cloud_platform/models/get_autoscale_configuration_policy_response_data.py @@ -0,0 +1,75 @@ +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 new file mode 100644 index 0000000..bb8c048 --- /dev/null +++ b/unikraft_cloud_platform/models/get_autoscale_configuration_policy_response_policy_response.py @@ -0,0 +1,108 @@ +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 new file mode 100644 index 0000000..e3db6e5 --- /dev/null +++ b/unikraft_cloud_platform/models/get_autoscale_configurations_response.py @@ -0,0 +1,120 @@ +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 new file mode 100644 index 0000000..4a87bc0 --- /dev/null +++ b/unikraft_cloud_platform/models/get_autoscale_configurations_response_data.py @@ -0,0 +1,75 @@ +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 new file mode 100644 index 0000000..ff34c0c --- /dev/null +++ b/unikraft_cloud_platform/models/get_autoscale_configurations_response_service_group.py @@ -0,0 +1,200 @@ +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 new file mode 100644 index 0000000..98944cf --- /dev/null +++ b/unikraft_cloud_platform/models/get_autoscale_configurations_response_status.py @@ -0,0 +1,17 @@ +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_certificates_response.py b/unikraft_cloud_platform/models/get_certificates_response.py new file mode 100644 index 0000000..ce6d4cc --- /dev/null +++ b/unikraft_cloud_platform/models/get_certificates_response.py @@ -0,0 +1,130 @@ +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 new file mode 100644 index 0000000..84fff5a --- /dev/null +++ b/unikraft_cloud_platform/models/get_certificates_response_data.py @@ -0,0 +1,71 @@ +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 new file mode 100644 index 0000000..2cf6af0 --- /dev/null +++ b/unikraft_cloud_platform/models/get_image_response.py @@ -0,0 +1,126 @@ +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 new file mode 100644 index 0000000..70e21cb --- /dev/null +++ b/unikraft_cloud_platform/models/get_image_response_data.py @@ -0,0 +1,67 @@ +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_instance_logs_by_uuid_request_body.py b/unikraft_cloud_platform/models/get_instance_logs_by_uuid_request_body.py new file mode 100644 index 0000000..af80aa1 --- /dev/null +++ b/unikraft_cloud_platform/models/get_instance_logs_by_uuid_request_body.py @@ -0,0 +1,65 @@ +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 new file mode 100644 index 0000000..4b1d1e0 --- /dev/null +++ b/unikraft_cloud_platform/models/get_instance_logs_request.py @@ -0,0 +1,92 @@ +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_response.py b/unikraft_cloud_platform/models/get_instance_logs_response.py new file mode 100644 index 0000000..66ab84b --- /dev/null +++ b/unikraft_cloud_platform/models/get_instance_logs_response.py @@ -0,0 +1,130 @@ +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 new file mode 100644 index 0000000..f4d87da --- /dev/null +++ b/unikraft_cloud_platform/models/get_instance_logs_response_available.py @@ -0,0 +1,64 @@ +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 new file mode 100644 index 0000000..8362beb --- /dev/null +++ b/unikraft_cloud_platform/models/get_instance_logs_response_data.py @@ -0,0 +1,74 @@ +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 new file mode 100644 index 0000000..ce61012 --- /dev/null +++ b/unikraft_cloud_platform/models/get_instance_logs_response_logged_instance.py @@ -0,0 +1,159 @@ +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 new file mode 100644 index 0000000..673de0f --- /dev/null +++ b/unikraft_cloud_platform/models/get_instance_logs_response_logged_instance_state.py @@ -0,0 +1,22 @@ +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 new file mode 100644 index 0000000..ce7e106 --- /dev/null +++ b/unikraft_cloud_platform/models/get_instance_logs_response_range.py @@ -0,0 +1,64 @@ +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_metrics_response.py b/unikraft_cloud_platform/models/get_instance_metrics_response.py new file mode 100644 index 0000000..27df394 --- /dev/null +++ b/unikraft_cloud_platform/models/get_instance_metrics_response.py @@ -0,0 +1,130 @@ +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 new file mode 100644 index 0000000..e697f0d --- /dev/null +++ b/unikraft_cloud_platform/models/get_instance_metrics_response_data.py @@ -0,0 +1,73 @@ +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 new file mode 100644 index 0000000..c7b5e88 --- /dev/null +++ b/unikraft_cloud_platform/models/get_instance_metrics_response_instance_metrics.py @@ -0,0 +1,195 @@ +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_instances_response.py b/unikraft_cloud_platform/models/get_instances_response.py new file mode 100644 index 0000000..ce4ba30 --- /dev/null +++ b/unikraft_cloud_platform/models/get_instances_response.py @@ -0,0 +1,127 @@ +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 new file mode 100644 index 0000000..407bfa2 --- /dev/null +++ b/unikraft_cloud_platform/models/get_instances_response_data.py @@ -0,0 +1,71 @@ +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_service_groups_response.py b/unikraft_cloud_platform/models/get_service_groups_response.py new file mode 100644 index 0000000..7508a96 --- /dev/null +++ b/unikraft_cloud_platform/models/get_service_groups_response.py @@ -0,0 +1,130 @@ +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 new file mode 100644 index 0000000..6893a81 --- /dev/null +++ b/unikraft_cloud_platform/models/get_service_groups_response_data.py @@ -0,0 +1,71 @@ +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_volumes_response.py b/unikraft_cloud_platform/models/get_volumes_response.py new file mode 100644 index 0000000..bc5aab1 --- /dev/null +++ b/unikraft_cloud_platform/models/get_volumes_response.py @@ -0,0 +1,120 @@ +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 new file mode 100644 index 0000000..1c17923 --- /dev/null +++ b/unikraft_cloud_platform/models/get_volumes_response_data.py @@ -0,0 +1,71 @@ +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 new file mode 100644 index 0000000..d0ffa29 --- /dev/null +++ b/unikraft_cloud_platform/models/healthz_response.py @@ -0,0 +1,127 @@ +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 new file mode 100644 index 0000000..f42c467 --- /dev/null +++ b/unikraft_cloud_platform/models/healthz_response_data.py @@ -0,0 +1,69 @@ +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 new file mode 100644 index 0000000..676afe4 --- /dev/null +++ b/unikraft_cloud_platform/models/healthz_response_data_services.py @@ -0,0 +1,42 @@ +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 new file mode 100644 index 0000000..72e77c9 --- /dev/null +++ b/unikraft_cloud_platform/models/image.py @@ -0,0 +1,228 @@ +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 + + @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, + ) + + 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 diff --git a/unikraft_cloud_platform/models/image_labels.py b/unikraft_cloud_platform/models/image_labels.py new file mode 100644 index 0000000..053ab09 --- /dev/null +++ b/unikraft_cloud_platform/models/image_labels.py @@ -0,0 +1,44 @@ +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 new file mode 100644 index 0000000..b38f322 --- /dev/null +++ b/unikraft_cloud_platform/models/instance.py @@ -0,0 +1,603 @@ +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 + + stop_code = self.stop_code + + 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() + + 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) + + service_group: Union[Unset, dict[str, Any]] = UNSET + if not isinstance(self.service_group, Unset): + service_group = self.service_group.to_dict() + + 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 + + @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, + ) + + 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 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 new file mode 100644 index 0000000..10d43d0 --- /dev/null +++ b/unikraft_cloud_platform/models/instance_create_args_instance_create_request_roms.py @@ -0,0 +1,66 @@ +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 new file mode 100644 index 0000000..eeb282a --- /dev/null +++ b/unikraft_cloud_platform/models/instance_env.py @@ -0,0 +1,49 @@ +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 new file mode 100644 index 0000000..c339be2 --- /dev/null +++ b/unikraft_cloud_platform/models/instance_instance_service_group.py @@ -0,0 +1,114 @@ +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 new file mode 100644 index 0000000..78482cb --- /dev/null +++ b/unikraft_cloud_platform/models/instance_instance_volume.py @@ -0,0 +1,107 @@ +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_network_interface.py b/unikraft_cloud_platform/models/instance_network_interface.py new file mode 100644 index 0000000..c1108fa --- /dev/null +++ b/unikraft_cloud_platform/models/instance_network_interface.py @@ -0,0 +1,122 @@ +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_restart_policy.py b/unikraft_cloud_platform/models/instance_restart_policy.py new file mode 100644 index 0000000..d1c9544 --- /dev/null +++ b/unikraft_cloud_platform/models/instance_restart_policy.py @@ -0,0 +1,15 @@ +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 new file mode 100644 index 0000000..352f817 --- /dev/null +++ b/unikraft_cloud_platform/models/instance_scale_to_zero.py @@ -0,0 +1,105 @@ +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 new file mode 100644 index 0000000..d7f22a9 --- /dev/null +++ b/unikraft_cloud_platform/models/instance_scale_to_zero_policy.py @@ -0,0 +1,15 @@ +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_instance_domain.py b/unikraft_cloud_platform/models/instance_service_group_instance_domain.py new file mode 100644 index 0000000..64e8a7c --- /dev/null +++ b/unikraft_cloud_platform/models/instance_service_group_instance_domain.py @@ -0,0 +1,70 @@ +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_state.py b/unikraft_cloud_platform/models/instance_state.py new file mode 100644 index 0000000..05afb7a --- /dev/null +++ b/unikraft_cloud_platform/models/instance_state.py @@ -0,0 +1,18 @@ +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 new file mode 100644 index 0000000..99cda9d --- /dev/null +++ b/unikraft_cloud_platform/models/name_or_uuid.py @@ -0,0 +1,44 @@ +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 new file mode 100644 index 0000000..3c92526 --- /dev/null +++ b/unikraft_cloud_platform/models/object_.py @@ -0,0 +1,80 @@ +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 new file mode 100644 index 0000000..6ab0771 --- /dev/null +++ b/unikraft_cloud_platform/models/quotas.py @@ -0,0 +1,155 @@ +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 new file mode 100644 index 0000000..c289b35 --- /dev/null +++ b/unikraft_cloud_platform/models/quotas_limits.py @@ -0,0 +1,118 @@ +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 new file mode 100644 index 0000000..4630f4f --- /dev/null +++ b/unikraft_cloud_platform/models/quotas_response.py @@ -0,0 +1,117 @@ +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 new file mode 100644 index 0000000..380da98 --- /dev/null +++ b/unikraft_cloud_platform/models/quotas_response_data.py @@ -0,0 +1,71 @@ +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 new file mode 100644 index 0000000..c3af9e7 --- /dev/null +++ b/unikraft_cloud_platform/models/quotas_stats.py @@ -0,0 +1,119 @@ +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 new file mode 100644 index 0000000..62f7867 --- /dev/null +++ b/unikraft_cloud_platform/models/response_error.py @@ -0,0 +1,57 @@ +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 new file mode 100644 index 0000000..0aff987 --- /dev/null +++ b/unikraft_cloud_platform/models/response_status.py @@ -0,0 +1,14 @@ +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 new file mode 100644 index 0000000..2feed90 --- /dev/null +++ b/unikraft_cloud_platform/models/service.py @@ -0,0 +1,102 @@ +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. + + """ + + 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, + } + ) + if destination_port is not UNSET: + field_dict["destination_port"] = destination_port + if handlers is not UNSET: + field_dict["handlers"] = handlers + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + port = d.pop("port") + + destination_port = d.pop("destination_port", UNSET) + + 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, + ) + + 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 diff --git a/unikraft_cloud_platform/models/service_group.py b/unikraft_cloud_platform/models/service_group.py new file mode 100644 index 0000000..d73ecbf --- /dev/null +++ b/unikraft_cloud_platform/models/service_group.py @@ -0,0 +1,287 @@ +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 new file mode 100644 index 0000000..8886666 --- /dev/null +++ b/unikraft_cloud_platform/models/service_group_instance.py @@ -0,0 +1,78 @@ +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 new file mode 100644 index 0000000..27dbf05 --- /dev/null +++ b/unikraft_cloud_platform/models/service_group_template.py @@ -0,0 +1,72 @@ +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 new file mode 100644 index 0000000..c3ac1aa --- /dev/null +++ b/unikraft_cloud_platform/models/service_handlers_item.py @@ -0,0 +1,15 @@ +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/start_instance_response.py b/unikraft_cloud_platform/models/start_instance_response.py new file mode 100644 index 0000000..bac6a23 --- /dev/null +++ b/unikraft_cloud_platform/models/start_instance_response.py @@ -0,0 +1,130 @@ +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 new file mode 100644 index 0000000..8e2c2ce --- /dev/null +++ b/unikraft_cloud_platform/models/start_instance_response_data.py @@ -0,0 +1,71 @@ +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 new file mode 100644 index 0000000..10295b9 --- /dev/null +++ b/unikraft_cloud_platform/models/start_instance_response_started_instance.py @@ -0,0 +1,127 @@ +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/stop_instance_response.py b/unikraft_cloud_platform/models/stop_instance_response.py new file mode 100644 index 0000000..aedf688 --- /dev/null +++ b/unikraft_cloud_platform/models/stop_instance_response.py @@ -0,0 +1,130 @@ +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 new file mode 100644 index 0000000..6ff1b50 --- /dev/null +++ b/unikraft_cloud_platform/models/stop_instance_response_data.py @@ -0,0 +1,71 @@ +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 new file mode 100644 index 0000000..bfe210e --- /dev/null +++ b/unikraft_cloud_platform/models/stop_instance_response_stopped_instance.py @@ -0,0 +1,132 @@ +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 new file mode 100644 index 0000000..c7bba85 --- /dev/null +++ b/unikraft_cloud_platform/models/stop_instance_response_stopped_instance_previous_state.py @@ -0,0 +1,24 @@ +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 new file mode 100644 index 0000000..c98a2f2 --- /dev/null +++ b/unikraft_cloud_platform/models/stop_instance_response_stopped_instance_state.py @@ -0,0 +1,20 @@ +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 new file mode 100644 index 0000000..621f2e5 --- /dev/null +++ b/unikraft_cloud_platform/models/stop_instances_request_id.py @@ -0,0 +1,92 @@ +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/update_instance_by_uuid_request_body.py b/unikraft_cloud_platform/models/update_instance_by_uuid_request_body.py new file mode 100644 index 0000000..80c4abb --- /dev/null +++ b/unikraft_cloud_platform/models/update_instance_by_uuid_request_body.py @@ -0,0 +1,93 @@ +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 new file mode 100644 index 0000000..b2a74e8 --- /dev/null +++ b/unikraft_cloud_platform/models/update_instance_by_uuid_request_body_op.py @@ -0,0 +1,15 @@ +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 new file mode 100644 index 0000000..ffdd35e --- /dev/null +++ b/unikraft_cloud_platform/models/update_instance_by_uuid_request_body_prop.py @@ -0,0 +1,22 @@ +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 new file mode 100644 index 0000000..d50deda --- /dev/null +++ b/unikraft_cloud_platform/models/update_instances_request.py @@ -0,0 +1,114 @@ +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 new file mode 100644 index 0000000..a7e6705 --- /dev/null +++ b/unikraft_cloud_platform/models/update_instances_request_op.py @@ -0,0 +1,15 @@ +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 new file mode 100644 index 0000000..8f19d18 --- /dev/null +++ b/unikraft_cloud_platform/models/update_instances_request_prop.py @@ -0,0 +1,22 @@ +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 new file mode 100644 index 0000000..5b16729 --- /dev/null +++ b/unikraft_cloud_platform/models/update_instances_response.py @@ -0,0 +1,127 @@ +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 new file mode 100644 index 0000000..68d2278 --- /dev/null +++ b/unikraft_cloud_platform/models/update_instances_response_data.py @@ -0,0 +1,71 @@ +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 new file mode 100644 index 0000000..1b3b839 --- /dev/null +++ b/unikraft_cloud_platform/models/update_instances_response_updated_instance.py @@ -0,0 +1,110 @@ +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 new file mode 100644 index 0000000..ebf8b82 --- /dev/null +++ b/unikraft_cloud_platform/models/update_service_group_by_uuid_request_body.py @@ -0,0 +1,92 @@ +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 new file mode 100644 index 0000000..d9ad288 --- /dev/null +++ b/unikraft_cloud_platform/models/update_service_group_by_uuid_request_body_op.py @@ -0,0 +1,17 @@ +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 new file mode 100644 index 0000000..2dc76e3 --- /dev/null +++ b/unikraft_cloud_platform/models/update_service_group_by_uuid_request_body_prop.py @@ -0,0 +1,18 @@ +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 new file mode 100644 index 0000000..687f85c --- /dev/null +++ b/unikraft_cloud_platform/models/update_service_groups_request_item.py @@ -0,0 +1,120 @@ +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 new file mode 100644 index 0000000..2dfa22e --- /dev/null +++ b/unikraft_cloud_platform/models/update_service_groups_request_item_op.py @@ -0,0 +1,15 @@ +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 new file mode 100644 index 0000000..ad77204 --- /dev/null +++ b/unikraft_cloud_platform/models/update_service_groups_request_item_prop.py @@ -0,0 +1,16 @@ +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 new file mode 100644 index 0000000..38831a6 --- /dev/null +++ b/unikraft_cloud_platform/models/update_service_groups_response.py @@ -0,0 +1,127 @@ +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 new file mode 100644 index 0000000..9c1df26 --- /dev/null +++ b/unikraft_cloud_platform/models/update_service_groups_response_data.py @@ -0,0 +1,75 @@ +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 new file mode 100644 index 0000000..e34f5e2 --- /dev/null +++ b/unikraft_cloud_platform/models/update_service_groups_response_updated_service_group.py @@ -0,0 +1,112 @@ +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 new file mode 100644 index 0000000..b0fd599 --- /dev/null +++ b/unikraft_cloud_platform/models/update_volume_by_uuid_request_body.py @@ -0,0 +1,92 @@ +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 new file mode 100644 index 0000000..0936b5d --- /dev/null +++ b/unikraft_cloud_platform/models/update_volume_by_uuid_request_body_op.py @@ -0,0 +1,15 @@ +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 new file mode 100644 index 0000000..8a3ce1a --- /dev/null +++ b/unikraft_cloud_platform/models/update_volume_by_uuid_request_body_prop.py @@ -0,0 +1,16 @@ +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 new file mode 100644 index 0000000..3cb2778 --- /dev/null +++ b/unikraft_cloud_platform/models/update_volumes_request_item.py @@ -0,0 +1,115 @@ +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 new file mode 100644 index 0000000..73c5383 --- /dev/null +++ b/unikraft_cloud_platform/models/update_volumes_request_item_op.py @@ -0,0 +1,15 @@ +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 new file mode 100644 index 0000000..68b89f7 --- /dev/null +++ b/unikraft_cloud_platform/models/update_volumes_request_item_prop.py @@ -0,0 +1,16 @@ +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 new file mode 100644 index 0000000..34fd011 --- /dev/null +++ b/unikraft_cloud_platform/models/update_volumes_response.py @@ -0,0 +1,127 @@ +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 new file mode 100644 index 0000000..44bb17c --- /dev/null +++ b/unikraft_cloud_platform/models/update_volumes_response_data.py @@ -0,0 +1,71 @@ +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 new file mode 100644 index 0000000..d444369 --- /dev/null +++ b/unikraft_cloud_platform/models/update_volumes_response_updated_volume.py @@ -0,0 +1,110 @@ +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/volume.py b/unikraft_cloud_platform/models/volume.py new file mode 100644 index 0000000..ba1f878 --- /dev/null +++ b/unikraft_cloud_platform/models/volume.py @@ -0,0 +1,233 @@ +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.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 + + @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, + ) + + volume.additional_properties = d + return 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/volume_instance_id.py b/unikraft_cloud_platform/models/volume_instance_id.py new file mode 100644 index 0000000..cc19ed9 --- /dev/null +++ b/unikraft_cloud_platform/models/volume_instance_id.py @@ -0,0 +1,65 @@ +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_state.py b/unikraft_cloud_platform/models/volume_state.py new file mode 100644 index 0000000..6ccfa1e --- /dev/null +++ b/unikraft_cloud_platform/models/volume_state.py @@ -0,0 +1,19 @@ +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 new file mode 100644 index 0000000..4b7fab6 --- /dev/null +++ b/unikraft_cloud_platform/models/volume_volume_instance_mount.py @@ -0,0 +1,72 @@ +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_instance_by_uuid_request_body.py b/unikraft_cloud_platform/models/wait_instance_by_uuid_request_body.py new file mode 100644 index 0000000..5f160df --- /dev/null +++ b/unikraft_cloud_platform/models/wait_instance_by_uuid_request_body.py @@ -0,0 +1,68 @@ +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 new file mode 100644 index 0000000..0fcfeda --- /dev/null +++ b/unikraft_cloud_platform/models/wait_instance_by_uuid_request_body_state.py @@ -0,0 +1,18 @@ +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 new file mode 100644 index 0000000..ae79aa2 --- /dev/null +++ b/unikraft_cloud_platform/models/wait_instance_response.py @@ -0,0 +1,130 @@ +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 new file mode 100644 index 0000000..6e0b08a --- /dev/null +++ b/unikraft_cloud_platform/models/wait_instance_response_data.py @@ -0,0 +1,71 @@ +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 new file mode 100644 index 0000000..67a0cf0 --- /dev/null +++ b/unikraft_cloud_platform/models/wait_instance_response_waited_instance.py @@ -0,0 +1,112 @@ +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 new file mode 100644 index 0000000..ea338b6 --- /dev/null +++ b/unikraft_cloud_platform/models/wait_instance_response_waited_instance_state.py @@ -0,0 +1,20 @@ +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 new file mode 100644 index 0000000..7a24c3b --- /dev/null +++ b/unikraft_cloud_platform/models/wait_instances_state.py @@ -0,0 +1,18 @@ +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 new file mode 100644 index 0000000..1aad327 --- /dev/null +++ b/unikraft_cloud_platform/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561 \ No newline at end of file diff --git a/unikraft_cloud_platform/types.py b/unikraft_cloud_platform/types.py new file mode 100644 index 0000000..1b96ca4 --- /dev/null +++ b/unikraft_cloud_platform/types.py @@ -0,0 +1,54 @@ +"""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"]