|
| 1 | +// ---------------------------------------------------------------------------- |
| 2 | +// |
| 3 | +// *** AUTO GENERATED CODE *** Type: MMv1 *** |
| 4 | +// |
| 5 | +// ---------------------------------------------------------------------------- |
| 6 | +// |
| 7 | +// This file is automatically generated by Magic Modules and manual |
| 8 | +// changes will be clobbered when the file is regenerated. |
| 9 | +// |
| 10 | +// Please read more about how to change this file in |
| 11 | +// .github/CONTRIBUTING.md. |
| 12 | +// |
| 13 | +// ---------------------------------------------------------------------------- |
| 14 | + |
| 15 | +package redis |
| 16 | + |
| 17 | +import ( |
| 18 | + "reflect" |
| 19 | + |
| 20 | + "github.com/GoogleCloudPlatform/terraform-google-conversion/v5/tfplan2cai/converters/google/resources/cai" |
| 21 | + "github.com/hashicorp/terraform-provider-google-beta/google-beta/tpgresource" |
| 22 | + transport_tpg "github.com/hashicorp/terraform-provider-google-beta/google-beta/transport" |
| 23 | +) |
| 24 | + |
| 25 | +const RedisClusterUserCreatedConnectionsAssetType string = "redis.googleapis.com/ClusterUserCreatedConnections" |
| 26 | + |
| 27 | +func ResourceConverterRedisClusterUserCreatedConnections() cai.ResourceConverter { |
| 28 | + return cai.ResourceConverter{ |
| 29 | + AssetType: RedisClusterUserCreatedConnectionsAssetType, |
| 30 | + Convert: GetRedisClusterUserCreatedConnectionsCaiObject, |
| 31 | + } |
| 32 | +} |
| 33 | + |
| 34 | +func GetRedisClusterUserCreatedConnectionsCaiObject(d tpgresource.TerraformResourceData, config *transport_tpg.Config) ([]cai.Asset, error) { |
| 35 | + name, err := cai.AssetName(d, config, "//redis.googleapis.com/projects/{{project}}/locations/{{region}}/clusters/{{name}}") |
| 36 | + if err != nil { |
| 37 | + return []cai.Asset{}, err |
| 38 | + } |
| 39 | + if obj, err := GetRedisClusterUserCreatedConnectionsApiObject(d, config); err == nil { |
| 40 | + return []cai.Asset{{ |
| 41 | + Name: name, |
| 42 | + Type: RedisClusterUserCreatedConnectionsAssetType, |
| 43 | + Resource: &cai.AssetResource{ |
| 44 | + Version: "v1beta1", |
| 45 | + DiscoveryDocumentURI: "https://www.googleapis.com/discovery/v1/apis/redis/v1beta1/rest", |
| 46 | + DiscoveryName: "ClusterUserCreatedConnections", |
| 47 | + Data: obj, |
| 48 | + }, |
| 49 | + }}, nil |
| 50 | + } else { |
| 51 | + return []cai.Asset{}, err |
| 52 | + } |
| 53 | +} |
| 54 | + |
| 55 | +func GetRedisClusterUserCreatedConnectionsApiObject(d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]interface{}, error) { |
| 56 | + obj := make(map[string]interface{}) |
| 57 | + clusterEndpointsProp, err := expandRedisClusterUserCreatedConnectionsClusterEndpoints(d.Get("cluster_endpoints"), d, config) |
| 58 | + if err != nil { |
| 59 | + return nil, err |
| 60 | + } else if v, ok := d.GetOkExists("cluster_endpoints"); !tpgresource.IsEmptyValue(reflect.ValueOf(clusterEndpointsProp)) && (ok || !reflect.DeepEqual(v, clusterEndpointsProp)) { |
| 61 | + obj["clusterEndpoints"] = clusterEndpointsProp |
| 62 | + } |
| 63 | + |
| 64 | + return obj, nil |
| 65 | +} |
| 66 | + |
| 67 | +func expandRedisClusterUserCreatedConnectionsClusterEndpoints(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| 68 | + l := v.([]interface{}) |
| 69 | + req := make([]interface{}, 0, len(l)) |
| 70 | + for _, raw := range l { |
| 71 | + if raw == nil { |
| 72 | + continue |
| 73 | + } |
| 74 | + original := raw.(map[string]interface{}) |
| 75 | + transformed := make(map[string]interface{}) |
| 76 | + |
| 77 | + transformedConnections, err := expandRedisClusterUserCreatedConnectionsClusterEndpointsConnections(original["connections"], d, config) |
| 78 | + if err != nil { |
| 79 | + return nil, err |
| 80 | + } else if val := reflect.ValueOf(transformedConnections); val.IsValid() && !tpgresource.IsEmptyValue(val) { |
| 81 | + transformed["connections"] = transformedConnections |
| 82 | + } |
| 83 | + |
| 84 | + req = append(req, transformed) |
| 85 | + } |
| 86 | + return req, nil |
| 87 | +} |
| 88 | + |
| 89 | +func expandRedisClusterUserCreatedConnectionsClusterEndpointsConnections(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| 90 | + l := v.([]interface{}) |
| 91 | + req := make([]interface{}, 0, len(l)) |
| 92 | + for _, raw := range l { |
| 93 | + if raw == nil { |
| 94 | + continue |
| 95 | + } |
| 96 | + original := raw.(map[string]interface{}) |
| 97 | + transformed := make(map[string]interface{}) |
| 98 | + |
| 99 | + transformedPscConnection, err := expandRedisClusterUserCreatedConnectionsClusterEndpointsConnectionsPscConnection(original["psc_connection"], d, config) |
| 100 | + if err != nil { |
| 101 | + return nil, err |
| 102 | + } else if val := reflect.ValueOf(transformedPscConnection); val.IsValid() && !tpgresource.IsEmptyValue(val) { |
| 103 | + transformed["pscConnection"] = transformedPscConnection |
| 104 | + } |
| 105 | + |
| 106 | + req = append(req, transformed) |
| 107 | + } |
| 108 | + return req, nil |
| 109 | +} |
| 110 | + |
| 111 | +func expandRedisClusterUserCreatedConnectionsClusterEndpointsConnectionsPscConnection(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| 112 | + l := v.([]interface{}) |
| 113 | + if len(l) == 0 || l[0] == nil { |
| 114 | + return nil, nil |
| 115 | + } |
| 116 | + raw := l[0] |
| 117 | + original := raw.(map[string]interface{}) |
| 118 | + transformed := make(map[string]interface{}) |
| 119 | + |
| 120 | + transformedPscConnectionId, err := expandRedisClusterUserCreatedConnectionsClusterEndpointsConnectionsPscConnectionPscConnectionId(original["psc_connection_id"], d, config) |
| 121 | + if err != nil { |
| 122 | + return nil, err |
| 123 | + } else if val := reflect.ValueOf(transformedPscConnectionId); val.IsValid() && !tpgresource.IsEmptyValue(val) { |
| 124 | + transformed["pscConnectionId"] = transformedPscConnectionId |
| 125 | + } |
| 126 | + |
| 127 | + transformedAddress, err := expandRedisClusterUserCreatedConnectionsClusterEndpointsConnectionsPscConnectionAddress(original["address"], d, config) |
| 128 | + if err != nil { |
| 129 | + return nil, err |
| 130 | + } else if val := reflect.ValueOf(transformedAddress); val.IsValid() && !tpgresource.IsEmptyValue(val) { |
| 131 | + transformed["address"] = transformedAddress |
| 132 | + } |
| 133 | + |
| 134 | + transformedForwardingRule, err := expandRedisClusterUserCreatedConnectionsClusterEndpointsConnectionsPscConnectionForwardingRule(original["forwarding_rule"], d, config) |
| 135 | + if err != nil { |
| 136 | + return nil, err |
| 137 | + } else if val := reflect.ValueOf(transformedForwardingRule); val.IsValid() && !tpgresource.IsEmptyValue(val) { |
| 138 | + transformed["forwardingRule"] = transformedForwardingRule |
| 139 | + } |
| 140 | + |
| 141 | + transformedProjectId, err := expandRedisClusterUserCreatedConnectionsClusterEndpointsConnectionsPscConnectionProjectId(original["project_id"], d, config) |
| 142 | + if err != nil { |
| 143 | + return nil, err |
| 144 | + } else if val := reflect.ValueOf(transformedProjectId); val.IsValid() && !tpgresource.IsEmptyValue(val) { |
| 145 | + transformed["projectId"] = transformedProjectId |
| 146 | + } |
| 147 | + |
| 148 | + transformedNetwork, err := expandRedisClusterUserCreatedConnectionsClusterEndpointsConnectionsPscConnectionNetwork(original["network"], d, config) |
| 149 | + if err != nil { |
| 150 | + return nil, err |
| 151 | + } else if val := reflect.ValueOf(transformedNetwork); val.IsValid() && !tpgresource.IsEmptyValue(val) { |
| 152 | + transformed["network"] = transformedNetwork |
| 153 | + } |
| 154 | + |
| 155 | + transformedServiceAttachment, err := expandRedisClusterUserCreatedConnectionsClusterEndpointsConnectionsPscConnectionServiceAttachment(original["service_attachment"], d, config) |
| 156 | + if err != nil { |
| 157 | + return nil, err |
| 158 | + } else if val := reflect.ValueOf(transformedServiceAttachment); val.IsValid() && !tpgresource.IsEmptyValue(val) { |
| 159 | + transformed["serviceAttachment"] = transformedServiceAttachment |
| 160 | + } |
| 161 | + |
| 162 | + transformedPscConnectionStatus, err := expandRedisClusterUserCreatedConnectionsClusterEndpointsConnectionsPscConnectionPscConnectionStatus(original["psc_connection_status"], d, config) |
| 163 | + if err != nil { |
| 164 | + return nil, err |
| 165 | + } else if val := reflect.ValueOf(transformedPscConnectionStatus); val.IsValid() && !tpgresource.IsEmptyValue(val) { |
| 166 | + transformed["pscConnectionStatus"] = transformedPscConnectionStatus |
| 167 | + } |
| 168 | + |
| 169 | + transformedConnectionType, err := expandRedisClusterUserCreatedConnectionsClusterEndpointsConnectionsPscConnectionConnectionType(original["connection_type"], d, config) |
| 170 | + if err != nil { |
| 171 | + return nil, err |
| 172 | + } else if val := reflect.ValueOf(transformedConnectionType); val.IsValid() && !tpgresource.IsEmptyValue(val) { |
| 173 | + transformed["connectionType"] = transformedConnectionType |
| 174 | + } |
| 175 | + |
| 176 | + return transformed, nil |
| 177 | +} |
| 178 | + |
| 179 | +func expandRedisClusterUserCreatedConnectionsClusterEndpointsConnectionsPscConnectionPscConnectionId(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| 180 | + return v, nil |
| 181 | +} |
| 182 | + |
| 183 | +func expandRedisClusterUserCreatedConnectionsClusterEndpointsConnectionsPscConnectionAddress(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| 184 | + return v, nil |
| 185 | +} |
| 186 | + |
| 187 | +func expandRedisClusterUserCreatedConnectionsClusterEndpointsConnectionsPscConnectionForwardingRule(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| 188 | + return v, nil |
| 189 | +} |
| 190 | + |
| 191 | +func expandRedisClusterUserCreatedConnectionsClusterEndpointsConnectionsPscConnectionProjectId(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| 192 | + return v, nil |
| 193 | +} |
| 194 | + |
| 195 | +func expandRedisClusterUserCreatedConnectionsClusterEndpointsConnectionsPscConnectionNetwork(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| 196 | + return v, nil |
| 197 | +} |
| 198 | + |
| 199 | +func expandRedisClusterUserCreatedConnectionsClusterEndpointsConnectionsPscConnectionServiceAttachment(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| 200 | + return v, nil |
| 201 | +} |
| 202 | + |
| 203 | +func expandRedisClusterUserCreatedConnectionsClusterEndpointsConnectionsPscConnectionPscConnectionStatus(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| 204 | + return v, nil |
| 205 | +} |
| 206 | + |
| 207 | +func expandRedisClusterUserCreatedConnectionsClusterEndpointsConnectionsPscConnectionConnectionType(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| 208 | + return v, nil |
| 209 | +} |
0 commit comments