|
11 | 11 | package datalake |
12 | 12 |
|
13 | 13 | import ( |
| 14 | + "context" |
| 15 | + |
| 16 | + "github.com/hashicorp/terraform-plugin-framework/resource" |
14 | 17 | "github.com/hashicorp/terraform-plugin-framework/resource/schema" |
15 | | - "github.com/hashicorp/terraform-plugin-framework/resource/schema/booldefault" |
16 | | - "github.com/hashicorp/terraform-plugin-framework/resource/schema/boolplanmodifier" |
17 | | - "github.com/hashicorp/terraform-plugin-framework/resource/schema/int64default" |
18 | 18 | "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" |
19 | 19 | "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" |
20 | | - "github.com/hashicorp/terraform-plugin-framework/types" |
| 20 | + |
| 21 | + "github.com/cloudera/terraform-provider-cdp/utils" |
21 | 22 | ) |
22 | 23 |
|
23 | | -var awsDatalakeResourceSchema = schema.Schema{ |
24 | | - MarkdownDescription: "A Data Lake is a service which provides a protective ring around the data stored in a cloud object store, including authentication, authorization, and governance support.", |
25 | | - Attributes: map[string]schema.Attribute{ |
26 | | - "id": schema.StringAttribute{ |
27 | | - Computed: true, |
28 | | - PlanModifiers: []planmodifier.String{ |
29 | | - stringplanmodifier.UseStateForUnknown(), |
30 | | - }, |
31 | | - }, |
32 | | - "polling_options": schema.SingleNestedAttribute{ |
33 | | - MarkdownDescription: "Polling related configuration options that could specify various values that will be used during CDP resource creation.", |
34 | | - Optional: true, |
35 | | - Attributes: map[string]schema.Attribute{ |
36 | | - "async": schema.BoolAttribute{ |
37 | | - MarkdownDescription: "Boolean value that specifies if Terraform should wait for resource creation/deletion.", |
38 | | - Optional: true, |
39 | | - Computed: true, |
40 | | - Default: booldefault.StaticBool(false), |
41 | | - PlanModifiers: []planmodifier.Bool{ |
42 | | - boolplanmodifier.UseStateForUnknown(), |
43 | | - }, |
44 | | - }, |
45 | | - "polling_timeout": schema.Int64Attribute{ |
46 | | - MarkdownDescription: "Timeout value in minutes that specifies for how long should the polling go for resource creation/deletion.", |
47 | | - Default: int64default.StaticInt64(90), |
48 | | - Computed: true, |
49 | | - Optional: true, |
50 | | - }, |
51 | | - "call_failure_threshold": schema.Int64Attribute{ |
52 | | - MarkdownDescription: "Threshold value that specifies how many times should a single call failure happen before giving up the polling.", |
53 | | - Default: int64default.StaticInt64(3), |
54 | | - Computed: true, |
55 | | - Optional: true, |
56 | | - }, |
57 | | - }, |
58 | | - }, |
59 | | - "instance_profile": schema.StringAttribute{ |
60 | | - Required: true, |
61 | | - }, |
62 | | - "storage_location_base": schema.StringAttribute{ |
63 | | - Required: true, |
64 | | - }, |
| 24 | +func (r *awsDatalakeResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) { |
| 25 | + attr := map[string]schema.Attribute{} |
| 26 | + utils.Append(attr, generalAttributes) |
| 27 | + utils.Append(attr, map[string]schema.Attribute{ |
65 | 28 | "certificate_expiration_state": schema.StringAttribute{ |
66 | 29 | Computed: true, |
67 | 30 | PlanModifiers: []planmodifier.String{ |
68 | 31 | stringplanmodifier.UseStateForUnknown(), |
69 | 32 | }, |
70 | 33 | }, |
71 | | - "creation_date": schema.StringAttribute{ |
72 | | - Computed: true, |
73 | | - PlanModifiers: []planmodifier.String{ |
74 | | - stringplanmodifier.UseStateForUnknown(), |
75 | | - }, |
76 | | - }, |
77 | | - "crn": schema.StringAttribute{ |
78 | | - Computed: true, |
79 | | - PlanModifiers: []planmodifier.String{ |
80 | | - stringplanmodifier.UseStateForUnknown(), |
81 | | - }, |
82 | | - }, |
83 | | - "datalake_name": schema.StringAttribute{ |
| 34 | + "storage_location_base": schema.StringAttribute{ |
84 | 35 | Required: true, |
85 | 36 | }, |
86 | | - "enable_ranger_raz": schema.BoolAttribute{ |
87 | | - Optional: true, |
88 | | - Computed: true, |
89 | | - PlanModifiers: []planmodifier.Bool{ |
90 | | - boolplanmodifier.UseStateForUnknown(), |
91 | | - }, |
92 | | - }, |
93 | | - "environment_crn": schema.StringAttribute{ |
94 | | - Computed: true, |
95 | | - PlanModifiers: []planmodifier.String{ |
96 | | - stringplanmodifier.UseStateForUnknown(), |
97 | | - }, |
98 | | - }, |
99 | | - "environment_name": schema.StringAttribute{ |
| 37 | + "instance_profile": schema.StringAttribute{ |
100 | 38 | Required: true, |
101 | 39 | }, |
102 | | - "image": schema.SingleNestedAttribute{ |
103 | | - Optional: true, |
104 | | - Attributes: map[string]schema.Attribute{ |
105 | | - "catalog_name": schema.StringAttribute{ |
106 | | - Optional: true, |
107 | | - }, |
108 | | - "id": schema.StringAttribute{ |
109 | | - Optional: true, |
110 | | - }, |
111 | | - "os": schema.StringAttribute{ |
112 | | - Optional: true, |
113 | | - }, |
114 | | - }, |
115 | | - }, |
116 | | - "java_version": schema.Int64Attribute{ |
117 | | - Optional: true, |
118 | | - }, |
119 | | - "multi_az": schema.BoolAttribute{ |
120 | | - Optional: true, |
121 | | - Computed: true, |
122 | | - PlanModifiers: []planmodifier.Bool{ |
123 | | - boolplanmodifier.UseStateForUnknown(), |
124 | | - }, |
125 | | - }, |
126 | | - "recipes": schema.SetNestedAttribute{ |
127 | | - Optional: true, |
128 | | - NestedObject: schema.NestedAttributeObject{ |
129 | | - Attributes: map[string]schema.Attribute{ |
130 | | - "instance_group_name": schema.StringAttribute{ |
131 | | - MarkdownDescription: "The name of the designated instance group.", |
132 | | - Required: true, |
133 | | - }, |
134 | | - "recipe_names": schema.SetAttribute{ |
135 | | - MarkdownDescription: "The set of recipe names that are going to be applied on the given instance group.", |
136 | | - ElementType: types.StringType, |
137 | | - Required: true, |
138 | | - }, |
139 | | - }, |
140 | | - }, |
141 | | - }, |
142 | | - "runtime": schema.StringAttribute{ |
143 | | - Optional: true, |
144 | | - }, |
145 | | - "scale": schema.StringAttribute{ |
146 | | - Computed: true, |
147 | | - Optional: true, |
148 | | - }, |
149 | | - "status": schema.StringAttribute{ |
150 | | - Computed: true, |
151 | | - PlanModifiers: []planmodifier.String{ |
152 | | - stringplanmodifier.UseStateForUnknown(), |
153 | | - }, |
154 | | - }, |
155 | | - "status_reason": schema.StringAttribute{ |
156 | | - Computed: true, |
157 | | - PlanModifiers: []planmodifier.String{ |
158 | | - stringplanmodifier.UseStateForUnknown(), |
159 | | - }, |
160 | | - }, |
161 | | - "tags": schema.MapAttribute{ |
162 | | - Optional: true, |
163 | | - ElementType: types.StringType, |
164 | | - }, |
165 | | - }, |
| 40 | + }) |
| 41 | + resp.Schema = schema.Schema{ |
| 42 | + MarkdownDescription: "A Data Lake is a service which provides a protective ring around the data stored in a cloud object store, including authentication, authorization, and governance support.", |
| 43 | + Attributes: attr, |
| 44 | + } |
166 | 45 | } |
0 commit comments