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