@@ -5,6 +5,7 @@ package resource
55
66import (
77 "context"
8+ "iter"
89
910 "github.com/hashicorp/terraform-plugin-framework/diag"
1011 "github.com/hashicorp/terraform-plugin-framework/tfsdk"
@@ -24,30 +25,62 @@ type List interface {
2425 ListResources (context.Context , ListRequest , ListResponse )
2526}
2627
28+ // ListWithConfigure is an interface type that extends List to include a method
29+ // which the framework will automatically call so provider developers have the
30+ // opportunity to setup any necessary provider-level data or clients.
2731type ListWithConfigure interface {
2832 List
2933 Configure (context.Context , ConfigureRequest , * ConfigureResponse )
3034}
3135
36+ // ListWithConfigValidators is an interface type that extends List to include
37+ // declarative validations.
38+ //
39+ // Declaring validation using this methodology simplifies implementation of
40+ // reusable functionality. These also include descriptions, which can be used
41+ // for automating documentation.
42+ //
43+ // Validation will include ListConfigValidators and ValidateListConfig, if both
44+ // are implemented, in addition to any Attribute or Type validation.
3245type ListWithConfigValidators interface {
3346 List
3447 ListConfigValidators (context.Context ) []ListConfigValidator
3548}
3649
50+ // ListWithValidateConfig is an interface type that extends List to include
51+ // imperative validation.
52+ //
53+ // Declaring validation using this methodology simplifies one-off
54+ // functionality that typically applies to a single resource. Any documentation
55+ // of this functionality must be manually added into schema descriptions.
56+ //
57+ // Validation will include ListConfigValidators and ValidateListConfig, if both
58+ // are implemented, in addition to any Attribute or Type validation.
3759type ListWithValidateConfig interface {
3860 List
3961 ValidateListConfig (context.Context , ValidateListConfigRequest , * ValidateListConfigResponse )
4062}
4163
64+ // ListRequest represents a request for the provider to list instances of a
65+ // managed resource type that satisfy a user-defined request. An instance of
66+ // this rqeuest struct is passed as an argument to the provider's ListResources
67+ // function implementation.
4268type ListRequest struct {
4369 Config tfsdk.Config
4470 IncludeResourceObject bool
4571}
4672
73+ // ListResponse represents a response to a ListRequest. An instance of this
74+ // response struct is supplied as an argument to the provider's ListResource
75+ // function implementation function. The provider should set an iterator
76+ // function on the response struct.
4777type ListResponse struct {
48- Results [] ListResult // TODO: streamify
78+ Results iter. Seq [ ListResult ] // Speculative + exploratory use of Go 1.23 iterators
4979}
5080
81+ // ListResult represents a managed resource instance. A provider's ListResource
82+ // function implementation will emit zero or more results for a user-provided
83+ // request.
5184type ListResult struct {
5285 Identity tfsdk.ResourceIdentity
5386 Resource tfsdk.ResourceObject
0 commit comments