Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2010-2014 Amazon.com, Inc. or its affiliates. All Rights Reserved.
   * 
   * Licensed under the Apache License, Version 2.0 (the "License").
   * You may not use this file except in compliance with the License.
   * A copy of the License is located at
   * 
   *  http://aws.amazon.com/apache2.0
   * 
  * or in the "license" file accompanying this file. This file is distributed
  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
  * express or implied. See the License for the specific language governing
  * permissions and limitations under the License.
  */
 package com.amazonaws.services.ec2.model;
 
 
 import  com.amazonaws.services.ec2.model.transform.CreateTagsRequestMarshaller;

Container for the parameters to the CreateTags operation.

Adds or overwrites one or more tags for the specified EC2 resource or resources. Each resource can have a maximum of 10 tags. Each tag consists of a key and optional value. Tag keys must be unique per resource.

For more information about tags, see Tagging Your Resources in the Amazon Elastic Compute Cloud User Guide .

See also:
com.amazonaws.services.ec2.AmazonEC2.createTags(CreateTagsRequest)
 
 public class CreateTagsRequest extends AmazonWebServiceRequest implements Serializable, DryRunSupportedRequest<CreateTagsRequest> {

    
The IDs of one or more resources to tag. For example, ami-1a2b3c4d.
 
One or more tags. The value parameter is required, but if you don't want the tag to have a value, specify the parameter with no value, and we set the value to an empty string.
 
     private com.amazonaws.internal.ListWithAutoConstructFlag<Tag> tags;

    
Default constructor for a new CreateTagsRequest object. Callers should use the setter or fluent setter (with...) methods to initialize this object after creating it.
 
     public CreateTagsRequest() {}
    
    
Constructs a new CreateTagsRequest object. Callers should use the setter or fluent setter (with...) methods to initialize any additional object members.

Parameters:
resources The IDs of one or more resources to tag. For example, ami-1a2b3c4d.
tags One or more tags. The value parameter is required, but if you don't want the tag to have a value, specify the parameter with no value, and we set the value to an empty string.
 
     public CreateTagsRequest(java.util.List<Stringresourcesjava.util.List<Tag> tags) {
         setResources(resources);
         setTags(tags);
     }

    
The IDs of one or more resources to tag. For example, ami-1a2b3c4d.

Returns:
The IDs of one or more resources to tag. For example, ami-1a2b3c4d.
 
     public java.util.List<StringgetResources() {
         if ( == null) {
                = new com.amazonaws.internal.ListWithAutoConstructFlag<String>();
               .setAutoConstruct(true);
         }
         return ;
     }
    
    
The IDs of one or more resources to tag. For example, ami-1a2b3c4d.

Parameters:
resources The IDs of one or more resources to tag. For example, ami-1a2b3c4d.
 
     public void setResources(java.util.Collection<Stringresources) {
         if (resources == null) {
             this. = null;
             return;
         }
         resourcesCopy.addAll(resources);
        this. = resourcesCopy;
    }
    
    
The IDs of one or more resources to tag. For example, ami-1a2b3c4d.

Returns a reference to this object so that method calls can be chained together.

Parameters:
resources The IDs of one or more resources to tag. For example, ami-1a2b3c4d.
Returns:
A reference to this updated object so that method calls can be chained together.
    public CreateTagsRequest withResources(String... resources) {
        if (getResources() == nullsetResources(new java.util.ArrayList<String>(resources.length));
        for (String value : resources) {
            getResources().add(value);
        }
        return this;
    }
    
    
The IDs of one or more resources to tag. For example, ami-1a2b3c4d.

Returns a reference to this object so that method calls can be chained together.

Parameters:
resources The IDs of one or more resources to tag. For example, ami-1a2b3c4d.
Returns:
A reference to this updated object so that method calls can be chained together.
    public CreateTagsRequest withResources(java.util.Collection<Stringresources) {
        if (resources == null) {
            this. = null;
        } else {
            com.amazonaws.internal.ListWithAutoConstructFlag<StringresourcesCopy = new com.amazonaws.internal.ListWithAutoConstructFlag<String>(resources.size());
            resourcesCopy.addAll(resources);
            this. = resourcesCopy;
        }
        return this;
    }

    
One or more tags. The value parameter is required, but if you don't want the tag to have a value, specify the parameter with no value, and we set the value to an empty string.

Returns:
One or more tags. The value parameter is required, but if you don't want the tag to have a value, specify the parameter with no value, and we set the value to an empty string.
    public java.util.List<Tag> getTags() {
        if ( == null) {
               = new com.amazonaws.internal.ListWithAutoConstructFlag<Tag>();
              .setAutoConstruct(true);
        }
        return ;
    }
    
    
One or more tags. The value parameter is required, but if you don't want the tag to have a value, specify the parameter with no value, and we set the value to an empty string.

Parameters:
tags One or more tags. The value parameter is required, but if you don't want the tag to have a value, specify the parameter with no value, and we set the value to an empty string.
    public void setTags(java.util.Collection<Tag> tags) {
        if (tags == null) {
            this. = null;
            return;
        }
        com.amazonaws.internal.ListWithAutoConstructFlag<Tag> tagsCopy = new com.amazonaws.internal.ListWithAutoConstructFlag<Tag>(tags.size());
        tagsCopy.addAll(tags);
        this. = tagsCopy;
    }
    
    
One or more tags. The value parameter is required, but if you don't want the tag to have a value, specify the parameter with no value, and we set the value to an empty string.

Returns a reference to this object so that method calls can be chained together.

Parameters:
tags One or more tags. The value parameter is required, but if you don't want the tag to have a value, specify the parameter with no value, and we set the value to an empty string.
Returns:
A reference to this updated object so that method calls can be chained together.
    public CreateTagsRequest withTags(Tag... tags) {
        if (getTags() == nullsetTags(new java.util.ArrayList<Tag>(tags.length));
        for (Tag value : tags) {
            getTags().add(value);
        }
        return this;
    }
    
    
One or more tags. The value parameter is required, but if you don't want the tag to have a value, specify the parameter with no value, and we set the value to an empty string.

Returns a reference to this object so that method calls can be chained together.

Parameters:
tags One or more tags. The value parameter is required, but if you don't want the tag to have a value, specify the parameter with no value, and we set the value to an empty string.
Returns:
A reference to this updated object so that method calls can be chained together.
    public CreateTagsRequest withTags(java.util.Collection<Tag> tags) {
        if (tags == null) {
            this. = null;
        } else {
            com.amazonaws.internal.ListWithAutoConstructFlag<Tag> tagsCopy = new com.amazonaws.internal.ListWithAutoConstructFlag<Tag>(tags.size());
            tagsCopy.addAll(tags);
            this. = tagsCopy;
        }
        return this;
    }

    
This method is intended for internal use only. Returns the marshaled request configured with additional parameters to enable operation dry-run.
    @Override
        Request<CreateTagsRequestrequest = new CreateTagsRequestMarshaller().marshall(this);
        request.addParameter("DryRun", Boolean.toString(true));
        return request;
    }
    
    
Returns a string representation of this object; useful for testing and debugging.

Returns:
A string representation of this object.
See also:
java.lang.Object.toString()
    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("{");
        if (getResources() != nullsb.append("Resources: " + getResources() + ",");
        if (getTags() != nullsb.append("Tags: " + getTags() );
        sb.append("}");
        return sb.toString();
    }
    
    @Override
    public int hashCode() {
        final int prime = 31;
        int hashCode = 1;
        
        hashCode = prime * hashCode + ((getResources() == null) ? 0 : getResources().hashCode()); 
        hashCode = prime * hashCode + ((getTags() == null) ? 0 : getTags().hashCode()); 
        return hashCode;
    }
    
    @Override
    public boolean equals(Object obj) {
        if (this == objreturn true;
        if (obj == nullreturn false;
        if (obj instanceof CreateTagsRequest == falsereturn false;
        CreateTagsRequest other = (CreateTagsRequest)obj;
        
        if (other.getResources() == null ^ this.getResources() == nullreturn false;
        if (other.getResources() != null && other.getResources().equals(this.getResources()) == falsereturn false
        if (other.getTags() == null ^ this.getTags() == nullreturn false;
        if (other.getTags() != null && other.getTags().equals(this.getTags()) == falsereturn false
        return true;
    }
    
}
    
New to GrepCode? Check out our FAQ X