Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | 1x 1x 1x 132x 3x 6x 6x 6x 6x 6x 6x 6x 1x 1x 1x 1x 3x 3x 3x 1x | import DefaultAPIHandler from './default'; import { Asset, Assets } from '../../../types'; export const schema = { type: 'array', items: { type: 'object', properties: { id: { type: 'string' }, type: { type: 'string' }, name: { type: 'string' }, status: { type: 'string', enum: ['active', 'paused', 'suspended'] }, sink: { type: 'object' }, filters: { type: 'array', items: { type: 'object', }, }, }, required: ['name'], }, }; export type LogStream = { type: 'eventbridge' | 'eventgrid' | 'datadog' | 'http' | 'splunk' | 'sumo'; name: string; id: string; status?: 'active' | 'suspended' | 'paused'; sink?: { [key: string]: string | boolean; }; }; export default class LogStreamsHandler extends DefaultAPIHandler { existing: Asset[] | null; constructor(config: DefaultAPIHandler) { super({ ...config, type: 'logStreams', stripUpdateFields: ['type'], stripCreateFields: ['status', 'sink.awsPartnerEventSource'], sensitiveFieldsToObfuscate: ['sink.httpAuthorization'], }); } objString(item: Asset): string { return super.objString(item.name); } async getType(): Promise<Asset> { Iif (this.existing) { return this.existing; } const logStreams = await this.client.logStreams.getAll({ paginate: false }).then((logStreams) => logStreams.map((logStream) => { if (logStream.status === 'suspended') delete logStream.status; return logStream; }) ); this.existing = logStreams; return logStreams; } async processChanges(assets: Assets): Promise<void> { const { logStreams } = assets; Iif (!logStreams) return; const changes = await this.calcChanges(assets).then((changes) => { return { ...changes, update: changes.update.map((update: LogStream) => { Iif (update.type === 'eventbridge' || update.type === 'eventgrid') { delete update.sink; } Iif (update.status === 'suspended') { // @ts-ignore because while status is usually expected for update payloads, it is ok to be omitted // for suspended log streams. Setting as `active` in these instances would probably be ok // but bit presumptuous, let suspended log streams remain suspended. delete update.status; } return update; }), }; }); await super.processChanges(assets, changes); } } |