diff --git a/DO_OPENAPI_COMMIT_SHA.txt b/DO_OPENAPI_COMMIT_SHA.txt index 65d9f414..f8a6610b 100644 --- a/DO_OPENAPI_COMMIT_SHA.txt +++ b/DO_OPENAPI_COMMIT_SHA.txt @@ -1 +1 @@ -b0a1e19 +352faf3 diff --git a/requirements.txt b/requirements.txt index c4752c18..5cb5bb20 100644 --- a/requirements.txt +++ b/requirements.txt @@ -25,5 +25,5 @@ requests-oauthlib==1.3.1 ; python_full_version >= "3.7.2" and python_full_versio requests==2.31.0 ; python_full_version >= "3.7.2" and python_full_version < "4.0.0" six==1.16.0 ; python_full_version >= "3.7.2" and python_full_version < "4.0.0" typing-extensions==4.4.0 ; python_full_version >= "3.7.2" and python_full_version < "4.0.0" -urllib3==1.26.17 ; python_full_version >= "3.7.2" and python_full_version < "4.0.0" +urllib3==1.26.18 ; python_full_version >= "3.7.2" and python_full_version < "4.0.0" yarl==1.8.1 ; python_full_version >= "3.7.2" and python_full_version < "4.0.0" diff --git a/src/pydo/aio/operations/_operations.py b/src/pydo/aio/operations/_operations.py index 11a211d3..ce438918 100644 --- a/src/pydo/aio/operations/_operations.py +++ b/src/pydo/aio/operations/_operations.py @@ -221,6 +221,9 @@ build_monitoring_create_alert_policy_request, build_monitoring_delete_alert_policy_request, build_monitoring_get_alert_policy_request, + build_monitoring_get_app_cpu_percentage_metrics_request, + build_monitoring_get_app_memory_percentage_metrics_request, + build_monitoring_get_app_restart_count_metrics_yml_request, build_monitoring_get_droplet_bandwidth_metrics_request, build_monitoring_get_droplet_cpu_metrics_request, build_monitoring_get_droplet_filesystem_free_metrics_request, @@ -105243,6 +105246,330 @@ async def get_droplet_memory_available_metrics( return cast(JSON, deserialized) + @distributed_trace_async + async def get_app_memory_percentage_metrics( + self, + *, + app_id: str, + start: str, + end: str, + app_component: Optional[str] = None, + **kwargs: Any + ) -> JSON: + """Get App Memory Percentage Metrics. + + To retrieve memory percentage metrics for a given app, send a GET request to + ``/v2/monitoring/metrics/apps/memory_percentage``. + + :keyword app_id: The app UUID. Required. + :paramtype app_id: str + :keyword start: Timestamp to start metric window. Required. + :paramtype start: str + :keyword end: Timestamp to end metric window. Required. + :paramtype end: str + :keyword app_component: The app component name. Default value is None. + :paramtype app_component: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "data": { + "result": [ + { + "metric": { + "str": "str" # An object containing the + metric labels. Required. + }, + "values": [ + [ + {} + ] + ] + } + ], + "resultType": "str" # Required. "matrix" + }, + "status": "str" # Required. Known values are: "success" and "error". + } + """ + error_map = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 401: lambda response: ClientAuthenticationError(response=response), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[JSON] + + request = build_monitoring_get_app_memory_percentage_metrics_request( + app_id=app_id, + start=start, + end=end, + app_component=app_component, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error( + status_code=response.status_code, response=response, error_map=error_map + ) + raise HttpResponseError(response=response) + + response_headers = {} + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) + + return cast(JSON, deserialized) + + @distributed_trace_async + async def get_app_cpu_percentage_metrics( + self, + *, + app_id: str, + start: str, + end: str, + app_component: Optional[str] = None, + **kwargs: Any + ) -> JSON: + """Get App CPU Percentage Metrics. + + To retrieve cpu percentage metrics for a given app, send a GET request to + ``/v2/monitoring/metrics/apps/cpu_percentage``. + + :keyword app_id: The app UUID. Required. + :paramtype app_id: str + :keyword start: Timestamp to start metric window. Required. + :paramtype start: str + :keyword end: Timestamp to end metric window. Required. + :paramtype end: str + :keyword app_component: The app component name. Default value is None. + :paramtype app_component: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "data": { + "result": [ + { + "metric": { + "str": "str" # An object containing the + metric labels. Required. + }, + "values": [ + [ + {} + ] + ] + } + ], + "resultType": "str" # Required. "matrix" + }, + "status": "str" # Required. Known values are: "success" and "error". + } + """ + error_map = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 401: lambda response: ClientAuthenticationError(response=response), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[JSON] + + request = build_monitoring_get_app_cpu_percentage_metrics_request( + app_id=app_id, + start=start, + end=end, + app_component=app_component, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error( + status_code=response.status_code, response=response, error_map=error_map + ) + raise HttpResponseError(response=response) + + response_headers = {} + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) + + return cast(JSON, deserialized) + + @distributed_trace_async + async def get_app_restart_count_metrics_yml( + self, + *, + app_id: str, + start: str, + end: str, + app_component: Optional[str] = None, + **kwargs: Any + ) -> JSON: + """Get App Restart Count Metrics. + + To retrieve restart count metrics for a given app, send a GET request to + ``/v2/monitoring/metrics/apps/restart_count``. + + :keyword app_id: The app UUID. Required. + :paramtype app_id: str + :keyword start: Timestamp to start metric window. Required. + :paramtype start: str + :keyword end: Timestamp to end metric window. Required. + :paramtype end: str + :keyword app_component: The app component name. Default value is None. + :paramtype app_component: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "data": { + "result": [ + { + "metric": { + "str": "str" # An object containing the + metric labels. Required. + }, + "values": [ + [ + {} + ] + ] + } + ], + "resultType": "str" # Required. "matrix" + }, + "status": "str" # Required. Known values are: "success" and "error". + } + """ + error_map = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 401: lambda response: ClientAuthenticationError(response=response), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[JSON] + + request = build_monitoring_get_app_restart_count_metrics_yml_request( + app_id=app_id, + start=start, + end=end, + app_component=app_component, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error( + status_code=response.status_code, response=response, error_map=error_map + ) + raise HttpResponseError(response=response) + + response_headers = {} + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) + + return cast(JSON, deserialized) + class ProjectsOperations: """ diff --git a/src/pydo/operations/_operations.py b/src/pydo/operations/_operations.py index 404fe220..c6ae6dad 100644 --- a/src/pydo/operations/_operations.py +++ b/src/pydo/operations/_operations.py @@ -5161,6 +5161,105 @@ def build_monitoring_get_droplet_memory_available_metrics_request( ) +def build_monitoring_get_app_memory_percentage_metrics_request( + *, + app_id: str, + start: str, + end: str, + app_component: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/v2/monitoring/metrics/apps/memory_percentage" + + # Construct parameters + _params["app_id"] = _SERIALIZER.query("app_id", app_id, "str") + if app_component is not None: + _params["app_component"] = _SERIALIZER.query( + "app_component", app_component, "str" + ) + _params["start"] = _SERIALIZER.query("start", start, "str") + _params["end"] = _SERIALIZER.query("end", end, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest( + method="GET", url=_url, params=_params, headers=_headers, **kwargs + ) + + +def build_monitoring_get_app_cpu_percentage_metrics_request( + *, + app_id: str, + start: str, + end: str, + app_component: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/v2/monitoring/metrics/apps/cpu_percentage" + + # Construct parameters + _params["app_id"] = _SERIALIZER.query("app_id", app_id, "str") + if app_component is not None: + _params["app_component"] = _SERIALIZER.query( + "app_component", app_component, "str" + ) + _params["start"] = _SERIALIZER.query("start", start, "str") + _params["end"] = _SERIALIZER.query("end", end, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest( + method="GET", url=_url, params=_params, headers=_headers, **kwargs + ) + + +def build_monitoring_get_app_restart_count_metrics_yml_request( + *, + app_id: str, + start: str, + end: str, + app_component: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/v2/monitoring/metrics/apps/restart_count" + + # Construct parameters + _params["app_id"] = _SERIALIZER.query("app_id", app_id, "str") + if app_component is not None: + _params["app_component"] = _SERIALIZER.query( + "app_component", app_component, "str" + ) + _params["start"] = _SERIALIZER.query("start", start, "str") + _params["end"] = _SERIALIZER.query("end", end, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest( + method="GET", url=_url, params=_params, headers=_headers, **kwargs + ) + + def build_projects_list_request( *, per_page: int = 20, page: int = 1, **kwargs: Any ) -> HttpRequest: @@ -112000,6 +112099,330 @@ def get_droplet_memory_available_metrics( return cast(JSON, deserialized) + @distributed_trace + def get_app_memory_percentage_metrics( + self, + *, + app_id: str, + start: str, + end: str, + app_component: Optional[str] = None, + **kwargs: Any + ) -> JSON: + """Get App Memory Percentage Metrics. + + To retrieve memory percentage metrics for a given app, send a GET request to + ``/v2/monitoring/metrics/apps/memory_percentage``. + + :keyword app_id: The app UUID. Required. + :paramtype app_id: str + :keyword start: Timestamp to start metric window. Required. + :paramtype start: str + :keyword end: Timestamp to end metric window. Required. + :paramtype end: str + :keyword app_component: The app component name. Default value is None. + :paramtype app_component: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "data": { + "result": [ + { + "metric": { + "str": "str" # An object containing the + metric labels. Required. + }, + "values": [ + [ + {} + ] + ] + } + ], + "resultType": "str" # Required. "matrix" + }, + "status": "str" # Required. Known values are: "success" and "error". + } + """ + error_map = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 401: lambda response: ClientAuthenticationError(response=response), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[JSON] + + request = build_monitoring_get_app_memory_percentage_metrics_request( + app_id=app_id, + start=start, + end=end, + app_component=app_component, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error( + status_code=response.status_code, response=response, error_map=error_map + ) + raise HttpResponseError(response=response) + + response_headers = {} + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) + + return cast(JSON, deserialized) + + @distributed_trace + def get_app_cpu_percentage_metrics( + self, + *, + app_id: str, + start: str, + end: str, + app_component: Optional[str] = None, + **kwargs: Any + ) -> JSON: + """Get App CPU Percentage Metrics. + + To retrieve cpu percentage metrics for a given app, send a GET request to + ``/v2/monitoring/metrics/apps/cpu_percentage``. + + :keyword app_id: The app UUID. Required. + :paramtype app_id: str + :keyword start: Timestamp to start metric window. Required. + :paramtype start: str + :keyword end: Timestamp to end metric window. Required. + :paramtype end: str + :keyword app_component: The app component name. Default value is None. + :paramtype app_component: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "data": { + "result": [ + { + "metric": { + "str": "str" # An object containing the + metric labels. Required. + }, + "values": [ + [ + {} + ] + ] + } + ], + "resultType": "str" # Required. "matrix" + }, + "status": "str" # Required. Known values are: "success" and "error". + } + """ + error_map = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 401: lambda response: ClientAuthenticationError(response=response), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[JSON] + + request = build_monitoring_get_app_cpu_percentage_metrics_request( + app_id=app_id, + start=start, + end=end, + app_component=app_component, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error( + status_code=response.status_code, response=response, error_map=error_map + ) + raise HttpResponseError(response=response) + + response_headers = {} + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) + + return cast(JSON, deserialized) + + @distributed_trace + def get_app_restart_count_metrics_yml( + self, + *, + app_id: str, + start: str, + end: str, + app_component: Optional[str] = None, + **kwargs: Any + ) -> JSON: + """Get App Restart Count Metrics. + + To retrieve restart count metrics for a given app, send a GET request to + ``/v2/monitoring/metrics/apps/restart_count``. + + :keyword app_id: The app UUID. Required. + :paramtype app_id: str + :keyword start: Timestamp to start metric window. Required. + :paramtype start: str + :keyword end: Timestamp to end metric window. Required. + :paramtype end: str + :keyword app_component: The app component name. Default value is None. + :paramtype app_component: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "data": { + "result": [ + { + "metric": { + "str": "str" # An object containing the + metric labels. Required. + }, + "values": [ + [ + {} + ] + ] + } + ], + "resultType": "str" # Required. "matrix" + }, + "status": "str" # Required. Known values are: "success" and "error". + } + """ + error_map = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 401: lambda response: ClientAuthenticationError(response=response), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[JSON] + + request = build_monitoring_get_app_restart_count_metrics_yml_request( + app_id=app_id, + start=start, + end=end, + app_component=app_component, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error( + status_code=response.status_code, response=response, error_map=error_map + ) + raise HttpResponseError(response=response) + + response_headers = {} + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) + + return cast(JSON, deserialized) + class ProjectsOperations: """