@cdktn/provider-generator 0.24.0-pre.87 → 0.24.0-pre.89
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/__tests__/edge-provider-schema/builder.d.ts +9 -3
- package/build/__tests__/edge-provider-schema/builder.js +6 -3
- package/build/__tests__/edge-provider-schema/index.js +119 -1
- package/build/__tests__/provider.test.js +4 -1
- package/build/get/__tests__/generator/ephemeral-resources.test.d.ts +2 -0
- package/build/get/__tests__/generator/ephemeral-resources.test.js +49 -0
- package/build/get/__tests__/generator/provider-functions.test.d.ts +2 -0
- package/build/get/__tests__/generator/provider-functions.test.js +176 -0
- package/build/get/__tests__/generator/provider.test.js +9 -1
- package/build/get/__tests__/generator/write-only.test.d.ts +2 -0
- package/build/get/__tests__/generator/write-only.test.js +65 -0
- package/build/get/__tests__/target-versions.test.d.ts +2 -0
- package/build/get/__tests__/target-versions.test.js +171 -0
- package/build/get/constructs-maker.d.ts +8 -1
- package/build/get/constructs-maker.js +13 -4
- package/build/get/generator/emitter/attributes-emitter.d.ts +12 -2
- package/build/get/generator/emitter/attributes-emitter.js +47 -5
- package/build/get/generator/emitter/index.d.ts +1 -0
- package/build/get/generator/emitter/index.js +2 -1
- package/build/get/generator/emitter/provider-functions-emitter.d.ts +11 -0
- package/build/get/generator/emitter/provider-functions-emitter.js +94 -0
- package/build/get/generator/emitter/resource-emitter.d.ts +5 -1
- package/build/get/generator/emitter/resource-emitter.js +83 -7
- package/build/get/generator/models/attribute-model.d.ts +2 -0
- package/build/get/generator/models/attribute-model.js +2 -1
- package/build/get/generator/models/index.d.ts +1 -0
- package/build/get/generator/models/index.js +2 -1
- package/build/get/generator/models/provider-function-model.d.ts +102 -0
- package/build/get/generator/models/provider-function-model.js +667 -0
- package/build/get/generator/models/resource-model.d.ts +3 -0
- package/build/get/generator/models/resource-model.js +13 -4
- package/build/get/generator/models/struct.d.ts +2 -0
- package/build/get/generator/models/struct.js +6 -2
- package/build/get/generator/provider-generator.d.ts +2 -0
- package/build/get/generator/provider-generator.js +31 -3
- package/build/get/generator/resource-parser.js +3 -1
- package/package.json +5 -5
- package/src/__tests__/__snapshots__/edge-provider-schema.test.ts.snap +4 -0
- package/src/__tests__/edge-provider-schema/builder.ts +17 -1
- package/src/__tests__/edge-provider-schema/index.ts +124 -1
- package/src/__tests__/provider.test.ts +3 -0
- package/src/get/__tests__/generator/__snapshots__/ephemeral-resources.test.ts.snap +524 -0
- package/src/get/__tests__/generator/__snapshots__/provider-functions.test.ts.snap +444 -0
- package/src/get/__tests__/generator/__snapshots__/write-only.test.ts.snap +262 -0
- package/src/get/__tests__/generator/ephemeral-resources.test.ts +46 -0
- package/src/get/__tests__/generator/fixtures/ephemeral-resources.test.fixture.json +160 -0
- package/src/get/__tests__/generator/fixtures/provider-functions-collision.test.fixture.json +31 -0
- package/src/get/__tests__/generator/fixtures/provider-functions-synthetic.test.fixture.json +192 -0
- package/src/get/__tests__/generator/fixtures/provider-functions.test.fixture.json +170 -0
- package/src/get/__tests__/generator/fixtures/write-only.test.fixture.json +58 -0
- package/src/get/__tests__/generator/provider-functions.test.ts +262 -0
- package/src/get/__tests__/generator/provider.test.ts +8 -0
- package/src/get/__tests__/generator/write-only.test.ts +71 -0
- package/src/get/__tests__/target-versions.test.ts +206 -0
- package/src/get/constructs-maker.ts +43 -3
- package/src/get/generator/emitter/attributes-emitter.ts +61 -6
- package/src/get/generator/emitter/index.ts +1 -0
- package/src/get/generator/emitter/provider-functions-emitter.ts +117 -0
- package/src/get/generator/emitter/resource-emitter.ts +110 -6
- package/src/get/generator/models/attribute-model.ts +3 -0
- package/src/get/generator/models/index.ts +1 -0
- package/src/get/generator/models/provider-function-model.ts +872 -0
- package/src/get/generator/models/resource-model.ts +25 -3
- package/src/get/generator/models/struct.ts +9 -1
- package/src/get/generator/provider-generator.ts +70 -4
- package/src/get/generator/resource-parser.ts +2 -0
|
@@ -0,0 +1,444 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
|
|
2
|
+
|
|
3
|
+
exports[`generate provider functions covering variadic parameters, primitive/list returns, and a 'default' parameter name matches the snapshot: example-provider-functions 1`] = `
|
|
4
|
+
"// generated from provider function schema
|
|
5
|
+
|
|
6
|
+
import * as cdktn from 'cdktn';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Provider-defined functions of the example provider.
|
|
10
|
+
*/
|
|
11
|
+
export class ExampleProviderFunctions {
|
|
12
|
+
private readonly providerLocalName: string;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @param providerLocalName The local name of the provider in required_providers; defaults to the registry short name. Override when the provider is declared under a different local name — aliases do not change the namespace, local names do.
|
|
16
|
+
*/
|
|
17
|
+
constructor(providerLocalName: string) {
|
|
18
|
+
this.providerLocalName = providerLocalName;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Returns an object describing the build that produced the given seed.
|
|
23
|
+
* @param {string} seed
|
|
24
|
+
* @returns {object}
|
|
25
|
+
*/
|
|
26
|
+
public buildInfo(seed: string): cdktn.IResolvable {
|
|
27
|
+
return cdktn.TerraformProviderFunction.invoke(this.providerLocalName, "build_info", [seed]);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Returns true_value if condition is true, otherwise returns false_value. The dynamic return type allows either branch to be a value of any type.
|
|
32
|
+
* @param {boolean | IResolvable} condition
|
|
33
|
+
* @param {any} trueValue
|
|
34
|
+
* @param {any} falseValue
|
|
35
|
+
* @returns {any}
|
|
36
|
+
*/
|
|
37
|
+
public conditionIf(condition: boolean | cdktn.IResolvable, trueValue: any, falseValue: any): cdktn.IResolvable {
|
|
38
|
+
return cdktn.TerraformProviderFunction.invoke(this.providerLocalName, "condition_if", [condition, trueValue, falseValue]);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Renders the given map of config objects as a single string.
|
|
43
|
+
* @param {any} configs
|
|
44
|
+
* @returns {string}
|
|
45
|
+
*/
|
|
46
|
+
public configMap(configs: any): string {
|
|
47
|
+
return cdktn.Token.asString(cdktn.TerraformProviderFunction.invoke(this.providerLocalName, "config_map", [configs]));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Returns a map of config objects keyed by tag for the given prefix.
|
|
52
|
+
* @param {string} prefix
|
|
53
|
+
* @returns {{ [key: string]: any }}
|
|
54
|
+
*/
|
|
55
|
+
public configsByTag(prefix: string): { [key: string]: any } {
|
|
56
|
+
return cdktn.Token.asAnyMap(cdktn.TerraformProviderFunction.invoke(this.providerLocalName, "configs_by_tag", [prefix]));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Returns a map of counts keyed by tag for the given prefix.
|
|
61
|
+
* @param {string} prefix
|
|
62
|
+
* @returns {{ [key: string]: number }}
|
|
63
|
+
*/
|
|
64
|
+
public countByTag(prefix: string): { [key: string]: number } {
|
|
65
|
+
return cdktn.Token.asNumberMap(cdktn.TerraformProviderFunction.invoke(this.providerLocalName, "count_by_tag", [prefix]));
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Deduplicates each group of names, returning a list of name sets.
|
|
70
|
+
* @param {Array<Set<string>>} nameGroups
|
|
71
|
+
* @returns {Array<Set<string>>}
|
|
72
|
+
*/
|
|
73
|
+
public dedupeNameGroups(nameGroups: string[][] | cdktn.IResolvable): cdktn.IResolvable {
|
|
74
|
+
return cdktn.TerraformProviderFunction.invoke(this.providerLocalName, "dedupe_name_groups", [nameGroups]);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Returns a default map of string tags derived from the given prefix - used to prove a map(string) RETURN can be fed directly into another function's map(string) PARAMETER (see tag_map above).
|
|
79
|
+
* @param {string} prefix
|
|
80
|
+
* @returns {{ [key: string]: string }}
|
|
81
|
+
*/
|
|
82
|
+
public defaultTags(prefix: string): { [key: string]: string } {
|
|
83
|
+
return cdktn.Token.asStringMap(cdktn.TerraformProviderFunction.invoke(this.providerLocalName, "default_tags", [prefix]));
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Renders the given list of config objects as a single string.
|
|
88
|
+
* @param {Array<object>} configs
|
|
89
|
+
* @returns {string}
|
|
90
|
+
*/
|
|
91
|
+
public describeConfigs(configs: any[] | cdktn.IResolvable): string {
|
|
92
|
+
return cdktn.Token.asString(cdktn.TerraformProviderFunction.invoke(this.providerLocalName, "describe_configs", [configs]));
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Returns true if any flag in the given set of flags is true.
|
|
97
|
+
* @param {Set<boolean | IResolvable>} flags - Terraform set; ordering is not guaranteed and duplicate values are removed.
|
|
98
|
+
* @returns {boolean | IResolvable}
|
|
99
|
+
*/
|
|
100
|
+
public flagSet(flags: Array<boolean | cdktn.IResolvable> | cdktn.IResolvable): cdktn.IResolvable {
|
|
101
|
+
return cdktn.TerraformProviderFunction.invoke(this.providerLocalName, "flag_set", [flags]);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Returns a map of flags keyed by tag for the given prefix.
|
|
106
|
+
* @param {string} prefix
|
|
107
|
+
* @returns {{ [key: string]: boolean }}
|
|
108
|
+
*/
|
|
109
|
+
public flagsByTag(prefix: string): { [key: string]: boolean } {
|
|
110
|
+
return cdktn.Token.asBooleanMap(cdktn.TerraformProviderFunction.invoke(this.providerLocalName, "flags_by_tag", [prefix]));
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Returns a set of flags derived from the given seed - used to prove a set(bool) RETURN can be fed directly into another function's set(bool) PARAMETER (see flag_set above).
|
|
115
|
+
* @param {string} seed
|
|
116
|
+
* @returns {Set<boolean | IResolvable>} Terraform set; ordering is not guaranteed and duplicate values are removed.
|
|
117
|
+
*/
|
|
118
|
+
public flagsForSeed(seed: string): cdktn.IResolvable {
|
|
119
|
+
return cdktn.TerraformProviderFunction.invoke(this.providerLocalName, "flags_for_seed", [seed]);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Returns true if any flag in the given ordered list of flags is true.
|
|
124
|
+
* @param {Array<boolean | IResolvable>} flags
|
|
125
|
+
* @returns {boolean | IResolvable}
|
|
126
|
+
*/
|
|
127
|
+
public flagsOrdered(flags: Array<boolean | cdktn.IResolvable> | cdktn.IResolvable): cdktn.IResolvable {
|
|
128
|
+
return cdktn.TerraformProviderFunction.invoke(this.providerLocalName, "flags_ordered", [flags]);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Joins the given strings together using the provided separator.
|
|
133
|
+
* @param {string} separator
|
|
134
|
+
* @param {Array<string>} values
|
|
135
|
+
* @returns {string}
|
|
136
|
+
*/
|
|
137
|
+
public joinStrings(separator: string, values: Array<string>): string {
|
|
138
|
+
return cdktn.Token.asString(cdktn.TerraformProviderFunction.invoke(this.providerLocalName, "join_strings", [separator, ...values]));
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* A deprecated helper kept around for backwards compatibility.
|
|
143
|
+
* @deprecated Use new_helper instead.
|
|
144
|
+
* @param {string} input
|
|
145
|
+
* @returns {string}
|
|
146
|
+
*/
|
|
147
|
+
public legacyHelper(input: string): string {
|
|
148
|
+
return cdktn.Token.asString(cdktn.TerraformProviderFunction.invoke(this.providerLocalName, "legacy_helper", [input]));
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Returns a list of numbers counting up from 1 to the given count.
|
|
153
|
+
* @param {number} count
|
|
154
|
+
* @returns {Array<number>}
|
|
155
|
+
*/
|
|
156
|
+
public listNumbers(count: number): number[] {
|
|
157
|
+
return cdktn.Token.asNumberList(cdktn.TerraformProviderFunction.invoke(this.providerLocalName, "list_numbers", [count]));
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Returns a list of names prefixed with the given prefix.
|
|
162
|
+
* @param {string} prefix
|
|
163
|
+
* @returns {Array<string>}
|
|
164
|
+
*/
|
|
165
|
+
public listPrefixedNames(prefix: string): string[] {
|
|
166
|
+
return cdktn.Token.asList(cdktn.TerraformProviderFunction.invoke(this.providerLocalName, "list_prefixed_names", [prefix]));
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Joins a possibly-null prefix with a required suffix.
|
|
171
|
+
* @param {string | IResolvable} prefix - Pass cdktn.Token.nullValue() for an explicit Terraform null.
|
|
172
|
+
* @param {string} suffix
|
|
173
|
+
* @returns {string}
|
|
174
|
+
*/
|
|
175
|
+
public midNullable(prefix: string | cdktn.IResolvable, suffix: string): string {
|
|
176
|
+
return cdktn.Token.asString(cdktn.TerraformProviderFunction.invoke(this.providerLocalName, "mid_nullable", [prefix, suffix]));
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Flattens a matrix (a list of lists of strings) into a single string.
|
|
181
|
+
* @param {Array<Array<string>>} matrix
|
|
182
|
+
* @returns {string}
|
|
183
|
+
*/
|
|
184
|
+
public nestedList(matrix: string[][] | cdktn.IResolvable): string {
|
|
185
|
+
return cdktn.Token.asString(cdktn.TerraformProviderFunction.invoke(this.providerLocalName, "nested_list", [matrix]));
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Adds up a default starting value and any number of addends.
|
|
190
|
+
* @param {number} defaultValue
|
|
191
|
+
* @param {Array<number>} addends
|
|
192
|
+
* @returns {number}
|
|
193
|
+
*/
|
|
194
|
+
public sum(defaultValue: number, addends: Array<number>): number {
|
|
195
|
+
return cdktn.Token.asNumber(cdktn.TerraformProviderFunction.invoke(this.providerLocalName, "sum", [defaultValue, ...addends]));
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Renders the given map of string tags as a single string.
|
|
200
|
+
* @param {{ [key: string]: string }} tags
|
|
201
|
+
* @returns {string}
|
|
202
|
+
*/
|
|
203
|
+
public tagMap(tags: { [key: string]: string }): string {
|
|
204
|
+
return cdktn.Token.asString(cdktn.TerraformProviderFunction.invoke(this.providerLocalName, "tag_map", [tags]));
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Greets the given name, optionally with a custom greeting.
|
|
209
|
+
* @param {string} name
|
|
210
|
+
* @param {string | IResolvable} greeting - Omit or pass cdktn.Token.nullValue() to render the Terraform null keyword.
|
|
211
|
+
* @returns {string}
|
|
212
|
+
*/
|
|
213
|
+
public trailingNullable(name: string, greeting?: string | cdktn.IResolvable): string {
|
|
214
|
+
return cdktn.Token.asString(cdktn.TerraformProviderFunction.invoke(this.providerLocalName, "trailing_nullable", [name, greeting]));
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Returns the distinct name lists among the given ones.
|
|
219
|
+
* @param {Set<Array<string>>} nameLists - Terraform set; ordering is not guaranteed and duplicate values are removed.
|
|
220
|
+
* @returns {Set<Array<string>>} Terraform set; ordering is not guaranteed and duplicate values are removed.
|
|
221
|
+
*/
|
|
222
|
+
public uniqueNameLists(nameLists: string[][] | cdktn.IResolvable): cdktn.IResolvable {
|
|
223
|
+
return cdktn.TerraformProviderFunction.invoke(this.providerLocalName, "unique_name_lists", [nameLists]);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Joins a label with any number of possibly-null items.
|
|
228
|
+
* @param {string} label
|
|
229
|
+
* @param {Array<string | IResolvable>} items - Pass cdktn.Token.nullValue() for an explicit Terraform null.
|
|
230
|
+
* @returns {string}
|
|
231
|
+
*/
|
|
232
|
+
public variadicNullable(label: string, items: Array<string | cdktn.IResolvable>): string {
|
|
233
|
+
return cdktn.Token.asString(cdktn.TerraformProviderFunction.invoke(this.providerLocalName, "variadic_nullable", [label, ...items]));
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
"
|
|
237
|
+
`;
|
|
238
|
+
|
|
239
|
+
exports[`generate provider functions covering variadic parameters, primitive/list returns, and a 'default' parameter name matches the snapshot: provider-index 1`] = `
|
|
240
|
+
"// generated by cdktn get
|
|
241
|
+
export * as providerFunctions from './provider-functions/index';
|
|
242
|
+
|
|
243
|
+
"
|
|
244
|
+
`;
|
|
245
|
+
|
|
246
|
+
exports[`generate provider functions covering variadic parameters, primitive/list returns, and a 'default' parameter name matches the snapshot: provider-lazy-index 1`] = `
|
|
247
|
+
"// generated by cdktn get
|
|
248
|
+
Object.defineProperty(exports, 'providerFunctions', { get: function () { return require('./provider-functions'); } });
|
|
249
|
+
|
|
250
|
+
"
|
|
251
|
+
`;
|
|
252
|
+
|
|
253
|
+
exports[`generate provider functions for the time provider (real terraform 1.15.6 schema fragment): provider-index 1`] = `
|
|
254
|
+
"// generated by cdktn get
|
|
255
|
+
export * as staticResource from './static-resource/index';
|
|
256
|
+
export * as provider from './provider/index';
|
|
257
|
+
export * as providerFunctions from './provider-functions/index';
|
|
258
|
+
|
|
259
|
+
"
|
|
260
|
+
`;
|
|
261
|
+
|
|
262
|
+
exports[`generate provider functions for the time provider (real terraform 1.15.6 schema fragment): provider-lazy-index 1`] = `
|
|
263
|
+
"// generated by cdktn get
|
|
264
|
+
Object.defineProperty(exports, 'staticResource', { get: function () { return require('./static-resource'); } });
|
|
265
|
+
Object.defineProperty(exports, 'provider', { get: function () { return require('./provider'); } });
|
|
266
|
+
Object.defineProperty(exports, 'providerFunctions', { get: function () { return require('./provider-functions'); } });
|
|
267
|
+
|
|
268
|
+
"
|
|
269
|
+
`;
|
|
270
|
+
|
|
271
|
+
exports[`generate provider functions for the time provider (real terraform 1.15.6 schema fragment): time-provider 1`] = `
|
|
272
|
+
"// https://registry.terraform.io/providers/hashicorp/time/latest/docs
|
|
273
|
+
// generated from terraform resource schema
|
|
274
|
+
|
|
275
|
+
import { Construct } from 'constructs';
|
|
276
|
+
import * as cdktn from 'cdktn';
|
|
277
|
+
|
|
278
|
+
// Configuration
|
|
279
|
+
|
|
280
|
+
export interface TimeProviderConfig {
|
|
281
|
+
/**
|
|
282
|
+
* Alias name
|
|
283
|
+
*
|
|
284
|
+
* Docs at Terraform Registry: {@link https://registry.terraform.io/providers/hashicorp/time/latest/docs#alias TimeProvider#alias}
|
|
285
|
+
*/
|
|
286
|
+
readonly alias?: string;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
import { TimeProviderFunctions } from '../provider-functions/index';
|
|
290
|
+
/**
|
|
291
|
+
* Represents a {@link https://registry.terraform.io/providers/hashicorp/time/latest/docs time}
|
|
292
|
+
*/
|
|
293
|
+
export class TimeProvider extends cdktn.TerraformProvider {
|
|
294
|
+
|
|
295
|
+
// =================
|
|
296
|
+
// STATIC PROPERTIES
|
|
297
|
+
// =================
|
|
298
|
+
public static readonly tfResourceType = "time";
|
|
299
|
+
|
|
300
|
+
// ==============
|
|
301
|
+
// STATIC Methods
|
|
302
|
+
// ==============
|
|
303
|
+
/**
|
|
304
|
+
* Generates CDKTN code for importing a TimeProvider resource upon running "cdktn plan <stack-name>"
|
|
305
|
+
* @param scope The scope in which to define this construct
|
|
306
|
+
* @param importToId The construct id used in the generated config for the TimeProvider to import
|
|
307
|
+
* @param importFromId The id of the existing TimeProvider that should be imported. Refer to the {@link https://registry.terraform.io/providers/hashicorp/time/latest/docs#import import section} in the documentation of this resource for the id to use
|
|
308
|
+
* @param provider? Optional instance of the provider where the TimeProvider to import is found
|
|
309
|
+
*/
|
|
310
|
+
public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktn.TerraformProvider) {
|
|
311
|
+
return new cdktn.ImportableResource(scope, importToId, { terraformResourceType: "time", importId: importFromId, provider });
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
// ===========
|
|
315
|
+
// INITIALIZER
|
|
316
|
+
// ===========
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* Create a new {@link https://registry.terraform.io/providers/hashicorp/time/latest/docs time} Resource
|
|
320
|
+
*
|
|
321
|
+
* @param scope The scope in which to define this construct
|
|
322
|
+
* @param id The scoped construct ID. Must be unique amongst siblings in the same scope
|
|
323
|
+
* @param options TimeProviderConfig = {}
|
|
324
|
+
*/
|
|
325
|
+
public constructor(scope: Construct, id: string, config: TimeProviderConfig = {}) {
|
|
326
|
+
super(scope, id, {
|
|
327
|
+
terraformResourceType: 'time',
|
|
328
|
+
terraformGeneratorMetadata: {
|
|
329
|
+
providerName: 'time'
|
|
330
|
+
},
|
|
331
|
+
terraformProviderSource: 'registry.terraform.io/hashicorp/time'
|
|
332
|
+
});
|
|
333
|
+
this._alias = config.alias;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
// ==========
|
|
337
|
+
// ATTRIBUTES
|
|
338
|
+
// ==========
|
|
339
|
+
|
|
340
|
+
// alias - computed: false, optional: true, required: false
|
|
341
|
+
private _alias?: string;
|
|
342
|
+
public get alias() {
|
|
343
|
+
return this._alias;
|
|
344
|
+
}
|
|
345
|
+
public set alias(value: string | undefined) {
|
|
346
|
+
this._alias = value;
|
|
347
|
+
}
|
|
348
|
+
public resetAlias() {
|
|
349
|
+
this._alias = undefined;
|
|
350
|
+
}
|
|
351
|
+
// Temporarily expose input value. Use with caution.
|
|
352
|
+
public get aliasInput() {
|
|
353
|
+
return this._alias;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
// ==========================
|
|
357
|
+
// PROVIDER-DEFINED FUNCTIONS
|
|
358
|
+
// ==========================
|
|
359
|
+
private _functions?: TimeProviderFunctions;
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* Provider-defined functions of the time provider.
|
|
363
|
+
*/
|
|
364
|
+
public get functions(): TimeProviderFunctions {
|
|
365
|
+
if (!this._functions) {
|
|
366
|
+
this._functions = new TimeProviderFunctions(this.terraformResourceType);
|
|
367
|
+
}
|
|
368
|
+
return this._functions;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
// =========
|
|
372
|
+
// SYNTHESIS
|
|
373
|
+
// =========
|
|
374
|
+
|
|
375
|
+
protected synthesizeAttributes(): { [name: string]: any } {
|
|
376
|
+
return {
|
|
377
|
+
alias: cdktn.stringToTerraform(this._alias),
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
protected synthesizeHclAttributes(): { [name: string]: any } {
|
|
382
|
+
const attrs = {
|
|
383
|
+
alias: {
|
|
384
|
+
value: cdktn.stringToHclTerraform(this._alias),
|
|
385
|
+
isBlock: false,
|
|
386
|
+
type: "simple",
|
|
387
|
+
storageClassType: "string",
|
|
388
|
+
},
|
|
389
|
+
};
|
|
390
|
+
|
|
391
|
+
// remove undefined attributes
|
|
392
|
+
return Object.fromEntries(Object.entries(attrs).filter(([_, value]) => value !== undefined && value.value !== undefined ))
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
"
|
|
396
|
+
`;
|
|
397
|
+
|
|
398
|
+
exports[`generate provider functions for the time provider (real terraform 1.15.6 schema fragment): time-provider-functions 1`] = `
|
|
399
|
+
"// generated from provider function schema
|
|
400
|
+
|
|
401
|
+
import * as cdktn from 'cdktn';
|
|
402
|
+
|
|
403
|
+
/**
|
|
404
|
+
* Provider-defined functions of the time provider.
|
|
405
|
+
*/
|
|
406
|
+
export class TimeProviderFunctions {
|
|
407
|
+
private readonly providerLocalName: string;
|
|
408
|
+
|
|
409
|
+
/**
|
|
410
|
+
* @param providerLocalName The local name of the provider in required_providers; defaults to the registry short name. Override when the provider is declared under a different local name — aliases do not change the namespace, local names do.
|
|
411
|
+
*/
|
|
412
|
+
constructor(providerLocalName: string) {
|
|
413
|
+
this.providerLocalName = providerLocalName;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
/**
|
|
417
|
+
* Given a [Go duration string](https://pkg.go.dev/time#ParseDuration), will parse and return an object representation of that duration.
|
|
418
|
+
* @param {string} duration - Go time package duration string to parse
|
|
419
|
+
* @returns {object}
|
|
420
|
+
*/
|
|
421
|
+
public durationParse(duration: string): cdktn.IResolvable {
|
|
422
|
+
return cdktn.TerraformProviderFunction.invoke(this.providerLocalName, "duration_parse", [duration]);
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
/**
|
|
426
|
+
* Given an RFC3339 timestamp string, will parse and return an object representation of that date and time.
|
|
427
|
+
* @param {string} timestamp - RFC3339 timestamp string to parse
|
|
428
|
+
* @returns {object}
|
|
429
|
+
*/
|
|
430
|
+
public rfc3339Parse(timestamp: string): cdktn.IResolvable {
|
|
431
|
+
return cdktn.TerraformProviderFunction.invoke(this.providerLocalName, "rfc3339_parse", [timestamp]);
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
/**
|
|
435
|
+
* Given a unix timestamp integer, will parse and return an object representation of that date and time. A unix timestamp is the number of seconds elapsed since January 1, 1970 UTC.
|
|
436
|
+
* @param {number} unixTimestamp - Unix Timestamp integer to parse
|
|
437
|
+
* @returns {object}
|
|
438
|
+
*/
|
|
439
|
+
public unixTimestampParse(unixTimestamp: number): cdktn.IResolvable {
|
|
440
|
+
return cdktn.TerraformProviderFunction.invoke(this.providerLocalName, "unix_timestamp_parse", [unixTimestamp]);
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
"
|
|
444
|
+
`;
|