com.oracle.bmc.apmtraces.internal.http.GetTraceSnapshotConverter Maven / Gradle / Ivy
/**
* Copyright (c) 2016, 2023, 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.apmtraces.internal.http;
import com.oracle.bmc.http.internal.ResponseHelper;
import com.oracle.bmc.apmtraces.model.*;
import com.oracle.bmc.apmtraces.requests.*;
import com.oracle.bmc.apmtraces.responses.*;
import com.oracle.bmc.util.internal.Validate;
@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20200630")
public class GetTraceSnapshotConverter {
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(GetTraceSnapshotConverter.class);
public static com.oracle.bmc.apmtraces.requests.GetTraceSnapshotRequest interceptRequest(
com.oracle.bmc.apmtraces.requests.GetTraceSnapshotRequest request) {
return request;
}
public static com.oracle.bmc.http.internal.WrappedInvocationBuilder fromRequest(
com.oracle.bmc.http.internal.RestClient client,
com.oracle.bmc.apmtraces.requests.GetTraceSnapshotRequest request) {
Validate.notNull(request, "request instance is required");
Validate.notNull(request.getApmDomainId(), "apmDomainId is required");
Validate.notBlank(request.getTraceKey(), "traceKey must not be blank");
com.oracle.bmc.http.internal.WrappedWebTarget target =
client.getBaseTarget()
.path("/20200630")
.path("traces")
.path(
com.oracle.bmc.util.internal.HttpUtils.encodePathSegment(
request.getTraceKey()))
.path("snapshotData");
target =
target.queryParam(
"apmDomainId",
com.oracle.bmc.util.internal.HttpUtils.attemptEncodeQueryParam(
request.getApmDomainId()));
if (request.getIsSummarized() != null) {
target =
target.queryParam(
"isSummarized",
com.oracle.bmc.util.internal.HttpUtils.attemptEncodeQueryParam(
request.getIsSummarized()));
}
if (request.getThreadId() != null) {
target =
target.queryParam(
"threadId",
com.oracle.bmc.util.internal.HttpUtils.attemptEncodeQueryParam(
request.getThreadId()));
}
if (request.getSnapshotTime() != null) {
target =
target.queryParam(
"snapshotTime",
com.oracle.bmc.util.internal.HttpUtils.attemptEncodeQueryParam(
request.getSnapshotTime()));
}
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.apmtraces.responses.GetTraceSnapshotResponse>
fromResponse() {
return fromResponse(java.util.Optional.empty());
}
public static java.util.function.Function<
javax.ws.rs.core.Response,
com.oracle.bmc.apmtraces.responses.GetTraceSnapshotResponse>
fromResponse(java.util.Optional serviceDetails) {
final java.util.function.Function<
javax.ws.rs.core.Response,
com.oracle.bmc.apmtraces.responses.GetTraceSnapshotResponse>
transformer =
new java.util.function.Function<
javax.ws.rs.core.Response,
com.oracle.bmc.apmtraces.responses.GetTraceSnapshotResponse>() {
@Override
public com.oracle.bmc.apmtraces.responses.GetTraceSnapshotResponse
apply(javax.ws.rs.core.Response rawResponse) {
LOG.trace(
"Transform function invoked for com.oracle.bmc.apmtraces.responses.GetTraceSnapshotResponse");
final java.util.function.Function<
javax.ws.rs.core.Response,
com.oracle.bmc.http.internal.WithHeaders<
com.oracle.bmc.apmtraces.model
.TraceSnapshot>>
responseFn;
if (serviceDetails.isPresent()) {
responseFn =
RESPONSE_CONVERSION_FACTORY.create(
com.oracle.bmc.apmtraces.model.TraceSnapshot
.class,
serviceDetails.get());
} else {
responseFn =
RESPONSE_CONVERSION_FACTORY.create(
com.oracle.bmc.apmtraces.model.TraceSnapshot
.class);
}
com.oracle.bmc.http.internal.WithHeaders<
com.oracle.bmc.apmtraces.model.TraceSnapshot>
response = responseFn.apply(rawResponse);
javax.ws.rs.core.MultivaluedMap headers =
response.getHeaders();
com.oracle.bmc.apmtraces.responses.GetTraceSnapshotResponse.Builder
builder =
com.oracle.bmc.apmtraces.responses
.GetTraceSnapshotResponse.builder()
.__httpStatusCode__(rawResponse.getStatus())
.headers(headers);
builder.traceSnapshot(response.getItem());
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.apmtraces.responses.GetTraceSnapshotResponse
responseWrapper = builder.build();
ResponseHelper.closeResponseSilentlyIfNotBuffered(rawResponse);
return responseWrapper;
}
};
return transformer;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy