Skip to content

Commit 2c7e256

Browse files
authored
Reporting command implementation(Audit, Action and Password). (#194)
1 parent 32df4e9 commit 2c7e256

18 files changed

Lines changed: 3021 additions & 3 deletions

File tree

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import type { Auth } from '@keeper-security/keeperapi'
2+
import { KeeperSdkError, ResultCodes } from '../utils'
3+
import { runAuditReport } from './auditReport'
4+
import { runActionReport } from './actionReport'
5+
import type {
6+
ActionReportOptions,
7+
ActionReportResult,
8+
AuditReportOptions,
9+
AuditReportResult,
10+
} from './reportTypes'
11+
import type { AuthProvider } from './reportUtils'
12+
13+
export class EnterpriseReportManager {
14+
private readonly authProvider: AuthProvider
15+
16+
constructor(authProvider: AuthProvider) {
17+
this.authProvider = authProvider
18+
}
19+
20+
public async runAuditReport(options: AuditReportOptions = {}): Promise<AuditReportResult> {
21+
return runAuditReport(this.requireAuth(), options)
22+
}
23+
24+
public async runActionReport(options: ActionReportOptions = {}): Promise<ActionReportResult> {
25+
return runActionReport(this.requireAuth(), options)
26+
}
27+
28+
private requireAuth(): Auth {
29+
const auth = this.authProvider()
30+
if (!auth) {
31+
throw new KeeperSdkError('You are not logged in. Please log in first.', ResultCodes.NOT_LOGGED_IN)
32+
}
33+
return auth
34+
}
35+
}

0 commit comments

Comments
 (0)