Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions,
see Getting Started with Amazon Web Services in China
(PDF).
Use DeleteOpsItem
with an Amazon SDK
The following code example shows how to use DeleteOpsItem
.
- Python
-
- SDK for Python (Boto3)
-
class OpsItemWrapper:
"""Encapsulates AWS Systems Manager OpsItem actions."""
def __init__(self, ssm_client):
"""
:param ssm_client: A Boto3 Systems Manager client.
"""
self.ssm_client = ssm_client
self.id = None
@classmethod
def from_client(cls):
"""
:return: A OpsItemWrapper instance.
"""
ssm_client = boto3.client("ssm")
return cls(ssm_client)
def delete(self):
"""
Delete the OpsItem.
"""
if self.id is None:
return
try:
self.ssm_client.delete_ops_item(OpsItemId=self.id)
print(f"Deleted ops item with id {self.id}")
self.id = None
except ClientError as err:
logger.error(
"Couldn't delete ops item %s. Here's why: %s: %s",
self.id,
err.response["Error"]["Code"],
err.response["Error"]["Message"],
)
raise
For a complete list of Amazon SDK developer guides and code examples, see
Using this service with an Amazon SDK.
This topic also includes information about getting started and details about previous SDK versions.