/**
 * Apm Traces API
 * API for APM Trace service. Use this API to query the Traces and associated Spans.

 * OpenAPI spec version: 20200630
 *
 *
 * NOTE: This class is auto generated by OracleSDKGenerator.
 * Do not edit the class manually.
 *
 * Copyright (c) 2020, 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.
 */ import common = require ( "oci-common" ) ; import * as requests from "./request" ; import * as model from "./model" ; import * as responses from "./response" ; import { paginateRecords , paginateResponses } from "oci-common" ; import { composeResponse , composeRequest , GenericRetrier } from "oci-common" ; export enum QueryApiKeys { } /**
 * This service client uses  common . CircuitBreaker . DefaultConfiguration for all the operations by default if no circuit breaker configuration is defined by the user.
  export class QueryClient { protected static serviceEndpointTemplate = "https://apm-trace.{region}.oci.{secondLevelDomain}" ; protected "_endpoint" : string = "" ; protected "_defaultHeaders" : any = { } ; protected "_clientConfiguration" : common . ClientConfiguration ; protected _circuitBreaker = null ; protected _httpClient : common . HttpClient ; constructor ( params , clientConfiguration ? ) { const requestSigner = params . authenticationDetailsProvider ? new common . DefaultRequestSigner ( params . authenticationDetailsProvider ) : null ; if ( clientConfiguration ) { this . _clientConfiguration = clientConfiguration ; this . _circuitBreaker = clientConfiguration . circuitBreaker ? clientConfiguration . circuitBreaker ! . circuit : null ; } const specCircuitBreakerEnabled = true ; if ( ! this . _circuitBreaker && common . utils . isCircuitBreakerSystemEnabled ( clientConfiguration ! ) && ( specCircuitBreakerEnabled || common . CircuitBreaker . DefaultCircuitBreakerOverriden ) ) { this . _circuitBreaker = new common . CircuitBreaker ( ) . circuit ; } this . _httpClient = params . httpClient || new common . FetchHttpClient ( requestSigner , this . _circuitBreaker ) ; if ( params . authenticationDetailsProvider && common . isRegionProvider ( params . authenticationDetailsProvider ) ) { const provider = params . authenticationDetailsProvider ; if ( provider . getRegion ( ) ) { this . region = provider . getRegion ( ) ; } } } /**
     * Get the endpoint that is being used to call (ex, https://www.example.com).
     */ public get endpoint ( ) { return this . _endpoint ; } param endpoint public set endpoint ( endpoint ) { this . _endpoint = endpoint ; this . _endpoint = this . _endpoint + "/20200630" ; if ( this . logger ) this . logger . info ( `QueryClient endpoint set to ${ this . _endpoint }` ) ; } public get logger ( ) { return common . LOG . logger ; } /**
     * Sets the region to call (ex, Region.US_PHOENIX_1).
     * Note, this will call  {@link #endpoint(String) endpoint} after resolving the endpoint.
     *  param region public set region ( region ) { this . endpoint = common . EndpointBuilder . createEndpointFromRegion ( QueryClient . serviceEndpointTemplate , region ) ; } /**
     * Sets the regionId to call (ex, 'us-phoenix-1').
     *
     * Note, this will first try to map the region ID to a known Region and call  {@link #region(Region) region} .
     * If no known Region could be determined, it will create an endpoint assuming its in default Realm OC1
     * and then call  {@link #endpoint(String) endpoint} .
     *  param regionId public set regionId ( regionId ) { this . endpoint = common . EndpointBuilder . createEndpointFromRegionId ( QueryClient . serviceEndpointTemplate , regionId ) ; } param ListQuickPicksRequest return throws example Click  https to see how to use ListQuickPicks API.
      public async listQuickPicks ( listQuickPicksRequest ) { if ( this . logger ) this . logger . debug ( "Calling operation QueryClient#listQuickPicks." ) ; const pathParams = { } ; const queryParams = { "apmDomainId" : listQuickPicksRequest . apmDomainId , "limit" : listQuickPicksRequest . limit , "page" : listQuickPicksRequest . page } ; let headerParams = { "Content-Type" : common . Constants . APPLICATION_JSON , "opc-request-id" : listQuickPicksRequest . opcRequestId } ; const specRetryConfiguration = common . NoRetryConfigurationDetails ; const retrier = GenericRetrier . createPreferredRetrier ( this . _clientConfiguration ? this . _clientConfiguration . retryConfiguration : undefined , listQuickPicksRequest . retryConfiguration , specRetryConfiguration ) ; if ( this . logger ) retrier . logger = this . logger ; const request = await composeRequest ( { baseEndpoint : this . _endpoint , defaultHeaders : this . _defaultHeaders , path : "/queries/quickPicks" , method : "GET" , pathParams : pathParams , headerParams : headerParams , queryParams : queryParams } ) ; try { const response = await retrier . makeServiceCall ( this . _httpClient , request ) ; const sdkResponse = composeResponse ( { responseObject : < responses . ListQuickPicksResponse > { } , body : await response . json ( ) , bodyKey : "items" , bodyModel : model . QuickPickSummary , type : "Array<model.QuickPickSummary>" , responseHeaders : [ { value : response . headers . get ( "opc-request-id" ) , key : "opcRequestId" , dataType : "string" } , { value : response . headers . get ( "opc-total-items" ) , key : "opcTotalItems" , dataType : "number" } , { value : response . headers . get ( "opc-next-page" ) , key : "opcNextPage" , dataType : "string" } ] } ) ; return sdkResponse ; } catch ( err ) { throw err ; } } param request public listAllQuickPicks ( request ) { return paginateRecords ( request , req => this . listQuickPicks ( req ) ) ; } param request public listAllQuickPicksResponses ( request ) { return paginateResponses ( request , req => this . listQuickPicks ( req ) ) ; } param request public listQuickPicksRecordIterator ( request ) { return paginateRecords ( request , req => this . listQuickPicks ( req ) ) ; } param request public listQuickPicksResponseIterator ( request ) { return paginateResponses ( request , req => this . listQuickPicks ( req ) ) ; } param QueryRequest return throws example Click  https to see how to use Query API.
      public async query ( queryRequest ) { if ( this . logger ) this . logger . debug ( "Calling operation QueryClient#query." ) ; const pathParams = { } ; const queryParams = { "apmDomainId" : queryRequest . apmDomainId , "limit" : queryRequest . limit , "page" : queryRequest . page , "timeSpanStartedGreaterThanOrEqualTo" : queryRequest . timeSpanStartedGreaterThanOrEqualTo , "timeSpanStartedLessThan" : queryRequest . timeSpanStartedLessThan } ; let headerParams = { "Content-Type" : common . Constants . APPLICATION_JSON , "opc-request-id" : queryRequest . opcRequestId } ; const specRetryConfiguration = common . NoRetryConfigurationDetails ; const retrier = GenericRetrier . createPreferredRetrier ( this . _clientConfiguration ? this . _clientConfiguration . retryConfiguration : undefined , queryRequest . retryConfiguration , specRetryConfiguration ) ; if ( this . logger ) retrier . logger = this . logger ; const request = await composeRequest ( { baseEndpoint : this . _endpoint , defaultHeaders : this . _defaultHeaders , path : "/queries/actions/runQuery" , method : "POST" , bodyContent : common . ObjectSerializer . serialize ( queryRequest . queryDetails , "QueryDetails" , model . QueryDetails . getJsonObj ) , pathParams : pathParams , headerParams : headerParams , queryParams : queryParams } ) ; try { const response = await retrier . makeServiceCall ( this . _httpClient , request ) ; const sdkResponse = composeResponse ( { responseObject : < responses . QueryResponse > { } , body : await response . json ( ) , bodyKey : "queryResultResponse" , bodyModel : model . QueryResultResponse , type : "model.QueryResultResponse" , responseHeaders : [ { value : response . headers . get ( "opc-request-id" ) , key : "opcRequestId" , dataType : "string" } , { value : response . headers . get ( "opc-total-items" ) , key : "opcTotalItems" , dataType : "number" } , { value : response . headers . get ( "opc-next-page" ) , key : "opcNextPage" , dataType : "string" } ] } ) ; return sdkResponse ; } catch ( err ) { throw err ; } } param QueryOldRequest return throws example Click  https to see how to use QueryOld API.
      public async queryOld ( queryOldRequest ) { if ( this . logger ) this . logger . debug ( "Calling operation QueryClient#queryOld." ) ; const pathParams = { } ; const queryParams = { "apmDomainId" : queryOldRequest . apmDomainId , "limit" : queryOldRequest . limit , "page" : queryOldRequest . page , "timeSpanStartedGreaterThanOrEqualTo" : queryOldRequest . timeSpanStartedGreaterThanOrEqualTo , "timeSpanStartedLessThan" : queryOldRequest . timeSpanStartedLessThan } ; let headerParams = { "Content-Type" : common . Constants . APPLICATION_JSON , "opc-request-id" : queryOldRequest . opcRequestId } ; const specRetryConfiguration = common . NoRetryConfigurationDetails ; const retrier = GenericRetrier . createPreferredRetrier ( this . _clientConfiguration ? this . _clientConfiguration . retryConfiguration : undefined , queryOldRequest . retryConfiguration , specRetryConfiguration ) ; if ( this . logger ) retrier . logger = this . logger ; const request = await composeRequest ( { baseEndpoint : this . _endpoint , defaultHeaders : this . _defaultHeaders , path : "/queries/action/runQuery" , method : "POST" , bodyContent : common . ObjectSerializer . serialize ( queryOldRequest . queryDetails , "QueryDetails" , model . QueryDetails . getJsonObj ) , pathParams : pathParams , headerParams : headerParams , queryParams : queryParams } ) ; try { const response = await retrier . makeServiceCall ( this . _httpClient , request ) ; const sdkResponse = composeResponse ( { responseObject : < responses . QueryOldResponse > { } , body : await response . json ( ) , bodyKey : "queryResultResponse" , bodyModel : model . QueryResultResponse , type : "model.QueryResultResponse" , responseHeaders : [ { value : response . headers . get ( "opc-request-id" ) , key : "opcRequestId" , dataType : "string" } , { value : response . headers . get ( "opc-total-items" ) , key : "opcTotalItems" , dataType : "number" } , { value : response . headers . get ( "opc-next-page" ) , key : "opcNextPage" , dataType : "string" } ] } ) ; return sdkResponse ; } catch ( err ) { throw err ; } } } export enum TraceApiKeys { } /**
 * This service client uses  common . CircuitBreaker . DefaultConfiguration for all the operations by default if no circuit breaker configuration is defined by the user.
  export class TraceClient { protected static serviceEndpointTemplate = "https://apm-trace.{region}.oci.{secondLevelDomain}" ; protected "_endpoint" : string = "" ; protected "_defaultHeaders" : any = { } ; protected "_clientConfiguration" : common . ClientConfiguration ; protected _circuitBreaker = null ; protected _httpClient : common . HttpClient ; constructor ( params , clientConfiguration ? ) { const requestSigner = params . authenticationDetailsProvider ? new common . DefaultRequestSigner ( params . authenticationDetailsProvider ) : null ; if ( clientConfiguration ) { this . _clientConfiguration = clientConfiguration ; this . _circuitBreaker = clientConfiguration . circuitBreaker ? clientConfiguration . circuitBreaker ! . circuit : null ; } const specCircuitBreakerEnabled = true ; if ( ! this . _circuitBreaker && common . utils . isCircuitBreakerSystemEnabled ( clientConfiguration ! ) && ( specCircuitBreakerEnabled || common . CircuitBreaker . DefaultCircuitBreakerOverriden ) ) { this . _circuitBreaker = new common . CircuitBreaker ( ) . circuit ; } this . _httpClient = params . httpClient || new common . FetchHttpClient ( requestSigner , this . _circuitBreaker ) ; if ( params . authenticationDetailsProvider && common . isRegionProvider ( params . authenticationDetailsProvider ) ) { const provider = params . authenticationDetailsProvider ; if ( provider . getRegion ( ) ) { this . region = provider . getRegion ( ) ; } } } /**
     * Get the endpoint that is being used to call (ex, https://www.example.com).
     */ public get endpoint ( ) { return this . _endpoint ; } param endpoint public set endpoint ( endpoint ) { this . _endpoint = endpoint ; this . _endpoint = this . _endpoint + "/20200630" ; if ( this . logger ) this . logger . info ( `TraceClient endpoint set to ${ this . _endpoint }` ) ; } public get logger ( ) { return common . LOG . logger ; } /**
     * Sets the region to call (ex, Region.US_PHOENIX_1).
     * Note, this will call  {@link #endpoint(String) endpoint} after resolving the endpoint.
     *  param region public set region ( region ) { this . endpoint = common . EndpointBuilder . createEndpointFromRegion ( TraceClient . serviceEndpointTemplate , region ) ; } /**
     * Sets the regionId to call (ex, 'us-phoenix-1').
     *
     * Note, this will first try to map the region ID to a known Region and call  {@link #region(Region) region} .
     * If no known Region could be determined, it will create an endpoint assuming its in default Realm OC1
     * and then call  {@link #endpoint(String) endpoint} .
     *  param regionId public set regionId ( regionId ) { this . endpoint = common . EndpointBuilder . createEndpointFromRegionId ( TraceClient . serviceEndpointTemplate , regionId ) ; } param GetSpanRequest return throws example Click  https to see how to use GetSpan API.
      public async getSpan ( getSpanRequest ) { if ( this . logger ) this . logger . debug ( "Calling operation TraceClient#getSpan." ) ; const pathParams = { "{spanKey}" : getSpanRequest . spanKey , "{traceKey}" : getSpanRequest . traceKey } ; const queryParams = { "apmDomainId" : getSpanRequest . apmDomainId } ; let headerParams = { "Content-Type" : common . Constants . APPLICATION_JSON , "opc-request-id" : getSpanRequest . opcRequestId } ; const specRetryConfiguration = common . NoRetryConfigurationDetails ; const retrier = GenericRetrier . createPreferredRetrier ( this . _clientConfiguration ? this . _clientConfiguration . retryConfiguration : undefined , getSpanRequest . retryConfiguration , specRetryConfiguration ) ; if ( this . logger ) retrier . logger = this . logger ; const request = await composeRequest ( { baseEndpoint : this . _endpoint , defaultHeaders : this . _defaultHeaders , path : "/spans/{traceKey}/{spanKey}" , method : "GET" , pathParams : pathParams , headerParams : headerParams , queryParams : queryParams } ) ; try { const response = await retrier . makeServiceCall ( this . _httpClient , request ) ; const sdkResponse = composeResponse ( { responseObject : < responses . GetSpanResponse > { } , body : await response . json ( ) , bodyKey : "span" , bodyModel : model . Span , type : "model.Span" , responseHeaders : [ { value : response . headers . get ( "opc-request-id" ) , key : "opcRequestId" , dataType : "string" } ] } ) ; return sdkResponse ; } catch ( err ) { throw err ; } } param GetTraceRequest return throws example Click  https to see how to use GetTrace API.
      public async getTrace ( getTraceRequest ) { if ( this . logger ) this . logger . debug ( "Calling operation TraceClient#getTrace." ) ; const pathParams = { "{traceKey}" : getTraceRequest . traceKey } ; const queryParams = { "apmDomainId" : getTraceRequest . apmDomainId } ; let headerParams = { "Content-Type" : common . Constants . APPLICATION_JSON , "opc-request-id" : getTraceRequest . opcRequestId } ; const specRetryConfiguration = common . NoRetryConfigurationDetails ; const retrier = GenericRetrier . createPreferredRetrier ( this . _clientConfiguration ? this . _clientConfiguration . retryConfiguration : undefined , getTraceRequest . retryConfiguration , specRetryConfiguration ) ; if ( this . logger ) retrier . logger = this . logger ; const request = await composeRequest ( { baseEndpoint : this . _endpoint , defaultHeaders : this . _defaultHeaders , path : "/traces/{traceKey}" , method : "GET" , pathParams : pathParams , headerParams : headerParams , queryParams : queryParams } ) ; try { const response = await retrier . makeServiceCall ( this . _httpClient , request ) ; const sdkResponse = composeResponse ( { responseObject : < responses . GetTraceResponse > { } , body : await response . json ( ) , bodyKey : "trace" , bodyModel : model . Trace , type : "model.Trace" , responseHeaders : [ { value : response . headers . get ( "opc-request-id" ) , key : "opcRequestId" , dataType : "string" } ] } ) ; return sdkResponse ; } catch ( err ) { throw err ; } } }