# GRE Tunnels ## List GRE tunnels `client.MagicTransit.GRETunnels.List(ctx, params) (*GRETunnelListResponse, error)` **get** `/accounts/{account_id}/magic/gre_tunnels` Lists GRE tunnels associated with an account. ### Parameters - `params GRETunnelListParams` - `AccountID param.Field[string]` Path param: Identifier - `XMagicNewHcTarget param.Field[bool]` Header param: If true, the health check target in the response body will be presented using the new object format. Defaults to false. ### Returns - `type GRETunnelListResponse struct{…}` - `GRETunnels []GRETunnelListResponseGRETunnel` - `ID string` Identifier - `CloudflareGREEndpoint string` The IP address assigned to the Cloudflare side of the GRE tunnel. - `CustomerGREEndpoint string` The IP address assigned to the customer side of the GRE tunnel. - `InterfaceAddress string` A 31-bit prefix (/31 in CIDR notation) supporting two hosts, one for each side of the tunnel. Select the subnet from the following private IP space: 10.0.0.0–10.255.255.255, 172.16.0.0–172.31.255.255, 192.168.0.0–192.168.255.255. - `Name string` The name of the tunnel. The name cannot contain spaces or special characters, must be 15 characters or less, and cannot share a name with another GRE tunnel. - `AutomaticReturnRouting bool` True if automatic stateful return routing should be enabled for a tunnel, false otherwise. - `BGP GRETunnelListResponseGRETunnelsBGP` - `CustomerASN int64` ASN used on the customer end of the BGP session - `ExtraPrefixes []string` Prefixes in this list will be advertised to the customer device, in addition to the routes in the Magic routing table. - `Md5Key string` MD5 key to use for session authentication. Note that *this is not a security measure*. MD5 is not a valid security mechanism, and the key is not treated as a secret value. This is *only* supported for preventing misconfiguration, not for defending against malicious attacks. The MD5 key, if set, must be of non-zero length and consist only of the following types of character: * ASCII alphanumerics: `[a-zA-Z0-9]` * Special characters in the set `'!@#$%^&*()+[]{}<>/.,;:_-~`= |` In other words, MD5 keys may contain any printable ASCII character aside from newline (0x0A), quotation mark (`"`), vertical tab (0x0B), carriage return (0x0D), tab (0x09), form feed (0x0C), and the question mark (`?`). Requests specifying an MD5 key with one or more of these disallowed characters will be rejected. - `BGPStatus GRETunnelListResponseGRETunnelsBGPStatus` - `State GRETunnelListResponseGRETunnelsBGPStatusState` - `const GRETunnelListResponseGRETunnelsBGPStatusStateBGPDown GRETunnelListResponseGRETunnelsBGPStatusState = "BGP_DOWN"` - `const GRETunnelListResponseGRETunnelsBGPStatusStateBGPUp GRETunnelListResponseGRETunnelsBGPStatusState = "BGP_UP"` - `const GRETunnelListResponseGRETunnelsBGPStatusStateBGPEstablishing GRETunnelListResponseGRETunnelsBGPStatusState = "BGP_ESTABLISHING"` - `TCPEstablished bool` - `UpdatedAt Time` - `BGPState string` - `CfSpeakerIP string` - `CfSpeakerPort int64` - `CustomerSpeakerIP string` - `CustomerSpeakerPort int64` - `CreatedOn Time` The date and time the tunnel was created. - `Description string` An optional description of the GRE tunnel. - `HealthCheck GRETunnelListResponseGRETunnelsHealthCheck` - `Direction GRETunnelListResponseGRETunnelsHealthCheckDirection` The direction of the flow of the healthcheck. Either unidirectional, where the probe comes to you via the tunnel and the result comes back to Cloudflare via the open Internet, or bidirectional where both the probe and result come and go via the tunnel. - `const GRETunnelListResponseGRETunnelsHealthCheckDirectionUnidirectional GRETunnelListResponseGRETunnelsHealthCheckDirection = "unidirectional"` - `const GRETunnelListResponseGRETunnelsHealthCheckDirectionBidirectional GRETunnelListResponseGRETunnelsHealthCheckDirection = "bidirectional"` - `Enabled bool` Determines whether to run healthchecks for a tunnel. - `Rate HealthCheckRate` How frequent the health check is run. The default value is `mid`. - `const HealthCheckRateLow HealthCheckRate = "low"` - `const HealthCheckRateMid HealthCheckRate = "mid"` - `const HealthCheckRateHigh HealthCheckRate = "high"` - `Target GRETunnelListResponseGRETunnelsHealthCheckTargetUnion` The destination address in a request type health check. After the healthcheck is decapsulated at the customer end of the tunnel, the ICMP echo will be forwarded to this address. This field defaults to `customer_gre_endpoint address`. This field is ignored for bidirectional healthchecks as the interface_address (not assigned to the Cloudflare side of the tunnel) is used as the target. Must be in object form if the x-magic-new-hc-target header is set to true and string form if x-magic-new-hc-target is absent or set to false. - `type GRETunnelListResponseGRETunnelsHealthCheckTargetMagicHealthCheckTarget struct{…}` The destination address in a request type health check. After the healthcheck is decapsulated at the customer end of the tunnel, the ICMP echo will be forwarded to this address. This field defaults to `customer_gre_endpoint address`. This field is ignored for bidirectional healthchecks as the interface_address (not assigned to the Cloudflare side of the tunnel) is used as the target. - `Effective string` The effective health check target. If 'saved' is empty, then this field will be populated with the calculated default value on GET requests. Ignored in POST, PUT, and PATCH requests. - `Saved string` The saved health check target. Setting the value to the empty string indicates that the calculated default value will be used. - `UnionString` - `Type HealthCheckType` The type of healthcheck to run, reply or request. The default value is `reply`. - `const HealthCheckTypeReply HealthCheckType = "reply"` - `const HealthCheckTypeRequest HealthCheckType = "request"` - `InterfaceAddress6 string` A 127 bit IPV6 prefix from within the virtual_subnet6 prefix space with the address being the first IP of the subnet and not same as the address of virtual_subnet6. Eg if virtual_subnet6 is 2606:54c1:7:0:a9fe:12d2::/127 , interface_address6 could be 2606:54c1:7:0:a9fe:12d2:1:200/127 - `ModifiedOn Time` The date and time the tunnel was last modified. - `Mtu int64` Maximum Transmission Unit (MTU) in bytes for the GRE tunnel. The minimum value is 576. - `TTL int64` Time To Live (TTL) in number of hops of the GRE tunnel. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/magic_transit" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) greTunnels, err := client.MagicTransit.GRETunnels.List(context.TODO(), magic_transit.GRETunnelListParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", greTunnels.GRETunnels) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": { "gre_tunnels": [ { "id": "c4a7362d577a6c3019a474fd6f485821", "cloudflare_gre_endpoint": "203.0.113.1", "customer_gre_endpoint": "203.0.113.1", "interface_address": "192.0.2.0/31", "name": "GRE_1", "automatic_return_routing": true, "bgp": { "customer_asn": 0, "extra_prefixes": [ "string" ], "md5_key": "md5_key" }, "bgp_status": { "state": "BGP_DOWN", "tcp_established": true, "updated_at": "2019-12-27T18:11:19.117Z", "bgp_state": "bgp_state", "cf_speaker_ip": "192.168.1.1", "cf_speaker_port": 1, "customer_speaker_ip": "192.168.1.1", "customer_speaker_port": 1 }, "created_on": "2017-06-14T00:00:00Z", "description": "Tunnel for ISP X", "health_check": { "direction": "bidirectional", "enabled": true, "rate": "low", "target": { "effective": "203.0.113.1", "saved": "203.0.113.1" }, "type": "request" }, "interface_address6": "2606:54c1:7:0:a9fe:12d2:1:200/127", "modified_on": "2017-06-14T05:20:00Z", "mtu": 0, "ttl": 0 } ] }, "success": true } ``` ## List GRE Tunnel Details `client.MagicTransit.GRETunnels.Get(ctx, greTunnelID, params) (*GRETunnelGetResponse, error)` **get** `/accounts/{account_id}/magic/gre_tunnels/{gre_tunnel_id}` Lists informtion for a specific GRE tunnel. ### Parameters - `greTunnelID string` Identifier - `params GRETunnelGetParams` - `AccountID param.Field[string]` Path param: Identifier - `XMagicNewHcTarget param.Field[bool]` Header param: If true, the health check target in the response body will be presented using the new object format. Defaults to false. ### Returns - `type GRETunnelGetResponse struct{…}` - `GRETunnel GRETunnelGetResponseGRETunnel` - `ID string` Identifier - `CloudflareGREEndpoint string` The IP address assigned to the Cloudflare side of the GRE tunnel. - `CustomerGREEndpoint string` The IP address assigned to the customer side of the GRE tunnel. - `InterfaceAddress string` A 31-bit prefix (/31 in CIDR notation) supporting two hosts, one for each side of the tunnel. Select the subnet from the following private IP space: 10.0.0.0–10.255.255.255, 172.16.0.0–172.31.255.255, 192.168.0.0–192.168.255.255. - `Name string` The name of the tunnel. The name cannot contain spaces or special characters, must be 15 characters or less, and cannot share a name with another GRE tunnel. - `AutomaticReturnRouting bool` True if automatic stateful return routing should be enabled for a tunnel, false otherwise. - `BGP GRETunnelGetResponseGRETunnelBGP` - `CustomerASN int64` ASN used on the customer end of the BGP session - `ExtraPrefixes []string` Prefixes in this list will be advertised to the customer device, in addition to the routes in the Magic routing table. - `Md5Key string` MD5 key to use for session authentication. Note that *this is not a security measure*. MD5 is not a valid security mechanism, and the key is not treated as a secret value. This is *only* supported for preventing misconfiguration, not for defending against malicious attacks. The MD5 key, if set, must be of non-zero length and consist only of the following types of character: * ASCII alphanumerics: `[a-zA-Z0-9]` * Special characters in the set `'!@#$%^&*()+[]{}<>/.,;:_-~`= |` In other words, MD5 keys may contain any printable ASCII character aside from newline (0x0A), quotation mark (`"`), vertical tab (0x0B), carriage return (0x0D), tab (0x09), form feed (0x0C), and the question mark (`?`). Requests specifying an MD5 key with one or more of these disallowed characters will be rejected. - `BGPStatus GRETunnelGetResponseGRETunnelBGPStatus` - `State GRETunnelGetResponseGRETunnelBGPStatusState` - `const GRETunnelGetResponseGRETunnelBGPStatusStateBGPDown GRETunnelGetResponseGRETunnelBGPStatusState = "BGP_DOWN"` - `const GRETunnelGetResponseGRETunnelBGPStatusStateBGPUp GRETunnelGetResponseGRETunnelBGPStatusState = "BGP_UP"` - `const GRETunnelGetResponseGRETunnelBGPStatusStateBGPEstablishing GRETunnelGetResponseGRETunnelBGPStatusState = "BGP_ESTABLISHING"` - `TCPEstablished bool` - `UpdatedAt Time` - `BGPState string` - `CfSpeakerIP string` - `CfSpeakerPort int64` - `CustomerSpeakerIP string` - `CustomerSpeakerPort int64` - `CreatedOn Time` The date and time the tunnel was created. - `Description string` An optional description of the GRE tunnel. - `HealthCheck GRETunnelGetResponseGRETunnelHealthCheck` - `Direction GRETunnelGetResponseGRETunnelHealthCheckDirection` The direction of the flow of the healthcheck. Either unidirectional, where the probe comes to you via the tunnel and the result comes back to Cloudflare via the open Internet, or bidirectional where both the probe and result come and go via the tunnel. - `const GRETunnelGetResponseGRETunnelHealthCheckDirectionUnidirectional GRETunnelGetResponseGRETunnelHealthCheckDirection = "unidirectional"` - `const GRETunnelGetResponseGRETunnelHealthCheckDirectionBidirectional GRETunnelGetResponseGRETunnelHealthCheckDirection = "bidirectional"` - `Enabled bool` Determines whether to run healthchecks for a tunnel. - `Rate HealthCheckRate` How frequent the health check is run. The default value is `mid`. - `const HealthCheckRateLow HealthCheckRate = "low"` - `const HealthCheckRateMid HealthCheckRate = "mid"` - `const HealthCheckRateHigh HealthCheckRate = "high"` - `Target GRETunnelGetResponseGRETunnelHealthCheckTargetUnion` The destination address in a request type health check. After the healthcheck is decapsulated at the customer end of the tunnel, the ICMP echo will be forwarded to this address. This field defaults to `customer_gre_endpoint address`. This field is ignored for bidirectional healthchecks as the interface_address (not assigned to the Cloudflare side of the tunnel) is used as the target. Must be in object form if the x-magic-new-hc-target header is set to true and string form if x-magic-new-hc-target is absent or set to false. - `type GRETunnelGetResponseGRETunnelHealthCheckTargetMagicHealthCheckTarget struct{…}` The destination address in a request type health check. After the healthcheck is decapsulated at the customer end of the tunnel, the ICMP echo will be forwarded to this address. This field defaults to `customer_gre_endpoint address`. This field is ignored for bidirectional healthchecks as the interface_address (not assigned to the Cloudflare side of the tunnel) is used as the target. - `Effective string` The effective health check target. If 'saved' is empty, then this field will be populated with the calculated default value on GET requests. Ignored in POST, PUT, and PATCH requests. - `Saved string` The saved health check target. Setting the value to the empty string indicates that the calculated default value will be used. - `UnionString` - `Type HealthCheckType` The type of healthcheck to run, reply or request. The default value is `reply`. - `const HealthCheckTypeReply HealthCheckType = "reply"` - `const HealthCheckTypeRequest HealthCheckType = "request"` - `InterfaceAddress6 string` A 127 bit IPV6 prefix from within the virtual_subnet6 prefix space with the address being the first IP of the subnet and not same as the address of virtual_subnet6. Eg if virtual_subnet6 is 2606:54c1:7:0:a9fe:12d2::/127 , interface_address6 could be 2606:54c1:7:0:a9fe:12d2:1:200/127 - `ModifiedOn Time` The date and time the tunnel was last modified. - `Mtu int64` Maximum Transmission Unit (MTU) in bytes for the GRE tunnel. The minimum value is 576. - `TTL int64` Time To Live (TTL) in number of hops of the GRE tunnel. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/magic_transit" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) greTunnel, err := client.MagicTransit.GRETunnels.Get( context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", magic_transit.GRETunnelGetParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", greTunnel.GRETunnel) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": { "gre_tunnel": { "id": "c4a7362d577a6c3019a474fd6f485821", "cloudflare_gre_endpoint": "203.0.113.1", "customer_gre_endpoint": "203.0.113.1", "interface_address": "192.0.2.0/31", "name": "GRE_1", "automatic_return_routing": true, "bgp": { "customer_asn": 0, "extra_prefixes": [ "string" ], "md5_key": "md5_key" }, "bgp_status": { "state": "BGP_DOWN", "tcp_established": true, "updated_at": "2019-12-27T18:11:19.117Z", "bgp_state": "bgp_state", "cf_speaker_ip": "192.168.1.1", "cf_speaker_port": 1, "customer_speaker_ip": "192.168.1.1", "customer_speaker_port": 1 }, "created_on": "2017-06-14T00:00:00Z", "description": "Tunnel for ISP X", "health_check": { "direction": "bidirectional", "enabled": true, "rate": "low", "target": { "effective": "203.0.113.1", "saved": "203.0.113.1" }, "type": "request" }, "interface_address6": "2606:54c1:7:0:a9fe:12d2:1:200/127", "modified_on": "2017-06-14T05:20:00Z", "mtu": 0, "ttl": 0 } }, "success": true } ``` ## Create a GRE tunnel `client.MagicTransit.GRETunnels.New(ctx, params) (*GRETunnelNewResponse, error)` **post** `/accounts/{account_id}/magic/gre_tunnels` Creates a new GRE tunnel. Use `?validate_only=true` as an optional query parameter to only run validation without persisting changes. ### Parameters - `params GRETunnelNewParams` - `AccountID param.Field[string]` Path param: Identifier - `CloudflareGREEndpoint param.Field[string]` Body param: The IP address assigned to the Cloudflare side of the GRE tunnel. - `CustomerGREEndpoint param.Field[string]` Body param: The IP address assigned to the customer side of the GRE tunnel. - `InterfaceAddress param.Field[string]` Body param: A 31-bit prefix (/31 in CIDR notation) supporting two hosts, one for each side of the tunnel. Select the subnet from the following private IP space: 10.0.0.0–10.255.255.255, 172.16.0.0–172.31.255.255, 192.168.0.0–192.168.255.255. - `Name param.Field[string]` Body param: The name of the tunnel. The name cannot contain spaces or special characters, must be 15 characters or less, and cannot share a name with another GRE tunnel. - `AutomaticReturnRouting param.Field[bool]` Body param: True if automatic stateful return routing should be enabled for a tunnel, false otherwise. - `BGP param.Field[GRETunnelNewParamsBGP]` Body param - `CustomerASN int64` ASN used on the customer end of the BGP session - `ExtraPrefixes []string` Prefixes in this list will be advertised to the customer device, in addition to the routes in the Magic routing table. - `Md5Key string` MD5 key to use for session authentication. Note that *this is not a security measure*. MD5 is not a valid security mechanism, and the key is not treated as a secret value. This is *only* supported for preventing misconfiguration, not for defending against malicious attacks. The MD5 key, if set, must be of non-zero length and consist only of the following types of character: * ASCII alphanumerics: `[a-zA-Z0-9]` * Special characters in the set `'!@#$%^&*()+[]{}<>/.,;:_-~`= |` In other words, MD5 keys may contain any printable ASCII character aside from newline (0x0A), quotation mark (`"`), vertical tab (0x0B), carriage return (0x0D), tab (0x09), form feed (0x0C), and the question mark (`?`). Requests specifying an MD5 key with one or more of these disallowed characters will be rejected. - `Description param.Field[string]` Body param: An optional description of the GRE tunnel. - `HealthCheck param.Field[GRETunnelNewParamsHealthCheck]` Body param - `Direction GRETunnelNewParamsHealthCheckDirection` The direction of the flow of the healthcheck. Either unidirectional, where the probe comes to you via the tunnel and the result comes back to Cloudflare via the open Internet, or bidirectional where both the probe and result come and go via the tunnel. - `const GRETunnelNewParamsHealthCheckDirectionUnidirectional GRETunnelNewParamsHealthCheckDirection = "unidirectional"` - `const GRETunnelNewParamsHealthCheckDirectionBidirectional GRETunnelNewParamsHealthCheckDirection = "bidirectional"` - `Enabled bool` Determines whether to run healthchecks for a tunnel. - `Rate HealthCheckRate` How frequent the health check is run. The default value is `mid`. - `const HealthCheckRateLow HealthCheckRate = "low"` - `const HealthCheckRateMid HealthCheckRate = "mid"` - `const HealthCheckRateHigh HealthCheckRate = "high"` - `Target GRETunnelNewParamsHealthCheckTargetUnion` The destination address in a request type health check. After the healthcheck is decapsulated at the customer end of the tunnel, the ICMP echo will be forwarded to this address. This field defaults to `customer_gre_endpoint address`. This field is ignored for bidirectional healthchecks as the interface_address (not assigned to the Cloudflare side of the tunnel) is used as the target. Must be in object form if the x-magic-new-hc-target header is set to true and string form if x-magic-new-hc-target is absent or set to false. - `type GRETunnelNewParamsHealthCheckTargetMagicHealthCheckTarget struct{…}` The destination address in a request type health check. After the healthcheck is decapsulated at the customer end of the tunnel, the ICMP echo will be forwarded to this address. This field defaults to `customer_gre_endpoint address`. This field is ignored for bidirectional healthchecks as the interface_address (not assigned to the Cloudflare side of the tunnel) is used as the target. - `Effective string` The effective health check target. If 'saved' is empty, then this field will be populated with the calculated default value on GET requests. Ignored in POST, PUT, and PATCH requests. - `Saved string` The saved health check target. Setting the value to the empty string indicates that the calculated default value will be used. - `UnionString` - `Type HealthCheckType` The type of healthcheck to run, reply or request. The default value is `reply`. - `const HealthCheckTypeReply HealthCheckType = "reply"` - `const HealthCheckTypeRequest HealthCheckType = "request"` - `InterfaceAddress6 param.Field[string]` Body param: A 127 bit IPV6 prefix from within the virtual_subnet6 prefix space with the address being the first IP of the subnet and not same as the address of virtual_subnet6. Eg if virtual_subnet6 is 2606:54c1:7:0:a9fe:12d2::/127 , interface_address6 could be 2606:54c1:7:0:a9fe:12d2:1:200/127 - `Mtu param.Field[int64]` Body param: Maximum Transmission Unit (MTU) in bytes for the GRE tunnel. The minimum value is 576. - `TTL param.Field[int64]` Body param: Time To Live (TTL) in number of hops of the GRE tunnel. - `XMagicNewHcTarget param.Field[bool]` Header param: If true, the health check target in the request and response bodies will be presented using the new object format. Defaults to false. ### Returns - `type GRETunnelNewResponse struct{…}` - `ID string` Identifier - `CloudflareGREEndpoint string` The IP address assigned to the Cloudflare side of the GRE tunnel. - `CustomerGREEndpoint string` The IP address assigned to the customer side of the GRE tunnel. - `InterfaceAddress string` A 31-bit prefix (/31 in CIDR notation) supporting two hosts, one for each side of the tunnel. Select the subnet from the following private IP space: 10.0.0.0–10.255.255.255, 172.16.0.0–172.31.255.255, 192.168.0.0–192.168.255.255. - `Name string` The name of the tunnel. The name cannot contain spaces or special characters, must be 15 characters or less, and cannot share a name with another GRE tunnel. - `AutomaticReturnRouting bool` True if automatic stateful return routing should be enabled for a tunnel, false otherwise. - `BGP GRETunnelNewResponseBGP` - `CustomerASN int64` ASN used on the customer end of the BGP session - `ExtraPrefixes []string` Prefixes in this list will be advertised to the customer device, in addition to the routes in the Magic routing table. - `Md5Key string` MD5 key to use for session authentication. Note that *this is not a security measure*. MD5 is not a valid security mechanism, and the key is not treated as a secret value. This is *only* supported for preventing misconfiguration, not for defending against malicious attacks. The MD5 key, if set, must be of non-zero length and consist only of the following types of character: * ASCII alphanumerics: `[a-zA-Z0-9]` * Special characters in the set `'!@#$%^&*()+[]{}<>/.,;:_-~`= |` In other words, MD5 keys may contain any printable ASCII character aside from newline (0x0A), quotation mark (`"`), vertical tab (0x0B), carriage return (0x0D), tab (0x09), form feed (0x0C), and the question mark (`?`). Requests specifying an MD5 key with one or more of these disallowed characters will be rejected. - `BGPStatus GRETunnelNewResponseBGPStatus` - `State GRETunnelNewResponseBGPStatusState` - `const GRETunnelNewResponseBGPStatusStateBGPDown GRETunnelNewResponseBGPStatusState = "BGP_DOWN"` - `const GRETunnelNewResponseBGPStatusStateBGPUp GRETunnelNewResponseBGPStatusState = "BGP_UP"` - `const GRETunnelNewResponseBGPStatusStateBGPEstablishing GRETunnelNewResponseBGPStatusState = "BGP_ESTABLISHING"` - `TCPEstablished bool` - `UpdatedAt Time` - `BGPState string` - `CfSpeakerIP string` - `CfSpeakerPort int64` - `CustomerSpeakerIP string` - `CustomerSpeakerPort int64` - `CreatedOn Time` The date and time the tunnel was created. - `Description string` An optional description of the GRE tunnel. - `HealthCheck GRETunnelNewResponseHealthCheck` - `Direction GRETunnelNewResponseHealthCheckDirection` The direction of the flow of the healthcheck. Either unidirectional, where the probe comes to you via the tunnel and the result comes back to Cloudflare via the open Internet, or bidirectional where both the probe and result come and go via the tunnel. - `const GRETunnelNewResponseHealthCheckDirectionUnidirectional GRETunnelNewResponseHealthCheckDirection = "unidirectional"` - `const GRETunnelNewResponseHealthCheckDirectionBidirectional GRETunnelNewResponseHealthCheckDirection = "bidirectional"` - `Enabled bool` Determines whether to run healthchecks for a tunnel. - `Rate HealthCheckRate` How frequent the health check is run. The default value is `mid`. - `const HealthCheckRateLow HealthCheckRate = "low"` - `const HealthCheckRateMid HealthCheckRate = "mid"` - `const HealthCheckRateHigh HealthCheckRate = "high"` - `Target GRETunnelNewResponseHealthCheckTargetUnion` The destination address in a request type health check. After the healthcheck is decapsulated at the customer end of the tunnel, the ICMP echo will be forwarded to this address. This field defaults to `customer_gre_endpoint address`. This field is ignored for bidirectional healthchecks as the interface_address (not assigned to the Cloudflare side of the tunnel) is used as the target. Must be in object form if the x-magic-new-hc-target header is set to true and string form if x-magic-new-hc-target is absent or set to false. - `type GRETunnelNewResponseHealthCheckTargetMagicHealthCheckTarget struct{…}` The destination address in a request type health check. After the healthcheck is decapsulated at the customer end of the tunnel, the ICMP echo will be forwarded to this address. This field defaults to `customer_gre_endpoint address`. This field is ignored for bidirectional healthchecks as the interface_address (not assigned to the Cloudflare side of the tunnel) is used as the target. - `Effective string` The effective health check target. If 'saved' is empty, then this field will be populated with the calculated default value on GET requests. Ignored in POST, PUT, and PATCH requests. - `Saved string` The saved health check target. Setting the value to the empty string indicates that the calculated default value will be used. - `UnionString` - `Type HealthCheckType` The type of healthcheck to run, reply or request. The default value is `reply`. - `const HealthCheckTypeReply HealthCheckType = "reply"` - `const HealthCheckTypeRequest HealthCheckType = "request"` - `InterfaceAddress6 string` A 127 bit IPV6 prefix from within the virtual_subnet6 prefix space with the address being the first IP of the subnet and not same as the address of virtual_subnet6. Eg if virtual_subnet6 is 2606:54c1:7:0:a9fe:12d2::/127 , interface_address6 could be 2606:54c1:7:0:a9fe:12d2:1:200/127 - `ModifiedOn Time` The date and time the tunnel was last modified. - `Mtu int64` Maximum Transmission Unit (MTU) in bytes for the GRE tunnel. The minimum value is 576. - `TTL int64` Time To Live (TTL) in number of hops of the GRE tunnel. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/magic_transit" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) greTunnel, err := client.MagicTransit.GRETunnels.New(context.TODO(), magic_transit.GRETunnelNewParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), CloudflareGREEndpoint: cloudflare.F("203.0.113.1"), CustomerGREEndpoint: cloudflare.F("203.0.113.1"), InterfaceAddress: cloudflare.F("192.0.2.0/31"), Name: cloudflare.F("GRE_1"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", greTunnel.ID) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": { "id": "c4a7362d577a6c3019a474fd6f485821", "cloudflare_gre_endpoint": "203.0.113.1", "customer_gre_endpoint": "203.0.113.1", "interface_address": "192.0.2.0/31", "name": "GRE_1", "automatic_return_routing": true, "bgp": { "customer_asn": 0, "extra_prefixes": [ "string" ], "md5_key": "md5_key" }, "bgp_status": { "state": "BGP_DOWN", "tcp_established": true, "updated_at": "2019-12-27T18:11:19.117Z", "bgp_state": "bgp_state", "cf_speaker_ip": "192.168.1.1", "cf_speaker_port": 1, "customer_speaker_ip": "192.168.1.1", "customer_speaker_port": 1 }, "created_on": "2017-06-14T00:00:00Z", "description": "Tunnel for ISP X", "health_check": { "direction": "bidirectional", "enabled": true, "rate": "low", "target": { "effective": "203.0.113.1", "saved": "203.0.113.1" }, "type": "request" }, "interface_address6": "2606:54c1:7:0:a9fe:12d2:1:200/127", "modified_on": "2017-06-14T05:20:00Z", "mtu": 0, "ttl": 0 }, "success": true } ``` ## Update GRE Tunnel `client.MagicTransit.GRETunnels.Update(ctx, greTunnelID, params) (*GRETunnelUpdateResponse, error)` **put** `/accounts/{account_id}/magic/gre_tunnels/{gre_tunnel_id}` Updates a specific GRE tunnel. Use `?validate_only=true` as an optional query parameter to only run validation without persisting changes. ### Parameters - `greTunnelID string` Identifier - `params GRETunnelUpdateParams` - `AccountID param.Field[string]` Path param: Identifier - `CloudflareGREEndpoint param.Field[string]` Body param: The IP address assigned to the Cloudflare side of the GRE tunnel. - `CustomerGREEndpoint param.Field[string]` Body param: The IP address assigned to the customer side of the GRE tunnel. - `InterfaceAddress param.Field[string]` Body param: A 31-bit prefix (/31 in CIDR notation) supporting two hosts, one for each side of the tunnel. Select the subnet from the following private IP space: 10.0.0.0–10.255.255.255, 172.16.0.0–172.31.255.255, 192.168.0.0–192.168.255.255. - `Name param.Field[string]` Body param: The name of the tunnel. The name cannot contain spaces or special characters, must be 15 characters or less, and cannot share a name with another GRE tunnel. - `AutomaticReturnRouting param.Field[bool]` Body param: True if automatic stateful return routing should be enabled for a tunnel, false otherwise. - `Description param.Field[string]` Body param: An optional description of the GRE tunnel. - `HealthCheck param.Field[GRETunnelUpdateParamsHealthCheck]` Body param - `Direction GRETunnelUpdateParamsHealthCheckDirection` The direction of the flow of the healthcheck. Either unidirectional, where the probe comes to you via the tunnel and the result comes back to Cloudflare via the open Internet, or bidirectional where both the probe and result come and go via the tunnel. - `const GRETunnelUpdateParamsHealthCheckDirectionUnidirectional GRETunnelUpdateParamsHealthCheckDirection = "unidirectional"` - `const GRETunnelUpdateParamsHealthCheckDirectionBidirectional GRETunnelUpdateParamsHealthCheckDirection = "bidirectional"` - `Enabled bool` Determines whether to run healthchecks for a tunnel. - `Rate HealthCheckRate` How frequent the health check is run. The default value is `mid`. - `const HealthCheckRateLow HealthCheckRate = "low"` - `const HealthCheckRateMid HealthCheckRate = "mid"` - `const HealthCheckRateHigh HealthCheckRate = "high"` - `Target GRETunnelUpdateParamsHealthCheckTargetUnion` The destination address in a request type health check. After the healthcheck is decapsulated at the customer end of the tunnel, the ICMP echo will be forwarded to this address. This field defaults to `customer_gre_endpoint address`. This field is ignored for bidirectional healthchecks as the interface_address (not assigned to the Cloudflare side of the tunnel) is used as the target. Must be in object form if the x-magic-new-hc-target header is set to true and string form if x-magic-new-hc-target is absent or set to false. - `type GRETunnelUpdateParamsHealthCheckTargetMagicHealthCheckTarget struct{…}` The destination address in a request type health check. After the healthcheck is decapsulated at the customer end of the tunnel, the ICMP echo will be forwarded to this address. This field defaults to `customer_gre_endpoint address`. This field is ignored for bidirectional healthchecks as the interface_address (not assigned to the Cloudflare side of the tunnel) is used as the target. - `Effective string` The effective health check target. If 'saved' is empty, then this field will be populated with the calculated default value on GET requests. Ignored in POST, PUT, and PATCH requests. - `Saved string` The saved health check target. Setting the value to the empty string indicates that the calculated default value will be used. - `UnionString` - `Type HealthCheckType` The type of healthcheck to run, reply or request. The default value is `reply`. - `const HealthCheckTypeReply HealthCheckType = "reply"` - `const HealthCheckTypeRequest HealthCheckType = "request"` - `InterfaceAddress6 param.Field[string]` Body param: A 127 bit IPV6 prefix from within the virtual_subnet6 prefix space with the address being the first IP of the subnet and not same as the address of virtual_subnet6. Eg if virtual_subnet6 is 2606:54c1:7:0:a9fe:12d2::/127 , interface_address6 could be 2606:54c1:7:0:a9fe:12d2:1:200/127 - `Mtu param.Field[int64]` Body param: Maximum Transmission Unit (MTU) in bytes for the GRE tunnel. The minimum value is 576. - `TTL param.Field[int64]` Body param: Time To Live (TTL) in number of hops of the GRE tunnel. - `XMagicNewHcTarget param.Field[bool]` Header param: If true, the health check target in the request and response bodies will be presented using the new object format. Defaults to false. ### Returns - `type GRETunnelUpdateResponse struct{…}` - `Modified bool` - `ModifiedGRETunnel GRETunnelUpdateResponseModifiedGRETunnel` - `ID string` Identifier - `CloudflareGREEndpoint string` The IP address assigned to the Cloudflare side of the GRE tunnel. - `CustomerGREEndpoint string` The IP address assigned to the customer side of the GRE tunnel. - `InterfaceAddress string` A 31-bit prefix (/31 in CIDR notation) supporting two hosts, one for each side of the tunnel. Select the subnet from the following private IP space: 10.0.0.0–10.255.255.255, 172.16.0.0–172.31.255.255, 192.168.0.0–192.168.255.255. - `Name string` The name of the tunnel. The name cannot contain spaces or special characters, must be 15 characters or less, and cannot share a name with another GRE tunnel. - `AutomaticReturnRouting bool` True if automatic stateful return routing should be enabled for a tunnel, false otherwise. - `BGP GRETunnelUpdateResponseModifiedGRETunnelBGP` - `CustomerASN int64` ASN used on the customer end of the BGP session - `ExtraPrefixes []string` Prefixes in this list will be advertised to the customer device, in addition to the routes in the Magic routing table. - `Md5Key string` MD5 key to use for session authentication. Note that *this is not a security measure*. MD5 is not a valid security mechanism, and the key is not treated as a secret value. This is *only* supported for preventing misconfiguration, not for defending against malicious attacks. The MD5 key, if set, must be of non-zero length and consist only of the following types of character: * ASCII alphanumerics: `[a-zA-Z0-9]` * Special characters in the set `'!@#$%^&*()+[]{}<>/.,;:_-~`= |` In other words, MD5 keys may contain any printable ASCII character aside from newline (0x0A), quotation mark (`"`), vertical tab (0x0B), carriage return (0x0D), tab (0x09), form feed (0x0C), and the question mark (`?`). Requests specifying an MD5 key with one or more of these disallowed characters will be rejected. - `BGPStatus GRETunnelUpdateResponseModifiedGRETunnelBGPStatus` - `State GRETunnelUpdateResponseModifiedGRETunnelBGPStatusState` - `const GRETunnelUpdateResponseModifiedGRETunnelBGPStatusStateBGPDown GRETunnelUpdateResponseModifiedGRETunnelBGPStatusState = "BGP_DOWN"` - `const GRETunnelUpdateResponseModifiedGRETunnelBGPStatusStateBGPUp GRETunnelUpdateResponseModifiedGRETunnelBGPStatusState = "BGP_UP"` - `const GRETunnelUpdateResponseModifiedGRETunnelBGPStatusStateBGPEstablishing GRETunnelUpdateResponseModifiedGRETunnelBGPStatusState = "BGP_ESTABLISHING"` - `TCPEstablished bool` - `UpdatedAt Time` - `BGPState string` - `CfSpeakerIP string` - `CfSpeakerPort int64` - `CustomerSpeakerIP string` - `CustomerSpeakerPort int64` - `CreatedOn Time` The date and time the tunnel was created. - `Description string` An optional description of the GRE tunnel. - `HealthCheck GRETunnelUpdateResponseModifiedGRETunnelHealthCheck` - `Direction GRETunnelUpdateResponseModifiedGRETunnelHealthCheckDirection` The direction of the flow of the healthcheck. Either unidirectional, where the probe comes to you via the tunnel and the result comes back to Cloudflare via the open Internet, or bidirectional where both the probe and result come and go via the tunnel. - `const GRETunnelUpdateResponseModifiedGRETunnelHealthCheckDirectionUnidirectional GRETunnelUpdateResponseModifiedGRETunnelHealthCheckDirection = "unidirectional"` - `const GRETunnelUpdateResponseModifiedGRETunnelHealthCheckDirectionBidirectional GRETunnelUpdateResponseModifiedGRETunnelHealthCheckDirection = "bidirectional"` - `Enabled bool` Determines whether to run healthchecks for a tunnel. - `Rate HealthCheckRate` How frequent the health check is run. The default value is `mid`. - `const HealthCheckRateLow HealthCheckRate = "low"` - `const HealthCheckRateMid HealthCheckRate = "mid"` - `const HealthCheckRateHigh HealthCheckRate = "high"` - `Target GRETunnelUpdateResponseModifiedGRETunnelHealthCheckTargetUnion` The destination address in a request type health check. After the healthcheck is decapsulated at the customer end of the tunnel, the ICMP echo will be forwarded to this address. This field defaults to `customer_gre_endpoint address`. This field is ignored for bidirectional healthchecks as the interface_address (not assigned to the Cloudflare side of the tunnel) is used as the target. Must be in object form if the x-magic-new-hc-target header is set to true and string form if x-magic-new-hc-target is absent or set to false. - `type GRETunnelUpdateResponseModifiedGRETunnelHealthCheckTargetMagicHealthCheckTarget struct{…}` The destination address in a request type health check. After the healthcheck is decapsulated at the customer end of the tunnel, the ICMP echo will be forwarded to this address. This field defaults to `customer_gre_endpoint address`. This field is ignored for bidirectional healthchecks as the interface_address (not assigned to the Cloudflare side of the tunnel) is used as the target. - `Effective string` The effective health check target. If 'saved' is empty, then this field will be populated with the calculated default value on GET requests. Ignored in POST, PUT, and PATCH requests. - `Saved string` The saved health check target. Setting the value to the empty string indicates that the calculated default value will be used. - `UnionString` - `Type HealthCheckType` The type of healthcheck to run, reply or request. The default value is `reply`. - `const HealthCheckTypeReply HealthCheckType = "reply"` - `const HealthCheckTypeRequest HealthCheckType = "request"` - `InterfaceAddress6 string` A 127 bit IPV6 prefix from within the virtual_subnet6 prefix space with the address being the first IP of the subnet and not same as the address of virtual_subnet6. Eg if virtual_subnet6 is 2606:54c1:7:0:a9fe:12d2::/127 , interface_address6 could be 2606:54c1:7:0:a9fe:12d2:1:200/127 - `ModifiedOn Time` The date and time the tunnel was last modified. - `Mtu int64` Maximum Transmission Unit (MTU) in bytes for the GRE tunnel. The minimum value is 576. - `TTL int64` Time To Live (TTL) in number of hops of the GRE tunnel. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/magic_transit" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) greTunnel, err := client.MagicTransit.GRETunnels.Update( context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", magic_transit.GRETunnelUpdateParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), CloudflareGREEndpoint: cloudflare.F("203.0.113.1"), CustomerGREEndpoint: cloudflare.F("203.0.113.1"), InterfaceAddress: cloudflare.F("192.0.2.0/31"), Name: cloudflare.F("GRE_1"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", greTunnel.Modified) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": { "modified": true, "modified_gre_tunnel": { "id": "c4a7362d577a6c3019a474fd6f485821", "cloudflare_gre_endpoint": "203.0.113.1", "customer_gre_endpoint": "203.0.113.1", "interface_address": "192.0.2.0/31", "name": "GRE_1", "automatic_return_routing": true, "bgp": { "customer_asn": 0, "extra_prefixes": [ "string" ], "md5_key": "md5_key" }, "bgp_status": { "state": "BGP_DOWN", "tcp_established": true, "updated_at": "2019-12-27T18:11:19.117Z", "bgp_state": "bgp_state", "cf_speaker_ip": "192.168.1.1", "cf_speaker_port": 1, "customer_speaker_ip": "192.168.1.1", "customer_speaker_port": 1 }, "created_on": "2017-06-14T00:00:00Z", "description": "Tunnel for ISP X", "health_check": { "direction": "bidirectional", "enabled": true, "rate": "low", "target": { "effective": "203.0.113.1", "saved": "203.0.113.1" }, "type": "request" }, "interface_address6": "2606:54c1:7:0:a9fe:12d2:1:200/127", "modified_on": "2017-06-14T05:20:00Z", "mtu": 0, "ttl": 0 } }, "success": true } ``` ## Delete GRE Tunnel `client.MagicTransit.GRETunnels.Delete(ctx, greTunnelID, params) (*GRETunnelDeleteResponse, error)` **delete** `/accounts/{account_id}/magic/gre_tunnels/{gre_tunnel_id}` Disables and removes a specific static GRE tunnel. Use `?validate_only=true` as an optional query parameter to only run validation without persisting changes. ### Parameters - `greTunnelID string` Identifier - `params GRETunnelDeleteParams` - `AccountID param.Field[string]` Path param: Identifier - `XMagicNewHcTarget param.Field[bool]` Header param: If true, the health check target in the response body will be presented using the new object format. Defaults to false. ### Returns - `type GRETunnelDeleteResponse struct{…}` - `Deleted bool` - `DeletedGRETunnel GRETunnelDeleteResponseDeletedGRETunnel` - `ID string` Identifier - `CloudflareGREEndpoint string` The IP address assigned to the Cloudflare side of the GRE tunnel. - `CustomerGREEndpoint string` The IP address assigned to the customer side of the GRE tunnel. - `InterfaceAddress string` A 31-bit prefix (/31 in CIDR notation) supporting two hosts, one for each side of the tunnel. Select the subnet from the following private IP space: 10.0.0.0–10.255.255.255, 172.16.0.0–172.31.255.255, 192.168.0.0–192.168.255.255. - `Name string` The name of the tunnel. The name cannot contain spaces or special characters, must be 15 characters or less, and cannot share a name with another GRE tunnel. - `AutomaticReturnRouting bool` True if automatic stateful return routing should be enabled for a tunnel, false otherwise. - `BGP GRETunnelDeleteResponseDeletedGRETunnelBGP` - `CustomerASN int64` ASN used on the customer end of the BGP session - `ExtraPrefixes []string` Prefixes in this list will be advertised to the customer device, in addition to the routes in the Magic routing table. - `Md5Key string` MD5 key to use for session authentication. Note that *this is not a security measure*. MD5 is not a valid security mechanism, and the key is not treated as a secret value. This is *only* supported for preventing misconfiguration, not for defending against malicious attacks. The MD5 key, if set, must be of non-zero length and consist only of the following types of character: * ASCII alphanumerics: `[a-zA-Z0-9]` * Special characters in the set `'!@#$%^&*()+[]{}<>/.,;:_-~`= |` In other words, MD5 keys may contain any printable ASCII character aside from newline (0x0A), quotation mark (`"`), vertical tab (0x0B), carriage return (0x0D), tab (0x09), form feed (0x0C), and the question mark (`?`). Requests specifying an MD5 key with one or more of these disallowed characters will be rejected. - `BGPStatus GRETunnelDeleteResponseDeletedGRETunnelBGPStatus` - `State GRETunnelDeleteResponseDeletedGRETunnelBGPStatusState` - `const GRETunnelDeleteResponseDeletedGRETunnelBGPStatusStateBGPDown GRETunnelDeleteResponseDeletedGRETunnelBGPStatusState = "BGP_DOWN"` - `const GRETunnelDeleteResponseDeletedGRETunnelBGPStatusStateBGPUp GRETunnelDeleteResponseDeletedGRETunnelBGPStatusState = "BGP_UP"` - `const GRETunnelDeleteResponseDeletedGRETunnelBGPStatusStateBGPEstablishing GRETunnelDeleteResponseDeletedGRETunnelBGPStatusState = "BGP_ESTABLISHING"` - `TCPEstablished bool` - `UpdatedAt Time` - `BGPState string` - `CfSpeakerIP string` - `CfSpeakerPort int64` - `CustomerSpeakerIP string` - `CustomerSpeakerPort int64` - `CreatedOn Time` The date and time the tunnel was created. - `Description string` An optional description of the GRE tunnel. - `HealthCheck GRETunnelDeleteResponseDeletedGRETunnelHealthCheck` - `Direction GRETunnelDeleteResponseDeletedGRETunnelHealthCheckDirection` The direction of the flow of the healthcheck. Either unidirectional, where the probe comes to you via the tunnel and the result comes back to Cloudflare via the open Internet, or bidirectional where both the probe and result come and go via the tunnel. - `const GRETunnelDeleteResponseDeletedGRETunnelHealthCheckDirectionUnidirectional GRETunnelDeleteResponseDeletedGRETunnelHealthCheckDirection = "unidirectional"` - `const GRETunnelDeleteResponseDeletedGRETunnelHealthCheckDirectionBidirectional GRETunnelDeleteResponseDeletedGRETunnelHealthCheckDirection = "bidirectional"` - `Enabled bool` Determines whether to run healthchecks for a tunnel. - `Rate HealthCheckRate` How frequent the health check is run. The default value is `mid`. - `const HealthCheckRateLow HealthCheckRate = "low"` - `const HealthCheckRateMid HealthCheckRate = "mid"` - `const HealthCheckRateHigh HealthCheckRate = "high"` - `Target GRETunnelDeleteResponseDeletedGRETunnelHealthCheckTargetUnion` The destination address in a request type health check. After the healthcheck is decapsulated at the customer end of the tunnel, the ICMP echo will be forwarded to this address. This field defaults to `customer_gre_endpoint address`. This field is ignored for bidirectional healthchecks as the interface_address (not assigned to the Cloudflare side of the tunnel) is used as the target. Must be in object form if the x-magic-new-hc-target header is set to true and string form if x-magic-new-hc-target is absent or set to false. - `type GRETunnelDeleteResponseDeletedGRETunnelHealthCheckTargetMagicHealthCheckTarget struct{…}` The destination address in a request type health check. After the healthcheck is decapsulated at the customer end of the tunnel, the ICMP echo will be forwarded to this address. This field defaults to `customer_gre_endpoint address`. This field is ignored for bidirectional healthchecks as the interface_address (not assigned to the Cloudflare side of the tunnel) is used as the target. - `Effective string` The effective health check target. If 'saved' is empty, then this field will be populated with the calculated default value on GET requests. Ignored in POST, PUT, and PATCH requests. - `Saved string` The saved health check target. Setting the value to the empty string indicates that the calculated default value will be used. - `UnionString` - `Type HealthCheckType` The type of healthcheck to run, reply or request. The default value is `reply`. - `const HealthCheckTypeReply HealthCheckType = "reply"` - `const HealthCheckTypeRequest HealthCheckType = "request"` - `InterfaceAddress6 string` A 127 bit IPV6 prefix from within the virtual_subnet6 prefix space with the address being the first IP of the subnet and not same as the address of virtual_subnet6. Eg if virtual_subnet6 is 2606:54c1:7:0:a9fe:12d2::/127 , interface_address6 could be 2606:54c1:7:0:a9fe:12d2:1:200/127 - `ModifiedOn Time` The date and time the tunnel was last modified. - `Mtu int64` Maximum Transmission Unit (MTU) in bytes for the GRE tunnel. The minimum value is 576. - `TTL int64` Time To Live (TTL) in number of hops of the GRE tunnel. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/magic_transit" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) greTunnel, err := client.MagicTransit.GRETunnels.Delete( context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", magic_transit.GRETunnelDeleteParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", greTunnel.Deleted) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": { "deleted": true, "deleted_gre_tunnel": { "id": "c4a7362d577a6c3019a474fd6f485821", "cloudflare_gre_endpoint": "203.0.113.1", "customer_gre_endpoint": "203.0.113.1", "interface_address": "192.0.2.0/31", "name": "GRE_1", "automatic_return_routing": true, "bgp": { "customer_asn": 0, "extra_prefixes": [ "string" ], "md5_key": "md5_key" }, "bgp_status": { "state": "BGP_DOWN", "tcp_established": true, "updated_at": "2019-12-27T18:11:19.117Z", "bgp_state": "bgp_state", "cf_speaker_ip": "192.168.1.1", "cf_speaker_port": 1, "customer_speaker_ip": "192.168.1.1", "customer_speaker_port": 1 }, "created_on": "2017-06-14T00:00:00Z", "description": "Tunnel for ISP X", "health_check": { "direction": "bidirectional", "enabled": true, "rate": "low", "target": { "effective": "203.0.113.1", "saved": "203.0.113.1" }, "type": "request" }, "interface_address6": "2606:54c1:7:0:a9fe:12d2:1:200/127", "modified_on": "2017-06-14T05:20:00Z", "mtu": 0, "ttl": 0 } }, "success": true } ``` ## Update multiple GRE tunnels `client.MagicTransit.GRETunnels.BulkUpdate(ctx, params) (*GRETunnelBulkUpdateResponse, error)` **put** `/accounts/{account_id}/magic/gre_tunnels` Updates multiple GRE tunnels. Use `?validate_only=true` as an optional query parameter to only run validation without persisting changes. ### Parameters - `params GRETunnelBulkUpdateParams` - `AccountID param.Field[string]` Path param: Identifier - `Body param.Field[unknown]` Body param - `XMagicNewHcTarget param.Field[bool]` Header param: If true, the health check target in the request and response bodies will be presented using the new object format. Defaults to false. ### Returns - `type GRETunnelBulkUpdateResponse struct{…}` - `Modified bool` - `ModifiedGRETunnels []GRETunnelBulkUpdateResponseModifiedGRETunnel` - `ID string` Identifier - `CloudflareGREEndpoint string` The IP address assigned to the Cloudflare side of the GRE tunnel. - `CustomerGREEndpoint string` The IP address assigned to the customer side of the GRE tunnel. - `InterfaceAddress string` A 31-bit prefix (/31 in CIDR notation) supporting two hosts, one for each side of the tunnel. Select the subnet from the following private IP space: 10.0.0.0–10.255.255.255, 172.16.0.0–172.31.255.255, 192.168.0.0–192.168.255.255. - `Name string` The name of the tunnel. The name cannot contain spaces or special characters, must be 15 characters or less, and cannot share a name with another GRE tunnel. - `AutomaticReturnRouting bool` True if automatic stateful return routing should be enabled for a tunnel, false otherwise. - `BGP GRETunnelBulkUpdateResponseModifiedGRETunnelsBGP` - `CustomerASN int64` ASN used on the customer end of the BGP session - `ExtraPrefixes []string` Prefixes in this list will be advertised to the customer device, in addition to the routes in the Magic routing table. - `Md5Key string` MD5 key to use for session authentication. Note that *this is not a security measure*. MD5 is not a valid security mechanism, and the key is not treated as a secret value. This is *only* supported for preventing misconfiguration, not for defending against malicious attacks. The MD5 key, if set, must be of non-zero length and consist only of the following types of character: * ASCII alphanumerics: `[a-zA-Z0-9]` * Special characters in the set `'!@#$%^&*()+[]{}<>/.,;:_-~`= |` In other words, MD5 keys may contain any printable ASCII character aside from newline (0x0A), quotation mark (`"`), vertical tab (0x0B), carriage return (0x0D), tab (0x09), form feed (0x0C), and the question mark (`?`). Requests specifying an MD5 key with one or more of these disallowed characters will be rejected. - `BGPStatus GRETunnelBulkUpdateResponseModifiedGRETunnelsBGPStatus` - `State GRETunnelBulkUpdateResponseModifiedGRETunnelsBGPStatusState` - `const GRETunnelBulkUpdateResponseModifiedGRETunnelsBGPStatusStateBGPDown GRETunnelBulkUpdateResponseModifiedGRETunnelsBGPStatusState = "BGP_DOWN"` - `const GRETunnelBulkUpdateResponseModifiedGRETunnelsBGPStatusStateBGPUp GRETunnelBulkUpdateResponseModifiedGRETunnelsBGPStatusState = "BGP_UP"` - `const GRETunnelBulkUpdateResponseModifiedGRETunnelsBGPStatusStateBGPEstablishing GRETunnelBulkUpdateResponseModifiedGRETunnelsBGPStatusState = "BGP_ESTABLISHING"` - `TCPEstablished bool` - `UpdatedAt Time` - `BGPState string` - `CfSpeakerIP string` - `CfSpeakerPort int64` - `CustomerSpeakerIP string` - `CustomerSpeakerPort int64` - `CreatedOn Time` The date and time the tunnel was created. - `Description string` An optional description of the GRE tunnel. - `HealthCheck GRETunnelBulkUpdateResponseModifiedGRETunnelsHealthCheck` - `Direction GRETunnelBulkUpdateResponseModifiedGRETunnelsHealthCheckDirection` The direction of the flow of the healthcheck. Either unidirectional, where the probe comes to you via the tunnel and the result comes back to Cloudflare via the open Internet, or bidirectional where both the probe and result come and go via the tunnel. - `const GRETunnelBulkUpdateResponseModifiedGRETunnelsHealthCheckDirectionUnidirectional GRETunnelBulkUpdateResponseModifiedGRETunnelsHealthCheckDirection = "unidirectional"` - `const GRETunnelBulkUpdateResponseModifiedGRETunnelsHealthCheckDirectionBidirectional GRETunnelBulkUpdateResponseModifiedGRETunnelsHealthCheckDirection = "bidirectional"` - `Enabled bool` Determines whether to run healthchecks for a tunnel. - `Rate HealthCheckRate` How frequent the health check is run. The default value is `mid`. - `const HealthCheckRateLow HealthCheckRate = "low"` - `const HealthCheckRateMid HealthCheckRate = "mid"` - `const HealthCheckRateHigh HealthCheckRate = "high"` - `Target GRETunnelBulkUpdateResponseModifiedGRETunnelsHealthCheckTargetUnion` The destination address in a request type health check. After the healthcheck is decapsulated at the customer end of the tunnel, the ICMP echo will be forwarded to this address. This field defaults to `customer_gre_endpoint address`. This field is ignored for bidirectional healthchecks as the interface_address (not assigned to the Cloudflare side of the tunnel) is used as the target. Must be in object form if the x-magic-new-hc-target header is set to true and string form if x-magic-new-hc-target is absent or set to false. - `type GRETunnelBulkUpdateResponseModifiedGRETunnelsHealthCheckTargetMagicHealthCheckTarget struct{…}` The destination address in a request type health check. After the healthcheck is decapsulated at the customer end of the tunnel, the ICMP echo will be forwarded to this address. This field defaults to `customer_gre_endpoint address`. This field is ignored for bidirectional healthchecks as the interface_address (not assigned to the Cloudflare side of the tunnel) is used as the target. - `Effective string` The effective health check target. If 'saved' is empty, then this field will be populated with the calculated default value on GET requests. Ignored in POST, PUT, and PATCH requests. - `Saved string` The saved health check target. Setting the value to the empty string indicates that the calculated default value will be used. - `UnionString` - `Type HealthCheckType` The type of healthcheck to run, reply or request. The default value is `reply`. - `const HealthCheckTypeReply HealthCheckType = "reply"` - `const HealthCheckTypeRequest HealthCheckType = "request"` - `InterfaceAddress6 string` A 127 bit IPV6 prefix from within the virtual_subnet6 prefix space with the address being the first IP of the subnet and not same as the address of virtual_subnet6. Eg if virtual_subnet6 is 2606:54c1:7:0:a9fe:12d2::/127 , interface_address6 could be 2606:54c1:7:0:a9fe:12d2:1:200/127 - `ModifiedOn Time` The date and time the tunnel was last modified. - `Mtu int64` Maximum Transmission Unit (MTU) in bytes for the GRE tunnel. The minimum value is 576. - `TTL int64` Time To Live (TTL) in number of hops of the GRE tunnel. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/magic_transit" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) response, err := client.MagicTransit.GRETunnels.BulkUpdate(context.TODO(), magic_transit.GRETunnelBulkUpdateParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Body: map[string]interface{}{ }, }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", response.Modified) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": { "modified": true, "modified_gre_tunnels": [ { "id": "c4a7362d577a6c3019a474fd6f485821", "cloudflare_gre_endpoint": "203.0.113.1", "customer_gre_endpoint": "203.0.113.1", "interface_address": "192.0.2.0/31", "name": "GRE_1", "automatic_return_routing": true, "bgp": { "customer_asn": 0, "extra_prefixes": [ "string" ], "md5_key": "md5_key" }, "bgp_status": { "state": "BGP_DOWN", "tcp_established": true, "updated_at": "2019-12-27T18:11:19.117Z", "bgp_state": "bgp_state", "cf_speaker_ip": "192.168.1.1", "cf_speaker_port": 1, "customer_speaker_ip": "192.168.1.1", "customer_speaker_port": 1 }, "created_on": "2017-06-14T00:00:00Z", "description": "Tunnel for ISP X", "health_check": { "direction": "bidirectional", "enabled": true, "rate": "low", "target": { "effective": "203.0.113.1", "saved": "203.0.113.1" }, "type": "request" }, "interface_address6": "2606:54c1:7:0:a9fe:12d2:1:200/127", "modified_on": "2017-06-14T05:20:00Z", "mtu": 0, "ttl": 0 } ] }, "success": true } ```