@@ -78,6 +78,36 @@ Valid only when 'RuntimeType' is set to CLOUD. The value can be updated only whe
78
78
Optional : true ,
79
79
Description : `The display name of the Apigee organization.` ,
80
80
},
81
+ "properties" : {
82
+ Type : schema .TypeList ,
83
+ Computed : true ,
84
+ Optional : true ,
85
+ Description : `Properties defined in the Apigee organization profile.` ,
86
+ MaxItems : 1 ,
87
+ Elem : & schema.Resource {
88
+ Schema : map [string ]* schema.Schema {
89
+ "property" : {
90
+ Type : schema .TypeList ,
91
+ Optional : true ,
92
+ Description : `List of all properties in the object.` ,
93
+ Elem : & schema.Resource {
94
+ Schema : map [string ]* schema.Schema {
95
+ "name" : {
96
+ Type : schema .TypeString ,
97
+ Optional : true ,
98
+ Description : `Name of the property.` ,
99
+ },
100
+ "value" : {
101
+ Type : schema .TypeString ,
102
+ Optional : true ,
103
+ Description : `Value of the property.` ,
104
+ },
105
+ },
106
+ },
107
+ },
108
+ },
109
+ },
110
+ },
81
111
"retention" : {
82
112
Type : schema .TypeString ,
83
113
Optional : true ,
@@ -177,6 +207,12 @@ func resourceApigeeOrganizationCreate(d *schema.ResourceData, meta interface{})
177
207
} else if v , ok := d .GetOkExists ("runtime_database_encryption_key_name" ); ! isEmptyValue (reflect .ValueOf (runtimeDatabaseEncryptionKeyNameProp )) && (ok || ! reflect .DeepEqual (v , runtimeDatabaseEncryptionKeyNameProp )) {
178
208
obj ["runtimeDatabaseEncryptionKeyName" ] = runtimeDatabaseEncryptionKeyNameProp
179
209
}
210
+ propertiesProp , err := expandApigeeOrganizationProperties (d .Get ("properties" ), d , config )
211
+ if err != nil {
212
+ return err
213
+ } else if v , ok := d .GetOkExists ("properties" ); ! isEmptyValue (reflect .ValueOf (propertiesProp )) && (ok || ! reflect .DeepEqual (v , propertiesProp )) {
214
+ obj ["properties" ] = propertiesProp
215
+ }
180
216
181
217
obj , err = resourceApigeeOrganizationEncoder (d , meta , obj )
182
218
if err != nil {
@@ -290,6 +326,9 @@ func resourceApigeeOrganizationRead(d *schema.ResourceData, meta interface{}) er
290
326
if err := d .Set ("runtime_database_encryption_key_name" , flattenApigeeOrganizationRuntimeDatabaseEncryptionKeyName (res ["runtimeDatabaseEncryptionKeyName" ], d , config )); err != nil {
291
327
return fmt .Errorf ("Error reading Organization: %s" , err )
292
328
}
329
+ if err := d .Set ("properties" , flattenApigeeOrganizationProperties (res ["properties" ], d , config )); err != nil {
330
+ return fmt .Errorf ("Error reading Organization: %s" , err )
331
+ }
293
332
294
333
return nil
295
334
}
@@ -346,6 +385,12 @@ func resourceApigeeOrganizationUpdate(d *schema.ResourceData, meta interface{})
346
385
} else if v , ok := d .GetOkExists ("runtime_database_encryption_key_name" ); ! isEmptyValue (reflect .ValueOf (v )) && (ok || ! reflect .DeepEqual (v , runtimeDatabaseEncryptionKeyNameProp )) {
347
386
obj ["runtimeDatabaseEncryptionKeyName" ] = runtimeDatabaseEncryptionKeyNameProp
348
387
}
388
+ propertiesProp , err := expandApigeeOrganizationProperties (d .Get ("properties" ), d , config )
389
+ if err != nil {
390
+ return err
391
+ } else if v , ok := d .GetOkExists ("properties" ); ! isEmptyValue (reflect .ValueOf (v )) && (ok || ! reflect .DeepEqual (v , propertiesProp )) {
392
+ obj ["properties" ] = propertiesProp
393
+ }
349
394
350
395
obj , err = resourceApigeeOrganizationEncoder (d , meta , obj )
351
396
if err != nil {
@@ -497,6 +542,46 @@ func flattenApigeeOrganizationRuntimeDatabaseEncryptionKeyName(v interface{}, d
497
542
return v
498
543
}
499
544
545
+ func flattenApigeeOrganizationProperties (v interface {}, d * schema.ResourceData , config * Config ) interface {} {
546
+ if v == nil {
547
+ return nil
548
+ }
549
+ original := v .(map [string ]interface {})
550
+ if len (original ) == 0 {
551
+ return nil
552
+ }
553
+ transformed := make (map [string ]interface {})
554
+ transformed ["property" ] =
555
+ flattenApigeeOrganizationPropertiesProperty (original ["property" ], d , config )
556
+ return []interface {}{transformed }
557
+ }
558
+ func flattenApigeeOrganizationPropertiesProperty (v interface {}, d * schema.ResourceData , config * Config ) interface {} {
559
+ if v == nil {
560
+ return v
561
+ }
562
+ l := v .([]interface {})
563
+ transformed := make ([]interface {}, 0 , len (l ))
564
+ for _ , raw := range l {
565
+ original := raw .(map [string ]interface {})
566
+ if len (original ) < 1 {
567
+ // Do not include empty json objects coming back from the api
568
+ continue
569
+ }
570
+ transformed = append (transformed , map [string ]interface {}{
571
+ "name" : flattenApigeeOrganizationPropertiesPropertyName (original ["name" ], d , config ),
572
+ "value" : flattenApigeeOrganizationPropertiesPropertyValue (original ["value" ], d , config ),
573
+ })
574
+ }
575
+ return transformed
576
+ }
577
+ func flattenApigeeOrganizationPropertiesPropertyName (v interface {}, d * schema.ResourceData , config * Config ) interface {} {
578
+ return v
579
+ }
580
+
581
+ func flattenApigeeOrganizationPropertiesPropertyValue (v interface {}, d * schema.ResourceData , config * Config ) interface {} {
582
+ return v
583
+ }
584
+
500
585
func expandApigeeOrganizationDisplayName (v interface {}, d TerraformResourceData , config * Config ) (interface {}, error ) {
501
586
return v , nil
502
587
}
@@ -525,6 +610,62 @@ func expandApigeeOrganizationRuntimeDatabaseEncryptionKeyName(v interface{}, d T
525
610
return v , nil
526
611
}
527
612
613
+ func expandApigeeOrganizationProperties (v interface {}, d TerraformResourceData , config * Config ) (interface {}, error ) {
614
+ l := v .([]interface {})
615
+ if len (l ) == 0 || l [0 ] == nil {
616
+ return nil , nil
617
+ }
618
+ raw := l [0 ]
619
+ original := raw .(map [string ]interface {})
620
+ transformed := make (map [string ]interface {})
621
+
622
+ transformedProperty , err := expandApigeeOrganizationPropertiesProperty (original ["property" ], d , config )
623
+ if err != nil {
624
+ return nil , err
625
+ } else if val := reflect .ValueOf (transformedProperty ); val .IsValid () && ! isEmptyValue (val ) {
626
+ transformed ["property" ] = transformedProperty
627
+ }
628
+
629
+ return transformed , nil
630
+ }
631
+
632
+ func expandApigeeOrganizationPropertiesProperty (v interface {}, d TerraformResourceData , config * Config ) (interface {}, error ) {
633
+ l := v .([]interface {})
634
+ req := make ([]interface {}, 0 , len (l ))
635
+ for _ , raw := range l {
636
+ if raw == nil {
637
+ continue
638
+ }
639
+ original := raw .(map [string ]interface {})
640
+ transformed := make (map [string ]interface {})
641
+
642
+ transformedName , err := expandApigeeOrganizationPropertiesPropertyName (original ["name" ], d , config )
643
+ if err != nil {
644
+ return nil , err
645
+ } else if val := reflect .ValueOf (transformedName ); val .IsValid () && ! isEmptyValue (val ) {
646
+ transformed ["name" ] = transformedName
647
+ }
648
+
649
+ transformedValue , err := expandApigeeOrganizationPropertiesPropertyValue (original ["value" ], d , config )
650
+ if err != nil {
651
+ return nil , err
652
+ } else if val := reflect .ValueOf (transformedValue ); val .IsValid () && ! isEmptyValue (val ) {
653
+ transformed ["value" ] = transformedValue
654
+ }
655
+
656
+ req = append (req , transformed )
657
+ }
658
+ return req , nil
659
+ }
660
+
661
+ func expandApigeeOrganizationPropertiesPropertyName (v interface {}, d TerraformResourceData , config * Config ) (interface {}, error ) {
662
+ return v , nil
663
+ }
664
+
665
+ func expandApigeeOrganizationPropertiesPropertyValue (v interface {}, d TerraformResourceData , config * Config ) (interface {}, error ) {
666
+ return v , nil
667
+ }
668
+
528
669
func resourceApigeeOrganizationEncoder (d * schema.ResourceData , meta interface {}, obj map [string ]interface {}) (map [string ]interface {}, error ) {
529
670
obj ["name" ] = d .Get ("project_id" ).(string )
530
671
return obj , nil
0 commit comments