@@ -78,6 +78,36 @@ Valid only when 'RuntimeType' is set to CLOUD. The value can be updated only whe
7878 Optional : true ,
7979 Description : `The display name of the Apigee organization.` ,
8080 },
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+ },
81111 "retention" : {
82112 Type : schema .TypeString ,
83113 Optional : true ,
@@ -177,6 +207,12 @@ func resourceApigeeOrganizationCreate(d *schema.ResourceData, meta interface{})
177207 } else if v , ok := d .GetOkExists ("runtime_database_encryption_key_name" ); ! isEmptyValue (reflect .ValueOf (runtimeDatabaseEncryptionKeyNameProp )) && (ok || ! reflect .DeepEqual (v , runtimeDatabaseEncryptionKeyNameProp )) {
178208 obj ["runtimeDatabaseEncryptionKeyName" ] = runtimeDatabaseEncryptionKeyNameProp
179209 }
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+ }
180216
181217 obj , err = resourceApigeeOrganizationEncoder (d , meta , obj )
182218 if err != nil {
@@ -290,6 +326,9 @@ func resourceApigeeOrganizationRead(d *schema.ResourceData, meta interface{}) er
290326 if err := d .Set ("runtime_database_encryption_key_name" , flattenApigeeOrganizationRuntimeDatabaseEncryptionKeyName (res ["runtimeDatabaseEncryptionKeyName" ], d , config )); err != nil {
291327 return fmt .Errorf ("Error reading Organization: %s" , err )
292328 }
329+ if err := d .Set ("properties" , flattenApigeeOrganizationProperties (res ["properties" ], d , config )); err != nil {
330+ return fmt .Errorf ("Error reading Organization: %s" , err )
331+ }
293332
294333 return nil
295334}
@@ -346,6 +385,12 @@ func resourceApigeeOrganizationUpdate(d *schema.ResourceData, meta interface{})
346385 } else if v , ok := d .GetOkExists ("runtime_database_encryption_key_name" ); ! isEmptyValue (reflect .ValueOf (v )) && (ok || ! reflect .DeepEqual (v , runtimeDatabaseEncryptionKeyNameProp )) {
347386 obj ["runtimeDatabaseEncryptionKeyName" ] = runtimeDatabaseEncryptionKeyNameProp
348387 }
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+ }
349394
350395 obj , err = resourceApigeeOrganizationEncoder (d , meta , obj )
351396 if err != nil {
@@ -497,6 +542,46 @@ func flattenApigeeOrganizationRuntimeDatabaseEncryptionKeyName(v interface{}, d
497542 return v
498543}
499544
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+
500585func expandApigeeOrganizationDisplayName (v interface {}, d TerraformResourceData , config * Config ) (interface {}, error ) {
501586 return v , nil
502587}
@@ -525,6 +610,62 @@ func expandApigeeOrganizationRuntimeDatabaseEncryptionKeyName(v interface{}, d T
525610 return v , nil
526611}
527612
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+
528669func resourceApigeeOrganizationEncoder (d * schema.ResourceData , meta interface {}, obj map [string ]interface {}) (map [string ]interface {}, error ) {
529670 obj ["name" ] = d .Get ("project_id" ).(string )
530671 return obj , nil
0 commit comments