/** * <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; }
/** * 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); }
/** * <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; }
ctr.setTags( tags ); ctr.withResources( instanceIds.get( i ) ); client.createTags( ctr );
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 to tag. For example, * ami-1a2b3c4d. * @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); }
/** * 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> * 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; }
/** * 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); }
/** * * @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; } }
CreateTagsRequest createTagsRequest = new CreateTagsRequest(); createTagsRequest.setTags(tags); createTagsRequest.withResources(vpcres.getVpc().getVpcId()) ; ec2.createTags(createTagsRequest);
/** * <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; }
tagRequest.setTags(tags);
/** * Update the tags stored in EC2 with the specified information. * Re-try 5 times if instances isn't up by catchErrorCode - e.g. InvalidSpotInstanceRequestID.NotFound or InvalidInstanceRequestID.NotFound * @param ec2 * @param inst_tags * @param catchErrorCode * @param params * @throws InterruptedException */ private void updateRemoteTags(AmazonEC2 ec2, Collection<Tag> inst_tags, String catchErrorCode, String... params) throws InterruptedException { for (int i = 0; i < 5; i++) { try { CreateTagsRequest tag_request = new CreateTagsRequest(); tag_request.withResources(params).setTags(inst_tags); ec2.createTags(tag_request); break; } catch (AmazonServiceException e) { if (e.getErrorCode().equals(catchErrorCode)) { Thread.sleep(5000); continue; } LOGGER.log(Level.SEVERE, e.getErrorMessage(), e); } } }
/** * Update the tags stored in EC2 with the specified information. Re-try 5 times if instances isn't up by * catchErrorCode - e.g. InvalidSpotInstanceRequestID.NotFound or InvalidInstanceRequestID.NotFound * * @param ec2 * @param instTags * @param catchErrorCode * @param params * @throws InterruptedException */ private void updateRemoteTags(AmazonEC2 ec2, Collection<Tag> instTags, String catchErrorCode, String... params) throws InterruptedException { for (int i = 0; i < 5; i++) { try { CreateTagsRequest tagRequest = new CreateTagsRequest(); tagRequest.withResources(params).setTags(instTags); ec2.createTags(tagRequest); break; } catch (AmazonServiceException e) { if (e.getErrorCode().equals(catchErrorCode)) { Thread.sleep(5000); continue; } LOGGER.log(Level.SEVERE, e.getErrorMessage(), e); } } }
protected void pushLiveInstancedata() throws AmazonClientException { Instance inst = getInstance(getInstanceId(), getCloud()); /* Now that we have our instance, we can set tags on it */ if (inst != null && tags != null && !tags.isEmpty()) { HashSet<Tag> inst_tags = new HashSet<Tag>(); for(EC2Tag t : tags) { inst_tags.add(new Tag(t.getName(), t.getValue())); } CreateTagsRequest tag_request = new CreateTagsRequest(); tag_request.withResources(inst.getInstanceId()).setTags(inst_tags); getCloud().connect().createTags(tag_request); } }
protected void pushLiveInstancedata() throws AmazonClientException { Instance inst = null; try { inst = CloudHelper.getInstanceWithRetry(getInstanceId(), getCloud()); } catch (InterruptedException e) { // We'll just retry next time we test for idleness. LOGGER.fine("InterruptedException while get " + getInstanceId() + " Exception: " + e); } /* Now that we have our instance, we can set tags on it */ if (inst != null && tags != null && !tags.isEmpty()) { HashSet<Tag> instTags = new HashSet<Tag>(); for (EC2Tag t : tags) { instTags.add(new Tag(t.getName(), t.getValue())); } List<String> resources = getResourcesToTag(inst); CreateTagsRequest tagRequest = new CreateTagsRequest(); tagRequest.withResources(resources).setTags(instTags); getCloud().connect().createTags(tagRequest); } }
tags.add(t); CreateTagsRequest ctr = new CreateTagsRequest(); ctr.setTags(tags); ctr.withResources(instanceId); this.ec2.createTags(ctr);