diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index bd7d5e603e..0292035140 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -1080,6 +1080,16 @@ components: required: true schema: type: string + LLMObsPromptEnvironmentQueryParameter: + description: >- + Optional `DD_ENV` value used to resolve the prompt version deployed to the matching Feature Flags environment. This value is not a Feature Flags environment UUID. Using this parameter additionally requires the `feature_flag_config_read` and `feature_flag_environment_config_read` permissions. This parameter cannot be used with `label`. + example: production + in: query + name: environment + required: false + schema: + minLength: 1 + type: string LLMObsPromptIDPathParameter: description: The customer-provided identifier of the Agent Observability prompt. example: "customer-support-assistant" @@ -1090,7 +1100,7 @@ components: type: string LLMObsPromptLabelQueryParameter: description: >- - **Deprecated.** Optional label of the prompt version to return. Do not use this parameter for new integrations. If omitted, the latest version is returned. If the prompt has no labels, the latest version is returned even when a label is requested. If the prompt has labels but none match the requested label, a 404 response is returned. + **Deprecated.** Optional label of the prompt version to return. Do not use this parameter for new integrations. If omitted, the latest version is returned. If the prompt has no labels, the latest version is returned even when a label is requested. If the prompt has labels but none match the requested label, a 404 response is returned. This parameter cannot be used with `environment`. in: query name: label required: false @@ -167110,11 +167120,13 @@ paths: **Note**: This endpoint is in preview and is subject to change. If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). get: - description: Get the latest version of an Agent Observability prompt by prompt ID. + description: >- + Get an Agent Observability prompt by prompt ID. When `environment` is omitted, this returns the latest version or uses the deprecated `label` behavior and requires `llm_observability_read`. When `environment` is supplied, it must be a nonempty `DD_ENV` value, cannot be combined with `label`, and additionally requires `feature_flag_config_read` and `feature_flag_environment_config_read`. An empty environment or combining it with `label` returns 400, and missing either additional permission returns 403. A missing prompt or deployment returns 404 without falling back to the latest version. An environment resolution failure returns 500. operationId: GetLLMObsPrompt parameters: - $ref: "#/components/parameters/LLMObsPromptIDPathParameter" - $ref: "#/components/parameters/LLMObsPromptLabelQueryParameter" + - $ref: "#/components/parameters/LLMObsPromptEnvironmentQueryParameter" responses: "200": content: @@ -167137,6 +167149,14 @@ paths: schema: $ref: "#/components/schemas/LLMObsPromptSDKResponse" description: OK + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: |- + Bad Request + The environment is empty, or environment and label are both supplied. "401": content: application/json: @@ -167148,15 +167168,28 @@ paths: application/json: schema: $ref: "#/components/schemas/JSONAPIErrorResponse" - description: Forbidden + description: |- + Forbidden + The application key lacks `llm_observability_read`, or environment resolution was requested without both + `feature_flag_config_read` and `feature_flag_environment_config_read`. "404": content: application/json: schema: $ref: "#/components/schemas/JSONAPIErrorResponse" - description: Not Found + description: |- + Not Found + The prompt does not exist, or no prompt deployment can be resolved for the supplied environment. "429": $ref: "#/components/responses/TooManyRequestsResponse" + "500": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: |- + Internal Server Error + Environment resolution failed. security: - apiKeyAuth: [] appKeyAuth: [] diff --git a/examples/v2/agent-observability/GetLLMObsPrompt_2452494832.py b/examples/v2/agent-observability/GetLLMObsPrompt_2452494832.py new file mode 100644 index 0000000000..982bd02f9c --- /dev/null +++ b/examples/v2/agent-observability/GetLLMObsPrompt_2452494832.py @@ -0,0 +1,17 @@ +""" +Get an Agent Observability prompt by environment returns "OK" response +""" + +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v2.api.agent_observability_api import AgentObservabilityApi + +configuration = Configuration() +configuration.unstable_operations["get_llm_obs_prompt"] = True +with ApiClient(configuration) as api_client: + api_instance = AgentObservabilityApi(api_client) + response = api_instance.get_llm_obs_prompt( + prompt_id="prompt_id", + environment="production", + ) + + print(response) diff --git a/src/datadog_api_client/v2/api/agent_observability_api.py b/src/datadog_api_client/v2/api/agent_observability_api.py index 3804f19a5c..ef90f7d242 100644 --- a/src/datadog_api_client/v2/api/agent_observability_api.py +++ b/src/datadog_api_client/v2/api/agent_observability_api.py @@ -941,6 +941,14 @@ def __init__(self, api_client=None): "attribute": "label", "location": "query", }, + "environment": { + "validation": { + "min_length": 1, + }, + "openapi_types": (str,), + "attribute": "environment", + "location": "query", + }, }, headers_map={ "accept": ["application/json"], @@ -2832,15 +2840,18 @@ def get_llm_obs_prompt( prompt_id: str, *, label: Union[str, UnsetType] = unset, + environment: Union[str, UnsetType] = unset, ) -> LLMObsPromptSDKResponse: """Get an Agent Observability prompt. - Get the latest version of an Agent Observability prompt by prompt ID. + Get an Agent Observability prompt by prompt ID. When ``environment`` is omitted, this returns the latest version or uses the deprecated ``label`` behavior and requires ``llm_observability_read``. When ``environment`` is supplied, it must be a nonempty ``DD_ENV`` value, cannot be combined with ``label`` , and additionally requires ``feature_flag_config_read`` and ``feature_flag_environment_config_read``. An empty environment or combining it with ``label`` returns 400, and missing either additional permission returns 403. A missing prompt or deployment returns 404 without falling back to the latest version. An environment resolution failure returns 500. :param prompt_id: The customer-provided identifier of the Agent Observability prompt. :type prompt_id: str - :param label: **Deprecated.** Optional label of the prompt version to return. Do not use this parameter for new integrations. If omitted, the latest version is returned. If the prompt has no labels, the latest version is returned even when a label is requested. If the prompt has labels but none match the requested label, a 404 response is returned. + :param label: **Deprecated.** Optional label of the prompt version to return. Do not use this parameter for new integrations. If omitted, the latest version is returned. If the prompt has no labels, the latest version is returned even when a label is requested. If the prompt has labels but none match the requested label, a 404 response is returned. This parameter cannot be used with ``environment``. :type label: str, optional + :param environment: Optional ``DD_ENV`` value used to resolve the prompt version deployed to the matching Feature Flags environment. This value is not a Feature Flags environment UUID. Using this parameter additionally requires the ``feature_flag_config_read`` and ``feature_flag_environment_config_read`` permissions. This parameter cannot be used with ``label``. + :type environment: str, optional :rtype: LLMObsPromptSDKResponse """ kwargs: Dict[str, Any] = {} @@ -2849,6 +2860,9 @@ def get_llm_obs_prompt( if label is not unset: kwargs["label"] = label + if environment is not unset: + kwargs["environment"] = environment + return self._get_llm_obs_prompt_endpoint.call_with_http_info(**kwargs) def get_llm_obs_prompt_version( diff --git a/tests/v2/features/agent_observability.feature b/tests/v2/features/agent_observability.feature index 0b036ba38e..e0ef7783fc 100644 --- a/tests/v2/features/agent_observability.feature +++ b/tests/v2/features/agent_observability.feature @@ -766,6 +766,23 @@ Feature: Agent Observability When the request is sent Then the response status is 200 OK + @skip @team:DataDog/ml-observability + Scenario: Get an Agent Observability prompt by environment returns "OK" response + Given operation "GetLLMObsPrompt" enabled + And new "GetLLMObsPrompt" request + And request contains "prompt_id" parameter from "REPLACE.ME" + And request contains "environment" parameter with value "production" + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/ml-observability + Scenario: Get an Agent Observability prompt returns "Bad Request" response + Given operation "GetLLMObsPrompt" enabled + And new "GetLLMObsPrompt" request + And request contains "prompt_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + @generated @skip @team:DataDog/ml-observability Scenario: Get an Agent Observability prompt returns "Not Found" response Given operation "GetLLMObsPrompt" enabled