GeezerVison is showing github.com — feat(api): manual updates · cleanlab/codex-python@5a4e424
File treeExpand file treeCollapse file tree Open diff view settings tests/api_resources/projects
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboard +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | | -configured_endpoints: 55 | | 1 | +configured_endpoints: 56 | 2 | 2 | openapi_spec_hash: 12260ab88069ff15d254606e041debfb | 3 | | -config_hash: bed87752f4056d0c4bf2ddf856307800 | | 3 | +config_hash: 6c3ad84d97bf1d0989ad2ec0cae64078 |
Collapse file Copy file name to clipboardExpand all lines: api.md +2Lines changed: 2 additions & 0 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -206,6 +206,7 @@ from codex.types.projects import ( | 206 | 206 | QueryLogListByGroupResponse, | 207 | 207 | QueryLogListGroupsResponse, | 208 | 208 | QueryLogStartRemediationResponse, | | 209 | + QueryLogUpdateMetadataResponse, | 209 | 210 | ) | 210 | 211 | ``` | 211 | 212 |
| @@ -217,6 +218,7 @@ Methods: | 217 | 218 | - <code title="get /api/projects/{project_id}/query_logs/logs_by_group">client.projects.query_logs.<a href="./src/codex/resources/projects/query_logs.py">list_by_group</a>(project_id, \*\*<a href="src/codex/types/projects/query_log_list_by_group_params.py">params</a>) -> <a href="./src/codex/types/projects/query_log_list_by_group_response.py">QueryLogListByGroupResponse</a></code> | 218 | 219 | - <code title="get /api/projects/{project_id}/query_logs/groups">client.projects.query_logs.<a href="./src/codex/resources/projects/query_logs.py">list_groups</a>(project_id, \*\*<a href="src/codex/types/projects/query_log_list_groups_params.py">params</a>) -> <a href="./src/codex/types/projects/query_log_list_groups_response.py">SyncOffsetPageQueryLogGroups[QueryLogListGroupsResponse]</a></code> | 219 | 220 | - <code title="post /api/projects/{project_id}/query_logs/{query_log_id}/start_remediation">client.projects.query_logs.<a href="./src/codex/resources/projects/query_logs.py">start_remediation</a>(query_log_id, \*, project_id) -> <a href="./src/codex/types/projects/query_log_start_remediation_response.py">QueryLogStartRemediationResponse</a></code> | | 221 | +- <code title="put /api/projects/{project_id}/query_logs/{query_log_id}/metadata">client.projects.query_logs.<a href="./src/codex/resources/projects/query_logs.py">update_metadata</a>(query_log_id, \*, project_id, \*\*<a href="src/codex/types/projects/query_log_update_metadata_params.py">params</a>) -> <a href="./src/codex/types/projects/query_log_update_metadata_response.py">QueryLogUpdateMetadataResponse</a></code> | 220 | 222 |
| 221 | 223 | ## Remediations | 222 | 224 |
| |
Collapse file Copy file name to clipboardExpand all lines: src/codex/resources/projects/query_logs.py +90Lines changed: 90 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 29 | 29 | query_log_list_params, | 30 | 30 | query_log_list_groups_params, | 31 | 31 | query_log_list_by_group_params, | | 32 | + query_log_update_metadata_params, | 32 | 33 | query_log_add_user_feedback_params, | 33 | 34 | ) | 34 | 35 | from ...types.projects.query_log_list_response import QueryLogListResponse | 35 | 36 | from ...types.projects.query_log_retrieve_response import QueryLogRetrieveResponse | 36 | 37 | from ...types.projects.query_log_list_groups_response import QueryLogListGroupsResponse | 37 | 38 | from ...types.projects.query_log_list_by_group_response import QueryLogListByGroupResponse | | 39 | +from ...types.projects.query_log_update_metadata_response import QueryLogUpdateMetadataResponse | 38 | 40 | from ...types.projects.query_log_add_user_feedback_response import QueryLogAddUserFeedbackResponse | 39 | 41 | from ...types.projects.query_log_start_remediation_response import QueryLogStartRemediationResponse | 40 | 42 |
| @@ -464,6 +466,44 @@ def start_remediation( | 464 | 466 | cast_to=QueryLogStartRemediationResponse, | 465 | 467 | ) | 466 | 468 |
| | 469 | + def update_metadata( | | 470 | + self, | | 471 | + query_log_id: str, | | 472 | + *, | | 473 | + project_id: str, | | 474 | + body: object, | | 475 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. | | 476 | + # The extra values given here take precedence over values defined on the client or passed to this method. | | 477 | + extra_headers: Headers | None = None, | | 478 | + extra_query: Query | None = None, | | 479 | + extra_body: Body | None = None, | | 480 | + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, | | 481 | + ) -> QueryLogUpdateMetadataResponse: | | 482 | + """ | | 483 | + Update Metadata Route | | 484 | +
| | 485 | + Args: | | 486 | + extra_headers: Send extra headers | | 487 | +
| | 488 | + extra_query: Add additional query parameters to the request | | 489 | +
| | 490 | + extra_body: Add additional JSON properties to the request | | 491 | +
| | 492 | + timeout: Override the client-level default timeout for this request, in seconds | | 493 | + """ | | 494 | + if not project_id: | | 495 | + raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}") | | 496 | + if not query_log_id: | | 497 | + raise ValueError(f"Expected a non-empty value for `query_log_id` but received {query_log_id!r}") | | 498 | + return self._put( | | 499 | + f"/api/projects/{project_id}/query_logs/{query_log_id}/metadata", | | 500 | + body=maybe_transform(body, query_log_update_metadata_params.QueryLogUpdateMetadataParams), | | 501 | + options=make_request_options( | | 502 | + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout | | 503 | + ), | | 504 | + cast_to=QueryLogUpdateMetadataResponse, | | 505 | + ) | | 506 | + | 467 | 507 |
| 468 | 508 | class AsyncQueryLogsResource(AsyncAPIResource): | 469 | 509 | @cached_property | @@ -890,6 +930,44 @@ async def start_remediation( | 890 | 930 | cast_to=QueryLogStartRemediationResponse, | 891 | 931 | ) | 892 | 932 |
| | 933 | + async def update_metadata( | | 934 | + self, | | 935 | + query_log_id: str, | | 936 | + *, | | 937 | + project_id: str, | | 938 | + body: object, | | 939 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. | | 940 | + # The extra values given here take precedence over values defined on the client or passed to this method. | | 941 | + extra_headers: Headers | None = None, | | 942 | + extra_query: Query | None = None, | | 943 | + extra_body: Body | None = None, | | 944 | + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, | | 945 | + ) -> QueryLogUpdateMetadataResponse: | | 946 | + """ | | 947 | + Update Metadata Route | | 948 | +
| | 949 | + Args: | | 950 | + extra_headers: Send extra headers | | 951 | +
| | 952 | + extra_query: Add additional query parameters to the request | | 953 | +
| | 954 | + extra_body: Add additional JSON properties to the request | | 955 | +
| | 956 | + timeout: Override the client-level default timeout for this request, in seconds | | 957 | + """ | | 958 | + if not project_id: | | 959 | + raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}") | | 960 | + if not query_log_id: | | 961 | + raise ValueError(f"Expected a non-empty value for `query_log_id` but received {query_log_id!r}") | | 962 | + return await self._put( | | 963 | + f"/api/projects/{project_id}/query_logs/{query_log_id}/metadata", | | 964 | + body=await async_maybe_transform(body, query_log_update_metadata_params.QueryLogUpdateMetadataParams), | | 965 | + options=make_request_options( | | 966 | + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout | | 967 | + ), | | 968 | + cast_to=QueryLogUpdateMetadataResponse, | | 969 | + ) | | 970 | + | 893 | 971 |
| 894 | 972 | class QueryLogsResourceWithRawResponse: | 895 | 973 | def __init__(self, query_logs: QueryLogsResource) -> None: | @@ -913,6 +991,9 @@ def __init__(self, query_logs: QueryLogsResource) -> None: | 913 | 991 | self.start_remediation = to_raw_response_wrapper( | 914 | 992 | query_logs.start_remediation, | 915 | 993 | ) | | 994 | + self.update_metadata = to_raw_response_wrapper( | | 995 | + query_logs.update_metadata, | | 996 | + ) | 916 | 997 |
| 917 | 998 |
| 918 | 999 | class AsyncQueryLogsResourceWithRawResponse: | @@ -937,6 +1018,9 @@ def __init__(self, query_logs: AsyncQueryLogsResource) -> None: | 937 | 1018 | self.start_remediation = async_to_raw_response_wrapper( | 938 | 1019 | query_logs.start_remediation, | 939 | 1020 | ) | | 1021 | + self.update_metadata = async_to_raw_response_wrapper( | | 1022 | + query_logs.update_metadata, | | 1023 | + ) | 940 | 1024 |
| 941 | 1025 |
| 942 | 1026 | class QueryLogsResourceWithStreamingResponse: | @@ -961,6 +1045,9 @@ def __init__(self, query_logs: QueryLogsResource) -> None: | 961 | 1045 | self.start_remediation = to_streamed_response_wrapper( | 962 | 1046 | query_logs.start_remediation, | 963 | 1047 | ) | | 1048 | + self.update_metadata = to_streamed_response_wrapper( | | 1049 | + query_logs.update_metadata, | | 1050 | + ) | 964 | 1051 |
| 965 | 1052 |
| 966 | 1053 | class AsyncQueryLogsResourceWithStreamingResponse: | @@ -985,3 +1072,6 @@ def __init__(self, query_logs: AsyncQueryLogsResource) -> None: | 985 | 1072 | self.start_remediation = async_to_streamed_response_wrapper( | 986 | 1073 | query_logs.start_remediation, | 987 | 1074 | ) | | 1075 | + self.update_metadata = async_to_streamed_response_wrapper( | | 1076 | + query_logs.update_metadata, | | 1077 | + ) |
Collapse file Copy file name to clipboardExpand all lines: src/codex/types/projects/__init__.py +2Lines changed: 2 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 26 | 26 | from .query_log_list_groups_response import QueryLogListGroupsResponse as QueryLogListGroupsResponse | 27 | 27 | from .remediation_edit_answer_params import RemediationEditAnswerParams as RemediationEditAnswerParams | 28 | 28 | from .query_log_list_by_group_response import QueryLogListByGroupResponse as QueryLogListByGroupResponse | | 29 | +from .query_log_update_metadata_params import QueryLogUpdateMetadataParams as QueryLogUpdateMetadataParams | 29 | 30 | from .remediation_edit_answer_response import RemediationEditAnswerResponse as RemediationEditAnswerResponse | 30 | 31 | from .query_log_add_user_feedback_params import QueryLogAddUserFeedbackParams as QueryLogAddUserFeedbackParams | | 32 | +from .query_log_update_metadata_response import QueryLogUpdateMetadataResponse as QueryLogUpdateMetadataResponse | 31 | 33 | from .query_log_add_user_feedback_response import QueryLogAddUserFeedbackResponse as QueryLogAddUserFeedbackResponse | 32 | 34 | from .query_log_start_remediation_response import QueryLogStartRemediationResponse as QueryLogStartRemediationResponse | 33 | 35 | from .remediation_edit_draft_answer_params import RemediationEditDraftAnswerParams as RemediationEditDraftAnswerParams | |
Collapse file Copy file name to clipboard +13Lines changed: 13 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. | | 2 | + | | 3 | +from __future__ import annotations | | 4 | + | | 5 | +from typing_extensions import Required, TypedDict | | 6 | + | | 7 | +__all__ = ["QueryLogUpdateMetadataParams"] | | 8 | + | | 9 | + | | 10 | +class QueryLogUpdateMetadataParams(TypedDict, total=False): | | 11 | + project_id: Required[str] | | 12 | + | | 13 | + body: Required[object] |
Collapse file Copy file name to clipboard +17Lines changed: 17 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. | | 2 | + | | 3 | +from typing import List, Optional | | 4 | + | | 5 | +from ..._models import BaseModel | | 6 | + | | 7 | +__all__ = ["QueryLogUpdateMetadataResponse"] | | 8 | + | | 9 | + | | 10 | +class QueryLogUpdateMetadataResponse(BaseModel): | | 11 | + id: str | | 12 | + | | 13 | + custom_metadata: Optional[object] = None | | 14 | + """Arbitrary metadata supplied by the user/system""" | | 15 | + | | 16 | + custom_metadata_keys: Optional[List[str]] = None | | 17 | + """Keys of the custom metadata""" |
Collapse file Copy file name to clipboardExpand all lines: tests/api_resources/projects/test_query_logs.py +115Lines changed: 115 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 21 | 21 | QueryLogRetrieveResponse, | 22 | 22 | QueryLogListGroupsResponse, | 23 | 23 | QueryLogListByGroupResponse, | | 24 | + QueryLogUpdateMetadataResponse, | 24 | 25 | QueryLogAddUserFeedbackResponse, | 25 | 26 | QueryLogStartRemediationResponse, | 26 | 27 | ) | @@ -387,6 +388,63 @@ def test_path_params_start_remediation(self, client: Codex) -> None: | 387 | 388 | project_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", | 388 | 389 | ) | 389 | 390 |
| | 391 | + @pytest.mark.skip(reason="Prism tests are disabled") | | 392 | + @parametrize | | 393 | + def test_method_update_metadata(self, client: Codex) -> None: | | 394 | + query_log = client.projects.query_logs.update_metadata( | | 395 | + query_log_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", | | 396 | + project_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", | | 397 | + body={}, | | 398 | + ) | | 399 | + assert_matches_type(QueryLogUpdateMetadataResponse, query_log, path=["response"]) | | 400 | + | | 401 | + @pytest.mark.skip(reason="Prism tests are disabled") | | 402 | + @parametrize | | 403 | + def test_raw_response_update_metadata(self, client: Codex) -> None: | | 404 | + response = client.projects.query_logs.with_raw_response.update_metadata( | | 405 | + query_log_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", | | 406 | + project_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", | | 407 | + body={}, | | 408 | + ) | | 409 | + | | 410 | + assert response.is_closed is True | | 411 | + assert response.http_request.headers.get("X-Stainless-Lang") == "python" | | 412 | + query_log = response.parse() | | 413 | + assert_matches_type(QueryLogUpdateMetadataResponse, query_log, path=["response"]) | | 414 | + | | 415 | + @pytest.mark.skip(reason="Prism tests are disabled") | | 416 | + @parametrize | | 417 | + def test_streaming_response_update_metadata(self, client: Codex) -> None: | | 418 | + with client.projects.query_logs.with_streaming_response.update_metadata( | | 419 | + query_log_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", | | 420 | + project_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", | | 421 | + body={}, | | 422 | + ) as response: | | 423 | + assert not response.is_closed | | 424 | + assert response.http_request.headers.get("X-Stainless-Lang") == "python" | | 425 | + | | 426 | + query_log = response.parse() | | 427 | + assert_matches_type(QueryLogUpdateMetadataResponse, query_log, path=["response"]) | | 428 | + | | 429 | + assert cast(Any, response.is_closed) is True | | 430 | + | | 431 | + @pytest.mark.skip(reason="Prism tests are disabled") | | 432 | + @parametrize | | 433 | + def test_path_params_update_metadata(self, client: Codex) -> None: | | 434 | + with pytest.raises(ValueError, match=r"Expected a non-empty value for `project_id` but received ''"): | | 435 | + client.projects.query_logs.with_raw_response.update_metadata( | | 436 | + query_log_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", | | 437 | + project_id="", | | 438 | + body={}, | | 439 | + ) | | 440 | + | | 441 | + with pytest.raises(ValueError, match=r"Expected a non-empty value for `query_log_id` but received ''"): | | 442 | + client.projects.query_logs.with_raw_response.update_metadata( | | 443 | + query_log_id="", | | 444 | + project_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", | | 445 | + body={}, | | 446 | + ) | | 447 | + | 390 | 448 |
| 391 | 449 | class TestAsyncQueryLogs: | 392 | 450 | parametrize = pytest.mark.parametrize( | @@ -748,3 +806,60 @@ async def test_path_params_start_remediation(self, async_client: AsyncCodex) -> | 748 | 806 | query_log_id="", | 749 | 807 | project_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", | 750 | 808 | ) | | 809 | + | | 810 | + @pytest.mark.skip(reason="Prism tests are disabled") | | 811 | + @parametrize | | 812 | + async def test_method_update_metadata(self, async_client: AsyncCodex) -> None: | | 813 | + query_log = await async_client.projects.query_logs.update_metadata( | | 814 | + query_log_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", | | 815 | + project_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", | | 816 | + body={}, | | 817 | + ) | | 818 | + assert_matches_type(QueryLogUpdateMetadataResponse, query_log, path=["response"]) | | 819 | + | | 820 | + @pytest.mark.skip(reason="Prism tests are disabled") | | 821 | + @parametrize | | 822 | + async def test_raw_response_update_metadata(self, async_client: AsyncCodex) -> None: | | 823 | + response = await async_client.projects.query_logs.with_raw_response.update_metadata( | | 824 | + query_log_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", | | 825 | + project_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", | | 826 | + body={}, | | 827 | + ) | | 828 | + | | 829 | + assert response.is_closed is True | | 830 | + assert response.http_request.headers.get("X-Stainless-Lang") == "python" | | 831 | + query_log = await response.parse() | | 832 | + assert_matches_type(QueryLogUpdateMetadataResponse, query_log, path=["response"]) | | 833 | + | | 834 | + @pytest.mark.skip(reason="Prism tests are disabled") | | 835 | + @parametrize | | 836 | + async def test_streaming_response_update_metadata(self, async_client: AsyncCodex) -> None: | | 837 | + async with async_client.projects.query_logs.with_streaming_response.update_metadata( | | 838 | + query_log_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", | | 839 | + project_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", | | 840 | + body={}, | | 841 | + ) as response: | | 842 | + assert not response.is_closed | | 843 | + assert response.http_request.headers.get("X-Stainless-Lang") == "python" | | 844 | + | | 845 | + query_log = await response.parse() | | 846 | + assert_matches_type(QueryLogUpdateMetadataResponse, query_log, path=["response"]) | | 847 | + | | 848 | + assert cast(Any, response.is_closed) is True | | 849 | + | | 850 | + @pytest.mark.skip(reason="Prism tests are disabled") | | 851 | + @parametrize | | 852 | + async def test_path_params_update_metadata(self, async_client: AsyncCodex) -> None: | | 853 | + with pytest.raises(ValueError, match=r"Expected a non-empty value for `project_id` but received ''"): | | 854 | + await async_client.projects.query_logs.with_raw_response.update_metadata( | | 855 | + query_log_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", | | 856 | + project_id="", | | 857 | + body={}, | | 858 | + ) | | 859 | + | | 860 | + with pytest.raises(ValueError, match=r"Expected a non-empty value for `query_log_id` but received ''"): | | 861 | + await async_client.projects.query_logs.with_raw_response.update_metadata( | | 862 | + query_log_id="", | | 863 | + project_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", | | 864 | + body={}, | | 865 | + ) |
|