diff --git a/DO_OPENAPI_COMMIT_SHA.txt b/DO_OPENAPI_COMMIT_SHA.txt index 113dac6..3e045b5 100644 --- a/DO_OPENAPI_COMMIT_SHA.txt +++ b/DO_OPENAPI_COMMIT_SHA.txt @@ -1 +1 @@ -49db048 +cf0a60a diff --git a/src/pydo/aio/operations/_operations.py b/src/pydo/aio/operations/_operations.py index 3b2a2c8..e68d312 100644 --- a/src/pydo/aio/operations/_operations.py +++ b/src/pydo/aio/operations/_operations.py @@ -378,6 +378,17 @@ 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_database_mysql_cpu_usage_request, + build_monitoring_get_database_mysql_disk_usage_request, + build_monitoring_get_database_mysql_index_vs_sequential_reads_request, + build_monitoring_get_database_mysql_load_request, + build_monitoring_get_database_mysql_memory_usage_request, + build_monitoring_get_database_mysql_op_rates_request, + build_monitoring_get_database_mysql_schema_latency_request, + build_monitoring_get_database_mysql_schema_throughput_request, + build_monitoring_get_database_mysql_threads_active_request, + build_monitoring_get_database_mysql_threads_connected_request, + build_monitoring_get_database_mysql_threads_created_rate_request, build_monitoring_get_destination_request, build_monitoring_get_droplet_autoscale_current_cpu_utilization_yml_request, build_monitoring_get_droplet_autoscale_current_instances_request, @@ -156624,6 +156635,1596 @@ async def get_droplet_autoscale_target_memory_utilization( # pylint: disable=na return cast(JSON, deserialized) # type: ignore + @distributed_trace_async + async def get_database_mysql_cpu_usage( + self, *, db_id: str, aggregate: str, start: str, end: str, **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Get Database MySQL CPU Usage Metrics. + + Retrieve CPU usage (percent) for a MySQL cluster. Response is a time series of cluster-level + CPU usage. Use **aggregate** to get avg, max, or min over the range. + + :keyword db_id: The DBaaS cluster UUID (database ID). Required. + :paramtype db_id: str + :keyword aggregate: Aggregation over the time range (avg, max, or min). Known values are: + "avg", "max", and "min". Required. + :paramtype aggregate: str + :keyword start: UNIX timestamp to start metric window. Required. + :paramtype start: str + :keyword end: UNIX timestamp to end metric window. Required. + :paramtype end: 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's labels. These labels are key/value pairs that vary + depending on the metric being queried. For example, load balancer + metrics contain a ``lb_id`` label, while Droplet metrics contain + a ``host_id`` label, and App Platform metrics contain a + ``app_component`` label. Required. + }, + "values": [ + [ + {} + ] + ] + } + ], + "resultType": "str" # Required. "matrix" + }, + "status": "str" # Required. Known values are: "success" and "error". + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + 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: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_monitoring_get_database_mysql_cpu_usage_request( + db_id=db_id, + aggregate=aggregate, + start=start, + end=end, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + 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 response.status_code == 404: + 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) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @distributed_trace_async + async def get_database_mysql_load( + self, + *, + db_id: str, + metric: str, + aggregate: str, + start: str, + end: str, + **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Get Database MySQL Load Average Metrics. + + Retrieve load metrics for a MySQL cluster. Use **metric** for the window: **load1** (1-minute), + **load5** (5-minute), or **load15** (15-minute). Use **aggregate** to get either the average + (avg) or maximum (max) over that window over the time range. + + :keyword db_id: The DBaaS cluster UUID (database ID). Required. + :paramtype db_id: str + :keyword metric: Load window: **load1** (1-minute), **load5** (5-minute), **load15** + (15-minute). The value is either average or max over that window, depending on the + **aggregate** parameter (avg or max). Known values are: "load1", "load5", and "load15". + Required. + :paramtype metric: str + :keyword aggregate: Aggregation over the time range (avg or max). Known values are: "avg" and + "max". Required. + :paramtype aggregate: str + :keyword start: UNIX timestamp to start metric window. Required. + :paramtype start: str + :keyword end: UNIX timestamp to end metric window. Required. + :paramtype end: 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's labels. These labels are key/value pairs that vary + depending on the metric being queried. For example, load balancer + metrics contain a ``lb_id`` label, while Droplet metrics contain + a ``host_id`` label, and App Platform metrics contain a + ``app_component`` label. Required. + }, + "values": [ + [ + {} + ] + ] + } + ], + "resultType": "str" # Required. "matrix" + }, + "status": "str" # Required. Known values are: "success" and "error". + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + 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: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_monitoring_get_database_mysql_load_request( + db_id=db_id, + metric=metric, + aggregate=aggregate, + start=start, + end=end, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + 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 response.status_code == 404: + 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) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @distributed_trace_async + async def get_database_mysql_memory_usage( + self, *, db_id: str, aggregate: str, start: str, end: str, **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Get Database MySQL Memory Usage Metrics. + + Retrieve memory usage (percent) for a MySQL cluster. Use **aggregate** (avg, max, or min) over + the time range. + + :keyword db_id: The DBaaS cluster UUID (database ID). Required. + :paramtype db_id: str + :keyword aggregate: Aggregation over the time range (avg, max, or min). Known values are: + "avg", "max", and "min". Required. + :paramtype aggregate: str + :keyword start: UNIX timestamp to start metric window. Required. + :paramtype start: str + :keyword end: UNIX timestamp to end metric window. Required. + :paramtype end: 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's labels. These labels are key/value pairs that vary + depending on the metric being queried. For example, load balancer + metrics contain a ``lb_id`` label, while Droplet metrics contain + a ``host_id`` label, and App Platform metrics contain a + ``app_component`` label. Required. + }, + "values": [ + [ + {} + ] + ] + } + ], + "resultType": "str" # Required. "matrix" + }, + "status": "str" # Required. Known values are: "success" and "error". + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + 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: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_monitoring_get_database_mysql_memory_usage_request( + db_id=db_id, + aggregate=aggregate, + start=start, + end=end, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + 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 response.status_code == 404: + 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) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @distributed_trace_async + async def get_database_mysql_disk_usage( + self, *, db_id: str, aggregate: str, start: str, end: str, **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Get Database MySQL Disk Usage Metrics. + + Retrieve disk usage (percent) for a MySQL cluster. Use **aggregate** (avg, max, or min) over + the time range. + + :keyword db_id: The DBaaS cluster UUID (database ID). Required. + :paramtype db_id: str + :keyword aggregate: Aggregation over the time range (avg, max, or min). Known values are: + "avg", "max", and "min". Required. + :paramtype aggregate: str + :keyword start: UNIX timestamp to start metric window. Required. + :paramtype start: str + :keyword end: UNIX timestamp to end metric window. Required. + :paramtype end: 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's labels. These labels are key/value pairs that vary + depending on the metric being queried. For example, load balancer + metrics contain a ``lb_id`` label, while Droplet metrics contain + a ``host_id`` label, and App Platform metrics contain a + ``app_component`` label. Required. + }, + "values": [ + [ + {} + ] + ] + } + ], + "resultType": "str" # Required. "matrix" + }, + "status": "str" # Required. Known values are: "success" and "error". + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + 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: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_monitoring_get_database_mysql_disk_usage_request( + db_id=db_id, + aggregate=aggregate, + start=start, + end=end, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + 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 response.status_code == 404: + 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) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @distributed_trace_async + async def get_database_mysql_threads_connected( + self, *, db_id: str, start: str, end: str, **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Get Database MySQL Threads Connected Metrics. + + Retrieve current threads connected for a MySQL service (gauge). + + :keyword db_id: The DBaaS cluster UUID (database ID). Required. + :paramtype db_id: str + :keyword start: UNIX timestamp to start metric window. Required. + :paramtype start: str + :keyword end: UNIX timestamp to end metric window. Required. + :paramtype end: 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's labels. These labels are key/value pairs that vary + depending on the metric being queried. For example, load balancer + metrics contain a ``lb_id`` label, while Droplet metrics contain + a ``host_id`` label, and App Platform metrics contain a + ``app_component`` label. Required. + }, + "values": [ + [ + {} + ] + ] + } + ], + "resultType": "str" # Required. "matrix" + }, + "status": "str" # Required. Known values are: "success" and "error". + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + 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: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_monitoring_get_database_mysql_threads_connected_request( + db_id=db_id, + start=start, + end=end, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + 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 response.status_code == 404: + 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) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @distributed_trace_async + async def get_database_mysql_threads_created_rate( + self, *, db_id: str, start: str, end: str, **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Get Database MySQL Threads Created Rate Metrics. + + Retrieve threads created rate for a MySQL service (per second). + + :keyword db_id: The DBaaS cluster UUID (database ID). Required. + :paramtype db_id: str + :keyword start: UNIX timestamp to start metric window. Required. + :paramtype start: str + :keyword end: UNIX timestamp to end metric window. Required. + :paramtype end: 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's labels. These labels are key/value pairs that vary + depending on the metric being queried. For example, load balancer + metrics contain a ``lb_id`` label, while Droplet metrics contain + a ``host_id`` label, and App Platform metrics contain a + ``app_component`` label. Required. + }, + "values": [ + [ + {} + ] + ] + } + ], + "resultType": "str" # Required. "matrix" + }, + "status": "str" # Required. Known values are: "success" and "error". + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + 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: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_monitoring_get_database_mysql_threads_created_rate_request( + db_id=db_id, + start=start, + end=end, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + 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 response.status_code == 404: + 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) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @distributed_trace_async + async def get_database_mysql_threads_active( + self, *, db_id: str, start: str, end: str, **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Get Database MySQL Threads Active Metrics. + + Retrieve active (running) threads for a MySQL service. + + :keyword db_id: The DBaaS cluster UUID (database ID). Required. + :paramtype db_id: str + :keyword start: UNIX timestamp to start metric window. Required. + :paramtype start: str + :keyword end: UNIX timestamp to end metric window. Required. + :paramtype end: 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's labels. These labels are key/value pairs that vary + depending on the metric being queried. For example, load balancer + metrics contain a ``lb_id`` label, while Droplet metrics contain + a ``host_id`` label, and App Platform metrics contain a + ``app_component`` label. Required. + }, + "values": [ + [ + {} + ] + ] + } + ], + "resultType": "str" # Required. "matrix" + }, + "status": "str" # Required. Known values are: "success" and "error". + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + 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: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_monitoring_get_database_mysql_threads_active_request( + db_id=db_id, + start=start, + end=end, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + 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 response.status_code == 404: + 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) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @distributed_trace_async + async def get_database_mysql_index_vs_sequential_reads( # pylint: disable=name-too-long + self, *, db_id: str, start: str, end: str, **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Get Database MySQL Index vs Sequential Reads Metrics. + + Retrieve index vs sequential reads ratio (percent) for a MySQL service — i.e. percentage of + reads using an index. + + :keyword db_id: The DBaaS cluster UUID (database ID). Required. + :paramtype db_id: str + :keyword start: UNIX timestamp to start metric window. Required. + :paramtype start: str + :keyword end: UNIX timestamp to end metric window. Required. + :paramtype end: 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's labels. These labels are key/value pairs that vary + depending on the metric being queried. For example, load balancer + metrics contain a ``lb_id`` label, while Droplet metrics contain + a ``host_id`` label, and App Platform metrics contain a + ``app_component`` label. Required. + }, + "values": [ + [ + {} + ] + ] + } + ], + "resultType": "str" # Required. "matrix" + }, + "status": "str" # Required. Known values are: "success" and "error". + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + 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: ClsType[JSON] = kwargs.pop("cls", None) + + _request = ( + build_monitoring_get_database_mysql_index_vs_sequential_reads_request( + db_id=db_id, + start=start, + end=end, + headers=_headers, + params=_params, + ) + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + 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 response.status_code == 404: + 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) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @distributed_trace_async + async def get_database_mysql_op_rates( + self, *, db_id: str, metric: str, start: str, end: str, **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Get Database MySQL Operations Throughput Metrics. + + Retrieve operations rate (per second) for a MySQL service. Use **metric** to choose select, + insert, update, or delete. + + :keyword db_id: The DBaaS cluster UUID (database ID). Required. + :paramtype db_id: str + :keyword metric: Operation type (select, insert, update, or delete). Known values are: + "select", "insert", "update", and "delete". Required. + :paramtype metric: str + :keyword start: UNIX timestamp to start metric window. Required. + :paramtype start: str + :keyword end: UNIX timestamp to end metric window. Required. + :paramtype end: 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's labels. These labels are key/value pairs that vary + depending on the metric being queried. For example, load balancer + metrics contain a ``lb_id`` label, while Droplet metrics contain + a ``host_id`` label, and App Platform metrics contain a + ``app_component`` label. Required. + }, + "values": [ + [ + {} + ] + ] + } + ], + "resultType": "str" # Required. "matrix" + }, + "status": "str" # Required. Known values are: "success" and "error". + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + 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: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_monitoring_get_database_mysql_op_rates_request( + db_id=db_id, + metric=metric, + start=start, + end=end, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + 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 response.status_code == 404: + 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) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @distributed_trace_async + async def get_database_mysql_schema_throughput( + self, + *, + db_id: str, + schema: str, + metric: str, + start: str, + end: str, + **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Get Database MySQL Schema Throughput Metrics. + + Retrieve table I/O throughput (rows per second) for a schema. Requires **schema** and + **metric** (insert, fetch, update, delete). + + :keyword db_id: The DBaaS cluster UUID (database ID). Required. + :paramtype db_id: str + :keyword schema: The schema (database) name. Required. + :paramtype schema: str + :keyword metric: Table I/O operation (insert, fetch, update, or delete). Known values are: + "insert", "fetch", "update", and "delete". Required. + :paramtype metric: str + :keyword start: UNIX timestamp to start metric window. Required. + :paramtype start: str + :keyword end: UNIX timestamp to end metric window. Required. + :paramtype end: 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's labels. These labels are key/value pairs that vary + depending on the metric being queried. For example, load balancer + metrics contain a ``lb_id`` label, while Droplet metrics contain + a ``host_id`` label, and App Platform metrics contain a + ``app_component`` label. Required. + }, + "values": [ + [ + {} + ] + ] + } + ], + "resultType": "str" # Required. "matrix" + }, + "status": "str" # Required. Known values are: "success" and "error". + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + 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: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_monitoring_get_database_mysql_schema_throughput_request( + db_id=db_id, + schema=schema, + metric=metric, + start=start, + end=end, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + 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 response.status_code == 404: + 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) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @distributed_trace_async + async def get_database_mysql_schema_latency( + self, + *, + db_id: str, + schema: str, + metric: str, + start: str, + end: str, + **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Get Database MySQL Schema Latency Metrics. + + Retrieve table I/O latency (seconds) for a schema. Requires **schema** and **metric** (insert, + fetch, update, delete). + + :keyword db_id: The DBaaS cluster UUID (database ID). Required. + :paramtype db_id: str + :keyword schema: The schema (database) name. Required. + :paramtype schema: str + :keyword metric: Table I/O operation (insert, fetch, update, or delete). Known values are: + "insert", "fetch", "update", and "delete". Required. + :paramtype metric: str + :keyword start: UNIX timestamp to start metric window. Required. + :paramtype start: str + :keyword end: UNIX timestamp to end metric window. Required. + :paramtype end: 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's labels. These labels are key/value pairs that vary + depending on the metric being queried. For example, load balancer + metrics contain a ``lb_id`` label, while Droplet metrics contain + a ``host_id`` label, and App Platform metrics contain a + ``app_component`` label. Required. + }, + "values": [ + [ + {} + ] + ] + } + ], + "resultType": "str" # Required. "matrix" + }, + "status": "str" # Required. Known values are: "success" and "error". + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + 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: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_monitoring_get_database_mysql_schema_latency_request( + db_id=db_id, + schema=schema, + metric=metric, + start=start, + end=end, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + 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 response.status_code == 404: + 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) # type: ignore + + return cast(JSON, deserialized) # type: ignore + @overload async def create_destination( self, body: JSON, *, content_type: str = "application/json", **kwargs: Any diff --git a/src/pydo/operations/_operations.py b/src/pydo/operations/_operations.py index 8045fb6..f06ed50 100644 --- a/src/pydo/operations/_operations.py +++ b/src/pydo/operations/_operations.py @@ -7528,6 +7528,280 @@ def build_monitoring_get_droplet_autoscale_target_memory_utilization_request( # ) +def build_monitoring_get_database_mysql_cpu_usage_request( # pylint: disable=name-too-long + *, db_id: str, aggregate: str, start: str, end: str, **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/database/mysql/cpu_usage" + + # Construct parameters + _params["db_id"] = _SERIALIZER.query("db_id", db_id, "str") + _params["aggregate"] = _SERIALIZER.query("aggregate", aggregate, "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_database_mysql_load_request( # pylint: disable=name-too-long + *, db_id: str, metric: str, aggregate: str, start: str, end: str, **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/database/mysql/load" + + # Construct parameters + _params["db_id"] = _SERIALIZER.query("db_id", db_id, "str") + _params["metric"] = _SERIALIZER.query("metric", metric, "str") + _params["aggregate"] = _SERIALIZER.query("aggregate", aggregate, "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_database_mysql_memory_usage_request( # pylint: disable=name-too-long + *, db_id: str, aggregate: str, start: str, end: str, **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/database/mysql/memory_usage" + + # Construct parameters + _params["db_id"] = _SERIALIZER.query("db_id", db_id, "str") + _params["aggregate"] = _SERIALIZER.query("aggregate", aggregate, "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_database_mysql_disk_usage_request( # pylint: disable=name-too-long + *, db_id: str, aggregate: str, start: str, end: str, **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/database/mysql/disk_usage" + + # Construct parameters + _params["db_id"] = _SERIALIZER.query("db_id", db_id, "str") + _params["aggregate"] = _SERIALIZER.query("aggregate", aggregate, "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_database_mysql_threads_connected_request( # pylint: disable=name-too-long + *, db_id: str, start: str, end: str, **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/database/mysql/threads_connected" + + # Construct parameters + _params["db_id"] = _SERIALIZER.query("db_id", db_id, "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_database_mysql_threads_created_rate_request( # pylint: disable=name-too-long + *, db_id: str, start: str, end: str, **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/database/mysql/threads_created_rate" + + # Construct parameters + _params["db_id"] = _SERIALIZER.query("db_id", db_id, "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_database_mysql_threads_active_request( # pylint: disable=name-too-long + *, db_id: str, start: str, end: str, **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/database/mysql/threads_active" + + # Construct parameters + _params["db_id"] = _SERIALIZER.query("db_id", db_id, "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_database_mysql_index_vs_sequential_reads_request( # pylint: disable=name-too-long + *, db_id: str, start: str, end: str, **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/database/mysql/index_vs_sequential_reads" + + # Construct parameters + _params["db_id"] = _SERIALIZER.query("db_id", db_id, "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_database_mysql_op_rates_request( # pylint: disable=name-too-long + *, db_id: str, metric: str, start: str, end: str, **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/database/mysql/op_rates" + + # Construct parameters + _params["db_id"] = _SERIALIZER.query("db_id", db_id, "str") + _params["metric"] = _SERIALIZER.query("metric", metric, "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_database_mysql_schema_throughput_request( # pylint: disable=name-too-long + *, db_id: str, schema: str, metric: str, start: str, end: str, **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/database/mysql/schema_throughput" + + # Construct parameters + _params["db_id"] = _SERIALIZER.query("db_id", db_id, "str") + _params["schema"] = _SERIALIZER.query("schema", schema, "str") + _params["metric"] = _SERIALIZER.query("metric", metric, "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_database_mysql_schema_latency_request( # pylint: disable=name-too-long + *, db_id: str, schema: str, metric: str, start: str, end: str, **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/database/mysql/schema_latency" + + # Construct parameters + _params["db_id"] = _SERIALIZER.query("db_id", db_id, "str") + _params["schema"] = _SERIALIZER.query("schema", schema, "str") + _params["metric"] = _SERIALIZER.query("metric", metric, "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_create_destination_request( **kwargs: Any, ) -> HttpRequest: # pylint: disable=name-too-long @@ -169535,6 +169809,1596 @@ def get_droplet_autoscale_target_memory_utilization( # pylint: disable=name-too return cast(JSON, deserialized) # type: ignore + @distributed_trace + def get_database_mysql_cpu_usage( + self, *, db_id: str, aggregate: str, start: str, end: str, **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Get Database MySQL CPU Usage Metrics. + + Retrieve CPU usage (percent) for a MySQL cluster. Response is a time series of cluster-level + CPU usage. Use **aggregate** to get avg, max, or min over the range. + + :keyword db_id: The DBaaS cluster UUID (database ID). Required. + :paramtype db_id: str + :keyword aggregate: Aggregation over the time range (avg, max, or min). Known values are: + "avg", "max", and "min". Required. + :paramtype aggregate: str + :keyword start: UNIX timestamp to start metric window. Required. + :paramtype start: str + :keyword end: UNIX timestamp to end metric window. Required. + :paramtype end: 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's labels. These labels are key/value pairs that vary + depending on the metric being queried. For example, load balancer + metrics contain a ``lb_id`` label, while Droplet metrics contain + a ``host_id`` label, and App Platform metrics contain a + ``app_component`` label. Required. + }, + "values": [ + [ + {} + ] + ] + } + ], + "resultType": "str" # Required. "matrix" + }, + "status": "str" # Required. Known values are: "success" and "error". + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + 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: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_monitoring_get_database_mysql_cpu_usage_request( + db_id=db_id, + aggregate=aggregate, + start=start, + end=end, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + 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 response.status_code == 404: + 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) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @distributed_trace + def get_database_mysql_load( + self, + *, + db_id: str, + metric: str, + aggregate: str, + start: str, + end: str, + **kwargs: Any, + ) -> JSON: + # pylint: disable=line-too-long + """Get Database MySQL Load Average Metrics. + + Retrieve load metrics for a MySQL cluster. Use **metric** for the window: **load1** (1-minute), + **load5** (5-minute), or **load15** (15-minute). Use **aggregate** to get either the average + (avg) or maximum (max) over that window over the time range. + + :keyword db_id: The DBaaS cluster UUID (database ID). Required. + :paramtype db_id: str + :keyword metric: Load window: **load1** (1-minute), **load5** (5-minute), **load15** + (15-minute). The value is either average or max over that window, depending on the + **aggregate** parameter (avg or max). Known values are: "load1", "load5", and "load15". + Required. + :paramtype metric: str + :keyword aggregate: Aggregation over the time range (avg or max). Known values are: "avg" and + "max". Required. + :paramtype aggregate: str + :keyword start: UNIX timestamp to start metric window. Required. + :paramtype start: str + :keyword end: UNIX timestamp to end metric window. Required. + :paramtype end: 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's labels. These labels are key/value pairs that vary + depending on the metric being queried. For example, load balancer + metrics contain a ``lb_id`` label, while Droplet metrics contain + a ``host_id`` label, and App Platform metrics contain a + ``app_component`` label. Required. + }, + "values": [ + [ + {} + ] + ] + } + ], + "resultType": "str" # Required. "matrix" + }, + "status": "str" # Required. Known values are: "success" and "error". + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + 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: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_monitoring_get_database_mysql_load_request( + db_id=db_id, + metric=metric, + aggregate=aggregate, + start=start, + end=end, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + 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 response.status_code == 404: + 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) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @distributed_trace + def get_database_mysql_memory_usage( + self, *, db_id: str, aggregate: str, start: str, end: str, **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Get Database MySQL Memory Usage Metrics. + + Retrieve memory usage (percent) for a MySQL cluster. Use **aggregate** (avg, max, or min) over + the time range. + + :keyword db_id: The DBaaS cluster UUID (database ID). Required. + :paramtype db_id: str + :keyword aggregate: Aggregation over the time range (avg, max, or min). Known values are: + "avg", "max", and "min". Required. + :paramtype aggregate: str + :keyword start: UNIX timestamp to start metric window. Required. + :paramtype start: str + :keyword end: UNIX timestamp to end metric window. Required. + :paramtype end: 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's labels. These labels are key/value pairs that vary + depending on the metric being queried. For example, load balancer + metrics contain a ``lb_id`` label, while Droplet metrics contain + a ``host_id`` label, and App Platform metrics contain a + ``app_component`` label. Required. + }, + "values": [ + [ + {} + ] + ] + } + ], + "resultType": "str" # Required. "matrix" + }, + "status": "str" # Required. Known values are: "success" and "error". + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + 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: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_monitoring_get_database_mysql_memory_usage_request( + db_id=db_id, + aggregate=aggregate, + start=start, + end=end, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + 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 response.status_code == 404: + 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) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @distributed_trace + def get_database_mysql_disk_usage( + self, *, db_id: str, aggregate: str, start: str, end: str, **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Get Database MySQL Disk Usage Metrics. + + Retrieve disk usage (percent) for a MySQL cluster. Use **aggregate** (avg, max, or min) over + the time range. + + :keyword db_id: The DBaaS cluster UUID (database ID). Required. + :paramtype db_id: str + :keyword aggregate: Aggregation over the time range (avg, max, or min). Known values are: + "avg", "max", and "min". Required. + :paramtype aggregate: str + :keyword start: UNIX timestamp to start metric window. Required. + :paramtype start: str + :keyword end: UNIX timestamp to end metric window. Required. + :paramtype end: 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's labels. These labels are key/value pairs that vary + depending on the metric being queried. For example, load balancer + metrics contain a ``lb_id`` label, while Droplet metrics contain + a ``host_id`` label, and App Platform metrics contain a + ``app_component`` label. Required. + }, + "values": [ + [ + {} + ] + ] + } + ], + "resultType": "str" # Required. "matrix" + }, + "status": "str" # Required. Known values are: "success" and "error". + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + 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: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_monitoring_get_database_mysql_disk_usage_request( + db_id=db_id, + aggregate=aggregate, + start=start, + end=end, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + 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 response.status_code == 404: + 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) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @distributed_trace + def get_database_mysql_threads_connected( + self, *, db_id: str, start: str, end: str, **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Get Database MySQL Threads Connected Metrics. + + Retrieve current threads connected for a MySQL service (gauge). + + :keyword db_id: The DBaaS cluster UUID (database ID). Required. + :paramtype db_id: str + :keyword start: UNIX timestamp to start metric window. Required. + :paramtype start: str + :keyword end: UNIX timestamp to end metric window. Required. + :paramtype end: 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's labels. These labels are key/value pairs that vary + depending on the metric being queried. For example, load balancer + metrics contain a ``lb_id`` label, while Droplet metrics contain + a ``host_id`` label, and App Platform metrics contain a + ``app_component`` label. Required. + }, + "values": [ + [ + {} + ] + ] + } + ], + "resultType": "str" # Required. "matrix" + }, + "status": "str" # Required. Known values are: "success" and "error". + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + 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: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_monitoring_get_database_mysql_threads_connected_request( + db_id=db_id, + start=start, + end=end, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + 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 response.status_code == 404: + 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) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @distributed_trace + def get_database_mysql_threads_created_rate( + self, *, db_id: str, start: str, end: str, **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Get Database MySQL Threads Created Rate Metrics. + + Retrieve threads created rate for a MySQL service (per second). + + :keyword db_id: The DBaaS cluster UUID (database ID). Required. + :paramtype db_id: str + :keyword start: UNIX timestamp to start metric window. Required. + :paramtype start: str + :keyword end: UNIX timestamp to end metric window. Required. + :paramtype end: 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's labels. These labels are key/value pairs that vary + depending on the metric being queried. For example, load balancer + metrics contain a ``lb_id`` label, while Droplet metrics contain + a ``host_id`` label, and App Platform metrics contain a + ``app_component`` label. Required. + }, + "values": [ + [ + {} + ] + ] + } + ], + "resultType": "str" # Required. "matrix" + }, + "status": "str" # Required. Known values are: "success" and "error". + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + 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: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_monitoring_get_database_mysql_threads_created_rate_request( + db_id=db_id, + start=start, + end=end, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + 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 response.status_code == 404: + 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) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @distributed_trace + def get_database_mysql_threads_active( + self, *, db_id: str, start: str, end: str, **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Get Database MySQL Threads Active Metrics. + + Retrieve active (running) threads for a MySQL service. + + :keyword db_id: The DBaaS cluster UUID (database ID). Required. + :paramtype db_id: str + :keyword start: UNIX timestamp to start metric window. Required. + :paramtype start: str + :keyword end: UNIX timestamp to end metric window. Required. + :paramtype end: 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's labels. These labels are key/value pairs that vary + depending on the metric being queried. For example, load balancer + metrics contain a ``lb_id`` label, while Droplet metrics contain + a ``host_id`` label, and App Platform metrics contain a + ``app_component`` label. Required. + }, + "values": [ + [ + {} + ] + ] + } + ], + "resultType": "str" # Required. "matrix" + }, + "status": "str" # Required. Known values are: "success" and "error". + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + 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: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_monitoring_get_database_mysql_threads_active_request( + db_id=db_id, + start=start, + end=end, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + 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 response.status_code == 404: + 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) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @distributed_trace + def get_database_mysql_index_vs_sequential_reads( # pylint: disable=name-too-long + self, *, db_id: str, start: str, end: str, **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Get Database MySQL Index vs Sequential Reads Metrics. + + Retrieve index vs sequential reads ratio (percent) for a MySQL service — i.e. percentage of + reads using an index. + + :keyword db_id: The DBaaS cluster UUID (database ID). Required. + :paramtype db_id: str + :keyword start: UNIX timestamp to start metric window. Required. + :paramtype start: str + :keyword end: UNIX timestamp to end metric window. Required. + :paramtype end: 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's labels. These labels are key/value pairs that vary + depending on the metric being queried. For example, load balancer + metrics contain a ``lb_id`` label, while Droplet metrics contain + a ``host_id`` label, and App Platform metrics contain a + ``app_component`` label. Required. + }, + "values": [ + [ + {} + ] + ] + } + ], + "resultType": "str" # Required. "matrix" + }, + "status": "str" # Required. Known values are: "success" and "error". + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + 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: ClsType[JSON] = kwargs.pop("cls", None) + + _request = ( + build_monitoring_get_database_mysql_index_vs_sequential_reads_request( + db_id=db_id, + start=start, + end=end, + headers=_headers, + params=_params, + ) + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + 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 response.status_code == 404: + 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) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @distributed_trace + def get_database_mysql_op_rates( + self, *, db_id: str, metric: str, start: str, end: str, **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Get Database MySQL Operations Throughput Metrics. + + Retrieve operations rate (per second) for a MySQL service. Use **metric** to choose select, + insert, update, or delete. + + :keyword db_id: The DBaaS cluster UUID (database ID). Required. + :paramtype db_id: str + :keyword metric: Operation type (select, insert, update, or delete). Known values are: + "select", "insert", "update", and "delete". Required. + :paramtype metric: str + :keyword start: UNIX timestamp to start metric window. Required. + :paramtype start: str + :keyword end: UNIX timestamp to end metric window. Required. + :paramtype end: 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's labels. These labels are key/value pairs that vary + depending on the metric being queried. For example, load balancer + metrics contain a ``lb_id`` label, while Droplet metrics contain + a ``host_id`` label, and App Platform metrics contain a + ``app_component`` label. Required. + }, + "values": [ + [ + {} + ] + ] + } + ], + "resultType": "str" # Required. "matrix" + }, + "status": "str" # Required. Known values are: "success" and "error". + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + 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: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_monitoring_get_database_mysql_op_rates_request( + db_id=db_id, + metric=metric, + start=start, + end=end, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + 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 response.status_code == 404: + 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) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @distributed_trace + def get_database_mysql_schema_throughput( + self, + *, + db_id: str, + schema: str, + metric: str, + start: str, + end: str, + **kwargs: Any, + ) -> JSON: + # pylint: disable=line-too-long + """Get Database MySQL Schema Throughput Metrics. + + Retrieve table I/O throughput (rows per second) for a schema. Requires **schema** and + **metric** (insert, fetch, update, delete). + + :keyword db_id: The DBaaS cluster UUID (database ID). Required. + :paramtype db_id: str + :keyword schema: The schema (database) name. Required. + :paramtype schema: str + :keyword metric: Table I/O operation (insert, fetch, update, or delete). Known values are: + "insert", "fetch", "update", and "delete". Required. + :paramtype metric: str + :keyword start: UNIX timestamp to start metric window. Required. + :paramtype start: str + :keyword end: UNIX timestamp to end metric window. Required. + :paramtype end: 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's labels. These labels are key/value pairs that vary + depending on the metric being queried. For example, load balancer + metrics contain a ``lb_id`` label, while Droplet metrics contain + a ``host_id`` label, and App Platform metrics contain a + ``app_component`` label. Required. + }, + "values": [ + [ + {} + ] + ] + } + ], + "resultType": "str" # Required. "matrix" + }, + "status": "str" # Required. Known values are: "success" and "error". + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + 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: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_monitoring_get_database_mysql_schema_throughput_request( + db_id=db_id, + schema=schema, + metric=metric, + start=start, + end=end, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + 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 response.status_code == 404: + 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) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @distributed_trace + def get_database_mysql_schema_latency( + self, + *, + db_id: str, + schema: str, + metric: str, + start: str, + end: str, + **kwargs: Any, + ) -> JSON: + # pylint: disable=line-too-long + """Get Database MySQL Schema Latency Metrics. + + Retrieve table I/O latency (seconds) for a schema. Requires **schema** and **metric** (insert, + fetch, update, delete). + + :keyword db_id: The DBaaS cluster UUID (database ID). Required. + :paramtype db_id: str + :keyword schema: The schema (database) name. Required. + :paramtype schema: str + :keyword metric: Table I/O operation (insert, fetch, update, or delete). Known values are: + "insert", "fetch", "update", and "delete". Required. + :paramtype metric: str + :keyword start: UNIX timestamp to start metric window. Required. + :paramtype start: str + :keyword end: UNIX timestamp to end metric window. Required. + :paramtype end: 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's labels. These labels are key/value pairs that vary + depending on the metric being queried. For example, load balancer + metrics contain a ``lb_id`` label, while Droplet metrics contain + a ``host_id`` label, and App Platform metrics contain a + ``app_component`` label. Required. + }, + "values": [ + [ + {} + ] + ] + } + ], + "resultType": "str" # Required. "matrix" + }, + "status": "str" # Required. Known values are: "success" and "error". + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + 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: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_monitoring_get_database_mysql_schema_latency_request( + db_id=db_id, + schema=schema, + metric=metric, + start=start, + end=end, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + 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 response.status_code == 404: + 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) # type: ignore + + return cast(JSON, deserialized) # type: ignore + @overload def create_destination( self, body: JSON, *, content_type: str = "application/json", **kwargs: Any