.withValue(name); CreateTagsRequest tag_request = new CreateTagsRequest() .withTags(tag);
tags.add( t ); CreateTagsRequest ctr = new CreateTagsRequest(); ctr.setTags( tags ); ctr.withResources( instanceIds.get( i ) ); client.createTags( ctr );
/** * Constructs a new CreateTagsRequest object. Callers should use the setter or fluent setter (with...) methods to * initialize any additional object members. * * @param resources * The IDs of one or more resources, separated by spaces.</p> * <p> * Constraints: Up to 1000 resource IDs. We recommend breaking up this request into smaller batches. * @param tags * One or more tags. The <code>value</code> 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<String> resources, java.util.List<Tag> tags) { setResources(resources); setTags(tags); }
int idx = 1; for (Instance instance : instances) { CreateTagsRequest createTagsRequest = new CreateTagsRequest(); createTagsRequest.withResources(instance.getInstanceId()) // .withTags(new Tag("Name", "travel-ecommerce-" + idx)); ec2.createTags(createTagsRequest);
try { if( !tagsDone ) { CreateTagsRequest createTagsRequest = new CreateTagsRequest(); createTagsRequest.withResources(ids).withTags(new Tag("Name", NAME)); ec2.createTags(createTagsRequest); tagsDone = true;
protected void setInstanceName() { ec2.createTags(new CreateTagsRequest(newArrayList(instanceId), newArrayList(new Tag("Name", hostLabel + " started at " + new Date())))); }
CreateTagsRequest tagRequest = new CreateTagsRequest(); String dateStr = ec2TagSimpleDateFormat.format(new Date()); tags.add(new Tag("Name","s3BktLdr-wkr-"+dateStr)); tagRequest.setResources(amiIds); tagRequest.setTags(tags);
/** * * @param resourceId * @param clientMap * @param pacTag * @return */ private Boolean setEC2VolumeTag(final String resourceId, final Map<String, Object> clientMap, Map<String, String> pacTag) { AmazonEC2 ec2Client = (AmazonEC2) clientMap.get("client"); CreateTagsRequest createTagsRequest = new CreateTagsRequest(Arrays.asList(resourceId), new ArrayList<>()); createTagsRequest.setTags(pacTag.entrySet().stream().map(t -> new Tag(t.getKey(), t.getValue())) .collect(Collectors.toList())); try { CreateTagsResult createTagsResult = ec2Client.createTags(createTagsRequest); return Boolean.TRUE; } catch (AmazonServiceException ase) { logger.error("error tagging ec2 - > " + resourceId, ase); throw ase; } }
/** * <p> * One or more tags. The <code>value</code> 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. * </p> * * @param tags * One or more tags. The <code>value</code> 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. * @return Returns a reference to this object so that method calls can be chained together. */ public CreateTagsRequest withTags(java.util.Collection<Tag> tags) { setTags(tags); return this; }
/** * One or more tags. The <code>value</code> 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. * <p> * Returns a reference to this object so that method calls can be chained together. * * @param tags One or more tags. The <code>value</code> 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. * * @return A reference to this updated object so that method calls can be chained * together. */ public CreateTagsRequest withTags(Tag... tags) { if (getTags() == null) setTags(new java.util.ArrayList<Tag>(tags.length)); for (Tag value : tags) { getTags().add(value); } return this; }
/** * <p> * The IDs of one or more resources, separated by spaces. * </p> * <p> * Constraints: Up to 1000 resource IDs. We recommend breaking up this request into smaller batches. * </p> * * @param resources * The IDs of one or more resources, separated by spaces.</p> * <p> * Constraints: Up to 1000 resource IDs. We recommend breaking up this request into smaller batches. * @return Returns a reference to this object so that method calls can be chained together. */ public CreateTagsRequest withResources(java.util.Collection<String> resources) { setResources(resources); return this; }
/** * The IDs of one or more resources to tag. For example, ami-1a2b3c4d. * <p> * Returns a reference to this object so that method calls can be chained together. * * @param resources The IDs of one or more resources to tag. For example, ami-1a2b3c4d. * * @return A reference to this updated object so that method calls can be chained * together. */ public CreateTagsRequest withResources(String... resources) { if (getResources() == null) setResources(new java.util.ArrayList<String>(resources.length)); for (String value : resources) { getResources().add(value); } return this; }
@Override public List<Tag> createTags(List<com.amazonaws.services.ec2.model.Tag> tags, List<String> resources, ResultCapture<Void> extractor) { CreateTagsRequest request = new CreateTagsRequest() .withTags(tags) .withResources(resources); return createTags(request, extractor); }
protected void setInstanceName() { ec2.createTags(new CreateTagsRequest(asList(instanceId), asList(new Tag("Name", hostLabel + " started at " + new Date())))); }
/** * <p> * One or more tags. The <code>value</code> 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. * </p> * <p> * <b>NOTE:</b> This method appends the values to the existing list (if any). Use * {@link #setTags(java.util.Collection)} or {@link #withTags(java.util.Collection)} if you want to override the * existing values. * </p> * * @param tags * One or more tags. The <code>value</code> 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. * @return Returns a reference to this object so that method calls can be chained together. */ public CreateTagsRequest withTags(Tag... tags) { if (this.tags == null) { setTags(new com.amazonaws.internal.SdkInternalList<Tag>(tags.length)); } for (Tag ele : tags) { this.tags.add(ele); } return this; }
/** * <p> * The IDs of one or more resources, separated by spaces. * </p> * <p> * Constraints: Up to 1000 resource IDs. We recommend breaking up this request into smaller batches. * </p> * <p> * <b>NOTE:</b> This method appends the values to the existing list (if any). Use * {@link #setResources(java.util.Collection)} or {@link #withResources(java.util.Collection)} if you want to * override the existing values. * </p> * * @param resources * The IDs of one or more resources, separated by spaces.</p> * <p> * Constraints: Up to 1000 resource IDs. We recommend breaking up this request into smaller batches. * @return Returns a reference to this object so that method calls can be chained together. */ public CreateTagsRequest withResources(String... resources) { if (this.resources == null) { setResources(new com.amazonaws.internal.SdkInternalList<String>(resources.length)); } for (String ele : resources) { this.resources.add(ele); } return this; }
@Override public List<com.amazonaws.resources.ec2.Tag> createTags(List<Tag> tags, ResultCapture<Void> extractor) { CreateTagsRequest request = new CreateTagsRequest() .withTags(tags); return createTags(request, extractor); }
tags.add( t ); CreateTagsRequest ctr = new CreateTagsRequest(); ctr.setTags( tags ); ctr.withResources( instanceIds.get( i ) ); client.createTags( ctr );
@Override public List<Tag> createTags(List<com.amazonaws.services.ec2.model.Tag> tags, List<String> resources, ResultCapture<Void> extractor) { CreateTagsRequest request = new CreateTagsRequest() .withTags(tags) .withResources(resources); return createTags(request, extractor); }
public void createVolume(String instanceId){ System.out.println("Creating the volume begins..."); CreateVolumeRequest creq = new CreateVolumeRequest(50, "us-west-2a"); CreateVolumeResult cres = ec2.createVolume(creq); // Create the list of tags we want to create System.out.println("Setting the tags to the volume..."); ArrayList<Tag> instanceTags = new ArrayList<Tag>(); instanceTags.add(new Tag("Name","Sachin")); CreateTagsRequest createTagsRequest = new CreateTagsRequest().withTags(instanceTags).withResources(cres.getVolume().getVolumeId()); ec2.createTags(createTagsRequest); System.out.println("Attaching the volume to the instance...."); AttachVolumeRequest areq = new AttachVolumeRequest(cres.getVolume().getVolumeId(),instanceId, "/dev/sdh"); AttachVolumeResult ares = ec2.attachVolume(areq); System.out.println("Creating the volume ends..."); }