Find an activity by name. This requires listing activities until one is found with a matching name. :param name: The name of the activity to search for. :return: If found, the ARN of the activity; otherwise, None.
(self, name)
| 55 | |
| 56 | # snippet-start:[python.example_code.sfn.ListActivities] |
| 57 | def find(self, name): |
| 58 | """ |
| 59 | Find an activity by name. This requires listing activities until one is found |
| 60 | with a matching name. |
| 61 | |
| 62 | :param name: The name of the activity to search for. |
| 63 | :return: If found, the ARN of the activity; otherwise, None. |
| 64 | """ |
| 65 | try: |
| 66 | paginator = self.stepfunctions_client.get_paginator("list_activities") |
| 67 | for page in paginator.paginate(): |
| 68 | for activity in page.get("activities", []): |
| 69 | if activity["name"] == name: |
| 70 | return activity["activityArn"] |
| 71 | except ClientError as err: |
| 72 | logger.error( |
| 73 | "Couldn't list activities. Here's why: %s: %s", |
| 74 | err.response["Error"]["Code"], |
| 75 | err.response["Error"]["Message"], |
| 76 | ) |
| 77 | raise |
| 78 | |
| 79 | # snippet-end:[python.example_code.sfn.ListActivities] |
| 80 |