@@ -15,35 +15,35 @@ import (
15
15
)
16
16
17
17
// Ensure provider defined types fully satisfy framework interfaces.
18
- var _ datasource.DataSource = & ProjectAPIKeysDataSource {}
18
+ var _ datasource.DataSource = & APIKeysDataSource {}
19
19
20
- func NewProjectAPIKeysDataSource () datasource.DataSource {
21
- return & ProjectAPIKeysDataSource {}
20
+ func NewAPIKeysDataSource () datasource.DataSource {
21
+ return & APIKeysDataSource {}
22
22
}
23
23
24
- // ProjectAPIKeysDataSource defines the data source implementation.
25
- type ProjectAPIKeysDataSource struct {
24
+ // APIKeysDataSource defines the data source implementation.
25
+ type APIKeysDataSource struct {
26
26
client * api.ClientWithResponses
27
27
}
28
28
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 "`
32
32
AnonKey types.String `tfsdk:"anon_key"`
33
33
ServiceRoleKey types.String `tfsdk:"service_role_key"`
34
34
}
35
35
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 "
38
38
}
39
39
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 ) {
41
41
resp .Schema = schema.Schema {
42
- MarkdownDescription : "Project API Keys data source" ,
42
+ MarkdownDescription : "API Keys data source" ,
43
43
44
44
Attributes : map [string ]schema.Attribute {
45
- "project_id " : schema.StringAttribute {
46
- MarkdownDescription : "Project identifier " ,
45
+ "project_ref " : schema.StringAttribute {
46
+ MarkdownDescription : "Project reference ID " ,
47
47
Required : true ,
48
48
},
49
49
"anon_key" : schema.StringAttribute {
@@ -60,7 +60,7 @@ func (d *ProjectAPIKeysDataSource) Schema(ctx context.Context, req datasource.Sc
60
60
}
61
61
}
62
62
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 ) {
64
64
// Prevent panic if the provider has not been configured.
65
65
if req .ProviderData == nil {
66
66
return
@@ -78,23 +78,23 @@ func (d *ProjectAPIKeysDataSource) Configure(ctx context.Context, req datasource
78
78
d .client = client
79
79
}
80
80
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
83
83
84
84
// Read Terraform configuration data into the model
85
85
resp .Diagnostics .Append (req .Config .Get (ctx , & data )... )
86
86
if resp .Diagnostics .HasError () {
87
87
return
88
88
}
89
89
90
- httpResp , err := d .client .V1GetProjectApiKeysWithResponse (ctx , data .ProjectId .ValueString (), & api.V1GetProjectApiKeysParams {})
90
+ httpResp , err := d .client .V1GetProjectApiKeysWithResponse (ctx , data .ProjectRef .ValueString (), & api.V1GetProjectApiKeysParams {})
91
91
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 ))
93
93
return
94
94
}
95
95
96
96
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 ))
98
98
return
99
99
}
100
100
@@ -107,7 +107,7 @@ func (d *ProjectAPIKeysDataSource) Read(ctx context.Context, req datasource.Read
107
107
}
108
108
}
109
109
110
- tflog .Trace (ctx , "read project API keys" )
110
+ tflog .Trace (ctx , "read API keys" )
111
111
112
112
// Save data into Terraform state
113
113
resp .Diagnostics .Append (resp .State .Set (ctx , & data )... )
0 commit comments