diff --git a/.changelog/8090.txt b/.changelog/8090.txt new file mode 100644 index 00000000000..156d1eb4dd4 --- /dev/null +++ b/.changelog/8090.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +dlp: added multiple `sensitivity_score` field to `google_data_loss_prevention_inspect_template` resource +``` diff --git a/google/resource_data_loss_prevention_inspect_template_test.go b/google/resource_data_loss_prevention_inspect_template_test.go index deb95794447..d433fedcf50 100644 --- a/google/resource_data_loss_prevention_inspect_template_test.go +++ b/google/resource_data_loss_prevention_inspect_template_test.go @@ -247,12 +247,12 @@ func TestAccDataLossPreventionInspectTemplate_dlpInspectTemplate_withInfoTypesVe t.Parallel() context := map[string]interface{}{ - "project": GetTestProjectFromEnv(), + "project": acctest.GetTestProjectFromEnv(), "random_suffix": RandString(t, 10), } VcrTest(t, resource.TestCase{ - PreCheck: func() { AccTestPreCheck(t) }, + PreCheck: func() { acctest.AccTestPreCheck(t) }, ProtoV5ProviderFactories: ProtoV5ProviderFactories(t), CheckDestroy: testAccCheckDataLossPreventionInspectTemplateDestroyProducer(t), Steps: []resource.TestStep{ @@ -543,12 +543,12 @@ func TestAccDataLossPreventionInspectTemplate_dlpInspectTemplate_withExcludeByHo t.Parallel() context := map[string]interface{}{ - "project": GetTestProjectFromEnv(), + "project": acctest.GetTestProjectFromEnv(), "random_suffix": RandString(t, 10), } VcrTest(t, resource.TestCase{ - PreCheck: func() { AccTestPreCheck(t) }, + PreCheck: func() { acctest.AccTestPreCheck(t) }, ProtoV5ProviderFactories: ProtoV5ProviderFactories(t), CheckDestroy: testAccCheckDataLossPreventionInspectTemplateDestroyProducer(t), Steps: []resource.TestStep{ @@ -862,3 +862,379 @@ resource "google_data_loss_prevention_inspect_template" "basic" { } `, context) } + +func TestAccDataLossPreventionInspectTemplate_dlpInspectTemplate_withSensitivityScore(t *testing.T) { + t.Parallel() + + context := map[string]interface{}{ + "project": acctest.GetTestProjectFromEnv(), + } + + VcrTest(t, resource.TestCase{ + PreCheck: func() { acctest.AccTestPreCheck(t) }, + ProtoV5ProviderFactories: ProtoV5ProviderFactories(t), + CheckDestroy: testAccCheckDataLossPreventionInspectTemplateDestroyProducer(t), + Steps: []resource.TestStep{ + { + Config: testAccDataLossPreventionInspectTemplate_dlpInspectTemplate_withSensitivityScoreBasic(context), + }, + { + ResourceName: "google_data_loss_prevention_inspect_template.basic", + ImportState: true, + ImportStateVerify: true, + }, + { + Config: testAccDataLossPreventionInspectTemplate_dlpInspectTemplate_withSensitivityScoreUpdate(context), + }, + { + ResourceName: "google_data_loss_prevention_inspect_template.basic", + ImportState: true, + ImportStateVerify: true, + }, + { + Config: testAccDataLossPreventionInspectTemplate_dlpInspectTemplate_withSensitivityScoreUpdate2(context), + }, + { + ResourceName: "google_data_loss_prevention_inspect_template.basic", + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +func testAccDataLossPreventionInspectTemplate_dlpInspectTemplate_withSensitivityScoreBasic(context map[string]interface{}) string { + return Nprintf(` +resource "google_data_loss_prevention_inspect_template" "basic" { + parent = "projects/%{project}" + description = "Description" + display_name = "Display" + + inspect_config { + custom_info_types { + info_type { + name = "MY_CUSTOM_TYPE" + sensitivity_score { + score = "SENSITIVITY_MODERATE" + } + } + sensitivity_score { + score = "SENSITIVITY_HIGH" + } + surrogate_type {} + } + info_types { + name = "EMAIL_ADDRESS" + sensitivity_score { + score = "SENSITIVITY_MODERATE" + } + } + info_types { + name = "PERSON_NAME" + version = "latest" + } + info_types { + name = "LAST_NAME" + } + info_types { + name = "DOMAIN_NAME" + } + info_types { + name = "PHONE_NUMBER" + } + info_types { + name = "FIRST_NAME" + } + + min_likelihood = "UNLIKELY" + rule_set { + info_types { + name = "EMAIL_ADDRESS" + } + rules { + exclusion_rule { + exclude_info_types { + info_types { + name = "LAST_NAME" + sensitivity_score { + score = "SENSITIVITY_LOW" + } + } + } + matching_type = "MATCHING_TYPE_FULL_MATCH" + } + } + } + rule_set { + info_types { + name = "EMAIL_ADDRESS" + sensitivity_score { + score = "SENSITIVITY_LOW" + } + } + info_types { + name = "DOMAIN_NAME" + } + info_types { + name = "PHONE_NUMBER" + } + info_types { + name = "PERSON_NAME" + } + info_types { + name = "FIRST_NAME" + } + rules { + exclusion_rule { + dictionary { + word_list { + words = ["TEST"] + } + } + matching_type = "MATCHING_TYPE_PARTIAL_MATCH" + } + } + } + + limits { + max_findings_per_item = 10 + max_findings_per_request = 50 + max_findings_per_info_type { + max_findings = "75" + info_type { + name = "PERSON_NAME" + sensitivity_score { + score = "SENSITIVITY_HIGH" + } + } + } + max_findings_per_info_type { + max_findings = "80" + info_type { + name = "LAST_NAME" + } + } + } + } +} +`, context) +} + +func testAccDataLossPreventionInspectTemplate_dlpInspectTemplate_withSensitivityScoreUpdate(context map[string]interface{}) string { + return Nprintf(` +resource "google_data_loss_prevention_inspect_template" "basic" { + parent = "projects/%{project}" + description = "Description" + display_name = "Display" + + inspect_config { + custom_info_types { + info_type { + name = "MY_CUSTOM_TYPE" + } + sensitivity_score { + score = "SENSITIVITY_LOW" + } + surrogate_type {} + } + info_types { + name = "EMAIL_ADDRESS" + sensitivity_score { + score = "SENSITIVITY_LOW" + } + } + info_types { + name = "PERSON_NAME" + version = "latest" + } + info_types { + name = "LAST_NAME" + } + info_types { + name = "DOMAIN_NAME" + } + info_types { + name = "PHONE_NUMBER" + } + info_types { + name = "FIRST_NAME" + } + + min_likelihood = "UNLIKELY" + rule_set { + info_types { + name = "EMAIL_ADDRESS" + } + rules { + exclusion_rule { + exclude_info_types { + info_types { + name = "LAST_NAME" + } + } + matching_type = "MATCHING_TYPE_FULL_MATCH" + } + } + } + rule_set { + info_types { + name = "EMAIL_ADDRESS" + } + info_types { + name = "DOMAIN_NAME" + } + info_types { + name = "PHONE_NUMBER" + } + info_types { + name = "PERSON_NAME" + } + info_types { + name = "FIRST_NAME" + } + rules { + exclusion_rule { + dictionary { + word_list { + words = ["TEST"] + } + } + matching_type = "MATCHING_TYPE_PARTIAL_MATCH" + } + } + } + + limits { + max_findings_per_item = 10 + max_findings_per_request = 50 + max_findings_per_info_type { + max_findings = "75" + info_type { + name = "PERSON_NAME" + sensitivity_score { + score = "SENSITIVITY_MODERATE" + } + } + } + max_findings_per_info_type { + max_findings = "80" + info_type { + name = "LAST_NAME" + } + } + } + } +} +`, context) +} + +func testAccDataLossPreventionInspectTemplate_dlpInspectTemplate_withSensitivityScoreUpdate2(context map[string]interface{}) string { + return Nprintf(` +resource "google_data_loss_prevention_inspect_template" "basic" { + parent = "projects/%{project}" + description = "Description" + display_name = "Display" + + inspect_config { + custom_info_types { + info_type { + name = "MY_CUSTOM_TYPE" + sensitivity_score { + score = "SENSITIVITY_LOW" + } + } + surrogate_type {} + } + info_types { + name = "EMAIL_ADDRESS" + sensitivity_score { + score = "SENSITIVITY_HIGH" + } + } + info_types { + name = "PERSON_NAME" + version = "latest" + } + info_types { + name = "LAST_NAME" + } + info_types { + name = "DOMAIN_NAME" + } + info_types { + name = "PHONE_NUMBER" + } + info_types { + name = "FIRST_NAME" + } + + min_likelihood = "UNLIKELY" + rule_set { + info_types { + name = "EMAIL_ADDRESS" + } + rules { + exclusion_rule { + exclude_info_types { + info_types { + name = "LAST_NAME" + sensitivity_score { + score = "SENSITIVITY_HIGH" + } + } + } + matching_type = "MATCHING_TYPE_FULL_MATCH" + } + } + } + rule_set { + info_types { + name = "EMAIL_ADDRESS" + } + info_types { + name = "DOMAIN_NAME" + } + info_types { + name = "PHONE_NUMBER" + } + info_types { + name = "PERSON_NAME" + } + info_types { + name = "FIRST_NAME" + } + rules { + exclusion_rule { + dictionary { + word_list { + words = ["TEST"] + } + } + matching_type = "MATCHING_TYPE_PARTIAL_MATCH" + } + } + } + + limits { + max_findings_per_item = 10 + max_findings_per_request = 50 + max_findings_per_info_type { + max_findings = "75" + info_type { + name = "PERSON_NAME" + sensitivity_score { + score = "SENSITIVITY_LOW" + } + } + } + max_findings_per_info_type { + max_findings = "80" + info_type { + name = "LAST_NAME" + } + } + } + } +} +`, context) +} diff --git a/google/services/datalossprevention/resource_data_loss_prevention_inspect_template.go b/google/services/datalossprevention/resource_data_loss_prevention_inspect_template.go index bb76c1ffed4..b242c3d36ed 100644 --- a/google/services/datalossprevention/resource_data_loss_prevention_inspect_template.go +++ b/google/services/datalossprevention/resource_data_loss_prevention_inspect_template.go @@ -108,6 +108,22 @@ treated as a custom info type.`, Description: `Name of the information type. Either a name of your choosing when creating a CustomInfoType, or one of the names listed at https://cloud.google.com/dlp/docs/infotypes-reference when specifying a built-in type.`, }, + "sensitivity_score": { + Type: schema.TypeList, + Optional: true, + Description: `Optional custom sensitivity for this InfoType. This only applies to data profiling.`, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "score": { + Type: schema.TypeString, + Required: true, + ValidateFunc: verify.ValidateEnum([]string{"SENSITIVITY_LOW", "SENSITIVITY_MODERATE", "SENSITIVITY_HIGH"}), + Description: `The sensitivity score applied to the resource. Possible values: ["SENSITIVITY_LOW", "SENSITIVITY_MODERATE", "SENSITIVITY_HIGH"]`, + }, + }, + }, + }, "version": { Type: schema.TypeString, Optional: true, @@ -200,6 +216,22 @@ Its syntax (https://github.com/google/re2/wiki/Syntax) can be found under the go }, }, }, + "sensitivity_score": { + Type: schema.TypeList, + Optional: true, + Description: `Optional custom sensitivity for this InfoType. This only applies to data profiling.`, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "score": { + Type: schema.TypeString, + Required: true, + ValidateFunc: verify.ValidateEnum([]string{"SENSITIVITY_LOW", "SENSITIVITY_MODERATE", "SENSITIVITY_HIGH"}), + Description: `The sensitivity score applied to the resource. Possible values: ["SENSITIVITY_LOW", "SENSITIVITY_MODERATE", "SENSITIVITY_HIGH"]`, + }, + }, + }, + }, "stored_type": { Type: schema.TypeList, Optional: true, @@ -256,6 +288,22 @@ By default this may be all types, but may change over time as detectors are upda Description: `Name of the information type. Either a name of your choosing when creating a CustomInfoType, or one of the names listed at https://cloud.google.com/dlp/docs/infotypes-reference when specifying a built-in type.`, }, + "sensitivity_score": { + Type: schema.TypeList, + Optional: true, + Description: `Optional custom sensitivity for this InfoType. This only applies to data profiling.`, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "score": { + Type: schema.TypeString, + Required: true, + ValidateFunc: verify.ValidateEnum([]string{"SENSITIVITY_LOW", "SENSITIVITY_MODERATE", "SENSITIVITY_HIGH"}), + Description: `The sensitivity score applied to the resource. Possible values: ["SENSITIVITY_LOW", "SENSITIVITY_MODERATE", "SENSITIVITY_HIGH"]`, + }, + }, + }, + }, "version": { Type: schema.TypeString, Optional: true, @@ -302,6 +350,22 @@ specified in another InfoTypeLimit.`, Description: `Name of the information type. Either a name of your choosing when creating a CustomInfoType, or one of the names listed at https://cloud.google.com/dlp/docs/infotypes-reference when specifying a built-in type.`, }, + "sensitivity_score": { + Type: schema.TypeList, + Optional: true, + Description: `Optional custom sensitivity for this InfoType. This only applies to data profiling.`, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "score": { + Type: schema.TypeString, + Required: true, + ValidateFunc: verify.ValidateEnum([]string{"SENSITIVITY_LOW", "SENSITIVITY_MODERATE", "SENSITIVITY_HIGH"}), + Description: `The sensitivity score applied to the resource. Possible values: ["SENSITIVITY_LOW", "SENSITIVITY_MODERATE", "SENSITIVITY_HIGH"]`, + }, + }, + }, + }, "version": { Type: schema.TypeString, Optional: true, @@ -347,6 +411,22 @@ other rules are executed in the order they are specified for each info type.`, Description: `Name of the information type. Either a name of your choosing when creating a CustomInfoType, or one of the names listed at https://cloud.google.com/dlp/docs/infotypes-reference when specifying a built-in type.`, }, + "sensitivity_score": { + Type: schema.TypeList, + Optional: true, + Description: `Optional custom sensitivity for this InfoType. This only applies to data profiling.`, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "score": { + Type: schema.TypeString, + Required: true, + ValidateFunc: verify.ValidateEnum([]string{"SENSITIVITY_LOW", "SENSITIVITY_MODERATE", "SENSITIVITY_HIGH"}), + Description: `The sensitivity score applied to the resource. Possible values: ["SENSITIVITY_LOW", "SENSITIVITY_MODERATE", "SENSITIVITY_HIGH"]`, + }, + }, + }, + }, "version": { Type: schema.TypeString, Optional: true, @@ -497,6 +577,22 @@ office using the hotword regex '(xxx)', where 'xxx' is the area code in question Description: `Name of the information type. Either a name of your choosing when creating a CustomInfoType, or one of the names listed at https://cloud.google.com/dlp/docs/infotypes-reference when specifying a built-in type.`, }, + "sensitivity_score": { + Type: schema.TypeList, + Optional: true, + Description: `Optional custom sensitivity for this InfoType. This only applies to data profiling.`, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "score": { + Type: schema.TypeString, + Required: true, + ValidateFunc: verify.ValidateEnum([]string{"SENSITIVITY_LOW", "SENSITIVITY_MODERATE", "SENSITIVITY_HIGH"}), + Description: `The sensitivity score applied to the resource. Possible values: ["SENSITIVITY_LOW", "SENSITIVITY_MODERATE", "SENSITIVITY_HIGH"]`, + }, + }, + }, + }, "version": { Type: schema.TypeString, Optional: true, @@ -1074,6 +1170,8 @@ func flattenDataLossPreventionInspectTemplateInspectConfigLimitsMaxFindingsPerIn flattenDataLossPreventionInspectTemplateInspectConfigLimitsMaxFindingsPerInfoTypeInfoTypeName(original["name"], d, config) transformed["version"] = flattenDataLossPreventionInspectTemplateInspectConfigLimitsMaxFindingsPerInfoTypeInfoTypeVersion(original["version"], d, config) + transformed["sensitivity_score"] = + flattenDataLossPreventionInspectTemplateInspectConfigLimitsMaxFindingsPerInfoTypeInfoTypeSensitivityScore(original["sensitivityScore"], d, config) return []interface{}{transformed} } func flattenDataLossPreventionInspectTemplateInspectConfigLimitsMaxFindingsPerInfoTypeInfoTypeName(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { @@ -1084,6 +1182,23 @@ func flattenDataLossPreventionInspectTemplateInspectConfigLimitsMaxFindingsPerIn return v } +func flattenDataLossPreventionInspectTemplateInspectConfigLimitsMaxFindingsPerInfoTypeInfoTypeSensitivityScore(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { + if v == nil { + return nil + } + original := v.(map[string]interface{}) + if len(original) == 0 { + return nil + } + transformed := make(map[string]interface{}) + transformed["score"] = + flattenDataLossPreventionInspectTemplateInspectConfigLimitsMaxFindingsPerInfoTypeInfoTypeSensitivityScoreScore(original["score"], d, config) + return []interface{}{transformed} +} +func flattenDataLossPreventionInspectTemplateInspectConfigLimitsMaxFindingsPerInfoTypeInfoTypeSensitivityScoreScore(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { + return v +} + func flattenDataLossPreventionInspectTemplateInspectConfigLimitsMaxFindingsPerInfoTypeMaxFindings(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { // Handles the string fixed64 format if strVal, ok := v.(string); ok { @@ -1114,8 +1229,9 @@ func flattenDataLossPreventionInspectTemplateInspectConfigInfoTypes(v interface{ continue } transformed = append(transformed, map[string]interface{}{ - "name": flattenDataLossPreventionInspectTemplateInspectConfigInfoTypesName(original["name"], d, config), - "version": flattenDataLossPreventionInspectTemplateInspectConfigInfoTypesVersion(original["version"], d, config), + "name": flattenDataLossPreventionInspectTemplateInspectConfigInfoTypesName(original["name"], d, config), + "version": flattenDataLossPreventionInspectTemplateInspectConfigInfoTypesVersion(original["version"], d, config), + "sensitivity_score": flattenDataLossPreventionInspectTemplateInspectConfigInfoTypesSensitivityScore(original["sensitivityScore"], d, config), }) } return transformed @@ -1128,6 +1244,23 @@ func flattenDataLossPreventionInspectTemplateInspectConfigInfoTypesVersion(v int return v } +func flattenDataLossPreventionInspectTemplateInspectConfigInfoTypesSensitivityScore(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { + if v == nil { + return nil + } + original := v.(map[string]interface{}) + if len(original) == 0 { + return nil + } + transformed := make(map[string]interface{}) + transformed["score"] = + flattenDataLossPreventionInspectTemplateInspectConfigInfoTypesSensitivityScoreScore(original["score"], d, config) + return []interface{}{transformed} +} +func flattenDataLossPreventionInspectTemplateInspectConfigInfoTypesSensitivityScoreScore(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { + return v +} + func flattenDataLossPreventionInspectTemplateInspectConfigContentOptions(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { return v } @@ -1164,8 +1297,9 @@ func flattenDataLossPreventionInspectTemplateInspectConfigRuleSetInfoTypes(v int continue } transformed = append(transformed, map[string]interface{}{ - "name": flattenDataLossPreventionInspectTemplateInspectConfigRuleSetInfoTypesName(original["name"], d, config), - "version": flattenDataLossPreventionInspectTemplateInspectConfigRuleSetInfoTypesVersion(original["version"], d, config), + "name": flattenDataLossPreventionInspectTemplateInspectConfigRuleSetInfoTypesName(original["name"], d, config), + "version": flattenDataLossPreventionInspectTemplateInspectConfigRuleSetInfoTypesVersion(original["version"], d, config), + "sensitivity_score": flattenDataLossPreventionInspectTemplateInspectConfigRuleSetInfoTypesSensitivityScore(original["sensitivityScore"], d, config), }) } return transformed @@ -1178,6 +1312,23 @@ func flattenDataLossPreventionInspectTemplateInspectConfigRuleSetInfoTypesVersio return v } +func flattenDataLossPreventionInspectTemplateInspectConfigRuleSetInfoTypesSensitivityScore(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { + if v == nil { + return nil + } + original := v.(map[string]interface{}) + if len(original) == 0 { + return nil + } + transformed := make(map[string]interface{}) + transformed["score"] = + flattenDataLossPreventionInspectTemplateInspectConfigRuleSetInfoTypesSensitivityScoreScore(original["score"], d, config) + return []interface{}{transformed} +} +func flattenDataLossPreventionInspectTemplateInspectConfigRuleSetInfoTypesSensitivityScoreScore(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { + return v +} + func flattenDataLossPreventionInspectTemplateInspectConfigRuleSetRules(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { if v == nil { return v @@ -1445,8 +1596,9 @@ func flattenDataLossPreventionInspectTemplateInspectConfigRuleSetRulesExclusionR continue } transformed = append(transformed, map[string]interface{}{ - "name": flattenDataLossPreventionInspectTemplateInspectConfigRuleSetRulesExclusionRuleExcludeInfoTypesInfoTypesName(original["name"], d, config), - "version": flattenDataLossPreventionInspectTemplateInspectConfigRuleSetRulesExclusionRuleExcludeInfoTypesInfoTypesVersion(original["version"], d, config), + "name": flattenDataLossPreventionInspectTemplateInspectConfigRuleSetRulesExclusionRuleExcludeInfoTypesInfoTypesName(original["name"], d, config), + "version": flattenDataLossPreventionInspectTemplateInspectConfigRuleSetRulesExclusionRuleExcludeInfoTypesInfoTypesVersion(original["version"], d, config), + "sensitivity_score": flattenDataLossPreventionInspectTemplateInspectConfigRuleSetRulesExclusionRuleExcludeInfoTypesInfoTypesSensitivityScore(original["sensitivityScore"], d, config), }) } return transformed @@ -1459,6 +1611,23 @@ func flattenDataLossPreventionInspectTemplateInspectConfigRuleSetRulesExclusionR return v } +func flattenDataLossPreventionInspectTemplateInspectConfigRuleSetRulesExclusionRuleExcludeInfoTypesInfoTypesSensitivityScore(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { + if v == nil { + return nil + } + original := v.(map[string]interface{}) + if len(original) == 0 { + return nil + } + transformed := make(map[string]interface{}) + transformed["score"] = + flattenDataLossPreventionInspectTemplateInspectConfigRuleSetRulesExclusionRuleExcludeInfoTypesInfoTypesSensitivityScoreScore(original["score"], d, config) + return []interface{}{transformed} +} +func flattenDataLossPreventionInspectTemplateInspectConfigRuleSetRulesExclusionRuleExcludeInfoTypesInfoTypesSensitivityScoreScore(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { + return v +} + func flattenDataLossPreventionInspectTemplateInspectConfigRuleSetRulesExclusionRuleExcludeByHotword(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { if v == nil { return nil @@ -1559,13 +1728,14 @@ func flattenDataLossPreventionInspectTemplateInspectConfigCustomInfoTypes(v inte continue } transformed = append(transformed, map[string]interface{}{ - "info_type": flattenDataLossPreventionInspectTemplateInspectConfigCustomInfoTypesInfoType(original["infoType"], d, config), - "likelihood": flattenDataLossPreventionInspectTemplateInspectConfigCustomInfoTypesLikelihood(original["likelihood"], d, config), - "exclusion_type": flattenDataLossPreventionInspectTemplateInspectConfigCustomInfoTypesExclusionType(original["exclusionType"], d, config), - "regex": flattenDataLossPreventionInspectTemplateInspectConfigCustomInfoTypesRegex(original["regex"], d, config), - "dictionary": flattenDataLossPreventionInspectTemplateInspectConfigCustomInfoTypesDictionary(original["dictionary"], d, config), - "surrogate_type": flattenDataLossPreventionInspectTemplateInspectConfigCustomInfoTypesSurrogateType(original["surrogateType"], d, config), - "stored_type": flattenDataLossPreventionInspectTemplateInspectConfigCustomInfoTypesStoredType(original["storedType"], d, config), + "info_type": flattenDataLossPreventionInspectTemplateInspectConfigCustomInfoTypesInfoType(original["infoType"], d, config), + "likelihood": flattenDataLossPreventionInspectTemplateInspectConfigCustomInfoTypesLikelihood(original["likelihood"], d, config), + "exclusion_type": flattenDataLossPreventionInspectTemplateInspectConfigCustomInfoTypesExclusionType(original["exclusionType"], d, config), + "sensitivity_score": flattenDataLossPreventionInspectTemplateInspectConfigCustomInfoTypesSensitivityScore(original["sensitivityScore"], d, config), + "regex": flattenDataLossPreventionInspectTemplateInspectConfigCustomInfoTypesRegex(original["regex"], d, config), + "dictionary": flattenDataLossPreventionInspectTemplateInspectConfigCustomInfoTypesDictionary(original["dictionary"], d, config), + "surrogate_type": flattenDataLossPreventionInspectTemplateInspectConfigCustomInfoTypesSurrogateType(original["surrogateType"], d, config), + "stored_type": flattenDataLossPreventionInspectTemplateInspectConfigCustomInfoTypesStoredType(original["storedType"], d, config), }) } return transformed @@ -1583,6 +1753,8 @@ func flattenDataLossPreventionInspectTemplateInspectConfigCustomInfoTypesInfoTyp flattenDataLossPreventionInspectTemplateInspectConfigCustomInfoTypesInfoTypeName(original["name"], d, config) transformed["version"] = flattenDataLossPreventionInspectTemplateInspectConfigCustomInfoTypesInfoTypeVersion(original["version"], d, config) + transformed["sensitivity_score"] = + flattenDataLossPreventionInspectTemplateInspectConfigCustomInfoTypesInfoTypeSensitivityScore(original["sensitivityScore"], d, config) return []interface{}{transformed} } func flattenDataLossPreventionInspectTemplateInspectConfigCustomInfoTypesInfoTypeName(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { @@ -1593,6 +1765,23 @@ func flattenDataLossPreventionInspectTemplateInspectConfigCustomInfoTypesInfoTyp return v } +func flattenDataLossPreventionInspectTemplateInspectConfigCustomInfoTypesInfoTypeSensitivityScore(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { + if v == nil { + return nil + } + original := v.(map[string]interface{}) + if len(original) == 0 { + return nil + } + transformed := make(map[string]interface{}) + transformed["score"] = + flattenDataLossPreventionInspectTemplateInspectConfigCustomInfoTypesInfoTypeSensitivityScoreScore(original["score"], d, config) + return []interface{}{transformed} +} +func flattenDataLossPreventionInspectTemplateInspectConfigCustomInfoTypesInfoTypeSensitivityScoreScore(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { + return v +} + func flattenDataLossPreventionInspectTemplateInspectConfigCustomInfoTypesLikelihood(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { return v } @@ -1601,6 +1790,23 @@ func flattenDataLossPreventionInspectTemplateInspectConfigCustomInfoTypesExclusi return v } +func flattenDataLossPreventionInspectTemplateInspectConfigCustomInfoTypesSensitivityScore(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { + if v == nil { + return nil + } + original := v.(map[string]interface{}) + if len(original) == 0 { + return nil + } + transformed := make(map[string]interface{}) + transformed["score"] = + flattenDataLossPreventionInspectTemplateInspectConfigCustomInfoTypesSensitivityScoreScore(original["score"], d, config) + return []interface{}{transformed} +} +func flattenDataLossPreventionInspectTemplateInspectConfigCustomInfoTypesSensitivityScoreScore(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { + return v +} + func flattenDataLossPreventionInspectTemplateInspectConfigCustomInfoTypesRegex(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { if v == nil { return nil @@ -1879,6 +2085,13 @@ func expandDataLossPreventionInspectTemplateInspectConfigLimitsMaxFindingsPerInf transformed["version"] = transformedVersion } + transformedSensitivityScore, err := expandDataLossPreventionInspectTemplateInspectConfigLimitsMaxFindingsPerInfoTypeInfoTypeSensitivityScore(original["sensitivity_score"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedSensitivityScore); val.IsValid() && !tpgresource.IsEmptyValue(val) { + transformed["sensitivityScore"] = transformedSensitivityScore + } + return transformed, nil } @@ -1890,6 +2103,29 @@ func expandDataLossPreventionInspectTemplateInspectConfigLimitsMaxFindingsPerInf return v, nil } +func expandDataLossPreventionInspectTemplateInspectConfigLimitsMaxFindingsPerInfoTypeInfoTypeSensitivityScore(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + l := v.([]interface{}) + if len(l) == 0 || l[0] == nil { + return nil, nil + } + raw := l[0] + original := raw.(map[string]interface{}) + transformed := make(map[string]interface{}) + + transformedScore, err := expandDataLossPreventionInspectTemplateInspectConfigLimitsMaxFindingsPerInfoTypeInfoTypeSensitivityScoreScore(original["score"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedScore); val.IsValid() && !tpgresource.IsEmptyValue(val) { + transformed["score"] = transformedScore + } + + return transformed, nil +} + +func expandDataLossPreventionInspectTemplateInspectConfigLimitsMaxFindingsPerInfoTypeInfoTypeSensitivityScoreScore(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} + func expandDataLossPreventionInspectTemplateInspectConfigLimitsMaxFindingsPerInfoTypeMaxFindings(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { return v, nil } @@ -1918,6 +2154,13 @@ func expandDataLossPreventionInspectTemplateInspectConfigInfoTypes(v interface{} transformed["version"] = transformedVersion } + transformedSensitivityScore, err := expandDataLossPreventionInspectTemplateInspectConfigInfoTypesSensitivityScore(original["sensitivity_score"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedSensitivityScore); val.IsValid() && !tpgresource.IsEmptyValue(val) { + transformed["sensitivityScore"] = transformedSensitivityScore + } + req = append(req, transformed) } return req, nil @@ -1931,6 +2174,29 @@ func expandDataLossPreventionInspectTemplateInspectConfigInfoTypesVersion(v inte return v, nil } +func expandDataLossPreventionInspectTemplateInspectConfigInfoTypesSensitivityScore(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + l := v.([]interface{}) + if len(l) == 0 || l[0] == nil { + return nil, nil + } + raw := l[0] + original := raw.(map[string]interface{}) + transformed := make(map[string]interface{}) + + transformedScore, err := expandDataLossPreventionInspectTemplateInspectConfigInfoTypesSensitivityScoreScore(original["score"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedScore); val.IsValid() && !tpgresource.IsEmptyValue(val) { + transformed["score"] = transformedScore + } + + return transformed, nil +} + +func expandDataLossPreventionInspectTemplateInspectConfigInfoTypesSensitivityScoreScore(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} + func expandDataLossPreventionInspectTemplateInspectConfigContentOptions(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { return v, nil } @@ -1988,6 +2254,13 @@ func expandDataLossPreventionInspectTemplateInspectConfigRuleSetInfoTypes(v inte transformed["version"] = transformedVersion } + transformedSensitivityScore, err := expandDataLossPreventionInspectTemplateInspectConfigRuleSetInfoTypesSensitivityScore(original["sensitivity_score"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedSensitivityScore); val.IsValid() && !tpgresource.IsEmptyValue(val) { + transformed["sensitivityScore"] = transformedSensitivityScore + } + req = append(req, transformed) } return req, nil @@ -2001,6 +2274,29 @@ func expandDataLossPreventionInspectTemplateInspectConfigRuleSetInfoTypesVersion return v, nil } +func expandDataLossPreventionInspectTemplateInspectConfigRuleSetInfoTypesSensitivityScore(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + l := v.([]interface{}) + if len(l) == 0 || l[0] == nil { + return nil, nil + } + raw := l[0] + original := raw.(map[string]interface{}) + transformed := make(map[string]interface{}) + + transformedScore, err := expandDataLossPreventionInspectTemplateInspectConfigRuleSetInfoTypesSensitivityScoreScore(original["score"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedScore); val.IsValid() && !tpgresource.IsEmptyValue(val) { + transformed["score"] = transformedScore + } + + return transformed, nil +} + +func expandDataLossPreventionInspectTemplateInspectConfigRuleSetInfoTypesSensitivityScoreScore(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} + func expandDataLossPreventionInspectTemplateInspectConfigRuleSetRules(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { l := v.([]interface{}) req := make([]interface{}, 0, len(l)) @@ -2365,6 +2661,13 @@ func expandDataLossPreventionInspectTemplateInspectConfigRuleSetRulesExclusionRu transformed["version"] = transformedVersion } + transformedSensitivityScore, err := expandDataLossPreventionInspectTemplateInspectConfigRuleSetRulesExclusionRuleExcludeInfoTypesInfoTypesSensitivityScore(original["sensitivity_score"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedSensitivityScore); val.IsValid() && !tpgresource.IsEmptyValue(val) { + transformed["sensitivityScore"] = transformedSensitivityScore + } + req = append(req, transformed) } return req, nil @@ -2378,6 +2681,29 @@ func expandDataLossPreventionInspectTemplateInspectConfigRuleSetRulesExclusionRu return v, nil } +func expandDataLossPreventionInspectTemplateInspectConfigRuleSetRulesExclusionRuleExcludeInfoTypesInfoTypesSensitivityScore(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + l := v.([]interface{}) + if len(l) == 0 || l[0] == nil { + return nil, nil + } + raw := l[0] + original := raw.(map[string]interface{}) + transformed := make(map[string]interface{}) + + transformedScore, err := expandDataLossPreventionInspectTemplateInspectConfigRuleSetRulesExclusionRuleExcludeInfoTypesInfoTypesSensitivityScoreScore(original["score"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedScore); val.IsValid() && !tpgresource.IsEmptyValue(val) { + transformed["score"] = transformedScore + } + + return transformed, nil +} + +func expandDataLossPreventionInspectTemplateInspectConfigRuleSetRulesExclusionRuleExcludeInfoTypesInfoTypesSensitivityScoreScore(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} + func expandDataLossPreventionInspectTemplateInspectConfigRuleSetRulesExclusionRuleExcludeByHotword(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { l := v.([]interface{}) if len(l) == 0 || l[0] == nil { @@ -2503,6 +2829,13 @@ func expandDataLossPreventionInspectTemplateInspectConfigCustomInfoTypes(v inter transformed["exclusionType"] = transformedExclusionType } + transformedSensitivityScore, err := expandDataLossPreventionInspectTemplateInspectConfigCustomInfoTypesSensitivityScore(original["sensitivity_score"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedSensitivityScore); val.IsValid() && !tpgresource.IsEmptyValue(val) { + transformed["sensitivityScore"] = transformedSensitivityScore + } + transformedRegex, err := expandDataLossPreventionInspectTemplateInspectConfigCustomInfoTypesRegex(original["regex"], d, config) if err != nil { return nil, err @@ -2559,6 +2892,13 @@ func expandDataLossPreventionInspectTemplateInspectConfigCustomInfoTypesInfoType transformed["version"] = transformedVersion } + transformedSensitivityScore, err := expandDataLossPreventionInspectTemplateInspectConfigCustomInfoTypesInfoTypeSensitivityScore(original["sensitivity_score"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedSensitivityScore); val.IsValid() && !tpgresource.IsEmptyValue(val) { + transformed["sensitivityScore"] = transformedSensitivityScore + } + return transformed, nil } @@ -2570,6 +2910,29 @@ func expandDataLossPreventionInspectTemplateInspectConfigCustomInfoTypesInfoType return v, nil } +func expandDataLossPreventionInspectTemplateInspectConfigCustomInfoTypesInfoTypeSensitivityScore(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + l := v.([]interface{}) + if len(l) == 0 || l[0] == nil { + return nil, nil + } + raw := l[0] + original := raw.(map[string]interface{}) + transformed := make(map[string]interface{}) + + transformedScore, err := expandDataLossPreventionInspectTemplateInspectConfigCustomInfoTypesInfoTypeSensitivityScoreScore(original["score"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedScore); val.IsValid() && !tpgresource.IsEmptyValue(val) { + transformed["score"] = transformedScore + } + + return transformed, nil +} + +func expandDataLossPreventionInspectTemplateInspectConfigCustomInfoTypesInfoTypeSensitivityScoreScore(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} + func expandDataLossPreventionInspectTemplateInspectConfigCustomInfoTypesLikelihood(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { return v, nil } @@ -2578,6 +2941,29 @@ func expandDataLossPreventionInspectTemplateInspectConfigCustomInfoTypesExclusio return v, nil } +func expandDataLossPreventionInspectTemplateInspectConfigCustomInfoTypesSensitivityScore(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + l := v.([]interface{}) + if len(l) == 0 || l[0] == nil { + return nil, nil + } + raw := l[0] + original := raw.(map[string]interface{}) + transformed := make(map[string]interface{}) + + transformedScore, err := expandDataLossPreventionInspectTemplateInspectConfigCustomInfoTypesSensitivityScoreScore(original["score"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedScore); val.IsValid() && !tpgresource.IsEmptyValue(val) { + transformed["score"] = transformedScore + } + + return transformed, nil +} + +func expandDataLossPreventionInspectTemplateInspectConfigCustomInfoTypesSensitivityScoreScore(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} + func expandDataLossPreventionInspectTemplateInspectConfigCustomInfoTypesRegex(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { l := v.([]interface{}) if len(l) == 0 || l[0] == nil { diff --git a/website/docs/r/data_loss_prevention_inspect_template.html.markdown b/website/docs/r/data_loss_prevention_inspect_template.html.markdown index a50c265837d..3aa0e5d6c81 100644 --- a/website/docs/r/data_loss_prevention_inspect_template.html.markdown +++ b/website/docs/r/data_loss_prevention_inspect_template.html.markdown @@ -394,6 +394,19 @@ The following arguments are supported: (Optional) Version name for this InfoType. +* `sensitivity_score` - + (Optional) + Optional custom sensitivity for this InfoType. This only applies to data profiling. + Structure is [documented below](#nested_sensitivity_score). + + +The `sensitivity_score` block supports: + +* `score` - + (Required) + The sensitivity score applied to the resource. + Possible values are: `SENSITIVITY_LOW`, `SENSITIVITY_MODERATE`, `SENSITIVITY_HIGH`. + The `info_types` block supports: * `name` - @@ -405,6 +418,19 @@ The following arguments are supported: (Optional) Version of the information type to use. By default, the version is set to stable +* `sensitivity_score` - + (Optional) + Optional custom sensitivity for this InfoType. This only applies to data profiling. + Structure is [documented below](#nested_sensitivity_score). + + +The `sensitivity_score` block supports: + +* `score` - + (Required) + The sensitivity score applied to the resource. + Possible values are: `SENSITIVITY_LOW`, `SENSITIVITY_MODERATE`, `SENSITIVITY_HIGH`. + The `rule_set` block supports: * `info_types` - @@ -429,6 +455,19 @@ The following arguments are supported: (Optional) Version name for this InfoType. +* `sensitivity_score` - + (Optional) + Optional custom sensitivity for this InfoType. This only applies to data profiling. + Structure is [documented below](#nested_sensitivity_score). + + +The `sensitivity_score` block supports: + +* `score` - + (Required) + The sensitivity score applied to the resource. + Possible values are: `SENSITIVITY_LOW`, `SENSITIVITY_MODERATE`, `SENSITIVITY_HIGH`. + The `rules` block supports: * `hotword_rule` - @@ -587,6 +626,19 @@ The following arguments are supported: (Optional) Version name for this InfoType. +* `sensitivity_score` - + (Optional) + Optional custom sensitivity for this InfoType. This only applies to data profiling. + Structure is [documented below](#nested_sensitivity_score). + + +The `sensitivity_score` block supports: + +* `score` - + (Required) + The sensitivity score applied to the resource. + Possible values are: `SENSITIVITY_LOW`, `SENSITIVITY_MODERATE`, `SENSITIVITY_HIGH`. + The `exclude_by_hotword` block supports: * `hotword_regex` - @@ -648,6 +700,11 @@ The following arguments are supported: If set to EXCLUSION_TYPE_EXCLUDE this infoType will not cause a finding to be returned. It still can be used for rules matching. Possible values are: `EXCLUSION_TYPE_EXCLUDE`. +* `sensitivity_score` - + (Optional) + Optional custom sensitivity for this InfoType. This only applies to data profiling. + Structure is [documented below](#nested_sensitivity_score). + * `regex` - (Optional) Regular expression which defines the rule. @@ -679,6 +736,26 @@ The following arguments are supported: (Optional) Version name for this InfoType. +* `sensitivity_score` - + (Optional) + Optional custom sensitivity for this InfoType. This only applies to data profiling. + Structure is [documented below](#nested_sensitivity_score). + + +The `sensitivity_score` block supports: + +* `score` - + (Required) + The sensitivity score applied to the resource. + Possible values are: `SENSITIVITY_LOW`, `SENSITIVITY_MODERATE`, `SENSITIVITY_HIGH`. + +The `sensitivity_score` block supports: + +* `score` - + (Required) + The sensitivity score applied to the resource. + Possible values are: `SENSITIVITY_LOW`, `SENSITIVITY_MODERATE`, `SENSITIVITY_HIGH`. + The `regex` block supports: * `pattern` -