Skip to content

Commit a8144ea

Browse files
authored
feat: Add patch command to HTTPConnection
1 parent 363baa0 commit a8144ea

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

py/src/braintrust/logger.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -788,6 +788,9 @@ def get(self, path: str, *args: Any, **kwargs: Any) -> requests.Response:
788788
def post(self, path: str, *args: Any, **kwargs: Any) -> requests.Response:
789789
return self.session.post(_urljoin(self.base_url, path), *args, **kwargs)
790790

791+
def patch(self, path: str, *args: Any, **kwargs: Any) -> requests.Response:
792+
return self.session.patch(_urljoin(self.base_url, path), *args, **kwargs)
793+
791794
def put(self, path: str, *args: Any, **kwargs: Any) -> requests.Response:
792795
return self.session.put(_urljoin(self.base_url, path), *args, **kwargs)
793796

@@ -804,6 +807,11 @@ def post_json(self, object_type: str, args: Mapping[str, Any] | None = None) ->
804807
response_raise_for_status(resp)
805808
return resp.json()
806809

810+
def patch_json(self, object_type: str, args: Mapping[str, Any] | None = None) -> Any:
811+
resp = self.patch(f"/{object_type.lstrip('/')}", json=args)
812+
response_raise_for_status(resp)
813+
return resp.json()
814+
807815

808816
# Sometimes we'd like to launch network requests concurrently. We provide a
809817
# thread pool to accomplish this. Use a multiple of number of CPU cores to limit

0 commit comments

Comments
 (0)