|
| 1 | +// Generated by cdk-import |
| 2 | +import * as cdk from "aws-cdk-lib"; |
| 3 | +import * as constructs from "constructs"; |
| 4 | + |
| 5 | +/** |
| 6 | + * An example resource schema demonstrating some basic constructs and validation rules. |
| 7 | + * |
| 8 | + * @schema CfnClusterOutageSimulationProps |
| 9 | + */ |
| 10 | +export interface CfnClusterOutageSimulationProps { |
| 11 | + /** |
| 12 | + * The profile is defined in AWS Secret manager. See [Secret Manager Profile setup](../../../examples/profile-secret.yaml). |
| 13 | + * |
| 14 | + * @schema CfnClusterOutageSimulationProps#Profile |
| 15 | + */ |
| 16 | + readonly profile: string; |
| 17 | + |
| 18 | + /** |
| 19 | + * List of settings that configure your cluster regions. For Global Clusters, each object in the array represents a zone where your clusters nodes deploy. For non-Global replica sets and sharded clusters, this array has one object representing where your clusters nodes deploy. |
| 20 | + * |
| 21 | + * @schema CfnClusterOutageSimulationProps#OutageFilters |
| 22 | + */ |
| 23 | + readonly outageFilters: Filter[]; |
| 24 | + |
| 25 | + /** |
| 26 | + * Human-readable label that identifies the project. |
| 27 | + * |
| 28 | + * @schema CfnClusterOutageSimulationProps#ProjectId |
| 29 | + */ |
| 30 | + readonly projectId: string; |
| 31 | + |
| 32 | + /** |
| 33 | + * Human-readable label that identifies the cluster . |
| 34 | + * |
| 35 | + * @schema CfnClusterOutageSimulationProps#ClusterName |
| 36 | + */ |
| 37 | + readonly clusterName: string; |
| 38 | +} |
| 39 | + |
| 40 | +/** |
| 41 | + * Converts an object of type 'CfnClusterOutageSimulationProps' to JSON representation. |
| 42 | + */ |
| 43 | +/* eslint-disable max-len, quote-props */ |
| 44 | +export function toJson_CfnClusterOutageSimulationProps( |
| 45 | + obj: CfnClusterOutageSimulationProps | undefined |
| 46 | +): Record<string, any> | undefined { |
| 47 | + if (obj === undefined) { |
| 48 | + return undefined; |
| 49 | + } |
| 50 | + const result = { |
| 51 | + Profile: obj.profile, |
| 52 | + OutageFilters: obj.outageFilters?.map((y) => toJson_Filter(y)), |
| 53 | + ProjectId: obj.projectId, |
| 54 | + ClusterName: obj.clusterName, |
| 55 | + }; |
| 56 | + // filter undefined values |
| 57 | + return Object.entries(result).reduce( |
| 58 | + (r, i) => (i[1] === undefined ? r : { ...r, [i[0]]: i[1] }), |
| 59 | + {} |
| 60 | + ); |
| 61 | +} |
| 62 | +/* eslint-enable max-len, quote-props */ |
| 63 | + |
| 64 | +/** |
| 65 | + * @schema Filter |
| 66 | + */ |
| 67 | +export interface Filter { |
| 68 | + /** |
| 69 | + * @schema Filter#CloudProvider |
| 70 | + */ |
| 71 | + readonly cloudProvider?: FilterCloudProvider; |
| 72 | + |
| 73 | + /** |
| 74 | + * @schema Filter#Region |
| 75 | + */ |
| 76 | + readonly region?: string; |
| 77 | + |
| 78 | + /** |
| 79 | + * @schema Filter#Type |
| 80 | + */ |
| 81 | + readonly type?: string; |
| 82 | +} |
| 83 | + |
| 84 | +/** |
| 85 | + * Converts an object of type 'Filter' to JSON representation. |
| 86 | + */ |
| 87 | +/* eslint-disable max-len, quote-props */ |
| 88 | +export function toJson_Filter( |
| 89 | + obj: Filter | undefined |
| 90 | +): Record<string, any> | undefined { |
| 91 | + if (obj === undefined) { |
| 92 | + return undefined; |
| 93 | + } |
| 94 | + const result = { |
| 95 | + CloudProvider: obj.cloudProvider, |
| 96 | + Region: obj.region, |
| 97 | + Type: obj.type, |
| 98 | + }; |
| 99 | + // filter undefined values |
| 100 | + return Object.entries(result).reduce( |
| 101 | + (r, i) => (i[1] === undefined ? r : { ...r, [i[0]]: i[1] }), |
| 102 | + {} |
| 103 | + ); |
| 104 | +} |
| 105 | +/* eslint-enable max-len, quote-props */ |
| 106 | + |
| 107 | +/** |
| 108 | + * @schema FilterCloudProvider |
| 109 | + */ |
| 110 | +export enum FilterCloudProvider { |
| 111 | + /** AWS */ |
| 112 | + AWS = "AWS", |
| 113 | + /** AZURE */ |
| 114 | + AZURE = "AZURE", |
| 115 | + /** GCP */ |
| 116 | + GCP = "GCP", |
| 117 | +} |
| 118 | + |
| 119 | +/** |
| 120 | + * A CloudFormation `MongoDB::Atlas::ClusterOutageSimulation` |
| 121 | + * |
| 122 | + * @cloudformationResource MongoDB::Atlas::ClusterOutageSimulation |
| 123 | + * @stability external |
| 124 | + */ |
| 125 | +export class CfnClusterOutageSimulation extends cdk.CfnResource { |
| 126 | + /** |
| 127 | + * The CloudFormation resource type name for this resource class. |
| 128 | + */ |
| 129 | + public static readonly CFN_RESOURCE_TYPE_NAME = |
| 130 | + "MongoDB::Atlas::ClusterOutageSimulation"; |
| 131 | + |
| 132 | + /** |
| 133 | + * Resource props. |
| 134 | + */ |
| 135 | + public readonly props: CfnClusterOutageSimulationProps; |
| 136 | + |
| 137 | + /** |
| 138 | + * Attribute `MongoDB::Atlas::ClusterOutageSimulation.SimulationId` |
| 139 | + */ |
| 140 | + public readonly attrSimulationId: string; |
| 141 | + /** |
| 142 | + * Attribute `MongoDB::Atlas::ClusterOutageSimulation.StartRequestDate` |
| 143 | + */ |
| 144 | + public readonly attrStartRequestDate: string; |
| 145 | + /** |
| 146 | + * Attribute `MongoDB::Atlas::ClusterOutageSimulation.State` |
| 147 | + */ |
| 148 | + public readonly attrState: string; |
| 149 | + |
| 150 | + /** |
| 151 | + * Create a new `MongoDB::Atlas::ClusterOutageSimulation`. |
| 152 | + * |
| 153 | + * @param scope - scope in which this resource is defined |
| 154 | + * @param id - scoped id of the resource |
| 155 | + * @param props - resource properties |
| 156 | + */ |
| 157 | + constructor( |
| 158 | + scope: constructs.Construct, |
| 159 | + id: string, |
| 160 | + props: CfnClusterOutageSimulationProps |
| 161 | + ) { |
| 162 | + super(scope, id, { |
| 163 | + type: CfnClusterOutageSimulation.CFN_RESOURCE_TYPE_NAME, |
| 164 | + properties: toJson_CfnClusterOutageSimulationProps(props)!, |
| 165 | + }); |
| 166 | + |
| 167 | + this.props = props; |
| 168 | + |
| 169 | + this.attrSimulationId = cdk.Token.asString(this.getAtt("SimulationId")); |
| 170 | + this.attrStartRequestDate = cdk.Token.asString( |
| 171 | + this.getAtt("StartRequestDate") |
| 172 | + ); |
| 173 | + this.attrState = cdk.Token.asString(this.getAtt("State")); |
| 174 | + } |
| 175 | +} |
0 commit comments