@@ -87,7 +87,7 @@ func ResourceGKEBackupBackupPlan() *schema.Resource {
8787 Type : schema .TypeBool ,
8888 Optional : true ,
8989 Description : `If True, include all namespaced resources.` ,
90- ExactlyOneOf : []string {"backup_config.0.all_namespaces" , "backup_config.0.selected_namespaces" , "backup_config.0.selected_applications" },
90+ ExactlyOneOf : []string {"backup_config.0.all_namespaces" , "backup_config.0.selected_namespaces" , "backup_config.0.selected_applications" , "backup_config.0.selected_namespace_labels" },
9191 },
9292 "encryption_key" : {
9393 Type : schema .TypeList ,
@@ -154,7 +154,37 @@ non-standard or requires additional setup to restore.`,
154154 },
155155 },
156156 },
157- ExactlyOneOf : []string {"backup_config.0.all_namespaces" , "backup_config.0.selected_namespaces" , "backup_config.0.selected_applications" },
157+ ExactlyOneOf : []string {"backup_config.0.all_namespaces" , "backup_config.0.selected_namespaces" , "backup_config.0.selected_applications" , "backup_config.0.selected_namespace_labels" },
158+ },
159+ "selected_namespace_labels" : {
160+ Type : schema .TypeList ,
161+ Optional : true ,
162+ Description : `If set, include just the resources in the listed namespace Labels.` ,
163+ MaxItems : 1 ,
164+ Elem : & schema.Resource {
165+ Schema : map [string ]* schema.Schema {
166+ "resource_labels" : {
167+ Type : schema .TypeList ,
168+ Required : true ,
169+ Description : `A list of Kubernetes Namespace labels.` ,
170+ Elem : & schema.Resource {
171+ Schema : map [string ]* schema.Schema {
172+ "key" : {
173+ Type : schema .TypeString ,
174+ Required : true ,
175+ Description : `The key of the kubernetes label.` ,
176+ },
177+ "value" : {
178+ Type : schema .TypeString ,
179+ Required : true ,
180+ Description : `The value of the Label.` ,
181+ },
182+ },
183+ },
184+ },
185+ },
186+ },
187+ ExactlyOneOf : []string {"backup_config.0.all_namespaces" , "backup_config.0.selected_namespaces" , "backup_config.0.selected_applications" , "backup_config.0.selected_namespace_labels" },
158188 },
159189 "selected_namespaces" : {
160190 Type : schema .TypeList ,
@@ -173,7 +203,7 @@ non-standard or requires additional setup to restore.`,
173203 },
174204 },
175205 },
176- ExactlyOneOf : []string {"backup_config.0.all_namespaces" , "backup_config.0.selected_namespaces" , "backup_config.0.selected_applications" },
206+ ExactlyOneOf : []string {"backup_config.0.all_namespaces" , "backup_config.0.selected_namespaces" , "backup_config.0.selected_applications" , "backup_config.0.selected_namespace_labels" },
177207 },
178208 },
179209 },
@@ -1244,6 +1274,8 @@ func flattenGKEBackupBackupPlanBackupConfig(v interface{}, d *schema.ResourceDat
12441274 flattenGKEBackupBackupPlanBackupConfigSelectedNamespaces (original ["selectedNamespaces" ], d , config )
12451275 transformed ["selected_applications" ] =
12461276 flattenGKEBackupBackupPlanBackupConfigSelectedApplications (original ["selectedApplications" ], d , config )
1277+ transformed ["selected_namespace_labels" ] =
1278+ flattenGKEBackupBackupPlanBackupConfigSelectedNamespaceLabels (original ["selectedNamespaceLabels" ], d , config )
12471279 transformed ["permissive_mode" ] =
12481280 flattenGKEBackupBackupPlanBackupConfigPermissiveMode (original ["permissiveMode" ], d , config )
12491281 return []interface {}{transformed }
@@ -1334,6 +1366,46 @@ func flattenGKEBackupBackupPlanBackupConfigSelectedApplicationsNamespacedNamesNa
13341366 return v
13351367}
13361368
1369+ func flattenGKEBackupBackupPlanBackupConfigSelectedNamespaceLabels (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
1370+ if v == nil {
1371+ return nil
1372+ }
1373+ original := v .(map [string ]interface {})
1374+ if len (original ) == 0 {
1375+ return nil
1376+ }
1377+ transformed := make (map [string ]interface {})
1378+ transformed ["resource_labels" ] =
1379+ flattenGKEBackupBackupPlanBackupConfigSelectedNamespaceLabelsResourceLabels (original ["resourceLabels" ], d , config )
1380+ return []interface {}{transformed }
1381+ }
1382+ func flattenGKEBackupBackupPlanBackupConfigSelectedNamespaceLabelsResourceLabels (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
1383+ if v == nil {
1384+ return v
1385+ }
1386+ l := v .([]interface {})
1387+ transformed := make ([]interface {}, 0 , len (l ))
1388+ for _ , raw := range l {
1389+ original := raw .(map [string ]interface {})
1390+ if len (original ) < 1 {
1391+ // Do not include empty json objects coming back from the api
1392+ continue
1393+ }
1394+ transformed = append (transformed , map [string ]interface {}{
1395+ "key" : flattenGKEBackupBackupPlanBackupConfigSelectedNamespaceLabelsResourceLabelsKey (original ["key" ], d , config ),
1396+ "value" : flattenGKEBackupBackupPlanBackupConfigSelectedNamespaceLabelsResourceLabelsValue (original ["value" ], d , config ),
1397+ })
1398+ }
1399+ return transformed
1400+ }
1401+ func flattenGKEBackupBackupPlanBackupConfigSelectedNamespaceLabelsResourceLabelsKey (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
1402+ return v
1403+ }
1404+
1405+ func flattenGKEBackupBackupPlanBackupConfigSelectedNamespaceLabelsResourceLabelsValue (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
1406+ return v
1407+ }
1408+
13371409func flattenGKEBackupBackupPlanBackupConfigPermissiveMode (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
13381410 return v
13391411}
@@ -1747,6 +1819,13 @@ func expandGKEBackupBackupPlanBackupConfig(v interface{}, d tpgresource.Terrafor
17471819 transformed ["selectedApplications" ] = transformedSelectedApplications
17481820 }
17491821
1822+ transformedSelectedNamespaceLabels , err := expandGKEBackupBackupPlanBackupConfigSelectedNamespaceLabels (original ["selected_namespace_labels" ], d , config )
1823+ if err != nil {
1824+ return nil , err
1825+ } else if val := reflect .ValueOf (transformedSelectedNamespaceLabels ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
1826+ transformed ["selectedNamespaceLabels" ] = transformedSelectedNamespaceLabels
1827+ }
1828+
17501829 transformedPermissiveMode , err := expandGKEBackupBackupPlanBackupConfigPermissiveMode (original ["permissive_mode" ], d , config )
17511830 if err != nil {
17521831 return nil , err
@@ -1871,6 +1950,62 @@ func expandGKEBackupBackupPlanBackupConfigSelectedApplicationsNamespacedNamesNam
18711950 return v , nil
18721951}
18731952
1953+ func expandGKEBackupBackupPlanBackupConfigSelectedNamespaceLabels (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
1954+ l := v .([]interface {})
1955+ if len (l ) == 0 || l [0 ] == nil {
1956+ return nil , nil
1957+ }
1958+ raw := l [0 ]
1959+ original := raw .(map [string ]interface {})
1960+ transformed := make (map [string ]interface {})
1961+
1962+ transformedResourceLabels , err := expandGKEBackupBackupPlanBackupConfigSelectedNamespaceLabelsResourceLabels (original ["resource_labels" ], d , config )
1963+ if err != nil {
1964+ return nil , err
1965+ } else if val := reflect .ValueOf (transformedResourceLabels ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
1966+ transformed ["resourceLabels" ] = transformedResourceLabels
1967+ }
1968+
1969+ return transformed , nil
1970+ }
1971+
1972+ func expandGKEBackupBackupPlanBackupConfigSelectedNamespaceLabelsResourceLabels (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
1973+ l := v .([]interface {})
1974+ req := make ([]interface {}, 0 , len (l ))
1975+ for _ , raw := range l {
1976+ if raw == nil {
1977+ continue
1978+ }
1979+ original := raw .(map [string ]interface {})
1980+ transformed := make (map [string ]interface {})
1981+
1982+ transformedKey , err := expandGKEBackupBackupPlanBackupConfigSelectedNamespaceLabelsResourceLabelsKey (original ["key" ], d , config )
1983+ if err != nil {
1984+ return nil , err
1985+ } else if val := reflect .ValueOf (transformedKey ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
1986+ transformed ["key" ] = transformedKey
1987+ }
1988+
1989+ transformedValue , err := expandGKEBackupBackupPlanBackupConfigSelectedNamespaceLabelsResourceLabelsValue (original ["value" ], d , config )
1990+ if err != nil {
1991+ return nil , err
1992+ } else if val := reflect .ValueOf (transformedValue ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
1993+ transformed ["value" ] = transformedValue
1994+ }
1995+
1996+ req = append (req , transformed )
1997+ }
1998+ return req , nil
1999+ }
2000+
2001+ func expandGKEBackupBackupPlanBackupConfigSelectedNamespaceLabelsResourceLabelsKey (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
2002+ return v , nil
2003+ }
2004+
2005+ func expandGKEBackupBackupPlanBackupConfigSelectedNamespaceLabelsResourceLabelsValue (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
2006+ return v , nil
2007+ }
2008+
18742009func expandGKEBackupBackupPlanBackupConfigPermissiveMode (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
18752010 return v , nil
18762011}
0 commit comments