From edf58a10b2bf8ebdcad5903c5a86fb4232e75c1b Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Thu, 10 Oct 2024 13:45:44 -0400 Subject: [PATCH] d/aws_bedrock_foundation_models: Use 'DataSourceComputedListOfObjectAttribute'. --- .../bedrock/foundation_model_data_source.go | 23 +++++------ .../bedrock/foundation_models_data_source.go | 39 ++++++------------- 2 files changed, 23 insertions(+), 39 deletions(-) diff --git a/internal/service/bedrock/foundation_model_data_source.go b/internal/service/bedrock/foundation_model_data_source.go index aa5b2a78595d..060351bb3d5b 100644 --- a/internal/service/bedrock/foundation_model_data_source.go +++ b/internal/service/bedrock/foundation_model_data_source.go @@ -50,7 +50,8 @@ func (d *foundationModelDataSource) Schema(ctx context.Context, request datasour Computed: true, }, "model_arn": schema.StringAttribute{ - Computed: true, + CustomType: fwtypes.ARNType, + Computed: true, }, "model_id": schema.StringAttribute{ Required: true, @@ -105,14 +106,14 @@ func (d *foundationModelDataSource) Read(ctx context.Context, request datasource } type foundationModelDataSourceModel struct { - CustomizationsSupported fwtypes.SetValueOf[types.String] `tfsdk:"customizations_supported"` - ID types.String `tfsdk:"id"` - InferenceTypesSupported fwtypes.SetValueOf[types.String] `tfsdk:"inference_types_supported"` - InputModalities fwtypes.SetValueOf[types.String] `tfsdk:"input_modalities"` - ModelARN types.String `tfsdk:"model_arn"` - ModelID types.String `tfsdk:"model_id"` - ModelName types.String `tfsdk:"model_name"` - OutputModalities fwtypes.SetValueOf[types.String] `tfsdk:"output_modalities"` - ProviderName types.String `tfsdk:"provider_name"` - ResponseStreamingSupported types.Bool `tfsdk:"response_streaming_supported"` + CustomizationsSupported fwtypes.SetOfString `tfsdk:"customizations_supported"` + ID types.String `tfsdk:"id"` + InferenceTypesSupported fwtypes.SetOfString `tfsdk:"inference_types_supported"` + InputModalities fwtypes.SetOfString `tfsdk:"input_modalities"` + ModelARN fwtypes.ARN `tfsdk:"model_arn"` + ModelID types.String `tfsdk:"model_id"` + ModelName types.String `tfsdk:"model_name"` + OutputModalities fwtypes.SetOfString `tfsdk:"output_modalities"` + ProviderName types.String `tfsdk:"provider_name"` + ResponseStreamingSupported types.Bool `tfsdk:"response_streaming_supported"` } diff --git a/internal/service/bedrock/foundation_models_data_source.go b/internal/service/bedrock/foundation_models_data_source.go index 24730098de8e..f18606b06415 100644 --- a/internal/service/bedrock/foundation_models_data_source.go +++ b/internal/service/bedrock/foundation_models_data_source.go @@ -10,7 +10,6 @@ import ( "github.com/aws/aws-sdk-go-v2/service/bedrock" awstypes "github.com/aws/aws-sdk-go-v2/service/bedrock/types" "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" - "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" "github.com/hashicorp/terraform-plugin-framework/schema/validator" @@ -55,24 +54,8 @@ func (d *foundationModelsDataSource) Schema(ctx context.Context, request datasou stringvalidator.RegexMatches(regexache.MustCompile(`^[A-Za-z0-9- ]{1,63}$`), ""), }, }, - names.AttrID: framework.IDAttribute(), - "model_summaries": schema.ListAttribute{ - CustomType: fwtypes.NewListNestedObjectTypeOf[foundationModelSummaryModel](ctx), - Computed: true, - ElementType: types.ObjectType{ - AttrTypes: map[string]attr.Type{ - "customizations_supported": types.SetType{ElemType: types.StringType}, - "inference_types_supported": types.SetType{ElemType: types.StringType}, - "input_modalities": types.SetType{ElemType: types.StringType}, - "model_arn": types.StringType, - "model_id": types.StringType, - "model_name": types.StringType, - "output_modalities": types.SetType{ElemType: types.StringType}, - names.AttrProviderName: types.StringType, - "response_streaming_supported": types.BoolType, - }, - }, - }, + names.AttrID: framework.IDAttribute(), + "model_summaries": framework.DataSourceComputedListOfObjectAttribute[foundationModelSummaryModel](ctx), }, } } @@ -120,13 +103,13 @@ type foundationModelsDataSourceModel struct { } type foundationModelSummaryModel struct { - CustomizationsSupported fwtypes.SetValueOf[types.String] `tfsdk:"customizations_supported"` - InferenceTypesSupported fwtypes.SetValueOf[types.String] `tfsdk:"inference_types_supported"` - InputModalities fwtypes.SetValueOf[types.String] `tfsdk:"input_modalities"` - ModelARN types.String `tfsdk:"model_arn"` - ModelID types.String `tfsdk:"model_id"` - ModelName types.String `tfsdk:"model_name"` - OutputModalities fwtypes.SetValueOf[types.String] `tfsdk:"output_modalities"` - ProviderName types.String `tfsdk:"provider_name"` - ResponseStreamingSupported types.Bool `tfsdk:"response_streaming_supported"` + CustomizationsSupported fwtypes.SetOfString `tfsdk:"customizations_supported"` + InferenceTypesSupported fwtypes.SetOfString `tfsdk:"inference_types_supported"` + InputModalities fwtypes.SetOfString `tfsdk:"input_modalities"` + ModelARN fwtypes.ARN `tfsdk:"model_arn"` + ModelID types.String `tfsdk:"model_id"` + ModelName types.String `tfsdk:"model_name"` + OutputModalities fwtypes.SetOfString `tfsdk:"output_modalities"` + ProviderName types.String `tfsdk:"provider_name"` + ResponseStreamingSupported types.Bool `tfsdk:"response_streaming_supported"` }