/**
 * Support Management API
 * Use the Support Management API to manage support requests. For more information, see [Getting Help and Contacting Support](/iaas/Content/GSG/Tasks/contactingsupport.htm). **Note**: Before you can create service requests with this API, you need to have an Oracle Single Sign On (SSO) account, and you need to register your Customer Support Identifier (CSI) with My Oracle Support.
 * OpenAPI spec version: 20181231
 * Contact: oci_ops_cims_dev_us_grp@oracle.com
 *
 * 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 IncidentApiKeys { } /**
 * 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 IncidentClient { protected static serviceEndpointTemplate = "https://incidentmanagement.{region}.{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 + "/20181231" ; if ( this . logger ) this . logger . info ( `IncidentClient 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 ( IncidentClient . 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 ( IncidentClient . serviceEndpointTemplate , regionId ) ; } param CreateIncidentRequest return throws example Click  https to see how to use CreateIncident API.
      public async createIncident ( createIncidentRequest ) { if ( this . logger ) this . logger . debug ( "Calling operation IncidentClient#createIncident." ) ; const pathParams = { } ; const queryParams = { } ; let headerParams = { "Content-Type" : common . Constants . APPLICATION_JSON , "opc-request-id" : createIncidentRequest . opcRequestId , "ocid" : createIncidentRequest . ocid , "homeregion" : createIncidentRequest . homeregion } ; const specRetryConfiguration = common . NoRetryConfigurationDetails ; const retrier = GenericRetrier . createPreferredRetrier ( this . _clientConfiguration ? this . _clientConfiguration . retryConfiguration : undefined , createIncidentRequest . retryConfiguration , specRetryConfiguration ) ; if ( this . logger ) retrier . logger = this . logger ; const request = await composeRequest ( { baseEndpoint : this . _endpoint , defaultHeaders : this . _defaultHeaders , path : "/v2/incidents" , method : "POST" , bodyContent : common . ObjectSerializer . serialize ( createIncidentRequest . createIncidentDetails , "CreateIncident" , model . CreateIncident . getJsonObj ) , pathParams : pathParams , headerParams : headerParams , queryParams : queryParams } ) ; try { const response = await retrier . makeServiceCall ( this . _httpClient , request ) ; const sdkResponse = composeResponse ( { responseObject : < responses . CreateIncidentResponse > { } , body : await response . json ( ) , bodyKey : "incident" , bodyModel : model . Incident , type : "model.Incident" , responseHeaders : [ { value : response . headers . get ( "opc-request-id" ) , key : "opcRequestId" , dataType : "string" } ] } ) ; return sdkResponse ; } catch ( err ) { throw err ; } } param GetIncidentRequest return throws example Click  https to see how to use GetIncident API.
      public async getIncident ( getIncidentRequest ) { if ( this . logger ) this . logger . debug ( "Calling operation IncidentClient#getIncident." ) ; const pathParams = { "{incidentKey}" : getIncidentRequest . incidentKey } ; const queryParams = { } ; let headerParams = { "Content-Type" : common . Constants . APPLICATION_JSON , "opc-request-id" : getIncidentRequest . opcRequestId , "csi" : getIncidentRequest . csi , "ocid" : getIncidentRequest . ocid , "homeregion" : getIncidentRequest . homeregion , "problem-type" : getIncidentRequest . problemType } ; const specRetryConfiguration = common . NoRetryConfigurationDetails ; const retrier = GenericRetrier . createPreferredRetrier ( this . _clientConfiguration ? this . _clientConfiguration . retryConfiguration : undefined , getIncidentRequest . retryConfiguration , specRetryConfiguration ) ; if ( this . logger ) retrier . logger = this . logger ; const request = await composeRequest ( { baseEndpoint : this . _endpoint , defaultHeaders : this . _defaultHeaders , path : "/v2/incidents/{incidentKey}" , method : "GET" , pathParams : pathParams , headerParams : headerParams , queryParams : queryParams } ) ; try { const response = await retrier . makeServiceCall ( this . _httpClient , request ) ; const sdkResponse = composeResponse ( { responseObject : < responses . GetIncidentResponse > { } , body : await response . json ( ) , bodyKey : "incident" , bodyModel : model . Incident , type : "model.Incident" , responseHeaders : [ { value : response . headers . get ( "opc-request-id" ) , key : "opcRequestId" , dataType : "string" } ] } ) ; return sdkResponse ; } catch ( err ) { throw err ; } } param GetStatusRequest return throws example Click  https to see how to use GetStatus API.
      public async getStatus ( getStatusRequest ) { if ( this . logger ) this . logger . debug ( "Calling operation IncidentClient#getStatus." ) ; const pathParams = { "{source}" : getStatusRequest . source } ; const queryParams = { } ; let headerParams = { "Content-Type" : common . Constants . APPLICATION_JSON , "opc-request-id" : getStatusRequest . opcRequestId , "ocid" : getStatusRequest . ocid , "homeregion" : getStatusRequest . homeregion } ; const specRetryConfiguration = common . NoRetryConfigurationDetails ; const retrier = GenericRetrier . createPreferredRetrier ( this . _clientConfiguration ? this . _clientConfiguration . retryConfiguration : undefined , getStatusRequest . retryConfiguration , specRetryConfiguration ) ; if ( this . logger ) retrier . logger = this . logger ; const request = await composeRequest ( { baseEndpoint : this . _endpoint , defaultHeaders : this . _defaultHeaders , path : "/v2/incidents/status/{source}" , method : "GET" , pathParams : pathParams , headerParams : headerParams , queryParams : queryParams } ) ; try { const response = await retrier . makeServiceCall ( this . _httpClient , request ) ; const sdkResponse = composeResponse ( { responseObject : < responses . GetStatusResponse > { } , body : await response . json ( ) , bodyKey : "status" , bodyModel : model . Status , type : "model.Status" , responseHeaders : [ { value : response . headers . get ( "opc-request-id" ) , key : "opcRequestId" , dataType : "string" } ] } ) ; return sdkResponse ; } catch ( err ) { throw err ; } } param ListIncidentResourceTypesRequest return throws example Click  https to see how to use ListIncidentResourceTypes API.
      public async listIncidentResourceTypes ( listIncidentResourceTypesRequest ) { if ( this . logger ) this . logger . debug ( "Calling operation IncidentClient#listIncidentResourceTypes." ) ; const pathParams = { } ; const queryParams = { "problemType" : listIncidentResourceTypesRequest . problemType , "limit" : listIncidentResourceTypesRequest . limit , "page" : listIncidentResourceTypesRequest . page , "sortBy" : listIncidentResourceTypesRequest . sortBy , "sortOrder" : listIncidentResourceTypesRequest . sortOrder , "compartmentId" : listIncidentResourceTypesRequest . compartmentId , "name" : listIncidentResourceTypesRequest . name } ; let headerParams = { "Content-Type" : common . Constants . APPLICATION_JSON , "opc-request-id" : listIncidentResourceTypesRequest . opcRequestId , "csi" : listIncidentResourceTypesRequest . csi , "ocid" : listIncidentResourceTypesRequest . ocid , "homeregion" : listIncidentResourceTypesRequest . homeregion } ; const specRetryConfiguration = common . NoRetryConfigurationDetails ; const retrier = GenericRetrier . createPreferredRetrier ( this . _clientConfiguration ? this . _clientConfiguration . retryConfiguration : undefined , listIncidentResourceTypesRequest . retryConfiguration , specRetryConfiguration ) ; if ( this . logger ) retrier . logger = this . logger ; const request = await composeRequest ( { baseEndpoint : this . _endpoint , defaultHeaders : this . _defaultHeaders , path : "/v2/incidents/incidentResourceTypes" , method : "GET" , pathParams : pathParams , headerParams : headerParams , queryParams : queryParams } ) ; try { const response = await retrier . makeServiceCall ( this . _httpClient , request ) ; const sdkResponse = composeResponse ( { responseObject : < responses . ListIncidentResourceTypesResponse > { } , body : await response . json ( ) , bodyKey : "items" , bodyModel : model . IncidentResourceType , type : "Array<model.IncidentResourceType>" , 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 listAllIncidentResourceTypes ( request ) { return paginateRecords ( request , req => this . listIncidentResourceTypes ( req ) ) ; } param request public listAllIncidentResourceTypesResponses ( request ) { return paginateResponses ( request , req => this . listIncidentResourceTypes ( req ) ) ; } param request public listIncidentResourceTypesRecordIterator ( request ) { return paginateRecords ( request , req => this . listIncidentResourceTypes ( req ) ) ; } param request public listIncidentResourceTypesResponseIterator ( request ) { return paginateResponses ( request , req => this . listIncidentResourceTypes ( req ) ) ; } param ListIncidentsRequest return throws example Click  https to see how to use ListIncidents API.
      public async listIncidents ( listIncidentsRequest ) { if ( this . logger ) this . logger . debug ( "Calling operation IncidentClient#listIncidents." ) ; const pathParams = { } ; const queryParams = { "limit" : listIncidentsRequest . limit , "compartmentId" : listIncidentsRequest . compartmentId , "sortBy" : listIncidentsRequest . sortBy , "sortOrder" : listIncidentsRequest . sortOrder , "lifecycleState" : listIncidentsRequest . lifecycleState , "page" : listIncidentsRequest . page , "problemType" : listIncidentsRequest . problemType } ; let headerParams = { "Content-Type" : common . Constants . APPLICATION_JSON , "csi" : listIncidentsRequest . csi , "opc-request-id" : listIncidentsRequest . opcRequestId , "ocid" : listIncidentsRequest . ocid , "homeregion" : listIncidentsRequest . homeregion } ; const specRetryConfiguration = common . NoRetryConfigurationDetails ; const retrier = GenericRetrier . createPreferredRetrier ( this . _clientConfiguration ? this . _clientConfiguration . retryConfiguration : undefined , listIncidentsRequest . retryConfiguration , specRetryConfiguration ) ; if ( this . logger ) retrier . logger = this . logger ; const request = await composeRequest ( { baseEndpoint : this . _endpoint , defaultHeaders : this . _defaultHeaders , path : "/v2/incidents" , method : "GET" , pathParams : pathParams , headerParams : headerParams , queryParams : queryParams } ) ; try { const response = await retrier . makeServiceCall ( this . _httpClient , request ) ; const sdkResponse = composeResponse ( { responseObject : < responses . ListIncidentsResponse > { } , body : await response . json ( ) , bodyKey : "items" , bodyModel : model . IncidentSummary , type : "Array<model.IncidentSummary>" , 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 listAllIncidents ( request ) { return paginateRecords ( request , req => this . listIncidents ( req ) ) ; } param request public listAllIncidentsResponses ( request ) { return paginateResponses ( request , req => this . listIncidents ( req ) ) ; } param request public listIncidentsRecordIterator ( request ) { return paginateRecords ( request , req => this . listIncidents ( req ) ) ; } param request public listIncidentsResponseIterator ( request ) { return paginateResponses ( request , req => this . listIncidents ( req ) ) ; } param UpdateIncidentRequest return throws example Click  https to see how to use UpdateIncident API.
      public async updateIncident ( updateIncidentRequest ) { if ( this . logger ) this . logger . debug ( "Calling operation IncidentClient#updateIncident." ) ; const pathParams = { "{incidentKey}" : updateIncidentRequest . incidentKey } ; const queryParams = { } ; let headerParams = { "Content-Type" : common . Constants . APPLICATION_JSON , "csi" : updateIncidentRequest . csi , "opc-request-id" : updateIncidentRequest . opcRequestId , "if-match" : updateIncidentRequest . ifMatch , "ocid" : updateIncidentRequest . ocid , "homeregion" : updateIncidentRequest . homeregion } ; const specRetryConfiguration = common . NoRetryConfigurationDetails ; const retrier = GenericRetrier . createPreferredRetrier ( this . _clientConfiguration ? this . _clientConfiguration . retryConfiguration : undefined , updateIncidentRequest . retryConfiguration , specRetryConfiguration ) ; if ( this . logger ) retrier . logger = this . logger ; const request = await composeRequest ( { baseEndpoint : this . _endpoint , defaultHeaders : this . _defaultHeaders , path : "/v2/incidents/{incidentKey}" , method : "PUT" , bodyContent : common . ObjectSerializer . serialize ( updateIncidentRequest . updateIncidentDetails , "UpdateIncident" , model . UpdateIncident . getJsonObj ) , pathParams : pathParams , headerParams : headerParams , queryParams : queryParams } ) ; try { const response = await retrier . makeServiceCall ( this . _httpClient , request ) ; const sdkResponse = composeResponse ( { responseObject : < responses . UpdateIncidentResponse > { } , body : await response . json ( ) , bodyKey : "incident" , bodyModel : model . Incident , type : "model.Incident" , responseHeaders : [ { value : response . headers . get ( "opc-request-id" ) , key : "opcRequestId" , dataType : "string" } ] } ) ; return sdkResponse ; } catch ( err ) { throw err ; } } param ValidateUserRequest return throws example Click  https to see how to use ValidateUser API.
      public async validateUser ( validateUserRequest ) { if ( this . logger ) this . logger . debug ( "Calling operation IncidentClient#validateUser." ) ; const pathParams = { } ; const queryParams = { "problemType" : validateUserRequest . problemType } ; let headerParams = { "Content-Type" : common . Constants . APPLICATION_JSON , "csi" : validateUserRequest . csi , "opc-request-id" : validateUserRequest . opcRequestId , "ocid" : validateUserRequest . ocid , "homeregion" : validateUserRequest . homeregion } ; const specRetryConfiguration = common . NoRetryConfigurationDetails ; const retrier = GenericRetrier . createPreferredRetrier ( this . _clientConfiguration ? this . _clientConfiguration . retryConfiguration : undefined , validateUserRequest . retryConfiguration , specRetryConfiguration ) ; if ( this . logger ) retrier . logger = this . logger ; const request = await composeRequest ( { baseEndpoint : this . _endpoint , defaultHeaders : this . _defaultHeaders , path : "/v2/incidents/user/validate" , method : "GET" , pathParams : pathParams , headerParams : headerParams , queryParams : queryParams } ) ; try { const response = await retrier . makeServiceCall ( this . _httpClient , request ) ; const sdkResponse = composeResponse ( { responseObject : < responses . ValidateUserResponse > { } , body : await response . json ( ) , bodyKey : "validationResponse" , bodyModel : model . ValidationResponse , type : "model.ValidationResponse" , responseHeaders : [ { value : response . headers . get ( "opc-request-id" ) , key : "opcRequestId" , dataType : "string" } ] } ) ; return sdkResponse ; } catch ( err ) { throw err ; } } } export enum UserApiKeys { } /**
 * 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 UserClient { protected static serviceEndpointTemplate = "https://incidentmanagement.{region}.{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 + "/20181231" ; if ( this . logger ) this . logger . info ( `UserClient 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 ( UserClient . 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 ( UserClient . serviceEndpointTemplate , regionId ) ; } param CreateUserRequest return throws example Click  https to see how to use CreateUser API.
      public async createUser ( createUserRequest ) { if ( this . logger ) this . logger . debug ( "Calling operation UserClient#createUser." ) ; const pathParams = { } ; const queryParams = { } ; let headerParams = { "Content-Type" : common . Constants . APPLICATION_JSON , "opc-request-id" : createUserRequest . opcRequestId , "ocid" : createUserRequest . ocid , "homeregion" : createUserRequest . homeregion } ; const specRetryConfiguration = common . NoRetryConfigurationDetails ; const retrier = GenericRetrier . createPreferredRetrier ( this . _clientConfiguration ? this . _clientConfiguration . retryConfiguration : undefined , createUserRequest . retryConfiguration , specRetryConfiguration ) ; if ( this . logger ) retrier . logger = this . logger ; const request = await composeRequest ( { baseEndpoint : this . _endpoint , defaultHeaders : this . _defaultHeaders , path : "/v2/users" , method : "POST" , bodyContent : common . ObjectSerializer . serialize ( createUserRequest . createUserDetails , "CreateUserDetails" , model . CreateUserDetails . getJsonObj ) , pathParams : pathParams , headerParams : headerParams , queryParams : queryParams } ) ; try { const response = await retrier . makeServiceCall ( this . _httpClient , request ) ; const sdkResponse = composeResponse ( { responseObject : < responses . CreateUserResponse > { } , body : await response . json ( ) , bodyKey : "user" , bodyModel : model . User , type : "model.User" , responseHeaders : [ { value : response . headers . get ( "opc-request-id" ) , key : "opcRequestId" , dataType : "string" } ] } ) ; return sdkResponse ; } catch ( err ) { throw err ; } } }