Skip to content

Commit

Permalink
Add Intercept Endpoint Group resource to Network Security. (#12522) (#…
Browse files Browse the repository at this point in the history
…3210)

[upstream:9ffbaefa36297db91b4e79927bd62e5afe260207]

Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored Dec 13, 2024
1 parent 8da12ca commit e5d2fc6
Showing 1 changed file with 86 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
// ----------------------------------------------------------------------------
//
// *** 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 networksecurity

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 NetworkSecurityInterceptEndpointGroupAssetType string = "networksecurity.googleapis.com/InterceptEndpointGroup"

func ResourceConverterNetworkSecurityInterceptEndpointGroup() cai.ResourceConverter {
return cai.ResourceConverter{
AssetType: NetworkSecurityInterceptEndpointGroupAssetType,
Convert: GetNetworkSecurityInterceptEndpointGroupCaiObject,
}
}

func GetNetworkSecurityInterceptEndpointGroupCaiObject(d tpgresource.TerraformResourceData, config *transport_tpg.Config) ([]cai.Asset, error) {
name, err := cai.AssetName(d, config, "//networksecurity.googleapis.com/projects/{{project}}/locations/{{location}}/interceptEndpointGroups/{{intercept_endpoint_group_id}}")
if err != nil {
return []cai.Asset{}, err
}
if obj, err := GetNetworkSecurityInterceptEndpointGroupApiObject(d, config); err == nil {
return []cai.Asset{{
Name: name,
Type: NetworkSecurityInterceptEndpointGroupAssetType,
Resource: &cai.AssetResource{
Version: "v1beta1",
DiscoveryDocumentURI: "https://www.googleapis.com/discovery/v1/apis/networksecurity/v1beta1/rest",
DiscoveryName: "InterceptEndpointGroup",
Data: obj,
},
}}, nil
} else {
return []cai.Asset{}, err
}
}

func GetNetworkSecurityInterceptEndpointGroupApiObject(d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]interface{}, error) {
obj := make(map[string]interface{})
interceptDeploymentGroupProp, err := expandNetworkSecurityInterceptEndpointGroupInterceptDeploymentGroup(d.Get("intercept_deployment_group"), d, config)
if err != nil {
return nil, err
} else if v, ok := d.GetOkExists("intercept_deployment_group"); !tpgresource.IsEmptyValue(reflect.ValueOf(interceptDeploymentGroupProp)) && (ok || !reflect.DeepEqual(v, interceptDeploymentGroupProp)) {
obj["interceptDeploymentGroup"] = interceptDeploymentGroupProp
}
labelsProp, err := expandNetworkSecurityInterceptEndpointGroupEffectiveLabels(d.Get("effective_labels"), d, config)
if err != nil {
return nil, err
} else if v, ok := d.GetOkExists("effective_labels"); !tpgresource.IsEmptyValue(reflect.ValueOf(labelsProp)) && (ok || !reflect.DeepEqual(v, labelsProp)) {
obj["labels"] = labelsProp
}

return obj, nil
}

func expandNetworkSecurityInterceptEndpointGroupInterceptDeploymentGroup(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}

func expandNetworkSecurityInterceptEndpointGroupEffectiveLabels(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]string, error) {
if v == nil {
return map[string]string{}, nil
}
m := make(map[string]string)
for k, val := range v.(map[string]interface{}) {
m[k] = val.(string)
}
return m, nil
}

0 comments on commit e5d2fc6

Please sign in to comment.