Skip to content

Commit 0498192

Browse files
authored
feat: add search_pipelines method (#61)
[SC-134382]
1 parent e0c90d5 commit 0498192

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/codeocean/capsule.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,3 +547,24 @@ def search_capsules_iterator(self, search_params: CapsuleSearchParams) -> Iterat
547547
return
548548

549549
params["next_token"] = response.next_token
550+
551+
def search_pipelines(self, search_params: CapsuleSearchParams) -> CapsuleSearchResults:
552+
"""Search for pipelines with filtering, sorting, and pagination
553+
options."""
554+
res = self.client.post("pipelines/search", json=search_params.to_dict())
555+
556+
return CapsuleSearchResults.from_dict(res.json())
557+
558+
def search_pipelines_iterator(self, search_params: CapsuleSearchParams) -> Iterator[Capsule]:
559+
"""Iterate through all pipelines matching search criteria with automatic pagination."""
560+
params = search_params.to_dict()
561+
while True:
562+
response = self.search_pipelines(search_params=CapsuleSearchParams(**params))
563+
564+
for result in response.results:
565+
yield result
566+
567+
if not response.has_more:
568+
return
569+
570+
params["next_token"] = response.next_token

0 commit comments

Comments
 (0)