/
vdm-attributes.ts
80 lines (70 loc) · 2.14 KB
/
vdm-attributes.ts
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
import { Construct } from 'constructs';
import { CfnVdmAttributes } from './ses.generated';
import { IResource, Resource } from '../../core';
/**
* Virtual Deliverablity Manager (VDM) attributes
*/
export interface IVdmAttributes extends IResource {
/**
* The name of the resource behind the Virtual Deliverablity Manager attributes.
*
* @attribute
*/
readonly vdmAttributesName: string;
}
/**
* Properties for the Virtual Deliverablity Manager (VDM) attributes
*/
export interface VdmAttributesProps {
/**
* Whether engagement metrics are enabled for your account
*
* @default true
*/
readonly engagementMetrics?: boolean;
/**
* Whether optimized shared delivery is enabled for your account
*
* @default true
*/
readonly optimizedSharedDelivery?: boolean;
}
/**
* Virtual Deliverablity Manager (VDM) attributes
*/
export class VdmAttributes extends Resource implements IVdmAttributes {
/**
* Use an existing Virtual Deliverablity Manager attributes resource
*/
public static fromVdmAttributesName(scope: Construct, id: string, vdmAttributesName: string): IVdmAttributes {
class Import extends Resource implements IVdmAttributes {
public readonly vdmAttributesName = vdmAttributesName;
}
return new Import(scope, id);
}
public readonly vdmAttributesName: string;
/**
* Resource ID for the Virtual Deliverablity Manager attributes
*
* @attribute
*/
public readonly vdmAttributesResourceId: string;
constructor(scope: Construct, id: string, props: VdmAttributesProps = {}) {
super(scope, id);
const resource = new CfnVdmAttributes(this, 'Resource', {
dashboardAttributes: {
engagementMetrics: booleanToEnabledDisabled(props.engagementMetrics ?? true),
},
guardianAttributes: {
optimizedSharedDelivery: booleanToEnabledDisabled(props.optimizedSharedDelivery ?? true),
},
});
this.vdmAttributesName = resource.ref;
this.vdmAttributesResourceId = resource.attrVdmAttributesResourceId;
}
}
function booleanToEnabledDisabled(value: boolean): 'ENABLED' | 'DISABLED' {
return value === true
? 'ENABLED'
: 'DISABLED';
}