in internal/services/azapi_resource_id_data_source.go [114:139]
func (r *ResourceIdDataSource) ValidateConfig(ctx context.Context, request datasource.ValidateConfigRequest, response *datasource.ValidateConfigResponse) {
var config *ResourceIdDataSourceModel
if response.Diagnostics.Append(request.Config.Get(ctx, &config)...); response.Diagnostics.HasError() {
return
}
if config == nil {
return
}
if config.Name.IsNull() && !config.ParentID.IsNull() {
response.Diagnostics.AddError("Invalid configuration", `The argument "name" is required when the argument "parent_id" is set`)
}
if !config.Name.IsNull() && config.ParentID.IsNull() {
response.Diagnostics.AddError("Invalid configuration", `The argument "parent_id" is required when the argument "name" is set`)
}
if config.Name.IsNull() && config.ResourceID.IsNull() {
response.Diagnostics.AddError("Invalid configuration", `One of the arguments "name" or "resource_id" must be set`)
}
if !config.Name.IsNull() && !config.ResourceID.IsNull() {
response.Diagnostics.AddError("Invalid configuration", `Only one of the arguments "name" or "resource_id" can be set`)
}
if response.Diagnostics.HasError() {
return
}
}