@@ -11,6 +11,7 @@ import (
1111 "github.com/hashicorp/terraform-plugin-framework/internal/fwschema"
1212 "github.com/hashicorp/terraform-plugin-framework/resource"
1313 "github.com/hashicorp/terraform-plugin-framework/tfsdk"
14+ "github.com/hashicorp/terraform-plugin-go/tfprotov5"
1415 "github.com/hashicorp/terraform-plugin-go/tftypes"
1516)
1617
@@ -41,6 +42,16 @@ type ListResource interface {
4142 List (context.Context , ListRequest , * ListResultsStream )
4243}
4344
45+ // ListResourceWithProtoSchemas is an interface type that extends ListResource to include a method
46+ // which allows provider developers to supply the ProtoV5 representations of resource and resource identity
47+ // schemas. This is necessary if list functionality is being used with a legacy resource.
48+ type ListResourceWithProtoSchemas interface {
49+ ListResource
50+
51+ // Schemas is called to provide the ProtoV5 representations of the resource and resource identity schemas.
52+ Schemas (context.Context , * SchemaResponse )
53+ }
54+
4455// ListResourceWithConfigure is an interface type that extends ListResource to include a method
4556// which the framework will automatically call so provider developers have the
4657// opportunity to setup any necessary provider-level data or clients.
@@ -182,6 +193,20 @@ type ListResult struct {
182193 Diagnostics diag.Diagnostics
183194}
184195
196+ // SchemaResponse represents a response that is populated by the Schemas method
197+ // and is used to pass along the ProtoV5 representations of the resource and resource identity schemas.
198+ type SchemaResponse struct {
199+ // ProtoV5IdentitySchema is the ProtoV5 representation of the resource identity
200+ // schema. This should only be supplied if framework functionality is being used
201+ // with a legacy resource. Currently, this only applies to list.
202+ ProtoV5IdentitySchema func () * tfprotov5.ResourceIdentitySchema
203+
204+ // ProtoV5Schema is the ProtoV5 representation of the resource schema
205+ // This should only be supplied if framework functionality is being used
206+ // with a legacy resource. Currently, this only applies to list.
207+ ProtoV5Schema func () * tfprotov5.Schema
208+ }
209+
185210// ValidateConfigRequest represents a request to validate the configuration of
186211// a list resource. An instance of this request struct is supplied as an
187212// argument to the [ListResourceWithValidateConfig.ValidateListResourceConfig]
0 commit comments