@@ -8,18 +8,19 @@ import (
8
8
"fmt"
9
9
10
10
"github.com/go-resty/resty/v2"
11
- "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator "
11
+ "github.com/hashicorp/terraform-plugin-framework/attr "
12
12
"github.com/hashicorp/terraform-plugin-framework/path"
13
13
"github.com/hashicorp/terraform-plugin-framework/resource"
14
14
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
15
15
//"github.com/hashicorp/terraform-plugin-framework/resource/schema/booldefault"
16
16
//"github.com/hashicorp/terraform-plugin-framework/resource/schema/boolplanmodifier"
17
- //"github.com/hashicorp/terraform-plugin-framework/resource/schema/int64default"
17
+ "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
18
+ "github.com/hashicorp/terraform-plugin-framework/resource/schema/listdefault"
18
19
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
19
20
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringdefault"
20
21
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
21
22
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
22
- // "github.com/hashicorp/terraform-plugin-framework/types"
23
+ "github.com/hashicorp/terraform-plugin-framework/types"
23
24
"github.com/hashicorp/terraform-plugin-log/tflog"
24
25
)
25
26
@@ -88,10 +89,134 @@ func (self *CustomResourceResource) Schema(
88
89
},
89
90
},
90
91
// FIXME "properties": {},
91
- // FIXME "create": {},
92
- // FIXME "read": {},
93
- // FIXME "update": {},
94
- // FIXME "delete": {},
92
+ "create" : schema.SingleNestedAttribute {
93
+ MarkdownDescription : "Resource's create action" ,
94
+ Attributes : map [string ]schema.Attribute {
95
+ "id" : schema.StringAttribute {
96
+ MarkdownDescription : "Runnable ID" ,
97
+ Required : true ,
98
+ },
99
+ "name" : schema.StringAttribute {
100
+ MarkdownDescription : "Runnable name" ,
101
+ Required : true ,
102
+ },
103
+ "type" : schema.StringAttribute {
104
+ MarkdownDescription : "Runnable type, either abx.action or vro.workflow" ,
105
+ Required : true ,
106
+ Validators : []validator.String {
107
+ stringvalidator .OneOf ([]string {"abx.action" , "vro.workflow" }... ),
108
+ },
109
+ },
110
+ "project_id" : schema.StringAttribute {
111
+ MarkdownDescription : "Runnable's project ID" ,
112
+ Required : true ,
113
+ },
114
+ "input_parameters" : schema.ListAttribute {
115
+ MarkdownDescription : "TODO" ,
116
+ ElementType : types .StringType ,
117
+ Computed : true ,
118
+ Optional : true ,
119
+ Default : listdefault .StaticValue (types .ListValueMust (types .StringType , []attr.Value {})),
120
+ },
121
+ },
122
+ Required : true ,
123
+ },
124
+ "read" : schema.SingleNestedAttribute {
125
+ MarkdownDescription : "Resource's read action" ,
126
+ Attributes : map [string ]schema.Attribute {
127
+ "id" : schema.StringAttribute {
128
+ MarkdownDescription : "Runnable ID" ,
129
+ Required : true ,
130
+ },
131
+ "name" : schema.StringAttribute {
132
+ MarkdownDescription : "Runnable name" ,
133
+ Required : true ,
134
+ },
135
+ "type" : schema.StringAttribute {
136
+ MarkdownDescription : "Runnable type, either abx.action or vro.workflow" ,
137
+ Required : true ,
138
+ Validators : []validator.String {
139
+ stringvalidator .OneOf ([]string {"abx.action" , "vro.workflow" }... ),
140
+ },
141
+ },
142
+ "project_id" : schema.StringAttribute {
143
+ MarkdownDescription : "Runnable's project ID" ,
144
+ Required : true ,
145
+ },
146
+ "input_parameters" : schema.ListAttribute {
147
+ MarkdownDescription : "TODO" ,
148
+ ElementType : types .StringType ,
149
+ Computed : true ,
150
+ Optional : true ,
151
+ Default : listdefault .StaticValue (types .ListValueMust (types .StringType , []attr.Value {})),
152
+ },
153
+ },
154
+ Required : true ,
155
+ },
156
+ "update" : schema.SingleNestedAttribute {
157
+ MarkdownDescription : "Resource's update action" ,
158
+ Attributes : map [string ]schema.Attribute {
159
+ "id" : schema.StringAttribute {
160
+ MarkdownDescription : "Runnable ID" ,
161
+ Required : true ,
162
+ },
163
+ "name" : schema.StringAttribute {
164
+ MarkdownDescription : "Runnable name" ,
165
+ Required : true ,
166
+ },
167
+ "type" : schema.StringAttribute {
168
+ MarkdownDescription : "Runnable type, either abx.action or vro.workflow" ,
169
+ Required : true ,
170
+ Validators : []validator.String {
171
+ stringvalidator .OneOf ([]string {"abx.action" , "vro.workflow" }... ),
172
+ },
173
+ },
174
+ "project_id" : schema.StringAttribute {
175
+ MarkdownDescription : "Runnable's project ID" ,
176
+ Required : true ,
177
+ },
178
+ "input_parameters" : schema.ListAttribute {
179
+ MarkdownDescription : "TODO" ,
180
+ ElementType : types .StringType ,
181
+ Computed : true ,
182
+ Optional : true ,
183
+ Default : listdefault .StaticValue (types .ListValueMust (types .StringType , []attr.Value {})),
184
+ },
185
+ },
186
+ Required : true ,
187
+ },
188
+ "delete" : schema.SingleNestedAttribute {
189
+ MarkdownDescription : "Resource's delete action" ,
190
+ Attributes : map [string ]schema.Attribute {
191
+ "id" : schema.StringAttribute {
192
+ MarkdownDescription : "Runnable ID" ,
193
+ Required : true ,
194
+ },
195
+ "name" : schema.StringAttribute {
196
+ MarkdownDescription : "Runnable name" ,
197
+ Required : true ,
198
+ },
199
+ "type" : schema.StringAttribute {
200
+ MarkdownDescription : "Runnable type, either abx.action or vro.workflow" ,
201
+ Required : true ,
202
+ Validators : []validator.String {
203
+ stringvalidator .OneOf ([]string {"abx.action" , "vro.workflow" }... ),
204
+ },
205
+ },
206
+ "project_id" : schema.StringAttribute {
207
+ MarkdownDescription : "Runnable's project ID" ,
208
+ Required : true ,
209
+ },
210
+ "input_parameters" : schema.ListAttribute {
211
+ MarkdownDescription : "TODO" ,
212
+ ElementType : types .StringType ,
213
+ Computed : true ,
214
+ Optional : true ,
215
+ Default : listdefault .StaticValue (types .ListValueMust (types .StringType , []attr.Value {})),
216
+ },
217
+ },
218
+ Required : true ,
219
+ },
95
220
// FIXME "additional_actions": {},
96
221
"project_id" : schema.StringAttribute {
97
222
MarkdownDescription : "Project ID" ,
0 commit comments