com.oracle.bmc.waf.internal.http.GetWebAppFirewallPolicyConverter 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 GetWebAppFirewallPolicyConverter {
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(GetWebAppFirewallPolicyConverter.class);
public static com.oracle.bmc.waf.requests.GetWebAppFirewallPolicyRequest interceptRequest(
com.oracle.bmc.waf.requests.GetWebAppFirewallPolicyRequest request) {
return request;
}
public static com.oracle.bmc.http.internal.WrappedInvocationBuilder fromRequest(
com.oracle.bmc.http.internal.RestClient client,
com.oracle.bmc.waf.requests.GetWebAppFirewallPolicyRequest request) {
Validate.notNull(request, "request instance is required");
Validate.notBlank(
request.getWebAppFirewallPolicyId(), "webAppFirewallPolicyId must not be blank");
com.oracle.bmc.http.internal.WrappedWebTarget target =
client.getBaseTarget()
.path("/20210930")
.path("webAppFirewallPolicies")
.path(
com.oracle.bmc.util.internal.HttpUtils.encodePathSegment(
request.getWebAppFirewallPolicyId()));
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.GetWebAppFirewallPolicyResponse>
fromResponse() {
return fromResponse(java.util.Optional.empty());
}
public static java.util.function.Function<
javax.ws.rs.core.Response,
com.oracle.bmc.waf.responses.GetWebAppFirewallPolicyResponse>
fromResponse(java.util.Optional serviceDetails) {
final java.util.function.Function<
javax.ws.rs.core.Response,
com.oracle.bmc.waf.responses.GetWebAppFirewallPolicyResponse>
transformer =
new java.util.function.Function<
javax.ws.rs.core.Response,
com.oracle.bmc.waf.responses.GetWebAppFirewallPolicyResponse>() {
@Override
public com.oracle.bmc.waf.responses.GetWebAppFirewallPolicyResponse
apply(javax.ws.rs.core.Response rawResponse) {
LOG.trace(
"Transform function invoked for com.oracle.bmc.waf.responses.GetWebAppFirewallPolicyResponse");
final java.util.function.Function<
javax.ws.rs.core.Response,
com.oracle.bmc.http.internal.WithHeaders<
com.oracle.bmc.waf.model
.WebAppFirewallPolicy>>
responseFn;
if (serviceDetails.isPresent()) {
responseFn =
RESPONSE_CONVERSION_FACTORY.create(
com.oracle.bmc.waf.model.WebAppFirewallPolicy
.class,
serviceDetails.get());
} else {
responseFn =
RESPONSE_CONVERSION_FACTORY.create(
com.oracle.bmc.waf.model.WebAppFirewallPolicy
.class);
}
com.oracle.bmc.http.internal.WithHeaders<
com.oracle.bmc.waf.model.WebAppFirewallPolicy>
response = responseFn.apply(rawResponse);
javax.ws.rs.core.MultivaluedMap headers =
response.getHeaders();
com.oracle.bmc.waf.responses.GetWebAppFirewallPolicyResponse.Builder
builder =
com.oracle.bmc.waf.responses
.GetWebAppFirewallPolicyResponse.builder()
.__httpStatusCode__(rawResponse.getStatus())
.headers(headers);
builder.webAppFirewallPolicy(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.GetWebAppFirewallPolicyResponse
responseWrapper = builder.build();
ResponseHelper.closeResponseSilentlyIfNotBuffered(rawResponse);
return responseWrapper;
}
};
return transformer;
}
}