Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new resource for Application for Apphub #2018

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,318 @@
// ----------------------------------------------------------------------------
//
// *** 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 apphub

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 ApphubApplicationAssetType string = "apphub.googleapis.com/Application"

func ResourceConverterApphubApplication() cai.ResourceConverter {
return cai.ResourceConverter{
AssetType: ApphubApplicationAssetType,
Convert: GetApphubApplicationCaiObject,
}
}

func GetApphubApplicationCaiObject(d tpgresource.TerraformResourceData, config *transport_tpg.Config) ([]cai.Asset, error) {
name, err := cai.AssetName(d, config, "//apphub.googleapis.com/projects/{{project}}/locations/{{location}}/applications/{{application_id}}")
if err != nil {
return []cai.Asset{}, err
}
if obj, err := GetApphubApplicationApiObject(d, config); err == nil {
return []cai.Asset{{
Name: name,
Type: ApphubApplicationAssetType,
Resource: &cai.AssetResource{
Version: "v1",
DiscoveryDocumentURI: "https://www.googleapis.com/discovery/v1/apis/apphub/v1/rest",
DiscoveryName: "Application",
Data: obj,
},
}}, nil
} else {
return []cai.Asset{}, err
}
}

func GetApphubApplicationApiObject(d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]interface{}, error) {
obj := make(map[string]interface{})
displayNameProp, err := expandApphubApplicationDisplayName(d.Get("display_name"), d, config)
if err != nil {
return nil, err
} else if v, ok := d.GetOkExists("display_name"); !tpgresource.IsEmptyValue(reflect.ValueOf(displayNameProp)) && (ok || !reflect.DeepEqual(v, displayNameProp)) {
obj["displayName"] = displayNameProp
}
descriptionProp, err := expandApphubApplicationDescription(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
}
attributesProp, err := expandApphubApplicationAttributes(d.Get("attributes"), d, config)
if err != nil {
return nil, err
} else if v, ok := d.GetOkExists("attributes"); !tpgresource.IsEmptyValue(reflect.ValueOf(attributesProp)) && (ok || !reflect.DeepEqual(v, attributesProp)) {
obj["attributes"] = attributesProp
}
scopeProp, err := expandApphubApplicationScope(d.Get("scope"), d, config)
if err != nil {
return nil, err
} else if v, ok := d.GetOkExists("scope"); !tpgresource.IsEmptyValue(reflect.ValueOf(scopeProp)) && (ok || !reflect.DeepEqual(v, scopeProp)) {
obj["scope"] = scopeProp
}

return obj, nil
}

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

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

func expandApphubApplicationAttributes(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{})

transformedCriticality, err := expandApphubApplicationAttributesCriticality(original["criticality"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedCriticality); val.IsValid() && !tpgresource.IsEmptyValue(val) {
transformed["criticality"] = transformedCriticality
}

transformedEnvironment, err := expandApphubApplicationAttributesEnvironment(original["environment"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedEnvironment); val.IsValid() && !tpgresource.IsEmptyValue(val) {
transformed["environment"] = transformedEnvironment
}

transformedDeveloperOwners, err := expandApphubApplicationAttributesDeveloperOwners(original["developer_owners"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedDeveloperOwners); val.IsValid() && !tpgresource.IsEmptyValue(val) {
transformed["developerOwners"] = transformedDeveloperOwners
}

transformedOperatorOwners, err := expandApphubApplicationAttributesOperatorOwners(original["operator_owners"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedOperatorOwners); val.IsValid() && !tpgresource.IsEmptyValue(val) {
transformed["operatorOwners"] = transformedOperatorOwners
}

transformedBusinessOwners, err := expandApphubApplicationAttributesBusinessOwners(original["business_owners"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedBusinessOwners); val.IsValid() && !tpgresource.IsEmptyValue(val) {
transformed["businessOwners"] = transformedBusinessOwners
}

return transformed, nil
}

func expandApphubApplicationAttributesCriticality(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{})

transformedType, err := expandApphubApplicationAttributesCriticalityType(original["type"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedType); val.IsValid() && !tpgresource.IsEmptyValue(val) {
transformed["type"] = transformedType
}

return transformed, nil
}

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

func expandApphubApplicationAttributesEnvironment(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{})

transformedType, err := expandApphubApplicationAttributesEnvironmentType(original["type"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedType); val.IsValid() && !tpgresource.IsEmptyValue(val) {
transformed["type"] = transformedType
}

return transformed, nil
}

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

func expandApphubApplicationAttributesDeveloperOwners(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{})

transformedDisplayName, err := expandApphubApplicationAttributesDeveloperOwnersDisplayName(original["display_name"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedDisplayName); val.IsValid() && !tpgresource.IsEmptyValue(val) {
transformed["displayName"] = transformedDisplayName
}

transformedEmail, err := expandApphubApplicationAttributesDeveloperOwnersEmail(original["email"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedEmail); val.IsValid() && !tpgresource.IsEmptyValue(val) {
transformed["email"] = transformedEmail
}

req = append(req, transformed)
}
return req, nil
}

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

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

func expandApphubApplicationAttributesOperatorOwners(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{})

transformedDisplayName, err := expandApphubApplicationAttributesOperatorOwnersDisplayName(original["display_name"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedDisplayName); val.IsValid() && !tpgresource.IsEmptyValue(val) {
transformed["displayName"] = transformedDisplayName
}

transformedEmail, err := expandApphubApplicationAttributesOperatorOwnersEmail(original["email"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedEmail); val.IsValid() && !tpgresource.IsEmptyValue(val) {
transformed["email"] = transformedEmail
}

req = append(req, transformed)
}
return req, nil
}

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

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

func expandApphubApplicationAttributesBusinessOwners(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{})

transformedDisplayName, err := expandApphubApplicationAttributesBusinessOwnersDisplayName(original["display_name"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedDisplayName); val.IsValid() && !tpgresource.IsEmptyValue(val) {
transformed["displayName"] = transformedDisplayName
}

transformedEmail, err := expandApphubApplicationAttributesBusinessOwnersEmail(original["email"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedEmail); val.IsValid() && !tpgresource.IsEmptyValue(val) {
transformed["email"] = transformedEmail
}

req = append(req, transformed)
}
return req, nil
}

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

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

func expandApphubApplicationScope(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{})

transformedType, err := expandApphubApplicationScopeType(original["type"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedType); val.IsValid() && !tpgresource.IsEmptyValue(val) {
transformed["type"] = transformedType
}

return transformed, nil
}

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