@@ -81,6 +81,81 @@ func DatabaseAutonomousContainerDatabaseResource() *schema.Resource {
8181 Computed : true ,
8282 Elem : schema .TypeString ,
8383 },
84+ "maintenance_window_details" : {
85+ Type : schema .TypeList ,
86+ Optional : true ,
87+ MaxItems : 1 ,
88+ MinItems : 1 ,
89+ Elem : & schema.Resource {
90+ Schema : map [string ]* schema.Schema {
91+ // Required
92+ "preference" : {
93+ Type : schema .TypeString ,
94+ Required : true ,
95+ },
96+
97+ // Optional
98+ "days_of_week" : {
99+ Type : schema .TypeList ,
100+ Optional : true ,
101+ Computed : true ,
102+ Elem : & schema.Resource {
103+ Schema : map [string ]* schema.Schema {
104+ // Required
105+ "name" : {
106+ Type : schema .TypeString ,
107+ Required : true ,
108+ },
109+
110+ // Optional
111+
112+ // Computed
113+ },
114+ },
115+ },
116+ "hours_of_day" : {
117+ Type : schema .TypeList ,
118+ Optional : true ,
119+ Computed : true ,
120+ MaxItems : 20 ,
121+ MinItems : 0 ,
122+ Elem : & schema.Schema {
123+ Type : schema .TypeInt ,
124+ },
125+ },
126+ "months" : {
127+ Type : schema .TypeList ,
128+ Optional : true ,
129+ Computed : true ,
130+ Elem : & schema.Resource {
131+ Schema : map [string ]* schema.Schema {
132+ // Required
133+ "name" : {
134+ Type : schema .TypeString ,
135+ Required : true ,
136+ },
137+
138+ // Optional
139+
140+ // Computed
141+ },
142+ },
143+ },
144+ "weeks_of_month" : {
145+ Type : schema .TypeList ,
146+ Optional : true ,
147+ Computed : true ,
148+ MaxItems : 4 ,
149+ MinItems : 1 ,
150+ Elem : & schema.Schema {
151+ Type : schema .TypeInt ,
152+ },
153+ },
154+
155+ // Computed
156+ },
157+ },
158+ },
84159 "service_level_agreement_type" : {
85160 Type : schema .TypeString ,
86161 Optional : true ,
@@ -101,6 +176,77 @@ func DatabaseAutonomousContainerDatabaseResource() *schema.Resource {
101176 Type : schema .TypeString ,
102177 Computed : true ,
103178 },
179+ "maintenance_window" : {
180+ Type : schema .TypeList ,
181+ Computed : true ,
182+ MaxItems : 1 ,
183+ MinItems : 1 ,
184+ Elem : & schema.Resource {
185+ Schema : map [string ]* schema.Schema {
186+ // Required
187+
188+ // Optional
189+
190+ // Computed
191+ "days_of_week" : {
192+ Type : schema .TypeList ,
193+ Computed : true ,
194+ Elem : & schema.Resource {
195+ Schema : map [string ]* schema.Schema {
196+ // Required
197+
198+ // Optional
199+
200+ // Computed
201+ "name" : {
202+ Type : schema .TypeString ,
203+ Computed : true ,
204+ },
205+ },
206+ },
207+ },
208+ "hours_of_day" : {
209+ Type : schema .TypeList ,
210+ Computed : true ,
211+ MaxItems : 20 ,
212+ MinItems : 0 ,
213+ Elem : & schema.Schema {
214+ Type : schema .TypeInt ,
215+ },
216+ },
217+ "months" : {
218+ Type : schema .TypeList ,
219+ Computed : true ,
220+ Elem : & schema.Resource {
221+ Schema : map [string ]* schema.Schema {
222+ // Required
223+
224+ // Optional
225+
226+ // Computed
227+ "name" : {
228+ Type : schema .TypeString ,
229+ Computed : true ,
230+ },
231+ },
232+ },
233+ },
234+ "preference" : {
235+ Type : schema .TypeString ,
236+ Computed : true ,
237+ },
238+ "weeks_of_month" : {
239+ Type : schema .TypeList ,
240+ Computed : true ,
241+ MaxItems : 4 ,
242+ MinItems : 1 ,
243+ Elem : & schema.Schema {
244+ Type : schema .TypeInt ,
245+ },
246+ },
247+ },
248+ },
249+ },
104250 "next_maintenance_run_id" : {
105251 Type : schema .TypeString ,
106252 Computed : true ,
@@ -242,6 +388,17 @@ func (s *DatabaseAutonomousContainerDatabaseResourceCrud) Create() error {
242388 request .FreeformTags = objectMapToStringMap (freeformTags .(map [string ]interface {}))
243389 }
244390
391+ if maintenanceWindowDetails , ok := s .D .GetOkExists ("maintenance_window_details" ); ok {
392+ if tmpList := maintenanceWindowDetails .([]interface {}); len (tmpList ) > 0 {
393+ fieldKeyFormat := fmt .Sprintf ("%s.%d.%%s" , "maintenance_window_details" , 0 )
394+ tmp , err := s .mapToMaintenanceWindow (fieldKeyFormat )
395+ if err != nil {
396+ return err
397+ }
398+ request .MaintenanceWindowDetails = & tmp
399+ }
400+ }
401+
245402 if patchModel , ok := s .D .GetOkExists ("patch_model" ); ok {
246403 request .PatchModel = oci_database .CreateAutonomousContainerDatabaseDetailsPatchModelEnum (patchModel .(string ))
247404 }
@@ -321,6 +478,17 @@ func (s *DatabaseAutonomousContainerDatabaseResourceCrud) Update() error {
321478 request .FreeformTags = objectMapToStringMap (freeformTags .(map [string ]interface {}))
322479 }
323480
481+ if maintenanceWindowDetails , ok := s .D .GetOkExists ("maintenance_window_details" ); ok {
482+ if tmpList := maintenanceWindowDetails .([]interface {}); len (tmpList ) > 0 {
483+ fieldKeyFormat := fmt .Sprintf ("%s.%d.%%s" , "maintenance_window_details" , 0 )
484+ tmp , err := s .mapToMaintenanceWindow (fieldKeyFormat )
485+ if err != nil {
486+ return err
487+ }
488+ request .MaintenanceWindowDetails = & tmp
489+ }
490+ }
491+
324492 if patchModel , ok := s .D .GetOkExists ("patch_model" ); ok {
325493 request .PatchModel = oci_database .UpdateAutonomousContainerDatabaseDetailsPatchModelEnum (patchModel .(string ))
326494 }
@@ -385,6 +553,12 @@ func (s *DatabaseAutonomousContainerDatabaseResourceCrud) SetData() error {
385553 s .D .Set ("lifecycle_details" , * s .Res .LifecycleDetails )
386554 }
387555
556+ if s .Res .MaintenanceWindow != nil {
557+ s .D .Set ("maintenance_window" , []interface {}{MaintenanceWindowToMap (s .Res .MaintenanceWindow )})
558+ } else {
559+ s .D .Set ("maintenance_window" , nil )
560+ }
561+
388562 if s .Res .NextMaintenanceRunId != nil {
389563 s .D .Set ("next_maintenance_run_id" , * s .Res .NextMaintenanceRunId )
390564 }
@@ -423,6 +597,105 @@ func AutonomousContainerDatabaseBackupConfigToMap(obj *oci_database.AutonomousCo
423597 return result
424598}
425599
600+ func (s * DatabaseAutonomousContainerDatabaseResourceCrud ) mapToDayOfWeek (fieldKeyFormat string ) (oci_database.DayOfWeek , error ) {
601+ result := oci_database.DayOfWeek {}
602+
603+ if name , ok := s .D .GetOkExists (fmt .Sprintf (fieldKeyFormat , "name" )); ok {
604+ result .Name = oci_database .DayOfWeekNameEnum (name .(string ))
605+ }
606+
607+ return result , nil
608+ }
609+
610+ func (s * DatabaseAutonomousContainerDatabaseResourceCrud ) mapToMaintenanceWindow (fieldKeyFormat string ) (oci_database.MaintenanceWindow , error ) {
611+ result := oci_database.MaintenanceWindow {}
612+
613+ if preference , ok := s .D .GetOkExists (fmt .Sprintf (fieldKeyFormat , "preference" )); ok {
614+ result .Preference = oci_database .MaintenanceWindowPreferenceEnum (preference .(string ))
615+
616+ // maintenance window fields are expected to be nil when preference = NO_PREFERENCE
617+ if result .Preference == oci_database .MaintenanceWindowPreferenceNoPreference {
618+ return result , nil
619+ }
620+ }
621+
622+ if daysOfWeek , ok := s .D .GetOkExists (fmt .Sprintf (fieldKeyFormat , "days_of_week" )); ok {
623+ interfaces := daysOfWeek .([]interface {})
624+ tmp := make ([]oci_database.DayOfWeek , len (interfaces ))
625+ for i := range interfaces {
626+ stateDataIndex := i
627+ fieldKeyFormatNextLevel := fmt .Sprintf ("%s.%d.%%s" , fmt .Sprintf (fieldKeyFormat , "days_of_week" ), stateDataIndex )
628+ converted , err := s .mapToDayOfWeek (fieldKeyFormatNextLevel )
629+ if err != nil {
630+ return result , err
631+ }
632+ tmp [i ] = converted
633+ }
634+ if len (tmp ) != 0 || s .D .HasChange (fmt .Sprintf (fieldKeyFormat , "days_of_week" )) {
635+ result .DaysOfWeek = tmp
636+ }
637+ }
638+
639+ if hoursOfDay , ok := s .D .GetOkExists (fmt .Sprintf (fieldKeyFormat , "hours_of_day" )); ok {
640+ interfaces := hoursOfDay .([]interface {})
641+ tmp := make ([]int , len (interfaces ))
642+ for i := range interfaces {
643+ if interfaces [i ] != nil {
644+ tmp [i ] = interfaces [i ].(int )
645+ }
646+ }
647+ if len (tmp ) != 0 || s .D .HasChange (fmt .Sprintf (fieldKeyFormat , "hours_of_day" )) {
648+ result .HoursOfDay = tmp
649+ }
650+ }
651+
652+ if months , ok := s .D .GetOkExists (fmt .Sprintf (fieldKeyFormat , "months" )); ok {
653+ interfaces := months .([]interface {})
654+ tmp := make ([]oci_database.Month , len (interfaces ))
655+ for i := range interfaces {
656+ stateDataIndex := i
657+ fieldKeyFormatNextLevel := fmt .Sprintf ("%s.%d.%%s" , fmt .Sprintf (fieldKeyFormat , "months" ), stateDataIndex )
658+ converted , err := s .mapToMonth (fieldKeyFormatNextLevel )
659+ if err != nil {
660+ return result , err
661+ }
662+ tmp [i ] = converted
663+ }
664+ if len (tmp ) != 0 || s .D .HasChange (fmt .Sprintf (fieldKeyFormat , "months" )) {
665+ result .Months = tmp
666+ }
667+ }
668+
669+ if preference , ok := s .D .GetOkExists (fmt .Sprintf (fieldKeyFormat , "preference" )); ok {
670+ result .Preference = oci_database .MaintenanceWindowPreferenceEnum (preference .(string ))
671+ }
672+
673+ if weeksOfMonth , ok := s .D .GetOkExists (fmt .Sprintf (fieldKeyFormat , "weeks_of_month" )); ok {
674+ interfaces := weeksOfMonth .([]interface {})
675+ tmp := make ([]int , len (interfaces ))
676+ for i := range interfaces {
677+ if interfaces [i ] != nil {
678+ tmp [i ] = interfaces [i ].(int )
679+ }
680+ }
681+ if len (tmp ) != 0 || s .D .HasChange (fmt .Sprintf (fieldKeyFormat , "weeks_of_month" )) {
682+ result .WeeksOfMonth = tmp
683+ }
684+ }
685+
686+ return result , nil
687+ }
688+
689+ func (s * DatabaseAutonomousContainerDatabaseResourceCrud ) mapToMonth (fieldKeyFormat string ) (oci_database.Month , error ) {
690+ result := oci_database.Month {}
691+
692+ if name , ok := s .D .GetOkExists (fmt .Sprintf (fieldKeyFormat , "name" )); ok {
693+ result .Name = oci_database .MonthNameEnum (name .(string ))
694+ }
695+
696+ return result , nil
697+ }
698+
426699func (s * DatabaseAutonomousContainerDatabaseResourceCrud ) updateCompartment (compartment interface {}) error {
427700 changeCompartmentRequest := oci_database.ChangeAutonomousContainerDatabaseCompartmentRequest {}
428701
0 commit comments