@@ -12,7 +12,6 @@ import (
12
12
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
13
13
"github.com/hashicorp/terraform-plugin-framework/diag"
14
14
tfpath "github.com/hashicorp/terraform-plugin-framework/path"
15
- "github.com/hashicorp/terraform-plugin-framework/provider"
16
15
"github.com/hashicorp/terraform-plugin-framework/types"
17
16
)
18
17
38
37
_ datasource.DataSource = & InventoryDataSource {}
39
38
_ datasource.DataSourceWithConfigure = & InventoryDataSource {}
40
39
_ datasource.DataSourceWithConfigValidators = & InventoryDataSource {}
40
+ _ datasource.DataSourceWithValidateConfig = & InventoryDataSource {}
41
41
)
42
42
43
43
// NewInventoryDataSource is a helper function to simplify the provider implementation.
@@ -105,9 +105,8 @@ func (d *InventoryDataSource) Read(ctx context.Context, req datasource.ReadReque
105
105
return
106
106
}
107
107
108
- URI := path .Join (d .client .getApiEndpoint (), "inventories" )
109
- resourceURL , err := ReturnAAPNamedURL (state .Id , state .Name , state .OrganizationName , URI )
110
- // resourceURL, err := state.ResourceUrlFromParameters(d)
108
+ uri := path .Join (d .client .getApiEndpoint (), "inventories" )
109
+ resourceURL , err := ReturnAAPNamedURL (state .Id , state .Name , state .OrganizationName , uri )
111
110
if err != nil {
112
111
resp .Diagnostics .AddError ("Minimal Data Not Supplied" , "Expected either [id] or [name + organization_name] pair" )
113
112
return
@@ -164,7 +163,7 @@ func (d *InventoryDataSource) ConfigValidators(_ context.Context) []datasource.C
164
163
}
165
164
}
166
165
167
- func (d * InventoryDataSource ) ValidateConfig (ctx context.Context , req provider .ValidateConfigRequest , resp * provider .ValidateConfigResponse ) {
166
+ func (d * InventoryDataSource ) ValidateConfig (ctx context.Context , req datasource .ValidateConfigRequest , resp * datasource .ValidateConfigResponse ) {
168
167
var data InventoryDataSourceModel
169
168
170
169
resp .Diagnostics .Append (req .Config .Get (ctx , & data )... )
@@ -181,30 +180,29 @@ func (d *InventoryDataSource) ValidateConfig(ctx context.Context, req provider.V
181
180
return
182
181
}
183
182
184
- if IsValueNotProvided (data .Id ) && IsValueNotProvided (data .Name ) {
183
+ if ! IsValueProvided (data .Id ) && ! IsValueProvided (data .Name ) {
185
184
resp .Diagnostics .AddAttributeWarning (
186
185
tfpath .Root ("id" ),
187
- "Missing Atribute Configuration" ,
186
+ "Missing Attribute Configuration" ,
188
187
"Expected either [id] or [name + organization_name] pair" ,
189
188
)
190
189
}
191
190
192
- if IsValueProvided (data .Name ) && IsValueNotProvided (data .OrganizationName ) {
191
+ if IsValueProvided (data .Name ) && ! IsValueProvided (data .OrganizationName ) {
193
192
resp .Diagnostics .AddAttributeWarning (
194
193
tfpath .Root ("organization_name" ),
195
194
"Missing Attribute Configuration" ,
196
195
"Expected organization_name to be configured with name." ,
197
196
)
198
197
}
199
198
200
- if IsValueNotProvided (data .Name ) && IsValueProvided (data .OrganizationName ) {
199
+ if ! IsValueProvided (data .Name ) && IsValueProvided (data .OrganizationName ) {
201
200
resp .Diagnostics .AddAttributeWarning (
202
201
tfpath .Root ("name" ),
203
202
"Missing Attribute Configuration" ,
204
203
"Expected name to be configured with organization_name." ,
205
204
)
206
205
}
207
-
208
206
}
209
207
210
208
func (dm * InventoryDataSourceModel ) ParseHttpResponse (body []byte ) diag.Diagnostics {
0 commit comments