diff --git a/DO_OPENAPI_COMMIT_SHA.txt b/DO_OPENAPI_COMMIT_SHA.txt index 5c897da7..0d7f063d 100644 --- a/DO_OPENAPI_COMMIT_SHA.txt +++ b/DO_OPENAPI_COMMIT_SHA.txt @@ -1 +1 @@ -380d7ee +1932316 diff --git a/docs/source/pydo.resources.aio.inference.audio.rst b/docs/source/pydo.resources.aio.inference.audio.rst new file mode 100644 index 00000000..53b01025 --- /dev/null +++ b/docs/source/pydo.resources.aio.inference.audio.rst @@ -0,0 +1,21 @@ +pydo.resources.aio.inference.audio package +========================================== + +Submodules +---------- + +pydo.resources.aio.inference.audio.speech module +------------------------------------------------ + +.. automodule:: pydo.resources.aio.inference.audio.speech + :members: + :undoc-members: + :show-inheritance: + +Module contents +--------------- + +.. automodule:: pydo.resources.aio.inference.audio + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/source/pydo.resources.aio.inference.videos.rst b/docs/source/pydo.resources.aio.inference.videos.rst new file mode 100644 index 00000000..a4fc12f0 --- /dev/null +++ b/docs/source/pydo.resources.aio.inference.videos.rst @@ -0,0 +1,21 @@ +pydo.resources.aio.inference.videos package +=========================================== + +Submodules +---------- + +pydo.resources.aio.inference.videos.content module +-------------------------------------------------- + +.. automodule:: pydo.resources.aio.inference.videos.content + :members: + :undoc-members: + :show-inheritance: + +Module contents +--------------- + +.. automodule:: pydo.resources.aio.inference.videos + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/source/pydo.resources.inference.audio.rst b/docs/source/pydo.resources.inference.audio.rst new file mode 100644 index 00000000..4428a496 --- /dev/null +++ b/docs/source/pydo.resources.inference.audio.rst @@ -0,0 +1,21 @@ +pydo.resources.inference.audio package +====================================== + +Submodules +---------- + +pydo.resources.inference.audio.speech module +-------------------------------------------- + +.. automodule:: pydo.resources.inference.audio.speech + :members: + :undoc-members: + :show-inheritance: + +Module contents +--------------- + +.. automodule:: pydo.resources.inference.audio + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/source/pydo.resources.inference.videos.rst b/docs/source/pydo.resources.inference.videos.rst new file mode 100644 index 00000000..3bfa31fd --- /dev/null +++ b/docs/source/pydo.resources.inference.videos.rst @@ -0,0 +1,21 @@ +pydo.resources.inference.videos package +======================================= + +Submodules +---------- + +pydo.resources.inference.videos.content module +---------------------------------------------- + +.. automodule:: pydo.resources.inference.videos.content + :members: + :undoc-members: + :show-inheritance: + +Module contents +--------------- + +.. automodule:: pydo.resources.inference.videos + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/source/pydo.types.audio.rst b/docs/source/pydo.types.audio.rst new file mode 100644 index 00000000..2cda1b65 --- /dev/null +++ b/docs/source/pydo.types.audio.rst @@ -0,0 +1,10 @@ +pydo.types.audio package +======================== + +Module contents +--------------- + +.. automodule:: pydo.types.audio + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/source/pydo.types.videos.rst b/docs/source/pydo.types.videos.rst new file mode 100644 index 00000000..c35963b4 --- /dev/null +++ b/docs/source/pydo.types.videos.rst @@ -0,0 +1,10 @@ +pydo.types.videos package +========================= + +Module contents +--------------- + +.. automodule:: pydo.types.videos + :members: + :undoc-members: + :show-inheritance: diff --git a/src/pydo/aio/operations/_operations.py b/src/pydo/aio/operations/_operations.py index 6fbc0da9..429e7866 100644 --- a/src/pydo/aio/operations/_operations.py +++ b/src/pydo/aio/operations/_operations.py @@ -486,9 +486,13 @@ build_inference_create_image_request, build_inference_create_messages_request, build_inference_create_response_request, + build_inference_create_speech_request, build_inference_create_systemone_request, + build_inference_create_video_request, build_inference_get_batch_request, build_inference_get_batch_results_request, + build_inference_get_video_content_request, + build_inference_get_video_request, build_inference_list_batches_request, build_inference_list_models_request, build_inference_upload_batch_file_request, @@ -504,15 +508,18 @@ build_insights_get_prom_query_range_request, build_insights_get_prom_query_request, build_insights_get_prom_series_request, + build_insights_get_resource_request, build_insights_get_trace_request, build_insights_list_alert_instances_request, build_insights_list_alert_rules_request, build_insights_list_notification_channels_request, + build_insights_list_resources_request, build_insights_post_logs_search_request, build_insights_post_spans_search_request, build_insights_post_traces_search_request, build_insights_update_alert_rule_request, build_insights_update_notification_channel_request, + build_insights_update_resource_signals_request, build_invoices_get_by_uuid_request, build_invoices_get_csv_by_uuid_request, build_invoices_get_pdf_by_uuid_request, @@ -187225,6 +187232,718 @@ async def post_spans_search( return cast(JSON, deserialized) # type: ignore + @distributed_trace_async + async def list_resources( + self, + *, + filter_product_types: Optional[List[str]] = None, + filter_regions: Optional[List[str]] = None, + pagination_page: int = 1, + pagination_per_page: int = 20, + pagination_sort: Optional[str] = None, + pagination_sort_direction: Optional[str] = None, + **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """List Resource Signal Enablement. + + To list the resources in your account that have telemetry signal enablement + recorded, along with the current state of their metrics, logs, and traces + signals, send a GET request to ``/v2/insights/resources``. + + Results are paginated with ``pagination.page`` and ``pagination.per_page`` + (default ``20``\\ , maximum ``200``\\ ) and can be sorted with ``pagination.sort`` and + ``pagination.sort_direction``. Optionally filter by ``filter.product_types`` and + ``filter.regions``. + + A signal is omitted from a resource when no explicit enablement has ever been + recorded for it. + + :keyword filter_product_types: Optional filter. When set, only resources of these product types + are returned. Repeat the parameter for multiple product types. Default value is None. + :paramtype filter_product_types: list[str] + :keyword filter_regions: Optional filter. When set, only resources in these regions are + returned. Repeat the parameter for multiple regions. Default value is None. + :paramtype filter_regions: list[str] + :keyword pagination_page: Which 'page' of paginated results to return. Default value is 1. + :paramtype pagination_page: int + :keyword pagination_per_page: Number of items returned per page. Default value is 20. + :paramtype pagination_per_page: int + :keyword pagination_sort: Field to sort by. Defaults to ``resource_urn``. Known values are: + "resource_urn" and "effective_at". Default value is None. + :paramtype pagination_sort: str + :keyword pagination_sort_direction: Sort direction. Defaults to ``asc``. Known values are: + "asc" and "desc". Default value is None. + :paramtype pagination_sort_direction: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "pagination": { + "page": 0, # Optional. The current page number. + "pages": 0, # Optional. The total number of pages. Omitted when + there are no results. + "per_page": 0, # Optional. The number of items per page. + "total": 0 # Optional. The total number of resources across all + pages. Omitted when there are no results. + }, + "resources": [ + { + "product_type": "str", # The product type of the resource, + for example ``droplet`` or ``kubernetes``. Required. + "resource_urn": "str", # The uniform resource name (URN) of + the resource. Required. + "logs": { + "effective_at": "2020-02-20 00:00:00", # Optional. + When this signal state last changed. + "enabled": bool # Optional. Whether the signal is + enabled for the resource. + }, + "metrics": { + "effective_at": "2020-02-20 00:00:00", # Optional. + When this signal state last changed. + "enabled": bool # Optional. Whether the signal is + enabled for the resource. + }, + "region": "str", # Optional. The region slug for + region-specific resources. Omitted when the resource has no region. + "traces": { + "effective_at": "2020-02-20 00:00:00", # Optional. + When this signal state last changed. + "enabled": bool # Optional. Whether the signal is + enabled for the resource. + } + } + ] + } + # response body for status code(s): 400 + 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_insights_list_resources_request( + filter_product_types=filter_product_types, + filter_regions=filter_regions, + pagination_page=pagination_page, + pagination_per_page=pagination_per_page, + pagination_sort=pagination_sort, + pagination_sort_direction=pagination_sort_direction, + 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, 400]: + 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 == 400: + 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_resource(self, resource_urn: str, **kwargs: Any) -> JSON: + # pylint: disable=line-too-long + """Retrieve Resource Signal Enablement. + + To retrieve the current metrics, logs, and traces signal enablement for a + single resource, send a GET request to + ``/v2/insights/resources/{resource_urn}``. + + A ``404`` is returned when no signal enablement has been recorded for the + resource. + + :param resource_urn: The uniform resource name (URN) of the resource, for example + ``do:droplet:12345``. Required. + :type resource_urn: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "resource": { + "product_type": "str", # The product type of the resource, for + example ``droplet`` or ``kubernetes``. Required. + "resource_urn": "str", # The uniform resource name (URN) of the + resource. Required. + "logs": { + "effective_at": "2020-02-20 00:00:00", # Optional. When this + signal state last changed. + "enabled": bool # Optional. Whether the signal is enabled + for the resource. + }, + "metrics": { + "effective_at": "2020-02-20 00:00:00", # Optional. When this + signal state last changed. + "enabled": bool # Optional. Whether the signal is enabled + for the resource. + }, + "region": "str", # Optional. The region slug for region-specific + resources. Omitted when the resource has no region. + "traces": { + "effective_at": "2020-02-20 00:00:00", # Optional. When this + signal state last changed. + "enabled": bool # Optional. Whether the signal is enabled + for the resource. + } + } + } + # response body for status code(s): 400, 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_insights_get_resource_request( + resource_urn=resource_urn, + 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, 400, 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 == 400: + 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 update_resource_signals( + self, + resource_urn: str, + body: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Update Resource Signal Enablement. + + To enable or disable telemetry signals for a resource, send a PUT request to + ``/v2/insights/resources/{resource_urn}/signals``. + + This endpoint uses merge semantics. Set ``metrics``\\ , ``logs``\\ , or ``traces`` to + ``true`` or ``false`` to change that signal; omit a signal to leave it unchanged. + At least one signal must be set. + + ``region`` is only used when the resource has no existing enablement. On later + updates, omit it or send the stored value; changing the region is rejected + with a ``400``. + + Requires both the ``insights:update`` and ``insights:create`` scopes. + + :param resource_urn: The uniform resource name (URN) of the resource, for example + ``do:droplet:12345``. Required. + :type resource_urn: str + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "logs": bool, # Optional. Enable or disable the logs signal. Omit to leave + unchanged. + "metrics": bool, # Optional. Enable or disable the metrics signal. Omit to + leave unchanged. + "region": "str", # Optional. The region slug for region-specific resources. + Only used when the resource has no existing enablement. On later updates, omit it + or send the stored value; changing the region is rejected. + "traces": bool # Optional. Enable or disable the traces signal. Omit to + leave unchanged. + } + + # response body for status code(s): 200 + response == { + "resource": { + "product_type": "str", # The product type of the resource, for + example ``droplet`` or ``kubernetes``. Required. + "resource_urn": "str", # The uniform resource name (URN) of the + resource. Required. + "logs": { + "effective_at": "2020-02-20 00:00:00", # Optional. When this + signal state last changed. + "enabled": bool # Optional. Whether the signal is enabled + for the resource. + }, + "metrics": { + "effective_at": "2020-02-20 00:00:00", # Optional. When this + signal state last changed. + "enabled": bool # Optional. Whether the signal is enabled + for the resource. + }, + "region": "str", # Optional. The region slug for region-specific + resources. Omitted when the resource has no region. + "traces": { + "effective_at": "2020-02-20 00:00:00", # Optional. When this + signal state last changed. + "enabled": bool # Optional. Whether the signal is enabled + for the resource. + } + } + } + # response body for status code(s): 400, 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. + } + """ + + @overload + async def update_resource_signals( + self, + resource_urn: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Update Resource Signal Enablement. + + To enable or disable telemetry signals for a resource, send a PUT request to + ``/v2/insights/resources/{resource_urn}/signals``. + + This endpoint uses merge semantics. Set ``metrics``\\ , ``logs``\\ , or ``traces`` to + ``true`` or ``false`` to change that signal; omit a signal to leave it unchanged. + At least one signal must be set. + + ``region`` is only used when the resource has no existing enablement. On later + updates, omit it or send the stored value; changing the region is rejected + with a ``400``. + + Requires both the ``insights:update`` and ``insights:create`` scopes. + + :param resource_urn: The uniform resource name (URN) of the resource, for example + ``do:droplet:12345``. Required. + :type resource_urn: str + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "resource": { + "product_type": "str", # The product type of the resource, for + example ``droplet`` or ``kubernetes``. Required. + "resource_urn": "str", # The uniform resource name (URN) of the + resource. Required. + "logs": { + "effective_at": "2020-02-20 00:00:00", # Optional. When this + signal state last changed. + "enabled": bool # Optional. Whether the signal is enabled + for the resource. + }, + "metrics": { + "effective_at": "2020-02-20 00:00:00", # Optional. When this + signal state last changed. + "enabled": bool # Optional. Whether the signal is enabled + for the resource. + }, + "region": "str", # Optional. The region slug for region-specific + resources. Omitted when the resource has no region. + "traces": { + "effective_at": "2020-02-20 00:00:00", # Optional. When this + signal state last changed. + "enabled": bool # Optional. Whether the signal is enabled + for the resource. + } + } + } + # response body for status code(s): 400, 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. + } + """ + + @distributed_trace_async + async def update_resource_signals( + self, resource_urn: str, body: Union[JSON, IO[bytes]], **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Update Resource Signal Enablement. + + To enable or disable telemetry signals for a resource, send a PUT request to + ``/v2/insights/resources/{resource_urn}/signals``. + + This endpoint uses merge semantics. Set ``metrics``\\ , ``logs``\\ , or ``traces`` to + ``true`` or ``false`` to change that signal; omit a signal to leave it unchanged. + At least one signal must be set. + + ``region`` is only used when the resource has no existing enablement. On later + updates, omit it or send the stored value; changing the region is rejected + with a ``400``. + + Requires both the ``insights:update`` and ``insights:create`` scopes. + + :param resource_urn: The uniform resource name (URN) of the resource, for example + ``do:droplet:12345``. Required. + :type resource_urn: str + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "logs": bool, # Optional. Enable or disable the logs signal. Omit to leave + unchanged. + "metrics": bool, # Optional. Enable or disable the metrics signal. Omit to + leave unchanged. + "region": "str", # Optional. The region slug for region-specific resources. + Only used when the resource has no existing enablement. On later updates, omit it + or send the stored value; changing the region is rejected. + "traces": bool # Optional. Enable or disable the traces signal. Omit to + leave unchanged. + } + + # response body for status code(s): 200 + response == { + "resource": { + "product_type": "str", # The product type of the resource, for + example ``droplet`` or ``kubernetes``. Required. + "resource_urn": "str", # The uniform resource name (URN) of the + resource. Required. + "logs": { + "effective_at": "2020-02-20 00:00:00", # Optional. When this + signal state last changed. + "enabled": bool # Optional. Whether the signal is enabled + for the resource. + }, + "metrics": { + "effective_at": "2020-02-20 00:00:00", # Optional. When this + signal state last changed. + "enabled": bool # Optional. Whether the signal is enabled + for the resource. + }, + "region": "str", # Optional. The region slug for region-specific + resources. Omitted when the resource has no region. + "traces": { + "effective_at": "2020-02-20 00:00:00", # Optional. When this + signal state last changed. + "enabled": bool # Optional. Whether the signal is enabled + for the resource. + } + } + } + # response body for status code(s): 400, 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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) + cls: ClsType[JSON] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = body + + _request = build_insights_update_resource_signals_request( + resource_urn=resource_urn, + content_type=content_type, + json=_json, + content=_content, + 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, 400, 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 == 400: + 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 + class SignalsOperations: """ @@ -342499,6 +343218,655 @@ async def create_async_invoke( return cast(JSON, deserialized) # type: ignore + @overload + async def create_speech( + self, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> Union[JSON, AsyncIterator[bytes]]: + # pylint: disable=line-too-long + """Generate speech from text. + + Convert text input to speech audio. The response may be raw audio bytes (\\ ``audio/mpeg``\\ , + ``audio/wav``\\ , and similar) or a JSON envelope with base64-encoded audio in + ``data[].b64_json``. + + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object or AsyncIterator[bytes] + :rtype: JSON or AsyncIterator[bytes] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "input": "str", # The text to convert to speech. Required. + "model": "str", # The text-to-speech model to use. Required. + "instructions": "str", # Optional. Optional style or delivery instructions + for the synthesizer. + "response_format": "str", # Optional. The audio format to return. Supported + values include ``mp3`` and ``wav``. The API may return raw audio bytes or a JSON + envelope with base64-encoded audio. + "voice": "str" # Optional. The voice to use for synthesis. + } + + # response body for status code(s): 200 + response == { + "data": [ + { + "b64_json": "str" # Base64-encoded audio bytes. Required. + } + ], + "created": 0 # Optional. Unix timestamp (in seconds) of when the audio was + created. + } + """ + + @overload + async def create_speech( + self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> Union[JSON, AsyncIterator[bytes]]: + """Generate speech from text. + + Convert text input to speech audio. The response may be raw audio bytes (\\ ``audio/mpeg``\\ , + ``audio/wav``\\ , and similar) or a JSON envelope with base64-encoded audio in + ``data[].b64_json``. + + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object or AsyncIterator[bytes] + :rtype: JSON or AsyncIterator[bytes] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "data": [ + { + "b64_json": "str" # Base64-encoded audio bytes. Required. + } + ], + "created": 0 # Optional. Unix timestamp (in seconds) of when the audio was + created. + } + """ + + @distributed_trace_async + async def create_speech( + self, body: Union[JSON, IO[bytes]], **kwargs: Any + ) -> Union[JSON, AsyncIterator[bytes]]: + # pylint: disable=line-too-long + """Generate speech from text. + + Convert text input to speech audio. The response may be raw audio bytes (\\ ``audio/mpeg``\\ , + ``audio/wav``\\ , and similar) or a JSON envelope with base64-encoded audio in + ``data[].b64_json``. + + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :return: JSON object or AsyncIterator[bytes] + :rtype: JSON or AsyncIterator[bytes] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "input": "str", # The text to convert to speech. Required. + "model": "str", # The text-to-speech model to use. Required. + "instructions": "str", # Optional. Optional style or delivery instructions + for the synthesizer. + "response_format": "str", # Optional. The audio format to return. Supported + values include ``mp3`` and ``wav``. The API may return raw audio bytes or a JSON + envelope with base64-encoded audio. + "voice": "str" # Optional. The voice to use for synthesis. + } + + # response body for status code(s): 200 + response == { + "data": [ + { + "b64_json": "str" # Base64-encoded audio bytes. Required. + } + ], + "created": 0 # Optional. Unix timestamp (in seconds) of when the audio was + created. + } + """ + 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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) + cls: ClsType[Union[JSON, AsyncIterator[bytes]]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = body + + _request = build_inference_create_speech_request( + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = True + 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, 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) + + 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") + ) + + deserialized = response.iter_bytes() + + 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") + ) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, cast(Union[JSON, AsyncIterator[bytes]], deserialized), response_headers) # type: ignore + + return cast(Union[JSON, AsyncIterator[bytes]], deserialized) # type: ignore + + @overload + async def create_video( + self, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Start a video generation job. + + Start an asynchronous video generation job from a text prompt. Poll ``GET + /v1/videos/{video_id}`` until the job reaches a terminal status, then download the MP4 with + ``GET /v1/videos/{video_id}/content`` or from ``output.url`` when present. + + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "model": "str", # The video generation model to use. Required. + "prompt": "str", # A text description of the desired video. Required. + "fps": 0, # Optional. Frames per second for the generated video. + "size": "str" # Optional. The output resolution, for example ``1280x720``. + } + + # response body for status code(s): 200 + response == { + "id": "str", # The video generation job identifier. Required. + "status": "str", # Job status. Poll until the value is a terminal state such + as ``completed`` or ``failed``. Required. + "created_at": 0, # Optional. Unix timestamp (in seconds) of when the job was + created. + "error": { + "str": {} # Optional. Error details when status is ``failed``. + }, + "model": "str", # Optional. The model used for generation. + "object": "str", # Optional. Object type returned by the API. + "output": { + "url": "str" # Optional. Presigned URL for the generated MP4. + }, + "x_request_id": "str" # Optional. Request correlation identifier when + provided by the API. + } + """ + + @overload + async def create_video( + self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Start a video generation job. + + Start an asynchronous video generation job from a text prompt. Poll ``GET + /v1/videos/{video_id}`` until the job reaches a terminal status, then download the MP4 with + ``GET /v1/videos/{video_id}/content`` or from ``output.url`` when present. + + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "id": "str", # The video generation job identifier. Required. + "status": "str", # Job status. Poll until the value is a terminal state such + as ``completed`` or ``failed``. Required. + "created_at": 0, # Optional. Unix timestamp (in seconds) of when the job was + created. + "error": { + "str": {} # Optional. Error details when status is ``failed``. + }, + "model": "str", # Optional. The model used for generation. + "object": "str", # Optional. Object type returned by the API. + "output": { + "url": "str" # Optional. Presigned URL for the generated MP4. + }, + "x_request_id": "str" # Optional. Request correlation identifier when + provided by the API. + } + """ + + @distributed_trace_async + async def create_video(self, body: Union[JSON, IO[bytes]], **kwargs: Any) -> JSON: + # pylint: disable=line-too-long + """Start a video generation job. + + Start an asynchronous video generation job from a text prompt. Poll ``GET + /v1/videos/{video_id}`` until the job reaches a terminal status, then download the MP4 with + ``GET /v1/videos/{video_id}/content`` or from ``output.url`` when present. + + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "model": "str", # The video generation model to use. Required. + "prompt": "str", # A text description of the desired video. Required. + "fps": 0, # Optional. Frames per second for the generated video. + "size": "str" # Optional. The output resolution, for example ``1280x720``. + } + + # response body for status code(s): 200 + response == { + "id": "str", # The video generation job identifier. Required. + "status": "str", # Job status. Poll until the value is a terminal state such + as ``completed`` or ``failed``. Required. + "created_at": 0, # Optional. Unix timestamp (in seconds) of when the job was + created. + "error": { + "str": {} # Optional. Error details when status is ``failed``. + }, + "model": "str", # Optional. The model used for generation. + "object": "str", # Optional. Object type returned by the API. + "output": { + "url": "str" # Optional. Presigned URL for the generated MP4. + }, + "x_request_id": "str" # Optional. Request correlation identifier when + provided by the API. + } + """ + 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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) + cls: ClsType[JSON] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = body + + _request = build_inference_create_video_request( + content_type=content_type, + json=_json, + content=_content, + 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]: + 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 = {} + 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_video(self, video_id: str, **kwargs: Any) -> JSON: + # pylint: disable=line-too-long + """Retrieve a video generation job. + + Returns the current state of a video generation job. Poll until ``status`` reaches a terminal + value such as ``completed`` or ``failed``. + + :param video_id: The video generation job identifier. Required. + :type video_id: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "id": "str", # The video generation job identifier. Required. + "status": "str", # Job status. Poll until the value is a terminal state such + as ``completed`` or ``failed``. Required. + "created_at": 0, # Optional. Unix timestamp (in seconds) of when the job was + created. + "error": { + "str": {} # Optional. Error details when status is ``failed``. + }, + "model": "str", # Optional. The model used for generation. + "object": "str", # Optional. Object type returned by the API. + "output": { + "url": "str" # Optional. Presigned URL for the generated MP4. + }, + "x_request_id": "str" # Optional. Request correlation identifier when + provided by the API. + } + # 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_inference_get_video_request( + video_id=video_id, + 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_video_content( + self, video_id: str, **kwargs: Any + ) -> Union[AsyncIterator[bytes], JSON]: + # pylint: disable=line-too-long + """Download generated video content. + + Downloads the generated MP4 for a completed video generation job. + + :param video_id: The video generation job identifier. Required. + :type video_id: str + :return: AsyncIterator[bytes] or JSON object + :rtype: AsyncIterator[bytes] or JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # 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[Union[AsyncIterator[bytes], JSON]] = kwargs.pop("cls", None) + + _request = build_inference_get_video_content_request( + video_id=video_id, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = True + 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") + ) + + deserialized = response.iter_bytes() + + 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") + ) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, cast(Union[AsyncIterator[bytes], JSON], deserialized), response_headers) # type: ignore + + return cast(Union[AsyncIterator[bytes], JSON], deserialized) # type: ignore + @overload async def create_batch_file( self, body: JSON, *, content_type: str = "application/json", **kwargs: Any diff --git a/src/pydo/inference/__init__.py b/src/pydo/inference/__init__.py index e023bca1..58a7f52f 100644 --- a/src/pydo/inference/__init__.py +++ b/src/pydo/inference/__init__.py @@ -58,6 +58,7 @@ "responses", "speech", "systemone", + "videos", ) diff --git a/src/pydo/inference/aio/__init__.py b/src/pydo/inference/aio/__init__.py index 3be8fed7..761006ed 100644 --- a/src/pydo/inference/aio/__init__.py +++ b/src/pydo/inference/aio/__init__.py @@ -36,6 +36,7 @@ "responses", "speech", "systemone", + "videos", ) diff --git a/src/pydo/operations/_operations.py b/src/pydo/operations/_operations.py index 8a6ecb77..39e49b91 100644 --- a/src/pydo/operations/_operations.py +++ b/src/pydo/operations/_operations.py @@ -9480,6 +9480,109 @@ def build_insights_post_spans_search_request(region: str, **kwargs: Any) -> Http return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs) +def build_insights_list_resources_request( + *, + filter_product_types: Optional[List[str]] = None, + filter_regions: Optional[List[str]] = None, + pagination_page: int = 1, + pagination_per_page: int = 20, + pagination_sort: Optional[str] = None, + pagination_sort_direction: Optional[str] = None, + **kwargs: Any, +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/v2/insights/resources" + + # Construct parameters + if filter_product_types is not None: + _params["filter.product_types"] = [ + _SERIALIZER.query("filter_product_types", q, "str") if q is not None else "" + for q in filter_product_types + ] + if filter_regions is not None: + _params["filter.regions"] = [ + _SERIALIZER.query("filter_regions", q, "str") if q is not None else "" + for q in filter_regions + ] + if pagination_page is not None: + _params["pagination.page"] = _SERIALIZER.query( + "pagination_page", pagination_page, "int", minimum=1 + ) + if pagination_per_page is not None: + _params["pagination.per_page"] = _SERIALIZER.query( + "pagination_per_page", pagination_per_page, "int", maximum=200, minimum=1 + ) + if pagination_sort is not None: + _params["pagination.sort"] = _SERIALIZER.query( + "pagination_sort", pagination_sort, "str" + ) + if pagination_sort_direction is not None: + _params["pagination.sort_direction"] = _SERIALIZER.query( + "pagination_sort_direction", pagination_sort_direction, "str" + ) + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest( + method="GET", url=_url, params=_params, headers=_headers, **kwargs + ) + + +def build_insights_get_resource_request( + resource_urn: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/v2/insights/resources/{resource_urn}" + path_format_arguments = { + "resource_urn": _SERIALIZER.url("resource_urn", resource_urn, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, headers=_headers, **kwargs) + + +def build_insights_update_resource_signals_request( # pylint: disable=name-too-long + resource_urn: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/v2/insights/resources/{resource_urn}/signals" + path_format_arguments = { + "resource_urn": _SERIALIZER.url("resource_urn", resource_urn, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header( + "content_type", content_type, "str" + ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, headers=_headers, **kwargs) + + def build_signals_list_consents_request( *, source: Optional[str] = None, **kwargs: Any ) -> HttpRequest: @@ -21341,6 +21444,90 @@ def build_inference_create_async_invoke_request( return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs) +def build_inference_create_speech_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) + accept = _headers.pop( + "Accept", "application/json, audio/mpeg, audio/wav, audio/mp3" + ) + + # Construct URL + _url = "/v1/audio/speech" + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header( + "content_type", content_type, "str" + ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs) + + +def build_inference_create_video_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/v1/videos" + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header( + "content_type", content_type, "str" + ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs) + + +def build_inference_get_video_request(video_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/v1/videos/{video_id}" + path_format_arguments = { + "video_id": _SERIALIZER.url("video_id", video_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, headers=_headers, **kwargs) + + +def build_inference_get_video_content_request( # pylint: disable=name-too-long + video_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + + accept = _headers.pop("Accept", "video/mp4, application/json") + + # Construct URL + _url = "/v1/videos/{video_id}/content" + path_format_arguments = { + "video_id": _SERIALIZER.url("video_id", video_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, headers=_headers, **kwargs) + + def build_inference_create_batch_file_request( **kwargs: Any, ) -> HttpRequest: # pylint: disable=name-too-long @@ -207820,45 +208007,205 @@ def post_spans_search( return cast(JSON, deserialized) # type: ignore + @distributed_trace + def list_resources( + self, + *, + filter_product_types: Optional[List[str]] = None, + filter_regions: Optional[List[str]] = None, + pagination_page: int = 1, + pagination_per_page: int = 20, + pagination_sort: Optional[str] = None, + pagination_sort_direction: Optional[str] = None, + **kwargs: Any, + ) -> JSON: + # pylint: disable=line-too-long + """List Resource Signal Enablement. -class SignalsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. + To list the resources in your account that have telemetry signal enablement + recorded, along with the current state of their metrics, logs, and traces + signals, send a GET request to ``/v2/insights/resources``. - Instead, you should access the following operations through - :class:`~pydo.GeneratedClient`'s - :attr:`signals` attribute. - """ + Results are paginated with ``pagination.page`` and ``pagination.per_page`` + (default ``20``\\ , maximum ``200``\\ ) and can be sorted with ``pagination.sort`` and + ``pagination.sort_direction``. Optionally filter by ``filter.product_types`` and + ``filter.regions``. - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = ( - input_args.pop(0) if input_args else kwargs.pop("deserializer") + A signal is omitted from a resource when no explicit enablement has ever been + recorded for it. + + :keyword filter_product_types: Optional filter. When set, only resources of these product types + are returned. Repeat the parameter for multiple product types. Default value is None. + :paramtype filter_product_types: list[str] + :keyword filter_regions: Optional filter. When set, only resources in these regions are + returned. Repeat the parameter for multiple regions. Default value is None. + :paramtype filter_regions: list[str] + :keyword pagination_page: Which 'page' of paginated results to return. Default value is 1. + :paramtype pagination_page: int + :keyword pagination_per_page: Number of items returned per page. Default value is 20. + :paramtype pagination_per_page: int + :keyword pagination_sort: Field to sort by. Defaults to ``resource_urn``. Known values are: + "resource_urn" and "effective_at". Default value is None. + :paramtype pagination_sort: str + :keyword pagination_sort_direction: Sort direction. Defaults to ``asc``. Known values are: + "asc" and "desc". Default value is None. + :paramtype pagination_sort_direction: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "pagination": { + "page": 0, # Optional. The current page number. + "pages": 0, # Optional. The total number of pages. Omitted when + there are no results. + "per_page": 0, # Optional. The number of items per page. + "total": 0 # Optional. The total number of resources across all + pages. Omitted when there are no results. + }, + "resources": [ + { + "product_type": "str", # The product type of the resource, + for example ``droplet`` or ``kubernetes``. Required. + "resource_urn": "str", # The uniform resource name (URN) of + the resource. Required. + "logs": { + "effective_at": "2020-02-20 00:00:00", # Optional. + When this signal state last changed. + "enabled": bool # Optional. Whether the signal is + enabled for the resource. + }, + "metrics": { + "effective_at": "2020-02-20 00:00:00", # Optional. + When this signal state last changed. + "enabled": bool # Optional. Whether the signal is + enabled for the resource. + }, + "region": "str", # Optional. The region slug for + region-specific resources. Omitted when the resource has no region. + "traces": { + "effective_at": "2020-02-20 00:00:00", # Optional. + When this signal state last changed. + "enabled": bool # Optional. Whether the signal is + enabled for the resource. + } + } + ] + } + # response body for status code(s): 400 + 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_insights_list_resources_request( + filter_product_types=filter_product_types, + filter_regions=filter_regions, + pagination_page=pagination_page, + pagination_per_page=pagination_per_page, + pagination_sort=pagination_sort, + pagination_sort_direction=pagination_sort_direction, + 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, 400]: + 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 == 400: + 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 list_consents(self, *, source: Optional[str] = None, **kwargs: Any) -> JSON: + def get_resource(self, resource_urn: str, **kwargs: Any) -> JSON: # pylint: disable=line-too-long - """List All Consent Records. + """Retrieve Resource Signal Enablement. - To list all signals consent records for your team, send a GET request to - ``/v1/consent``. Each record indicates whether signals collection is enabled - for a source: per-environment records (\\ ``source: agent``\\ ) for Harness Runtime, and - the team-level record (\\ ``source: inference``\\ ) for Serverless Inference chat - completions. + To retrieve the current metrics, logs, and traces signal enablement for a + single resource, send a GET request to + ``/v2/insights/resources/{resource_urn}``. - Pass ``?source=agent`` or ``?source=inference`` to return only that source's - records. When filtered, the response also echoes the ``source``. + A ``404`` is returned when no signal enablement has been recorded for the + resource. - :keyword source: Filter consent records by source. ``agent`` returns per-environment records - (Harness Runtime); ``inference`` returns the team-level record for Serverless Inference chat - completions. When omitted, records for all sources are returned. Known values are: "agent" and - "inference". Default value is None. - :paramtype source: str + :param resource_urn: The uniform resource name (URN) of the resource, for example + ``do:droplet:12345``. Required. + :type resource_urn: str :return: JSON object :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: @@ -207868,31 +208215,34 @@ def list_consents(self, *, source: Optional[str] = None, **kwargs: Any) -> JSON: # response body for status code(s): 200 response == { - "consents": [ - { - "agent_id": "str", # The unique identifier of the - environment. For Harness Runtime, this is the Environment Config ID. - Empty for team-level records ("" ``source: inference``"" ), which are not - tied to an environment. Required. - "enabled": bool, # Whether signals collection is enabled for - this source. Required. - "id": 0, # The unique numeric identifier for the consent - record. Required. - "source": "str", # The source this consent applies to. - ``agent`` is per-environment consent for Harness Runtime; ``inference`` - is team-level consent for Serverless Inference chat completions. - Required. Known values are: "agent" and "inference". - "team_id": 0, # The team ID that owns this consent record. - Required. - "updated_at": "2020-02-20 00:00:00" # A time value given in - ISO8601 combined date and time format. Required. + "resource": { + "product_type": "str", # The product type of the resource, for + example ``droplet`` or ``kubernetes``. Required. + "resource_urn": "str", # The uniform resource name (URN) of the + resource. Required. + "logs": { + "effective_at": "2020-02-20 00:00:00", # Optional. When this + signal state last changed. + "enabled": bool # Optional. Whether the signal is enabled + for the resource. + }, + "metrics": { + "effective_at": "2020-02-20 00:00:00", # Optional. When this + signal state last changed. + "enabled": bool # Optional. Whether the signal is enabled + for the resource. + }, + "region": "str", # Optional. The region slug for region-specific + resources. Omitted when the resource has no region. + "traces": { + "effective_at": "2020-02-20 00:00:00", # Optional. When this + signal state last changed. + "enabled": bool # Optional. Whether the signal is enabled + for the resource. } - ], - "source": "str" # Optional. Echoes the ``source`` filter when the request - was filtered by source. Omitted when the list was not filtered. Known values are: - "agent" and "inference". + } } - # response body for status code(s): 400 + # response body for status code(s): 400, 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 @@ -207922,8 +208272,8 @@ def list_consents(self, *, source: Optional[str] = None, **kwargs: Any) -> JSON: cls: ClsType[JSON] = kwargs.pop("cls", None) - _request = build_signals_list_consents_request( - source=source, + _request = build_insights_get_resource_request( + resource_urn=resource_urn, headers=_headers, params=_params, ) @@ -207938,7 +208288,7 @@ def list_consents(self, *, source: Optional[str] = None, **kwargs: Any) -> JSON: response = pipeline_response.http_response - if response.status_code not in [200, 400]: + if response.status_code not in [200, 400, 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 @@ -207977,40 +208327,57 @@ def list_consents(self, *, source: Optional[str] = None, **kwargs: Any) -> 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 update_team_consent( + def update_resource_signals( self, + resource_urn: str, body: JSON, *, - source: str, content_type: str = "application/json", **kwargs: Any, ) -> JSON: # pylint: disable=line-too-long - """Update Team-Level Consent. + """Update Resource Signal Enablement. - To enable or disable signals collection for a source that is consented at - the team level, send a PUT request to ``/v1/consent?source=inference`` with - an ``enabled`` boolean in the request body. Currently the only team-level - source is ``inference``\\ , which covers Serverless Inference chat completions - made by your team. + To enable or disable telemetry signals for a resource, send a PUT request to + ``/v2/insights/resources/{resource_urn}/signals``. - To revoke consent, send the same request with ``enabled`` set to ``false``. - The ``source`` query parameter is required. Per-environment consent for Harness - Runtime environments is managed with ``PUT /v1/consent/{agent_id}`` instead. + This endpoint uses merge semantics. Set ``metrics``\\ , ``logs``\\ , or ``traces`` to + ``true`` or ``false`` to change that signal; omit a signal to leave it unchanged. + At least one signal must be set. + ``region`` is only used when the resource has no existing enablement. On later + updates, omit it or send the stored value; changing the region is rejected + with a ``400``. + + Requires both the ``insights:update`` and ``insights:create`` scopes. + + :param resource_urn: The uniform resource name (URN) of the resource, for example + ``do:droplet:12345``. Required. + :type resource_urn: str :param body: Required. :type body: JSON - :keyword source: The consent source to update. Only team-level sources are accepted on this - endpoint; currently ``inference`` (Serverless Inference chat completions). Per-environment - consent (\\ ``agent``\\ ) is managed with ``PUT /v1/consent/{agent_id}`` instead. "inference" - Required. - :paramtype source: str :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -208023,31 +208390,47 @@ def update_team_consent( # JSON input template you can fill out and use as your body input. body = { - "enabled": bool # Whether to enable signals collection for this source. - Required. + "logs": bool, # Optional. Enable or disable the logs signal. Omit to leave + unchanged. + "metrics": bool, # Optional. Enable or disable the metrics signal. Omit to + leave unchanged. + "region": "str", # Optional. The region slug for region-specific resources. + Only used when the resource has no existing enablement. On later updates, omit it + or send the stored value; changing the region is rejected. + "traces": bool # Optional. Enable or disable the traces signal. Omit to + leave unchanged. } # response body for status code(s): 200 response == { - "consent": { - "agent_id": "str", # The unique identifier of the environment. For - Harness Runtime, this is the Environment Config ID. Empty for team-level - records ("" ``source: inference``"" ), which are not tied to an environment. - Required. - "enabled": bool, # Whether signals collection is enabled for this - source. Required. - "id": 0, # The unique numeric identifier for the consent record. - Required. - "source": "str", # The source this consent applies to. ``agent`` is - per-environment consent for Harness Runtime; ``inference`` is team-level - consent for Serverless Inference chat completions. Required. Known values - are: "agent" and "inference". - "team_id": 0, # The team ID that owns this consent record. Required. - "updated_at": "2020-02-20 00:00:00" # A time value given in ISO8601 - combined date and time format. Required. + "resource": { + "product_type": "str", # The product type of the resource, for + example ``droplet`` or ``kubernetes``. Required. + "resource_urn": "str", # The uniform resource name (URN) of the + resource. Required. + "logs": { + "effective_at": "2020-02-20 00:00:00", # Optional. When this + signal state last changed. + "enabled": bool # Optional. Whether the signal is enabled + for the resource. + }, + "metrics": { + "effective_at": "2020-02-20 00:00:00", # Optional. When this + signal state last changed. + "enabled": bool # Optional. Whether the signal is enabled + for the resource. + }, + "region": "str", # Optional. The region slug for region-specific + resources. Omitted when the resource has no region. + "traces": { + "effective_at": "2020-02-20 00:00:00", # Optional. When this + signal state last changed. + "enabled": bool # Optional. Whether the signal is enabled + for the resource. + } } } - # response body for status code(s): 400 + # response body for status code(s): 400, 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 @@ -208061,34 +208444,35 @@ def update_team_consent( """ @overload - def update_team_consent( + def update_resource_signals( self, + resource_urn: str, body: IO[bytes], *, - source: str, content_type: str = "application/json", **kwargs: Any, ) -> JSON: # pylint: disable=line-too-long - """Update Team-Level Consent. + """Update Resource Signal Enablement. - To enable or disable signals collection for a source that is consented at - the team level, send a PUT request to ``/v1/consent?source=inference`` with - an ``enabled`` boolean in the request body. Currently the only team-level - source is ``inference``\\ , which covers Serverless Inference chat completions - made by your team. + To enable or disable telemetry signals for a resource, send a PUT request to + ``/v2/insights/resources/{resource_urn}/signals``. - To revoke consent, send the same request with ``enabled`` set to ``false``. - The ``source`` query parameter is required. Per-environment consent for Harness - Runtime environments is managed with ``PUT /v1/consent/{agent_id}`` instead. + This endpoint uses merge semantics. Set ``metrics``\\ , ``logs``\\ , or ``traces`` to + ``true`` or ``false`` to change that signal; omit a signal to leave it unchanged. + At least one signal must be set. + + ``region`` is only used when the resource has no existing enablement. On later + updates, omit it or send the stored value; changing the region is rejected + with a ``400``. + Requires both the ``insights:update`` and ``insights:create`` scopes. + + :param resource_urn: The uniform resource name (URN) of the resource, for example + ``do:droplet:12345``. Required. + :type resource_urn: str :param body: Required. :type body: IO[bytes] - :keyword source: The consent source to update. Only team-level sources are accepted on this - endpoint; currently ``inference`` (Serverless Inference chat completions). Per-environment - consent (\\ ``agent``\\ ) is managed with ``PUT /v1/consent/{agent_id}`` instead. "inference" - Required. - :paramtype source: str :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str @@ -208101,25 +208485,34 @@ def update_team_consent( # response body for status code(s): 200 response == { - "consent": { - "agent_id": "str", # The unique identifier of the environment. For - Harness Runtime, this is the Environment Config ID. Empty for team-level - records ("" ``source: inference``"" ), which are not tied to an environment. - Required. - "enabled": bool, # Whether signals collection is enabled for this - source. Required. - "id": 0, # The unique numeric identifier for the consent record. - Required. - "source": "str", # The source this consent applies to. ``agent`` is - per-environment consent for Harness Runtime; ``inference`` is team-level - consent for Serverless Inference chat completions. Required. Known values - are: "agent" and "inference". - "team_id": 0, # The team ID that owns this consent record. Required. - "updated_at": "2020-02-20 00:00:00" # A time value given in ISO8601 - combined date and time format. Required. + "resource": { + "product_type": "str", # The product type of the resource, for + example ``droplet`` or ``kubernetes``. Required. + "resource_urn": "str", # The uniform resource name (URN) of the + resource. Required. + "logs": { + "effective_at": "2020-02-20 00:00:00", # Optional. When this + signal state last changed. + "enabled": bool # Optional. Whether the signal is enabled + for the resource. + }, + "metrics": { + "effective_at": "2020-02-20 00:00:00", # Optional. When this + signal state last changed. + "enabled": bool # Optional. Whether the signal is enabled + for the resource. + }, + "region": "str", # Optional. The region slug for region-specific + resources. Omitted when the resource has no region. + "traces": { + "effective_at": "2020-02-20 00:00:00", # Optional. When this + signal state last changed. + "enabled": bool # Optional. Whether the signal is enabled + for the resource. + } } } - # response body for status code(s): 400 + # response body for status code(s): 400, 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 @@ -208133,29 +208526,30 @@ def update_team_consent( """ @distributed_trace - def update_team_consent( - self, body: Union[JSON, IO[bytes]], *, source: str, **kwargs: Any + def update_resource_signals( + self, resource_urn: str, body: Union[JSON, IO[bytes]], **kwargs: Any ) -> JSON: # pylint: disable=line-too-long - """Update Team-Level Consent. + """Update Resource Signal Enablement. - To enable or disable signals collection for a source that is consented at - the team level, send a PUT request to ``/v1/consent?source=inference`` with - an ``enabled`` boolean in the request body. Currently the only team-level - source is ``inference``\\ , which covers Serverless Inference chat completions - made by your team. + To enable or disable telemetry signals for a resource, send a PUT request to + ``/v2/insights/resources/{resource_urn}/signals``. - To revoke consent, send the same request with ``enabled`` set to ``false``. - The ``source`` query parameter is required. Per-environment consent for Harness - Runtime environments is managed with ``PUT /v1/consent/{agent_id}`` instead. + This endpoint uses merge semantics. Set ``metrics``\\ , ``logs``\\ , or ``traces`` to + ``true`` or ``false`` to change that signal; omit a signal to leave it unchanged. + At least one signal must be set. + ``region`` is only used when the resource has no existing enablement. On later + updates, omit it or send the stored value; changing the region is rejected + with a ``400``. + + Requires both the ``insights:update`` and ``insights:create`` scopes. + + :param resource_urn: The uniform resource name (URN) of the resource, for example + ``do:droplet:12345``. Required. + :type resource_urn: str :param body: Is either a JSON type or a IO[bytes] type. Required. :type body: JSON or IO[bytes] - :keyword source: The consent source to update. Only team-level sources are accepted on this - endpoint; currently ``inference`` (Serverless Inference chat completions). Per-environment - consent (\\ ``agent``\\ ) is managed with ``PUT /v1/consent/{agent_id}`` instead. "inference" - Required. - :paramtype source: str :return: JSON object :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: @@ -208165,31 +208559,47 @@ def update_team_consent( # JSON input template you can fill out and use as your body input. body = { - "enabled": bool # Whether to enable signals collection for this source. - Required. + "logs": bool, # Optional. Enable or disable the logs signal. Omit to leave + unchanged. + "metrics": bool, # Optional. Enable or disable the metrics signal. Omit to + leave unchanged. + "region": "str", # Optional. The region slug for region-specific resources. + Only used when the resource has no existing enablement. On later updates, omit it + or send the stored value; changing the region is rejected. + "traces": bool # Optional. Enable or disable the traces signal. Omit to + leave unchanged. } # response body for status code(s): 200 response == { - "consent": { - "agent_id": "str", # The unique identifier of the environment. For - Harness Runtime, this is the Environment Config ID. Empty for team-level - records ("" ``source: inference``"" ), which are not tied to an environment. - Required. - "enabled": bool, # Whether signals collection is enabled for this - source. Required. - "id": 0, # The unique numeric identifier for the consent record. - Required. - "source": "str", # The source this consent applies to. ``agent`` is - per-environment consent for Harness Runtime; ``inference`` is team-level - consent for Serverless Inference chat completions. Required. Known values - are: "agent" and "inference". - "team_id": 0, # The team ID that owns this consent record. Required. - "updated_at": "2020-02-20 00:00:00" # A time value given in ISO8601 - combined date and time format. Required. + "resource": { + "product_type": "str", # The product type of the resource, for + example ``droplet`` or ``kubernetes``. Required. + "resource_urn": "str", # The uniform resource name (URN) of the + resource. Required. + "logs": { + "effective_at": "2020-02-20 00:00:00", # Optional. When this + signal state last changed. + "enabled": bool # Optional. Whether the signal is enabled + for the resource. + }, + "metrics": { + "effective_at": "2020-02-20 00:00:00", # Optional. When this + signal state last changed. + "enabled": bool # Optional. Whether the signal is enabled + for the resource. + }, + "region": "str", # Optional. The region slug for region-specific + resources. Omitted when the resource has no region. + "traces": { + "effective_at": "2020-02-20 00:00:00", # Optional. When this + signal state last changed. + "enabled": bool # Optional. Whether the signal is enabled + for the resource. + } } } - # response body for status code(s): 400 + # response body for status code(s): 400, 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 @@ -208230,8 +208640,8 @@ def update_team_consent( else: _json = body - _request = build_signals_update_team_consent_request( - source=source, + _request = build_insights_update_resource_signals_request( + resource_urn=resource_urn, content_type=content_type, json=_json, content=_content, @@ -208249,7 +208659,7 @@ def update_team_consent( response = pipeline_response.http_response - if response.status_code not in [200, 400]: + if response.status_code not in [200, 400, 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 @@ -208288,26 +208698,66 @@ def update_team_consent( 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 + +class SignalsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~pydo.GeneratedClient`'s + :attr:`signals` attribute. + """ + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = ( + input_args.pop(0) if input_args else kwargs.pop("deserializer") + ) + @distributed_trace - def get_consent(self, agent_id: str, **kwargs: Any) -> JSON: + def list_consents(self, *, source: Optional[str] = None, **kwargs: Any) -> JSON: # pylint: disable=line-too-long - """Retrieve Consent for an Environment. + """List All Consent Records. - To retrieve the consent record for a specific environment, send a GET - request to ``/v1/consent/{agent_id}``. The response includes an ``enabled`` - field indicating whether signals collection is on for this environment. + To list all signals consent records for your team, send a GET request to + ``/v1/consent``. Each record indicates whether signals collection is enabled + for a source: per-environment records (\\ ``source: agent``\\ ) for Harness Runtime, and + the team-level record (\\ ``source: inference``\\ ) for Serverless Inference chat + completions. - This endpoint only serves per-environment (\\ ``source: agent``\\ ) records. Team-level - inference consent is read from ``GET /v1/consent?source=inference``. + Pass ``?source=agent`` or ``?source=inference`` to return only that source's + records. When filtered, the response also echoes the ``source``. - :param agent_id: A unique identifier for an environment. For Harness Runtime, this is the - Environment Config ID. Required. - :type agent_id: str + :keyword source: Filter consent records by source. ``agent`` returns per-environment records + (Harness Runtime); ``inference`` returns the team-level record for Serverless Inference chat + completions. When omitted, records for all sources are returned. Known values are: "agent" and + "inference". Default value is None. + :paramtype source: str :return: JSON object :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: @@ -208317,18 +208767,31 @@ def get_consent(self, agent_id: str, **kwargs: Any) -> JSON: # response body for status code(s): 200 response == { - "agent_id": "str", # The unique identifier of the environment. For Harness - Runtime, this is the Environment Config ID. Required. - "enabled": bool, # Whether signals collection is enabled for this - environment. Required. - "source": "str", # The source this consent applies to. Always ``agent`` for - per-environment records returned by this endpoint. Required. "agent" - "team_id": 0, # The team ID that owns this consent record. Required. - "id": 0, # Optional. The unique numeric identifier for the consent record. - "updated_at": "2020-02-20 00:00:00" # Optional. A time value given in - ISO8601 combined date and time format. + "consents": [ + { + "agent_id": "str", # The unique identifier of the + environment. For Harness Runtime, this is the Environment Config ID. + Empty for team-level records ("" ``source: inference``"" ), which are not + tied to an environment. Required. + "enabled": bool, # Whether signals collection is enabled for + this source. Required. + "id": 0, # The unique numeric identifier for the consent + record. Required. + "source": "str", # The source this consent applies to. + ``agent`` is per-environment consent for Harness Runtime; ``inference`` + is team-level consent for Serverless Inference chat completions. + Required. Known values are: "agent" and "inference". + "team_id": 0, # The team ID that owns this consent record. + Required. + "updated_at": "2020-02-20 00:00:00" # A time value given in + ISO8601 combined date and time format. Required. + } + ], + "source": "str" # Optional. Echoes the ``source`` filter when the request + was filtered by source. Omitted when the list was not filtered. Known values are: + "agent" and "inference". } - # response body for status code(s): 400, 404 + # response body for status code(s): 400 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 @@ -208358,8 +208821,8 @@ def get_consent(self, agent_id: str, **kwargs: Any) -> JSON: cls: ClsType[JSON] = kwargs.pop("cls", None) - _request = build_signals_get_consent_request( - agent_id=agent_id, + _request = build_signals_list_consents_request( + source=source, headers=_headers, params=_params, ) @@ -208374,7 +208837,7 @@ def get_consent(self, agent_id: str, **kwargs: Any) -> JSON: response = pipeline_response.http_response - if response.status_code not in [200, 400, 404]: + if response.status_code not in [200, 400]: 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 @@ -208413,52 +208876,40 @@ def get_consent(self, agent_id: str, **kwargs: Any) -> 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 update_consent( + def update_team_consent( self, - agent_id: str, body: JSON, *, + source: str, content_type: str = "application/json", **kwargs: Any, ) -> JSON: # pylint: disable=line-too-long - """Update Consent for an Environment. + """Update Team-Level Consent. - To enable or disable signals collection for a specific environment, send a - PUT request to ``/v1/consent/{agent_id}`` with an ``enabled`` boolean in the - request body. + To enable or disable signals collection for a source that is consented at + the team level, send a PUT request to ``/v1/consent?source=inference`` with + an ``enabled`` boolean in the request body. Currently the only team-level + source is ``inference``\\ , which covers Serverless Inference chat completions + made by your team. - This endpoint only manages per-environment (\\ ``source: agent``\\ ) consent. To manage - team-level consent for Serverless Inference, use - ``PUT /v1/consent?source=inference`` instead. + To revoke consent, send the same request with ``enabled`` set to ``false``. + The ``source`` query parameter is required. Per-environment consent for Harness + Runtime environments is managed with ``PUT /v1/consent/{agent_id}`` instead. - :param agent_id: A unique identifier for an environment. For Harness Runtime, this is the - Environment Config ID. Required. - :type agent_id: str :param body: Required. :type body: JSON + :keyword source: The consent source to update. Only team-level sources are accepted on this + endpoint; currently ``inference`` (Serverless Inference chat completions). Per-environment + consent (\\ ``agent``\\ ) is managed with ``PUT /v1/consent/{agent_id}`` instead. "inference" + Required. + :paramtype source: str :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -208471,7 +208922,7 @@ def update_consent( # JSON input template you can fill out and use as your body input. body = { - "enabled": bool # Whether to enable signals collection for this environment. + "enabled": bool # Whether to enable signals collection for this source. Required. } @@ -208495,7 +208946,7 @@ def update_consent( combined date and time format. Required. } } - # response body for status code(s): 400, 404 + # response body for status code(s): 400 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 @@ -208509,30 +208960,34 @@ def update_consent( """ @overload - def update_consent( + def update_team_consent( self, - agent_id: str, body: IO[bytes], *, + source: str, content_type: str = "application/json", **kwargs: Any, ) -> JSON: # pylint: disable=line-too-long - """Update Consent for an Environment. + """Update Team-Level Consent. - To enable or disable signals collection for a specific environment, send a - PUT request to ``/v1/consent/{agent_id}`` with an ``enabled`` boolean in the - request body. + To enable or disable signals collection for a source that is consented at + the team level, send a PUT request to ``/v1/consent?source=inference`` with + an ``enabled`` boolean in the request body. Currently the only team-level + source is ``inference``\\ , which covers Serverless Inference chat completions + made by your team. - This endpoint only manages per-environment (\\ ``source: agent``\\ ) consent. To manage - team-level consent for Serverless Inference, use - ``PUT /v1/consent?source=inference`` instead. + To revoke consent, send the same request with ``enabled`` set to ``false``. + The ``source`` query parameter is required. Per-environment consent for Harness + Runtime environments is managed with ``PUT /v1/consent/{agent_id}`` instead. - :param agent_id: A unique identifier for an environment. For Harness Runtime, this is the - Environment Config ID. Required. - :type agent_id: str :param body: Required. :type body: IO[bytes] + :keyword source: The consent source to update. Only team-level sources are accepted on this + endpoint; currently ``inference`` (Serverless Inference chat completions). Per-environment + consent (\\ ``agent``\\ ) is managed with ``PUT /v1/consent/{agent_id}`` instead. "inference" + Required. + :paramtype source: str :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str @@ -208563,7 +209018,7 @@ def update_consent( combined date and time format. Required. } } - # response body for status code(s): 400, 404 + # response body for status code(s): 400 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 @@ -208577,25 +209032,29 @@ def update_consent( """ @distributed_trace - def update_consent( - self, agent_id: str, body: Union[JSON, IO[bytes]], **kwargs: Any + def update_team_consent( + self, body: Union[JSON, IO[bytes]], *, source: str, **kwargs: Any ) -> JSON: # pylint: disable=line-too-long - """Update Consent for an Environment. + """Update Team-Level Consent. - To enable or disable signals collection for a specific environment, send a - PUT request to ``/v1/consent/{agent_id}`` with an ``enabled`` boolean in the - request body. + To enable or disable signals collection for a source that is consented at + the team level, send a PUT request to ``/v1/consent?source=inference`` with + an ``enabled`` boolean in the request body. Currently the only team-level + source is ``inference``\\ , which covers Serverless Inference chat completions + made by your team. - This endpoint only manages per-environment (\\ ``source: agent``\\ ) consent. To manage - team-level consent for Serverless Inference, use - ``PUT /v1/consent?source=inference`` instead. + To revoke consent, send the same request with ``enabled`` set to ``false``. + The ``source`` query parameter is required. Per-environment consent for Harness + Runtime environments is managed with ``PUT /v1/consent/{agent_id}`` instead. - :param agent_id: A unique identifier for an environment. For Harness Runtime, this is the - Environment Config ID. Required. - :type agent_id: str :param body: Is either a JSON type or a IO[bytes] type. Required. :type body: JSON or IO[bytes] + :keyword source: The consent source to update. Only team-level sources are accepted on this + endpoint; currently ``inference`` (Serverless Inference chat completions). Per-environment + consent (\\ ``agent``\\ ) is managed with ``PUT /v1/consent/{agent_id}`` instead. "inference" + Required. + :paramtype source: str :return: JSON object :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: @@ -208605,7 +209064,7 @@ def update_consent( # JSON input template you can fill out and use as your body input. body = { - "enabled": bool # Whether to enable signals collection for this environment. + "enabled": bool # Whether to enable signals collection for this source. Required. } @@ -208629,7 +209088,447 @@ def update_consent( combined date and time format. Required. } } - # response body for status code(s): 400, 404 + # response body for status code(s): 400 + 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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) + cls: ClsType[JSON] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = body + + _request = build_signals_update_team_consent_request( + source=source, + content_type=content_type, + json=_json, + content=_content, + 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, 400]: + 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 == 400: + 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_consent(self, agent_id: str, **kwargs: Any) -> JSON: + # pylint: disable=line-too-long + """Retrieve Consent for an Environment. + + To retrieve the consent record for a specific environment, send a GET + request to ``/v1/consent/{agent_id}``. The response includes an ``enabled`` + field indicating whether signals collection is on for this environment. + + This endpoint only serves per-environment (\\ ``source: agent``\\ ) records. Team-level + inference consent is read from ``GET /v1/consent?source=inference``. + + :param agent_id: A unique identifier for an environment. For Harness Runtime, this is the + Environment Config ID. Required. + :type agent_id: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "agent_id": "str", # The unique identifier of the environment. For Harness + Runtime, this is the Environment Config ID. Required. + "enabled": bool, # Whether signals collection is enabled for this + environment. Required. + "source": "str", # The source this consent applies to. Always ``agent`` for + per-environment records returned by this endpoint. Required. "agent" + "team_id": 0, # The team ID that owns this consent record. Required. + "id": 0, # Optional. The unique numeric identifier for the consent record. + "updated_at": "2020-02-20 00:00:00" # Optional. A time value given in + ISO8601 combined date and time format. + } + # response body for status code(s): 400, 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_signals_get_consent_request( + agent_id=agent_id, + 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, 400, 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 == 400: + 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 update_consent( + self, + agent_id: str, + body: JSON, + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> JSON: + # pylint: disable=line-too-long + """Update Consent for an Environment. + + To enable or disable signals collection for a specific environment, send a + PUT request to ``/v1/consent/{agent_id}`` with an ``enabled`` boolean in the + request body. + + This endpoint only manages per-environment (\\ ``source: agent``\\ ) consent. To manage + team-level consent for Serverless Inference, use + ``PUT /v1/consent?source=inference`` instead. + + :param agent_id: A unique identifier for an environment. For Harness Runtime, this is the + Environment Config ID. Required. + :type agent_id: str + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "enabled": bool # Whether to enable signals collection for this environment. + Required. + } + + # response body for status code(s): 200 + response == { + "consent": { + "agent_id": "str", # The unique identifier of the environment. For + Harness Runtime, this is the Environment Config ID. Empty for team-level + records ("" ``source: inference``"" ), which are not tied to an environment. + Required. + "enabled": bool, # Whether signals collection is enabled for this + source. Required. + "id": 0, # The unique numeric identifier for the consent record. + Required. + "source": "str", # The source this consent applies to. ``agent`` is + per-environment consent for Harness Runtime; ``inference`` is team-level + consent for Serverless Inference chat completions. Required. Known values + are: "agent" and "inference". + "team_id": 0, # The team ID that owns this consent record. Required. + "updated_at": "2020-02-20 00:00:00" # A time value given in ISO8601 + combined date and time format. Required. + } + } + # response body for status code(s): 400, 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. + } + """ + + @overload + def update_consent( + self, + agent_id: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> JSON: + # pylint: disable=line-too-long + """Update Consent for an Environment. + + To enable or disable signals collection for a specific environment, send a + PUT request to ``/v1/consent/{agent_id}`` with an ``enabled`` boolean in the + request body. + + This endpoint only manages per-environment (\\ ``source: agent``\\ ) consent. To manage + team-level consent for Serverless Inference, use + ``PUT /v1/consent?source=inference`` instead. + + :param agent_id: A unique identifier for an environment. For Harness Runtime, this is the + Environment Config ID. Required. + :type agent_id: str + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "consent": { + "agent_id": "str", # The unique identifier of the environment. For + Harness Runtime, this is the Environment Config ID. Empty for team-level + records ("" ``source: inference``"" ), which are not tied to an environment. + Required. + "enabled": bool, # Whether signals collection is enabled for this + source. Required. + "id": 0, # The unique numeric identifier for the consent record. + Required. + "source": "str", # The source this consent applies to. ``agent`` is + per-environment consent for Harness Runtime; ``inference`` is team-level + consent for Serverless Inference chat completions. Required. Known values + are: "agent" and "inference". + "team_id": 0, # The team ID that owns this consent record. Required. + "updated_at": "2020-02-20 00:00:00" # A time value given in ISO8601 + combined date and time format. Required. + } + } + # response body for status code(s): 400, 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. + } + """ + + @distributed_trace + def update_consent( + self, agent_id: str, body: Union[JSON, IO[bytes]], **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Update Consent for an Environment. + + To enable or disable signals collection for a specific environment, send a + PUT request to ``/v1/consent/{agent_id}`` with an ``enabled`` boolean in the + request body. + + This endpoint only manages per-environment (\\ ``source: agent``\\ ) consent. To manage + team-level consent for Serverless Inference, use + ``PUT /v1/consent?source=inference`` instead. + + :param agent_id: A unique identifier for an environment. For Harness Runtime, this is the + Environment Config ID. Required. + :type agent_id: str + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "enabled": bool # Whether to enable signals collection for this environment. + Required. + } + + # response body for status code(s): 200 + response == { + "consent": { + "agent_id": "str", # The unique identifier of the environment. For + Harness Runtime, this is the Environment Config ID. Empty for team-level + records ("" ``source: inference``"" ), which are not tied to an environment. + Required. + "enabled": bool, # Whether signals collection is enabled for this + source. Required. + "id": 0, # The unique numeric identifier for the consent record. + Required. + "source": "str", # The source this consent applies to. ``agent`` is + per-environment consent for Harness Runtime; ``inference`` is team-level + consent for Serverless Inference chat completions. Required. Known values + are: "agent" and "inference". + "team_id": 0, # The team ID that owns this consent record. Required. + "updated_at": "2020-02-20 00:00:00" # A time value given in ISO8601 + combined date and time format. Required. + } + } + # response body for status code(s): 400, 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 @@ -363044,6 +363943,655 @@ def create_async_invoke(self, body: Union[JSON, IO[bytes]], **kwargs: Any) -> JS return cast(JSON, deserialized) # type: ignore + @overload + def create_speech( + self, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> Union[JSON, Iterator[bytes]]: + # pylint: disable=line-too-long + """Generate speech from text. + + Convert text input to speech audio. The response may be raw audio bytes (\\ ``audio/mpeg``\\ , + ``audio/wav``\\ , and similar) or a JSON envelope with base64-encoded audio in + ``data[].b64_json``. + + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object or Iterator[bytes] + :rtype: JSON or Iterator[bytes] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "input": "str", # The text to convert to speech. Required. + "model": "str", # The text-to-speech model to use. Required. + "instructions": "str", # Optional. Optional style or delivery instructions + for the synthesizer. + "response_format": "str", # Optional. The audio format to return. Supported + values include ``mp3`` and ``wav``. The API may return raw audio bytes or a JSON + envelope with base64-encoded audio. + "voice": "str" # Optional. The voice to use for synthesis. + } + + # response body for status code(s): 200 + response == { + "data": [ + { + "b64_json": "str" # Base64-encoded audio bytes. Required. + } + ], + "created": 0 # Optional. Unix timestamp (in seconds) of when the audio was + created. + } + """ + + @overload + def create_speech( + self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> Union[JSON, Iterator[bytes]]: + """Generate speech from text. + + Convert text input to speech audio. The response may be raw audio bytes (\\ ``audio/mpeg``\\ , + ``audio/wav``\\ , and similar) or a JSON envelope with base64-encoded audio in + ``data[].b64_json``. + + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object or Iterator[bytes] + :rtype: JSON or Iterator[bytes] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "data": [ + { + "b64_json": "str" # Base64-encoded audio bytes. Required. + } + ], + "created": 0 # Optional. Unix timestamp (in seconds) of when the audio was + created. + } + """ + + @distributed_trace + def create_speech( + self, body: Union[JSON, IO[bytes]], **kwargs: Any + ) -> Union[JSON, Iterator[bytes]]: + # pylint: disable=line-too-long + """Generate speech from text. + + Convert text input to speech audio. The response may be raw audio bytes (\\ ``audio/mpeg``\\ , + ``audio/wav``\\ , and similar) or a JSON envelope with base64-encoded audio in + ``data[].b64_json``. + + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :return: JSON object or Iterator[bytes] + :rtype: JSON or Iterator[bytes] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "input": "str", # The text to convert to speech. Required. + "model": "str", # The text-to-speech model to use. Required. + "instructions": "str", # Optional. Optional style or delivery instructions + for the synthesizer. + "response_format": "str", # Optional. The audio format to return. Supported + values include ``mp3`` and ``wav``. The API may return raw audio bytes or a JSON + envelope with base64-encoded audio. + "voice": "str" # Optional. The voice to use for synthesis. + } + + # response body for status code(s): 200 + response == { + "data": [ + { + "b64_json": "str" # Base64-encoded audio bytes. Required. + } + ], + "created": 0 # Optional. Unix timestamp (in seconds) of when the audio was + created. + } + """ + 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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) + cls: ClsType[Union[JSON, Iterator[bytes]]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = body + + _request = build_inference_create_speech_request( + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = True + 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, 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) + + 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") + ) + + deserialized = response.iter_bytes() + + 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") + ) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, cast(Union[JSON, Iterator[bytes]], deserialized), response_headers) # type: ignore + + return cast(Union[JSON, Iterator[bytes]], deserialized) # type: ignore + + @overload + def create_video( + self, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Start a video generation job. + + Start an asynchronous video generation job from a text prompt. Poll ``GET + /v1/videos/{video_id}`` until the job reaches a terminal status, then download the MP4 with + ``GET /v1/videos/{video_id}/content`` or from ``output.url`` when present. + + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "model": "str", # The video generation model to use. Required. + "prompt": "str", # A text description of the desired video. Required. + "fps": 0, # Optional. Frames per second for the generated video. + "size": "str" # Optional. The output resolution, for example ``1280x720``. + } + + # response body for status code(s): 200 + response == { + "id": "str", # The video generation job identifier. Required. + "status": "str", # Job status. Poll until the value is a terminal state such + as ``completed`` or ``failed``. Required. + "created_at": 0, # Optional. Unix timestamp (in seconds) of when the job was + created. + "error": { + "str": {} # Optional. Error details when status is ``failed``. + }, + "model": "str", # Optional. The model used for generation. + "object": "str", # Optional. Object type returned by the API. + "output": { + "url": "str" # Optional. Presigned URL for the generated MP4. + }, + "x_request_id": "str" # Optional. Request correlation identifier when + provided by the API. + } + """ + + @overload + def create_video( + self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Start a video generation job. + + Start an asynchronous video generation job from a text prompt. Poll ``GET + /v1/videos/{video_id}`` until the job reaches a terminal status, then download the MP4 with + ``GET /v1/videos/{video_id}/content`` or from ``output.url`` when present. + + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "id": "str", # The video generation job identifier. Required. + "status": "str", # Job status. Poll until the value is a terminal state such + as ``completed`` or ``failed``. Required. + "created_at": 0, # Optional. Unix timestamp (in seconds) of when the job was + created. + "error": { + "str": {} # Optional. Error details when status is ``failed``. + }, + "model": "str", # Optional. The model used for generation. + "object": "str", # Optional. Object type returned by the API. + "output": { + "url": "str" # Optional. Presigned URL for the generated MP4. + }, + "x_request_id": "str" # Optional. Request correlation identifier when + provided by the API. + } + """ + + @distributed_trace + def create_video(self, body: Union[JSON, IO[bytes]], **kwargs: Any) -> JSON: + # pylint: disable=line-too-long + """Start a video generation job. + + Start an asynchronous video generation job from a text prompt. Poll ``GET + /v1/videos/{video_id}`` until the job reaches a terminal status, then download the MP4 with + ``GET /v1/videos/{video_id}/content`` or from ``output.url`` when present. + + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "model": "str", # The video generation model to use. Required. + "prompt": "str", # A text description of the desired video. Required. + "fps": 0, # Optional. Frames per second for the generated video. + "size": "str" # Optional. The output resolution, for example ``1280x720``. + } + + # response body for status code(s): 200 + response == { + "id": "str", # The video generation job identifier. Required. + "status": "str", # Job status. Poll until the value is a terminal state such + as ``completed`` or ``failed``. Required. + "created_at": 0, # Optional. Unix timestamp (in seconds) of when the job was + created. + "error": { + "str": {} # Optional. Error details when status is ``failed``. + }, + "model": "str", # Optional. The model used for generation. + "object": "str", # Optional. Object type returned by the API. + "output": { + "url": "str" # Optional. Presigned URL for the generated MP4. + }, + "x_request_id": "str" # Optional. Request correlation identifier when + provided by the API. + } + """ + 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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) + cls: ClsType[JSON] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = body + + _request = build_inference_create_video_request( + content_type=content_type, + json=_json, + content=_content, + 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) + + response_headers = {} + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @distributed_trace + def get_video(self, video_id: str, **kwargs: Any) -> JSON: + # pylint: disable=line-too-long + """Retrieve a video generation job. + + Returns the current state of a video generation job. Poll until ``status`` reaches a terminal + value such as ``completed`` or ``failed``. + + :param video_id: The video generation job identifier. Required. + :type video_id: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "id": "str", # The video generation job identifier. Required. + "status": "str", # Job status. Poll until the value is a terminal state such + as ``completed`` or ``failed``. Required. + "created_at": 0, # Optional. Unix timestamp (in seconds) of when the job was + created. + "error": { + "str": {} # Optional. Error details when status is ``failed``. + }, + "model": "str", # Optional. The model used for generation. + "object": "str", # Optional. Object type returned by the API. + "output": { + "url": "str" # Optional. Presigned URL for the generated MP4. + }, + "x_request_id": "str" # Optional. Request correlation identifier when + provided by the API. + } + # 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_inference_get_video_request( + video_id=video_id, + 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_video_content( + self, video_id: str, **kwargs: Any + ) -> Union[Iterator[bytes], JSON]: + # pylint: disable=line-too-long + """Download generated video content. + + Downloads the generated MP4 for a completed video generation job. + + :param video_id: The video generation job identifier. Required. + :type video_id: str + :return: Iterator[bytes] or JSON object + :rtype: Iterator[bytes] or JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # 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[Union[Iterator[bytes], JSON]] = kwargs.pop("cls", None) + + _request = build_inference_get_video_content_request( + video_id=video_id, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = True + 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") + ) + + deserialized = response.iter_bytes() + + 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") + ) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, cast(Union[Iterator[bytes], JSON], deserialized), response_headers) # type: ignore + + return cast(Union[Iterator[bytes], JSON], deserialized) # type: ignore + @overload def create_batch_file( self, body: JSON, *, content_type: str = "application/json", **kwargs: Any diff --git a/src/pydo/resources/aio/inference/__init__.py b/src/pydo/resources/aio/inference/__init__.py index 64010fce..89f6127d 100644 --- a/src/pydo/resources/aio/inference/__init__.py +++ b/src/pydo/resources/aio/inference/__init__.py @@ -8,6 +8,7 @@ from pydo.aio import Client from .async_invoke import AsyncInvoke +from .audio import Audio from .batches import Batches from .chat import Chat from .embeddings import Embeddings @@ -17,6 +18,7 @@ from .models import Models from .responses import Responses from .systemone import Systemone +from .videos import Videos class InferenceResources: @@ -24,6 +26,7 @@ class InferenceResources: def __init__(self, client: Client) -> None: self.async_invoke = AsyncInvoke(client) + self.audio = Audio(client) self.batches = Batches(client) self.chat = Chat(client) self.embeddings = Embeddings(client) @@ -33,6 +36,7 @@ def __init__(self, client: Client) -> None: self.models = Models(client) self.responses = Responses(client) self.systemone = Systemone(client) + self.videos = Videos(client) __all__ = ["InferenceResources"] diff --git a/src/pydo/resources/aio/inference/audio/__init__.py b/src/pydo/resources/aio/inference/audio/__init__.py new file mode 100644 index 00000000..681e3cc7 --- /dev/null +++ b/src/pydo/resources/aio/inference/audio/__init__.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) DigitalOcean. +# Licensed under the Apache-2.0 License. +# ------------------------------------ +# Generated by scripts/generate_inference_resources.py — do not edit. +from __future__ import annotations + + +from pydo.aio import Client +from .speech import Speech + + +class Audio: + """Inference path namespace (generated).""" + + def __init__(self, client: Client) -> None: + self.speech = Speech(client) + + +__all__ = ["Audio"] diff --git a/src/pydo/resources/aio/inference/audio/speech.py b/src/pydo/resources/aio/inference/audio/speech.py new file mode 100644 index 00000000..4fc07fad --- /dev/null +++ b/src/pydo/resources/aio/inference/audio/speech.py @@ -0,0 +1,33 @@ +# ------------------------------------ +# Copyright (c) DigitalOcean. +# Licensed under the Apache-2.0 License. +# ------------------------------------ +# Generated by scripts/generate_inference_resources.py — do not edit. +from __future__ import annotations + +from typing import Any + +from pydo.aio import Client +from pydo.custom_extensions import ( + _SDK_KWARGS, + _prepare_body, + _wrap, + _wrap_with_id_alias, +) + + +class Speech: + """Inference resource helper (generated).""" + + def __init__(self, client: Client) -> None: + self._client = client + + async def create(self, **kwargs: Any) -> Any: + """Delegates to ``client.inference.create_speech``.""" + body = {k: v for k, v in kwargs.items() if k not in _SDK_KWARGS} + sdk = {k: v for k, v in kwargs.items() if k in _SDK_KWARGS} + body = _prepare_body("create_speech", body) + return _wrap_with_id_alias( + await self._client.inference.create_speech(body, **sdk), + primary_id_field="speech_id", + ) diff --git a/src/pydo/resources/aio/inference/videos/__init__.py b/src/pydo/resources/aio/inference/videos/__init__.py new file mode 100644 index 00000000..231fe76f --- /dev/null +++ b/src/pydo/resources/aio/inference/videos/__init__.py @@ -0,0 +1,48 @@ +# ------------------------------------ +# Copyright (c) DigitalOcean. +# Licensed under the Apache-2.0 License. +# ------------------------------------ +# Generated by scripts/generate_inference_resources.py — do not edit. +from __future__ import annotations + + +from typing import Any + +from pydo.aio import Client +from pydo.custom_extensions import ( + _SDK_KWARGS, + _prepare_body, + _wrap, + _wrap_with_id_alias, +) +from .content import Content + + +class Videos: + """Inference resource helper (generated).""" + + def __init__(self, client: Client) -> None: + self._client = client + self.content = Content(client) + + async def create(self, **kwargs: Any) -> Any: + """Delegates to ``client.inference.create_video``.""" + body = {k: v for k, v in kwargs.items() if k not in _SDK_KWARGS} + sdk = {k: v for k, v in kwargs.items() if k in _SDK_KWARGS} + body = _prepare_body("create_video", body) + return _wrap_with_id_alias( + await self._client.inference.create_video(body, **sdk), + primary_id_field="video_id", + ) + + async def get(self, video_id: str, **kwargs: Any) -> Any: + """Delegates to ``client.inference.get_video``.""" + return _wrap_with_id_alias( + await self._client.inference.get_video(video_id=video_id, **kwargs), + primary_id_field="video_id", + ) + + retrieve = get + + +__all__ = ["Videos"] diff --git a/src/pydo/resources/aio/inference/videos/content.py b/src/pydo/resources/aio/inference/videos/content.py new file mode 100644 index 00000000..044a8b71 --- /dev/null +++ b/src/pydo/resources/aio/inference/videos/content.py @@ -0,0 +1,32 @@ +# ------------------------------------ +# Copyright (c) DigitalOcean. +# Licensed under the Apache-2.0 License. +# ------------------------------------ +# Generated by scripts/generate_inference_resources.py — do not edit. +from __future__ import annotations + +from typing import Any + +from pydo.aio import Client +from pydo.custom_extensions import ( + _SDK_KWARGS, + _prepare_body, + _wrap, + _wrap_with_id_alias, +) + + +class Content: + """Inference resource helper (generated).""" + + def __init__(self, client: Client) -> None: + self._client = client + + async def get(self, video_id: str, **kwargs: Any) -> Any: + """Delegates to ``client.inference.get_video_content``.""" + return _wrap_with_id_alias( + await self._client.inference.get_video_content(video_id=video_id, **kwargs), + primary_id_field="video_id", + ) + + retrieve = get diff --git a/src/pydo/resources/client_surface.py b/src/pydo/resources/client_surface.py index b4d72544..99a6aea4 100644 --- a/src/pydo/resources/client_surface.py +++ b/src/pydo/resources/client_surface.py @@ -18,6 +18,12 @@ def async_invoke(self) -> Any: return self._require_inference_resource_root().async_invoke + @property + def audio(self) -> Any: + """Nested serverless inference API under path segment ``audio``.""" + + return self._require_inference_resource_root().audio + @property def batches(self) -> Any: """Nested serverless inference API under path segment ``batches``.""" @@ -66,6 +72,12 @@ def systemone(self) -> Any: return self._require_inference_resource_root().systemone + @property + def videos(self) -> Any: + """Nested serverless inference API under path segment ``videos``.""" + + return self._require_inference_resource_root().videos + @property def audio(self) -> Any: """Audio namespace (TTS + generation via async-invoke).""" diff --git a/src/pydo/resources/inference/__init__.py b/src/pydo/resources/inference/__init__.py index fa4039a0..ec3e5489 100644 --- a/src/pydo/resources/inference/__init__.py +++ b/src/pydo/resources/inference/__init__.py @@ -8,6 +8,7 @@ from pydo import Client from .async_invoke import AsyncInvoke +from .audio import Audio from .batches import Batches from .chat import Chat from .embeddings import Embeddings @@ -17,6 +18,7 @@ from .models import Models from .responses import Responses from .systemone import Systemone +from .videos import Videos class InferenceResources: @@ -24,6 +26,7 @@ class InferenceResources: def __init__(self, client: Client) -> None: self.async_invoke = AsyncInvoke(client) + self.audio = Audio(client) self.batches = Batches(client) self.chat = Chat(client) self.embeddings = Embeddings(client) @@ -33,6 +36,7 @@ def __init__(self, client: Client) -> None: self.models = Models(client) self.responses = Responses(client) self.systemone = Systemone(client) + self.videos = Videos(client) __all__ = ["InferenceResources"] diff --git a/src/pydo/resources/inference/audio/__init__.py b/src/pydo/resources/inference/audio/__init__.py new file mode 100644 index 00000000..aaab2317 --- /dev/null +++ b/src/pydo/resources/inference/audio/__init__.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) DigitalOcean. +# Licensed under the Apache-2.0 License. +# ------------------------------------ +# Generated by scripts/generate_inference_resources.py — do not edit. +from __future__ import annotations + + +from pydo import Client +from .speech import Speech + + +class Audio: + """Inference path namespace (generated).""" + + def __init__(self, client: Client) -> None: + self.speech = Speech(client) + + +__all__ = ["Audio"] diff --git a/src/pydo/resources/inference/audio/speech.py b/src/pydo/resources/inference/audio/speech.py new file mode 100644 index 00000000..44b092dc --- /dev/null +++ b/src/pydo/resources/inference/audio/speech.py @@ -0,0 +1,33 @@ +# ------------------------------------ +# Copyright (c) DigitalOcean. +# Licensed under the Apache-2.0 License. +# ------------------------------------ +# Generated by scripts/generate_inference_resources.py — do not edit. +from __future__ import annotations + +from typing import Any + +from pydo import Client +from pydo.custom_extensions import ( + _SDK_KWARGS, + _prepare_body, + _wrap, + _wrap_with_id_alias, +) + + +class Speech: + """Inference resource helper (generated).""" + + def __init__(self, client: Client) -> None: + self._client = client + + def create(self, **kwargs: Any) -> Any: + """Delegates to ``client.inference.create_speech``.""" + body = {k: v for k, v in kwargs.items() if k not in _SDK_KWARGS} + sdk = {k: v for k, v in kwargs.items() if k in _SDK_KWARGS} + body = _prepare_body("create_speech", body) + return _wrap_with_id_alias( + self._client.inference.create_speech(body, **sdk), + primary_id_field="speech_id", + ) diff --git a/src/pydo/resources/inference/videos/__init__.py b/src/pydo/resources/inference/videos/__init__.py new file mode 100644 index 00000000..1d9987d0 --- /dev/null +++ b/src/pydo/resources/inference/videos/__init__.py @@ -0,0 +1,48 @@ +# ------------------------------------ +# Copyright (c) DigitalOcean. +# Licensed under the Apache-2.0 License. +# ------------------------------------ +# Generated by scripts/generate_inference_resources.py — do not edit. +from __future__ import annotations + + +from typing import Any + +from pydo import Client +from pydo.custom_extensions import ( + _SDK_KWARGS, + _prepare_body, + _wrap, + _wrap_with_id_alias, +) +from .content import Content + + +class Videos: + """Inference resource helper (generated).""" + + def __init__(self, client: Client) -> None: + self._client = client + self.content = Content(client) + + def create(self, **kwargs: Any) -> Any: + """Delegates to ``client.inference.create_video``.""" + body = {k: v for k, v in kwargs.items() if k not in _SDK_KWARGS} + sdk = {k: v for k, v in kwargs.items() if k in _SDK_KWARGS} + body = _prepare_body("create_video", body) + return _wrap_with_id_alias( + self._client.inference.create_video(body, **sdk), + primary_id_field="video_id", + ) + + def get(self, video_id: str, **kwargs: Any) -> Any: + """Delegates to ``client.inference.get_video``.""" + return _wrap_with_id_alias( + self._client.inference.get_video(video_id=video_id, **kwargs), + primary_id_field="video_id", + ) + + retrieve = get + + +__all__ = ["Videos"] diff --git a/src/pydo/resources/inference/videos/content.py b/src/pydo/resources/inference/videos/content.py new file mode 100644 index 00000000..8c87bd37 --- /dev/null +++ b/src/pydo/resources/inference/videos/content.py @@ -0,0 +1,32 @@ +# ------------------------------------ +# Copyright (c) DigitalOcean. +# Licensed under the Apache-2.0 License. +# ------------------------------------ +# Generated by scripts/generate_inference_resources.py — do not edit. +from __future__ import annotations + +from typing import Any + +from pydo import Client +from pydo.custom_extensions import ( + _SDK_KWARGS, + _prepare_body, + _wrap, + _wrap_with_id_alias, +) + + +class Content: + """Inference resource helper (generated).""" + + def __init__(self, client: Client) -> None: + self._client = client + + def get(self, video_id: str, **kwargs: Any) -> Any: + """Delegates to ``client.inference.get_video_content``.""" + return _wrap_with_id_alias( + self._client.inference.get_video_content(video_id=video_id, **kwargs), + primary_id_field="video_id", + ) + + retrieve = get diff --git a/src/pydo/resources/inference_surface.json b/src/pydo/resources/inference_surface.json index 5521521d..c44f4434 100644 --- a/src/pydo/resources/inference_surface.json +++ b/src/pydo/resources/inference_surface.json @@ -83,6 +83,54 @@ "create" ] }, + { + "op_method": "create_speech", + "path_segments": [ + "audio", + "speech" + ], + "path_params": [], + "facade_methods": [ + "create" + ] + }, + { + "op_method": "create_video", + "path_segments": [ + "videos" + ], + "path_params": [], + "facade_methods": [ + "create" + ] + }, + { + "op_method": "get_video", + "path_segments": [ + "videos" + ], + "path_params": [ + "video_id" + ], + "facade_methods": [ + "get", + "retrieve" + ] + }, + { + "op_method": "get_video_content", + "path_segments": [ + "videos", + "content" + ], + "path_params": [ + "video_id" + ], + "facade_methods": [ + "get", + "retrieve" + ] + }, { "op_method": "create_batch_file", "path_segments": [ diff --git a/src/pydo/types/__init__.py b/src/pydo/types/__init__.py index d98c4989..19bdcbc1 100644 --- a/src/pydo/types/__init__.py +++ b/src/pydo/types/__init__.py @@ -15,6 +15,8 @@ """ from pydo.types.async_invoke import AsyncInvokeResponse +from pydo.types.audio import SpeechAudioItem +from pydo.types.audio import SpeechResponse from pydo.types.batches import Batch from pydo.types.batches import BatchFileCreateResponse from pydo.types.batches import BatchResultsResponse @@ -45,9 +47,13 @@ from pydo.types.systemone import SystemoneAnswer from pydo.types.systemone import SystemoneResponse from pydo.types.systemone import SystemoneUsage +from pydo.types.videos import VideoGeneration +from pydo.types.videos import VideoGenerationOutput __all__ = [ "AsyncInvokeResponse", + "SpeechAudioItem", + "SpeechResponse", "Batch", "BatchFileCreateResponse", "BatchResultsResponse", @@ -78,4 +84,6 @@ "SystemoneAnswer", "SystemoneResponse", "SystemoneUsage", + "VideoGeneration", + "VideoGenerationOutput", ] diff --git a/src/pydo/types/audio/__init__.py b/src/pydo/types/audio/__init__.py new file mode 100644 index 00000000..fff17f99 --- /dev/null +++ b/src/pydo/types/audio/__init__.py @@ -0,0 +1,26 @@ +# ------------------------------------ +# Copyright (c) DigitalOcean. +# Licensed under the Apache-2.0 License. +# ------------------------------------ +# Generated by scripts/generate_inference_types.py — do not edit. +from __future__ import annotations + +from typing import Any, List, Optional + +from pydo.custom_extensions import DotDict + + +class SpeechAudioItem(DotDict): + """Typed response for ``speech_audio_item`` schema.""" + + b64_json: str # Base64-encoded audio bytes + + +class SpeechResponse(DotDict): + """Typed response for ``speech_response`` schema.""" + + created: int # Unix timestamp (in seconds) of when the audio was created + data: List[Any] # Generated audio items + + +__all__ = ["SpeechAudioItem", "SpeechResponse"] diff --git a/src/pydo/types/videos/__init__.py b/src/pydo/types/videos/__init__.py new file mode 100644 index 00000000..c59c1486 --- /dev/null +++ b/src/pydo/types/videos/__init__.py @@ -0,0 +1,34 @@ +# ------------------------------------ +# Copyright (c) DigitalOcean. +# Licensed under the Apache-2.0 License. +# ------------------------------------ +# Generated by scripts/generate_inference_types.py — do not edit. +from __future__ import annotations + +from typing import Any, Optional + +from pydo.custom_extensions import DotDict + + +class VideoGeneration(DotDict): + """Typed response for ``video_generation`` schema.""" + + id: str # The video generation job identifier + object: str # Object type returned by the API + created_at: int # Unix timestamp (in seconds) of when the job was created + model: str # The model used for generation + status: str + output: Optional[Any] + error: Optional[Any] # Error details when status is `failed` + x_request_id: Optional[ + str + ] # Request correlation identifier when provided by the API + + +class VideoGenerationOutput(DotDict): + """Typed response for ``video_generation_output`` schema.""" + + url: str # Presigned URL for the generated MP4 + + +__all__ = ["VideoGeneration", "VideoGenerationOutput"]