Skip to content

Commit afa4de5

Browse files
ankitgoyal0301Dawid212
authored andcommitted
Update create_url updateMask for google_chronicle_rule_deployment res… (GoogleCloudPlatform#13053)
1 parent 5783809 commit afa4de5

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

mmv1/products/chronicle/RuleDeployment.yaml

+4-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ references:
2121
api: 'https://cloud.google.com/chronicle/docs/reference/rest/v1alpha/RuleDeployment'
2222
base_url: projects/{{project}}/locations/{{location}}/instances/{{instance}}/rules/{{rules}}/deployments
2323
self_link: projects/{{project}}/locations/{{location}}/instances/{{instance}}/rules/{{rule}}/deployment
24-
create_url: projects/{{project}}/locations/{{location}}/instances/{{instance}}/rules/{{rule}}/deployment?updateMask=enabled,alerting,archived,runFrequency
24+
create_url: projects/{{project}}/locations/{{location}}/instances/{{instance}}/rules/{{rule}}/deployment
2525
id_format: projects/{{project}}/locations/{{location}}/instances/{{instance}}/rules/{{rule}}/deployment
2626
import_format:
2727
- projects/{{project}}/locations/{{location}}/instances/{{instance}}/rules/{{rule}}/deployment
@@ -31,6 +31,9 @@ update_mask: true
3131
exclude_delete: true
3232
autogen_status: UnVsZURlcGxveW1lbnQ=
3333

34+
custom_code:
35+
pre_create: 'templates/terraform/pre_create/chronicle_rule_deployment.go.tmpl'
36+
3437
examples:
3538
- name: 'chronicle_ruledeployment_basic'
3639
primary_resource_id: 'example'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Read the config and update the mask only if set by the user in terraform code
2+
3+
params := []string{"enabled", "alerting", "archived", "run_frequency"}
4+
var existingParams []string
5+
6+
// Populating existingParams with the params that exist
7+
for _, param := range params {
8+
if _, ok := d.GetOk(param); ok {
9+
existingParams = append(existingParams, param)
10+
}
11+
}
12+
13+
// Updating the url to have updateMask
14+
url, err = transport_tpg.AddQueryParams(url, map[string]string{"updateMask": strings.Join(existingParams, ",")})
15+
if err != nil {
16+
return err
17+
}

0 commit comments

Comments
 (0)