|
1 | 1 | package connection |
2 | 2 |
|
3 | 3 | import ( |
4 | | - "terraform-provider-hookdeck/internal/validators" |
5 | | - |
6 | | - "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" |
7 | 4 | "github.com/hashicorp/terraform-plugin-framework/resource/schema" |
8 | | - "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" |
9 | | - "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" |
10 | | - "github.com/hashicorp/terraform-plugin-framework/schema/validator" |
11 | 5 | ) |
12 | 6 |
|
13 | 7 | func schemaAttributes() map[string]schema.Attribute { |
14 | | - filterRulePropertySchema := schema.SingleNestedAttribute{ |
15 | | - Optional: true, |
16 | | - Attributes: map[string]schema.Attribute{ |
17 | | - "boolean": schema.BoolAttribute{ |
18 | | - Optional: true, |
19 | | - }, |
20 | | - "json": schema.StringAttribute{ |
21 | | - Optional: true, |
22 | | - Description: `Stringied JSON using our filter syntax to filter on request headers`, |
23 | | - }, |
24 | | - "number": schema.NumberAttribute{ |
25 | | - Optional: true, |
26 | | - }, |
27 | | - "string": schema.StringAttribute{ |
28 | | - Optional: true, |
29 | | - }, |
30 | | - }, |
31 | | - Validators: []validator.Object{ |
32 | | - validators.ExactlyOneChild(), |
33 | | - }, |
34 | | - } |
35 | | - |
36 | | - return map[string]schema.Attribute{ |
37 | | - "created_at": schema.StringAttribute{ |
38 | | - Computed: true, |
39 | | - Validators: []validator.String{ |
40 | | - validators.IsRFC3339(), |
41 | | - }, |
42 | | - PlanModifiers: []planmodifier.String{ |
43 | | - stringplanmodifier.UseStateForUnknown(), |
44 | | - }, |
45 | | - Description: "Date the connection was created", |
46 | | - }, |
47 | | - "description": schema.StringAttribute{ |
48 | | - Optional: true, |
49 | | - PlanModifiers: []planmodifier.String{ |
50 | | - stringplanmodifier.UseStateForUnknown(), |
51 | | - }, |
52 | | - Description: "Description for the connection", |
53 | | - }, |
54 | | - "destination_id": schema.StringAttribute{ |
55 | | - Required: true, |
56 | | - PlanModifiers: []planmodifier.String{ |
57 | | - stringplanmodifier.RequiresReplace(), |
58 | | - }, |
59 | | - Description: "ID of a destination to bind to the connection", |
60 | | - }, |
61 | | - "disabled_at": schema.StringAttribute{ |
62 | | - Computed: true, |
63 | | - Optional: true, |
64 | | - Validators: []validator.String{ |
65 | | - validators.IsRFC3339(), |
66 | | - }, |
67 | | - Description: "Date the connection was disabled", |
68 | | - }, |
69 | | - "id": schema.StringAttribute{ |
70 | | - Computed: true, |
71 | | - Description: `ID of the connection`, |
72 | | - PlanModifiers: []planmodifier.String{ |
73 | | - stringplanmodifier.UseStateForUnknown(), |
74 | | - }, |
75 | | - }, |
76 | | - "name": schema.StringAttribute{ |
77 | | - Optional: true, |
78 | | - PlanModifiers: []planmodifier.String{ |
79 | | - stringplanmodifier.UseStateForUnknown(), |
80 | | - }, |
81 | | - Description: `A unique, human-friendly name for the connection`, |
82 | | - }, |
83 | | - "paused_at": schema.StringAttribute{ |
84 | | - Computed: true, |
85 | | - Validators: []validator.String{ |
86 | | - validators.IsRFC3339(), |
87 | | - }, |
88 | | - Description: "Date the connection was paused", |
89 | | - }, |
90 | | - "rules": schema.SetNestedAttribute{ |
91 | | - Optional: true, |
92 | | - NestedObject: schema.NestedAttributeObject{ |
93 | | - Attributes: map[string]schema.Attribute{ |
94 | | - "delay_rule": schema.SingleNestedAttribute{ |
95 | | - Optional: true, |
96 | | - Attributes: map[string]schema.Attribute{ |
97 | | - "delay": schema.Int64Attribute{ |
98 | | - Required: true, |
99 | | - Description: `Delay to introduce in MS`, |
100 | | - }, |
101 | | - }, |
102 | | - }, |
103 | | - "filter_rule": schema.SingleNestedAttribute{ |
104 | | - Optional: true, |
105 | | - Attributes: map[string]schema.Attribute{ |
106 | | - "body": filterRulePropertySchema, |
107 | | - "headers": filterRulePropertySchema, |
108 | | - "path": filterRulePropertySchema, |
109 | | - "query": filterRulePropertySchema, |
110 | | - }, |
111 | | - Validators: []validator.Object{ |
112 | | - validators.AtLeastOneChild(), |
113 | | - }, |
114 | | - }, |
115 | | - "retry_rule": schema.SingleNestedAttribute{ |
116 | | - Optional: true, |
117 | | - Attributes: map[string]schema.Attribute{ |
118 | | - "count": schema.Int64Attribute{ |
119 | | - Optional: true, |
120 | | - Description: `Maximum number of retries to attempt`, |
121 | | - }, |
122 | | - "interval": schema.Int64Attribute{ |
123 | | - Optional: true, |
124 | | - Description: `Time in MS between each retry`, |
125 | | - }, |
126 | | - "strategy": schema.StringAttribute{ |
127 | | - Required: true, |
128 | | - Validators: []validator.String{ |
129 | | - stringvalidator.OneOf( |
130 | | - "linear", |
131 | | - "exponential", |
132 | | - ), |
133 | | - }, |
134 | | - MarkdownDescription: `must be one of ["linear", "exponential"]` + "\n" + |
135 | | - `Algorithm to use when calculating delay between retries`, |
136 | | - }, |
137 | | - }, |
138 | | - }, |
139 | | - "transform_rule": schema.SingleNestedAttribute{ |
140 | | - Optional: true, |
141 | | - Attributes: map[string]schema.Attribute{ |
142 | | - "transformation_id": schema.StringAttribute{ |
143 | | - Required: true, |
144 | | - Description: `ID of the attached transformation object.`, |
145 | | - }, |
146 | | - }, |
147 | | - }, |
148 | | - }, |
149 | | - Validators: []validator.Object{ |
150 | | - validators.ExactlyOneChild(), |
151 | | - }, |
152 | | - }, |
153 | | - }, |
154 | | - "source_id": schema.StringAttribute{ |
155 | | - Required: true, |
156 | | - PlanModifiers: []planmodifier.String{ |
157 | | - stringplanmodifier.RequiresReplace(), |
158 | | - }, |
159 | | - Description: `ID of a source to bind to the connection`, |
160 | | - }, |
161 | | - "team_id": schema.StringAttribute{ |
162 | | - Computed: true, |
163 | | - PlanModifiers: []planmodifier.String{ |
164 | | - stringplanmodifier.UseStateForUnknown(), |
165 | | - }, |
166 | | - Description: `ID of the workspace`, |
167 | | - }, |
168 | | - "updated_at": schema.StringAttribute{ |
169 | | - Computed: true, |
170 | | - Validators: []validator.String{ |
171 | | - validators.IsRFC3339(), |
172 | | - }, |
173 | | - Description: `Date the connection was last updated`, |
174 | | - }, |
175 | | - } |
| 8 | + return schemaAttributesV1() |
176 | 9 | } |
0 commit comments