Create an OpsItem :param title: The OpsItem title. :param source: The OpsItem source. :param category: The OpsItem category. :param severity: The OpsItem severity. :param description: The OpsItem description.
(self, title, source, category, severity, description)
| 33 | |
| 34 | # snippet-start:[python.example_code.ssm.CreateOpsItem] |
| 35 | def create(self, title, source, category, severity, description): |
| 36 | """ |
| 37 | Create an OpsItem |
| 38 | |
| 39 | :param title: The OpsItem title. |
| 40 | :param source: The OpsItem source. |
| 41 | :param category: The OpsItem category. |
| 42 | :param severity: The OpsItem severity. |
| 43 | :param description: The OpsItem description. |
| 44 | |
| 45 | """ |
| 46 | try: |
| 47 | response = self.ssm_client.create_ops_item( |
| 48 | Title=title, |
| 49 | Source=source, |
| 50 | Category=category, |
| 51 | Severity=severity, |
| 52 | Description=description, |
| 53 | ) |
| 54 | self.id = response["OpsItemId"] |
| 55 | except self.ssm_client.exceptions.OpsItemLimitExceededException as err: |
| 56 | logger.error( |
| 57 | "Couldn't create ops item because you have exceeded your open OpsItem limit. " |
| 58 | "Here's why: %s: %s", |
| 59 | err.response["Error"]["Code"], |
| 60 | err.response["Error"]["Message"], |
| 61 | ) |
| 62 | raise |
| 63 | except ClientError as err: |
| 64 | logger.error( |
| 65 | "Couldn't create ops item %s. Here's why: %s: %s", |
| 66 | title, |
| 67 | err.response["Error"]["Code"], |
| 68 | err.response["Error"]["Message"], |
| 69 | ) |
| 70 | raise |
| 71 | # snippet-end:[python.example_code.ssm.CreateOpsItem] |
| 72 | |
| 73 | # snippet-start:[python.example_code.ssm.DeleteOpsItem] |
| 74 | def delete(self): |
no outgoing calls