Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions list/list_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,13 @@ import (
// - Validation: Schema-based or entire configuration via
// ListResourceWithConfigValidators or ListResourceWithValidateConfig.
type ListResource interface {
// Metadata should return the full name of the list resource such as
// examplecloud_thing. This name should match the full name of the managed
// resource to be listed; otherwise, the GetMetadata RPC will return an
// error diagnostic.
//
// The method signature is intended to be compatible with the Metadata
// method signature in the Resource interface. One implementation of
// Metadata can satisfy both interfaces.
Metadata(context.Context, resource.MetadataRequest, *resource.MetadataResponse)
// A single provider-defined type can implement the
// Create-Read-Update-Delete (CRUD) operations ([resource.Resource]) and
// the List (L) operation ([list.ListResource]). The
// [resource.ResourceMetadata] interface is embedded in both interfaces.
// This allows a single implementation of `Metadata()` to satisfy both
// interfaces without code duplication.
resource.ResourceMetadata

// ListResourceConfigSchema should return the schema for list blocks.
ListResourceConfigSchema(context.Context, ListResourceSchemaRequest, *ListResourceSchemaResponse)
Expand Down
10 changes: 7 additions & 3 deletions resource/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ import (
// Although not required, it is conventional for resources to implement the
// ResourceWithImportState interface.
type Resource interface {
// Metadata should return the full name of the resource, such as
// examplecloud_thing.
Metadata(context.Context, MetadataRequest, *MetadataResponse)
ResourceMetadata

// Schema should return the schema for this resource.
Schema(context.Context, SchemaRequest, *SchemaResponse)
Expand Down Expand Up @@ -57,6 +55,12 @@ type Resource interface {
Delete(context.Context, DeleteRequest, *DeleteResponse)
}

type ResourceMetadata interface {
// Metadata should return the full name of the resource, such as
// examplecloud_thing.
Metadata(context.Context, MetadataRequest, *MetadataResponse)
}

// ResourceWithConfigure is an interface type that extends Resource to
// include a method which the framework will automatically call so provider
// developers have the opportunity to setup any necessary provider-level data
Expand Down