@@ -13,7 +13,7 @@ import (
1313
1414func ResourceMaintenanceWindow () * schema.Resource {
1515 apikeySchema := map [string ]* schema.Schema {
16- "maintenance_window_id " : {
16+ "id " : {
1717 Description : "A UUID v1 or v4 to use instead of a randomly generated ID." ,
1818 Type : schema .TypeString ,
1919 Computed : true ,
@@ -48,7 +48,7 @@ func ResourceMaintenanceWindow() *schema.Resource {
4848 Description : "Creates a Kibana Maintenance Window." ,
4949
5050 CreateContext : resourceMaintenanceWindowCreate ,
51- // UpdateContext: resourceMaintenanceWindowUpdate,
51+ UpdateContext : resourceMaintenanceWindowUpdate ,
5252 ReadContext : resourceMaintenanceWindowRead ,
5353 DeleteContext : resourceMaintenanceWindowDelete ,
5454
@@ -63,16 +63,15 @@ func ResourceMaintenanceWindow() *schema.Resource {
6363func getMaintenanceWindowFromResourceData (d * schema.ResourceData , serverVersion * version.Version ) (models.MaintenanceWindow , diag.Diagnostics ) {
6464 var diags diag.Diagnostics
6565 maintenanceWindow := models.MaintenanceWindow {
66- MaintenanceWindowID : d .Get ("maintenance_window_id" ).(string ),
67- Title : d .Get ("title" ).(string ),
68- Enabled : d .Get ("enabled" ).(bool ),
69- Start : d .Get ("start" ).(string ),
70- Duration : d .Get ("duration" ).(int ),
66+ Title : d .Get ("title" ).(string ),
67+ Enabled : d .Get ("enabled" ).(bool ),
68+ Start : d .Get ("start" ).(string ),
69+ Duration : d .Get ("duration" ).(int ),
7170 }
7271
7372 // Explicitly set maintenance window id if provided, otherwise we'll use the autogenerated ID from the Kibana API response
74- if maintenanceWindowID := getOrNilString ("MaintenanceWindowID " , d ); maintenanceWindowID != nil && * maintenanceWindowID != "" {
75- maintenanceWindow .MaintenanceWindowID = * maintenanceWindowID
73+ if maintenanceWindowID := getOrNilString ("id " , d ); maintenanceWindowID != nil && * maintenanceWindowID != "" {
74+ maintenanceWindow .Id = * maintenanceWindowID
7675 }
7776
7877 return maintenanceWindow , diags
@@ -105,13 +104,37 @@ func resourceMaintenanceWindowCreate(ctx context.Context, d *schema.ResourceData
105104 return resourceRuleRead (ctx , d , meta )
106105}
107106
107+ func resourceMaintenanceWindowUpdate (ctx context.Context , d * schema.ResourceData , meta interface {}) diag.Diagnostics {
108+ client , diags := clients .NewApiClientFromSDKResource (d , meta )
109+ if diags .HasError () {
110+ return diags
111+ }
112+
113+ serverVersion , diags := client .ServerVersion (ctx )
114+ if diags .HasError () {
115+ return diags
116+ }
117+
118+ maintenanceWindow , diags := getMaintenanceWindowFromResourceData (d , serverVersion )
119+ if diags .HasError () {
120+ return diags
121+ }
122+
123+ // DO NOTHING
124+ // res, diags := kibana.UpdateAlertingRule(ctx, client, maintenanceWindow)
125+ d .SetId (maintenanceWindow .MaintenanceWindowID )
126+
127+ return resourceRuleRead (ctx , d , meta )
128+ }
129+
108130func resourceMaintenanceWindowRead (ctx context.Context , d * schema.ResourceData , meta interface {}) diag.Diagnostics {
109131 client , diags := clients .NewApiClientFromSDKResource (d , meta )
110132 if diags .HasError () {
111133 return diags
112134 }
113135
114136 maintenanceWindow , diags := kibana .GetMaintenanceWindow (ctx , client , d .Id ())
137+
115138 if maintenanceWindow == nil && diags == nil {
116139 d .SetId ("" )
117140 return diags
@@ -121,7 +144,7 @@ func resourceMaintenanceWindowRead(ctx context.Context, d *schema.ResourceData,
121144 }
122145
123146 // set the fields
124- if err := d .Set ("maintenance_window_id " , maintenanceWindow .MaintenanceWindowID ); err != nil {
147+ if err := d .Set ("id " , maintenanceWindow .Id ); err != nil {
125148 return diag .FromErr (err )
126149 }
127150 if err := d .Set ("title" , maintenanceWindow .Title ); err != nil {
0 commit comments