diff --git a/datasource/attribute_test.go b/datasource/attribute_test.go index 7d5f64e..8d6ac1a 100644 --- a/datasource/attribute_test.go +++ b/datasource/attribute_test.go @@ -247,12 +247,14 @@ func TestAttributes_Validate(t *testing.T) { AttributeTypes: schema.ObjectAttributeTypes{ { Name: "obj_attr_one", - Object: schema.ObjectAttributeTypes{ - { - Name: "nested_obj_attr_one", - }, - { - Name: "nested_obj_attr_one", + Object: &schema.ObjectType{ + AttributeTypes: schema.ObjectAttributeTypes{ + { + Name: "nested_obj_attr_one", + }, + { + Name: "nested_obj_attr_one", + }, }, }, }, diff --git a/provider/attribute_test.go b/provider/attribute_test.go index 9867032..ca65027 100644 --- a/provider/attribute_test.go +++ b/provider/attribute_test.go @@ -247,12 +247,14 @@ func TestAttributes_Validate(t *testing.T) { AttributeTypes: schema.ObjectAttributeTypes{ { Name: "obj_attr_one", - Object: schema.ObjectAttributeTypes{ - { - Name: "nested_obj_attr_one", - }, - { - Name: "nested_obj_attr_one", + Object: &schema.ObjectType{ + AttributeTypes: schema.ObjectAttributeTypes{ + { + Name: "nested_obj_attr_one", + }, + { + Name: "nested_obj_attr_one", + }, }, }, }, diff --git a/resource/attribute_test.go b/resource/attribute_test.go index d0ab2db..eef16dd 100644 --- a/resource/attribute_test.go +++ b/resource/attribute_test.go @@ -247,12 +247,14 @@ func TestAttributes_Validate(t *testing.T) { AttributeTypes: schema.ObjectAttributeTypes{ { Name: "obj_attr_one", - Object: schema.ObjectAttributeTypes{ - { - Name: "nested_obj_attr_one", - }, - { - Name: "nested_obj_attr_one", + Object: &schema.ObjectType{ + AttributeTypes: schema.ObjectAttributeTypes{ + { + Name: "nested_obj_attr_one", + }, + { + Name: "nested_obj_attr_one", + }, }, }, }, diff --git a/schema/element_type.go b/schema/element_type.go index d8c3d30..3bb541f 100644 --- a/schema/element_type.go +++ b/schema/element_type.go @@ -4,13 +4,13 @@ package schema type ElementType struct { - Bool *BoolType `json:"bool,omitempty"` - Float64 *Float64Type `json:"float64,omitempty"` - Int64 *Int64Type `json:"int64,omitempty"` - List *ListType `json:"list,omitempty"` - Map *MapType `json:"map,omitempty"` - Number *NumberType `json:"number,omitempty"` - Object []ObjectAttributeType `json:"object,omitempty"` - Set *SetType `json:"set,omitempty"` - String *StringType `json:"string,omitempty"` + Bool *BoolType `json:"bool,omitempty"` + Float64 *Float64Type `json:"float64,omitempty"` + Int64 *Int64Type `json:"int64,omitempty"` + List *ListType `json:"list,omitempty"` + Map *MapType `json:"map,omitempty"` + Number *NumberType `json:"number,omitempty"` + Object *ObjectType `json:"object,omitempty"` + Set *SetType `json:"set,omitempty"` + String *StringType `json:"string,omitempty"` } diff --git a/schema/object_attribute_type.go b/schema/object_attribute_type.go index a8935d0..5777a8c 100644 --- a/schema/object_attribute_type.go +++ b/schema/object_attribute_type.go @@ -12,15 +12,15 @@ import ( type ObjectAttributeType struct { Name string `json:"name"` - Bool *BoolType `json:"bool,omitempty"` - Float64 *Float64Type `json:"float64,omitempty"` - Int64 *Int64Type `json:"int64,omitempty"` - List *ListType `json:"list,omitempty"` - Map *MapType `json:"map,omitempty"` - Number *NumberType `json:"number,omitempty"` - Object ObjectAttributeTypes `json:"object,omitempty"` - Set *SetType `json:"set,omitempty"` - String *StringType `json:"string,omitempty"` + Bool *BoolType `json:"bool,omitempty"` + Float64 *Float64Type `json:"float64,omitempty"` + Int64 *Int64Type `json:"int64,omitempty"` + List *ListType `json:"list,omitempty"` + Map *MapType `json:"map,omitempty"` + Number *NumberType `json:"number,omitempty"` + Object *ObjectType `json:"object,omitempty"` + Set *SetType `json:"set,omitempty"` + String *StringType `json:"string,omitempty"` } type ObjectValidateRequest struct { @@ -46,7 +46,7 @@ func (o ObjectAttributeTypes) Validate(ctx context.Context, req ObjectValidateRe Path: fmt.Sprintf("%s object attribute type %q", req.Path, attributeType.Name), } - err := attributeType.Object.Validate(ctx, objectValidateRequest) + err := attributeType.Object.AttributeTypes.Validate(ctx, objectValidateRequest) nestedErrs = errors.Join(nestedErrs, err) } diff --git a/schema/object_type.go b/schema/object_type.go new file mode 100644 index 0000000..fb1aa93 --- /dev/null +++ b/schema/object_type.go @@ -0,0 +1,11 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package schema + +type ObjectType struct { + AttributeTypes ObjectAttributeTypes `json:"attribute_types"` + + // CustomType is a customization of the ObjectType. + CustomType *CustomType `json:"custom_type,omitempty"` +} diff --git a/spec/example.json b/spec/example.json index 95130eb..42455bd 100644 --- a/spec/example.json +++ b/spec/example.json @@ -109,12 +109,14 @@ "list": { "computed_optional_required": "computed", "element_type": { - "object": [ - { - "name": "obj_string_attr", - "string": {} - } - ] + "object": { + "attribute_types": [ + { + "name": "obj_string_attr", + "string": {} + } + ] + } } } }, @@ -123,17 +125,21 @@ "list": { "computed_optional_required": "computed", "element_type": { - "object": [ - { - "name": "obj_obj_attr", - "object": [ - { - "name": "obj_obj_string_attr", - "string": {} + "object": { + "attribute_types": [ + { + "name": "obj_obj_attr", + "object": { + "attribute_types": [ + { + "name": "obj_obj_string_attr", + "string": {} + } + ] } - ] - } - ] + } + ] + } } } }, @@ -220,6 +226,30 @@ ] } }, + { + "name": "object_attribute_attribute_types_object_custom_type", + "object": { + "computed_optional_required": "computed", + "attribute_types": [ + { + "name": "obj_object_attr", + "object": { + "attribute_types": [ + { + "name": "obj_object_string_attr", + "string": {} + } + ], + "custom_type": { + "import": "github.com/hashicorp/terraform-plugin-framework/types/basetypes", + "type": "basetypes.ObjectType", + "value_type": "basetypes.ObjectValue" + } + } + } + ] + } + }, { "name": "object_attribute_attribute_types_string_custom_type", "object": { @@ -277,12 +307,14 @@ { "name": "obj_list_attr", "list": { - "object": [ - { - "name": "obj_list_obj_attr", - "string": {} - } - ] + "object": { + "attribute_types": [ + { + "name": "obj_list_obj_attr", + "string": {} + } + ] + } } } ] @@ -777,12 +809,14 @@ "list": { "optional_required": "optional", "element_type": { - "object": [ - { - "name": "obj_string_attr", - "string": {} - } - ] + "object": { + "attribute_types": [ + { + "name": "obj_string_attr", + "string": {} + } + ] + } } } }, @@ -791,17 +825,21 @@ "list": { "optional_required": "optional", "element_type": { - "object": [ - { - "name": "obj_obj_attr", - "object": [ - { - "name": "obj_obj_string_attr", - "string": {} + "object": { + "attribute_types": [ + { + "name": "obj_obj_attr", + "object": { + "attribute_types": [ + { + "name": "obj_obj_string_attr", + "string": {} + } + ] } - ] - } - ] + } + ] + } } } }, @@ -888,6 +926,30 @@ ] } }, + { + "name": "object_attribute_attribute_types_object_custom_type", + "object": { + "optional_required": "optional", + "attribute_types": [ + { + "name": "obj_object_attr", + "object": { + "attribute_types": [ + { + "name": "obj_object_string_attr", + "string": {} + } + ], + "custom_type": { + "import": "github.com/hashicorp/terraform-plugin-framework/types/basetypes", + "type": "basetypes.ObjectType", + "value_type": "basetypes.ObjectValue" + } + } + } + ] + } + }, { "name": "object_attribute_attribute_types_string_custom_type", "object": { @@ -945,12 +1007,14 @@ { "name": "obj_list_attr", "list": { - "object": [ - { - "name": "obj_list_obj_attr", - "string": {} - } - ] + "object": { + "attribute_types": [ + { + "name": "obj_list_obj_attr", + "string": {} + } + ] + } } } ] @@ -1506,12 +1570,14 @@ "list": { "computed_optional_required": "computed", "element_type": { - "object": [ - { - "name": "obj_string_attr", - "string": {} - } - ] + "object": { + "attribute_types": [ + { + "name": "obj_string_attr", + "string": {} + } + ] + } } } }, @@ -1520,17 +1586,21 @@ "list": { "computed_optional_required": "computed", "element_type": { - "object": [ - { - "name": "obj_obj_attr", - "object": [ - { - "name": "obj_obj_string_attr", - "string": {} + "object": { + "attribute_types": [ + { + "name": "obj_obj_attr", + "object": { + "attribute_types": [ + { + "name": "obj_obj_string_attr", + "string": {} + } + ] } - ] - } - ] + } + ] + } } } }, @@ -1629,6 +1699,30 @@ ] } }, + { + "name": "object_attribute_attribute_types_object_custom_type", + "object": { + "computed_optional_required": "computed", + "attribute_types": [ + { + "name": "obj_object_attr", + "object": { + "attribute_types": [ + { + "name": "obj_object_string_attr", + "string": {} + } + ], + "custom_type": { + "import": "github.com/hashicorp/terraform-plugin-framework/types/basetypes", + "type": "basetypes.ObjectType", + "value_type": "basetypes.ObjectValue" + } + } + } + ] + } + }, { "name": "object_attribute_attribute_types_string_custom_type", "object": { @@ -1686,12 +1780,14 @@ { "name": "obj_list_attr", "list": { - "object": [ - { - "name": "obj_list_obj_attr", - "string": {} - } - ] + "object": { + "attribute_types": [ + { + "name": "obj_list_obj_attr", + "string": {} + } + ] + } } } ] diff --git a/spec/schema.json b/spec/schema.json index dccaab3..1cfc104 100644 --- a/spec/schema.json +++ b/spec/schema.json @@ -367,7 +367,7 @@ "$ref": "#/$defs/schema_map_type" }, "object": { - "$ref": "#/$defs/schema_object_attribute_types" + "$ref": "#/$defs/schema_object_type" }, "set": { "$ref": "#/$defs/schema_set_type" @@ -468,7 +468,7 @@ "$ref": "#/$defs/schema_number_type" }, "object": { - "$ref": "#/$defs/schema_object_attribute_types" + "$ref": "#/$defs/schema_object_type" }, "set": { "$ref": "#/$defs/schema_set_type" @@ -551,7 +551,7 @@ "$ref": "#/$defs/schema_number_type" }, "object": { - "$ref": "#/$defs/schema_object_attribute_types" + "$ref": "#/$defs/schema_object_type" }, "set": { "$ref": "#/$defs/schema_set_type" @@ -650,7 +650,7 @@ "$ref": "#/$defs/schema_number_type" }, "object": { - "$ref": "#/$defs/schema_object_attribute_types" + "$ref": "#/$defs/schema_object_type" }, "set": { "$ref": "#/$defs/schema_set_type" @@ -710,6 +710,18 @@ } ] }, + "schema_object_type": { + "type": "object", + "additionalProperties": false, + "properties": { + "attribute_types": { + "$ref": "#/$defs/schema_object_attribute_types" + }, + "custom_type": { + "$ref": "#/$defs/schema_custom_type" + } + } + }, "schema_optional_required": { "enum": [ "optional", @@ -742,7 +754,7 @@ "$ref": "#/$defs/schema_number_type" }, "object": { - "$ref": "#/$defs/schema_object_attribute_types" + "$ref": "#/$defs/schema_object_type" }, "set": { "$ref": "#/$defs/schema_set_type" diff --git a/spec/specification_test.go b/spec/specification_test.go index 015c41b..5ddee42 100644 --- a/spec/specification_test.go +++ b/spec/specification_test.go @@ -185,10 +185,12 @@ func TestSpecification_JSONUnmarshal(t *testing.T) { List: &datasource.ListAttribute{ ComputedOptionalRequired: schema.Computed, ElementType: schema.ElementType{ - Object: []schema.ObjectAttributeType{ - { - Name: "obj_string_attr", - String: &schema.StringType{}, + Object: &schema.ObjectType{ + AttributeTypes: []schema.ObjectAttributeType{ + { + Name: "obj_string_attr", + String: &schema.StringType{}, + }, }, }, }, @@ -199,13 +201,17 @@ func TestSpecification_JSONUnmarshal(t *testing.T) { List: &datasource.ListAttribute{ ComputedOptionalRequired: schema.Computed, ElementType: schema.ElementType{ - Object: []schema.ObjectAttributeType{ - { - Name: "obj_obj_attr", - Object: []schema.ObjectAttributeType{ - { - Name: "obj_obj_string_attr", - String: &schema.StringType{}, + Object: &schema.ObjectType{ + AttributeTypes: []schema.ObjectAttributeType{ + { + Name: "obj_obj_attr", + Object: &schema.ObjectType{ + AttributeTypes: []schema.ObjectAttributeType{ + { + Name: "obj_obj_string_attr", + String: &schema.StringType{}, + }, + }, }, }, }, @@ -296,6 +302,30 @@ func TestSpecification_JSONUnmarshal(t *testing.T) { ComputedOptionalRequired: schema.Computed, }, }, + { + Name: "object_attribute_attribute_types_object_custom_type", + Object: &datasource.ObjectAttribute{ + AttributeTypes: []schema.ObjectAttributeType{ + { + Name: "obj_object_attr", + Object: &schema.ObjectType{ + AttributeTypes: []schema.ObjectAttributeType{ + { + Name: "obj_object_string_attr", + String: &schema.StringType{}, + }, + }, + CustomType: &schema.CustomType{ + Import: pointer("github.com/hashicorp/terraform-plugin-framework/types/basetypes"), + Type: "basetypes.ObjectType", + ValueType: "basetypes.ObjectValue", + }, + }, + }, + }, + ComputedOptionalRequired: schema.Computed, + }, + }, { Name: "object_attribute_attribute_types_string_custom_type", Object: &datasource.ObjectAttribute{ @@ -355,10 +385,12 @@ func TestSpecification_JSONUnmarshal(t *testing.T) { Name: "obj_list_attr", List: &schema.ListType{ ElementType: schema.ElementType{ - Object: []schema.ObjectAttributeType{ - { - Name: "obj_list_obj_attr", - String: &schema.StringType{}, + Object: &schema.ObjectType{ + AttributeTypes: []schema.ObjectAttributeType{ + { + Name: "obj_list_obj_attr", + String: &schema.StringType{}, + }, }, }, }, @@ -859,10 +891,12 @@ func TestSpecification_JSONUnmarshal(t *testing.T) { List: &provider.ListAttribute{ OptionalRequired: schema.Optional, ElementType: schema.ElementType{ - Object: []schema.ObjectAttributeType{ - { - Name: "obj_string_attr", - String: &schema.StringType{}, + Object: &schema.ObjectType{ + AttributeTypes: []schema.ObjectAttributeType{ + { + Name: "obj_string_attr", + String: &schema.StringType{}, + }, }, }, }, @@ -873,13 +907,17 @@ func TestSpecification_JSONUnmarshal(t *testing.T) { List: &provider.ListAttribute{ OptionalRequired: schema.Optional, ElementType: schema.ElementType{ - Object: []schema.ObjectAttributeType{ - { - Name: "obj_obj_attr", - Object: []schema.ObjectAttributeType{ - { - Name: "obj_obj_string_attr", - String: &schema.StringType{}, + Object: &schema.ObjectType{ + AttributeTypes: []schema.ObjectAttributeType{ + { + Name: "obj_obj_attr", + Object: &schema.ObjectType{ + AttributeTypes: []schema.ObjectAttributeType{ + { + Name: "obj_obj_string_attr", + String: &schema.StringType{}, + }, + }, }, }, }, @@ -970,6 +1008,30 @@ func TestSpecification_JSONUnmarshal(t *testing.T) { OptionalRequired: schema.Optional, }, }, + { + Name: "object_attribute_attribute_types_object_custom_type", + Object: &provider.ObjectAttribute{ + AttributeTypes: []schema.ObjectAttributeType{ + { + Name: "obj_object_attr", + Object: &schema.ObjectType{ + AttributeTypes: []schema.ObjectAttributeType{ + { + Name: "obj_object_string_attr", + String: &schema.StringType{}, + }, + }, + CustomType: &schema.CustomType{ + Import: pointer("github.com/hashicorp/terraform-plugin-framework/types/basetypes"), + Type: "basetypes.ObjectType", + ValueType: "basetypes.ObjectValue", + }, + }, + }, + }, + OptionalRequired: schema.Optional, + }, + }, { Name: "object_attribute_attribute_types_string_custom_type", Object: &provider.ObjectAttribute{ @@ -1029,10 +1091,12 @@ func TestSpecification_JSONUnmarshal(t *testing.T) { Name: "obj_list_attr", List: &schema.ListType{ ElementType: schema.ElementType{ - Object: []schema.ObjectAttributeType{ - { - Name: "obj_list_obj_attr", - String: &schema.StringType{}, + Object: &schema.ObjectType{ + AttributeTypes: []schema.ObjectAttributeType{ + { + Name: "obj_list_obj_attr", + String: &schema.StringType{}, + }, }, }, }, @@ -1592,10 +1656,12 @@ func TestSpecification_JSONUnmarshal(t *testing.T) { List: &resource.ListAttribute{ ComputedOptionalRequired: schema.Computed, ElementType: schema.ElementType{ - Object: []schema.ObjectAttributeType{ - { - Name: "obj_string_attr", - String: &schema.StringType{}, + Object: &schema.ObjectType{ + AttributeTypes: []schema.ObjectAttributeType{ + { + Name: "obj_string_attr", + String: &schema.StringType{}, + }, }, }, }, @@ -1606,13 +1672,17 @@ func TestSpecification_JSONUnmarshal(t *testing.T) { List: &resource.ListAttribute{ ComputedOptionalRequired: schema.Computed, ElementType: schema.ElementType{ - Object: []schema.ObjectAttributeType{ - { - Name: "obj_obj_attr", - Object: []schema.ObjectAttributeType{ - { - Name: "obj_obj_string_attr", - String: &schema.StringType{}, + Object: &schema.ObjectType{ + AttributeTypes: []schema.ObjectAttributeType{ + { + Name: "obj_obj_attr", + Object: &schema.ObjectType{ + AttributeTypes: []schema.ObjectAttributeType{ + { + Name: "obj_obj_string_attr", + String: &schema.StringType{}, + }, + }, }, }, }, @@ -1715,6 +1785,30 @@ func TestSpecification_JSONUnmarshal(t *testing.T) { ComputedOptionalRequired: schema.Computed, }, }, + { + Name: "object_attribute_attribute_types_object_custom_type", + Object: &resource.ObjectAttribute{ + AttributeTypes: []schema.ObjectAttributeType{ + { + Name: "obj_object_attr", + Object: &schema.ObjectType{ + AttributeTypes: []schema.ObjectAttributeType{ + { + Name: "obj_object_string_attr", + String: &schema.StringType{}, + }, + }, + CustomType: &schema.CustomType{ + Import: pointer("github.com/hashicorp/terraform-plugin-framework/types/basetypes"), + Type: "basetypes.ObjectType", + ValueType: "basetypes.ObjectValue", + }, + }, + }, + }, + ComputedOptionalRequired: schema.Computed, + }, + }, { Name: "object_attribute_attribute_types_string_custom_type", Object: &resource.ObjectAttribute{ @@ -1774,10 +1868,12 @@ func TestSpecification_JSONUnmarshal(t *testing.T) { Name: "obj_list_attr", List: &schema.ListType{ ElementType: schema.ElementType{ - Object: []schema.ObjectAttributeType{ - { - Name: "obj_list_obj_attr", - String: &schema.StringType{}, + Object: &schema.ObjectType{ + AttributeTypes: []schema.ObjectAttributeType{ + { + Name: "obj_list_obj_attr", + String: &schema.StringType{}, + }, }, }, }, @@ -2957,12 +3053,14 @@ func TestSpecification_Validate_DataSources(t *testing.T) { AttributeTypes: []schema.ObjectAttributeType{ { Name: "obj_attr", - Object: []schema.ObjectAttributeType{ - { - Name: "obj_obj_attr", - }, - { - Name: "obj_obj_attr", + Object: &schema.ObjectType{ + AttributeTypes: []schema.ObjectAttributeType{ + { + Name: "obj_obj_attr", + }, + { + Name: "obj_obj_attr", + }, }, }, }, @@ -2989,9 +3087,11 @@ func TestSpecification_Validate_DataSources(t *testing.T) { AttributeTypes: []schema.ObjectAttributeType{ { Name: "obj_attr", - Object: []schema.ObjectAttributeType{ - { - Name: "obj_attr", + Object: &schema.ObjectType{ + AttributeTypes: []schema.ObjectAttributeType{ + { + Name: "obj_attr", + }, }, }, }, @@ -3682,12 +3782,14 @@ func TestSpecification_Validate_Provider(t *testing.T) { AttributeTypes: []schema.ObjectAttributeType{ { Name: "obj_attr", - Object: []schema.ObjectAttributeType{ - { - Name: "obj_obj_attr", - }, - { - Name: "obj_obj_attr", + Object: &schema.ObjectType{ + AttributeTypes: []schema.ObjectAttributeType{ + { + Name: "obj_obj_attr", + }, + { + Name: "obj_obj_attr", + }, }, }, }, @@ -3712,9 +3814,11 @@ func TestSpecification_Validate_Provider(t *testing.T) { AttributeTypes: []schema.ObjectAttributeType{ { Name: "obj_attr", - Object: []schema.ObjectAttributeType{ - { - Name: "obj_attr", + Object: &schema.ObjectType{ + AttributeTypes: []schema.ObjectAttributeType{ + { + Name: "obj_attr", + }, }, }, }, @@ -4484,12 +4588,14 @@ func TestSpecification_Validate_Resources(t *testing.T) { AttributeTypes: []schema.ObjectAttributeType{ { Name: "obj_attr", - Object: []schema.ObjectAttributeType{ - { - Name: "obj_obj_attr", - }, - { - Name: "obj_obj_attr", + Object: &schema.ObjectType{ + AttributeTypes: []schema.ObjectAttributeType{ + { + Name: "obj_obj_attr", + }, + { + Name: "obj_obj_attr", + }, }, }, }, @@ -4516,9 +4622,11 @@ func TestSpecification_Validate_Resources(t *testing.T) { AttributeTypes: []schema.ObjectAttributeType{ { Name: "obj_attr", - Object: []schema.ObjectAttributeType{ - { - Name: "obj_attr", + Object: &schema.ObjectType{ + AttributeTypes: []schema.ObjectAttributeType{ + { + Name: "obj_attr", + }, }, }, }, @@ -4681,10 +4789,12 @@ func TestSpecification_Generate(t *testing.T) { List: &datasource.ListAttribute{ ComputedOptionalRequired: schema.Computed, ElementType: schema.ElementType{ - Object: []schema.ObjectAttributeType{ - { - Name: "obj_string_attr", - String: &schema.StringType{}, + Object: &schema.ObjectType{ + AttributeTypes: []schema.ObjectAttributeType{ + { + Name: "obj_string_attr", + String: &schema.StringType{}, + }, }, }, }, @@ -4695,13 +4805,17 @@ func TestSpecification_Generate(t *testing.T) { List: &datasource.ListAttribute{ ComputedOptionalRequired: schema.Computed, ElementType: schema.ElementType{ - Object: []schema.ObjectAttributeType{ - { - Name: "obj_obj_attr", - Object: []schema.ObjectAttributeType{ - { - Name: "obj_obj_string_attr", - String: &schema.StringType{}, + Object: &schema.ObjectType{ + AttributeTypes: []schema.ObjectAttributeType{ + { + Name: "obj_obj_attr", + Object: &schema.ObjectType{ + AttributeTypes: []schema.ObjectAttributeType{ + { + Name: "obj_obj_string_attr", + String: &schema.StringType{}, + }, + }, }, }, }, @@ -4792,6 +4906,30 @@ func TestSpecification_Generate(t *testing.T) { ComputedOptionalRequired: schema.Computed, }, }, + { + Name: "object_attribute_attribute_types_object_custom_type", + Object: &datasource.ObjectAttribute{ + AttributeTypes: []schema.ObjectAttributeType{ + { + Name: "obj_object_attr", + Object: &schema.ObjectType{ + AttributeTypes: []schema.ObjectAttributeType{ + { + Name: "obj_object_string_attr", + String: &schema.StringType{}, + }, + }, + CustomType: &schema.CustomType{ + Import: pointer("github.com/hashicorp/terraform-plugin-framework/types/basetypes"), + Type: "basetypes.ObjectType", + ValueType: "basetypes.ObjectValue", + }, + }, + }, + }, + ComputedOptionalRequired: schema.Computed, + }, + }, { Name: "object_attribute_attribute_types_string_custom_type", Object: &datasource.ObjectAttribute{ @@ -4851,10 +4989,12 @@ func TestSpecification_Generate(t *testing.T) { Name: "obj_list_attr", List: &schema.ListType{ ElementType: schema.ElementType{ - Object: []schema.ObjectAttributeType{ - { - Name: "obj_list_obj_attr", - String: &schema.StringType{}, + Object: &schema.ObjectType{ + AttributeTypes: []schema.ObjectAttributeType{ + { + Name: "obj_list_obj_attr", + String: &schema.StringType{}, + }, }, }, }, @@ -5355,10 +5495,12 @@ func TestSpecification_Generate(t *testing.T) { List: &provider.ListAttribute{ OptionalRequired: schema.Optional, ElementType: schema.ElementType{ - Object: []schema.ObjectAttributeType{ - { - Name: "obj_string_attr", - String: &schema.StringType{}, + Object: &schema.ObjectType{ + AttributeTypes: []schema.ObjectAttributeType{ + { + Name: "obj_string_attr", + String: &schema.StringType{}, + }, }, }, }, @@ -5369,13 +5511,17 @@ func TestSpecification_Generate(t *testing.T) { List: &provider.ListAttribute{ OptionalRequired: schema.Optional, ElementType: schema.ElementType{ - Object: []schema.ObjectAttributeType{ - { - Name: "obj_obj_attr", - Object: []schema.ObjectAttributeType{ - { - Name: "obj_obj_string_attr", - String: &schema.StringType{}, + Object: &schema.ObjectType{ + AttributeTypes: []schema.ObjectAttributeType{ + { + Name: "obj_obj_attr", + Object: &schema.ObjectType{ + AttributeTypes: []schema.ObjectAttributeType{ + { + Name: "obj_obj_string_attr", + String: &schema.StringType{}, + }, + }, }, }, }, @@ -5466,6 +5612,30 @@ func TestSpecification_Generate(t *testing.T) { OptionalRequired: schema.Optional, }, }, + { + Name: "object_attribute_attribute_types_object_custom_type", + Object: &provider.ObjectAttribute{ + AttributeTypes: []schema.ObjectAttributeType{ + { + Name: "obj_object_attr", + Object: &schema.ObjectType{ + AttributeTypes: []schema.ObjectAttributeType{ + { + Name: "obj_object_string_attr", + String: &schema.StringType{}, + }, + }, + CustomType: &schema.CustomType{ + Import: pointer("github.com/hashicorp/terraform-plugin-framework/types/basetypes"), + Type: "basetypes.ObjectType", + ValueType: "basetypes.ObjectValue", + }, + }, + }, + }, + OptionalRequired: schema.Optional, + }, + }, { Name: "object_attribute_attribute_types_string_custom_type", Object: &provider.ObjectAttribute{ @@ -5525,10 +5695,12 @@ func TestSpecification_Generate(t *testing.T) { Name: "obj_list_attr", List: &schema.ListType{ ElementType: schema.ElementType{ - Object: []schema.ObjectAttributeType{ - { - Name: "obj_list_obj_attr", - String: &schema.StringType{}, + Object: &schema.ObjectType{ + AttributeTypes: []schema.ObjectAttributeType{ + { + Name: "obj_list_obj_attr", + String: &schema.StringType{}, + }, }, }, }, @@ -6088,10 +6260,12 @@ func TestSpecification_Generate(t *testing.T) { List: &resource.ListAttribute{ ComputedOptionalRequired: schema.Computed, ElementType: schema.ElementType{ - Object: []schema.ObjectAttributeType{ - { - Name: "obj_string_attr", - String: &schema.StringType{}, + Object: &schema.ObjectType{ + AttributeTypes: []schema.ObjectAttributeType{ + { + Name: "obj_string_attr", + String: &schema.StringType{}, + }, }, }, }, @@ -6102,13 +6276,17 @@ func TestSpecification_Generate(t *testing.T) { List: &resource.ListAttribute{ ComputedOptionalRequired: schema.Computed, ElementType: schema.ElementType{ - Object: []schema.ObjectAttributeType{ - { - Name: "obj_obj_attr", - Object: []schema.ObjectAttributeType{ - { - Name: "obj_obj_string_attr", - String: &schema.StringType{}, + Object: &schema.ObjectType{ + AttributeTypes: []schema.ObjectAttributeType{ + { + Name: "obj_obj_attr", + Object: &schema.ObjectType{ + AttributeTypes: []schema.ObjectAttributeType{ + { + Name: "obj_obj_string_attr", + String: &schema.StringType{}, + }, + }, }, }, }, @@ -6211,6 +6389,30 @@ func TestSpecification_Generate(t *testing.T) { ComputedOptionalRequired: schema.Computed, }, }, + { + Name: "object_attribute_attribute_types_object_custom_type", + Object: &resource.ObjectAttribute{ + AttributeTypes: []schema.ObjectAttributeType{ + { + Name: "obj_object_attr", + Object: &schema.ObjectType{ + AttributeTypes: []schema.ObjectAttributeType{ + { + Name: "obj_object_string_attr", + String: &schema.StringType{}, + }, + }, + CustomType: &schema.CustomType{ + Import: pointer("github.com/hashicorp/terraform-plugin-framework/types/basetypes"), + Type: "basetypes.ObjectType", + ValueType: "basetypes.ObjectValue", + }, + }, + }, + }, + ComputedOptionalRequired: schema.Computed, + }, + }, { Name: "object_attribute_attribute_types_string_custom_type", Object: &resource.ObjectAttribute{ @@ -6270,10 +6472,12 @@ func TestSpecification_Generate(t *testing.T) { Name: "obj_list_attr", List: &schema.ListType{ ElementType: schema.ElementType{ - Object: []schema.ObjectAttributeType{ - { - Name: "obj_list_obj_attr", - String: &schema.StringType{}, + Object: &schema.ObjectType{ + AttributeTypes: []schema.ObjectAttributeType{ + { + Name: "obj_list_obj_attr", + String: &schema.StringType{}, + }, }, }, },