本文整理了Java中com.amazonaws.services.ec2.model.Tag.<init>()
方法的一些代码示例,展示了Tag.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Tag.<init>()
方法的具体详情如下:
包路径:com.amazonaws.services.ec2.model.Tag
类名称:Tag
方法名:<init>
[英]Default constructor for Tag object. Callers should use the setter or fluent setter (with...) methods to initialize the object after creating it.
[中]标记对象的默认构造函数。呼叫者应使用setter或fluent setter(带…)方法在创建对象后初始化该对象。
代码示例来源: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: h2oai/h2o-2
if( !tagsDone ) {
CreateTagsRequest createTagsRequest = new CreateTagsRequest();
createTagsRequest.withResources(ids).withTags(new Tag("Name", NAME));
ec2.createTags(createTagsRequest);
tagsDone = true;
代码示例来源:origin: awsdocs/aws-doc-sdk-examples
Tag tag = new Tag()
.withKey("Name")
.withValue(name);
代码示例来源: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: apache/usergrid
Tag t = new Tag();
t.setKey( "Name" );
t.setValue( runnerNames );
代码示例来源:origin: apache/usergrid
Tag t = new Tag();
t.setKey( "Name" );
t.setValue( instanceNames );
代码示例来源:origin: aws-amplify/aws-sdk-android
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) {
int xmlEvent = context.nextEvent();
if (xmlEvent == XmlPullParser.END_DOCUMENT) return tag;
if (xmlEvent == XmlPullParser.START_TAG) {
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 == XmlPullParser.END_TAG) {
if (context.getCurrentDepth() < originalDepth) {
return tag;
}
}
}
}
代码示例来源:origin: com.elastisys.scale/cloudpool.aws.commons
private List<Tag> tags() {
List<Tag> tags = new ArrayList<>();
for (Entry<String, String> tag : this.instanceTemplate.getTags().entrySet()) {
tags.add(new Tag(tag.getKey(), tag.getValue()));
}
return tags;
}
代码示例来源:origin: com.elastisys.scale/cloudpool.aws.commons
private Collection<Tag> tags() {
List<Tag> tags = new ArrayList<>();
for (Entry<String, String> tag : this.instanceTemplate.getTags().entrySet()) {
tags.add(new Tag(tag.getKey(), tag.getValue()));
}
return tags;
}
代码示例来源:origin: com.xebialabs.overthere/itest-support
protected void setInstanceName() {
ec2.createTags(new CreateTagsRequest(newArrayList(instanceId), newArrayList(new Tag("Name", hostLabel + " started at " + new Date()))));
}
代码示例来源:origin: com.xebialabs.cloud/overcast
protected void setInstanceName() {
ec2.createTags(new CreateTagsRequest(asList(instanceId), asList(new Tag("Name", hostLabel + " started at " + new Date()))));
}
代码示例来源:origin: org.kuali.common/kuali-aws
protected static List<Tag> getTags(EnvironmentService env) {
List<String> list = SpringUtils.getNoneSensitiveListFromCSV(env, TAGS_KEY, NullUtils.NONE);
List<Tag> tags = new ArrayList<Tag>();
for (String element : list) {
String[] tokens = Str.splitAndTrim(element, "=");
Assert.isTrue(tokens.length == 2, "Expected exactly 2 tokens");
String key = tokens[0];
String value = tokens[1];
Tag tag = new Tag(key, value);
tags.add(tag);
}
return ImmutableList.copyOf(tags);
}
代码示例来源:origin: tmobile/pacbot
/**
*
* @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;
}
}
代码示例来源:origin: electronicarts/gatling-aws-maven-plugin
@Override public void execute() throws MojoExecutionException, MojoFailureException {
final AwsGatlingRunner runner = new AwsGatlingRunner(this.ec2EndPoint);
runner.setInstanceTag(new Tag(this.ec2TagName, this.ec2TagValue));
final Map<String, Instance> instances = runner.findExistingInstances(this.instanceType);
runner.terminateInstances(instances.keySet());
}
}
代码示例来源:origin: UrbanCode/terraform
/**
*
* @param instanceId
* @param tag
* @param value
* @param ec2Client
*/
public void tagInstance(String instanceId, String tag, String value, AmazonEC2 ec2Client) {
//quick fix
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// swallow
}
CreateTagsRequest request = new CreateTagsRequest();
request = request.withResources(instanceId)
.withTags(new Tag(tag, value));
ec2Client.createTags(request);
}
代码示例来源:origin: LendingClub/mercator
@Test
public void testEc2Instance() throws IOException {
Instance instance = new Instance();
instance.setInstanceId("i-123456");
instance.setTags(Lists.newArrayList(new Tag("foo", "bar"), new Tag("fizz", "buzz")));
JsonNode n = new JsonConverter().toJson(instance);
Assertions.assertThat(n.path("aws_instanceId").asText()).isEqualTo("i-123456");
Assertions.assertThat(n.path("aws_tag_foo").asText()).isEqualTo("bar");
Assertions.assertThat(n.path("aws_tag_fizz").asText()).isEqualTo("buzz");
logger.info("{}", mapper.writerWithDefaultPrettyPrinter().writeValueAsString(n));
}
代码示例来源:origin: org.jenkins-ci.plugins/ec2
protected void clearLiveInstancedata() throws AmazonClientException {
Instance inst = getInstance(getInstanceId(), getCloud());
/* Now that we have our instance, we can clear the tags on it */
if (!tags.isEmpty()) {
HashSet<Tag> inst_tags = new HashSet<Tag>();
for(EC2Tag t : tags) {
inst_tags.add(new Tag(t.getName(), t.getValue()));
}
DeleteTagsRequest tag_request = new DeleteTagsRequest();
tag_request.withResources(inst.getInstanceId()).setTags(inst_tags);
getCloud().connect().deleteTags(tag_request);
}
}
代码示例来源:origin: org.jenkins-ci.plugins/ec2
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);
}
}
代码示例来源:origin: jenkinsci/ec2-plugin
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);
}
}
代码示例来源:origin: LendingClub/mercator
@Test
public void testIt() throws JsonProcessingException {
String account = "123456";
Regions region = Regions.US_WEST_1;
VPCScanner scanner = getProjector().createBuilder(AWSScannerBuilder.class).withAccountId(account).withRegion(region).buildVPCScanner();
Vpc vpc = new Vpc();
vpc.setVpcId("vpc-1234");
vpc.setCidrBlock("192.168.100.0/24");
vpc.setTags(Lists.newArrayList(new Tag("fizz","buzz")));
JsonNode n = scanner.convertAwsObject(vpc, Region.getRegion(region));
prettyPrint(n);
Assertions.assertThat(n.path("aws_region").asText()).isEqualTo(region.getName());
Assertions.assertThat(n.path("aws_account").asText()).isEqualTo(account);
Assertions.assertThat(n.path("aws_arn").asText()).isEqualTo("arn:aws:ec2:us-west-1:123456:vpc/vpc-1234");
Assertions.assertThat(n.path("aws_tag_fizz").asText()).isEqualTo("buzz");
Assertions.assertThat(n.path("aws_cidrBlock").asText()).isEqualTo("192.168.100.0/24");
}
}
内容来源于网络,如有侵权,请联系作者删除!