-
Notifications
You must be signed in to change notification settings - Fork 97
/
Copy pathint64_attribute.go
208 lines (179 loc) · 7.67 KB
/
int64_attribute.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package schema
import (
"github.com/hashicorp/terraform-plugin-go/tftypes"
"github.com/hashicorp/terraform-plugin-framework/attr"
"github.com/hashicorp/terraform-plugin-framework/internal/fwschema"
"github.com/hashicorp/terraform-plugin-framework/internal/fwschema/fwxschema"
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-framework/types/basetypes"
)
// Ensure the implementation satisifies the desired interfaces.
var (
_ Attribute = Int64Attribute{}
_ fwxschema.AttributeWithInt64Validators = Int64Attribute{}
)
// Int64Attribute represents a schema attribute that is a 64-bit integer.
// When retrieving the value for this attribute, use types.Int64 as the value
// type unless the CustomType field is set.
//
// Use Float64Attribute for 64-bit floating point number attributes or
// NumberAttribute for 512-bit generic number attributes.
//
// Terraform configurations configure this attribute using expressions that
// return a number or directly via an integer value.
//
// example_attribute = 123
//
// Terraform configurations reference this attribute using the attribute name.
//
// .example_attribute
type Int64Attribute struct {
// CustomType enables the use of a custom attribute type in place of the
// default basetypes.Int64Type. When retrieving data, the basetypes.Int64Valuable
// associated with this custom type must be used in place of types.Int64.
CustomType basetypes.Int64Typable
// Required indicates whether the practitioner must enter a value for
// this attribute or not. Required and Optional cannot both be true,
// and Required and Computed cannot both be true.
Required bool
// Optional indicates whether the practitioner can choose to enter a value
// for this attribute or not. Optional and Required cannot both be true.
Optional bool
// Computed indicates whether the provider may return its own value for
// this Attribute or not. Required and Computed cannot both be true. If
// Required and Optional are both false, Computed must be true, and the
// attribute will be considered "read only" for the practitioner, with
// only the provider able to set its value.
Computed bool
// Sensitive indicates whether the value of this attribute should be
// considered sensitive data. Setting it to true will obscure the value
// in CLI output. Sensitive does not impact how values are stored, and
// practitioners are encouraged to store their state as if the entire
// file is sensitive.
Sensitive bool
// Description is used in various tooling, like the language server, to
// give practitioners more information about what this attribute is,
// what it's for, and how it should be used. It should be written as
// plain text, with no special formatting.
Description string
// MarkdownDescription is used in various tooling, like the
// documentation generator, to give practitioners more information
// about what this attribute is, what it's for, and how it should be
// used. It should be formatted using Markdown.
MarkdownDescription string
// DeprecationMessage defines warning diagnostic details to display when
// practitioner configurations use this Attribute. The warning diagnostic
// summary is automatically set to "Attribute Deprecated" along with
// configuration source file and line information.
//
// Set this field to a practitioner actionable message such as:
//
// - "Configure other_attribute instead. This attribute will be removed
// in the next major version of the provider."
// - "Remove this attribute's configuration as it no longer is used and
// the attribute will be removed in the next major version of the
// provider."
//
// In Terraform 1.2.7 and later, this warning diagnostic is displayed any
// time a practitioner attempts to configure a value for this attribute and
// certain scenarios where this attribute is referenced.
//
// In Terraform 1.2.6 and earlier, this warning diagnostic is only
// displayed when the Attribute is Required or Optional, and if the
// practitioner configuration sets the value to a known or unknown value
// (which may eventually be null). It has no effect when the Attribute is
// Computed-only (read-only; not Required or Optional).
//
// Across any Terraform version, there are no warnings raised for
// practitioner configuration values set directly to null, as there is no
// way for the framework to differentiate between an unset and null
// configuration due to how Terraform sends configuration information
// across the protocol.
//
// Additional information about deprecation enhancements for read-only
// attributes can be found in:
//
// - https://github.com/hashicorp/terraform/issues/7569
//
DeprecationMessage string
// Validators define value validation functionality for the attribute. All
// elements of the slice of AttributeValidator are run, regardless of any
// previous error diagnostics.
//
// Many common use case validators can be found in the
// github.com/hashicorp/terraform-plugin-framework-validators Go module.
//
// If the Type field points to a custom type that implements the
// xattr.TypeWithValidate interface, the validators defined in this field
// are run in addition to the validation defined by the type.
Validators []validator.Int64
}
// ApplyTerraform5AttributePathStep always returns an error as it is not
// possible to step further into a Int64Attribute.
func (a Int64Attribute) ApplyTerraform5AttributePathStep(step tftypes.AttributePathStep) (interface{}, error) {
return a.GetType().ApplyTerraform5AttributePathStep(step)
}
// Equal returns true if the given Attribute is a Int64Attribute
// and all fields are equal.
func (a Int64Attribute) Equal(o fwschema.Attribute) bool {
if _, ok := o.(Int64Attribute); !ok {
return false
}
return fwschema.AttributesEqual(a, o)
}
// GetDeprecationMessage returns the DeprecationMessage field value.
func (a Int64Attribute) GetDeprecationMessage() string {
return a.DeprecationMessage
}
// GetDescription returns the Description field value.
func (a Int64Attribute) GetDescription() string {
return a.Description
}
// GetMarkdownDescription returns the MarkdownDescription field value.
func (a Int64Attribute) GetMarkdownDescription() string {
return a.MarkdownDescription
}
// GetType returns types.Int64Type or the CustomType field value if defined.
func (a Int64Attribute) GetType() attr.Type {
if a.CustomType != nil {
return a.CustomType
}
return types.Int64Type
}
// Int64Validators returns the Validators field value.
func (a Int64Attribute) Int64Validators() []validator.Int64 {
return a.Validators
}
// IsComputed returns the Computed field value.
func (a Int64Attribute) IsComputed() bool {
return a.Computed
}
// IsOptional returns the Optional field value.
func (a Int64Attribute) IsOptional() bool {
return a.Optional
}
// IsRequired returns the Required field value.
func (a Int64Attribute) IsRequired() bool {
return a.Required
}
// IsSensitive returns the Sensitive field value.
func (a Int64Attribute) IsSensitive() bool {
return a.Sensitive
}
// IsWriteOnly returns false as write-only attributes are not supported in data source schemas.
func (a Int64Attribute) IsWriteOnly() bool {
return false
}
// IsRequiredForImport returns false as this behavior is only relevant
// for managed resource identity schema attributes.
func (a Int64Attribute) IsRequiredForImport() bool {
return false
}
// IsOptionalForImport returns false as this behavior is only relevant
// for managed resource identity schema attributes.
func (a Int64Attribute) IsOptionalForImport() bool {
return false
}