@@ -160,3 +160,147 @@ func (s SuperListNestedAttribute) GetDataSource(ctx context.Context) schemaD.Att
160
160
a .MarkdownDescription = genDataSourceAttrDescription (ctx , a .MarkdownDescription , deprecationMessage , a .Validators )
161
161
return a
162
162
}
163
+
164
+ // * SuperTypeOf
165
+
166
+ var _ Attribute = SuperListNestedAttributeOf [struct {}]{}
167
+
168
+ type SuperListNestedAttributeOf [T any ] struct {
169
+ Deprecated * Deprecated
170
+ Common * schemaR.ListNestedAttribute
171
+ Resource * schemaR.ListNestedAttribute
172
+ DataSource * schemaD.ListNestedAttribute
173
+ Attributes Attributes
174
+ }
175
+
176
+ // IsResource returns true if the attribute is a resource attribute.
177
+ func (s SuperListNestedAttributeOf [T ]) IsResource () bool {
178
+ return s .Resource != nil || s .Common != nil
179
+ }
180
+
181
+ // IsDataSource returns true if the attribute is a data source attribute.
182
+ func (s SuperListNestedAttributeOf [T ]) IsDataSource () bool {
183
+ return s .DataSource != nil || s .Common != nil
184
+ }
185
+
186
+ //nolint:dupl
187
+ func (s SuperListNestedAttributeOf [T ]) GetResource (ctx context.Context ) schemaR.Attribute {
188
+ var (
189
+ common schemaR.ListNestedAttribute
190
+ resource schemaR.ListNestedAttribute
191
+ )
192
+
193
+ if s .Common != nil {
194
+ common = * s .Common
195
+ }
196
+
197
+ if s .Resource != nil {
198
+ resource = * s .Resource
199
+ }
200
+
201
+ a := schemaR.ListNestedAttribute {
202
+ Required : computeIsRequired (common , resource ),
203
+ Optional : computeIsOptional (common , resource ),
204
+ Computed : computeIsComputed (common , resource ),
205
+ Sensitive : computeIsSensitive (common , resource ),
206
+ MarkdownDescription : computeMarkdownDescription (common , resource ),
207
+ Description : computeDescription (common , resource ),
208
+ DeprecationMessage : computeDeprecationMessage (common , resource ),
209
+ NestedObject : schemaR.NestedAttributeObject {
210
+ Attributes : s .Attributes .process (ctx , resourceT ).(map [string ]schemaR.Attribute ),
211
+ },
212
+ }
213
+
214
+ a .Validators = append (a .Validators , common .Validators ... )
215
+ a .Validators = append (a .Validators , resource .Validators ... )
216
+ a .PlanModifiers = append (a .PlanModifiers , common .PlanModifiers ... )
217
+ a .PlanModifiers = append (a .PlanModifiers , resource .PlanModifiers ... )
218
+
219
+ defaultVDescription := ""
220
+
221
+ if s .Common != nil {
222
+ if s .Common .CustomType != nil {
223
+ a .CustomType = s .Common .CustomType
224
+ }
225
+ }
226
+
227
+ if s .Resource != nil {
228
+ if s .Resource .Default != nil {
229
+ a .Default = s .Resource .Default
230
+ defaultVDescription = s .Resource .Default .MarkdownDescription (ctx )
231
+ }
232
+ if s .Resource .CustomType != nil {
233
+ a .CustomType = s .Resource .CustomType
234
+ }
235
+ }
236
+ // * If user has not provided a custom type, we will use the default supertypes
237
+ if a .CustomType == nil {
238
+ a .CustomType = supertypes.NewListNestedObjectTypeOf [T ](ctx )
239
+ }
240
+
241
+ deprecationMessage := ""
242
+ if s .Deprecated != nil {
243
+ a .DeprecationMessage = s .Deprecated .DeprecationMessage
244
+ deprecationMessage = s .Deprecated .computeDeprecatedDocumentation ()
245
+ }
246
+
247
+ a .MarkdownDescription = genResourceAttrDescription (ctx , a .MarkdownDescription , defaultVDescription , deprecationMessage , a .Validators , a .PlanModifiers )
248
+ return a
249
+ }
250
+
251
+ //nolint:dupl
252
+ func (s SuperListNestedAttributeOf [T ]) GetDataSource (ctx context.Context ) schemaD.Attribute {
253
+ var (
254
+ common schemaR.ListNestedAttribute
255
+ dataSource schemaD.ListNestedAttribute
256
+ )
257
+
258
+ if s .Common != nil {
259
+ common = * s .Common
260
+ }
261
+
262
+ if s .DataSource != nil {
263
+ dataSource = * s .DataSource
264
+ }
265
+
266
+ a := schemaD.ListNestedAttribute {
267
+ Required : computeIsRequired (common , dataSource ),
268
+ Optional : computeIsOptional (common , dataSource ),
269
+ Computed : computeIsComputed (common , dataSource ),
270
+ Sensitive : computeIsSensitive (common , dataSource ),
271
+ MarkdownDescription : computeMarkdownDescription (common , dataSource ),
272
+ Description : computeDescription (common , dataSource ),
273
+ DeprecationMessage : computeDeprecationMessage (common , dataSource ),
274
+ NestedObject : schemaD.NestedAttributeObject {
275
+ Attributes : s .Attributes .process (ctx , dataSourceT ).(map [string ]schemaD.Attribute ),
276
+ },
277
+ }
278
+
279
+ a .Validators = append (a .Validators , common .Validators ... )
280
+ a .Validators = append (a .Validators , dataSource .Validators ... )
281
+
282
+ if s .Common != nil {
283
+ if s .Common .CustomType != nil {
284
+ a .CustomType = s .Common .CustomType
285
+ }
286
+ }
287
+
288
+ if s .DataSource != nil {
289
+ if s .DataSource .CustomType != nil {
290
+ a .CustomType = s .DataSource .CustomType
291
+ }
292
+ }
293
+ // * If user has not provided a custom type, we will use the default supertypes
294
+ if a .CustomType == nil {
295
+ a .CustomType = supertypes.NewListNestedObjectTypeOf [T ](ctx )
296
+ }
297
+
298
+ deprecationMessage := ""
299
+ if s .Deprecated != nil {
300
+ a .DeprecationMessage = s .Deprecated .DeprecationMessage
301
+ deprecationMessage = s .Deprecated .computeDeprecatedDocumentation ()
302
+ }
303
+
304
+ a .MarkdownDescription = genDataSourceAttrDescription (ctx , a .MarkdownDescription , deprecationMessage , a .Validators )
305
+ return a
306
+ }
0 commit comments