com.amazonaws.services.ec2.model.Tag类的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(9.6k)|赞(0)|评价(0)|浏览(95)

本文整理了Java中com.amazonaws.services.ec2.model.Tag类的一些代码示例,展示了Tag类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Tag类的具体详情如下:
包路径:com.amazonaws.services.ec2.model.Tag
类名称:Tag

Tag介绍

[英]Describes a tag.
[中]描述一个标签。

代码示例

代码示例来源:origin: opentripplanner/OpenTripPlanner

res.getReservation().getInstances().forEach(i -> {
  Collection<Tag> tags = Arrays.asList(
      new Tag("name", workerName),
      new Tag("project", project)
  );
  i.setTags(tags);

代码示例来源:origin: aws/aws-sdk-java

public Request<CreateTagsRequest> marshall(CreateTagsRequest createTagsRequest) {
    throw new SdkClientException("Invalid argument passed to marshall(...)");
  request.addParameter("Action", "CreateTags");
  request.addParameter("Version", "2016-11-15");
  request.setHttpMethod(HttpMethodName.POST);
  if (!createTagsRequestResourcesList.isEmpty() || !createTagsRequestResourcesList.isAutoConstruct()) {
    int resourcesListIndex = 1;
        request.addParameter("ResourceId." + resourcesListIndex, StringUtils.fromString(createTagsRequestResourcesListValue));
  if (!createTagsRequestTagsList.isEmpty() || !createTagsRequestTagsList.isAutoConstruct()) {
    int tagsListIndex = 1;
      if (createTagsRequestTagsListValue.getKey() != null) {
        request.addParameter("Tag." + tagsListIndex + ".Key", StringUtils.fromString(createTagsRequestTagsListValue.getKey()));
      if (createTagsRequestTagsListValue.getValue() != null) {
        request.addParameter("Tag." + tagsListIndex + ".Value", StringUtils.fromString(createTagsRequestTagsListValue.getValue()));

代码示例来源:origin: aws/aws-sdk-java

public Tag unmarshall(StaxUnmarshallerContext context) throws Exception {
  Tag tag = new Tag();
  int originalDepth = context.getCurrentDepth();
  int targetDepth = originalDepth + 1;
  if (context.isStartOfDocument())
    targetDepth += 1;
  while (true) {
    XMLEvent xmlEvent = context.nextEvent();
    if (xmlEvent.isEndDocument())
      return tag;
    if (xmlEvent.isAttribute() || xmlEvent.isStartElement()) {
      if (context.testExpression("key", targetDepth)) {
        tag.setKey(StringStaxUnmarshaller.getInstance().unmarshall(context));
        continue;
      }
      if (context.testExpression("value", targetDepth)) {
        tag.setValue(StringStaxUnmarshaller.getInstance().unmarshall(context));
        continue;
      }
    } else if (xmlEvent.isEndElement()) {
      if (context.getCurrentDepth() < originalDepth) {
        return tag;
      }
    }
  }
}

代码示例来源:origin: aws/aws-sdk-java

@Override
public int hashCode() {
  final int prime = 31;
  int hashCode = 1;
  hashCode = prime * hashCode + ((getKey() == null) ? 0 : getKey().hashCode());
  hashCode = prime * hashCode + ((getValue() == null) ? 0 : getValue().hashCode());
  return hashCode;
}

代码示例来源:origin: aws/aws-sdk-java

/**
 * Constructs a new Tag object. Callers should use the setter or fluent setter (with...) methods to initialize any
 * additional object members.
 * 
 * @param key
 *        The key of the tag.</p>
 *        <p>
 *        Constraints: Tag keys are case-sensitive and accept a maximum of 127 Unicode characters. May not begin
 *        with <code>aws:</code>.
 * @param value
 *        The value of the tag.
 *        </p>
 *        <p>
 *        Constraints: Tag values are case-sensitive and accept a maximum of 255 Unicode characters.
 */
public Tag(String key, String value) {
  setKey(key);
  setValue(value);
}

代码示例来源:origin: aws-amplify/aws-sdk-android

request.addParameter("Action", "DeleteTags");
request.addParameter("Version", "2015-10-01");
    request.addParameter("ResourceId." + resourcesListIndex, StringUtils.fromString(resourcesListValue));
  Tag tagMember = tagsListValue;
  if (tagMember != null) {
    if (tagMember.getKey() != null) {
      request.addParameter("Tag." + tagsListIndex + ".Key", StringUtils.fromString(tagMember.getKey()));
    if (tagMember.getValue() != null) {
      request.addParameter("Tag." + tagsListIndex + ".Value", StringUtils.fromString(tagMember.getValue()));

代码示例来源:origin: org.kuali.common/kuali-aws

protected Optional<Tag> getTag(List<Tag> tags, String key) {
  for (Tag tag : tags) {
    if (tag.getKey().equals(key)) {
      return Optional.of(tag);
    }
  }
  return absent();
}

代码示例来源:origin: awsdocs/aws-doc-sdk-examples

Tag tag = new Tag()
  .withKey("Name")
  .withValue(name);

代码示例来源:origin: h2oai/h2o-2

String name = null;
if( instance.getTags().size() > 0 )
 name = instance.getTags().get(0).getValue();
if( NAME.equals(name) )
 instances.add(instance);

代码示例来源:origin: aws/aws-sdk-java

/**
 * Constructs a new Tag object. Callers should use the setter or fluent setter (with...) methods to initialize any
 * additional object members.
 * 
 * @param key
 *        The key of the tag.</p>
 *        <p>
 *        Constraints: Tag keys are case-sensitive and accept a maximum of 127 Unicode characters. May not begin
 *        with <code>aws:</code>.
 */
public Tag(String key) {
  setKey(key);
}

代码示例来源:origin: aws/aws-sdk-java

/**
 * <p>
 * The value of the tag.
 * </p>
 * <p>
 * Constraints: Tag values are case-sensitive and accept a maximum of 255 Unicode characters.
 * </p>
 * 
 * @param value
 *        The value of the tag.</p>
 *        <p>
 *        Constraints: Tag values are case-sensitive and accept a maximum of 255 Unicode characters.
 * @return Returns a reference to this object so that method calls can be chained together.
 */
public Tag withValue(String value) {
  setValue(value);
  return this;
}

代码示例来源:origin: aws-amplify/aws-sdk-android

request.addParameter("Action", "CreateTags");
request.addParameter("Version", "2015-10-01");
    request.addParameter("ResourceId." + resourcesListIndex, StringUtils.fromString(resourcesListValue));
  Tag tagMember = tagsListValue;
  if (tagMember != null) {
    if (tagMember.getKey() != null) {
      request.addParameter("Tag." + tagsListIndex + ".Key", StringUtils.fromString(tagMember.getKey()));
    if (tagMember.getValue() != null) {
      request.addParameter("Tag." + tagsListIndex + ".Value", StringUtils.fromString(tagMember.getValue()));

代码示例来源:origin: aws/aws-sdk-java

@Override
public boolean equals(Object obj) {
  if (this == obj)
    return true;
  if (obj == null)
    return false;
  if (obj instanceof Tag == false)
    return false;
  Tag other = (Tag) obj;
  if (other.getKey() == null ^ this.getKey() == null)
    return false;
  if (other.getKey() != null && other.getKey().equals(this.getKey()) == false)
    return false;
  if (other.getValue() == null ^ this.getValue() == null)
    return false;
  if (other.getValue() != null && other.getValue().equals(this.getValue()) == false)
    return false;
  return true;
}

代码示例来源:origin: pinterest/soundwave

public static Tag getAwsTag(Instance awsInstance, String tagName) {
  List<Tag> tags = awsInstance.getTags();
  java.util.Optional<Tag> tag =
    tags.stream().filter(t -> StringUtils.equals(t.getKey(), tagName)).findFirst();
  return tag.isPresent() ? tag.get() : null;
 }
}

代码示例来源:origin: aws-amplify/aws-sdk-android

/**
 * Constructs a new Tag object.
 * Callers should use the setter or fluent setter (with...) methods to
 * initialize any additional object members.
 * 
 * @param key The key of the tag. <p>Constraints: Tag keys are
 * case-sensitive and accept a maximum of 127 Unicode characters. May not
 * begin with <code>aws:</code>
 * @param value The value of the tag. <p>Constraints: Tag values are
 * case-sensitive and accept a maximum of 255 Unicode characters.
 */
public Tag(String key, String value) {
  setKey(key);
  setValue(value);
}

代码示例来源:origin: aws/aws-sdk-java

/**
 * <p>
 * The key of the tag.
 * </p>
 * <p>
 * Constraints: Tag keys are case-sensitive and accept a maximum of 127 Unicode characters. May not begin with
 * <code>aws:</code>.
 * </p>
 * 
 * @param key
 *        The key of the tag.</p>
 *        <p>
 *        Constraints: Tag keys are case-sensitive and accept a maximum of 127 Unicode characters. May not begin
 *        with <code>aws:</code>.
 * @return Returns a reference to this object so that method calls can be chained together.
 */
public Tag withKey(String key) {
  setKey(key);
  return this;
}

代码示例来源:origin: com.amazonaws/aws-java-sdk-ec2

/**
 * <p>
 * The value of the tag.
 * </p>
 * <p>
 * Constraints: Tag values are case-sensitive and accept a maximum of 255 Unicode characters.
 * </p>
 * 
 * @param value
 *        The value of the tag.</p>
 *        <p>
 *        Constraints: Tag values are case-sensitive and accept a maximum of 255 Unicode characters.
 * @return Returns a reference to this object so that method calls can be chained together.
 */
public Tag withValue(String value) {
  setValue(value);
  return this;
}

代码示例来源:origin: aws/aws-sdk-java

public Request<DeleteTagsRequest> marshall(DeleteTagsRequest deleteTagsRequest) {
    throw new SdkClientException("Invalid argument passed to marshall(...)");
  request.addParameter("Action", "DeleteTags");
  request.addParameter("Version", "2016-11-15");
  request.setHttpMethod(HttpMethodName.POST);
  if (!deleteTagsRequestResourcesList.isEmpty() || !deleteTagsRequestResourcesList.isAutoConstruct()) {
    int resourcesListIndex = 1;
        request.addParameter("ResourceId." + resourcesListIndex, StringUtils.fromString(deleteTagsRequestResourcesListValue));
  if (!deleteTagsRequestTagsList.isEmpty() || !deleteTagsRequestTagsList.isAutoConstruct()) {
    int tagsListIndex = 1;
      if (deleteTagsRequestTagsListValue.getKey() != null) {
        request.addParameter("Tag." + tagsListIndex + ".Key", StringUtils.fromString(deleteTagsRequestTagsListValue.getKey()));
      if (deleteTagsRequestTagsListValue.getValue() != null) {
        request.addParameter("Tag." + tagsListIndex + ".Value", StringUtils.fromString(deleteTagsRequestTagsListValue.getValue()));

代码示例来源:origin: aws/aws-sdk-java

/**
 * Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be
 * redacted from this string using a placeholder value.
 *
 * @return A string representation of this object.
 *
 * @see java.lang.Object#toString()
 */
@Override
public String toString() {
  StringBuilder sb = new StringBuilder();
  sb.append("{");
  if (getKey() != null)
    sb.append("Key: ").append(getKey()).append(",");
  if (getValue() != null)
    sb.append("Value: ").append(getValue());
  sb.append("}");
  return sb.toString();
}

代码示例来源:origin: h2oai/h2o-2

if( !tagsDone ) {
 CreateTagsRequest createTagsRequest = new CreateTagsRequest();
 createTagsRequest.withResources(ids).withTags(new Tag("Name", NAME));
 ec2.createTags(createTagsRequest);
 tagsDone = true;

相关文章