identityClient.createTag( CreateTagRequest.builder() .tagNamespaceId(tagNamespaceId) .createTagDetails( CreateTagDetails.builder() .name(tagOneName) .description("Java SDK example tag one") .build()) .build()); identityClient.createTag( CreateTagRequest.builder() .tagNamespaceId(tagNamespaceId) .createTagDetails( CreateTagDetails.builder() .name(tagTwoName) .description("Java SDK example tag two") .build()) .build());
public static Tag createTag( Identity client, String tagNamespaceId, String name, String description, boolean isCostTracking) { CreateTagDetails createTagDetails = CreateTagDetails.builder() .isCostTracking(isCostTracking) .name(name) .description(description) .build(); try { Tag tag = client.createTag( CreateTagRequest.builder() .createTagDetails(createTagDetails) .tagNamespaceId(tagNamespaceId) .build()) .getTag(); if (tag == null) { throw new RuntimeException( "Tag creation fails with " + createTagDetails.toString()); } System.out.println("Tag" + createTagDetails.getName() + " created successfully"); return tag; } catch (Exception ex) { throw new RuntimeException("Tag creation fails with error:" + ex.getMessage()); } }
/** * Build the instance of CreateTagRequest as configured by this builder * * Note that this method takes calls to {@link Builder#invocationCallback(com.oracle.bmc.util.internal.Consumer)} into account, * while the method {@link Builder#buildWithoutInvocationCallback} does not. * * This is the preferred method to build an instance. * * @return instance of CreateTagRequest */ public CreateTagRequest build() { CreateTagRequest request = buildWithoutInvocationCallback(); request.setInvocationCallback(invocationCallback); return request; } }
/** * Copy method to populate the builder with values from the given instance. * @return this builder instance */ public Builder copy(CreateTagRequest o) { tagNamespaceId(o.getTagNamespaceId()); createTagDetails(o.getCreateTagDetails()); opcRetryToken(o.getOpcRetryToken()); invocationCallback(o.getInvocationCallback()); return this; }