|
27 | 27 | IterableRegisteredAPIsResponse, |
28 | 28 | IterableRunLogsResponse, |
29 | 29 | IterableRunsResponse, |
| 30 | + IterableWebInputsResponse, |
30 | 31 | ) |
31 | 32 |
|
32 | 33 | if sys.version_info >= (3, 11): |
@@ -983,6 +984,181 @@ def list_registered_apis( |
983 | 984 | self.get("/registered_apis", query_params=query_params) |
984 | 985 | ) |
985 | 986 |
|
| 987 | + @paging.has_paginator( |
| 988 | + paging.NullableMarkerPaginator, items_key="web_input_summaries" |
| 989 | + ) |
| 990 | + def list_web_inputs( |
| 991 | + self, |
| 992 | + *, |
| 993 | + filter_roles: ( |
| 994 | + t.Literal["viewer", "respondent"] |
| 995 | + | t.Iterable[t.Literal["viewer", "respondent"]] |
| 996 | + | MissingType |
| 997 | + ) = MISSING, |
| 998 | + filter_states: ( |
| 999 | + t.Literal["open", "closed"] |
| 1000 | + | t.Iterable[t.Literal["open", "closed"]] |
| 1001 | + | MissingType |
| 1002 | + ) = MISSING, |
| 1003 | + filter_flow_ids: ( |
| 1004 | + t.Iterable[uuid.UUID | str] | uuid.UUID | str | MissingType |
| 1005 | + ) = MISSING, |
| 1006 | + filter_run_ids: ( |
| 1007 | + t.Iterable[uuid.UUID | str] | uuid.UUID | str | MissingType |
| 1008 | + ) = MISSING, |
| 1009 | + orderby: str | t.Iterable[str] | MissingType = MISSING, |
| 1010 | + per_page: int | MissingType = MISSING, |
| 1011 | + marker: str | MissingType = MISSING, |
| 1012 | + query_params: dict[str, t.Any] | None = None, |
| 1013 | + ) -> IterableWebInputsResponse: |
| 1014 | + """ |
| 1015 | + List web inputs. |
| 1016 | +
|
| 1017 | + :param filter_roles: |
| 1018 | + Filter web inputs to only include those the user has the given role for. |
| 1019 | + :param filter_states: |
| 1020 | + Filter web inputs to only include those in the given state(s). |
| 1021 | + :param filter_flow_ids: |
| 1022 | + Filter web inputs to only include those associated with the given flow IDs. |
| 1023 | + :param filter_run_ids: |
| 1024 | + Filter web inputs to only include those associated with the given run IDs. |
| 1025 | + :param orderby: |
| 1026 | + A criterion for ordering web inputs in the listing. Known criteria include |
| 1027 | + ``created_timestamp``, ``edited_timestamp``, and ``closed_timestamp``. |
| 1028 | + An optional sort order can be provided (either ``ASC`` or ``DESC``) |
| 1029 | + and must be separated by a space. |
| 1030 | + For example: ``"created_timestamp DESC"``. |
| 1031 | + :param per_page: |
| 1032 | + The number of results to return per page. |
| 1033 | + :param marker: |
| 1034 | + A marker for pagination. Provided by the server on a previous request. |
| 1035 | + :param query_params: |
| 1036 | + Any additional parameters to be passed through as query params. |
| 1037 | +
|
| 1038 | + .. tab-set:: |
| 1039 | +
|
| 1040 | + .. tab-item:: Example Usage |
| 1041 | +
|
| 1042 | + .. code-block:: python |
| 1043 | +
|
| 1044 | + from globus_sdk import FlowsClient |
| 1045 | +
|
| 1046 | + flows = FlowsClient(...) |
| 1047 | + for web_input in flows.list_web_inputs(filter_states="open"): |
| 1048 | + print(f"Title: {web_input['title']}") |
| 1049 | + print(f"Status: {web_input['status']}") |
| 1050 | +
|
| 1051 | + .. tab-item:: Paginated Usage |
| 1052 | +
|
| 1053 | + .. paginatedusage:: list_web_inputs |
| 1054 | +
|
| 1055 | + .. tab-item:: Example Response Data |
| 1056 | +
|
| 1057 | + .. expandtestfixture:: flows.list_web_inputs |
| 1058 | +
|
| 1059 | + .. tab-item:: API Info |
| 1060 | +
|
| 1061 | + .. extdoclink:: List Web Inputs |
| 1062 | + :service: flows |
| 1063 | + :ref: Web-Inputs/paths/~1web_inputs/get |
| 1064 | + """ |
| 1065 | + query_params = { |
| 1066 | + "filter_roles": commajoin(filter_roles), |
| 1067 | + "filter_states": commajoin(filter_states), |
| 1068 | + "filter_flow_ids": commajoin(filter_flow_ids), |
| 1069 | + "filter_run_ids": commajoin(filter_run_ids), |
| 1070 | + # if `orderby` is an iterable (e.g., generator expression), it gets |
| 1071 | + # converted to a list in this step |
| 1072 | + "orderby": commajoin(orderby), |
| 1073 | + "per_page": per_page, |
| 1074 | + "marker": marker, |
| 1075 | + **(query_params or {}), |
| 1076 | + } |
| 1077 | + return IterableWebInputsResponse( |
| 1078 | + self.get("/web_inputs", query_params=query_params) |
| 1079 | + ) |
| 1080 | + |
| 1081 | + def get_web_input( |
| 1082 | + self, |
| 1083 | + web_input_id: uuid.UUID | str, |
| 1084 | + ) -> GlobusHTTPResponse: |
| 1085 | + """ |
| 1086 | + Get a web input by ID. |
| 1087 | +
|
| 1088 | + Returns data about the web input if the current user has any role on it |
| 1089 | + (``viewer`` or ``respondent``). If the web input's flow has an associated |
| 1090 | + authentication policy that the caller's session does not satisfy, the |
| 1091 | + service may instead respond with a GARE (Globus Auth Requirements Error) |
| 1092 | + requiring reauthentication. |
| 1093 | +
|
| 1094 | + :param web_input_id: The ID of the web input to fetch |
| 1095 | +
|
| 1096 | + .. tab-set:: |
| 1097 | +
|
| 1098 | + .. tab-item:: Example Usage |
| 1099 | +
|
| 1100 | + .. code-block:: python |
| 1101 | +
|
| 1102 | + from globus_sdk import FlowsClient |
| 1103 | +
|
| 1104 | + flows = FlowsClient(...) |
| 1105 | + flows.get_web_input("11111111-2222-3333-4444-555555555555") |
| 1106 | +
|
| 1107 | + .. tab-item:: Example Response Data |
| 1108 | +
|
| 1109 | + .. expandtestfixture:: flows.get_web_input |
| 1110 | +
|
| 1111 | + .. tab-item:: API Info |
| 1112 | +
|
| 1113 | + .. extdoclink:: Get Web Input |
| 1114 | + :service: flows |
| 1115 | + :ref: Web-Inputs/paths/~1web_inputs~1{web_input_id}/get |
| 1116 | + """ |
| 1117 | + return self.get(f"/web_inputs/{web_input_id}") |
| 1118 | + |
| 1119 | + def respond_to_web_input( |
| 1120 | + self, |
| 1121 | + web_input_id: uuid.UUID | str, |
| 1122 | + value: t.Any, |
| 1123 | + ) -> GlobusHTTPResponse: |
| 1124 | + """ |
| 1125 | + Submit a response to a web input. |
| 1126 | +
|
| 1127 | + The caller must have the ``respondent`` role on the web input. |
| 1128 | +
|
| 1129 | + If the web input is a ``selection``-type web input, |
| 1130 | + ``value`` must be the ``option_id`` of one of the web input's options. |
| 1131 | +
|
| 1132 | + :param web_input_id: The ID of the web input to respond to |
| 1133 | + :param value: The response value |
| 1134 | +
|
| 1135 | + .. tab-set:: |
| 1136 | +
|
| 1137 | + .. tab-item:: Example Usage |
| 1138 | +
|
| 1139 | + .. code-block:: python |
| 1140 | +
|
| 1141 | + from globus_sdk import FlowsClient |
| 1142 | +
|
| 1143 | + flows = FlowsClient(...) |
| 1144 | + flows.respond_to_web_input( |
| 1145 | + "11111111-2222-3333-4444-555555555555", |
| 1146 | + value="22222222-3333-4444-5555-666666666666", |
| 1147 | + ) |
| 1148 | +
|
| 1149 | + .. tab-item:: Example Response Data |
| 1150 | +
|
| 1151 | + .. expandtestfixture:: flows.respond_to_web_input |
| 1152 | +
|
| 1153 | + .. tab-item:: API Info |
| 1154 | +
|
| 1155 | + .. extdoclink:: Respond to Web Input |
| 1156 | + :service: flows |
| 1157 | + :ref: Web-Inputs/paths/~1web_inputs~1{web_input_id}~1respond/post |
| 1158 | + """ |
| 1159 | + data = {"response": {"value": value}} |
| 1160 | + return self.post(f"/web_inputs/{web_input_id}/respond", data=data) |
| 1161 | + |
986 | 1162 |
|
987 | 1163 | class SpecificFlowClient(client.BaseClient): |
988 | 1164 | r""" |
|
0 commit comments