From d4199803d14d603eb50a8e355b976e24811f3b5f Mon Sep 17 00:00:00 2001 From: The Magician Date: Fri, 30 Aug 2024 11:13:02 -0700 Subject: [PATCH] Add Resource V2 SCC Findings Export to Big Query Folder Config (#11517) (#2736) [upstream:68282ea6e38b34150888bdff9bae1a27c73bb7f9] Signed-off-by: Modular Magician --- ...tycenterv2_folder_scc_big_query_exports.go | 89 +++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 tfplan2cai/converters/google/resources/services/securitycenterv2/securitycenterv2_folder_scc_big_query_exports.go diff --git a/tfplan2cai/converters/google/resources/services/securitycenterv2/securitycenterv2_folder_scc_big_query_exports.go b/tfplan2cai/converters/google/resources/services/securitycenterv2/securitycenterv2_folder_scc_big_query_exports.go new file mode 100644 index 000000000..3f8349fb5 --- /dev/null +++ b/tfplan2cai/converters/google/resources/services/securitycenterv2/securitycenterv2_folder_scc_big_query_exports.go @@ -0,0 +1,89 @@ +// ---------------------------------------------------------------------------- +// +// *** AUTO GENERATED CODE *** Type: MMv1 *** +// +// ---------------------------------------------------------------------------- +// +// This file is automatically generated by Magic Modules and manual +// changes will be clobbered when the file is regenerated. +// +// Please read more about how to change this file in +// .github/CONTRIBUTING.md. +// +// ---------------------------------------------------------------------------- + +package securitycenterv2 + +import ( + "reflect" + + "github.com/GoogleCloudPlatform/terraform-google-conversion/v5/tfplan2cai/converters/google/resources/cai" + "github.com/hashicorp/terraform-provider-google-beta/google-beta/tpgresource" + transport_tpg "github.com/hashicorp/terraform-provider-google-beta/google-beta/transport" +) + +const SecurityCenterV2FolderSccBigQueryExportsAssetType string = "securitycenter.googleapis.com/FolderSccBigQueryExports" + +func ResourceConverterSecurityCenterV2FolderSccBigQueryExports() cai.ResourceConverter { + return cai.ResourceConverter{ + AssetType: SecurityCenterV2FolderSccBigQueryExportsAssetType, + Convert: GetSecurityCenterV2FolderSccBigQueryExportsCaiObject, + } +} + +func GetSecurityCenterV2FolderSccBigQueryExportsCaiObject(d tpgresource.TerraformResourceData, config *transport_tpg.Config) ([]cai.Asset, error) { + name, err := cai.AssetName(d, config, "//securitycenter.googleapis.com/folders/{{folder}}/locations/{{location}}/bigQueryExports/{{big_query_export_id}}") + if err != nil { + return []cai.Asset{}, err + } + if obj, err := GetSecurityCenterV2FolderSccBigQueryExportsApiObject(d, config); err == nil { + return []cai.Asset{{ + Name: name, + Type: SecurityCenterV2FolderSccBigQueryExportsAssetType, + Resource: &cai.AssetResource{ + Version: "v2", + DiscoveryDocumentURI: "https://www.googleapis.com/discovery/v1/apis/securitycenter/v2/rest", + DiscoveryName: "FolderSccBigQueryExports", + Data: obj, + }, + }}, nil + } else { + return []cai.Asset{}, err + } +} + +func GetSecurityCenterV2FolderSccBigQueryExportsApiObject(d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]interface{}, error) { + obj := make(map[string]interface{}) + descriptionProp, err := expandSecurityCenterV2FolderSccBigQueryExportsDescription(d.Get("description"), d, config) + if err != nil { + return nil, err + } else if v, ok := d.GetOkExists("description"); !tpgresource.IsEmptyValue(reflect.ValueOf(descriptionProp)) && (ok || !reflect.DeepEqual(v, descriptionProp)) { + obj["description"] = descriptionProp + } + datasetProp, err := expandSecurityCenterV2FolderSccBigQueryExportsDataset(d.Get("dataset"), d, config) + if err != nil { + return nil, err + } else if v, ok := d.GetOkExists("dataset"); !tpgresource.IsEmptyValue(reflect.ValueOf(datasetProp)) && (ok || !reflect.DeepEqual(v, datasetProp)) { + obj["dataset"] = datasetProp + } + filterProp, err := expandSecurityCenterV2FolderSccBigQueryExportsFilter(d.Get("filter"), d, config) + if err != nil { + return nil, err + } else if v, ok := d.GetOkExists("filter"); !tpgresource.IsEmptyValue(reflect.ValueOf(filterProp)) && (ok || !reflect.DeepEqual(v, filterProp)) { + obj["filter"] = filterProp + } + + return obj, nil +} + +func expandSecurityCenterV2FolderSccBigQueryExportsDescription(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} + +func expandSecurityCenterV2FolderSccBigQueryExportsDataset(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} + +func expandSecurityCenterV2FolderSccBigQueryExportsFilter(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +}