Example usage for com.amazonaws.services.ec2.model DeleteTagsRequest DeleteTagsRequest

List of usage examples for com.amazonaws.services.ec2.model DeleteTagsRequest DeleteTagsRequest

Introduction

In this page you can find the example usage for com.amazonaws.services.ec2.model DeleteTagsRequest DeleteTagsRequest.

Prototype

public DeleteTagsRequest(java.util.List<String> resources) 

Source Link

Document

Constructs a new DeleteTagsRequest object.

Usage

From source file:org.elasticdroid.model.ControlInstancesModel.java

License:Open Source License

public Object deleteTags(List<String> instances) {

    //create credentials using the BasicAWSCredentials class
    BasicAWSCredentials credentials = new BasicAWSCredentials(connectionData.get("accessKey"),
            connectionData.get("secretAccessKey"));
    //create Amazon EC2 Client object, and set tye end point to the region. params[3]
    //contains endpoint
    AmazonEC2Client amazonEC2Client = new AmazonEC2Client(credentials);

    //override the default connection endpoint if provided.
    if (connectionData.get("endpoint") != null) {
        amazonEC2Client.setEndpoint(connectionData.get("endpoint"));
    }//from   w ww.j  a  va  2s  .co  m

    //create empty tags for each of the instances from which the name tag is to be deleted.
    for (String instance : instances) {
        Log.v(TAG, "Tagging " + instance);
        //create a tag with Name for each instance from which Name tag is to be deleted.
        ec2Tags.add(new Tag("Name"));
    }

    DeleteTagsRequest request = new DeleteTagsRequest(instances);
    request.setTags(ec2Tags);

    //okay, tag the instance
    try {
        amazonEC2Client.deleteTags(request);
    } catch (AmazonServiceException amazonServiceException) {
        return amazonServiceException;
    } catch (AmazonClientException amazonClientException) {
        return amazonClientException;
    }

    return new Boolean(true); //return true to indicate success!
}