From 2a7a0f5f1421db1da6b9b8df09b653a25158a342 Mon Sep 17 00:00:00 2001 From: API Engineering Date: Mon, 3 Feb 2025 17:53:54 +0000 Subject: [PATCH] [bot] Updated client based on openapi-25f2388/clientgen --- DO_OPENAPI_COMMIT_SHA.txt | 2 +- src/pydo/aio/operations/_operations.py | 3490 +++++++++++++------ src/pydo/operations/_operations.py | 4448 ++++++++++++++++-------- 3 files changed, 5477 insertions(+), 2463 deletions(-) diff --git a/DO_OPENAPI_COMMIT_SHA.txt b/DO_OPENAPI_COMMIT_SHA.txt index 23e84f0..3c95cfe 100644 --- a/DO_OPENAPI_COMMIT_SHA.txt +++ b/DO_OPENAPI_COMMIT_SHA.txt @@ -1 +1 @@ -9d34fba +25f2388 diff --git a/src/pydo/aio/operations/_operations.py b/src/pydo/aio/operations/_operations.py index 5571e2b..aea2953 100644 --- a/src/pydo/aio/operations/_operations.py +++ b/src/pydo/aio/operations/_operations.py @@ -204,11 +204,13 @@ build_genai_cancel_indexing_job_request, build_genai_create_agent_api_key_request, build_genai_create_agent_request, + build_genai_create_anthropic_api_key_request, build_genai_create_indexing_job_request, build_genai_create_knowledge_base_data_source_request, build_genai_create_knowledge_base_request, build_genai_delete_agent_api_key_request, build_genai_delete_agent_request, + build_genai_delete_anthropic_api_key_request, build_genai_delete_knowledge_base_data_source_request, build_genai_delete_knowledge_base_request, build_genai_detach_agent_function_request, @@ -216,10 +218,13 @@ build_genai_detach_knowledge_base_request, build_genai_get_agent_children_request, build_genai_get_agent_request, + build_genai_get_anthropic_api_key_request, build_genai_get_indexing_job_request, build_genai_get_knowledge_base_request, build_genai_list_agent_api_keys_request, + build_genai_list_agents_by_anthropic_key_request, build_genai_list_agents_request, + build_genai_list_anthropic_api_keys_request, build_genai_list_datacenter_regions_request, build_genai_list_indexing_job_data_sources_request, build_genai_list_indexing_jobs_request, @@ -231,6 +236,7 @@ build_genai_update_agent_deployment_visibility_request, build_genai_update_agent_function_request, build_genai_update_agent_request, + build_genai_update_anthropic_api_key_request, build_genai_update_attached_agent_request, build_genai_update_knowledge_base_request, build_image_actions_get_request, @@ -164286,398 +164292,6 @@ def __init__(self, *args, **kwargs) -> None: input_args.pop(0) if input_args else kwargs.pop("deserializer") ) - @distributed_trace_async - async def list_agents( - self, - *, - only_deployed: Optional[bool] = None, - page: Optional[int] = None, - per_page: Optional[int] = None, - **kwargs: Any - ) -> JSON: - # pylint: disable=line-too-long - """List Agents. - - To list all agents, send a GET request to ``/v2/gen-ai/agents``. - - :keyword only_deployed: Only list agents that are deployed. Default value is None. - :paramtype only_deployed: bool - :keyword page: Page number. Default value is None. - :paramtype page: int - :keyword per_page: Items per page. Default value is None. - :paramtype per_page: int - :return: JSON object - :rtype: JSON - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "agents": [ - { - "chatbot": { - "button_background_color": "str", # Optional. A - Chatbot. - "logo": "str", # Optional. A Chatbot. - "name": "str", # Optional. Name of chatbot. - "primary_color": "str", # Optional. A Chatbot. - "secondary_color": "str", # Optional. A Chatbot. - "starting_message": "str" # Optional. A Chatbot. - }, - "chatbot_identifiers": [ - { - "agent_chatbot_identifier": "str" # - Optional. Agent chatbot identifier. - } - ], - "created_at": "2020-02-20 00:00:00", # Optional. Creation - date / time. - "deployment": { - "created_at": "2020-02-20 00:00:00", # Optional. - Creation date / time. - "name": "str", # Optional. Name. - "status": "STATUS_UNKNOWN", # Optional. Default - value is "STATUS_UNKNOWN". Known values are: "STATUS_UNKNOWN", - "STATUS_WAITING_FOR_DEPLOYMENT", "STATUS_DEPLOYING", - "STATUS_RUNNING", "STATUS_FAILED", "STATUS_WAITING_FOR_UNDEPLOYMENT", - "STATUS_UNDEPLOYING", "STATUS_UNDEPLOYMENT_FAILED", and - "STATUS_DELETED". - "updated_at": "2020-02-20 00:00:00", # Optional. - Last modified. - "url": "str", # Optional. Access your deployed agent - here. - "uuid": "str", # Optional. Unique id. - "visibility": "VISIBILITY_UNKNOWN" # Optional. - Default value is "VISIBILITY_UNKNOWN". * VISIBILITY_UNKNOWN: The - status of the deployment is unknown * VISIBILITY_DISABLED: The - deployment is disabled and will no longer service requests * - VISIBILITY_PLAYGROUND: Deprecated: No longer a valid state * - VISIBILITY_PUBLIC: The deployment is public and will service requests - from the public internet * VISIBILITY_PRIVATE: The deployment is - private and will only service requests from other agents, or through - API keys. Known values are: "VISIBILITY_UNKNOWN", - "VISIBILITY_DISABLED", "VISIBILITY_PLAYGROUND", "VISIBILITY_PUBLIC", - and "VISIBILITY_PRIVATE". - }, - "description": "str", # Optional. Description of agent. - "if_case": "str", # Optional. Instructions to the agent on - how to use the route. - "instruction": "str", # Optional. Agent instruction. - Instructions help your agent to perform its job effectively. See `Write - Effective Agent Instructions - `_ - for best practices. - "k": 0, # Optional. How many results should be considered - from an attached knowledge base. - "max_tokens": 0, # Optional. Specifies the maximum number of - tokens the model can process in a single input or output, set as a number - between 1 and 512. This determines the length of each response. - "model": { - "agreement": { - "description": "str", # Optional. Agreement - Description. - "name": "str", # Optional. Agreement - Description. - "url": "str", # Optional. Agreement - Description. - "uuid": "str" # Optional. Agreement - Description. - }, - "created_at": "2020-02-20 00:00:00", # Optional. - Creation date / time. - "inference_name": "str", # Optional. Internally used - name. - "inference_version": "str", # Optional. Internally - used version. - "is_foundational": bool, # Optional. True if it is a - foundational model provided by do. - "metadata": {}, # Optional. Additional meta data. - "name": "str", # Optional. Name of the model. - "parent_uuid": "str", # Optional. Unique id of the - model, this model is based on. - "provider": "MODEL_PROVIDER_DIGITALOCEAN", # - Optional. Default value is "MODEL_PROVIDER_DIGITALOCEAN". Known - values are: "MODEL_PROVIDER_DIGITALOCEAN" and - "MODEL_PROVIDER_ANTHROPIC". - "updated_at": "2020-02-20 00:00:00", # Optional. - Last modified. - "upload_complete": bool, # Optional. Model has been - fully uploaded. - "url": "str", # Optional. Download url. - "uuid": "str", # Optional. Unique id. - "version": { - "major": 0, # Optional. Major version - number. - "minor": 0, # Optional. Minor version - number. - "patch": 0 # Optional. Patch version number. - } - }, - "name": "str", # Optional. Agent name. - "project_id": "str", # Optional. The DigitalOcean project ID - associated with the agent. - "region": "str", # Optional. Region code. - "route_created_at": "2020-02-20 00:00:00", # Optional. - Creation of route date / time. - "route_created_by": "str", # Optional. Id of user that - created the route. - "route_name": "str", # Optional. Route name. - "route_uuid": "str", # Optional. Route uuid. - "tags": [ - "str" # Optional. A set of abitrary tags to organize - your agent. - ], - "temperature": 0.0, # Optional. Controls the model"u2019s - creativity, specified as a number between 0 and 1. Lower values produce - more predictable and conservative responses, while higher values - encourage creativity and variation. - "template": { - "created_at": "2020-02-20 00:00:00", # Optional. The - agent template's creation date. - "description": "str", # Optional. Description of the - agent template. - "instruction": "str", # Optional. Instructions for - the agent template. - "k": 0, # Optional. The 'k' value for the agent - template. - "knowledge_bases": [ - { - "added_to_agent_at": "2020-02-20 - 00:00:00", # Optional. Time when the knowledge base was - added to the agent. - "created_at": "2020-02-20 00:00:00", - # Optional. Creation date / time. - "database_id": "str", # Optional. - List of knowledge bases associated with the agent template. - "embedding_model_uuid": "str", # - Optional. List of knowledge bases associated with the agent - template. - "is_public": bool, # Optional. - Whether the knowledge base is public or not. - "last_indexing_job": { - "completed_datasources": 0, - # Optional. Number of datasources indexed completed. - "created_at": "2020-02-20 - 00:00:00", # Optional. Creation date / time. - "data_source_uuids": [ - "str" # Optional. - IndexingJob description. - ], - "finished_at": "2020-02-20 - 00:00:00", # Optional. IndexingJob description. - "knowledge_base_uuid": "str", - # Optional. Knowledge base id. - "phase": - "BATCH_JOB_PHASE_UNKNOWN", # Optional. Default value is - "BATCH_JOB_PHASE_UNKNOWN". Known values are: - "BATCH_JOB_PHASE_UNKNOWN", "BATCH_JOB_PHASE_PENDING", - "BATCH_JOB_PHASE_RUNNING", "BATCH_JOB_PHASE_SUCCEEDED", - "BATCH_JOB_PHASE_FAILED", and "BATCH_JOB_PHASE_ERROR". - "started_at": "2020-02-20 - 00:00:00", # Optional. IndexingJob description. - "tokens": 0, # Optional. - Number of tokens. - "total_datasources": 0, # - Optional. Number of datasources being indexed. - "updated_at": "2020-02-20 - 00:00:00", # Optional. Last modified. - "uuid": "str" # Optional. - Unique id. - }, - "name": "str", # Optional. Name of - knowledge base. - "project_id": "str", # Optional. - List of knowledge bases associated with the agent template. - "region": "str", # Optional. Region - code. - "tags": [ - "str" # Optional. Tags to - organize related resources. - ], - "updated_at": "2020-02-20 00:00:00", - # Optional. Last modified. - "user_id": "str", # Optional. Id of - user that created the knowledge base. - "uuid": "str" # Optional. Unique id - for knowledge base. - } - ], - "max_tokens": 0, # Optional. The max_tokens setting - for the agent template. - "model": { - "agreement": { - "description": "str", # Optional. - Agreement Description. - "name": "str", # Optional. Agreement - Description. - "url": "str", # Optional. Agreement - Description. - "uuid": "str" # Optional. Agreement - Description. - }, - "created_at": "2020-02-20 00:00:00", # - Optional. Creation date / time. - "inference_name": "str", # Optional. - Internally used name. - "inference_version": "str", # Optional. - Internally used version. - "is_foundational": bool, # Optional. True if - it is a foundational model provided by do. - "metadata": {}, # Optional. Additional meta - data. - "name": "str", # Optional. Name of the - model. - "parent_uuid": "str", # Optional. Unique id - of the model, this model is based on. - "provider": "MODEL_PROVIDER_DIGITALOCEAN", # - Optional. Default value is "MODEL_PROVIDER_DIGITALOCEAN". Known - values are: "MODEL_PROVIDER_DIGITALOCEAN" and - "MODEL_PROVIDER_ANTHROPIC". - "updated_at": "2020-02-20 00:00:00", # - Optional. Last modified. - "upload_complete": bool, # Optional. Model - has been fully uploaded. - "url": "str", # Optional. Download url. - "uuid": "str", # Optional. Unique id. - "version": { - "major": 0, # Optional. Major - version number. - "minor": 0, # Optional. Minor - version number. - "patch": 0 # Optional. Patch version - number. - } - }, - "name": "str", # Optional. Name of the agent - template. - "temperature": 0.0, # Optional. The temperature - setting for the agent template. - "top_p": 0.0, # Optional. The top_p setting for the - agent template. - "updated_at": "2020-02-20 00:00:00", # Optional. The - agent template's last updated date. - "uuid": "str" # Optional. Unique id. - }, - "top_p": 0.0, # Optional. Defines the cumulative probability - threshold for word selection, specified as a number between 0 and 1. - Higher values allow for more diverse outputs, while lower values ensure - focused and coherent responses. - "updated_at": "2020-02-20 00:00:00", # Optional. Last - modified. - "url": "str", # Optional. Access your agent under this url. - "user_id": "str", # Optional. Id of user that created the - agent. - "uuid": "str" # Optional. Unique agent id. - } - ], - "links": { - "pages": { - "first": "str", # Optional. First page. - "last": "str", # Optional. Last page. - "next": "str", # Optional. Next page. - "previous": "str" # Optional. Previous page. - } - }, - "meta": { - "page": 0, # Optional. The current page. - "pages": 0, # Optional. Total number of pages. - "total": 0 # Optional. Total amount of items over all pages. - } - } - # 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_genai_list_agents_request( - only_deployed=only_deployed, - page=page, - per_page=per_page, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = ( - await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 404]: - if _stream: - await response.read() # Load the body in memory and close the socket - map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore - raise HttpResponseError(response=response) - - response_headers = {} - if response.status_code == 200: - response_headers["ratelimit-limit"] = self._deserialize( - "int", response.headers.get("ratelimit-limit") - ) - response_headers["ratelimit-remaining"] = self._deserialize( - "int", response.headers.get("ratelimit-remaining") - ) - response_headers["ratelimit-reset"] = self._deserialize( - "int", response.headers.get("ratelimit-reset") - ) - - if response.content: - deserialized = response.json() - else: - deserialized = None - - if response.status_code == 404: - response_headers["ratelimit-limit"] = self._deserialize( - "int", response.headers.get("ratelimit-limit") - ) - response_headers["ratelimit-remaining"] = self._deserialize( - "int", response.headers.get("ratelimit-remaining") - ) - response_headers["ratelimit-reset"] = self._deserialize( - "int", response.headers.get("ratelimit-reset") - ) - - if response.content: - deserialized = response.json() - else: - deserialized = None - - if cls: - return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore - - return cast(JSON, deserialized) # type: ignore - @overload async def create_agent( self, @@ -164706,6 +164320,8 @@ async def create_agent( # JSON input template you can fill out and use as your body input. body = { + "anthropic_key_uuid": "str", # Optional. Optional Anthropic API key ID to + use with Anthropic models. "description": "str", # Optional. A text description of the agent, not used in inference. "instruction": "str", # Optional. Agent instruction. Instructions help your @@ -165518,6 +165134,8 @@ async def create_agent( # JSON input template you can fill out and use as your body input. body = { + "anthropic_key_uuid": "str", # Optional. Optional Anthropic API key ID to + use with Anthropic models. "description": "str", # Optional. A text description of the agent, not used in inference. "instruction": "str", # Optional. Agent instruction. Instructions help your @@ -166004,6 +165622,398 @@ async def create_agent( return cast(JSON, deserialized) # type: ignore + @distributed_trace_async + async def list_agents( + self, + *, + only_deployed: Optional[bool] = None, + page: Optional[int] = None, + per_page: Optional[int] = None, + **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """List Agents. + + To list all agents, send a GET request to ``/v2/gen-ai/agents``. + + :keyword only_deployed: Only list agents that are deployed. Default value is None. + :paramtype only_deployed: bool + :keyword page: Page number. Default value is None. + :paramtype page: int + :keyword per_page: Items per page. Default value is None. + :paramtype per_page: int + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "agents": [ + { + "chatbot": { + "button_background_color": "str", # Optional. A + Chatbot. + "logo": "str", # Optional. A Chatbot. + "name": "str", # Optional. Name of chatbot. + "primary_color": "str", # Optional. A Chatbot. + "secondary_color": "str", # Optional. A Chatbot. + "starting_message": "str" # Optional. A Chatbot. + }, + "chatbot_identifiers": [ + { + "agent_chatbot_identifier": "str" # + Optional. Agent chatbot identifier. + } + ], + "created_at": "2020-02-20 00:00:00", # Optional. Creation + date / time. + "deployment": { + "created_at": "2020-02-20 00:00:00", # Optional. + Creation date / time. + "name": "str", # Optional. Name. + "status": "STATUS_UNKNOWN", # Optional. Default + value is "STATUS_UNKNOWN". Known values are: "STATUS_UNKNOWN", + "STATUS_WAITING_FOR_DEPLOYMENT", "STATUS_DEPLOYING", + "STATUS_RUNNING", "STATUS_FAILED", "STATUS_WAITING_FOR_UNDEPLOYMENT", + "STATUS_UNDEPLOYING", "STATUS_UNDEPLOYMENT_FAILED", and + "STATUS_DELETED". + "updated_at": "2020-02-20 00:00:00", # Optional. + Last modified. + "url": "str", # Optional. Access your deployed agent + here. + "uuid": "str", # Optional. Unique id. + "visibility": "VISIBILITY_UNKNOWN" # Optional. + Default value is "VISIBILITY_UNKNOWN". * VISIBILITY_UNKNOWN: The + status of the deployment is unknown * VISIBILITY_DISABLED: The + deployment is disabled and will no longer service requests * + VISIBILITY_PLAYGROUND: Deprecated: No longer a valid state * + VISIBILITY_PUBLIC: The deployment is public and will service requests + from the public internet * VISIBILITY_PRIVATE: The deployment is + private and will only service requests from other agents, or through + API keys. Known values are: "VISIBILITY_UNKNOWN", + "VISIBILITY_DISABLED", "VISIBILITY_PLAYGROUND", "VISIBILITY_PUBLIC", + and "VISIBILITY_PRIVATE". + }, + "description": "str", # Optional. Description of agent. + "if_case": "str", # Optional. Instructions to the agent on + how to use the route. + "instruction": "str", # Optional. Agent instruction. + Instructions help your agent to perform its job effectively. See `Write + Effective Agent Instructions + `_ + for best practices. + "k": 0, # Optional. How many results should be considered + from an attached knowledge base. + "max_tokens": 0, # Optional. Specifies the maximum number of + tokens the model can process in a single input or output, set as a number + between 1 and 512. This determines the length of each response. + "model": { + "agreement": { + "description": "str", # Optional. Agreement + Description. + "name": "str", # Optional. Agreement + Description. + "url": "str", # Optional. Agreement + Description. + "uuid": "str" # Optional. Agreement + Description. + }, + "created_at": "2020-02-20 00:00:00", # Optional. + Creation date / time. + "inference_name": "str", # Optional. Internally used + name. + "inference_version": "str", # Optional. Internally + used version. + "is_foundational": bool, # Optional. True if it is a + foundational model provided by do. + "metadata": {}, # Optional. Additional meta data. + "name": "str", # Optional. Name of the model. + "parent_uuid": "str", # Optional. Unique id of the + model, this model is based on. + "provider": "MODEL_PROVIDER_DIGITALOCEAN", # + Optional. Default value is "MODEL_PROVIDER_DIGITALOCEAN". Known + values are: "MODEL_PROVIDER_DIGITALOCEAN" and + "MODEL_PROVIDER_ANTHROPIC". + "updated_at": "2020-02-20 00:00:00", # Optional. + Last modified. + "upload_complete": bool, # Optional. Model has been + fully uploaded. + "url": "str", # Optional. Download url. + "uuid": "str", # Optional. Unique id. + "version": { + "major": 0, # Optional. Major version + number. + "minor": 0, # Optional. Minor version + number. + "patch": 0 # Optional. Patch version number. + } + }, + "name": "str", # Optional. Agent name. + "project_id": "str", # Optional. The DigitalOcean project ID + associated with the agent. + "region": "str", # Optional. Region code. + "route_created_at": "2020-02-20 00:00:00", # Optional. + Creation of route date / time. + "route_created_by": "str", # Optional. Id of user that + created the route. + "route_name": "str", # Optional. Route name. + "route_uuid": "str", # Optional. Route uuid. + "tags": [ + "str" # Optional. A set of abitrary tags to organize + your agent. + ], + "temperature": 0.0, # Optional. Controls the model"u2019s + creativity, specified as a number between 0 and 1. Lower values produce + more predictable and conservative responses, while higher values + encourage creativity and variation. + "template": { + "created_at": "2020-02-20 00:00:00", # Optional. The + agent template's creation date. + "description": "str", # Optional. Description of the + agent template. + "instruction": "str", # Optional. Instructions for + the agent template. + "k": 0, # Optional. The 'k' value for the agent + template. + "knowledge_bases": [ + { + "added_to_agent_at": "2020-02-20 + 00:00:00", # Optional. Time when the knowledge base was + added to the agent. + "created_at": "2020-02-20 00:00:00", + # Optional. Creation date / time. + "database_id": "str", # Optional. + List of knowledge bases associated with the agent template. + "embedding_model_uuid": "str", # + Optional. List of knowledge bases associated with the agent + template. + "is_public": bool, # Optional. + Whether the knowledge base is public or not. + "last_indexing_job": { + "completed_datasources": 0, + # Optional. Number of datasources indexed completed. + "created_at": "2020-02-20 + 00:00:00", # Optional. Creation date / time. + "data_source_uuids": [ + "str" # Optional. + IndexingJob description. + ], + "finished_at": "2020-02-20 + 00:00:00", # Optional. IndexingJob description. + "knowledge_base_uuid": "str", + # Optional. Knowledge base id. + "phase": + "BATCH_JOB_PHASE_UNKNOWN", # Optional. Default value is + "BATCH_JOB_PHASE_UNKNOWN". Known values are: + "BATCH_JOB_PHASE_UNKNOWN", "BATCH_JOB_PHASE_PENDING", + "BATCH_JOB_PHASE_RUNNING", "BATCH_JOB_PHASE_SUCCEEDED", + "BATCH_JOB_PHASE_FAILED", and "BATCH_JOB_PHASE_ERROR". + "started_at": "2020-02-20 + 00:00:00", # Optional. IndexingJob description. + "tokens": 0, # Optional. + Number of tokens. + "total_datasources": 0, # + Optional. Number of datasources being indexed. + "updated_at": "2020-02-20 + 00:00:00", # Optional. Last modified. + "uuid": "str" # Optional. + Unique id. + }, + "name": "str", # Optional. Name of + knowledge base. + "project_id": "str", # Optional. + List of knowledge bases associated with the agent template. + "region": "str", # Optional. Region + code. + "tags": [ + "str" # Optional. Tags to + organize related resources. + ], + "updated_at": "2020-02-20 00:00:00", + # Optional. Last modified. + "user_id": "str", # Optional. Id of + user that created the knowledge base. + "uuid": "str" # Optional. Unique id + for knowledge base. + } + ], + "max_tokens": 0, # Optional. The max_tokens setting + for the agent template. + "model": { + "agreement": { + "description": "str", # Optional. + Agreement Description. + "name": "str", # Optional. Agreement + Description. + "url": "str", # Optional. Agreement + Description. + "uuid": "str" # Optional. Agreement + Description. + }, + "created_at": "2020-02-20 00:00:00", # + Optional. Creation date / time. + "inference_name": "str", # Optional. + Internally used name. + "inference_version": "str", # Optional. + Internally used version. + "is_foundational": bool, # Optional. True if + it is a foundational model provided by do. + "metadata": {}, # Optional. Additional meta + data. + "name": "str", # Optional. Name of the + model. + "parent_uuid": "str", # Optional. Unique id + of the model, this model is based on. + "provider": "MODEL_PROVIDER_DIGITALOCEAN", # + Optional. Default value is "MODEL_PROVIDER_DIGITALOCEAN". Known + values are: "MODEL_PROVIDER_DIGITALOCEAN" and + "MODEL_PROVIDER_ANTHROPIC". + "updated_at": "2020-02-20 00:00:00", # + Optional. Last modified. + "upload_complete": bool, # Optional. Model + has been fully uploaded. + "url": "str", # Optional. Download url. + "uuid": "str", # Optional. Unique id. + "version": { + "major": 0, # Optional. Major + version number. + "minor": 0, # Optional. Minor + version number. + "patch": 0 # Optional. Patch version + number. + } + }, + "name": "str", # Optional. Name of the agent + template. + "temperature": 0.0, # Optional. The temperature + setting for the agent template. + "top_p": 0.0, # Optional. The top_p setting for the + agent template. + "updated_at": "2020-02-20 00:00:00", # Optional. The + agent template's last updated date. + "uuid": "str" # Optional. Unique id. + }, + "top_p": 0.0, # Optional. Defines the cumulative probability + threshold for word selection, specified as a number between 0 and 1. + Higher values allow for more diverse outputs, while lower values ensure + focused and coherent responses. + "updated_at": "2020-02-20 00:00:00", # Optional. Last + modified. + "url": "str", # Optional. Access your agent under this url. + "user_id": "str", # Optional. Id of user that created the + agent. + "uuid": "str" # Optional. Unique agent id. + } + ], + "links": { + "pages": { + "first": "str", # Optional. First page. + "last": "str", # Optional. Last page. + "next": "str", # Optional. Next page. + "previous": "str" # Optional. Previous page. + } + }, + "meta": { + "page": 0, # Optional. The current page. + "pages": 0, # Optional. Total number of pages. + "total": 0 # Optional. Total amount of items over all pages. + } + } + # 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_genai_list_agents_request( + only_deployed=only_deployed, + page=page, + per_page=per_page, + 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 list_agent_api_keys( self, @@ -166408,6 +166418,129 @@ async def create_agent_api_key( return cast(JSON, deserialized) # type: ignore + @distributed_trace_async + async def delete_agent_api_key( + self, agent_uuid: str, api_key_uuid: str, **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Delete API Key for an Agent. + + To delete an API key for an agent, send a DELETE request to + ``/v2/gen-ai/agents/{agent_uuid}/api_keys/{api_key_uuid}``. + + :param agent_uuid: A unique identifier for your agent. Required. + :type agent_uuid: str + :param api_key_uuid: API key for an agent. Required. + :type api_key_uuid: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "api_key_info": { + "created_at": "2020-02-20 00:00:00", # Optional. Creation date. + "created_by": "str", # Optional. Created by. + "deleted_at": "2020-02-20 00:00:00", # Optional. Deleted date. + "name": "str", # Optional. Name. + "secret_key": "str", # Optional. Agent API Key Info. + "uuid": "str" # Optional. Uuid. + } + } + # 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_genai_delete_agent_api_key_request( + agent_uuid=agent_uuid, + api_key_uuid=api_key_uuid, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + @overload async def update_agent_api_key( self, @@ -166680,129 +166813,6 @@ async def update_agent_api_key( return cast(JSON, deserialized) # type: ignore - @distributed_trace_async - async def delete_agent_api_key( - self, agent_uuid: str, api_key_uuid: str, **kwargs: Any - ) -> JSON: - # pylint: disable=line-too-long - """Delete API Key for an Agent. - - To delete an API key for an agent, send a DELETE request to - ``/v2/gen-ai/agents/{agent_uuid}/api_keys/{api_key_uuid}``. - - :param agent_uuid: A unique identifier for your agent. Required. - :type agent_uuid: str - :param api_key_uuid: API key for an agent. Required. - :type api_key_uuid: str - :return: JSON object - :rtype: JSON - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "api_key_info": { - "created_at": "2020-02-20 00:00:00", # Optional. Creation date. - "created_by": "str", # Optional. Created by. - "deleted_at": "2020-02-20 00:00:00", # Optional. Deleted date. - "name": "str", # Optional. Name. - "secret_key": "str", # Optional. Agent API Key Info. - "uuid": "str" # Optional. Uuid. - } - } - # 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_genai_delete_agent_api_key_request( - agent_uuid=agent_uuid, - api_key_uuid=api_key_uuid, - 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 regenerate_agent_api_key( self, agent_uuid: str, api_key_uuid: str, **kwargs: Any @@ -168248,21 +168258,31 @@ async def attach_agent_function( return cast(JSON, deserialized) # type: ignore - @distributed_trace_async - async def detach_agent_function( - self, agent_uuid: str, function_uuid: str, **kwargs: Any + @overload + async def update_agent_function( + self, + agent_uuid: str, + function_uuid: str, + body: Optional[JSON] = None, + *, + content_type: str = "application/json", + **kwargs: Any ) -> JSON: # pylint: disable=line-too-long - """Delete Function Route for an Agent. + """Update Function Route for an Agent. - To delete a function route from an agent, send a DELETE request to + To update the function route, send a PUT request to ``/v2/gen-ai/agents/{agent_uuid}/functions/{function_uuid}``. - :param agent_uuid: The id of the agent the function route belongs to. Required. + :param agent_uuid: Agent id. Required. :type agent_uuid: str - :param function_uuid: The function route to be destroyed. This does not destroy the function - itself. Required. + :param function_uuid: Function id. Required. :type function_uuid: str + :param body: Default value is None. + :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: @@ -168270,6 +168290,22 @@ async def detach_agent_function( Example: .. code-block:: python + # JSON input template you can fill out and use as your body input. + body = { + "agent_uuid": "str", # Optional. Agent id. + "description": "str", # Optional. Funciton description. + "faas_name": "str", # Optional. The name of the function in the DigitalOcean + functions platform. + "faas_namespace": "str", # Optional. The namespace of the function in the + DigitalOcean functions platform. + "function_name": "str", # Optional. Function name. + "function_uuid": "str", # Optional. Function id. + "input_schema": {}, # Optional. Describe the input schema for the function + so the agent may call it. + "output_schema": {} # Optional. Describe the output schema for the function + so the agent handle its response. + } + # response body for status code(s): 200 response == { "agent": { @@ -168641,91 +168677,13 @@ async def detach_agent_function( 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_genai_detach_agent_function_request( - agent_uuid=agent_uuid, - function_uuid=function_uuid, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = ( - await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 404]: - if _stream: - await response.read() # Load the body in memory and close the socket - map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore - raise HttpResponseError(response=response) - - response_headers = {} - if response.status_code == 200: - response_headers["ratelimit-limit"] = self._deserialize( - "int", response.headers.get("ratelimit-limit") - ) - response_headers["ratelimit-remaining"] = self._deserialize( - "int", response.headers.get("ratelimit-remaining") - ) - response_headers["ratelimit-reset"] = self._deserialize( - "int", response.headers.get("ratelimit-reset") - ) - - if response.content: - deserialized = response.json() - else: - deserialized = None - - if response.status_code == 404: - response_headers["ratelimit-limit"] = self._deserialize( - "int", response.headers.get("ratelimit-limit") - ) - response_headers["ratelimit-remaining"] = self._deserialize( - "int", response.headers.get("ratelimit-remaining") - ) - response_headers["ratelimit-reset"] = self._deserialize( - "int", response.headers.get("ratelimit-reset") - ) - - if response.content: - deserialized = response.json() - else: - deserialized = None - - if cls: - return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore - - return cast(JSON, deserialized) # type: ignore @overload async def update_agent_function( self, agent_uuid: str, function_uuid: str, - body: Optional[JSON] = None, + body: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -168741,8 +168699,8 @@ async def update_agent_function( :param function_uuid: Function id. Required. :type function_uuid: str :param body: Default value is None. - :type body: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + :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 @@ -168752,22 +168710,6 @@ async def update_agent_function( Example: .. code-block:: python - # JSON input template you can fill out and use as your body input. - body = { - "agent_uuid": "str", # Optional. Agent id. - "description": "str", # Optional. Funciton description. - "faas_name": "str", # Optional. The name of the function in the DigitalOcean - functions platform. - "faas_namespace": "str", # Optional. The namespace of the function in the - DigitalOcean functions platform. - "function_name": "str", # Optional. Function name. - "function_uuid": "str", # Optional. Function id. - "input_schema": {}, # Optional. Describe the input schema for the function - so the agent may call it. - "output_schema": {} # Optional. Describe the output schema for the function - so the agent handle its response. - } - # response body for status code(s): 200 response == { "agent": { @@ -169140,14 +169082,12 @@ async def update_agent_function( } """ - @overload + @distributed_trace_async async def update_agent_function( self, agent_uuid: str, function_uuid: str, - body: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", + body: Optional[Union[JSON, IO[bytes]]] = None, **kwargs: Any ) -> JSON: # pylint: disable=line-too-long @@ -169160,11 +169100,8 @@ async def update_agent_function( :type agent_uuid: str :param function_uuid: Function id. Required. :type function_uuid: str - :param body: Default value is None. - :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 + :param body: Is either a JSON type or a IO[bytes] type. Default value is None. + :type body: JSON or IO[bytes] :return: JSON object :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: @@ -169172,6 +169109,22 @@ async def update_agent_function( Example: .. code-block:: python + # JSON input template you can fill out and use as your body input. + body = { + "agent_uuid": "str", # Optional. Agent id. + "description": "str", # Optional. Funciton description. + "faas_name": "str", # Optional. The name of the function in the DigitalOcean + functions platform. + "faas_namespace": "str", # Optional. The namespace of the function in the + DigitalOcean functions platform. + "function_name": "str", # Optional. Function name. + "function_uuid": "str", # Optional. Function id. + "input_schema": {}, # Optional. Describe the input schema for the function + so the agent may call it. + "output_schema": {} # Optional. Describe the output schema for the function + so the agent handle its response. + } + # response body for status code(s): 200 response == { "agent": { @@ -169543,27 +169496,117 @@ async def update_agent_function( 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: + if body is not None: + _json = body + else: + _json = None + + _request = build_genai_update_agent_function_request( + agent_uuid=agent_uuid, + function_uuid=function_uuid, + 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, 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 update_agent_function( - self, - agent_uuid: str, - function_uuid: str, - body: Optional[Union[JSON, IO[bytes]]] = None, - **kwargs: Any + async def detach_agent_function( + self, agent_uuid: str, function_uuid: str, **kwargs: Any ) -> JSON: # pylint: disable=line-too-long - """Update Function Route for an Agent. + """Delete Function Route for an Agent. - To update the function route, send a PUT request to + To delete a function route from an agent, send a DELETE request to ``/v2/gen-ai/agents/{agent_uuid}/functions/{function_uuid}``. - :param agent_uuid: Agent id. Required. + :param agent_uuid: The id of the agent the function route belongs to. Required. :type agent_uuid: str - :param function_uuid: Function id. Required. + :param function_uuid: The function route to be destroyed. This does not destroy the function + itself. Required. :type function_uuid: str - :param body: Is either a JSON type or a IO[bytes] type. Default value is None. - :type body: JSON or IO[bytes] :return: JSON object :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: @@ -169571,22 +169614,6 @@ async def update_agent_function( Example: .. code-block:: python - # JSON input template you can fill out and use as your body input. - body = { - "agent_uuid": "str", # Optional. Agent id. - "description": "str", # Optional. Funciton description. - "faas_name": "str", # Optional. The name of the function in the DigitalOcean - functions platform. - "faas_namespace": "str", # Optional. The namespace of the function in the - DigitalOcean functions platform. - "function_name": "str", # Optional. Function name. - "function_uuid": "str", # Optional. Function id. - "input_schema": {}, # Optional. Describe the input schema for the function - so the agent may call it. - "output_schema": {} # Optional. Describe the output schema for the function - so the agent handle its response. - } - # response body for status code(s): 200 response == { "agent": { @@ -169971,31 +169998,14 @@ async def update_agent_function( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = 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: - if body is not None: - _json = body - else: - _json = None - - _request = build_genai_update_agent_function_request( + _request = build_genai_detach_agent_function_request( agent_uuid=agent_uuid, function_uuid=function_uuid, - content_type=content_type, - json=_json, - content=_content, headers=_headers, params=_params, ) @@ -172481,6 +172491,8 @@ async def update_agent( # JSON input template you can fill out and use as your body input. body = { + "anthropic_key_uuid": "str", # Optional. Optional anthropic key uuid for use + with anthropic models. "description": "str", # Optional. Agent description. "instruction": "str", # Optional. Agent instruction. Instructions help your agent to perform its job effectively. See `Write Effective Agent Instructions @@ -173303,6 +173315,8 @@ async def update_agent( # JSON input template you can fill out and use as your body input. body = { + "anthropic_key_uuid": "str", # Optional. Optional anthropic key uuid for use + with anthropic models. "description": "str", # Optional. Agent description. "instruction": "str", # Optional. Agent instruction. Instructions help your agent to perform its job effectively. See `Write Effective Agent Instructions @@ -175614,6 +175628,1426 @@ async def update_agent_deployment_visibility( return cast(JSON, deserialized) # type: ignore + @distributed_trace_async + async def list_anthropic_api_keys( + self, + *, + page: Optional[int] = None, + per_page: Optional[int] = None, + **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """List Anthropic API Keys. + + To list all Anthropic API keys, send a GET request to ``/v2/gen-ai/anthropic/keys``. + + :keyword page: Page number. Default value is None. + :paramtype page: int + :keyword per_page: Items per page. Default value is None. + :paramtype per_page: int + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "api_key_infos": [ + { + "created_at": "2020-02-20 00:00:00", # Optional. Key + creation date. + "created_by": "str", # Optional. Created by user id from DO. + "deleted_at": "2020-02-20 00:00:00", # Optional. Key deleted + date. + "name": "str", # Optional. Name. + "updated_at": "2020-02-20 00:00:00", # Optional. Key last + updated date. + "uuid": "str" # Optional. Uuid. + } + ], + "links": { + "pages": { + "first": "str", # Optional. First page. + "last": "str", # Optional. Last page. + "next": "str", # Optional. Next page. + "previous": "str" # Optional. Previous page. + } + }, + "meta": { + "page": 0, # Optional. The current page. + "pages": 0, # Optional. Total number of pages. + "total": 0 # Optional. Total amount of items over all pages. + } + } + # 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_genai_list_anthropic_api_keys_request( + page=page, + per_page=per_page, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @overload + async def create_anthropic_api_key( + self, + body: Optional[JSON] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Create Anthropic API Key. + + To create an Anthropic API key, send a POST request to ``/v2/gen-ai/anthropic/keys``. + + :param body: Default value is None. + :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 = { + "api_key": "str", # Optional. Anthropic API key. + "name": "str" # Optional. Name of the key. + } + + # response body for status code(s): 200 + response == { + "api_key_info": { + "created_at": "2020-02-20 00:00:00", # Optional. Key creation date. + "created_by": "str", # Optional. Created by user id from DO. + "deleted_at": "2020-02-20 00:00:00", # Optional. Key deleted date. + "name": "str", # Optional. Name. + "updated_at": "2020-02-20 00:00:00", # Optional. Key last updated + date. + "uuid": "str" # Optional. Uuid. + } + } + # 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. + } + """ + + @overload + async def create_anthropic_api_key( + self, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Create Anthropic API Key. + + To create an Anthropic API key, send a POST request to ``/v2/gen-ai/anthropic/keys``. + + :param body: Default value is None. + :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 == { + "api_key_info": { + "created_at": "2020-02-20 00:00:00", # Optional. Key creation date. + "created_by": "str", # Optional. Created by user id from DO. + "deleted_at": "2020-02-20 00:00:00", # Optional. Key deleted date. + "name": "str", # Optional. Name. + "updated_at": "2020-02-20 00:00:00", # Optional. Key last updated + date. + "uuid": "str" # Optional. Uuid. + } + } + # 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. + } + """ + + @distributed_trace_async + async def create_anthropic_api_key( + self, body: Optional[Union[JSON, IO[bytes]]] = None, **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Create Anthropic API Key. + + To create an Anthropic API key, send a POST request to ``/v2/gen-ai/anthropic/keys``. + + :param body: Is either a JSON type or a IO[bytes] type. Default value is None. + :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 = { + "api_key": "str", # Optional. Anthropic API key. + "name": "str" # Optional. Name of the key. + } + + # response body for status code(s): 200 + response == { + "api_key_info": { + "created_at": "2020-02-20 00:00:00", # Optional. Key creation date. + "created_by": "str", # Optional. Created by user id from DO. + "deleted_at": "2020-02-20 00:00:00", # Optional. Key deleted date. + "name": "str", # Optional. Name. + "updated_at": "2020-02-20 00:00:00", # Optional. Key last updated + date. + "uuid": "str" # Optional. Uuid. + } + } + # 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 = 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: + if body is not None: + _json = body + else: + _json = None + + _request = build_genai_create_anthropic_api_key_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, 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 delete_anthropic_api_key(self, api_key_uuid: str, **kwargs: Any) -> JSON: + # pylint: disable=line-too-long + """Delete Anthropic API Key. + + To delete an Anthropic API key, send a DELETE request to + ``/v2/gen-ai/anthropic/keys/{api_key_uuid}``. + + :param api_key_uuid: API key ID. Required. + :type api_key_uuid: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "api_key_info": { + "created_at": "2020-02-20 00:00:00", # Optional. Key creation date. + "created_by": "str", # Optional. Created by user id from DO. + "deleted_at": "2020-02-20 00:00:00", # Optional. Key deleted date. + "name": "str", # Optional. Name. + "updated_at": "2020-02-20 00:00:00", # Optional. Key last updated + date. + "uuid": "str" # Optional. Uuid. + } + } + # 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_genai_delete_anthropic_api_key_request( + api_key_uuid=api_key_uuid, + 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_anthropic_api_key(self, api_key_uuid: str, **kwargs: Any) -> JSON: + # pylint: disable=line-too-long + """Get Anthropic API Key. + + To retrieve details of an Anthropic API key, send a GET request to + ``/v2/gen-ai/anthropic/keys/{api_key_uuid}``. + + :param api_key_uuid: API key ID. Required. + :type api_key_uuid: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "api_key_info": { + "created_at": "2020-02-20 00:00:00", # Optional. Key creation date. + "created_by": "str", # Optional. Created by user id from DO. + "deleted_at": "2020-02-20 00:00:00", # Optional. Key deleted date. + "name": "str", # Optional. Name. + "updated_at": "2020-02-20 00:00:00", # Optional. Key last updated + date. + "uuid": "str" # Optional. Uuid. + } + } + # 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_genai_get_anthropic_api_key_request( + api_key_uuid=api_key_uuid, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @overload + async def update_anthropic_api_key( + self, + api_key_uuid: str, + body: Optional[JSON] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Update Anthropic API Key. + + To update an Anthropic API key, send a PUT request to + ``/v2/gen-ai/anthropic/keys/{api_key_uuid}``. + + :param api_key_uuid: API key ID. Required. + :type api_key_uuid: str + :param body: Default value is None. + :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 = { + "api_key": "str", # Optional. Anthropic API key. + "api_key_uuid": "str", # Optional. API key ID. + "name": "str" # Optional. Name of the key. + } + + # response body for status code(s): 200 + response == { + "api_key_info": { + "created_at": "2020-02-20 00:00:00", # Optional. Key creation date. + "created_by": "str", # Optional. Created by user id from DO. + "deleted_at": "2020-02-20 00:00:00", # Optional. Key deleted date. + "name": "str", # Optional. Name. + "updated_at": "2020-02-20 00:00:00", # Optional. Key last updated + date. + "uuid": "str" # Optional. Uuid. + } + } + # 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. + } + """ + + @overload + async def update_anthropic_api_key( + self, + api_key_uuid: str, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Update Anthropic API Key. + + To update an Anthropic API key, send a PUT request to + ``/v2/gen-ai/anthropic/keys/{api_key_uuid}``. + + :param api_key_uuid: API key ID. Required. + :type api_key_uuid: str + :param body: Default value is None. + :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 == { + "api_key_info": { + "created_at": "2020-02-20 00:00:00", # Optional. Key creation date. + "created_by": "str", # Optional. Created by user id from DO. + "deleted_at": "2020-02-20 00:00:00", # Optional. Key deleted date. + "name": "str", # Optional. Name. + "updated_at": "2020-02-20 00:00:00", # Optional. Key last updated + date. + "uuid": "str" # Optional. Uuid. + } + } + # 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. + } + """ + + @distributed_trace_async + async def update_anthropic_api_key( + self, + api_key_uuid: str, + body: Optional[Union[JSON, IO[bytes]]] = None, + **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Update Anthropic API Key. + + To update an Anthropic API key, send a PUT request to + ``/v2/gen-ai/anthropic/keys/{api_key_uuid}``. + + :param api_key_uuid: API key ID. Required. + :type api_key_uuid: str + :param body: Is either a JSON type or a IO[bytes] type. Default value is None. + :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 = { + "api_key": "str", # Optional. Anthropic API key. + "api_key_uuid": "str", # Optional. API key ID. + "name": "str" # Optional. Name of the key. + } + + # response body for status code(s): 200 + response == { + "api_key_info": { + "created_at": "2020-02-20 00:00:00", # Optional. Key creation date. + "created_by": "str", # Optional. Created by user id from DO. + "deleted_at": "2020-02-20 00:00:00", # Optional. Key deleted date. + "name": "str", # Optional. Name. + "updated_at": "2020-02-20 00:00:00", # Optional. Key last updated + date. + "uuid": "str" # Optional. Uuid. + } + } + # 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 = 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: + if body is not None: + _json = body + else: + _json = None + + _request = build_genai_update_anthropic_api_key_request( + api_key_uuid=api_key_uuid, + 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, 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 list_agents_by_anthropic_key( + self, + uuid: str, + *, + page: Optional[int] = None, + per_page: Optional[int] = None, + **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """List agents by Anthropic key. + + List Agents by Anthropic Key. + + :param uuid: Unique ID of Anthropic key. Required. + :type uuid: str + :keyword page: Page number. Default value is None. + :paramtype page: int + :keyword per_page: Items per page. Default value is None. + :paramtype per_page: int + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "agents": [ + { + "anthropic_api_key": { + "created_at": "2020-02-20 00:00:00", # Optional. Key + creation date. + "created_by": "str", # Optional. Created by user id + from DO. + "deleted_at": "2020-02-20 00:00:00", # Optional. Key + deleted date. + "name": "str", # Optional. Name. + "updated_at": "2020-02-20 00:00:00", # Optional. Key + last updated date. + "uuid": "str" # Optional. Uuid. + }, + "api_key_infos": [ + { + "created_at": "2020-02-20 00:00:00", # + Optional. Creation date. + "created_by": "str", # Optional. Created by. + "deleted_at": "2020-02-20 00:00:00", # + Optional. Deleted date. + "name": "str", # Optional. Name. + "secret_key": "str", # Optional. Api key + infos. + "uuid": "str" # Optional. Uuid. + } + ], + "api_keys": [ + { + "api_key": "str" # Optional. Api key. + } + ], + "chatbot": { + "button_background_color": "str", # Optional. A + Chatbot. + "logo": "str", # Optional. A Chatbot. + "name": "str", # Optional. Name of chatbot. + "primary_color": "str", # Optional. A Chatbot. + "secondary_color": "str", # Optional. A Chatbot. + "starting_message": "str" # Optional. A Chatbot. + }, + "chatbot_identifiers": [ + { + "agent_chatbot_identifier": "str" # + Optional. Agent chatbot identifier. + } + ], + "child_agents": [ + ... + ], + "created_at": "2020-02-20 00:00:00", # Optional. Creation + date / time. + "deployment": { + "created_at": "2020-02-20 00:00:00", # Optional. + Creation date / time. + "name": "str", # Optional. Name. + "status": "STATUS_UNKNOWN", # Optional. Default + value is "STATUS_UNKNOWN". Known values are: "STATUS_UNKNOWN", + "STATUS_WAITING_FOR_DEPLOYMENT", "STATUS_DEPLOYING", + "STATUS_RUNNING", "STATUS_FAILED", "STATUS_WAITING_FOR_UNDEPLOYMENT", + "STATUS_UNDEPLOYING", "STATUS_UNDEPLOYMENT_FAILED", and + "STATUS_DELETED". + "updated_at": "2020-02-20 00:00:00", # Optional. + Last modified. + "url": "str", # Optional. Access your deployed agent + here. + "uuid": "str", # Optional. Unique id. + "visibility": "VISIBILITY_UNKNOWN" # Optional. + Default value is "VISIBILITY_UNKNOWN". * VISIBILITY_UNKNOWN: The + status of the deployment is unknown * VISIBILITY_DISABLED: The + deployment is disabled and will no longer service requests * + VISIBILITY_PLAYGROUND: Deprecated: No longer a valid state * + VISIBILITY_PUBLIC: The deployment is public and will service requests + from the public internet * VISIBILITY_PRIVATE: The deployment is + private and will only service requests from other agents, or through + API keys. Known values are: "VISIBILITY_UNKNOWN", + "VISIBILITY_DISABLED", "VISIBILITY_PLAYGROUND", "VISIBILITY_PUBLIC", + and "VISIBILITY_PRIVATE". + }, + "description": "str", # Optional. Description of agent. + "functions": [ + { + "api_key": "str", # Optional. Api key. + "created_at": "2020-02-20 00:00:00", # + Optional. Creation date / time. + "description": "str", # Optional. Agent + description. + "faas_name": "str", # Optional. + "faas_namespace": "str", # Optional. + "input_schema": {}, # Optional. Any object. + "name": "str", # Optional. Name. + "output_schema": {}, # Optional. Any object. + "updated_at": "2020-02-20 00:00:00", # + Optional. Last modified. + "url": "str", # Optional. Download your + agent here. + "uuid": "str" # Optional. Unique id. + } + ], + "guardrails": [ + { + "agent_uuid": "str", # Optional. The + guardrails the agent is attached to. + "created_at": "2020-02-20 00:00:00", # + Optional. The guardrails the agent is attached to. + "default_response": "str", # Optional. The + guardrails the agent is attached to. + "description": "str", # Optional. The + guardrails the agent is attached to. + "guardrail_uuid": "str", # Optional. The + guardrails the agent is attached to. + "is_attached": bool, # Optional. The + guardrails the agent is attached to. + "is_default": bool, # Optional. The + guardrails the agent is attached to. + "metadata": {}, # Optional. Any object. + "name": "str", # Optional. The guardrails + the agent is attached to. + "priority": 0, # Optional. The guardrails + the agent is attached to. + "type": "GUARDRAIL_TYPE_UNKNOWN", # + Optional. Default value is "GUARDRAIL_TYPE_UNKNOWN". Known values + are: "GUARDRAIL_TYPE_UNKNOWN", "GUARDRAIL_TYPE_JAILBREAK", + "GUARDRAIL_TYPE_SENSITIVE_DATA", and + "GUARDRAIL_TYPE_CONTENT_MODERATION". + "updated_at": "2020-02-20 00:00:00", # + Optional. The guardrails the agent is attached to. + "uuid": "str" # Optional. The guardrails the + agent is attached to. + } + ], + "if_case": "str", # Optional. + "instruction": "str", # Optional. Agent instruction. + Instructions help your agent to perform its job effectively. See `Write + Effective Agent Instructions + `_ + for best practices. + "k": 0, # Optional. + "knowledge_bases": [ + { + "added_to_agent_at": "2020-02-20 00:00:00", + # Optional. Time when the knowledge base was added to the agent. + "created_at": "2020-02-20 00:00:00", # + Optional. Creation date / time. + "database_id": "str", # Optional. Knowledge + bases. + "embedding_model_uuid": "str", # Optional. + Knowledge bases. + "is_public": bool, # Optional. Whether the + knowledge base is public or not. + "last_indexing_job": { + "completed_datasources": 0, # + Optional. Number of datasources indexed completed. + "created_at": "2020-02-20 00:00:00", + # Optional. Creation date / time. + "data_source_uuids": [ + "str" # Optional. + IndexingJob description. + ], + "finished_at": "2020-02-20 00:00:00", + # Optional. IndexingJob description. + "knowledge_base_uuid": "str", # + Optional. Knowledge base id. + "phase": "BATCH_JOB_PHASE_UNKNOWN", + # Optional. Default value is "BATCH_JOB_PHASE_UNKNOWN". Known + values are: "BATCH_JOB_PHASE_UNKNOWN", + "BATCH_JOB_PHASE_PENDING", "BATCH_JOB_PHASE_RUNNING", + "BATCH_JOB_PHASE_SUCCEEDED", "BATCH_JOB_PHASE_FAILED", and + "BATCH_JOB_PHASE_ERROR". + "started_at": "2020-02-20 00:00:00", + # Optional. IndexingJob description. + "tokens": 0, # Optional. Number of + tokens. + "total_datasources": 0, # Optional. + Number of datasources being indexed. + "updated_at": "2020-02-20 00:00:00", + # Optional. Last modified. + "uuid": "str" # Optional. Unique id. + }, + "name": "str", # Optional. Name of knowledge + base. + "project_id": "str", # Optional. Knowledge + bases. + "region": "str", # Optional. Region code. + "tags": [ + "str" # Optional. Tags to organize + related resources. + ], + "updated_at": "2020-02-20 00:00:00", # + Optional. Last modified. + "user_id": "str", # Optional. Id of user + that created the knowledge base. + "uuid": "str" # Optional. Unique id for + knowledge base. + } + ], + "max_tokens": 0, # Optional. + "model": { + "agreement": { + "description": "str", # Optional. Agreement + Description. + "name": "str", # Optional. Agreement + Description. + "url": "str", # Optional. Agreement + Description. + "uuid": "str" # Optional. Agreement + Description. + }, + "created_at": "2020-02-20 00:00:00", # Optional. + Creation date / time. + "inference_name": "str", # Optional. Internally used + name. + "inference_version": "str", # Optional. Internally + used version. + "is_foundational": bool, # Optional. True if it is a + foundational model provided by do. + "metadata": {}, # Optional. Additional meta data. + "name": "str", # Optional. Name of the model. + "parent_uuid": "str", # Optional. Unique id of the + model, this model is based on. + "provider": "MODEL_PROVIDER_DIGITALOCEAN", # + Optional. Default value is "MODEL_PROVIDER_DIGITALOCEAN". Known + values are: "MODEL_PROVIDER_DIGITALOCEAN" and + "MODEL_PROVIDER_ANTHROPIC". + "updated_at": "2020-02-20 00:00:00", # Optional. + Last modified. + "upload_complete": bool, # Optional. Model has been + fully uploaded. + "url": "str", # Optional. Download url. + "uuid": "str", # Optional. Unique id. + "version": { + "major": 0, # Optional. Major version + number. + "minor": 0, # Optional. Minor version + number. + "patch": 0 # Optional. Patch version number. + } + }, + "name": "str", # Optional. Agent name. + "parent_agents": [ + ... + ], + "project_id": "str", # Optional. + "region": "str", # Optional. Region code. + "route_created_at": "2020-02-20 00:00:00", # Optional. + Creation of route date / time. + "route_created_by": "str", # Optional. + "route_name": "str", # Optional. Route name. + "route_uuid": "str", # Optional. + "tags": [ + "str" # Optional. Agent tag to organize related + resources. + ], + "temperature": 0.0, # Optional. + "template": { + "created_at": "2020-02-20 00:00:00", # Optional. The + agent template's creation date. + "description": "str", # Optional. Description of the + agent template. + "instruction": "str", # Optional. Instructions for + the agent template. + "k": 0, # Optional. The 'k' value for the agent + template. + "knowledge_bases": [ + { + "added_to_agent_at": "2020-02-20 + 00:00:00", # Optional. Time when the knowledge base was + added to the agent. + "created_at": "2020-02-20 00:00:00", + # Optional. Creation date / time. + "database_id": "str", # Optional. + List of knowledge bases associated with the agent template. + "embedding_model_uuid": "str", # + Optional. List of knowledge bases associated with the agent + template. + "is_public": bool, # Optional. + Whether the knowledge base is public or not. + "last_indexing_job": { + "completed_datasources": 0, + # Optional. Number of datasources indexed completed. + "created_at": "2020-02-20 + 00:00:00", # Optional. Creation date / time. + "data_source_uuids": [ + "str" # Optional. + IndexingJob description. + ], + "finished_at": "2020-02-20 + 00:00:00", # Optional. IndexingJob description. + "knowledge_base_uuid": "str", + # Optional. Knowledge base id. + "phase": + "BATCH_JOB_PHASE_UNKNOWN", # Optional. Default value is + "BATCH_JOB_PHASE_UNKNOWN". Known values are: + "BATCH_JOB_PHASE_UNKNOWN", "BATCH_JOB_PHASE_PENDING", + "BATCH_JOB_PHASE_RUNNING", "BATCH_JOB_PHASE_SUCCEEDED", + "BATCH_JOB_PHASE_FAILED", and "BATCH_JOB_PHASE_ERROR". + "started_at": "2020-02-20 + 00:00:00", # Optional. IndexingJob description. + "tokens": 0, # Optional. + Number of tokens. + "total_datasources": 0, # + Optional. Number of datasources being indexed. + "updated_at": "2020-02-20 + 00:00:00", # Optional. Last modified. + "uuid": "str" # Optional. + Unique id. + }, + "name": "str", # Optional. Name of + knowledge base. + "project_id": "str", # Optional. + List of knowledge bases associated with the agent template. + "region": "str", # Optional. Region + code. + "tags": [ + "str" # Optional. Tags to + organize related resources. + ], + "updated_at": "2020-02-20 00:00:00", + # Optional. Last modified. + "user_id": "str", # Optional. Id of + user that created the knowledge base. + "uuid": "str" # Optional. Unique id + for knowledge base. + } + ], + "max_tokens": 0, # Optional. The max_tokens setting + for the agent template. + "model": { + "agreement": { + "description": "str", # Optional. + Agreement Description. + "name": "str", # Optional. Agreement + Description. + "url": "str", # Optional. Agreement + Description. + "uuid": "str" # Optional. Agreement + Description. + }, + "created_at": "2020-02-20 00:00:00", # + Optional. Creation date / time. + "inference_name": "str", # Optional. + Internally used name. + "inference_version": "str", # Optional. + Internally used version. + "is_foundational": bool, # Optional. True if + it is a foundational model provided by do. + "metadata": {}, # Optional. Additional meta + data. + "name": "str", # Optional. Name of the + model. + "parent_uuid": "str", # Optional. Unique id + of the model, this model is based on. + "provider": "MODEL_PROVIDER_DIGITALOCEAN", # + Optional. Default value is "MODEL_PROVIDER_DIGITALOCEAN". Known + values are: "MODEL_PROVIDER_DIGITALOCEAN" and + "MODEL_PROVIDER_ANTHROPIC". + "updated_at": "2020-02-20 00:00:00", # + Optional. Last modified. + "upload_complete": bool, # Optional. Model + has been fully uploaded. + "url": "str", # Optional. Download url. + "uuid": "str", # Optional. Unique id. + "version": { + "major": 0, # Optional. Major + version number. + "minor": 0, # Optional. Minor + version number. + "patch": 0 # Optional. Patch version + number. + } + }, + "name": "str", # Optional. Name of the agent + template. + "temperature": 0.0, # Optional. The temperature + setting for the agent template. + "top_p": 0.0, # Optional. The top_p setting for the + agent template. + "updated_at": "2020-02-20 00:00:00", # Optional. The + agent template's last updated date. + "uuid": "str" # Optional. Unique id. + }, + "top_p": 0.0, # Optional. + "updated_at": "2020-02-20 00:00:00", # Optional. Last + modified. + "url": "str", # Optional. Access your agent under this url. + "user_id": "str", # Optional. Id of user that created the + agent. + "uuid": "str" # Optional. Unique agent id. + } + ], + "links": { + "pages": { + "first": "str", # Optional. First page. + "last": "str", # Optional. Last page. + "next": "str", # Optional. Next page. + "previous": "str" # Optional. Previous page. + } + }, + "meta": { + "page": 0, # Optional. The current page. + "pages": 0, # Optional. Total number of pages. + "total": 0 # Optional. Total amount of items over all pages. + } + } + # 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_genai_list_agents_by_anthropic_key_request( + uuid=uuid, + page=page, + per_page=per_page, + 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 list_indexing_jobs( self, @@ -177266,6 +178700,198 @@ async def create_knowledge_base( return cast(JSON, deserialized) # type: ignore + @distributed_trace_async + async def list_knowledge_base_data_sources( + self, + knowledge_base_uuid: str, + *, + page: Optional[int] = None, + per_page: Optional[int] = None, + **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """List Data Sources for a Knowledge Base. + + To list all data sources for a knowledge base, send a GET request to + ``/v2/gen-ai/knowledge_bases/{knowledge_base_uuid}/data_sources``. + + :param knowledge_base_uuid: Knowledge base id. Required. + :type knowledge_base_uuid: str + :keyword page: Page number. Default value is None. + :paramtype page: int + :keyword per_page: Items per page. Default value is None. + :paramtype per_page: int + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "knowledge_base_data_sources": [ + { + "bucket_name": "str", # Optional. Name of storage bucket - + Deprecated, moved to data_source_details. + "created_at": "2020-02-20 00:00:00", # Optional. Creation + date / time. + "file_upload_data_source": { + "original_file_name": "str", # Optional. The + original file name. + "size_in_bytes": "str", # Optional. The size of the + file in bytes. + "stored_object_key": "str" # Optional. The object + key the file was stored as. + }, + "item_path": "str", # Optional. Path of folder or object in + bucket - Deprecated, moved to data_source_details. + "last_indexing_job": { + "completed_datasources": 0, # Optional. Number of + datasources indexed completed. + "created_at": "2020-02-20 00:00:00", # Optional. + Creation date / time. + "data_source_uuids": [ + "str" # Optional. IndexingJob description. + ], + "finished_at": "2020-02-20 00:00:00", # Optional. + IndexingJob description. + "knowledge_base_uuid": "str", # Optional. Knowledge + base id. + "phase": "BATCH_JOB_PHASE_UNKNOWN", # Optional. + Default value is "BATCH_JOB_PHASE_UNKNOWN". Known values are: + "BATCH_JOB_PHASE_UNKNOWN", "BATCH_JOB_PHASE_PENDING", + "BATCH_JOB_PHASE_RUNNING", "BATCH_JOB_PHASE_SUCCEEDED", + "BATCH_JOB_PHASE_FAILED", and "BATCH_JOB_PHASE_ERROR". + "started_at": "2020-02-20 00:00:00", # Optional. + IndexingJob description. + "tokens": 0, # Optional. Number of tokens. + "total_datasources": 0, # Optional. Number of + datasources being indexed. + "updated_at": "2020-02-20 00:00:00", # Optional. + Last modified. + "uuid": "str" # Optional. Unique id. + }, + "region": "str", # Optional. Region code - Deprecated, moved + to data_source_details. + "spaces_data_source": { + "bucket_name": "str", # Optional. Spaces bucket + name. + "item_path": "str", # Optional. Spaces Bucket Data + Source. + "region": "str" # Optional. Region of bucket. + }, + "updated_at": "2020-02-20 00:00:00", # Optional. Last + modified. + "uuid": "str" # Optional. Unique id of knowledge base. + } + ], + "links": { + "pages": { + "first": "str", # Optional. First page. + "last": "str", # Optional. Last page. + "next": "str", # Optional. Next page. + "previous": "str" # Optional. Previous page. + } + }, + "meta": { + "page": 0, # Optional. The current page. + "pages": 0, # Optional. Total number of pages. + "total": 0 # Optional. Total amount of items over all pages. + } + } + # 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_genai_list_knowledge_base_data_sources_request( + knowledge_base_uuid=knowledge_base_uuid, + page=page, + per_page=per_page, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + @overload async def create_knowledge_base_data_source( self, @@ -177672,198 +179298,6 @@ async def create_knowledge_base_data_source( return cast(JSON, deserialized) # type: ignore - @distributed_trace_async - async def list_knowledge_base_data_sources( - self, - knowledge_base_uuid: str, - *, - page: Optional[int] = None, - per_page: Optional[int] = None, - **kwargs: Any - ) -> JSON: - # pylint: disable=line-too-long - """List Data Sources for a Knowledge Base. - - To list all data sources for a knowledge base, send a GET request to - ``/v2/gen-ai/knowledge_bases/{knowledge_base_uuid}/data_sources``. - - :param knowledge_base_uuid: Knowledge base id. Required. - :type knowledge_base_uuid: str - :keyword page: Page number. Default value is None. - :paramtype page: int - :keyword per_page: Items per page. Default value is None. - :paramtype per_page: int - :return: JSON object - :rtype: JSON - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "knowledge_base_data_sources": [ - { - "bucket_name": "str", # Optional. Name of storage bucket - - Deprecated, moved to data_source_details. - "created_at": "2020-02-20 00:00:00", # Optional. Creation - date / time. - "file_upload_data_source": { - "original_file_name": "str", # Optional. The - original file name. - "size_in_bytes": "str", # Optional. The size of the - file in bytes. - "stored_object_key": "str" # Optional. The object - key the file was stored as. - }, - "item_path": "str", # Optional. Path of folder or object in - bucket - Deprecated, moved to data_source_details. - "last_indexing_job": { - "completed_datasources": 0, # Optional. Number of - datasources indexed completed. - "created_at": "2020-02-20 00:00:00", # Optional. - Creation date / time. - "data_source_uuids": [ - "str" # Optional. IndexingJob description. - ], - "finished_at": "2020-02-20 00:00:00", # Optional. - IndexingJob description. - "knowledge_base_uuid": "str", # Optional. Knowledge - base id. - "phase": "BATCH_JOB_PHASE_UNKNOWN", # Optional. - Default value is "BATCH_JOB_PHASE_UNKNOWN". Known values are: - "BATCH_JOB_PHASE_UNKNOWN", "BATCH_JOB_PHASE_PENDING", - "BATCH_JOB_PHASE_RUNNING", "BATCH_JOB_PHASE_SUCCEEDED", - "BATCH_JOB_PHASE_FAILED", and "BATCH_JOB_PHASE_ERROR". - "started_at": "2020-02-20 00:00:00", # Optional. - IndexingJob description. - "tokens": 0, # Optional. Number of tokens. - "total_datasources": 0, # Optional. Number of - datasources being indexed. - "updated_at": "2020-02-20 00:00:00", # Optional. - Last modified. - "uuid": "str" # Optional. Unique id. - }, - "region": "str", # Optional. Region code - Deprecated, moved - to data_source_details. - "spaces_data_source": { - "bucket_name": "str", # Optional. Spaces bucket - name. - "item_path": "str", # Optional. Spaces Bucket Data - Source. - "region": "str" # Optional. Region of bucket. - }, - "updated_at": "2020-02-20 00:00:00", # Optional. Last - modified. - "uuid": "str" # Optional. Unique id of knowledge base. - } - ], - "links": { - "pages": { - "first": "str", # Optional. First page. - "last": "str", # Optional. Last page. - "next": "str", # Optional. Next page. - "previous": "str" # Optional. Previous page. - } - }, - "meta": { - "page": 0, # Optional. The current page. - "pages": 0, # Optional. Total number of pages. - "total": 0 # Optional. Total amount of items over all pages. - } - } - # 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_genai_list_knowledge_base_data_sources_request( - knowledge_base_uuid=knowledge_base_uuid, - page=page, - per_page=per_page, - 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 delete_knowledge_base_data_source( self, knowledge_base_uuid: str, data_source_uuid: str, **kwargs: Any @@ -177981,166 +179415,6 @@ async def delete_knowledge_base_data_source( return cast(JSON, deserialized) # type: ignore - @distributed_trace_async - async def get_knowledge_base(self, uuid: str, **kwargs: Any) -> JSON: - # pylint: disable=line-too-long - """Retrieve Information About an Existing Knowledge Base. - - To retrive information about an existing knowledge base, send a GET request to - ``/v2/gen-ai/knowledge_bases/{uuid}``. - - :param uuid: Knowledge base id. Required. - :type uuid: str - :return: JSON object - :rtype: JSON - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "database_status": "CREATING", # Optional. Default value is "CREATING". - Known values are: "CREATING", "ONLINE", "POWEROFF", "REBUILDING", "REBALANCING", - "DECOMMISSIONED", "FORKING", "MIGRATING", "RESIZING", "RESTORING", "POWERING_ON", - and "UNHEALTHY". - "knowledge_base": { - "added_to_agent_at": "2020-02-20 00:00:00", # Optional. Time when - the knowledge base was added to the agent. - "created_at": "2020-02-20 00:00:00", # Optional. Creation date / - time. - "database_id": "str", # Optional. Knowledgebase Description. - "embedding_model_uuid": "str", # Optional. Knowledgebase - Description. - "is_public": bool, # Optional. Whether the knowledge base is public - or not. - "last_indexing_job": { - "completed_datasources": 0, # Optional. Number of - datasources indexed completed. - "created_at": "2020-02-20 00:00:00", # Optional. Creation - date / time. - "data_source_uuids": [ - "str" # Optional. IndexingJob description. - ], - "finished_at": "2020-02-20 00:00:00", # Optional. - IndexingJob description. - "knowledge_base_uuid": "str", # Optional. Knowledge base id. - "phase": "BATCH_JOB_PHASE_UNKNOWN", # Optional. Default - value is "BATCH_JOB_PHASE_UNKNOWN". Known values are: - "BATCH_JOB_PHASE_UNKNOWN", "BATCH_JOB_PHASE_PENDING", - "BATCH_JOB_PHASE_RUNNING", "BATCH_JOB_PHASE_SUCCEEDED", - "BATCH_JOB_PHASE_FAILED", and "BATCH_JOB_PHASE_ERROR". - "started_at": "2020-02-20 00:00:00", # Optional. IndexingJob - description. - "tokens": 0, # Optional. Number of tokens. - "total_datasources": 0, # Optional. Number of datasources - being indexed. - "updated_at": "2020-02-20 00:00:00", # Optional. Last - modified. - "uuid": "str" # Optional. Unique id. - }, - "name": "str", # Optional. Name of knowledge base. - "project_id": "str", # Optional. Knowledgebase Description. - "region": "str", # Optional. Region code. - "tags": [ - "str" # Optional. Tags to organize related resources. - ], - "updated_at": "2020-02-20 00:00:00", # Optional. Last modified. - "user_id": "str", # Optional. Id of user that created the knowledge - base. - "uuid": "str" # Optional. Unique id for knowledge base. - } - } - # 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_genai_get_knowledge_base_request( - uuid=uuid, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = ( - await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 404]: - if _stream: - await response.read() # Load the body in memory and close the socket - map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore - raise HttpResponseError(response=response) - - response_headers = {} - if response.status_code == 200: - response_headers["ratelimit-limit"] = self._deserialize( - "int", response.headers.get("ratelimit-limit") - ) - response_headers["ratelimit-remaining"] = self._deserialize( - "int", response.headers.get("ratelimit-remaining") - ) - response_headers["ratelimit-reset"] = self._deserialize( - "int", response.headers.get("ratelimit-reset") - ) - - if response.content: - deserialized = response.json() - else: - deserialized = None - - if response.status_code == 404: - response_headers["ratelimit-limit"] = self._deserialize( - "int", response.headers.get("ratelimit-limit") - ) - response_headers["ratelimit-remaining"] = self._deserialize( - "int", response.headers.get("ratelimit-remaining") - ) - response_headers["ratelimit-reset"] = self._deserialize( - "int", response.headers.get("ratelimit-reset") - ) - - if response.content: - deserialized = response.json() - else: - deserialized = None - - if cls: - return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore - - return cast(JSON, deserialized) # type: ignore - @overload async def update_knowledge_base( self, @@ -178637,6 +179911,166 @@ async def delete_knowledge_base(self, uuid: str, **kwargs: Any) -> JSON: return cast(JSON, deserialized) # type: ignore + @distributed_trace_async + async def get_knowledge_base(self, uuid: str, **kwargs: Any) -> JSON: + # pylint: disable=line-too-long + """Retrieve Information About an Existing Knowledge Base. + + To retrive information about an existing knowledge base, send a GET request to + ``/v2/gen-ai/knowledge_bases/{uuid}``. + + :param uuid: Knowledge base id. Required. + :type uuid: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "database_status": "CREATING", # Optional. Default value is "CREATING". + Known values are: "CREATING", "ONLINE", "POWEROFF", "REBUILDING", "REBALANCING", + "DECOMMISSIONED", "FORKING", "MIGRATING", "RESIZING", "RESTORING", "POWERING_ON", + and "UNHEALTHY". + "knowledge_base": { + "added_to_agent_at": "2020-02-20 00:00:00", # Optional. Time when + the knowledge base was added to the agent. + "created_at": "2020-02-20 00:00:00", # Optional. Creation date / + time. + "database_id": "str", # Optional. Knowledgebase Description. + "embedding_model_uuid": "str", # Optional. Knowledgebase + Description. + "is_public": bool, # Optional. Whether the knowledge base is public + or not. + "last_indexing_job": { + "completed_datasources": 0, # Optional. Number of + datasources indexed completed. + "created_at": "2020-02-20 00:00:00", # Optional. Creation + date / time. + "data_source_uuids": [ + "str" # Optional. IndexingJob description. + ], + "finished_at": "2020-02-20 00:00:00", # Optional. + IndexingJob description. + "knowledge_base_uuid": "str", # Optional. Knowledge base id. + "phase": "BATCH_JOB_PHASE_UNKNOWN", # Optional. Default + value is "BATCH_JOB_PHASE_UNKNOWN". Known values are: + "BATCH_JOB_PHASE_UNKNOWN", "BATCH_JOB_PHASE_PENDING", + "BATCH_JOB_PHASE_RUNNING", "BATCH_JOB_PHASE_SUCCEEDED", + "BATCH_JOB_PHASE_FAILED", and "BATCH_JOB_PHASE_ERROR". + "started_at": "2020-02-20 00:00:00", # Optional. IndexingJob + description. + "tokens": 0, # Optional. Number of tokens. + "total_datasources": 0, # Optional. Number of datasources + being indexed. + "updated_at": "2020-02-20 00:00:00", # Optional. Last + modified. + "uuid": "str" # Optional. Unique id. + }, + "name": "str", # Optional. Name of knowledge base. + "project_id": "str", # Optional. Knowledgebase Description. + "region": "str", # Optional. Region code. + "tags": [ + "str" # Optional. Tags to organize related resources. + ], + "updated_at": "2020-02-20 00:00:00", # Optional. Last modified. + "user_id": "str", # Optional. Id of user that created the knowledge + base. + "uuid": "str" # Optional. Unique id for knowledge base. + } + } + # 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_genai_get_knowledge_base_request( + uuid=uuid, + 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 list_models( self, diff --git a/src/pydo/operations/_operations.py b/src/pydo/operations/_operations.py index 1635929..6c2e9ae 100644 --- a/src/pydo/operations/_operations.py +++ b/src/pydo/operations/_operations.py @@ -9104,6 +9104,27 @@ def build_uptime_delete_alert_request( return HttpRequest(method="DELETE", url=_url, headers=_headers, **kwargs) +def build_genai_create_agent_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 = "/v2/gen-ai/agents" + + # 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_genai_list_agents_request( *, only_deployed: Optional[bool] = None, @@ -9137,27 +9158,6 @@ def build_genai_list_agents_request( ) -def build_genai_create_agent_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 = "/v2/gen-ai/agents" - - # 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_genai_list_agent_api_keys_request( agent_uuid: str, *, @@ -9220,14 +9220,11 @@ def build_genai_create_agent_api_key_request( return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs) -def build_genai_update_agent_api_key_request( +def build_genai_delete_agent_api_key_request( agent_uuid: str, api_key_uuid: 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 @@ -9240,20 +9237,19 @@ def build_genai_update_agent_api_key_request( _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) + return HttpRequest(method="DELETE", url=_url, headers=_headers, **kwargs) -def build_genai_delete_agent_api_key_request( +def build_genai_update_agent_api_key_request( agent_uuid: str, api_key_uuid: 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 @@ -9266,9 +9262,13 @@ def build_genai_delete_agent_api_key_request( _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="DELETE", url=_url, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, headers=_headers, **kwargs) def build_genai_regenerate_agent_api_key_request( # pylint: disable=name-too-long @@ -9321,11 +9321,14 @@ def build_genai_attach_agent_function_request( # pylint: disable=name-too-long return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs) -def build_genai_detach_agent_function_request( # pylint: disable=name-too-long +def build_genai_update_agent_function_request( # pylint: disable=name-too-long agent_uuid: str, function_uuid: 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 @@ -9338,19 +9341,20 @@ def build_genai_detach_agent_function_request( # pylint: disable=name-too-long _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="DELETE", url=_url, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, headers=_headers, **kwargs) -def build_genai_update_agent_function_request( # pylint: disable=name-too-long +def build_genai_detach_agent_function_request( # pylint: disable=name-too-long agent_uuid: str, function_uuid: 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 @@ -9363,13 +9367,9 @@ def build_genai_update_agent_function_request( # pylint: disable=name-too-long _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) + return HttpRequest(method="DELETE", url=_url, headers=_headers, **kwargs) def build_genai_detach_knowledge_base_request( # pylint: disable=name-too-long @@ -9623,6 +9623,158 @@ def build_genai_update_agent_deployment_visibility_request( # pylint: disable=n return HttpRequest(method="PUT", url=_url, headers=_headers, **kwargs) +def build_genai_list_anthropic_api_keys_request( # pylint: disable=name-too-long + *, page: Optional[int] = None, per_page: Optional[int] = 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/gen-ai/anthropic/keys" + + # Construct parameters + if page is not None: + _params["page"] = _SERIALIZER.query("page", page, "int") + if per_page is not None: + _params["per_page"] = _SERIALIZER.query("per_page", per_page, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest( + method="GET", url=_url, params=_params, headers=_headers, **kwargs + ) + + +def build_genai_create_anthropic_api_key_request( + **kwargs: Any, +) -> HttpRequest: # pylint: disable=name-too-long + _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/gen-ai/anthropic/keys" + + # 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_genai_delete_anthropic_api_key_request( # pylint: disable=name-too-long + api_key_uuid: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/v2/gen-ai/anthropic/keys/{api_key_uuid}" + path_format_arguments = { + "api_key_uuid": _SERIALIZER.url("api_key_uuid", api_key_uuid, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, headers=_headers, **kwargs) + + +def build_genai_get_anthropic_api_key_request( # pylint: disable=name-too-long + api_key_uuid: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/v2/gen-ai/anthropic/keys/{api_key_uuid}" + path_format_arguments = { + "api_key_uuid": _SERIALIZER.url("api_key_uuid", api_key_uuid, "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_genai_update_anthropic_api_key_request( # pylint: disable=name-too-long + api_key_uuid: 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/gen-ai/anthropic/keys/{api_key_uuid}" + path_format_arguments = { + "api_key_uuid": _SERIALIZER.url("api_key_uuid", api_key_uuid, "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_genai_list_agents_by_anthropic_key_request( # pylint: disable=name-too-long + uuid: str, + *, + page: Optional[int] = None, + per_page: Optional[int] = 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/gen-ai/anthropic/keys/{uuid}/agents" + path_format_arguments = { + "uuid": _SERIALIZER.url("uuid", uuid, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + if page is not None: + _params["page"] = _SERIALIZER.query("page", page, "int") + if per_page is not None: + _params["per_page"] = _SERIALIZER.query("per_page", per_page, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest( + method="GET", url=_url, params=_params, headers=_headers, **kwargs + ) + + def build_genai_list_indexing_jobs_request( *, page: Optional[int] = None, per_page: Optional[int] = None, **kwargs: Any ) -> HttpRequest: @@ -9785,6 +9937,42 @@ def build_genai_create_knowledge_base_request( return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs) +def build_genai_list_knowledge_base_data_sources_request( # pylint: disable=name-too-long + knowledge_base_uuid: str, + *, + page: Optional[int] = None, + per_page: Optional[int] = 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/gen-ai/knowledge_bases/{knowledge_base_uuid}/data_sources" + path_format_arguments = { + "knowledge_base_uuid": _SERIALIZER.url( + "knowledge_base_uuid", knowledge_base_uuid, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + if page is not None: + _params["page"] = _SERIALIZER.query("page", page, "int") + if per_page is not None: + _params["per_page"] = _SERIALIZER.query("per_page", per_page, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest( + method="GET", url=_url, params=_params, headers=_headers, **kwargs + ) + + def build_genai_create_knowledge_base_data_source_request( # pylint: disable=name-too-long knowledge_base_uuid: str, **kwargs: Any ) -> HttpRequest: @@ -9815,42 +10003,6 @@ def build_genai_create_knowledge_base_data_source_request( # pylint: disable=na return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs) -def build_genai_list_knowledge_base_data_sources_request( # pylint: disable=name-too-long - knowledge_base_uuid: str, - *, - page: Optional[int] = None, - per_page: Optional[int] = 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/gen-ai/knowledge_bases/{knowledge_base_uuid}/data_sources" - path_format_arguments = { - "knowledge_base_uuid": _SERIALIZER.url( - "knowledge_base_uuid", knowledge_base_uuid, "str" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if page is not None: - _params["page"] = _SERIALIZER.query("page", page, "int") - if per_page is not None: - _params["per_page"] = _SERIALIZER.query("per_page", per_page, "int") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest( - method="GET", url=_url, params=_params, headers=_headers, **kwargs - ) - - def build_genai_delete_knowledge_base_data_source_request( # pylint: disable=name-too-long knowledge_base_uuid: str, data_source_uuid: str, **kwargs: Any ) -> HttpRequest: @@ -9877,9 +10029,14 @@ def build_genai_delete_knowledge_base_data_source_request( # pylint: disable=na return HttpRequest(method="DELETE", url=_url, headers=_headers, **kwargs) -def build_genai_get_knowledge_base_request(uuid: str, **kwargs: Any) -> HttpRequest: +def build_genai_update_knowledge_base_request( + uuid: str, **kwargs: Any +) -> HttpRequest: # pylint: disable=name-too-long _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 @@ -9891,19 +10048,20 @@ def build_genai_get_knowledge_base_request(uuid: str, **kwargs: Any) -> HttpRequ _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="GET", url=_url, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, headers=_headers, **kwargs) -def build_genai_update_knowledge_base_request( +def build_genai_delete_knowledge_base_request( uuid: str, **kwargs: Any ) -> HttpRequest: # pylint: disable=name-too-long _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 @@ -9915,18 +10073,12 @@ def build_genai_update_knowledge_base_request( _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) + return HttpRequest(method="DELETE", url=_url, headers=_headers, **kwargs) -def build_genai_delete_knowledge_base_request( - uuid: str, **kwargs: Any -) -> HttpRequest: # pylint: disable=name-too-long +def build_genai_get_knowledge_base_request(uuid: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) accept = _headers.pop("Accept", "application/json") @@ -9942,7 +10094,7 @@ def build_genai_delete_knowledge_base_request( # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="DELETE", url=_url, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, headers=_headers, **kwargs) def build_genai_list_models_request( @@ -173797,26 +173949,25 @@ def __init__(self, *args, **kwargs): input_args.pop(0) if input_args else kwargs.pop("deserializer") ) - @distributed_trace - def list_agents( + @overload + def create_agent( self, + body: Optional[JSON] = None, *, - only_deployed: Optional[bool] = None, - page: Optional[int] = None, - per_page: Optional[int] = None, + content_type: str = "application/json", **kwargs: Any, ) -> JSON: # pylint: disable=line-too-long - """List Agents. + """Create an Agent. - To list all agents, send a GET request to ``/v2/gen-ai/agents``. + To create a new agent, send a POST request to ``/v2/gen-ai/agents``. The response body contains + a JSON object with the newly created agent object. - :keyword only_deployed: Only list agents that are deployed. Default value is None. - :paramtype only_deployed: bool - :keyword page: Page number. Default value is None. - :paramtype page: int - :keyword per_page: Items per page. Default value is None. - :paramtype per_page: int + :param body: Default value is None. + :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: @@ -173824,67 +173975,333 @@ def list_agents( Example: .. code-block:: python + # JSON input template you can fill out and use as your body input. + body = { + "anthropic_key_uuid": "str", # Optional. Optional Anthropic API key ID to + use with Anthropic models. + "description": "str", # Optional. A text description of the agent, not used + in inference. + "instruction": "str", # Optional. Agent instruction. Instructions help your + agent to perform its job effectively. See `Write Effective Agent Instructions + `_ + for best practices. + "knowledge_base_uuid": [ + "str" # Optional. Ids of the knowledge base(s) to attach to the + agent. + ], + "model_uuid": "str", # Optional. Identifier for the foundation model. + "name": "str", # Optional. Agent name. + "project_id": "str", # Optional. The id of the DigitalOcean project this + agent will belong to. + "region": "str", # Optional. The DigitalOcean region to deploy your agent + in. + "tags": [ + "str" # Optional. Agent tag to organize related resources. + ] + } + # response body for status code(s): 200 response == { - "agents": [ - { - "chatbot": { - "button_background_color": "str", # Optional. A - Chatbot. - "logo": "str", # Optional. A Chatbot. - "name": "str", # Optional. Name of chatbot. - "primary_color": "str", # Optional. A Chatbot. - "secondary_color": "str", # Optional. A Chatbot. - "starting_message": "str" # Optional. A Chatbot. - }, - "chatbot_identifiers": [ - { - "agent_chatbot_identifier": "str" # - Optional. Agent chatbot identifier. - } - ], + "agent": { + "anthropic_api_key": { + "created_at": "2020-02-20 00:00:00", # Optional. Key + creation date. + "created_by": "str", # Optional. Created by user id from DO. + "deleted_at": "2020-02-20 00:00:00", # Optional. Key deleted + date. + "name": "str", # Optional. Name. + "updated_at": "2020-02-20 00:00:00", # Optional. Key last + updated date. + "uuid": "str" # Optional. Uuid. + }, + "api_key_infos": [ + { + "created_at": "2020-02-20 00:00:00", # Optional. + Creation date. + "created_by": "str", # Optional. Created by. + "deleted_at": "2020-02-20 00:00:00", # Optional. + Deleted date. + "name": "str", # Optional. Name. + "secret_key": "str", # Optional. Api key infos. + "uuid": "str" # Optional. Uuid. + } + ], + "api_keys": [ + { + "api_key": "str" # Optional. Api key. + } + ], + "chatbot": { + "button_background_color": "str", # Optional. A Chatbot. + "logo": "str", # Optional. A Chatbot. + "name": "str", # Optional. Name of chatbot. + "primary_color": "str", # Optional. A Chatbot. + "secondary_color": "str", # Optional. A Chatbot. + "starting_message": "str" # Optional. A Chatbot. + }, + "chatbot_identifiers": [ + { + "agent_chatbot_identifier": "str" # Optional. Agent + chatbot identifier. + } + ], + "child_agents": [ + ... + ], + "created_at": "2020-02-20 00:00:00", # Optional. Creation date / + time. + "deployment": { "created_at": "2020-02-20 00:00:00", # Optional. Creation date / time. - "deployment": { + "name": "str", # Optional. Name. + "status": "STATUS_UNKNOWN", # Optional. Default value is + "STATUS_UNKNOWN". Known values are: "STATUS_UNKNOWN", + "STATUS_WAITING_FOR_DEPLOYMENT", "STATUS_DEPLOYING", "STATUS_RUNNING", + "STATUS_FAILED", "STATUS_WAITING_FOR_UNDEPLOYMENT", "STATUS_UNDEPLOYING", + "STATUS_UNDEPLOYMENT_FAILED", and "STATUS_DELETED". + "updated_at": "2020-02-20 00:00:00", # Optional. Last + modified. + "url": "str", # Optional. Access your deployed agent here. + "uuid": "str", # Optional. Unique id. + "visibility": "VISIBILITY_UNKNOWN" # Optional. Default value + is "VISIBILITY_UNKNOWN". * VISIBILITY_UNKNOWN: The status of the + deployment is unknown * VISIBILITY_DISABLED: The deployment is + disabled and will no longer service requests * VISIBILITY_PLAYGROUND: + Deprecated: No longer a valid state * VISIBILITY_PUBLIC: The deployment + is public and will service requests from the public internet * + VISIBILITY_PRIVATE: The deployment is private and will only service + requests from other agents, or through API keys. Known values are: + "VISIBILITY_UNKNOWN", "VISIBILITY_DISABLED", "VISIBILITY_PLAYGROUND", + "VISIBILITY_PUBLIC", and "VISIBILITY_PRIVATE". + }, + "description": "str", # Optional. Description of agent. + "functions": [ + { + "api_key": "str", # Optional. Api key. "created_at": "2020-02-20 00:00:00", # Optional. Creation date / time. + "description": "str", # Optional. Agent description. + "faas_name": "str", # Optional. An Agent. + "faas_namespace": "str", # Optional. An Agent. + "input_schema": {}, # Optional. Any object. "name": "str", # Optional. Name. - "status": "STATUS_UNKNOWN", # Optional. Default - value is "STATUS_UNKNOWN". Known values are: "STATUS_UNKNOWN", - "STATUS_WAITING_FOR_DEPLOYMENT", "STATUS_DEPLOYING", - "STATUS_RUNNING", "STATUS_FAILED", "STATUS_WAITING_FOR_UNDEPLOYMENT", - "STATUS_UNDEPLOYING", "STATUS_UNDEPLOYMENT_FAILED", and - "STATUS_DELETED". + "output_schema": {}, # Optional. Any object. "updated_at": "2020-02-20 00:00:00", # Optional. Last modified. - "url": "str", # Optional. Access your deployed agent - here. - "uuid": "str", # Optional. Unique id. - "visibility": "VISIBILITY_UNKNOWN" # Optional. - Default value is "VISIBILITY_UNKNOWN". * VISIBILITY_UNKNOWN: The - status of the deployment is unknown * VISIBILITY_DISABLED: The - deployment is disabled and will no longer service requests * - VISIBILITY_PLAYGROUND: Deprecated: No longer a valid state * - VISIBILITY_PUBLIC: The deployment is public and will service requests - from the public internet * VISIBILITY_PRIVATE: The deployment is - private and will only service requests from other agents, or through - API keys. Known values are: "VISIBILITY_UNKNOWN", - "VISIBILITY_DISABLED", "VISIBILITY_PLAYGROUND", "VISIBILITY_PUBLIC", - and "VISIBILITY_PRIVATE". + "url": "str", # Optional. Download your agent here. + "uuid": "str" # Optional. Unique id. + } + ], + "guardrails": [ + { + "agent_uuid": "str", # Optional. The guardrails the + agent is attached to. + "created_at": "2020-02-20 00:00:00", # Optional. The + guardrails the agent is attached to. + "default_response": "str", # Optional. The + guardrails the agent is attached to. + "description": "str", # Optional. The guardrails the + agent is attached to. + "guardrail_uuid": "str", # Optional. The guardrails + the agent is attached to. + "is_attached": bool, # Optional. The guardrails the + agent is attached to. + "is_default": bool, # Optional. The guardrails the + agent is attached to. + "metadata": {}, # Optional. Any object. + "name": "str", # Optional. The guardrails the agent + is attached to. + "priority": 0, # Optional. The guardrails the agent + is attached to. + "type": "GUARDRAIL_TYPE_UNKNOWN", # Optional. + Default value is "GUARDRAIL_TYPE_UNKNOWN". Known values are: + "GUARDRAIL_TYPE_UNKNOWN", "GUARDRAIL_TYPE_JAILBREAK", + "GUARDRAIL_TYPE_SENSITIVE_DATA", and + "GUARDRAIL_TYPE_CONTENT_MODERATION". + "updated_at": "2020-02-20 00:00:00", # Optional. The + guardrails the agent is attached to. + "uuid": "str" # Optional. The guardrails the agent + is attached to. + } + ], + "if_case": "str", # Optional. An Agent. + "instruction": "str", # Optional. Agent instruction. Instructions + help your agent to perform its job effectively. See `Write Effective Agent + Instructions + `_ + for best practices. + "k": 0, # Optional. An Agent. + "knowledge_bases": [ + { + "added_to_agent_at": "2020-02-20 00:00:00", # + Optional. Time when the knowledge base was added to the agent. + "created_at": "2020-02-20 00:00:00", # Optional. + Creation date / time. + "database_id": "str", # Optional. Knowledge bases. + "embedding_model_uuid": "str", # Optional. Knowledge + bases. + "is_public": bool, # Optional. Whether the knowledge + base is public or not. + "last_indexing_job": { + "completed_datasources": 0, # Optional. + Number of datasources indexed completed. + "created_at": "2020-02-20 00:00:00", # + Optional. Creation date / time. + "data_source_uuids": [ + "str" # Optional. IndexingJob + description. + ], + "finished_at": "2020-02-20 00:00:00", # + Optional. IndexingJob description. + "knowledge_base_uuid": "str", # Optional. + Knowledge base id. + "phase": "BATCH_JOB_PHASE_UNKNOWN", # + Optional. Default value is "BATCH_JOB_PHASE_UNKNOWN". Known + values are: "BATCH_JOB_PHASE_UNKNOWN", "BATCH_JOB_PHASE_PENDING", + "BATCH_JOB_PHASE_RUNNING", "BATCH_JOB_PHASE_SUCCEEDED", + "BATCH_JOB_PHASE_FAILED", and "BATCH_JOB_PHASE_ERROR". + "started_at": "2020-02-20 00:00:00", # + Optional. IndexingJob description. + "tokens": 0, # Optional. Number of tokens. + "total_datasources": 0, # Optional. Number + of datasources being indexed. + "updated_at": "2020-02-20 00:00:00", # + Optional. Last modified. + "uuid": "str" # Optional. Unique id. + }, + "name": "str", # Optional. Name of knowledge base. + "project_id": "str", # Optional. Knowledge bases. + "region": "str", # Optional. Region code. + "tags": [ + "str" # Optional. Tags to organize related + resources. + ], + "updated_at": "2020-02-20 00:00:00", # Optional. + Last modified. + "user_id": "str", # Optional. Id of user that + created the knowledge base. + "uuid": "str" # Optional. Unique id for knowledge + base. + } + ], + "max_tokens": 0, # Optional. An Agent. + "model": { + "agreement": { + "description": "str", # Optional. Agreement + Description. + "name": "str", # Optional. Agreement Description. + "url": "str", # Optional. Agreement Description. + "uuid": "str" # Optional. Agreement Description. }, - "description": "str", # Optional. Description of agent. - "if_case": "str", # Optional. Instructions to the agent on - how to use the route. - "instruction": "str", # Optional. Agent instruction. - Instructions help your agent to perform its job effectively. See `Write - Effective Agent Instructions - `_ - for best practices. - "k": 0, # Optional. How many results should be considered - from an attached knowledge base. - "max_tokens": 0, # Optional. Specifies the maximum number of - tokens the model can process in a single input or output, set as a number - between 1 and 512. This determines the length of each response. + "created_at": "2020-02-20 00:00:00", # Optional. Creation + date / time. + "inference_name": "str", # Optional. Internally used name. + "inference_version": "str", # Optional. Internally used + version. + "is_foundational": bool, # Optional. True if it is a + foundational model provided by do. + "metadata": {}, # Optional. Additional meta data. + "name": "str", # Optional. Name of the model. + "parent_uuid": "str", # Optional. Unique id of the model, + this model is based on. + "provider": "MODEL_PROVIDER_DIGITALOCEAN", # Optional. + Default value is "MODEL_PROVIDER_DIGITALOCEAN". Known values are: + "MODEL_PROVIDER_DIGITALOCEAN" and "MODEL_PROVIDER_ANTHROPIC". + "updated_at": "2020-02-20 00:00:00", # Optional. Last + modified. + "upload_complete": bool, # Optional. Model has been fully + uploaded. + "url": "str", # Optional. Download url. + "uuid": "str", # Optional. Unique id. + "version": { + "major": 0, # Optional. Major version number. + "minor": 0, # Optional. Minor version number. + "patch": 0 # Optional. Patch version number. + } + }, + "name": "str", # Optional. Agent name. + "parent_agents": [ + ... + ], + "project_id": "str", # Optional. An Agent. + "region": "str", # Optional. Region code. + "route_created_at": "2020-02-20 00:00:00", # Optional. Creation of + route date / time. + "route_created_by": "str", # Optional. An Agent. + "route_name": "str", # Optional. Route name. + "route_uuid": "str", # Optional. An Agent. + "tags": [ + "str" # Optional. Agent tag to organize related resources. + ], + "temperature": 0.0, # Optional. An Agent. + "template": { + "created_at": "2020-02-20 00:00:00", # Optional. The agent + template's creation date. + "description": "str", # Optional. Description of the agent + template. + "instruction": "str", # Optional. Instructions for the agent + template. + "k": 0, # Optional. The 'k' value for the agent template. + "knowledge_bases": [ + { + "added_to_agent_at": "2020-02-20 00:00:00", + # Optional. Time when the knowledge base was added to the agent. + "created_at": "2020-02-20 00:00:00", # + Optional. Creation date / time. + "database_id": "str", # Optional. List of + knowledge bases associated with the agent template. + "embedding_model_uuid": "str", # Optional. + List of knowledge bases associated with the agent template. + "is_public": bool, # Optional. Whether the + knowledge base is public or not. + "last_indexing_job": { + "completed_datasources": 0, # + Optional. Number of datasources indexed completed. + "created_at": "2020-02-20 00:00:00", + # Optional. Creation date / time. + "data_source_uuids": [ + "str" # Optional. + IndexingJob description. + ], + "finished_at": "2020-02-20 00:00:00", + # Optional. IndexingJob description. + "knowledge_base_uuid": "str", # + Optional. Knowledge base id. + "phase": "BATCH_JOB_PHASE_UNKNOWN", + # Optional. Default value is "BATCH_JOB_PHASE_UNKNOWN". Known + values are: "BATCH_JOB_PHASE_UNKNOWN", + "BATCH_JOB_PHASE_PENDING", "BATCH_JOB_PHASE_RUNNING", + "BATCH_JOB_PHASE_SUCCEEDED", "BATCH_JOB_PHASE_FAILED", and + "BATCH_JOB_PHASE_ERROR". + "started_at": "2020-02-20 00:00:00", + # Optional. IndexingJob description. + "tokens": 0, # Optional. Number of + tokens. + "total_datasources": 0, # Optional. + Number of datasources being indexed. + "updated_at": "2020-02-20 00:00:00", + # Optional. Last modified. + "uuid": "str" # Optional. Unique id. + }, + "name": "str", # Optional. Name of knowledge + base. + "project_id": "str", # Optional. List of + knowledge bases associated with the agent template. + "region": "str", # Optional. Region code. + "tags": [ + "str" # Optional. Tags to organize + related resources. + ], + "updated_at": "2020-02-20 00:00:00", # + Optional. Last modified. + "user_id": "str", # Optional. Id of user + that created the knowledge base. + "uuid": "str" # Optional. Unique id for + knowledge base. + } + ], + "max_tokens": 0, # Optional. The max_tokens setting for the + agent template. "model": { "agreement": { "description": "str", # Optional. Agreement @@ -173926,175 +174343,20 @@ def list_agents( "patch": 0 # Optional. Patch version number. } }, - "name": "str", # Optional. Agent name. - "project_id": "str", # Optional. The DigitalOcean project ID - associated with the agent. - "region": "str", # Optional. Region code. - "route_created_at": "2020-02-20 00:00:00", # Optional. - Creation of route date / time. - "route_created_by": "str", # Optional. Id of user that - created the route. - "route_name": "str", # Optional. Route name. - "route_uuid": "str", # Optional. Route uuid. - "tags": [ - "str" # Optional. A set of abitrary tags to organize - your agent. - ], - "temperature": 0.0, # Optional. Controls the model"u2019s - creativity, specified as a number between 0 and 1. Lower values produce - more predictable and conservative responses, while higher values - encourage creativity and variation. - "template": { - "created_at": "2020-02-20 00:00:00", # Optional. The - agent template's creation date. - "description": "str", # Optional. Description of the - agent template. - "instruction": "str", # Optional. Instructions for - the agent template. - "k": 0, # Optional. The 'k' value for the agent - template. - "knowledge_bases": [ - { - "added_to_agent_at": "2020-02-20 - 00:00:00", # Optional. Time when the knowledge base was - added to the agent. - "created_at": "2020-02-20 00:00:00", - # Optional. Creation date / time. - "database_id": "str", # Optional. - List of knowledge bases associated with the agent template. - "embedding_model_uuid": "str", # - Optional. List of knowledge bases associated with the agent - template. - "is_public": bool, # Optional. - Whether the knowledge base is public or not. - "last_indexing_job": { - "completed_datasources": 0, - # Optional. Number of datasources indexed completed. - "created_at": "2020-02-20 - 00:00:00", # Optional. Creation date / time. - "data_source_uuids": [ - "str" # Optional. - IndexingJob description. - ], - "finished_at": "2020-02-20 - 00:00:00", # Optional. IndexingJob description. - "knowledge_base_uuid": "str", - # Optional. Knowledge base id. - "phase": - "BATCH_JOB_PHASE_UNKNOWN", # Optional. Default value is - "BATCH_JOB_PHASE_UNKNOWN". Known values are: - "BATCH_JOB_PHASE_UNKNOWN", "BATCH_JOB_PHASE_PENDING", - "BATCH_JOB_PHASE_RUNNING", "BATCH_JOB_PHASE_SUCCEEDED", - "BATCH_JOB_PHASE_FAILED", and "BATCH_JOB_PHASE_ERROR". - "started_at": "2020-02-20 - 00:00:00", # Optional. IndexingJob description. - "tokens": 0, # Optional. - Number of tokens. - "total_datasources": 0, # - Optional. Number of datasources being indexed. - "updated_at": "2020-02-20 - 00:00:00", # Optional. Last modified. - "uuid": "str" # Optional. - Unique id. - }, - "name": "str", # Optional. Name of - knowledge base. - "project_id": "str", # Optional. - List of knowledge bases associated with the agent template. - "region": "str", # Optional. Region - code. - "tags": [ - "str" # Optional. Tags to - organize related resources. - ], - "updated_at": "2020-02-20 00:00:00", - # Optional. Last modified. - "user_id": "str", # Optional. Id of - user that created the knowledge base. - "uuid": "str" # Optional. Unique id - for knowledge base. - } - ], - "max_tokens": 0, # Optional. The max_tokens setting - for the agent template. - "model": { - "agreement": { - "description": "str", # Optional. - Agreement Description. - "name": "str", # Optional. Agreement - Description. - "url": "str", # Optional. Agreement - Description. - "uuid": "str" # Optional. Agreement - Description. - }, - "created_at": "2020-02-20 00:00:00", # - Optional. Creation date / time. - "inference_name": "str", # Optional. - Internally used name. - "inference_version": "str", # Optional. - Internally used version. - "is_foundational": bool, # Optional. True if - it is a foundational model provided by do. - "metadata": {}, # Optional. Additional meta - data. - "name": "str", # Optional. Name of the - model. - "parent_uuid": "str", # Optional. Unique id - of the model, this model is based on. - "provider": "MODEL_PROVIDER_DIGITALOCEAN", # - Optional. Default value is "MODEL_PROVIDER_DIGITALOCEAN". Known - values are: "MODEL_PROVIDER_DIGITALOCEAN" and - "MODEL_PROVIDER_ANTHROPIC". - "updated_at": "2020-02-20 00:00:00", # - Optional. Last modified. - "upload_complete": bool, # Optional. Model - has been fully uploaded. - "url": "str", # Optional. Download url. - "uuid": "str", # Optional. Unique id. - "version": { - "major": 0, # Optional. Major - version number. - "minor": 0, # Optional. Minor - version number. - "patch": 0 # Optional. Patch version - number. - } - }, - "name": "str", # Optional. Name of the agent - template. - "temperature": 0.0, # Optional. The temperature - setting for the agent template. - "top_p": 0.0, # Optional. The top_p setting for the - agent template. - "updated_at": "2020-02-20 00:00:00", # Optional. The - agent template's last updated date. - "uuid": "str" # Optional. Unique id. - }, - "top_p": 0.0, # Optional. Defines the cumulative probability - threshold for word selection, specified as a number between 0 and 1. - Higher values allow for more diverse outputs, while lower values ensure - focused and coherent responses. - "updated_at": "2020-02-20 00:00:00", # Optional. Last - modified. - "url": "str", # Optional. Access your agent under this url. - "user_id": "str", # Optional. Id of user that created the - agent. - "uuid": "str" # Optional. Unique agent id. - } - ], - "links": { - "pages": { - "first": "str", # Optional. First page. - "last": "str", # Optional. Last page. - "next": "str", # Optional. Next page. - "previous": "str" # Optional. Previous page. - } - }, - "meta": { - "page": 0, # Optional. The current page. - "pages": 0, # Optional. Total number of pages. - "total": 0 # Optional. Total amount of items over all pages. + "name": "str", # Optional. Name of the agent template. + "temperature": 0.0, # Optional. The temperature setting for + the agent template. + "top_p": 0.0, # Optional. The top_p setting for the agent + template. + "updated_at": "2020-02-20 00:00:00", # Optional. The agent + template's last updated date. + "uuid": "str" # Optional. Unique id. + }, + "top_p": 0.0, # Optional. An Agent. + "updated_at": "2020-02-20 00:00:00", # Optional. Last modified. + "url": "str", # Optional. Access your agent under this url. + "user_id": "str", # Optional. Id of user that created the agent. + "uuid": "str" # Optional. Unique agent id. } } # response body for status code(s): 404 @@ -174109,90 +174371,11 @@ def list_agents( 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_genai_list_agents_request( - only_deployed=only_deployed, - page=page, - per_page=per_page, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = ( - self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 404]: - if _stream: - response.read() # Load the body in memory and close the socket - map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore - raise HttpResponseError(response=response) - - response_headers = {} - if response.status_code == 200: - response_headers["ratelimit-limit"] = self._deserialize( - "int", response.headers.get("ratelimit-limit") - ) - response_headers["ratelimit-remaining"] = self._deserialize( - "int", response.headers.get("ratelimit-remaining") - ) - response_headers["ratelimit-reset"] = self._deserialize( - "int", response.headers.get("ratelimit-reset") - ) - - if response.content: - deserialized = response.json() - else: - deserialized = None - - if response.status_code == 404: - response_headers["ratelimit-limit"] = self._deserialize( - "int", response.headers.get("ratelimit-limit") - ) - response_headers["ratelimit-remaining"] = self._deserialize( - "int", response.headers.get("ratelimit-remaining") - ) - response_headers["ratelimit-reset"] = self._deserialize( - "int", response.headers.get("ratelimit-reset") - ) - - if response.content: - deserialized = response.json() - else: - deserialized = None - - if cls: - return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore - - return cast(JSON, deserialized) # type: ignore @overload def create_agent( self, - body: Optional[JSON] = None, + body: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any, @@ -174204,8 +174387,8 @@ def create_agent( a JSON object with the newly created agent object. :param body: Default value is None. - :type body: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + :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 @@ -174215,29 +174398,6 @@ def create_agent( Example: .. code-block:: python - # JSON input template you can fill out and use as your body input. - body = { - "description": "str", # Optional. A text description of the agent, not used - in inference. - "instruction": "str", # Optional. Agent instruction. Instructions help your - agent to perform its job effectively. See `Write Effective Agent Instructions - `_ - for best practices. - "knowledge_base_uuid": [ - "str" # Optional. Ids of the knowledge base(s) to attach to the - agent. - ], - "model_uuid": "str", # Optional. Identifier for the foundation model. - "name": "str", # Optional. Agent name. - "project_id": "str", # Optional. The id of the DigitalOcean project this - agent will belong to. - "region": "str", # Optional. The DigitalOcean region to deploy your agent - in. - "tags": [ - "str" # Optional. Agent tag to organize related resources. - ] - } - # response body for status code(s): 200 response == { "agent": { @@ -174610,13 +174770,9 @@ def create_agent( } """ - @overload + @distributed_trace def create_agent( - self, - body: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any, + self, body: Optional[Union[JSON, IO[bytes]]] = None, **kwargs: Any ) -> JSON: # pylint: disable=line-too-long """Create an Agent. @@ -174624,11 +174780,8 @@ def create_agent( To create a new agent, send a POST request to ``/v2/gen-ai/agents``. The response body contains a JSON object with the newly created agent object. - :param body: Default value is None. - :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 + :param body: Is either a JSON type or a IO[bytes] type. Default value is None. + :type body: JSON or IO[bytes] :return: JSON object :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: @@ -174636,6 +174789,31 @@ def create_agent( Example: .. code-block:: python + # JSON input template you can fill out and use as your body input. + body = { + "anthropic_key_uuid": "str", # Optional. Optional Anthropic API key ID to + use with Anthropic models. + "description": "str", # Optional. A text description of the agent, not used + in inference. + "instruction": "str", # Optional. Agent instruction. Instructions help your + agent to perform its job effectively. See `Write Effective Agent Instructions + `_ + for best practices. + "knowledge_base_uuid": [ + "str" # Optional. Ids of the knowledge base(s) to attach to the + agent. + ], + "model_uuid": "str", # Optional. Identifier for the foundation model. + "name": "str", # Optional. Agent name. + "project_id": "str", # Optional. The id of the DigitalOcean project this + agent will belong to. + "region": "str", # Optional. The DigitalOcean region to deploy your agent + in. + "tags": [ + "str" # Optional. Agent tag to organize related resources. + ] + } + # response body for status code(s): 200 response == { "agent": { @@ -175007,19 +175185,120 @@ def create_agent( 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: + if body is not None: + _json = body + else: + _json = None + + _request = build_genai_create_agent_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, 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 create_agent( - self, body: Optional[Union[JSON, IO[bytes]]] = None, **kwargs: Any + def list_agents( + self, + *, + only_deployed: Optional[bool] = None, + page: Optional[int] = None, + per_page: Optional[int] = None, + **kwargs: Any, ) -> JSON: # pylint: disable=line-too-long - """Create an Agent. + """List Agents. - To create a new agent, send a POST request to ``/v2/gen-ai/agents``. The response body contains - a JSON object with the newly created agent object. + To list all agents, send a GET request to ``/v2/gen-ai/agents``. - :param body: Is either a JSON type or a IO[bytes] type. Default value is None. - :type body: JSON or IO[bytes] + :keyword only_deployed: Only list agents that are deployed. Default value is None. + :paramtype only_deployed: bool + :keyword page: Page number. Default value is None. + :paramtype page: int + :keyword per_page: Items per page. Default value is None. + :paramtype per_page: int :return: JSON object :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: @@ -175027,331 +175306,67 @@ def create_agent( Example: .. code-block:: python - # JSON input template you can fill out and use as your body input. - body = { - "description": "str", # Optional. A text description of the agent, not used - in inference. - "instruction": "str", # Optional. Agent instruction. Instructions help your - agent to perform its job effectively. See `Write Effective Agent Instructions - `_ - for best practices. - "knowledge_base_uuid": [ - "str" # Optional. Ids of the knowledge base(s) to attach to the - agent. - ], - "model_uuid": "str", # Optional. Identifier for the foundation model. - "name": "str", # Optional. Agent name. - "project_id": "str", # Optional. The id of the DigitalOcean project this - agent will belong to. - "region": "str", # Optional. The DigitalOcean region to deploy your agent - in. - "tags": [ - "str" # Optional. Agent tag to organize related resources. - ] - } - # response body for status code(s): 200 response == { - "agent": { - "anthropic_api_key": { - "created_at": "2020-02-20 00:00:00", # Optional. Key - creation date. - "created_by": "str", # Optional. Created by user id from DO. - "deleted_at": "2020-02-20 00:00:00", # Optional. Key deleted - date. - "name": "str", # Optional. Name. - "updated_at": "2020-02-20 00:00:00", # Optional. Key last - updated date. - "uuid": "str" # Optional. Uuid. - }, - "api_key_infos": [ - { - "created_at": "2020-02-20 00:00:00", # Optional. - Creation date. - "created_by": "str", # Optional. Created by. - "deleted_at": "2020-02-20 00:00:00", # Optional. - Deleted date. - "name": "str", # Optional. Name. - "secret_key": "str", # Optional. Api key infos. - "uuid": "str" # Optional. Uuid. - } - ], - "api_keys": [ - { - "api_key": "str" # Optional. Api key. - } - ], - "chatbot": { - "button_background_color": "str", # Optional. A Chatbot. - "logo": "str", # Optional. A Chatbot. - "name": "str", # Optional. Name of chatbot. - "primary_color": "str", # Optional. A Chatbot. - "secondary_color": "str", # Optional. A Chatbot. - "starting_message": "str" # Optional. A Chatbot. - }, - "chatbot_identifiers": [ - { - "agent_chatbot_identifier": "str" # Optional. Agent - chatbot identifier. - } - ], - "child_agents": [ - ... - ], - "created_at": "2020-02-20 00:00:00", # Optional. Creation date / - time. - "deployment": { + "agents": [ + { + "chatbot": { + "button_background_color": "str", # Optional. A + Chatbot. + "logo": "str", # Optional. A Chatbot. + "name": "str", # Optional. Name of chatbot. + "primary_color": "str", # Optional. A Chatbot. + "secondary_color": "str", # Optional. A Chatbot. + "starting_message": "str" # Optional. A Chatbot. + }, + "chatbot_identifiers": [ + { + "agent_chatbot_identifier": "str" # + Optional. Agent chatbot identifier. + } + ], "created_at": "2020-02-20 00:00:00", # Optional. Creation date / time. - "name": "str", # Optional. Name. - "status": "STATUS_UNKNOWN", # Optional. Default value is - "STATUS_UNKNOWN". Known values are: "STATUS_UNKNOWN", - "STATUS_WAITING_FOR_DEPLOYMENT", "STATUS_DEPLOYING", "STATUS_RUNNING", - "STATUS_FAILED", "STATUS_WAITING_FOR_UNDEPLOYMENT", "STATUS_UNDEPLOYING", - "STATUS_UNDEPLOYMENT_FAILED", and "STATUS_DELETED". - "updated_at": "2020-02-20 00:00:00", # Optional. Last - modified. - "url": "str", # Optional. Access your deployed agent here. - "uuid": "str", # Optional. Unique id. - "visibility": "VISIBILITY_UNKNOWN" # Optional. Default value - is "VISIBILITY_UNKNOWN". * VISIBILITY_UNKNOWN: The status of the - deployment is unknown * VISIBILITY_DISABLED: The deployment is - disabled and will no longer service requests * VISIBILITY_PLAYGROUND: - Deprecated: No longer a valid state * VISIBILITY_PUBLIC: The deployment - is public and will service requests from the public internet * - VISIBILITY_PRIVATE: The deployment is private and will only service - requests from other agents, or through API keys. Known values are: - "VISIBILITY_UNKNOWN", "VISIBILITY_DISABLED", "VISIBILITY_PLAYGROUND", - "VISIBILITY_PUBLIC", and "VISIBILITY_PRIVATE". - }, - "description": "str", # Optional. Description of agent. - "functions": [ - { - "api_key": "str", # Optional. Api key. + "deployment": { "created_at": "2020-02-20 00:00:00", # Optional. Creation date / time. - "description": "str", # Optional. Agent description. - "faas_name": "str", # Optional. An Agent. - "faas_namespace": "str", # Optional. An Agent. - "input_schema": {}, # Optional. Any object. "name": "str", # Optional. Name. - "output_schema": {}, # Optional. Any object. - "updated_at": "2020-02-20 00:00:00", # Optional. - Last modified. - "url": "str", # Optional. Download your agent here. - "uuid": "str" # Optional. Unique id. - } - ], - "guardrails": [ - { - "agent_uuid": "str", # Optional. The guardrails the - agent is attached to. - "created_at": "2020-02-20 00:00:00", # Optional. The - guardrails the agent is attached to. - "default_response": "str", # Optional. The - guardrails the agent is attached to. - "description": "str", # Optional. The guardrails the - agent is attached to. - "guardrail_uuid": "str", # Optional. The guardrails - the agent is attached to. - "is_attached": bool, # Optional. The guardrails the - agent is attached to. - "is_default": bool, # Optional. The guardrails the - agent is attached to. - "metadata": {}, # Optional. Any object. - "name": "str", # Optional. The guardrails the agent - is attached to. - "priority": 0, # Optional. The guardrails the agent - is attached to. - "type": "GUARDRAIL_TYPE_UNKNOWN", # Optional. - Default value is "GUARDRAIL_TYPE_UNKNOWN". Known values are: - "GUARDRAIL_TYPE_UNKNOWN", "GUARDRAIL_TYPE_JAILBREAK", - "GUARDRAIL_TYPE_SENSITIVE_DATA", and - "GUARDRAIL_TYPE_CONTENT_MODERATION". - "updated_at": "2020-02-20 00:00:00", # Optional. The - guardrails the agent is attached to. - "uuid": "str" # Optional. The guardrails the agent - is attached to. - } - ], - "if_case": "str", # Optional. An Agent. - "instruction": "str", # Optional. Agent instruction. Instructions - help your agent to perform its job effectively. See `Write Effective Agent - Instructions - `_ - for best practices. - "k": 0, # Optional. An Agent. - "knowledge_bases": [ - { - "added_to_agent_at": "2020-02-20 00:00:00", # - Optional. Time when the knowledge base was added to the agent. - "created_at": "2020-02-20 00:00:00", # Optional. - Creation date / time. - "database_id": "str", # Optional. Knowledge bases. - "embedding_model_uuid": "str", # Optional. Knowledge - bases. - "is_public": bool, # Optional. Whether the knowledge - base is public or not. - "last_indexing_job": { - "completed_datasources": 0, # Optional. - Number of datasources indexed completed. - "created_at": "2020-02-20 00:00:00", # - Optional. Creation date / time. - "data_source_uuids": [ - "str" # Optional. IndexingJob - description. - ], - "finished_at": "2020-02-20 00:00:00", # - Optional. IndexingJob description. - "knowledge_base_uuid": "str", # Optional. - Knowledge base id. - "phase": "BATCH_JOB_PHASE_UNKNOWN", # - Optional. Default value is "BATCH_JOB_PHASE_UNKNOWN". Known - values are: "BATCH_JOB_PHASE_UNKNOWN", "BATCH_JOB_PHASE_PENDING", - "BATCH_JOB_PHASE_RUNNING", "BATCH_JOB_PHASE_SUCCEEDED", - "BATCH_JOB_PHASE_FAILED", and "BATCH_JOB_PHASE_ERROR". - "started_at": "2020-02-20 00:00:00", # - Optional. IndexingJob description. - "tokens": 0, # Optional. Number of tokens. - "total_datasources": 0, # Optional. Number - of datasources being indexed. - "updated_at": "2020-02-20 00:00:00", # - Optional. Last modified. - "uuid": "str" # Optional. Unique id. - }, - "name": "str", # Optional. Name of knowledge base. - "project_id": "str", # Optional. Knowledge bases. - "region": "str", # Optional. Region code. - "tags": [ - "str" # Optional. Tags to organize related - resources. - ], + "status": "STATUS_UNKNOWN", # Optional. Default + value is "STATUS_UNKNOWN". Known values are: "STATUS_UNKNOWN", + "STATUS_WAITING_FOR_DEPLOYMENT", "STATUS_DEPLOYING", + "STATUS_RUNNING", "STATUS_FAILED", "STATUS_WAITING_FOR_UNDEPLOYMENT", + "STATUS_UNDEPLOYING", "STATUS_UNDEPLOYMENT_FAILED", and + "STATUS_DELETED". "updated_at": "2020-02-20 00:00:00", # Optional. Last modified. - "user_id": "str", # Optional. Id of user that - created the knowledge base. - "uuid": "str" # Optional. Unique id for knowledge - base. - } - ], - "max_tokens": 0, # Optional. An Agent. - "model": { - "agreement": { - "description": "str", # Optional. Agreement - Description. - "name": "str", # Optional. Agreement Description. - "url": "str", # Optional. Agreement Description. - "uuid": "str" # Optional. Agreement Description. + "url": "str", # Optional. Access your deployed agent + here. + "uuid": "str", # Optional. Unique id. + "visibility": "VISIBILITY_UNKNOWN" # Optional. + Default value is "VISIBILITY_UNKNOWN". * VISIBILITY_UNKNOWN: The + status of the deployment is unknown * VISIBILITY_DISABLED: The + deployment is disabled and will no longer service requests * + VISIBILITY_PLAYGROUND: Deprecated: No longer a valid state * + VISIBILITY_PUBLIC: The deployment is public and will service requests + from the public internet * VISIBILITY_PRIVATE: The deployment is + private and will only service requests from other agents, or through + API keys. Known values are: "VISIBILITY_UNKNOWN", + "VISIBILITY_DISABLED", "VISIBILITY_PLAYGROUND", "VISIBILITY_PUBLIC", + and "VISIBILITY_PRIVATE". }, - "created_at": "2020-02-20 00:00:00", # Optional. Creation - date / time. - "inference_name": "str", # Optional. Internally used name. - "inference_version": "str", # Optional. Internally used - version. - "is_foundational": bool, # Optional. True if it is a - foundational model provided by do. - "metadata": {}, # Optional. Additional meta data. - "name": "str", # Optional. Name of the model. - "parent_uuid": "str", # Optional. Unique id of the model, - this model is based on. - "provider": "MODEL_PROVIDER_DIGITALOCEAN", # Optional. - Default value is "MODEL_PROVIDER_DIGITALOCEAN". Known values are: - "MODEL_PROVIDER_DIGITALOCEAN" and "MODEL_PROVIDER_ANTHROPIC". - "updated_at": "2020-02-20 00:00:00", # Optional. Last - modified. - "upload_complete": bool, # Optional. Model has been fully - uploaded. - "url": "str", # Optional. Download url. - "uuid": "str", # Optional. Unique id. - "version": { - "major": 0, # Optional. Major version number. - "minor": 0, # Optional. Minor version number. - "patch": 0 # Optional. Patch version number. - } - }, - "name": "str", # Optional. Agent name. - "parent_agents": [ - ... - ], - "project_id": "str", # Optional. An Agent. - "region": "str", # Optional. Region code. - "route_created_at": "2020-02-20 00:00:00", # Optional. Creation of - route date / time. - "route_created_by": "str", # Optional. An Agent. - "route_name": "str", # Optional. Route name. - "route_uuid": "str", # Optional. An Agent. - "tags": [ - "str" # Optional. Agent tag to organize related resources. - ], - "temperature": 0.0, # Optional. An Agent. - "template": { - "created_at": "2020-02-20 00:00:00", # Optional. The agent - template's creation date. - "description": "str", # Optional. Description of the agent - template. - "instruction": "str", # Optional. Instructions for the agent - template. - "k": 0, # Optional. The 'k' value for the agent template. - "knowledge_bases": [ - { - "added_to_agent_at": "2020-02-20 00:00:00", - # Optional. Time when the knowledge base was added to the agent. - "created_at": "2020-02-20 00:00:00", # - Optional. Creation date / time. - "database_id": "str", # Optional. List of - knowledge bases associated with the agent template. - "embedding_model_uuid": "str", # Optional. - List of knowledge bases associated with the agent template. - "is_public": bool, # Optional. Whether the - knowledge base is public or not. - "last_indexing_job": { - "completed_datasources": 0, # - Optional. Number of datasources indexed completed. - "created_at": "2020-02-20 00:00:00", - # Optional. Creation date / time. - "data_source_uuids": [ - "str" # Optional. - IndexingJob description. - ], - "finished_at": "2020-02-20 00:00:00", - # Optional. IndexingJob description. - "knowledge_base_uuid": "str", # - Optional. Knowledge base id. - "phase": "BATCH_JOB_PHASE_UNKNOWN", - # Optional. Default value is "BATCH_JOB_PHASE_UNKNOWN". Known - values are: "BATCH_JOB_PHASE_UNKNOWN", - "BATCH_JOB_PHASE_PENDING", "BATCH_JOB_PHASE_RUNNING", - "BATCH_JOB_PHASE_SUCCEEDED", "BATCH_JOB_PHASE_FAILED", and - "BATCH_JOB_PHASE_ERROR". - "started_at": "2020-02-20 00:00:00", - # Optional. IndexingJob description. - "tokens": 0, # Optional. Number of - tokens. - "total_datasources": 0, # Optional. - Number of datasources being indexed. - "updated_at": "2020-02-20 00:00:00", - # Optional. Last modified. - "uuid": "str" # Optional. Unique id. - }, - "name": "str", # Optional. Name of knowledge - base. - "project_id": "str", # Optional. List of - knowledge bases associated with the agent template. - "region": "str", # Optional. Region code. - "tags": [ - "str" # Optional. Tags to organize - related resources. - ], - "updated_at": "2020-02-20 00:00:00", # - Optional. Last modified. - "user_id": "str", # Optional. Id of user - that created the knowledge base. - "uuid": "str" # Optional. Unique id for - knowledge base. - } - ], - "max_tokens": 0, # Optional. The max_tokens setting for the - agent template. + "description": "str", # Optional. Description of agent. + "if_case": "str", # Optional. Instructions to the agent on + how to use the route. + "instruction": "str", # Optional. Agent instruction. + Instructions help your agent to perform its job effectively. See `Write + Effective Agent Instructions + `_ + for best practices. + "k": 0, # Optional. How many results should be considered + from an attached knowledge base. + "max_tokens": 0, # Optional. Specifies the maximum number of + tokens the model can process in a single input or output, set as a number + between 1 and 512. This determines the length of each response. "model": { "agreement": { "description": "str", # Optional. Agreement @@ -175393,20 +175408,175 @@ def create_agent( "patch": 0 # Optional. Patch version number. } }, - "name": "str", # Optional. Name of the agent template. - "temperature": 0.0, # Optional. The temperature setting for - the agent template. - "top_p": 0.0, # Optional. The top_p setting for the agent - template. - "updated_at": "2020-02-20 00:00:00", # Optional. The agent - template's last updated date. - "uuid": "str" # Optional. Unique id. - }, - "top_p": 0.0, # Optional. An Agent. - "updated_at": "2020-02-20 00:00:00", # Optional. Last modified. - "url": "str", # Optional. Access your agent under this url. - "user_id": "str", # Optional. Id of user that created the agent. - "uuid": "str" # Optional. Unique agent id. + "name": "str", # Optional. Agent name. + "project_id": "str", # Optional. The DigitalOcean project ID + associated with the agent. + "region": "str", # Optional. Region code. + "route_created_at": "2020-02-20 00:00:00", # Optional. + Creation of route date / time. + "route_created_by": "str", # Optional. Id of user that + created the route. + "route_name": "str", # Optional. Route name. + "route_uuid": "str", # Optional. Route uuid. + "tags": [ + "str" # Optional. A set of abitrary tags to organize + your agent. + ], + "temperature": 0.0, # Optional. Controls the model"u2019s + creativity, specified as a number between 0 and 1. Lower values produce + more predictable and conservative responses, while higher values + encourage creativity and variation. + "template": { + "created_at": "2020-02-20 00:00:00", # Optional. The + agent template's creation date. + "description": "str", # Optional. Description of the + agent template. + "instruction": "str", # Optional. Instructions for + the agent template. + "k": 0, # Optional. The 'k' value for the agent + template. + "knowledge_bases": [ + { + "added_to_agent_at": "2020-02-20 + 00:00:00", # Optional. Time when the knowledge base was + added to the agent. + "created_at": "2020-02-20 00:00:00", + # Optional. Creation date / time. + "database_id": "str", # Optional. + List of knowledge bases associated with the agent template. + "embedding_model_uuid": "str", # + Optional. List of knowledge bases associated with the agent + template. + "is_public": bool, # Optional. + Whether the knowledge base is public or not. + "last_indexing_job": { + "completed_datasources": 0, + # Optional. Number of datasources indexed completed. + "created_at": "2020-02-20 + 00:00:00", # Optional. Creation date / time. + "data_source_uuids": [ + "str" # Optional. + IndexingJob description. + ], + "finished_at": "2020-02-20 + 00:00:00", # Optional. IndexingJob description. + "knowledge_base_uuid": "str", + # Optional. Knowledge base id. + "phase": + "BATCH_JOB_PHASE_UNKNOWN", # Optional. Default value is + "BATCH_JOB_PHASE_UNKNOWN". Known values are: + "BATCH_JOB_PHASE_UNKNOWN", "BATCH_JOB_PHASE_PENDING", + "BATCH_JOB_PHASE_RUNNING", "BATCH_JOB_PHASE_SUCCEEDED", + "BATCH_JOB_PHASE_FAILED", and "BATCH_JOB_PHASE_ERROR". + "started_at": "2020-02-20 + 00:00:00", # Optional. IndexingJob description. + "tokens": 0, # Optional. + Number of tokens. + "total_datasources": 0, # + Optional. Number of datasources being indexed. + "updated_at": "2020-02-20 + 00:00:00", # Optional. Last modified. + "uuid": "str" # Optional. + Unique id. + }, + "name": "str", # Optional. Name of + knowledge base. + "project_id": "str", # Optional. + List of knowledge bases associated with the agent template. + "region": "str", # Optional. Region + code. + "tags": [ + "str" # Optional. Tags to + organize related resources. + ], + "updated_at": "2020-02-20 00:00:00", + # Optional. Last modified. + "user_id": "str", # Optional. Id of + user that created the knowledge base. + "uuid": "str" # Optional. Unique id + for knowledge base. + } + ], + "max_tokens": 0, # Optional. The max_tokens setting + for the agent template. + "model": { + "agreement": { + "description": "str", # Optional. + Agreement Description. + "name": "str", # Optional. Agreement + Description. + "url": "str", # Optional. Agreement + Description. + "uuid": "str" # Optional. Agreement + Description. + }, + "created_at": "2020-02-20 00:00:00", # + Optional. Creation date / time. + "inference_name": "str", # Optional. + Internally used name. + "inference_version": "str", # Optional. + Internally used version. + "is_foundational": bool, # Optional. True if + it is a foundational model provided by do. + "metadata": {}, # Optional. Additional meta + data. + "name": "str", # Optional. Name of the + model. + "parent_uuid": "str", # Optional. Unique id + of the model, this model is based on. + "provider": "MODEL_PROVIDER_DIGITALOCEAN", # + Optional. Default value is "MODEL_PROVIDER_DIGITALOCEAN". Known + values are: "MODEL_PROVIDER_DIGITALOCEAN" and + "MODEL_PROVIDER_ANTHROPIC". + "updated_at": "2020-02-20 00:00:00", # + Optional. Last modified. + "upload_complete": bool, # Optional. Model + has been fully uploaded. + "url": "str", # Optional. Download url. + "uuid": "str", # Optional. Unique id. + "version": { + "major": 0, # Optional. Major + version number. + "minor": 0, # Optional. Minor + version number. + "patch": 0 # Optional. Patch version + number. + } + }, + "name": "str", # Optional. Name of the agent + template. + "temperature": 0.0, # Optional. The temperature + setting for the agent template. + "top_p": 0.0, # Optional. The top_p setting for the + agent template. + "updated_at": "2020-02-20 00:00:00", # Optional. The + agent template's last updated date. + "uuid": "str" # Optional. Unique id. + }, + "top_p": 0.0, # Optional. Defines the cumulative probability + threshold for word selection, specified as a number between 0 and 1. + Higher values allow for more diverse outputs, while lower values ensure + focused and coherent responses. + "updated_at": "2020-02-20 00:00:00", # Optional. Last + modified. + "url": "str", # Optional. Access your agent under this url. + "user_id": "str", # Optional. Id of user that created the + agent. + "uuid": "str" # Optional. Unique agent id. + } + ], + "links": { + "pages": { + "first": "str", # Optional. First page. + "last": "str", # Optional. Last page. + "next": "str", # Optional. Next page. + "previous": "str" # Optional. Previous page. + } + }, + "meta": { + "page": 0, # Optional. The current page. + "pages": 0, # Optional. Total number of pages. + "total": 0 # Optional. Total amount of items over all pages. } } # response body for status code(s): 404 @@ -175434,29 +175604,15 @@ def create_agent( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = 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: - if body is not None: - _json = body - else: - _json = None - - _request = build_genai_create_agent_request( - content_type=content_type, - json=_json, - content=_content, + _request = build_genai_list_agents_request( + only_deployed=only_deployed, + page=page, + per_page=per_page, headers=_headers, params=_params, ) @@ -175919,6 +176075,129 @@ def create_agent_api_key( return cast(JSON, deserialized) # type: ignore + @distributed_trace + def delete_agent_api_key( + self, agent_uuid: str, api_key_uuid: str, **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Delete API Key for an Agent. + + To delete an API key for an agent, send a DELETE request to + ``/v2/gen-ai/agents/{agent_uuid}/api_keys/{api_key_uuid}``. + + :param agent_uuid: A unique identifier for your agent. Required. + :type agent_uuid: str + :param api_key_uuid: API key for an agent. Required. + :type api_key_uuid: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "api_key_info": { + "created_at": "2020-02-20 00:00:00", # Optional. Creation date. + "created_by": "str", # Optional. Created by. + "deleted_at": "2020-02-20 00:00:00", # Optional. Deleted date. + "name": "str", # Optional. Name. + "secret_key": "str", # Optional. Agent API Key Info. + "uuid": "str" # Optional. Uuid. + } + } + # 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_genai_delete_agent_api_key_request( + agent_uuid=agent_uuid, + api_key_uuid=api_key_uuid, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + @overload def update_agent_api_key( self, @@ -176191,129 +176470,6 @@ def update_agent_api_key( return cast(JSON, deserialized) # type: ignore - @distributed_trace - def delete_agent_api_key( - self, agent_uuid: str, api_key_uuid: str, **kwargs: Any - ) -> JSON: - # pylint: disable=line-too-long - """Delete API Key for an Agent. - - To delete an API key for an agent, send a DELETE request to - ``/v2/gen-ai/agents/{agent_uuid}/api_keys/{api_key_uuid}``. - - :param agent_uuid: A unique identifier for your agent. Required. - :type agent_uuid: str - :param api_key_uuid: API key for an agent. Required. - :type api_key_uuid: str - :return: JSON object - :rtype: JSON - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "api_key_info": { - "created_at": "2020-02-20 00:00:00", # Optional. Creation date. - "created_by": "str", # Optional. Created by. - "deleted_at": "2020-02-20 00:00:00", # Optional. Deleted date. - "name": "str", # Optional. Name. - "secret_key": "str", # Optional. Agent API Key Info. - "uuid": "str" # Optional. Uuid. - } - } - # 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_genai_delete_agent_api_key_request( - agent_uuid=agent_uuid, - api_key_uuid=api_key_uuid, - 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 regenerate_agent_api_key( self, agent_uuid: str, api_key_uuid: str, **kwargs: Any @@ -177759,21 +177915,31 @@ def attach_agent_function( return cast(JSON, deserialized) # type: ignore - @distributed_trace - def detach_agent_function( - self, agent_uuid: str, function_uuid: str, **kwargs: Any + @overload + def update_agent_function( + self, + agent_uuid: str, + function_uuid: str, + body: Optional[JSON] = None, + *, + content_type: str = "application/json", + **kwargs: Any, ) -> JSON: # pylint: disable=line-too-long - """Delete Function Route for an Agent. + """Update Function Route for an Agent. - To delete a function route from an agent, send a DELETE request to + To update the function route, send a PUT request to ``/v2/gen-ai/agents/{agent_uuid}/functions/{function_uuid}``. - :param agent_uuid: The id of the agent the function route belongs to. Required. + :param agent_uuid: Agent id. Required. :type agent_uuid: str - :param function_uuid: The function route to be destroyed. This does not destroy the function - itself. Required. + :param function_uuid: Function id. Required. :type function_uuid: str + :param body: Default value is None. + :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: @@ -177781,6 +177947,22 @@ def detach_agent_function( Example: .. code-block:: python + # JSON input template you can fill out and use as your body input. + body = { + "agent_uuid": "str", # Optional. Agent id. + "description": "str", # Optional. Funciton description. + "faas_name": "str", # Optional. The name of the function in the DigitalOcean + functions platform. + "faas_namespace": "str", # Optional. The namespace of the function in the + DigitalOcean functions platform. + "function_name": "str", # Optional. Function name. + "function_uuid": "str", # Optional. Function id. + "input_schema": {}, # Optional. Describe the input schema for the function + so the agent may call it. + "output_schema": {} # Optional. Describe the output schema for the function + so the agent handle its response. + } + # response body for status code(s): 200 response == { "agent": { @@ -178152,91 +178334,13 @@ def detach_agent_function( 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_genai_detach_agent_function_request( - agent_uuid=agent_uuid, - function_uuid=function_uuid, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = ( - self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 404]: - if _stream: - response.read() # Load the body in memory and close the socket - map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore - raise HttpResponseError(response=response) - - response_headers = {} - if response.status_code == 200: - response_headers["ratelimit-limit"] = self._deserialize( - "int", response.headers.get("ratelimit-limit") - ) - response_headers["ratelimit-remaining"] = self._deserialize( - "int", response.headers.get("ratelimit-remaining") - ) - response_headers["ratelimit-reset"] = self._deserialize( - "int", response.headers.get("ratelimit-reset") - ) - - if response.content: - deserialized = response.json() - else: - deserialized = None - - if response.status_code == 404: - response_headers["ratelimit-limit"] = self._deserialize( - "int", response.headers.get("ratelimit-limit") - ) - response_headers["ratelimit-remaining"] = self._deserialize( - "int", response.headers.get("ratelimit-remaining") - ) - response_headers["ratelimit-reset"] = self._deserialize( - "int", response.headers.get("ratelimit-reset") - ) - - if response.content: - deserialized = response.json() - else: - deserialized = None - - if cls: - return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore - - return cast(JSON, deserialized) # type: ignore @overload def update_agent_function( self, agent_uuid: str, function_uuid: str, - body: Optional[JSON] = None, + body: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any, @@ -178252,8 +178356,8 @@ def update_agent_function( :param function_uuid: Function id. Required. :type function_uuid: str :param body: Default value is None. - :type body: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + :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 @@ -178263,22 +178367,6 @@ def update_agent_function( Example: .. code-block:: python - # JSON input template you can fill out and use as your body input. - body = { - "agent_uuid": "str", # Optional. Agent id. - "description": "str", # Optional. Funciton description. - "faas_name": "str", # Optional. The name of the function in the DigitalOcean - functions platform. - "faas_namespace": "str", # Optional. The namespace of the function in the - DigitalOcean functions platform. - "function_name": "str", # Optional. Function name. - "function_uuid": "str", # Optional. Function id. - "input_schema": {}, # Optional. Describe the input schema for the function - so the agent may call it. - "output_schema": {} # Optional. Describe the output schema for the function - so the agent handle its response. - } - # response body for status code(s): 200 response == { "agent": { @@ -178651,14 +178739,12 @@ def update_agent_function( } """ - @overload + @distributed_trace def update_agent_function( self, agent_uuid: str, function_uuid: str, - body: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", + body: Optional[Union[JSON, IO[bytes]]] = None, **kwargs: Any, ) -> JSON: # pylint: disable=line-too-long @@ -178671,11 +178757,8 @@ def update_agent_function( :type agent_uuid: str :param function_uuid: Function id. Required. :type function_uuid: str - :param body: Default value is None. - :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 + :param body: Is either a JSON type or a IO[bytes] type. Default value is None. + :type body: JSON or IO[bytes] :return: JSON object :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: @@ -178683,6 +178766,22 @@ def update_agent_function( Example: .. code-block:: python + # JSON input template you can fill out and use as your body input. + body = { + "agent_uuid": "str", # Optional. Agent id. + "description": "str", # Optional. Funciton description. + "faas_name": "str", # Optional. The name of the function in the DigitalOcean + functions platform. + "faas_namespace": "str", # Optional. The namespace of the function in the + DigitalOcean functions platform. + "function_name": "str", # Optional. Function name. + "function_uuid": "str", # Optional. Function id. + "input_schema": {}, # Optional. Describe the input schema for the function + so the agent may call it. + "output_schema": {} # Optional. Describe the output schema for the function + so the agent handle its response. + } + # response body for status code(s): 200 response == { "agent": { @@ -179054,27 +179153,117 @@ def update_agent_function( 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: + if body is not None: + _json = body + else: + _json = None + + _request = build_genai_update_agent_function_request( + agent_uuid=agent_uuid, + function_uuid=function_uuid, + 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, 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 update_agent_function( - self, - agent_uuid: str, - function_uuid: str, - body: Optional[Union[JSON, IO[bytes]]] = None, - **kwargs: Any, + def detach_agent_function( + self, agent_uuid: str, function_uuid: str, **kwargs: Any ) -> JSON: # pylint: disable=line-too-long - """Update Function Route for an Agent. + """Delete Function Route for an Agent. - To update the function route, send a PUT request to + To delete a function route from an agent, send a DELETE request to ``/v2/gen-ai/agents/{agent_uuid}/functions/{function_uuid}``. - :param agent_uuid: Agent id. Required. + :param agent_uuid: The id of the agent the function route belongs to. Required. :type agent_uuid: str - :param function_uuid: Function id. Required. + :param function_uuid: The function route to be destroyed. This does not destroy the function + itself. Required. :type function_uuid: str - :param body: Is either a JSON type or a IO[bytes] type. Default value is None. - :type body: JSON or IO[bytes] :return: JSON object :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: @@ -179082,22 +179271,6 @@ def update_agent_function( Example: .. code-block:: python - # JSON input template you can fill out and use as your body input. - body = { - "agent_uuid": "str", # Optional. Agent id. - "description": "str", # Optional. Funciton description. - "faas_name": "str", # Optional. The name of the function in the DigitalOcean - functions platform. - "faas_namespace": "str", # Optional. The namespace of the function in the - DigitalOcean functions platform. - "function_name": "str", # Optional. Function name. - "function_uuid": "str", # Optional. Function id. - "input_schema": {}, # Optional. Describe the input schema for the function - so the agent may call it. - "output_schema": {} # Optional. Describe the output schema for the function - so the agent handle its response. - } - # response body for status code(s): 200 response == { "agent": { @@ -179482,31 +179655,14 @@ def update_agent_function( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = 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: - if body is not None: - _json = body - else: - _json = None - - _request = build_genai_update_agent_function_request( + _request = build_genai_detach_agent_function_request( agent_uuid=agent_uuid, function_uuid=function_uuid, - content_type=content_type, - json=_json, - content=_content, headers=_headers, params=_params, ) @@ -181992,6 +182148,8 @@ def update_agent( # JSON input template you can fill out and use as your body input. body = { + "anthropic_key_uuid": "str", # Optional. Optional anthropic key uuid for use + with anthropic models. "description": "str", # Optional. Agent description. "instruction": "str", # Optional. Agent instruction. Instructions help your agent to perform its job effectively. See `Write Effective Agent Instructions @@ -182814,6 +182972,8 @@ def update_agent( # JSON input template you can fill out and use as your body input. body = { + "anthropic_key_uuid": "str", # Optional. Optional anthropic key uuid for use + with anthropic models. "description": "str", # Optional. Agent description. "instruction": "str", # Optional. Agent instruction. Instructions help your agent to perform its job effectively. See `Write Effective Agent Instructions @@ -185125,6 +185285,1426 @@ def update_agent_deployment_visibility( return cast(JSON, deserialized) # type: ignore + @distributed_trace + def list_anthropic_api_keys( + self, + *, + page: Optional[int] = None, + per_page: Optional[int] = None, + **kwargs: Any, + ) -> JSON: + # pylint: disable=line-too-long + """List Anthropic API Keys. + + To list all Anthropic API keys, send a GET request to ``/v2/gen-ai/anthropic/keys``. + + :keyword page: Page number. Default value is None. + :paramtype page: int + :keyword per_page: Items per page. Default value is None. + :paramtype per_page: int + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "api_key_infos": [ + { + "created_at": "2020-02-20 00:00:00", # Optional. Key + creation date. + "created_by": "str", # Optional. Created by user id from DO. + "deleted_at": "2020-02-20 00:00:00", # Optional. Key deleted + date. + "name": "str", # Optional. Name. + "updated_at": "2020-02-20 00:00:00", # Optional. Key last + updated date. + "uuid": "str" # Optional. Uuid. + } + ], + "links": { + "pages": { + "first": "str", # Optional. First page. + "last": "str", # Optional. Last page. + "next": "str", # Optional. Next page. + "previous": "str" # Optional. Previous page. + } + }, + "meta": { + "page": 0, # Optional. The current page. + "pages": 0, # Optional. Total number of pages. + "total": 0 # Optional. Total amount of items over all pages. + } + } + # 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_genai_list_anthropic_api_keys_request( + page=page, + per_page=per_page, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @overload + def create_anthropic_api_key( + self, + body: Optional[JSON] = None, + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> JSON: + # pylint: disable=line-too-long + """Create Anthropic API Key. + + To create an Anthropic API key, send a POST request to ``/v2/gen-ai/anthropic/keys``. + + :param body: Default value is None. + :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 = { + "api_key": "str", # Optional. Anthropic API key. + "name": "str" # Optional. Name of the key. + } + + # response body for status code(s): 200 + response == { + "api_key_info": { + "created_at": "2020-02-20 00:00:00", # Optional. Key creation date. + "created_by": "str", # Optional. Created by user id from DO. + "deleted_at": "2020-02-20 00:00:00", # Optional. Key deleted date. + "name": "str", # Optional. Name. + "updated_at": "2020-02-20 00:00:00", # Optional. Key last updated + date. + "uuid": "str" # Optional. Uuid. + } + } + # 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. + } + """ + + @overload + def create_anthropic_api_key( + self, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> JSON: + # pylint: disable=line-too-long + """Create Anthropic API Key. + + To create an Anthropic API key, send a POST request to ``/v2/gen-ai/anthropic/keys``. + + :param body: Default value is None. + :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 == { + "api_key_info": { + "created_at": "2020-02-20 00:00:00", # Optional. Key creation date. + "created_by": "str", # Optional. Created by user id from DO. + "deleted_at": "2020-02-20 00:00:00", # Optional. Key deleted date. + "name": "str", # Optional. Name. + "updated_at": "2020-02-20 00:00:00", # Optional. Key last updated + date. + "uuid": "str" # Optional. Uuid. + } + } + # 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. + } + """ + + @distributed_trace + def create_anthropic_api_key( + self, body: Optional[Union[JSON, IO[bytes]]] = None, **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Create Anthropic API Key. + + To create an Anthropic API key, send a POST request to ``/v2/gen-ai/anthropic/keys``. + + :param body: Is either a JSON type or a IO[bytes] type. Default value is None. + :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 = { + "api_key": "str", # Optional. Anthropic API key. + "name": "str" # Optional. Name of the key. + } + + # response body for status code(s): 200 + response == { + "api_key_info": { + "created_at": "2020-02-20 00:00:00", # Optional. Key creation date. + "created_by": "str", # Optional. Created by user id from DO. + "deleted_at": "2020-02-20 00:00:00", # Optional. Key deleted date. + "name": "str", # Optional. Name. + "updated_at": "2020-02-20 00:00:00", # Optional. Key last updated + date. + "uuid": "str" # Optional. Uuid. + } + } + # 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 = 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: + if body is not None: + _json = body + else: + _json = None + + _request = build_genai_create_anthropic_api_key_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, 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 delete_anthropic_api_key(self, api_key_uuid: str, **kwargs: Any) -> JSON: + # pylint: disable=line-too-long + """Delete Anthropic API Key. + + To delete an Anthropic API key, send a DELETE request to + ``/v2/gen-ai/anthropic/keys/{api_key_uuid}``. + + :param api_key_uuid: API key ID. Required. + :type api_key_uuid: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "api_key_info": { + "created_at": "2020-02-20 00:00:00", # Optional. Key creation date. + "created_by": "str", # Optional. Created by user id from DO. + "deleted_at": "2020-02-20 00:00:00", # Optional. Key deleted date. + "name": "str", # Optional. Name. + "updated_at": "2020-02-20 00:00:00", # Optional. Key last updated + date. + "uuid": "str" # Optional. Uuid. + } + } + # 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_genai_delete_anthropic_api_key_request( + api_key_uuid=api_key_uuid, + 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_anthropic_api_key(self, api_key_uuid: str, **kwargs: Any) -> JSON: + # pylint: disable=line-too-long + """Get Anthropic API Key. + + To retrieve details of an Anthropic API key, send a GET request to + ``/v2/gen-ai/anthropic/keys/{api_key_uuid}``. + + :param api_key_uuid: API key ID. Required. + :type api_key_uuid: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "api_key_info": { + "created_at": "2020-02-20 00:00:00", # Optional. Key creation date. + "created_by": "str", # Optional. Created by user id from DO. + "deleted_at": "2020-02-20 00:00:00", # Optional. Key deleted date. + "name": "str", # Optional. Name. + "updated_at": "2020-02-20 00:00:00", # Optional. Key last updated + date. + "uuid": "str" # Optional. Uuid. + } + } + # 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_genai_get_anthropic_api_key_request( + api_key_uuid=api_key_uuid, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @overload + def update_anthropic_api_key( + self, + api_key_uuid: str, + body: Optional[JSON] = None, + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> JSON: + # pylint: disable=line-too-long + """Update Anthropic API Key. + + To update an Anthropic API key, send a PUT request to + ``/v2/gen-ai/anthropic/keys/{api_key_uuid}``. + + :param api_key_uuid: API key ID. Required. + :type api_key_uuid: str + :param body: Default value is None. + :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 = { + "api_key": "str", # Optional. Anthropic API key. + "api_key_uuid": "str", # Optional. API key ID. + "name": "str" # Optional. Name of the key. + } + + # response body for status code(s): 200 + response == { + "api_key_info": { + "created_at": "2020-02-20 00:00:00", # Optional. Key creation date. + "created_by": "str", # Optional. Created by user id from DO. + "deleted_at": "2020-02-20 00:00:00", # Optional. Key deleted date. + "name": "str", # Optional. Name. + "updated_at": "2020-02-20 00:00:00", # Optional. Key last updated + date. + "uuid": "str" # Optional. Uuid. + } + } + # 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. + } + """ + + @overload + def update_anthropic_api_key( + self, + api_key_uuid: str, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> JSON: + # pylint: disable=line-too-long + """Update Anthropic API Key. + + To update an Anthropic API key, send a PUT request to + ``/v2/gen-ai/anthropic/keys/{api_key_uuid}``. + + :param api_key_uuid: API key ID. Required. + :type api_key_uuid: str + :param body: Default value is None. + :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 == { + "api_key_info": { + "created_at": "2020-02-20 00:00:00", # Optional. Key creation date. + "created_by": "str", # Optional. Created by user id from DO. + "deleted_at": "2020-02-20 00:00:00", # Optional. Key deleted date. + "name": "str", # Optional. Name. + "updated_at": "2020-02-20 00:00:00", # Optional. Key last updated + date. + "uuid": "str" # Optional. Uuid. + } + } + # 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. + } + """ + + @distributed_trace + def update_anthropic_api_key( + self, + api_key_uuid: str, + body: Optional[Union[JSON, IO[bytes]]] = None, + **kwargs: Any, + ) -> JSON: + # pylint: disable=line-too-long + """Update Anthropic API Key. + + To update an Anthropic API key, send a PUT request to + ``/v2/gen-ai/anthropic/keys/{api_key_uuid}``. + + :param api_key_uuid: API key ID. Required. + :type api_key_uuid: str + :param body: Is either a JSON type or a IO[bytes] type. Default value is None. + :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 = { + "api_key": "str", # Optional. Anthropic API key. + "api_key_uuid": "str", # Optional. API key ID. + "name": "str" # Optional. Name of the key. + } + + # response body for status code(s): 200 + response == { + "api_key_info": { + "created_at": "2020-02-20 00:00:00", # Optional. Key creation date. + "created_by": "str", # Optional. Created by user id from DO. + "deleted_at": "2020-02-20 00:00:00", # Optional. Key deleted date. + "name": "str", # Optional. Name. + "updated_at": "2020-02-20 00:00:00", # Optional. Key last updated + date. + "uuid": "str" # Optional. Uuid. + } + } + # 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 = 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: + if body is not None: + _json = body + else: + _json = None + + _request = build_genai_update_anthropic_api_key_request( + api_key_uuid=api_key_uuid, + 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, 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 list_agents_by_anthropic_key( + self, + uuid: str, + *, + page: Optional[int] = None, + per_page: Optional[int] = None, + **kwargs: Any, + ) -> JSON: + # pylint: disable=line-too-long + """List agents by Anthropic key. + + List Agents by Anthropic Key. + + :param uuid: Unique ID of Anthropic key. Required. + :type uuid: str + :keyword page: Page number. Default value is None. + :paramtype page: int + :keyword per_page: Items per page. Default value is None. + :paramtype per_page: int + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "agents": [ + { + "anthropic_api_key": { + "created_at": "2020-02-20 00:00:00", # Optional. Key + creation date. + "created_by": "str", # Optional. Created by user id + from DO. + "deleted_at": "2020-02-20 00:00:00", # Optional. Key + deleted date. + "name": "str", # Optional. Name. + "updated_at": "2020-02-20 00:00:00", # Optional. Key + last updated date. + "uuid": "str" # Optional. Uuid. + }, + "api_key_infos": [ + { + "created_at": "2020-02-20 00:00:00", # + Optional. Creation date. + "created_by": "str", # Optional. Created by. + "deleted_at": "2020-02-20 00:00:00", # + Optional. Deleted date. + "name": "str", # Optional. Name. + "secret_key": "str", # Optional. Api key + infos. + "uuid": "str" # Optional. Uuid. + } + ], + "api_keys": [ + { + "api_key": "str" # Optional. Api key. + } + ], + "chatbot": { + "button_background_color": "str", # Optional. A + Chatbot. + "logo": "str", # Optional. A Chatbot. + "name": "str", # Optional. Name of chatbot. + "primary_color": "str", # Optional. A Chatbot. + "secondary_color": "str", # Optional. A Chatbot. + "starting_message": "str" # Optional. A Chatbot. + }, + "chatbot_identifiers": [ + { + "agent_chatbot_identifier": "str" # + Optional. Agent chatbot identifier. + } + ], + "child_agents": [ + ... + ], + "created_at": "2020-02-20 00:00:00", # Optional. Creation + date / time. + "deployment": { + "created_at": "2020-02-20 00:00:00", # Optional. + Creation date / time. + "name": "str", # Optional. Name. + "status": "STATUS_UNKNOWN", # Optional. Default + value is "STATUS_UNKNOWN". Known values are: "STATUS_UNKNOWN", + "STATUS_WAITING_FOR_DEPLOYMENT", "STATUS_DEPLOYING", + "STATUS_RUNNING", "STATUS_FAILED", "STATUS_WAITING_FOR_UNDEPLOYMENT", + "STATUS_UNDEPLOYING", "STATUS_UNDEPLOYMENT_FAILED", and + "STATUS_DELETED". + "updated_at": "2020-02-20 00:00:00", # Optional. + Last modified. + "url": "str", # Optional. Access your deployed agent + here. + "uuid": "str", # Optional. Unique id. + "visibility": "VISIBILITY_UNKNOWN" # Optional. + Default value is "VISIBILITY_UNKNOWN". * VISIBILITY_UNKNOWN: The + status of the deployment is unknown * VISIBILITY_DISABLED: The + deployment is disabled and will no longer service requests * + VISIBILITY_PLAYGROUND: Deprecated: No longer a valid state * + VISIBILITY_PUBLIC: The deployment is public and will service requests + from the public internet * VISIBILITY_PRIVATE: The deployment is + private and will only service requests from other agents, or through + API keys. Known values are: "VISIBILITY_UNKNOWN", + "VISIBILITY_DISABLED", "VISIBILITY_PLAYGROUND", "VISIBILITY_PUBLIC", + and "VISIBILITY_PRIVATE". + }, + "description": "str", # Optional. Description of agent. + "functions": [ + { + "api_key": "str", # Optional. Api key. + "created_at": "2020-02-20 00:00:00", # + Optional. Creation date / time. + "description": "str", # Optional. Agent + description. + "faas_name": "str", # Optional. + "faas_namespace": "str", # Optional. + "input_schema": {}, # Optional. Any object. + "name": "str", # Optional. Name. + "output_schema": {}, # Optional. Any object. + "updated_at": "2020-02-20 00:00:00", # + Optional. Last modified. + "url": "str", # Optional. Download your + agent here. + "uuid": "str" # Optional. Unique id. + } + ], + "guardrails": [ + { + "agent_uuid": "str", # Optional. The + guardrails the agent is attached to. + "created_at": "2020-02-20 00:00:00", # + Optional. The guardrails the agent is attached to. + "default_response": "str", # Optional. The + guardrails the agent is attached to. + "description": "str", # Optional. The + guardrails the agent is attached to. + "guardrail_uuid": "str", # Optional. The + guardrails the agent is attached to. + "is_attached": bool, # Optional. The + guardrails the agent is attached to. + "is_default": bool, # Optional. The + guardrails the agent is attached to. + "metadata": {}, # Optional. Any object. + "name": "str", # Optional. The guardrails + the agent is attached to. + "priority": 0, # Optional. The guardrails + the agent is attached to. + "type": "GUARDRAIL_TYPE_UNKNOWN", # + Optional. Default value is "GUARDRAIL_TYPE_UNKNOWN". Known values + are: "GUARDRAIL_TYPE_UNKNOWN", "GUARDRAIL_TYPE_JAILBREAK", + "GUARDRAIL_TYPE_SENSITIVE_DATA", and + "GUARDRAIL_TYPE_CONTENT_MODERATION". + "updated_at": "2020-02-20 00:00:00", # + Optional. The guardrails the agent is attached to. + "uuid": "str" # Optional. The guardrails the + agent is attached to. + } + ], + "if_case": "str", # Optional. + "instruction": "str", # Optional. Agent instruction. + Instructions help your agent to perform its job effectively. See `Write + Effective Agent Instructions + `_ + for best practices. + "k": 0, # Optional. + "knowledge_bases": [ + { + "added_to_agent_at": "2020-02-20 00:00:00", + # Optional. Time when the knowledge base was added to the agent. + "created_at": "2020-02-20 00:00:00", # + Optional. Creation date / time. + "database_id": "str", # Optional. Knowledge + bases. + "embedding_model_uuid": "str", # Optional. + Knowledge bases. + "is_public": bool, # Optional. Whether the + knowledge base is public or not. + "last_indexing_job": { + "completed_datasources": 0, # + Optional. Number of datasources indexed completed. + "created_at": "2020-02-20 00:00:00", + # Optional. Creation date / time. + "data_source_uuids": [ + "str" # Optional. + IndexingJob description. + ], + "finished_at": "2020-02-20 00:00:00", + # Optional. IndexingJob description. + "knowledge_base_uuid": "str", # + Optional. Knowledge base id. + "phase": "BATCH_JOB_PHASE_UNKNOWN", + # Optional. Default value is "BATCH_JOB_PHASE_UNKNOWN". Known + values are: "BATCH_JOB_PHASE_UNKNOWN", + "BATCH_JOB_PHASE_PENDING", "BATCH_JOB_PHASE_RUNNING", + "BATCH_JOB_PHASE_SUCCEEDED", "BATCH_JOB_PHASE_FAILED", and + "BATCH_JOB_PHASE_ERROR". + "started_at": "2020-02-20 00:00:00", + # Optional. IndexingJob description. + "tokens": 0, # Optional. Number of + tokens. + "total_datasources": 0, # Optional. + Number of datasources being indexed. + "updated_at": "2020-02-20 00:00:00", + # Optional. Last modified. + "uuid": "str" # Optional. Unique id. + }, + "name": "str", # Optional. Name of knowledge + base. + "project_id": "str", # Optional. Knowledge + bases. + "region": "str", # Optional. Region code. + "tags": [ + "str" # Optional. Tags to organize + related resources. + ], + "updated_at": "2020-02-20 00:00:00", # + Optional. Last modified. + "user_id": "str", # Optional. Id of user + that created the knowledge base. + "uuid": "str" # Optional. Unique id for + knowledge base. + } + ], + "max_tokens": 0, # Optional. + "model": { + "agreement": { + "description": "str", # Optional. Agreement + Description. + "name": "str", # Optional. Agreement + Description. + "url": "str", # Optional. Agreement + Description. + "uuid": "str" # Optional. Agreement + Description. + }, + "created_at": "2020-02-20 00:00:00", # Optional. + Creation date / time. + "inference_name": "str", # Optional. Internally used + name. + "inference_version": "str", # Optional. Internally + used version. + "is_foundational": bool, # Optional. True if it is a + foundational model provided by do. + "metadata": {}, # Optional. Additional meta data. + "name": "str", # Optional. Name of the model. + "parent_uuid": "str", # Optional. Unique id of the + model, this model is based on. + "provider": "MODEL_PROVIDER_DIGITALOCEAN", # + Optional. Default value is "MODEL_PROVIDER_DIGITALOCEAN". Known + values are: "MODEL_PROVIDER_DIGITALOCEAN" and + "MODEL_PROVIDER_ANTHROPIC". + "updated_at": "2020-02-20 00:00:00", # Optional. + Last modified. + "upload_complete": bool, # Optional. Model has been + fully uploaded. + "url": "str", # Optional. Download url. + "uuid": "str", # Optional. Unique id. + "version": { + "major": 0, # Optional. Major version + number. + "minor": 0, # Optional. Minor version + number. + "patch": 0 # Optional. Patch version number. + } + }, + "name": "str", # Optional. Agent name. + "parent_agents": [ + ... + ], + "project_id": "str", # Optional. + "region": "str", # Optional. Region code. + "route_created_at": "2020-02-20 00:00:00", # Optional. + Creation of route date / time. + "route_created_by": "str", # Optional. + "route_name": "str", # Optional. Route name. + "route_uuid": "str", # Optional. + "tags": [ + "str" # Optional. Agent tag to organize related + resources. + ], + "temperature": 0.0, # Optional. + "template": { + "created_at": "2020-02-20 00:00:00", # Optional. The + agent template's creation date. + "description": "str", # Optional. Description of the + agent template. + "instruction": "str", # Optional. Instructions for + the agent template. + "k": 0, # Optional. The 'k' value for the agent + template. + "knowledge_bases": [ + { + "added_to_agent_at": "2020-02-20 + 00:00:00", # Optional. Time when the knowledge base was + added to the agent. + "created_at": "2020-02-20 00:00:00", + # Optional. Creation date / time. + "database_id": "str", # Optional. + List of knowledge bases associated with the agent template. + "embedding_model_uuid": "str", # + Optional. List of knowledge bases associated with the agent + template. + "is_public": bool, # Optional. + Whether the knowledge base is public or not. + "last_indexing_job": { + "completed_datasources": 0, + # Optional. Number of datasources indexed completed. + "created_at": "2020-02-20 + 00:00:00", # Optional. Creation date / time. + "data_source_uuids": [ + "str" # Optional. + IndexingJob description. + ], + "finished_at": "2020-02-20 + 00:00:00", # Optional. IndexingJob description. + "knowledge_base_uuid": "str", + # Optional. Knowledge base id. + "phase": + "BATCH_JOB_PHASE_UNKNOWN", # Optional. Default value is + "BATCH_JOB_PHASE_UNKNOWN". Known values are: + "BATCH_JOB_PHASE_UNKNOWN", "BATCH_JOB_PHASE_PENDING", + "BATCH_JOB_PHASE_RUNNING", "BATCH_JOB_PHASE_SUCCEEDED", + "BATCH_JOB_PHASE_FAILED", and "BATCH_JOB_PHASE_ERROR". + "started_at": "2020-02-20 + 00:00:00", # Optional. IndexingJob description. + "tokens": 0, # Optional. + Number of tokens. + "total_datasources": 0, # + Optional. Number of datasources being indexed. + "updated_at": "2020-02-20 + 00:00:00", # Optional. Last modified. + "uuid": "str" # Optional. + Unique id. + }, + "name": "str", # Optional. Name of + knowledge base. + "project_id": "str", # Optional. + List of knowledge bases associated with the agent template. + "region": "str", # Optional. Region + code. + "tags": [ + "str" # Optional. Tags to + organize related resources. + ], + "updated_at": "2020-02-20 00:00:00", + # Optional. Last modified. + "user_id": "str", # Optional. Id of + user that created the knowledge base. + "uuid": "str" # Optional. Unique id + for knowledge base. + } + ], + "max_tokens": 0, # Optional. The max_tokens setting + for the agent template. + "model": { + "agreement": { + "description": "str", # Optional. + Agreement Description. + "name": "str", # Optional. Agreement + Description. + "url": "str", # Optional. Agreement + Description. + "uuid": "str" # Optional. Agreement + Description. + }, + "created_at": "2020-02-20 00:00:00", # + Optional. Creation date / time. + "inference_name": "str", # Optional. + Internally used name. + "inference_version": "str", # Optional. + Internally used version. + "is_foundational": bool, # Optional. True if + it is a foundational model provided by do. + "metadata": {}, # Optional. Additional meta + data. + "name": "str", # Optional. Name of the + model. + "parent_uuid": "str", # Optional. Unique id + of the model, this model is based on. + "provider": "MODEL_PROVIDER_DIGITALOCEAN", # + Optional. Default value is "MODEL_PROVIDER_DIGITALOCEAN". Known + values are: "MODEL_PROVIDER_DIGITALOCEAN" and + "MODEL_PROVIDER_ANTHROPIC". + "updated_at": "2020-02-20 00:00:00", # + Optional. Last modified. + "upload_complete": bool, # Optional. Model + has been fully uploaded. + "url": "str", # Optional. Download url. + "uuid": "str", # Optional. Unique id. + "version": { + "major": 0, # Optional. Major + version number. + "minor": 0, # Optional. Minor + version number. + "patch": 0 # Optional. Patch version + number. + } + }, + "name": "str", # Optional. Name of the agent + template. + "temperature": 0.0, # Optional. The temperature + setting for the agent template. + "top_p": 0.0, # Optional. The top_p setting for the + agent template. + "updated_at": "2020-02-20 00:00:00", # Optional. The + agent template's last updated date. + "uuid": "str" # Optional. Unique id. + }, + "top_p": 0.0, # Optional. + "updated_at": "2020-02-20 00:00:00", # Optional. Last + modified. + "url": "str", # Optional. Access your agent under this url. + "user_id": "str", # Optional. Id of user that created the + agent. + "uuid": "str" # Optional. Unique agent id. + } + ], + "links": { + "pages": { + "first": "str", # Optional. First page. + "last": "str", # Optional. Last page. + "next": "str", # Optional. Next page. + "previous": "str" # Optional. Previous page. + } + }, + "meta": { + "page": 0, # Optional. The current page. + "pages": 0, # Optional. Total number of pages. + "total": 0 # Optional. Total amount of items over all pages. + } + } + # 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_genai_list_agents_by_anthropic_key_request( + uuid=uuid, + page=page, + per_page=per_page, + 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 list_indexing_jobs( self, @@ -186777,6 +188357,198 @@ def create_knowledge_base( return cast(JSON, deserialized) # type: ignore + @distributed_trace + def list_knowledge_base_data_sources( + self, + knowledge_base_uuid: str, + *, + page: Optional[int] = None, + per_page: Optional[int] = None, + **kwargs: Any, + ) -> JSON: + # pylint: disable=line-too-long + """List Data Sources for a Knowledge Base. + + To list all data sources for a knowledge base, send a GET request to + ``/v2/gen-ai/knowledge_bases/{knowledge_base_uuid}/data_sources``. + + :param knowledge_base_uuid: Knowledge base id. Required. + :type knowledge_base_uuid: str + :keyword page: Page number. Default value is None. + :paramtype page: int + :keyword per_page: Items per page. Default value is None. + :paramtype per_page: int + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "knowledge_base_data_sources": [ + { + "bucket_name": "str", # Optional. Name of storage bucket - + Deprecated, moved to data_source_details. + "created_at": "2020-02-20 00:00:00", # Optional. Creation + date / time. + "file_upload_data_source": { + "original_file_name": "str", # Optional. The + original file name. + "size_in_bytes": "str", # Optional. The size of the + file in bytes. + "stored_object_key": "str" # Optional. The object + key the file was stored as. + }, + "item_path": "str", # Optional. Path of folder or object in + bucket - Deprecated, moved to data_source_details. + "last_indexing_job": { + "completed_datasources": 0, # Optional. Number of + datasources indexed completed. + "created_at": "2020-02-20 00:00:00", # Optional. + Creation date / time. + "data_source_uuids": [ + "str" # Optional. IndexingJob description. + ], + "finished_at": "2020-02-20 00:00:00", # Optional. + IndexingJob description. + "knowledge_base_uuid": "str", # Optional. Knowledge + base id. + "phase": "BATCH_JOB_PHASE_UNKNOWN", # Optional. + Default value is "BATCH_JOB_PHASE_UNKNOWN". Known values are: + "BATCH_JOB_PHASE_UNKNOWN", "BATCH_JOB_PHASE_PENDING", + "BATCH_JOB_PHASE_RUNNING", "BATCH_JOB_PHASE_SUCCEEDED", + "BATCH_JOB_PHASE_FAILED", and "BATCH_JOB_PHASE_ERROR". + "started_at": "2020-02-20 00:00:00", # Optional. + IndexingJob description. + "tokens": 0, # Optional. Number of tokens. + "total_datasources": 0, # Optional. Number of + datasources being indexed. + "updated_at": "2020-02-20 00:00:00", # Optional. + Last modified. + "uuid": "str" # Optional. Unique id. + }, + "region": "str", # Optional. Region code - Deprecated, moved + to data_source_details. + "spaces_data_source": { + "bucket_name": "str", # Optional. Spaces bucket + name. + "item_path": "str", # Optional. Spaces Bucket Data + Source. + "region": "str" # Optional. Region of bucket. + }, + "updated_at": "2020-02-20 00:00:00", # Optional. Last + modified. + "uuid": "str" # Optional. Unique id of knowledge base. + } + ], + "links": { + "pages": { + "first": "str", # Optional. First page. + "last": "str", # Optional. Last page. + "next": "str", # Optional. Next page. + "previous": "str" # Optional. Previous page. + } + }, + "meta": { + "page": 0, # Optional. The current page. + "pages": 0, # Optional. Total number of pages. + "total": 0 # Optional. Total amount of items over all pages. + } + } + # 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_genai_list_knowledge_base_data_sources_request( + knowledge_base_uuid=knowledge_base_uuid, + page=page, + per_page=per_page, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + @overload def create_knowledge_base_data_source( self, @@ -187183,198 +188955,6 @@ def create_knowledge_base_data_source( return cast(JSON, deserialized) # type: ignore - @distributed_trace - def list_knowledge_base_data_sources( - self, - knowledge_base_uuid: str, - *, - page: Optional[int] = None, - per_page: Optional[int] = None, - **kwargs: Any, - ) -> JSON: - # pylint: disable=line-too-long - """List Data Sources for a Knowledge Base. - - To list all data sources for a knowledge base, send a GET request to - ``/v2/gen-ai/knowledge_bases/{knowledge_base_uuid}/data_sources``. - - :param knowledge_base_uuid: Knowledge base id. Required. - :type knowledge_base_uuid: str - :keyword page: Page number. Default value is None. - :paramtype page: int - :keyword per_page: Items per page. Default value is None. - :paramtype per_page: int - :return: JSON object - :rtype: JSON - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "knowledge_base_data_sources": [ - { - "bucket_name": "str", # Optional. Name of storage bucket - - Deprecated, moved to data_source_details. - "created_at": "2020-02-20 00:00:00", # Optional. Creation - date / time. - "file_upload_data_source": { - "original_file_name": "str", # Optional. The - original file name. - "size_in_bytes": "str", # Optional. The size of the - file in bytes. - "stored_object_key": "str" # Optional. The object - key the file was stored as. - }, - "item_path": "str", # Optional. Path of folder or object in - bucket - Deprecated, moved to data_source_details. - "last_indexing_job": { - "completed_datasources": 0, # Optional. Number of - datasources indexed completed. - "created_at": "2020-02-20 00:00:00", # Optional. - Creation date / time. - "data_source_uuids": [ - "str" # Optional. IndexingJob description. - ], - "finished_at": "2020-02-20 00:00:00", # Optional. - IndexingJob description. - "knowledge_base_uuid": "str", # Optional. Knowledge - base id. - "phase": "BATCH_JOB_PHASE_UNKNOWN", # Optional. - Default value is "BATCH_JOB_PHASE_UNKNOWN". Known values are: - "BATCH_JOB_PHASE_UNKNOWN", "BATCH_JOB_PHASE_PENDING", - "BATCH_JOB_PHASE_RUNNING", "BATCH_JOB_PHASE_SUCCEEDED", - "BATCH_JOB_PHASE_FAILED", and "BATCH_JOB_PHASE_ERROR". - "started_at": "2020-02-20 00:00:00", # Optional. - IndexingJob description. - "tokens": 0, # Optional. Number of tokens. - "total_datasources": 0, # Optional. Number of - datasources being indexed. - "updated_at": "2020-02-20 00:00:00", # Optional. - Last modified. - "uuid": "str" # Optional. Unique id. - }, - "region": "str", # Optional. Region code - Deprecated, moved - to data_source_details. - "spaces_data_source": { - "bucket_name": "str", # Optional. Spaces bucket - name. - "item_path": "str", # Optional. Spaces Bucket Data - Source. - "region": "str" # Optional. Region of bucket. - }, - "updated_at": "2020-02-20 00:00:00", # Optional. Last - modified. - "uuid": "str" # Optional. Unique id of knowledge base. - } - ], - "links": { - "pages": { - "first": "str", # Optional. First page. - "last": "str", # Optional. Last page. - "next": "str", # Optional. Next page. - "previous": "str" # Optional. Previous page. - } - }, - "meta": { - "page": 0, # Optional. The current page. - "pages": 0, # Optional. Total number of pages. - "total": 0 # Optional. Total amount of items over all pages. - } - } - # 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_genai_list_knowledge_base_data_sources_request( - knowledge_base_uuid=knowledge_base_uuid, - page=page, - per_page=per_page, - 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 delete_knowledge_base_data_source( self, knowledge_base_uuid: str, data_source_uuid: str, **kwargs: Any @@ -187492,166 +189072,6 @@ def delete_knowledge_base_data_source( return cast(JSON, deserialized) # type: ignore - @distributed_trace - def get_knowledge_base(self, uuid: str, **kwargs: Any) -> JSON: - # pylint: disable=line-too-long - """Retrieve Information About an Existing Knowledge Base. - - To retrive information about an existing knowledge base, send a GET request to - ``/v2/gen-ai/knowledge_bases/{uuid}``. - - :param uuid: Knowledge base id. Required. - :type uuid: str - :return: JSON object - :rtype: JSON - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "database_status": "CREATING", # Optional. Default value is "CREATING". - Known values are: "CREATING", "ONLINE", "POWEROFF", "REBUILDING", "REBALANCING", - "DECOMMISSIONED", "FORKING", "MIGRATING", "RESIZING", "RESTORING", "POWERING_ON", - and "UNHEALTHY". - "knowledge_base": { - "added_to_agent_at": "2020-02-20 00:00:00", # Optional. Time when - the knowledge base was added to the agent. - "created_at": "2020-02-20 00:00:00", # Optional. Creation date / - time. - "database_id": "str", # Optional. Knowledgebase Description. - "embedding_model_uuid": "str", # Optional. Knowledgebase - Description. - "is_public": bool, # Optional. Whether the knowledge base is public - or not. - "last_indexing_job": { - "completed_datasources": 0, # Optional. Number of - datasources indexed completed. - "created_at": "2020-02-20 00:00:00", # Optional. Creation - date / time. - "data_source_uuids": [ - "str" # Optional. IndexingJob description. - ], - "finished_at": "2020-02-20 00:00:00", # Optional. - IndexingJob description. - "knowledge_base_uuid": "str", # Optional. Knowledge base id. - "phase": "BATCH_JOB_PHASE_UNKNOWN", # Optional. Default - value is "BATCH_JOB_PHASE_UNKNOWN". Known values are: - "BATCH_JOB_PHASE_UNKNOWN", "BATCH_JOB_PHASE_PENDING", - "BATCH_JOB_PHASE_RUNNING", "BATCH_JOB_PHASE_SUCCEEDED", - "BATCH_JOB_PHASE_FAILED", and "BATCH_JOB_PHASE_ERROR". - "started_at": "2020-02-20 00:00:00", # Optional. IndexingJob - description. - "tokens": 0, # Optional. Number of tokens. - "total_datasources": 0, # Optional. Number of datasources - being indexed. - "updated_at": "2020-02-20 00:00:00", # Optional. Last - modified. - "uuid": "str" # Optional. Unique id. - }, - "name": "str", # Optional. Name of knowledge base. - "project_id": "str", # Optional. Knowledgebase Description. - "region": "str", # Optional. Region code. - "tags": [ - "str" # Optional. Tags to organize related resources. - ], - "updated_at": "2020-02-20 00:00:00", # Optional. Last modified. - "user_id": "str", # Optional. Id of user that created the knowledge - base. - "uuid": "str" # Optional. Unique id for knowledge base. - } - } - # 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_genai_get_knowledge_base_request( - uuid=uuid, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = ( - self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 404]: - if _stream: - response.read() # Load the body in memory and close the socket - map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore - raise HttpResponseError(response=response) - - response_headers = {} - if response.status_code == 200: - response_headers["ratelimit-limit"] = self._deserialize( - "int", response.headers.get("ratelimit-limit") - ) - response_headers["ratelimit-remaining"] = self._deserialize( - "int", response.headers.get("ratelimit-remaining") - ) - response_headers["ratelimit-reset"] = self._deserialize( - "int", response.headers.get("ratelimit-reset") - ) - - if response.content: - deserialized = response.json() - else: - deserialized = None - - if response.status_code == 404: - response_headers["ratelimit-limit"] = self._deserialize( - "int", response.headers.get("ratelimit-limit") - ) - response_headers["ratelimit-remaining"] = self._deserialize( - "int", response.headers.get("ratelimit-remaining") - ) - response_headers["ratelimit-reset"] = self._deserialize( - "int", response.headers.get("ratelimit-reset") - ) - - if response.content: - deserialized = response.json() - else: - deserialized = None - - if cls: - return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore - - return cast(JSON, deserialized) # type: ignore - @overload def update_knowledge_base( self, @@ -188148,6 +189568,166 @@ def delete_knowledge_base(self, uuid: str, **kwargs: Any) -> JSON: return cast(JSON, deserialized) # type: ignore + @distributed_trace + def get_knowledge_base(self, uuid: str, **kwargs: Any) -> JSON: + # pylint: disable=line-too-long + """Retrieve Information About an Existing Knowledge Base. + + To retrive information about an existing knowledge base, send a GET request to + ``/v2/gen-ai/knowledge_bases/{uuid}``. + + :param uuid: Knowledge base id. Required. + :type uuid: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "database_status": "CREATING", # Optional. Default value is "CREATING". + Known values are: "CREATING", "ONLINE", "POWEROFF", "REBUILDING", "REBALANCING", + "DECOMMISSIONED", "FORKING", "MIGRATING", "RESIZING", "RESTORING", "POWERING_ON", + and "UNHEALTHY". + "knowledge_base": { + "added_to_agent_at": "2020-02-20 00:00:00", # Optional. Time when + the knowledge base was added to the agent. + "created_at": "2020-02-20 00:00:00", # Optional. Creation date / + time. + "database_id": "str", # Optional. Knowledgebase Description. + "embedding_model_uuid": "str", # Optional. Knowledgebase + Description. + "is_public": bool, # Optional. Whether the knowledge base is public + or not. + "last_indexing_job": { + "completed_datasources": 0, # Optional. Number of + datasources indexed completed. + "created_at": "2020-02-20 00:00:00", # Optional. Creation + date / time. + "data_source_uuids": [ + "str" # Optional. IndexingJob description. + ], + "finished_at": "2020-02-20 00:00:00", # Optional. + IndexingJob description. + "knowledge_base_uuid": "str", # Optional. Knowledge base id. + "phase": "BATCH_JOB_PHASE_UNKNOWN", # Optional. Default + value is "BATCH_JOB_PHASE_UNKNOWN". Known values are: + "BATCH_JOB_PHASE_UNKNOWN", "BATCH_JOB_PHASE_PENDING", + "BATCH_JOB_PHASE_RUNNING", "BATCH_JOB_PHASE_SUCCEEDED", + "BATCH_JOB_PHASE_FAILED", and "BATCH_JOB_PHASE_ERROR". + "started_at": "2020-02-20 00:00:00", # Optional. IndexingJob + description. + "tokens": 0, # Optional. Number of tokens. + "total_datasources": 0, # Optional. Number of datasources + being indexed. + "updated_at": "2020-02-20 00:00:00", # Optional. Last + modified. + "uuid": "str" # Optional. Unique id. + }, + "name": "str", # Optional. Name of knowledge base. + "project_id": "str", # Optional. Knowledgebase Description. + "region": "str", # Optional. Region code. + "tags": [ + "str" # Optional. Tags to organize related resources. + ], + "updated_at": "2020-02-20 00:00:00", # Optional. Last modified. + "user_id": "str", # Optional. Id of user that created the knowledge + base. + "uuid": "str" # Optional. Unique id for knowledge base. + } + } + # 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_genai_get_knowledge_base_request( + uuid=uuid, + 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 list_models( self,