|
| 1 | +func flatten{{$.GetPrefix}}{{$.TitlelizeProperty}}(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| 2 | + if v == nil { |
| 3 | + return v |
| 4 | + } |
| 5 | + l := v.([]interface{}) |
| 6 | + transformed := make([]interface{}, 0, len(l)) |
| 7 | + for _, raw := range l { |
| 8 | + original := raw.(map[string]interface{}) |
| 9 | + if len(original) < 1 { |
| 10 | + // Do not include empty json objects coming back from the api |
| 11 | + continue |
| 12 | + } |
| 13 | + connection := flatten{{$.GetPrefix}}{{$.TitlelizeProperty}}Connections(original["connections"], d, config) |
| 14 | + if len(connection.([]interface{})) == 0 { |
| 15 | + continue |
| 16 | + } |
| 17 | + transformed = append(transformed, map[string]interface{}{ |
| 18 | + "connections": connection, |
| 19 | + }) |
| 20 | + } |
| 21 | + return transformed |
| 22 | +} |
| 23 | +func flatten{{$.GetPrefix}}{{$.TitlelizeProperty}}Connections(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| 24 | + if v == nil { |
| 25 | + return v |
| 26 | + } |
| 27 | + l := v.([]interface{}) |
| 28 | + transformed := make([]interface{}, 0, len(l)) |
| 29 | + for _, raw := range l { |
| 30 | + original := raw.(map[string]interface{}) |
| 31 | + if len(original) < 1 { |
| 32 | + // Do not include empty json objects coming back from the api |
| 33 | + continue |
| 34 | + } |
| 35 | + pscConnections := flatten{{$.GetPrefix}}{{$.TitlelizeProperty}}ConnectionsPscConnection(original["pscConnection"], d, config) |
| 36 | + if pscConnections == nil { |
| 37 | + continue |
| 38 | + } |
| 39 | + transformed = append(transformed, map[string]interface{}{ |
| 40 | + "psc_connection": pscConnections, |
| 41 | + }) |
| 42 | + |
| 43 | + } |
| 44 | + return transformed |
| 45 | +} |
| 46 | +func flatten{{$.GetPrefix}}{{$.TitlelizeProperty}}ConnectionsPscConnection(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| 47 | + if v == nil { |
| 48 | + return nil |
| 49 | + } |
| 50 | + original := v.(map[string]interface{}) |
| 51 | + if len(original) == 0 { |
| 52 | + return nil |
| 53 | + } |
| 54 | + transformed := make(map[string]interface{}) |
| 55 | + transformed["psc_connection_id"] = |
| 56 | + flatten{{$.GetPrefix}}{{$.TitlelizeProperty}}ConnectionsPscConnectionPscConnectionId(original["pscConnectionId"], d, config) |
| 57 | + transformed["address"] = |
| 58 | + flatten{{$.GetPrefix}}{{$.TitlelizeProperty}}ConnectionsPscConnectionAddress(original["address"], d, config) |
| 59 | + transformed["forwarding_rule"] = |
| 60 | + flatten{{$.GetPrefix}}{{$.TitlelizeProperty}}ConnectionsPscConnectionForwardingRule(original["forwardingRule"], d, config) |
| 61 | + transformed["project_id"] = |
| 62 | + flatten{{$.GetPrefix}}{{$.TitlelizeProperty}}ConnectionsPscConnectionProjectId(original["projectId"], d, config) |
| 63 | + transformed["network"] = |
| 64 | + flatten{{$.GetPrefix}}{{$.TitlelizeProperty}}ConnectionsPscConnectionNetwork(original["network"], d, config) |
| 65 | + transformed["service_attachment"] = |
| 66 | + flatten{{$.GetPrefix}}{{$.TitlelizeProperty}}ConnectionsPscConnectionServiceAttachment(original["serviceAttachment"], d, config) |
| 67 | + transformed["psc_connection_status"] = |
| 68 | + flatten{{$.GetPrefix}}{{$.TitlelizeProperty}}ConnectionsPscConnectionPscConnectionStatus(original["pscConnectionStatus"], d, config) |
| 69 | + transformed["connection_type"] = |
| 70 | + flatten{{$.GetPrefix}}{{$.TitlelizeProperty}}ConnectionsPscConnectionConnectionType(original["connectionType"], d, config) |
| 71 | + return []interface{}{transformed} |
| 72 | +} |
| 73 | +func flatten{{$.GetPrefix}}{{$.TitlelizeProperty}}ConnectionsPscConnectionPscConnectionId(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| 74 | + return v |
| 75 | +} |
| 76 | + |
| 77 | +func flatten{{$.GetPrefix}}{{$.TitlelizeProperty}}ConnectionsPscConnectionAddress(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| 78 | + return v |
| 79 | +} |
| 80 | + |
| 81 | +func flatten{{$.GetPrefix}}{{$.TitlelizeProperty}}ConnectionsPscConnectionForwardingRule(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| 82 | + return v |
| 83 | +} |
| 84 | + |
| 85 | +func flatten{{$.GetPrefix}}{{$.TitlelizeProperty}}ConnectionsPscConnectionProjectId(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| 86 | + return v |
| 87 | +} |
| 88 | + |
| 89 | +func flatten{{$.GetPrefix}}{{$.TitlelizeProperty}}ConnectionsPscConnectionNetwork(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| 90 | + return v |
| 91 | +} |
| 92 | + |
| 93 | +func flatten{{$.GetPrefix}}{{$.TitlelizeProperty}}ConnectionsPscConnectionServiceAttachment(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| 94 | + return v |
| 95 | +} |
| 96 | + |
| 97 | +func flatten{{$.GetPrefix}}{{$.TitlelizeProperty}}ConnectionsPscConnectionPscConnectionStatus(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| 98 | + return v |
| 99 | +} |
| 100 | + |
| 101 | +func flatten{{$.GetPrefix}}{{$.TitlelizeProperty}}ConnectionsPscConnectionConnectionType(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| 102 | + return v |
| 103 | +} |
0 commit comments