-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add google_chronicle_reference_list resource to chronicle (#12717)
[upstream:d0f8efaf8b363e53e099e9a4f7211f06750fce76] Signed-off-by: Modular Magician <[email protected]>
- Loading branch information
1 parent
655023f
commit fea6dc4
Showing
1 changed file
with
111 additions
and
0 deletions.
There are no files selected for viewing
111 changes: 111 additions & 0 deletions
111
tfplan2cai/converters/google/resources/services/chronicle/chronicle_reference_list.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
// ---------------------------------------------------------------------------- | ||
// | ||
// *** 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 chronicle | ||
|
||
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 ChronicleReferenceListAssetType string = "{{location}}-chronicle.googleapis.com/ReferenceList" | ||
|
||
func ResourceConverterChronicleReferenceList() cai.ResourceConverter { | ||
return cai.ResourceConverter{ | ||
AssetType: ChronicleReferenceListAssetType, | ||
Convert: GetChronicleReferenceListCaiObject, | ||
} | ||
} | ||
|
||
func GetChronicleReferenceListCaiObject(d tpgresource.TerraformResourceData, config *transport_tpg.Config) ([]cai.Asset, error) { | ||
name, err := cai.AssetName(d, config, "//{{location}}-chronicle.googleapis.com/projects/{{project}}/locations/{{location}}/instances/{{instance}}/referenceLists/{{reference_list_id}}") | ||
if err != nil { | ||
return []cai.Asset{}, err | ||
} | ||
if obj, err := GetChronicleReferenceListApiObject(d, config); err == nil { | ||
return []cai.Asset{{ | ||
Name: name, | ||
Type: ChronicleReferenceListAssetType, | ||
Resource: &cai.AssetResource{ | ||
Version: "v1beta", | ||
DiscoveryDocumentURI: "https://www.googleapis.com/discovery/v1/apis/{{location}}-chronicle/v1beta/rest", | ||
DiscoveryName: "ReferenceList", | ||
Data: obj, | ||
}, | ||
}}, nil | ||
} else { | ||
return []cai.Asset{}, err | ||
} | ||
} | ||
|
||
func GetChronicleReferenceListApiObject(d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]interface{}, error) { | ||
obj := make(map[string]interface{}) | ||
descriptionProp, err := expandChronicleReferenceListDescription(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 | ||
} | ||
entriesProp, err := expandChronicleReferenceListEntries(d.Get("entries"), d, config) | ||
if err != nil { | ||
return nil, err | ||
} else if v, ok := d.GetOkExists("entries"); !tpgresource.IsEmptyValue(reflect.ValueOf(entriesProp)) && (ok || !reflect.DeepEqual(v, entriesProp)) { | ||
obj["entries"] = entriesProp | ||
} | ||
syntaxTypeProp, err := expandChronicleReferenceListSyntaxType(d.Get("syntax_type"), d, config) | ||
if err != nil { | ||
return nil, err | ||
} else if v, ok := d.GetOkExists("syntax_type"); !tpgresource.IsEmptyValue(reflect.ValueOf(syntaxTypeProp)) && (ok || !reflect.DeepEqual(v, syntaxTypeProp)) { | ||
obj["syntaxType"] = syntaxTypeProp | ||
} | ||
|
||
return obj, nil | ||
} | ||
|
||
func expandChronicleReferenceListDescription(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { | ||
return v, nil | ||
} | ||
|
||
func expandChronicleReferenceListEntries(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { | ||
l := v.([]interface{}) | ||
req := make([]interface{}, 0, len(l)) | ||
for _, raw := range l { | ||
if raw == nil { | ||
continue | ||
} | ||
original := raw.(map[string]interface{}) | ||
transformed := make(map[string]interface{}) | ||
|
||
transformedValue, err := expandChronicleReferenceListEntriesValue(original["value"], d, config) | ||
if err != nil { | ||
return nil, err | ||
} else if val := reflect.ValueOf(transformedValue); val.IsValid() && !tpgresource.IsEmptyValue(val) { | ||
transformed["value"] = transformedValue | ||
} | ||
|
||
req = append(req, transformed) | ||
} | ||
return req, nil | ||
} | ||
|
||
func expandChronicleReferenceListEntriesValue(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { | ||
return v, nil | ||
} | ||
|
||
func expandChronicleReferenceListSyntaxType(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { | ||
return v, nil | ||
} |