2323 ApplicationSummary ,
2424 ApplicationVersion ,
2525 Client ,
26+ ForbiddenException ,
2627 InputArtifact ,
2728 InputItem ,
2829 NotFoundException ,
@@ -533,6 +534,7 @@ def application_runs_static( # noqa: PLR0913, PLR0917
533534 tags : set [str ] | None = None ,
534535 query : str | None = None ,
535536 limit : int | None = None ,
537+ for_organization : str | None = None ,
536538 ) -> list [dict [str , Any ]]:
537539 """Get a list of all application runs, static variant.
538540
@@ -551,6 +553,8 @@ def application_runs_static( # noqa: PLR0913, PLR0917
551553 If None, no filtering is applied. Cannot be used together with custom_metadata, note_regex, or tags.
552554 Performs a union search: matches runs where the query appears in the note OR matches any tag.
553555 limit (int | None): The maximum number of runs to retrieve. If None, all runs are retrieved.
556+ for_organization (str | None): If set, returns all runs triggered by users of the specified
557+ organization. If None, only the runs of the current user are returned.
554558
555559 Returns:
556560 list[RunData]: A list of all application runs.
@@ -587,6 +591,7 @@ def application_runs_static( # noqa: PLR0913, PLR0917
587591 tags = tags ,
588592 query = query ,
589593 limit = limit ,
594+ for_organization = for_organization ,
590595 )
591596 ]
592597
@@ -601,6 +606,7 @@ def application_runs( # noqa: C901, PLR0912, PLR0913, PLR0914, PLR0915, PLR0917
601606 tags : set [str ] | None = None ,
602607 query : str | None = None ,
603608 limit : int | None = None ,
609+ for_organization : str | None = None ,
604610 ) -> list [RunData ]:
605611 """Get a list of all application runs.
606612
@@ -619,12 +625,15 @@ def application_runs( # noqa: C901, PLR0912, PLR0913, PLR0914, PLR0915, PLR0917
619625 If None, no filtering is applied. Cannot be used together with custom_metadata, note_regex, or tags.
620626 Performs a union search: matches runs where the query appears in the note OR matches any tag.
621627 limit (int | None): The maximum number of runs to retrieve. If None, all runs are retrieved.
628+ for_organization (str | None): If set, returns all runs triggered by users of the specified
629+ organization. If None, only the runs of the current user are returned.
622630
623631 Returns:
624632 list[RunData]: A list of all application runs.
625633
626634 Raises:
627635 ValueError: If query is used together with custom_metadata, note_regex, or tags.
636+ ForbiddenException: If the user is not authorized to list runs for the specified organization.
628637 RuntimeError: If the application run list cannot be retrieved.
629638 """
630639 # Validate that query is not used with other metadata filters
@@ -658,6 +667,7 @@ def application_runs( # noqa: C901, PLR0912, PLR0913, PLR0914, PLR0915, PLR0917
658667 custom_metadata = custom_metadata_note ,
659668 sort = "-submitted_at" ,
660669 page_size = page_size ,
670+ for_organization = for_organization ,
661671 )
662672 for run in note_run_iterator :
663673 if has_output and run .output == RunOutput .NONE :
@@ -677,6 +687,7 @@ def application_runs( # noqa: C901, PLR0912, PLR0913, PLR0914, PLR0915, PLR0917
677687 custom_metadata = custom_metadata_tags ,
678688 sort = "-submitted_at" ,
679689 page_size = page_size ,
690+ for_organization = for_organization ,
680691 )
681692 for run in tag_run_iterator :
682693 if has_output and run .output == RunOutput .NONE :
@@ -727,6 +738,7 @@ def application_runs( # noqa: C901, PLR0912, PLR0913, PLR0914, PLR0915, PLR0917
727738 custom_metadata = custom_metadata ,
728739 sort = "-submitted_at" ,
729740 page_size = page_size ,
741+ for_organization = for_organization ,
730742 )
731743 for run in run_iterator :
732744 if has_output and run .output == RunOutput .NONE :
@@ -766,6 +778,8 @@ def application_runs( # noqa: C901, PLR0912, PLR0913, PLR0914, PLR0915, PLR0917
766778 if limit is not None and len (runs ) >= limit :
767779 break
768780 return runs
781+ except ForbiddenException :
782+ raise
769783 except Exception as e :
770784 message = f"Failed to retrieve application runs: { e } "
771785 logger .exception (message )
0 commit comments