All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.oracle.bmc.nosql.internal.http.GetTableConverter Maven / Gradle / Ivy

There is a newer version: 3.49.0
Show newest version
/**
 * Copyright (c) 2016, 2020, 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.nosql.internal.http;

import com.oracle.bmc.http.internal.ResponseHelper;
import com.oracle.bmc.nosql.model.*;
import com.oracle.bmc.nosql.requests.*;
import com.oracle.bmc.nosql.responses.*;
import org.apache.commons.lang3.Validate;

@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20190828")
@lombok.extern.slf4j.Slf4j
public class GetTableConverter {
    private static final com.oracle.bmc.http.internal.ResponseConversionFunctionFactory
            RESPONSE_CONVERSION_FACTORY =
                    new com.oracle.bmc.http.internal.ResponseConversionFunctionFactory();

    public static com.oracle.bmc.nosql.requests.GetTableRequest interceptRequest(
            com.oracle.bmc.nosql.requests.GetTableRequest request) {

        return request;
    }

    public static com.oracle.bmc.http.internal.WrappedInvocationBuilder fromRequest(
            com.oracle.bmc.http.internal.RestClient client,
            com.oracle.bmc.nosql.requests.GetTableRequest request) {
        Validate.notNull(request, "request instance is required");
        Validate.notBlank(request.getTableNameOrId(), "tableNameOrId must not be blank");

        com.oracle.bmc.http.internal.WrappedWebTarget target =
                client.getBaseTarget()
                        .path("/20190828")
                        .path("tables")
                        .path(
                                com.oracle.bmc.util.internal.HttpUtils.encodePathSegment(
                                        request.getTableNameOrId()));

        if (request.getCompartmentId() != null) {
            target =
                    target.queryParam(
                            "compartmentId",
                            com.oracle.bmc.util.internal.HttpUtils.attemptEncodeQueryParam(
                                    request.getCompartmentId()));
        }

        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());
        }

        return ib;
    }

    public static com.google.common.base.Function<
                    javax.ws.rs.core.Response, com.oracle.bmc.nosql.responses.GetTableResponse>
            fromResponse() {
        final com.google.common.base.Function<
                        javax.ws.rs.core.Response, com.oracle.bmc.nosql.responses.GetTableResponse>
                transformer =
                        new com.google.common.base.Function<
                                javax.ws.rs.core.Response,
                                com.oracle.bmc.nosql.responses.GetTableResponse>() {
                            @Override
                            public com.oracle.bmc.nosql.responses.GetTableResponse apply(
                                    javax.ws.rs.core.Response rawResponse) {
                                LOG.trace(
                                        "Transform function invoked for com.oracle.bmc.nosql.responses.GetTableResponse");
                                com.google.common.base.Function<
                                                javax.ws.rs.core.Response,
                                                com.oracle.bmc.http.internal.WithHeaders>
                                        responseFn =
                                                RESPONSE_CONVERSION_FACTORY.create(Table.class);

                                com.oracle.bmc.http.internal.WithHeaders
response = responseFn.apply(rawResponse); javax.ws.rs.core.MultivaluedMap headers = response.getHeaders(); com.oracle.bmc.nosql.responses.GetTableResponse.Builder builder = com.oracle.bmc.nosql.responses.GetTableResponse.builder(); builder.table(response.getItem()); com.google.common.base.Optional> etagHeader = com.oracle.bmc.http.internal.HeaderUtils.get( headers, "etag"); if (etagHeader.isPresent()) { builder.etag( com.oracle.bmc.http.internal.HeaderUtils.toValue( "etag", etagHeader.get().get(0), String.class)); } com.google.common.base.Optional> opcRequestIdHeader = com.oracle.bmc.http.internal.HeaderUtils.get( 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.nosql.responses.GetTableResponse responseWrapper = builder.build(); ResponseHelper.closeResponseSilentlyIfNotBuffered(rawResponse); return responseWrapper; } }; return transformer; } }