com.oracle.bmc.waf.internal.http.GetWebAppFirewallConverter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of oci-java-sdk-waf Show documentation
Show all versions of oci-java-sdk-waf Show documentation
This project contains the SDK used for Oracle Cloud Infrastructure Waf
/**
* Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved.
* This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license.
*/
package com.oracle.bmc.waf.internal.http;
import com.oracle.bmc.http.internal.ResponseHelper;
import com.oracle.bmc.waf.model.*;
import com.oracle.bmc.waf.requests.*;
import com.oracle.bmc.waf.responses.*;
import com.oracle.bmc.util.internal.Validate;
@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20210930")
public class GetWebAppFirewallConverter {
private static final com.oracle.bmc.http.internal.ResponseConversionFunctionFactoryV2
RESPONSE_CONVERSION_FACTORY =
new com.oracle.bmc.http.internal.ResponseConversionFunctionFactoryV2();
private static final org.slf4j.Logger LOG =
org.slf4j.LoggerFactory.getLogger(GetWebAppFirewallConverter.class);
public static com.oracle.bmc.waf.requests.GetWebAppFirewallRequest interceptRequest(
com.oracle.bmc.waf.requests.GetWebAppFirewallRequest request) {
return request;
}
public static com.oracle.bmc.http.internal.WrappedInvocationBuilder fromRequest(
com.oracle.bmc.http.internal.RestClient client,
com.oracle.bmc.waf.requests.GetWebAppFirewallRequest request) {
Validate.notNull(request, "request instance is required");
Validate.notBlank(request.getWebAppFirewallId(), "webAppFirewallId must not be blank");
com.oracle.bmc.http.internal.WrappedWebTarget target =
client.getBaseTarget()
.path("/20210930")
.path("webAppFirewalls")
.path(
com.oracle.bmc.util.internal.HttpUtils.encodePathSegment(
request.getWebAppFirewallId()));
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 (client.getClientConfigurator() != null) {
client.getClientConfigurator().customizeRequest(request, ib);
}
return ib;
}
public static java.util.function.Function<
javax.ws.rs.core.Response,
com.oracle.bmc.waf.responses.GetWebAppFirewallResponse>
fromResponse() {
return fromResponse(java.util.Optional.empty());
}
public static java.util.function.Function<
javax.ws.rs.core.Response,
com.oracle.bmc.waf.responses.GetWebAppFirewallResponse>
fromResponse(java.util.Optional serviceDetails) {
final java.util.function.Function<
javax.ws.rs.core.Response,
com.oracle.bmc.waf.responses.GetWebAppFirewallResponse>
transformer =
new java.util.function.Function<
javax.ws.rs.core.Response,
com.oracle.bmc.waf.responses.GetWebAppFirewallResponse>() {
@Override
public com.oracle.bmc.waf.responses.GetWebAppFirewallResponse apply(
javax.ws.rs.core.Response rawResponse) {
LOG.trace(
"Transform function invoked for com.oracle.bmc.waf.responses.GetWebAppFirewallResponse");
final java.util.function.Function<
javax.ws.rs.core.Response,
com.oracle.bmc.http.internal.WithHeaders<
com.oracle.bmc.waf.model.WebAppFirewall>>
responseFn;
if (serviceDetails.isPresent()) {
responseFn =
RESPONSE_CONVERSION_FACTORY.create(
com.oracle.bmc.waf.model.WebAppFirewall.class,
serviceDetails.get());
} else {
responseFn =
RESPONSE_CONVERSION_FACTORY.create(
com.oracle.bmc.waf.model.WebAppFirewall.class);
}
com.oracle.bmc.http.internal.WithHeaders<
com.oracle.bmc.waf.model.WebAppFirewall>
response = responseFn.apply(rawResponse);
javax.ws.rs.core.MultivaluedMap headers =
response.getHeaders();
com.oracle.bmc.waf.responses.GetWebAppFirewallResponse.Builder
builder =
com.oracle.bmc.waf.responses
.GetWebAppFirewallResponse.builder()
.__httpStatusCode__(rawResponse.getStatus())
.headers(headers);
builder.webAppFirewall(response.getItem());
java.util.Optional> etagHeader =
com.oracle.bmc.http.internal.HeaderUtils.getHeadersWithName(
headers, "etag");
if (etagHeader.isPresent()) {
builder.etag(
com.oracle.bmc.http.internal.HeaderUtils.toValue(
"etag", etagHeader.get().get(0), String.class));
}
java.util.Optional> opcRequestIdHeader =
com.oracle.bmc.http.internal.HeaderUtils.getHeadersWithName(
headers, "opc-request-id");
if (opcRequestIdHeader.isPresent()) {
builder.opcRequestId(
com.oracle.bmc.http.internal.HeaderUtils.toValue(
"opc-request-id",
opcRequestIdHeader.get().get(0),
String.class));
}
com.oracle.bmc.waf.responses.GetWebAppFirewallResponse
responseWrapper = builder.build();
ResponseHelper.closeResponseSilentlyIfNotBuffered(rawResponse);
return responseWrapper;
}
};
return transformer;
}
}