48 lines
1.4 KiB
Go
48 lines
1.4 KiB
Go
package sqlserverflexalpha
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/hashicorp/terraform-plugin-framework/datasource"
|
|
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
|
|
"github.com/hashicorp/terraform-plugin-framework/types"
|
|
)
|
|
|
|
var _ datasource.DataSource = (*versionDataSource)(nil)
|
|
|
|
func NewVersionDataSource() datasource.DataSource {
|
|
return &versionDataSource{}
|
|
}
|
|
|
|
type versionDataSource struct{}
|
|
|
|
type versionDataSourceModel struct {
|
|
Id types.String `tfsdk:"id"`
|
|
}
|
|
|
|
func (d *versionDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) {
|
|
resp.TypeName = req.ProviderTypeName + "sqlserverflexalpha_version"
|
|
}
|
|
|
|
func (d *versionDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) {
|
|
resp.Schema = sqlserverflexalphaGen.VersionDataSourceSchema(ctx)
|
|
}
|
|
|
|
func (d *versionDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
|
|
var data sqlserverflexalphaGen.versionDataSourceModel
|
|
|
|
// Read Terraform configuration data into the model
|
|
resp.Diagnostics.Append(req.Config.Get(ctx, &data)...)
|
|
|
|
if resp.Diagnostics.HasError() {
|
|
return
|
|
}
|
|
|
|
// Todo: Read API call logic
|
|
|
|
// Example data value setting
|
|
data.Id = types.StringValue("example-id")
|
|
|
|
// Save data into Terraform state
|
|
resp.Diagnostics.Append(resp.State.Set(ctx, &data)...)
|
|
}
|