@@ -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.
@@ -96,6 +96,7 @@ func (d *InventoryDataSource) Schema(_ context.Context, _ datasource.SchemaReque
96
96
97
97
// Read refreshes the Terraform state with the latest data.
98
98
func (d * InventoryDataSource ) Read (ctx context.Context , req datasource.ReadRequest , resp * datasource.ReadResponse ) {
99
+
99
100
var state InventoryDataSourceModel
100
101
var diags diag.Diagnostics
101
102
@@ -107,7 +108,6 @@ func (d *InventoryDataSource) Read(ctx context.Context, req datasource.ReadReque
107
108
108
109
URI := path .Join (d .client .getApiEndpoint (), "inventories" )
109
110
resourceURL , err := ReturnAAPNamedURL (state .Id , state .Name , state .OrganizationName , URI )
110
- // resourceURL, err := state.ResourceUrlFromParameters(d)
111
111
if err != nil {
112
112
resp .Diagnostics .AddError ("Minimal Data Not Supplied" , "Expected either [id] or [name + organization_name] pair" )
113
113
return
@@ -164,7 +164,7 @@ func (d *InventoryDataSource) ConfigValidators(_ context.Context) []datasource.C
164
164
}
165
165
}
166
166
167
- func (d * InventoryDataSource ) ValidateConfig (ctx context.Context , req provider .ValidateConfigRequest , resp * provider .ValidateConfigResponse ) {
167
+ func (d * InventoryDataSource ) ValidateConfig (ctx context.Context , req datasource .ValidateConfigRequest , resp * datasource .ValidateConfigResponse ) {
168
168
var data InventoryDataSourceModel
169
169
170
170
resp .Diagnostics .Append (req .Config .Get (ctx , & data )... )
@@ -181,23 +181,23 @@ func (d *InventoryDataSource) ValidateConfig(ctx context.Context, req provider.V
181
181
return
182
182
}
183
183
184
- if IsValueNotProvided (data .Id ) && IsValueNotProvided (data .Name ) {
184
+ if ! IsValueProvided (data .Id ) && ! IsValueProvided (data .Name ) {
185
185
resp .Diagnostics .AddAttributeWarning (
186
186
tfpath .Root ("id" ),
187
187
"Missing Atribute Configuration" ,
188
188
"Expected either [id] or [name + organization_name] pair" ,
189
189
)
190
190
}
191
191
192
- if IsValueProvided (data .Name ) && IsValueNotProvided (data .OrganizationName ) {
192
+ if IsValueProvided (data .Name ) && ! IsValueProvided (data .OrganizationName ) {
193
193
resp .Diagnostics .AddAttributeWarning (
194
194
tfpath .Root ("organization_name" ),
195
195
"Missing Attribute Configuration" ,
196
196
"Expected organization_name to be configured with name." ,
197
197
)
198
198
}
199
199
200
- if IsValueNotProvided (data .Name ) && IsValueProvided (data .OrganizationName ) {
200
+ if ! IsValueProvided (data .Name ) && IsValueProvided (data .OrganizationName ) {
201
201
resp .Diagnostics .AddAttributeWarning (
202
202
tfpath .Root ("name" ),
203
203
"Missing Attribute Configuration" ,
0 commit comments