/**
 * Copyright (c) 2020, 2021 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 identity from "oci-identity" ; import * as audit from "oci-audit" ; const provider = new common . ConfigFileAuthenticationDetailsProvider ( ) ; const compartmentId = provider . getTenantId ( ) ; ( async ( ) => { const options = { timeout : 10000 , errorThresholdPercentage : 50 , resetTimeout : 30000 } ; const clientConfiguration = { circuitBreaker : new common . CircuitBreaker ( options ) } ; const identityClient = new identity . IdentityClient ( { authenticationDetailsProvider : provider } , clientConfiguration ) ; const auditClient = new audit . AuditClient ( { authenticationDetailsProvider : provider } , clientConfiguration ) ; let listUserReq ; listUserReq = { compartmentId : compartmentId } ; const response = await identityClient . listUsers ( listUserReq ) ; console . log ( "List User Repsonse: " , response ) ; const endTime = new Date ( ) ; const offset = new Date ( ) . setDate ( new Date ( ) . getDate ( ) - 5 ) ; const startTime = new Date ( offset ) ; const listEventRequest = { compartmentId : compartmentId , startTime : startTime , endTime : endTime } ; try { const listEventResponse = await auditClient . listEvents ( listEventRequest ) ; console . log ( "response: " , listEventResponse ) ; } catch ( err ) { console . log ( "what is err: " , err ) ; } } ) ( ) ;