Skip to content

Commit

Permalink
d/aws_bedrock_foundation_models: Use 'DataSourceComputedListOfObjectA…
Browse files Browse the repository at this point in the history
…ttribute'.
  • Loading branch information
ewbankkit committed Oct 10, 2024
1 parent 18e8fa1 commit edf58a1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 39 deletions.
23 changes: 12 additions & 11 deletions internal/service/bedrock/foundation_model_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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"`
}
39 changes: 11 additions & 28 deletions internal/service/bedrock/foundation_models_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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),
},
}
}
Expand Down Expand Up @@ -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"`
}

0 comments on commit edf58a1

Please sign in to comment.