/** * Copy method to populate the builder with values from the given instance. * @return this builder instance */ public Builder copy(CreateCertificateRequest o) { createCertificateDetails(o.getCreateCertificateDetails()); loadBalancerId(o.getLoadBalancerId()); opcRequestId(o.getOpcRequestId()); opcRetryToken(o.getOpcRetryToken()); invocationCallback(o.getInvocationCallback()); return this; }
/** * Build the instance of CreateCertificateRequest 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 CreateCertificateRequest */ public CreateCertificateRequest build() { CreateCertificateRequest request = buildWithoutInvocationCallback(); request.setInvocationCallback(invocationCallback); return request; } }
@Override public CreateCertificateResponse createCertificate(CreateCertificateRequest request) { LOG.trace("Called createCertificate"); request = CreateCertificateConverter.interceptRequest(request); com.oracle.bmc.http.internal.WrappedInvocationBuilder ib = CreateCertificateConverter.fromRequest(client, request); com.google.common.base.Function<javax.ws.rs.core.Response, CreateCertificateResponse> transformer = CreateCertificateConverter.fromResponse(); int attempts = 0; while (true) { try { javax.ws.rs.core.Response response = client.post(ib, request.getCreateCertificateDetails(), 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; } } } }
void updateCertificates(LoadBalancer lb, Task task) { if (lb.getCertificates() != null) { lb.getCertificates().forEach( (name, existingCert) -> { CertificateDetails cert = (description.getCertificates() != null)? description.getCertificates().get(name) : null; if (cert == null) { // Delete certificate: must have no listener using it DeleteCertificateResponse res = description.getCredentials().getLoadBalancerClient().deleteCertificate( DeleteCertificateRequest.builder().loadBalancerId(lb.getId()).certificateName(name).build()); task.updateStatus(UPDATE, "DeleteCertificateRequest of ${name} submitted - work request id: ${rs.getOpcWorkRequestId()}"); OracleWorkRequestPoller.poll(res.getOpcWorkRequestId(), UPDATE, task, description.getCredentials().getLoadBalancerClient()); } }); } // Add new certificate Map<String, CertificateDetails> certificates = description.getCertificates(); if (certificates != null) { certificates.forEach( (name, details) -> { Certificate cert = lb.getCertificates().get(name); if (cert == null) { CreateCertificateResponse res = description.getCredentials().getLoadBalancerClient().createCertificate( CreateCertificateRequest.builder().loadBalancerId(description.getLoadBalancerId()) .createCertificateDetails(toCreate(details, name)).build()); task.updateStatus(UPDATE, "CreateCertificateRequest of ${name} submitted - work request id: ${rs.getOpcWorkRequestId()}"); OracleWorkRequestPoller.poll(res.getOpcWorkRequestId(), UPDATE, task, description.getCredentials().getLoadBalancerClient()); } }); } }
client.post( ib, interceptedRequest.getCreateCertificateDetails(), interceptedRequest, onSuccess,
public static com.oracle.bmc.http.internal.WrappedInvocationBuilder fromRequest( com.oracle.bmc.http.internal.RestClient client, CreateCertificateRequest request) { Validate.notNull(request, "request instance is required"); Validate.notNull( request.getCreateCertificateDetails(), "createCertificateDetails is required"); Validate.notBlank(request.getLoadBalancerId(), "loadBalancerId must not be blank"); com.oracle.bmc.http.internal.WrappedWebTarget target = client.getBaseTarget() .path("/20170115") .path("loadBalancers") .path( com.oracle.bmc.util.internal.HttpUtils.encodePathSegment( request.getLoadBalancerId())) .path("certificates"); com.oracle.bmc.http.internal.WrappedInvocationBuilder ib = target.request(); ib.accept(javax.ws.rs.core.MediaType.APPLICATION_JSON); if (request.getOpcRequestId() != null) { ib.header("opc-request-id", request.getOpcRequestId()); } if (request.getOpcRetryToken() != null) { ib.header("opc-retry-token", request.getOpcRetryToken()); } return ib; }