@@ -112,6 +112,43 @@ supported asset types.`,
112112 Type : schema .TypeString ,
113113 },
114114 },
115+ "condition" : {
116+ Type : schema .TypeList ,
117+ Optional : true ,
118+ Description : `A condition which determines whether an asset update should be published. If specified, an asset
119+ will be returned only when the expression evaluates to true. When set, expression field
120+ must be a valid CEL expression on a TemporalAsset with name temporal_asset. Example: a Feed with
121+ expression "temporal_asset.deleted == true" will only publish Asset deletions. Other fields of
122+ condition are optional.` ,
123+ MaxItems : 1 ,
124+ Elem : & schema.Resource {
125+ Schema : map [string ]* schema.Schema {
126+ "expression" : {
127+ Type : schema .TypeString ,
128+ Required : true ,
129+ Description : `Textual representation of an expression in Common Expression Language syntax.` ,
130+ },
131+ "description" : {
132+ Type : schema .TypeString ,
133+ Optional : true ,
134+ Description : `Description of the expression. This is a longer text which describes the expression,
135+ e.g. when hovered over it in a UI.` ,
136+ },
137+ "location" : {
138+ Type : schema .TypeString ,
139+ Optional : true ,
140+ Description : `String indicating the location of the expression for error reporting, e.g. a file
141+ name and a position in the file.` ,
142+ },
143+ "title" : {
144+ Type : schema .TypeString ,
145+ Optional : true ,
146+ Description : `Title for the expression, i.e. a short string describing its purpose.
147+ This can be used e.g. in UIs which allow to enter the expression.` ,
148+ },
149+ },
150+ },
151+ },
115152 "content_type" : {
116153 Type : schema .TypeString ,
117154 Optional : true ,
@@ -165,6 +202,12 @@ func resourceCloudAssetFolderFeedCreate(d *schema.ResourceData, meta interface{}
165202 } else if v , ok := d .GetOkExists ("feed_output_config" ); ! isEmptyValue (reflect .ValueOf (feedOutputConfigProp )) && (ok || ! reflect .DeepEqual (v , feedOutputConfigProp )) {
166203 obj ["feedOutputConfig" ] = feedOutputConfigProp
167204 }
205+ conditionProp , err := expandCloudAssetFolderFeedCondition (d .Get ("condition" ), d , config )
206+ if err != nil {
207+ return err
208+ } else if v , ok := d .GetOkExists ("condition" ); ! isEmptyValue (reflect .ValueOf (conditionProp )) && (ok || ! reflect .DeepEqual (v , conditionProp )) {
209+ obj ["condition" ] = conditionProp
210+ }
168211
169212 obj , err = resourceCloudAssetFolderFeedEncoder (d , meta , obj )
170213 if err != nil {
@@ -260,6 +303,9 @@ func resourceCloudAssetFolderFeedRead(d *schema.ResourceData, meta interface{})
260303 if err := d .Set ("feed_output_config" , flattenCloudAssetFolderFeedFeedOutputConfig (res ["feedOutputConfig" ], d , config )); err != nil {
261304 return fmt .Errorf ("Error reading FolderFeed: %s" , err )
262305 }
306+ if err := d .Set ("condition" , flattenCloudAssetFolderFeedCondition (res ["condition" ], d , config )); err != nil {
307+ return fmt .Errorf ("Error reading FolderFeed: %s" , err )
308+ }
263309
264310 return nil
265311}
@@ -298,6 +344,12 @@ func resourceCloudAssetFolderFeedUpdate(d *schema.ResourceData, meta interface{}
298344 } else if v , ok := d .GetOkExists ("feed_output_config" ); ! isEmptyValue (reflect .ValueOf (v )) && (ok || ! reflect .DeepEqual (v , feedOutputConfigProp )) {
299345 obj ["feedOutputConfig" ] = feedOutputConfigProp
300346 }
347+ conditionProp , err := expandCloudAssetFolderFeedCondition (d .Get ("condition" ), d , config )
348+ if err != nil {
349+ return err
350+ } else if v , ok := d .GetOkExists ("condition" ); ! isEmptyValue (reflect .ValueOf (v )) && (ok || ! reflect .DeepEqual (v , conditionProp )) {
351+ obj ["condition" ] = conditionProp
352+ }
301353
302354 obj , err = resourceCloudAssetFolderFeedEncoder (d , meta , obj )
303355 if err != nil {
@@ -327,6 +379,10 @@ func resourceCloudAssetFolderFeedUpdate(d *schema.ResourceData, meta interface{}
327379 if d .HasChange ("feed_output_config" ) {
328380 updateMask = append (updateMask , "feedOutputConfig" )
329381 }
382+
383+ if d .HasChange ("condition" ) {
384+ updateMask = append (updateMask , "condition" )
385+ }
330386 // updateMask is a URL parameter but not present in the schema, so replaceVars
331387 // won't set it
332388 url , err = addQueryParams (url , map [string ]string {"updateMask" : strings .Join (updateMask , "," )})
@@ -446,6 +502,41 @@ func flattenCloudAssetFolderFeedFeedOutputConfigPubsubDestinationTopic(v interfa
446502 return v
447503}
448504
505+ func flattenCloudAssetFolderFeedCondition (v interface {}, d * schema.ResourceData , config * Config ) interface {} {
506+ if v == nil {
507+ return nil
508+ }
509+ original := v .(map [string ]interface {})
510+ if len (original ) == 0 {
511+ return nil
512+ }
513+ transformed := make (map [string ]interface {})
514+ transformed ["expression" ] =
515+ flattenCloudAssetFolderFeedConditionExpression (original ["expression" ], d , config )
516+ transformed ["title" ] =
517+ flattenCloudAssetFolderFeedConditionTitle (original ["title" ], d , config )
518+ transformed ["description" ] =
519+ flattenCloudAssetFolderFeedConditionDescription (original ["description" ], d , config )
520+ transformed ["location" ] =
521+ flattenCloudAssetFolderFeedConditionLocation (original ["location" ], d , config )
522+ return []interface {}{transformed }
523+ }
524+ func flattenCloudAssetFolderFeedConditionExpression (v interface {}, d * schema.ResourceData , config * Config ) interface {} {
525+ return v
526+ }
527+
528+ func flattenCloudAssetFolderFeedConditionTitle (v interface {}, d * schema.ResourceData , config * Config ) interface {} {
529+ return v
530+ }
531+
532+ func flattenCloudAssetFolderFeedConditionDescription (v interface {}, d * schema.ResourceData , config * Config ) interface {} {
533+ return v
534+ }
535+
536+ func flattenCloudAssetFolderFeedConditionLocation (v interface {}, d * schema.ResourceData , config * Config ) interface {} {
537+ return v
538+ }
539+
449540func expandCloudAssetFolderFeedAssetNames (v interface {}, d TerraformResourceData , config * Config ) (interface {}, error ) {
450541 return v , nil
451542}
@@ -500,6 +591,62 @@ func expandCloudAssetFolderFeedFeedOutputConfigPubsubDestinationTopic(v interfac
500591 return v , nil
501592}
502593
594+ func expandCloudAssetFolderFeedCondition (v interface {}, d TerraformResourceData , config * Config ) (interface {}, error ) {
595+ l := v .([]interface {})
596+ if len (l ) == 0 || l [0 ] == nil {
597+ return nil , nil
598+ }
599+ raw := l [0 ]
600+ original := raw .(map [string ]interface {})
601+ transformed := make (map [string ]interface {})
602+
603+ transformedExpression , err := expandCloudAssetFolderFeedConditionExpression (original ["expression" ], d , config )
604+ if err != nil {
605+ return nil , err
606+ } else if val := reflect .ValueOf (transformedExpression ); val .IsValid () && ! isEmptyValue (val ) {
607+ transformed ["expression" ] = transformedExpression
608+ }
609+
610+ transformedTitle , err := expandCloudAssetFolderFeedConditionTitle (original ["title" ], d , config )
611+ if err != nil {
612+ return nil , err
613+ } else if val := reflect .ValueOf (transformedTitle ); val .IsValid () && ! isEmptyValue (val ) {
614+ transformed ["title" ] = transformedTitle
615+ }
616+
617+ transformedDescription , err := expandCloudAssetFolderFeedConditionDescription (original ["description" ], d , config )
618+ if err != nil {
619+ return nil , err
620+ } else if val := reflect .ValueOf (transformedDescription ); val .IsValid () && ! isEmptyValue (val ) {
621+ transformed ["description" ] = transformedDescription
622+ }
623+
624+ transformedLocation , err := expandCloudAssetFolderFeedConditionLocation (original ["location" ], d , config )
625+ if err != nil {
626+ return nil , err
627+ } else if val := reflect .ValueOf (transformedLocation ); val .IsValid () && ! isEmptyValue (val ) {
628+ transformed ["location" ] = transformedLocation
629+ }
630+
631+ return transformed , nil
632+ }
633+
634+ func expandCloudAssetFolderFeedConditionExpression (v interface {}, d TerraformResourceData , config * Config ) (interface {}, error ) {
635+ return v , nil
636+ }
637+
638+ func expandCloudAssetFolderFeedConditionTitle (v interface {}, d TerraformResourceData , config * Config ) (interface {}, error ) {
639+ return v , nil
640+ }
641+
642+ func expandCloudAssetFolderFeedConditionDescription (v interface {}, d TerraformResourceData , config * Config ) (interface {}, error ) {
643+ return v , nil
644+ }
645+
646+ func expandCloudAssetFolderFeedConditionLocation (v interface {}, d TerraformResourceData , config * Config ) (interface {}, error ) {
647+ return v , nil
648+ }
649+
503650func resourceCloudAssetFolderFeedEncoder (d * schema.ResourceData , meta interface {}, obj map [string ]interface {}) (map [string ]interface {}, error ) {
504651 // Remove the "folders/" prefix from the folder ID
505652 if folder , ok := d .GetOkExists ("folder" ); ok {
0 commit comments