diff --git a/services/git/oas_commit b/services/git/oas_commit new file mode 100644 index 000000000..e3713dde3 --- /dev/null +++ b/services/git/oas_commit @@ -0,0 +1 @@ +0e64886dd0847341800d7191ed193b75413be998 diff --git a/services/git/src/stackit/git/__init__.py b/services/git/src/stackit/git/__init__.py index 27e86a369..7bd204d82 100644 --- a/services/git/src/stackit/git/__init__.py +++ b/services/git/src/stackit/git/__init__.py @@ -29,19 +29,29 @@ "ApiKeyError", "ApiAttributeError", "ApiException", + "AlreadyExistsError", + "Authentication", + "AuthenticationList", + "BadErrorResponse", + "ConflictErrorResponse", + "CreateAuthenticationPayload", "CreateInstancePayload", + "CreateRunnerPayload", + "FeatureToggle", "Flavor", "GenericErrorResponse", "Instance", - "InstanceFlavor", "InternalServerErrorResponse", "ListFlavors", "ListInstances", - "ListRunnerLabels", + "NotFoundErrorResponse", + "PatchAuthenticationPayload", "PatchInstancePayload", "PatchOperation", - "RunnerLabel", - "UnauthorizedResponse", + "Runner", + "RunnerRuntime", + "RunnerRuntimeList", + "UnauthorizedErrorResponse", ] # import apis into sdk package @@ -59,26 +69,52 @@ from stackit.git.exceptions import OpenApiException as OpenApiException # import models into sdk package +from stackit.git.models.already_exists_error import ( + AlreadyExistsError as AlreadyExistsError, +) +from stackit.git.models.authentication import Authentication as Authentication +from stackit.git.models.authentication_list import ( + AuthenticationList as AuthenticationList, +) +from stackit.git.models.bad_error_response import BadErrorResponse as BadErrorResponse +from stackit.git.models.conflict_error_response import ( + ConflictErrorResponse as ConflictErrorResponse, +) +from stackit.git.models.create_authentication_payload import ( + CreateAuthenticationPayload as CreateAuthenticationPayload, +) from stackit.git.models.create_instance_payload import ( CreateInstancePayload as CreateInstancePayload, ) +from stackit.git.models.create_runner_payload import ( + CreateRunnerPayload as CreateRunnerPayload, +) +from stackit.git.models.feature_toggle import FeatureToggle as FeatureToggle from stackit.git.models.flavor import Flavor as Flavor from stackit.git.models.generic_error_response import ( GenericErrorResponse as GenericErrorResponse, ) from stackit.git.models.instance import Instance as Instance -from stackit.git.models.instance_flavor import InstanceFlavor as InstanceFlavor from stackit.git.models.internal_server_error_response import ( InternalServerErrorResponse as InternalServerErrorResponse, ) from stackit.git.models.list_flavors import ListFlavors as ListFlavors from stackit.git.models.list_instances import ListInstances as ListInstances -from stackit.git.models.list_runner_labels import ListRunnerLabels as ListRunnerLabels +from stackit.git.models.not_found_error_response import ( + NotFoundErrorResponse as NotFoundErrorResponse, +) +from stackit.git.models.patch_authentication_payload import ( + PatchAuthenticationPayload as PatchAuthenticationPayload, +) from stackit.git.models.patch_instance_payload import ( PatchInstancePayload as PatchInstancePayload, ) from stackit.git.models.patch_operation import PatchOperation as PatchOperation -from stackit.git.models.runner_label import RunnerLabel as RunnerLabel -from stackit.git.models.unauthorized_response import ( - UnauthorizedResponse as UnauthorizedResponse, +from stackit.git.models.runner import Runner as Runner +from stackit.git.models.runner_runtime import RunnerRuntime as RunnerRuntime +from stackit.git.models.runner_runtime_list import ( + RunnerRuntimeList as RunnerRuntimeList, +) +from stackit.git.models.unauthorized_error_response import ( + UnauthorizedErrorResponse as UnauthorizedErrorResponse, ) diff --git a/services/git/src/stackit/git/api/default_api.py b/services/git/src/stackit/git/api/default_api.py index 7f85cabdf..8b9a2c46c 100644 --- a/services/git/src/stackit/git/api/default_api.py +++ b/services/git/src/stackit/git/api/default_api.py @@ -13,25 +13,26 @@ """ # noqa: E501 from typing import Any, Dict, List, Optional, Tuple, Union +from uuid import UUID -from pydantic import ( - Field, - StrictFloat, - StrictInt, - StrictStr, - validate_call, -) +from pydantic import Field, StrictFloat, StrictInt, StrictStr, validate_call from stackit.core.configuration import Configuration from typing_extensions import Annotated from stackit.git.api_client import ApiClient, RequestSerialized from stackit.git.api_response import ApiResponse +from stackit.git.models.authentication import Authentication +from stackit.git.models.authentication_list import AuthenticationList +from stackit.git.models.create_authentication_payload import CreateAuthenticationPayload from stackit.git.models.create_instance_payload import CreateInstancePayload +from stackit.git.models.create_runner_payload import CreateRunnerPayload from stackit.git.models.instance import Instance from stackit.git.models.list_flavors import ListFlavors from stackit.git.models.list_instances import ListInstances -from stackit.git.models.list_runner_labels import ListRunnerLabels +from stackit.git.models.patch_authentication_payload import PatchAuthenticationPayload from stackit.git.models.patch_instance_payload import PatchInstancePayload +from stackit.git.models.runner import Runner +from stackit.git.models.runner_runtime_list import RunnerRuntimeList from stackit.git.rest import RESTResponseType @@ -48,11 +49,2131 @@ def __init__(self, configuration: Configuration = None) -> None: self.configuration = configuration self.api_client = ApiClient(self.configuration) + @validate_call + def create_authentication( + self, + project_id: Annotated[UUID, Field(description="Project identifier.")], + instance_id: Annotated[UUID, Field(description="Instance identifier.")], + create_authentication_payload: Annotated[ + CreateAuthenticationPayload, Field(description="Authentication Definition configuration data.") + ], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> Authentication: + """Creates an authentication source + + Creates an authentication source for the corresponding STACKIT Git instance + + :param project_id: Project identifier. (required) + :type project_id: UUID + :param instance_id: Instance identifier. (required) + :type instance_id: UUID + :param create_authentication_payload: Authentication Definition configuration data. (required) + :type create_authentication_payload: CreateAuthenticationPayload + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._create_authentication_serialize( + project_id=project_id, + instance_id=instance_id, + create_authentication_payload=create_authentication_payload, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "202": "Authentication", + "400": "BadErrorResponse", + "401": "UnauthorizedErrorResponse", + "404": "NotFoundErrorResponse", + "409": "ConflictErrorResponse", + "500": "InternalServerErrorResponse", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def create_authentication_with_http_info( + self, + project_id: Annotated[UUID, Field(description="Project identifier.")], + instance_id: Annotated[UUID, Field(description="Instance identifier.")], + create_authentication_payload: Annotated[ + CreateAuthenticationPayload, Field(description="Authentication Definition configuration data.") + ], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[Authentication]: + """Creates an authentication source + + Creates an authentication source for the corresponding STACKIT Git instance + + :param project_id: Project identifier. (required) + :type project_id: UUID + :param instance_id: Instance identifier. (required) + :type instance_id: UUID + :param create_authentication_payload: Authentication Definition configuration data. (required) + :type create_authentication_payload: CreateAuthenticationPayload + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._create_authentication_serialize( + project_id=project_id, + instance_id=instance_id, + create_authentication_payload=create_authentication_payload, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "202": "Authentication", + "400": "BadErrorResponse", + "401": "UnauthorizedErrorResponse", + "404": "NotFoundErrorResponse", + "409": "ConflictErrorResponse", + "500": "InternalServerErrorResponse", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def create_authentication_without_preload_content( + self, + project_id: Annotated[UUID, Field(description="Project identifier.")], + instance_id: Annotated[UUID, Field(description="Instance identifier.")], + create_authentication_payload: Annotated[ + CreateAuthenticationPayload, Field(description="Authentication Definition configuration data.") + ], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Creates an authentication source + + Creates an authentication source for the corresponding STACKIT Git instance + + :param project_id: Project identifier. (required) + :type project_id: UUID + :param instance_id: Instance identifier. (required) + :type instance_id: UUID + :param create_authentication_payload: Authentication Definition configuration data. (required) + :type create_authentication_payload: CreateAuthenticationPayload + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._create_authentication_serialize( + project_id=project_id, + instance_id=instance_id, + create_authentication_payload=create_authentication_payload, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "202": "Authentication", + "400": "BadErrorResponse", + "401": "UnauthorizedErrorResponse", + "404": "NotFoundErrorResponse", + "409": "ConflictErrorResponse", + "500": "InternalServerErrorResponse", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _create_authentication_serialize( + self, + project_id, + instance_id, + create_authentication_payload, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if project_id is not None: + _path_params["projectId"] = project_id + if instance_id is not None: + _path_params["instanceId"] = instance_id + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if create_authentication_payload is not None: + _body_params = create_authentication_payload + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params["Content-Type"] = _content_type + else: + _default_content_type = self.api_client.select_header_content_type(["application/json"]) + if _default_content_type is not None: + _header_params["Content-Type"] = _default_content_type + + # authentication setting + _auth_settings: List[str] = [] + + return self.api_client.param_serialize( + method="POST", + resource_path="/v1beta/projects/{projectId}/instances/{instanceId}/authentications", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) + @validate_call def create_instance( self, - project_id: Annotated[str, Field(min_length=36, strict=True, max_length=36, description="Project identifier.")], - create_instance_payload: Annotated[CreateInstancePayload, Field(description="Instance configuration options.")], + project_id: Annotated[UUID, Field(description="Project identifier.")], + create_instance_payload: Annotated[CreateInstancePayload, Field(description="Instance configuration options.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> Instance: + """Create an Instance. + + Creates a new STACKIT Git instance as a project resource. + + :param project_id: Project identifier. (required) + :type project_id: UUID + :param create_instance_payload: Instance configuration options. (required) + :type create_instance_payload: CreateInstancePayload + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._create_instance_serialize( + project_id=project_id, + create_instance_payload=create_instance_payload, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "202": "Instance", + "400": "GenericErrorResponse", + "401": None, + "409": "GenericErrorResponse", + "500": "GenericErrorResponse", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def create_instance_with_http_info( + self, + project_id: Annotated[UUID, Field(description="Project identifier.")], + create_instance_payload: Annotated[CreateInstancePayload, Field(description="Instance configuration options.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[Instance]: + """Create an Instance. + + Creates a new STACKIT Git instance as a project resource. + + :param project_id: Project identifier. (required) + :type project_id: UUID + :param create_instance_payload: Instance configuration options. (required) + :type create_instance_payload: CreateInstancePayload + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._create_instance_serialize( + project_id=project_id, + create_instance_payload=create_instance_payload, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "202": "Instance", + "400": "GenericErrorResponse", + "401": None, + "409": "GenericErrorResponse", + "500": "GenericErrorResponse", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def create_instance_without_preload_content( + self, + project_id: Annotated[UUID, Field(description="Project identifier.")], + create_instance_payload: Annotated[CreateInstancePayload, Field(description="Instance configuration options.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Create an Instance. + + Creates a new STACKIT Git instance as a project resource. + + :param project_id: Project identifier. (required) + :type project_id: UUID + :param create_instance_payload: Instance configuration options. (required) + :type create_instance_payload: CreateInstancePayload + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._create_instance_serialize( + project_id=project_id, + create_instance_payload=create_instance_payload, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "202": "Instance", + "400": "GenericErrorResponse", + "401": None, + "409": "GenericErrorResponse", + "500": "GenericErrorResponse", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _create_instance_serialize( + self, + project_id, + create_instance_payload, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if project_id is not None: + _path_params["projectId"] = project_id + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if create_instance_payload is not None: + _body_params = create_instance_payload + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params["Content-Type"] = _content_type + else: + _default_content_type = self.api_client.select_header_content_type(["application/json"]) + if _default_content_type is not None: + _header_params["Content-Type"] = _default_content_type + + # authentication setting + _auth_settings: List[str] = [] + + return self.api_client.param_serialize( + method="POST", + resource_path="/v1beta/projects/{projectId}/instances", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) + + @validate_call + def create_runner( + self, + project_id: Annotated[UUID, Field(description="Project identifier.")], + instance_id: Annotated[UUID, Field(description="Instance identifier.")], + create_runner_payload: Annotated[CreateRunnerPayload, Field(description="Runner configuration options.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> Runner: + """Create the runner associated to this instance. + + Creates the runner associated to this STACKIT Git instance. + + :param project_id: Project identifier. (required) + :type project_id: UUID + :param instance_id: Instance identifier. (required) + :type instance_id: UUID + :param create_runner_payload: Runner configuration options. (required) + :type create_runner_payload: CreateRunnerPayload + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._create_runner_serialize( + project_id=project_id, + instance_id=instance_id, + create_runner_payload=create_runner_payload, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "202": "Runner", + "400": "GenericErrorResponse", + "401": None, + "409": "AlreadyExistsError", + "500": "GenericErrorResponse", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def create_runner_with_http_info( + self, + project_id: Annotated[UUID, Field(description="Project identifier.")], + instance_id: Annotated[UUID, Field(description="Instance identifier.")], + create_runner_payload: Annotated[CreateRunnerPayload, Field(description="Runner configuration options.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[Runner]: + """Create the runner associated to this instance. + + Creates the runner associated to this STACKIT Git instance. + + :param project_id: Project identifier. (required) + :type project_id: UUID + :param instance_id: Instance identifier. (required) + :type instance_id: UUID + :param create_runner_payload: Runner configuration options. (required) + :type create_runner_payload: CreateRunnerPayload + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._create_runner_serialize( + project_id=project_id, + instance_id=instance_id, + create_runner_payload=create_runner_payload, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "202": "Runner", + "400": "GenericErrorResponse", + "401": None, + "409": "AlreadyExistsError", + "500": "GenericErrorResponse", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def create_runner_without_preload_content( + self, + project_id: Annotated[UUID, Field(description="Project identifier.")], + instance_id: Annotated[UUID, Field(description="Instance identifier.")], + create_runner_payload: Annotated[CreateRunnerPayload, Field(description="Runner configuration options.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Create the runner associated to this instance. + + Creates the runner associated to this STACKIT Git instance. + + :param project_id: Project identifier. (required) + :type project_id: UUID + :param instance_id: Instance identifier. (required) + :type instance_id: UUID + :param create_runner_payload: Runner configuration options. (required) + :type create_runner_payload: CreateRunnerPayload + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._create_runner_serialize( + project_id=project_id, + instance_id=instance_id, + create_runner_payload=create_runner_payload, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "202": "Runner", + "400": "GenericErrorResponse", + "401": None, + "409": "AlreadyExistsError", + "500": "GenericErrorResponse", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _create_runner_serialize( + self, + project_id, + instance_id, + create_runner_payload, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if project_id is not None: + _path_params["projectId"] = project_id + if instance_id is not None: + _path_params["instanceId"] = instance_id + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if create_runner_payload is not None: + _body_params = create_runner_payload + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params["Content-Type"] = _content_type + else: + _default_content_type = self.api_client.select_header_content_type(["application/json"]) + if _default_content_type is not None: + _header_params["Content-Type"] = _default_content_type + + # authentication setting + _auth_settings: List[str] = [] + + return self.api_client.param_serialize( + method="POST", + resource_path="/v1beta/projects/{projectId}/instances/{instanceId}/runner", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) + + @validate_call + def delete_authentication( + self, + project_id: Annotated[UUID, Field(description="Project identifier.")], + instance_id: Annotated[UUID, Field(description="Instance identifier.")], + authentication_id: Annotated[UUID, Field(description="Authentication Source identifier.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> None: + """Delete Authentication Source + + Deletes the authentication source associated to this STACKIT Git instance. + + :param project_id: Project identifier. (required) + :type project_id: UUID + :param instance_id: Instance identifier. (required) + :type instance_id: UUID + :param authentication_id: Authentication Source identifier. (required) + :type authentication_id: UUID + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._delete_authentication_serialize( + project_id=project_id, + instance_id=instance_id, + authentication_id=authentication_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "204": None, + "400": "GenericErrorResponse", + "401": "UnauthorizedErrorResponse", + "404": "GenericErrorResponse", + "409": "GenericErrorResponse", + "500": "GenericErrorResponse", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def delete_authentication_with_http_info( + self, + project_id: Annotated[UUID, Field(description="Project identifier.")], + instance_id: Annotated[UUID, Field(description="Instance identifier.")], + authentication_id: Annotated[UUID, Field(description="Authentication Source identifier.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[None]: + """Delete Authentication Source + + Deletes the authentication source associated to this STACKIT Git instance. + + :param project_id: Project identifier. (required) + :type project_id: UUID + :param instance_id: Instance identifier. (required) + :type instance_id: UUID + :param authentication_id: Authentication Source identifier. (required) + :type authentication_id: UUID + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._delete_authentication_serialize( + project_id=project_id, + instance_id=instance_id, + authentication_id=authentication_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "204": None, + "400": "GenericErrorResponse", + "401": "UnauthorizedErrorResponse", + "404": "GenericErrorResponse", + "409": "GenericErrorResponse", + "500": "GenericErrorResponse", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def delete_authentication_without_preload_content( + self, + project_id: Annotated[UUID, Field(description="Project identifier.")], + instance_id: Annotated[UUID, Field(description="Instance identifier.")], + authentication_id: Annotated[UUID, Field(description="Authentication Source identifier.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Delete Authentication Source + + Deletes the authentication source associated to this STACKIT Git instance. + + :param project_id: Project identifier. (required) + :type project_id: UUID + :param instance_id: Instance identifier. (required) + :type instance_id: UUID + :param authentication_id: Authentication Source identifier. (required) + :type authentication_id: UUID + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._delete_authentication_serialize( + project_id=project_id, + instance_id=instance_id, + authentication_id=authentication_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "204": None, + "400": "GenericErrorResponse", + "401": "UnauthorizedErrorResponse", + "404": "GenericErrorResponse", + "409": "GenericErrorResponse", + "500": "GenericErrorResponse", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _delete_authentication_serialize( + self, + project_id, + instance_id, + authentication_id, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if project_id is not None: + _path_params["projectId"] = project_id + if instance_id is not None: + _path_params["instanceId"] = instance_id + if authentication_id is not None: + _path_params["authenticationId"] = authentication_id + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # authentication setting + _auth_settings: List[str] = [] + + return self.api_client.param_serialize( + method="DELETE", + resource_path="/v1beta/projects/{projectId}/instances/{instanceId}/authentications/{authenticationId}", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) + + @validate_call + def delete_instance( + self, + project_id: Annotated[UUID, Field(description="Project identifier.")], + instance_id: Annotated[UUID, Field(description="Instance identifier.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> None: + """Delete Instance. + + Deletes a STACKIT Git instance and destroys all associated data. + + :param project_id: Project identifier. (required) + :type project_id: UUID + :param instance_id: Instance identifier. (required) + :type instance_id: UUID + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._delete_instance_serialize( + project_id=project_id, + instance_id=instance_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "204": None, + "400": "GenericErrorResponse", + "401": None, + "404": "GenericErrorResponse", + "409": "GenericErrorResponse", + "500": "GenericErrorResponse", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def delete_instance_with_http_info( + self, + project_id: Annotated[UUID, Field(description="Project identifier.")], + instance_id: Annotated[UUID, Field(description="Instance identifier.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[None]: + """Delete Instance. + + Deletes a STACKIT Git instance and destroys all associated data. + + :param project_id: Project identifier. (required) + :type project_id: UUID + :param instance_id: Instance identifier. (required) + :type instance_id: UUID + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._delete_instance_serialize( + project_id=project_id, + instance_id=instance_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "204": None, + "400": "GenericErrorResponse", + "401": None, + "404": "GenericErrorResponse", + "409": "GenericErrorResponse", + "500": "GenericErrorResponse", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def delete_instance_without_preload_content( + self, + project_id: Annotated[UUID, Field(description="Project identifier.")], + instance_id: Annotated[UUID, Field(description="Instance identifier.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Delete Instance. + + Deletes a STACKIT Git instance and destroys all associated data. + + :param project_id: Project identifier. (required) + :type project_id: UUID + :param instance_id: Instance identifier. (required) + :type instance_id: UUID + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._delete_instance_serialize( + project_id=project_id, + instance_id=instance_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "204": None, + "400": "GenericErrorResponse", + "401": None, + "404": "GenericErrorResponse", + "409": "GenericErrorResponse", + "500": "GenericErrorResponse", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _delete_instance_serialize( + self, + project_id, + instance_id, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if project_id is not None: + _path_params["projectId"] = project_id + if instance_id is not None: + _path_params["instanceId"] = instance_id + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # authentication setting + _auth_settings: List[str] = [] + + return self.api_client.param_serialize( + method="DELETE", + resource_path="/v1beta/projects/{projectId}/instances/{instanceId}", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) + + @validate_call + def delete_runner( + self, + project_id: Annotated[UUID, Field(description="Project identifier.")], + instance_id: Annotated[UUID, Field(description="Instance identifier.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> None: + """Delete Runner. + + Deletes the runner associated to this STACKIT Git instance and destroys all associated data. + + :param project_id: Project identifier. (required) + :type project_id: UUID + :param instance_id: Instance identifier. (required) + :type instance_id: UUID + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._delete_runner_serialize( + project_id=project_id, + instance_id=instance_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "204": None, + "400": "GenericErrorResponse", + "401": None, + "404": None, + "500": "GenericErrorResponse", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def delete_runner_with_http_info( + self, + project_id: Annotated[UUID, Field(description="Project identifier.")], + instance_id: Annotated[UUID, Field(description="Instance identifier.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[None]: + """Delete Runner. + + Deletes the runner associated to this STACKIT Git instance and destroys all associated data. + + :param project_id: Project identifier. (required) + :type project_id: UUID + :param instance_id: Instance identifier. (required) + :type instance_id: UUID + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._delete_runner_serialize( + project_id=project_id, + instance_id=instance_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "204": None, + "400": "GenericErrorResponse", + "401": None, + "404": None, + "500": "GenericErrorResponse", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def delete_runner_without_preload_content( + self, + project_id: Annotated[UUID, Field(description="Project identifier.")], + instance_id: Annotated[UUID, Field(description="Instance identifier.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Delete Runner. + + Deletes the runner associated to this STACKIT Git instance and destroys all associated data. + + :param project_id: Project identifier. (required) + :type project_id: UUID + :param instance_id: Instance identifier. (required) + :type instance_id: UUID + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._delete_runner_serialize( + project_id=project_id, + instance_id=instance_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "204": None, + "400": "GenericErrorResponse", + "401": None, + "404": None, + "500": "GenericErrorResponse", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _delete_runner_serialize( + self, + project_id, + instance_id, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if project_id is not None: + _path_params["projectId"] = project_id + if instance_id is not None: + _path_params["instanceId"] = instance_id + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # authentication setting + _auth_settings: List[str] = [] + + return self.api_client.param_serialize( + method="DELETE", + resource_path="/v1beta/projects/{projectId}/instances/{instanceId}/runner", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) + + @validate_call + def get_authentication( + self, + project_id: Annotated[UUID, Field(description="Project identifier.")], + instance_id: Annotated[UUID, Field(description="Instance identifier.")], + authentication_id: Annotated[UUID, Field(description="Authentication Source identifier.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> Authentication: + """Get authentication provider + + Get authentication provider + + :param project_id: Project identifier. (required) + :type project_id: UUID + :param instance_id: Instance identifier. (required) + :type instance_id: UUID + :param authentication_id: Authentication Source identifier. (required) + :type authentication_id: UUID + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_authentication_serialize( + project_id=project_id, + instance_id=instance_id, + authentication_id=authentication_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "Authentication", + "400": "BadErrorResponse", + "401": "UnauthorizedErrorResponse", + "500": "InternalServerErrorResponse", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def get_authentication_with_http_info( + self, + project_id: Annotated[UUID, Field(description="Project identifier.")], + instance_id: Annotated[UUID, Field(description="Instance identifier.")], + authentication_id: Annotated[UUID, Field(description="Authentication Source identifier.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[Authentication]: + """Get authentication provider + + Get authentication provider + + :param project_id: Project identifier. (required) + :type project_id: UUID + :param instance_id: Instance identifier. (required) + :type instance_id: UUID + :param authentication_id: Authentication Source identifier. (required) + :type authentication_id: UUID + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_authentication_serialize( + project_id=project_id, + instance_id=instance_id, + authentication_id=authentication_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "Authentication", + "400": "BadErrorResponse", + "401": "UnauthorizedErrorResponse", + "500": "InternalServerErrorResponse", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def get_authentication_without_preload_content( + self, + project_id: Annotated[UUID, Field(description="Project identifier.")], + instance_id: Annotated[UUID, Field(description="Instance identifier.")], + authentication_id: Annotated[UUID, Field(description="Authentication Source identifier.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Get authentication provider + + Get authentication provider + + :param project_id: Project identifier. (required) + :type project_id: UUID + :param instance_id: Instance identifier. (required) + :type instance_id: UUID + :param authentication_id: Authentication Source identifier. (required) + :type authentication_id: UUID + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_authentication_serialize( + project_id=project_id, + instance_id=instance_id, + authentication_id=authentication_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "Authentication", + "400": "BadErrorResponse", + "401": "UnauthorizedErrorResponse", + "500": "InternalServerErrorResponse", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _get_authentication_serialize( + self, + project_id, + instance_id, + authentication_id, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if project_id is not None: + _path_params["projectId"] = project_id + if instance_id is not None: + _path_params["instanceId"] = instance_id + if authentication_id is not None: + _path_params["authenticationId"] = authentication_id + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # authentication setting + _auth_settings: List[str] = [] + + return self.api_client.param_serialize( + method="GET", + resource_path="/v1beta/projects/{projectId}/instances/{instanceId}/authentications/{authenticationId}", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) + + @validate_call + def get_instance( + self, + project_id: Annotated[UUID, Field(description="Project identifier.")], + instance_id: Annotated[UUID, Field(description="Instance identifier.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> Instance: + """Get Instance information. + + Retrieves information about a STACKIT Git instance. + + :param project_id: Project identifier. (required) + :type project_id: UUID + :param instance_id: Instance identifier. (required) + :type instance_id: UUID + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_instance_serialize( + project_id=project_id, + instance_id=instance_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "Instance", + "400": "GenericErrorResponse", + "401": None, + "404": "GenericErrorResponse", + "500": "GenericErrorResponse", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def get_instance_with_http_info( + self, + project_id: Annotated[UUID, Field(description="Project identifier.")], + instance_id: Annotated[UUID, Field(description="Instance identifier.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[Instance]: + """Get Instance information. + + Retrieves information about a STACKIT Git instance. + + :param project_id: Project identifier. (required) + :type project_id: UUID + :param instance_id: Instance identifier. (required) + :type instance_id: UUID + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_instance_serialize( + project_id=project_id, + instance_id=instance_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "Instance", + "400": "GenericErrorResponse", + "401": None, + "404": "GenericErrorResponse", + "500": "GenericErrorResponse", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def get_instance_without_preload_content( + self, + project_id: Annotated[UUID, Field(description="Project identifier.")], + instance_id: Annotated[UUID, Field(description="Instance identifier.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Get Instance information. + + Retrieves information about a STACKIT Git instance. + + :param project_id: Project identifier. (required) + :type project_id: UUID + :param instance_id: Instance identifier. (required) + :type instance_id: UUID + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_instance_serialize( + project_id=project_id, + instance_id=instance_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "Instance", + "400": "GenericErrorResponse", + "401": None, + "404": "GenericErrorResponse", + "500": "GenericErrorResponse", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _get_instance_serialize( + self, + project_id, + instance_id, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if project_id is not None: + _path_params["projectId"] = project_id + if instance_id is not None: + _path_params["instanceId"] = instance_id + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # authentication setting + _auth_settings: List[str] = [] + + return self.api_client.param_serialize( + method="GET", + resource_path="/v1beta/projects/{projectId}/instances/{instanceId}", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) + + @validate_call + def get_runner( + self, + project_id: Annotated[UUID, Field(description="Project identifier.")], + instance_id: Annotated[UUID, Field(description="Instance identifier.")], _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -62,15 +2183,15 @@ def create_instance( _content_type: Optional[StrictStr] = None, _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, - ) -> Instance: - """Create an Instance. + ) -> Runner: + """Get Runner information. - Creates a new STACKIT Git instance as a project resource. + Retrieves information about a runner in a STACKIT Git instance. :param project_id: Project identifier. (required) - :type project_id: str - :param create_instance_payload: Instance configuration options. (required) - :type create_instance_payload: CreateInstancePayload + :type project_id: UUID + :param instance_id: Instance identifier. (required) + :type instance_id: UUID :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of @@ -93,9 +2214,9 @@ def create_instance( :return: Returns the result object. """ # noqa: E501 - _param = self._create_instance_serialize( + _param = self._get_runner_serialize( project_id=project_id, - create_instance_payload=create_instance_payload, + instance_id=instance_id, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -103,10 +2224,10 @@ def create_instance( ) _response_types_map: Dict[str, Optional[str]] = { - "201": "Instance", + "200": "Runner", "400": "GenericErrorResponse", - "401": "UnauthorizedResponse", - "409": "GenericErrorResponse", + "401": None, + "404": None, "500": "GenericErrorResponse", } response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) @@ -117,10 +2238,10 @@ def create_instance( ).data @validate_call - def create_instance_with_http_info( + def get_runner_with_http_info( self, - project_id: Annotated[str, Field(min_length=36, strict=True, max_length=36, description="Project identifier.")], - create_instance_payload: Annotated[CreateInstancePayload, Field(description="Instance configuration options.")], + project_id: Annotated[UUID, Field(description="Project identifier.")], + instance_id: Annotated[UUID, Field(description="Instance identifier.")], _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -130,15 +2251,15 @@ def create_instance_with_http_info( _content_type: Optional[StrictStr] = None, _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, - ) -> ApiResponse[Instance]: - """Create an Instance. + ) -> ApiResponse[Runner]: + """Get Runner information. - Creates a new STACKIT Git instance as a project resource. + Retrieves information about a runner in a STACKIT Git instance. :param project_id: Project identifier. (required) - :type project_id: str - :param create_instance_payload: Instance configuration options. (required) - :type create_instance_payload: CreateInstancePayload + :type project_id: UUID + :param instance_id: Instance identifier. (required) + :type instance_id: UUID :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of @@ -161,9 +2282,9 @@ def create_instance_with_http_info( :return: Returns the result object. """ # noqa: E501 - _param = self._create_instance_serialize( + _param = self._get_runner_serialize( project_id=project_id, - create_instance_payload=create_instance_payload, + instance_id=instance_id, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -171,10 +2292,10 @@ def create_instance_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { - "201": "Instance", + "200": "Runner", "400": "GenericErrorResponse", - "401": "UnauthorizedResponse", - "409": "GenericErrorResponse", + "401": None, + "404": None, "500": "GenericErrorResponse", } response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) @@ -185,10 +2306,10 @@ def create_instance_with_http_info( ) @validate_call - def create_instance_without_preload_content( + def get_runner_without_preload_content( self, - project_id: Annotated[str, Field(min_length=36, strict=True, max_length=36, description="Project identifier.")], - create_instance_payload: Annotated[CreateInstancePayload, Field(description="Instance configuration options.")], + project_id: Annotated[UUID, Field(description="Project identifier.")], + instance_id: Annotated[UUID, Field(description="Instance identifier.")], _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -199,14 +2320,14 @@ def create_instance_without_preload_content( _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, ) -> RESTResponseType: - """Create an Instance. + """Get Runner information. - Creates a new STACKIT Git instance as a project resource. + Retrieves information about a runner in a STACKIT Git instance. :param project_id: Project identifier. (required) - :type project_id: str - :param create_instance_payload: Instance configuration options. (required) - :type create_instance_payload: CreateInstancePayload + :type project_id: UUID + :param instance_id: Instance identifier. (required) + :type instance_id: UUID :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of @@ -229,9 +2350,9 @@ def create_instance_without_preload_content( :return: Returns the result object. """ # noqa: E501 - _param = self._create_instance_serialize( + _param = self._get_runner_serialize( project_id=project_id, - create_instance_payload=create_instance_payload, + instance_id=instance_id, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -239,19 +2360,19 @@ def create_instance_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { - "201": "Instance", + "200": "Runner", "400": "GenericErrorResponse", - "401": "UnauthorizedResponse", - "409": "GenericErrorResponse", + "401": None, + "404": None, "500": "GenericErrorResponse", } response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) return response_data.response - def _create_instance_serialize( + def _get_runner_serialize( self, project_id, - create_instance_payload, + instance_id, _request_auth, _content_type, _headers, @@ -272,31 +2393,23 @@ def _create_instance_serialize( # process the path parameters if project_id is not None: _path_params["projectId"] = project_id + if instance_id is not None: + _path_params["instanceId"] = instance_id # process the query parameters # process the header parameters # process the form parameters # process the body parameter - if create_instance_payload is not None: - _body_params = create_instance_payload # set the HTTP header `Accept` if "Accept" not in _header_params: _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) - # set the HTTP header `Content-Type` - if _content_type: - _header_params["Content-Type"] = _content_type - else: - _default_content_type = self.api_client.select_header_content_type(["application/json"]) - if _default_content_type is not None: - _header_params["Content-Type"] = _default_content_type - # authentication setting _auth_settings: List[str] = [] return self.api_client.param_serialize( - method="POST", - resource_path="/v1beta/projects/{projectId}/instances", + method="GET", + resource_path="/v1beta/projects/{projectId}/instances/{instanceId}/runner", path_params=_path_params, query_params=_query_params, header_params=_header_params, @@ -310,12 +2423,10 @@ def _create_instance_serialize( ) @validate_call - def delete_instance( + def list_authentication( self, - project_id: Annotated[str, Field(min_length=36, strict=True, max_length=36, description="Project identifier.")], - instance_id: Annotated[ - str, Field(min_length=36, strict=True, max_length=36, description="Instance identifier.") - ], + project_id: Annotated[UUID, Field(description="Project identifier.")], + instance_id: Annotated[UUID, Field(description="Instance identifier.")], _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -325,15 +2436,15 @@ def delete_instance( _content_type: Optional[StrictStr] = None, _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, - ) -> None: - """Delete Instance. + ) -> AuthenticationList: + """List authentication sources - Deletes a STACKIT Git instance and destroys all associated data. + Lists all authentication sources belonging to a specific instance :param project_id: Project identifier. (required) - :type project_id: str + :type project_id: UUID :param instance_id: Instance identifier. (required) - :type instance_id: str + :type instance_id: UUID :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of @@ -356,7 +2467,7 @@ def delete_instance( :return: Returns the result object. """ # noqa: E501 - _param = self._delete_instance_serialize( + _param = self._list_authentication_serialize( project_id=project_id, instance_id=instance_id, _request_auth=_request_auth, @@ -366,12 +2477,10 @@ def delete_instance( ) _response_types_map: Dict[str, Optional[str]] = { - "202": None, - "400": "GenericErrorResponse", - "401": "UnauthorizedResponse", - "404": None, - "409": None, - "500": "GenericErrorResponse", + "200": "AuthenticationList", + "400": "BadErrorResponse", + "401": "UnauthorizedErrorResponse", + "500": "InternalServerErrorResponse", } response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) response_data.read() @@ -381,12 +2490,10 @@ def delete_instance( ).data @validate_call - def delete_instance_with_http_info( + def list_authentication_with_http_info( self, - project_id: Annotated[str, Field(min_length=36, strict=True, max_length=36, description="Project identifier.")], - instance_id: Annotated[ - str, Field(min_length=36, strict=True, max_length=36, description="Instance identifier.") - ], + project_id: Annotated[UUID, Field(description="Project identifier.")], + instance_id: Annotated[UUID, Field(description="Instance identifier.")], _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -396,15 +2503,15 @@ def delete_instance_with_http_info( _content_type: Optional[StrictStr] = None, _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, - ) -> ApiResponse[None]: - """Delete Instance. + ) -> ApiResponse[AuthenticationList]: + """List authentication sources - Deletes a STACKIT Git instance and destroys all associated data. + Lists all authentication sources belonging to a specific instance :param project_id: Project identifier. (required) - :type project_id: str + :type project_id: UUID :param instance_id: Instance identifier. (required) - :type instance_id: str + :type instance_id: UUID :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of @@ -427,7 +2534,7 @@ def delete_instance_with_http_info( :return: Returns the result object. """ # noqa: E501 - _param = self._delete_instance_serialize( + _param = self._list_authentication_serialize( project_id=project_id, instance_id=instance_id, _request_auth=_request_auth, @@ -437,12 +2544,10 @@ def delete_instance_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { - "202": None, - "400": "GenericErrorResponse", - "401": "UnauthorizedResponse", - "404": None, - "409": None, - "500": "GenericErrorResponse", + "200": "AuthenticationList", + "400": "BadErrorResponse", + "401": "UnauthorizedErrorResponse", + "500": "InternalServerErrorResponse", } response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) response_data.read() @@ -452,12 +2557,10 @@ def delete_instance_with_http_info( ) @validate_call - def delete_instance_without_preload_content( + def list_authentication_without_preload_content( self, - project_id: Annotated[str, Field(min_length=36, strict=True, max_length=36, description="Project identifier.")], - instance_id: Annotated[ - str, Field(min_length=36, strict=True, max_length=36, description="Instance identifier.") - ], + project_id: Annotated[UUID, Field(description="Project identifier.")], + instance_id: Annotated[UUID, Field(description="Instance identifier.")], _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -468,14 +2571,14 @@ def delete_instance_without_preload_content( _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, ) -> RESTResponseType: - """Delete Instance. + """List authentication sources - Deletes a STACKIT Git instance and destroys all associated data. + Lists all authentication sources belonging to a specific instance :param project_id: Project identifier. (required) - :type project_id: str + :type project_id: UUID :param instance_id: Instance identifier. (required) - :type instance_id: str + :type instance_id: UUID :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of @@ -498,7 +2601,7 @@ def delete_instance_without_preload_content( :return: Returns the result object. """ # noqa: E501 - _param = self._delete_instance_serialize( + _param = self._list_authentication_serialize( project_id=project_id, instance_id=instance_id, _request_auth=_request_auth, @@ -508,17 +2611,15 @@ def delete_instance_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { - "202": None, - "400": "GenericErrorResponse", - "401": "UnauthorizedResponse", - "404": None, - "409": None, - "500": "GenericErrorResponse", + "200": "AuthenticationList", + "400": "BadErrorResponse", + "401": "UnauthorizedErrorResponse", + "500": "InternalServerErrorResponse", } response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) return response_data.response - def _delete_instance_serialize( + def _list_authentication_serialize( self, project_id, instance_id, @@ -557,8 +2658,8 @@ def _delete_instance_serialize( _auth_settings: List[str] = [] return self.api_client.param_serialize( - method="DELETE", - resource_path="/v1beta/projects/{projectId}/instances/{instanceId}", + method="GET", + resource_path="/v1beta/projects/{projectId}/instances/{instanceId}/authentications", path_params=_path_params, query_params=_query_params, header_params=_header_params, @@ -572,12 +2673,9 @@ def _delete_instance_serialize( ) @validate_call - def get_instance( + def list_flavors( self, - project_id: Annotated[str, Field(min_length=36, strict=True, max_length=36, description="Project identifier.")], - instance_id: Annotated[ - str, Field(min_length=36, strict=True, max_length=36, description="Instance identifier.") - ], + project_id: Annotated[UUID, Field(description="Project identifier.")], _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -587,15 +2685,13 @@ def get_instance( _content_type: Optional[StrictStr] = None, _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, - ) -> Instance: - """Get Instance information. + ) -> ListFlavors: + """Returns the details for the given STACKIT Git flavors. - Retrieves information about a STACKIT Git instance. + Provides detailed information about possible Git Flavors. :param project_id: Project identifier. (required) - :type project_id: str - :param instance_id: Instance identifier. (required) - :type instance_id: str + :type project_id: UUID :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of @@ -618,9 +2714,8 @@ def get_instance( :return: Returns the result object. """ # noqa: E501 - _param = self._get_instance_serialize( + _param = self._list_flavors_serialize( project_id=project_id, - instance_id=instance_id, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -628,9 +2723,9 @@ def get_instance( ) _response_types_map: Dict[str, Optional[str]] = { - "200": "Instance", + "200": "ListFlavors", "400": "GenericErrorResponse", - "401": "UnauthorizedResponse", + "401": None, "404": None, "500": "GenericErrorResponse", } @@ -642,12 +2737,9 @@ def get_instance( ).data @validate_call - def get_instance_with_http_info( + def list_flavors_with_http_info( self, - project_id: Annotated[str, Field(min_length=36, strict=True, max_length=36, description="Project identifier.")], - instance_id: Annotated[ - str, Field(min_length=36, strict=True, max_length=36, description="Instance identifier.") - ], + project_id: Annotated[UUID, Field(description="Project identifier.")], _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -657,15 +2749,13 @@ def get_instance_with_http_info( _content_type: Optional[StrictStr] = None, _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, - ) -> ApiResponse[Instance]: - """Get Instance information. + ) -> ApiResponse[ListFlavors]: + """Returns the details for the given STACKIT Git flavors. - Retrieves information about a STACKIT Git instance. + Provides detailed information about possible Git Flavors. :param project_id: Project identifier. (required) - :type project_id: str - :param instance_id: Instance identifier. (required) - :type instance_id: str + :type project_id: UUID :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of @@ -688,9 +2778,8 @@ def get_instance_with_http_info( :return: Returns the result object. """ # noqa: E501 - _param = self._get_instance_serialize( + _param = self._list_flavors_serialize( project_id=project_id, - instance_id=instance_id, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -698,9 +2787,9 @@ def get_instance_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { - "200": "Instance", + "200": "ListFlavors", "400": "GenericErrorResponse", - "401": "UnauthorizedResponse", + "401": None, "404": None, "500": "GenericErrorResponse", } @@ -712,12 +2801,9 @@ def get_instance_with_http_info( ) @validate_call - def get_instance_without_preload_content( + def list_flavors_without_preload_content( self, - project_id: Annotated[str, Field(min_length=36, strict=True, max_length=36, description="Project identifier.")], - instance_id: Annotated[ - str, Field(min_length=36, strict=True, max_length=36, description="Instance identifier.") - ], + project_id: Annotated[UUID, Field(description="Project identifier.")], _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -728,14 +2814,12 @@ def get_instance_without_preload_content( _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, ) -> RESTResponseType: - """Get Instance information. + """Returns the details for the given STACKIT Git flavors. - Retrieves information about a STACKIT Git instance. + Provides detailed information about possible Git Flavors. :param project_id: Project identifier. (required) - :type project_id: str - :param instance_id: Instance identifier. (required) - :type instance_id: str + :type project_id: UUID :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of @@ -758,9 +2842,8 @@ def get_instance_without_preload_content( :return: Returns the result object. """ # noqa: E501 - _param = self._get_instance_serialize( + _param = self._list_flavors_serialize( project_id=project_id, - instance_id=instance_id, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -768,19 +2851,18 @@ def get_instance_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { - "200": "Instance", + "200": "ListFlavors", "400": "GenericErrorResponse", - "401": "UnauthorizedResponse", + "401": None, "404": None, "500": "GenericErrorResponse", } response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) return response_data.response - def _get_instance_serialize( + def _list_flavors_serialize( self, project_id, - instance_id, _request_auth, _content_type, _headers, @@ -801,8 +2883,6 @@ def _get_instance_serialize( # process the path parameters if project_id is not None: _path_params["projectId"] = project_id - if instance_id is not None: - _path_params["instanceId"] = instance_id # process the query parameters # process the header parameters # process the form parameters @@ -817,7 +2897,7 @@ def _get_instance_serialize( return self.api_client.param_serialize( method="GET", - resource_path="/v1beta/projects/{projectId}/instances/{instanceId}", + resource_path="/v1beta/projects/{projectId}/flavors", path_params=_path_params, query_params=_query_params, header_params=_header_params, @@ -831,9 +2911,9 @@ def _get_instance_serialize( ) @validate_call - def list_flavors( + def list_instances( self, - project_id: Annotated[str, Field(min_length=36, strict=True, max_length=36, description="Project identifier.")], + project_id: Annotated[UUID, Field(description="Project identifier.")], _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -843,13 +2923,13 @@ def list_flavors( _content_type: Optional[StrictStr] = None, _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, - ) -> ListFlavors: - """Returns the details for the given STACKIT Git flavors. + ) -> ListInstances: + """List Instances. - Provides detailed information about possible Git Flavors. + Lists all STACKIT Git instances within a project. :param project_id: Project identifier. (required) - :type project_id: str + :type project_id: UUID :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of @@ -872,7 +2952,7 @@ def list_flavors( :return: Returns the result object. """ # noqa: E501 - _param = self._list_flavors_serialize( + _param = self._list_instances_serialize( project_id=project_id, _request_auth=_request_auth, _content_type=_content_type, @@ -881,10 +2961,9 @@ def list_flavors( ) _response_types_map: Dict[str, Optional[str]] = { - "200": "ListFlavors", + "200": "ListInstances", "400": "GenericErrorResponse", - "401": "UnauthorizedResponse", - "404": None, + "401": None, "500": "GenericErrorResponse", } response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) @@ -895,9 +2974,9 @@ def list_flavors( ).data @validate_call - def list_flavors_with_http_info( + def list_instances_with_http_info( self, - project_id: Annotated[str, Field(min_length=36, strict=True, max_length=36, description="Project identifier.")], + project_id: Annotated[UUID, Field(description="Project identifier.")], _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -907,13 +2986,13 @@ def list_flavors_with_http_info( _content_type: Optional[StrictStr] = None, _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, - ) -> ApiResponse[ListFlavors]: - """Returns the details for the given STACKIT Git flavors. + ) -> ApiResponse[ListInstances]: + """List Instances. - Provides detailed information about possible Git Flavors. + Lists all STACKIT Git instances within a project. :param project_id: Project identifier. (required) - :type project_id: str + :type project_id: UUID :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of @@ -936,7 +3015,7 @@ def list_flavors_with_http_info( :return: Returns the result object. """ # noqa: E501 - _param = self._list_flavors_serialize( + _param = self._list_instances_serialize( project_id=project_id, _request_auth=_request_auth, _content_type=_content_type, @@ -945,10 +3024,9 @@ def list_flavors_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { - "200": "ListFlavors", + "200": "ListInstances", "400": "GenericErrorResponse", - "401": "UnauthorizedResponse", - "404": None, + "401": None, "500": "GenericErrorResponse", } response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) @@ -959,9 +3037,9 @@ def list_flavors_with_http_info( ) @validate_call - def list_flavors_without_preload_content( + def list_instances_without_preload_content( self, - project_id: Annotated[str, Field(min_length=36, strict=True, max_length=36, description="Project identifier.")], + project_id: Annotated[UUID, Field(description="Project identifier.")], _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -972,12 +3050,12 @@ def list_flavors_without_preload_content( _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, ) -> RESTResponseType: - """Returns the details for the given STACKIT Git flavors. + """List Instances. - Provides detailed information about possible Git Flavors. + Lists all STACKIT Git instances within a project. :param project_id: Project identifier. (required) - :type project_id: str + :type project_id: UUID :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of @@ -1000,7 +3078,7 @@ def list_flavors_without_preload_content( :return: Returns the result object. """ # noqa: E501 - _param = self._list_flavors_serialize( + _param = self._list_instances_serialize( project_id=project_id, _request_auth=_request_auth, _content_type=_content_type, @@ -1009,16 +3087,15 @@ def list_flavors_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { - "200": "ListFlavors", + "200": "ListInstances", "400": "GenericErrorResponse", - "401": "UnauthorizedResponse", - "404": None, + "401": None, "500": "GenericErrorResponse", } response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) return response_data.response - def _list_flavors_serialize( + def _list_instances_serialize( self, project_id, _request_auth, @@ -1055,7 +3132,7 @@ def _list_flavors_serialize( return self.api_client.param_serialize( method="GET", - resource_path="/v1beta/projects/{projectId}/flavors", + resource_path="/v1beta/projects/{projectId}/instances", path_params=_path_params, query_params=_query_params, header_params=_header_params, @@ -1069,9 +3146,9 @@ def _list_flavors_serialize( ) @validate_call - def list_instances( + def list_runner_runtimes( self, - project_id: Annotated[str, Field(min_length=36, strict=True, max_length=36, description="Project identifier.")], + project_id: Annotated[UUID, Field(description="Project identifier.")], _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -1081,13 +3158,13 @@ def list_instances( _content_type: Optional[StrictStr] = None, _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, - ) -> ListInstances: - """List Instances. + ) -> RunnerRuntimeList: + """list_runner_runtimes - Lists all STACKIT Git instances within a project. + A list of runner runtimes that are available to be enabled for the project. :param project_id: Project identifier. (required) - :type project_id: str + :type project_id: UUID :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of @@ -1110,7 +3187,7 @@ def list_instances( :return: Returns the result object. """ # noqa: E501 - _param = self._list_instances_serialize( + _param = self._list_runner_runtimes_serialize( project_id=project_id, _request_auth=_request_auth, _content_type=_content_type, @@ -1119,9 +3196,10 @@ def list_instances( ) _response_types_map: Dict[str, Optional[str]] = { - "200": "ListInstances", + "200": "RunnerRuntimeList", "400": "GenericErrorResponse", - "401": "UnauthorizedResponse", + "401": None, + "404": "GenericErrorResponse", "500": "GenericErrorResponse", } response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) @@ -1132,9 +3210,9 @@ def list_instances( ).data @validate_call - def list_instances_with_http_info( + def list_runner_runtimes_with_http_info( self, - project_id: Annotated[str, Field(min_length=36, strict=True, max_length=36, description="Project identifier.")], + project_id: Annotated[UUID, Field(description="Project identifier.")], _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -1144,13 +3222,13 @@ def list_instances_with_http_info( _content_type: Optional[StrictStr] = None, _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, - ) -> ApiResponse[ListInstances]: - """List Instances. + ) -> ApiResponse[RunnerRuntimeList]: + """list_runner_runtimes - Lists all STACKIT Git instances within a project. + A list of runner runtimes that are available to be enabled for the project. :param project_id: Project identifier. (required) - :type project_id: str + :type project_id: UUID :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of @@ -1173,7 +3251,7 @@ def list_instances_with_http_info( :return: Returns the result object. """ # noqa: E501 - _param = self._list_instances_serialize( + _param = self._list_runner_runtimes_serialize( project_id=project_id, _request_auth=_request_auth, _content_type=_content_type, @@ -1182,9 +3260,10 @@ def list_instances_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { - "200": "ListInstances", + "200": "RunnerRuntimeList", "400": "GenericErrorResponse", - "401": "UnauthorizedResponse", + "401": None, + "404": "GenericErrorResponse", "500": "GenericErrorResponse", } response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) @@ -1195,9 +3274,9 @@ def list_instances_with_http_info( ) @validate_call - def list_instances_without_preload_content( + def list_runner_runtimes_without_preload_content( self, - project_id: Annotated[str, Field(min_length=36, strict=True, max_length=36, description="Project identifier.")], + project_id: Annotated[UUID, Field(description="Project identifier.")], _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -1208,12 +3287,12 @@ def list_instances_without_preload_content( _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, ) -> RESTResponseType: - """List Instances. + """list_runner_runtimes - Lists all STACKIT Git instances within a project. + A list of runner runtimes that are available to be enabled for the project. :param project_id: Project identifier. (required) - :type project_id: str + :type project_id: UUID :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of @@ -1236,7 +3315,7 @@ def list_instances_without_preload_content( :return: Returns the result object. """ # noqa: E501 - _param = self._list_instances_serialize( + _param = self._list_runner_runtimes_serialize( project_id=project_id, _request_auth=_request_auth, _content_type=_content_type, @@ -1245,15 +3324,16 @@ def list_instances_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { - "200": "ListInstances", + "200": "RunnerRuntimeList", "400": "GenericErrorResponse", - "401": "UnauthorizedResponse", + "401": None, + "404": "GenericErrorResponse", "500": "GenericErrorResponse", } response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) return response_data.response - def _list_instances_serialize( + def _list_runner_runtimes_serialize( self, project_id, _request_auth, @@ -1290,7 +3370,7 @@ def _list_instances_serialize( return self.api_client.param_serialize( method="GET", - resource_path="/v1beta/projects/{projectId}/instances", + resource_path="/v1beta/projects/{projectId}/runner-runtimes", path_params=_path_params, query_params=_query_params, header_params=_header_params, @@ -1304,9 +3384,14 @@ def _list_instances_serialize( ) @validate_call - def list_runner_labels( + def patch_authentication( self, - project_id: Annotated[str, Field(min_length=36, strict=True, max_length=36, description="Project identifier.")], + project_id: Annotated[UUID, Field(description="Project identifier.")], + instance_id: Annotated[UUID, Field(description="Instance identifier.")], + authentication_id: Annotated[UUID, Field(description="Authentication Source identifier.")], + patch_authentication_payload: Annotated[ + PatchAuthenticationPayload, Field(description="Authentication Definition configuration data.") + ], _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -1316,13 +3401,19 @@ def list_runner_labels( _content_type: Optional[StrictStr] = None, _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, - ) -> ListRunnerLabels: - """Returns the details for the given STACKIT Git RunnerLabels. + ) -> Authentication: + """Patch Authentication. - Type of runners we can use for running jobs. + Patches the Authentication Provider. :param project_id: Project identifier. (required) - :type project_id: str + :type project_id: UUID + :param instance_id: Instance identifier. (required) + :type instance_id: UUID + :param authentication_id: Authentication Source identifier. (required) + :type authentication_id: UUID + :param patch_authentication_payload: Authentication Definition configuration data. (required) + :type patch_authentication_payload: PatchAuthenticationPayload :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of @@ -1345,8 +3436,11 @@ def list_runner_labels( :return: Returns the result object. """ # noqa: E501 - _param = self._list_runner_labels_serialize( + _param = self._patch_authentication_serialize( project_id=project_id, + instance_id=instance_id, + authentication_id=authentication_id, + patch_authentication_payload=patch_authentication_payload, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -1354,11 +3448,11 @@ def list_runner_labels( ) _response_types_map: Dict[str, Optional[str]] = { - "200": "ListRunnerLabels", - "400": "GenericErrorResponse", - "401": "UnauthorizedResponse", - "404": None, - "500": "GenericErrorResponse", + "202": "Authentication", + "400": "BadErrorResponse", + "401": "UnauthorizedErrorResponse", + "404": "NotFoundErrorResponse", + "500": "InternalServerErrorResponse", } response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) response_data.read() @@ -1368,9 +3462,14 @@ def list_runner_labels( ).data @validate_call - def list_runner_labels_with_http_info( + def patch_authentication_with_http_info( self, - project_id: Annotated[str, Field(min_length=36, strict=True, max_length=36, description="Project identifier.")], + project_id: Annotated[UUID, Field(description="Project identifier.")], + instance_id: Annotated[UUID, Field(description="Instance identifier.")], + authentication_id: Annotated[UUID, Field(description="Authentication Source identifier.")], + patch_authentication_payload: Annotated[ + PatchAuthenticationPayload, Field(description="Authentication Definition configuration data.") + ], _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -1380,13 +3479,19 @@ def list_runner_labels_with_http_info( _content_type: Optional[StrictStr] = None, _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, - ) -> ApiResponse[ListRunnerLabels]: - """Returns the details for the given STACKIT Git RunnerLabels. + ) -> ApiResponse[Authentication]: + """Patch Authentication. - Type of runners we can use for running jobs. + Patches the Authentication Provider. :param project_id: Project identifier. (required) - :type project_id: str + :type project_id: UUID + :param instance_id: Instance identifier. (required) + :type instance_id: UUID + :param authentication_id: Authentication Source identifier. (required) + :type authentication_id: UUID + :param patch_authentication_payload: Authentication Definition configuration data. (required) + :type patch_authentication_payload: PatchAuthenticationPayload :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of @@ -1409,8 +3514,11 @@ def list_runner_labels_with_http_info( :return: Returns the result object. """ # noqa: E501 - _param = self._list_runner_labels_serialize( + _param = self._patch_authentication_serialize( project_id=project_id, + instance_id=instance_id, + authentication_id=authentication_id, + patch_authentication_payload=patch_authentication_payload, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -1418,11 +3526,11 @@ def list_runner_labels_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { - "200": "ListRunnerLabels", - "400": "GenericErrorResponse", - "401": "UnauthorizedResponse", - "404": None, - "500": "GenericErrorResponse", + "202": "Authentication", + "400": "BadErrorResponse", + "401": "UnauthorizedErrorResponse", + "404": "NotFoundErrorResponse", + "500": "InternalServerErrorResponse", } response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) response_data.read() @@ -1432,9 +3540,14 @@ def list_runner_labels_with_http_info( ) @validate_call - def list_runner_labels_without_preload_content( + def patch_authentication_without_preload_content( self, - project_id: Annotated[str, Field(min_length=36, strict=True, max_length=36, description="Project identifier.")], + project_id: Annotated[UUID, Field(description="Project identifier.")], + instance_id: Annotated[UUID, Field(description="Instance identifier.")], + authentication_id: Annotated[UUID, Field(description="Authentication Source identifier.")], + patch_authentication_payload: Annotated[ + PatchAuthenticationPayload, Field(description="Authentication Definition configuration data.") + ], _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -1445,12 +3558,18 @@ def list_runner_labels_without_preload_content( _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, ) -> RESTResponseType: - """Returns the details for the given STACKIT Git RunnerLabels. + """Patch Authentication. - Type of runners we can use for running jobs. + Patches the Authentication Provider. :param project_id: Project identifier. (required) - :type project_id: str + :type project_id: UUID + :param instance_id: Instance identifier. (required) + :type instance_id: UUID + :param authentication_id: Authentication Source identifier. (required) + :type authentication_id: UUID + :param patch_authentication_payload: Authentication Definition configuration data. (required) + :type patch_authentication_payload: PatchAuthenticationPayload :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of @@ -1473,8 +3592,11 @@ def list_runner_labels_without_preload_content( :return: Returns the result object. """ # noqa: E501 - _param = self._list_runner_labels_serialize( + _param = self._patch_authentication_serialize( project_id=project_id, + instance_id=instance_id, + authentication_id=authentication_id, + patch_authentication_payload=patch_authentication_payload, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -1482,18 +3604,21 @@ def list_runner_labels_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { - "200": "ListRunnerLabels", - "400": "GenericErrorResponse", - "401": "UnauthorizedResponse", - "404": None, - "500": "GenericErrorResponse", + "202": "Authentication", + "400": "BadErrorResponse", + "401": "UnauthorizedErrorResponse", + "404": "NotFoundErrorResponse", + "500": "InternalServerErrorResponse", } response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) return response_data.response - def _list_runner_labels_serialize( + def _patch_authentication_serialize( self, project_id, + instance_id, + authentication_id, + patch_authentication_payload, _request_auth, _content_type, _headers, @@ -1514,21 +3639,35 @@ def _list_runner_labels_serialize( # process the path parameters if project_id is not None: _path_params["projectId"] = project_id + if instance_id is not None: + _path_params["instanceId"] = instance_id + if authentication_id is not None: + _path_params["authenticationId"] = authentication_id # process the query parameters # process the header parameters # process the form parameters # process the body parameter + if patch_authentication_payload is not None: + _body_params = patch_authentication_payload # set the HTTP header `Accept` if "Accept" not in _header_params: _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + # set the HTTP header `Content-Type` + if _content_type: + _header_params["Content-Type"] = _content_type + else: + _default_content_type = self.api_client.select_header_content_type(["application/json"]) + if _default_content_type is not None: + _header_params["Content-Type"] = _default_content_type + # authentication setting _auth_settings: List[str] = [] return self.api_client.param_serialize( - method="GET", - resource_path="/v1beta/projects/{projectId}/runner-labels", + method="PATCH", + resource_path="/v1beta/projects/{projectId}/instances/{instanceId}/authentications/{authenticationId}", path_params=_path_params, query_params=_query_params, header_params=_header_params, @@ -1544,10 +3683,8 @@ def _list_runner_labels_serialize( @validate_call def patch_instance( self, - project_id: Annotated[str, Field(min_length=36, strict=True, max_length=36, description="Project identifier.")], - instance_id: Annotated[ - str, Field(min_length=36, strict=True, max_length=36, description="Instance identifier.") - ], + project_id: Annotated[UUID, Field(description="Project identifier.")], + instance_id: Annotated[UUID, Field(description="Instance identifier.")], patch_instance_payload: PatchInstancePayload, _request_timeout: Union[ None, @@ -1564,9 +3701,9 @@ def patch_instance( Patches the Instance. :param project_id: Project identifier. (required) - :type project_id: str + :type project_id: UUID :param instance_id: Instance identifier. (required) - :type instance_id: str + :type instance_id: UUID :param patch_instance_payload: (required) :type patch_instance_payload: PatchInstancePayload :param _request_timeout: timeout setting for this request. If one @@ -1605,7 +3742,7 @@ def patch_instance( "200": "Instance", "202": None, "400": "GenericErrorResponse", - "401": "UnauthorizedResponse", + "401": None, "404": None, "409": None, "500": "GenericErrorResponse", @@ -1620,10 +3757,8 @@ def patch_instance( @validate_call def patch_instance_with_http_info( self, - project_id: Annotated[str, Field(min_length=36, strict=True, max_length=36, description="Project identifier.")], - instance_id: Annotated[ - str, Field(min_length=36, strict=True, max_length=36, description="Instance identifier.") - ], + project_id: Annotated[UUID, Field(description="Project identifier.")], + instance_id: Annotated[UUID, Field(description="Instance identifier.")], patch_instance_payload: PatchInstancePayload, _request_timeout: Union[ None, @@ -1640,9 +3775,9 @@ def patch_instance_with_http_info( Patches the Instance. :param project_id: Project identifier. (required) - :type project_id: str + :type project_id: UUID :param instance_id: Instance identifier. (required) - :type instance_id: str + :type instance_id: UUID :param patch_instance_payload: (required) :type patch_instance_payload: PatchInstancePayload :param _request_timeout: timeout setting for this request. If one @@ -1681,7 +3816,7 @@ def patch_instance_with_http_info( "200": "Instance", "202": None, "400": "GenericErrorResponse", - "401": "UnauthorizedResponse", + "401": None, "404": None, "409": None, "500": "GenericErrorResponse", @@ -1696,10 +3831,8 @@ def patch_instance_with_http_info( @validate_call def patch_instance_without_preload_content( self, - project_id: Annotated[str, Field(min_length=36, strict=True, max_length=36, description="Project identifier.")], - instance_id: Annotated[ - str, Field(min_length=36, strict=True, max_length=36, description="Instance identifier.") - ], + project_id: Annotated[UUID, Field(description="Project identifier.")], + instance_id: Annotated[UUID, Field(description="Instance identifier.")], patch_instance_payload: PatchInstancePayload, _request_timeout: Union[ None, @@ -1716,9 +3849,9 @@ def patch_instance_without_preload_content( Patches the Instance. :param project_id: Project identifier. (required) - :type project_id: str + :type project_id: UUID :param instance_id: Instance identifier. (required) - :type instance_id: str + :type instance_id: UUID :param patch_instance_payload: (required) :type patch_instance_payload: PatchInstancePayload :param _request_timeout: timeout setting for this request. If one @@ -1757,7 +3890,7 @@ def patch_instance_without_preload_content( "200": "Instance", "202": None, "400": "GenericErrorResponse", - "401": "UnauthorizedResponse", + "401": None, "404": None, "409": None, "500": "GenericErrorResponse", diff --git a/services/git/src/stackit/git/api_client.py b/services/git/src/stackit/git/api_client.py index 8ca96a1e9..685848096 100644 --- a/services/git/src/stackit/git/api_client.py +++ b/services/git/src/stackit/git/api_client.py @@ -13,11 +13,13 @@ """ # noqa: E501 import datetime +import decimal import json import mimetypes import os import re import tempfile +import uuid from enum import Enum from typing import Dict, List, Optional, Tuple, Union from urllib.parse import quote @@ -64,8 +66,10 @@ class ApiClient: "bool": bool, "date": datetime.date, "datetime": datetime.datetime, + "decimal": decimal.Decimal, "object": object, } + _pool = None def __init__(self, configuration, header_name=None, header_value=None, cookie=None) -> None: self.config: Configuration = configuration @@ -268,7 +272,7 @@ def response_deserialize( return_data = self.__deserialize_file(response_data) elif response_type is not None: match = None - content_type = response_data.getheader("content-type") + content_type = response_data.headers.get("content-type") if content_type is not None: match = re.search(r"charset=([a-zA-Z\-\d]+)[\s;]?", content_type) encoding = match.group(1) if match else "utf-8" @@ -285,7 +289,7 @@ def response_deserialize( return ApiResponse( status_code=response_data.status, data=return_data, - headers=response_data.getheaders(), + headers=response_data.headers, raw_data=response_data.data, ) @@ -297,6 +301,7 @@ def sanitize_for_serialization(self, obj): If obj is str, int, long, float, bool, return directly. If obj is datetime.datetime, datetime.date convert to string in iso8601 format. + If obj is decimal.Decimal return string representation. If obj is list, sanitize each element in the list. If obj is dict, return the dict. If obj is OpenAPI model, return the properties dict. @@ -312,12 +317,16 @@ def sanitize_for_serialization(self, obj): return obj.get_secret_value() elif isinstance(obj, self.PRIMITIVE_TYPES): return obj + elif isinstance(obj, uuid.UUID): + return str(obj) elif isinstance(obj, list): return [self.sanitize_for_serialization(sub_obj) for sub_obj in obj] elif isinstance(obj, tuple): return tuple(self.sanitize_for_serialization(sub_obj) for sub_obj in obj) elif isinstance(obj, (datetime.datetime, datetime.date)): return obj.isoformat() + elif isinstance(obj, decimal.Decimal): + return str(obj) elif isinstance(obj, dict): obj_dict = obj @@ -327,7 +336,7 @@ def sanitize_for_serialization(self, obj): # and attributes which value is not None. # Convert attribute name to json key in # model definition for request. - if hasattr(obj, "to_dict") and callable(obj.to_dict): + if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): obj_dict = obj.to_dict() else: obj_dict = obj.__dict__ @@ -355,7 +364,7 @@ def deserialize(self, response_text: str, response_type: str, content_type: Opti data = json.loads(response_text) except ValueError: data = response_text - elif re.match(r"^application/(json|[\w!#$&.+-^_]+\+json)\s*(;|$)", content_type, re.IGNORECASE): + elif re.match(r"^application/(json|[\w!#$&.+\-^_]+\+json)\s*(;|$)", content_type, re.IGNORECASE): if response_text == "": data = "" else: @@ -401,12 +410,14 @@ def __deserialize(self, data, klass): if klass in self.PRIMITIVE_TYPES: return self.__deserialize_primitive(data, klass) - elif klass == object: + elif klass is object: return self.__deserialize_object(data) - elif klass == datetime.date: + elif klass is datetime.date: return self.__deserialize_date(data) - elif klass == datetime.datetime: + elif klass is datetime.datetime: return self.__deserialize_datetime(data) + elif klass is decimal.Decimal: + return decimal.Decimal(data) elif issubclass(klass, Enum): return self.__deserialize_enum(data, klass) else: @@ -554,12 +565,14 @@ def __deserialize_file(self, response): os.close(fd) os.remove(path) - content_disposition = response.getheader("Content-Disposition") + content_disposition = response.headers.get("Content-Disposition") if content_disposition: m = re.search(r'filename=[\'"]?([^\'"\s]+)[\'"]?', content_disposition) if m is None: raise ValueError("Unexpected 'content-disposition' header value") - filename = m.group(1) + filename = os.path.basename(m.group(1)) # Strip any directory traversal + if filename in ("", ".", ".."): # fall back to tmp filename + filename = os.path.basename(path) path = os.path.join(os.path.dirname(path), filename) with open(path, "wb") as f: diff --git a/services/git/src/stackit/git/exceptions.py b/services/git/src/stackit/git/exceptions.py index 6173d7dc8..2d36d6a25 100644 --- a/services/git/src/stackit/git/exceptions.py +++ b/services/git/src/stackit/git/exceptions.py @@ -130,7 +130,7 @@ def __init__( self.body = http_resp.data.decode("utf-8") except Exception: # noqa: S110 pass - self.headers = http_resp.getheaders() + self.headers = http_resp.headers @classmethod def from_response( diff --git a/services/git/src/stackit/git/models/__init__.py b/services/git/src/stackit/git/models/__init__.py index d8d85ea58..389f7c924 100644 --- a/services/git/src/stackit/git/models/__init__.py +++ b/services/git/src/stackit/git/models/__init__.py @@ -13,20 +13,29 @@ Do not edit the class manually. """ # noqa: E501 - # import models into model package +from stackit.git.models.already_exists_error import AlreadyExistsError +from stackit.git.models.authentication import Authentication +from stackit.git.models.authentication_list import AuthenticationList +from stackit.git.models.bad_error_response import BadErrorResponse +from stackit.git.models.conflict_error_response import ConflictErrorResponse +from stackit.git.models.create_authentication_payload import CreateAuthenticationPayload from stackit.git.models.create_instance_payload import CreateInstancePayload +from stackit.git.models.create_runner_payload import CreateRunnerPayload +from stackit.git.models.feature_toggle import FeatureToggle from stackit.git.models.flavor import Flavor from stackit.git.models.generic_error_response import GenericErrorResponse from stackit.git.models.instance import Instance -from stackit.git.models.instance_flavor import InstanceFlavor from stackit.git.models.internal_server_error_response import ( InternalServerErrorResponse, ) from stackit.git.models.list_flavors import ListFlavors from stackit.git.models.list_instances import ListInstances -from stackit.git.models.list_runner_labels import ListRunnerLabels +from stackit.git.models.not_found_error_response import NotFoundErrorResponse +from stackit.git.models.patch_authentication_payload import PatchAuthenticationPayload from stackit.git.models.patch_instance_payload import PatchInstancePayload from stackit.git.models.patch_operation import PatchOperation -from stackit.git.models.runner_label import RunnerLabel -from stackit.git.models.unauthorized_response import UnauthorizedResponse +from stackit.git.models.runner import Runner +from stackit.git.models.runner_runtime import RunnerRuntime +from stackit.git.models.runner_runtime_list import RunnerRuntimeList +from stackit.git.models.unauthorized_error_response import UnauthorizedErrorResponse diff --git a/services/git/src/stackit/git/models/unauthorized_response.py b/services/git/src/stackit/git/models/already_exists_error.py similarity index 84% rename from services/git/src/stackit/git/models/unauthorized_response.py rename to services/git/src/stackit/git/models/already_exists_error.py index 40b83963a..11b7f6190 100644 --- a/services/git/src/stackit/git/models/unauthorized_response.py +++ b/services/git/src/stackit/git/models/already_exists_error.py @@ -22,13 +22,13 @@ from typing_extensions import Self -class UnauthorizedResponse(BaseModel): +class AlreadyExistsError(BaseModel): """ - The request could not be authorized. + Error response when a resource already exists. """ # noqa: E501 - error: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["error"] + message: StrictStr + __properties: ClassVar[List[str]] = ["message"] model_config = ConfigDict( populate_by_name=True, @@ -47,7 +47,7 @@ def to_json(self) -> str: @classmethod def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of UnauthorizedResponse from a JSON string""" + """Create an instance of AlreadyExistsError from a JSON string""" return cls.from_dict(json.loads(json_str)) def to_dict(self) -> Dict[str, Any]: @@ -71,12 +71,12 @@ def to_dict(self) -> Dict[str, Any]: @classmethod def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of UnauthorizedResponse from a dict""" + """Create an instance of AlreadyExistsError from a dict""" if obj is None: return None if not isinstance(obj, dict): return cls.model_validate(obj) - _obj = cls.model_validate({"error": obj.get("error")}) + _obj = cls.model_validate({"message": obj.get("message")}) return _obj diff --git a/services/git/src/stackit/git/models/authentication.py b/services/git/src/stackit/git/models/authentication.py new file mode 100644 index 000000000..d4311e134 --- /dev/null +++ b/services/git/src/stackit/git/models/authentication.py @@ -0,0 +1,156 @@ +# coding: utf-8 + +""" + STACKIT Git API + + STACKIT Git management API. + + The version of the OpenAPI document: 1beta.0.4 + Contact: git@stackit.cloud + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations + +import json +import pprint +import re # noqa: F401 +from datetime import datetime +from typing import Any, ClassVar, Dict, List, Optional, Set +from uuid import UUID + +from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from typing_extensions import Annotated, Self + + +class Authentication(BaseModel): + """ + Describes an authentication definition associated to a STACKIT Git instance. The provider type will be an openidConnect type. + """ # noqa: E501 + + auto_discover_url: Annotated[str, Field(strict=True)] = Field( + description="The well-known configuration url to use for this authentication definition." + ) + client_id: StrictStr = Field(description="The IDP client id to use.") + created_at: datetime = Field( + description="The date and time the creation of the authentication definition was triggered." + ) + icon_url: Annotated[str, Field(strict=True)] = Field( + description="The url of the icon to use for this authentication definition." + ) + id: UUID = Field( + description="An auto generated unique uuid which identifies the authentication definition in STACKIT Git instances." + ) + name: Annotated[str, Field(strict=True, max_length=32)] = Field( + description="The name to identify an authentication definition associated with a STACKIT Git instance." + ) + provider: StrictStr = Field(description="The Oauth2 provider to use.") + scopes: StrictStr = Field(description="Scopes defines the OIDC scopes to request.") + status: StrictStr = Field(description="The current status of the authentication definition.") + __properties: ClassVar[List[str]] = [ + "auto_discover_url", + "client_id", + "created_at", + "icon_url", + "id", + "name", + "provider", + "scopes", + "status", + ] + + @field_validator("auto_discover_url") + def auto_discover_url_validate_regular_expression(cls, value): + """Validates the regular expression""" + if not re.match(r"^https:\/\/[a-zA-Z0-9\-\.]+(\.[a-zA-Z]{2,})+(\/.*)?$", value): + raise ValueError( + r"must validate the regular expression /^https:\/\/[a-zA-Z0-9\-\.]+(\.[a-zA-Z]{2,})+(\/.*)?$/" + ) + return value + + @field_validator("created_at", mode="before") + def created_at_change_year_zero_to_one(cls, value): + """Workaround which prevents year 0 issue""" + if isinstance(value, str): + # Check for year "0000" at the beginning of the string + # This assumes common date formats like YYYY-MM-DDTHH:MM:SS+00:00 or YYYY-MM-DDTHH:MM:SSZ + if value.startswith("0000-01-01T") and re.match( + r"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\+\d{2}:\d{2}|Z)$", value + ): + # Workaround: Replace "0000" with "0001" + return "0001" + value[4:] # Take "0001" and append the rest of the string + return value + + @field_validator("icon_url") + def icon_url_validate_regular_expression(cls, value): + """Validates the regular expression""" + if not re.match(r"^https:\/\/[a-zA-Z0-9\-\.]+(\.[a-zA-Z]{2,})+(\/.*)?$", value): + raise ValueError( + r"must validate the regular expression /^https:\/\/[a-zA-Z0-9\-\.]+(\.[a-zA-Z]{2,})+(\/.*)?$/" + ) + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of Authentication from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of Authentication from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "auto_discover_url": obj.get("auto_discover_url"), + "client_id": obj.get("client_id"), + "created_at": obj.get("created_at"), + "icon_url": obj.get("icon_url"), + "id": obj.get("id"), + "name": obj.get("name"), + "provider": obj.get("provider"), + "scopes": obj.get("scopes"), + "status": obj.get("status"), + } + ) + return _obj diff --git a/services/git/src/stackit/git/models/authentication_list.py b/services/git/src/stackit/git/models/authentication_list.py new file mode 100644 index 000000000..224cb44c7 --- /dev/null +++ b/services/git/src/stackit/git/models/authentication_list.py @@ -0,0 +1,99 @@ +# coding: utf-8 + +""" + STACKIT Git API + + STACKIT Git management API. + + The version of the OpenAPI document: 1beta.0.4 + Contact: git@stackit.cloud + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations + +import json +import pprint +from typing import Any, ClassVar, Dict, List, Optional, Set + +from pydantic import BaseModel, ConfigDict, Field +from typing_extensions import Annotated, Self + +from stackit.git.models.authentication import Authentication + + +class AuthenticationList(BaseModel): + """ + A list of authentications belonging to an Instance. + """ # noqa: E501 + + authentication: Annotated[List[Authentication], Field(max_length=50)] + __properties: ClassVar[List[str]] = ["authentication"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of AuthenticationList from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in authentication (list) + _items = [] + if self.authentication: + for _item_authentication in self.authentication: + if _item_authentication: + _items.append(_item_authentication.to_dict()) + _dict["authentication"] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of AuthenticationList from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "authentication": ( + [Authentication.from_dict(_item) for _item in obj["authentication"]] + if obj.get("authentication") is not None + else None + ) + } + ) + return _obj diff --git a/services/git/src/stackit/git/models/runner_label.py b/services/git/src/stackit/git/models/bad_error_response.py similarity index 71% rename from services/git/src/stackit/git/models/runner_label.py rename to services/git/src/stackit/git/models/bad_error_response.py index aac476f6b..86233a751 100644 --- a/services/git/src/stackit/git/models/runner_label.py +++ b/services/git/src/stackit/git/models/bad_error_response.py @@ -18,19 +18,18 @@ import pprint from typing import Any, ClassVar, Dict, List, Optional, Set -from pydantic import BaseModel, ConfigDict, Field, StrictStr -from typing_extensions import Annotated, Self +from pydantic import BaseModel, ConfigDict, StrictStr +from typing_extensions import Self -class RunnerLabel(BaseModel): +class BadErrorResponse(BaseModel): """ - Describes a STACKIT Git RunnerLabel. + 400 Error Response. """ # noqa: E501 - description: StrictStr = Field(description="RunnerLabel description.") - id: Annotated[str, Field(strict=True, max_length=36)] = Field(description="RunnerLabel id.") - label: Annotated[str, Field(strict=True, max_length=64)] = Field(description="RunnerLabel label.") - __properties: ClassVar[List[str]] = ["description", "id", "label"] + details: Optional[StrictStr] = None + error: Optional[StrictStr] = None + __properties: ClassVar[List[str]] = ["details", "error"] model_config = ConfigDict( populate_by_name=True, @@ -49,7 +48,7 @@ def to_json(self) -> str: @classmethod def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of RunnerLabel from a JSON string""" + """Create an instance of BadErrorResponse from a JSON string""" return cls.from_dict(json.loads(json_str)) def to_dict(self) -> Dict[str, Any]: @@ -73,14 +72,12 @@ def to_dict(self) -> Dict[str, Any]: @classmethod def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of RunnerLabel from a dict""" + """Create an instance of BadErrorResponse from a dict""" if obj is None: return None if not isinstance(obj, dict): return cls.model_validate(obj) - _obj = cls.model_validate( - {"description": obj.get("description"), "id": obj.get("id"), "label": obj.get("label")} - ) + _obj = cls.model_validate({"details": obj.get("details"), "error": obj.get("error")}) return _obj diff --git a/services/git/src/stackit/git/models/conflict_error_response.py b/services/git/src/stackit/git/models/conflict_error_response.py new file mode 100644 index 000000000..dec38a288 --- /dev/null +++ b/services/git/src/stackit/git/models/conflict_error_response.py @@ -0,0 +1,83 @@ +# coding: utf-8 + +""" + STACKIT Git API + + STACKIT Git management API. + + The version of the OpenAPI document: 1beta.0.4 + Contact: git@stackit.cloud + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations + +import json +import pprint +from typing import Any, ClassVar, Dict, List, Optional, Set + +from pydantic import BaseModel, ConfigDict, StrictStr +from typing_extensions import Self + + +class ConflictErrorResponse(BaseModel): + """ + 409 Error Response. + """ # noqa: E501 + + details: Optional[StrictStr] = None + error: Optional[StrictStr] = None + __properties: ClassVar[List[str]] = ["details", "error"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of ConflictErrorResponse from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of ConflictErrorResponse from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({"details": obj.get("details"), "error": obj.get("error")}) + return _obj diff --git a/services/git/src/stackit/git/models/create_authentication_payload.py b/services/git/src/stackit/git/models/create_authentication_payload.py new file mode 100644 index 000000000..bf1985a9e --- /dev/null +++ b/services/git/src/stackit/git/models/create_authentication_payload.py @@ -0,0 +1,136 @@ +# coding: utf-8 + +""" + STACKIT Git API + + STACKIT Git management API. + + The version of the OpenAPI document: 1beta.0.4 + Contact: git@stackit.cloud + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations + +import json +import pprint +import re # noqa: F401 +from typing import Any, ClassVar, Dict, List, Optional, Set + +from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from typing_extensions import Annotated, Self + + +class CreateAuthenticationPayload(BaseModel): + """ + Properties to patch on an authentication. All fields are optional. + """ # noqa: E501 + + auto_discover_url: Annotated[str, Field(strict=True)] = Field( + description="The well-known configuration url to use for this authentication definition." + ) + client_id: Annotated[str, Field(strict=True, max_length=256)] = Field(description="The IDP client id to use.") + client_secret: StrictStr = Field(description="The IDP client secret to use.") + icon_url: Optional[Annotated[str, Field(strict=True)]] = Field( + default=None, description="The url of the icon to use for this authentication definition." + ) + name: Annotated[str, Field(strict=True, max_length=32)] = Field( + description="The name to identify an authentication definition associated with a STACKIT Git instance." + ) + provider: Optional[StrictStr] = Field(default="openidConnect", description="The Oauth2 provider to use.") + scopes: Optional[StrictStr] = Field( + default="openid profile email", description="Scopes defines the OIDC scopes to request." + ) + __properties: ClassVar[List[str]] = [ + "auto_discover_url", + "client_id", + "client_secret", + "icon_url", + "name", + "provider", + "scopes", + ] + + @field_validator("auto_discover_url") + def auto_discover_url_validate_regular_expression(cls, value): + """Validates the regular expression""" + if not re.match(r"^https:\/\/[a-zA-Z0-9\-\.]+(\.[a-zA-Z]{2,})+(\/.*)?$", value): + raise ValueError( + r"must validate the regular expression /^https:\/\/[a-zA-Z0-9\-\.]+(\.[a-zA-Z]{2,})+(\/.*)?$/" + ) + return value + + @field_validator("icon_url") + def icon_url_validate_regular_expression(cls, value): + """Validates the regular expression""" + if value is None: + return value + + if not re.match(r"^https:\/\/[a-zA-Z0-9\-\.]+(\.[a-zA-Z]{2,})+(\/.*)?$", value): + raise ValueError( + r"must validate the regular expression /^https:\/\/[a-zA-Z0-9\-\.]+(\.[a-zA-Z]{2,})+(\/.*)?$/" + ) + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of CreateAuthenticationPayload from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of CreateAuthenticationPayload from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "auto_discover_url": obj.get("auto_discover_url"), + "client_id": obj.get("client_id"), + "client_secret": obj.get("client_secret"), + "icon_url": obj.get("icon_url"), + "name": obj.get("name"), + "provider": obj.get("provider") if obj.get("provider") is not None else "openidConnect", + "scopes": obj.get("scopes") if obj.get("scopes") is not None else "openid profile email", + } + ) + return _obj diff --git a/services/git/src/stackit/git/models/create_instance_payload.py b/services/git/src/stackit/git/models/create_instance_payload.py index 3fe888e5c..75fa6e001 100644 --- a/services/git/src/stackit/git/models/create_instance_payload.py +++ b/services/git/src/stackit/git/models/create_instance_payload.py @@ -22,8 +22,6 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator from typing_extensions import Annotated, Self -from stackit.git.models.instance_flavor import InstanceFlavor - class CreateInstancePayload(BaseModel): """ @@ -33,12 +31,22 @@ class CreateInstancePayload(BaseModel): acl: Optional[Annotated[List[StrictStr], Field(max_length=50)]] = Field( default=None, description="A list of CIDR network addresses that are allowed to access the instance." ) - flavor: Optional[InstanceFlavor] = None + flavor: Optional[StrictStr] = None name: Annotated[str, Field(min_length=5, strict=True, max_length=32)] = Field( description="A user chosen name to distinguish multiple STACKIT Git instances." ) __properties: ClassVar[List[str]] = ["acl", "flavor", "name"] + @field_validator("flavor") + def flavor_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(["git-10", "git-100"]): + raise ValueError("must be one of enum values ('git-10', 'git-100')") + return value + @field_validator("name") def name_validate_regular_expression(cls, value): """Validates the regular expression""" diff --git a/services/git/src/stackit/git/models/create_runner_payload.py b/services/git/src/stackit/git/models/create_runner_payload.py new file mode 100644 index 000000000..6d3f1d4c7 --- /dev/null +++ b/services/git/src/stackit/git/models/create_runner_payload.py @@ -0,0 +1,82 @@ +# coding: utf-8 + +""" + STACKIT Git API + + STACKIT Git management API. + + The version of the OpenAPI document: 1beta.0.4 + Contact: git@stackit.cloud + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations + +import json +import pprint +from typing import Any, ClassVar, Dict, List, Optional, Set + +from pydantic import BaseModel, ConfigDict, StrictStr +from typing_extensions import Self + + +class CreateRunnerPayload(BaseModel): + """ + Request a runner to be created supporting the requested list of runtime labels. + """ # noqa: E501 + + labels: List[StrictStr] + __properties: ClassVar[List[str]] = ["labels"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of CreateRunnerPayload from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of CreateRunnerPayload from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({"labels": obj.get("labels")}) + return _obj diff --git a/services/git/src/stackit/git/models/feature_toggle.py b/services/git/src/stackit/git/models/feature_toggle.py new file mode 100644 index 000000000..80987381d --- /dev/null +++ b/services/git/src/stackit/git/models/feature_toggle.py @@ -0,0 +1,126 @@ +# coding: utf-8 + +""" + STACKIT Git API + + STACKIT Git management API. + + The version of the OpenAPI document: 1beta.0.4 + Contact: git@stackit.cloud + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations + +import json +import pprint +from typing import Any, ClassVar, Dict, List, Optional, Set + +from pydantic import ( + BaseModel, + ConfigDict, + Field, + StrictBool, + StrictStr, + field_validator, +) +from typing_extensions import Self + + +class FeatureToggle(BaseModel): + """ + Feature toggles for the instance. + """ # noqa: E501 + + default_email_notifications: Optional[StrictStr] = Field(default=None, description="Default email notifications.") + enable_commit_signatures: Optional[StrictBool] = Field(default=None, description="Enable commit signatures.") + enable_local_login: Optional[StrictBool] = Field(default=None, description="Enable local login.") + __properties: ClassVar[List[str]] = [ + "default_email_notifications", + "enable_commit_signatures", + "enable_local_login", + ] + + @field_validator("default_email_notifications") + def default_email_notifications_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(["enabled", "disabled", "onmention", "andyourown"]): + raise ValueError("must be one of enum values ('enabled', 'disabled', 'onmention', 'andyourown')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of FeatureToggle from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # set to None if default_email_notifications (nullable) is None + # and model_fields_set contains the field + if self.default_email_notifications is None and "default_email_notifications" in self.model_fields_set: + _dict["default_email_notifications"] = None + + # set to None if enable_commit_signatures (nullable) is None + # and model_fields_set contains the field + if self.enable_commit_signatures is None and "enable_commit_signatures" in self.model_fields_set: + _dict["enable_commit_signatures"] = None + + # set to None if enable_local_login (nullable) is None + # and model_fields_set contains the field + if self.enable_local_login is None and "enable_local_login" in self.model_fields_set: + _dict["enable_local_login"] = None + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of FeatureToggle from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "default_email_notifications": obj.get("default_email_notifications"), + "enable_commit_signatures": obj.get("enable_commit_signatures"), + "enable_local_login": obj.get("enable_local_login"), + } + ) + return _obj diff --git a/services/git/src/stackit/git/models/instance.py b/services/git/src/stackit/git/models/instance.py index e665b27a7..498ac9222 100644 --- a/services/git/src/stackit/git/models/instance.py +++ b/services/git/src/stackit/git/models/instance.py @@ -19,10 +19,13 @@ import re # noqa: F401 from datetime import datetime from typing import Any, ClassVar, Dict, List, Optional, Set +from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator from typing_extensions import Annotated, Self +from stackit.git.models.feature_toggle import FeatureToggle + class Instance(BaseModel): """ @@ -33,10 +36,9 @@ class Instance(BaseModel): consumed_disk: StrictStr = Field(description="How many bytes of disk space is consumed. Read Only.") consumed_object_storage: StrictStr = Field(description="How many bytes of Object Storage is consumed. Read Only.") created: datetime = Field(description="The date and time the creation of the STACKIT Git instance was triggered.") - flavor: StrictStr = Field(description="Desired instance flavor. Must be one of the defined enum values") - id: Annotated[str, Field(strict=True, max_length=36)] = Field( - description="A auto generated unique id which identifies the STACKIT Git instances." - ) + feature_toggle: FeatureToggle + flavor: StrictStr = Field(description="Instance flavor.") + id: UUID = Field(description="A auto generated unique id which identifies the STACKIT Git instances.") name: Annotated[str, Field(strict=True, max_length=32)] = Field( description="A user chosen name to distinguish multiple STACKIT Git instances." ) @@ -54,6 +56,7 @@ class Instance(BaseModel): "consumed_disk", "consumed_object_storage", "created", + "feature_toggle", "flavor", "id", "name", @@ -121,6 +124,9 @@ def to_dict(self) -> Dict[str, Any]: exclude=excluded_fields, exclude_none=True, ) + # override the default output from pydantic by calling `to_dict()` of feature_toggle + if self.feature_toggle: + _dict["feature_toggle"] = self.feature_toggle.to_dict() return _dict @classmethod @@ -138,6 +144,9 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "consumed_disk": obj.get("consumed_disk"), "consumed_object_storage": obj.get("consumed_object_storage"), "created": obj.get("created"), + "feature_toggle": ( + FeatureToggle.from_dict(obj["feature_toggle"]) if obj.get("feature_toggle") is not None else None + ), "flavor": obj.get("flavor"), "id": obj.get("id"), "name": obj.get("name"), diff --git a/services/git/src/stackit/git/models/instance_flavor.py b/services/git/src/stackit/git/models/instance_flavor.py deleted file mode 100644 index 356c3d42a..000000000 --- a/services/git/src/stackit/git/models/instance_flavor.py +++ /dev/null @@ -1,37 +0,0 @@ -# coding: utf-8 - -""" - STACKIT Git API - - STACKIT Git management API. - - The version of the OpenAPI document: 1beta.0.4 - Contact: git@stackit.cloud - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - -from __future__ import annotations - -import json -from enum import Enum - -from typing_extensions import Self - - -class InstanceFlavor(str, Enum): - """ - Desired instance flavor. Must be one of the defined enum values. - """ - - """ - allowed enum values - """ - GIT_MINUS_10 = "git-10" - GIT_MINUS_100 = "git-100" - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Create an instance of InstanceFlavor from a JSON string""" - return cls(json.loads(json_str)) diff --git a/services/git/src/stackit/git/models/internal_server_error_response.py b/services/git/src/stackit/git/models/internal_server_error_response.py index 8e3784f74..460f428ea 100644 --- a/services/git/src/stackit/git/models/internal_server_error_response.py +++ b/services/git/src/stackit/git/models/internal_server_error_response.py @@ -27,8 +27,9 @@ class InternalServerErrorResponse(BaseModel): Internal server error. """ # noqa: E501 + details: Optional[StrictStr] = None error: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["error"] + __properties: ClassVar[List[str]] = ["details", "error"] model_config = ConfigDict( populate_by_name=True, @@ -78,5 +79,5 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: if not isinstance(obj, dict): return cls.model_validate(obj) - _obj = cls.model_validate({"error": obj.get("error")}) + _obj = cls.model_validate({"details": obj.get("details"), "error": obj.get("error")}) return _obj diff --git a/services/git/src/stackit/git/models/list_flavors.py b/services/git/src/stackit/git/models/list_flavors.py index babb918bd..2a374a156 100644 --- a/services/git/src/stackit/git/models/list_flavors.py +++ b/services/git/src/stackit/git/models/list_flavors.py @@ -72,9 +72,9 @@ def to_dict(self) -> Dict[str, Any]: # override the default output from pydantic by calling `to_dict()` of each item in flavors (list) _items = [] if self.flavors: - for _item in self.flavors: - if _item: - _items.append(_item.to_dict()) + for _item_flavors in self.flavors: + if _item_flavors: + _items.append(_item_flavors.to_dict()) _dict["flavors"] = _items return _dict diff --git a/services/git/src/stackit/git/models/list_instances.py b/services/git/src/stackit/git/models/list_instances.py index 2f48730b7..0c7853158 100644 --- a/services/git/src/stackit/git/models/list_instances.py +++ b/services/git/src/stackit/git/models/list_instances.py @@ -72,9 +72,9 @@ def to_dict(self) -> Dict[str, Any]: # override the default output from pydantic by calling `to_dict()` of each item in instances (list) _items = [] if self.instances: - for _item in self.instances: - if _item: - _items.append(_item.to_dict()) + for _item_instances in self.instances: + if _item_instances: + _items.append(_item_instances.to_dict()) _dict["instances"] = _items return _dict diff --git a/services/git/src/stackit/git/models/not_found_error_response.py b/services/git/src/stackit/git/models/not_found_error_response.py new file mode 100644 index 000000000..dbf478cc6 --- /dev/null +++ b/services/git/src/stackit/git/models/not_found_error_response.py @@ -0,0 +1,83 @@ +# coding: utf-8 + +""" + STACKIT Git API + + STACKIT Git management API. + + The version of the OpenAPI document: 1beta.0.4 + Contact: git@stackit.cloud + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations + +import json +import pprint +from typing import Any, ClassVar, Dict, List, Optional, Set + +from pydantic import BaseModel, ConfigDict, StrictStr +from typing_extensions import Self + + +class NotFoundErrorResponse(BaseModel): + """ + 404 Error Response. + """ # noqa: E501 + + details: Optional[StrictStr] = None + error: Optional[StrictStr] = None + __properties: ClassVar[List[str]] = ["details", "error"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of NotFoundErrorResponse from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of NotFoundErrorResponse from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({"details": obj.get("details"), "error": obj.get("error")}) + return _obj diff --git a/services/git/src/stackit/git/models/patch_authentication_payload.py b/services/git/src/stackit/git/models/patch_authentication_payload.py new file mode 100644 index 000000000..c4399a5e9 --- /dev/null +++ b/services/git/src/stackit/git/models/patch_authentication_payload.py @@ -0,0 +1,134 @@ +# coding: utf-8 + +""" + STACKIT Git API + + STACKIT Git management API. + + The version of the OpenAPI document: 1beta.0.4 + Contact: git@stackit.cloud + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations + +import json +import pprint +import re # noqa: F401 +from typing import Any, ClassVar, Dict, List, Optional, Set + +from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from typing_extensions import Annotated, Self + + +class PatchAuthenticationPayload(BaseModel): + """ + Properties to patch on an authentication. All fields are optional. + """ # noqa: E501 + + auto_discover_url: Optional[Annotated[str, Field(strict=True)]] = Field( + default=None, description="The well-known configuration url to use for this authentication definition." + ) + client_id: Optional[Annotated[str, Field(strict=True, max_length=256)]] = Field( + default=None, description="The IDP client id to use." + ) + client_secret: Optional[StrictStr] = Field(default=None, description="The IDP client secret to use.") + icon_url: Optional[Annotated[str, Field(strict=True)]] = Field( + default=None, description="The url of the icon to use for this authentication definition." + ) + provider: Optional[StrictStr] = Field(default=None, description="The Oauth2 provider to use.") + scopes: Optional[StrictStr] = Field(default=None, description="Scopes defines the OIDC scopes to request.") + __properties: ClassVar[List[str]] = [ + "auto_discover_url", + "client_id", + "client_secret", + "icon_url", + "provider", + "scopes", + ] + + @field_validator("auto_discover_url") + def auto_discover_url_validate_regular_expression(cls, value): + """Validates the regular expression""" + if value is None: + return value + + if not re.match(r"^https:\/\/[a-zA-Z0-9\-\.]+(\.[a-zA-Z]{2,})+(\/.*)?$", value): + raise ValueError( + r"must validate the regular expression /^https:\/\/[a-zA-Z0-9\-\.]+(\.[a-zA-Z]{2,})+(\/.*)?$/" + ) + return value + + @field_validator("icon_url") + def icon_url_validate_regular_expression(cls, value): + """Validates the regular expression""" + if value is None: + return value + + if not re.match(r"^https:\/\/[a-zA-Z0-9\-\.]+(\.[a-zA-Z]{2,})+(\/.*)?$", value): + raise ValueError( + r"must validate the regular expression /^https:\/\/[a-zA-Z0-9\-\.]+(\.[a-zA-Z]{2,})+(\/.*)?$/" + ) + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PatchAuthenticationPayload from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PatchAuthenticationPayload from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "auto_discover_url": obj.get("auto_discover_url"), + "client_id": obj.get("client_id"), + "client_secret": obj.get("client_secret"), + "icon_url": obj.get("icon_url"), + "provider": obj.get("provider"), + "scopes": obj.get("scopes"), + } + ) + return _obj diff --git a/services/git/src/stackit/git/models/patch_instance_payload.py b/services/git/src/stackit/git/models/patch_instance_payload.py index 617766a13..6e2e7c594 100644 --- a/services/git/src/stackit/git/models/patch_instance_payload.py +++ b/services/git/src/stackit/git/models/patch_instance_payload.py @@ -21,6 +21,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing_extensions import Annotated, Self +from stackit.git.models.feature_toggle import FeatureToggle + class PatchInstancePayload(BaseModel): """ @@ -30,7 +32,8 @@ class PatchInstancePayload(BaseModel): acl: Optional[Annotated[List[StrictStr], Field(max_length=50)]] = Field( default=None, description="A list of CIDR network addresses that are allowed to access the instance." ) - __properties: ClassVar[List[str]] = ["acl"] + feature_toggle: Optional[FeatureToggle] = None + __properties: ClassVar[List[str]] = ["acl", "feature_toggle"] model_config = ConfigDict( populate_by_name=True, @@ -69,6 +72,9 @@ def to_dict(self) -> Dict[str, Any]: exclude=excluded_fields, exclude_none=True, ) + # override the default output from pydantic by calling `to_dict()` of feature_toggle + if self.feature_toggle: + _dict["feature_toggle"] = self.feature_toggle.to_dict() # set to None if acl (nullable) is None # and model_fields_set contains the field if self.acl is None and "acl" in self.model_fields_set: @@ -85,5 +91,12 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: if not isinstance(obj, dict): return cls.model_validate(obj) - _obj = cls.model_validate({"acl": obj.get("acl")}) + _obj = cls.model_validate( + { + "acl": obj.get("acl"), + "feature_toggle": ( + FeatureToggle.from_dict(obj["feature_toggle"]) if obj.get("feature_toggle") is not None else None + ), + } + ) return _obj diff --git a/services/git/src/stackit/git/models/runner.py b/services/git/src/stackit/git/models/runner.py new file mode 100644 index 000000000..e02bf4672 --- /dev/null +++ b/services/git/src/stackit/git/models/runner.py @@ -0,0 +1,108 @@ +# coding: utf-8 + +""" + STACKIT Git API + + STACKIT Git management API. + + The version of the OpenAPI document: 1beta.0.4 + Contact: git@stackit.cloud + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations + +import json +import pprint +import re # noqa: F401 +from datetime import datetime +from typing import Any, ClassVar, Dict, List, Optional, Set +from uuid import UUID + +from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from typing_extensions import Self + + +class Runner(BaseModel): + """ + Describes a runner associated to a STACKIT Git instance. + """ # noqa: E501 + + created_at: datetime + id: UUID + labels: List[StrictStr] + status: StrictStr = Field(description="The current status of the runner.") + __properties: ClassVar[List[str]] = ["created_at", "id", "labels", "status"] + + @field_validator("created_at", mode="before") + def created_at_change_year_zero_to_one(cls, value): + """Workaround which prevents year 0 issue""" + if isinstance(value, str): + # Check for year "0000" at the beginning of the string + # This assumes common date formats like YYYY-MM-DDTHH:MM:SS+00:00 or YYYY-MM-DDTHH:MM:SSZ + if value.startswith("0000-01-01T") and re.match( + r"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\+\d{2}:\d{2}|Z)$", value + ): + # Workaround: Replace "0000" with "0001" + return "0001" + value[4:] # Take "0001" and append the rest of the string + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of Runner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of Runner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "created_at": obj.get("created_at"), + "id": obj.get("id"), + "labels": obj.get("labels"), + "status": obj.get("status"), + } + ) + return _obj diff --git a/services/git/src/stackit/git/models/runner_runtime.py b/services/git/src/stackit/git/models/runner_runtime.py new file mode 100644 index 000000000..65c1ef237 --- /dev/null +++ b/services/git/src/stackit/git/models/runner_runtime.py @@ -0,0 +1,94 @@ +# coding: utf-8 + +""" + STACKIT Git API + + STACKIT Git management API. + + The version of the OpenAPI document: 1beta.0.4 + Contact: git@stackit.cloud + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations + +import json +import pprint +from typing import Any, ClassVar, Dict, List, Optional, Set + +from pydantic import BaseModel, ConfigDict, Field, StrictStr +from typing_extensions import Self + + +class RunnerRuntime(BaseModel): + """ + Describes a STACKIT Git Runner runtime. + """ # noqa: E501 + + availability: StrictStr = Field(description="Indicates the availability of the runner label") + description: StrictStr = Field(description="Human-friendly description of the runtime and it's capabilities.") + display_name: StrictStr = Field(description="Human-friendly name of the runtime.") + id: StrictStr = Field(description="Runtime identifier.") + label: StrictStr = Field(description="Runtime label.") + __properties: ClassVar[List[str]] = ["availability", "description", "display_name", "id", "label"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of RunnerRuntime from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of RunnerRuntime from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "availability": obj.get("availability"), + "description": obj.get("description"), + "display_name": obj.get("display_name"), + "id": obj.get("id"), + "label": obj.get("label"), + } + ) + return _obj diff --git a/services/git/src/stackit/git/models/list_runner_labels.py b/services/git/src/stackit/git/models/runner_runtime_list.py similarity index 72% rename from services/git/src/stackit/git/models/list_runner_labels.py rename to services/git/src/stackit/git/models/runner_runtime_list.py index 040bc7c66..2778510be 100644 --- a/services/git/src/stackit/git/models/list_runner_labels.py +++ b/services/git/src/stackit/git/models/runner_runtime_list.py @@ -18,19 +18,19 @@ import pprint from typing import Any, ClassVar, Dict, List, Optional, Set -from pydantic import BaseModel, ConfigDict, Field +from pydantic import BaseModel, ConfigDict from typing_extensions import Self -from stackit.git.models.runner_label import RunnerLabel +from stackit.git.models.runner_runtime import RunnerRuntime -class ListRunnerLabels(BaseModel): +class RunnerRuntimeList(BaseModel): """ A list of STACKIT Git RunnerLabels. """ # noqa: E501 - runner_labels: List[RunnerLabel] = Field(alias="runner-labels") - __properties: ClassVar[List[str]] = ["runner-labels"] + items: List[RunnerRuntime] + __properties: ClassVar[List[str]] = ["items"] model_config = ConfigDict( populate_by_name=True, @@ -49,7 +49,7 @@ def to_json(self) -> str: @classmethod def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ListRunnerLabels from a JSON string""" + """Create an instance of RunnerRuntimeList from a JSON string""" return cls.from_dict(json.loads(json_str)) def to_dict(self) -> Dict[str, Any]: @@ -69,18 +69,18 @@ def to_dict(self) -> Dict[str, Any]: exclude=excluded_fields, exclude_none=True, ) - # override the default output from pydantic by calling `to_dict()` of each item in runner_labels (list) + # override the default output from pydantic by calling `to_dict()` of each item in items (list) _items = [] - if self.runner_labels: - for _item in self.runner_labels: - if _item: - _items.append(_item.to_dict()) - _dict["runner-labels"] = _items + if self.items: + for _item_items in self.items: + if _item_items: + _items.append(_item_items.to_dict()) + _dict["items"] = _items return _dict @classmethod def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ListRunnerLabels from a dict""" + """Create an instance of RunnerRuntimeList from a dict""" if obj is None: return None @@ -89,10 +89,8 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: _obj = cls.model_validate( { - "runner-labels": ( - [RunnerLabel.from_dict(_item) for _item in obj["runner-labels"]] - if obj.get("runner-labels") is not None - else None + "items": ( + [RunnerRuntime.from_dict(_item) for _item in obj["items"]] if obj.get("items") is not None else None ) } ) diff --git a/services/git/src/stackit/git/models/unauthorized_error_response.py b/services/git/src/stackit/git/models/unauthorized_error_response.py new file mode 100644 index 000000000..96f2f4124 --- /dev/null +++ b/services/git/src/stackit/git/models/unauthorized_error_response.py @@ -0,0 +1,109 @@ +# coding: utf-8 + +""" + STACKIT Git API + + STACKIT Git management API. + + The version of the OpenAPI document: 1beta.0.4 + Contact: git@stackit.cloud + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations + +import json +import pprint +import re # noqa: F401 +from datetime import datetime +from typing import Any, ClassVar, Dict, List, Optional, Set + +from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr, field_validator +from typing_extensions import Self + + +class UnauthorizedErrorResponse(BaseModel): + """ + Unauthorized Error Response. + """ # noqa: E501 + + error: Optional[StrictStr] = None + message: StrictStr + path: Optional[StrictStr] = None + status: Optional[StrictInt] = None + timestamp: Optional[datetime] = None + __properties: ClassVar[List[str]] = ["error", "message", "path", "status", "timestamp"] + + @field_validator("timestamp", mode="before") + def timestamp_change_year_zero_to_one(cls, value): + """Workaround which prevents year 0 issue""" + if isinstance(value, str): + # Check for year "0000" at the beginning of the string + # This assumes common date formats like YYYY-MM-DDTHH:MM:SS+00:00 or YYYY-MM-DDTHH:MM:SSZ + if value.startswith("0000-01-01T") and re.match( + r"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\+\d{2}:\d{2}|Z)$", value + ): + # Workaround: Replace "0000" with "0001" + return "0001" + value[4:] # Take "0001" and append the rest of the string + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of UnauthorizedErrorResponse from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of UnauthorizedErrorResponse from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "error": obj.get("error"), + "message": obj.get("message"), + "path": obj.get("path"), + "status": obj.get("status"), + "timestamp": obj.get("timestamp"), + } + ) + return _obj diff --git a/services/git/src/stackit/git/rest.py b/services/git/src/stackit/git/rest.py index bcf1f39fe..32a596bc4 100644 --- a/services/git/src/stackit/git/rest.py +++ b/services/git/src/stackit/git/rest.py @@ -39,12 +39,17 @@ def read(self): self.data = self.response.content return self.data + @property + def headers(self): + """Returns a dictionary of response headers.""" + return self.response.headers + def getheaders(self): - """Returns a dictionary of the response headers.""" + """Returns a dictionary of the response headers; use ``headers`` instead.""" return self.response.headers def getheader(self, name, default=None): - """Returns a given response header.""" + """Returns a given response header; use ``headers.get()`` instead.""" return self.response.headers.get(name, default) @@ -94,6 +99,7 @@ def request(self, method, url, headers=None, body=None, post_params=None, _reque url, data=request_body, headers=headers, + timeout=_request_timeout, ) elif content_type == "application/x-www-form-urlencoded": r = self.session.request( @@ -101,6 +107,7 @@ def request(self, method, url, headers=None, body=None, post_params=None, _reque url, params=post_params, headers=headers, + timeout=_request_timeout, ) elif content_type == "multipart/form-data": # must del headers['Content-Type'], or the correct @@ -114,6 +121,7 @@ def request(self, method, url, headers=None, body=None, post_params=None, _reque url, files=post_params, headers=headers, + timeout=_request_timeout, ) # Pass a `string` parameter directly in the body to support # other content types than JSON when `body` argument is @@ -124,10 +132,17 @@ def request(self, method, url, headers=None, body=None, post_params=None, _reque url, data=body, headers=headers, + timeout=_request_timeout, ) elif headers["Content-Type"].startswith("text/") and isinstance(body, bool): request_body = "true" if body else "false" - r = self.session.request(method, url, data=request_body, headers=headers) + r = self.session.request( + method, + url, + data=request_body, + headers=headers, + timeout=_request_timeout, + ) else: # Cannot generate the request from given parameters msg = """Cannot prepare a request message for provided @@ -141,6 +156,7 @@ def request(self, method, url, headers=None, body=None, post_params=None, _reque url, params={}, headers=headers, + timeout=_request_timeout, ) except requests.exceptions.SSLError as e: msg = "\n".join([type(e).__name__, str(e)])