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

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

Introduction

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

Prototype


public void setTags(java.util.Collection<Tag> tags) 

Source Link

Document

The tags to delete.

Usage

From source file:com.carrotgarden.maven.aws.ecc.CarrotElasticCompute.java

License:BSD License

public void tagDelete(final String resourceId, final String key, final String value) {

    final DeleteTagsRequest request = new DeleteTagsRequest();

    final Collection<String> resourceList = new ArrayList<String>(1);
    resourceList.add(resourceId);/*  w ww .  ja  v a 2 s. c o m*/

    final Collection<Tag> tagList = new ArrayList<Tag>(1);
    tagList.add(new Tag(key, value));

    request.setResources(resourceList);
    request.setTags(tagList);

    logger.info("tag delete request=" + request);

    amazonClient.deleteTags(request);

}

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 www.j a  v  a2 s  . c  o  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!
}