From 1a13f70034dc9d2d4aeb16fceb959d19d80d998d Mon Sep 17 00:00:00 2001 From: SDK Generator Bot Date: Wed, 14 May 2025 09:34:01 +0000 Subject: [PATCH 1/2] Generate sqlserverflex --- .../src/stackit/sqlserverflex/__init__.py | 4 + .../stackit/sqlserverflex/api/default_api.py | 394 ++++++++++++++++++ .../stackit/sqlserverflex/models/__init__.py | 4 + .../sqlserverflex/models/data_point.py | 83 ++++ .../src/stackit/sqlserverflex/models/host.py | 101 +++++ .../sqlserverflex/models/host_metric.py | 103 +++++ .../models/list_metrics_response.py | 93 +++++ 7 files changed, 782 insertions(+) create mode 100644 services/sqlserverflex/src/stackit/sqlserverflex/models/data_point.py create mode 100644 services/sqlserverflex/src/stackit/sqlserverflex/models/host.py create mode 100644 services/sqlserverflex/src/stackit/sqlserverflex/models/host_metric.py create mode 100644 services/sqlserverflex/src/stackit/sqlserverflex/models/list_metrics_response.py diff --git a/services/sqlserverflex/src/stackit/sqlserverflex/__init__.py b/services/sqlserverflex/src/stackit/sqlserverflex/__init__.py index 08573c84..c088aac1 100644 --- a/services/sqlserverflex/src/stackit/sqlserverflex/__init__.py +++ b/services/sqlserverflex/src/stackit/sqlserverflex/__init__.py @@ -45,6 +45,7 @@ from stackit.sqlserverflex.models.create_instance_response import CreateInstanceResponse from stackit.sqlserverflex.models.create_user_payload import CreateUserPayload from stackit.sqlserverflex.models.create_user_response import CreateUserResponse +from stackit.sqlserverflex.models.data_point import DataPoint from stackit.sqlserverflex.models.database import Database from stackit.sqlserverflex.models.database_documentation_create_database_request_options import ( DatabaseDocumentationCreateDatabaseRequestOptions, @@ -55,6 +56,8 @@ from stackit.sqlserverflex.models.get_database_response import GetDatabaseResponse from stackit.sqlserverflex.models.get_instance_response import GetInstanceResponse from stackit.sqlserverflex.models.get_user_response import GetUserResponse +from stackit.sqlserverflex.models.host import Host +from stackit.sqlserverflex.models.host_metric import HostMetric from stackit.sqlserverflex.models.instance import Instance from stackit.sqlserverflex.models.instance_documentation_acl import ( InstanceDocumentationACL, @@ -77,6 +80,7 @@ from stackit.sqlserverflex.models.list_databases_response import ListDatabasesResponse from stackit.sqlserverflex.models.list_flavors_response import ListFlavorsResponse from stackit.sqlserverflex.models.list_instances_response import ListInstancesResponse +from stackit.sqlserverflex.models.list_metrics_response import ListMetricsResponse from stackit.sqlserverflex.models.list_restore_jobs_response import ( ListRestoreJobsResponse, ) diff --git a/services/sqlserverflex/src/stackit/sqlserverflex/api/default_api.py b/services/sqlserverflex/src/stackit/sqlserverflex/api/default_api.py index 2be2b646..88ea217a 100644 --- a/services/sqlserverflex/src/stackit/sqlserverflex/api/default_api.py +++ b/services/sqlserverflex/src/stackit/sqlserverflex/api/default_api.py @@ -44,6 +44,7 @@ from stackit.sqlserverflex.models.list_databases_response import ListDatabasesResponse from stackit.sqlserverflex.models.list_flavors_response import ListFlavorsResponse from stackit.sqlserverflex.models.list_instances_response import ListInstancesResponse +from stackit.sqlserverflex.models.list_metrics_response import ListMetricsResponse from stackit.sqlserverflex.models.list_restore_jobs_response import ( ListRestoreJobsResponse, ) @@ -4481,6 +4482,399 @@ def _list_instances_serialize( _request_auth=_request_auth, ) + @validate_call + def list_metrics( + self, + project_id: Annotated[StrictStr, Field(description="The UUID of the project.")], + instance_id: Annotated[StrictStr, Field(description="The UUID of the instance.")], + metric: Annotated[ + StrictStr, + Field( + description="The name of the metric. Valid metrics are 'cpu', 'memory', 'data-disk-size', 'data-disk-use','log-disk-size', 'log-disk-use', 'life-expectancy' and 'connections'." + ), + ], + granularity: Annotated[StrictStr, Field(description="The granularity in ISO8601 e.g. 5 minutes are 'PT5M'.")], + period: Annotated[ + Optional[StrictStr], + Field( + description="The period in ISO8601 format e.g. 5 minutes are 'PT5M'. If no period is provided, the standard value of 5 minutes is used." + ), + ] = None, + start: Annotated[ + Optional[StrictStr], + Field( + description="The start of the timeframe as timestamp in ISO8601 (RFC3339) e.g. '2023-08-28T07:10:52.536Z'. If no start time is provided, current server time as UTC is used." + ), + ] = None, + end: Annotated[ + Optional[StrictStr], + Field( + description="The end of the timeframe as timestamp in ISO8601 (RFC3339) e.g. '2023-08-28T07:10:52.536Z'." + ), + ] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ListMetricsResponse: + """Get Metric + + Returns a metric for an instance. The metric will only be for the master pod if needed. Granularity parameter is always needed. If start and end time is provided, period is not considered in max-connections and disk-use. If you provide start time, you have to provide end time as well and vice versa. + + :param project_id: The UUID of the project. (required) + :type project_id: str + :param instance_id: The UUID of the instance. (required) + :type instance_id: str + :param metric: The name of the metric. Valid metrics are 'cpu', 'memory', 'data-disk-size', 'data-disk-use','log-disk-size', 'log-disk-use', 'life-expectancy' and 'connections'. (required) + :type metric: str + :param granularity: The granularity in ISO8601 e.g. 5 minutes are 'PT5M'. (required) + :type granularity: str + :param period: The period in ISO8601 format e.g. 5 minutes are 'PT5M'. If no period is provided, the standard value of 5 minutes is used. + :type period: str + :param start: The start of the timeframe as timestamp in ISO8601 (RFC3339) e.g. '2023-08-28T07:10:52.536Z'. If no start time is provided, current server time as UTC is used. + :type start: str + :param end: The end of the timeframe as timestamp in ISO8601 (RFC3339) e.g. '2023-08-28T07:10:52.536Z'. + :type end: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._list_metrics_serialize( + project_id=project_id, + instance_id=instance_id, + metric=metric, + granularity=granularity, + period=period, + start=start, + end=end, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "ListMetricsResponse", + "400": "InstanceError", + "405": "InstanceError", + "500": "InstanceError", + } + 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 list_metrics_with_http_info( + self, + project_id: Annotated[StrictStr, Field(description="The UUID of the project.")], + instance_id: Annotated[StrictStr, Field(description="The UUID of the instance.")], + metric: Annotated[ + StrictStr, + Field( + description="The name of the metric. Valid metrics are 'cpu', 'memory', 'data-disk-size', 'data-disk-use','log-disk-size', 'log-disk-use', 'life-expectancy' and 'connections'." + ), + ], + granularity: Annotated[StrictStr, Field(description="The granularity in ISO8601 e.g. 5 minutes are 'PT5M'.")], + period: Annotated[ + Optional[StrictStr], + Field( + description="The period in ISO8601 format e.g. 5 minutes are 'PT5M'. If no period is provided, the standard value of 5 minutes is used." + ), + ] = None, + start: Annotated[ + Optional[StrictStr], + Field( + description="The start of the timeframe as timestamp in ISO8601 (RFC3339) e.g. '2023-08-28T07:10:52.536Z'. If no start time is provided, current server time as UTC is used." + ), + ] = None, + end: Annotated[ + Optional[StrictStr], + Field( + description="The end of the timeframe as timestamp in ISO8601 (RFC3339) e.g. '2023-08-28T07:10:52.536Z'." + ), + ] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[ListMetricsResponse]: + """Get Metric + + Returns a metric for an instance. The metric will only be for the master pod if needed. Granularity parameter is always needed. If start and end time is provided, period is not considered in max-connections and disk-use. If you provide start time, you have to provide end time as well and vice versa. + + :param project_id: The UUID of the project. (required) + :type project_id: str + :param instance_id: The UUID of the instance. (required) + :type instance_id: str + :param metric: The name of the metric. Valid metrics are 'cpu', 'memory', 'data-disk-size', 'data-disk-use','log-disk-size', 'log-disk-use', 'life-expectancy' and 'connections'. (required) + :type metric: str + :param granularity: The granularity in ISO8601 e.g. 5 minutes are 'PT5M'. (required) + :type granularity: str + :param period: The period in ISO8601 format e.g. 5 minutes are 'PT5M'. If no period is provided, the standard value of 5 minutes is used. + :type period: str + :param start: The start of the timeframe as timestamp in ISO8601 (RFC3339) e.g. '2023-08-28T07:10:52.536Z'. If no start time is provided, current server time as UTC is used. + :type start: str + :param end: The end of the timeframe as timestamp in ISO8601 (RFC3339) e.g. '2023-08-28T07:10:52.536Z'. + :type end: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._list_metrics_serialize( + project_id=project_id, + instance_id=instance_id, + metric=metric, + granularity=granularity, + period=period, + start=start, + end=end, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "ListMetricsResponse", + "400": "InstanceError", + "405": "InstanceError", + "500": "InstanceError", + } + 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 list_metrics_without_preload_content( + self, + project_id: Annotated[StrictStr, Field(description="The UUID of the project.")], + instance_id: Annotated[StrictStr, Field(description="The UUID of the instance.")], + metric: Annotated[ + StrictStr, + Field( + description="The name of the metric. Valid metrics are 'cpu', 'memory', 'data-disk-size', 'data-disk-use','log-disk-size', 'log-disk-use', 'life-expectancy' and 'connections'." + ), + ], + granularity: Annotated[StrictStr, Field(description="The granularity in ISO8601 e.g. 5 minutes are 'PT5M'.")], + period: Annotated[ + Optional[StrictStr], + Field( + description="The period in ISO8601 format e.g. 5 minutes are 'PT5M'. If no period is provided, the standard value of 5 minutes is used." + ), + ] = None, + start: Annotated[ + Optional[StrictStr], + Field( + description="The start of the timeframe as timestamp in ISO8601 (RFC3339) e.g. '2023-08-28T07:10:52.536Z'. If no start time is provided, current server time as UTC is used." + ), + ] = None, + end: Annotated[ + Optional[StrictStr], + Field( + description="The end of the timeframe as timestamp in ISO8601 (RFC3339) e.g. '2023-08-28T07:10:52.536Z'." + ), + ] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Get Metric + + Returns a metric for an instance. The metric will only be for the master pod if needed. Granularity parameter is always needed. If start and end time is provided, period is not considered in max-connections and disk-use. If you provide start time, you have to provide end time as well and vice versa. + + :param project_id: The UUID of the project. (required) + :type project_id: str + :param instance_id: The UUID of the instance. (required) + :type instance_id: str + :param metric: The name of the metric. Valid metrics are 'cpu', 'memory', 'data-disk-size', 'data-disk-use','log-disk-size', 'log-disk-use', 'life-expectancy' and 'connections'. (required) + :type metric: str + :param granularity: The granularity in ISO8601 e.g. 5 minutes are 'PT5M'. (required) + :type granularity: str + :param period: The period in ISO8601 format e.g. 5 minutes are 'PT5M'. If no period is provided, the standard value of 5 minutes is used. + :type period: str + :param start: The start of the timeframe as timestamp in ISO8601 (RFC3339) e.g. '2023-08-28T07:10:52.536Z'. If no start time is provided, current server time as UTC is used. + :type start: str + :param end: The end of the timeframe as timestamp in ISO8601 (RFC3339) e.g. '2023-08-28T07:10:52.536Z'. + :type end: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._list_metrics_serialize( + project_id=project_id, + instance_id=instance_id, + metric=metric, + granularity=granularity, + period=period, + start=start, + end=end, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "ListMetricsResponse", + "400": "InstanceError", + "405": "InstanceError", + "500": "InstanceError", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _list_metrics_serialize( + self, + project_id, + instance_id, + metric, + granularity, + period, + start, + end, + _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]] = {} + _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 metric is not None: + _path_params["metric"] = metric + # process the query parameters + if granularity is not None: + + _query_params.append(("granularity", granularity)) + + if period is not None: + + _query_params.append(("period", period)) + + if start is not None: + + _query_params.append(("start", start)) + + if end is not None: + + _query_params.append(("end", end)) + + # 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="/v2/projects/{projectId}/instances/{instanceId}/metrics/{metric}", + 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 list_restore_jobs( self, diff --git a/services/sqlserverflex/src/stackit/sqlserverflex/models/__init__.py b/services/sqlserverflex/src/stackit/sqlserverflex/models/__init__.py index 57e05a5f..49e15790 100644 --- a/services/sqlserverflex/src/stackit/sqlserverflex/models/__init__.py +++ b/services/sqlserverflex/src/stackit/sqlserverflex/models/__init__.py @@ -26,6 +26,7 @@ from stackit.sqlserverflex.models.create_instance_response import CreateInstanceResponse from stackit.sqlserverflex.models.create_user_payload import CreateUserPayload from stackit.sqlserverflex.models.create_user_response import CreateUserResponse +from stackit.sqlserverflex.models.data_point import DataPoint from stackit.sqlserverflex.models.database import Database from stackit.sqlserverflex.models.database_documentation_create_database_request_options import ( DatabaseDocumentationCreateDatabaseRequestOptions, @@ -36,6 +37,8 @@ from stackit.sqlserverflex.models.get_database_response import GetDatabaseResponse from stackit.sqlserverflex.models.get_instance_response import GetInstanceResponse from stackit.sqlserverflex.models.get_user_response import GetUserResponse +from stackit.sqlserverflex.models.host import Host +from stackit.sqlserverflex.models.host_metric import HostMetric from stackit.sqlserverflex.models.instance import Instance from stackit.sqlserverflex.models.instance_documentation_acl import ( InstanceDocumentationACL, @@ -58,6 +61,7 @@ from stackit.sqlserverflex.models.list_databases_response import ListDatabasesResponse from stackit.sqlserverflex.models.list_flavors_response import ListFlavorsResponse from stackit.sqlserverflex.models.list_instances_response import ListInstancesResponse +from stackit.sqlserverflex.models.list_metrics_response import ListMetricsResponse from stackit.sqlserverflex.models.list_restore_jobs_response import ( ListRestoreJobsResponse, ) diff --git a/services/sqlserverflex/src/stackit/sqlserverflex/models/data_point.py b/services/sqlserverflex/src/stackit/sqlserverflex/models/data_point.py new file mode 100644 index 00000000..a3900542 --- /dev/null +++ b/services/sqlserverflex/src/stackit/sqlserverflex/models/data_point.py @@ -0,0 +1,83 @@ +# coding: utf-8 + +""" + STACKIT MSSQL Service API + + This is the documentation for the STACKIT MSSQL service + + The version of the OpenAPI document: 2.0.0 + Contact: support@stackit.cloud + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 docstring might be too long + +from __future__ import annotations + +import json +import pprint +from typing import Any, ClassVar, Dict, List, Optional, Set, Union + +from pydantic import BaseModel, ConfigDict, StrictFloat, StrictInt, StrictStr +from typing_extensions import Self + + +class DataPoint(BaseModel): + """ + DataPoint + """ + + timestamp: Optional[StrictStr] = None + value: Optional[Union[StrictFloat, StrictInt]] = None + __properties: ClassVar[List[str]] = ["timestamp", "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 DataPoint 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 DataPoint from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({"timestamp": obj.get("timestamp"), "value": obj.get("value")}) + return _obj diff --git a/services/sqlserverflex/src/stackit/sqlserverflex/models/host.py b/services/sqlserverflex/src/stackit/sqlserverflex/models/host.py new file mode 100644 index 00000000..981fb1ef --- /dev/null +++ b/services/sqlserverflex/src/stackit/sqlserverflex/models/host.py @@ -0,0 +1,101 @@ +# coding: utf-8 + +""" + STACKIT MSSQL Service API + + This is the documentation for the STACKIT MSSQL service + + The version of the OpenAPI document: 2.0.0 + Contact: support@stackit.cloud + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 docstring might be too long + +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 + +from stackit.sqlserverflex.models.host_metric import HostMetric + + +class Host(BaseModel): + """ + Host + """ + + host_metrics: Optional[List[HostMetric]] = Field(default=None, alias="hostMetrics") + id: Optional[StrictStr] = None + __properties: ClassVar[List[str]] = ["hostMetrics", "id"] + + 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 Host 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 host_metrics (list) + _items = [] + if self.host_metrics: + for _item in self.host_metrics: + if _item: + _items.append(_item.to_dict()) + _dict["hostMetrics"] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of Host from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "hostMetrics": ( + [HostMetric.from_dict(_item) for _item in obj["hostMetrics"]] + if obj.get("hostMetrics") is not None + else None + ), + "id": obj.get("id"), + } + ) + return _obj diff --git a/services/sqlserverflex/src/stackit/sqlserverflex/models/host_metric.py b/services/sqlserverflex/src/stackit/sqlserverflex/models/host_metric.py new file mode 100644 index 00000000..b0678d9c --- /dev/null +++ b/services/sqlserverflex/src/stackit/sqlserverflex/models/host_metric.py @@ -0,0 +1,103 @@ +# coding: utf-8 + +""" + STACKIT MSSQL Service API + + This is the documentation for the STACKIT MSSQL service + + The version of the OpenAPI document: 2.0.0 + Contact: support@stackit.cloud + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 docstring might be too long + +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 + +from stackit.sqlserverflex.models.data_point import DataPoint + + +class HostMetric(BaseModel): + """ + HostMetric + """ + + datapoints: Optional[List[DataPoint]] = None + name: Optional[StrictStr] = None + units: Optional[StrictStr] = None + __properties: ClassVar[List[str]] = ["datapoints", "name", "units"] + + 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 HostMetric 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 datapoints (list) + _items = [] + if self.datapoints: + for _item in self.datapoints: + if _item: + _items.append(_item.to_dict()) + _dict["datapoints"] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of HostMetric from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "datapoints": ( + [DataPoint.from_dict(_item) for _item in obj["datapoints"]] + if obj.get("datapoints") is not None + else None + ), + "name": obj.get("name"), + "units": obj.get("units"), + } + ) + return _obj diff --git a/services/sqlserverflex/src/stackit/sqlserverflex/models/list_metrics_response.py b/services/sqlserverflex/src/stackit/sqlserverflex/models/list_metrics_response.py new file mode 100644 index 00000000..93f82907 --- /dev/null +++ b/services/sqlserverflex/src/stackit/sqlserverflex/models/list_metrics_response.py @@ -0,0 +1,93 @@ +# coding: utf-8 + +""" + STACKIT MSSQL Service API + + This is the documentation for the STACKIT MSSQL service + + The version of the OpenAPI document: 2.0.0 + Contact: support@stackit.cloud + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 docstring might be too long + +from __future__ import annotations + +import json +import pprint +from typing import Any, ClassVar, Dict, List, Optional, Set + +from pydantic import BaseModel, ConfigDict +from typing_extensions import Self + +from stackit.sqlserverflex.models.host import Host + + +class ListMetricsResponse(BaseModel): + """ + ListMetricsResponse + """ + + hosts: Optional[List[Host]] = None + __properties: ClassVar[List[str]] = ["hosts"] + + 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 ListMetricsResponse 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 hosts (list) + _items = [] + if self.hosts: + for _item in self.hosts: + if _item: + _items.append(_item.to_dict()) + _dict["hosts"] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of ListMetricsResponse from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + {"hosts": [Host.from_dict(_item) for _item in obj["hosts"]] if obj.get("hosts") is not None else None} + ) + return _obj From 667b680a9fd78903da63d70a6dba032823bce0a0 Mon Sep 17 00:00:00 2001 From: Marcel Jacek Date: Wed, 14 May 2025 14:51:55 +0200 Subject: [PATCH 2/2] Update CHANGELOG.md and pyproject.toml --- CHANGELOG.md | 2 ++ services/sqlserverflex/CHANGELOG.md | 3 +++ services/sqlserverflex/pyproject.toml | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 68b306be..6d9a4ade 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ - **Breaking Change:** Added organization id to `VendorSubscription` - `ske`: [v0.4.2](services/ske/CHANGELOG.md#v042-2025-05-13) - **Feature:** Added `ClusterError` +- `sqlserverflex`: [v1.0.2](services/sqlserverflex/CHANGELOG.md#v102-2025-05-14) + - **Feature:** Added new method `list_metrics` ## Release (2025-05-09) - `stackitmarketplace`: diff --git a/services/sqlserverflex/CHANGELOG.md b/services/sqlserverflex/CHANGELOG.md index c5c47d9c..f029a0e6 100644 --- a/services/sqlserverflex/CHANGELOG.md +++ b/services/sqlserverflex/CHANGELOG.md @@ -1,3 +1,6 @@ +## v1.0.2 (2025-05-14) +- **Feature:** Add new method `list_metrics` + ## v1.0.1 (2025-05-09) - **Feature:** Update user-agent header diff --git a/services/sqlserverflex/pyproject.toml b/services/sqlserverflex/pyproject.toml index 7e19c0a8..e9cf204f 100644 --- a/services/sqlserverflex/pyproject.toml +++ b/services/sqlserverflex/pyproject.toml @@ -3,7 +3,7 @@ name = "stackit-sqlserverflex" [tool.poetry] name = "stackit-sqlserverflex" -version = "v1.0.1" +version = "v1.0.2" authors = [ "STACKIT Developer Tools ", ]