diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index 22f8459..e4cdb9b 100755 --- a/.speakeasy/gen.lock +++ b/.speakeasy/gen.lock @@ -4,16 +4,16 @@ management: docChecksum: 34d22936f2456c2c461abdfc773e3fc4 docVersion: 0.0.3 speakeasyVersion: internal - generationVersion: 2.228.1 - releaseVersion: 0.2.0 - configChecksum: aa46c3314b27098c848b44960a4abd53 + generationVersion: 2.230.1 + releaseVersion: 0.2.1 + configChecksum: c37646e1dc61322a4f6640ddd3e168c0 repoURL: https://github.com/LukeHagar/plexterraform.git repoSubDirectory: . published: true features: terraform: constsAndDefaults: 0.1.2 - core: 3.8.0 + core: 3.8.1 globalSecurity: 2.81.2 globalServerURLs: 2.82.1 nameOverrides: 2.81.1 @@ -80,6 +80,15 @@ generatedFiles: - internal/validators/ExactlyOneChild.go - internal/validators/JSONParseValidator.go - internal/validators/RFC3339Validator.go + - internal/validators/boolvalidators/not_null.go + - internal/validators/float64validators/not_null.go + - internal/validators/int64validators/not_null.go + - internal/validators/listvalidators/not_null.go + - internal/validators/mapvalidators/not_null.go + - internal/validators/numbervalidators/not_null.go + - internal/validators/objectvalidators/not_null.go + - internal/validators/setvalidators/not_null.go + - internal/validators/stringvalidators/not_null.go - main.go - terraform-registry-manifest.json - tools/tools.go diff --git a/README.md b/README.md index e7c52bc..0030c58 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ terraform { required_providers { PlexAPI = { source = "LukeHagar/PlexAPI" - version = "0.2.0" + version = "0.2.1" } } } diff --git a/RELEASES.md b/RELEASES.md index 9fdc847..8f5f649 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -22,4 +22,12 @@ Based on: - OpenAPI Doc 0.0.3 - Speakeasy CLI 1.133.1 (2.228.1) https://github.com/speakeasy-api/speakeasy ### Generated -- [terraform v0.2.0] . \ No newline at end of file +- [terraform v0.2.0] . + +## 2024-01-09 01:09:28 +### Changes +Based on: +- OpenAPI Doc 0.0.3 +- Speakeasy CLI 1.134.0 (2.230.1) https://github.com/speakeasy-api/speakeasy +### Generated +- [terraform v0.2.1] . \ No newline at end of file diff --git a/docs/index.md b/docs/index.md index ff53fa0..6b3c0da 100644 --- a/docs/index.md +++ b/docs/index.md @@ -17,7 +17,7 @@ terraform { required_providers { PlexAPI = { source = "LukeHagar/PlexAPI" - version = "0.2.0" + version = "0.2.1" } } } diff --git a/examples/provider/provider.tf b/examples/provider/provider.tf index ee90fc9..b2addb5 100644 --- a/examples/provider/provider.tf +++ b/examples/provider/provider.tf @@ -2,7 +2,7 @@ terraform { required_providers { PlexAPI = { source = "LukeHagar/PlexAPI" - version = "0.2.0" + version = "0.2.1" } } } diff --git a/gen.yaml b/gen.yaml index 8f7d0d7..5776af9 100644 --- a/gen.yaml +++ b/gen.yaml @@ -8,7 +8,7 @@ generation: fixes: nameResolutionDec2023: false terraform: - version: 0.2.0 + version: 0.2.1 author: LukeHagar imports: option: openapi diff --git a/internal/planmodifiers/boolplanmodifier/suppress_diff.go b/internal/planmodifiers/boolplanmodifier/suppress_diff.go index f6929f0..11ba192 100644 --- a/internal/planmodifiers/boolplanmodifier/suppress_diff.go +++ b/internal/planmodifiers/boolplanmodifier/suppress_diff.go @@ -10,8 +10,6 @@ import ( ) const ( - // Standard suppresses "(known after changes)" messages unless there's an explicit change in state [excluding null <=> unknown transitions] - Standard = iota // ExplicitSuppress strategy suppresses "(known after changes)" messages unless we're in the initial creation ExplicitSuppress = iota ) @@ -53,9 +51,6 @@ func (m suppressDiff) PlanModifyBool(ctx context.Context, req planmodifier.BoolR if utils.IsAllStateUnknown(ctx, req.State) { return } - if m.strategy == Standard && utils.IsAnyKnownChange(ctx, req.Plan, req.State) { - return - } resp.PlanValue = req.StateValue } diff --git a/internal/planmodifiers/float64planmodifier/suppress_diff.go b/internal/planmodifiers/float64planmodifier/suppress_diff.go index d5c1d60..aa19393 100644 --- a/internal/planmodifiers/float64planmodifier/suppress_diff.go +++ b/internal/planmodifiers/float64planmodifier/suppress_diff.go @@ -10,8 +10,6 @@ import ( ) const ( - // Standard suppresses "(known after changes)" messages unless there's an explicit change in state [excluding null <=> unknown transitions] - Standard = iota // ExplicitSuppress strategy suppresses "(known after changes)" messages unless we're in the initial creation ExplicitSuppress = iota ) @@ -53,9 +51,6 @@ func (m suppressDiff) PlanModifyFloat64(ctx context.Context, req planmodifier.Fl if utils.IsAllStateUnknown(ctx, req.State) { return } - if m.strategy == Standard && utils.IsAnyKnownChange(ctx, req.Plan, req.State) { - return - } resp.PlanValue = req.StateValue } diff --git a/internal/planmodifiers/int64planmodifier/suppress_diff.go b/internal/planmodifiers/int64planmodifier/suppress_diff.go index f3c09ad..9415e13 100644 --- a/internal/planmodifiers/int64planmodifier/suppress_diff.go +++ b/internal/planmodifiers/int64planmodifier/suppress_diff.go @@ -10,8 +10,6 @@ import ( ) const ( - // Standard suppresses "(known after changes)" messages unless there's an explicit change in state [excluding null <=> unknown transitions] - Standard = iota // ExplicitSuppress strategy suppresses "(known after changes)" messages unless we're in the initial creation ExplicitSuppress = iota ) @@ -53,9 +51,6 @@ func (m suppressDiff) PlanModifyInt64(ctx context.Context, req planmodifier.Int6 if utils.IsAllStateUnknown(ctx, req.State) { return } - if m.strategy == Standard && utils.IsAnyKnownChange(ctx, req.Plan, req.State) { - return - } resp.PlanValue = req.StateValue } diff --git a/internal/planmodifiers/listplanmodifier/suppress_diff.go b/internal/planmodifiers/listplanmodifier/suppress_diff.go index f6a93d2..9ccca88 100644 --- a/internal/planmodifiers/listplanmodifier/suppress_diff.go +++ b/internal/planmodifiers/listplanmodifier/suppress_diff.go @@ -10,8 +10,6 @@ import ( ) const ( - // Standard suppresses "(known after changes)" messages unless there's an explicit change in state [excluding null <=> unknown transitions] - Standard = iota // ExplicitSuppress strategy suppresses "(known after changes)" messages unless we're in the initial creation ExplicitSuppress = iota ) @@ -53,9 +51,6 @@ func (m suppressDiff) PlanModifyList(ctx context.Context, req planmodifier.ListR if utils.IsAllStateUnknown(ctx, req.State) { return } - if m.strategy == Standard && utils.IsAnyKnownChange(ctx, req.Plan, req.State) { - return - } resp.PlanValue = req.StateValue } diff --git a/internal/planmodifiers/mapplanmodifier/suppress_diff.go b/internal/planmodifiers/mapplanmodifier/suppress_diff.go index 669ab05..dd7b430 100644 --- a/internal/planmodifiers/mapplanmodifier/suppress_diff.go +++ b/internal/planmodifiers/mapplanmodifier/suppress_diff.go @@ -10,8 +10,6 @@ import ( ) const ( - // Standard suppresses "(known after changes)" messages unless there's an explicit change in state [excluding null <=> unknown transitions] - Standard = iota // ExplicitSuppress strategy suppresses "(known after changes)" messages unless we're in the initial creation ExplicitSuppress = iota ) @@ -53,9 +51,6 @@ func (m suppressDiff) PlanModifyMap(ctx context.Context, req planmodifier.MapReq if utils.IsAllStateUnknown(ctx, req.State) { return } - if m.strategy == Standard && utils.IsAnyKnownChange(ctx, req.Plan, req.State) { - return - } resp.PlanValue = req.StateValue } diff --git a/internal/planmodifiers/numberplanmodifier/suppress_diff.go b/internal/planmodifiers/numberplanmodifier/suppress_diff.go index efd6cbb..f981d3b 100644 --- a/internal/planmodifiers/numberplanmodifier/suppress_diff.go +++ b/internal/planmodifiers/numberplanmodifier/suppress_diff.go @@ -10,8 +10,6 @@ import ( ) const ( - // Standard suppresses "(known after changes)" messages unless there's an explicit change in state [excluding null <=> unknown transitions] - Standard = iota // ExplicitSuppress strategy suppresses "(known after changes)" messages unless we're in the initial creation ExplicitSuppress = iota ) @@ -53,9 +51,6 @@ func (m suppressDiff) PlanModifyNumber(ctx context.Context, req planmodifier.Num if utils.IsAllStateUnknown(ctx, req.State) { return } - if m.strategy == Standard && utils.IsAnyKnownChange(ctx, req.Plan, req.State) { - return - } resp.PlanValue = req.StateValue } diff --git a/internal/planmodifiers/objectplanmodifier/suppress_diff.go b/internal/planmodifiers/objectplanmodifier/suppress_diff.go index 51c4a34..580d443 100644 --- a/internal/planmodifiers/objectplanmodifier/suppress_diff.go +++ b/internal/planmodifiers/objectplanmodifier/suppress_diff.go @@ -10,8 +10,6 @@ import ( ) const ( - // Standard suppresses "(known after changes)" messages unless there's an explicit change in state [excluding null <=> unknown transitions] - Standard = iota // ExplicitSuppress strategy suppresses "(known after changes)" messages unless we're in the initial creation ExplicitSuppress = iota ) @@ -53,9 +51,6 @@ func (m suppressDiff) PlanModifyObject(ctx context.Context, req planmodifier.Obj if utils.IsAllStateUnknown(ctx, req.State) { return } - if m.strategy == Standard && utils.IsAnyKnownChange(ctx, req.Plan, req.State) { - return - } resp.PlanValue = req.StateValue } diff --git a/internal/planmodifiers/setplanmodifier/suppress_diff.go b/internal/planmodifiers/setplanmodifier/suppress_diff.go index 8591d33..8add9b1 100644 --- a/internal/planmodifiers/setplanmodifier/suppress_diff.go +++ b/internal/planmodifiers/setplanmodifier/suppress_diff.go @@ -10,8 +10,6 @@ import ( ) const ( - // Standard suppresses "(known after changes)" messages unless there's an explicit change in state [excluding null <=> unknown transitions] - Standard = iota // ExplicitSuppress strategy suppresses "(known after changes)" messages unless we're in the initial creation ExplicitSuppress = iota ) @@ -53,9 +51,6 @@ func (m suppressDiff) PlanModifySet(ctx context.Context, req planmodifier.SetReq if utils.IsAllStateUnknown(ctx, req.State) { return } - if m.strategy == Standard && utils.IsAnyKnownChange(ctx, req.Plan, req.State) { - return - } resp.PlanValue = req.StateValue } diff --git a/internal/planmodifiers/stringplanmodifier/suppress_diff.go b/internal/planmodifiers/stringplanmodifier/suppress_diff.go index 6835ad0..4d57743 100644 --- a/internal/planmodifiers/stringplanmodifier/suppress_diff.go +++ b/internal/planmodifiers/stringplanmodifier/suppress_diff.go @@ -10,8 +10,6 @@ import ( ) const ( - // Standard suppresses "(known after changes)" messages unless there's an explicit change in state [excluding null <=> unknown transitions] - Standard = iota // ExplicitSuppress strategy suppresses "(known after changes)" messages unless we're in the initial creation ExplicitSuppress = iota ) @@ -53,9 +51,6 @@ func (m suppressDiff) PlanModifyString(ctx context.Context, req planmodifier.Str if utils.IsAllStateUnknown(ctx, req.State) { return } - if m.strategy == Standard && utils.IsAnyKnownChange(ctx, req.Plan, req.State) { - return - } resp.PlanValue = req.StateValue } diff --git a/internal/planmodifiers/utils/state_check.go b/internal/planmodifiers/utils/state_check.go index 9b087eb..66d9150 100644 --- a/internal/planmodifiers/utils/state_check.go +++ b/internal/planmodifiers/utils/state_check.go @@ -23,91 +23,3 @@ func IsAllStateUnknown(ctx context.Context, state tfsdk.State) bool { return !anyFound } - -func IsAnyKnownChange(ctx context.Context, plan tfsdk.Plan, state tfsdk.State) bool { - attrs := state.Schema.GetAttributes() - anyFound := false - for k, _ := range attrs { - stateValue := new(attr.Value) - planValue := new(attr.Value) - state.GetAttribute(ctx, path.Root(k), stateValue) - plan.GetAttribute(ctx, path.Root(k), planValue) - anyFound = !isKnownEqual(ctx, stateValue, planValue) - if anyFound { - break - } - } - - return anyFound -} - -type HasElements interface { - Elements() []attr.Value - IsUnknown() bool - IsNull() bool -} -type HasAttributes interface { - Attributes() map[string]attr.Value - IsUnknown() bool - IsNull() bool -} - -func isKnownEqual(ctx context.Context, a *attr.Value, b *attr.Value) bool { - if (*a).IsUnknown() || (*b).IsUnknown() { - return true - } - aType := (*a).Type(ctx) - bType := (*b).Type(ctx) - if !aType.Equal(bType) { - return false - } - attributeTypes, ok := aType.(attr.TypeWithAttributeTypes) - if ok { - check := true - for k, _ := range attributeTypes.AttributeTypes() { - objValA, isObjA := (*a).(HasAttributes) - objValB, isObjB := (*b).(HasAttributes) - if isObjA && isObjB { - if objValA.IsUnknown() || objValB.IsUnknown() { - continue - } - attrA, foundA := objValA.Attributes()[k] - attrB, foundB := objValB.Attributes()[k] - if foundA != foundB { - return false - } - if foundA { - check = isKnownEqual(ctx, &attrA, &attrB) - } - } - if !check { - break - } - } - return check - } - _, ok = aType.(attr.TypeWithElementType) - if ok { - aVal, aValList := (*a).(HasElements) - bVal, bValList := (*b).(HasElements) - if aValList && bValList { - if ((aVal).IsUnknown() || (aVal).IsNull()) && ((bVal).IsUnknown() || (bVal).IsNull()) { - return true - } - if len(aVal.Elements()) != len(bVal.Elements()) { - return false - } else { - for i, _ := range aVal.Elements() { - if !isKnownEqual(ctx, &aVal.Elements()[i], &bVal.Elements()[i]) { - return false - } - } - } - return true - } - return false - } - - isEqual := (*a).Equal(*b) - return isEqual -} diff --git a/internal/sdk/sdk.go b/internal/sdk/sdk.go index c0a8a20..7257f82 100644 --- a/internal/sdk/sdk.go +++ b/internal/sdk/sdk.go @@ -259,9 +259,9 @@ func New(opts ...SDKOption) *PlexAPI { sdkConfiguration: sdkConfiguration{ Language: "go", OpenAPIDocVersion: "0.0.3", - SDKVersion: "0.2.0", - GenVersion: "2.228.1", - UserAgent: "speakeasy-sdk/go 0.2.0 2.228.1 0.0.3 PlexAPI", + SDKVersion: "0.2.1", + GenVersion: "2.230.1", + UserAgent: "speakeasy-sdk/go 0.2.1 2.230.1 0.0.3 PlexAPI", ServerDefaults: []map[string]string{ { "protocol": "http", diff --git a/internal/validators/boolvalidators/not_null.go b/internal/validators/boolvalidators/not_null.go new file mode 100644 index 0000000..45e2e97 --- /dev/null +++ b/internal/validators/boolvalidators/not_null.go @@ -0,0 +1,49 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package boolvalidators + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-framework/schema/validator" +) + +var _ validator.Bool = BoolNotNullValidator{} + +// BoolNotNullValidator validates that an attribute is not null. Most +// attributes should set Required: true instead, however in certain scenarios, +// such as a computed nested attribute, all underlying attributes must also be +// computed for planning to not show unexpected differences. +type BoolNotNullValidator struct{} + +// Description describes the validation in plain text formatting. +func (v BoolNotNullValidator) Description(_ context.Context) string { + return "value must be configured" +} + +// MarkdownDescription describes the validation in Markdown formatting. +func (v BoolNotNullValidator) MarkdownDescription(ctx context.Context) string { + return v.Description(ctx) +} + +// Validate performs the validation. +func (v BoolNotNullValidator) ValidateBool(ctx context.Context, req validator.BoolRequest, resp *validator.BoolResponse) { + if !req.ConfigValue.IsNull() { + return + } + + resp.Diagnostics.AddAttributeError( + req.Path, + "Missing Attribute Value", + req.Path.String()+": "+v.Description(ctx), + ) +} + +// NotNull returns an validator which ensures that the attribute is +// configured. Most attributes should set Required: true instead, however in +// certain scenarios, such as a computed nested attribute, all underlying +// attributes must also be computed for planning to not show unexpected +// differences. +func NotNull() validator.Bool { + return BoolNotNullValidator{} +} diff --git a/internal/validators/float64validators/not_null.go b/internal/validators/float64validators/not_null.go new file mode 100644 index 0000000..75099c2 --- /dev/null +++ b/internal/validators/float64validators/not_null.go @@ -0,0 +1,49 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package float64validators + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-framework/schema/validator" +) + +var _ validator.Float64 = Float64NotNullValidator{} + +// Float64NotNullValidator validates that an attribute is not null. Most +// attributes should set Required: true instead, however in certain scenarios, +// such as a computed nested attribute, all underlying attributes must also be +// computed for planning to not show unexpected differences. +type Float64NotNullValidator struct{} + +// Description describes the validation in plain text formatting. +func (v Float64NotNullValidator) Description(_ context.Context) string { + return "value must be configured" +} + +// MarkdownDescription describes the validation in Markdown formatting. +func (v Float64NotNullValidator) MarkdownDescription(ctx context.Context) string { + return v.Description(ctx) +} + +// Validate performs the validation. +func (v Float64NotNullValidator) ValidateFloat64(ctx context.Context, req validator.Float64Request, resp *validator.Float64Response) { + if !req.ConfigValue.IsNull() { + return + } + + resp.Diagnostics.AddAttributeError( + req.Path, + "Missing Attribute Value", + req.Path.String()+": "+v.Description(ctx), + ) +} + +// NotNull returns an validator which ensures that the attribute is +// configured. Most attributes should set Required: true instead, however in +// certain scenarios, such as a computed nested attribute, all underlying +// attributes must also be computed for planning to not show unexpected +// differences. +func NotNull() validator.Float64 { + return Float64NotNullValidator{} +} diff --git a/internal/validators/int64validators/not_null.go b/internal/validators/int64validators/not_null.go new file mode 100644 index 0000000..32192d8 --- /dev/null +++ b/internal/validators/int64validators/not_null.go @@ -0,0 +1,49 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package int64validators + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-framework/schema/validator" +) + +var _ validator.Int64 = Int64NotNullValidator{} + +// Int64NotNullValidator validates that an attribute is not null. Most +// attributes should set Required: true instead, however in certain scenarios, +// such as a computed nested attribute, all underlying attributes must also be +// computed for planning to not show unexpected differences. +type Int64NotNullValidator struct{} + +// Description describes the validation in plain text formatting. +func (v Int64NotNullValidator) Description(_ context.Context) string { + return "value must be configured" +} + +// MarkdownDescription describes the validation in Markdown formatting. +func (v Int64NotNullValidator) MarkdownDescription(ctx context.Context) string { + return v.Description(ctx) +} + +// Validate performs the validation. +func (v Int64NotNullValidator) ValidateInt64(ctx context.Context, req validator.Int64Request, resp *validator.Int64Response) { + if !req.ConfigValue.IsNull() { + return + } + + resp.Diagnostics.AddAttributeError( + req.Path, + "Missing Attribute Value", + req.Path.String()+": "+v.Description(ctx), + ) +} + +// NotNull returns an validator which ensures that the attribute is +// configured. Most attributes should set Required: true instead, however in +// certain scenarios, such as a computed nested attribute, all underlying +// attributes must also be computed for planning to not show unexpected +// differences. +func NotNull() validator.Int64 { + return Int64NotNullValidator{} +} diff --git a/internal/validators/listvalidators/not_null.go b/internal/validators/listvalidators/not_null.go new file mode 100644 index 0000000..c7bfa6e --- /dev/null +++ b/internal/validators/listvalidators/not_null.go @@ -0,0 +1,49 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package listvalidators + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-framework/schema/validator" +) + +var _ validator.List = ListNotNullValidator{} + +// ListNotNullValidator validates that an attribute is not null. Most +// attributes should set Required: true instead, however in certain scenarios, +// such as a computed nested attribute, all underlying attributes must also be +// computed for planning to not show unexpected differences. +type ListNotNullValidator struct{} + +// Description describes the validation in plain text formatting. +func (v ListNotNullValidator) Description(_ context.Context) string { + return "value must be configured" +} + +// MarkdownDescription describes the validation in Markdown formatting. +func (v ListNotNullValidator) MarkdownDescription(ctx context.Context) string { + return v.Description(ctx) +} + +// Validate performs the validation. +func (v ListNotNullValidator) ValidateList(ctx context.Context, req validator.ListRequest, resp *validator.ListResponse) { + if !req.ConfigValue.IsNull() { + return + } + + resp.Diagnostics.AddAttributeError( + req.Path, + "Missing Attribute Value", + req.Path.String()+": "+v.Description(ctx), + ) +} + +// NotNull returns an validator which ensures that the attribute is +// configured. Most attributes should set Required: true instead, however in +// certain scenarios, such as a computed nested attribute, all underlying +// attributes must also be computed for planning to not show unexpected +// differences. +func NotNull() validator.List { + return ListNotNullValidator{} +} diff --git a/internal/validators/mapvalidators/not_null.go b/internal/validators/mapvalidators/not_null.go new file mode 100644 index 0000000..7d22172 --- /dev/null +++ b/internal/validators/mapvalidators/not_null.go @@ -0,0 +1,49 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package mapvalidators + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-framework/schema/validator" +) + +var _ validator.Map = MapNotNullValidator{} + +// MapNotNullValidator validates that an attribute is not null. Most +// attributes should set Required: true instead, however in certain scenarios, +// such as a computed nested attribute, all underlying attributes must also be +// computed for planning to not show unexpected differences. +type MapNotNullValidator struct{} + +// Description describes the validation in plain text formatting. +func (v MapNotNullValidator) Description(_ context.Context) string { + return "value must be configured" +} + +// MarkdownDescription describes the validation in Markdown formatting. +func (v MapNotNullValidator) MarkdownDescription(ctx context.Context) string { + return v.Description(ctx) +} + +// Validate performs the validation. +func (v MapNotNullValidator) ValidateMap(ctx context.Context, req validator.MapRequest, resp *validator.MapResponse) { + if !req.ConfigValue.IsNull() { + return + } + + resp.Diagnostics.AddAttributeError( + req.Path, + "Missing Attribute Value", + req.Path.String()+": "+v.Description(ctx), + ) +} + +// NotNull returns an validator which ensures that the attribute is +// configured. Most attributes should set Required: true instead, however in +// certain scenarios, such as a computed nested attribute, all underlying +// attributes must also be computed for planning to not show unexpected +// differences. +func NotNull() validator.Map { + return MapNotNullValidator{} +} diff --git a/internal/validators/numbervalidators/not_null.go b/internal/validators/numbervalidators/not_null.go new file mode 100644 index 0000000..b085170 --- /dev/null +++ b/internal/validators/numbervalidators/not_null.go @@ -0,0 +1,49 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package numbervalidators + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-framework/schema/validator" +) + +var _ validator.Number = NumberNotNullValidator{} + +// NumberNotNullValidator validates that an attribute is not null. Most +// attributes should set Required: true instead, however in certain scenarios, +// such as a computed nested attribute, all underlying attributes must also be +// computed for planning to not show unexpected differences. +type NumberNotNullValidator struct{} + +// Description describes the validation in plain text formatting. +func (v NumberNotNullValidator) Description(_ context.Context) string { + return "value must be configured" +} + +// MarkdownDescription describes the validation in Markdown formatting. +func (v NumberNotNullValidator) MarkdownDescription(ctx context.Context) string { + return v.Description(ctx) +} + +// Validate performs the validation. +func (v NumberNotNullValidator) ValidateNumber(ctx context.Context, req validator.NumberRequest, resp *validator.NumberResponse) { + if !req.ConfigValue.IsNull() { + return + } + + resp.Diagnostics.AddAttributeError( + req.Path, + "Missing Attribute Value", + req.Path.String()+": "+v.Description(ctx), + ) +} + +// NotNull returns an validator which ensures that the attribute is +// configured. Most attributes should set Required: true instead, however in +// certain scenarios, such as a computed nested attribute, all underlying +// attributes must also be computed for planning to not show unexpected +// differences. +func NotNull() validator.Number { + return NumberNotNullValidator{} +} diff --git a/internal/validators/objectvalidators/not_null.go b/internal/validators/objectvalidators/not_null.go new file mode 100644 index 0000000..c45ca8d --- /dev/null +++ b/internal/validators/objectvalidators/not_null.go @@ -0,0 +1,49 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package objectvalidators + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-framework/schema/validator" +) + +var _ validator.Object = ObjectNotNullValidator{} + +// ObjectNotNullValidator validates that an attribute is not null. Most +// attributes should set Required: true instead, however in certain scenarios, +// such as a computed nested attribute, all underlying attributes must also be +// computed for planning to not show unexpected differences. +type ObjectNotNullValidator struct{} + +// Description describes the validation in plain text formatting. +func (v ObjectNotNullValidator) Description(_ context.Context) string { + return "value must be configured" +} + +// MarkdownDescription describes the validation in Markdown formatting. +func (v ObjectNotNullValidator) MarkdownDescription(ctx context.Context) string { + return v.Description(ctx) +} + +// Validate performs the validation. +func (v ObjectNotNullValidator) ValidateObject(ctx context.Context, req validator.ObjectRequest, resp *validator.ObjectResponse) { + if !req.ConfigValue.IsNull() { + return + } + + resp.Diagnostics.AddAttributeError( + req.Path, + "Missing Attribute Value", + req.Path.String()+": "+v.Description(ctx), + ) +} + +// NotNull returns an validator which ensures that the attribute is +// configured. Most attributes should set Required: true instead, however in +// certain scenarios, such as a computed nested attribute, all underlying +// attributes must also be computed for planning to not show unexpected +// differences. +func NotNull() validator.Object { + return ObjectNotNullValidator{} +} diff --git a/internal/validators/setvalidators/not_null.go b/internal/validators/setvalidators/not_null.go new file mode 100644 index 0000000..23d6c16 --- /dev/null +++ b/internal/validators/setvalidators/not_null.go @@ -0,0 +1,49 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package setvalidators + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-framework/schema/validator" +) + +var _ validator.Set = SetNotNullValidator{} + +// SetNotNullValidator validates that an attribute is not null. Most +// attributes should set Required: true instead, however in certain scenarios, +// such as a computed nested attribute, all underlying attributes must also be +// computed for planning to not show unexpected differences. +type SetNotNullValidator struct{} + +// Description describes the validation in plain text formatting. +func (v SetNotNullValidator) Description(_ context.Context) string { + return "value must be configured" +} + +// MarkdownDescription describes the validation in Markdown formatting. +func (v SetNotNullValidator) MarkdownDescription(ctx context.Context) string { + return v.Description(ctx) +} + +// Validate performs the validation. +func (v SetNotNullValidator) ValidateSet(ctx context.Context, req validator.SetRequest, resp *validator.SetResponse) { + if !req.ConfigValue.IsNull() { + return + } + + resp.Diagnostics.AddAttributeError( + req.Path, + "Missing Attribute Value", + req.Path.String()+": "+v.Description(ctx), + ) +} + +// NotNull returns an validator which ensures that the attribute is +// configured. Most attributes should set Required: true instead, however in +// certain scenarios, such as a computed nested attribute, all underlying +// attributes must also be computed for planning to not show unexpected +// differences. +func NotNull() validator.Set { + return SetNotNullValidator{} +} diff --git a/internal/validators/stringvalidators/not_null.go b/internal/validators/stringvalidators/not_null.go new file mode 100644 index 0000000..f15f8ae --- /dev/null +++ b/internal/validators/stringvalidators/not_null.go @@ -0,0 +1,49 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package stringvalidators + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-framework/schema/validator" +) + +var _ validator.String = StringNotNullValidator{} + +// StringNotNullValidator validates that an attribute is not null. Most +// attributes should set Required: true instead, however in certain scenarios, +// such as a computed nested attribute, all underlying attributes must also be +// computed for planning to not show unexpected differences. +type StringNotNullValidator struct{} + +// Description describes the validation in plain text formatting. +func (v StringNotNullValidator) Description(_ context.Context) string { + return "value must be configured" +} + +// MarkdownDescription describes the validation in Markdown formatting. +func (v StringNotNullValidator) MarkdownDescription(ctx context.Context) string { + return v.Description(ctx) +} + +// Validate performs the validation. +func (v StringNotNullValidator) ValidateString(ctx context.Context, req validator.StringRequest, resp *validator.StringResponse) { + if !req.ConfigValue.IsNull() { + return + } + + resp.Diagnostics.AddAttributeError( + req.Path, + "Missing Attribute Value", + req.Path.String()+": "+v.Description(ctx), + ) +} + +// NotNull returns an validator which ensures that the attribute is +// configured. Most attributes should set Required: true instead, however in +// certain scenarios, such as a computed nested attribute, all underlying +// attributes must also be computed for planning to not show unexpected +// differences. +func NotNull() validator.String { + return StringNotNullValidator{} +}