@@ -26,6 +26,10 @@ type RegistryNoCodeModules interface {
26
26
// **Note: This API is still in BETA and subject to change.**
27
27
Read (ctx context.Context , noCodeModuleID string , options * RegistryNoCodeModuleReadOptions ) (* RegistryNoCodeModule , error )
28
28
29
+ // ReadVariables returns the variables for a version of a no-code module
30
+ // **Note: This API is still in BETA and subject to change.**
31
+ ReadVariables (ctx context.Context , noCodeModuleID , noCodeModuleVersion string , options * RegistryNoCodeModuleReadVariablesOptions ) (* RegistryModuleVariableList , error )
32
+
29
33
// Update a registry no-code module
30
34
// **Note: This API is still in BETA and subject to change.**
31
35
Update (ctx context.Context , noCodeModuleID string , options RegistryNoCodeModuleUpdateOptions ) (* RegistryNoCodeModule , error )
@@ -41,6 +45,44 @@ type RegistryNoCodeModules interface {
41
45
UpgradeWorkspace (ctx context.Context , noCodeModuleID string , workspaceID string , options * RegistryNoCodeModuleUpgradeWorkspaceOptions ) (* WorkspaceUpgrade , error )
42
46
}
43
47
48
+ // RegistryModuleVariableList is a list of registry module variables.
49
+ type RegistryModuleVariableList struct {
50
+ Items []* RegistryModuleVariable
51
+
52
+ // NOTE: At the time of authoring this comment, the API endpoint to fetch
53
+ // registry module variables does not support pagination. This field is
54
+ // included to satisfy jsonapi unmarshaler implementation here:
55
+ // https://github.com/hashicorp/go-tfe/blob/3d29602707fa4b10469d1a02685644bd159d3ccc/tfe.go#L859
56
+ * Pagination
57
+ }
58
+
59
+ // RegistryModuleVariable represents a registry module variable.
60
+ type RegistryModuleVariable struct {
61
+ // ID is the ID of the variable.
62
+ ID string `jsonapi:"primary,registry-module-variables"`
63
+
64
+ // Name is the name of the variable.
65
+ Name string `jsonapi:"attr,name"`
66
+
67
+ // VariableType is the type of the variable.
68
+ VariableType string `jsonapi:"attr,type"`
69
+
70
+ // Description is the description of the variable.
71
+ Description string `jsonapi:"attr,description"`
72
+
73
+ // Required is a boolean indicating if the variable is required.
74
+ Required bool `jsonapi:"attr,required"`
75
+
76
+ // Sensitive is a boolean indicating if the variable is sensitive.
77
+ Sensitive bool `jsonapi:"attr,sensitive"`
78
+
79
+ // Options is a slice of strings representing the options for the variable.
80
+ Options []string `jsonapi:"attr,options"`
81
+
82
+ // HasGlobal is a boolean indicating if the variable is global.
83
+ HasGlobal bool `jsonapi:"attr,has-global"`
84
+ }
85
+
44
86
type RegistryNoCodeModuleCreateWorkspaceOptions struct {
45
87
Type string `jsonapi:"primary,no-code-module-workspace"`
46
88
@@ -160,6 +202,14 @@ type RegistryNoCodeModuleReadOptions struct {
160
202
Include []RegistryNoCodeModuleIncludeOpt `url:"include,omitempty"`
161
203
}
162
204
205
+ type RegistryNoCodeModuleReadVariablesOptions struct {
206
+ // Type is a public field utilized by JSON:API to
207
+ // set the resource type via the field tag.
208
+ // It is not a user-defined value and does not need to be set.
209
+ // https://jsonapi.org/format/#crud-updating
210
+ Type string `jsonapi:"primary,no-code-modules"`
211
+ }
212
+
163
213
// RegistryNoCodeModuleUpdateOptions is used when updating a registry no-code module
164
214
type RegistryNoCodeModuleUpdateOptions struct {
165
215
// Type is a public field utilized by JSON:API to
@@ -243,6 +293,39 @@ func (r *registryNoCodeModules) Read(ctx context.Context, noCodeModuleID string,
243
293
return rm , nil
244
294
}
245
295
296
+ // ReadVariables retrieves the no-code variable options for a version of a
297
+ // module.
298
+ func (r * registryNoCodeModules ) ReadVariables (
299
+ ctx context.Context ,
300
+ noCodeModuleID , noCodeModuleVersion string ,
301
+ options * RegistryNoCodeModuleReadVariablesOptions ,
302
+ ) (* RegistryModuleVariableList , error ) {
303
+ if ! validStringID (& noCodeModuleID ) {
304
+ return nil , ErrInvalidModuleID
305
+ }
306
+ if ! validVersion (noCodeModuleVersion ) {
307
+ return nil , ErrInvalidVersion
308
+ }
309
+
310
+ u := fmt .Sprintf (
311
+ "no-code-modules/%s/versions/%s/module-variables" ,
312
+ url .PathEscape (noCodeModuleID ),
313
+ url .PathEscape (noCodeModuleVersion ),
314
+ )
315
+ req , err := r .client .NewRequest ("GET" , u , options )
316
+ if err != nil {
317
+ return nil , err
318
+ }
319
+
320
+ resp := & RegistryModuleVariableList {}
321
+ err = req .Do (ctx , resp )
322
+ if err != nil {
323
+ return nil , err
324
+ }
325
+
326
+ return resp , nil
327
+ }
328
+
246
329
// Update a registry no-code module
247
330
func (r * registryNoCodeModules ) Update (ctx context.Context , noCodeModuleID string , options RegistryNoCodeModuleUpdateOptions ) (* RegistryNoCodeModule , error ) {
248
331
if ! validString (& noCodeModuleID ) {
0 commit comments