/**
 * Budgets API
 * Use the Budgets API to manage budgets and budget alerts.
 * OpenAPI spec version: 20190111
 *
 *
 * 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 { BudgetWaiter } from "./budget-waiter" ; import { composeResponse , composeRequest , GenericRetrier } from "oci-common" ; export enum BudgetApiKeys { } /**
 * 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 BudgetClient { protected static serviceEndpointTemplate = "https://usage.{region}.oci.{secondLevelDomain}" ; protected "_endpoint" : string = "" ; protected "_defaultHeaders" : any = { } ; protected "_waiters" : BudgetWaiter ; 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 + "/20190111" ; if ( this . logger ) this . logger . info ( `BudgetClient 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 ( BudgetClient . 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 ( BudgetClient . serviceEndpointTemplate , regionId ) ; } param config return public createWaiters ( config ? ) { this . _waiters = new BudgetWaiter ( this , config ) ; return this . _waiters ; } return public getWaiters ( ) { if ( this . _waiters ) { return this . _waiters ; } throw Error ( "Waiters do not exist. Please create waiters." ) ; } param CreateAlertRuleRequest return throws example Click  https to see how to use CreateAlertRule API.
      public async createAlertRule ( createAlertRuleRequest ) { if ( this . logger ) this . logger . debug ( "Calling operation BudgetClient#createAlertRule." ) ; const pathParams = { "{budgetId}" : createAlertRuleRequest . budgetId } ; const queryParams = { } ; let headerParams = { "Content-Type" : common . Constants . APPLICATION_JSON , "opc-retry-token" : createAlertRuleRequest . opcRetryToken , "opc-request-id" : createAlertRuleRequest . opcRequestId } ; const specRetryConfiguration = common . NoRetryConfigurationDetails ; const retrier = GenericRetrier . createPreferredRetrier ( this . _clientConfiguration ? this . _clientConfiguration . retryConfiguration : undefined , createAlertRuleRequest . retryConfiguration , specRetryConfiguration ) ; if ( this . logger ) retrier . logger = this . logger ; const request = await composeRequest ( { baseEndpoint : this . _endpoint , defaultHeaders : this . _defaultHeaders , path : "/budgets/{budgetId}/alertRules" , method : "POST" , bodyContent : common . ObjectSerializer . serialize ( createAlertRuleRequest . createAlertRuleDetails , "CreateAlertRuleDetails" , model . CreateAlertRuleDetails . getJsonObj ) , pathParams : pathParams , headerParams : headerParams , queryParams : queryParams } ) ; try { const response = await retrier . makeServiceCall ( this . _httpClient , request ) ; const sdkResponse = composeResponse ( { responseObject : < responses . CreateAlertRuleResponse > { } , body : await response . json ( ) , bodyKey : "alertRule" , bodyModel : model . AlertRule , type : "model.AlertRule" , responseHeaders : [ { value : response . headers . get ( "opc-request-id" ) , key : "opcRequestId" , dataType : "string" } , { value : response . headers . get ( "etag" ) , key : "etag" , dataType : "string" } ] } ) ; return sdkResponse ; } catch ( err ) { throw err ; } } param CreateBudgetRequest return throws example Click  https to see how to use CreateBudget API.
      public async createBudget ( createBudgetRequest ) { if ( this . logger ) this . logger . debug ( "Calling operation BudgetClient#createBudget." ) ; const pathParams = { } ; const queryParams = { } ; let headerParams = { "Content-Type" : common . Constants . APPLICATION_JSON , "opc-retry-token" : createBudgetRequest . opcRetryToken , "opc-request-id" : createBudgetRequest . opcRequestId } ; const specRetryConfiguration = common . NoRetryConfigurationDetails ; const retrier = GenericRetrier . createPreferredRetrier ( this . _clientConfiguration ? this . _clientConfiguration . retryConfiguration : undefined , createBudgetRequest . retryConfiguration , specRetryConfiguration ) ; if ( this . logger ) retrier . logger = this . logger ; const request = await composeRequest ( { baseEndpoint : this . _endpoint , defaultHeaders : this . _defaultHeaders , path : "/budgets" , method : "POST" , bodyContent : common . ObjectSerializer . serialize ( createBudgetRequest . createBudgetDetails , "CreateBudgetDetails" , model . CreateBudgetDetails . getJsonObj ) , pathParams : pathParams , headerParams : headerParams , queryParams : queryParams } ) ; try { const response = await retrier . makeServiceCall ( this . _httpClient , request ) ; const sdkResponse = composeResponse ( { responseObject : < responses . CreateBudgetResponse > { } , body : await response . json ( ) , bodyKey : "budget" , bodyModel : model . Budget , type : "model.Budget" , responseHeaders : [ { value : response . headers . get ( "opc-request-id" ) , key : "opcRequestId" , dataType : "string" } , { value : response . headers . get ( "etag" ) , key : "etag" , dataType : "string" } ] } ) ; return sdkResponse ; } catch ( err ) { throw err ; } } param DeleteAlertRuleRequest return throws example Click  https to see how to use DeleteAlertRule API.
      public async deleteAlertRule ( deleteAlertRuleRequest ) { if ( this . logger ) this . logger . debug ( "Calling operation BudgetClient#deleteAlertRule." ) ; const pathParams = { "{budgetId}" : deleteAlertRuleRequest . budgetId , "{alertRuleId}" : deleteAlertRuleRequest . alertRuleId } ; const queryParams = { } ; let headerParams = { "Content-Type" : common . Constants . APPLICATION_JSON , "if-match" : deleteAlertRuleRequest . ifMatch , "opc-request-id" : deleteAlertRuleRequest . opcRequestId } ; const specRetryConfiguration = common . NoRetryConfigurationDetails ; const retrier = GenericRetrier . createPreferredRetrier ( this . _clientConfiguration ? this . _clientConfiguration . retryConfiguration : undefined , deleteAlertRuleRequest . retryConfiguration , specRetryConfiguration ) ; if ( this . logger ) retrier . logger = this . logger ; const request = await composeRequest ( { baseEndpoint : this . _endpoint , defaultHeaders : this . _defaultHeaders , path : "/budgets/{budgetId}/alertRules/{alertRuleId}" , method : "DELETE" , pathParams : pathParams , headerParams : headerParams , queryParams : queryParams } ) ; try { const response = await retrier . makeServiceCall ( this . _httpClient , request ) ; const sdkResponse = composeResponse ( { responseObject : < responses . DeleteAlertRuleResponse > { } , responseHeaders : [ { value : response . headers . get ( "opc-request-id" ) , key : "opcRequestId" , dataType : "string" } ] } ) ; return sdkResponse ; } catch ( err ) { throw err ; } } param DeleteBudgetRequest return throws example Click  https to see how to use DeleteBudget API.
      public async deleteBudget ( deleteBudgetRequest ) { if ( this . logger ) this . logger . debug ( "Calling operation BudgetClient#deleteBudget." ) ; const pathParams = { "{budgetId}" : deleteBudgetRequest . budgetId } ; const queryParams = { } ; let headerParams = { "Content-Type" : common . Constants . APPLICATION_JSON , "if-match" : deleteBudgetRequest . ifMatch , "opc-request-id" : deleteBudgetRequest . opcRequestId } ; const specRetryConfiguration = common . NoRetryConfigurationDetails ; const retrier = GenericRetrier . createPreferredRetrier ( this . _clientConfiguration ? this . _clientConfiguration . retryConfiguration : undefined , deleteBudgetRequest . retryConfiguration , specRetryConfiguration ) ; if ( this . logger ) retrier . logger = this . logger ; const request = await composeRequest ( { baseEndpoint : this . _endpoint , defaultHeaders : this . _defaultHeaders , path : "/budgets/{budgetId}" , method : "DELETE" , pathParams : pathParams , headerParams : headerParams , queryParams : queryParams } ) ; try { const response = await retrier . makeServiceCall ( this . _httpClient , request ) ; const sdkResponse = composeResponse ( { responseObject : < responses . DeleteBudgetResponse > { } , responseHeaders : [ { value : response . headers . get ( "opc-request-id" ) , key : "opcRequestId" , dataType : "string" } ] } ) ; return sdkResponse ; } catch ( err ) { throw err ; } } param GetAlertRuleRequest return throws example Click  https to see how to use GetAlertRule API.
      public async getAlertRule ( getAlertRuleRequest ) { if ( this . logger ) this . logger . debug ( "Calling operation BudgetClient#getAlertRule." ) ; const pathParams = { "{budgetId}" : getAlertRuleRequest . budgetId , "{alertRuleId}" : getAlertRuleRequest . alertRuleId } ; const queryParams = { } ; let headerParams = { "Content-Type" : common . Constants . APPLICATION_JSON , "opc-request-id" : getAlertRuleRequest . opcRequestId } ; const specRetryConfiguration = common . NoRetryConfigurationDetails ; const retrier = GenericRetrier . createPreferredRetrier ( this . _clientConfiguration ? this . _clientConfiguration . retryConfiguration : undefined , getAlertRuleRequest . retryConfiguration , specRetryConfiguration ) ; if ( this . logger ) retrier . logger = this . logger ; const request = await composeRequest ( { baseEndpoint : this . _endpoint , defaultHeaders : this . _defaultHeaders , path : "/budgets/{budgetId}/alertRules/{alertRuleId}" , method : "GET" , pathParams : pathParams , headerParams : headerParams , queryParams : queryParams } ) ; try { const response = await retrier . makeServiceCall ( this . _httpClient , request ) ; const sdkResponse = composeResponse ( { responseObject : < responses . GetAlertRuleResponse > { } , body : await response . json ( ) , bodyKey : "alertRule" , bodyModel : model . AlertRule , type : "model.AlertRule" , responseHeaders : [ { value : response . headers . get ( "etag" ) , key : "etag" , dataType : "string" } , { value : response . headers . get ( "opc-request-id" ) , key : "opcRequestId" , dataType : "string" } ] } ) ; return sdkResponse ; } catch ( err ) { throw err ; } } param GetBudgetRequest return throws example Click  https to see how to use GetBudget API.
      public async getBudget ( getBudgetRequest ) { if ( this . logger ) this . logger . debug ( "Calling operation BudgetClient#getBudget." ) ; const pathParams = { "{budgetId}" : getBudgetRequest . budgetId } ; const queryParams = { } ; let headerParams = { "Content-Type" : common . Constants . APPLICATION_JSON , "opc-request-id" : getBudgetRequest . opcRequestId } ; const specRetryConfiguration = common . NoRetryConfigurationDetails ; const retrier = GenericRetrier . createPreferredRetrier ( this . _clientConfiguration ? this . _clientConfiguration . retryConfiguration : undefined , getBudgetRequest . retryConfiguration , specRetryConfiguration ) ; if ( this . logger ) retrier . logger = this . logger ; const request = await composeRequest ( { baseEndpoint : this . _endpoint , defaultHeaders : this . _defaultHeaders , path : "/budgets/{budgetId}" , method : "GET" , pathParams : pathParams , headerParams : headerParams , queryParams : queryParams } ) ; try { const response = await retrier . makeServiceCall ( this . _httpClient , request ) ; const sdkResponse = composeResponse ( { responseObject : < responses . GetBudgetResponse > { } , body : await response . json ( ) , bodyKey : "budget" , bodyModel : model . Budget , type : "model.Budget" , responseHeaders : [ { value : response . headers . get ( "etag" ) , key : "etag" , dataType : "string" } , { value : response . headers . get ( "opc-request-id" ) , key : "opcRequestId" , dataType : "string" } ] } ) ; return sdkResponse ; } catch ( err ) { throw err ; } } param ListAlertRulesRequest return throws example Click  https to see how to use ListAlertRules API.
      public async listAlertRules ( listAlertRulesRequest ) { if ( this . logger ) this . logger . debug ( "Calling operation BudgetClient#listAlertRules." ) ; const pathParams = { "{budgetId}" : listAlertRulesRequest . budgetId } ; const queryParams = { "limit" : listAlertRulesRequest . limit , "page" : listAlertRulesRequest . page , "sortOrder" : listAlertRulesRequest . sortOrder , "sortBy" : listAlertRulesRequest . sortBy , "lifecycleState" : listAlertRulesRequest . lifecycleState , "displayName" : listAlertRulesRequest . displayName } ; let headerParams = { "Content-Type" : common . Constants . APPLICATION_JSON , "opc-request-id" : listAlertRulesRequest . opcRequestId } ; const specRetryConfiguration = common . NoRetryConfigurationDetails ; const retrier = GenericRetrier . createPreferredRetrier ( this . _clientConfiguration ? this . _clientConfiguration . retryConfiguration : undefined , listAlertRulesRequest . retryConfiguration , specRetryConfiguration ) ; if ( this . logger ) retrier . logger = this . logger ; const request = await composeRequest ( { baseEndpoint : this . _endpoint , defaultHeaders : this . _defaultHeaders , path : "/budgets/{budgetId}/alertRules" , method : "GET" , pathParams : pathParams , headerParams : headerParams , queryParams : queryParams } ) ; try { const response = await retrier . makeServiceCall ( this . _httpClient , request ) ; const sdkResponse = composeResponse ( { responseObject : < responses . ListAlertRulesResponse > { } , body : await response . json ( ) , bodyKey : "items" , bodyModel : model . AlertRuleSummary , type : "Array<model.AlertRuleSummary>" , responseHeaders : [ { value : response . headers . get ( "opc-request-id" ) , key : "opcRequestId" , dataType : "string" } , { value : response . headers . get ( "opc-next-page" ) , key : "opcNextPage" , dataType : "string" } ] } ) ; return sdkResponse ; } catch ( err ) { throw err ; } } param request public listAllAlertRules ( request ) { return paginateRecords ( request , req => this . listAlertRules ( req ) ) ; } param request public listAllAlertRulesResponses ( request ) { return paginateResponses ( request , req => this . listAlertRules ( req ) ) ; } param request public listAlertRulesRecordIterator ( request ) { return paginateRecords ( request , req => this . listAlertRules ( req ) ) ; } param request public listAlertRulesResponseIterator ( request ) { return paginateResponses ( request , req => this . listAlertRules ( req ) ) ; } param ListBudgetsRequest return throws example Click  https to see how to use ListBudgets API.
        public async listBudgets ( listBudgetsRequest ) { if ( this . logger ) this . logger . debug ( "Calling operation BudgetClient#listBudgets." ) ; const pathParams = { } ; const queryParams = { "compartmentId" : listBudgetsRequest . compartmentId , "limit" : listBudgetsRequest . limit , "page" : listBudgetsRequest . page , "sortOrder" : listBudgetsRequest . sortOrder , "sortBy" : listBudgetsRequest . sortBy , "lifecycleState" : listBudgetsRequest . lifecycleState , "displayName" : listBudgetsRequest . displayName , "targetType" : listBudgetsRequest . targetType } ; let headerParams = { "Content-Type" : common . Constants . APPLICATION_JSON , "opc-request-id" : listBudgetsRequest . opcRequestId } ; const specRetryConfiguration = common . NoRetryConfigurationDetails ; const retrier = GenericRetrier . createPreferredRetrier ( this . _clientConfiguration ? this . _clientConfiguration . retryConfiguration : undefined , listBudgetsRequest . retryConfiguration , specRetryConfiguration ) ; if ( this . logger ) retrier . logger = this . logger ; const request = await composeRequest ( { baseEndpoint : this . _endpoint , defaultHeaders : this . _defaultHeaders , path : "/budgets" , method : "GET" , pathParams : pathParams , headerParams : headerParams , queryParams : queryParams } ) ; try { const response = await retrier . makeServiceCall ( this . _httpClient , request ) ; const sdkResponse = composeResponse ( { responseObject : < responses . ListBudgetsResponse > { } , body : await response . json ( ) , bodyKey : "items" , bodyModel : model . BudgetSummary , type : "Array<model.BudgetSummary>" , responseHeaders : [ { value : response . headers . get ( "opc-request-id" ) , key : "opcRequestId" , dataType : "string" } , { value : response . headers . get ( "opc-next-page" ) , key : "opcNextPage" , dataType : "string" } ] } ) ; return sdkResponse ; } catch ( err ) { throw err ; } } param request public listAllBudgets ( request ) { return paginateRecords ( request , req => this . listBudgets ( req ) ) ; } param request public listAllBudgetsResponses ( request ) { return paginateResponses ( request , req => this . listBudgets ( req ) ) ; } param request public listBudgetsRecordIterator ( request ) { return paginateRecords ( request , req => this . listBudgets ( req ) ) ; } param request public listBudgetsResponseIterator ( request ) { return paginateResponses ( request , req => this . listBudgets ( req ) ) ; } param UpdateAlertRuleRequest return throws example Click  https to see how to use UpdateAlertRule API.
      public async updateAlertRule ( updateAlertRuleRequest ) { if ( this . logger ) this . logger . debug ( "Calling operation BudgetClient#updateAlertRule." ) ; const pathParams = { "{budgetId}" : updateAlertRuleRequest . budgetId , "{alertRuleId}" : updateAlertRuleRequest . alertRuleId } ; const queryParams = { } ; let headerParams = { "Content-Type" : common . Constants . APPLICATION_JSON , "if-match" : updateAlertRuleRequest . ifMatch , "opc-request-id" : updateAlertRuleRequest . opcRequestId } ; const specRetryConfiguration = common . NoRetryConfigurationDetails ; const retrier = GenericRetrier . createPreferredRetrier ( this . _clientConfiguration ? this . _clientConfiguration . retryConfiguration : undefined , updateAlertRuleRequest . retryConfiguration , specRetryConfiguration ) ; if ( this . logger ) retrier . logger = this . logger ; const request = await composeRequest ( { baseEndpoint : this . _endpoint , defaultHeaders : this . _defaultHeaders , path : "/budgets/{budgetId}/alertRules/{alertRuleId}" , method : "PUT" , bodyContent : common . ObjectSerializer . serialize ( updateAlertRuleRequest . updateAlertRuleDetails , "UpdateAlertRuleDetails" , model . UpdateAlertRuleDetails . getJsonObj ) , pathParams : pathParams , headerParams : headerParams , queryParams : queryParams } ) ; try { const response = await retrier . makeServiceCall ( this . _httpClient , request ) ; const sdkResponse = composeResponse ( { responseObject : < responses . UpdateAlertRuleResponse > { } , body : await response . json ( ) , bodyKey : "alertRule" , bodyModel : model . AlertRule , type : "model.AlertRule" , responseHeaders : [ { value : response . headers . get ( "opc-request-id" ) , key : "opcRequestId" , dataType : "string" } , { value : response . headers . get ( "etag" ) , key : "etag" , dataType : "string" } ] } ) ; return sdkResponse ; } catch ( err ) { throw err ; } } param UpdateBudgetRequest return throws example Click  https to see how to use UpdateBudget API.
      public async updateBudget ( updateBudgetRequest ) { if ( this . logger ) this . logger . debug ( "Calling operation BudgetClient#updateBudget." ) ; const pathParams = { "{budgetId}" : updateBudgetRequest . budgetId } ; const queryParams = { } ; let headerParams = { "Content-Type" : common . Constants . APPLICATION_JSON , "if-match" : updateBudgetRequest . ifMatch , "opc-request-id" : updateBudgetRequest . opcRequestId } ; const specRetryConfiguration = common . NoRetryConfigurationDetails ; const retrier = GenericRetrier . createPreferredRetrier ( this . _clientConfiguration ? this . _clientConfiguration . retryConfiguration : undefined , updateBudgetRequest . retryConfiguration , specRetryConfiguration ) ; if ( this . logger ) retrier . logger = this . logger ; const request = await composeRequest ( { baseEndpoint : this . _endpoint , defaultHeaders : this . _defaultHeaders , path : "/budgets/{budgetId}" , method : "PUT" , bodyContent : common . ObjectSerializer . serialize ( updateBudgetRequest . updateBudgetDetails , "UpdateBudgetDetails" , model . UpdateBudgetDetails . getJsonObj ) , pathParams : pathParams , headerParams : headerParams , queryParams : queryParams } ) ; try { const response = await retrier . makeServiceCall ( this . _httpClient , request ) ; const sdkResponse = composeResponse ( { responseObject : < responses . UpdateBudgetResponse > { } , body : await response . json ( ) , bodyKey : "budget" , bodyModel : model . Budget , type : "model.Budget" , responseHeaders : [ { value : response . headers . get ( "opc-request-id" ) , key : "opcRequestId" , dataType : "string" } , { value : response . headers . get ( "etag" ) , key : "etag" , dataType : "string" } ] } ) ; return sdkResponse ; } catch ( err ) { throw err ; } } }