Search in sources :

Example 1 with SsmException

use of software.amazon.awssdk.services.ssm.model.SsmException in project aws-doc-sdk-examples by awsdocs.

the class GetParameter method getParaValue.

// snippet-start:[ssm.Java2.get_para_value.main]
public static void getParaValue(SsmClient ssmClient, String paraName) {
    try {
        GetParameterRequest parameterRequest = GetParameterRequest.builder().name(paraName).build();
        GetParameterResponse parameterResponse = ssmClient.getParameter(parameterRequest);
        System.out.println("The parameter value is " + parameterResponse.parameter().value());
    } catch (SsmException e) {
        System.err.println(e.getMessage());
        System.exit(1);
    }
}
Also used : GetParameterRequest(software.amazon.awssdk.services.ssm.model.GetParameterRequest) GetParameterResponse(software.amazon.awssdk.services.ssm.model.GetParameterResponse) SsmException(software.amazon.awssdk.services.ssm.model.SsmException)

Example 2 with SsmException

use of software.amazon.awssdk.services.ssm.model.SsmException in project aws-doc-sdk-examples by awsdocs.

the class CreateOpsItem method createNewOpsItem.

// snippet-start:[ssm.java2.create_ops.main]
public static String createNewOpsItem(SsmClient ssmClient, String title, String source, String category, String severity) {
    try {
        CreateOpsItemRequest opsItemRequest = CreateOpsItemRequest.builder().description("Created by the SSM Java API").title(title).source(source).category(category).severity(severity).build();
        CreateOpsItemResponse itemResponse = ssmClient.createOpsItem(opsItemRequest);
        return itemResponse.opsItemId();
    } catch (SsmException e) {
        System.err.println(e.getMessage());
        System.exit(1);
    }
    return "";
}
Also used : CreateOpsItemRequest(software.amazon.awssdk.services.ssm.model.CreateOpsItemRequest) CreateOpsItemResponse(software.amazon.awssdk.services.ssm.model.CreateOpsItemResponse) SsmException(software.amazon.awssdk.services.ssm.model.SsmException)

Example 3 with SsmException

use of software.amazon.awssdk.services.ssm.model.SsmException in project aws-doc-sdk-examples by awsdocs.

the class DescribeOpsItems method describeItems.

// snippet-start:[ssm.java2.describe_ops.main]
public static void describeItems(SsmClient ssmClient) {
    try {
        DescribeOpsItemsRequest itemsRequest = DescribeOpsItemsRequest.builder().maxResults(10).build();
        DescribeOpsItemsResponse itemsResponse = ssmClient.describeOpsItems(itemsRequest);
        List<OpsItemSummary> items = itemsResponse.opsItemSummaries();
        for (OpsItemSummary item : items) {
            System.out.println("The item title is " + item.title());
        }
    } catch (SsmException e) {
        System.err.println(e.getMessage());
        System.exit(1);
    }
}
Also used : DescribeOpsItemsRequest(software.amazon.awssdk.services.ssm.model.DescribeOpsItemsRequest) DescribeOpsItemsResponse(software.amazon.awssdk.services.ssm.model.DescribeOpsItemsResponse) SsmException(software.amazon.awssdk.services.ssm.model.SsmException) OpsItemSummary(software.amazon.awssdk.services.ssm.model.OpsItemSummary)

Example 4 with SsmException

use of software.amazon.awssdk.services.ssm.model.SsmException in project aws-doc-sdk-examples by awsdocs.

the class GetOpsItem method getOpsItem.

// snippet-start:[ssm.Java2.get_ops.main]
public static void getOpsItem(SsmClient ssmClient, String opsID) {
    try {
        GetOpsItemRequest opsRequest = GetOpsItemRequest.builder().opsItemId(opsID).build();
        // Get SSM Parameters (you can define them in the AWS Management Console)
        GetOpsItemResponse opsItem = ssmClient.getOpsItem(opsRequest);
        OpsItem item = opsItem.opsItem();
        System.out.println(item.title());
        System.out.println(item.description());
        System.out.println(item.source());
    } catch (SsmException e) {
        System.err.println(e.getMessage());
        System.exit(1);
    }
}
Also used : GetOpsItemResponse(software.amazon.awssdk.services.ssm.model.GetOpsItemResponse) OpsItem(software.amazon.awssdk.services.ssm.model.OpsItem) GetOpsItemRequest(software.amazon.awssdk.services.ssm.model.GetOpsItemRequest) SsmException(software.amazon.awssdk.services.ssm.model.SsmException)

Example 5 with SsmException

use of software.amazon.awssdk.services.ssm.model.SsmException in project aws-doc-sdk-examples by awsdocs.

the class ResolveOpsItem method setOpsItemStatus.

// snippet-start:[ssm.Java2.resolve_ops.main]
public static void setOpsItemStatus(SsmClient ssmClient, String opsID) {
    try {
        UpdateOpsItemRequest opsItemRequest = UpdateOpsItemRequest.builder().opsItemId(opsID).status(OpsItemStatus.RESOLVED).build();
        ssmClient.updateOpsItem(opsItemRequest);
    } catch (SsmException e) {
        System.err.println(e.getMessage());
        System.exit(1);
    }
}
Also used : UpdateOpsItemRequest(software.amazon.awssdk.services.ssm.model.UpdateOpsItemRequest) SsmException(software.amazon.awssdk.services.ssm.model.SsmException)

Aggregations

SsmException (software.amazon.awssdk.services.ssm.model.SsmException)6 CreateOpsItemRequest (software.amazon.awssdk.services.ssm.model.CreateOpsItemRequest)1 CreateOpsItemResponse (software.amazon.awssdk.services.ssm.model.CreateOpsItemResponse)1 DescribeOpsItemsRequest (software.amazon.awssdk.services.ssm.model.DescribeOpsItemsRequest)1 DescribeOpsItemsResponse (software.amazon.awssdk.services.ssm.model.DescribeOpsItemsResponse)1 DescribeParametersRequest (software.amazon.awssdk.services.ssm.model.DescribeParametersRequest)1 DescribeParametersResponse (software.amazon.awssdk.services.ssm.model.DescribeParametersResponse)1 GetOpsItemRequest (software.amazon.awssdk.services.ssm.model.GetOpsItemRequest)1 GetOpsItemResponse (software.amazon.awssdk.services.ssm.model.GetOpsItemResponse)1 GetParameterRequest (software.amazon.awssdk.services.ssm.model.GetParameterRequest)1 GetParameterResponse (software.amazon.awssdk.services.ssm.model.GetParameterResponse)1 OpsItem (software.amazon.awssdk.services.ssm.model.OpsItem)1 OpsItemSummary (software.amazon.awssdk.services.ssm.model.OpsItemSummary)1 ParameterMetadata (software.amazon.awssdk.services.ssm.model.ParameterMetadata)1 UpdateOpsItemRequest (software.amazon.awssdk.services.ssm.model.UpdateOpsItemRequest)1