Services or capabilities described in AWS documentation might vary by Region. To see the differences applicable to the AWS European Sovereign Cloud Region, see the AWS European Sovereign Cloud User Guide.Use DeleteOpsItem with an AWS SDK
The following code examples show 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
- SAP ABAP
-
- SDK for SAP ABAP
-
TRY.
lo_ssm->deleteopsitem( iv_opsitemid = iv_ops_item_id ).
MESSAGE 'OpsItem deleted.' TYPE 'I'.
CATCH /aws1/cx_ssmopsiteminvparamex.
MESSAGE 'Invalid OpsItem parameter.' TYPE 'I'.
ENDTRY.
For a complete list of AWS SDK developer guides and code examples, see
Using this service with an AWS SDK.
This topic also includes information about getting started and details about previous SDK versions.