@@ -15,35 +15,35 @@ import (
1515)
1616
1717// Ensure provider defined types fully satisfy framework interfaces.
18- var _ datasource.DataSource = & ProjectAPIKeysDataSource {}
18+ var _ datasource.DataSource = & APIKeysDataSource {}
1919
20- func NewProjectAPIKeysDataSource () datasource.DataSource {
21- return & ProjectAPIKeysDataSource {}
20+ func NewAPIKeysDataSource () datasource.DataSource {
21+ return & APIKeysDataSource {}
2222}
2323
24- // ProjectAPIKeysDataSource defines the data source implementation.
25- type ProjectAPIKeysDataSource struct {
24+ // APIKeysDataSource defines the data source implementation.
25+ type APIKeysDataSource struct {
2626 client * api.ClientWithResponses
2727}
2828
29- // ProjectAPIKeysDataSourceModel describes the data source data model.
30- type ProjectAPIKeysDataSourceModel struct {
31- ProjectId types.String `tfsdk:"project_id "`
29+ // APIKeysDataSourceModel describes the data source data model.
30+ type APIKeysDataSourceModel struct {
31+ ProjectRef types.String `tfsdk:"project_ref "`
3232 AnonKey types.String `tfsdk:"anon_key"`
3333 ServiceRoleKey types.String `tfsdk:"service_role_key"`
3434}
3535
36- func (d * ProjectAPIKeysDataSource ) Metadata (ctx context.Context , req datasource.MetadataRequest , resp * datasource.MetadataResponse ) {
37- resp .TypeName = req .ProviderTypeName + "_project_apikeys "
36+ func (d * APIKeysDataSource ) Metadata (ctx context.Context , req datasource.MetadataRequest , resp * datasource.MetadataResponse ) {
37+ resp .TypeName = req .ProviderTypeName + "_apikeys "
3838}
3939
40- func (d * ProjectAPIKeysDataSource ) Schema (ctx context.Context , req datasource.SchemaRequest , resp * datasource.SchemaResponse ) {
40+ func (d * APIKeysDataSource ) Schema (ctx context.Context , req datasource.SchemaRequest , resp * datasource.SchemaResponse ) {
4141 resp .Schema = schema.Schema {
42- MarkdownDescription : "Project API Keys data source" ,
42+ MarkdownDescription : "API Keys data source" ,
4343
4444 Attributes : map [string ]schema.Attribute {
45- "project_id " : schema.StringAttribute {
46- MarkdownDescription : "Project identifier " ,
45+ "project_ref " : schema.StringAttribute {
46+ MarkdownDescription : "Project reference ID " ,
4747 Required : true ,
4848 },
4949 "anon_key" : schema.StringAttribute {
@@ -60,7 +60,7 @@ func (d *ProjectAPIKeysDataSource) Schema(ctx context.Context, req datasource.Sc
6060 }
6161}
6262
63- func (d * ProjectAPIKeysDataSource ) Configure (ctx context.Context , req datasource.ConfigureRequest , resp * datasource.ConfigureResponse ) {
63+ func (d * APIKeysDataSource ) Configure (ctx context.Context , req datasource.ConfigureRequest , resp * datasource.ConfigureResponse ) {
6464 // Prevent panic if the provider has not been configured.
6565 if req .ProviderData == nil {
6666 return
@@ -78,23 +78,23 @@ func (d *ProjectAPIKeysDataSource) Configure(ctx context.Context, req datasource
7878 d .client = client
7979}
8080
81- func (d * ProjectAPIKeysDataSource ) Read (ctx context.Context , req datasource.ReadRequest , resp * datasource.ReadResponse ) {
82- var data ProjectAPIKeysDataSourceModel
81+ func (d * APIKeysDataSource ) Read (ctx context.Context , req datasource.ReadRequest , resp * datasource.ReadResponse ) {
82+ var data APIKeysDataSourceModel
8383
8484 // Read Terraform configuration data into the model
8585 resp .Diagnostics .Append (req .Config .Get (ctx , & data )... )
8686 if resp .Diagnostics .HasError () {
8787 return
8888 }
8989
90- httpResp , err := d .client .V1GetProjectApiKeysWithResponse (ctx , data .ProjectId .ValueString (), & api.V1GetProjectApiKeysParams {})
90+ httpResp , err := d .client .V1GetProjectApiKeysWithResponse (ctx , data .ProjectRef .ValueString (), & api.V1GetProjectApiKeysParams {})
9191 if err != nil {
92- resp .Diagnostics .AddError ("Client Error" , fmt .Sprintf ("Unable to read project API keys, got error: %s" , err ))
92+ resp .Diagnostics .AddError ("Client Error" , fmt .Sprintf ("Unable to read API keys, got error: %s" , err ))
9393 return
9494 }
9595
9696 if httpResp .JSON200 == nil {
97- resp .Diagnostics .AddError ("Client Error" , fmt .Sprintf ("Unable to read project API keys, got status %d: %s" , httpResp .StatusCode (), httpResp .Body ))
97+ resp .Diagnostics .AddError ("Client Error" , fmt .Sprintf ("Unable to read API keys, got status %d: %s" , httpResp .StatusCode (), httpResp .Body ))
9898 return
9999 }
100100
@@ -107,7 +107,7 @@ func (d *ProjectAPIKeysDataSource) Read(ctx context.Context, req datasource.Read
107107 }
108108 }
109109
110- tflog .Trace (ctx , "read project API keys" )
110+ tflog .Trace (ctx , "read API keys" )
111111
112112 // Save data into Terraform state
113113 resp .Diagnostics .Append (resp .State .Set (ctx , & data )... )
0 commit comments