From 0abce4a910311fad54044131f5529f0a67ea813d Mon Sep 17 00:00:00 2001 From: Benjamin Bennett Date: Mon, 4 Sep 2023 13:31:19 +0100 Subject: [PATCH 1/6] Default to empty string for package flag, and use data source, provider, or resource name as package name (#20) --- internal/cmd/generate_all.go | 2 +- internal/cmd/generate_data_sources.go | 2 +- internal/cmd/generate_provider.go | 2 +- internal/cmd/generate_resources.go | 2 +- .../all_output/datasource_data_source_gen.go | 1863 ----------------- .../all_output/provider_provider_gen.go | 1002 --------- .../all_output/resource_resource_gen.go | 1020 --------- internal/schema/schemas.go | 4 + 8 files changed, 8 insertions(+), 3889 deletions(-) delete mode 100644 internal/cmd/testdata/custom_and_external/all_output/datasource_data_source_gen.go delete mode 100644 internal/cmd/testdata/custom_and_external/all_output/provider_provider_gen.go delete mode 100644 internal/cmd/testdata/custom_and_external/all_output/resource_resource_gen.go diff --git a/internal/cmd/generate_all.go b/internal/cmd/generate_all.go index 317e3b48..8aa0ef79 100644 --- a/internal/cmd/generate_all.go +++ b/internal/cmd/generate_all.go @@ -27,7 +27,7 @@ func (cmd *GenerateAllCommand) Flags() *flag.FlagSet { fs := flag.NewFlagSet("generate all", flag.ExitOnError) fs.StringVar(&cmd.flagIRInputPath, "input", "", "path to intermediate representation (JSON)") fs.StringVar(&cmd.flagOutputPath, "output", "./output", "directory path to output generated code files") - fs.StringVar(&cmd.flagPackageName, "package", "provider", "name of Go package for generated code files") + fs.StringVar(&cmd.flagPackageName, "package", "", "name of Go package for generated code files") return fs } diff --git a/internal/cmd/generate_data_sources.go b/internal/cmd/generate_data_sources.go index 51bd91bb..7ac99dd5 100644 --- a/internal/cmd/generate_data_sources.go +++ b/internal/cmd/generate_data_sources.go @@ -32,7 +32,7 @@ func (cmd *GenerateDataSourcesCommand) Flags() *flag.FlagSet { fs := flag.NewFlagSet("generate data-sources", flag.ExitOnError) fs.StringVar(&cmd.flagIRInputPath, "input", "./ir.json", "path to intermediate representation (JSON)") fs.StringVar(&cmd.flagOutputPath, "output", "./output", "directory path to output generated code files") - fs.StringVar(&cmd.flagPackageName, "package", "provider", "name of Go package for generated code files") + fs.StringVar(&cmd.flagPackageName, "package", "", "name of Go package for generated code files") return fs } diff --git a/internal/cmd/generate_provider.go b/internal/cmd/generate_provider.go index 2b761430..6ea622b9 100644 --- a/internal/cmd/generate_provider.go +++ b/internal/cmd/generate_provider.go @@ -32,7 +32,7 @@ func (cmd *GenerateProviderCommand) Flags() *flag.FlagSet { fs := flag.NewFlagSet("generate provider", flag.ExitOnError) fs.StringVar(&cmd.flagIRInputPath, "input", "./ir.json", "path to intermediate representation (JSON)") fs.StringVar(&cmd.flagOutputPath, "output", "./output", "directory path to output generated code files") - fs.StringVar(&cmd.flagPackageName, "package", "provider", "name of Go package for generated code files") + fs.StringVar(&cmd.flagPackageName, "package", "", "name of Go package for generated code files") return fs } diff --git a/internal/cmd/generate_resources.go b/internal/cmd/generate_resources.go index 0dd9ea1d..59e06ef4 100644 --- a/internal/cmd/generate_resources.go +++ b/internal/cmd/generate_resources.go @@ -32,7 +32,7 @@ func (cmd *GenerateResourcesCommand) Flags() *flag.FlagSet { fs := flag.NewFlagSet("generate resources", flag.ExitOnError) fs.StringVar(&cmd.flagIRInputPath, "input", "./ir.json", "path to intermediate representation (JSON)") fs.StringVar(&cmd.flagOutputPath, "output", "./output", "directory path to output generated code files") - fs.StringVar(&cmd.flagPackageName, "package", "provider", "name of Go package for generated code files") + fs.StringVar(&cmd.flagPackageName, "package", "", "name of Go package for generated code files") return fs } diff --git a/internal/cmd/testdata/custom_and_external/all_output/datasource_data_source_gen.go b/internal/cmd/testdata/custom_and_external/all_output/datasource_data_source_gen.go deleted file mode 100644 index 73f02147..00000000 --- a/internal/cmd/testdata/custom_and_external/all_output/datasource_data_source_gen.go +++ /dev/null @@ -1,1863 +0,0 @@ -// Code generated by terraform-plugin-framework-generator DO NOT EDIT. - -package generated - -import ( - "context" - "example.com/apisdk" - "github.com/hashicorp/terraform-plugin-framework/attr" - "github.com/hashicorp/terraform-plugin-framework/datasource/schema" - "github.com/hashicorp/terraform-plugin-framework/diag" - "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/hashicorp/terraform-plugin-framework/types/basetypes" -) - -var datasourceDataSourceSchema = schema.Schema{ - Attributes: map[string]schema.Attribute{ - "bool_attribute": schema.BoolAttribute{ - Computed: true, - }, - "list_list_attribute": schema.ListAttribute{ - ElementType: types.ListType{ - ElemType: types.StringType, - }, - Computed: true, - }, - "list_map_attribute": schema.ListAttribute{ - ElementType: types.MapType{ - ElemType: types.StringType, - }, - Computed: true, - }, - "list_nested_attribute_assoc_ext_type": schema.ListNestedAttribute{ - NestedObject: schema.NestedAttributeObject{ - Attributes: map[string]schema.Attribute{ - "bool_attribute": schema.BoolAttribute{ - Computed: true, - }, - "float64_attribute": schema.Float64Attribute{ - Optional: true, - Computed: true, - }, - "int64_attribute": schema.Int64Attribute{ - Optional: true, - Computed: true, - }, - "number_attribute": schema.NumberAttribute{ - Optional: true, - Computed: true, - }, - "string_attribute": schema.StringAttribute{ - Optional: true, - Computed: true, - }, - }, - }, - Optional: true, - }, - "list_nested_attribute_one": schema.ListNestedAttribute{ - NestedObject: schema.NestedAttributeObject{ - Attributes: map[string]schema.Attribute{ - "bool_attribute": schema.BoolAttribute{ - Computed: true, - }, - }, - }, - Computed: true, - }, - "list_nested_attribute_three": schema.ListNestedAttribute{ - NestedObject: schema.NestedAttributeObject{ - Attributes: map[string]schema.Attribute{ - "list_nested_attribute_three_list_nested_attribute_one": schema.ListNestedAttribute{ - NestedObject: schema.NestedAttributeObject{ - Attributes: map[string]schema.Attribute{ - "list_attribute": schema.ListAttribute{ - ElementType: types.StringType, - Computed: true, - }, - }, - }, - Computed: true, - }, - }, - }, - Computed: true, - }, - "list_nested_attribute_two": schema.ListNestedAttribute{ - NestedObject: schema.NestedAttributeObject{ - Attributes: map[string]schema.Attribute{ - "list_nested_attribute_two_list_nested_attribute_one": schema.ListNestedAttribute{ - NestedObject: schema.NestedAttributeObject{ - Attributes: map[string]schema.Attribute{ - "bool_attribute": schema.BoolAttribute{ - Computed: true, - }, - }, - }, - Computed: true, - }, - }, - }, - Computed: true, - }, - "list_object_attribute": schema.ListAttribute{ - ElementType: types.ObjectType{ - AttrTypes: map[string]attr.Type{ - "obj_string_attr": types.StringType, - }, - }, - Computed: true, - }, - "list_object_object_attribute": schema.ListAttribute{ - ElementType: types.ObjectType{ - AttrTypes: map[string]attr.Type{ - "obj_obj_attr": types.ObjectType{ - AttrTypes: map[string]attr.Type{ - "obj_obj_string_attr": types.StringType, - }, - }, - }, - }, - Computed: true, - }, - "map_nested_attribute_assoc_ext_type": schema.MapNestedAttribute{ - NestedObject: schema.NestedAttributeObject{ - Attributes: map[string]schema.Attribute{ - "bool_attribute": schema.BoolAttribute{ - Computed: true, - }, - "float64_attribute": schema.Float64Attribute{ - Optional: true, - Computed: true, - }, - "int64_attribute": schema.Int64Attribute{ - Optional: true, - Computed: true, - }, - "number_attribute": schema.NumberAttribute{ - Optional: true, - Computed: true, - }, - "string_attribute": schema.StringAttribute{ - Optional: true, - Computed: true, - }, - }, - }, - Optional: true, - }, - "object_attribute": schema.ObjectAttribute{ - AttributeTypes: map[string]attr.Type{ - "obj_string_attr": types.StringType, - }, - Computed: true, - }, - "object_list_attribute": schema.ObjectAttribute{ - AttributeTypes: map[string]attr.Type{ - "obj_list_attr": types.ListType{ - ElemType: types.StringType, - }, - }, - Computed: true, - }, - "object_list_object_attribute": schema.ObjectAttribute{ - AttributeTypes: map[string]attr.Type{ - "obj_list_attr": types.ListType{ - ElemType: types.ObjectType{ - AttrTypes: map[string]attr.Type{ - "obj_list_obj_attr": types.StringType, - }, - }, - }, - }, - Computed: true, - }, - "set_nested_attribute_assoc_ext_type": schema.SetNestedAttribute{ - NestedObject: schema.NestedAttributeObject{ - Attributes: map[string]schema.Attribute{ - "bool_attribute": schema.BoolAttribute{ - Computed: true, - }, - "float64_attribute": schema.Float64Attribute{ - Optional: true, - Computed: true, - }, - "int64_attribute": schema.Int64Attribute{ - Optional: true, - Computed: true, - }, - "number_attribute": schema.NumberAttribute{ - Optional: true, - Computed: true, - }, - "string_attribute": schema.StringAttribute{ - Optional: true, - Computed: true, - }, - }, - }, - Optional: true, - }, - "single_nested_attribute_assoc_ext_type": schema.SingleNestedAttribute{ - Attributes: map[string]schema.Attribute{ - "bool_attribute": schema.BoolAttribute{ - Computed: true, - }, - "float64_attribute": schema.Float64Attribute{ - Optional: true, - Computed: true, - }, - "int64_attribute": schema.Int64Attribute{ - Optional: true, - Computed: true, - }, - "number_attribute": schema.NumberAttribute{ - Optional: true, - Computed: true, - }, - "string_attribute": schema.StringAttribute{ - Optional: true, - Computed: true, - }, - }, - Optional: true, - }, - "single_nested_attribute_one": schema.SingleNestedAttribute{ - Attributes: map[string]schema.Attribute{ - "bool_attribute": schema.BoolAttribute{ - Computed: true, - }, - }, - Computed: true, - }, - "single_nested_attribute_three": schema.SingleNestedAttribute{ - Attributes: map[string]schema.Attribute{ - "single_nested_attribute_three_single_nested_attribute_one": schema.SingleNestedAttribute{ - Attributes: map[string]schema.Attribute{ - "list_attribute": schema.ListAttribute{ - ElementType: types.StringType, - Computed: true, - }, - }, - Computed: true, - }, - }, - Computed: true, - }, - "single_nested_attribute_two": schema.SingleNestedAttribute{ - Attributes: map[string]schema.Attribute{ - "single_nested_attribute_two_single_nested_attribute_one": schema.SingleNestedAttribute{ - Attributes: map[string]schema.Attribute{ - "bool_attribute": schema.BoolAttribute{ - Computed: true, - }, - }, - Computed: true, - }, - }, - Computed: true, - }, - }, - Blocks: map[string]schema.Block{ - "list_nested_block_assoc_ext_type": schema.ListNestedBlock{ - NestedObject: schema.NestedBlockObject{ - Attributes: map[string]schema.Attribute{ - "bool_attribute": schema.BoolAttribute{ - Computed: true, - }, - "float64_attribute": schema.Float64Attribute{ - Optional: true, - Computed: true, - }, - "int64_attribute": schema.Int64Attribute{ - Optional: true, - Computed: true, - }, - "number_attribute": schema.NumberAttribute{ - Optional: true, - Computed: true, - }, - "string_attribute": schema.StringAttribute{ - Optional: true, - Computed: true, - }, - }, - }, - }, - "list_nested_block_one": schema.ListNestedBlock{ - NestedObject: schema.NestedBlockObject{ - Attributes: map[string]schema.Attribute{ - "bool_attribute": schema.BoolAttribute{ - Computed: true, - }, - }, - }, - }, - "list_nested_block_three": schema.ListNestedBlock{ - NestedObject: schema.NestedBlockObject{ - Attributes: map[string]schema.Attribute{ - "object_attribute": schema.ObjectAttribute{ - AttributeTypes: map[string]attr.Type{ - "string_attribute_type": types.StringType, - }, - Computed: true, - }, - }, - Blocks: map[string]schema.Block{ - "list_nested_block_three_list_nested_block_one": schema.ListNestedBlock{ - NestedObject: schema.NestedBlockObject{ - Attributes: map[string]schema.Attribute{ - "list_attribute": schema.ListAttribute{ - ElementType: types.StringType, - Computed: true, - }, - }, - }, - }, - }, - }, - }, - "list_nested_block_two": schema.ListNestedBlock{ - NestedObject: schema.NestedBlockObject{ - Blocks: map[string]schema.Block{ - "list_nested_block_two_list_nested_block_one": schema.ListNestedBlock{ - NestedObject: schema.NestedBlockObject{ - Attributes: map[string]schema.Attribute{ - "bool_attribute": schema.BoolAttribute{ - Computed: true, - }, - }, - }, - }, - }, - }, - }, - "set_nested_block_assoc_ext_type": schema.SetNestedBlock{ - NestedObject: schema.NestedBlockObject{ - Attributes: map[string]schema.Attribute{ - "bool_attribute": schema.BoolAttribute{ - Computed: true, - }, - "float64_attribute": schema.Float64Attribute{ - Optional: true, - Computed: true, - }, - "int64_attribute": schema.Int64Attribute{ - Optional: true, - Computed: true, - }, - "number_attribute": schema.NumberAttribute{ - Optional: true, - Computed: true, - }, - "string_attribute": schema.StringAttribute{ - Optional: true, - Computed: true, - }, - }, - }, - }, - "single_nested_block_assoc_ext_type": schema.SingleNestedBlock{ - Attributes: map[string]schema.Attribute{ - "bool_attribute": schema.BoolAttribute{ - Computed: true, - }, - "float64_attribute": schema.Float64Attribute{ - Optional: true, - Computed: true, - }, - "int64_attribute": schema.Int64Attribute{ - Optional: true, - Computed: true, - }, - "number_attribute": schema.NumberAttribute{ - Optional: true, - Computed: true, - }, - "string_attribute": schema.StringAttribute{ - Optional: true, - Computed: true, - }, - }, - }, - "single_nested_block_one": schema.SingleNestedBlock{ - Attributes: map[string]schema.Attribute{ - "bool_attribute": schema.BoolAttribute{ - Computed: true, - }, - }, - }, - "single_nested_block_three": schema.SingleNestedBlock{ - Attributes: map[string]schema.Attribute{ - "object_attribute": schema.ObjectAttribute{ - AttributeTypes: map[string]attr.Type{ - "string_attribute_type": types.StringType, - }, - Computed: true, - }, - }, - Blocks: map[string]schema.Block{ - "single_nested_block_three_list_nested_block_one": schema.ListNestedBlock{ - NestedObject: schema.NestedBlockObject{ - Attributes: map[string]schema.Attribute{ - "list_attribute": schema.ListAttribute{ - ElementType: types.StringType, - Computed: true, - }, - }, - }, - }, - }, - }, - "single_nested_block_two": schema.SingleNestedBlock{ - Blocks: map[string]schema.Block{ - "single_nested_block_two_single_nested_block_one": schema.SingleNestedBlock{ - Attributes: map[string]schema.Attribute{ - "bool_attribute": schema.BoolAttribute{ - Computed: true, - }, - }, - }, - }, - }, - }, -} - -type DatasourceModel struct { - BoolAttribute types.Bool `tfsdk:"bool_attribute"` - ListListAttribute types.List `tfsdk:"list_list_attribute"` - ListMapAttribute types.List `tfsdk:"list_map_attribute"` - ListNestedAttributeAssocExtType types.List `tfsdk:"list_nested_attribute_assoc_ext_type"` - ListNestedAttributeOne types.List `tfsdk:"list_nested_attribute_one"` - ListNestedAttributeThree types.List `tfsdk:"list_nested_attribute_three"` - ListNestedAttributeTwo types.List `tfsdk:"list_nested_attribute_two"` - ListObjectAttribute types.List `tfsdk:"list_object_attribute"` - ListObjectObjectAttribute types.List `tfsdk:"list_object_object_attribute"` - MapNestedAttributeAssocExtType types.Map `tfsdk:"map_nested_attribute_assoc_ext_type"` - ObjectAttribute types.Object `tfsdk:"object_attribute"` - ObjectListAttribute types.Object `tfsdk:"object_list_attribute"` - ObjectListObjectAttribute types.Object `tfsdk:"object_list_object_attribute"` - SetNestedAttributeAssocExtType types.Set `tfsdk:"set_nested_attribute_assoc_ext_type"` - SingleNestedAttributeAssocExtType types.Object `tfsdk:"single_nested_attribute_assoc_ext_type"` - SingleNestedAttributeOne types.Object `tfsdk:"single_nested_attribute_one"` - SingleNestedAttributeThree types.Object `tfsdk:"single_nested_attribute_three"` - SingleNestedAttributeTwo types.Object `tfsdk:"single_nested_attribute_two"` - ListNestedBlockAssocExtType types.List `tfsdk:"list_nested_block_assoc_ext_type"` - ListNestedBlockOne types.List `tfsdk:"list_nested_block_one"` - ListNestedBlockThree types.List `tfsdk:"list_nested_block_three"` - ListNestedBlockTwo types.List `tfsdk:"list_nested_block_two"` - SetNestedBlockAssocExtType types.Set `tfsdk:"set_nested_block_assoc_ext_type"` - SingleNestedBlockAssocExtType types.Object `tfsdk:"single_nested_block_assoc_ext_type"` - SingleNestedBlockOne types.Object `tfsdk:"single_nested_block_one"` - SingleNestedBlockThree types.Object `tfsdk:"single_nested_block_three"` - SingleNestedBlockTwo types.Object `tfsdk:"single_nested_block_two"` -} - -type ListNestedAttributeAssocExtTypeModel struct { - BoolAttribute types.Bool `tfsdk:"bool_attribute"` - Float64Attribute types.Float64 `tfsdk:"float64_attribute"` - Int64Attribute types.Int64 `tfsdk:"int64_attribute"` - NumberAttribute types.Number `tfsdk:"number_attribute"` - StringAttribute types.String `tfsdk:"string_attribute"` -} - -type ListNestedAttributeOneModel struct { - BoolAttribute types.Bool `tfsdk:"bool_attribute"` -} - -type ListNestedAttributeThreeModel struct { - ListNestedAttributeThreeListNestedAttributeOne types.List `tfsdk:"list_nested_attribute_three_list_nested_attribute_one"` -} - -type ListNestedAttributeThreeListNestedAttributeOneModel struct { - ListAttribute types.List `tfsdk:"list_attribute"` -} - -type ListNestedAttributeTwoModel struct { - ListNestedAttributeTwoListNestedAttributeOne types.List `tfsdk:"list_nested_attribute_two_list_nested_attribute_one"` -} - -type ListNestedAttributeTwoListNestedAttributeOneModel struct { - BoolAttribute types.Bool `tfsdk:"bool_attribute"` -} - -type MapNestedAttributeAssocExtTypeModel struct { - BoolAttribute types.Bool `tfsdk:"bool_attribute"` - Float64Attribute types.Float64 `tfsdk:"float64_attribute"` - Int64Attribute types.Int64 `tfsdk:"int64_attribute"` - NumberAttribute types.Number `tfsdk:"number_attribute"` - StringAttribute types.String `tfsdk:"string_attribute"` -} - -type SetNestedAttributeAssocExtTypeModel struct { - BoolAttribute types.Bool `tfsdk:"bool_attribute"` - Float64Attribute types.Float64 `tfsdk:"float64_attribute"` - Int64Attribute types.Int64 `tfsdk:"int64_attribute"` - NumberAttribute types.Number `tfsdk:"number_attribute"` - StringAttribute types.String `tfsdk:"string_attribute"` -} - -type SingleNestedAttributeAssocExtTypeModel struct { - BoolAttribute types.Bool `tfsdk:"bool_attribute"` - Float64Attribute types.Float64 `tfsdk:"float64_attribute"` - Int64Attribute types.Int64 `tfsdk:"int64_attribute"` - NumberAttribute types.Number `tfsdk:"number_attribute"` - StringAttribute types.String `tfsdk:"string_attribute"` -} - -type SingleNestedAttributeOneModel struct { - BoolAttribute types.Bool `tfsdk:"bool_attribute"` -} - -type SingleNestedAttributeThreeModel struct { - SingleNestedAttributeThreeSingleNestedAttributeOne types.Object `tfsdk:"single_nested_attribute_three_single_nested_attribute_one"` -} - -type SingleNestedAttributeThreeSingleNestedAttributeOneModel struct { - ListAttribute types.List `tfsdk:"list_attribute"` -} - -type SingleNestedAttributeTwoModel struct { - SingleNestedAttributeTwoSingleNestedAttributeOne types.Object `tfsdk:"single_nested_attribute_two_single_nested_attribute_one"` -} - -type SingleNestedAttributeTwoSingleNestedAttributeOneModel struct { - BoolAttribute types.Bool `tfsdk:"bool_attribute"` -} - -type ListNestedBlockAssocExtTypeModel struct { - BoolAttribute types.Bool `tfsdk:"bool_attribute"` - Float64Attribute types.Float64 `tfsdk:"float64_attribute"` - Int64Attribute types.Int64 `tfsdk:"int64_attribute"` - NumberAttribute types.Number `tfsdk:"number_attribute"` - StringAttribute types.String `tfsdk:"string_attribute"` -} - -type ListNestedBlockOneModel struct { - BoolAttribute types.Bool `tfsdk:"bool_attribute"` -} - -type ListNestedBlockThreeModel struct { - ObjectAttribute types.Object `tfsdk:"object_attribute"` - ListNestedBlockThreeListNestedBlockOne types.List `tfsdk:"list_nested_block_three_list_nested_block_one"` -} - -type ListNestedBlockThreeListNestedBlockOneModel struct { - ListAttribute types.List `tfsdk:"list_attribute"` -} - -type ListNestedBlockTwoModel struct { - ListNestedBlockTwoListNestedBlockOne types.List `tfsdk:"list_nested_block_two_list_nested_block_one"` -} - -type ListNestedBlockTwoListNestedBlockOneModel struct { - BoolAttribute types.Bool `tfsdk:"bool_attribute"` -} - -type SetNestedBlockAssocExtTypeModel struct { - BoolAttribute types.Bool `tfsdk:"bool_attribute"` - Float64Attribute types.Float64 `tfsdk:"float64_attribute"` - Int64Attribute types.Int64 `tfsdk:"int64_attribute"` - NumberAttribute types.Number `tfsdk:"number_attribute"` - StringAttribute types.String `tfsdk:"string_attribute"` -} - -type SingleNestedBlockAssocExtTypeModel struct { - BoolAttribute types.Bool `tfsdk:"bool_attribute"` - Float64Attribute types.Float64 `tfsdk:"float64_attribute"` - Int64Attribute types.Int64 `tfsdk:"int64_attribute"` - NumberAttribute types.Number `tfsdk:"number_attribute"` - StringAttribute types.String `tfsdk:"string_attribute"` -} - -type SingleNestedBlockOneModel struct { - BoolAttribute types.Bool `tfsdk:"bool_attribute"` -} - -type SingleNestedBlockThreeModel struct { - ObjectAttribute types.Object `tfsdk:"object_attribute"` - SingleNestedBlockThreeListNestedBlockOne types.List `tfsdk:"single_nested_block_three_list_nested_block_one"` -} - -type SingleNestedBlockThreeListNestedBlockOneModel struct { - ListAttribute types.List `tfsdk:"list_attribute"` -} - -type SingleNestedBlockTwoModel struct { - SingleNestedBlockTwoSingleNestedBlockOne types.Object `tfsdk:"single_nested_block_two_single_nested_block_one"` -} - -type SingleNestedBlockTwoSingleNestedBlockOneModel struct { - BoolAttribute types.Bool `tfsdk:"bool_attribute"` -} - -func (m ListNestedAttributeAssocExtTypeModel) ObjectType(ctx context.Context) types.ObjectType { - return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} -} - -func (m ListNestedAttributeAssocExtTypeModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { - return map[string]attr.Type{ - "bool_attribute": types.BoolType, - "float64_attribute": types.Float64Type, - "int64_attribute": types.Int64Type, - "number_attribute": types.NumberType, - "string_attribute": types.StringType, - } -} - -func (m ListNestedAttributeAssocExtTypeModel) ObjectNull(ctx context.Context) types.Object { - return types.ObjectNull( - m.ObjectAttributeTypes(ctx), - ) -} - -func (m ListNestedAttributeAssocExtTypeModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { - return types.ObjectValueFrom( - ctx, - m.ObjectAttributeTypes(ctx), - data, - ) -} -func (m ListNestedAttributeOneModel) ObjectType(ctx context.Context) types.ObjectType { - return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} -} - -func (m ListNestedAttributeOneModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { - return map[string]attr.Type{ - "bool_attribute": types.BoolType, - } -} - -func (m ListNestedAttributeOneModel) ObjectNull(ctx context.Context) types.Object { - return types.ObjectNull( - m.ObjectAttributeTypes(ctx), - ) -} - -func (m ListNestedAttributeOneModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { - return types.ObjectValueFrom( - ctx, - m.ObjectAttributeTypes(ctx), - data, - ) -} -func (m ListNestedAttributeThreeModel) ObjectType(ctx context.Context) types.ObjectType { - return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} -} - -func (m ListNestedAttributeThreeModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { - return map[string]attr.Type{ - "list_nested_attribute_three_list_nested_attribute_one": types.ListType{ - ElemType: ListNestedAttributeThreeListNestedAttributeOneModel{}.ObjectType(ctx), - }, - } -} - -func (m ListNestedAttributeThreeModel) ObjectNull(ctx context.Context) types.Object { - return types.ObjectNull( - m.ObjectAttributeTypes(ctx), - ) -} - -func (m ListNestedAttributeThreeModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { - return types.ObjectValueFrom( - ctx, - m.ObjectAttributeTypes(ctx), - data, - ) -} - -func (m ListNestedAttributeThreeListNestedAttributeOneModel) ObjectType(ctx context.Context) types.ObjectType { - return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} -} - -func (m ListNestedAttributeThreeListNestedAttributeOneModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { - return map[string]attr.Type{ - "list_attribute": types.ListType{ - ElemType: types.StringType, - }, - } -} - -func (m ListNestedAttributeThreeListNestedAttributeOneModel) ObjectNull(ctx context.Context) types.Object { - return types.ObjectNull( - m.ObjectAttributeTypes(ctx), - ) -} - -func (m ListNestedAttributeThreeListNestedAttributeOneModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { - return types.ObjectValueFrom( - ctx, - m.ObjectAttributeTypes(ctx), - data, - ) -} -func (m ListNestedAttributeTwoModel) ObjectType(ctx context.Context) types.ObjectType { - return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} -} - -func (m ListNestedAttributeTwoModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { - return map[string]attr.Type{ - "list_nested_attribute_two_list_nested_attribute_one": types.ListType{ - ElemType: ListNestedAttributeTwoListNestedAttributeOneModel{}.ObjectType(ctx), - }, - } -} - -func (m ListNestedAttributeTwoModel) ObjectNull(ctx context.Context) types.Object { - return types.ObjectNull( - m.ObjectAttributeTypes(ctx), - ) -} - -func (m ListNestedAttributeTwoModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { - return types.ObjectValueFrom( - ctx, - m.ObjectAttributeTypes(ctx), - data, - ) -} - -func (m ListNestedAttributeTwoListNestedAttributeOneModel) ObjectType(ctx context.Context) types.ObjectType { - return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} -} - -func (m ListNestedAttributeTwoListNestedAttributeOneModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { - return map[string]attr.Type{ - "bool_attribute": types.BoolType, - } -} - -func (m ListNestedAttributeTwoListNestedAttributeOneModel) ObjectNull(ctx context.Context) types.Object { - return types.ObjectNull( - m.ObjectAttributeTypes(ctx), - ) -} - -func (m ListNestedAttributeTwoListNestedAttributeOneModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { - return types.ObjectValueFrom( - ctx, - m.ObjectAttributeTypes(ctx), - data, - ) -} -func (m MapNestedAttributeAssocExtTypeModel) ObjectType(ctx context.Context) types.ObjectType { - return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} -} - -func (m MapNestedAttributeAssocExtTypeModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { - return map[string]attr.Type{ - "bool_attribute": types.BoolType, - "float64_attribute": types.Float64Type, - "int64_attribute": types.Int64Type, - "number_attribute": types.NumberType, - "string_attribute": types.StringType, - } -} - -func (m MapNestedAttributeAssocExtTypeModel) ObjectNull(ctx context.Context) types.Object { - return types.ObjectNull( - m.ObjectAttributeTypes(ctx), - ) -} - -func (m MapNestedAttributeAssocExtTypeModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { - return types.ObjectValueFrom( - ctx, - m.ObjectAttributeTypes(ctx), - data, - ) -} -func (m SetNestedAttributeAssocExtTypeModel) ObjectType(ctx context.Context) types.ObjectType { - return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} -} - -func (m SetNestedAttributeAssocExtTypeModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { - return map[string]attr.Type{ - "bool_attribute": types.BoolType, - "float64_attribute": types.Float64Type, - "int64_attribute": types.Int64Type, - "number_attribute": types.NumberType, - "string_attribute": types.StringType, - } -} - -func (m SetNestedAttributeAssocExtTypeModel) ObjectNull(ctx context.Context) types.Object { - return types.ObjectNull( - m.ObjectAttributeTypes(ctx), - ) -} - -func (m SetNestedAttributeAssocExtTypeModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { - return types.ObjectValueFrom( - ctx, - m.ObjectAttributeTypes(ctx), - data, - ) -} -func (m SingleNestedAttributeAssocExtTypeModel) ObjectType(ctx context.Context) types.ObjectType { - return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} -} - -func (m SingleNestedAttributeAssocExtTypeModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { - return map[string]attr.Type{ - "bool_attribute": types.BoolType, - "float64_attribute": types.Float64Type, - "int64_attribute": types.Int64Type, - "number_attribute": types.NumberType, - "string_attribute": types.StringType, - } -} - -func (m SingleNestedAttributeAssocExtTypeModel) ObjectNull(ctx context.Context) types.Object { - return types.ObjectNull( - m.ObjectAttributeTypes(ctx), - ) -} - -func (m SingleNestedAttributeAssocExtTypeModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { - return types.ObjectValueFrom( - ctx, - m.ObjectAttributeTypes(ctx), - data, - ) -} -func (m SingleNestedAttributeOneModel) ObjectType(ctx context.Context) types.ObjectType { - return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} -} - -func (m SingleNestedAttributeOneModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { - return map[string]attr.Type{ - "bool_attribute": types.BoolType, - } -} - -func (m SingleNestedAttributeOneModel) ObjectNull(ctx context.Context) types.Object { - return types.ObjectNull( - m.ObjectAttributeTypes(ctx), - ) -} - -func (m SingleNestedAttributeOneModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { - return types.ObjectValueFrom( - ctx, - m.ObjectAttributeTypes(ctx), - data, - ) -} -func (m SingleNestedAttributeThreeModel) ObjectType(ctx context.Context) types.ObjectType { - return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} -} - -func (m SingleNestedAttributeThreeModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { - return map[string]attr.Type{ - "single_nested_attribute_three_single_nested_attribute_one": types.ObjectType{ - AttrTypes: SingleNestedAttributeThreeSingleNestedAttributeOneModel{}.ObjectAttributeTypes(ctx), - }, - } -} - -func (m SingleNestedAttributeThreeModel) ObjectNull(ctx context.Context) types.Object { - return types.ObjectNull( - m.ObjectAttributeTypes(ctx), - ) -} - -func (m SingleNestedAttributeThreeModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { - return types.ObjectValueFrom( - ctx, - m.ObjectAttributeTypes(ctx), - data, - ) -} - -func (m SingleNestedAttributeThreeSingleNestedAttributeOneModel) ObjectType(ctx context.Context) types.ObjectType { - return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} -} - -func (m SingleNestedAttributeThreeSingleNestedAttributeOneModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { - return map[string]attr.Type{ - "list_attribute": types.ListType{ - ElemType: types.StringType, - }, - } -} - -func (m SingleNestedAttributeThreeSingleNestedAttributeOneModel) ObjectNull(ctx context.Context) types.Object { - return types.ObjectNull( - m.ObjectAttributeTypes(ctx), - ) -} - -func (m SingleNestedAttributeThreeSingleNestedAttributeOneModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { - return types.ObjectValueFrom( - ctx, - m.ObjectAttributeTypes(ctx), - data, - ) -} -func (m SingleNestedAttributeTwoModel) ObjectType(ctx context.Context) types.ObjectType { - return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} -} - -func (m SingleNestedAttributeTwoModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { - return map[string]attr.Type{ - "single_nested_attribute_two_single_nested_attribute_one": types.ObjectType{ - AttrTypes: SingleNestedAttributeTwoSingleNestedAttributeOneModel{}.ObjectAttributeTypes(ctx), - }, - } -} - -func (m SingleNestedAttributeTwoModel) ObjectNull(ctx context.Context) types.Object { - return types.ObjectNull( - m.ObjectAttributeTypes(ctx), - ) -} - -func (m SingleNestedAttributeTwoModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { - return types.ObjectValueFrom( - ctx, - m.ObjectAttributeTypes(ctx), - data, - ) -} - -func (m SingleNestedAttributeTwoSingleNestedAttributeOneModel) ObjectType(ctx context.Context) types.ObjectType { - return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} -} - -func (m SingleNestedAttributeTwoSingleNestedAttributeOneModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { - return map[string]attr.Type{ - "bool_attribute": types.BoolType, - } -} - -func (m SingleNestedAttributeTwoSingleNestedAttributeOneModel) ObjectNull(ctx context.Context) types.Object { - return types.ObjectNull( - m.ObjectAttributeTypes(ctx), - ) -} - -func (m SingleNestedAttributeTwoSingleNestedAttributeOneModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { - return types.ObjectValueFrom( - ctx, - m.ObjectAttributeTypes(ctx), - data, - ) -} -func (m ListNestedBlockAssocExtTypeModel) ObjectType(ctx context.Context) types.ObjectType { - return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} -} - -func (m ListNestedBlockAssocExtTypeModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { - return map[string]attr.Type{ - "bool_attribute": types.BoolType, - "float64_attribute": types.Float64Type, - "int64_attribute": types.Int64Type, - "number_attribute": types.NumberType, - "string_attribute": types.StringType, - } -} - -func (m ListNestedBlockAssocExtTypeModel) ObjectNull(ctx context.Context) types.Object { - return types.ObjectNull( - m.ObjectAttributeTypes(ctx), - ) -} - -func (m ListNestedBlockAssocExtTypeModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { - return types.ObjectValueFrom( - ctx, - m.ObjectAttributeTypes(ctx), - data, - ) -} -func (m ListNestedBlockOneModel) ObjectType(ctx context.Context) types.ObjectType { - return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} -} - -func (m ListNestedBlockOneModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { - return map[string]attr.Type{ - "bool_attribute": types.BoolType, - } -} - -func (m ListNestedBlockOneModel) ObjectNull(ctx context.Context) types.Object { - return types.ObjectNull( - m.ObjectAttributeTypes(ctx), - ) -} - -func (m ListNestedBlockOneModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { - return types.ObjectValueFrom( - ctx, - m.ObjectAttributeTypes(ctx), - data, - ) -} -func (m ListNestedBlockThreeModel) ObjectType(ctx context.Context) types.ObjectType { - return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} -} - -func (m ListNestedBlockThreeModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { - return map[string]attr.Type{ - "list_nested_block_three_list_nested_block_one": types.ListType{ - ElemType: ListNestedBlockThreeListNestedBlockOneModel{}.ObjectType(ctx), - }, - "object_attribute": types.ObjectType{ - AttrTypes: map[string]attr.Type{ - "string_attribute_type": types.StringType, - }, - }, - } -} - -func (m ListNestedBlockThreeModel) ObjectNull(ctx context.Context) types.Object { - return types.ObjectNull( - m.ObjectAttributeTypes(ctx), - ) -} - -func (m ListNestedBlockThreeModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { - return types.ObjectValueFrom( - ctx, - m.ObjectAttributeTypes(ctx), - data, - ) -} - -func (m ListNestedBlockThreeListNestedBlockOneModel) ObjectType(ctx context.Context) types.ObjectType { - return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} -} - -func (m ListNestedBlockThreeListNestedBlockOneModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { - return map[string]attr.Type{ - "list_attribute": types.ListType{ - ElemType: types.StringType, - }, - } -} - -func (m ListNestedBlockThreeListNestedBlockOneModel) ObjectNull(ctx context.Context) types.Object { - return types.ObjectNull( - m.ObjectAttributeTypes(ctx), - ) -} - -func (m ListNestedBlockThreeListNestedBlockOneModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { - return types.ObjectValueFrom( - ctx, - m.ObjectAttributeTypes(ctx), - data, - ) -} -func (m ListNestedBlockTwoModel) ObjectType(ctx context.Context) types.ObjectType { - return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} -} - -func (m ListNestedBlockTwoModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { - return map[string]attr.Type{ - "list_nested_block_two_list_nested_block_one": types.ListType{ - ElemType: ListNestedBlockTwoListNestedBlockOneModel{}.ObjectType(ctx), - }, - } -} - -func (m ListNestedBlockTwoModel) ObjectNull(ctx context.Context) types.Object { - return types.ObjectNull( - m.ObjectAttributeTypes(ctx), - ) -} - -func (m ListNestedBlockTwoModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { - return types.ObjectValueFrom( - ctx, - m.ObjectAttributeTypes(ctx), - data, - ) -} - -func (m ListNestedBlockTwoListNestedBlockOneModel) ObjectType(ctx context.Context) types.ObjectType { - return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} -} - -func (m ListNestedBlockTwoListNestedBlockOneModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { - return map[string]attr.Type{ - "bool_attribute": types.BoolType, - } -} - -func (m ListNestedBlockTwoListNestedBlockOneModel) ObjectNull(ctx context.Context) types.Object { - return types.ObjectNull( - m.ObjectAttributeTypes(ctx), - ) -} - -func (m ListNestedBlockTwoListNestedBlockOneModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { - return types.ObjectValueFrom( - ctx, - m.ObjectAttributeTypes(ctx), - data, - ) -} -func (m SetNestedBlockAssocExtTypeModel) ObjectType(ctx context.Context) types.ObjectType { - return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} -} - -func (m SetNestedBlockAssocExtTypeModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { - return map[string]attr.Type{ - "bool_attribute": types.BoolType, - "float64_attribute": types.Float64Type, - "int64_attribute": types.Int64Type, - "number_attribute": types.NumberType, - "string_attribute": types.StringType, - } -} - -func (m SetNestedBlockAssocExtTypeModel) ObjectNull(ctx context.Context) types.Object { - return types.ObjectNull( - m.ObjectAttributeTypes(ctx), - ) -} - -func (m SetNestedBlockAssocExtTypeModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { - return types.ObjectValueFrom( - ctx, - m.ObjectAttributeTypes(ctx), - data, - ) -} -func (m SingleNestedBlockAssocExtTypeModel) ObjectType(ctx context.Context) types.ObjectType { - return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} -} - -func (m SingleNestedBlockAssocExtTypeModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { - return map[string]attr.Type{ - "bool_attribute": types.BoolType, - "float64_attribute": types.Float64Type, - "int64_attribute": types.Int64Type, - "number_attribute": types.NumberType, - "string_attribute": types.StringType, - } -} - -func (m SingleNestedBlockAssocExtTypeModel) ObjectNull(ctx context.Context) types.Object { - return types.ObjectNull( - m.ObjectAttributeTypes(ctx), - ) -} - -func (m SingleNestedBlockAssocExtTypeModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { - return types.ObjectValueFrom( - ctx, - m.ObjectAttributeTypes(ctx), - data, - ) -} -func (m SingleNestedBlockOneModel) ObjectType(ctx context.Context) types.ObjectType { - return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} -} - -func (m SingleNestedBlockOneModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { - return map[string]attr.Type{ - "bool_attribute": types.BoolType, - } -} - -func (m SingleNestedBlockOneModel) ObjectNull(ctx context.Context) types.Object { - return types.ObjectNull( - m.ObjectAttributeTypes(ctx), - ) -} - -func (m SingleNestedBlockOneModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { - return types.ObjectValueFrom( - ctx, - m.ObjectAttributeTypes(ctx), - data, - ) -} -func (m SingleNestedBlockThreeModel) ObjectType(ctx context.Context) types.ObjectType { - return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} -} - -func (m SingleNestedBlockThreeModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { - return map[string]attr.Type{ - "object_attribute": types.ObjectType{ - AttrTypes: map[string]attr.Type{ - "string_attribute_type": types.StringType, - }, - }, - "single_nested_block_three_list_nested_block_one": types.ListType{ - ElemType: SingleNestedBlockThreeListNestedBlockOneModel{}.ObjectType(ctx), - }, - } -} - -func (m SingleNestedBlockThreeModel) ObjectNull(ctx context.Context) types.Object { - return types.ObjectNull( - m.ObjectAttributeTypes(ctx), - ) -} - -func (m SingleNestedBlockThreeModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { - return types.ObjectValueFrom( - ctx, - m.ObjectAttributeTypes(ctx), - data, - ) -} - -func (m SingleNestedBlockThreeListNestedBlockOneModel) ObjectType(ctx context.Context) types.ObjectType { - return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} -} - -func (m SingleNestedBlockThreeListNestedBlockOneModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { - return map[string]attr.Type{ - "list_attribute": types.ListType{ - ElemType: types.StringType, - }, - } -} - -func (m SingleNestedBlockThreeListNestedBlockOneModel) ObjectNull(ctx context.Context) types.Object { - return types.ObjectNull( - m.ObjectAttributeTypes(ctx), - ) -} - -func (m SingleNestedBlockThreeListNestedBlockOneModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { - return types.ObjectValueFrom( - ctx, - m.ObjectAttributeTypes(ctx), - data, - ) -} -func (m SingleNestedBlockTwoModel) ObjectType(ctx context.Context) types.ObjectType { - return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} -} - -func (m SingleNestedBlockTwoModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { - return map[string]attr.Type{ - "single_nested_block_two_single_nested_block_one": types.ObjectType{ - AttrTypes: SingleNestedBlockTwoSingleNestedBlockOneModel{}.ObjectAttributeTypes(ctx), - }, - } -} - -func (m SingleNestedBlockTwoModel) ObjectNull(ctx context.Context) types.Object { - return types.ObjectNull( - m.ObjectAttributeTypes(ctx), - ) -} - -func (m SingleNestedBlockTwoModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { - return types.ObjectValueFrom( - ctx, - m.ObjectAttributeTypes(ctx), - data, - ) -} - -func (m SingleNestedBlockTwoSingleNestedBlockOneModel) ObjectType(ctx context.Context) types.ObjectType { - return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} -} - -func (m SingleNestedBlockTwoSingleNestedBlockOneModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { - return map[string]attr.Type{ - "bool_attribute": types.BoolType, - } -} - -func (m SingleNestedBlockTwoSingleNestedBlockOneModel) ObjectNull(ctx context.Context) types.Object { - return types.ObjectNull( - m.ObjectAttributeTypes(ctx), - ) -} - -func (m SingleNestedBlockTwoSingleNestedBlockOneModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { - return types.ObjectValueFrom( - ctx, - m.ObjectAttributeTypes(ctx), - data, - ) -} - -func ToListNestedAttributeAssocExtType(ctx context.Context, tfList types.List) ([]*apisdk.Type, diag.Diagnostics) { - var diags diag.Diagnostics - - if tfList.IsNull() { - return nil, diags - } - - if tfList.IsUnknown() { - diags.Append(diag.NewErrorDiagnostic( - "List Value Is Unknown", - `Model field "ListNestedAttributeAssocExtType" is unknown.`, - )) - - return nil, diags - } - - var listObjects []types.Object - - diags.Append(tfList.ElementsAs(ctx, &listObjects, false)...) - - if diags.HasError() { - return nil, diags - } - - apiObjects := make([]*apisdk.Type, 0, len(listObjects)) - - for _, listObject := range listObjects { - if listObject.IsNull() { - apiObjects = append(apiObjects, nil) - - continue - } - - if listObject.IsUnknown() { - diags.Append(diag.NewErrorDiagnostic( - "Object Value Within List Is Unknown", - `Model field "ListNestedAttributeAssocExtType" contains an object which is unknown.`, - )) - - return nil, diags - } - - var tfModel ListNestedAttributeAssocExtTypeModel - - d := listObject.As(ctx, &tfModel, basetypes.ObjectAsOptions{}) - - diags.Append(d...) - - if diags.HasError() { - return nil, diags - } - - apiObjects = append(apiObjects, &apisdk.Type{ - BoolAttribute: tfModel.BoolAttribute.ValueBoolPointer(), - Float64Attribute: tfModel.Float64Attribute.ValueFloat64Pointer(), - Int64Attribute: tfModel.Int64Attribute.ValueInt64Pointer(), - NumberAttribute: tfModel.NumberAttribute.ValueBigFloat(), - StringAttribute: tfModel.StringAttribute.ValueStringPointer(), - }) - } - - return apiObjects, diags -} - -func FromListNestedAttributeAssocExtType(ctx context.Context, apiObjects []*apisdk.Type) (types.List, diag.Diagnostics) { - var diags diag.Diagnostics - var tfModel ListNestedAttributeAssocExtTypeModel - - if apiObjects == nil { - return types.ListNull( - tfModel.ObjectType(ctx), - ), diags - } - - var tfModels []*ListNestedAttributeAssocExtTypeModel - - for _, apiObject := range apiObjects { - if apiObject == nil { - tfModels = append(tfModels, nil) - - continue - } - - tfModels = append(tfModels, &ListNestedAttributeAssocExtTypeModel{ - BoolAttribute: types.BoolPointerValue(apiObject.BoolAttribute), - Float64Attribute: types.Float64PointerValue(apiObject.Float64Attribute), - Int64Attribute: types.Int64PointerValue(apiObject.Int64Attribute), - NumberAttribute: types.NumberValue(apiObject.NumberAttribute), - StringAttribute: types.StringPointerValue(apiObject.StringAttribute), - }) - } - - return types.ListValueFrom(ctx, tfModel.ObjectType(ctx), tfModels) -} - -func ToMapNestedAttributeAssocExtType(ctx context.Context, tfMap types.Map) (map[string]*apisdk.Type, diag.Diagnostics) { - var diags diag.Diagnostics - - if tfMap.IsNull() { - return nil, diags - } - - if tfMap.IsUnknown() { - diags.Append(diag.NewErrorDiagnostic( - "Map Value Is Unknown", - `Model field "MapNestedAttributeAssocExtType" is unknown.`, - )) - - return nil, diags - } - - mapObjects := make(map[string]types.Object) - - diags.Append(tfMap.ElementsAs(ctx, &mapObjects, false)...) - - if diags.HasError() { - return nil, diags - } - - apiObjects := make(map[string]*apisdk.Type, len(mapObjects)) - - for k, mapObject := range mapObjects { - if mapObject.IsNull() { - apiObjects[k] = nil - - continue - } - - if mapObject.IsUnknown() { - diags.Append(diag.NewErrorDiagnostic( - "Object Value Within Map Is Unknown", - `Model field "MapNestedAttributeAssocExtType" contains an object which is unknown.`, - )) - - return nil, diags - } - - var tfModel MapNestedAttributeAssocExtTypeModel - - d := mapObject.As(ctx, &tfModel, basetypes.ObjectAsOptions{}) - - diags.Append(d...) - - if diags.HasError() { - return nil, diags - } - - apiObjects[k] = &apisdk.Type{ - BoolAttribute: tfModel.BoolAttribute.ValueBoolPointer(), - Float64Attribute: tfModel.Float64Attribute.ValueFloat64Pointer(), - Int64Attribute: tfModel.Int64Attribute.ValueInt64Pointer(), - NumberAttribute: tfModel.NumberAttribute.ValueBigFloat(), - StringAttribute: tfModel.StringAttribute.ValueStringPointer(), - } - } - - return apiObjects, diags -} - -func FromMapNestedAttributeAssocExtType(ctx context.Context, apiObjects map[string]*apisdk.Type) (types.Map, diag.Diagnostics) { - var diags diag.Diagnostics - var tfModel MapNestedAttributeAssocExtTypeModel - - if apiObjects == nil { - return types.MapNull( - tfModel.ObjectType(ctx), - ), diags - } - - tfModels := make(map[string]*MapNestedAttributeAssocExtTypeModel) - - for k, apiObject := range apiObjects { - if apiObject == nil { - tfModels[k] = nil - - continue - } - - tfModels[k] = &MapNestedAttributeAssocExtTypeModel{ - BoolAttribute: types.BoolPointerValue(apiObject.BoolAttribute), - Float64Attribute: types.Float64PointerValue(apiObject.Float64Attribute), - Int64Attribute: types.Int64PointerValue(apiObject.Int64Attribute), - NumberAttribute: types.NumberValue(apiObject.NumberAttribute), - StringAttribute: types.StringPointerValue(apiObject.StringAttribute), - } - } - - return types.MapValueFrom(ctx, tfModel.ObjectType(ctx), tfModels) -} - -func ToSetNestedAttributeAssocExtType(ctx context.Context, tfSet types.Set) ([]*apisdk.Type, diag.Diagnostics) { - var diags diag.Diagnostics - - if tfSet.IsNull() { - return nil, diags - } - - if tfSet.IsUnknown() { - diags.Append(diag.NewErrorDiagnostic( - "Set Value Is Unknown", - `Model field "SetNestedAttributeAssocExtType" is unknown.`, - )) - - return nil, diags - } - - var setObjects []types.Object - - diags.Append(tfSet.ElementsAs(ctx, &setObjects, false)...) - - if diags.HasError() { - return nil, diags - } - - apiObjects := make([]*apisdk.Type, 0, len(setObjects)) - - for _, setObject := range setObjects { - if setObject.IsNull() { - apiObjects = append(apiObjects, nil) - - continue - } - - if setObject.IsUnknown() { - diags.Append(diag.NewErrorDiagnostic( - "Object Value Within Set Is Unknown", - `Model field "SetNestedAttributeAssocExtType" contains an object which is unknown.`, - )) - - return nil, diags - } - - var tfModel SetNestedAttributeAssocExtTypeModel - - d := setObject.As(ctx, &tfModel, basetypes.ObjectAsOptions{}) - - diags.Append(d...) - - if diags.HasError() { - return nil, diags - } - - apiObjects = append(apiObjects, &apisdk.Type{ - BoolAttribute: tfModel.BoolAttribute.ValueBoolPointer(), - Float64Attribute: tfModel.Float64Attribute.ValueFloat64Pointer(), - Int64Attribute: tfModel.Int64Attribute.ValueInt64Pointer(), - NumberAttribute: tfModel.NumberAttribute.ValueBigFloat(), - StringAttribute: tfModel.StringAttribute.ValueStringPointer(), - }) - } - - return apiObjects, diags -} - -func FromSetNestedAttributeAssocExtType(ctx context.Context, apiObjects []*apisdk.Type) (types.Set, diag.Diagnostics) { - var diags diag.Diagnostics - var tfModel SetNestedAttributeAssocExtTypeModel - - if apiObjects == nil { - return types.SetNull( - tfModel.ObjectType(ctx), - ), diags - } - - var tfModels []*SetNestedAttributeAssocExtTypeModel - - for _, apiObject := range apiObjects { - if apiObject == nil { - tfModels = append(tfModels, nil) - - continue - } - - tfModels = append(tfModels, &SetNestedAttributeAssocExtTypeModel{ - BoolAttribute: types.BoolPointerValue(apiObject.BoolAttribute), - Float64Attribute: types.Float64PointerValue(apiObject.Float64Attribute), - Int64Attribute: types.Int64PointerValue(apiObject.Int64Attribute), - NumberAttribute: types.NumberValue(apiObject.NumberAttribute), - StringAttribute: types.StringPointerValue(apiObject.StringAttribute), - }) - } - - return types.SetValueFrom(ctx, tfModel.ObjectType(ctx), tfModels) -} - -func ToSingleNestedAttributeAssocExtType(ctx context.Context, tfObject types.Object) (*apisdk.Type, diag.Diagnostics) { - var diags diag.Diagnostics - - if tfObject.IsNull() { - return nil, diags - } - - if tfObject.IsUnknown() { - diags.Append(diag.NewErrorDiagnostic( - "Object Value Is Unknown", - `Model field "SingleNestedAttributeAssocExtType" is unknown.`, - )) - - return nil, diags - } - - var tfModel SingleNestedAttributeAssocExtTypeModel - - diags.Append(tfObject.As(ctx, &tfModel, basetypes.ObjectAsOptions{})...) - - if diags.HasError() { - return nil, diags - } - - apiObject := &apisdk.Type{ - BoolAttribute: tfModel.BoolAttribute.ValueBoolPointer(), - Float64Attribute: tfModel.Float64Attribute.ValueFloat64Pointer(), - Int64Attribute: tfModel.Int64Attribute.ValueInt64Pointer(), - NumberAttribute: tfModel.NumberAttribute.ValueBigFloat(), - StringAttribute: tfModel.StringAttribute.ValueStringPointer(), - } - - return apiObject, diags -} - -func FromSingleNestedAttributeAssocExtType(ctx context.Context, apiObject *apisdk.Type) (types.Object, diag.Diagnostics) { - var diags diag.Diagnostics - var tfModel SingleNestedAttributeAssocExtTypeModel - - if apiObject == nil { - return tfModel.ObjectNull(ctx), diags - } - - tfModel.BoolAttribute = types.BoolPointerValue(apiObject.BoolAttribute) - tfModel.Float64Attribute = types.Float64PointerValue(apiObject.Float64Attribute) - tfModel.Int64Attribute = types.Int64PointerValue(apiObject.Int64Attribute) - tfModel.NumberAttribute = types.NumberValue(apiObject.NumberAttribute) - tfModel.StringAttribute = types.StringPointerValue(apiObject.StringAttribute) - - return tfModel.ObjectValueFrom(ctx, tfModel) -} - -func ToListNestedBlockAssocExtType(ctx context.Context, tfList types.List) ([]*apisdk.Type, diag.Diagnostics) { - var diags diag.Diagnostics - - if tfList.IsNull() { - return nil, diags - } - - if tfList.IsUnknown() { - diags.Append(diag.NewErrorDiagnostic( - "List Value Is Unknown", - `Model field "ListNestedBlockAssocExtType" is unknown.`, - )) - - return nil, diags - } - - var listObjects []types.Object - - diags.Append(tfList.ElementsAs(ctx, &listObjects, false)...) - - if diags.HasError() { - return nil, diags - } - - apiObjects := make([]*apisdk.Type, 0, len(listObjects)) - - for _, listObject := range listObjects { - if listObject.IsNull() { - apiObjects = append(apiObjects, nil) - - continue - } - - if listObject.IsUnknown() { - diags.Append(diag.NewErrorDiagnostic( - "Object Value Within List Is Unknown", - `Model field "ListNestedBlockAssocExtType" contains an object which is unknown.`, - )) - - return nil, diags - } - - var tfModel ListNestedBlockAssocExtTypeModel - - d := listObject.As(ctx, &tfModel, basetypes.ObjectAsOptions{}) - - diags.Append(d...) - - if diags.HasError() { - return nil, diags - } - - apiObjects = append(apiObjects, &apisdk.Type{ - BoolAttribute: tfModel.BoolAttribute.ValueBoolPointer(), - Float64Attribute: tfModel.Float64Attribute.ValueFloat64Pointer(), - Int64Attribute: tfModel.Int64Attribute.ValueInt64Pointer(), - NumberAttribute: tfModel.NumberAttribute.ValueBigFloat(), - StringAttribute: tfModel.StringAttribute.ValueStringPointer(), - }) - } - - return apiObjects, diags -} - -func FromListNestedBlockAssocExtType(ctx context.Context, apiObjects []*apisdk.Type) (types.List, diag.Diagnostics) { - var diags diag.Diagnostics - var tfModel ListNestedBlockAssocExtTypeModel - - if apiObjects == nil { - return types.ListNull( - tfModel.ObjectType(ctx), - ), diags - } - - var tfModels []*ListNestedBlockAssocExtTypeModel - - for _, apiObject := range apiObjects { - if apiObject == nil { - tfModels = append(tfModels, nil) - - continue - } - - tfModels = append(tfModels, &ListNestedBlockAssocExtTypeModel{ - BoolAttribute: types.BoolPointerValue(apiObject.BoolAttribute), - Float64Attribute: types.Float64PointerValue(apiObject.Float64Attribute), - Int64Attribute: types.Int64PointerValue(apiObject.Int64Attribute), - NumberAttribute: types.NumberValue(apiObject.NumberAttribute), - StringAttribute: types.StringPointerValue(apiObject.StringAttribute), - }) - } - - return types.ListValueFrom(ctx, tfModel.ObjectType(ctx), tfModels) -} - -func ToSetNestedBlockAssocExtType(ctx context.Context, tfSet types.Set) ([]*apisdk.Type, diag.Diagnostics) { - var diags diag.Diagnostics - - if tfSet.IsNull() { - return nil, diags - } - - if tfSet.IsUnknown() { - diags.Append(diag.NewErrorDiagnostic( - "Set Value Is Unknown", - `Model field "SetNestedBlockAssocExtType" is unknown.`, - )) - - return nil, diags - } - - var setObjects []types.Object - - diags.Append(tfSet.ElementsAs(ctx, &setObjects, false)...) - - if diags.HasError() { - return nil, diags - } - - apiObjects := make([]*apisdk.Type, 0, len(setObjects)) - - for _, setObject := range setObjects { - if setObject.IsNull() { - apiObjects = append(apiObjects, nil) - - continue - } - - if setObject.IsUnknown() { - diags.Append(diag.NewErrorDiagnostic( - "Object Value Within Set Is Unknown", - `Model field "SetNestedBlockAssocExtType" contains an object which is unknown.`, - )) - - return nil, diags - } - - var tfModel SetNestedBlockAssocExtTypeModel - - d := setObject.As(ctx, &tfModel, basetypes.ObjectAsOptions{}) - - diags.Append(d...) - - if diags.HasError() { - return nil, diags - } - - apiObjects = append(apiObjects, &apisdk.Type{ - BoolAttribute: tfModel.BoolAttribute.ValueBoolPointer(), - Float64Attribute: tfModel.Float64Attribute.ValueFloat64Pointer(), - Int64Attribute: tfModel.Int64Attribute.ValueInt64Pointer(), - NumberAttribute: tfModel.NumberAttribute.ValueBigFloat(), - StringAttribute: tfModel.StringAttribute.ValueStringPointer(), - }) - } - - return apiObjects, diags -} - -func FromSetNestedBlockAssocExtType(ctx context.Context, apiObjects []*apisdk.Type) (types.Set, diag.Diagnostics) { - var diags diag.Diagnostics - var tfModel SetNestedBlockAssocExtTypeModel - - if apiObjects == nil { - return types.SetNull( - tfModel.ObjectType(ctx), - ), diags - } - - var tfModels []*SetNestedBlockAssocExtTypeModel - - for _, apiObject := range apiObjects { - if apiObject == nil { - tfModels = append(tfModels, nil) - - continue - } - - tfModels = append(tfModels, &SetNestedBlockAssocExtTypeModel{ - BoolAttribute: types.BoolPointerValue(apiObject.BoolAttribute), - Float64Attribute: types.Float64PointerValue(apiObject.Float64Attribute), - Int64Attribute: types.Int64PointerValue(apiObject.Int64Attribute), - NumberAttribute: types.NumberValue(apiObject.NumberAttribute), - StringAttribute: types.StringPointerValue(apiObject.StringAttribute), - }) - } - - return types.SetValueFrom(ctx, tfModel.ObjectType(ctx), tfModels) -} - -func ToSingleNestedBlockAssocExtType(ctx context.Context, tfObject types.Object) (*apisdk.Type, diag.Diagnostics) { - var diags diag.Diagnostics - - if tfObject.IsNull() { - return nil, diags - } - - if tfObject.IsUnknown() { - diags.Append(diag.NewErrorDiagnostic( - "Object Value Is Unknown", - `Model field "SingleNestedBlockAssocExtType" is unknown.`, - )) - - return nil, diags - } - - var tfModel SingleNestedBlockAssocExtTypeModel - - diags.Append(tfObject.As(ctx, &tfModel, basetypes.ObjectAsOptions{})...) - - if diags.HasError() { - return nil, diags - } - - apiObject := &apisdk.Type{ - BoolAttribute: tfModel.BoolAttribute.ValueBoolPointer(), - Float64Attribute: tfModel.Float64Attribute.ValueFloat64Pointer(), - Int64Attribute: tfModel.Int64Attribute.ValueInt64Pointer(), - NumberAttribute: tfModel.NumberAttribute.ValueBigFloat(), - StringAttribute: tfModel.StringAttribute.ValueStringPointer(), - } - - return apiObject, diags -} - -func FromSingleNestedBlockAssocExtType(ctx context.Context, apiObject *apisdk.Type) (types.Object, diag.Diagnostics) { - var diags diag.Diagnostics - var tfModel SingleNestedBlockAssocExtTypeModel - - if apiObject == nil { - return tfModel.ObjectNull(ctx), diags - } - - tfModel.BoolAttribute = types.BoolPointerValue(apiObject.BoolAttribute) - tfModel.Float64Attribute = types.Float64PointerValue(apiObject.Float64Attribute) - tfModel.Int64Attribute = types.Int64PointerValue(apiObject.Int64Attribute) - tfModel.NumberAttribute = types.NumberValue(apiObject.NumberAttribute) - tfModel.StringAttribute = types.StringPointerValue(apiObject.StringAttribute) - - return tfModel.ObjectValueFrom(ctx, tfModel) -} diff --git a/internal/cmd/testdata/custom_and_external/all_output/provider_provider_gen.go b/internal/cmd/testdata/custom_and_external/all_output/provider_provider_gen.go deleted file mode 100644 index c1e64bd3..00000000 --- a/internal/cmd/testdata/custom_and_external/all_output/provider_provider_gen.go +++ /dev/null @@ -1,1002 +0,0 @@ -// Code generated by terraform-plugin-framework-generator DO NOT EDIT. - -package generated - -import ( - "context" - "example.com/apisdk" - "github.com/hashicorp/terraform-plugin-framework/attr" - "github.com/hashicorp/terraform-plugin-framework/diag" - "github.com/hashicorp/terraform-plugin-framework/provider/schema" - "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/hashicorp/terraform-plugin-framework/types/basetypes" -) - -var providerProviderSchema = schema.Schema{ - Attributes: map[string]schema.Attribute{ - "list_nested_attribute_assoc_ext_type": schema.ListNestedAttribute{ - NestedObject: schema.NestedAttributeObject{ - Attributes: map[string]schema.Attribute{ - "bool_attribute": schema.BoolAttribute{ - Optional: true, - }, - "float64_attribute": schema.Float64Attribute{ - Optional: true, - }, - "int64_attribute": schema.Int64Attribute{ - Optional: true, - }, - "number_attribute": schema.NumberAttribute{ - Optional: true, - }, - "string_attribute": schema.StringAttribute{ - Optional: true, - }, - }, - }, - Optional: true, - }, - "map_nested_attribute_assoc_ext_type": schema.MapNestedAttribute{ - NestedObject: schema.NestedAttributeObject{ - Attributes: map[string]schema.Attribute{ - "bool_attribute": schema.BoolAttribute{ - Optional: true, - }, - "float64_attribute": schema.Float64Attribute{ - Optional: true, - }, - "int64_attribute": schema.Int64Attribute{ - Optional: true, - }, - "number_attribute": schema.NumberAttribute{ - Optional: true, - }, - "string_attribute": schema.StringAttribute{ - Optional: true, - }, - }, - }, - Optional: true, - }, - "set_nested_attribute_assoc_ext_type": schema.SetNestedAttribute{ - NestedObject: schema.NestedAttributeObject{ - Attributes: map[string]schema.Attribute{ - "bool_attribute": schema.BoolAttribute{ - Optional: true, - }, - "float64_attribute": schema.Float64Attribute{ - Optional: true, - }, - "int64_attribute": schema.Int64Attribute{ - Optional: true, - }, - "number_attribute": schema.NumberAttribute{ - Optional: true, - }, - "string_attribute": schema.StringAttribute{ - Optional: true, - }, - }, - }, - Optional: true, - }, - "single_nested_attribute_assoc_ext_type": schema.SingleNestedAttribute{ - Attributes: map[string]schema.Attribute{ - "bool_attribute": schema.BoolAttribute{ - Optional: true, - }, - "float64_attribute": schema.Float64Attribute{ - Optional: true, - }, - "int64_attribute": schema.Int64Attribute{ - Optional: true, - }, - "number_attribute": schema.NumberAttribute{ - Optional: true, - }, - "string_attribute": schema.StringAttribute{ - Optional: true, - }, - }, - Optional: true, - }, - }, - Blocks: map[string]schema.Block{ - "list_nested_block_assoc_ext_type": schema.ListNestedBlock{ - NestedObject: schema.NestedBlockObject{ - Attributes: map[string]schema.Attribute{ - "bool_attribute": schema.BoolAttribute{ - Optional: true, - }, - "float64_attribute": schema.Float64Attribute{ - Optional: true, - }, - "int64_attribute": schema.Int64Attribute{ - Optional: true, - }, - "number_attribute": schema.NumberAttribute{ - Optional: true, - }, - "string_attribute": schema.StringAttribute{ - Optional: true, - }, - }, - }, - }, - "set_nested_block_assoc_ext_type": schema.SetNestedBlock{ - NestedObject: schema.NestedBlockObject{ - Attributes: map[string]schema.Attribute{ - "bool_attribute": schema.BoolAttribute{ - Optional: true, - }, - "float64_attribute": schema.Float64Attribute{ - Optional: true, - }, - "int64_attribute": schema.Int64Attribute{ - Optional: true, - }, - "number_attribute": schema.NumberAttribute{ - Optional: true, - }, - "string_attribute": schema.StringAttribute{ - Optional: true, - }, - }, - }, - }, - "single_nested_block_assoc_ext_type": schema.SingleNestedBlock{ - Attributes: map[string]schema.Attribute{ - "bool_attribute": schema.BoolAttribute{ - Optional: true, - }, - "float64_attribute": schema.Float64Attribute{ - Optional: true, - }, - "int64_attribute": schema.Int64Attribute{ - Optional: true, - }, - "number_attribute": schema.NumberAttribute{ - Optional: true, - }, - "string_attribute": schema.StringAttribute{ - Optional: true, - }, - }, - }, - }, -} - -type ProviderModel struct { - ListNestedAttributeAssocExtType types.List `tfsdk:"list_nested_attribute_assoc_ext_type"` - MapNestedAttributeAssocExtType types.Map `tfsdk:"map_nested_attribute_assoc_ext_type"` - SetNestedAttributeAssocExtType types.Set `tfsdk:"set_nested_attribute_assoc_ext_type"` - SingleNestedAttributeAssocExtType types.Object `tfsdk:"single_nested_attribute_assoc_ext_type"` - ListNestedBlockAssocExtType types.List `tfsdk:"list_nested_block_assoc_ext_type"` - SetNestedBlockAssocExtType types.Set `tfsdk:"set_nested_block_assoc_ext_type"` - SingleNestedBlockAssocExtType types.Object `tfsdk:"single_nested_block_assoc_ext_type"` -} - -type ListNestedAttributeAssocExtTypeModel struct { - BoolAttribute types.Bool `tfsdk:"bool_attribute"` - Float64Attribute types.Float64 `tfsdk:"float64_attribute"` - Int64Attribute types.Int64 `tfsdk:"int64_attribute"` - NumberAttribute types.Number `tfsdk:"number_attribute"` - StringAttribute types.String `tfsdk:"string_attribute"` -} - -type MapNestedAttributeAssocExtTypeModel struct { - BoolAttribute types.Bool `tfsdk:"bool_attribute"` - Float64Attribute types.Float64 `tfsdk:"float64_attribute"` - Int64Attribute types.Int64 `tfsdk:"int64_attribute"` - NumberAttribute types.Number `tfsdk:"number_attribute"` - StringAttribute types.String `tfsdk:"string_attribute"` -} - -type SetNestedAttributeAssocExtTypeModel struct { - BoolAttribute types.Bool `tfsdk:"bool_attribute"` - Float64Attribute types.Float64 `tfsdk:"float64_attribute"` - Int64Attribute types.Int64 `tfsdk:"int64_attribute"` - NumberAttribute types.Number `tfsdk:"number_attribute"` - StringAttribute types.String `tfsdk:"string_attribute"` -} - -type SingleNestedAttributeAssocExtTypeModel struct { - BoolAttribute types.Bool `tfsdk:"bool_attribute"` - Float64Attribute types.Float64 `tfsdk:"float64_attribute"` - Int64Attribute types.Int64 `tfsdk:"int64_attribute"` - NumberAttribute types.Number `tfsdk:"number_attribute"` - StringAttribute types.String `tfsdk:"string_attribute"` -} - -type ListNestedBlockAssocExtTypeModel struct { - BoolAttribute types.Bool `tfsdk:"bool_attribute"` - Float64Attribute types.Float64 `tfsdk:"float64_attribute"` - Int64Attribute types.Int64 `tfsdk:"int64_attribute"` - NumberAttribute types.Number `tfsdk:"number_attribute"` - StringAttribute types.String `tfsdk:"string_attribute"` -} - -type SetNestedBlockAssocExtTypeModel struct { - BoolAttribute types.Bool `tfsdk:"bool_attribute"` - Float64Attribute types.Float64 `tfsdk:"float64_attribute"` - Int64Attribute types.Int64 `tfsdk:"int64_attribute"` - NumberAttribute types.Number `tfsdk:"number_attribute"` - StringAttribute types.String `tfsdk:"string_attribute"` -} - -type SingleNestedBlockAssocExtTypeModel struct { - BoolAttribute types.Bool `tfsdk:"bool_attribute"` - Float64Attribute types.Float64 `tfsdk:"float64_attribute"` - Int64Attribute types.Int64 `tfsdk:"int64_attribute"` - NumberAttribute types.Number `tfsdk:"number_attribute"` - StringAttribute types.String `tfsdk:"string_attribute"` -} - -func (m ListNestedAttributeAssocExtTypeModel) ObjectType(ctx context.Context) types.ObjectType { - return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} -} - -func (m ListNestedAttributeAssocExtTypeModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { - return map[string]attr.Type{ - "bool_attribute": types.BoolType, - "float64_attribute": types.Float64Type, - "int64_attribute": types.Int64Type, - "number_attribute": types.NumberType, - "string_attribute": types.StringType, - } -} - -func (m ListNestedAttributeAssocExtTypeModel) ObjectNull(ctx context.Context) types.Object { - return types.ObjectNull( - m.ObjectAttributeTypes(ctx), - ) -} - -func (m ListNestedAttributeAssocExtTypeModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { - return types.ObjectValueFrom( - ctx, - m.ObjectAttributeTypes(ctx), - data, - ) -} -func (m MapNestedAttributeAssocExtTypeModel) ObjectType(ctx context.Context) types.ObjectType { - return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} -} - -func (m MapNestedAttributeAssocExtTypeModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { - return map[string]attr.Type{ - "bool_attribute": types.BoolType, - "float64_attribute": types.Float64Type, - "int64_attribute": types.Int64Type, - "number_attribute": types.NumberType, - "string_attribute": types.StringType, - } -} - -func (m MapNestedAttributeAssocExtTypeModel) ObjectNull(ctx context.Context) types.Object { - return types.ObjectNull( - m.ObjectAttributeTypes(ctx), - ) -} - -func (m MapNestedAttributeAssocExtTypeModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { - return types.ObjectValueFrom( - ctx, - m.ObjectAttributeTypes(ctx), - data, - ) -} -func (m SetNestedAttributeAssocExtTypeModel) ObjectType(ctx context.Context) types.ObjectType { - return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} -} - -func (m SetNestedAttributeAssocExtTypeModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { - return map[string]attr.Type{ - "bool_attribute": types.BoolType, - "float64_attribute": types.Float64Type, - "int64_attribute": types.Int64Type, - "number_attribute": types.NumberType, - "string_attribute": types.StringType, - } -} - -func (m SetNestedAttributeAssocExtTypeModel) ObjectNull(ctx context.Context) types.Object { - return types.ObjectNull( - m.ObjectAttributeTypes(ctx), - ) -} - -func (m SetNestedAttributeAssocExtTypeModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { - return types.ObjectValueFrom( - ctx, - m.ObjectAttributeTypes(ctx), - data, - ) -} -func (m SingleNestedAttributeAssocExtTypeModel) ObjectType(ctx context.Context) types.ObjectType { - return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} -} - -func (m SingleNestedAttributeAssocExtTypeModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { - return map[string]attr.Type{ - "bool_attribute": types.BoolType, - "float64_attribute": types.Float64Type, - "int64_attribute": types.Int64Type, - "number_attribute": types.NumberType, - "string_attribute": types.StringType, - } -} - -func (m SingleNestedAttributeAssocExtTypeModel) ObjectNull(ctx context.Context) types.Object { - return types.ObjectNull( - m.ObjectAttributeTypes(ctx), - ) -} - -func (m SingleNestedAttributeAssocExtTypeModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { - return types.ObjectValueFrom( - ctx, - m.ObjectAttributeTypes(ctx), - data, - ) -} -func (m ListNestedBlockAssocExtTypeModel) ObjectType(ctx context.Context) types.ObjectType { - return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} -} - -func (m ListNestedBlockAssocExtTypeModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { - return map[string]attr.Type{ - "bool_attribute": types.BoolType, - "float64_attribute": types.Float64Type, - "int64_attribute": types.Int64Type, - "number_attribute": types.NumberType, - "string_attribute": types.StringType, - } -} - -func (m ListNestedBlockAssocExtTypeModel) ObjectNull(ctx context.Context) types.Object { - return types.ObjectNull( - m.ObjectAttributeTypes(ctx), - ) -} - -func (m ListNestedBlockAssocExtTypeModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { - return types.ObjectValueFrom( - ctx, - m.ObjectAttributeTypes(ctx), - data, - ) -} -func (m SetNestedBlockAssocExtTypeModel) ObjectType(ctx context.Context) types.ObjectType { - return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} -} - -func (m SetNestedBlockAssocExtTypeModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { - return map[string]attr.Type{ - "bool_attribute": types.BoolType, - "float64_attribute": types.Float64Type, - "int64_attribute": types.Int64Type, - "number_attribute": types.NumberType, - "string_attribute": types.StringType, - } -} - -func (m SetNestedBlockAssocExtTypeModel) ObjectNull(ctx context.Context) types.Object { - return types.ObjectNull( - m.ObjectAttributeTypes(ctx), - ) -} - -func (m SetNestedBlockAssocExtTypeModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { - return types.ObjectValueFrom( - ctx, - m.ObjectAttributeTypes(ctx), - data, - ) -} -func (m SingleNestedBlockAssocExtTypeModel) ObjectType(ctx context.Context) types.ObjectType { - return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} -} - -func (m SingleNestedBlockAssocExtTypeModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { - return map[string]attr.Type{ - "bool_attribute": types.BoolType, - "float64_attribute": types.Float64Type, - "int64_attribute": types.Int64Type, - "number_attribute": types.NumberType, - "string_attribute": types.StringType, - } -} - -func (m SingleNestedBlockAssocExtTypeModel) ObjectNull(ctx context.Context) types.Object { - return types.ObjectNull( - m.ObjectAttributeTypes(ctx), - ) -} - -func (m SingleNestedBlockAssocExtTypeModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { - return types.ObjectValueFrom( - ctx, - m.ObjectAttributeTypes(ctx), - data, - ) -} - -func ToListNestedAttributeAssocExtType(ctx context.Context, tfList types.List) ([]*apisdk.Type, diag.Diagnostics) { - var diags diag.Diagnostics - - if tfList.IsNull() { - return nil, diags - } - - if tfList.IsUnknown() { - diags.Append(diag.NewErrorDiagnostic( - "List Value Is Unknown", - `Model field "ListNestedAttributeAssocExtType" is unknown.`, - )) - - return nil, diags - } - - var listObjects []types.Object - - diags.Append(tfList.ElementsAs(ctx, &listObjects, false)...) - - if diags.HasError() { - return nil, diags - } - - apiObjects := make([]*apisdk.Type, 0, len(listObjects)) - - for _, listObject := range listObjects { - if listObject.IsNull() { - apiObjects = append(apiObjects, nil) - - continue - } - - if listObject.IsUnknown() { - diags.Append(diag.NewErrorDiagnostic( - "Object Value Within List Is Unknown", - `Model field "ListNestedAttributeAssocExtType" contains an object which is unknown.`, - )) - - return nil, diags - } - - var tfModel ListNestedAttributeAssocExtTypeModel - - d := listObject.As(ctx, &tfModel, basetypes.ObjectAsOptions{}) - - diags.Append(d...) - - if diags.HasError() { - return nil, diags - } - - apiObjects = append(apiObjects, &apisdk.Type{ - BoolAttribute: tfModel.BoolAttribute.ValueBoolPointer(), - Float64Attribute: tfModel.Float64Attribute.ValueFloat64Pointer(), - Int64Attribute: tfModel.Int64Attribute.ValueInt64Pointer(), - NumberAttribute: tfModel.NumberAttribute.ValueBigFloat(), - StringAttribute: tfModel.StringAttribute.ValueStringPointer(), - }) - } - - return apiObjects, diags -} - -func FromListNestedAttributeAssocExtType(ctx context.Context, apiObjects []*apisdk.Type) (types.List, diag.Diagnostics) { - var diags diag.Diagnostics - var tfModel ListNestedAttributeAssocExtTypeModel - - if apiObjects == nil { - return types.ListNull( - tfModel.ObjectType(ctx), - ), diags - } - - var tfModels []*ListNestedAttributeAssocExtTypeModel - - for _, apiObject := range apiObjects { - if apiObject == nil { - tfModels = append(tfModels, nil) - - continue - } - - tfModels = append(tfModels, &ListNestedAttributeAssocExtTypeModel{ - BoolAttribute: types.BoolPointerValue(apiObject.BoolAttribute), - Float64Attribute: types.Float64PointerValue(apiObject.Float64Attribute), - Int64Attribute: types.Int64PointerValue(apiObject.Int64Attribute), - NumberAttribute: types.NumberValue(apiObject.NumberAttribute), - StringAttribute: types.StringPointerValue(apiObject.StringAttribute), - }) - } - - return types.ListValueFrom(ctx, tfModel.ObjectType(ctx), tfModels) -} - -func ToMapNestedAttributeAssocExtType(ctx context.Context, tfMap types.Map) (map[string]*apisdk.Type, diag.Diagnostics) { - var diags diag.Diagnostics - - if tfMap.IsNull() { - return nil, diags - } - - if tfMap.IsUnknown() { - diags.Append(diag.NewErrorDiagnostic( - "Map Value Is Unknown", - `Model field "MapNestedAttributeAssocExtType" is unknown.`, - )) - - return nil, diags - } - - mapObjects := make(map[string]types.Object) - - diags.Append(tfMap.ElementsAs(ctx, &mapObjects, false)...) - - if diags.HasError() { - return nil, diags - } - - apiObjects := make(map[string]*apisdk.Type, len(mapObjects)) - - for k, mapObject := range mapObjects { - if mapObject.IsNull() { - apiObjects[k] = nil - - continue - } - - if mapObject.IsUnknown() { - diags.Append(diag.NewErrorDiagnostic( - "Object Value Within Map Is Unknown", - `Model field "MapNestedAttributeAssocExtType" contains an object which is unknown.`, - )) - - return nil, diags - } - - var tfModel MapNestedAttributeAssocExtTypeModel - - d := mapObject.As(ctx, &tfModel, basetypes.ObjectAsOptions{}) - - diags.Append(d...) - - if diags.HasError() { - return nil, diags - } - - apiObjects[k] = &apisdk.Type{ - BoolAttribute: tfModel.BoolAttribute.ValueBoolPointer(), - Float64Attribute: tfModel.Float64Attribute.ValueFloat64Pointer(), - Int64Attribute: tfModel.Int64Attribute.ValueInt64Pointer(), - NumberAttribute: tfModel.NumberAttribute.ValueBigFloat(), - StringAttribute: tfModel.StringAttribute.ValueStringPointer(), - } - } - - return apiObjects, diags -} - -func FromMapNestedAttributeAssocExtType(ctx context.Context, apiObjects map[string]*apisdk.Type) (types.Map, diag.Diagnostics) { - var diags diag.Diagnostics - var tfModel MapNestedAttributeAssocExtTypeModel - - if apiObjects == nil { - return types.MapNull( - tfModel.ObjectType(ctx), - ), diags - } - - tfModels := make(map[string]*MapNestedAttributeAssocExtTypeModel) - - for k, apiObject := range apiObjects { - if apiObject == nil { - tfModels[k] = nil - - continue - } - - tfModels[k] = &MapNestedAttributeAssocExtTypeModel{ - BoolAttribute: types.BoolPointerValue(apiObject.BoolAttribute), - Float64Attribute: types.Float64PointerValue(apiObject.Float64Attribute), - Int64Attribute: types.Int64PointerValue(apiObject.Int64Attribute), - NumberAttribute: types.NumberValue(apiObject.NumberAttribute), - StringAttribute: types.StringPointerValue(apiObject.StringAttribute), - } - } - - return types.MapValueFrom(ctx, tfModel.ObjectType(ctx), tfModels) -} - -func ToSetNestedAttributeAssocExtType(ctx context.Context, tfSet types.Set) ([]*apisdk.Type, diag.Diagnostics) { - var diags diag.Diagnostics - - if tfSet.IsNull() { - return nil, diags - } - - if tfSet.IsUnknown() { - diags.Append(diag.NewErrorDiagnostic( - "Set Value Is Unknown", - `Model field "SetNestedAttributeAssocExtType" is unknown.`, - )) - - return nil, diags - } - - var setObjects []types.Object - - diags.Append(tfSet.ElementsAs(ctx, &setObjects, false)...) - - if diags.HasError() { - return nil, diags - } - - apiObjects := make([]*apisdk.Type, 0, len(setObjects)) - - for _, setObject := range setObjects { - if setObject.IsNull() { - apiObjects = append(apiObjects, nil) - - continue - } - - if setObject.IsUnknown() { - diags.Append(diag.NewErrorDiagnostic( - "Object Value Within Set Is Unknown", - `Model field "SetNestedAttributeAssocExtType" contains an object which is unknown.`, - )) - - return nil, diags - } - - var tfModel SetNestedAttributeAssocExtTypeModel - - d := setObject.As(ctx, &tfModel, basetypes.ObjectAsOptions{}) - - diags.Append(d...) - - if diags.HasError() { - return nil, diags - } - - apiObjects = append(apiObjects, &apisdk.Type{ - BoolAttribute: tfModel.BoolAttribute.ValueBoolPointer(), - Float64Attribute: tfModel.Float64Attribute.ValueFloat64Pointer(), - Int64Attribute: tfModel.Int64Attribute.ValueInt64Pointer(), - NumberAttribute: tfModel.NumberAttribute.ValueBigFloat(), - StringAttribute: tfModel.StringAttribute.ValueStringPointer(), - }) - } - - return apiObjects, diags -} - -func FromSetNestedAttributeAssocExtType(ctx context.Context, apiObjects []*apisdk.Type) (types.Set, diag.Diagnostics) { - var diags diag.Diagnostics - var tfModel SetNestedAttributeAssocExtTypeModel - - if apiObjects == nil { - return types.SetNull( - tfModel.ObjectType(ctx), - ), diags - } - - var tfModels []*SetNestedAttributeAssocExtTypeModel - - for _, apiObject := range apiObjects { - if apiObject == nil { - tfModels = append(tfModels, nil) - - continue - } - - tfModels = append(tfModels, &SetNestedAttributeAssocExtTypeModel{ - BoolAttribute: types.BoolPointerValue(apiObject.BoolAttribute), - Float64Attribute: types.Float64PointerValue(apiObject.Float64Attribute), - Int64Attribute: types.Int64PointerValue(apiObject.Int64Attribute), - NumberAttribute: types.NumberValue(apiObject.NumberAttribute), - StringAttribute: types.StringPointerValue(apiObject.StringAttribute), - }) - } - - return types.SetValueFrom(ctx, tfModel.ObjectType(ctx), tfModels) -} - -func ToSingleNestedAttributeAssocExtType(ctx context.Context, tfObject types.Object) (*apisdk.Type, diag.Diagnostics) { - var diags diag.Diagnostics - - if tfObject.IsNull() { - return nil, diags - } - - if tfObject.IsUnknown() { - diags.Append(diag.NewErrorDiagnostic( - "Object Value Is Unknown", - `Model field "SingleNestedAttributeAssocExtType" is unknown.`, - )) - - return nil, diags - } - - var tfModel SingleNestedAttributeAssocExtTypeModel - - diags.Append(tfObject.As(ctx, &tfModel, basetypes.ObjectAsOptions{})...) - - if diags.HasError() { - return nil, diags - } - - apiObject := &apisdk.Type{ - BoolAttribute: tfModel.BoolAttribute.ValueBoolPointer(), - Float64Attribute: tfModel.Float64Attribute.ValueFloat64Pointer(), - Int64Attribute: tfModel.Int64Attribute.ValueInt64Pointer(), - NumberAttribute: tfModel.NumberAttribute.ValueBigFloat(), - StringAttribute: tfModel.StringAttribute.ValueStringPointer(), - } - - return apiObject, diags -} - -func FromSingleNestedAttributeAssocExtType(ctx context.Context, apiObject *apisdk.Type) (types.Object, diag.Diagnostics) { - var diags diag.Diagnostics - var tfModel SingleNestedAttributeAssocExtTypeModel - - if apiObject == nil { - return tfModel.ObjectNull(ctx), diags - } - - tfModel.BoolAttribute = types.BoolPointerValue(apiObject.BoolAttribute) - tfModel.Float64Attribute = types.Float64PointerValue(apiObject.Float64Attribute) - tfModel.Int64Attribute = types.Int64PointerValue(apiObject.Int64Attribute) - tfModel.NumberAttribute = types.NumberValue(apiObject.NumberAttribute) - tfModel.StringAttribute = types.StringPointerValue(apiObject.StringAttribute) - - return tfModel.ObjectValueFrom(ctx, tfModel) -} - -func ToListNestedBlockAssocExtType(ctx context.Context, tfList types.List) ([]*apisdk.Type, diag.Diagnostics) { - var diags diag.Diagnostics - - if tfList.IsNull() { - return nil, diags - } - - if tfList.IsUnknown() { - diags.Append(diag.NewErrorDiagnostic( - "List Value Is Unknown", - `Model field "ListNestedBlockAssocExtType" is unknown.`, - )) - - return nil, diags - } - - var listObjects []types.Object - - diags.Append(tfList.ElementsAs(ctx, &listObjects, false)...) - - if diags.HasError() { - return nil, diags - } - - apiObjects := make([]*apisdk.Type, 0, len(listObjects)) - - for _, listObject := range listObjects { - if listObject.IsNull() { - apiObjects = append(apiObjects, nil) - - continue - } - - if listObject.IsUnknown() { - diags.Append(diag.NewErrorDiagnostic( - "Object Value Within List Is Unknown", - `Model field "ListNestedBlockAssocExtType" contains an object which is unknown.`, - )) - - return nil, diags - } - - var tfModel ListNestedBlockAssocExtTypeModel - - d := listObject.As(ctx, &tfModel, basetypes.ObjectAsOptions{}) - - diags.Append(d...) - - if diags.HasError() { - return nil, diags - } - - apiObjects = append(apiObjects, &apisdk.Type{ - BoolAttribute: tfModel.BoolAttribute.ValueBoolPointer(), - Float64Attribute: tfModel.Float64Attribute.ValueFloat64Pointer(), - Int64Attribute: tfModel.Int64Attribute.ValueInt64Pointer(), - NumberAttribute: tfModel.NumberAttribute.ValueBigFloat(), - StringAttribute: tfModel.StringAttribute.ValueStringPointer(), - }) - } - - return apiObjects, diags -} - -func FromListNestedBlockAssocExtType(ctx context.Context, apiObjects []*apisdk.Type) (types.List, diag.Diagnostics) { - var diags diag.Diagnostics - var tfModel ListNestedBlockAssocExtTypeModel - - if apiObjects == nil { - return types.ListNull( - tfModel.ObjectType(ctx), - ), diags - } - - var tfModels []*ListNestedBlockAssocExtTypeModel - - for _, apiObject := range apiObjects { - if apiObject == nil { - tfModels = append(tfModels, nil) - - continue - } - - tfModels = append(tfModels, &ListNestedBlockAssocExtTypeModel{ - BoolAttribute: types.BoolPointerValue(apiObject.BoolAttribute), - Float64Attribute: types.Float64PointerValue(apiObject.Float64Attribute), - Int64Attribute: types.Int64PointerValue(apiObject.Int64Attribute), - NumberAttribute: types.NumberValue(apiObject.NumberAttribute), - StringAttribute: types.StringPointerValue(apiObject.StringAttribute), - }) - } - - return types.ListValueFrom(ctx, tfModel.ObjectType(ctx), tfModels) -} - -func ToSetNestedBlockAssocExtType(ctx context.Context, tfSet types.Set) ([]*apisdk.Type, diag.Diagnostics) { - var diags diag.Diagnostics - - if tfSet.IsNull() { - return nil, diags - } - - if tfSet.IsUnknown() { - diags.Append(diag.NewErrorDiagnostic( - "Set Value Is Unknown", - `Model field "SetNestedBlockAssocExtType" is unknown.`, - )) - - return nil, diags - } - - var setObjects []types.Object - - diags.Append(tfSet.ElementsAs(ctx, &setObjects, false)...) - - if diags.HasError() { - return nil, diags - } - - apiObjects := make([]*apisdk.Type, 0, len(setObjects)) - - for _, setObject := range setObjects { - if setObject.IsNull() { - apiObjects = append(apiObjects, nil) - - continue - } - - if setObject.IsUnknown() { - diags.Append(diag.NewErrorDiagnostic( - "Object Value Within Set Is Unknown", - `Model field "SetNestedBlockAssocExtType" contains an object which is unknown.`, - )) - - return nil, diags - } - - var tfModel SetNestedBlockAssocExtTypeModel - - d := setObject.As(ctx, &tfModel, basetypes.ObjectAsOptions{}) - - diags.Append(d...) - - if diags.HasError() { - return nil, diags - } - - apiObjects = append(apiObjects, &apisdk.Type{ - BoolAttribute: tfModel.BoolAttribute.ValueBoolPointer(), - Float64Attribute: tfModel.Float64Attribute.ValueFloat64Pointer(), - Int64Attribute: tfModel.Int64Attribute.ValueInt64Pointer(), - NumberAttribute: tfModel.NumberAttribute.ValueBigFloat(), - StringAttribute: tfModel.StringAttribute.ValueStringPointer(), - }) - } - - return apiObjects, diags -} - -func FromSetNestedBlockAssocExtType(ctx context.Context, apiObjects []*apisdk.Type) (types.Set, diag.Diagnostics) { - var diags diag.Diagnostics - var tfModel SetNestedBlockAssocExtTypeModel - - if apiObjects == nil { - return types.SetNull( - tfModel.ObjectType(ctx), - ), diags - } - - var tfModels []*SetNestedBlockAssocExtTypeModel - - for _, apiObject := range apiObjects { - if apiObject == nil { - tfModels = append(tfModels, nil) - - continue - } - - tfModels = append(tfModels, &SetNestedBlockAssocExtTypeModel{ - BoolAttribute: types.BoolPointerValue(apiObject.BoolAttribute), - Float64Attribute: types.Float64PointerValue(apiObject.Float64Attribute), - Int64Attribute: types.Int64PointerValue(apiObject.Int64Attribute), - NumberAttribute: types.NumberValue(apiObject.NumberAttribute), - StringAttribute: types.StringPointerValue(apiObject.StringAttribute), - }) - } - - return types.SetValueFrom(ctx, tfModel.ObjectType(ctx), tfModels) -} - -func ToSingleNestedBlockAssocExtType(ctx context.Context, tfObject types.Object) (*apisdk.Type, diag.Diagnostics) { - var diags diag.Diagnostics - - if tfObject.IsNull() { - return nil, diags - } - - if tfObject.IsUnknown() { - diags.Append(diag.NewErrorDiagnostic( - "Object Value Is Unknown", - `Model field "SingleNestedBlockAssocExtType" is unknown.`, - )) - - return nil, diags - } - - var tfModel SingleNestedBlockAssocExtTypeModel - - diags.Append(tfObject.As(ctx, &tfModel, basetypes.ObjectAsOptions{})...) - - if diags.HasError() { - return nil, diags - } - - apiObject := &apisdk.Type{ - BoolAttribute: tfModel.BoolAttribute.ValueBoolPointer(), - Float64Attribute: tfModel.Float64Attribute.ValueFloat64Pointer(), - Int64Attribute: tfModel.Int64Attribute.ValueInt64Pointer(), - NumberAttribute: tfModel.NumberAttribute.ValueBigFloat(), - StringAttribute: tfModel.StringAttribute.ValueStringPointer(), - } - - return apiObject, diags -} - -func FromSingleNestedBlockAssocExtType(ctx context.Context, apiObject *apisdk.Type) (types.Object, diag.Diagnostics) { - var diags diag.Diagnostics - var tfModel SingleNestedBlockAssocExtTypeModel - - if apiObject == nil { - return tfModel.ObjectNull(ctx), diags - } - - tfModel.BoolAttribute = types.BoolPointerValue(apiObject.BoolAttribute) - tfModel.Float64Attribute = types.Float64PointerValue(apiObject.Float64Attribute) - tfModel.Int64Attribute = types.Int64PointerValue(apiObject.Int64Attribute) - tfModel.NumberAttribute = types.NumberValue(apiObject.NumberAttribute) - tfModel.StringAttribute = types.StringPointerValue(apiObject.StringAttribute) - - return tfModel.ObjectValueFrom(ctx, tfModel) -} diff --git a/internal/cmd/testdata/custom_and_external/all_output/resource_resource_gen.go b/internal/cmd/testdata/custom_and_external/all_output/resource_resource_gen.go deleted file mode 100644 index dfbc4e7c..00000000 --- a/internal/cmd/testdata/custom_and_external/all_output/resource_resource_gen.go +++ /dev/null @@ -1,1020 +0,0 @@ -// Code generated by terraform-plugin-framework-generator DO NOT EDIT. - -package generated - -import ( - "context" - "example.com/apisdk" - "github.com/hashicorp/terraform-plugin-framework/attr" - "github.com/hashicorp/terraform-plugin-framework/diag" - "github.com/hashicorp/terraform-plugin-framework/resource/schema" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/booldefault" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" - "github.com/hashicorp/terraform-plugin-framework/schema/validator" - "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/hashicorp/terraform-plugin-framework/types/basetypes" - planmodifieralias "github.com/my_account/my_project/myboolplanmodifier" - validatoralias "github.com/my_account/my_project/myboolvalidator" - boolalias "github.com/my_account_my_project/bool" -) - -var resourceResourceSchema = schema.Schema{ - Attributes: map[string]schema.Attribute{ - "bool_attribute": schema.BoolAttribute{ - CustomType: my_bool_type, - Computed: true, - PlanModifiers: []planmodifier.Bool{ - myboolplanmodifier.Modify(), - }, - Validators: []validator.Bool{ - myboolvalidator.Validate(), - }, - Default: booldefault.StaticBool(true), - }, - "list_nested_attribute_assoc_ext_type": schema.ListNestedAttribute{ - NestedObject: schema.NestedAttributeObject{ - Attributes: map[string]schema.Attribute{ - "bool_attribute": schema.BoolAttribute{ - Optional: true, - }, - "float64_attribute": schema.Float64Attribute{ - Optional: true, - }, - "int64_attribute": schema.Int64Attribute{ - Optional: true, - }, - "number_attribute": schema.NumberAttribute{ - Optional: true, - }, - "string_attribute": schema.StringAttribute{ - Optional: true, - }, - }, - }, - Optional: true, - }, - "map_nested_attribute_assoc_ext_type": schema.MapNestedAttribute{ - NestedObject: schema.NestedAttributeObject{ - Attributes: map[string]schema.Attribute{ - "bool_attribute": schema.BoolAttribute{ - Optional: true, - }, - "float64_attribute": schema.Float64Attribute{ - Optional: true, - }, - "int64_attribute": schema.Int64Attribute{ - Optional: true, - }, - "number_attribute": schema.NumberAttribute{ - Optional: true, - }, - "string_attribute": schema.StringAttribute{ - Optional: true, - }, - }, - }, - Optional: true, - }, - "set_nested_attribute_assoc_ext_type": schema.SetNestedAttribute{ - NestedObject: schema.NestedAttributeObject{ - Attributes: map[string]schema.Attribute{ - "bool_attribute": schema.BoolAttribute{ - Optional: true, - }, - "float64_attribute": schema.Float64Attribute{ - Optional: true, - }, - "int64_attribute": schema.Int64Attribute{ - Optional: true, - }, - "number_attribute": schema.NumberAttribute{ - Optional: true, - }, - "string_attribute": schema.StringAttribute{ - Optional: true, - }, - }, - }, - Optional: true, - }, - "single_nested_attribute_assoc_ext_type": schema.SingleNestedAttribute{ - Attributes: map[string]schema.Attribute{ - "bool_attribute": schema.BoolAttribute{ - Optional: true, - }, - "float64_attribute": schema.Float64Attribute{ - Optional: true, - }, - "int64_attribute": schema.Int64Attribute{ - Optional: true, - }, - "number_attribute": schema.NumberAttribute{ - Optional: true, - }, - "string_attribute": schema.StringAttribute{ - Optional: true, - }, - }, - Optional: true, - }, - }, - Blocks: map[string]schema.Block{ - "list_nested_block_assoc_ext_type": schema.ListNestedBlock{ - NestedObject: schema.NestedBlockObject{ - Attributes: map[string]schema.Attribute{ - "bool_attribute": schema.BoolAttribute{ - Optional: true, - }, - "float64_attribute": schema.Float64Attribute{ - Optional: true, - }, - "int64_attribute": schema.Int64Attribute{ - Optional: true, - }, - "number_attribute": schema.NumberAttribute{ - Optional: true, - }, - "string_attribute": schema.StringAttribute{ - Optional: true, - }, - }, - }, - }, - "set_nested_block_assoc_ext_type": schema.SetNestedBlock{ - NestedObject: schema.NestedBlockObject{ - Attributes: map[string]schema.Attribute{ - "bool_attribute": schema.BoolAttribute{ - Optional: true, - }, - "float64_attribute": schema.Float64Attribute{ - Optional: true, - }, - "int64_attribute": schema.Int64Attribute{ - Optional: true, - }, - "number_attribute": schema.NumberAttribute{ - Optional: true, - }, - "string_attribute": schema.StringAttribute{ - Optional: true, - }, - }, - }, - }, - "single_nested_block_assoc_ext_type": schema.SingleNestedBlock{ - Attributes: map[string]schema.Attribute{ - "bool_attribute": schema.BoolAttribute{ - Optional: true, - }, - "float64_attribute": schema.Float64Attribute{ - Optional: true, - }, - "int64_attribute": schema.Int64Attribute{ - Optional: true, - }, - "number_attribute": schema.NumberAttribute{ - Optional: true, - }, - "string_attribute": schema.StringAttribute{ - Optional: true, - }, - }, - }, - }, -} - -type ResourceModel struct { - BoolAttribute my_bool_value `tfsdk:"bool_attribute"` - ListNestedAttributeAssocExtType types.List `tfsdk:"list_nested_attribute_assoc_ext_type"` - MapNestedAttributeAssocExtType types.Map `tfsdk:"map_nested_attribute_assoc_ext_type"` - SetNestedAttributeAssocExtType types.Set `tfsdk:"set_nested_attribute_assoc_ext_type"` - SingleNestedAttributeAssocExtType types.Object `tfsdk:"single_nested_attribute_assoc_ext_type"` - ListNestedBlockAssocExtType types.List `tfsdk:"list_nested_block_assoc_ext_type"` - SetNestedBlockAssocExtType types.Set `tfsdk:"set_nested_block_assoc_ext_type"` - SingleNestedBlockAssocExtType types.Object `tfsdk:"single_nested_block_assoc_ext_type"` -} - -type ListNestedAttributeAssocExtTypeModel struct { - BoolAttribute types.Bool `tfsdk:"bool_attribute"` - Float64Attribute types.Float64 `tfsdk:"float64_attribute"` - Int64Attribute types.Int64 `tfsdk:"int64_attribute"` - NumberAttribute types.Number `tfsdk:"number_attribute"` - StringAttribute types.String `tfsdk:"string_attribute"` -} - -type MapNestedAttributeAssocExtTypeModel struct { - BoolAttribute types.Bool `tfsdk:"bool_attribute"` - Float64Attribute types.Float64 `tfsdk:"float64_attribute"` - Int64Attribute types.Int64 `tfsdk:"int64_attribute"` - NumberAttribute types.Number `tfsdk:"number_attribute"` - StringAttribute types.String `tfsdk:"string_attribute"` -} - -type SetNestedAttributeAssocExtTypeModel struct { - BoolAttribute types.Bool `tfsdk:"bool_attribute"` - Float64Attribute types.Float64 `tfsdk:"float64_attribute"` - Int64Attribute types.Int64 `tfsdk:"int64_attribute"` - NumberAttribute types.Number `tfsdk:"number_attribute"` - StringAttribute types.String `tfsdk:"string_attribute"` -} - -type SingleNestedAttributeAssocExtTypeModel struct { - BoolAttribute types.Bool `tfsdk:"bool_attribute"` - Float64Attribute types.Float64 `tfsdk:"float64_attribute"` - Int64Attribute types.Int64 `tfsdk:"int64_attribute"` - NumberAttribute types.Number `tfsdk:"number_attribute"` - StringAttribute types.String `tfsdk:"string_attribute"` -} - -type ListNestedBlockAssocExtTypeModel struct { - BoolAttribute types.Bool `tfsdk:"bool_attribute"` - Float64Attribute types.Float64 `tfsdk:"float64_attribute"` - Int64Attribute types.Int64 `tfsdk:"int64_attribute"` - NumberAttribute types.Number `tfsdk:"number_attribute"` - StringAttribute types.String `tfsdk:"string_attribute"` -} - -type SetNestedBlockAssocExtTypeModel struct { - BoolAttribute types.Bool `tfsdk:"bool_attribute"` - Float64Attribute types.Float64 `tfsdk:"float64_attribute"` - Int64Attribute types.Int64 `tfsdk:"int64_attribute"` - NumberAttribute types.Number `tfsdk:"number_attribute"` - StringAttribute types.String `tfsdk:"string_attribute"` -} - -type SingleNestedBlockAssocExtTypeModel struct { - BoolAttribute types.Bool `tfsdk:"bool_attribute"` - Float64Attribute types.Float64 `tfsdk:"float64_attribute"` - Int64Attribute types.Int64 `tfsdk:"int64_attribute"` - NumberAttribute types.Number `tfsdk:"number_attribute"` - StringAttribute types.String `tfsdk:"string_attribute"` -} - -func (m ListNestedAttributeAssocExtTypeModel) ObjectType(ctx context.Context) types.ObjectType { - return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} -} - -func (m ListNestedAttributeAssocExtTypeModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { - return map[string]attr.Type{ - "bool_attribute": types.BoolType, - "float64_attribute": types.Float64Type, - "int64_attribute": types.Int64Type, - "number_attribute": types.NumberType, - "string_attribute": types.StringType, - } -} - -func (m ListNestedAttributeAssocExtTypeModel) ObjectNull(ctx context.Context) types.Object { - return types.ObjectNull( - m.ObjectAttributeTypes(ctx), - ) -} - -func (m ListNestedAttributeAssocExtTypeModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { - return types.ObjectValueFrom( - ctx, - m.ObjectAttributeTypes(ctx), - data, - ) -} -func (m MapNestedAttributeAssocExtTypeModel) ObjectType(ctx context.Context) types.ObjectType { - return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} -} - -func (m MapNestedAttributeAssocExtTypeModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { - return map[string]attr.Type{ - "bool_attribute": types.BoolType, - "float64_attribute": types.Float64Type, - "int64_attribute": types.Int64Type, - "number_attribute": types.NumberType, - "string_attribute": types.StringType, - } -} - -func (m MapNestedAttributeAssocExtTypeModel) ObjectNull(ctx context.Context) types.Object { - return types.ObjectNull( - m.ObjectAttributeTypes(ctx), - ) -} - -func (m MapNestedAttributeAssocExtTypeModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { - return types.ObjectValueFrom( - ctx, - m.ObjectAttributeTypes(ctx), - data, - ) -} -func (m SetNestedAttributeAssocExtTypeModel) ObjectType(ctx context.Context) types.ObjectType { - return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} -} - -func (m SetNestedAttributeAssocExtTypeModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { - return map[string]attr.Type{ - "bool_attribute": types.BoolType, - "float64_attribute": types.Float64Type, - "int64_attribute": types.Int64Type, - "number_attribute": types.NumberType, - "string_attribute": types.StringType, - } -} - -func (m SetNestedAttributeAssocExtTypeModel) ObjectNull(ctx context.Context) types.Object { - return types.ObjectNull( - m.ObjectAttributeTypes(ctx), - ) -} - -func (m SetNestedAttributeAssocExtTypeModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { - return types.ObjectValueFrom( - ctx, - m.ObjectAttributeTypes(ctx), - data, - ) -} -func (m SingleNestedAttributeAssocExtTypeModel) ObjectType(ctx context.Context) types.ObjectType { - return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} -} - -func (m SingleNestedAttributeAssocExtTypeModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { - return map[string]attr.Type{ - "bool_attribute": types.BoolType, - "float64_attribute": types.Float64Type, - "int64_attribute": types.Int64Type, - "number_attribute": types.NumberType, - "string_attribute": types.StringType, - } -} - -func (m SingleNestedAttributeAssocExtTypeModel) ObjectNull(ctx context.Context) types.Object { - return types.ObjectNull( - m.ObjectAttributeTypes(ctx), - ) -} - -func (m SingleNestedAttributeAssocExtTypeModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { - return types.ObjectValueFrom( - ctx, - m.ObjectAttributeTypes(ctx), - data, - ) -} -func (m ListNestedBlockAssocExtTypeModel) ObjectType(ctx context.Context) types.ObjectType { - return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} -} - -func (m ListNestedBlockAssocExtTypeModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { - return map[string]attr.Type{ - "bool_attribute": types.BoolType, - "float64_attribute": types.Float64Type, - "int64_attribute": types.Int64Type, - "number_attribute": types.NumberType, - "string_attribute": types.StringType, - } -} - -func (m ListNestedBlockAssocExtTypeModel) ObjectNull(ctx context.Context) types.Object { - return types.ObjectNull( - m.ObjectAttributeTypes(ctx), - ) -} - -func (m ListNestedBlockAssocExtTypeModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { - return types.ObjectValueFrom( - ctx, - m.ObjectAttributeTypes(ctx), - data, - ) -} -func (m SetNestedBlockAssocExtTypeModel) ObjectType(ctx context.Context) types.ObjectType { - return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} -} - -func (m SetNestedBlockAssocExtTypeModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { - return map[string]attr.Type{ - "bool_attribute": types.BoolType, - "float64_attribute": types.Float64Type, - "int64_attribute": types.Int64Type, - "number_attribute": types.NumberType, - "string_attribute": types.StringType, - } -} - -func (m SetNestedBlockAssocExtTypeModel) ObjectNull(ctx context.Context) types.Object { - return types.ObjectNull( - m.ObjectAttributeTypes(ctx), - ) -} - -func (m SetNestedBlockAssocExtTypeModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { - return types.ObjectValueFrom( - ctx, - m.ObjectAttributeTypes(ctx), - data, - ) -} -func (m SingleNestedBlockAssocExtTypeModel) ObjectType(ctx context.Context) types.ObjectType { - return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} -} - -func (m SingleNestedBlockAssocExtTypeModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { - return map[string]attr.Type{ - "bool_attribute": types.BoolType, - "float64_attribute": types.Float64Type, - "int64_attribute": types.Int64Type, - "number_attribute": types.NumberType, - "string_attribute": types.StringType, - } -} - -func (m SingleNestedBlockAssocExtTypeModel) ObjectNull(ctx context.Context) types.Object { - return types.ObjectNull( - m.ObjectAttributeTypes(ctx), - ) -} - -func (m SingleNestedBlockAssocExtTypeModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { - return types.ObjectValueFrom( - ctx, - m.ObjectAttributeTypes(ctx), - data, - ) -} - -func ToListNestedAttributeAssocExtType(ctx context.Context, tfList types.List) ([]*apisdk.Type, diag.Diagnostics) { - var diags diag.Diagnostics - - if tfList.IsNull() { - return nil, diags - } - - if tfList.IsUnknown() { - diags.Append(diag.NewErrorDiagnostic( - "List Value Is Unknown", - `Model field "ListNestedAttributeAssocExtType" is unknown.`, - )) - - return nil, diags - } - - var listObjects []types.Object - - diags.Append(tfList.ElementsAs(ctx, &listObjects, false)...) - - if diags.HasError() { - return nil, diags - } - - apiObjects := make([]*apisdk.Type, 0, len(listObjects)) - - for _, listObject := range listObjects { - if listObject.IsNull() { - apiObjects = append(apiObjects, nil) - - continue - } - - if listObject.IsUnknown() { - diags.Append(diag.NewErrorDiagnostic( - "Object Value Within List Is Unknown", - `Model field "ListNestedAttributeAssocExtType" contains an object which is unknown.`, - )) - - return nil, diags - } - - var tfModel ListNestedAttributeAssocExtTypeModel - - d := listObject.As(ctx, &tfModel, basetypes.ObjectAsOptions{}) - - diags.Append(d...) - - if diags.HasError() { - return nil, diags - } - - apiObjects = append(apiObjects, &apisdk.Type{ - BoolAttribute: tfModel.BoolAttribute.ValueBoolPointer(), - Float64Attribute: tfModel.Float64Attribute.ValueFloat64Pointer(), - Int64Attribute: tfModel.Int64Attribute.ValueInt64Pointer(), - NumberAttribute: tfModel.NumberAttribute.ValueBigFloat(), - StringAttribute: tfModel.StringAttribute.ValueStringPointer(), - }) - } - - return apiObjects, diags -} - -func FromListNestedAttributeAssocExtType(ctx context.Context, apiObjects []*apisdk.Type) (types.List, diag.Diagnostics) { - var diags diag.Diagnostics - var tfModel ListNestedAttributeAssocExtTypeModel - - if apiObjects == nil { - return types.ListNull( - tfModel.ObjectType(ctx), - ), diags - } - - var tfModels []*ListNestedAttributeAssocExtTypeModel - - for _, apiObject := range apiObjects { - if apiObject == nil { - tfModels = append(tfModels, nil) - - continue - } - - tfModels = append(tfModels, &ListNestedAttributeAssocExtTypeModel{ - BoolAttribute: types.BoolPointerValue(apiObject.BoolAttribute), - Float64Attribute: types.Float64PointerValue(apiObject.Float64Attribute), - Int64Attribute: types.Int64PointerValue(apiObject.Int64Attribute), - NumberAttribute: types.NumberValue(apiObject.NumberAttribute), - StringAttribute: types.StringPointerValue(apiObject.StringAttribute), - }) - } - - return types.ListValueFrom(ctx, tfModel.ObjectType(ctx), tfModels) -} - -func ToMapNestedAttributeAssocExtType(ctx context.Context, tfMap types.Map) (map[string]*apisdk.Type, diag.Diagnostics) { - var diags diag.Diagnostics - - if tfMap.IsNull() { - return nil, diags - } - - if tfMap.IsUnknown() { - diags.Append(diag.NewErrorDiagnostic( - "Map Value Is Unknown", - `Model field "MapNestedAttributeAssocExtType" is unknown.`, - )) - - return nil, diags - } - - mapObjects := make(map[string]types.Object) - - diags.Append(tfMap.ElementsAs(ctx, &mapObjects, false)...) - - if diags.HasError() { - return nil, diags - } - - apiObjects := make(map[string]*apisdk.Type, len(mapObjects)) - - for k, mapObject := range mapObjects { - if mapObject.IsNull() { - apiObjects[k] = nil - - continue - } - - if mapObject.IsUnknown() { - diags.Append(diag.NewErrorDiagnostic( - "Object Value Within Map Is Unknown", - `Model field "MapNestedAttributeAssocExtType" contains an object which is unknown.`, - )) - - return nil, diags - } - - var tfModel MapNestedAttributeAssocExtTypeModel - - d := mapObject.As(ctx, &tfModel, basetypes.ObjectAsOptions{}) - - diags.Append(d...) - - if diags.HasError() { - return nil, diags - } - - apiObjects[k] = &apisdk.Type{ - BoolAttribute: tfModel.BoolAttribute.ValueBoolPointer(), - Float64Attribute: tfModel.Float64Attribute.ValueFloat64Pointer(), - Int64Attribute: tfModel.Int64Attribute.ValueInt64Pointer(), - NumberAttribute: tfModel.NumberAttribute.ValueBigFloat(), - StringAttribute: tfModel.StringAttribute.ValueStringPointer(), - } - } - - return apiObjects, diags -} - -func FromMapNestedAttributeAssocExtType(ctx context.Context, apiObjects map[string]*apisdk.Type) (types.Map, diag.Diagnostics) { - var diags diag.Diagnostics - var tfModel MapNestedAttributeAssocExtTypeModel - - if apiObjects == nil { - return types.MapNull( - tfModel.ObjectType(ctx), - ), diags - } - - tfModels := make(map[string]*MapNestedAttributeAssocExtTypeModel) - - for k, apiObject := range apiObjects { - if apiObject == nil { - tfModels[k] = nil - - continue - } - - tfModels[k] = &MapNestedAttributeAssocExtTypeModel{ - BoolAttribute: types.BoolPointerValue(apiObject.BoolAttribute), - Float64Attribute: types.Float64PointerValue(apiObject.Float64Attribute), - Int64Attribute: types.Int64PointerValue(apiObject.Int64Attribute), - NumberAttribute: types.NumberValue(apiObject.NumberAttribute), - StringAttribute: types.StringPointerValue(apiObject.StringAttribute), - } - } - - return types.MapValueFrom(ctx, tfModel.ObjectType(ctx), tfModels) -} - -func ToSetNestedAttributeAssocExtType(ctx context.Context, tfSet types.Set) ([]*apisdk.Type, diag.Diagnostics) { - var diags diag.Diagnostics - - if tfSet.IsNull() { - return nil, diags - } - - if tfSet.IsUnknown() { - diags.Append(diag.NewErrorDiagnostic( - "Set Value Is Unknown", - `Model field "SetNestedAttributeAssocExtType" is unknown.`, - )) - - return nil, diags - } - - var setObjects []types.Object - - diags.Append(tfSet.ElementsAs(ctx, &setObjects, false)...) - - if diags.HasError() { - return nil, diags - } - - apiObjects := make([]*apisdk.Type, 0, len(setObjects)) - - for _, setObject := range setObjects { - if setObject.IsNull() { - apiObjects = append(apiObjects, nil) - - continue - } - - if setObject.IsUnknown() { - diags.Append(diag.NewErrorDiagnostic( - "Object Value Within Set Is Unknown", - `Model field "SetNestedAttributeAssocExtType" contains an object which is unknown.`, - )) - - return nil, diags - } - - var tfModel SetNestedAttributeAssocExtTypeModel - - d := setObject.As(ctx, &tfModel, basetypes.ObjectAsOptions{}) - - diags.Append(d...) - - if diags.HasError() { - return nil, diags - } - - apiObjects = append(apiObjects, &apisdk.Type{ - BoolAttribute: tfModel.BoolAttribute.ValueBoolPointer(), - Float64Attribute: tfModel.Float64Attribute.ValueFloat64Pointer(), - Int64Attribute: tfModel.Int64Attribute.ValueInt64Pointer(), - NumberAttribute: tfModel.NumberAttribute.ValueBigFloat(), - StringAttribute: tfModel.StringAttribute.ValueStringPointer(), - }) - } - - return apiObjects, diags -} - -func FromSetNestedAttributeAssocExtType(ctx context.Context, apiObjects []*apisdk.Type) (types.Set, diag.Diagnostics) { - var diags diag.Diagnostics - var tfModel SetNestedAttributeAssocExtTypeModel - - if apiObjects == nil { - return types.SetNull( - tfModel.ObjectType(ctx), - ), diags - } - - var tfModels []*SetNestedAttributeAssocExtTypeModel - - for _, apiObject := range apiObjects { - if apiObject == nil { - tfModels = append(tfModels, nil) - - continue - } - - tfModels = append(tfModels, &SetNestedAttributeAssocExtTypeModel{ - BoolAttribute: types.BoolPointerValue(apiObject.BoolAttribute), - Float64Attribute: types.Float64PointerValue(apiObject.Float64Attribute), - Int64Attribute: types.Int64PointerValue(apiObject.Int64Attribute), - NumberAttribute: types.NumberValue(apiObject.NumberAttribute), - StringAttribute: types.StringPointerValue(apiObject.StringAttribute), - }) - } - - return types.SetValueFrom(ctx, tfModel.ObjectType(ctx), tfModels) -} - -func ToSingleNestedAttributeAssocExtType(ctx context.Context, tfObject types.Object) (*apisdk.Type, diag.Diagnostics) { - var diags diag.Diagnostics - - if tfObject.IsNull() { - return nil, diags - } - - if tfObject.IsUnknown() { - diags.Append(diag.NewErrorDiagnostic( - "Object Value Is Unknown", - `Model field "SingleNestedAttributeAssocExtType" is unknown.`, - )) - - return nil, diags - } - - var tfModel SingleNestedAttributeAssocExtTypeModel - - diags.Append(tfObject.As(ctx, &tfModel, basetypes.ObjectAsOptions{})...) - - if diags.HasError() { - return nil, diags - } - - apiObject := &apisdk.Type{ - BoolAttribute: tfModel.BoolAttribute.ValueBoolPointer(), - Float64Attribute: tfModel.Float64Attribute.ValueFloat64Pointer(), - Int64Attribute: tfModel.Int64Attribute.ValueInt64Pointer(), - NumberAttribute: tfModel.NumberAttribute.ValueBigFloat(), - StringAttribute: tfModel.StringAttribute.ValueStringPointer(), - } - - return apiObject, diags -} - -func FromSingleNestedAttributeAssocExtType(ctx context.Context, apiObject *apisdk.Type) (types.Object, diag.Diagnostics) { - var diags diag.Diagnostics - var tfModel SingleNestedAttributeAssocExtTypeModel - - if apiObject == nil { - return tfModel.ObjectNull(ctx), diags - } - - tfModel.BoolAttribute = types.BoolPointerValue(apiObject.BoolAttribute) - tfModel.Float64Attribute = types.Float64PointerValue(apiObject.Float64Attribute) - tfModel.Int64Attribute = types.Int64PointerValue(apiObject.Int64Attribute) - tfModel.NumberAttribute = types.NumberValue(apiObject.NumberAttribute) - tfModel.StringAttribute = types.StringPointerValue(apiObject.StringAttribute) - - return tfModel.ObjectValueFrom(ctx, tfModel) -} - -func ToListNestedBlockAssocExtType(ctx context.Context, tfList types.List) ([]*apisdk.Type, diag.Diagnostics) { - var diags diag.Diagnostics - - if tfList.IsNull() { - return nil, diags - } - - if tfList.IsUnknown() { - diags.Append(diag.NewErrorDiagnostic( - "List Value Is Unknown", - `Model field "ListNestedBlockAssocExtType" is unknown.`, - )) - - return nil, diags - } - - var listObjects []types.Object - - diags.Append(tfList.ElementsAs(ctx, &listObjects, false)...) - - if diags.HasError() { - return nil, diags - } - - apiObjects := make([]*apisdk.Type, 0, len(listObjects)) - - for _, listObject := range listObjects { - if listObject.IsNull() { - apiObjects = append(apiObjects, nil) - - continue - } - - if listObject.IsUnknown() { - diags.Append(diag.NewErrorDiagnostic( - "Object Value Within List Is Unknown", - `Model field "ListNestedBlockAssocExtType" contains an object which is unknown.`, - )) - - return nil, diags - } - - var tfModel ListNestedBlockAssocExtTypeModel - - d := listObject.As(ctx, &tfModel, basetypes.ObjectAsOptions{}) - - diags.Append(d...) - - if diags.HasError() { - return nil, diags - } - - apiObjects = append(apiObjects, &apisdk.Type{ - BoolAttribute: tfModel.BoolAttribute.ValueBoolPointer(), - Float64Attribute: tfModel.Float64Attribute.ValueFloat64Pointer(), - Int64Attribute: tfModel.Int64Attribute.ValueInt64Pointer(), - NumberAttribute: tfModel.NumberAttribute.ValueBigFloat(), - StringAttribute: tfModel.StringAttribute.ValueStringPointer(), - }) - } - - return apiObjects, diags -} - -func FromListNestedBlockAssocExtType(ctx context.Context, apiObjects []*apisdk.Type) (types.List, diag.Diagnostics) { - var diags diag.Diagnostics - var tfModel ListNestedBlockAssocExtTypeModel - - if apiObjects == nil { - return types.ListNull( - tfModel.ObjectType(ctx), - ), diags - } - - var tfModels []*ListNestedBlockAssocExtTypeModel - - for _, apiObject := range apiObjects { - if apiObject == nil { - tfModels = append(tfModels, nil) - - continue - } - - tfModels = append(tfModels, &ListNestedBlockAssocExtTypeModel{ - BoolAttribute: types.BoolPointerValue(apiObject.BoolAttribute), - Float64Attribute: types.Float64PointerValue(apiObject.Float64Attribute), - Int64Attribute: types.Int64PointerValue(apiObject.Int64Attribute), - NumberAttribute: types.NumberValue(apiObject.NumberAttribute), - StringAttribute: types.StringPointerValue(apiObject.StringAttribute), - }) - } - - return types.ListValueFrom(ctx, tfModel.ObjectType(ctx), tfModels) -} - -func ToSetNestedBlockAssocExtType(ctx context.Context, tfSet types.Set) ([]*apisdk.Type, diag.Diagnostics) { - var diags diag.Diagnostics - - if tfSet.IsNull() { - return nil, diags - } - - if tfSet.IsUnknown() { - diags.Append(diag.NewErrorDiagnostic( - "Set Value Is Unknown", - `Model field "SetNestedBlockAssocExtType" is unknown.`, - )) - - return nil, diags - } - - var setObjects []types.Object - - diags.Append(tfSet.ElementsAs(ctx, &setObjects, false)...) - - if diags.HasError() { - return nil, diags - } - - apiObjects := make([]*apisdk.Type, 0, len(setObjects)) - - for _, setObject := range setObjects { - if setObject.IsNull() { - apiObjects = append(apiObjects, nil) - - continue - } - - if setObject.IsUnknown() { - diags.Append(diag.NewErrorDiagnostic( - "Object Value Within Set Is Unknown", - `Model field "SetNestedBlockAssocExtType" contains an object which is unknown.`, - )) - - return nil, diags - } - - var tfModel SetNestedBlockAssocExtTypeModel - - d := setObject.As(ctx, &tfModel, basetypes.ObjectAsOptions{}) - - diags.Append(d...) - - if diags.HasError() { - return nil, diags - } - - apiObjects = append(apiObjects, &apisdk.Type{ - BoolAttribute: tfModel.BoolAttribute.ValueBoolPointer(), - Float64Attribute: tfModel.Float64Attribute.ValueFloat64Pointer(), - Int64Attribute: tfModel.Int64Attribute.ValueInt64Pointer(), - NumberAttribute: tfModel.NumberAttribute.ValueBigFloat(), - StringAttribute: tfModel.StringAttribute.ValueStringPointer(), - }) - } - - return apiObjects, diags -} - -func FromSetNestedBlockAssocExtType(ctx context.Context, apiObjects []*apisdk.Type) (types.Set, diag.Diagnostics) { - var diags diag.Diagnostics - var tfModel SetNestedBlockAssocExtTypeModel - - if apiObjects == nil { - return types.SetNull( - tfModel.ObjectType(ctx), - ), diags - } - - var tfModels []*SetNestedBlockAssocExtTypeModel - - for _, apiObject := range apiObjects { - if apiObject == nil { - tfModels = append(tfModels, nil) - - continue - } - - tfModels = append(tfModels, &SetNestedBlockAssocExtTypeModel{ - BoolAttribute: types.BoolPointerValue(apiObject.BoolAttribute), - Float64Attribute: types.Float64PointerValue(apiObject.Float64Attribute), - Int64Attribute: types.Int64PointerValue(apiObject.Int64Attribute), - NumberAttribute: types.NumberValue(apiObject.NumberAttribute), - StringAttribute: types.StringPointerValue(apiObject.StringAttribute), - }) - } - - return types.SetValueFrom(ctx, tfModel.ObjectType(ctx), tfModels) -} - -func ToSingleNestedBlockAssocExtType(ctx context.Context, tfObject types.Object) (*apisdk.Type, diag.Diagnostics) { - var diags diag.Diagnostics - - if tfObject.IsNull() { - return nil, diags - } - - if tfObject.IsUnknown() { - diags.Append(diag.NewErrorDiagnostic( - "Object Value Is Unknown", - `Model field "SingleNestedBlockAssocExtType" is unknown.`, - )) - - return nil, diags - } - - var tfModel SingleNestedBlockAssocExtTypeModel - - diags.Append(tfObject.As(ctx, &tfModel, basetypes.ObjectAsOptions{})...) - - if diags.HasError() { - return nil, diags - } - - apiObject := &apisdk.Type{ - BoolAttribute: tfModel.BoolAttribute.ValueBoolPointer(), - Float64Attribute: tfModel.Float64Attribute.ValueFloat64Pointer(), - Int64Attribute: tfModel.Int64Attribute.ValueInt64Pointer(), - NumberAttribute: tfModel.NumberAttribute.ValueBigFloat(), - StringAttribute: tfModel.StringAttribute.ValueStringPointer(), - } - - return apiObject, diags -} - -func FromSingleNestedBlockAssocExtType(ctx context.Context, apiObject *apisdk.Type) (types.Object, diag.Diagnostics) { - var diags diag.Diagnostics - var tfModel SingleNestedBlockAssocExtTypeModel - - if apiObject == nil { - return tfModel.ObjectNull(ctx), diags - } - - tfModel.BoolAttribute = types.BoolPointerValue(apiObject.BoolAttribute) - tfModel.Float64Attribute = types.Float64PointerValue(apiObject.Float64Attribute) - tfModel.Int64Attribute = types.Int64PointerValue(apiObject.Int64Attribute) - tfModel.NumberAttribute = types.NumberValue(apiObject.NumberAttribute) - tfModel.StringAttribute = types.StringPointerValue(apiObject.StringAttribute) - - return tfModel.ObjectValueFrom(ctx, tfModel) -} diff --git a/internal/schema/schemas.go b/internal/schema/schemas.go index 1ceeff81..7ab8c34e 100644 --- a/internal/schema/schemas.go +++ b/internal/schema/schemas.go @@ -23,6 +23,10 @@ func (g GeneratorSchemas) SchemasBytes(packageName, generatorType string) (map[s for k, s := range g.schemas { + if packageName == "" { + packageName = k + } + b, err := s.SchemaBytes(k, packageName, generatorType) if err != nil { From 5cc4e99924ec1f39b7549ea2185ea8cf769f9bf6 Mon Sep 17 00:00:00 2001 From: Benjamin Bennett Date: Mon, 4 Sep 2023 14:09:31 +0100 Subject: [PATCH 2/6] Adding test coverage to verify package name can be overridden by supplying --package flag (#20) --- Makefile | 8 +- internal/cmd/generate_all_test.go | 15 +- .../datasource_data_source_gen.go | 1863 +++++++++++++++++ .../default_pkg_name/provider_provider_gen.go | 1002 +++++++++ .../default_pkg_name/resource_resource_gen.go | 1020 +++++++++ .../datasource_data_source_gen.go | 1863 +++++++++++++++++ .../provider_provider_gen.go | 1002 +++++++++ .../resource_resource_gen.go | 1020 +++++++++ 8 files changed, 7787 insertions(+), 6 deletions(-) create mode 100644 internal/cmd/testdata/custom_and_external/all_output/default_pkg_name/datasource_data_source_gen.go create mode 100644 internal/cmd/testdata/custom_and_external/all_output/default_pkg_name/provider_provider_gen.go create mode 100644 internal/cmd/testdata/custom_and_external/all_output/default_pkg_name/resource_resource_gen.go create mode 100644 internal/cmd/testdata/custom_and_external/all_output/specified_pkg_name/datasource_data_source_gen.go create mode 100644 internal/cmd/testdata/custom_and_external/all_output/specified_pkg_name/provider_provider_gen.go create mode 100644 internal/cmd/testdata/custom_and_external/all_output/specified_pkg_name/resource_resource_gen.go diff --git a/Makefile b/Makefile index cc026914..796698e3 100644 --- a/Makefile +++ b/Makefile @@ -18,8 +18,12 @@ generate: testdata: go run ./cmd/terraform-plugin-codegen-framework generate all \ --input ./internal/cmd/testdata/custom_and_external/ir.json \ - --package generated \ - --output ./internal/cmd/testdata/custom_and_external/all_output + --package specified \ + --output ./internal/cmd/testdata/custom_and_external/all_output/specified_pkg_name + + go run ./cmd/terraform-plugin-codegen-framework generate all \ + --input ./internal/cmd/testdata/custom_and_external/ir.json \ + --output ./internal/cmd/testdata/custom_and_external/all_output/default_pkg_name go run ./cmd/terraform-plugin-codegen-framework generate resources \ --input ./internal/cmd/testdata/custom_and_external/ir.json \ diff --git a/internal/cmd/generate_all_test.go b/internal/cmd/generate_all_test.go index 5693a0a9..03dc7938 100644 --- a/internal/cmd/generate_all_test.go +++ b/internal/cmd/generate_all_test.go @@ -6,8 +6,9 @@ package cmd_test import ( "testing" - "github.com/hashicorp/terraform-plugin-codegen-framework/internal/cmd" "github.com/mitchellh/cli" + + "github.com/hashicorp/terraform-plugin-codegen-framework/internal/cmd" ) func TestGenerateAllCommand(t *testing.T) { @@ -15,11 +16,17 @@ func TestGenerateAllCommand(t *testing.T) { testCases := map[string]struct { irInputPath string + pkgName string goldenFileDir string }{ - "custom_and_external": { + "specified_pkg_name": { + irInputPath: "testdata/custom_and_external/ir.json", + pkgName: "specified", + goldenFileDir: "testdata/custom_and_external/all_output/specified_pkg_name", + }, + "default_pkg_name": { irInputPath: "testdata/custom_and_external/ir.json", - goldenFileDir: "testdata/custom_and_external/all_output", + goldenFileDir: "testdata/custom_and_external/all_output/default_pkg_name", }, } for name, testCase := range testCases { @@ -35,7 +42,7 @@ func TestGenerateAllCommand(t *testing.T) { args := []string{ "--input", testCase.irInputPath, - "--package", "generated", + "--package", testCase.pkgName, "--output", testOutputDir, } diff --git a/internal/cmd/testdata/custom_and_external/all_output/default_pkg_name/datasource_data_source_gen.go b/internal/cmd/testdata/custom_and_external/all_output/default_pkg_name/datasource_data_source_gen.go new file mode 100644 index 00000000..8c4942b9 --- /dev/null +++ b/internal/cmd/testdata/custom_and_external/all_output/default_pkg_name/datasource_data_source_gen.go @@ -0,0 +1,1863 @@ +// Code generated by terraform-plugin-framework-generator DO NOT EDIT. + +package datasource + +import ( + "context" + "example.com/apisdk" + "github.com/hashicorp/terraform-plugin-framework/attr" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-framework/types/basetypes" +) + +var datasourceDataSourceSchema = schema.Schema{ + Attributes: map[string]schema.Attribute{ + "bool_attribute": schema.BoolAttribute{ + Computed: true, + }, + "list_list_attribute": schema.ListAttribute{ + ElementType: types.ListType{ + ElemType: types.StringType, + }, + Computed: true, + }, + "list_map_attribute": schema.ListAttribute{ + ElementType: types.MapType{ + ElemType: types.StringType, + }, + Computed: true, + }, + "list_nested_attribute_assoc_ext_type": schema.ListNestedAttribute{ + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "bool_attribute": schema.BoolAttribute{ + Computed: true, + }, + "float64_attribute": schema.Float64Attribute{ + Optional: true, + Computed: true, + }, + "int64_attribute": schema.Int64Attribute{ + Optional: true, + Computed: true, + }, + "number_attribute": schema.NumberAttribute{ + Optional: true, + Computed: true, + }, + "string_attribute": schema.StringAttribute{ + Optional: true, + Computed: true, + }, + }, + }, + Optional: true, + }, + "list_nested_attribute_one": schema.ListNestedAttribute{ + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "bool_attribute": schema.BoolAttribute{ + Computed: true, + }, + }, + }, + Computed: true, + }, + "list_nested_attribute_three": schema.ListNestedAttribute{ + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "list_nested_attribute_three_list_nested_attribute_one": schema.ListNestedAttribute{ + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "list_attribute": schema.ListAttribute{ + ElementType: types.StringType, + Computed: true, + }, + }, + }, + Computed: true, + }, + }, + }, + Computed: true, + }, + "list_nested_attribute_two": schema.ListNestedAttribute{ + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "list_nested_attribute_two_list_nested_attribute_one": schema.ListNestedAttribute{ + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "bool_attribute": schema.BoolAttribute{ + Computed: true, + }, + }, + }, + Computed: true, + }, + }, + }, + Computed: true, + }, + "list_object_attribute": schema.ListAttribute{ + ElementType: types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "obj_string_attr": types.StringType, + }, + }, + Computed: true, + }, + "list_object_object_attribute": schema.ListAttribute{ + ElementType: types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "obj_obj_attr": types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "obj_obj_string_attr": types.StringType, + }, + }, + }, + }, + Computed: true, + }, + "map_nested_attribute_assoc_ext_type": schema.MapNestedAttribute{ + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "bool_attribute": schema.BoolAttribute{ + Computed: true, + }, + "float64_attribute": schema.Float64Attribute{ + Optional: true, + Computed: true, + }, + "int64_attribute": schema.Int64Attribute{ + Optional: true, + Computed: true, + }, + "number_attribute": schema.NumberAttribute{ + Optional: true, + Computed: true, + }, + "string_attribute": schema.StringAttribute{ + Optional: true, + Computed: true, + }, + }, + }, + Optional: true, + }, + "object_attribute": schema.ObjectAttribute{ + AttributeTypes: map[string]attr.Type{ + "obj_string_attr": types.StringType, + }, + Computed: true, + }, + "object_list_attribute": schema.ObjectAttribute{ + AttributeTypes: map[string]attr.Type{ + "obj_list_attr": types.ListType{ + ElemType: types.StringType, + }, + }, + Computed: true, + }, + "object_list_object_attribute": schema.ObjectAttribute{ + AttributeTypes: map[string]attr.Type{ + "obj_list_attr": types.ListType{ + ElemType: types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "obj_list_obj_attr": types.StringType, + }, + }, + }, + }, + Computed: true, + }, + "set_nested_attribute_assoc_ext_type": schema.SetNestedAttribute{ + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "bool_attribute": schema.BoolAttribute{ + Computed: true, + }, + "float64_attribute": schema.Float64Attribute{ + Optional: true, + Computed: true, + }, + "int64_attribute": schema.Int64Attribute{ + Optional: true, + Computed: true, + }, + "number_attribute": schema.NumberAttribute{ + Optional: true, + Computed: true, + }, + "string_attribute": schema.StringAttribute{ + Optional: true, + Computed: true, + }, + }, + }, + Optional: true, + }, + "single_nested_attribute_assoc_ext_type": schema.SingleNestedAttribute{ + Attributes: map[string]schema.Attribute{ + "bool_attribute": schema.BoolAttribute{ + Computed: true, + }, + "float64_attribute": schema.Float64Attribute{ + Optional: true, + Computed: true, + }, + "int64_attribute": schema.Int64Attribute{ + Optional: true, + Computed: true, + }, + "number_attribute": schema.NumberAttribute{ + Optional: true, + Computed: true, + }, + "string_attribute": schema.StringAttribute{ + Optional: true, + Computed: true, + }, + }, + Optional: true, + }, + "single_nested_attribute_one": schema.SingleNestedAttribute{ + Attributes: map[string]schema.Attribute{ + "bool_attribute": schema.BoolAttribute{ + Computed: true, + }, + }, + Computed: true, + }, + "single_nested_attribute_three": schema.SingleNestedAttribute{ + Attributes: map[string]schema.Attribute{ + "single_nested_attribute_three_single_nested_attribute_one": schema.SingleNestedAttribute{ + Attributes: map[string]schema.Attribute{ + "list_attribute": schema.ListAttribute{ + ElementType: types.StringType, + Computed: true, + }, + }, + Computed: true, + }, + }, + Computed: true, + }, + "single_nested_attribute_two": schema.SingleNestedAttribute{ + Attributes: map[string]schema.Attribute{ + "single_nested_attribute_two_single_nested_attribute_one": schema.SingleNestedAttribute{ + Attributes: map[string]schema.Attribute{ + "bool_attribute": schema.BoolAttribute{ + Computed: true, + }, + }, + Computed: true, + }, + }, + Computed: true, + }, + }, + Blocks: map[string]schema.Block{ + "list_nested_block_assoc_ext_type": schema.ListNestedBlock{ + NestedObject: schema.NestedBlockObject{ + Attributes: map[string]schema.Attribute{ + "bool_attribute": schema.BoolAttribute{ + Computed: true, + }, + "float64_attribute": schema.Float64Attribute{ + Optional: true, + Computed: true, + }, + "int64_attribute": schema.Int64Attribute{ + Optional: true, + Computed: true, + }, + "number_attribute": schema.NumberAttribute{ + Optional: true, + Computed: true, + }, + "string_attribute": schema.StringAttribute{ + Optional: true, + Computed: true, + }, + }, + }, + }, + "list_nested_block_one": schema.ListNestedBlock{ + NestedObject: schema.NestedBlockObject{ + Attributes: map[string]schema.Attribute{ + "bool_attribute": schema.BoolAttribute{ + Computed: true, + }, + }, + }, + }, + "list_nested_block_three": schema.ListNestedBlock{ + NestedObject: schema.NestedBlockObject{ + Attributes: map[string]schema.Attribute{ + "object_attribute": schema.ObjectAttribute{ + AttributeTypes: map[string]attr.Type{ + "string_attribute_type": types.StringType, + }, + Computed: true, + }, + }, + Blocks: map[string]schema.Block{ + "list_nested_block_three_list_nested_block_one": schema.ListNestedBlock{ + NestedObject: schema.NestedBlockObject{ + Attributes: map[string]schema.Attribute{ + "list_attribute": schema.ListAttribute{ + ElementType: types.StringType, + Computed: true, + }, + }, + }, + }, + }, + }, + }, + "list_nested_block_two": schema.ListNestedBlock{ + NestedObject: schema.NestedBlockObject{ + Blocks: map[string]schema.Block{ + "list_nested_block_two_list_nested_block_one": schema.ListNestedBlock{ + NestedObject: schema.NestedBlockObject{ + Attributes: map[string]schema.Attribute{ + "bool_attribute": schema.BoolAttribute{ + Computed: true, + }, + }, + }, + }, + }, + }, + }, + "set_nested_block_assoc_ext_type": schema.SetNestedBlock{ + NestedObject: schema.NestedBlockObject{ + Attributes: map[string]schema.Attribute{ + "bool_attribute": schema.BoolAttribute{ + Computed: true, + }, + "float64_attribute": schema.Float64Attribute{ + Optional: true, + Computed: true, + }, + "int64_attribute": schema.Int64Attribute{ + Optional: true, + Computed: true, + }, + "number_attribute": schema.NumberAttribute{ + Optional: true, + Computed: true, + }, + "string_attribute": schema.StringAttribute{ + Optional: true, + Computed: true, + }, + }, + }, + }, + "single_nested_block_assoc_ext_type": schema.SingleNestedBlock{ + Attributes: map[string]schema.Attribute{ + "bool_attribute": schema.BoolAttribute{ + Computed: true, + }, + "float64_attribute": schema.Float64Attribute{ + Optional: true, + Computed: true, + }, + "int64_attribute": schema.Int64Attribute{ + Optional: true, + Computed: true, + }, + "number_attribute": schema.NumberAttribute{ + Optional: true, + Computed: true, + }, + "string_attribute": schema.StringAttribute{ + Optional: true, + Computed: true, + }, + }, + }, + "single_nested_block_one": schema.SingleNestedBlock{ + Attributes: map[string]schema.Attribute{ + "bool_attribute": schema.BoolAttribute{ + Computed: true, + }, + }, + }, + "single_nested_block_three": schema.SingleNestedBlock{ + Attributes: map[string]schema.Attribute{ + "object_attribute": schema.ObjectAttribute{ + AttributeTypes: map[string]attr.Type{ + "string_attribute_type": types.StringType, + }, + Computed: true, + }, + }, + Blocks: map[string]schema.Block{ + "single_nested_block_three_list_nested_block_one": schema.ListNestedBlock{ + NestedObject: schema.NestedBlockObject{ + Attributes: map[string]schema.Attribute{ + "list_attribute": schema.ListAttribute{ + ElementType: types.StringType, + Computed: true, + }, + }, + }, + }, + }, + }, + "single_nested_block_two": schema.SingleNestedBlock{ + Blocks: map[string]schema.Block{ + "single_nested_block_two_single_nested_block_one": schema.SingleNestedBlock{ + Attributes: map[string]schema.Attribute{ + "bool_attribute": schema.BoolAttribute{ + Computed: true, + }, + }, + }, + }, + }, + }, +} + +type DatasourceModel struct { + BoolAttribute types.Bool `tfsdk:"bool_attribute"` + ListListAttribute types.List `tfsdk:"list_list_attribute"` + ListMapAttribute types.List `tfsdk:"list_map_attribute"` + ListNestedAttributeAssocExtType types.List `tfsdk:"list_nested_attribute_assoc_ext_type"` + ListNestedAttributeOne types.List `tfsdk:"list_nested_attribute_one"` + ListNestedAttributeThree types.List `tfsdk:"list_nested_attribute_three"` + ListNestedAttributeTwo types.List `tfsdk:"list_nested_attribute_two"` + ListObjectAttribute types.List `tfsdk:"list_object_attribute"` + ListObjectObjectAttribute types.List `tfsdk:"list_object_object_attribute"` + MapNestedAttributeAssocExtType types.Map `tfsdk:"map_nested_attribute_assoc_ext_type"` + ObjectAttribute types.Object `tfsdk:"object_attribute"` + ObjectListAttribute types.Object `tfsdk:"object_list_attribute"` + ObjectListObjectAttribute types.Object `tfsdk:"object_list_object_attribute"` + SetNestedAttributeAssocExtType types.Set `tfsdk:"set_nested_attribute_assoc_ext_type"` + SingleNestedAttributeAssocExtType types.Object `tfsdk:"single_nested_attribute_assoc_ext_type"` + SingleNestedAttributeOne types.Object `tfsdk:"single_nested_attribute_one"` + SingleNestedAttributeThree types.Object `tfsdk:"single_nested_attribute_three"` + SingleNestedAttributeTwo types.Object `tfsdk:"single_nested_attribute_two"` + ListNestedBlockAssocExtType types.List `tfsdk:"list_nested_block_assoc_ext_type"` + ListNestedBlockOne types.List `tfsdk:"list_nested_block_one"` + ListNestedBlockThree types.List `tfsdk:"list_nested_block_three"` + ListNestedBlockTwo types.List `tfsdk:"list_nested_block_two"` + SetNestedBlockAssocExtType types.Set `tfsdk:"set_nested_block_assoc_ext_type"` + SingleNestedBlockAssocExtType types.Object `tfsdk:"single_nested_block_assoc_ext_type"` + SingleNestedBlockOne types.Object `tfsdk:"single_nested_block_one"` + SingleNestedBlockThree types.Object `tfsdk:"single_nested_block_three"` + SingleNestedBlockTwo types.Object `tfsdk:"single_nested_block_two"` +} + +type ListNestedAttributeAssocExtTypeModel struct { + BoolAttribute types.Bool `tfsdk:"bool_attribute"` + Float64Attribute types.Float64 `tfsdk:"float64_attribute"` + Int64Attribute types.Int64 `tfsdk:"int64_attribute"` + NumberAttribute types.Number `tfsdk:"number_attribute"` + StringAttribute types.String `tfsdk:"string_attribute"` +} + +type ListNestedAttributeOneModel struct { + BoolAttribute types.Bool `tfsdk:"bool_attribute"` +} + +type ListNestedAttributeThreeModel struct { + ListNestedAttributeThreeListNestedAttributeOne types.List `tfsdk:"list_nested_attribute_three_list_nested_attribute_one"` +} + +type ListNestedAttributeThreeListNestedAttributeOneModel struct { + ListAttribute types.List `tfsdk:"list_attribute"` +} + +type ListNestedAttributeTwoModel struct { + ListNestedAttributeTwoListNestedAttributeOne types.List `tfsdk:"list_nested_attribute_two_list_nested_attribute_one"` +} + +type ListNestedAttributeTwoListNestedAttributeOneModel struct { + BoolAttribute types.Bool `tfsdk:"bool_attribute"` +} + +type MapNestedAttributeAssocExtTypeModel struct { + BoolAttribute types.Bool `tfsdk:"bool_attribute"` + Float64Attribute types.Float64 `tfsdk:"float64_attribute"` + Int64Attribute types.Int64 `tfsdk:"int64_attribute"` + NumberAttribute types.Number `tfsdk:"number_attribute"` + StringAttribute types.String `tfsdk:"string_attribute"` +} + +type SetNestedAttributeAssocExtTypeModel struct { + BoolAttribute types.Bool `tfsdk:"bool_attribute"` + Float64Attribute types.Float64 `tfsdk:"float64_attribute"` + Int64Attribute types.Int64 `tfsdk:"int64_attribute"` + NumberAttribute types.Number `tfsdk:"number_attribute"` + StringAttribute types.String `tfsdk:"string_attribute"` +} + +type SingleNestedAttributeAssocExtTypeModel struct { + BoolAttribute types.Bool `tfsdk:"bool_attribute"` + Float64Attribute types.Float64 `tfsdk:"float64_attribute"` + Int64Attribute types.Int64 `tfsdk:"int64_attribute"` + NumberAttribute types.Number `tfsdk:"number_attribute"` + StringAttribute types.String `tfsdk:"string_attribute"` +} + +type SingleNestedAttributeOneModel struct { + BoolAttribute types.Bool `tfsdk:"bool_attribute"` +} + +type SingleNestedAttributeThreeModel struct { + SingleNestedAttributeThreeSingleNestedAttributeOne types.Object `tfsdk:"single_nested_attribute_three_single_nested_attribute_one"` +} + +type SingleNestedAttributeThreeSingleNestedAttributeOneModel struct { + ListAttribute types.List `tfsdk:"list_attribute"` +} + +type SingleNestedAttributeTwoModel struct { + SingleNestedAttributeTwoSingleNestedAttributeOne types.Object `tfsdk:"single_nested_attribute_two_single_nested_attribute_one"` +} + +type SingleNestedAttributeTwoSingleNestedAttributeOneModel struct { + BoolAttribute types.Bool `tfsdk:"bool_attribute"` +} + +type ListNestedBlockAssocExtTypeModel struct { + BoolAttribute types.Bool `tfsdk:"bool_attribute"` + Float64Attribute types.Float64 `tfsdk:"float64_attribute"` + Int64Attribute types.Int64 `tfsdk:"int64_attribute"` + NumberAttribute types.Number `tfsdk:"number_attribute"` + StringAttribute types.String `tfsdk:"string_attribute"` +} + +type ListNestedBlockOneModel struct { + BoolAttribute types.Bool `tfsdk:"bool_attribute"` +} + +type ListNestedBlockThreeModel struct { + ObjectAttribute types.Object `tfsdk:"object_attribute"` + ListNestedBlockThreeListNestedBlockOne types.List `tfsdk:"list_nested_block_three_list_nested_block_one"` +} + +type ListNestedBlockThreeListNestedBlockOneModel struct { + ListAttribute types.List `tfsdk:"list_attribute"` +} + +type ListNestedBlockTwoModel struct { + ListNestedBlockTwoListNestedBlockOne types.List `tfsdk:"list_nested_block_two_list_nested_block_one"` +} + +type ListNestedBlockTwoListNestedBlockOneModel struct { + BoolAttribute types.Bool `tfsdk:"bool_attribute"` +} + +type SetNestedBlockAssocExtTypeModel struct { + BoolAttribute types.Bool `tfsdk:"bool_attribute"` + Float64Attribute types.Float64 `tfsdk:"float64_attribute"` + Int64Attribute types.Int64 `tfsdk:"int64_attribute"` + NumberAttribute types.Number `tfsdk:"number_attribute"` + StringAttribute types.String `tfsdk:"string_attribute"` +} + +type SingleNestedBlockAssocExtTypeModel struct { + BoolAttribute types.Bool `tfsdk:"bool_attribute"` + Float64Attribute types.Float64 `tfsdk:"float64_attribute"` + Int64Attribute types.Int64 `tfsdk:"int64_attribute"` + NumberAttribute types.Number `tfsdk:"number_attribute"` + StringAttribute types.String `tfsdk:"string_attribute"` +} + +type SingleNestedBlockOneModel struct { + BoolAttribute types.Bool `tfsdk:"bool_attribute"` +} + +type SingleNestedBlockThreeModel struct { + ObjectAttribute types.Object `tfsdk:"object_attribute"` + SingleNestedBlockThreeListNestedBlockOne types.List `tfsdk:"single_nested_block_three_list_nested_block_one"` +} + +type SingleNestedBlockThreeListNestedBlockOneModel struct { + ListAttribute types.List `tfsdk:"list_attribute"` +} + +type SingleNestedBlockTwoModel struct { + SingleNestedBlockTwoSingleNestedBlockOne types.Object `tfsdk:"single_nested_block_two_single_nested_block_one"` +} + +type SingleNestedBlockTwoSingleNestedBlockOneModel struct { + BoolAttribute types.Bool `tfsdk:"bool_attribute"` +} + +func (m ListNestedAttributeAssocExtTypeModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m ListNestedAttributeAssocExtTypeModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "bool_attribute": types.BoolType, + "float64_attribute": types.Float64Type, + "int64_attribute": types.Int64Type, + "number_attribute": types.NumberType, + "string_attribute": types.StringType, + } +} + +func (m ListNestedAttributeAssocExtTypeModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m ListNestedAttributeAssocExtTypeModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} +func (m ListNestedAttributeOneModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m ListNestedAttributeOneModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "bool_attribute": types.BoolType, + } +} + +func (m ListNestedAttributeOneModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m ListNestedAttributeOneModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} +func (m ListNestedAttributeThreeModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m ListNestedAttributeThreeModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "list_nested_attribute_three_list_nested_attribute_one": types.ListType{ + ElemType: ListNestedAttributeThreeListNestedAttributeOneModel{}.ObjectType(ctx), + }, + } +} + +func (m ListNestedAttributeThreeModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m ListNestedAttributeThreeModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} + +func (m ListNestedAttributeThreeListNestedAttributeOneModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m ListNestedAttributeThreeListNestedAttributeOneModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "list_attribute": types.ListType{ + ElemType: types.StringType, + }, + } +} + +func (m ListNestedAttributeThreeListNestedAttributeOneModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m ListNestedAttributeThreeListNestedAttributeOneModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} +func (m ListNestedAttributeTwoModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m ListNestedAttributeTwoModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "list_nested_attribute_two_list_nested_attribute_one": types.ListType{ + ElemType: ListNestedAttributeTwoListNestedAttributeOneModel{}.ObjectType(ctx), + }, + } +} + +func (m ListNestedAttributeTwoModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m ListNestedAttributeTwoModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} + +func (m ListNestedAttributeTwoListNestedAttributeOneModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m ListNestedAttributeTwoListNestedAttributeOneModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "bool_attribute": types.BoolType, + } +} + +func (m ListNestedAttributeTwoListNestedAttributeOneModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m ListNestedAttributeTwoListNestedAttributeOneModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} +func (m MapNestedAttributeAssocExtTypeModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m MapNestedAttributeAssocExtTypeModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "bool_attribute": types.BoolType, + "float64_attribute": types.Float64Type, + "int64_attribute": types.Int64Type, + "number_attribute": types.NumberType, + "string_attribute": types.StringType, + } +} + +func (m MapNestedAttributeAssocExtTypeModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m MapNestedAttributeAssocExtTypeModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} +func (m SetNestedAttributeAssocExtTypeModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m SetNestedAttributeAssocExtTypeModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "bool_attribute": types.BoolType, + "float64_attribute": types.Float64Type, + "int64_attribute": types.Int64Type, + "number_attribute": types.NumberType, + "string_attribute": types.StringType, + } +} + +func (m SetNestedAttributeAssocExtTypeModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m SetNestedAttributeAssocExtTypeModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} +func (m SingleNestedAttributeAssocExtTypeModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m SingleNestedAttributeAssocExtTypeModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "bool_attribute": types.BoolType, + "float64_attribute": types.Float64Type, + "int64_attribute": types.Int64Type, + "number_attribute": types.NumberType, + "string_attribute": types.StringType, + } +} + +func (m SingleNestedAttributeAssocExtTypeModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m SingleNestedAttributeAssocExtTypeModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} +func (m SingleNestedAttributeOneModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m SingleNestedAttributeOneModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "bool_attribute": types.BoolType, + } +} + +func (m SingleNestedAttributeOneModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m SingleNestedAttributeOneModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} +func (m SingleNestedAttributeThreeModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m SingleNestedAttributeThreeModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "single_nested_attribute_three_single_nested_attribute_one": types.ObjectType{ + AttrTypes: SingleNestedAttributeThreeSingleNestedAttributeOneModel{}.ObjectAttributeTypes(ctx), + }, + } +} + +func (m SingleNestedAttributeThreeModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m SingleNestedAttributeThreeModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} + +func (m SingleNestedAttributeThreeSingleNestedAttributeOneModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m SingleNestedAttributeThreeSingleNestedAttributeOneModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "list_attribute": types.ListType{ + ElemType: types.StringType, + }, + } +} + +func (m SingleNestedAttributeThreeSingleNestedAttributeOneModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m SingleNestedAttributeThreeSingleNestedAttributeOneModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} +func (m SingleNestedAttributeTwoModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m SingleNestedAttributeTwoModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "single_nested_attribute_two_single_nested_attribute_one": types.ObjectType{ + AttrTypes: SingleNestedAttributeTwoSingleNestedAttributeOneModel{}.ObjectAttributeTypes(ctx), + }, + } +} + +func (m SingleNestedAttributeTwoModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m SingleNestedAttributeTwoModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} + +func (m SingleNestedAttributeTwoSingleNestedAttributeOneModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m SingleNestedAttributeTwoSingleNestedAttributeOneModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "bool_attribute": types.BoolType, + } +} + +func (m SingleNestedAttributeTwoSingleNestedAttributeOneModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m SingleNestedAttributeTwoSingleNestedAttributeOneModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} +func (m ListNestedBlockAssocExtTypeModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m ListNestedBlockAssocExtTypeModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "bool_attribute": types.BoolType, + "float64_attribute": types.Float64Type, + "int64_attribute": types.Int64Type, + "number_attribute": types.NumberType, + "string_attribute": types.StringType, + } +} + +func (m ListNestedBlockAssocExtTypeModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m ListNestedBlockAssocExtTypeModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} +func (m ListNestedBlockOneModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m ListNestedBlockOneModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "bool_attribute": types.BoolType, + } +} + +func (m ListNestedBlockOneModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m ListNestedBlockOneModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} +func (m ListNestedBlockThreeModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m ListNestedBlockThreeModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "list_nested_block_three_list_nested_block_one": types.ListType{ + ElemType: ListNestedBlockThreeListNestedBlockOneModel{}.ObjectType(ctx), + }, + "object_attribute": types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "string_attribute_type": types.StringType, + }, + }, + } +} + +func (m ListNestedBlockThreeModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m ListNestedBlockThreeModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} + +func (m ListNestedBlockThreeListNestedBlockOneModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m ListNestedBlockThreeListNestedBlockOneModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "list_attribute": types.ListType{ + ElemType: types.StringType, + }, + } +} + +func (m ListNestedBlockThreeListNestedBlockOneModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m ListNestedBlockThreeListNestedBlockOneModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} +func (m ListNestedBlockTwoModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m ListNestedBlockTwoModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "list_nested_block_two_list_nested_block_one": types.ListType{ + ElemType: ListNestedBlockTwoListNestedBlockOneModel{}.ObjectType(ctx), + }, + } +} + +func (m ListNestedBlockTwoModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m ListNestedBlockTwoModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} + +func (m ListNestedBlockTwoListNestedBlockOneModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m ListNestedBlockTwoListNestedBlockOneModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "bool_attribute": types.BoolType, + } +} + +func (m ListNestedBlockTwoListNestedBlockOneModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m ListNestedBlockTwoListNestedBlockOneModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} +func (m SetNestedBlockAssocExtTypeModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m SetNestedBlockAssocExtTypeModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "bool_attribute": types.BoolType, + "float64_attribute": types.Float64Type, + "int64_attribute": types.Int64Type, + "number_attribute": types.NumberType, + "string_attribute": types.StringType, + } +} + +func (m SetNestedBlockAssocExtTypeModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m SetNestedBlockAssocExtTypeModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} +func (m SingleNestedBlockAssocExtTypeModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m SingleNestedBlockAssocExtTypeModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "bool_attribute": types.BoolType, + "float64_attribute": types.Float64Type, + "int64_attribute": types.Int64Type, + "number_attribute": types.NumberType, + "string_attribute": types.StringType, + } +} + +func (m SingleNestedBlockAssocExtTypeModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m SingleNestedBlockAssocExtTypeModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} +func (m SingleNestedBlockOneModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m SingleNestedBlockOneModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "bool_attribute": types.BoolType, + } +} + +func (m SingleNestedBlockOneModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m SingleNestedBlockOneModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} +func (m SingleNestedBlockThreeModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m SingleNestedBlockThreeModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "object_attribute": types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "string_attribute_type": types.StringType, + }, + }, + "single_nested_block_three_list_nested_block_one": types.ListType{ + ElemType: SingleNestedBlockThreeListNestedBlockOneModel{}.ObjectType(ctx), + }, + } +} + +func (m SingleNestedBlockThreeModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m SingleNestedBlockThreeModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} + +func (m SingleNestedBlockThreeListNestedBlockOneModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m SingleNestedBlockThreeListNestedBlockOneModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "list_attribute": types.ListType{ + ElemType: types.StringType, + }, + } +} + +func (m SingleNestedBlockThreeListNestedBlockOneModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m SingleNestedBlockThreeListNestedBlockOneModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} +func (m SingleNestedBlockTwoModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m SingleNestedBlockTwoModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "single_nested_block_two_single_nested_block_one": types.ObjectType{ + AttrTypes: SingleNestedBlockTwoSingleNestedBlockOneModel{}.ObjectAttributeTypes(ctx), + }, + } +} + +func (m SingleNestedBlockTwoModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m SingleNestedBlockTwoModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} + +func (m SingleNestedBlockTwoSingleNestedBlockOneModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m SingleNestedBlockTwoSingleNestedBlockOneModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "bool_attribute": types.BoolType, + } +} + +func (m SingleNestedBlockTwoSingleNestedBlockOneModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m SingleNestedBlockTwoSingleNestedBlockOneModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} + +func ToListNestedAttributeAssocExtType(ctx context.Context, tfList types.List) ([]*apisdk.Type, diag.Diagnostics) { + var diags diag.Diagnostics + + if tfList.IsNull() { + return nil, diags + } + + if tfList.IsUnknown() { + diags.Append(diag.NewErrorDiagnostic( + "List Value Is Unknown", + `Model field "ListNestedAttributeAssocExtType" is unknown.`, + )) + + return nil, diags + } + + var listObjects []types.Object + + diags.Append(tfList.ElementsAs(ctx, &listObjects, false)...) + + if diags.HasError() { + return nil, diags + } + + apiObjects := make([]*apisdk.Type, 0, len(listObjects)) + + for _, listObject := range listObjects { + if listObject.IsNull() { + apiObjects = append(apiObjects, nil) + + continue + } + + if listObject.IsUnknown() { + diags.Append(diag.NewErrorDiagnostic( + "Object Value Within List Is Unknown", + `Model field "ListNestedAttributeAssocExtType" contains an object which is unknown.`, + )) + + return nil, diags + } + + var tfModel ListNestedAttributeAssocExtTypeModel + + d := listObject.As(ctx, &tfModel, basetypes.ObjectAsOptions{}) + + diags.Append(d...) + + if diags.HasError() { + return nil, diags + } + + apiObjects = append(apiObjects, &apisdk.Type{ + BoolAttribute: tfModel.BoolAttribute.ValueBoolPointer(), + Float64Attribute: tfModel.Float64Attribute.ValueFloat64Pointer(), + Int64Attribute: tfModel.Int64Attribute.ValueInt64Pointer(), + NumberAttribute: tfModel.NumberAttribute.ValueBigFloat(), + StringAttribute: tfModel.StringAttribute.ValueStringPointer(), + }) + } + + return apiObjects, diags +} + +func FromListNestedAttributeAssocExtType(ctx context.Context, apiObjects []*apisdk.Type) (types.List, diag.Diagnostics) { + var diags diag.Diagnostics + var tfModel ListNestedAttributeAssocExtTypeModel + + if apiObjects == nil { + return types.ListNull( + tfModel.ObjectType(ctx), + ), diags + } + + var tfModels []*ListNestedAttributeAssocExtTypeModel + + for _, apiObject := range apiObjects { + if apiObject == nil { + tfModels = append(tfModels, nil) + + continue + } + + tfModels = append(tfModels, &ListNestedAttributeAssocExtTypeModel{ + BoolAttribute: types.BoolPointerValue(apiObject.BoolAttribute), + Float64Attribute: types.Float64PointerValue(apiObject.Float64Attribute), + Int64Attribute: types.Int64PointerValue(apiObject.Int64Attribute), + NumberAttribute: types.NumberValue(apiObject.NumberAttribute), + StringAttribute: types.StringPointerValue(apiObject.StringAttribute), + }) + } + + return types.ListValueFrom(ctx, tfModel.ObjectType(ctx), tfModels) +} + +func ToMapNestedAttributeAssocExtType(ctx context.Context, tfMap types.Map) (map[string]*apisdk.Type, diag.Diagnostics) { + var diags diag.Diagnostics + + if tfMap.IsNull() { + return nil, diags + } + + if tfMap.IsUnknown() { + diags.Append(diag.NewErrorDiagnostic( + "Map Value Is Unknown", + `Model field "MapNestedAttributeAssocExtType" is unknown.`, + )) + + return nil, diags + } + + mapObjects := make(map[string]types.Object) + + diags.Append(tfMap.ElementsAs(ctx, &mapObjects, false)...) + + if diags.HasError() { + return nil, diags + } + + apiObjects := make(map[string]*apisdk.Type, len(mapObjects)) + + for k, mapObject := range mapObjects { + if mapObject.IsNull() { + apiObjects[k] = nil + + continue + } + + if mapObject.IsUnknown() { + diags.Append(diag.NewErrorDiagnostic( + "Object Value Within Map Is Unknown", + `Model field "MapNestedAttributeAssocExtType" contains an object which is unknown.`, + )) + + return nil, diags + } + + var tfModel MapNestedAttributeAssocExtTypeModel + + d := mapObject.As(ctx, &tfModel, basetypes.ObjectAsOptions{}) + + diags.Append(d...) + + if diags.HasError() { + return nil, diags + } + + apiObjects[k] = &apisdk.Type{ + BoolAttribute: tfModel.BoolAttribute.ValueBoolPointer(), + Float64Attribute: tfModel.Float64Attribute.ValueFloat64Pointer(), + Int64Attribute: tfModel.Int64Attribute.ValueInt64Pointer(), + NumberAttribute: tfModel.NumberAttribute.ValueBigFloat(), + StringAttribute: tfModel.StringAttribute.ValueStringPointer(), + } + } + + return apiObjects, diags +} + +func FromMapNestedAttributeAssocExtType(ctx context.Context, apiObjects map[string]*apisdk.Type) (types.Map, diag.Diagnostics) { + var diags diag.Diagnostics + var tfModel MapNestedAttributeAssocExtTypeModel + + if apiObjects == nil { + return types.MapNull( + tfModel.ObjectType(ctx), + ), diags + } + + tfModels := make(map[string]*MapNestedAttributeAssocExtTypeModel) + + for k, apiObject := range apiObjects { + if apiObject == nil { + tfModels[k] = nil + + continue + } + + tfModels[k] = &MapNestedAttributeAssocExtTypeModel{ + BoolAttribute: types.BoolPointerValue(apiObject.BoolAttribute), + Float64Attribute: types.Float64PointerValue(apiObject.Float64Attribute), + Int64Attribute: types.Int64PointerValue(apiObject.Int64Attribute), + NumberAttribute: types.NumberValue(apiObject.NumberAttribute), + StringAttribute: types.StringPointerValue(apiObject.StringAttribute), + } + } + + return types.MapValueFrom(ctx, tfModel.ObjectType(ctx), tfModels) +} + +func ToSetNestedAttributeAssocExtType(ctx context.Context, tfSet types.Set) ([]*apisdk.Type, diag.Diagnostics) { + var diags diag.Diagnostics + + if tfSet.IsNull() { + return nil, diags + } + + if tfSet.IsUnknown() { + diags.Append(diag.NewErrorDiagnostic( + "Set Value Is Unknown", + `Model field "SetNestedAttributeAssocExtType" is unknown.`, + )) + + return nil, diags + } + + var setObjects []types.Object + + diags.Append(tfSet.ElementsAs(ctx, &setObjects, false)...) + + if diags.HasError() { + return nil, diags + } + + apiObjects := make([]*apisdk.Type, 0, len(setObjects)) + + for _, setObject := range setObjects { + if setObject.IsNull() { + apiObjects = append(apiObjects, nil) + + continue + } + + if setObject.IsUnknown() { + diags.Append(diag.NewErrorDiagnostic( + "Object Value Within Set Is Unknown", + `Model field "SetNestedAttributeAssocExtType" contains an object which is unknown.`, + )) + + return nil, diags + } + + var tfModel SetNestedAttributeAssocExtTypeModel + + d := setObject.As(ctx, &tfModel, basetypes.ObjectAsOptions{}) + + diags.Append(d...) + + if diags.HasError() { + return nil, diags + } + + apiObjects = append(apiObjects, &apisdk.Type{ + BoolAttribute: tfModel.BoolAttribute.ValueBoolPointer(), + Float64Attribute: tfModel.Float64Attribute.ValueFloat64Pointer(), + Int64Attribute: tfModel.Int64Attribute.ValueInt64Pointer(), + NumberAttribute: tfModel.NumberAttribute.ValueBigFloat(), + StringAttribute: tfModel.StringAttribute.ValueStringPointer(), + }) + } + + return apiObjects, diags +} + +func FromSetNestedAttributeAssocExtType(ctx context.Context, apiObjects []*apisdk.Type) (types.Set, diag.Diagnostics) { + var diags diag.Diagnostics + var tfModel SetNestedAttributeAssocExtTypeModel + + if apiObjects == nil { + return types.SetNull( + tfModel.ObjectType(ctx), + ), diags + } + + var tfModels []*SetNestedAttributeAssocExtTypeModel + + for _, apiObject := range apiObjects { + if apiObject == nil { + tfModels = append(tfModels, nil) + + continue + } + + tfModels = append(tfModels, &SetNestedAttributeAssocExtTypeModel{ + BoolAttribute: types.BoolPointerValue(apiObject.BoolAttribute), + Float64Attribute: types.Float64PointerValue(apiObject.Float64Attribute), + Int64Attribute: types.Int64PointerValue(apiObject.Int64Attribute), + NumberAttribute: types.NumberValue(apiObject.NumberAttribute), + StringAttribute: types.StringPointerValue(apiObject.StringAttribute), + }) + } + + return types.SetValueFrom(ctx, tfModel.ObjectType(ctx), tfModels) +} + +func ToSingleNestedAttributeAssocExtType(ctx context.Context, tfObject types.Object) (*apisdk.Type, diag.Diagnostics) { + var diags diag.Diagnostics + + if tfObject.IsNull() { + return nil, diags + } + + if tfObject.IsUnknown() { + diags.Append(diag.NewErrorDiagnostic( + "Object Value Is Unknown", + `Model field "SingleNestedAttributeAssocExtType" is unknown.`, + )) + + return nil, diags + } + + var tfModel SingleNestedAttributeAssocExtTypeModel + + diags.Append(tfObject.As(ctx, &tfModel, basetypes.ObjectAsOptions{})...) + + if diags.HasError() { + return nil, diags + } + + apiObject := &apisdk.Type{ + BoolAttribute: tfModel.BoolAttribute.ValueBoolPointer(), + Float64Attribute: tfModel.Float64Attribute.ValueFloat64Pointer(), + Int64Attribute: tfModel.Int64Attribute.ValueInt64Pointer(), + NumberAttribute: tfModel.NumberAttribute.ValueBigFloat(), + StringAttribute: tfModel.StringAttribute.ValueStringPointer(), + } + + return apiObject, diags +} + +func FromSingleNestedAttributeAssocExtType(ctx context.Context, apiObject *apisdk.Type) (types.Object, diag.Diagnostics) { + var diags diag.Diagnostics + var tfModel SingleNestedAttributeAssocExtTypeModel + + if apiObject == nil { + return tfModel.ObjectNull(ctx), diags + } + + tfModel.BoolAttribute = types.BoolPointerValue(apiObject.BoolAttribute) + tfModel.Float64Attribute = types.Float64PointerValue(apiObject.Float64Attribute) + tfModel.Int64Attribute = types.Int64PointerValue(apiObject.Int64Attribute) + tfModel.NumberAttribute = types.NumberValue(apiObject.NumberAttribute) + tfModel.StringAttribute = types.StringPointerValue(apiObject.StringAttribute) + + return tfModel.ObjectValueFrom(ctx, tfModel) +} + +func ToListNestedBlockAssocExtType(ctx context.Context, tfList types.List) ([]*apisdk.Type, diag.Diagnostics) { + var diags diag.Diagnostics + + if tfList.IsNull() { + return nil, diags + } + + if tfList.IsUnknown() { + diags.Append(diag.NewErrorDiagnostic( + "List Value Is Unknown", + `Model field "ListNestedBlockAssocExtType" is unknown.`, + )) + + return nil, diags + } + + var listObjects []types.Object + + diags.Append(tfList.ElementsAs(ctx, &listObjects, false)...) + + if diags.HasError() { + return nil, diags + } + + apiObjects := make([]*apisdk.Type, 0, len(listObjects)) + + for _, listObject := range listObjects { + if listObject.IsNull() { + apiObjects = append(apiObjects, nil) + + continue + } + + if listObject.IsUnknown() { + diags.Append(diag.NewErrorDiagnostic( + "Object Value Within List Is Unknown", + `Model field "ListNestedBlockAssocExtType" contains an object which is unknown.`, + )) + + return nil, diags + } + + var tfModel ListNestedBlockAssocExtTypeModel + + d := listObject.As(ctx, &tfModel, basetypes.ObjectAsOptions{}) + + diags.Append(d...) + + if diags.HasError() { + return nil, diags + } + + apiObjects = append(apiObjects, &apisdk.Type{ + BoolAttribute: tfModel.BoolAttribute.ValueBoolPointer(), + Float64Attribute: tfModel.Float64Attribute.ValueFloat64Pointer(), + Int64Attribute: tfModel.Int64Attribute.ValueInt64Pointer(), + NumberAttribute: tfModel.NumberAttribute.ValueBigFloat(), + StringAttribute: tfModel.StringAttribute.ValueStringPointer(), + }) + } + + return apiObjects, diags +} + +func FromListNestedBlockAssocExtType(ctx context.Context, apiObjects []*apisdk.Type) (types.List, diag.Diagnostics) { + var diags diag.Diagnostics + var tfModel ListNestedBlockAssocExtTypeModel + + if apiObjects == nil { + return types.ListNull( + tfModel.ObjectType(ctx), + ), diags + } + + var tfModels []*ListNestedBlockAssocExtTypeModel + + for _, apiObject := range apiObjects { + if apiObject == nil { + tfModels = append(tfModels, nil) + + continue + } + + tfModels = append(tfModels, &ListNestedBlockAssocExtTypeModel{ + BoolAttribute: types.BoolPointerValue(apiObject.BoolAttribute), + Float64Attribute: types.Float64PointerValue(apiObject.Float64Attribute), + Int64Attribute: types.Int64PointerValue(apiObject.Int64Attribute), + NumberAttribute: types.NumberValue(apiObject.NumberAttribute), + StringAttribute: types.StringPointerValue(apiObject.StringAttribute), + }) + } + + return types.ListValueFrom(ctx, tfModel.ObjectType(ctx), tfModels) +} + +func ToSetNestedBlockAssocExtType(ctx context.Context, tfSet types.Set) ([]*apisdk.Type, diag.Diagnostics) { + var diags diag.Diagnostics + + if tfSet.IsNull() { + return nil, diags + } + + if tfSet.IsUnknown() { + diags.Append(diag.NewErrorDiagnostic( + "Set Value Is Unknown", + `Model field "SetNestedBlockAssocExtType" is unknown.`, + )) + + return nil, diags + } + + var setObjects []types.Object + + diags.Append(tfSet.ElementsAs(ctx, &setObjects, false)...) + + if diags.HasError() { + return nil, diags + } + + apiObjects := make([]*apisdk.Type, 0, len(setObjects)) + + for _, setObject := range setObjects { + if setObject.IsNull() { + apiObjects = append(apiObjects, nil) + + continue + } + + if setObject.IsUnknown() { + diags.Append(diag.NewErrorDiagnostic( + "Object Value Within Set Is Unknown", + `Model field "SetNestedBlockAssocExtType" contains an object which is unknown.`, + )) + + return nil, diags + } + + var tfModel SetNestedBlockAssocExtTypeModel + + d := setObject.As(ctx, &tfModel, basetypes.ObjectAsOptions{}) + + diags.Append(d...) + + if diags.HasError() { + return nil, diags + } + + apiObjects = append(apiObjects, &apisdk.Type{ + BoolAttribute: tfModel.BoolAttribute.ValueBoolPointer(), + Float64Attribute: tfModel.Float64Attribute.ValueFloat64Pointer(), + Int64Attribute: tfModel.Int64Attribute.ValueInt64Pointer(), + NumberAttribute: tfModel.NumberAttribute.ValueBigFloat(), + StringAttribute: tfModel.StringAttribute.ValueStringPointer(), + }) + } + + return apiObjects, diags +} + +func FromSetNestedBlockAssocExtType(ctx context.Context, apiObjects []*apisdk.Type) (types.Set, diag.Diagnostics) { + var diags diag.Diagnostics + var tfModel SetNestedBlockAssocExtTypeModel + + if apiObjects == nil { + return types.SetNull( + tfModel.ObjectType(ctx), + ), diags + } + + var tfModels []*SetNestedBlockAssocExtTypeModel + + for _, apiObject := range apiObjects { + if apiObject == nil { + tfModels = append(tfModels, nil) + + continue + } + + tfModels = append(tfModels, &SetNestedBlockAssocExtTypeModel{ + BoolAttribute: types.BoolPointerValue(apiObject.BoolAttribute), + Float64Attribute: types.Float64PointerValue(apiObject.Float64Attribute), + Int64Attribute: types.Int64PointerValue(apiObject.Int64Attribute), + NumberAttribute: types.NumberValue(apiObject.NumberAttribute), + StringAttribute: types.StringPointerValue(apiObject.StringAttribute), + }) + } + + return types.SetValueFrom(ctx, tfModel.ObjectType(ctx), tfModels) +} + +func ToSingleNestedBlockAssocExtType(ctx context.Context, tfObject types.Object) (*apisdk.Type, diag.Diagnostics) { + var diags diag.Diagnostics + + if tfObject.IsNull() { + return nil, diags + } + + if tfObject.IsUnknown() { + diags.Append(diag.NewErrorDiagnostic( + "Object Value Is Unknown", + `Model field "SingleNestedBlockAssocExtType" is unknown.`, + )) + + return nil, diags + } + + var tfModel SingleNestedBlockAssocExtTypeModel + + diags.Append(tfObject.As(ctx, &tfModel, basetypes.ObjectAsOptions{})...) + + if diags.HasError() { + return nil, diags + } + + apiObject := &apisdk.Type{ + BoolAttribute: tfModel.BoolAttribute.ValueBoolPointer(), + Float64Attribute: tfModel.Float64Attribute.ValueFloat64Pointer(), + Int64Attribute: tfModel.Int64Attribute.ValueInt64Pointer(), + NumberAttribute: tfModel.NumberAttribute.ValueBigFloat(), + StringAttribute: tfModel.StringAttribute.ValueStringPointer(), + } + + return apiObject, diags +} + +func FromSingleNestedBlockAssocExtType(ctx context.Context, apiObject *apisdk.Type) (types.Object, diag.Diagnostics) { + var diags diag.Diagnostics + var tfModel SingleNestedBlockAssocExtTypeModel + + if apiObject == nil { + return tfModel.ObjectNull(ctx), diags + } + + tfModel.BoolAttribute = types.BoolPointerValue(apiObject.BoolAttribute) + tfModel.Float64Attribute = types.Float64PointerValue(apiObject.Float64Attribute) + tfModel.Int64Attribute = types.Int64PointerValue(apiObject.Int64Attribute) + tfModel.NumberAttribute = types.NumberValue(apiObject.NumberAttribute) + tfModel.StringAttribute = types.StringPointerValue(apiObject.StringAttribute) + + return tfModel.ObjectValueFrom(ctx, tfModel) +} diff --git a/internal/cmd/testdata/custom_and_external/all_output/default_pkg_name/provider_provider_gen.go b/internal/cmd/testdata/custom_and_external/all_output/default_pkg_name/provider_provider_gen.go new file mode 100644 index 00000000..ceac64e9 --- /dev/null +++ b/internal/cmd/testdata/custom_and_external/all_output/default_pkg_name/provider_provider_gen.go @@ -0,0 +1,1002 @@ +// Code generated by terraform-plugin-framework-generator DO NOT EDIT. + +package provider + +import ( + "context" + "example.com/apisdk" + "github.com/hashicorp/terraform-plugin-framework/attr" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/provider/schema" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-framework/types/basetypes" +) + +var providerProviderSchema = schema.Schema{ + Attributes: map[string]schema.Attribute{ + "list_nested_attribute_assoc_ext_type": schema.ListNestedAttribute{ + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "bool_attribute": schema.BoolAttribute{ + Optional: true, + }, + "float64_attribute": schema.Float64Attribute{ + Optional: true, + }, + "int64_attribute": schema.Int64Attribute{ + Optional: true, + }, + "number_attribute": schema.NumberAttribute{ + Optional: true, + }, + "string_attribute": schema.StringAttribute{ + Optional: true, + }, + }, + }, + Optional: true, + }, + "map_nested_attribute_assoc_ext_type": schema.MapNestedAttribute{ + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "bool_attribute": schema.BoolAttribute{ + Optional: true, + }, + "float64_attribute": schema.Float64Attribute{ + Optional: true, + }, + "int64_attribute": schema.Int64Attribute{ + Optional: true, + }, + "number_attribute": schema.NumberAttribute{ + Optional: true, + }, + "string_attribute": schema.StringAttribute{ + Optional: true, + }, + }, + }, + Optional: true, + }, + "set_nested_attribute_assoc_ext_type": schema.SetNestedAttribute{ + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "bool_attribute": schema.BoolAttribute{ + Optional: true, + }, + "float64_attribute": schema.Float64Attribute{ + Optional: true, + }, + "int64_attribute": schema.Int64Attribute{ + Optional: true, + }, + "number_attribute": schema.NumberAttribute{ + Optional: true, + }, + "string_attribute": schema.StringAttribute{ + Optional: true, + }, + }, + }, + Optional: true, + }, + "single_nested_attribute_assoc_ext_type": schema.SingleNestedAttribute{ + Attributes: map[string]schema.Attribute{ + "bool_attribute": schema.BoolAttribute{ + Optional: true, + }, + "float64_attribute": schema.Float64Attribute{ + Optional: true, + }, + "int64_attribute": schema.Int64Attribute{ + Optional: true, + }, + "number_attribute": schema.NumberAttribute{ + Optional: true, + }, + "string_attribute": schema.StringAttribute{ + Optional: true, + }, + }, + Optional: true, + }, + }, + Blocks: map[string]schema.Block{ + "list_nested_block_assoc_ext_type": schema.ListNestedBlock{ + NestedObject: schema.NestedBlockObject{ + Attributes: map[string]schema.Attribute{ + "bool_attribute": schema.BoolAttribute{ + Optional: true, + }, + "float64_attribute": schema.Float64Attribute{ + Optional: true, + }, + "int64_attribute": schema.Int64Attribute{ + Optional: true, + }, + "number_attribute": schema.NumberAttribute{ + Optional: true, + }, + "string_attribute": schema.StringAttribute{ + Optional: true, + }, + }, + }, + }, + "set_nested_block_assoc_ext_type": schema.SetNestedBlock{ + NestedObject: schema.NestedBlockObject{ + Attributes: map[string]schema.Attribute{ + "bool_attribute": schema.BoolAttribute{ + Optional: true, + }, + "float64_attribute": schema.Float64Attribute{ + Optional: true, + }, + "int64_attribute": schema.Int64Attribute{ + Optional: true, + }, + "number_attribute": schema.NumberAttribute{ + Optional: true, + }, + "string_attribute": schema.StringAttribute{ + Optional: true, + }, + }, + }, + }, + "single_nested_block_assoc_ext_type": schema.SingleNestedBlock{ + Attributes: map[string]schema.Attribute{ + "bool_attribute": schema.BoolAttribute{ + Optional: true, + }, + "float64_attribute": schema.Float64Attribute{ + Optional: true, + }, + "int64_attribute": schema.Int64Attribute{ + Optional: true, + }, + "number_attribute": schema.NumberAttribute{ + Optional: true, + }, + "string_attribute": schema.StringAttribute{ + Optional: true, + }, + }, + }, + }, +} + +type ProviderModel struct { + ListNestedAttributeAssocExtType types.List `tfsdk:"list_nested_attribute_assoc_ext_type"` + MapNestedAttributeAssocExtType types.Map `tfsdk:"map_nested_attribute_assoc_ext_type"` + SetNestedAttributeAssocExtType types.Set `tfsdk:"set_nested_attribute_assoc_ext_type"` + SingleNestedAttributeAssocExtType types.Object `tfsdk:"single_nested_attribute_assoc_ext_type"` + ListNestedBlockAssocExtType types.List `tfsdk:"list_nested_block_assoc_ext_type"` + SetNestedBlockAssocExtType types.Set `tfsdk:"set_nested_block_assoc_ext_type"` + SingleNestedBlockAssocExtType types.Object `tfsdk:"single_nested_block_assoc_ext_type"` +} + +type ListNestedAttributeAssocExtTypeModel struct { + BoolAttribute types.Bool `tfsdk:"bool_attribute"` + Float64Attribute types.Float64 `tfsdk:"float64_attribute"` + Int64Attribute types.Int64 `tfsdk:"int64_attribute"` + NumberAttribute types.Number `tfsdk:"number_attribute"` + StringAttribute types.String `tfsdk:"string_attribute"` +} + +type MapNestedAttributeAssocExtTypeModel struct { + BoolAttribute types.Bool `tfsdk:"bool_attribute"` + Float64Attribute types.Float64 `tfsdk:"float64_attribute"` + Int64Attribute types.Int64 `tfsdk:"int64_attribute"` + NumberAttribute types.Number `tfsdk:"number_attribute"` + StringAttribute types.String `tfsdk:"string_attribute"` +} + +type SetNestedAttributeAssocExtTypeModel struct { + BoolAttribute types.Bool `tfsdk:"bool_attribute"` + Float64Attribute types.Float64 `tfsdk:"float64_attribute"` + Int64Attribute types.Int64 `tfsdk:"int64_attribute"` + NumberAttribute types.Number `tfsdk:"number_attribute"` + StringAttribute types.String `tfsdk:"string_attribute"` +} + +type SingleNestedAttributeAssocExtTypeModel struct { + BoolAttribute types.Bool `tfsdk:"bool_attribute"` + Float64Attribute types.Float64 `tfsdk:"float64_attribute"` + Int64Attribute types.Int64 `tfsdk:"int64_attribute"` + NumberAttribute types.Number `tfsdk:"number_attribute"` + StringAttribute types.String `tfsdk:"string_attribute"` +} + +type ListNestedBlockAssocExtTypeModel struct { + BoolAttribute types.Bool `tfsdk:"bool_attribute"` + Float64Attribute types.Float64 `tfsdk:"float64_attribute"` + Int64Attribute types.Int64 `tfsdk:"int64_attribute"` + NumberAttribute types.Number `tfsdk:"number_attribute"` + StringAttribute types.String `tfsdk:"string_attribute"` +} + +type SetNestedBlockAssocExtTypeModel struct { + BoolAttribute types.Bool `tfsdk:"bool_attribute"` + Float64Attribute types.Float64 `tfsdk:"float64_attribute"` + Int64Attribute types.Int64 `tfsdk:"int64_attribute"` + NumberAttribute types.Number `tfsdk:"number_attribute"` + StringAttribute types.String `tfsdk:"string_attribute"` +} + +type SingleNestedBlockAssocExtTypeModel struct { + BoolAttribute types.Bool `tfsdk:"bool_attribute"` + Float64Attribute types.Float64 `tfsdk:"float64_attribute"` + Int64Attribute types.Int64 `tfsdk:"int64_attribute"` + NumberAttribute types.Number `tfsdk:"number_attribute"` + StringAttribute types.String `tfsdk:"string_attribute"` +} + +func (m ListNestedAttributeAssocExtTypeModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m ListNestedAttributeAssocExtTypeModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "bool_attribute": types.BoolType, + "float64_attribute": types.Float64Type, + "int64_attribute": types.Int64Type, + "number_attribute": types.NumberType, + "string_attribute": types.StringType, + } +} + +func (m ListNestedAttributeAssocExtTypeModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m ListNestedAttributeAssocExtTypeModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} +func (m MapNestedAttributeAssocExtTypeModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m MapNestedAttributeAssocExtTypeModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "bool_attribute": types.BoolType, + "float64_attribute": types.Float64Type, + "int64_attribute": types.Int64Type, + "number_attribute": types.NumberType, + "string_attribute": types.StringType, + } +} + +func (m MapNestedAttributeAssocExtTypeModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m MapNestedAttributeAssocExtTypeModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} +func (m SetNestedAttributeAssocExtTypeModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m SetNestedAttributeAssocExtTypeModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "bool_attribute": types.BoolType, + "float64_attribute": types.Float64Type, + "int64_attribute": types.Int64Type, + "number_attribute": types.NumberType, + "string_attribute": types.StringType, + } +} + +func (m SetNestedAttributeAssocExtTypeModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m SetNestedAttributeAssocExtTypeModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} +func (m SingleNestedAttributeAssocExtTypeModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m SingleNestedAttributeAssocExtTypeModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "bool_attribute": types.BoolType, + "float64_attribute": types.Float64Type, + "int64_attribute": types.Int64Type, + "number_attribute": types.NumberType, + "string_attribute": types.StringType, + } +} + +func (m SingleNestedAttributeAssocExtTypeModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m SingleNestedAttributeAssocExtTypeModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} +func (m ListNestedBlockAssocExtTypeModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m ListNestedBlockAssocExtTypeModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "bool_attribute": types.BoolType, + "float64_attribute": types.Float64Type, + "int64_attribute": types.Int64Type, + "number_attribute": types.NumberType, + "string_attribute": types.StringType, + } +} + +func (m ListNestedBlockAssocExtTypeModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m ListNestedBlockAssocExtTypeModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} +func (m SetNestedBlockAssocExtTypeModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m SetNestedBlockAssocExtTypeModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "bool_attribute": types.BoolType, + "float64_attribute": types.Float64Type, + "int64_attribute": types.Int64Type, + "number_attribute": types.NumberType, + "string_attribute": types.StringType, + } +} + +func (m SetNestedBlockAssocExtTypeModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m SetNestedBlockAssocExtTypeModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} +func (m SingleNestedBlockAssocExtTypeModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m SingleNestedBlockAssocExtTypeModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "bool_attribute": types.BoolType, + "float64_attribute": types.Float64Type, + "int64_attribute": types.Int64Type, + "number_attribute": types.NumberType, + "string_attribute": types.StringType, + } +} + +func (m SingleNestedBlockAssocExtTypeModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m SingleNestedBlockAssocExtTypeModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} + +func ToListNestedAttributeAssocExtType(ctx context.Context, tfList types.List) ([]*apisdk.Type, diag.Diagnostics) { + var diags diag.Diagnostics + + if tfList.IsNull() { + return nil, diags + } + + if tfList.IsUnknown() { + diags.Append(diag.NewErrorDiagnostic( + "List Value Is Unknown", + `Model field "ListNestedAttributeAssocExtType" is unknown.`, + )) + + return nil, diags + } + + var listObjects []types.Object + + diags.Append(tfList.ElementsAs(ctx, &listObjects, false)...) + + if diags.HasError() { + return nil, diags + } + + apiObjects := make([]*apisdk.Type, 0, len(listObjects)) + + for _, listObject := range listObjects { + if listObject.IsNull() { + apiObjects = append(apiObjects, nil) + + continue + } + + if listObject.IsUnknown() { + diags.Append(diag.NewErrorDiagnostic( + "Object Value Within List Is Unknown", + `Model field "ListNestedAttributeAssocExtType" contains an object which is unknown.`, + )) + + return nil, diags + } + + var tfModel ListNestedAttributeAssocExtTypeModel + + d := listObject.As(ctx, &tfModel, basetypes.ObjectAsOptions{}) + + diags.Append(d...) + + if diags.HasError() { + return nil, diags + } + + apiObjects = append(apiObjects, &apisdk.Type{ + BoolAttribute: tfModel.BoolAttribute.ValueBoolPointer(), + Float64Attribute: tfModel.Float64Attribute.ValueFloat64Pointer(), + Int64Attribute: tfModel.Int64Attribute.ValueInt64Pointer(), + NumberAttribute: tfModel.NumberAttribute.ValueBigFloat(), + StringAttribute: tfModel.StringAttribute.ValueStringPointer(), + }) + } + + return apiObjects, diags +} + +func FromListNestedAttributeAssocExtType(ctx context.Context, apiObjects []*apisdk.Type) (types.List, diag.Diagnostics) { + var diags diag.Diagnostics + var tfModel ListNestedAttributeAssocExtTypeModel + + if apiObjects == nil { + return types.ListNull( + tfModel.ObjectType(ctx), + ), diags + } + + var tfModels []*ListNestedAttributeAssocExtTypeModel + + for _, apiObject := range apiObjects { + if apiObject == nil { + tfModels = append(tfModels, nil) + + continue + } + + tfModels = append(tfModels, &ListNestedAttributeAssocExtTypeModel{ + BoolAttribute: types.BoolPointerValue(apiObject.BoolAttribute), + Float64Attribute: types.Float64PointerValue(apiObject.Float64Attribute), + Int64Attribute: types.Int64PointerValue(apiObject.Int64Attribute), + NumberAttribute: types.NumberValue(apiObject.NumberAttribute), + StringAttribute: types.StringPointerValue(apiObject.StringAttribute), + }) + } + + return types.ListValueFrom(ctx, tfModel.ObjectType(ctx), tfModels) +} + +func ToMapNestedAttributeAssocExtType(ctx context.Context, tfMap types.Map) (map[string]*apisdk.Type, diag.Diagnostics) { + var diags diag.Diagnostics + + if tfMap.IsNull() { + return nil, diags + } + + if tfMap.IsUnknown() { + diags.Append(diag.NewErrorDiagnostic( + "Map Value Is Unknown", + `Model field "MapNestedAttributeAssocExtType" is unknown.`, + )) + + return nil, diags + } + + mapObjects := make(map[string]types.Object) + + diags.Append(tfMap.ElementsAs(ctx, &mapObjects, false)...) + + if diags.HasError() { + return nil, diags + } + + apiObjects := make(map[string]*apisdk.Type, len(mapObjects)) + + for k, mapObject := range mapObjects { + if mapObject.IsNull() { + apiObjects[k] = nil + + continue + } + + if mapObject.IsUnknown() { + diags.Append(diag.NewErrorDiagnostic( + "Object Value Within Map Is Unknown", + `Model field "MapNestedAttributeAssocExtType" contains an object which is unknown.`, + )) + + return nil, diags + } + + var tfModel MapNestedAttributeAssocExtTypeModel + + d := mapObject.As(ctx, &tfModel, basetypes.ObjectAsOptions{}) + + diags.Append(d...) + + if diags.HasError() { + return nil, diags + } + + apiObjects[k] = &apisdk.Type{ + BoolAttribute: tfModel.BoolAttribute.ValueBoolPointer(), + Float64Attribute: tfModel.Float64Attribute.ValueFloat64Pointer(), + Int64Attribute: tfModel.Int64Attribute.ValueInt64Pointer(), + NumberAttribute: tfModel.NumberAttribute.ValueBigFloat(), + StringAttribute: tfModel.StringAttribute.ValueStringPointer(), + } + } + + return apiObjects, diags +} + +func FromMapNestedAttributeAssocExtType(ctx context.Context, apiObjects map[string]*apisdk.Type) (types.Map, diag.Diagnostics) { + var diags diag.Diagnostics + var tfModel MapNestedAttributeAssocExtTypeModel + + if apiObjects == nil { + return types.MapNull( + tfModel.ObjectType(ctx), + ), diags + } + + tfModels := make(map[string]*MapNestedAttributeAssocExtTypeModel) + + for k, apiObject := range apiObjects { + if apiObject == nil { + tfModels[k] = nil + + continue + } + + tfModels[k] = &MapNestedAttributeAssocExtTypeModel{ + BoolAttribute: types.BoolPointerValue(apiObject.BoolAttribute), + Float64Attribute: types.Float64PointerValue(apiObject.Float64Attribute), + Int64Attribute: types.Int64PointerValue(apiObject.Int64Attribute), + NumberAttribute: types.NumberValue(apiObject.NumberAttribute), + StringAttribute: types.StringPointerValue(apiObject.StringAttribute), + } + } + + return types.MapValueFrom(ctx, tfModel.ObjectType(ctx), tfModels) +} + +func ToSetNestedAttributeAssocExtType(ctx context.Context, tfSet types.Set) ([]*apisdk.Type, diag.Diagnostics) { + var diags diag.Diagnostics + + if tfSet.IsNull() { + return nil, diags + } + + if tfSet.IsUnknown() { + diags.Append(diag.NewErrorDiagnostic( + "Set Value Is Unknown", + `Model field "SetNestedAttributeAssocExtType" is unknown.`, + )) + + return nil, diags + } + + var setObjects []types.Object + + diags.Append(tfSet.ElementsAs(ctx, &setObjects, false)...) + + if diags.HasError() { + return nil, diags + } + + apiObjects := make([]*apisdk.Type, 0, len(setObjects)) + + for _, setObject := range setObjects { + if setObject.IsNull() { + apiObjects = append(apiObjects, nil) + + continue + } + + if setObject.IsUnknown() { + diags.Append(diag.NewErrorDiagnostic( + "Object Value Within Set Is Unknown", + `Model field "SetNestedAttributeAssocExtType" contains an object which is unknown.`, + )) + + return nil, diags + } + + var tfModel SetNestedAttributeAssocExtTypeModel + + d := setObject.As(ctx, &tfModel, basetypes.ObjectAsOptions{}) + + diags.Append(d...) + + if diags.HasError() { + return nil, diags + } + + apiObjects = append(apiObjects, &apisdk.Type{ + BoolAttribute: tfModel.BoolAttribute.ValueBoolPointer(), + Float64Attribute: tfModel.Float64Attribute.ValueFloat64Pointer(), + Int64Attribute: tfModel.Int64Attribute.ValueInt64Pointer(), + NumberAttribute: tfModel.NumberAttribute.ValueBigFloat(), + StringAttribute: tfModel.StringAttribute.ValueStringPointer(), + }) + } + + return apiObjects, diags +} + +func FromSetNestedAttributeAssocExtType(ctx context.Context, apiObjects []*apisdk.Type) (types.Set, diag.Diagnostics) { + var diags diag.Diagnostics + var tfModel SetNestedAttributeAssocExtTypeModel + + if apiObjects == nil { + return types.SetNull( + tfModel.ObjectType(ctx), + ), diags + } + + var tfModels []*SetNestedAttributeAssocExtTypeModel + + for _, apiObject := range apiObjects { + if apiObject == nil { + tfModels = append(tfModels, nil) + + continue + } + + tfModels = append(tfModels, &SetNestedAttributeAssocExtTypeModel{ + BoolAttribute: types.BoolPointerValue(apiObject.BoolAttribute), + Float64Attribute: types.Float64PointerValue(apiObject.Float64Attribute), + Int64Attribute: types.Int64PointerValue(apiObject.Int64Attribute), + NumberAttribute: types.NumberValue(apiObject.NumberAttribute), + StringAttribute: types.StringPointerValue(apiObject.StringAttribute), + }) + } + + return types.SetValueFrom(ctx, tfModel.ObjectType(ctx), tfModels) +} + +func ToSingleNestedAttributeAssocExtType(ctx context.Context, tfObject types.Object) (*apisdk.Type, diag.Diagnostics) { + var diags diag.Diagnostics + + if tfObject.IsNull() { + return nil, diags + } + + if tfObject.IsUnknown() { + diags.Append(diag.NewErrorDiagnostic( + "Object Value Is Unknown", + `Model field "SingleNestedAttributeAssocExtType" is unknown.`, + )) + + return nil, diags + } + + var tfModel SingleNestedAttributeAssocExtTypeModel + + diags.Append(tfObject.As(ctx, &tfModel, basetypes.ObjectAsOptions{})...) + + if diags.HasError() { + return nil, diags + } + + apiObject := &apisdk.Type{ + BoolAttribute: tfModel.BoolAttribute.ValueBoolPointer(), + Float64Attribute: tfModel.Float64Attribute.ValueFloat64Pointer(), + Int64Attribute: tfModel.Int64Attribute.ValueInt64Pointer(), + NumberAttribute: tfModel.NumberAttribute.ValueBigFloat(), + StringAttribute: tfModel.StringAttribute.ValueStringPointer(), + } + + return apiObject, diags +} + +func FromSingleNestedAttributeAssocExtType(ctx context.Context, apiObject *apisdk.Type) (types.Object, diag.Diagnostics) { + var diags diag.Diagnostics + var tfModel SingleNestedAttributeAssocExtTypeModel + + if apiObject == nil { + return tfModel.ObjectNull(ctx), diags + } + + tfModel.BoolAttribute = types.BoolPointerValue(apiObject.BoolAttribute) + tfModel.Float64Attribute = types.Float64PointerValue(apiObject.Float64Attribute) + tfModel.Int64Attribute = types.Int64PointerValue(apiObject.Int64Attribute) + tfModel.NumberAttribute = types.NumberValue(apiObject.NumberAttribute) + tfModel.StringAttribute = types.StringPointerValue(apiObject.StringAttribute) + + return tfModel.ObjectValueFrom(ctx, tfModel) +} + +func ToListNestedBlockAssocExtType(ctx context.Context, tfList types.List) ([]*apisdk.Type, diag.Diagnostics) { + var diags diag.Diagnostics + + if tfList.IsNull() { + return nil, diags + } + + if tfList.IsUnknown() { + diags.Append(diag.NewErrorDiagnostic( + "List Value Is Unknown", + `Model field "ListNestedBlockAssocExtType" is unknown.`, + )) + + return nil, diags + } + + var listObjects []types.Object + + diags.Append(tfList.ElementsAs(ctx, &listObjects, false)...) + + if diags.HasError() { + return nil, diags + } + + apiObjects := make([]*apisdk.Type, 0, len(listObjects)) + + for _, listObject := range listObjects { + if listObject.IsNull() { + apiObjects = append(apiObjects, nil) + + continue + } + + if listObject.IsUnknown() { + diags.Append(diag.NewErrorDiagnostic( + "Object Value Within List Is Unknown", + `Model field "ListNestedBlockAssocExtType" contains an object which is unknown.`, + )) + + return nil, diags + } + + var tfModel ListNestedBlockAssocExtTypeModel + + d := listObject.As(ctx, &tfModel, basetypes.ObjectAsOptions{}) + + diags.Append(d...) + + if diags.HasError() { + return nil, diags + } + + apiObjects = append(apiObjects, &apisdk.Type{ + BoolAttribute: tfModel.BoolAttribute.ValueBoolPointer(), + Float64Attribute: tfModel.Float64Attribute.ValueFloat64Pointer(), + Int64Attribute: tfModel.Int64Attribute.ValueInt64Pointer(), + NumberAttribute: tfModel.NumberAttribute.ValueBigFloat(), + StringAttribute: tfModel.StringAttribute.ValueStringPointer(), + }) + } + + return apiObjects, diags +} + +func FromListNestedBlockAssocExtType(ctx context.Context, apiObjects []*apisdk.Type) (types.List, diag.Diagnostics) { + var diags diag.Diagnostics + var tfModel ListNestedBlockAssocExtTypeModel + + if apiObjects == nil { + return types.ListNull( + tfModel.ObjectType(ctx), + ), diags + } + + var tfModels []*ListNestedBlockAssocExtTypeModel + + for _, apiObject := range apiObjects { + if apiObject == nil { + tfModels = append(tfModels, nil) + + continue + } + + tfModels = append(tfModels, &ListNestedBlockAssocExtTypeModel{ + BoolAttribute: types.BoolPointerValue(apiObject.BoolAttribute), + Float64Attribute: types.Float64PointerValue(apiObject.Float64Attribute), + Int64Attribute: types.Int64PointerValue(apiObject.Int64Attribute), + NumberAttribute: types.NumberValue(apiObject.NumberAttribute), + StringAttribute: types.StringPointerValue(apiObject.StringAttribute), + }) + } + + return types.ListValueFrom(ctx, tfModel.ObjectType(ctx), tfModels) +} + +func ToSetNestedBlockAssocExtType(ctx context.Context, tfSet types.Set) ([]*apisdk.Type, diag.Diagnostics) { + var diags diag.Diagnostics + + if tfSet.IsNull() { + return nil, diags + } + + if tfSet.IsUnknown() { + diags.Append(diag.NewErrorDiagnostic( + "Set Value Is Unknown", + `Model field "SetNestedBlockAssocExtType" is unknown.`, + )) + + return nil, diags + } + + var setObjects []types.Object + + diags.Append(tfSet.ElementsAs(ctx, &setObjects, false)...) + + if diags.HasError() { + return nil, diags + } + + apiObjects := make([]*apisdk.Type, 0, len(setObjects)) + + for _, setObject := range setObjects { + if setObject.IsNull() { + apiObjects = append(apiObjects, nil) + + continue + } + + if setObject.IsUnknown() { + diags.Append(diag.NewErrorDiagnostic( + "Object Value Within Set Is Unknown", + `Model field "SetNestedBlockAssocExtType" contains an object which is unknown.`, + )) + + return nil, diags + } + + var tfModel SetNestedBlockAssocExtTypeModel + + d := setObject.As(ctx, &tfModel, basetypes.ObjectAsOptions{}) + + diags.Append(d...) + + if diags.HasError() { + return nil, diags + } + + apiObjects = append(apiObjects, &apisdk.Type{ + BoolAttribute: tfModel.BoolAttribute.ValueBoolPointer(), + Float64Attribute: tfModel.Float64Attribute.ValueFloat64Pointer(), + Int64Attribute: tfModel.Int64Attribute.ValueInt64Pointer(), + NumberAttribute: tfModel.NumberAttribute.ValueBigFloat(), + StringAttribute: tfModel.StringAttribute.ValueStringPointer(), + }) + } + + return apiObjects, diags +} + +func FromSetNestedBlockAssocExtType(ctx context.Context, apiObjects []*apisdk.Type) (types.Set, diag.Diagnostics) { + var diags diag.Diagnostics + var tfModel SetNestedBlockAssocExtTypeModel + + if apiObjects == nil { + return types.SetNull( + tfModel.ObjectType(ctx), + ), diags + } + + var tfModels []*SetNestedBlockAssocExtTypeModel + + for _, apiObject := range apiObjects { + if apiObject == nil { + tfModels = append(tfModels, nil) + + continue + } + + tfModels = append(tfModels, &SetNestedBlockAssocExtTypeModel{ + BoolAttribute: types.BoolPointerValue(apiObject.BoolAttribute), + Float64Attribute: types.Float64PointerValue(apiObject.Float64Attribute), + Int64Attribute: types.Int64PointerValue(apiObject.Int64Attribute), + NumberAttribute: types.NumberValue(apiObject.NumberAttribute), + StringAttribute: types.StringPointerValue(apiObject.StringAttribute), + }) + } + + return types.SetValueFrom(ctx, tfModel.ObjectType(ctx), tfModels) +} + +func ToSingleNestedBlockAssocExtType(ctx context.Context, tfObject types.Object) (*apisdk.Type, diag.Diagnostics) { + var diags diag.Diagnostics + + if tfObject.IsNull() { + return nil, diags + } + + if tfObject.IsUnknown() { + diags.Append(diag.NewErrorDiagnostic( + "Object Value Is Unknown", + `Model field "SingleNestedBlockAssocExtType" is unknown.`, + )) + + return nil, diags + } + + var tfModel SingleNestedBlockAssocExtTypeModel + + diags.Append(tfObject.As(ctx, &tfModel, basetypes.ObjectAsOptions{})...) + + if diags.HasError() { + return nil, diags + } + + apiObject := &apisdk.Type{ + BoolAttribute: tfModel.BoolAttribute.ValueBoolPointer(), + Float64Attribute: tfModel.Float64Attribute.ValueFloat64Pointer(), + Int64Attribute: tfModel.Int64Attribute.ValueInt64Pointer(), + NumberAttribute: tfModel.NumberAttribute.ValueBigFloat(), + StringAttribute: tfModel.StringAttribute.ValueStringPointer(), + } + + return apiObject, diags +} + +func FromSingleNestedBlockAssocExtType(ctx context.Context, apiObject *apisdk.Type) (types.Object, diag.Diagnostics) { + var diags diag.Diagnostics + var tfModel SingleNestedBlockAssocExtTypeModel + + if apiObject == nil { + return tfModel.ObjectNull(ctx), diags + } + + tfModel.BoolAttribute = types.BoolPointerValue(apiObject.BoolAttribute) + tfModel.Float64Attribute = types.Float64PointerValue(apiObject.Float64Attribute) + tfModel.Int64Attribute = types.Int64PointerValue(apiObject.Int64Attribute) + tfModel.NumberAttribute = types.NumberValue(apiObject.NumberAttribute) + tfModel.StringAttribute = types.StringPointerValue(apiObject.StringAttribute) + + return tfModel.ObjectValueFrom(ctx, tfModel) +} diff --git a/internal/cmd/testdata/custom_and_external/all_output/default_pkg_name/resource_resource_gen.go b/internal/cmd/testdata/custom_and_external/all_output/default_pkg_name/resource_resource_gen.go new file mode 100644 index 00000000..67b79d6a --- /dev/null +++ b/internal/cmd/testdata/custom_and_external/all_output/default_pkg_name/resource_resource_gen.go @@ -0,0 +1,1020 @@ +// Code generated by terraform-plugin-framework-generator DO NOT EDIT. + +package resource + +import ( + "context" + "example.com/apisdk" + "github.com/hashicorp/terraform-plugin-framework/attr" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/resource/schema" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/booldefault" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" + "github.com/hashicorp/terraform-plugin-framework/schema/validator" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-framework/types/basetypes" + planmodifieralias "github.com/my_account/my_project/myboolplanmodifier" + validatoralias "github.com/my_account/my_project/myboolvalidator" + boolalias "github.com/my_account_my_project/bool" +) + +var resourceResourceSchema = schema.Schema{ + Attributes: map[string]schema.Attribute{ + "bool_attribute": schema.BoolAttribute{ + CustomType: my_bool_type, + Computed: true, + PlanModifiers: []planmodifier.Bool{ + myboolplanmodifier.Modify(), + }, + Validators: []validator.Bool{ + myboolvalidator.Validate(), + }, + Default: booldefault.StaticBool(true), + }, + "list_nested_attribute_assoc_ext_type": schema.ListNestedAttribute{ + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "bool_attribute": schema.BoolAttribute{ + Optional: true, + }, + "float64_attribute": schema.Float64Attribute{ + Optional: true, + }, + "int64_attribute": schema.Int64Attribute{ + Optional: true, + }, + "number_attribute": schema.NumberAttribute{ + Optional: true, + }, + "string_attribute": schema.StringAttribute{ + Optional: true, + }, + }, + }, + Optional: true, + }, + "map_nested_attribute_assoc_ext_type": schema.MapNestedAttribute{ + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "bool_attribute": schema.BoolAttribute{ + Optional: true, + }, + "float64_attribute": schema.Float64Attribute{ + Optional: true, + }, + "int64_attribute": schema.Int64Attribute{ + Optional: true, + }, + "number_attribute": schema.NumberAttribute{ + Optional: true, + }, + "string_attribute": schema.StringAttribute{ + Optional: true, + }, + }, + }, + Optional: true, + }, + "set_nested_attribute_assoc_ext_type": schema.SetNestedAttribute{ + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "bool_attribute": schema.BoolAttribute{ + Optional: true, + }, + "float64_attribute": schema.Float64Attribute{ + Optional: true, + }, + "int64_attribute": schema.Int64Attribute{ + Optional: true, + }, + "number_attribute": schema.NumberAttribute{ + Optional: true, + }, + "string_attribute": schema.StringAttribute{ + Optional: true, + }, + }, + }, + Optional: true, + }, + "single_nested_attribute_assoc_ext_type": schema.SingleNestedAttribute{ + Attributes: map[string]schema.Attribute{ + "bool_attribute": schema.BoolAttribute{ + Optional: true, + }, + "float64_attribute": schema.Float64Attribute{ + Optional: true, + }, + "int64_attribute": schema.Int64Attribute{ + Optional: true, + }, + "number_attribute": schema.NumberAttribute{ + Optional: true, + }, + "string_attribute": schema.StringAttribute{ + Optional: true, + }, + }, + Optional: true, + }, + }, + Blocks: map[string]schema.Block{ + "list_nested_block_assoc_ext_type": schema.ListNestedBlock{ + NestedObject: schema.NestedBlockObject{ + Attributes: map[string]schema.Attribute{ + "bool_attribute": schema.BoolAttribute{ + Optional: true, + }, + "float64_attribute": schema.Float64Attribute{ + Optional: true, + }, + "int64_attribute": schema.Int64Attribute{ + Optional: true, + }, + "number_attribute": schema.NumberAttribute{ + Optional: true, + }, + "string_attribute": schema.StringAttribute{ + Optional: true, + }, + }, + }, + }, + "set_nested_block_assoc_ext_type": schema.SetNestedBlock{ + NestedObject: schema.NestedBlockObject{ + Attributes: map[string]schema.Attribute{ + "bool_attribute": schema.BoolAttribute{ + Optional: true, + }, + "float64_attribute": schema.Float64Attribute{ + Optional: true, + }, + "int64_attribute": schema.Int64Attribute{ + Optional: true, + }, + "number_attribute": schema.NumberAttribute{ + Optional: true, + }, + "string_attribute": schema.StringAttribute{ + Optional: true, + }, + }, + }, + }, + "single_nested_block_assoc_ext_type": schema.SingleNestedBlock{ + Attributes: map[string]schema.Attribute{ + "bool_attribute": schema.BoolAttribute{ + Optional: true, + }, + "float64_attribute": schema.Float64Attribute{ + Optional: true, + }, + "int64_attribute": schema.Int64Attribute{ + Optional: true, + }, + "number_attribute": schema.NumberAttribute{ + Optional: true, + }, + "string_attribute": schema.StringAttribute{ + Optional: true, + }, + }, + }, + }, +} + +type ResourceModel struct { + BoolAttribute my_bool_value `tfsdk:"bool_attribute"` + ListNestedAttributeAssocExtType types.List `tfsdk:"list_nested_attribute_assoc_ext_type"` + MapNestedAttributeAssocExtType types.Map `tfsdk:"map_nested_attribute_assoc_ext_type"` + SetNestedAttributeAssocExtType types.Set `tfsdk:"set_nested_attribute_assoc_ext_type"` + SingleNestedAttributeAssocExtType types.Object `tfsdk:"single_nested_attribute_assoc_ext_type"` + ListNestedBlockAssocExtType types.List `tfsdk:"list_nested_block_assoc_ext_type"` + SetNestedBlockAssocExtType types.Set `tfsdk:"set_nested_block_assoc_ext_type"` + SingleNestedBlockAssocExtType types.Object `tfsdk:"single_nested_block_assoc_ext_type"` +} + +type ListNestedAttributeAssocExtTypeModel struct { + BoolAttribute types.Bool `tfsdk:"bool_attribute"` + Float64Attribute types.Float64 `tfsdk:"float64_attribute"` + Int64Attribute types.Int64 `tfsdk:"int64_attribute"` + NumberAttribute types.Number `tfsdk:"number_attribute"` + StringAttribute types.String `tfsdk:"string_attribute"` +} + +type MapNestedAttributeAssocExtTypeModel struct { + BoolAttribute types.Bool `tfsdk:"bool_attribute"` + Float64Attribute types.Float64 `tfsdk:"float64_attribute"` + Int64Attribute types.Int64 `tfsdk:"int64_attribute"` + NumberAttribute types.Number `tfsdk:"number_attribute"` + StringAttribute types.String `tfsdk:"string_attribute"` +} + +type SetNestedAttributeAssocExtTypeModel struct { + BoolAttribute types.Bool `tfsdk:"bool_attribute"` + Float64Attribute types.Float64 `tfsdk:"float64_attribute"` + Int64Attribute types.Int64 `tfsdk:"int64_attribute"` + NumberAttribute types.Number `tfsdk:"number_attribute"` + StringAttribute types.String `tfsdk:"string_attribute"` +} + +type SingleNestedAttributeAssocExtTypeModel struct { + BoolAttribute types.Bool `tfsdk:"bool_attribute"` + Float64Attribute types.Float64 `tfsdk:"float64_attribute"` + Int64Attribute types.Int64 `tfsdk:"int64_attribute"` + NumberAttribute types.Number `tfsdk:"number_attribute"` + StringAttribute types.String `tfsdk:"string_attribute"` +} + +type ListNestedBlockAssocExtTypeModel struct { + BoolAttribute types.Bool `tfsdk:"bool_attribute"` + Float64Attribute types.Float64 `tfsdk:"float64_attribute"` + Int64Attribute types.Int64 `tfsdk:"int64_attribute"` + NumberAttribute types.Number `tfsdk:"number_attribute"` + StringAttribute types.String `tfsdk:"string_attribute"` +} + +type SetNestedBlockAssocExtTypeModel struct { + BoolAttribute types.Bool `tfsdk:"bool_attribute"` + Float64Attribute types.Float64 `tfsdk:"float64_attribute"` + Int64Attribute types.Int64 `tfsdk:"int64_attribute"` + NumberAttribute types.Number `tfsdk:"number_attribute"` + StringAttribute types.String `tfsdk:"string_attribute"` +} + +type SingleNestedBlockAssocExtTypeModel struct { + BoolAttribute types.Bool `tfsdk:"bool_attribute"` + Float64Attribute types.Float64 `tfsdk:"float64_attribute"` + Int64Attribute types.Int64 `tfsdk:"int64_attribute"` + NumberAttribute types.Number `tfsdk:"number_attribute"` + StringAttribute types.String `tfsdk:"string_attribute"` +} + +func (m ListNestedAttributeAssocExtTypeModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m ListNestedAttributeAssocExtTypeModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "bool_attribute": types.BoolType, + "float64_attribute": types.Float64Type, + "int64_attribute": types.Int64Type, + "number_attribute": types.NumberType, + "string_attribute": types.StringType, + } +} + +func (m ListNestedAttributeAssocExtTypeModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m ListNestedAttributeAssocExtTypeModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} +func (m MapNestedAttributeAssocExtTypeModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m MapNestedAttributeAssocExtTypeModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "bool_attribute": types.BoolType, + "float64_attribute": types.Float64Type, + "int64_attribute": types.Int64Type, + "number_attribute": types.NumberType, + "string_attribute": types.StringType, + } +} + +func (m MapNestedAttributeAssocExtTypeModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m MapNestedAttributeAssocExtTypeModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} +func (m SetNestedAttributeAssocExtTypeModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m SetNestedAttributeAssocExtTypeModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "bool_attribute": types.BoolType, + "float64_attribute": types.Float64Type, + "int64_attribute": types.Int64Type, + "number_attribute": types.NumberType, + "string_attribute": types.StringType, + } +} + +func (m SetNestedAttributeAssocExtTypeModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m SetNestedAttributeAssocExtTypeModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} +func (m SingleNestedAttributeAssocExtTypeModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m SingleNestedAttributeAssocExtTypeModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "bool_attribute": types.BoolType, + "float64_attribute": types.Float64Type, + "int64_attribute": types.Int64Type, + "number_attribute": types.NumberType, + "string_attribute": types.StringType, + } +} + +func (m SingleNestedAttributeAssocExtTypeModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m SingleNestedAttributeAssocExtTypeModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} +func (m ListNestedBlockAssocExtTypeModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m ListNestedBlockAssocExtTypeModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "bool_attribute": types.BoolType, + "float64_attribute": types.Float64Type, + "int64_attribute": types.Int64Type, + "number_attribute": types.NumberType, + "string_attribute": types.StringType, + } +} + +func (m ListNestedBlockAssocExtTypeModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m ListNestedBlockAssocExtTypeModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} +func (m SetNestedBlockAssocExtTypeModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m SetNestedBlockAssocExtTypeModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "bool_attribute": types.BoolType, + "float64_attribute": types.Float64Type, + "int64_attribute": types.Int64Type, + "number_attribute": types.NumberType, + "string_attribute": types.StringType, + } +} + +func (m SetNestedBlockAssocExtTypeModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m SetNestedBlockAssocExtTypeModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} +func (m SingleNestedBlockAssocExtTypeModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m SingleNestedBlockAssocExtTypeModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "bool_attribute": types.BoolType, + "float64_attribute": types.Float64Type, + "int64_attribute": types.Int64Type, + "number_attribute": types.NumberType, + "string_attribute": types.StringType, + } +} + +func (m SingleNestedBlockAssocExtTypeModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m SingleNestedBlockAssocExtTypeModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} + +func ToListNestedAttributeAssocExtType(ctx context.Context, tfList types.List) ([]*apisdk.Type, diag.Diagnostics) { + var diags diag.Diagnostics + + if tfList.IsNull() { + return nil, diags + } + + if tfList.IsUnknown() { + diags.Append(diag.NewErrorDiagnostic( + "List Value Is Unknown", + `Model field "ListNestedAttributeAssocExtType" is unknown.`, + )) + + return nil, diags + } + + var listObjects []types.Object + + diags.Append(tfList.ElementsAs(ctx, &listObjects, false)...) + + if diags.HasError() { + return nil, diags + } + + apiObjects := make([]*apisdk.Type, 0, len(listObjects)) + + for _, listObject := range listObjects { + if listObject.IsNull() { + apiObjects = append(apiObjects, nil) + + continue + } + + if listObject.IsUnknown() { + diags.Append(diag.NewErrorDiagnostic( + "Object Value Within List Is Unknown", + `Model field "ListNestedAttributeAssocExtType" contains an object which is unknown.`, + )) + + return nil, diags + } + + var tfModel ListNestedAttributeAssocExtTypeModel + + d := listObject.As(ctx, &tfModel, basetypes.ObjectAsOptions{}) + + diags.Append(d...) + + if diags.HasError() { + return nil, diags + } + + apiObjects = append(apiObjects, &apisdk.Type{ + BoolAttribute: tfModel.BoolAttribute.ValueBoolPointer(), + Float64Attribute: tfModel.Float64Attribute.ValueFloat64Pointer(), + Int64Attribute: tfModel.Int64Attribute.ValueInt64Pointer(), + NumberAttribute: tfModel.NumberAttribute.ValueBigFloat(), + StringAttribute: tfModel.StringAttribute.ValueStringPointer(), + }) + } + + return apiObjects, diags +} + +func FromListNestedAttributeAssocExtType(ctx context.Context, apiObjects []*apisdk.Type) (types.List, diag.Diagnostics) { + var diags diag.Diagnostics + var tfModel ListNestedAttributeAssocExtTypeModel + + if apiObjects == nil { + return types.ListNull( + tfModel.ObjectType(ctx), + ), diags + } + + var tfModels []*ListNestedAttributeAssocExtTypeModel + + for _, apiObject := range apiObjects { + if apiObject == nil { + tfModels = append(tfModels, nil) + + continue + } + + tfModels = append(tfModels, &ListNestedAttributeAssocExtTypeModel{ + BoolAttribute: types.BoolPointerValue(apiObject.BoolAttribute), + Float64Attribute: types.Float64PointerValue(apiObject.Float64Attribute), + Int64Attribute: types.Int64PointerValue(apiObject.Int64Attribute), + NumberAttribute: types.NumberValue(apiObject.NumberAttribute), + StringAttribute: types.StringPointerValue(apiObject.StringAttribute), + }) + } + + return types.ListValueFrom(ctx, tfModel.ObjectType(ctx), tfModels) +} + +func ToMapNestedAttributeAssocExtType(ctx context.Context, tfMap types.Map) (map[string]*apisdk.Type, diag.Diagnostics) { + var diags diag.Diagnostics + + if tfMap.IsNull() { + return nil, diags + } + + if tfMap.IsUnknown() { + diags.Append(diag.NewErrorDiagnostic( + "Map Value Is Unknown", + `Model field "MapNestedAttributeAssocExtType" is unknown.`, + )) + + return nil, diags + } + + mapObjects := make(map[string]types.Object) + + diags.Append(tfMap.ElementsAs(ctx, &mapObjects, false)...) + + if diags.HasError() { + return nil, diags + } + + apiObjects := make(map[string]*apisdk.Type, len(mapObjects)) + + for k, mapObject := range mapObjects { + if mapObject.IsNull() { + apiObjects[k] = nil + + continue + } + + if mapObject.IsUnknown() { + diags.Append(diag.NewErrorDiagnostic( + "Object Value Within Map Is Unknown", + `Model field "MapNestedAttributeAssocExtType" contains an object which is unknown.`, + )) + + return nil, diags + } + + var tfModel MapNestedAttributeAssocExtTypeModel + + d := mapObject.As(ctx, &tfModel, basetypes.ObjectAsOptions{}) + + diags.Append(d...) + + if diags.HasError() { + return nil, diags + } + + apiObjects[k] = &apisdk.Type{ + BoolAttribute: tfModel.BoolAttribute.ValueBoolPointer(), + Float64Attribute: tfModel.Float64Attribute.ValueFloat64Pointer(), + Int64Attribute: tfModel.Int64Attribute.ValueInt64Pointer(), + NumberAttribute: tfModel.NumberAttribute.ValueBigFloat(), + StringAttribute: tfModel.StringAttribute.ValueStringPointer(), + } + } + + return apiObjects, diags +} + +func FromMapNestedAttributeAssocExtType(ctx context.Context, apiObjects map[string]*apisdk.Type) (types.Map, diag.Diagnostics) { + var diags diag.Diagnostics + var tfModel MapNestedAttributeAssocExtTypeModel + + if apiObjects == nil { + return types.MapNull( + tfModel.ObjectType(ctx), + ), diags + } + + tfModels := make(map[string]*MapNestedAttributeAssocExtTypeModel) + + for k, apiObject := range apiObjects { + if apiObject == nil { + tfModels[k] = nil + + continue + } + + tfModels[k] = &MapNestedAttributeAssocExtTypeModel{ + BoolAttribute: types.BoolPointerValue(apiObject.BoolAttribute), + Float64Attribute: types.Float64PointerValue(apiObject.Float64Attribute), + Int64Attribute: types.Int64PointerValue(apiObject.Int64Attribute), + NumberAttribute: types.NumberValue(apiObject.NumberAttribute), + StringAttribute: types.StringPointerValue(apiObject.StringAttribute), + } + } + + return types.MapValueFrom(ctx, tfModel.ObjectType(ctx), tfModels) +} + +func ToSetNestedAttributeAssocExtType(ctx context.Context, tfSet types.Set) ([]*apisdk.Type, diag.Diagnostics) { + var diags diag.Diagnostics + + if tfSet.IsNull() { + return nil, diags + } + + if tfSet.IsUnknown() { + diags.Append(diag.NewErrorDiagnostic( + "Set Value Is Unknown", + `Model field "SetNestedAttributeAssocExtType" is unknown.`, + )) + + return nil, diags + } + + var setObjects []types.Object + + diags.Append(tfSet.ElementsAs(ctx, &setObjects, false)...) + + if diags.HasError() { + return nil, diags + } + + apiObjects := make([]*apisdk.Type, 0, len(setObjects)) + + for _, setObject := range setObjects { + if setObject.IsNull() { + apiObjects = append(apiObjects, nil) + + continue + } + + if setObject.IsUnknown() { + diags.Append(diag.NewErrorDiagnostic( + "Object Value Within Set Is Unknown", + `Model field "SetNestedAttributeAssocExtType" contains an object which is unknown.`, + )) + + return nil, diags + } + + var tfModel SetNestedAttributeAssocExtTypeModel + + d := setObject.As(ctx, &tfModel, basetypes.ObjectAsOptions{}) + + diags.Append(d...) + + if diags.HasError() { + return nil, diags + } + + apiObjects = append(apiObjects, &apisdk.Type{ + BoolAttribute: tfModel.BoolAttribute.ValueBoolPointer(), + Float64Attribute: tfModel.Float64Attribute.ValueFloat64Pointer(), + Int64Attribute: tfModel.Int64Attribute.ValueInt64Pointer(), + NumberAttribute: tfModel.NumberAttribute.ValueBigFloat(), + StringAttribute: tfModel.StringAttribute.ValueStringPointer(), + }) + } + + return apiObjects, diags +} + +func FromSetNestedAttributeAssocExtType(ctx context.Context, apiObjects []*apisdk.Type) (types.Set, diag.Diagnostics) { + var diags diag.Diagnostics + var tfModel SetNestedAttributeAssocExtTypeModel + + if apiObjects == nil { + return types.SetNull( + tfModel.ObjectType(ctx), + ), diags + } + + var tfModels []*SetNestedAttributeAssocExtTypeModel + + for _, apiObject := range apiObjects { + if apiObject == nil { + tfModels = append(tfModels, nil) + + continue + } + + tfModels = append(tfModels, &SetNestedAttributeAssocExtTypeModel{ + BoolAttribute: types.BoolPointerValue(apiObject.BoolAttribute), + Float64Attribute: types.Float64PointerValue(apiObject.Float64Attribute), + Int64Attribute: types.Int64PointerValue(apiObject.Int64Attribute), + NumberAttribute: types.NumberValue(apiObject.NumberAttribute), + StringAttribute: types.StringPointerValue(apiObject.StringAttribute), + }) + } + + return types.SetValueFrom(ctx, tfModel.ObjectType(ctx), tfModels) +} + +func ToSingleNestedAttributeAssocExtType(ctx context.Context, tfObject types.Object) (*apisdk.Type, diag.Diagnostics) { + var diags diag.Diagnostics + + if tfObject.IsNull() { + return nil, diags + } + + if tfObject.IsUnknown() { + diags.Append(diag.NewErrorDiagnostic( + "Object Value Is Unknown", + `Model field "SingleNestedAttributeAssocExtType" is unknown.`, + )) + + return nil, diags + } + + var tfModel SingleNestedAttributeAssocExtTypeModel + + diags.Append(tfObject.As(ctx, &tfModel, basetypes.ObjectAsOptions{})...) + + if diags.HasError() { + return nil, diags + } + + apiObject := &apisdk.Type{ + BoolAttribute: tfModel.BoolAttribute.ValueBoolPointer(), + Float64Attribute: tfModel.Float64Attribute.ValueFloat64Pointer(), + Int64Attribute: tfModel.Int64Attribute.ValueInt64Pointer(), + NumberAttribute: tfModel.NumberAttribute.ValueBigFloat(), + StringAttribute: tfModel.StringAttribute.ValueStringPointer(), + } + + return apiObject, diags +} + +func FromSingleNestedAttributeAssocExtType(ctx context.Context, apiObject *apisdk.Type) (types.Object, diag.Diagnostics) { + var diags diag.Diagnostics + var tfModel SingleNestedAttributeAssocExtTypeModel + + if apiObject == nil { + return tfModel.ObjectNull(ctx), diags + } + + tfModel.BoolAttribute = types.BoolPointerValue(apiObject.BoolAttribute) + tfModel.Float64Attribute = types.Float64PointerValue(apiObject.Float64Attribute) + tfModel.Int64Attribute = types.Int64PointerValue(apiObject.Int64Attribute) + tfModel.NumberAttribute = types.NumberValue(apiObject.NumberAttribute) + tfModel.StringAttribute = types.StringPointerValue(apiObject.StringAttribute) + + return tfModel.ObjectValueFrom(ctx, tfModel) +} + +func ToListNestedBlockAssocExtType(ctx context.Context, tfList types.List) ([]*apisdk.Type, diag.Diagnostics) { + var diags diag.Diagnostics + + if tfList.IsNull() { + return nil, diags + } + + if tfList.IsUnknown() { + diags.Append(diag.NewErrorDiagnostic( + "List Value Is Unknown", + `Model field "ListNestedBlockAssocExtType" is unknown.`, + )) + + return nil, diags + } + + var listObjects []types.Object + + diags.Append(tfList.ElementsAs(ctx, &listObjects, false)...) + + if diags.HasError() { + return nil, diags + } + + apiObjects := make([]*apisdk.Type, 0, len(listObjects)) + + for _, listObject := range listObjects { + if listObject.IsNull() { + apiObjects = append(apiObjects, nil) + + continue + } + + if listObject.IsUnknown() { + diags.Append(diag.NewErrorDiagnostic( + "Object Value Within List Is Unknown", + `Model field "ListNestedBlockAssocExtType" contains an object which is unknown.`, + )) + + return nil, diags + } + + var tfModel ListNestedBlockAssocExtTypeModel + + d := listObject.As(ctx, &tfModel, basetypes.ObjectAsOptions{}) + + diags.Append(d...) + + if diags.HasError() { + return nil, diags + } + + apiObjects = append(apiObjects, &apisdk.Type{ + BoolAttribute: tfModel.BoolAttribute.ValueBoolPointer(), + Float64Attribute: tfModel.Float64Attribute.ValueFloat64Pointer(), + Int64Attribute: tfModel.Int64Attribute.ValueInt64Pointer(), + NumberAttribute: tfModel.NumberAttribute.ValueBigFloat(), + StringAttribute: tfModel.StringAttribute.ValueStringPointer(), + }) + } + + return apiObjects, diags +} + +func FromListNestedBlockAssocExtType(ctx context.Context, apiObjects []*apisdk.Type) (types.List, diag.Diagnostics) { + var diags diag.Diagnostics + var tfModel ListNestedBlockAssocExtTypeModel + + if apiObjects == nil { + return types.ListNull( + tfModel.ObjectType(ctx), + ), diags + } + + var tfModels []*ListNestedBlockAssocExtTypeModel + + for _, apiObject := range apiObjects { + if apiObject == nil { + tfModels = append(tfModels, nil) + + continue + } + + tfModels = append(tfModels, &ListNestedBlockAssocExtTypeModel{ + BoolAttribute: types.BoolPointerValue(apiObject.BoolAttribute), + Float64Attribute: types.Float64PointerValue(apiObject.Float64Attribute), + Int64Attribute: types.Int64PointerValue(apiObject.Int64Attribute), + NumberAttribute: types.NumberValue(apiObject.NumberAttribute), + StringAttribute: types.StringPointerValue(apiObject.StringAttribute), + }) + } + + return types.ListValueFrom(ctx, tfModel.ObjectType(ctx), tfModels) +} + +func ToSetNestedBlockAssocExtType(ctx context.Context, tfSet types.Set) ([]*apisdk.Type, diag.Diagnostics) { + var diags diag.Diagnostics + + if tfSet.IsNull() { + return nil, diags + } + + if tfSet.IsUnknown() { + diags.Append(diag.NewErrorDiagnostic( + "Set Value Is Unknown", + `Model field "SetNestedBlockAssocExtType" is unknown.`, + )) + + return nil, diags + } + + var setObjects []types.Object + + diags.Append(tfSet.ElementsAs(ctx, &setObjects, false)...) + + if diags.HasError() { + return nil, diags + } + + apiObjects := make([]*apisdk.Type, 0, len(setObjects)) + + for _, setObject := range setObjects { + if setObject.IsNull() { + apiObjects = append(apiObjects, nil) + + continue + } + + if setObject.IsUnknown() { + diags.Append(diag.NewErrorDiagnostic( + "Object Value Within Set Is Unknown", + `Model field "SetNestedBlockAssocExtType" contains an object which is unknown.`, + )) + + return nil, diags + } + + var tfModel SetNestedBlockAssocExtTypeModel + + d := setObject.As(ctx, &tfModel, basetypes.ObjectAsOptions{}) + + diags.Append(d...) + + if diags.HasError() { + return nil, diags + } + + apiObjects = append(apiObjects, &apisdk.Type{ + BoolAttribute: tfModel.BoolAttribute.ValueBoolPointer(), + Float64Attribute: tfModel.Float64Attribute.ValueFloat64Pointer(), + Int64Attribute: tfModel.Int64Attribute.ValueInt64Pointer(), + NumberAttribute: tfModel.NumberAttribute.ValueBigFloat(), + StringAttribute: tfModel.StringAttribute.ValueStringPointer(), + }) + } + + return apiObjects, diags +} + +func FromSetNestedBlockAssocExtType(ctx context.Context, apiObjects []*apisdk.Type) (types.Set, diag.Diagnostics) { + var diags diag.Diagnostics + var tfModel SetNestedBlockAssocExtTypeModel + + if apiObjects == nil { + return types.SetNull( + tfModel.ObjectType(ctx), + ), diags + } + + var tfModels []*SetNestedBlockAssocExtTypeModel + + for _, apiObject := range apiObjects { + if apiObject == nil { + tfModels = append(tfModels, nil) + + continue + } + + tfModels = append(tfModels, &SetNestedBlockAssocExtTypeModel{ + BoolAttribute: types.BoolPointerValue(apiObject.BoolAttribute), + Float64Attribute: types.Float64PointerValue(apiObject.Float64Attribute), + Int64Attribute: types.Int64PointerValue(apiObject.Int64Attribute), + NumberAttribute: types.NumberValue(apiObject.NumberAttribute), + StringAttribute: types.StringPointerValue(apiObject.StringAttribute), + }) + } + + return types.SetValueFrom(ctx, tfModel.ObjectType(ctx), tfModels) +} + +func ToSingleNestedBlockAssocExtType(ctx context.Context, tfObject types.Object) (*apisdk.Type, diag.Diagnostics) { + var diags diag.Diagnostics + + if tfObject.IsNull() { + return nil, diags + } + + if tfObject.IsUnknown() { + diags.Append(diag.NewErrorDiagnostic( + "Object Value Is Unknown", + `Model field "SingleNestedBlockAssocExtType" is unknown.`, + )) + + return nil, diags + } + + var tfModel SingleNestedBlockAssocExtTypeModel + + diags.Append(tfObject.As(ctx, &tfModel, basetypes.ObjectAsOptions{})...) + + if diags.HasError() { + return nil, diags + } + + apiObject := &apisdk.Type{ + BoolAttribute: tfModel.BoolAttribute.ValueBoolPointer(), + Float64Attribute: tfModel.Float64Attribute.ValueFloat64Pointer(), + Int64Attribute: tfModel.Int64Attribute.ValueInt64Pointer(), + NumberAttribute: tfModel.NumberAttribute.ValueBigFloat(), + StringAttribute: tfModel.StringAttribute.ValueStringPointer(), + } + + return apiObject, diags +} + +func FromSingleNestedBlockAssocExtType(ctx context.Context, apiObject *apisdk.Type) (types.Object, diag.Diagnostics) { + var diags diag.Diagnostics + var tfModel SingleNestedBlockAssocExtTypeModel + + if apiObject == nil { + return tfModel.ObjectNull(ctx), diags + } + + tfModel.BoolAttribute = types.BoolPointerValue(apiObject.BoolAttribute) + tfModel.Float64Attribute = types.Float64PointerValue(apiObject.Float64Attribute) + tfModel.Int64Attribute = types.Int64PointerValue(apiObject.Int64Attribute) + tfModel.NumberAttribute = types.NumberValue(apiObject.NumberAttribute) + tfModel.StringAttribute = types.StringPointerValue(apiObject.StringAttribute) + + return tfModel.ObjectValueFrom(ctx, tfModel) +} diff --git a/internal/cmd/testdata/custom_and_external/all_output/specified_pkg_name/datasource_data_source_gen.go b/internal/cmd/testdata/custom_and_external/all_output/specified_pkg_name/datasource_data_source_gen.go new file mode 100644 index 00000000..04de2682 --- /dev/null +++ b/internal/cmd/testdata/custom_and_external/all_output/specified_pkg_name/datasource_data_source_gen.go @@ -0,0 +1,1863 @@ +// Code generated by terraform-plugin-framework-generator DO NOT EDIT. + +package specified + +import ( + "context" + "example.com/apisdk" + "github.com/hashicorp/terraform-plugin-framework/attr" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-framework/types/basetypes" +) + +var datasourceDataSourceSchema = schema.Schema{ + Attributes: map[string]schema.Attribute{ + "bool_attribute": schema.BoolAttribute{ + Computed: true, + }, + "list_list_attribute": schema.ListAttribute{ + ElementType: types.ListType{ + ElemType: types.StringType, + }, + Computed: true, + }, + "list_map_attribute": schema.ListAttribute{ + ElementType: types.MapType{ + ElemType: types.StringType, + }, + Computed: true, + }, + "list_nested_attribute_assoc_ext_type": schema.ListNestedAttribute{ + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "bool_attribute": schema.BoolAttribute{ + Computed: true, + }, + "float64_attribute": schema.Float64Attribute{ + Optional: true, + Computed: true, + }, + "int64_attribute": schema.Int64Attribute{ + Optional: true, + Computed: true, + }, + "number_attribute": schema.NumberAttribute{ + Optional: true, + Computed: true, + }, + "string_attribute": schema.StringAttribute{ + Optional: true, + Computed: true, + }, + }, + }, + Optional: true, + }, + "list_nested_attribute_one": schema.ListNestedAttribute{ + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "bool_attribute": schema.BoolAttribute{ + Computed: true, + }, + }, + }, + Computed: true, + }, + "list_nested_attribute_three": schema.ListNestedAttribute{ + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "list_nested_attribute_three_list_nested_attribute_one": schema.ListNestedAttribute{ + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "list_attribute": schema.ListAttribute{ + ElementType: types.StringType, + Computed: true, + }, + }, + }, + Computed: true, + }, + }, + }, + Computed: true, + }, + "list_nested_attribute_two": schema.ListNestedAttribute{ + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "list_nested_attribute_two_list_nested_attribute_one": schema.ListNestedAttribute{ + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "bool_attribute": schema.BoolAttribute{ + Computed: true, + }, + }, + }, + Computed: true, + }, + }, + }, + Computed: true, + }, + "list_object_attribute": schema.ListAttribute{ + ElementType: types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "obj_string_attr": types.StringType, + }, + }, + Computed: true, + }, + "list_object_object_attribute": schema.ListAttribute{ + ElementType: types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "obj_obj_attr": types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "obj_obj_string_attr": types.StringType, + }, + }, + }, + }, + Computed: true, + }, + "map_nested_attribute_assoc_ext_type": schema.MapNestedAttribute{ + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "bool_attribute": schema.BoolAttribute{ + Computed: true, + }, + "float64_attribute": schema.Float64Attribute{ + Optional: true, + Computed: true, + }, + "int64_attribute": schema.Int64Attribute{ + Optional: true, + Computed: true, + }, + "number_attribute": schema.NumberAttribute{ + Optional: true, + Computed: true, + }, + "string_attribute": schema.StringAttribute{ + Optional: true, + Computed: true, + }, + }, + }, + Optional: true, + }, + "object_attribute": schema.ObjectAttribute{ + AttributeTypes: map[string]attr.Type{ + "obj_string_attr": types.StringType, + }, + Computed: true, + }, + "object_list_attribute": schema.ObjectAttribute{ + AttributeTypes: map[string]attr.Type{ + "obj_list_attr": types.ListType{ + ElemType: types.StringType, + }, + }, + Computed: true, + }, + "object_list_object_attribute": schema.ObjectAttribute{ + AttributeTypes: map[string]attr.Type{ + "obj_list_attr": types.ListType{ + ElemType: types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "obj_list_obj_attr": types.StringType, + }, + }, + }, + }, + Computed: true, + }, + "set_nested_attribute_assoc_ext_type": schema.SetNestedAttribute{ + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "bool_attribute": schema.BoolAttribute{ + Computed: true, + }, + "float64_attribute": schema.Float64Attribute{ + Optional: true, + Computed: true, + }, + "int64_attribute": schema.Int64Attribute{ + Optional: true, + Computed: true, + }, + "number_attribute": schema.NumberAttribute{ + Optional: true, + Computed: true, + }, + "string_attribute": schema.StringAttribute{ + Optional: true, + Computed: true, + }, + }, + }, + Optional: true, + }, + "single_nested_attribute_assoc_ext_type": schema.SingleNestedAttribute{ + Attributes: map[string]schema.Attribute{ + "bool_attribute": schema.BoolAttribute{ + Computed: true, + }, + "float64_attribute": schema.Float64Attribute{ + Optional: true, + Computed: true, + }, + "int64_attribute": schema.Int64Attribute{ + Optional: true, + Computed: true, + }, + "number_attribute": schema.NumberAttribute{ + Optional: true, + Computed: true, + }, + "string_attribute": schema.StringAttribute{ + Optional: true, + Computed: true, + }, + }, + Optional: true, + }, + "single_nested_attribute_one": schema.SingleNestedAttribute{ + Attributes: map[string]schema.Attribute{ + "bool_attribute": schema.BoolAttribute{ + Computed: true, + }, + }, + Computed: true, + }, + "single_nested_attribute_three": schema.SingleNestedAttribute{ + Attributes: map[string]schema.Attribute{ + "single_nested_attribute_three_single_nested_attribute_one": schema.SingleNestedAttribute{ + Attributes: map[string]schema.Attribute{ + "list_attribute": schema.ListAttribute{ + ElementType: types.StringType, + Computed: true, + }, + }, + Computed: true, + }, + }, + Computed: true, + }, + "single_nested_attribute_two": schema.SingleNestedAttribute{ + Attributes: map[string]schema.Attribute{ + "single_nested_attribute_two_single_nested_attribute_one": schema.SingleNestedAttribute{ + Attributes: map[string]schema.Attribute{ + "bool_attribute": schema.BoolAttribute{ + Computed: true, + }, + }, + Computed: true, + }, + }, + Computed: true, + }, + }, + Blocks: map[string]schema.Block{ + "list_nested_block_assoc_ext_type": schema.ListNestedBlock{ + NestedObject: schema.NestedBlockObject{ + Attributes: map[string]schema.Attribute{ + "bool_attribute": schema.BoolAttribute{ + Computed: true, + }, + "float64_attribute": schema.Float64Attribute{ + Optional: true, + Computed: true, + }, + "int64_attribute": schema.Int64Attribute{ + Optional: true, + Computed: true, + }, + "number_attribute": schema.NumberAttribute{ + Optional: true, + Computed: true, + }, + "string_attribute": schema.StringAttribute{ + Optional: true, + Computed: true, + }, + }, + }, + }, + "list_nested_block_one": schema.ListNestedBlock{ + NestedObject: schema.NestedBlockObject{ + Attributes: map[string]schema.Attribute{ + "bool_attribute": schema.BoolAttribute{ + Computed: true, + }, + }, + }, + }, + "list_nested_block_three": schema.ListNestedBlock{ + NestedObject: schema.NestedBlockObject{ + Attributes: map[string]schema.Attribute{ + "object_attribute": schema.ObjectAttribute{ + AttributeTypes: map[string]attr.Type{ + "string_attribute_type": types.StringType, + }, + Computed: true, + }, + }, + Blocks: map[string]schema.Block{ + "list_nested_block_three_list_nested_block_one": schema.ListNestedBlock{ + NestedObject: schema.NestedBlockObject{ + Attributes: map[string]schema.Attribute{ + "list_attribute": schema.ListAttribute{ + ElementType: types.StringType, + Computed: true, + }, + }, + }, + }, + }, + }, + }, + "list_nested_block_two": schema.ListNestedBlock{ + NestedObject: schema.NestedBlockObject{ + Blocks: map[string]schema.Block{ + "list_nested_block_two_list_nested_block_one": schema.ListNestedBlock{ + NestedObject: schema.NestedBlockObject{ + Attributes: map[string]schema.Attribute{ + "bool_attribute": schema.BoolAttribute{ + Computed: true, + }, + }, + }, + }, + }, + }, + }, + "set_nested_block_assoc_ext_type": schema.SetNestedBlock{ + NestedObject: schema.NestedBlockObject{ + Attributes: map[string]schema.Attribute{ + "bool_attribute": schema.BoolAttribute{ + Computed: true, + }, + "float64_attribute": schema.Float64Attribute{ + Optional: true, + Computed: true, + }, + "int64_attribute": schema.Int64Attribute{ + Optional: true, + Computed: true, + }, + "number_attribute": schema.NumberAttribute{ + Optional: true, + Computed: true, + }, + "string_attribute": schema.StringAttribute{ + Optional: true, + Computed: true, + }, + }, + }, + }, + "single_nested_block_assoc_ext_type": schema.SingleNestedBlock{ + Attributes: map[string]schema.Attribute{ + "bool_attribute": schema.BoolAttribute{ + Computed: true, + }, + "float64_attribute": schema.Float64Attribute{ + Optional: true, + Computed: true, + }, + "int64_attribute": schema.Int64Attribute{ + Optional: true, + Computed: true, + }, + "number_attribute": schema.NumberAttribute{ + Optional: true, + Computed: true, + }, + "string_attribute": schema.StringAttribute{ + Optional: true, + Computed: true, + }, + }, + }, + "single_nested_block_one": schema.SingleNestedBlock{ + Attributes: map[string]schema.Attribute{ + "bool_attribute": schema.BoolAttribute{ + Computed: true, + }, + }, + }, + "single_nested_block_three": schema.SingleNestedBlock{ + Attributes: map[string]schema.Attribute{ + "object_attribute": schema.ObjectAttribute{ + AttributeTypes: map[string]attr.Type{ + "string_attribute_type": types.StringType, + }, + Computed: true, + }, + }, + Blocks: map[string]schema.Block{ + "single_nested_block_three_list_nested_block_one": schema.ListNestedBlock{ + NestedObject: schema.NestedBlockObject{ + Attributes: map[string]schema.Attribute{ + "list_attribute": schema.ListAttribute{ + ElementType: types.StringType, + Computed: true, + }, + }, + }, + }, + }, + }, + "single_nested_block_two": schema.SingleNestedBlock{ + Blocks: map[string]schema.Block{ + "single_nested_block_two_single_nested_block_one": schema.SingleNestedBlock{ + Attributes: map[string]schema.Attribute{ + "bool_attribute": schema.BoolAttribute{ + Computed: true, + }, + }, + }, + }, + }, + }, +} + +type DatasourceModel struct { + BoolAttribute types.Bool `tfsdk:"bool_attribute"` + ListListAttribute types.List `tfsdk:"list_list_attribute"` + ListMapAttribute types.List `tfsdk:"list_map_attribute"` + ListNestedAttributeAssocExtType types.List `tfsdk:"list_nested_attribute_assoc_ext_type"` + ListNestedAttributeOne types.List `tfsdk:"list_nested_attribute_one"` + ListNestedAttributeThree types.List `tfsdk:"list_nested_attribute_three"` + ListNestedAttributeTwo types.List `tfsdk:"list_nested_attribute_two"` + ListObjectAttribute types.List `tfsdk:"list_object_attribute"` + ListObjectObjectAttribute types.List `tfsdk:"list_object_object_attribute"` + MapNestedAttributeAssocExtType types.Map `tfsdk:"map_nested_attribute_assoc_ext_type"` + ObjectAttribute types.Object `tfsdk:"object_attribute"` + ObjectListAttribute types.Object `tfsdk:"object_list_attribute"` + ObjectListObjectAttribute types.Object `tfsdk:"object_list_object_attribute"` + SetNestedAttributeAssocExtType types.Set `tfsdk:"set_nested_attribute_assoc_ext_type"` + SingleNestedAttributeAssocExtType types.Object `tfsdk:"single_nested_attribute_assoc_ext_type"` + SingleNestedAttributeOne types.Object `tfsdk:"single_nested_attribute_one"` + SingleNestedAttributeThree types.Object `tfsdk:"single_nested_attribute_three"` + SingleNestedAttributeTwo types.Object `tfsdk:"single_nested_attribute_two"` + ListNestedBlockAssocExtType types.List `tfsdk:"list_nested_block_assoc_ext_type"` + ListNestedBlockOne types.List `tfsdk:"list_nested_block_one"` + ListNestedBlockThree types.List `tfsdk:"list_nested_block_three"` + ListNestedBlockTwo types.List `tfsdk:"list_nested_block_two"` + SetNestedBlockAssocExtType types.Set `tfsdk:"set_nested_block_assoc_ext_type"` + SingleNestedBlockAssocExtType types.Object `tfsdk:"single_nested_block_assoc_ext_type"` + SingleNestedBlockOne types.Object `tfsdk:"single_nested_block_one"` + SingleNestedBlockThree types.Object `tfsdk:"single_nested_block_three"` + SingleNestedBlockTwo types.Object `tfsdk:"single_nested_block_two"` +} + +type ListNestedAttributeAssocExtTypeModel struct { + BoolAttribute types.Bool `tfsdk:"bool_attribute"` + Float64Attribute types.Float64 `tfsdk:"float64_attribute"` + Int64Attribute types.Int64 `tfsdk:"int64_attribute"` + NumberAttribute types.Number `tfsdk:"number_attribute"` + StringAttribute types.String `tfsdk:"string_attribute"` +} + +type ListNestedAttributeOneModel struct { + BoolAttribute types.Bool `tfsdk:"bool_attribute"` +} + +type ListNestedAttributeThreeModel struct { + ListNestedAttributeThreeListNestedAttributeOne types.List `tfsdk:"list_nested_attribute_three_list_nested_attribute_one"` +} + +type ListNestedAttributeThreeListNestedAttributeOneModel struct { + ListAttribute types.List `tfsdk:"list_attribute"` +} + +type ListNestedAttributeTwoModel struct { + ListNestedAttributeTwoListNestedAttributeOne types.List `tfsdk:"list_nested_attribute_two_list_nested_attribute_one"` +} + +type ListNestedAttributeTwoListNestedAttributeOneModel struct { + BoolAttribute types.Bool `tfsdk:"bool_attribute"` +} + +type MapNestedAttributeAssocExtTypeModel struct { + BoolAttribute types.Bool `tfsdk:"bool_attribute"` + Float64Attribute types.Float64 `tfsdk:"float64_attribute"` + Int64Attribute types.Int64 `tfsdk:"int64_attribute"` + NumberAttribute types.Number `tfsdk:"number_attribute"` + StringAttribute types.String `tfsdk:"string_attribute"` +} + +type SetNestedAttributeAssocExtTypeModel struct { + BoolAttribute types.Bool `tfsdk:"bool_attribute"` + Float64Attribute types.Float64 `tfsdk:"float64_attribute"` + Int64Attribute types.Int64 `tfsdk:"int64_attribute"` + NumberAttribute types.Number `tfsdk:"number_attribute"` + StringAttribute types.String `tfsdk:"string_attribute"` +} + +type SingleNestedAttributeAssocExtTypeModel struct { + BoolAttribute types.Bool `tfsdk:"bool_attribute"` + Float64Attribute types.Float64 `tfsdk:"float64_attribute"` + Int64Attribute types.Int64 `tfsdk:"int64_attribute"` + NumberAttribute types.Number `tfsdk:"number_attribute"` + StringAttribute types.String `tfsdk:"string_attribute"` +} + +type SingleNestedAttributeOneModel struct { + BoolAttribute types.Bool `tfsdk:"bool_attribute"` +} + +type SingleNestedAttributeThreeModel struct { + SingleNestedAttributeThreeSingleNestedAttributeOne types.Object `tfsdk:"single_nested_attribute_three_single_nested_attribute_one"` +} + +type SingleNestedAttributeThreeSingleNestedAttributeOneModel struct { + ListAttribute types.List `tfsdk:"list_attribute"` +} + +type SingleNestedAttributeTwoModel struct { + SingleNestedAttributeTwoSingleNestedAttributeOne types.Object `tfsdk:"single_nested_attribute_two_single_nested_attribute_one"` +} + +type SingleNestedAttributeTwoSingleNestedAttributeOneModel struct { + BoolAttribute types.Bool `tfsdk:"bool_attribute"` +} + +type ListNestedBlockAssocExtTypeModel struct { + BoolAttribute types.Bool `tfsdk:"bool_attribute"` + Float64Attribute types.Float64 `tfsdk:"float64_attribute"` + Int64Attribute types.Int64 `tfsdk:"int64_attribute"` + NumberAttribute types.Number `tfsdk:"number_attribute"` + StringAttribute types.String `tfsdk:"string_attribute"` +} + +type ListNestedBlockOneModel struct { + BoolAttribute types.Bool `tfsdk:"bool_attribute"` +} + +type ListNestedBlockThreeModel struct { + ObjectAttribute types.Object `tfsdk:"object_attribute"` + ListNestedBlockThreeListNestedBlockOne types.List `tfsdk:"list_nested_block_three_list_nested_block_one"` +} + +type ListNestedBlockThreeListNestedBlockOneModel struct { + ListAttribute types.List `tfsdk:"list_attribute"` +} + +type ListNestedBlockTwoModel struct { + ListNestedBlockTwoListNestedBlockOne types.List `tfsdk:"list_nested_block_two_list_nested_block_one"` +} + +type ListNestedBlockTwoListNestedBlockOneModel struct { + BoolAttribute types.Bool `tfsdk:"bool_attribute"` +} + +type SetNestedBlockAssocExtTypeModel struct { + BoolAttribute types.Bool `tfsdk:"bool_attribute"` + Float64Attribute types.Float64 `tfsdk:"float64_attribute"` + Int64Attribute types.Int64 `tfsdk:"int64_attribute"` + NumberAttribute types.Number `tfsdk:"number_attribute"` + StringAttribute types.String `tfsdk:"string_attribute"` +} + +type SingleNestedBlockAssocExtTypeModel struct { + BoolAttribute types.Bool `tfsdk:"bool_attribute"` + Float64Attribute types.Float64 `tfsdk:"float64_attribute"` + Int64Attribute types.Int64 `tfsdk:"int64_attribute"` + NumberAttribute types.Number `tfsdk:"number_attribute"` + StringAttribute types.String `tfsdk:"string_attribute"` +} + +type SingleNestedBlockOneModel struct { + BoolAttribute types.Bool `tfsdk:"bool_attribute"` +} + +type SingleNestedBlockThreeModel struct { + ObjectAttribute types.Object `tfsdk:"object_attribute"` + SingleNestedBlockThreeListNestedBlockOne types.List `tfsdk:"single_nested_block_three_list_nested_block_one"` +} + +type SingleNestedBlockThreeListNestedBlockOneModel struct { + ListAttribute types.List `tfsdk:"list_attribute"` +} + +type SingleNestedBlockTwoModel struct { + SingleNestedBlockTwoSingleNestedBlockOne types.Object `tfsdk:"single_nested_block_two_single_nested_block_one"` +} + +type SingleNestedBlockTwoSingleNestedBlockOneModel struct { + BoolAttribute types.Bool `tfsdk:"bool_attribute"` +} + +func (m ListNestedAttributeAssocExtTypeModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m ListNestedAttributeAssocExtTypeModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "bool_attribute": types.BoolType, + "float64_attribute": types.Float64Type, + "int64_attribute": types.Int64Type, + "number_attribute": types.NumberType, + "string_attribute": types.StringType, + } +} + +func (m ListNestedAttributeAssocExtTypeModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m ListNestedAttributeAssocExtTypeModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} +func (m ListNestedAttributeOneModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m ListNestedAttributeOneModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "bool_attribute": types.BoolType, + } +} + +func (m ListNestedAttributeOneModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m ListNestedAttributeOneModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} +func (m ListNestedAttributeThreeModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m ListNestedAttributeThreeModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "list_nested_attribute_three_list_nested_attribute_one": types.ListType{ + ElemType: ListNestedAttributeThreeListNestedAttributeOneModel{}.ObjectType(ctx), + }, + } +} + +func (m ListNestedAttributeThreeModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m ListNestedAttributeThreeModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} + +func (m ListNestedAttributeThreeListNestedAttributeOneModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m ListNestedAttributeThreeListNestedAttributeOneModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "list_attribute": types.ListType{ + ElemType: types.StringType, + }, + } +} + +func (m ListNestedAttributeThreeListNestedAttributeOneModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m ListNestedAttributeThreeListNestedAttributeOneModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} +func (m ListNestedAttributeTwoModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m ListNestedAttributeTwoModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "list_nested_attribute_two_list_nested_attribute_one": types.ListType{ + ElemType: ListNestedAttributeTwoListNestedAttributeOneModel{}.ObjectType(ctx), + }, + } +} + +func (m ListNestedAttributeTwoModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m ListNestedAttributeTwoModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} + +func (m ListNestedAttributeTwoListNestedAttributeOneModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m ListNestedAttributeTwoListNestedAttributeOneModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "bool_attribute": types.BoolType, + } +} + +func (m ListNestedAttributeTwoListNestedAttributeOneModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m ListNestedAttributeTwoListNestedAttributeOneModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} +func (m MapNestedAttributeAssocExtTypeModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m MapNestedAttributeAssocExtTypeModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "bool_attribute": types.BoolType, + "float64_attribute": types.Float64Type, + "int64_attribute": types.Int64Type, + "number_attribute": types.NumberType, + "string_attribute": types.StringType, + } +} + +func (m MapNestedAttributeAssocExtTypeModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m MapNestedAttributeAssocExtTypeModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} +func (m SetNestedAttributeAssocExtTypeModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m SetNestedAttributeAssocExtTypeModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "bool_attribute": types.BoolType, + "float64_attribute": types.Float64Type, + "int64_attribute": types.Int64Type, + "number_attribute": types.NumberType, + "string_attribute": types.StringType, + } +} + +func (m SetNestedAttributeAssocExtTypeModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m SetNestedAttributeAssocExtTypeModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} +func (m SingleNestedAttributeAssocExtTypeModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m SingleNestedAttributeAssocExtTypeModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "bool_attribute": types.BoolType, + "float64_attribute": types.Float64Type, + "int64_attribute": types.Int64Type, + "number_attribute": types.NumberType, + "string_attribute": types.StringType, + } +} + +func (m SingleNestedAttributeAssocExtTypeModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m SingleNestedAttributeAssocExtTypeModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} +func (m SingleNestedAttributeOneModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m SingleNestedAttributeOneModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "bool_attribute": types.BoolType, + } +} + +func (m SingleNestedAttributeOneModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m SingleNestedAttributeOneModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} +func (m SingleNestedAttributeThreeModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m SingleNestedAttributeThreeModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "single_nested_attribute_three_single_nested_attribute_one": types.ObjectType{ + AttrTypes: SingleNestedAttributeThreeSingleNestedAttributeOneModel{}.ObjectAttributeTypes(ctx), + }, + } +} + +func (m SingleNestedAttributeThreeModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m SingleNestedAttributeThreeModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} + +func (m SingleNestedAttributeThreeSingleNestedAttributeOneModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m SingleNestedAttributeThreeSingleNestedAttributeOneModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "list_attribute": types.ListType{ + ElemType: types.StringType, + }, + } +} + +func (m SingleNestedAttributeThreeSingleNestedAttributeOneModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m SingleNestedAttributeThreeSingleNestedAttributeOneModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} +func (m SingleNestedAttributeTwoModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m SingleNestedAttributeTwoModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "single_nested_attribute_two_single_nested_attribute_one": types.ObjectType{ + AttrTypes: SingleNestedAttributeTwoSingleNestedAttributeOneModel{}.ObjectAttributeTypes(ctx), + }, + } +} + +func (m SingleNestedAttributeTwoModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m SingleNestedAttributeTwoModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} + +func (m SingleNestedAttributeTwoSingleNestedAttributeOneModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m SingleNestedAttributeTwoSingleNestedAttributeOneModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "bool_attribute": types.BoolType, + } +} + +func (m SingleNestedAttributeTwoSingleNestedAttributeOneModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m SingleNestedAttributeTwoSingleNestedAttributeOneModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} +func (m ListNestedBlockAssocExtTypeModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m ListNestedBlockAssocExtTypeModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "bool_attribute": types.BoolType, + "float64_attribute": types.Float64Type, + "int64_attribute": types.Int64Type, + "number_attribute": types.NumberType, + "string_attribute": types.StringType, + } +} + +func (m ListNestedBlockAssocExtTypeModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m ListNestedBlockAssocExtTypeModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} +func (m ListNestedBlockOneModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m ListNestedBlockOneModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "bool_attribute": types.BoolType, + } +} + +func (m ListNestedBlockOneModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m ListNestedBlockOneModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} +func (m ListNestedBlockThreeModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m ListNestedBlockThreeModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "list_nested_block_three_list_nested_block_one": types.ListType{ + ElemType: ListNestedBlockThreeListNestedBlockOneModel{}.ObjectType(ctx), + }, + "object_attribute": types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "string_attribute_type": types.StringType, + }, + }, + } +} + +func (m ListNestedBlockThreeModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m ListNestedBlockThreeModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} + +func (m ListNestedBlockThreeListNestedBlockOneModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m ListNestedBlockThreeListNestedBlockOneModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "list_attribute": types.ListType{ + ElemType: types.StringType, + }, + } +} + +func (m ListNestedBlockThreeListNestedBlockOneModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m ListNestedBlockThreeListNestedBlockOneModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} +func (m ListNestedBlockTwoModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m ListNestedBlockTwoModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "list_nested_block_two_list_nested_block_one": types.ListType{ + ElemType: ListNestedBlockTwoListNestedBlockOneModel{}.ObjectType(ctx), + }, + } +} + +func (m ListNestedBlockTwoModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m ListNestedBlockTwoModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} + +func (m ListNestedBlockTwoListNestedBlockOneModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m ListNestedBlockTwoListNestedBlockOneModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "bool_attribute": types.BoolType, + } +} + +func (m ListNestedBlockTwoListNestedBlockOneModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m ListNestedBlockTwoListNestedBlockOneModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} +func (m SetNestedBlockAssocExtTypeModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m SetNestedBlockAssocExtTypeModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "bool_attribute": types.BoolType, + "float64_attribute": types.Float64Type, + "int64_attribute": types.Int64Type, + "number_attribute": types.NumberType, + "string_attribute": types.StringType, + } +} + +func (m SetNestedBlockAssocExtTypeModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m SetNestedBlockAssocExtTypeModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} +func (m SingleNestedBlockAssocExtTypeModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m SingleNestedBlockAssocExtTypeModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "bool_attribute": types.BoolType, + "float64_attribute": types.Float64Type, + "int64_attribute": types.Int64Type, + "number_attribute": types.NumberType, + "string_attribute": types.StringType, + } +} + +func (m SingleNestedBlockAssocExtTypeModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m SingleNestedBlockAssocExtTypeModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} +func (m SingleNestedBlockOneModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m SingleNestedBlockOneModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "bool_attribute": types.BoolType, + } +} + +func (m SingleNestedBlockOneModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m SingleNestedBlockOneModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} +func (m SingleNestedBlockThreeModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m SingleNestedBlockThreeModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "object_attribute": types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "string_attribute_type": types.StringType, + }, + }, + "single_nested_block_three_list_nested_block_one": types.ListType{ + ElemType: SingleNestedBlockThreeListNestedBlockOneModel{}.ObjectType(ctx), + }, + } +} + +func (m SingleNestedBlockThreeModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m SingleNestedBlockThreeModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} + +func (m SingleNestedBlockThreeListNestedBlockOneModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m SingleNestedBlockThreeListNestedBlockOneModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "list_attribute": types.ListType{ + ElemType: types.StringType, + }, + } +} + +func (m SingleNestedBlockThreeListNestedBlockOneModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m SingleNestedBlockThreeListNestedBlockOneModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} +func (m SingleNestedBlockTwoModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m SingleNestedBlockTwoModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "single_nested_block_two_single_nested_block_one": types.ObjectType{ + AttrTypes: SingleNestedBlockTwoSingleNestedBlockOneModel{}.ObjectAttributeTypes(ctx), + }, + } +} + +func (m SingleNestedBlockTwoModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m SingleNestedBlockTwoModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} + +func (m SingleNestedBlockTwoSingleNestedBlockOneModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m SingleNestedBlockTwoSingleNestedBlockOneModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "bool_attribute": types.BoolType, + } +} + +func (m SingleNestedBlockTwoSingleNestedBlockOneModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m SingleNestedBlockTwoSingleNestedBlockOneModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} + +func ToListNestedAttributeAssocExtType(ctx context.Context, tfList types.List) ([]*apisdk.Type, diag.Diagnostics) { + var diags diag.Diagnostics + + if tfList.IsNull() { + return nil, diags + } + + if tfList.IsUnknown() { + diags.Append(diag.NewErrorDiagnostic( + "List Value Is Unknown", + `Model field "ListNestedAttributeAssocExtType" is unknown.`, + )) + + return nil, diags + } + + var listObjects []types.Object + + diags.Append(tfList.ElementsAs(ctx, &listObjects, false)...) + + if diags.HasError() { + return nil, diags + } + + apiObjects := make([]*apisdk.Type, 0, len(listObjects)) + + for _, listObject := range listObjects { + if listObject.IsNull() { + apiObjects = append(apiObjects, nil) + + continue + } + + if listObject.IsUnknown() { + diags.Append(diag.NewErrorDiagnostic( + "Object Value Within List Is Unknown", + `Model field "ListNestedAttributeAssocExtType" contains an object which is unknown.`, + )) + + return nil, diags + } + + var tfModel ListNestedAttributeAssocExtTypeModel + + d := listObject.As(ctx, &tfModel, basetypes.ObjectAsOptions{}) + + diags.Append(d...) + + if diags.HasError() { + return nil, diags + } + + apiObjects = append(apiObjects, &apisdk.Type{ + BoolAttribute: tfModel.BoolAttribute.ValueBoolPointer(), + Float64Attribute: tfModel.Float64Attribute.ValueFloat64Pointer(), + Int64Attribute: tfModel.Int64Attribute.ValueInt64Pointer(), + NumberAttribute: tfModel.NumberAttribute.ValueBigFloat(), + StringAttribute: tfModel.StringAttribute.ValueStringPointer(), + }) + } + + return apiObjects, diags +} + +func FromListNestedAttributeAssocExtType(ctx context.Context, apiObjects []*apisdk.Type) (types.List, diag.Diagnostics) { + var diags diag.Diagnostics + var tfModel ListNestedAttributeAssocExtTypeModel + + if apiObjects == nil { + return types.ListNull( + tfModel.ObjectType(ctx), + ), diags + } + + var tfModels []*ListNestedAttributeAssocExtTypeModel + + for _, apiObject := range apiObjects { + if apiObject == nil { + tfModels = append(tfModels, nil) + + continue + } + + tfModels = append(tfModels, &ListNestedAttributeAssocExtTypeModel{ + BoolAttribute: types.BoolPointerValue(apiObject.BoolAttribute), + Float64Attribute: types.Float64PointerValue(apiObject.Float64Attribute), + Int64Attribute: types.Int64PointerValue(apiObject.Int64Attribute), + NumberAttribute: types.NumberValue(apiObject.NumberAttribute), + StringAttribute: types.StringPointerValue(apiObject.StringAttribute), + }) + } + + return types.ListValueFrom(ctx, tfModel.ObjectType(ctx), tfModels) +} + +func ToMapNestedAttributeAssocExtType(ctx context.Context, tfMap types.Map) (map[string]*apisdk.Type, diag.Diagnostics) { + var diags diag.Diagnostics + + if tfMap.IsNull() { + return nil, diags + } + + if tfMap.IsUnknown() { + diags.Append(diag.NewErrorDiagnostic( + "Map Value Is Unknown", + `Model field "MapNestedAttributeAssocExtType" is unknown.`, + )) + + return nil, diags + } + + mapObjects := make(map[string]types.Object) + + diags.Append(tfMap.ElementsAs(ctx, &mapObjects, false)...) + + if diags.HasError() { + return nil, diags + } + + apiObjects := make(map[string]*apisdk.Type, len(mapObjects)) + + for k, mapObject := range mapObjects { + if mapObject.IsNull() { + apiObjects[k] = nil + + continue + } + + if mapObject.IsUnknown() { + diags.Append(diag.NewErrorDiagnostic( + "Object Value Within Map Is Unknown", + `Model field "MapNestedAttributeAssocExtType" contains an object which is unknown.`, + )) + + return nil, diags + } + + var tfModel MapNestedAttributeAssocExtTypeModel + + d := mapObject.As(ctx, &tfModel, basetypes.ObjectAsOptions{}) + + diags.Append(d...) + + if diags.HasError() { + return nil, diags + } + + apiObjects[k] = &apisdk.Type{ + BoolAttribute: tfModel.BoolAttribute.ValueBoolPointer(), + Float64Attribute: tfModel.Float64Attribute.ValueFloat64Pointer(), + Int64Attribute: tfModel.Int64Attribute.ValueInt64Pointer(), + NumberAttribute: tfModel.NumberAttribute.ValueBigFloat(), + StringAttribute: tfModel.StringAttribute.ValueStringPointer(), + } + } + + return apiObjects, diags +} + +func FromMapNestedAttributeAssocExtType(ctx context.Context, apiObjects map[string]*apisdk.Type) (types.Map, diag.Diagnostics) { + var diags diag.Diagnostics + var tfModel MapNestedAttributeAssocExtTypeModel + + if apiObjects == nil { + return types.MapNull( + tfModel.ObjectType(ctx), + ), diags + } + + tfModels := make(map[string]*MapNestedAttributeAssocExtTypeModel) + + for k, apiObject := range apiObjects { + if apiObject == nil { + tfModels[k] = nil + + continue + } + + tfModels[k] = &MapNestedAttributeAssocExtTypeModel{ + BoolAttribute: types.BoolPointerValue(apiObject.BoolAttribute), + Float64Attribute: types.Float64PointerValue(apiObject.Float64Attribute), + Int64Attribute: types.Int64PointerValue(apiObject.Int64Attribute), + NumberAttribute: types.NumberValue(apiObject.NumberAttribute), + StringAttribute: types.StringPointerValue(apiObject.StringAttribute), + } + } + + return types.MapValueFrom(ctx, tfModel.ObjectType(ctx), tfModels) +} + +func ToSetNestedAttributeAssocExtType(ctx context.Context, tfSet types.Set) ([]*apisdk.Type, diag.Diagnostics) { + var diags diag.Diagnostics + + if tfSet.IsNull() { + return nil, diags + } + + if tfSet.IsUnknown() { + diags.Append(diag.NewErrorDiagnostic( + "Set Value Is Unknown", + `Model field "SetNestedAttributeAssocExtType" is unknown.`, + )) + + return nil, diags + } + + var setObjects []types.Object + + diags.Append(tfSet.ElementsAs(ctx, &setObjects, false)...) + + if diags.HasError() { + return nil, diags + } + + apiObjects := make([]*apisdk.Type, 0, len(setObjects)) + + for _, setObject := range setObjects { + if setObject.IsNull() { + apiObjects = append(apiObjects, nil) + + continue + } + + if setObject.IsUnknown() { + diags.Append(diag.NewErrorDiagnostic( + "Object Value Within Set Is Unknown", + `Model field "SetNestedAttributeAssocExtType" contains an object which is unknown.`, + )) + + return nil, diags + } + + var tfModel SetNestedAttributeAssocExtTypeModel + + d := setObject.As(ctx, &tfModel, basetypes.ObjectAsOptions{}) + + diags.Append(d...) + + if diags.HasError() { + return nil, diags + } + + apiObjects = append(apiObjects, &apisdk.Type{ + BoolAttribute: tfModel.BoolAttribute.ValueBoolPointer(), + Float64Attribute: tfModel.Float64Attribute.ValueFloat64Pointer(), + Int64Attribute: tfModel.Int64Attribute.ValueInt64Pointer(), + NumberAttribute: tfModel.NumberAttribute.ValueBigFloat(), + StringAttribute: tfModel.StringAttribute.ValueStringPointer(), + }) + } + + return apiObjects, diags +} + +func FromSetNestedAttributeAssocExtType(ctx context.Context, apiObjects []*apisdk.Type) (types.Set, diag.Diagnostics) { + var diags diag.Diagnostics + var tfModel SetNestedAttributeAssocExtTypeModel + + if apiObjects == nil { + return types.SetNull( + tfModel.ObjectType(ctx), + ), diags + } + + var tfModels []*SetNestedAttributeAssocExtTypeModel + + for _, apiObject := range apiObjects { + if apiObject == nil { + tfModels = append(tfModels, nil) + + continue + } + + tfModels = append(tfModels, &SetNestedAttributeAssocExtTypeModel{ + BoolAttribute: types.BoolPointerValue(apiObject.BoolAttribute), + Float64Attribute: types.Float64PointerValue(apiObject.Float64Attribute), + Int64Attribute: types.Int64PointerValue(apiObject.Int64Attribute), + NumberAttribute: types.NumberValue(apiObject.NumberAttribute), + StringAttribute: types.StringPointerValue(apiObject.StringAttribute), + }) + } + + return types.SetValueFrom(ctx, tfModel.ObjectType(ctx), tfModels) +} + +func ToSingleNestedAttributeAssocExtType(ctx context.Context, tfObject types.Object) (*apisdk.Type, diag.Diagnostics) { + var diags diag.Diagnostics + + if tfObject.IsNull() { + return nil, diags + } + + if tfObject.IsUnknown() { + diags.Append(diag.NewErrorDiagnostic( + "Object Value Is Unknown", + `Model field "SingleNestedAttributeAssocExtType" is unknown.`, + )) + + return nil, diags + } + + var tfModel SingleNestedAttributeAssocExtTypeModel + + diags.Append(tfObject.As(ctx, &tfModel, basetypes.ObjectAsOptions{})...) + + if diags.HasError() { + return nil, diags + } + + apiObject := &apisdk.Type{ + BoolAttribute: tfModel.BoolAttribute.ValueBoolPointer(), + Float64Attribute: tfModel.Float64Attribute.ValueFloat64Pointer(), + Int64Attribute: tfModel.Int64Attribute.ValueInt64Pointer(), + NumberAttribute: tfModel.NumberAttribute.ValueBigFloat(), + StringAttribute: tfModel.StringAttribute.ValueStringPointer(), + } + + return apiObject, diags +} + +func FromSingleNestedAttributeAssocExtType(ctx context.Context, apiObject *apisdk.Type) (types.Object, diag.Diagnostics) { + var diags diag.Diagnostics + var tfModel SingleNestedAttributeAssocExtTypeModel + + if apiObject == nil { + return tfModel.ObjectNull(ctx), diags + } + + tfModel.BoolAttribute = types.BoolPointerValue(apiObject.BoolAttribute) + tfModel.Float64Attribute = types.Float64PointerValue(apiObject.Float64Attribute) + tfModel.Int64Attribute = types.Int64PointerValue(apiObject.Int64Attribute) + tfModel.NumberAttribute = types.NumberValue(apiObject.NumberAttribute) + tfModel.StringAttribute = types.StringPointerValue(apiObject.StringAttribute) + + return tfModel.ObjectValueFrom(ctx, tfModel) +} + +func ToListNestedBlockAssocExtType(ctx context.Context, tfList types.List) ([]*apisdk.Type, diag.Diagnostics) { + var diags diag.Diagnostics + + if tfList.IsNull() { + return nil, diags + } + + if tfList.IsUnknown() { + diags.Append(diag.NewErrorDiagnostic( + "List Value Is Unknown", + `Model field "ListNestedBlockAssocExtType" is unknown.`, + )) + + return nil, diags + } + + var listObjects []types.Object + + diags.Append(tfList.ElementsAs(ctx, &listObjects, false)...) + + if diags.HasError() { + return nil, diags + } + + apiObjects := make([]*apisdk.Type, 0, len(listObjects)) + + for _, listObject := range listObjects { + if listObject.IsNull() { + apiObjects = append(apiObjects, nil) + + continue + } + + if listObject.IsUnknown() { + diags.Append(diag.NewErrorDiagnostic( + "Object Value Within List Is Unknown", + `Model field "ListNestedBlockAssocExtType" contains an object which is unknown.`, + )) + + return nil, diags + } + + var tfModel ListNestedBlockAssocExtTypeModel + + d := listObject.As(ctx, &tfModel, basetypes.ObjectAsOptions{}) + + diags.Append(d...) + + if diags.HasError() { + return nil, diags + } + + apiObjects = append(apiObjects, &apisdk.Type{ + BoolAttribute: tfModel.BoolAttribute.ValueBoolPointer(), + Float64Attribute: tfModel.Float64Attribute.ValueFloat64Pointer(), + Int64Attribute: tfModel.Int64Attribute.ValueInt64Pointer(), + NumberAttribute: tfModel.NumberAttribute.ValueBigFloat(), + StringAttribute: tfModel.StringAttribute.ValueStringPointer(), + }) + } + + return apiObjects, diags +} + +func FromListNestedBlockAssocExtType(ctx context.Context, apiObjects []*apisdk.Type) (types.List, diag.Diagnostics) { + var diags diag.Diagnostics + var tfModel ListNestedBlockAssocExtTypeModel + + if apiObjects == nil { + return types.ListNull( + tfModel.ObjectType(ctx), + ), diags + } + + var tfModels []*ListNestedBlockAssocExtTypeModel + + for _, apiObject := range apiObjects { + if apiObject == nil { + tfModels = append(tfModels, nil) + + continue + } + + tfModels = append(tfModels, &ListNestedBlockAssocExtTypeModel{ + BoolAttribute: types.BoolPointerValue(apiObject.BoolAttribute), + Float64Attribute: types.Float64PointerValue(apiObject.Float64Attribute), + Int64Attribute: types.Int64PointerValue(apiObject.Int64Attribute), + NumberAttribute: types.NumberValue(apiObject.NumberAttribute), + StringAttribute: types.StringPointerValue(apiObject.StringAttribute), + }) + } + + return types.ListValueFrom(ctx, tfModel.ObjectType(ctx), tfModels) +} + +func ToSetNestedBlockAssocExtType(ctx context.Context, tfSet types.Set) ([]*apisdk.Type, diag.Diagnostics) { + var diags diag.Diagnostics + + if tfSet.IsNull() { + return nil, diags + } + + if tfSet.IsUnknown() { + diags.Append(diag.NewErrorDiagnostic( + "Set Value Is Unknown", + `Model field "SetNestedBlockAssocExtType" is unknown.`, + )) + + return nil, diags + } + + var setObjects []types.Object + + diags.Append(tfSet.ElementsAs(ctx, &setObjects, false)...) + + if diags.HasError() { + return nil, diags + } + + apiObjects := make([]*apisdk.Type, 0, len(setObjects)) + + for _, setObject := range setObjects { + if setObject.IsNull() { + apiObjects = append(apiObjects, nil) + + continue + } + + if setObject.IsUnknown() { + diags.Append(diag.NewErrorDiagnostic( + "Object Value Within Set Is Unknown", + `Model field "SetNestedBlockAssocExtType" contains an object which is unknown.`, + )) + + return nil, diags + } + + var tfModel SetNestedBlockAssocExtTypeModel + + d := setObject.As(ctx, &tfModel, basetypes.ObjectAsOptions{}) + + diags.Append(d...) + + if diags.HasError() { + return nil, diags + } + + apiObjects = append(apiObjects, &apisdk.Type{ + BoolAttribute: tfModel.BoolAttribute.ValueBoolPointer(), + Float64Attribute: tfModel.Float64Attribute.ValueFloat64Pointer(), + Int64Attribute: tfModel.Int64Attribute.ValueInt64Pointer(), + NumberAttribute: tfModel.NumberAttribute.ValueBigFloat(), + StringAttribute: tfModel.StringAttribute.ValueStringPointer(), + }) + } + + return apiObjects, diags +} + +func FromSetNestedBlockAssocExtType(ctx context.Context, apiObjects []*apisdk.Type) (types.Set, diag.Diagnostics) { + var diags diag.Diagnostics + var tfModel SetNestedBlockAssocExtTypeModel + + if apiObjects == nil { + return types.SetNull( + tfModel.ObjectType(ctx), + ), diags + } + + var tfModels []*SetNestedBlockAssocExtTypeModel + + for _, apiObject := range apiObjects { + if apiObject == nil { + tfModels = append(tfModels, nil) + + continue + } + + tfModels = append(tfModels, &SetNestedBlockAssocExtTypeModel{ + BoolAttribute: types.BoolPointerValue(apiObject.BoolAttribute), + Float64Attribute: types.Float64PointerValue(apiObject.Float64Attribute), + Int64Attribute: types.Int64PointerValue(apiObject.Int64Attribute), + NumberAttribute: types.NumberValue(apiObject.NumberAttribute), + StringAttribute: types.StringPointerValue(apiObject.StringAttribute), + }) + } + + return types.SetValueFrom(ctx, tfModel.ObjectType(ctx), tfModels) +} + +func ToSingleNestedBlockAssocExtType(ctx context.Context, tfObject types.Object) (*apisdk.Type, diag.Diagnostics) { + var diags diag.Diagnostics + + if tfObject.IsNull() { + return nil, diags + } + + if tfObject.IsUnknown() { + diags.Append(diag.NewErrorDiagnostic( + "Object Value Is Unknown", + `Model field "SingleNestedBlockAssocExtType" is unknown.`, + )) + + return nil, diags + } + + var tfModel SingleNestedBlockAssocExtTypeModel + + diags.Append(tfObject.As(ctx, &tfModel, basetypes.ObjectAsOptions{})...) + + if diags.HasError() { + return nil, diags + } + + apiObject := &apisdk.Type{ + BoolAttribute: tfModel.BoolAttribute.ValueBoolPointer(), + Float64Attribute: tfModel.Float64Attribute.ValueFloat64Pointer(), + Int64Attribute: tfModel.Int64Attribute.ValueInt64Pointer(), + NumberAttribute: tfModel.NumberAttribute.ValueBigFloat(), + StringAttribute: tfModel.StringAttribute.ValueStringPointer(), + } + + return apiObject, diags +} + +func FromSingleNestedBlockAssocExtType(ctx context.Context, apiObject *apisdk.Type) (types.Object, diag.Diagnostics) { + var diags diag.Diagnostics + var tfModel SingleNestedBlockAssocExtTypeModel + + if apiObject == nil { + return tfModel.ObjectNull(ctx), diags + } + + tfModel.BoolAttribute = types.BoolPointerValue(apiObject.BoolAttribute) + tfModel.Float64Attribute = types.Float64PointerValue(apiObject.Float64Attribute) + tfModel.Int64Attribute = types.Int64PointerValue(apiObject.Int64Attribute) + tfModel.NumberAttribute = types.NumberValue(apiObject.NumberAttribute) + tfModel.StringAttribute = types.StringPointerValue(apiObject.StringAttribute) + + return tfModel.ObjectValueFrom(ctx, tfModel) +} diff --git a/internal/cmd/testdata/custom_and_external/all_output/specified_pkg_name/provider_provider_gen.go b/internal/cmd/testdata/custom_and_external/all_output/specified_pkg_name/provider_provider_gen.go new file mode 100644 index 00000000..129b9531 --- /dev/null +++ b/internal/cmd/testdata/custom_and_external/all_output/specified_pkg_name/provider_provider_gen.go @@ -0,0 +1,1002 @@ +// Code generated by terraform-plugin-framework-generator DO NOT EDIT. + +package specified + +import ( + "context" + "example.com/apisdk" + "github.com/hashicorp/terraform-plugin-framework/attr" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/provider/schema" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-framework/types/basetypes" +) + +var providerProviderSchema = schema.Schema{ + Attributes: map[string]schema.Attribute{ + "list_nested_attribute_assoc_ext_type": schema.ListNestedAttribute{ + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "bool_attribute": schema.BoolAttribute{ + Optional: true, + }, + "float64_attribute": schema.Float64Attribute{ + Optional: true, + }, + "int64_attribute": schema.Int64Attribute{ + Optional: true, + }, + "number_attribute": schema.NumberAttribute{ + Optional: true, + }, + "string_attribute": schema.StringAttribute{ + Optional: true, + }, + }, + }, + Optional: true, + }, + "map_nested_attribute_assoc_ext_type": schema.MapNestedAttribute{ + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "bool_attribute": schema.BoolAttribute{ + Optional: true, + }, + "float64_attribute": schema.Float64Attribute{ + Optional: true, + }, + "int64_attribute": schema.Int64Attribute{ + Optional: true, + }, + "number_attribute": schema.NumberAttribute{ + Optional: true, + }, + "string_attribute": schema.StringAttribute{ + Optional: true, + }, + }, + }, + Optional: true, + }, + "set_nested_attribute_assoc_ext_type": schema.SetNestedAttribute{ + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "bool_attribute": schema.BoolAttribute{ + Optional: true, + }, + "float64_attribute": schema.Float64Attribute{ + Optional: true, + }, + "int64_attribute": schema.Int64Attribute{ + Optional: true, + }, + "number_attribute": schema.NumberAttribute{ + Optional: true, + }, + "string_attribute": schema.StringAttribute{ + Optional: true, + }, + }, + }, + Optional: true, + }, + "single_nested_attribute_assoc_ext_type": schema.SingleNestedAttribute{ + Attributes: map[string]schema.Attribute{ + "bool_attribute": schema.BoolAttribute{ + Optional: true, + }, + "float64_attribute": schema.Float64Attribute{ + Optional: true, + }, + "int64_attribute": schema.Int64Attribute{ + Optional: true, + }, + "number_attribute": schema.NumberAttribute{ + Optional: true, + }, + "string_attribute": schema.StringAttribute{ + Optional: true, + }, + }, + Optional: true, + }, + }, + Blocks: map[string]schema.Block{ + "list_nested_block_assoc_ext_type": schema.ListNestedBlock{ + NestedObject: schema.NestedBlockObject{ + Attributes: map[string]schema.Attribute{ + "bool_attribute": schema.BoolAttribute{ + Optional: true, + }, + "float64_attribute": schema.Float64Attribute{ + Optional: true, + }, + "int64_attribute": schema.Int64Attribute{ + Optional: true, + }, + "number_attribute": schema.NumberAttribute{ + Optional: true, + }, + "string_attribute": schema.StringAttribute{ + Optional: true, + }, + }, + }, + }, + "set_nested_block_assoc_ext_type": schema.SetNestedBlock{ + NestedObject: schema.NestedBlockObject{ + Attributes: map[string]schema.Attribute{ + "bool_attribute": schema.BoolAttribute{ + Optional: true, + }, + "float64_attribute": schema.Float64Attribute{ + Optional: true, + }, + "int64_attribute": schema.Int64Attribute{ + Optional: true, + }, + "number_attribute": schema.NumberAttribute{ + Optional: true, + }, + "string_attribute": schema.StringAttribute{ + Optional: true, + }, + }, + }, + }, + "single_nested_block_assoc_ext_type": schema.SingleNestedBlock{ + Attributes: map[string]schema.Attribute{ + "bool_attribute": schema.BoolAttribute{ + Optional: true, + }, + "float64_attribute": schema.Float64Attribute{ + Optional: true, + }, + "int64_attribute": schema.Int64Attribute{ + Optional: true, + }, + "number_attribute": schema.NumberAttribute{ + Optional: true, + }, + "string_attribute": schema.StringAttribute{ + Optional: true, + }, + }, + }, + }, +} + +type ProviderModel struct { + ListNestedAttributeAssocExtType types.List `tfsdk:"list_nested_attribute_assoc_ext_type"` + MapNestedAttributeAssocExtType types.Map `tfsdk:"map_nested_attribute_assoc_ext_type"` + SetNestedAttributeAssocExtType types.Set `tfsdk:"set_nested_attribute_assoc_ext_type"` + SingleNestedAttributeAssocExtType types.Object `tfsdk:"single_nested_attribute_assoc_ext_type"` + ListNestedBlockAssocExtType types.List `tfsdk:"list_nested_block_assoc_ext_type"` + SetNestedBlockAssocExtType types.Set `tfsdk:"set_nested_block_assoc_ext_type"` + SingleNestedBlockAssocExtType types.Object `tfsdk:"single_nested_block_assoc_ext_type"` +} + +type ListNestedAttributeAssocExtTypeModel struct { + BoolAttribute types.Bool `tfsdk:"bool_attribute"` + Float64Attribute types.Float64 `tfsdk:"float64_attribute"` + Int64Attribute types.Int64 `tfsdk:"int64_attribute"` + NumberAttribute types.Number `tfsdk:"number_attribute"` + StringAttribute types.String `tfsdk:"string_attribute"` +} + +type MapNestedAttributeAssocExtTypeModel struct { + BoolAttribute types.Bool `tfsdk:"bool_attribute"` + Float64Attribute types.Float64 `tfsdk:"float64_attribute"` + Int64Attribute types.Int64 `tfsdk:"int64_attribute"` + NumberAttribute types.Number `tfsdk:"number_attribute"` + StringAttribute types.String `tfsdk:"string_attribute"` +} + +type SetNestedAttributeAssocExtTypeModel struct { + BoolAttribute types.Bool `tfsdk:"bool_attribute"` + Float64Attribute types.Float64 `tfsdk:"float64_attribute"` + Int64Attribute types.Int64 `tfsdk:"int64_attribute"` + NumberAttribute types.Number `tfsdk:"number_attribute"` + StringAttribute types.String `tfsdk:"string_attribute"` +} + +type SingleNestedAttributeAssocExtTypeModel struct { + BoolAttribute types.Bool `tfsdk:"bool_attribute"` + Float64Attribute types.Float64 `tfsdk:"float64_attribute"` + Int64Attribute types.Int64 `tfsdk:"int64_attribute"` + NumberAttribute types.Number `tfsdk:"number_attribute"` + StringAttribute types.String `tfsdk:"string_attribute"` +} + +type ListNestedBlockAssocExtTypeModel struct { + BoolAttribute types.Bool `tfsdk:"bool_attribute"` + Float64Attribute types.Float64 `tfsdk:"float64_attribute"` + Int64Attribute types.Int64 `tfsdk:"int64_attribute"` + NumberAttribute types.Number `tfsdk:"number_attribute"` + StringAttribute types.String `tfsdk:"string_attribute"` +} + +type SetNestedBlockAssocExtTypeModel struct { + BoolAttribute types.Bool `tfsdk:"bool_attribute"` + Float64Attribute types.Float64 `tfsdk:"float64_attribute"` + Int64Attribute types.Int64 `tfsdk:"int64_attribute"` + NumberAttribute types.Number `tfsdk:"number_attribute"` + StringAttribute types.String `tfsdk:"string_attribute"` +} + +type SingleNestedBlockAssocExtTypeModel struct { + BoolAttribute types.Bool `tfsdk:"bool_attribute"` + Float64Attribute types.Float64 `tfsdk:"float64_attribute"` + Int64Attribute types.Int64 `tfsdk:"int64_attribute"` + NumberAttribute types.Number `tfsdk:"number_attribute"` + StringAttribute types.String `tfsdk:"string_attribute"` +} + +func (m ListNestedAttributeAssocExtTypeModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m ListNestedAttributeAssocExtTypeModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "bool_attribute": types.BoolType, + "float64_attribute": types.Float64Type, + "int64_attribute": types.Int64Type, + "number_attribute": types.NumberType, + "string_attribute": types.StringType, + } +} + +func (m ListNestedAttributeAssocExtTypeModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m ListNestedAttributeAssocExtTypeModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} +func (m MapNestedAttributeAssocExtTypeModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m MapNestedAttributeAssocExtTypeModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "bool_attribute": types.BoolType, + "float64_attribute": types.Float64Type, + "int64_attribute": types.Int64Type, + "number_attribute": types.NumberType, + "string_attribute": types.StringType, + } +} + +func (m MapNestedAttributeAssocExtTypeModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m MapNestedAttributeAssocExtTypeModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} +func (m SetNestedAttributeAssocExtTypeModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m SetNestedAttributeAssocExtTypeModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "bool_attribute": types.BoolType, + "float64_attribute": types.Float64Type, + "int64_attribute": types.Int64Type, + "number_attribute": types.NumberType, + "string_attribute": types.StringType, + } +} + +func (m SetNestedAttributeAssocExtTypeModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m SetNestedAttributeAssocExtTypeModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} +func (m SingleNestedAttributeAssocExtTypeModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m SingleNestedAttributeAssocExtTypeModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "bool_attribute": types.BoolType, + "float64_attribute": types.Float64Type, + "int64_attribute": types.Int64Type, + "number_attribute": types.NumberType, + "string_attribute": types.StringType, + } +} + +func (m SingleNestedAttributeAssocExtTypeModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m SingleNestedAttributeAssocExtTypeModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} +func (m ListNestedBlockAssocExtTypeModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m ListNestedBlockAssocExtTypeModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "bool_attribute": types.BoolType, + "float64_attribute": types.Float64Type, + "int64_attribute": types.Int64Type, + "number_attribute": types.NumberType, + "string_attribute": types.StringType, + } +} + +func (m ListNestedBlockAssocExtTypeModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m ListNestedBlockAssocExtTypeModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} +func (m SetNestedBlockAssocExtTypeModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m SetNestedBlockAssocExtTypeModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "bool_attribute": types.BoolType, + "float64_attribute": types.Float64Type, + "int64_attribute": types.Int64Type, + "number_attribute": types.NumberType, + "string_attribute": types.StringType, + } +} + +func (m SetNestedBlockAssocExtTypeModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m SetNestedBlockAssocExtTypeModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} +func (m SingleNestedBlockAssocExtTypeModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m SingleNestedBlockAssocExtTypeModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "bool_attribute": types.BoolType, + "float64_attribute": types.Float64Type, + "int64_attribute": types.Int64Type, + "number_attribute": types.NumberType, + "string_attribute": types.StringType, + } +} + +func (m SingleNestedBlockAssocExtTypeModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m SingleNestedBlockAssocExtTypeModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} + +func ToListNestedAttributeAssocExtType(ctx context.Context, tfList types.List) ([]*apisdk.Type, diag.Diagnostics) { + var diags diag.Diagnostics + + if tfList.IsNull() { + return nil, diags + } + + if tfList.IsUnknown() { + diags.Append(diag.NewErrorDiagnostic( + "List Value Is Unknown", + `Model field "ListNestedAttributeAssocExtType" is unknown.`, + )) + + return nil, diags + } + + var listObjects []types.Object + + diags.Append(tfList.ElementsAs(ctx, &listObjects, false)...) + + if diags.HasError() { + return nil, diags + } + + apiObjects := make([]*apisdk.Type, 0, len(listObjects)) + + for _, listObject := range listObjects { + if listObject.IsNull() { + apiObjects = append(apiObjects, nil) + + continue + } + + if listObject.IsUnknown() { + diags.Append(diag.NewErrorDiagnostic( + "Object Value Within List Is Unknown", + `Model field "ListNestedAttributeAssocExtType" contains an object which is unknown.`, + )) + + return nil, diags + } + + var tfModel ListNestedAttributeAssocExtTypeModel + + d := listObject.As(ctx, &tfModel, basetypes.ObjectAsOptions{}) + + diags.Append(d...) + + if diags.HasError() { + return nil, diags + } + + apiObjects = append(apiObjects, &apisdk.Type{ + BoolAttribute: tfModel.BoolAttribute.ValueBoolPointer(), + Float64Attribute: tfModel.Float64Attribute.ValueFloat64Pointer(), + Int64Attribute: tfModel.Int64Attribute.ValueInt64Pointer(), + NumberAttribute: tfModel.NumberAttribute.ValueBigFloat(), + StringAttribute: tfModel.StringAttribute.ValueStringPointer(), + }) + } + + return apiObjects, diags +} + +func FromListNestedAttributeAssocExtType(ctx context.Context, apiObjects []*apisdk.Type) (types.List, diag.Diagnostics) { + var diags diag.Diagnostics + var tfModel ListNestedAttributeAssocExtTypeModel + + if apiObjects == nil { + return types.ListNull( + tfModel.ObjectType(ctx), + ), diags + } + + var tfModels []*ListNestedAttributeAssocExtTypeModel + + for _, apiObject := range apiObjects { + if apiObject == nil { + tfModels = append(tfModels, nil) + + continue + } + + tfModels = append(tfModels, &ListNestedAttributeAssocExtTypeModel{ + BoolAttribute: types.BoolPointerValue(apiObject.BoolAttribute), + Float64Attribute: types.Float64PointerValue(apiObject.Float64Attribute), + Int64Attribute: types.Int64PointerValue(apiObject.Int64Attribute), + NumberAttribute: types.NumberValue(apiObject.NumberAttribute), + StringAttribute: types.StringPointerValue(apiObject.StringAttribute), + }) + } + + return types.ListValueFrom(ctx, tfModel.ObjectType(ctx), tfModels) +} + +func ToMapNestedAttributeAssocExtType(ctx context.Context, tfMap types.Map) (map[string]*apisdk.Type, diag.Diagnostics) { + var diags diag.Diagnostics + + if tfMap.IsNull() { + return nil, diags + } + + if tfMap.IsUnknown() { + diags.Append(diag.NewErrorDiagnostic( + "Map Value Is Unknown", + `Model field "MapNestedAttributeAssocExtType" is unknown.`, + )) + + return nil, diags + } + + mapObjects := make(map[string]types.Object) + + diags.Append(tfMap.ElementsAs(ctx, &mapObjects, false)...) + + if diags.HasError() { + return nil, diags + } + + apiObjects := make(map[string]*apisdk.Type, len(mapObjects)) + + for k, mapObject := range mapObjects { + if mapObject.IsNull() { + apiObjects[k] = nil + + continue + } + + if mapObject.IsUnknown() { + diags.Append(diag.NewErrorDiagnostic( + "Object Value Within Map Is Unknown", + `Model field "MapNestedAttributeAssocExtType" contains an object which is unknown.`, + )) + + return nil, diags + } + + var tfModel MapNestedAttributeAssocExtTypeModel + + d := mapObject.As(ctx, &tfModel, basetypes.ObjectAsOptions{}) + + diags.Append(d...) + + if diags.HasError() { + return nil, diags + } + + apiObjects[k] = &apisdk.Type{ + BoolAttribute: tfModel.BoolAttribute.ValueBoolPointer(), + Float64Attribute: tfModel.Float64Attribute.ValueFloat64Pointer(), + Int64Attribute: tfModel.Int64Attribute.ValueInt64Pointer(), + NumberAttribute: tfModel.NumberAttribute.ValueBigFloat(), + StringAttribute: tfModel.StringAttribute.ValueStringPointer(), + } + } + + return apiObjects, diags +} + +func FromMapNestedAttributeAssocExtType(ctx context.Context, apiObjects map[string]*apisdk.Type) (types.Map, diag.Diagnostics) { + var diags diag.Diagnostics + var tfModel MapNestedAttributeAssocExtTypeModel + + if apiObjects == nil { + return types.MapNull( + tfModel.ObjectType(ctx), + ), diags + } + + tfModels := make(map[string]*MapNestedAttributeAssocExtTypeModel) + + for k, apiObject := range apiObjects { + if apiObject == nil { + tfModels[k] = nil + + continue + } + + tfModels[k] = &MapNestedAttributeAssocExtTypeModel{ + BoolAttribute: types.BoolPointerValue(apiObject.BoolAttribute), + Float64Attribute: types.Float64PointerValue(apiObject.Float64Attribute), + Int64Attribute: types.Int64PointerValue(apiObject.Int64Attribute), + NumberAttribute: types.NumberValue(apiObject.NumberAttribute), + StringAttribute: types.StringPointerValue(apiObject.StringAttribute), + } + } + + return types.MapValueFrom(ctx, tfModel.ObjectType(ctx), tfModels) +} + +func ToSetNestedAttributeAssocExtType(ctx context.Context, tfSet types.Set) ([]*apisdk.Type, diag.Diagnostics) { + var diags diag.Diagnostics + + if tfSet.IsNull() { + return nil, diags + } + + if tfSet.IsUnknown() { + diags.Append(diag.NewErrorDiagnostic( + "Set Value Is Unknown", + `Model field "SetNestedAttributeAssocExtType" is unknown.`, + )) + + return nil, diags + } + + var setObjects []types.Object + + diags.Append(tfSet.ElementsAs(ctx, &setObjects, false)...) + + if diags.HasError() { + return nil, diags + } + + apiObjects := make([]*apisdk.Type, 0, len(setObjects)) + + for _, setObject := range setObjects { + if setObject.IsNull() { + apiObjects = append(apiObjects, nil) + + continue + } + + if setObject.IsUnknown() { + diags.Append(diag.NewErrorDiagnostic( + "Object Value Within Set Is Unknown", + `Model field "SetNestedAttributeAssocExtType" contains an object which is unknown.`, + )) + + return nil, diags + } + + var tfModel SetNestedAttributeAssocExtTypeModel + + d := setObject.As(ctx, &tfModel, basetypes.ObjectAsOptions{}) + + diags.Append(d...) + + if diags.HasError() { + return nil, diags + } + + apiObjects = append(apiObjects, &apisdk.Type{ + BoolAttribute: tfModel.BoolAttribute.ValueBoolPointer(), + Float64Attribute: tfModel.Float64Attribute.ValueFloat64Pointer(), + Int64Attribute: tfModel.Int64Attribute.ValueInt64Pointer(), + NumberAttribute: tfModel.NumberAttribute.ValueBigFloat(), + StringAttribute: tfModel.StringAttribute.ValueStringPointer(), + }) + } + + return apiObjects, diags +} + +func FromSetNestedAttributeAssocExtType(ctx context.Context, apiObjects []*apisdk.Type) (types.Set, diag.Diagnostics) { + var diags diag.Diagnostics + var tfModel SetNestedAttributeAssocExtTypeModel + + if apiObjects == nil { + return types.SetNull( + tfModel.ObjectType(ctx), + ), diags + } + + var tfModels []*SetNestedAttributeAssocExtTypeModel + + for _, apiObject := range apiObjects { + if apiObject == nil { + tfModels = append(tfModels, nil) + + continue + } + + tfModels = append(tfModels, &SetNestedAttributeAssocExtTypeModel{ + BoolAttribute: types.BoolPointerValue(apiObject.BoolAttribute), + Float64Attribute: types.Float64PointerValue(apiObject.Float64Attribute), + Int64Attribute: types.Int64PointerValue(apiObject.Int64Attribute), + NumberAttribute: types.NumberValue(apiObject.NumberAttribute), + StringAttribute: types.StringPointerValue(apiObject.StringAttribute), + }) + } + + return types.SetValueFrom(ctx, tfModel.ObjectType(ctx), tfModels) +} + +func ToSingleNestedAttributeAssocExtType(ctx context.Context, tfObject types.Object) (*apisdk.Type, diag.Diagnostics) { + var diags diag.Diagnostics + + if tfObject.IsNull() { + return nil, diags + } + + if tfObject.IsUnknown() { + diags.Append(diag.NewErrorDiagnostic( + "Object Value Is Unknown", + `Model field "SingleNestedAttributeAssocExtType" is unknown.`, + )) + + return nil, diags + } + + var tfModel SingleNestedAttributeAssocExtTypeModel + + diags.Append(tfObject.As(ctx, &tfModel, basetypes.ObjectAsOptions{})...) + + if diags.HasError() { + return nil, diags + } + + apiObject := &apisdk.Type{ + BoolAttribute: tfModel.BoolAttribute.ValueBoolPointer(), + Float64Attribute: tfModel.Float64Attribute.ValueFloat64Pointer(), + Int64Attribute: tfModel.Int64Attribute.ValueInt64Pointer(), + NumberAttribute: tfModel.NumberAttribute.ValueBigFloat(), + StringAttribute: tfModel.StringAttribute.ValueStringPointer(), + } + + return apiObject, diags +} + +func FromSingleNestedAttributeAssocExtType(ctx context.Context, apiObject *apisdk.Type) (types.Object, diag.Diagnostics) { + var diags diag.Diagnostics + var tfModel SingleNestedAttributeAssocExtTypeModel + + if apiObject == nil { + return tfModel.ObjectNull(ctx), diags + } + + tfModel.BoolAttribute = types.BoolPointerValue(apiObject.BoolAttribute) + tfModel.Float64Attribute = types.Float64PointerValue(apiObject.Float64Attribute) + tfModel.Int64Attribute = types.Int64PointerValue(apiObject.Int64Attribute) + tfModel.NumberAttribute = types.NumberValue(apiObject.NumberAttribute) + tfModel.StringAttribute = types.StringPointerValue(apiObject.StringAttribute) + + return tfModel.ObjectValueFrom(ctx, tfModel) +} + +func ToListNestedBlockAssocExtType(ctx context.Context, tfList types.List) ([]*apisdk.Type, diag.Diagnostics) { + var diags diag.Diagnostics + + if tfList.IsNull() { + return nil, diags + } + + if tfList.IsUnknown() { + diags.Append(diag.NewErrorDiagnostic( + "List Value Is Unknown", + `Model field "ListNestedBlockAssocExtType" is unknown.`, + )) + + return nil, diags + } + + var listObjects []types.Object + + diags.Append(tfList.ElementsAs(ctx, &listObjects, false)...) + + if diags.HasError() { + return nil, diags + } + + apiObjects := make([]*apisdk.Type, 0, len(listObjects)) + + for _, listObject := range listObjects { + if listObject.IsNull() { + apiObjects = append(apiObjects, nil) + + continue + } + + if listObject.IsUnknown() { + diags.Append(diag.NewErrorDiagnostic( + "Object Value Within List Is Unknown", + `Model field "ListNestedBlockAssocExtType" contains an object which is unknown.`, + )) + + return nil, diags + } + + var tfModel ListNestedBlockAssocExtTypeModel + + d := listObject.As(ctx, &tfModel, basetypes.ObjectAsOptions{}) + + diags.Append(d...) + + if diags.HasError() { + return nil, diags + } + + apiObjects = append(apiObjects, &apisdk.Type{ + BoolAttribute: tfModel.BoolAttribute.ValueBoolPointer(), + Float64Attribute: tfModel.Float64Attribute.ValueFloat64Pointer(), + Int64Attribute: tfModel.Int64Attribute.ValueInt64Pointer(), + NumberAttribute: tfModel.NumberAttribute.ValueBigFloat(), + StringAttribute: tfModel.StringAttribute.ValueStringPointer(), + }) + } + + return apiObjects, diags +} + +func FromListNestedBlockAssocExtType(ctx context.Context, apiObjects []*apisdk.Type) (types.List, diag.Diagnostics) { + var diags diag.Diagnostics + var tfModel ListNestedBlockAssocExtTypeModel + + if apiObjects == nil { + return types.ListNull( + tfModel.ObjectType(ctx), + ), diags + } + + var tfModels []*ListNestedBlockAssocExtTypeModel + + for _, apiObject := range apiObjects { + if apiObject == nil { + tfModels = append(tfModels, nil) + + continue + } + + tfModels = append(tfModels, &ListNestedBlockAssocExtTypeModel{ + BoolAttribute: types.BoolPointerValue(apiObject.BoolAttribute), + Float64Attribute: types.Float64PointerValue(apiObject.Float64Attribute), + Int64Attribute: types.Int64PointerValue(apiObject.Int64Attribute), + NumberAttribute: types.NumberValue(apiObject.NumberAttribute), + StringAttribute: types.StringPointerValue(apiObject.StringAttribute), + }) + } + + return types.ListValueFrom(ctx, tfModel.ObjectType(ctx), tfModels) +} + +func ToSetNestedBlockAssocExtType(ctx context.Context, tfSet types.Set) ([]*apisdk.Type, diag.Diagnostics) { + var diags diag.Diagnostics + + if tfSet.IsNull() { + return nil, diags + } + + if tfSet.IsUnknown() { + diags.Append(diag.NewErrorDiagnostic( + "Set Value Is Unknown", + `Model field "SetNestedBlockAssocExtType" is unknown.`, + )) + + return nil, diags + } + + var setObjects []types.Object + + diags.Append(tfSet.ElementsAs(ctx, &setObjects, false)...) + + if diags.HasError() { + return nil, diags + } + + apiObjects := make([]*apisdk.Type, 0, len(setObjects)) + + for _, setObject := range setObjects { + if setObject.IsNull() { + apiObjects = append(apiObjects, nil) + + continue + } + + if setObject.IsUnknown() { + diags.Append(diag.NewErrorDiagnostic( + "Object Value Within Set Is Unknown", + `Model field "SetNestedBlockAssocExtType" contains an object which is unknown.`, + )) + + return nil, diags + } + + var tfModel SetNestedBlockAssocExtTypeModel + + d := setObject.As(ctx, &tfModel, basetypes.ObjectAsOptions{}) + + diags.Append(d...) + + if diags.HasError() { + return nil, diags + } + + apiObjects = append(apiObjects, &apisdk.Type{ + BoolAttribute: tfModel.BoolAttribute.ValueBoolPointer(), + Float64Attribute: tfModel.Float64Attribute.ValueFloat64Pointer(), + Int64Attribute: tfModel.Int64Attribute.ValueInt64Pointer(), + NumberAttribute: tfModel.NumberAttribute.ValueBigFloat(), + StringAttribute: tfModel.StringAttribute.ValueStringPointer(), + }) + } + + return apiObjects, diags +} + +func FromSetNestedBlockAssocExtType(ctx context.Context, apiObjects []*apisdk.Type) (types.Set, diag.Diagnostics) { + var diags diag.Diagnostics + var tfModel SetNestedBlockAssocExtTypeModel + + if apiObjects == nil { + return types.SetNull( + tfModel.ObjectType(ctx), + ), diags + } + + var tfModels []*SetNestedBlockAssocExtTypeModel + + for _, apiObject := range apiObjects { + if apiObject == nil { + tfModels = append(tfModels, nil) + + continue + } + + tfModels = append(tfModels, &SetNestedBlockAssocExtTypeModel{ + BoolAttribute: types.BoolPointerValue(apiObject.BoolAttribute), + Float64Attribute: types.Float64PointerValue(apiObject.Float64Attribute), + Int64Attribute: types.Int64PointerValue(apiObject.Int64Attribute), + NumberAttribute: types.NumberValue(apiObject.NumberAttribute), + StringAttribute: types.StringPointerValue(apiObject.StringAttribute), + }) + } + + return types.SetValueFrom(ctx, tfModel.ObjectType(ctx), tfModels) +} + +func ToSingleNestedBlockAssocExtType(ctx context.Context, tfObject types.Object) (*apisdk.Type, diag.Diagnostics) { + var diags diag.Diagnostics + + if tfObject.IsNull() { + return nil, diags + } + + if tfObject.IsUnknown() { + diags.Append(diag.NewErrorDiagnostic( + "Object Value Is Unknown", + `Model field "SingleNestedBlockAssocExtType" is unknown.`, + )) + + return nil, diags + } + + var tfModel SingleNestedBlockAssocExtTypeModel + + diags.Append(tfObject.As(ctx, &tfModel, basetypes.ObjectAsOptions{})...) + + if diags.HasError() { + return nil, diags + } + + apiObject := &apisdk.Type{ + BoolAttribute: tfModel.BoolAttribute.ValueBoolPointer(), + Float64Attribute: tfModel.Float64Attribute.ValueFloat64Pointer(), + Int64Attribute: tfModel.Int64Attribute.ValueInt64Pointer(), + NumberAttribute: tfModel.NumberAttribute.ValueBigFloat(), + StringAttribute: tfModel.StringAttribute.ValueStringPointer(), + } + + return apiObject, diags +} + +func FromSingleNestedBlockAssocExtType(ctx context.Context, apiObject *apisdk.Type) (types.Object, diag.Diagnostics) { + var diags diag.Diagnostics + var tfModel SingleNestedBlockAssocExtTypeModel + + if apiObject == nil { + return tfModel.ObjectNull(ctx), diags + } + + tfModel.BoolAttribute = types.BoolPointerValue(apiObject.BoolAttribute) + tfModel.Float64Attribute = types.Float64PointerValue(apiObject.Float64Attribute) + tfModel.Int64Attribute = types.Int64PointerValue(apiObject.Int64Attribute) + tfModel.NumberAttribute = types.NumberValue(apiObject.NumberAttribute) + tfModel.StringAttribute = types.StringPointerValue(apiObject.StringAttribute) + + return tfModel.ObjectValueFrom(ctx, tfModel) +} diff --git a/internal/cmd/testdata/custom_and_external/all_output/specified_pkg_name/resource_resource_gen.go b/internal/cmd/testdata/custom_and_external/all_output/specified_pkg_name/resource_resource_gen.go new file mode 100644 index 00000000..8a7bf0f4 --- /dev/null +++ b/internal/cmd/testdata/custom_and_external/all_output/specified_pkg_name/resource_resource_gen.go @@ -0,0 +1,1020 @@ +// Code generated by terraform-plugin-framework-generator DO NOT EDIT. + +package specified + +import ( + "context" + "example.com/apisdk" + "github.com/hashicorp/terraform-plugin-framework/attr" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/resource/schema" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/booldefault" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" + "github.com/hashicorp/terraform-plugin-framework/schema/validator" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-framework/types/basetypes" + planmodifieralias "github.com/my_account/my_project/myboolplanmodifier" + validatoralias "github.com/my_account/my_project/myboolvalidator" + boolalias "github.com/my_account_my_project/bool" +) + +var resourceResourceSchema = schema.Schema{ + Attributes: map[string]schema.Attribute{ + "bool_attribute": schema.BoolAttribute{ + CustomType: my_bool_type, + Computed: true, + PlanModifiers: []planmodifier.Bool{ + myboolplanmodifier.Modify(), + }, + Validators: []validator.Bool{ + myboolvalidator.Validate(), + }, + Default: booldefault.StaticBool(true), + }, + "list_nested_attribute_assoc_ext_type": schema.ListNestedAttribute{ + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "bool_attribute": schema.BoolAttribute{ + Optional: true, + }, + "float64_attribute": schema.Float64Attribute{ + Optional: true, + }, + "int64_attribute": schema.Int64Attribute{ + Optional: true, + }, + "number_attribute": schema.NumberAttribute{ + Optional: true, + }, + "string_attribute": schema.StringAttribute{ + Optional: true, + }, + }, + }, + Optional: true, + }, + "map_nested_attribute_assoc_ext_type": schema.MapNestedAttribute{ + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "bool_attribute": schema.BoolAttribute{ + Optional: true, + }, + "float64_attribute": schema.Float64Attribute{ + Optional: true, + }, + "int64_attribute": schema.Int64Attribute{ + Optional: true, + }, + "number_attribute": schema.NumberAttribute{ + Optional: true, + }, + "string_attribute": schema.StringAttribute{ + Optional: true, + }, + }, + }, + Optional: true, + }, + "set_nested_attribute_assoc_ext_type": schema.SetNestedAttribute{ + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "bool_attribute": schema.BoolAttribute{ + Optional: true, + }, + "float64_attribute": schema.Float64Attribute{ + Optional: true, + }, + "int64_attribute": schema.Int64Attribute{ + Optional: true, + }, + "number_attribute": schema.NumberAttribute{ + Optional: true, + }, + "string_attribute": schema.StringAttribute{ + Optional: true, + }, + }, + }, + Optional: true, + }, + "single_nested_attribute_assoc_ext_type": schema.SingleNestedAttribute{ + Attributes: map[string]schema.Attribute{ + "bool_attribute": schema.BoolAttribute{ + Optional: true, + }, + "float64_attribute": schema.Float64Attribute{ + Optional: true, + }, + "int64_attribute": schema.Int64Attribute{ + Optional: true, + }, + "number_attribute": schema.NumberAttribute{ + Optional: true, + }, + "string_attribute": schema.StringAttribute{ + Optional: true, + }, + }, + Optional: true, + }, + }, + Blocks: map[string]schema.Block{ + "list_nested_block_assoc_ext_type": schema.ListNestedBlock{ + NestedObject: schema.NestedBlockObject{ + Attributes: map[string]schema.Attribute{ + "bool_attribute": schema.BoolAttribute{ + Optional: true, + }, + "float64_attribute": schema.Float64Attribute{ + Optional: true, + }, + "int64_attribute": schema.Int64Attribute{ + Optional: true, + }, + "number_attribute": schema.NumberAttribute{ + Optional: true, + }, + "string_attribute": schema.StringAttribute{ + Optional: true, + }, + }, + }, + }, + "set_nested_block_assoc_ext_type": schema.SetNestedBlock{ + NestedObject: schema.NestedBlockObject{ + Attributes: map[string]schema.Attribute{ + "bool_attribute": schema.BoolAttribute{ + Optional: true, + }, + "float64_attribute": schema.Float64Attribute{ + Optional: true, + }, + "int64_attribute": schema.Int64Attribute{ + Optional: true, + }, + "number_attribute": schema.NumberAttribute{ + Optional: true, + }, + "string_attribute": schema.StringAttribute{ + Optional: true, + }, + }, + }, + }, + "single_nested_block_assoc_ext_type": schema.SingleNestedBlock{ + Attributes: map[string]schema.Attribute{ + "bool_attribute": schema.BoolAttribute{ + Optional: true, + }, + "float64_attribute": schema.Float64Attribute{ + Optional: true, + }, + "int64_attribute": schema.Int64Attribute{ + Optional: true, + }, + "number_attribute": schema.NumberAttribute{ + Optional: true, + }, + "string_attribute": schema.StringAttribute{ + Optional: true, + }, + }, + }, + }, +} + +type ResourceModel struct { + BoolAttribute my_bool_value `tfsdk:"bool_attribute"` + ListNestedAttributeAssocExtType types.List `tfsdk:"list_nested_attribute_assoc_ext_type"` + MapNestedAttributeAssocExtType types.Map `tfsdk:"map_nested_attribute_assoc_ext_type"` + SetNestedAttributeAssocExtType types.Set `tfsdk:"set_nested_attribute_assoc_ext_type"` + SingleNestedAttributeAssocExtType types.Object `tfsdk:"single_nested_attribute_assoc_ext_type"` + ListNestedBlockAssocExtType types.List `tfsdk:"list_nested_block_assoc_ext_type"` + SetNestedBlockAssocExtType types.Set `tfsdk:"set_nested_block_assoc_ext_type"` + SingleNestedBlockAssocExtType types.Object `tfsdk:"single_nested_block_assoc_ext_type"` +} + +type ListNestedAttributeAssocExtTypeModel struct { + BoolAttribute types.Bool `tfsdk:"bool_attribute"` + Float64Attribute types.Float64 `tfsdk:"float64_attribute"` + Int64Attribute types.Int64 `tfsdk:"int64_attribute"` + NumberAttribute types.Number `tfsdk:"number_attribute"` + StringAttribute types.String `tfsdk:"string_attribute"` +} + +type MapNestedAttributeAssocExtTypeModel struct { + BoolAttribute types.Bool `tfsdk:"bool_attribute"` + Float64Attribute types.Float64 `tfsdk:"float64_attribute"` + Int64Attribute types.Int64 `tfsdk:"int64_attribute"` + NumberAttribute types.Number `tfsdk:"number_attribute"` + StringAttribute types.String `tfsdk:"string_attribute"` +} + +type SetNestedAttributeAssocExtTypeModel struct { + BoolAttribute types.Bool `tfsdk:"bool_attribute"` + Float64Attribute types.Float64 `tfsdk:"float64_attribute"` + Int64Attribute types.Int64 `tfsdk:"int64_attribute"` + NumberAttribute types.Number `tfsdk:"number_attribute"` + StringAttribute types.String `tfsdk:"string_attribute"` +} + +type SingleNestedAttributeAssocExtTypeModel struct { + BoolAttribute types.Bool `tfsdk:"bool_attribute"` + Float64Attribute types.Float64 `tfsdk:"float64_attribute"` + Int64Attribute types.Int64 `tfsdk:"int64_attribute"` + NumberAttribute types.Number `tfsdk:"number_attribute"` + StringAttribute types.String `tfsdk:"string_attribute"` +} + +type ListNestedBlockAssocExtTypeModel struct { + BoolAttribute types.Bool `tfsdk:"bool_attribute"` + Float64Attribute types.Float64 `tfsdk:"float64_attribute"` + Int64Attribute types.Int64 `tfsdk:"int64_attribute"` + NumberAttribute types.Number `tfsdk:"number_attribute"` + StringAttribute types.String `tfsdk:"string_attribute"` +} + +type SetNestedBlockAssocExtTypeModel struct { + BoolAttribute types.Bool `tfsdk:"bool_attribute"` + Float64Attribute types.Float64 `tfsdk:"float64_attribute"` + Int64Attribute types.Int64 `tfsdk:"int64_attribute"` + NumberAttribute types.Number `tfsdk:"number_attribute"` + StringAttribute types.String `tfsdk:"string_attribute"` +} + +type SingleNestedBlockAssocExtTypeModel struct { + BoolAttribute types.Bool `tfsdk:"bool_attribute"` + Float64Attribute types.Float64 `tfsdk:"float64_attribute"` + Int64Attribute types.Int64 `tfsdk:"int64_attribute"` + NumberAttribute types.Number `tfsdk:"number_attribute"` + StringAttribute types.String `tfsdk:"string_attribute"` +} + +func (m ListNestedAttributeAssocExtTypeModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m ListNestedAttributeAssocExtTypeModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "bool_attribute": types.BoolType, + "float64_attribute": types.Float64Type, + "int64_attribute": types.Int64Type, + "number_attribute": types.NumberType, + "string_attribute": types.StringType, + } +} + +func (m ListNestedAttributeAssocExtTypeModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m ListNestedAttributeAssocExtTypeModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} +func (m MapNestedAttributeAssocExtTypeModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m MapNestedAttributeAssocExtTypeModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "bool_attribute": types.BoolType, + "float64_attribute": types.Float64Type, + "int64_attribute": types.Int64Type, + "number_attribute": types.NumberType, + "string_attribute": types.StringType, + } +} + +func (m MapNestedAttributeAssocExtTypeModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m MapNestedAttributeAssocExtTypeModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} +func (m SetNestedAttributeAssocExtTypeModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m SetNestedAttributeAssocExtTypeModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "bool_attribute": types.BoolType, + "float64_attribute": types.Float64Type, + "int64_attribute": types.Int64Type, + "number_attribute": types.NumberType, + "string_attribute": types.StringType, + } +} + +func (m SetNestedAttributeAssocExtTypeModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m SetNestedAttributeAssocExtTypeModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} +func (m SingleNestedAttributeAssocExtTypeModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m SingleNestedAttributeAssocExtTypeModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "bool_attribute": types.BoolType, + "float64_attribute": types.Float64Type, + "int64_attribute": types.Int64Type, + "number_attribute": types.NumberType, + "string_attribute": types.StringType, + } +} + +func (m SingleNestedAttributeAssocExtTypeModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m SingleNestedAttributeAssocExtTypeModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} +func (m ListNestedBlockAssocExtTypeModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m ListNestedBlockAssocExtTypeModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "bool_attribute": types.BoolType, + "float64_attribute": types.Float64Type, + "int64_attribute": types.Int64Type, + "number_attribute": types.NumberType, + "string_attribute": types.StringType, + } +} + +func (m ListNestedBlockAssocExtTypeModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m ListNestedBlockAssocExtTypeModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} +func (m SetNestedBlockAssocExtTypeModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m SetNestedBlockAssocExtTypeModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "bool_attribute": types.BoolType, + "float64_attribute": types.Float64Type, + "int64_attribute": types.Int64Type, + "number_attribute": types.NumberType, + "string_attribute": types.StringType, + } +} + +func (m SetNestedBlockAssocExtTypeModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m SetNestedBlockAssocExtTypeModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} +func (m SingleNestedBlockAssocExtTypeModel) ObjectType(ctx context.Context) types.ObjectType { + return types.ObjectType{AttrTypes: m.ObjectAttributeTypes(ctx)} +} + +func (m SingleNestedBlockAssocExtTypeModel) ObjectAttributeTypes(ctx context.Context) map[string]attr.Type { + return map[string]attr.Type{ + "bool_attribute": types.BoolType, + "float64_attribute": types.Float64Type, + "int64_attribute": types.Int64Type, + "number_attribute": types.NumberType, + "string_attribute": types.StringType, + } +} + +func (m SingleNestedBlockAssocExtTypeModel) ObjectNull(ctx context.Context) types.Object { + return types.ObjectNull( + m.ObjectAttributeTypes(ctx), + ) +} + +func (m SingleNestedBlockAssocExtTypeModel) ObjectValueFrom(ctx context.Context, data any) (types.Object, diag.Diagnostics) { + return types.ObjectValueFrom( + ctx, + m.ObjectAttributeTypes(ctx), + data, + ) +} + +func ToListNestedAttributeAssocExtType(ctx context.Context, tfList types.List) ([]*apisdk.Type, diag.Diagnostics) { + var diags diag.Diagnostics + + if tfList.IsNull() { + return nil, diags + } + + if tfList.IsUnknown() { + diags.Append(diag.NewErrorDiagnostic( + "List Value Is Unknown", + `Model field "ListNestedAttributeAssocExtType" is unknown.`, + )) + + return nil, diags + } + + var listObjects []types.Object + + diags.Append(tfList.ElementsAs(ctx, &listObjects, false)...) + + if diags.HasError() { + return nil, diags + } + + apiObjects := make([]*apisdk.Type, 0, len(listObjects)) + + for _, listObject := range listObjects { + if listObject.IsNull() { + apiObjects = append(apiObjects, nil) + + continue + } + + if listObject.IsUnknown() { + diags.Append(diag.NewErrorDiagnostic( + "Object Value Within List Is Unknown", + `Model field "ListNestedAttributeAssocExtType" contains an object which is unknown.`, + )) + + return nil, diags + } + + var tfModel ListNestedAttributeAssocExtTypeModel + + d := listObject.As(ctx, &tfModel, basetypes.ObjectAsOptions{}) + + diags.Append(d...) + + if diags.HasError() { + return nil, diags + } + + apiObjects = append(apiObjects, &apisdk.Type{ + BoolAttribute: tfModel.BoolAttribute.ValueBoolPointer(), + Float64Attribute: tfModel.Float64Attribute.ValueFloat64Pointer(), + Int64Attribute: tfModel.Int64Attribute.ValueInt64Pointer(), + NumberAttribute: tfModel.NumberAttribute.ValueBigFloat(), + StringAttribute: tfModel.StringAttribute.ValueStringPointer(), + }) + } + + return apiObjects, diags +} + +func FromListNestedAttributeAssocExtType(ctx context.Context, apiObjects []*apisdk.Type) (types.List, diag.Diagnostics) { + var diags diag.Diagnostics + var tfModel ListNestedAttributeAssocExtTypeModel + + if apiObjects == nil { + return types.ListNull( + tfModel.ObjectType(ctx), + ), diags + } + + var tfModels []*ListNestedAttributeAssocExtTypeModel + + for _, apiObject := range apiObjects { + if apiObject == nil { + tfModels = append(tfModels, nil) + + continue + } + + tfModels = append(tfModels, &ListNestedAttributeAssocExtTypeModel{ + BoolAttribute: types.BoolPointerValue(apiObject.BoolAttribute), + Float64Attribute: types.Float64PointerValue(apiObject.Float64Attribute), + Int64Attribute: types.Int64PointerValue(apiObject.Int64Attribute), + NumberAttribute: types.NumberValue(apiObject.NumberAttribute), + StringAttribute: types.StringPointerValue(apiObject.StringAttribute), + }) + } + + return types.ListValueFrom(ctx, tfModel.ObjectType(ctx), tfModels) +} + +func ToMapNestedAttributeAssocExtType(ctx context.Context, tfMap types.Map) (map[string]*apisdk.Type, diag.Diagnostics) { + var diags diag.Diagnostics + + if tfMap.IsNull() { + return nil, diags + } + + if tfMap.IsUnknown() { + diags.Append(diag.NewErrorDiagnostic( + "Map Value Is Unknown", + `Model field "MapNestedAttributeAssocExtType" is unknown.`, + )) + + return nil, diags + } + + mapObjects := make(map[string]types.Object) + + diags.Append(tfMap.ElementsAs(ctx, &mapObjects, false)...) + + if diags.HasError() { + return nil, diags + } + + apiObjects := make(map[string]*apisdk.Type, len(mapObjects)) + + for k, mapObject := range mapObjects { + if mapObject.IsNull() { + apiObjects[k] = nil + + continue + } + + if mapObject.IsUnknown() { + diags.Append(diag.NewErrorDiagnostic( + "Object Value Within Map Is Unknown", + `Model field "MapNestedAttributeAssocExtType" contains an object which is unknown.`, + )) + + return nil, diags + } + + var tfModel MapNestedAttributeAssocExtTypeModel + + d := mapObject.As(ctx, &tfModel, basetypes.ObjectAsOptions{}) + + diags.Append(d...) + + if diags.HasError() { + return nil, diags + } + + apiObjects[k] = &apisdk.Type{ + BoolAttribute: tfModel.BoolAttribute.ValueBoolPointer(), + Float64Attribute: tfModel.Float64Attribute.ValueFloat64Pointer(), + Int64Attribute: tfModel.Int64Attribute.ValueInt64Pointer(), + NumberAttribute: tfModel.NumberAttribute.ValueBigFloat(), + StringAttribute: tfModel.StringAttribute.ValueStringPointer(), + } + } + + return apiObjects, diags +} + +func FromMapNestedAttributeAssocExtType(ctx context.Context, apiObjects map[string]*apisdk.Type) (types.Map, diag.Diagnostics) { + var diags diag.Diagnostics + var tfModel MapNestedAttributeAssocExtTypeModel + + if apiObjects == nil { + return types.MapNull( + tfModel.ObjectType(ctx), + ), diags + } + + tfModels := make(map[string]*MapNestedAttributeAssocExtTypeModel) + + for k, apiObject := range apiObjects { + if apiObject == nil { + tfModels[k] = nil + + continue + } + + tfModels[k] = &MapNestedAttributeAssocExtTypeModel{ + BoolAttribute: types.BoolPointerValue(apiObject.BoolAttribute), + Float64Attribute: types.Float64PointerValue(apiObject.Float64Attribute), + Int64Attribute: types.Int64PointerValue(apiObject.Int64Attribute), + NumberAttribute: types.NumberValue(apiObject.NumberAttribute), + StringAttribute: types.StringPointerValue(apiObject.StringAttribute), + } + } + + return types.MapValueFrom(ctx, tfModel.ObjectType(ctx), tfModels) +} + +func ToSetNestedAttributeAssocExtType(ctx context.Context, tfSet types.Set) ([]*apisdk.Type, diag.Diagnostics) { + var diags diag.Diagnostics + + if tfSet.IsNull() { + return nil, diags + } + + if tfSet.IsUnknown() { + diags.Append(diag.NewErrorDiagnostic( + "Set Value Is Unknown", + `Model field "SetNestedAttributeAssocExtType" is unknown.`, + )) + + return nil, diags + } + + var setObjects []types.Object + + diags.Append(tfSet.ElementsAs(ctx, &setObjects, false)...) + + if diags.HasError() { + return nil, diags + } + + apiObjects := make([]*apisdk.Type, 0, len(setObjects)) + + for _, setObject := range setObjects { + if setObject.IsNull() { + apiObjects = append(apiObjects, nil) + + continue + } + + if setObject.IsUnknown() { + diags.Append(diag.NewErrorDiagnostic( + "Object Value Within Set Is Unknown", + `Model field "SetNestedAttributeAssocExtType" contains an object which is unknown.`, + )) + + return nil, diags + } + + var tfModel SetNestedAttributeAssocExtTypeModel + + d := setObject.As(ctx, &tfModel, basetypes.ObjectAsOptions{}) + + diags.Append(d...) + + if diags.HasError() { + return nil, diags + } + + apiObjects = append(apiObjects, &apisdk.Type{ + BoolAttribute: tfModel.BoolAttribute.ValueBoolPointer(), + Float64Attribute: tfModel.Float64Attribute.ValueFloat64Pointer(), + Int64Attribute: tfModel.Int64Attribute.ValueInt64Pointer(), + NumberAttribute: tfModel.NumberAttribute.ValueBigFloat(), + StringAttribute: tfModel.StringAttribute.ValueStringPointer(), + }) + } + + return apiObjects, diags +} + +func FromSetNestedAttributeAssocExtType(ctx context.Context, apiObjects []*apisdk.Type) (types.Set, diag.Diagnostics) { + var diags diag.Diagnostics + var tfModel SetNestedAttributeAssocExtTypeModel + + if apiObjects == nil { + return types.SetNull( + tfModel.ObjectType(ctx), + ), diags + } + + var tfModels []*SetNestedAttributeAssocExtTypeModel + + for _, apiObject := range apiObjects { + if apiObject == nil { + tfModels = append(tfModels, nil) + + continue + } + + tfModels = append(tfModels, &SetNestedAttributeAssocExtTypeModel{ + BoolAttribute: types.BoolPointerValue(apiObject.BoolAttribute), + Float64Attribute: types.Float64PointerValue(apiObject.Float64Attribute), + Int64Attribute: types.Int64PointerValue(apiObject.Int64Attribute), + NumberAttribute: types.NumberValue(apiObject.NumberAttribute), + StringAttribute: types.StringPointerValue(apiObject.StringAttribute), + }) + } + + return types.SetValueFrom(ctx, tfModel.ObjectType(ctx), tfModels) +} + +func ToSingleNestedAttributeAssocExtType(ctx context.Context, tfObject types.Object) (*apisdk.Type, diag.Diagnostics) { + var diags diag.Diagnostics + + if tfObject.IsNull() { + return nil, diags + } + + if tfObject.IsUnknown() { + diags.Append(diag.NewErrorDiagnostic( + "Object Value Is Unknown", + `Model field "SingleNestedAttributeAssocExtType" is unknown.`, + )) + + return nil, diags + } + + var tfModel SingleNestedAttributeAssocExtTypeModel + + diags.Append(tfObject.As(ctx, &tfModel, basetypes.ObjectAsOptions{})...) + + if diags.HasError() { + return nil, diags + } + + apiObject := &apisdk.Type{ + BoolAttribute: tfModel.BoolAttribute.ValueBoolPointer(), + Float64Attribute: tfModel.Float64Attribute.ValueFloat64Pointer(), + Int64Attribute: tfModel.Int64Attribute.ValueInt64Pointer(), + NumberAttribute: tfModel.NumberAttribute.ValueBigFloat(), + StringAttribute: tfModel.StringAttribute.ValueStringPointer(), + } + + return apiObject, diags +} + +func FromSingleNestedAttributeAssocExtType(ctx context.Context, apiObject *apisdk.Type) (types.Object, diag.Diagnostics) { + var diags diag.Diagnostics + var tfModel SingleNestedAttributeAssocExtTypeModel + + if apiObject == nil { + return tfModel.ObjectNull(ctx), diags + } + + tfModel.BoolAttribute = types.BoolPointerValue(apiObject.BoolAttribute) + tfModel.Float64Attribute = types.Float64PointerValue(apiObject.Float64Attribute) + tfModel.Int64Attribute = types.Int64PointerValue(apiObject.Int64Attribute) + tfModel.NumberAttribute = types.NumberValue(apiObject.NumberAttribute) + tfModel.StringAttribute = types.StringPointerValue(apiObject.StringAttribute) + + return tfModel.ObjectValueFrom(ctx, tfModel) +} + +func ToListNestedBlockAssocExtType(ctx context.Context, tfList types.List) ([]*apisdk.Type, diag.Diagnostics) { + var diags diag.Diagnostics + + if tfList.IsNull() { + return nil, diags + } + + if tfList.IsUnknown() { + diags.Append(diag.NewErrorDiagnostic( + "List Value Is Unknown", + `Model field "ListNestedBlockAssocExtType" is unknown.`, + )) + + return nil, diags + } + + var listObjects []types.Object + + diags.Append(tfList.ElementsAs(ctx, &listObjects, false)...) + + if diags.HasError() { + return nil, diags + } + + apiObjects := make([]*apisdk.Type, 0, len(listObjects)) + + for _, listObject := range listObjects { + if listObject.IsNull() { + apiObjects = append(apiObjects, nil) + + continue + } + + if listObject.IsUnknown() { + diags.Append(diag.NewErrorDiagnostic( + "Object Value Within List Is Unknown", + `Model field "ListNestedBlockAssocExtType" contains an object which is unknown.`, + )) + + return nil, diags + } + + var tfModel ListNestedBlockAssocExtTypeModel + + d := listObject.As(ctx, &tfModel, basetypes.ObjectAsOptions{}) + + diags.Append(d...) + + if diags.HasError() { + return nil, diags + } + + apiObjects = append(apiObjects, &apisdk.Type{ + BoolAttribute: tfModel.BoolAttribute.ValueBoolPointer(), + Float64Attribute: tfModel.Float64Attribute.ValueFloat64Pointer(), + Int64Attribute: tfModel.Int64Attribute.ValueInt64Pointer(), + NumberAttribute: tfModel.NumberAttribute.ValueBigFloat(), + StringAttribute: tfModel.StringAttribute.ValueStringPointer(), + }) + } + + return apiObjects, diags +} + +func FromListNestedBlockAssocExtType(ctx context.Context, apiObjects []*apisdk.Type) (types.List, diag.Diagnostics) { + var diags diag.Diagnostics + var tfModel ListNestedBlockAssocExtTypeModel + + if apiObjects == nil { + return types.ListNull( + tfModel.ObjectType(ctx), + ), diags + } + + var tfModels []*ListNestedBlockAssocExtTypeModel + + for _, apiObject := range apiObjects { + if apiObject == nil { + tfModels = append(tfModels, nil) + + continue + } + + tfModels = append(tfModels, &ListNestedBlockAssocExtTypeModel{ + BoolAttribute: types.BoolPointerValue(apiObject.BoolAttribute), + Float64Attribute: types.Float64PointerValue(apiObject.Float64Attribute), + Int64Attribute: types.Int64PointerValue(apiObject.Int64Attribute), + NumberAttribute: types.NumberValue(apiObject.NumberAttribute), + StringAttribute: types.StringPointerValue(apiObject.StringAttribute), + }) + } + + return types.ListValueFrom(ctx, tfModel.ObjectType(ctx), tfModels) +} + +func ToSetNestedBlockAssocExtType(ctx context.Context, tfSet types.Set) ([]*apisdk.Type, diag.Diagnostics) { + var diags diag.Diagnostics + + if tfSet.IsNull() { + return nil, diags + } + + if tfSet.IsUnknown() { + diags.Append(diag.NewErrorDiagnostic( + "Set Value Is Unknown", + `Model field "SetNestedBlockAssocExtType" is unknown.`, + )) + + return nil, diags + } + + var setObjects []types.Object + + diags.Append(tfSet.ElementsAs(ctx, &setObjects, false)...) + + if diags.HasError() { + return nil, diags + } + + apiObjects := make([]*apisdk.Type, 0, len(setObjects)) + + for _, setObject := range setObjects { + if setObject.IsNull() { + apiObjects = append(apiObjects, nil) + + continue + } + + if setObject.IsUnknown() { + diags.Append(diag.NewErrorDiagnostic( + "Object Value Within Set Is Unknown", + `Model field "SetNestedBlockAssocExtType" contains an object which is unknown.`, + )) + + return nil, diags + } + + var tfModel SetNestedBlockAssocExtTypeModel + + d := setObject.As(ctx, &tfModel, basetypes.ObjectAsOptions{}) + + diags.Append(d...) + + if diags.HasError() { + return nil, diags + } + + apiObjects = append(apiObjects, &apisdk.Type{ + BoolAttribute: tfModel.BoolAttribute.ValueBoolPointer(), + Float64Attribute: tfModel.Float64Attribute.ValueFloat64Pointer(), + Int64Attribute: tfModel.Int64Attribute.ValueInt64Pointer(), + NumberAttribute: tfModel.NumberAttribute.ValueBigFloat(), + StringAttribute: tfModel.StringAttribute.ValueStringPointer(), + }) + } + + return apiObjects, diags +} + +func FromSetNestedBlockAssocExtType(ctx context.Context, apiObjects []*apisdk.Type) (types.Set, diag.Diagnostics) { + var diags diag.Diagnostics + var tfModel SetNestedBlockAssocExtTypeModel + + if apiObjects == nil { + return types.SetNull( + tfModel.ObjectType(ctx), + ), diags + } + + var tfModels []*SetNestedBlockAssocExtTypeModel + + for _, apiObject := range apiObjects { + if apiObject == nil { + tfModels = append(tfModels, nil) + + continue + } + + tfModels = append(tfModels, &SetNestedBlockAssocExtTypeModel{ + BoolAttribute: types.BoolPointerValue(apiObject.BoolAttribute), + Float64Attribute: types.Float64PointerValue(apiObject.Float64Attribute), + Int64Attribute: types.Int64PointerValue(apiObject.Int64Attribute), + NumberAttribute: types.NumberValue(apiObject.NumberAttribute), + StringAttribute: types.StringPointerValue(apiObject.StringAttribute), + }) + } + + return types.SetValueFrom(ctx, tfModel.ObjectType(ctx), tfModels) +} + +func ToSingleNestedBlockAssocExtType(ctx context.Context, tfObject types.Object) (*apisdk.Type, diag.Diagnostics) { + var diags diag.Diagnostics + + if tfObject.IsNull() { + return nil, diags + } + + if tfObject.IsUnknown() { + diags.Append(diag.NewErrorDiagnostic( + "Object Value Is Unknown", + `Model field "SingleNestedBlockAssocExtType" is unknown.`, + )) + + return nil, diags + } + + var tfModel SingleNestedBlockAssocExtTypeModel + + diags.Append(tfObject.As(ctx, &tfModel, basetypes.ObjectAsOptions{})...) + + if diags.HasError() { + return nil, diags + } + + apiObject := &apisdk.Type{ + BoolAttribute: tfModel.BoolAttribute.ValueBoolPointer(), + Float64Attribute: tfModel.Float64Attribute.ValueFloat64Pointer(), + Int64Attribute: tfModel.Int64Attribute.ValueInt64Pointer(), + NumberAttribute: tfModel.NumberAttribute.ValueBigFloat(), + StringAttribute: tfModel.StringAttribute.ValueStringPointer(), + } + + return apiObject, diags +} + +func FromSingleNestedBlockAssocExtType(ctx context.Context, apiObject *apisdk.Type) (types.Object, diag.Diagnostics) { + var diags diag.Diagnostics + var tfModel SingleNestedBlockAssocExtTypeModel + + if apiObject == nil { + return tfModel.ObjectNull(ctx), diags + } + + tfModel.BoolAttribute = types.BoolPointerValue(apiObject.BoolAttribute) + tfModel.Float64Attribute = types.Float64PointerValue(apiObject.Float64Attribute) + tfModel.Int64Attribute = types.Int64PointerValue(apiObject.Int64Attribute) + tfModel.NumberAttribute = types.NumberValue(apiObject.NumberAttribute) + tfModel.StringAttribute = types.StringPointerValue(apiObject.StringAttribute) + + return tfModel.ObjectValueFrom(ctx, tfModel) +} From 4eca0ac74c607404ac0fb87a097d80a090ed65ee Mon Sep 17 00:00:00 2001 From: Benjamin Bennett Date: Mon, 4 Sep 2023 17:21:48 +0100 Subject: [PATCH 3/6] Add generated code to separate directories (#20) --- internal/cmd/generate_test.go | 50 +++++++++++++++---- .../datasource_data_source_gen.go | 2 +- .../provider_provider_gen.go | 2 +- .../resource_resource_gen.go | 2 +- .../datasource_data_source_gen.go | 0 .../provider_provider_gen.go | 0 .../resource_resource_gen.go | 0 .../datasource_data_source_gen.go | 0 .../provider_provider_gen.go | 0 .../resource_resource_gen.go | 0 internal/output/write.go | 27 ++++++++-- internal/schema/schemas.go | 4 +- 12 files changed, 71 insertions(+), 16 deletions(-) rename internal/cmd/testdata/custom_and_external/all_output/default_pkg_name/{ => datasource_datasource}/datasource_data_source_gen.go (99%) rename internal/cmd/testdata/custom_and_external/all_output/default_pkg_name/{ => provider_provider}/provider_provider_gen.go (99%) rename internal/cmd/testdata/custom_and_external/all_output/default_pkg_name/{ => resource_resource}/resource_resource_gen.go (99%) rename internal/cmd/testdata/custom_and_external/all_output/specified_pkg_name/{ => datasource_datasource}/datasource_data_source_gen.go (100%) rename internal/cmd/testdata/custom_and_external/all_output/specified_pkg_name/{ => provider_provider}/provider_provider_gen.go (100%) rename internal/cmd/testdata/custom_and_external/all_output/specified_pkg_name/{ => resource_resource}/resource_resource_gen.go (100%) rename internal/cmd/testdata/custom_and_external/data_sources_output/{ => datasource_datasource}/datasource_data_source_gen.go (100%) rename internal/cmd/testdata/custom_and_external/provider_output/{ => provider_provider}/provider_provider_gen.go (100%) rename internal/cmd/testdata/custom_and_external/resources_output/{ => resource_resource}/resource_resource_gen.go (100%) diff --git a/internal/cmd/generate_test.go b/internal/cmd/generate_test.go index c0cdcabf..ac430512 100644 --- a/internal/cmd/generate_test.go +++ b/internal/cmd/generate_test.go @@ -11,7 +11,6 @@ import ( "github.com/google/go-cmp/cmp" ) -// TODO: currently doesn't compare nested directory files func compareDirectories(t *testing.T, wantDirPath, gotDirPath string) { t.Helper() @@ -42,17 +41,50 @@ func compareDirectories(t *testing.T, wantDirPath, gotDirPath string) { continue } - gotFile, err := os.ReadFile(path.Join(gotDirPath, gotEntry.Name())) - if err != nil { - t.Fatalf("unexpected error reading `got` file: %s", err) - } - wantFile, _ := os.ReadFile(path.Join(wantDirPath, wantEntry.Name())) + compareFiles(t, path.Join(gotDirPath, gotEntry.Name()), path.Join(wantDirPath, wantEntry.Name())) + } +} + +func compareFiles(t *testing.T, got, want string) { + gotFile, err := os.Open(got) + + if err != nil { + t.Fatalf("unexpected error opening %s: %s", got, err) + } + + gotFileInfo, err := gotFile.Stat() + + if err != nil { + t.Fatalf("unexpected error stat %s: %s", got, err) + } + + if gotFileInfo.IsDir() { + dirEntries, err := os.ReadDir(got) + if err != nil { - t.Fatalf("unexpected error reading `want` file: %s", err) + t.Fatalf("unexpected error reading dir %s: %s", got, err) } - if diff := cmp.Diff(string(gotFile), string(wantFile)); diff != "" { - t.Errorf("unexpected difference in %s: %s", wantEntry.Name(), diff) + for _, dirEntry := range dirEntries { + compareFiles(t, path.Join(got, dirEntry.Name()), path.Join(want, dirEntry.Name())) } + + return + } + + gotFileBytes, err := os.ReadFile(got) + + if err != nil { + t.Fatalf("unexpected error reading `got` file: %s", err) + } + + wantFileBytes, err := os.ReadFile(want) + + if err != nil { + t.Fatalf("unexpected error reading `want` file: %s", err) + } + + if diff := cmp.Diff(string(gotFileBytes), string(wantFileBytes)); diff != "" { + t.Errorf("unexpected difference in %s: %s", got, diff) } } diff --git a/internal/cmd/testdata/custom_and_external/all_output/default_pkg_name/datasource_data_source_gen.go b/internal/cmd/testdata/custom_and_external/all_output/default_pkg_name/datasource_datasource/datasource_data_source_gen.go similarity index 99% rename from internal/cmd/testdata/custom_and_external/all_output/default_pkg_name/datasource_data_source_gen.go rename to internal/cmd/testdata/custom_and_external/all_output/default_pkg_name/datasource_datasource/datasource_data_source_gen.go index 8c4942b9..140d8733 100644 --- a/internal/cmd/testdata/custom_and_external/all_output/default_pkg_name/datasource_data_source_gen.go +++ b/internal/cmd/testdata/custom_and_external/all_output/default_pkg_name/datasource_datasource/datasource_data_source_gen.go @@ -1,6 +1,6 @@ // Code generated by terraform-plugin-framework-generator DO NOT EDIT. -package datasource +package datasource_datasource import ( "context" diff --git a/internal/cmd/testdata/custom_and_external/all_output/default_pkg_name/provider_provider_gen.go b/internal/cmd/testdata/custom_and_external/all_output/default_pkg_name/provider_provider/provider_provider_gen.go similarity index 99% rename from internal/cmd/testdata/custom_and_external/all_output/default_pkg_name/provider_provider_gen.go rename to internal/cmd/testdata/custom_and_external/all_output/default_pkg_name/provider_provider/provider_provider_gen.go index ceac64e9..5d396e33 100644 --- a/internal/cmd/testdata/custom_and_external/all_output/default_pkg_name/provider_provider_gen.go +++ b/internal/cmd/testdata/custom_and_external/all_output/default_pkg_name/provider_provider/provider_provider_gen.go @@ -1,6 +1,6 @@ // Code generated by terraform-plugin-framework-generator DO NOT EDIT. -package provider +package provider_provider import ( "context" diff --git a/internal/cmd/testdata/custom_and_external/all_output/default_pkg_name/resource_resource_gen.go b/internal/cmd/testdata/custom_and_external/all_output/default_pkg_name/resource_resource/resource_resource_gen.go similarity index 99% rename from internal/cmd/testdata/custom_and_external/all_output/default_pkg_name/resource_resource_gen.go rename to internal/cmd/testdata/custom_and_external/all_output/default_pkg_name/resource_resource/resource_resource_gen.go index 67b79d6a..e7ea2a9a 100644 --- a/internal/cmd/testdata/custom_and_external/all_output/default_pkg_name/resource_resource_gen.go +++ b/internal/cmd/testdata/custom_and_external/all_output/default_pkg_name/resource_resource/resource_resource_gen.go @@ -1,6 +1,6 @@ // Code generated by terraform-plugin-framework-generator DO NOT EDIT. -package resource +package resource_resource import ( "context" diff --git a/internal/cmd/testdata/custom_and_external/all_output/specified_pkg_name/datasource_data_source_gen.go b/internal/cmd/testdata/custom_and_external/all_output/specified_pkg_name/datasource_datasource/datasource_data_source_gen.go similarity index 100% rename from internal/cmd/testdata/custom_and_external/all_output/specified_pkg_name/datasource_data_source_gen.go rename to internal/cmd/testdata/custom_and_external/all_output/specified_pkg_name/datasource_datasource/datasource_data_source_gen.go diff --git a/internal/cmd/testdata/custom_and_external/all_output/specified_pkg_name/provider_provider_gen.go b/internal/cmd/testdata/custom_and_external/all_output/specified_pkg_name/provider_provider/provider_provider_gen.go similarity index 100% rename from internal/cmd/testdata/custom_and_external/all_output/specified_pkg_name/provider_provider_gen.go rename to internal/cmd/testdata/custom_and_external/all_output/specified_pkg_name/provider_provider/provider_provider_gen.go diff --git a/internal/cmd/testdata/custom_and_external/all_output/specified_pkg_name/resource_resource_gen.go b/internal/cmd/testdata/custom_and_external/all_output/specified_pkg_name/resource_resource/resource_resource_gen.go similarity index 100% rename from internal/cmd/testdata/custom_and_external/all_output/specified_pkg_name/resource_resource_gen.go rename to internal/cmd/testdata/custom_and_external/all_output/specified_pkg_name/resource_resource/resource_resource_gen.go diff --git a/internal/cmd/testdata/custom_and_external/data_sources_output/datasource_data_source_gen.go b/internal/cmd/testdata/custom_and_external/data_sources_output/datasource_datasource/datasource_data_source_gen.go similarity index 100% rename from internal/cmd/testdata/custom_and_external/data_sources_output/datasource_data_source_gen.go rename to internal/cmd/testdata/custom_and_external/data_sources_output/datasource_datasource/datasource_data_source_gen.go diff --git a/internal/cmd/testdata/custom_and_external/provider_output/provider_provider_gen.go b/internal/cmd/testdata/custom_and_external/provider_output/provider_provider/provider_provider_gen.go similarity index 100% rename from internal/cmd/testdata/custom_and_external/provider_output/provider_provider_gen.go rename to internal/cmd/testdata/custom_and_external/provider_output/provider_provider/provider_provider_gen.go diff --git a/internal/cmd/testdata/custom_and_external/resources_output/resource_resource_gen.go b/internal/cmd/testdata/custom_and_external/resources_output/resource_resource/resource_resource_gen.go similarity index 100% rename from internal/cmd/testdata/custom_and_external/resources_output/resource_resource_gen.go rename to internal/cmd/testdata/custom_and_external/resources_output/resource_resource/resource_resource_gen.go diff --git a/internal/output/write.go b/internal/output/write.go index fa0adc4a..03579d28 100644 --- a/internal/output/write.go +++ b/internal/output/write.go @@ -13,9 +13,16 @@ import ( func WriteDataSources(dataSourcesSchema, dataSourcesModels, dataSourcesModelObjectHelpers, dataSourcesToFrom map[string][]byte, outputDir string) error { for k, v := range dataSourcesSchema { + dirName := fmt.Sprintf("datasource_%s", k) + + err := os.MkdirAll(filepath.Join(outputDir, dirName), os.ModePerm) + if err != nil { + return err + } + filename := fmt.Sprintf("%s_data_source_gen.go", k) - f, err := os.Create(filepath.Join(outputDir, filename)) + f, err := os.Create(filepath.Join(outputDir, dirName, filename)) if err != nil { return err } @@ -46,9 +53,16 @@ func WriteDataSources(dataSourcesSchema, dataSourcesModels, dataSourcesModelObje func WriteResources(resourcesSchema, resourcesModels, resourcesModelObjectHelpers, resourcesToFrom map[string][]byte, outputDir string) error { for k, v := range resourcesSchema { + dirName := fmt.Sprintf("resource_%s", k) + + err := os.MkdirAll(filepath.Join(outputDir, dirName), os.ModePerm) + if err != nil { + return err + } + filename := fmt.Sprintf("%s_resource_gen.go", k) - f, err := os.Create(filepath.Join(outputDir, filename)) + f, err := os.Create(filepath.Join(outputDir, dirName, filename)) if err != nil { return err } @@ -79,9 +93,16 @@ func WriteResources(resourcesSchema, resourcesModels, resourcesModelObjectHelper func WriteProviders(providersSchema, providerModels, providerModelObjectHelpers, providerToFrom map[string][]byte, outputDir string) error { for k, v := range providersSchema { + dirName := fmt.Sprintf("provider_%s", k) + + err := os.MkdirAll(filepath.Join(outputDir, dirName), os.ModePerm) + if err != nil { + return err + } + filename := fmt.Sprintf("%s_provider_gen.go", k) - f, err := os.Create(filepath.Join(outputDir, filename)) + f, err := os.Create(filepath.Join(outputDir, dirName, filename)) if err != nil { return err } diff --git a/internal/schema/schemas.go b/internal/schema/schemas.go index 7ab8c34e..9f47d76b 100644 --- a/internal/schema/schemas.go +++ b/internal/schema/schemas.go @@ -5,6 +5,8 @@ package schema import ( "bytes" + "fmt" + "strings" ) // TODO: Field(s) could be added to handle end-user supplying their own templates to allow overriding. @@ -24,7 +26,7 @@ func (g GeneratorSchemas) SchemasBytes(packageName, generatorType string) (map[s for k, s := range g.schemas { if packageName == "" { - packageName = k + packageName = fmt.Sprintf("%s_%s", strings.ToLower(generatorType), k) } b, err := s.SchemaBytes(k, packageName, generatorType) From 22d1e3d2902f147dd3e0bd2157873f2e7fd1d099 Mon Sep 17 00:00:00 2001 From: Benjamin Bennett Date: Tue, 5 Sep 2023 08:39:14 +0100 Subject: [PATCH 4/6] Only create directory and package per data source and resource if packageName flag is not specified (#20) --- internal/cmd/generate_data_sources.go | 2 +- internal/cmd/generate_provider.go | 2 +- internal/cmd/generate_resources.go | 2 +- .../datasource_data_source_gen.go | 0 .../provider_provider_gen.go | 0 .../resource_resource_gen.go | 0 .../datasource_data_source_gen.go | 0 .../provider_provider_gen.go | 0 .../resource_resource_gen.go | 0 internal/output/write.go | 46 +++++++++++++------ 10 files changed, 34 insertions(+), 18 deletions(-) rename internal/cmd/testdata/custom_and_external/all_output/specified_pkg_name/{datasource_datasource => }/datasource_data_source_gen.go (100%) rename internal/cmd/testdata/custom_and_external/all_output/specified_pkg_name/{provider_provider => }/provider_provider_gen.go (100%) rename internal/cmd/testdata/custom_and_external/all_output/specified_pkg_name/{resource_resource => }/resource_resource_gen.go (100%) rename internal/cmd/testdata/custom_and_external/data_sources_output/{datasource_datasource => }/datasource_data_source_gen.go (100%) rename internal/cmd/testdata/custom_and_external/provider_output/{provider_provider => }/provider_provider_gen.go (100%) rename internal/cmd/testdata/custom_and_external/resources_output/{resource_resource => }/resource_resource_gen.go (100%) diff --git a/internal/cmd/generate_data_sources.go b/internal/cmd/generate_data_sources.go index 7ac99dd5..190e148a 100644 --- a/internal/cmd/generate_data_sources.go +++ b/internal/cmd/generate_data_sources.go @@ -183,7 +183,7 @@ func generateDataSourceCode(spec spec.Specification, outputPath, packageName, ge } // write code - err = output.WriteDataSources(formattedDataSourcesSchema, formattedDataSourcesModels, formattedDataSourcesModelObjectHelpers, formattedDataSourcesToFrom, outputPath) + err = output.WriteDataSources(formattedDataSourcesSchema, formattedDataSourcesModels, formattedDataSourcesModelObjectHelpers, formattedDataSourcesToFrom, outputPath, packageName) if err != nil { return fmt.Errorf("error writing Go code to output: %w", err) } diff --git a/internal/cmd/generate_provider.go b/internal/cmd/generate_provider.go index 6ea622b9..ab8381cb 100644 --- a/internal/cmd/generate_provider.go +++ b/internal/cmd/generate_provider.go @@ -183,7 +183,7 @@ func generateProviderCode(spec spec.Specification, outputPath, packageName, gene } // write code - err = output.WriteProviders(formattedProvidersSchema, formattedProvidersModels, formattedProvidersModelObjectHelpers, formattedProviderToFrom, outputPath) + err = output.WriteProviders(formattedProvidersSchema, formattedProvidersModels, formattedProvidersModelObjectHelpers, formattedProviderToFrom, outputPath, packageName) if err != nil { return fmt.Errorf("error writing Go code to output: %w", err) } diff --git a/internal/cmd/generate_resources.go b/internal/cmd/generate_resources.go index 59e06ef4..1f5d2eec 100644 --- a/internal/cmd/generate_resources.go +++ b/internal/cmd/generate_resources.go @@ -183,7 +183,7 @@ func generateResourceCode(spec spec.Specification, outputPath, packageName, gene } // write code - err = output.WriteResources(formattedResourcesSchema, formattedResourcesModels, formattedResourcesModelObjectHelpers, formattedResourcesToFrom, outputPath) + err = output.WriteResources(formattedResourcesSchema, formattedResourcesModels, formattedResourcesModelObjectHelpers, formattedResourcesToFrom, outputPath, packageName) if err != nil { return fmt.Errorf("error writing Go code to output: %w", err) } diff --git a/internal/cmd/testdata/custom_and_external/all_output/specified_pkg_name/datasource_datasource/datasource_data_source_gen.go b/internal/cmd/testdata/custom_and_external/all_output/specified_pkg_name/datasource_data_source_gen.go similarity index 100% rename from internal/cmd/testdata/custom_and_external/all_output/specified_pkg_name/datasource_datasource/datasource_data_source_gen.go rename to internal/cmd/testdata/custom_and_external/all_output/specified_pkg_name/datasource_data_source_gen.go diff --git a/internal/cmd/testdata/custom_and_external/all_output/specified_pkg_name/provider_provider/provider_provider_gen.go b/internal/cmd/testdata/custom_and_external/all_output/specified_pkg_name/provider_provider_gen.go similarity index 100% rename from internal/cmd/testdata/custom_and_external/all_output/specified_pkg_name/provider_provider/provider_provider_gen.go rename to internal/cmd/testdata/custom_and_external/all_output/specified_pkg_name/provider_provider_gen.go diff --git a/internal/cmd/testdata/custom_and_external/all_output/specified_pkg_name/resource_resource/resource_resource_gen.go b/internal/cmd/testdata/custom_and_external/all_output/specified_pkg_name/resource_resource_gen.go similarity index 100% rename from internal/cmd/testdata/custom_and_external/all_output/specified_pkg_name/resource_resource/resource_resource_gen.go rename to internal/cmd/testdata/custom_and_external/all_output/specified_pkg_name/resource_resource_gen.go diff --git a/internal/cmd/testdata/custom_and_external/data_sources_output/datasource_datasource/datasource_data_source_gen.go b/internal/cmd/testdata/custom_and_external/data_sources_output/datasource_data_source_gen.go similarity index 100% rename from internal/cmd/testdata/custom_and_external/data_sources_output/datasource_datasource/datasource_data_source_gen.go rename to internal/cmd/testdata/custom_and_external/data_sources_output/datasource_data_source_gen.go diff --git a/internal/cmd/testdata/custom_and_external/provider_output/provider_provider/provider_provider_gen.go b/internal/cmd/testdata/custom_and_external/provider_output/provider_provider_gen.go similarity index 100% rename from internal/cmd/testdata/custom_and_external/provider_output/provider_provider/provider_provider_gen.go rename to internal/cmd/testdata/custom_and_external/provider_output/provider_provider_gen.go diff --git a/internal/cmd/testdata/custom_and_external/resources_output/resource_resource/resource_resource_gen.go b/internal/cmd/testdata/custom_and_external/resources_output/resource_resource_gen.go similarity index 100% rename from internal/cmd/testdata/custom_and_external/resources_output/resource_resource/resource_resource_gen.go rename to internal/cmd/testdata/custom_and_external/resources_output/resource_resource_gen.go diff --git a/internal/output/write.go b/internal/output/write.go index 03579d28..225461bd 100644 --- a/internal/output/write.go +++ b/internal/output/write.go @@ -11,13 +11,21 @@ import ( "path/filepath" ) -func WriteDataSources(dataSourcesSchema, dataSourcesModels, dataSourcesModelObjectHelpers, dataSourcesToFrom map[string][]byte, outputDir string) error { +// WriteDataSources uses the packageName to determine whether to create a directory and package per data source. +// If packageName is an empty string, this indicates that the flag was not set, and the default behaviour is +// then to create a package and directory per data source. If packageName is set then all generated code is +// placed into the same directory and package. +func WriteDataSources(dataSourcesSchema, dataSourcesModels, dataSourcesModelObjectHelpers, dataSourcesToFrom map[string][]byte, outputDir, packageName string) error { for k, v := range dataSourcesSchema { - dirName := fmt.Sprintf("datasource_%s", k) + dirName := "" - err := os.MkdirAll(filepath.Join(outputDir, dirName), os.ModePerm) - if err != nil { - return err + if packageName == "" { + dirName = fmt.Sprintf("datasource_%s", k) + + err := os.MkdirAll(filepath.Join(outputDir, dirName), os.ModePerm) + if err != nil { + return err + } } filename := fmt.Sprintf("%s_data_source_gen.go", k) @@ -51,13 +59,17 @@ func WriteDataSources(dataSourcesSchema, dataSourcesModels, dataSourcesModelObje return nil } -func WriteResources(resourcesSchema, resourcesModels, resourcesModelObjectHelpers, resourcesToFrom map[string][]byte, outputDir string) error { +func WriteResources(resourcesSchema, resourcesModels, resourcesModelObjectHelpers, resourcesToFrom map[string][]byte, outputDir, packageName string) error { for k, v := range resourcesSchema { - dirName := fmt.Sprintf("resource_%s", k) + dirName := "" - err := os.MkdirAll(filepath.Join(outputDir, dirName), os.ModePerm) - if err != nil { - return err + if packageName == "" { + dirName = fmt.Sprintf("resource_%s", k) + + err := os.MkdirAll(filepath.Join(outputDir, dirName), os.ModePerm) + if err != nil { + return err + } } filename := fmt.Sprintf("%s_resource_gen.go", k) @@ -91,13 +103,17 @@ func WriteResources(resourcesSchema, resourcesModels, resourcesModelObjectHelper return nil } -func WriteProviders(providersSchema, providerModels, providerModelObjectHelpers, providerToFrom map[string][]byte, outputDir string) error { +func WriteProviders(providersSchema, providerModels, providerModelObjectHelpers, providerToFrom map[string][]byte, outputDir, packageName string) error { for k, v := range providersSchema { - dirName := fmt.Sprintf("provider_%s", k) + dirName := "" - err := os.MkdirAll(filepath.Join(outputDir, dirName), os.ModePerm) - if err != nil { - return err + if packageName == "" { + dirName = fmt.Sprintf("provider_%s", k) + + err := os.MkdirAll(filepath.Join(outputDir, dirName), os.ModePerm) + if err != nil { + return err + } } filename := fmt.Sprintf("%s_provider_gen.go", k) From 8a29f655ea9914f2883eb44c7876c527941f392b Mon Sep 17 00:00:00 2001 From: Benjamin Bennett Date: Tue, 5 Sep 2023 08:47:45 +0100 Subject: [PATCH 5/6] Changing the name of data source, provider and resource in ir.json to "example" to highlight the default behaviour for directory and package generation (#20) --- .../example_data_source_gen.go} | 6 +++--- .../example_provider_gen.go} | 6 +++--- .../example_resource_gen.go} | 6 +++--- ...source_data_source_gen.go => example_data_source_gen.go} | 4 ++-- .../{provider_provider_gen.go => example_provider_gen.go} | 4 ++-- .../{resource_resource_gen.go => example_resource_gen.go} | 4 ++-- ...source_data_source_gen.go => example_data_source_gen.go} | 4 ++-- internal/cmd/testdata/custom_and_external/ir.json | 6 +++--- .../{provider_provider_gen.go => example_provider_gen.go} | 4 ++-- .../{resource_resource_gen.go => example_resource_gen.go} | 4 ++-- 10 files changed, 24 insertions(+), 24 deletions(-) rename internal/cmd/testdata/custom_and_external/all_output/default_pkg_name/{datasource_datasource/datasource_data_source_gen.go => datasource_example/example_data_source_gen.go} (99%) rename internal/cmd/testdata/custom_and_external/all_output/default_pkg_name/{provider_provider/provider_provider_gen.go => provider_example/example_provider_gen.go} (99%) rename internal/cmd/testdata/custom_and_external/all_output/default_pkg_name/{resource_resource/resource_resource_gen.go => resource_example/example_resource_gen.go} (99%) rename internal/cmd/testdata/custom_and_external/all_output/specified_pkg_name/{datasource_data_source_gen.go => example_data_source_gen.go} (99%) rename internal/cmd/testdata/custom_and_external/all_output/specified_pkg_name/{provider_provider_gen.go => example_provider_gen.go} (99%) rename internal/cmd/testdata/custom_and_external/all_output/specified_pkg_name/{resource_resource_gen.go => example_resource_gen.go} (99%) rename internal/cmd/testdata/custom_and_external/data_sources_output/{datasource_data_source_gen.go => example_data_source_gen.go} (99%) rename internal/cmd/testdata/custom_and_external/provider_output/{provider_provider_gen.go => example_provider_gen.go} (99%) rename internal/cmd/testdata/custom_and_external/resources_output/{resource_resource_gen.go => example_resource_gen.go} (99%) diff --git a/internal/cmd/testdata/custom_and_external/all_output/default_pkg_name/datasource_datasource/datasource_data_source_gen.go b/internal/cmd/testdata/custom_and_external/all_output/default_pkg_name/datasource_example/example_data_source_gen.go similarity index 99% rename from internal/cmd/testdata/custom_and_external/all_output/default_pkg_name/datasource_datasource/datasource_data_source_gen.go rename to internal/cmd/testdata/custom_and_external/all_output/default_pkg_name/datasource_example/example_data_source_gen.go index 140d8733..8db0a851 100644 --- a/internal/cmd/testdata/custom_and_external/all_output/default_pkg_name/datasource_datasource/datasource_data_source_gen.go +++ b/internal/cmd/testdata/custom_and_external/all_output/default_pkg_name/datasource_example/example_data_source_gen.go @@ -1,6 +1,6 @@ // Code generated by terraform-plugin-framework-generator DO NOT EDIT. -package datasource_datasource +package datasource_example import ( "context" @@ -12,7 +12,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/types/basetypes" ) -var datasourceDataSourceSchema = schema.Schema{ +var exampleDataSourceSchema = schema.Schema{ Attributes: map[string]schema.Attribute{ "bool_attribute": schema.BoolAttribute{ Computed: true, @@ -423,7 +423,7 @@ var datasourceDataSourceSchema = schema.Schema{ }, } -type DatasourceModel struct { +type ExampleModel struct { BoolAttribute types.Bool `tfsdk:"bool_attribute"` ListListAttribute types.List `tfsdk:"list_list_attribute"` ListMapAttribute types.List `tfsdk:"list_map_attribute"` diff --git a/internal/cmd/testdata/custom_and_external/all_output/default_pkg_name/provider_provider/provider_provider_gen.go b/internal/cmd/testdata/custom_and_external/all_output/default_pkg_name/provider_example/example_provider_gen.go similarity index 99% rename from internal/cmd/testdata/custom_and_external/all_output/default_pkg_name/provider_provider/provider_provider_gen.go rename to internal/cmd/testdata/custom_and_external/all_output/default_pkg_name/provider_example/example_provider_gen.go index 5d396e33..b9caea8e 100644 --- a/internal/cmd/testdata/custom_and_external/all_output/default_pkg_name/provider_provider/provider_provider_gen.go +++ b/internal/cmd/testdata/custom_and_external/all_output/default_pkg_name/provider_example/example_provider_gen.go @@ -1,6 +1,6 @@ // Code generated by terraform-plugin-framework-generator DO NOT EDIT. -package provider_provider +package provider_example import ( "context" @@ -12,7 +12,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/types/basetypes" ) -var providerProviderSchema = schema.Schema{ +var exampleProviderSchema = schema.Schema{ Attributes: map[string]schema.Attribute{ "list_nested_attribute_assoc_ext_type": schema.ListNestedAttribute{ NestedObject: schema.NestedAttributeObject{ @@ -166,7 +166,7 @@ var providerProviderSchema = schema.Schema{ }, } -type ProviderModel struct { +type ExampleModel struct { ListNestedAttributeAssocExtType types.List `tfsdk:"list_nested_attribute_assoc_ext_type"` MapNestedAttributeAssocExtType types.Map `tfsdk:"map_nested_attribute_assoc_ext_type"` SetNestedAttributeAssocExtType types.Set `tfsdk:"set_nested_attribute_assoc_ext_type"` diff --git a/internal/cmd/testdata/custom_and_external/all_output/default_pkg_name/resource_resource/resource_resource_gen.go b/internal/cmd/testdata/custom_and_external/all_output/default_pkg_name/resource_example/example_resource_gen.go similarity index 99% rename from internal/cmd/testdata/custom_and_external/all_output/default_pkg_name/resource_resource/resource_resource_gen.go rename to internal/cmd/testdata/custom_and_external/all_output/default_pkg_name/resource_example/example_resource_gen.go index e7ea2a9a..c065b6b1 100644 --- a/internal/cmd/testdata/custom_and_external/all_output/default_pkg_name/resource_resource/resource_resource_gen.go +++ b/internal/cmd/testdata/custom_and_external/all_output/default_pkg_name/resource_example/example_resource_gen.go @@ -1,6 +1,6 @@ // Code generated by terraform-plugin-framework-generator DO NOT EDIT. -package resource_resource +package resource_example import ( "context" @@ -18,7 +18,7 @@ import ( boolalias "github.com/my_account_my_project/bool" ) -var resourceResourceSchema = schema.Schema{ +var exampleResourceSchema = schema.Schema{ Attributes: map[string]schema.Attribute{ "bool_attribute": schema.BoolAttribute{ CustomType: my_bool_type, @@ -183,7 +183,7 @@ var resourceResourceSchema = schema.Schema{ }, } -type ResourceModel struct { +type ExampleModel struct { BoolAttribute my_bool_value `tfsdk:"bool_attribute"` ListNestedAttributeAssocExtType types.List `tfsdk:"list_nested_attribute_assoc_ext_type"` MapNestedAttributeAssocExtType types.Map `tfsdk:"map_nested_attribute_assoc_ext_type"` diff --git a/internal/cmd/testdata/custom_and_external/all_output/specified_pkg_name/datasource_data_source_gen.go b/internal/cmd/testdata/custom_and_external/all_output/specified_pkg_name/example_data_source_gen.go similarity index 99% rename from internal/cmd/testdata/custom_and_external/all_output/specified_pkg_name/datasource_data_source_gen.go rename to internal/cmd/testdata/custom_and_external/all_output/specified_pkg_name/example_data_source_gen.go index 04de2682..41b4f29c 100644 --- a/internal/cmd/testdata/custom_and_external/all_output/specified_pkg_name/datasource_data_source_gen.go +++ b/internal/cmd/testdata/custom_and_external/all_output/specified_pkg_name/example_data_source_gen.go @@ -12,7 +12,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/types/basetypes" ) -var datasourceDataSourceSchema = schema.Schema{ +var exampleDataSourceSchema = schema.Schema{ Attributes: map[string]schema.Attribute{ "bool_attribute": schema.BoolAttribute{ Computed: true, @@ -423,7 +423,7 @@ var datasourceDataSourceSchema = schema.Schema{ }, } -type DatasourceModel struct { +type ExampleModel struct { BoolAttribute types.Bool `tfsdk:"bool_attribute"` ListListAttribute types.List `tfsdk:"list_list_attribute"` ListMapAttribute types.List `tfsdk:"list_map_attribute"` diff --git a/internal/cmd/testdata/custom_and_external/all_output/specified_pkg_name/provider_provider_gen.go b/internal/cmd/testdata/custom_and_external/all_output/specified_pkg_name/example_provider_gen.go similarity index 99% rename from internal/cmd/testdata/custom_and_external/all_output/specified_pkg_name/provider_provider_gen.go rename to internal/cmd/testdata/custom_and_external/all_output/specified_pkg_name/example_provider_gen.go index 129b9531..bf86270f 100644 --- a/internal/cmd/testdata/custom_and_external/all_output/specified_pkg_name/provider_provider_gen.go +++ b/internal/cmd/testdata/custom_and_external/all_output/specified_pkg_name/example_provider_gen.go @@ -12,7 +12,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/types/basetypes" ) -var providerProviderSchema = schema.Schema{ +var exampleProviderSchema = schema.Schema{ Attributes: map[string]schema.Attribute{ "list_nested_attribute_assoc_ext_type": schema.ListNestedAttribute{ NestedObject: schema.NestedAttributeObject{ @@ -166,7 +166,7 @@ var providerProviderSchema = schema.Schema{ }, } -type ProviderModel struct { +type ExampleModel struct { ListNestedAttributeAssocExtType types.List `tfsdk:"list_nested_attribute_assoc_ext_type"` MapNestedAttributeAssocExtType types.Map `tfsdk:"map_nested_attribute_assoc_ext_type"` SetNestedAttributeAssocExtType types.Set `tfsdk:"set_nested_attribute_assoc_ext_type"` diff --git a/internal/cmd/testdata/custom_and_external/all_output/specified_pkg_name/resource_resource_gen.go b/internal/cmd/testdata/custom_and_external/all_output/specified_pkg_name/example_resource_gen.go similarity index 99% rename from internal/cmd/testdata/custom_and_external/all_output/specified_pkg_name/resource_resource_gen.go rename to internal/cmd/testdata/custom_and_external/all_output/specified_pkg_name/example_resource_gen.go index 8a7bf0f4..dae97c89 100644 --- a/internal/cmd/testdata/custom_and_external/all_output/specified_pkg_name/resource_resource_gen.go +++ b/internal/cmd/testdata/custom_and_external/all_output/specified_pkg_name/example_resource_gen.go @@ -18,7 +18,7 @@ import ( boolalias "github.com/my_account_my_project/bool" ) -var resourceResourceSchema = schema.Schema{ +var exampleResourceSchema = schema.Schema{ Attributes: map[string]schema.Attribute{ "bool_attribute": schema.BoolAttribute{ CustomType: my_bool_type, @@ -183,7 +183,7 @@ var resourceResourceSchema = schema.Schema{ }, } -type ResourceModel struct { +type ExampleModel struct { BoolAttribute my_bool_value `tfsdk:"bool_attribute"` ListNestedAttributeAssocExtType types.List `tfsdk:"list_nested_attribute_assoc_ext_type"` MapNestedAttributeAssocExtType types.Map `tfsdk:"map_nested_attribute_assoc_ext_type"` diff --git a/internal/cmd/testdata/custom_and_external/data_sources_output/datasource_data_source_gen.go b/internal/cmd/testdata/custom_and_external/data_sources_output/example_data_source_gen.go similarity index 99% rename from internal/cmd/testdata/custom_and_external/data_sources_output/datasource_data_source_gen.go rename to internal/cmd/testdata/custom_and_external/data_sources_output/example_data_source_gen.go index 73f02147..5db691ba 100644 --- a/internal/cmd/testdata/custom_and_external/data_sources_output/datasource_data_source_gen.go +++ b/internal/cmd/testdata/custom_and_external/data_sources_output/example_data_source_gen.go @@ -12,7 +12,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/types/basetypes" ) -var datasourceDataSourceSchema = schema.Schema{ +var exampleDataSourceSchema = schema.Schema{ Attributes: map[string]schema.Attribute{ "bool_attribute": schema.BoolAttribute{ Computed: true, @@ -423,7 +423,7 @@ var datasourceDataSourceSchema = schema.Schema{ }, } -type DatasourceModel struct { +type ExampleModel struct { BoolAttribute types.Bool `tfsdk:"bool_attribute"` ListListAttribute types.List `tfsdk:"list_list_attribute"` ListMapAttribute types.List `tfsdk:"list_map_attribute"` diff --git a/internal/cmd/testdata/custom_and_external/ir.json b/internal/cmd/testdata/custom_and_external/ir.json index c6421234..60823499 100644 --- a/internal/cmd/testdata/custom_and_external/ir.json +++ b/internal/cmd/testdata/custom_and_external/ir.json @@ -1,7 +1,7 @@ { "datasources": [ { - "name": "datasource", + "name": "example", "schema": { "attributes": [ { @@ -732,7 +732,7 @@ } ], "provider": { - "name": "provider", + "name": "example", "schema": { "attributes": [ { @@ -1057,7 +1057,7 @@ }, "resources": [ { - "name": "resource", + "name": "example", "schema": { "attributes": [ { diff --git a/internal/cmd/testdata/custom_and_external/provider_output/provider_provider_gen.go b/internal/cmd/testdata/custom_and_external/provider_output/example_provider_gen.go similarity index 99% rename from internal/cmd/testdata/custom_and_external/provider_output/provider_provider_gen.go rename to internal/cmd/testdata/custom_and_external/provider_output/example_provider_gen.go index c1e64bd3..43c7577b 100644 --- a/internal/cmd/testdata/custom_and_external/provider_output/provider_provider_gen.go +++ b/internal/cmd/testdata/custom_and_external/provider_output/example_provider_gen.go @@ -12,7 +12,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/types/basetypes" ) -var providerProviderSchema = schema.Schema{ +var exampleProviderSchema = schema.Schema{ Attributes: map[string]schema.Attribute{ "list_nested_attribute_assoc_ext_type": schema.ListNestedAttribute{ NestedObject: schema.NestedAttributeObject{ @@ -166,7 +166,7 @@ var providerProviderSchema = schema.Schema{ }, } -type ProviderModel struct { +type ExampleModel struct { ListNestedAttributeAssocExtType types.List `tfsdk:"list_nested_attribute_assoc_ext_type"` MapNestedAttributeAssocExtType types.Map `tfsdk:"map_nested_attribute_assoc_ext_type"` SetNestedAttributeAssocExtType types.Set `tfsdk:"set_nested_attribute_assoc_ext_type"` diff --git a/internal/cmd/testdata/custom_and_external/resources_output/resource_resource_gen.go b/internal/cmd/testdata/custom_and_external/resources_output/example_resource_gen.go similarity index 99% rename from internal/cmd/testdata/custom_and_external/resources_output/resource_resource_gen.go rename to internal/cmd/testdata/custom_and_external/resources_output/example_resource_gen.go index dfbc4e7c..a32b165c 100644 --- a/internal/cmd/testdata/custom_and_external/resources_output/resource_resource_gen.go +++ b/internal/cmd/testdata/custom_and_external/resources_output/example_resource_gen.go @@ -18,7 +18,7 @@ import ( boolalias "github.com/my_account_my_project/bool" ) -var resourceResourceSchema = schema.Schema{ +var exampleResourceSchema = schema.Schema{ Attributes: map[string]schema.Attribute{ "bool_attribute": schema.BoolAttribute{ CustomType: my_bool_type, @@ -183,7 +183,7 @@ var resourceResourceSchema = schema.Schema{ }, } -type ResourceModel struct { +type ExampleModel struct { BoolAttribute my_bool_value `tfsdk:"bool_attribute"` ListNestedAttributeAssocExtType types.List `tfsdk:"list_nested_attribute_assoc_ext_type"` MapNestedAttributeAssocExtType types.Map `tfsdk:"map_nested_attribute_assoc_ext_type"` From d1832fb04d660eddce0b871bd44db742b43ff45a Mon Sep 17 00:00:00 2001 From: Benjamin Bennett Date: Tue, 5 Sep 2023 08:59:16 +0100 Subject: [PATCH 6/6] Adding doc comments (#20) --- internal/output/write.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/internal/output/write.go b/internal/output/write.go index 225461bd..4733871c 100644 --- a/internal/output/write.go +++ b/internal/output/write.go @@ -59,6 +59,10 @@ func WriteDataSources(dataSourcesSchema, dataSourcesModels, dataSourcesModelObje return nil } +// WriteResources uses the packageName to determine whether to create a directory and package per resource. +// If packageName is an empty string, this indicates that the flag was not set, and the default behaviour is +// then to create a package and directory per resource. If packageName is set then all generated code is +// placed into the same directory and package. func WriteResources(resourcesSchema, resourcesModels, resourcesModelObjectHelpers, resourcesToFrom map[string][]byte, outputDir, packageName string) error { for k, v := range resourcesSchema { dirName := "" @@ -103,6 +107,10 @@ func WriteResources(resourcesSchema, resourcesModels, resourcesModelObjectHelper return nil } +// WriteProviders uses the packageName to determine whether to create a directory and package for the provider. +// If packageName is an empty string, this indicates that the flag was not set, and the default behaviour is +// then to create a package and directory for the provider. If packageName is set then all generated code is +// placed into the same directory and package. func WriteProviders(providersSchema, providerModels, providerModelObjectHelpers, providerToFrom map[string][]byte, outputDir, packageName string) error { for k, v := range providersSchema { dirName := ""