import _ from 'lodash' ; import { ITemplate , ITemplateProperty } from '../interfaces' ; export class SubscriptionFilterBuilder { private readonly defaultTemplate : ITemplate = { Properties : { } , Type : 'AWS::Logs::SubscriptionFilter' , } ; constructor ( private template ? ) { this . template = _ . merge ( this . defaultTemplate , template || { } ) ; } public withDestinationArn ( destinationArn ) { this . template ! . Properties . DestinationArn = destinationArn ; return this ; } public withFilterPattern ( filterPattern ) { this . template ! . Properties . FilterPattern = filterPattern ; return this ; } public withLogGroupName ( logGroupName ) { this . template ! . Properties . LogGroupName = logGroupName ; return this ; } public withDependsOn ( dependsOn ) { this . template ! . DependsOn = dependsOn ; return this ; } public build ( ) { const { DestinationArn , FilterPattern , LogGroupName } = this . template ! . Properties ; if ( ! DestinationArn || ! FilterPattern || ! LogGroupName ) { throw new Error ( 'Missing a required property.' ) ; } return this . template as ITemplate ; } }