From 663dac1ee2467743cff18d043d5438f625ae28cc Mon Sep 17 00:00:00 2001 From: Peter Turi Date: Fri, 5 Jul 2024 00:06:12 +0200 Subject: [PATCH] chore: regen api (#1150) --- api/client/node/schemas/openapi.ts | 25 +++++++ .../src/openmeter/_operations/_operations.py | 67 +++++++++++++++++++ .../openmeter/aio/_operations/_operations.py | 54 +++++++++++++++ api/client/web/src/client/openapi.ts | 25 +++++++ 4 files changed, 171 insertions(+) diff --git a/api/client/node/schemas/openapi.ts b/api/client/node/schemas/openapi.ts index 8d350dd30..0b6d0cb50 100644 --- a/api/client/node/schemas/openapi.ts +++ b/api/client/node/schemas/openapi.ts @@ -228,6 +228,14 @@ export interface paths { */ post: operations['resetEntitlementUsage'] } + '/api/v1/debug/metrics': { + /** + * Get event metrics + * @description Returns debug metrics like the number of ingested events since mindnight UTC. + * The OpenMetrics Counter(s) reset every day at midnight UTC. + */ + get: operations['getDebugMetrics'] + } } export type webhooks = Record @@ -2094,4 +2102,21 @@ export interface operations { default: components['responses']['UnexpectedProblemResponse'] } } + /** + * Get event metrics + * @description Returns debug metrics like the number of ingested events since mindnight UTC. + * The OpenMetrics Counter(s) reset every day at midnight UTC. + */ + getDebugMetrics: { + responses: { + /** @description Dbeug metrics, like number of ingested events. */ + 200: { + content: { + 'text/plain': string + } + } + 401: components['responses']['UnauthorizedProblemResponse'] + default: components['responses']['UnexpectedProblemResponse'] + } + } } diff --git a/api/client/python/src/openmeter/_operations/_operations.py b/api/client/python/src/openmeter/_operations/_operations.py index 45b03d98c..dd03ffd78 100644 --- a/api/client/python/src/openmeter/_operations/_operations.py +++ b/api/client/python/src/openmeter/_operations/_operations.py @@ -777,6 +777,20 @@ def build_reset_entitlement_usage_request(subject_id_or_key: str, entitlement_id return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs) +def build_get_debug_metrics_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + + accept = _headers.pop("Accept", "text/plain, application/problem+json") + + # Construct URL + _url = "/api/v1/debug/metrics" + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, headers=_headers, **kwargs) + + class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-methods @distributed_trace def list_events( @@ -4648,3 +4662,56 @@ def reset_entitlement_usage( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def get_debug_metrics(self, **kwargs: Any) -> str: + """Get event metrics. + + Returns debug metrics like the number of ingested events since mindnight UTC. + The OpenMetrics Counter(s) reset every day at midnight UTC. + + :return: str + :rtype: str + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: lambda response: ClientAuthenticationError(response=response), + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[str] = kwargs.pop("cls", None) + + _request = build_get_debug_metrics_request( + 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]: + 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) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(str, deserialized), {}) # type: ignore + + return cast(str, deserialized) # type: ignore diff --git a/api/client/python/src/openmeter/aio/_operations/_operations.py b/api/client/python/src/openmeter/aio/_operations/_operations.py index 1ba82a3ee..4cf8eaee9 100644 --- a/api/client/python/src/openmeter/aio/_operations/_operations.py +++ b/api/client/python/src/openmeter/aio/_operations/_operations.py @@ -32,6 +32,7 @@ build_delete_feature_request, build_delete_meter_request, build_delete_subject_request, + build_get_debug_metrics_request, build_get_entitlement_history_request, build_get_entitlement_request, build_get_entitlement_value_request, @@ -3946,3 +3947,56 @@ async def reset_entitlement_usage( # pylint: disable=inconsistent-return-statem if cls: return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace_async + async def get_debug_metrics(self, **kwargs: Any) -> str: + """Get event metrics. + + Returns debug metrics like the number of ingested events since mindnight UTC. + The OpenMetrics Counter(s) reset every day at midnight UTC. + + :return: str + :rtype: str + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: lambda response: ClientAuthenticationError(response=response), + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[str] = kwargs.pop("cls", None) + + _request = build_get_debug_metrics_request( + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(str, deserialized), {}) # type: ignore + + return cast(str, deserialized) # type: ignore diff --git a/api/client/web/src/client/openapi.ts b/api/client/web/src/client/openapi.ts index 8d350dd30..0b6d0cb50 100644 --- a/api/client/web/src/client/openapi.ts +++ b/api/client/web/src/client/openapi.ts @@ -228,6 +228,14 @@ export interface paths { */ post: operations['resetEntitlementUsage'] } + '/api/v1/debug/metrics': { + /** + * Get event metrics + * @description Returns debug metrics like the number of ingested events since mindnight UTC. + * The OpenMetrics Counter(s) reset every day at midnight UTC. + */ + get: operations['getDebugMetrics'] + } } export type webhooks = Record @@ -2094,4 +2102,21 @@ export interface operations { default: components['responses']['UnexpectedProblemResponse'] } } + /** + * Get event metrics + * @description Returns debug metrics like the number of ingested events since mindnight UTC. + * The OpenMetrics Counter(s) reset every day at midnight UTC. + */ + getDebugMetrics: { + responses: { + /** @description Dbeug metrics, like number of ingested events. */ + 200: { + content: { + 'text/plain': string + } + } + 401: components['responses']['UnauthorizedProblemResponse'] + default: components['responses']['UnexpectedProblemResponse'] + } + } }