/** * Copy method to populate the builder with values from the given instance. * @return this builder instance */ public Builder copy(CreateCompartmentRequest o) { createCompartmentDetails(o.getCreateCompartmentDetails()); opcRetryToken(o.getOpcRetryToken()); invocationCallback(o.getInvocationCallback()); return this; }
/** * Build the instance of CreateCompartmentRequest 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 CreateCompartmentRequest */ public CreateCompartmentRequest build() { CreateCompartmentRequest request = buildWithoutInvocationCallback(); request.setInvocationCallback(invocationCallback); return request; } }
public static com.oracle.bmc.http.internal.WrappedInvocationBuilder fromRequest( com.oracle.bmc.http.internal.RestClient client, CreateCompartmentRequest request) { Validate.notNull(request, "request instance is required"); Validate.notNull( request.getCreateCompartmentDetails(), "createCompartmentDetails is required"); com.oracle.bmc.http.internal.WrappedWebTarget target = client.getBaseTarget().path("/20160918").path("compartments"); com.oracle.bmc.http.internal.WrappedInvocationBuilder ib = target.request(); ib.accept(javax.ws.rs.core.MediaType.APPLICATION_JSON); if (request.getOpcRetryToken() != null) { ib.header("opc-retry-token", request.getOpcRetryToken()); } return ib; }
private static Compartment createCompartment( Identity client, String compartmentId, String name) { CreateCompartmentDetails createCompartmentDetails = CreateCompartmentDetails.builder() .compartmentId(compartmentId) .name(name) .description(name) .build(); Compartment compartment = client.createCompartment( CreateCompartmentRequest.builder() .createCompartmentDetails(createCompartmentDetails) .build()) .getCompartment(); if (compartment == null) { throw new RuntimeException( "Compartment creation fails with " + createCompartmentDetails.toString()); } System.out.println("Compartment " + compartment.getName() + " created successfully"); return compartment; } }
@Override public CreateCompartmentResponse createCompartment(CreateCompartmentRequest request) { LOG.trace("Called createCompartment"); request = CreateCompartmentConverter.interceptRequest(request); com.oracle.bmc.http.internal.WrappedInvocationBuilder ib = CreateCompartmentConverter.fromRequest(client, request); com.google.common.base.Function<javax.ws.rs.core.Response, CreateCompartmentResponse> transformer = CreateCompartmentConverter.fromResponse(); int attempts = 0; while (true) { try { javax.ws.rs.core.Response response = client.post(ib, request.getCreateCompartmentDetails(), request); return transformer.apply(response); } catch (com.oracle.bmc.model.BmcException e) { if (++attempts < MAX_IMMEDIATE_RETRIES_IF_USING_INSTANCE_PRINCIPALS && canRetryRequestIfRefreshableAuthTokenUsed(e)) { continue; } else { throw e; } } } }
private static Compartment createChildCompartment( Identity client, String compartmentId, String name) { CreateCompartmentDetails createCompartmentDetails = CreateCompartmentDetails.builder() .compartmentId(compartmentId) .name(name) .description(name) .build(); Compartment compartment = client.createCompartment( CreateCompartmentRequest.builder() .createCompartmentDetails(createCompartmentDetails) .build()) .getCompartment(); if (compartment == null) { throw new RuntimeException( "Compartment creation fails with " + createCompartmentDetails.toString()); } System.out.println("Compartment " + compartment.getName() + " created successfully"); return compartment; }
client.post( ib, interceptedRequest.getCreateCompartmentDetails(), interceptedRequest, onSuccess,