@@ -18,6 +18,8 @@ import (
1818 "github.com/hashicorp/terraform-plugin-framework/internal/fwschema"
1919 "github.com/hashicorp/terraform-plugin-framework/internal/fwserver"
2020 "github.com/hashicorp/terraform-plugin-framework/internal/testing/testprovider"
21+ "github.com/hashicorp/terraform-plugin-framework/list"
22+ listschema "github.com/hashicorp/terraform-plugin-framework/list/schema"
2123 "github.com/hashicorp/terraform-plugin-framework/provider"
2224 "github.com/hashicorp/terraform-plugin-framework/provider/metaschema"
2325 providerschema "github.com/hashicorp/terraform-plugin-framework/provider/schema"
@@ -41,6 +43,7 @@ func TestServerGetProviderSchema(t *testing.T) {
4143 DataSourceSchemas : map [string ]fwschema.Schema {},
4244 EphemeralResourceSchemas : map [string ]fwschema.Schema {},
4345 FunctionDefinitions : map [string ]function.Definition {},
46+ ListResourceSchemas : map [string ]fwschema.Schema {},
4447 Provider : providerschema.Schema {},
4548 ResourceSchemas : map [string ]fwschema.Schema {},
4649 ServerCapabilities : & fwserver.ServerCapabilities {
@@ -111,6 +114,7 @@ func TestServerGetProviderSchema(t *testing.T) {
111114 },
112115 EphemeralResourceSchemas : map [string ]fwschema.Schema {},
113116 FunctionDefinitions : map [string ]function.Definition {},
117+ ListResourceSchemas : map [string ]fwschema.Schema {},
114118 Provider : providerschema.Schema {},
115119 ResourceSchemas : map [string ]fwschema.Schema {},
116120 ServerCapabilities : & fwserver.ServerCapabilities {
@@ -318,6 +322,7 @@ func TestServerGetProviderSchema(t *testing.T) {
318322 },
319323 EphemeralResourceSchemas : map [string ]fwschema.Schema {},
320324 FunctionDefinitions : map [string ]function.Definition {},
325+ ListResourceSchemas : map [string ]fwschema.Schema {},
321326 Provider : providerschema.Schema {},
322327 ResourceSchemas : map [string ]fwschema.Schema {},
323328 ServerCapabilities : & fwserver.ServerCapabilities {
@@ -388,6 +393,7 @@ func TestServerGetProviderSchema(t *testing.T) {
388393 },
389394 },
390395 FunctionDefinitions : map [string ]function.Definition {},
396+ ListResourceSchemas : map [string ]fwschema.Schema {},
391397 Provider : providerschema.Schema {},
392398 ResourceSchemas : map [string ]fwschema.Schema {},
393399 ServerCapabilities : & fwserver.ServerCapabilities {
@@ -601,6 +607,7 @@ func TestServerGetProviderSchema(t *testing.T) {
601607 },
602608 },
603609 FunctionDefinitions : map [string ]function.Definition {},
610+ ListResourceSchemas : map [string ]fwschema.Schema {},
604611 Provider : providerschema.Schema {},
605612 ResourceSchemas : map [string ]fwschema.Schema {},
606613 ServerCapabilities : & fwserver.ServerCapabilities {
@@ -655,8 +662,9 @@ func TestServerGetProviderSchema(t *testing.T) {
655662 Return : function.StringReturn {},
656663 },
657664 },
658- Provider : providerschema.Schema {},
659- ResourceSchemas : map [string ]fwschema.Schema {},
665+ ListResourceSchemas : map [string ]fwschema.Schema {},
666+ Provider : providerschema.Schema {},
667+ ResourceSchemas : map [string ]fwschema.Schema {},
660668 ServerCapabilities : & fwserver.ServerCapabilities {
661669 GetProviderSchemaOptional : true ,
662670 MoveResourceState : true ,
@@ -808,6 +816,82 @@ func TestServerGetProviderSchema(t *testing.T) {
808816 },
809817 },
810818 },
819+ "listresource-schemas" : {
820+ server : & fwserver.Server {
821+ Provider : & testprovider.Provider {
822+ ListResourcesMethod : func (_ context.Context ) []func () list.ListResource {
823+ return []func () list.ListResource {
824+ func () list.ListResource {
825+ return & testprovider.ListResource {
826+ ListResourceConfigSchemaMethod : func (_ context.Context , _ list.ListResourceSchemaRequest , resp * list.ListResourceSchemaResponse ) {
827+ resp .Schema = listschema.Schema {
828+ Attributes : map [string ]listschema.Attribute {
829+ "test1" : listschema.StringAttribute {
830+ Required : true ,
831+ },
832+ },
833+ }
834+ },
835+ MetadataMethod : func (_ context.Context , _ resource.MetadataRequest , resp * resource.MetadataResponse ) {
836+ resp .TypeName = "test_resource"
837+ },
838+ }
839+ },
840+ }
841+ },
842+ ResourcesMethod : func (_ context.Context ) []func () resource.Resource {
843+ return []func () resource.Resource {
844+ func () resource.Resource {
845+ return & testprovider.Resource {
846+ SchemaMethod : func (_ context.Context , _ resource.SchemaRequest , resp * resource.SchemaResponse ) {
847+ resp .Schema = resourceschema.Schema {
848+ Attributes : map [string ]resourceschema.Attribute {
849+ "test1" : resourceschema.StringAttribute {
850+ Required : true ,
851+ },
852+ },
853+ }
854+ },
855+ MetadataMethod : func (_ context.Context , _ resource.MetadataRequest , resp * resource.MetadataResponse ) {
856+ resp .TypeName = "test_resource"
857+ },
858+ }
859+ },
860+ }
861+ },
862+ },
863+ },
864+ request : & fwserver.GetProviderSchemaRequest {},
865+ expectedResponse : & fwserver.GetProviderSchemaResponse {
866+ DataSourceSchemas : map [string ]fwschema.Schema {},
867+ EphemeralResourceSchemas : map [string ]fwschema.Schema {},
868+ FunctionDefinitions : map [string ]function.Definition {},
869+ ListResourceSchemas : map [string ]fwschema.Schema {
870+ "test_resource" : listschema.Schema {
871+ Attributes : map [string ]listschema.Attribute {
872+ "test1" : listschema.StringAttribute {
873+ Required : true ,
874+ },
875+ },
876+ },
877+ },
878+ Provider : providerschema.Schema {},
879+ ResourceSchemas : map [string ]fwschema.Schema {
880+ "test_resource" : resourceschema.Schema {
881+ Attributes : map [string ]resourceschema.Attribute {
882+ "test1" : resourceschema.StringAttribute {
883+ Required : true ,
884+ },
885+ },
886+ },
887+ },
888+ ServerCapabilities : & fwserver.ServerCapabilities {
889+ GetProviderSchemaOptional : true ,
890+ MoveResourceState : true ,
891+ PlanDestroy : true ,
892+ },
893+ },
894+ },
811895 "provider" : {
812896 server : & fwserver.Server {
813897 Provider : & testprovider.Provider {
@@ -827,6 +911,7 @@ func TestServerGetProviderSchema(t *testing.T) {
827911 DataSourceSchemas : map [string ]fwschema.Schema {},
828912 EphemeralResourceSchemas : map [string ]fwschema.Schema {},
829913 FunctionDefinitions : map [string ]function.Definition {},
914+ ListResourceSchemas : map [string ]fwschema.Schema {},
830915 Provider : providerschema.Schema {
831916 Attributes : map [string ]providerschema.Attribute {
832917 "test" : providerschema.StringAttribute {
@@ -894,6 +979,7 @@ func TestServerGetProviderSchema(t *testing.T) {
894979 DataSourceSchemas : map [string ]fwschema.Schema {},
895980 EphemeralResourceSchemas : map [string ]fwschema.Schema {},
896981 FunctionDefinitions : map [string ]function.Definition {},
982+ ListResourceSchemas : map [string ]fwschema.Schema {},
897983 Provider : providerschema.Schema {},
898984 ProviderMeta : metaschema.Schema {
899985 Attributes : map [string ]metaschema.Attribute {
@@ -990,6 +1076,7 @@ func TestServerGetProviderSchema(t *testing.T) {
9901076 DataSourceSchemas : map [string ]fwschema.Schema {},
9911077 EphemeralResourceSchemas : map [string ]fwschema.Schema {},
9921078 FunctionDefinitions : map [string ]function.Definition {},
1079+ ListResourceSchemas : map [string ]fwschema.Schema {},
9931080 Provider : providerschema.Schema {},
9941081 ResourceSchemas : map [string ]fwschema.Schema {
9951082 "test_resource1" : resourceschema.Schema {
@@ -1203,6 +1290,7 @@ func TestServerGetProviderSchema(t *testing.T) {
12031290 DataSourceSchemas : map [string ]fwschema.Schema {},
12041291 EphemeralResourceSchemas : map [string ]fwschema.Schema {},
12051292 FunctionDefinitions : map [string ]function.Definition {},
1293+ ListResourceSchemas : map [string ]fwschema.Schema {},
12061294 Provider : providerschema.Schema {},
12071295 ResourceSchemas : map [string ]fwschema.Schema {
12081296 "testprovidertype_resource" : resourceschema.Schema {
0 commit comments