Skip to content

Commit 9b46f0d

Browse files
Feature gap: Add missed output fields for google_compute_route resource (#13100) (#9386)
[upstream:2a0685bbaa6b1dfa97f7ec9fb66159de40953171] Signed-off-by: Modular Magician <[email protected]>
1 parent d24fa93 commit 9b46f0d

File tree

4 files changed

+304
-0
lines changed

4 files changed

+304
-0
lines changed

.changelog/13100.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
compute: added `creation_timestamp`, `next_hop_peering`, ` warnings.code`, `warnings.message`, `warnings.data.key`, `warnings.data.value`, `next_hop_hub`, `route_type`, `as_paths.path_segment_type`, `as_paths.as_lists` and `route_status` fields to `google_compute_route` resource
3+
```

google-beta/services/compute/resource_compute_route.go

+220
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,42 @@ Default value is 1000. Valid range is 0 through 65535.`,
191191
},
192192
Set: schema.HashString,
193193
},
194+
"as_paths": {
195+
Type: schema.TypeList,
196+
Computed: true,
197+
Description: ``,
198+
Elem: &schema.Resource{
199+
Schema: map[string]*schema.Schema{
200+
"as_lists": {
201+
Type: schema.TypeList,
202+
Computed: true,
203+
Description: `The AS numbers of the AS Path.`,
204+
Elem: &schema.Schema{
205+
Type: schema.TypeInt,
206+
},
207+
},
208+
"path_segment_type": {
209+
Type: schema.TypeString,
210+
Computed: true,
211+
Description: `The type of the AS Path, which can be one of the following values:
212+
- 'AS_SET': unordered set of autonomous systems that the route in has traversed
213+
- 'AS_SEQUENCE': ordered set of autonomous systems that the route has traversed
214+
- 'AS_CONFED_SEQUENCE': ordered set of Member Autonomous Systems in the local confederation that the route has traversed
215+
- 'AS_CONFED_SET': unordered set of Member Autonomous Systems in the local confederation that the route has traversed`,
216+
},
217+
},
218+
},
219+
},
220+
"creation_timestamp": {
221+
Type: schema.TypeString,
222+
Computed: true,
223+
Description: `Creation timestamp in RFC3339 text format.`,
224+
},
225+
"next_hop_hub": {
226+
Type: schema.TypeString,
227+
Computed: true,
228+
Description: `The hub network that should handle matching packets, which should conform to RFC1035.`,
229+
},
194230
"next_hop_inter_region_cost": {
195231
Type: schema.TypeString,
196232
Computed: true,
@@ -211,6 +247,67 @@ Default value is 1000. Valid range is 0 through 65535.`,
211247
Computed: true,
212248
Description: `Indicates the origin of the route. Can be IGP (Interior Gateway Protocol), EGP (Exterior Gateway Protocol), or INCOMPLETE.`,
213249
},
250+
"next_hop_peering": {
251+
Type: schema.TypeString,
252+
Computed: true,
253+
Description: `The network peering name that should handle matching packets, which should conform to RFC1035.`,
254+
},
255+
"route_status": {
256+
Type: schema.TypeString,
257+
Computed: true,
258+
Description: `The status of the route, which can be one of the following values:
259+
- 'ACTIVE' for an active route
260+
- 'INACTIVE' for an inactive route`,
261+
},
262+
"route_type": {
263+
Type: schema.TypeString,
264+
Computed: true,
265+
Description: `The type of this route, which can be one of the following values:
266+
- 'TRANSIT' for a transit route that this router learned from another Cloud Router and will readvertise to one of its BGP peers
267+
- 'SUBNET' for a route from a subnet of the VPC
268+
- 'BGP' for a route learned from a BGP peer of this router
269+
- 'STATIC' for a static route`,
270+
},
271+
"warnings": {
272+
Type: schema.TypeList,
273+
Computed: true,
274+
Description: `If potential misconfigurations are detected for this route, this field will be populated with warning messages.`,
275+
Elem: &schema.Resource{
276+
Schema: map[string]*schema.Schema{
277+
"code": {
278+
Type: schema.TypeString,
279+
Computed: true,
280+
Description: `A warning code, if applicable. For example, Compute Engine returns
281+
NO_RESULTS_ON_PAGE if there are no results in the response.`,
282+
},
283+
"data": {
284+
Type: schema.TypeList,
285+
Computed: true,
286+
Description: `Metadata about this warning in key: value format. For example:
287+
"data": [ { "key": "scope", "value": "zones/us-east1-d" }`,
288+
Elem: &schema.Resource{
289+
Schema: map[string]*schema.Schema{
290+
"key": {
291+
Type: schema.TypeString,
292+
Computed: true,
293+
Description: `A key that provides more detail on the warning being returned. For example, for warnings where there are no results in a list request for a particular zone, this key might be scope and the key value might be the zone name. Other examples might be a key indicating a deprecated resource and a suggested replacement, or a warning about invalid network settings (for example, if an instance attempts to perform IP forwarding but is not enabled for IP forwarding).`,
294+
},
295+
"value": {
296+
Type: schema.TypeString,
297+
Computed: true,
298+
Description: `A warning data value corresponding to the key.`,
299+
},
300+
},
301+
},
302+
},
303+
"message": {
304+
Type: schema.TypeString,
305+
Computed: true,
306+
Description: `A human-readable description of the warning code.`,
307+
},
308+
},
309+
},
310+
},
214311
"next_hop_instance_zone": {
215312
Type: schema.TypeString,
216313
Optional: true,
@@ -472,6 +569,27 @@ func resourceComputeRouteRead(d *schema.ResourceData, meta interface{}) error {
472569
if err := d.Set("next_hop_ilb", flattenComputeRouteNextHopIlb(res["nextHopIlb"], d, config)); err != nil {
473570
return fmt.Errorf("Error reading Route: %s", err)
474571
}
572+
if err := d.Set("creation_timestamp", flattenComputeRouteCreationTimestamp(res["creationTimestamp"], d, config)); err != nil {
573+
return fmt.Errorf("Error reading Route: %s", err)
574+
}
575+
if err := d.Set("next_hop_peering", flattenComputeRouteNextHopPeering(res["nextHopPeering"], d, config)); err != nil {
576+
return fmt.Errorf("Error reading Route: %s", err)
577+
}
578+
if err := d.Set("warnings", flattenComputeRouteWarnings(res["warnings"], d, config)); err != nil {
579+
return fmt.Errorf("Error reading Route: %s", err)
580+
}
581+
if err := d.Set("next_hop_hub", flattenComputeRouteNextHopHub(res["nextHopHub"], d, config)); err != nil {
582+
return fmt.Errorf("Error reading Route: %s", err)
583+
}
584+
if err := d.Set("route_type", flattenComputeRouteRouteType(res["routeType"], d, config)); err != nil {
585+
return fmt.Errorf("Error reading Route: %s", err)
586+
}
587+
if err := d.Set("as_paths", flattenComputeRouteAsPaths(res["asPaths"], d, config)); err != nil {
588+
return fmt.Errorf("Error reading Route: %s", err)
589+
}
590+
if err := d.Set("route_status", flattenComputeRouteRouteStatus(res["routeStatus"], d, config)); err != nil {
591+
return fmt.Errorf("Error reading Route: %s", err)
592+
}
475593
if err := d.Set("self_link", tpgresource.ConvertSelfLinkToV1(res["selfLink"].(string))); err != nil {
476594
return fmt.Errorf("Error reading Route: %s", err)
477595
}
@@ -648,6 +766,108 @@ func flattenComputeRouteNextHopIlb(v interface{}, d *schema.ResourceData, config
648766
return v
649767
}
650768

769+
func flattenComputeRouteCreationTimestamp(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
770+
return v
771+
}
772+
773+
func flattenComputeRouteNextHopPeering(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
774+
return v
775+
}
776+
777+
func flattenComputeRouteWarnings(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
778+
if v == nil {
779+
return v
780+
}
781+
l := v.([]interface{})
782+
transformed := make([]interface{}, 0, len(l))
783+
for _, raw := range l {
784+
original := raw.(map[string]interface{})
785+
if len(original) < 1 {
786+
// Do not include empty json objects coming back from the api
787+
continue
788+
}
789+
transformed = append(transformed, map[string]interface{}{
790+
"code": flattenComputeRouteWarningsCode(original["code"], d, config),
791+
"message": flattenComputeRouteWarningsMessage(original["message"], d, config),
792+
"data": flattenComputeRouteWarningsData(original["data"], d, config),
793+
})
794+
}
795+
return transformed
796+
}
797+
func flattenComputeRouteWarningsCode(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
798+
return v
799+
}
800+
801+
func flattenComputeRouteWarningsMessage(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
802+
return v
803+
}
804+
805+
func flattenComputeRouteWarningsData(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
806+
if v == nil {
807+
return v
808+
}
809+
l := v.([]interface{})
810+
transformed := make([]interface{}, 0, len(l))
811+
for _, raw := range l {
812+
original := raw.(map[string]interface{})
813+
if len(original) < 1 {
814+
// Do not include empty json objects coming back from the api
815+
continue
816+
}
817+
transformed = append(transformed, map[string]interface{}{
818+
"key": flattenComputeRouteWarningsDataKey(original["key"], d, config),
819+
"value": flattenComputeRouteWarningsDataValue(original["value"], d, config),
820+
})
821+
}
822+
return transformed
823+
}
824+
func flattenComputeRouteWarningsDataKey(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
825+
return v
826+
}
827+
828+
func flattenComputeRouteWarningsDataValue(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
829+
return v
830+
}
831+
832+
func flattenComputeRouteNextHopHub(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
833+
return v
834+
}
835+
836+
func flattenComputeRouteRouteType(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
837+
return v
838+
}
839+
840+
func flattenComputeRouteAsPaths(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
841+
if v == nil {
842+
return v
843+
}
844+
l := v.([]interface{})
845+
transformed := make([]interface{}, 0, len(l))
846+
for _, raw := range l {
847+
original := raw.(map[string]interface{})
848+
if len(original) < 1 {
849+
// Do not include empty json objects coming back from the api
850+
continue
851+
}
852+
transformed = append(transformed, map[string]interface{}{
853+
"path_segment_type": flattenComputeRouteAsPathsPathSegmentType(original["pathSegmentType"], d, config),
854+
"as_lists": flattenComputeRouteAsPathsAsLists(original["asLists"], d, config),
855+
})
856+
}
857+
return transformed
858+
}
859+
func flattenComputeRouteAsPathsPathSegmentType(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
860+
return v
861+
}
862+
863+
func flattenComputeRouteAsPathsAsLists(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
864+
return v
865+
}
866+
867+
func flattenComputeRouteRouteStatus(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
868+
return v
869+
}
870+
651871
func expandComputeRouteDestRange(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
652872
return v, nil
653873
}

google-beta/services/compute/resource_compute_route_generated_meta.yaml

+11
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,29 @@ api_service_name: 'compute.googleapis.com'
55
api_version: 'beta'
66
api_resource_type_kind: 'Route'
77
fields:
8+
- field: 'as_paths.as_lists'
9+
- field: 'as_paths.path_segment_type'
10+
- field: 'creation_timestamp'
811
- field: 'description'
912
- field: 'dest_range'
1013
- field: 'name'
1114
- field: 'network'
1215
- field: 'next_hop_gateway'
16+
- field: 'next_hop_hub'
1317
- field: 'next_hop_ilb'
1418
- field: 'next_hop_instance'
1519
- field: 'next_hop_inter_region_cost'
1620
- field: 'next_hop_ip'
1721
- field: 'next_hop_med'
1822
- field: 'next_hop_network'
1923
- field: 'next_hop_origin'
24+
- field: 'next_hop_peering'
2025
- field: 'next_hop_vpn_tunnel'
2126
- field: 'priority'
27+
- field: 'route_status'
28+
- field: 'route_type'
2229
- field: 'tags'
30+
- field: 'warnings.code'
31+
- field: 'warnings.data.key'
32+
- field: 'warnings.data.value'
33+
- field: 'warnings.message'

website/docs/r/compute_route.html.markdown

+70
Original file line numberDiff line numberDiff line change
@@ -338,9 +338,79 @@ In addition to the arguments listed above, the following computed attributes are
338338

339339
* `next_hop_inter_region_cost` -
340340
Internal fixed region-to-region cost that Google Cloud calculates based on factors such as network performance, distance, and available bandwidth between regions.
341+
342+
* `creation_timestamp` -
343+
Creation timestamp in RFC3339 text format.
344+
345+
* `next_hop_peering` -
346+
The network peering name that should handle matching packets, which should conform to RFC1035.
347+
348+
* `warnings` -
349+
If potential misconfigurations are detected for this route, this field will be populated with warning messages.
350+
Structure is [documented below](#nested_warnings).
351+
352+
* `next_hop_hub` -
353+
The hub network that should handle matching packets, which should conform to RFC1035.
354+
355+
* `route_type` -
356+
The type of this route, which can be one of the following values:
357+
- 'TRANSIT' for a transit route that this router learned from another Cloud Router and will readvertise to one of its BGP peers
358+
- 'SUBNET' for a route from a subnet of the VPC
359+
- 'BGP' for a route learned from a BGP peer of this router
360+
- 'STATIC' for a static route
361+
362+
* `as_paths` -
363+
Structure is [documented below](#nested_as_paths).
364+
365+
* `route_status` -
366+
The status of the route, which can be one of the following values:
367+
- 'ACTIVE' for an active route
368+
- 'INACTIVE' for an inactive route
341369
* `self_link` - The URI of the created resource.
342370

343371

372+
<a name="nested_warnings"></a>The `warnings` block contains:
373+
374+
* `code` -
375+
(Output)
376+
A warning code, if applicable. For example, Compute Engine returns
377+
NO_RESULTS_ON_PAGE if there are no results in the response.
378+
379+
* `message` -
380+
(Output)
381+
A human-readable description of the warning code.
382+
383+
* `data` -
384+
(Output)
385+
Metadata about this warning in key: value format. For example:
386+
"data": [ { "key": "scope", "value": "zones/us-east1-d" }
387+
Structure is [documented below](#nested_warnings_warnings_data).
388+
389+
390+
<a name="nested_warnings_warnings_data"></a>The `data` block contains:
391+
392+
* `key` -
393+
(Output)
394+
A key that provides more detail on the warning being returned. For example, for warnings where there are no results in a list request for a particular zone, this key might be scope and the key value might be the zone name. Other examples might be a key indicating a deprecated resource and a suggested replacement, or a warning about invalid network settings (for example, if an instance attempts to perform IP forwarding but is not enabled for IP forwarding).
395+
396+
* `value` -
397+
(Output)
398+
A warning data value corresponding to the key.
399+
400+
<a name="nested_as_paths"></a>The `as_paths` block contains:
401+
402+
* `path_segment_type` -
403+
(Output)
404+
The type of the AS Path, which can be one of the following values:
405+
- 'AS_SET': unordered set of autonomous systems that the route in has traversed
406+
- 'AS_SEQUENCE': ordered set of autonomous systems that the route has traversed
407+
- 'AS_CONFED_SEQUENCE': ordered set of Member Autonomous Systems in the local confederation that the route has traversed
408+
- 'AS_CONFED_SET': unordered set of Member Autonomous Systems in the local confederation that the route has traversed
409+
410+
* `as_lists` -
411+
(Output)
412+
The AS numbers of the AS Path.
413+
344414
## Timeouts
345415

346416
This resource provides the following

0 commit comments

Comments
 (0)