/**
 * Announcements Service API
 * Manage Oracle Cloud Infrastructure console announcements.
 * OpenAPI spec version: 0.0.1
 *
 *
 * 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 AnnouncementApiKeys { } /**
 * 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 AnnouncementClient { protected static serviceEndpointTemplate = "https://announcements.{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 + "/20180904" ; if ( this . logger ) this . logger . info ( `AnnouncementClient 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 ( AnnouncementClient . 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 ( AnnouncementClient . serviceEndpointTemplate , regionId ) ; } param GetAnnouncementRequest return throws example Click  https to see how to use GetAnnouncement API.
      public async getAnnouncement ( getAnnouncementRequest ) { if ( this . logger ) this . logger . debug ( "Calling operation AnnouncementClient#getAnnouncement." ) ; const pathParams = { "{announcementId}" : getAnnouncementRequest . announcementId } ; const queryParams = { } ; let headerParams = { "Content-Type" : common . Constants . APPLICATION_JSON , "opc-request-id" : getAnnouncementRequest . opcRequestId } ; const specRetryConfiguration = common . NoRetryConfigurationDetails ; const retrier = GenericRetrier . createPreferredRetrier ( this . _clientConfiguration ? this . _clientConfiguration . retryConfiguration : undefined , getAnnouncementRequest . retryConfiguration , specRetryConfiguration ) ; if ( this . logger ) retrier . logger = this . logger ; const request = await composeRequest ( { baseEndpoint : this . _endpoint , defaultHeaders : this . _defaultHeaders , path : "/announcements/{announcementId}" , method : "GET" , pathParams : pathParams , headerParams : headerParams , queryParams : queryParams } ) ; try { const response = await retrier . makeServiceCall ( this . _httpClient , request ) ; const sdkResponse = composeResponse ( { responseObject : < responses . GetAnnouncementResponse > { } , body : await response . json ( ) , bodyKey : "announcement" , bodyModel : model . Announcement , type : "model.Announcement" , responseHeaders : [ { value : response . headers . get ( "opc-request-id" ) , key : "opcRequestId" , dataType : "string" } ] } ) ; return sdkResponse ; } catch ( err ) { throw err ; } } param GetAnnouncementUserStatusRequest return throws example Click  https to see how to use GetAnnouncementUserStatus API.
      public async getAnnouncementUserStatus ( getAnnouncementUserStatusRequest ) { if ( this . logger ) this . logger . debug ( "Calling operation AnnouncementClient#getAnnouncementUserStatus." ) ; const pathParams = { "{announcementId}" : getAnnouncementUserStatusRequest . announcementId } ; const queryParams = { } ; let headerParams = { "Content-Type" : common . Constants . APPLICATION_JSON , "opc-request-id" : getAnnouncementUserStatusRequest . opcRequestId } ; const specRetryConfiguration = common . NoRetryConfigurationDetails ; const retrier = GenericRetrier . createPreferredRetrier ( this . _clientConfiguration ? this . _clientConfiguration . retryConfiguration : undefined , getAnnouncementUserStatusRequest . retryConfiguration , specRetryConfiguration ) ; if ( this . logger ) retrier . logger = this . logger ; const request = await composeRequest ( { baseEndpoint : this . _endpoint , defaultHeaders : this . _defaultHeaders , path : "/announcements/{announcementId}/userStatus" , method : "GET" , pathParams : pathParams , headerParams : headerParams , queryParams : queryParams } ) ; try { const response = await retrier . makeServiceCall ( this . _httpClient , request ) ; const sdkResponse = composeResponse ( { responseObject : < responses . GetAnnouncementUserStatusResponse > { } , body : await response . json ( ) , bodyKey : "announcementUserStatusDetails" , bodyModel : model . AnnouncementUserStatusDetails , type : "model.AnnouncementUserStatusDetails" , responseHeaders : [ { value : response . headers . get ( "opc-request-id" ) , key : "opcRequestId" , dataType : "string" } ] } ) ; return sdkResponse ; } catch ( err ) { throw err ; } } param ListAnnouncementsRequest return throws example Click  https to see how to use ListAnnouncements API.
      public async listAnnouncements ( listAnnouncementsRequest ) { if ( this . logger ) this . logger . debug ( "Calling operation AnnouncementClient#listAnnouncements." ) ; const pathParams = { } ; const queryParams = { "limit" : listAnnouncementsRequest . limit , "page" : listAnnouncementsRequest . page , "compartmentId" : listAnnouncementsRequest . compartmentId , "announcementType" : listAnnouncementsRequest . announcementType , "lifecycleState" : listAnnouncementsRequest . lifecycleState , "isBanner" : listAnnouncementsRequest . isBanner , "sortBy" : listAnnouncementsRequest . sortBy , "sortOrder" : listAnnouncementsRequest . sortOrder , "timeOneEarliestTime" : listAnnouncementsRequest . timeOneEarliestTime , "timeOneLatestTime" : listAnnouncementsRequest . timeOneLatestTime } ; let headerParams = { "Content-Type" : common . Constants . APPLICATION_JSON , "opc-request-id" : listAnnouncementsRequest . opcRequestId } ; const specRetryConfiguration = common . NoRetryConfigurationDetails ; const retrier = GenericRetrier . createPreferredRetrier ( this . _clientConfiguration ? this . _clientConfiguration . retryConfiguration : undefined , listAnnouncementsRequest . retryConfiguration , specRetryConfiguration ) ; if ( this . logger ) retrier . logger = this . logger ; const request = await composeRequest ( { baseEndpoint : this . _endpoint , defaultHeaders : this . _defaultHeaders , path : "/announcements" , method : "GET" , pathParams : pathParams , headerParams : headerParams , queryParams : queryParams } ) ; try { const response = await retrier . makeServiceCall ( this . _httpClient , request ) ; const sdkResponse = composeResponse ( { responseObject : < responses . ListAnnouncementsResponse > { } , body : await response . json ( ) , bodyKey : "announcementsCollection" , bodyModel : model . AnnouncementsCollection , type : "model.AnnouncementsCollection" , responseHeaders : [ { value : response . headers . get ( "opc-next-page" ) , key : "opcNextPage" , dataType : "string" } , { value : response . headers . get ( "opc-request-id" ) , key : "opcRequestId" , dataType : "string" } ] } ) ; return sdkResponse ; } catch ( err ) { throw err ; } } param UpdateAnnouncementUserStatusRequest return throws example Click  https to see how to use UpdateAnnouncementUserStatus API.
      public async updateAnnouncementUserStatus ( updateAnnouncementUserStatusRequest ) { if ( this . logger ) this . logger . debug ( "Calling operation AnnouncementClient#updateAnnouncementUserStatus." ) ; const pathParams = { "{announcementId}" : updateAnnouncementUserStatusRequest . announcementId } ; const queryParams = { } ; let headerParams = { "Content-Type" : common . Constants . APPLICATION_JSON , "if-match" : updateAnnouncementUserStatusRequest . ifMatch , "opc-request-id" : updateAnnouncementUserStatusRequest . opcRequestId } ; const specRetryConfiguration = common . NoRetryConfigurationDetails ; const retrier = GenericRetrier . createPreferredRetrier ( this . _clientConfiguration ? this . _clientConfiguration . retryConfiguration : undefined , updateAnnouncementUserStatusRequest . retryConfiguration , specRetryConfiguration ) ; if ( this . logger ) retrier . logger = this . logger ; const request = await composeRequest ( { baseEndpoint : this . _endpoint , defaultHeaders : this . _defaultHeaders , path : "/announcements/{announcementId}/userStatus" , method : "PUT" , bodyContent : common . ObjectSerializer . serialize ( updateAnnouncementUserStatusRequest . statusDetails , "AnnouncementUserStatusDetails" , model . AnnouncementUserStatusDetails . getJsonObj ) , pathParams : pathParams , headerParams : headerParams , queryParams : queryParams } ) ; try { const response = await retrier . makeServiceCall ( this . _httpClient , request ) ; const sdkResponse = composeResponse ( { responseObject : < responses . UpdateAnnouncementUserStatusResponse > { } , 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 ; } } } export enum AnnouncementsPreferencesApiKeys { } /**
 * 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 AnnouncementsPreferencesClient { protected static serviceEndpointTemplate = "https://announcements.{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 + "/20180904" ; if ( this . logger ) this . logger . info ( `AnnouncementsPreferencesClient 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 ( AnnouncementsPreferencesClient . 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 ( AnnouncementsPreferencesClient . serviceEndpointTemplate , regionId ) ; } param CreateAnnouncementsPreferenceRequest return throws example Click  https to see how to use CreateAnnouncementsPreference API.
      public async createAnnouncementsPreference ( createAnnouncementsPreferenceRequest ) { if ( this . logger ) this . logger . debug ( "Calling operation AnnouncementsPreferencesClient#createAnnouncementsPreference." ) ; const pathParams = { } ; const queryParams = { } ; let headerParams = { "Content-Type" : common . Constants . APPLICATION_JSON , "opc-request-id" : createAnnouncementsPreferenceRequest . opcRequestId , "opc-retry-token" : createAnnouncementsPreferenceRequest . opcRetryToken } ; const specRetryConfiguration = common . NoRetryConfigurationDetails ; const retrier = GenericRetrier . createPreferredRetrier ( this . _clientConfiguration ? this . _clientConfiguration . retryConfiguration : undefined , createAnnouncementsPreferenceRequest . retryConfiguration , specRetryConfiguration ) ; if ( this . logger ) retrier . logger = this . logger ; const request = await composeRequest ( { baseEndpoint : this . _endpoint , defaultHeaders : this . _defaultHeaders , path : "/announcementsPreferences" , method : "POST" , bodyContent : common . ObjectSerializer . serialize ( createAnnouncementsPreferenceRequest . announcementsPreferenceDetails , "CreateAnnouncementsPreferencesDetails" , model . CreateAnnouncementsPreferencesDetails . getJsonObj ) , pathParams : pathParams , headerParams : headerParams , queryParams : queryParams } ) ; try { const response = await retrier . makeServiceCall ( this . _httpClient , request ) ; const sdkResponse = composeResponse ( { responseObject : < responses . CreateAnnouncementsPreferenceResponse > { } , body : await response . json ( ) , bodyKey : "announcementsPreferencesSummary" , bodyModel : model . AnnouncementsPreferencesSummary , type : "model.AnnouncementsPreferencesSummary" , 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 GetAnnouncementsPreferenceRequest return throws example Click  https to see how to use GetAnnouncementsPreference API.
      public async getAnnouncementsPreference ( getAnnouncementsPreferenceRequest ) { if ( this . logger ) this . logger . debug ( "Calling operation AnnouncementsPreferencesClient#getAnnouncementsPreference." ) ; const pathParams = { "{preferenceId}" : getAnnouncementsPreferenceRequest . preferenceId } ; const queryParams = { } ; let headerParams = { "Content-Type" : common . Constants . APPLICATION_JSON , "opc-request-id" : getAnnouncementsPreferenceRequest . opcRequestId } ; const specRetryConfiguration = common . NoRetryConfigurationDetails ; const retrier = GenericRetrier . createPreferredRetrier ( this . _clientConfiguration ? this . _clientConfiguration . retryConfiguration : undefined , getAnnouncementsPreferenceRequest . retryConfiguration , specRetryConfiguration ) ; if ( this . logger ) retrier . logger = this . logger ; const request = await composeRequest ( { baseEndpoint : this . _endpoint , defaultHeaders : this . _defaultHeaders , path : "/announcementsPreferences/{preferenceId}" , method : "GET" , pathParams : pathParams , headerParams : headerParams , queryParams : queryParams } ) ; try { const response = await retrier . makeServiceCall ( this . _httpClient , request ) ; const sdkResponse = composeResponse ( { responseObject : < responses . GetAnnouncementsPreferenceResponse > { } , body : await response . json ( ) , bodyKey : "announcementsPreferences" , bodyModel : model . AnnouncementsPreferences , type : "model.AnnouncementsPreferences" , responseHeaders : [ { value : response . headers . get ( "opc-request-id" ) , key : "opcRequestId" , dataType : "string" } ] } ) ; return sdkResponse ; } catch ( err ) { throw err ; } } param ListAnnouncementsPreferencesRequest return throws example Click  https to see how to use ListAnnouncementsPreferences API.
      public async listAnnouncementsPreferences ( listAnnouncementsPreferencesRequest ) { if ( this . logger ) this . logger . debug ( "Calling operation AnnouncementsPreferencesClient#listAnnouncementsPreferences." ) ; const pathParams = { } ; const queryParams = { "limit" : listAnnouncementsPreferencesRequest . limit , "page" : listAnnouncementsPreferencesRequest . page , "compartmentId" : listAnnouncementsPreferencesRequest . compartmentId } ; let headerParams = { "Content-Type" : common . Constants . APPLICATION_JSON , "opc-request-id" : listAnnouncementsPreferencesRequest . opcRequestId } ; const specRetryConfiguration = common . NoRetryConfigurationDetails ; const retrier = GenericRetrier . createPreferredRetrier ( this . _clientConfiguration ? this . _clientConfiguration . retryConfiguration : undefined , listAnnouncementsPreferencesRequest . retryConfiguration , specRetryConfiguration ) ; if ( this . logger ) retrier . logger = this . logger ; const request = await composeRequest ( { baseEndpoint : this . _endpoint , defaultHeaders : this . _defaultHeaders , path : "/announcementsPreferences" , method : "GET" , pathParams : pathParams , headerParams : headerParams , queryParams : queryParams } ) ; try { const response = await retrier . makeServiceCall ( this . _httpClient , request ) ; const sdkResponse = composeResponse ( { responseObject : < responses . ListAnnouncementsPreferencesResponse > { } , body : await response . json ( ) , bodyKey : "items" , bodyModel : model . AnnouncementsPreferencesSummary , type : "Array<model.AnnouncementsPreferencesSummary>" , responseHeaders : [ { value : response . headers . get ( "opc-next-page" ) , key : "opcNextPage" , dataType : "string" } , { value : response . headers . get ( "opc-request-id" ) , key : "opcRequestId" , dataType : "string" } ] } ) ; return sdkResponse ; } catch ( err ) { throw err ; } } param request public listAllAnnouncementsPreferences ( request ) { return paginateRecords ( request , req => this . listAnnouncementsPreferences ( req ) ) ; } param request public listAllAnnouncementsPreferencesResponses ( request ) { return paginateResponses ( request , req => this . listAnnouncementsPreferences ( req ) ) ; } param request public listAnnouncementsPreferencesRecordIterator ( request ) { return paginateRecords ( request , req => this . listAnnouncementsPreferences ( req ) ) ; } param request public listAnnouncementsPreferencesResponseIterator ( request ) { return paginateResponses ( request , req => this . listAnnouncementsPreferences ( req ) ) ; } param UpdateAnnouncementsPreferenceRequest return throws example Click  https to see how to use UpdateAnnouncementsPreference API.
      public async updateAnnouncementsPreference ( updateAnnouncementsPreferenceRequest ) { if ( this . logger ) this . logger . debug ( "Calling operation AnnouncementsPreferencesClient#updateAnnouncementsPreference." ) ; const pathParams = { "{preferenceId}" : updateAnnouncementsPreferenceRequest . preferenceId } ; const queryParams = { } ; let headerParams = { "Content-Type" : common . Constants . APPLICATION_JSON , "opc-request-id" : updateAnnouncementsPreferenceRequest . opcRequestId , "if-match" : updateAnnouncementsPreferenceRequest . ifMatch } ; const specRetryConfiguration = common . NoRetryConfigurationDetails ; const retrier = GenericRetrier . createPreferredRetrier ( this . _clientConfiguration ? this . _clientConfiguration . retryConfiguration : undefined , updateAnnouncementsPreferenceRequest . retryConfiguration , specRetryConfiguration ) ; if ( this . logger ) retrier . logger = this . logger ; const request = await composeRequest ( { baseEndpoint : this . _endpoint , defaultHeaders : this . _defaultHeaders , path : "/announcementsPreferences/{preferenceId}" , method : "PUT" , bodyContent : common . ObjectSerializer . serialize ( updateAnnouncementsPreferenceRequest . announcementsPreferenceDetails , "UpdateAnnouncementsPreferencesDetails" , model . UpdateAnnouncementsPreferencesDetails . getJsonObj ) , pathParams : pathParams , headerParams : headerParams , queryParams : queryParams } ) ; try { const response = await retrier . makeServiceCall ( this . _httpClient , request ) ; const sdkResponse = composeResponse ( { responseObject : < responses . UpdateAnnouncementsPreferenceResponse > { } , body : await response . json ( ) , bodyKey : "announcementsPreferencesSummary" , bodyModel : model . AnnouncementsPreferencesSummary , type : "model.AnnouncementsPreferencesSummary" , 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 ; } } }