# Networks # Routes ## List tunnel routes `client.ZeroTrust.Networks.Routes.List(ctx, params) (*V4PagePaginationArray[Teamnet], error)` **get** `/accounts/{account_id}/teamnet/routes` Lists and filters private network routes in an account. ### Parameters - `params NetworkRouteListParams` - `AccountID param.Field[string]` Path param: Cloudflare account ID - `Comment param.Field[string]` Query param: Optional remark describing the route. - `ExistedAt param.Field[string]` Query param: If provided, include only resources that were created (and not deleted) before this time. URL encoded. - `IsDeleted param.Field[bool]` Query param: If `true`, only include deleted routes. If `false`, exclude deleted routes. If empty, all routes will be included. - `NetworkSubset param.Field[string]` Query param: If set, only list routes that are contained within this IP range. - `NetworkSuperset param.Field[string]` Query param: If set, only list routes that contain this IP range. - `Page param.Field[float64]` Query param: Page number of paginated results. - `PerPage param.Field[float64]` Query param: Number of results to display. - `RouteID param.Field[string]` Query param: UUID of the route. - `TunTypes param.Field[[]NetworkRouteListParamsTunType]` Query param: The types of tunnels to filter by, separated by commas. - `const NetworkRouteListParamsTunTypeCfdTunnel NetworkRouteListParamsTunType = "cfd_tunnel"` - `const NetworkRouteListParamsTunTypeWARPConnector NetworkRouteListParamsTunType = "warp_connector"` - `const NetworkRouteListParamsTunTypeWARP NetworkRouteListParamsTunType = "warp"` - `const NetworkRouteListParamsTunTypeMagic NetworkRouteListParamsTunType = "magic"` - `const NetworkRouteListParamsTunTypeIPSec NetworkRouteListParamsTunType = "ip_sec"` - `const NetworkRouteListParamsTunTypeGRE NetworkRouteListParamsTunType = "gre"` - `const NetworkRouteListParamsTunTypeCNI NetworkRouteListParamsTunType = "cni"` - `TunnelID param.Field[string]` Query param: UUID of the tunnel. - `VirtualNetworkID param.Field[string]` Query param: UUID of the virtual network. ### Returns - `type Teamnet struct{…}` - `ID string` UUID of the route. - `Comment string` Optional remark describing the route. - `CreatedAt Time` Timestamp of when the resource was created. - `DeletedAt Time` Timestamp of when the resource was deleted. If `null`, the resource has not been deleted. - `Network string` The private IPv4 or IPv6 range connected by the route, in CIDR notation. - `TunType TeamnetTunType` The type of tunnel. - `const TeamnetTunTypeCfdTunnel TeamnetTunType = "cfd_tunnel"` - `const TeamnetTunTypeWARPConnector TeamnetTunType = "warp_connector"` - `const TeamnetTunTypeWARP TeamnetTunType = "warp"` - `const TeamnetTunTypeMagic TeamnetTunType = "magic"` - `const TeamnetTunTypeIPSec TeamnetTunType = "ip_sec"` - `const TeamnetTunTypeGRE TeamnetTunType = "gre"` - `const TeamnetTunTypeCNI TeamnetTunType = "cni"` - `TunnelID string` UUID of the tunnel. - `TunnelName string` A user-friendly name for a tunnel. - `VirtualNetworkID string` UUID of the virtual network. - `VirtualNetworkName string` A user-friendly name for the virtual network. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/zero_trust" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) page, err := client.ZeroTrust.Networks.Routes.List(context.TODO(), zero_trust.NetworkRouteListParams{ AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", page) } ``` #### 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": "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", "comment": "Example comment for this route.", "created_at": "2021-01-25T18:22:34.317854Z", "deleted_at": "2009-11-10T23:00:00.000000Z", "network": "172.16.0.0/16", "tun_type": "cfd_tunnel", "tunnel_id": "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", "tunnel_name": "blog", "virtual_network_id": "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", "virtual_network_name": "us-east-1-vpc" } ], "success": true, "result_info": { "count": 1, "page": 1, "per_page": 20, "total_count": 2000 } } ``` ## Get tunnel route `client.ZeroTrust.Networks.Routes.Get(ctx, routeID, query) (*Route, error)` **get** `/accounts/{account_id}/teamnet/routes/{route_id}` Get a private network route in an account. ### Parameters - `routeID string` UUID of the route. - `query NetworkRouteGetParams` - `AccountID param.Field[string]` Cloudflare account ID ### Returns - `type Route struct{…}` - `ID string` UUID of the route. - `Comment string` Optional remark describing the route. - `CreatedAt Time` Timestamp of when the resource was created. - `DeletedAt Time` Timestamp of when the resource was deleted. If `null`, the resource has not been deleted. - `Network string` The private IPv4 or IPv6 range connected by the route, in CIDR notation. - `TunnelID string` UUID of the tunnel. - `VirtualNetworkID string` UUID of the virtual network. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/zero_trust" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) route, err := client.ZeroTrust.Networks.Routes.Get( context.TODO(), "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", zero_trust.NetworkRouteGetParams{ AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", route.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": "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", "comment": "Example comment for this route.", "created_at": "2021-01-25T18:22:34.317854Z", "deleted_at": "2009-11-10T23:00:00.000000Z", "network": "172.16.0.0/16", "tunnel_id": "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", "virtual_network_id": "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415" }, "success": true } ``` ## Create a tunnel route `client.ZeroTrust.Networks.Routes.New(ctx, params) (*Route, error)` **post** `/accounts/{account_id}/teamnet/routes` Routes a private network through a Cloudflare Tunnel. ### Parameters - `params NetworkRouteNewParams` - `AccountID param.Field[string]` Path param: Cloudflare account ID - `Network param.Field[string]` Body param: The private IPv4 or IPv6 range connected by the route, in CIDR notation. - `TunnelID param.Field[string]` Body param: UUID of the tunnel. - `Comment param.Field[string]` Body param: Optional remark describing the route. - `VirtualNetworkID param.Field[string]` Body param: UUID of the virtual network. ### Returns - `type Route struct{…}` - `ID string` UUID of the route. - `Comment string` Optional remark describing the route. - `CreatedAt Time` Timestamp of when the resource was created. - `DeletedAt Time` Timestamp of when the resource was deleted. If `null`, the resource has not been deleted. - `Network string` The private IPv4 or IPv6 range connected by the route, in CIDR notation. - `TunnelID string` UUID of the tunnel. - `VirtualNetworkID string` UUID of the virtual network. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/zero_trust" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) route, err := client.ZeroTrust.Networks.Routes.New(context.TODO(), zero_trust.NetworkRouteNewParams{ AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), Network: cloudflare.F("172.16.0.0/16"), TunnelID: cloudflare.F("f70ff985-a4ef-4643-bbbc-4a0ed4fc8415"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", route.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": "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", "comment": "Example comment for this route.", "created_at": "2021-01-25T18:22:34.317854Z", "deleted_at": "2009-11-10T23:00:00.000000Z", "network": "172.16.0.0/16", "tunnel_id": "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", "virtual_network_id": "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415" }, "success": true } ``` ## Update a tunnel route `client.ZeroTrust.Networks.Routes.Edit(ctx, routeID, params) (*Route, error)` **patch** `/accounts/{account_id}/teamnet/routes/{route_id}` Updates an existing private network route in an account. The fields that are meant to be updated should be provided in the body of the request. ### Parameters - `routeID string` UUID of the route. - `params NetworkRouteEditParams` - `AccountID param.Field[string]` Path param: Cloudflare account ID - `Comment param.Field[string]` Body param: Optional remark describing the route. - `Network param.Field[string]` Body param: The private IPv4 or IPv6 range connected by the route, in CIDR notation. - `TunnelID param.Field[string]` Body param: UUID of the tunnel. - `VirtualNetworkID param.Field[string]` Body param: UUID of the virtual network. ### Returns - `type Route struct{…}` - `ID string` UUID of the route. - `Comment string` Optional remark describing the route. - `CreatedAt Time` Timestamp of when the resource was created. - `DeletedAt Time` Timestamp of when the resource was deleted. If `null`, the resource has not been deleted. - `Network string` The private IPv4 or IPv6 range connected by the route, in CIDR notation. - `TunnelID string` UUID of the tunnel. - `VirtualNetworkID string` UUID of the virtual network. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/zero_trust" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) route, err := client.ZeroTrust.Networks.Routes.Edit( context.TODO(), "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", zero_trust.NetworkRouteEditParams{ AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", route.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": "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", "comment": "Example comment for this route.", "created_at": "2021-01-25T18:22:34.317854Z", "deleted_at": "2009-11-10T23:00:00.000000Z", "network": "172.16.0.0/16", "tunnel_id": "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", "virtual_network_id": "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415" }, "success": true } ``` ## Delete a tunnel route `client.ZeroTrust.Networks.Routes.Delete(ctx, routeID, body) (*Route, error)` **delete** `/accounts/{account_id}/teamnet/routes/{route_id}` Deletes a private network route from an account. ### Parameters - `routeID string` UUID of the route. - `body NetworkRouteDeleteParams` - `AccountID param.Field[string]` Cloudflare account ID ### Returns - `type Route struct{…}` - `ID string` UUID of the route. - `Comment string` Optional remark describing the route. - `CreatedAt Time` Timestamp of when the resource was created. - `DeletedAt Time` Timestamp of when the resource was deleted. If `null`, the resource has not been deleted. - `Network string` The private IPv4 or IPv6 range connected by the route, in CIDR notation. - `TunnelID string` UUID of the tunnel. - `VirtualNetworkID string` UUID of the virtual network. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/zero_trust" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) route, err := client.ZeroTrust.Networks.Routes.Delete( context.TODO(), "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", zero_trust.NetworkRouteDeleteParams{ AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", route.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": "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", "comment": "Example comment for this route.", "created_at": "2021-01-25T18:22:34.317854Z", "deleted_at": "2009-11-10T23:00:00.000000Z", "network": "172.16.0.0/16", "tunnel_id": "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", "virtual_network_id": "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415" }, "success": true } ``` ## Domain Types ### Network Route - `type NetworkRoute struct{…}` - `ID string` UUID of the route. - `Comment string` Optional remark describing the route. - `CreatedAt Time` Timestamp of when the resource was created. - `DeletedAt Time` Timestamp of when the resource was deleted. If `null`, the resource has not been deleted. - `Network string` The private IPv4 or IPv6 range connected by the route, in CIDR notation. - `TunnelID string` UUID of the tunnel. - `VirtualNetworkID string` UUID of the virtual network. ### Route - `type Route struct{…}` - `ID string` UUID of the route. - `Comment string` Optional remark describing the route. - `CreatedAt Time` Timestamp of when the resource was created. - `DeletedAt Time` Timestamp of when the resource was deleted. If `null`, the resource has not been deleted. - `Network string` The private IPv4 or IPv6 range connected by the route, in CIDR notation. - `TunnelID string` UUID of the tunnel. - `VirtualNetworkID string` UUID of the virtual network. ### Teamnet - `type Teamnet struct{…}` - `ID string` UUID of the route. - `Comment string` Optional remark describing the route. - `CreatedAt Time` Timestamp of when the resource was created. - `DeletedAt Time` Timestamp of when the resource was deleted. If `null`, the resource has not been deleted. - `Network string` The private IPv4 or IPv6 range connected by the route, in CIDR notation. - `TunType TeamnetTunType` The type of tunnel. - `const TeamnetTunTypeCfdTunnel TeamnetTunType = "cfd_tunnel"` - `const TeamnetTunTypeWARPConnector TeamnetTunType = "warp_connector"` - `const TeamnetTunTypeWARP TeamnetTunType = "warp"` - `const TeamnetTunTypeMagic TeamnetTunType = "magic"` - `const TeamnetTunTypeIPSec TeamnetTunType = "ip_sec"` - `const TeamnetTunTypeGRE TeamnetTunType = "gre"` - `const TeamnetTunTypeCNI TeamnetTunType = "cni"` - `TunnelID string` UUID of the tunnel. - `TunnelName string` A user-friendly name for a tunnel. - `VirtualNetworkID string` UUID of the virtual network. - `VirtualNetworkName string` A user-friendly name for the virtual network. # IPs ## Get tunnel route by IP `client.ZeroTrust.Networks.Routes.IPs.Get(ctx, ip, params) (*Teamnet, error)` **get** `/accounts/{account_id}/teamnet/routes/ip/{ip}` Fetches routes that contain the given IP address. ### Parameters - `ip string` - `params NetworkRouteIPGetParams` - `AccountID param.Field[string]` Path param: Cloudflare account ID - `DefaultVirtualNetworkFallback param.Field[bool]` Query param: When the virtual_network_id parameter is not provided the request filter will default search routes that are in the default virtual network for the account. If this parameter is set to false, the search will include routes that do not have a virtual network. - `VirtualNetworkID param.Field[string]` Query param: UUID of the virtual network. ### Returns - `type Teamnet struct{…}` - `ID string` UUID of the route. - `Comment string` Optional remark describing the route. - `CreatedAt Time` Timestamp of when the resource was created. - `DeletedAt Time` Timestamp of when the resource was deleted. If `null`, the resource has not been deleted. - `Network string` The private IPv4 or IPv6 range connected by the route, in CIDR notation. - `TunType TeamnetTunType` The type of tunnel. - `const TeamnetTunTypeCfdTunnel TeamnetTunType = "cfd_tunnel"` - `const TeamnetTunTypeWARPConnector TeamnetTunType = "warp_connector"` - `const TeamnetTunTypeWARP TeamnetTunType = "warp"` - `const TeamnetTunTypeMagic TeamnetTunType = "magic"` - `const TeamnetTunTypeIPSec TeamnetTunType = "ip_sec"` - `const TeamnetTunTypeGRE TeamnetTunType = "gre"` - `const TeamnetTunTypeCNI TeamnetTunType = "cni"` - `TunnelID string` UUID of the tunnel. - `TunnelName string` A user-friendly name for a tunnel. - `VirtualNetworkID string` UUID of the virtual network. - `VirtualNetworkName string` A user-friendly name for the virtual network. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/zero_trust" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) teamnet, err := client.ZeroTrust.Networks.Routes.IPs.Get( context.TODO(), "10.1.0.137", zero_trust.NetworkRouteIPGetParams{ AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", teamnet.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": "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", "comment": "Example comment for this route.", "created_at": "2021-01-25T18:22:34.317854Z", "deleted_at": "2009-11-10T23:00:00.000000Z", "network": "172.16.0.0/16", "tun_type": "cfd_tunnel", "tunnel_id": "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", "tunnel_name": "blog", "virtual_network_id": "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", "virtual_network_name": "us-east-1-vpc" }, "success": true } ``` # Networks ## Create a tunnel route (CIDR Endpoint) `client.ZeroTrust.Networks.Routes.Networks.New(ctx, ipNetworkEncoded, params) (*Route, error)` **post** `/accounts/{account_id}/teamnet/routes/network/{ip_network_encoded}` Routes a private network through a Cloudflare Tunnel. The CIDR in `ip_network_encoded` must be written in URL-encoded format. ### Parameters - `ipNetworkEncoded string` IP/CIDR range in URL-encoded format - `params NetworkRouteNetworkNewParams` - `AccountID param.Field[string]` Path param: Cloudflare account ID - `TunnelID param.Field[string]` Body param: UUID of the tunnel. - `Comment param.Field[string]` Body param: Optional remark describing the route. - `VirtualNetworkID param.Field[string]` Body param: UUID of the virtual network. ### Returns - `type Route struct{…}` - `ID string` UUID of the route. - `Comment string` Optional remark describing the route. - `CreatedAt Time` Timestamp of when the resource was created. - `DeletedAt Time` Timestamp of when the resource was deleted. If `null`, the resource has not been deleted. - `Network string` The private IPv4 or IPv6 range connected by the route, in CIDR notation. - `TunnelID string` UUID of the tunnel. - `VirtualNetworkID string` UUID of the virtual network. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/zero_trust" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) route, err := client.ZeroTrust.Networks.Routes.Networks.New( context.TODO(), "172.16.0.0%2F16", zero_trust.NetworkRouteNetworkNewParams{ AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), TunnelID: cloudflare.F("f70ff985-a4ef-4643-bbbc-4a0ed4fc8415"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", route.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": "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", "comment": "Example comment for this route.", "created_at": "2021-01-25T18:22:34.317854Z", "deleted_at": "2009-11-10T23:00:00.000000Z", "network": "172.16.0.0/16", "tunnel_id": "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", "virtual_network_id": "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415" }, "success": true } ``` ## Update a tunnel route (CIDR Endpoint) `client.ZeroTrust.Networks.Routes.Networks.Edit(ctx, ipNetworkEncoded, body) (*Route, error)` **patch** `/accounts/{account_id}/teamnet/routes/network/{ip_network_encoded}` Updates an existing private network route in an account. The CIDR in `ip_network_encoded` must be written in URL-encoded format. ### Parameters - `ipNetworkEncoded string` IP/CIDR range in URL-encoded format - `body NetworkRouteNetworkEditParams` - `AccountID param.Field[string]` Cloudflare account ID ### Returns - `type Route struct{…}` - `ID string` UUID of the route. - `Comment string` Optional remark describing the route. - `CreatedAt Time` Timestamp of when the resource was created. - `DeletedAt Time` Timestamp of when the resource was deleted. If `null`, the resource has not been deleted. - `Network string` The private IPv4 or IPv6 range connected by the route, in CIDR notation. - `TunnelID string` UUID of the tunnel. - `VirtualNetworkID string` UUID of the virtual network. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/zero_trust" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) route, err := client.ZeroTrust.Networks.Routes.Networks.Edit( context.TODO(), "172.16.0.0%2F16", zero_trust.NetworkRouteNetworkEditParams{ AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", route.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": "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", "comment": "Example comment for this route.", "created_at": "2021-01-25T18:22:34.317854Z", "deleted_at": "2009-11-10T23:00:00.000000Z", "network": "172.16.0.0/16", "tunnel_id": "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", "virtual_network_id": "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415" }, "success": true } ``` ## Delete a tunnel route (CIDR Endpoint) `client.ZeroTrust.Networks.Routes.Networks.Delete(ctx, ipNetworkEncoded, params) (*Route, error)` **delete** `/accounts/{account_id}/teamnet/routes/network/{ip_network_encoded}` Deletes a private network route from an account. The CIDR in `ip_network_encoded` must be written in URL-encoded format. If no virtual_network_id is provided it will delete the route from the default vnet. If no tun_type is provided it will fetch the type from the tunnel_id or if that is missing it will assume Cloudflare Tunnel as default. If tunnel_id is provided it will delete the route from that tunnel, otherwise it will delete the route based on the vnet and tun_type. ### Parameters - `ipNetworkEncoded string` IP/CIDR range in URL-encoded format - `params NetworkRouteNetworkDeleteParams` - `AccountID param.Field[string]` Path param: Cloudflare account ID - `TunType param.Field[NetworkRouteNetworkDeleteParamsTunType]` Query param: The type of tunnel. - `const NetworkRouteNetworkDeleteParamsTunTypeCfdTunnel NetworkRouteNetworkDeleteParamsTunType = "cfd_tunnel"` - `const NetworkRouteNetworkDeleteParamsTunTypeWARPConnector NetworkRouteNetworkDeleteParamsTunType = "warp_connector"` - `const NetworkRouteNetworkDeleteParamsTunTypeWARP NetworkRouteNetworkDeleteParamsTunType = "warp"` - `const NetworkRouteNetworkDeleteParamsTunTypeMagic NetworkRouteNetworkDeleteParamsTunType = "magic"` - `const NetworkRouteNetworkDeleteParamsTunTypeIPSec NetworkRouteNetworkDeleteParamsTunType = "ip_sec"` - `const NetworkRouteNetworkDeleteParamsTunTypeGRE NetworkRouteNetworkDeleteParamsTunType = "gre"` - `const NetworkRouteNetworkDeleteParamsTunTypeCNI NetworkRouteNetworkDeleteParamsTunType = "cni"` - `TunnelID param.Field[string]` Query param: UUID of the tunnel. - `VirtualNetworkID param.Field[string]` Query param: UUID of the virtual network. ### Returns - `type Route struct{…}` - `ID string` UUID of the route. - `Comment string` Optional remark describing the route. - `CreatedAt Time` Timestamp of when the resource was created. - `DeletedAt Time` Timestamp of when the resource was deleted. If `null`, the resource has not been deleted. - `Network string` The private IPv4 or IPv6 range connected by the route, in CIDR notation. - `TunnelID string` UUID of the tunnel. - `VirtualNetworkID string` UUID of the virtual network. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/zero_trust" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) route, err := client.ZeroTrust.Networks.Routes.Networks.Delete( context.TODO(), "172.16.0.0%2F16", zero_trust.NetworkRouteNetworkDeleteParams{ AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", route.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": "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", "comment": "Example comment for this route.", "created_at": "2021-01-25T18:22:34.317854Z", "deleted_at": "2009-11-10T23:00:00.000000Z", "network": "172.16.0.0/16", "tunnel_id": "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", "virtual_network_id": "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415" }, "success": true } ``` # Virtual Networks ## List virtual networks `client.ZeroTrust.Networks.VirtualNetworks.List(ctx, params) (*SinglePage[VirtualNetwork], error)` **get** `/accounts/{account_id}/teamnet/virtual_networks` Lists and filters virtual networks in an account. ### Parameters - `params NetworkVirtualNetworkListParams` - `AccountID param.Field[string]` Path param: Cloudflare account ID - `ID param.Field[string]` Query param: UUID of the virtual network. - `IsDefault param.Field[bool]` Query param: If `true`, only include the default virtual network. If `false`, exclude the default virtual network. If empty, all virtual networks will be included. - `IsDefaultNetwork param.Field[bool]` Query param: If `true`, only include the default virtual network. If `false`, exclude the default virtual network. If empty, all virtual networks will be included. - `IsDeleted param.Field[bool]` Query param: If `true`, only include deleted virtual networks. If `false`, exclude deleted virtual networks. If empty, all virtual networks will be included. - `Name param.Field[string]` Query param: A user-friendly name for the virtual network. ### Returns - `type VirtualNetwork struct{…}` - `ID string` UUID of the virtual network. - `Comment string` Optional remark describing the virtual network. - `CreatedAt Time` Timestamp of when the resource was created. - `IsDefaultNetwork bool` If `true`, this virtual network is the default for the account. - `Name string` A user-friendly name for the virtual network. - `DeletedAt Time` Timestamp of when the resource was deleted. If `null`, the resource has not been deleted. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/zero_trust" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) page, err := client.ZeroTrust.Networks.VirtualNetworks.List(context.TODO(), zero_trust.NetworkVirtualNetworkListParams{ AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", page) } ``` #### 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": "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", "comment": "Staging VPC for data science", "created_at": "2021-01-25T18:22:34.317854Z", "is_default_network": true, "name": "us-east-1-vpc", "deleted_at": "2009-11-10T23:00:00.000000Z" } ], "success": true, "result_info": { "count": 1, "page": 1, "per_page": 20, "total_count": 2000 } } ``` ## Get a virtual network `client.ZeroTrust.Networks.VirtualNetworks.Get(ctx, virtualNetworkID, query) (*VirtualNetwork, error)` **get** `/accounts/{account_id}/teamnet/virtual_networks/{virtual_network_id}` Get a virtual network. ### Parameters - `virtualNetworkID string` UUID of the virtual network. - `query NetworkVirtualNetworkGetParams` - `AccountID param.Field[string]` Cloudflare account ID ### Returns - `type VirtualNetwork struct{…}` - `ID string` UUID of the virtual network. - `Comment string` Optional remark describing the virtual network. - `CreatedAt Time` Timestamp of when the resource was created. - `IsDefaultNetwork bool` If `true`, this virtual network is the default for the account. - `Name string` A user-friendly name for the virtual network. - `DeletedAt Time` Timestamp of when the resource was deleted. If `null`, the resource has not been deleted. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/zero_trust" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) virtualNetwork, err := client.ZeroTrust.Networks.VirtualNetworks.Get( context.TODO(), "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", zero_trust.NetworkVirtualNetworkGetParams{ AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", virtualNetwork.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": "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", "comment": "Staging VPC for data science", "created_at": "2021-01-25T18:22:34.317854Z", "is_default_network": true, "name": "us-east-1-vpc", "deleted_at": "2009-11-10T23:00:00.000000Z" }, "success": true } ``` ## Create a virtual network `client.ZeroTrust.Networks.VirtualNetworks.New(ctx, params) (*VirtualNetwork, error)` **post** `/accounts/{account_id}/teamnet/virtual_networks` Adds a new virtual network to an account. ### Parameters - `params NetworkVirtualNetworkNewParams` - `AccountID param.Field[string]` Path param: Cloudflare account ID - `Name param.Field[string]` Body param: A user-friendly name for the virtual network. - `Comment param.Field[string]` Body param: Optional remark describing the virtual network. - `IsDefault param.Field[bool]` Body param: If `true`, this virtual network is the default for the account. - `IsDefaultNetwork param.Field[bool]` Body param: If `true`, this virtual network is the default for the account. ### Returns - `type VirtualNetwork struct{…}` - `ID string` UUID of the virtual network. - `Comment string` Optional remark describing the virtual network. - `CreatedAt Time` Timestamp of when the resource was created. - `IsDefaultNetwork bool` If `true`, this virtual network is the default for the account. - `Name string` A user-friendly name for the virtual network. - `DeletedAt Time` Timestamp of when the resource was deleted. If `null`, the resource has not been deleted. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/zero_trust" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) virtualNetwork, err := client.ZeroTrust.Networks.VirtualNetworks.New(context.TODO(), zero_trust.NetworkVirtualNetworkNewParams{ AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), Name: cloudflare.F("us-east-1-vpc"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", virtualNetwork.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": "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", "comment": "Staging VPC for data science", "created_at": "2021-01-25T18:22:34.317854Z", "is_default_network": true, "name": "us-east-1-vpc", "deleted_at": "2009-11-10T23:00:00.000000Z" }, "success": true } ``` ## Update a virtual network `client.ZeroTrust.Networks.VirtualNetworks.Edit(ctx, virtualNetworkID, params) (*VirtualNetwork, error)` **patch** `/accounts/{account_id}/teamnet/virtual_networks/{virtual_network_id}` Updates an existing virtual network. ### Parameters - `virtualNetworkID string` UUID of the virtual network. - `params NetworkVirtualNetworkEditParams` - `AccountID param.Field[string]` Path param: Cloudflare account ID - `Comment param.Field[string]` Body param: Optional remark describing the virtual network. - `IsDefaultNetwork param.Field[bool]` Body param: If `true`, this virtual network is the default for the account. - `Name param.Field[string]` Body param: A user-friendly name for the virtual network. ### Returns - `type VirtualNetwork struct{…}` - `ID string` UUID of the virtual network. - `Comment string` Optional remark describing the virtual network. - `CreatedAt Time` Timestamp of when the resource was created. - `IsDefaultNetwork bool` If `true`, this virtual network is the default for the account. - `Name string` A user-friendly name for the virtual network. - `DeletedAt Time` Timestamp of when the resource was deleted. If `null`, the resource has not been deleted. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/zero_trust" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) virtualNetwork, err := client.ZeroTrust.Networks.VirtualNetworks.Edit( context.TODO(), "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", zero_trust.NetworkVirtualNetworkEditParams{ AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", virtualNetwork.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": "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", "comment": "Staging VPC for data science", "created_at": "2021-01-25T18:22:34.317854Z", "is_default_network": true, "name": "us-east-1-vpc", "deleted_at": "2009-11-10T23:00:00.000000Z" }, "success": true } ``` ## Delete a virtual network `client.ZeroTrust.Networks.VirtualNetworks.Delete(ctx, virtualNetworkID, body) (*VirtualNetwork, error)` **delete** `/accounts/{account_id}/teamnet/virtual_networks/{virtual_network_id}` Deletes an existing virtual network. ### Parameters - `virtualNetworkID string` UUID of the virtual network. - `body NetworkVirtualNetworkDeleteParams` - `AccountID param.Field[string]` Cloudflare account ID ### Returns - `type VirtualNetwork struct{…}` - `ID string` UUID of the virtual network. - `Comment string` Optional remark describing the virtual network. - `CreatedAt Time` Timestamp of when the resource was created. - `IsDefaultNetwork bool` If `true`, this virtual network is the default for the account. - `Name string` A user-friendly name for the virtual network. - `DeletedAt Time` Timestamp of when the resource was deleted. If `null`, the resource has not been deleted. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/zero_trust" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) virtualNetwork, err := client.ZeroTrust.Networks.VirtualNetworks.Delete( context.TODO(), "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", zero_trust.NetworkVirtualNetworkDeleteParams{ AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", virtualNetwork.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": "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", "comment": "Staging VPC for data science", "created_at": "2021-01-25T18:22:34.317854Z", "is_default_network": true, "name": "us-east-1-vpc", "deleted_at": "2009-11-10T23:00:00.000000Z" }, "success": true } ``` ## Domain Types ### Virtual Network - `type VirtualNetwork struct{…}` - `ID string` UUID of the virtual network. - `Comment string` Optional remark describing the virtual network. - `CreatedAt Time` Timestamp of when the resource was created. - `IsDefaultNetwork bool` If `true`, this virtual network is the default for the account. - `Name string` A user-friendly name for the virtual network. - `DeletedAt Time` Timestamp of when the resource was deleted. If `null`, the resource has not been deleted. # Subnets ## List Subnets `client.ZeroTrust.Networks.Subnets.List(ctx, params) (*V4PagePaginationArray[Subnet], error)` **get** `/accounts/{account_id}/zerotrust/subnets` Lists and filters subnets in an account. ### Parameters - `params NetworkSubnetListParams` - `AccountID param.Field[string]` Path param: Cloudflare account ID - `AddressFamily param.Field[NetworkSubnetListParamsAddressFamily]` Query param: If set, only include subnets in the given address family - `v4` or `v6` - `const NetworkSubnetListParamsAddressFamilyV4 NetworkSubnetListParamsAddressFamily = "v4"` - `const NetworkSubnetListParamsAddressFamilyV6 NetworkSubnetListParamsAddressFamily = "v6"` - `Comment param.Field[string]` Query param: If set, only list subnets with the given comment. - `ExistedAt param.Field[string]` Query param: If provided, include only resources that were created (and not deleted) before this time. URL encoded. - `IsDefaultNetwork param.Field[bool]` Query param: If `true`, only include default subnets. If `false`, exclude default subnets subnets. If not set, all subnets will be included. - `IsDeleted param.Field[bool]` Query param: If `true`, only include deleted subnets. If `false`, exclude deleted subnets. If not set, all subnets will be included. - `Name param.Field[string]` Query param: If set, only list subnets with the given name - `Network param.Field[string]` Query param: If set, only list the subnet whose network exactly matches the given CIDR. - `Page param.Field[float64]` Query param: Page number of paginated results. - `PerPage param.Field[float64]` Query param: Number of results to display. - `SortOrder param.Field[NetworkSubnetListParamsSortOrder]` Query param: Sort order of the results. `asc` means oldest to newest, `desc` means newest to oldest. If not set, they will not be in any particular order. - `const NetworkSubnetListParamsSortOrderAsc NetworkSubnetListParamsSortOrder = "asc"` - `const NetworkSubnetListParamsSortOrderDesc NetworkSubnetListParamsSortOrder = "desc"` - `SubnetTypes param.Field[NetworkSubnetListParamsSubnetTypes]` Query param: If set, the types of subnets to include, separated by comma. - `const NetworkSubnetListParamsSubnetTypesCloudflareSource NetworkSubnetListParamsSubnetTypes = "cloudflare_source"` - `const NetworkSubnetListParamsSubnetTypesWARP NetworkSubnetListParamsSubnetTypes = "warp"` ### Returns - `type Subnet struct{…}` - `ID string` The UUID of the subnet. - `Comment string` An optional description of the subnet. - `CreatedAt Time` Timestamp of when the resource was created. - `DeletedAt Time` Timestamp of when the resource was deleted. If `null`, the resource has not been deleted. - `IsDefaultNetwork bool` If `true`, this is the default subnet for the account. There can only be one default subnet per account. - `Name string` A user-friendly name for the subnet. - `Network string` The private IPv4 or IPv6 range defining the subnet, in CIDR notation. - `SubnetType SubnetSubnetType` The type of subnet. - `const SubnetSubnetTypeCloudflareSource SubnetSubnetType = "cloudflare_source"` - `const SubnetSubnetTypeWARP SubnetSubnetType = "warp"` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/zero_trust" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) page, err := client.ZeroTrust.Networks.Subnets.List(context.TODO(), zero_trust.NetworkSubnetListParams{ AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", page) } ``` #### 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": "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", "comment": "example comment", "created_at": "2021-01-25T18:22:34.317854Z", "deleted_at": "2009-11-10T23:00:00.000000Z", "is_default_network": true, "name": "IPv4 Cloudflare Source IPs", "network": "100.64.0.0/12", "subnet_type": "cloudflare_source" } ], "success": true, "result_info": { "count": 1, "page": 1, "per_page": 20, "total_count": 2000 } } ``` # WARP ## Create WARP IP subnet `client.ZeroTrust.Networks.Subnets.WARP.New(ctx, params) (*Subnet, error)` **post** `/accounts/{account_id}/zerotrust/subnets/warp` Create a WARP IP assignment subnet. Currently, only IPv4 subnets can be created. **Network constraints:** - The network must be within one of the following private IP ranges: - `10.0.0.0/8` (RFC 1918) - `172.16.0.0/12` (RFC 1918) - `192.168.0.0/16` (RFC 1918) - `100.64.0.0/10` (RFC 6598 - CGNAT) - The subnet must have a prefix length of `/24` or larger (e.g., `/16`, `/20`, `/24` are valid; `/25`, `/28` are not) ### Parameters - `params NetworkSubnetWARPNewParams` - `AccountID param.Field[string]` Path param: Cloudflare account ID - `Name param.Field[string]` Body param: A user-friendly name for the subnet. - `Network param.Field[string]` Body param: The private IPv4 or IPv6 range defining the subnet, in CIDR notation. - `Comment param.Field[string]` Body param: An optional description of the subnet. - `IsDefaultNetwork param.Field[bool]` Body param: If `true`, this is the default subnet for the account. There can only be one default subnet per account. ### Returns - `type Subnet struct{…}` - `ID string` The UUID of the subnet. - `Comment string` An optional description of the subnet. - `CreatedAt Time` Timestamp of when the resource was created. - `DeletedAt Time` Timestamp of when the resource was deleted. If `null`, the resource has not been deleted. - `IsDefaultNetwork bool` If `true`, this is the default subnet for the account. There can only be one default subnet per account. - `Name string` A user-friendly name for the subnet. - `Network string` The private IPv4 or IPv6 range defining the subnet, in CIDR notation. - `SubnetType SubnetSubnetType` The type of subnet. - `const SubnetSubnetTypeCloudflareSource SubnetSubnetType = "cloudflare_source"` - `const SubnetSubnetTypeWARP SubnetSubnetType = "warp"` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/zero_trust" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) subnet, err := client.ZeroTrust.Networks.Subnets.WARP.New(context.TODO(), zero_trust.NetworkSubnetWARPNewParams{ AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), Name: cloudflare.F("IPv4 Cloudflare Source IPs"), Network: cloudflare.F("100.64.0.0/12"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", subnet.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": "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", "comment": "example comment", "created_at": "2021-01-25T18:22:34.317854Z", "deleted_at": "2009-11-10T23:00:00.000000Z", "is_default_network": true, "name": "IPv4 Cloudflare Source IPs", "network": "100.64.0.0/12", "subnet_type": "cloudflare_source" }, "success": true } ``` ## Get WARP IP subnet `client.ZeroTrust.Networks.Subnets.WARP.Get(ctx, subnetID, query) (*Subnet, error)` **get** `/accounts/{account_id}/zerotrust/subnets/warp/{subnet_id}` Get a WARP IP assignment subnet. ### Parameters - `subnetID string` The UUID of the subnet. - `query NetworkSubnetWARPGetParams` - `AccountID param.Field[string]` Cloudflare account ID ### Returns - `type Subnet struct{…}` - `ID string` The UUID of the subnet. - `Comment string` An optional description of the subnet. - `CreatedAt Time` Timestamp of when the resource was created. - `DeletedAt Time` Timestamp of when the resource was deleted. If `null`, the resource has not been deleted. - `IsDefaultNetwork bool` If `true`, this is the default subnet for the account. There can only be one default subnet per account. - `Name string` A user-friendly name for the subnet. - `Network string` The private IPv4 or IPv6 range defining the subnet, in CIDR notation. - `SubnetType SubnetSubnetType` The type of subnet. - `const SubnetSubnetTypeCloudflareSource SubnetSubnetType = "cloudflare_source"` - `const SubnetSubnetTypeWARP SubnetSubnetType = "warp"` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/zero_trust" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) subnet, err := client.ZeroTrust.Networks.Subnets.WARP.Get( context.TODO(), "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", zero_trust.NetworkSubnetWARPGetParams{ AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", subnet.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": "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", "comment": "example comment", "created_at": "2021-01-25T18:22:34.317854Z", "deleted_at": "2009-11-10T23:00:00.000000Z", "is_default_network": true, "name": "IPv4 Cloudflare Source IPs", "network": "100.64.0.0/12", "subnet_type": "cloudflare_source" }, "success": true } ``` ## Update WARP IP subnet `client.ZeroTrust.Networks.Subnets.WARP.Edit(ctx, subnetID, params) (*Subnet, error)` **patch** `/accounts/{account_id}/zerotrust/subnets/warp/{subnet_id}` Updates a WARP IP assignment subnet. **Update constraints:** - The `network` field cannot be modified for WARP subnets. Only `name`, `comment`, and `is_default_network` can be updated. - IPv6 subnets cannot be updated ### Parameters - `subnetID string` The UUID of the subnet. - `params NetworkSubnetWARPEditParams` - `AccountID param.Field[string]` Path param: Cloudflare account ID - `Comment param.Field[string]` Body param: An optional description of the subnet. - `IsDefaultNetwork param.Field[bool]` Body param: If `true`, this is the default subnet for the account. There can only be one default subnet per account. - `Name param.Field[string]` Body param: A user-friendly name for the subnet. - `Network param.Field[string]` Body param: The private IPv4 or IPv6 range defining the subnet, in CIDR notation. ### Returns - `type Subnet struct{…}` - `ID string` The UUID of the subnet. - `Comment string` An optional description of the subnet. - `CreatedAt Time` Timestamp of when the resource was created. - `DeletedAt Time` Timestamp of when the resource was deleted. If `null`, the resource has not been deleted. - `IsDefaultNetwork bool` If `true`, this is the default subnet for the account. There can only be one default subnet per account. - `Name string` A user-friendly name for the subnet. - `Network string` The private IPv4 or IPv6 range defining the subnet, in CIDR notation. - `SubnetType SubnetSubnetType` The type of subnet. - `const SubnetSubnetTypeCloudflareSource SubnetSubnetType = "cloudflare_source"` - `const SubnetSubnetTypeWARP SubnetSubnetType = "warp"` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/zero_trust" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) subnet, err := client.ZeroTrust.Networks.Subnets.WARP.Edit( context.TODO(), "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", zero_trust.NetworkSubnetWARPEditParams{ AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", subnet.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": "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", "comment": "example comment", "created_at": "2021-01-25T18:22:34.317854Z", "deleted_at": "2009-11-10T23:00:00.000000Z", "is_default_network": true, "name": "IPv4 Cloudflare Source IPs", "network": "100.64.0.0/12", "subnet_type": "cloudflare_source" }, "success": true } ``` ## Delete WARP IP subnet `client.ZeroTrust.Networks.Subnets.WARP.Delete(ctx, subnetID, body) (*NetworkSubnetWARPDeleteResponse, error)` **delete** `/accounts/{account_id}/zerotrust/subnets/warp/{subnet_id}` Delete a WARP IP assignment subnet. This operation is idempotent - deleting an already-deleted or non-existent subnet will return success with a null result. ### Parameters - `subnetID string` The UUID of the subnet. - `body NetworkSubnetWARPDeleteParams` - `AccountID param.Field[string]` Cloudflare account ID ### Returns - `type NetworkSubnetWARPDeleteResponse struct{…}` - `ID string` The UUID of the subnet. - `Comment string` An optional description of the subnet. - `CreatedAt Time` Timestamp of when the resource was created. - `DeletedAt Time` Timestamp of when the resource was deleted. If `null`, the resource has not been deleted. - `IsDefaultNetwork bool` If `true`, this is the default subnet for the account. There can only be one default subnet per account. - `Name string` A user-friendly name for the subnet. - `Network string` The private IPv4 or IPv6 range defining the subnet, in CIDR notation. - `SubnetType NetworkSubnetWARPDeleteResponseSubnetType` The type of subnet. - `const NetworkSubnetWARPDeleteResponseSubnetTypeCloudflareSource NetworkSubnetWARPDeleteResponseSubnetType = "cloudflare_source"` - `const NetworkSubnetWARPDeleteResponseSubnetTypeWARP NetworkSubnetWARPDeleteResponseSubnetType = "warp"` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/zero_trust" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) warp, err := client.ZeroTrust.Networks.Subnets.WARP.Delete( context.TODO(), "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", zero_trust.NetworkSubnetWARPDeleteParams{ AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", warp.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": "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", "comment": "example comment", "created_at": "2021-01-25T18:22:34.317854Z", "deleted_at": "2009-11-10T23:00:00.000000Z", "is_default_network": true, "name": "IPv4 Cloudflare Source IPs", "network": "100.64.0.0/12", "subnet_type": "cloudflare_source" }, "success": true } ``` ## Domain Types ### Subnet - `type Subnet struct{…}` - `ID string` The UUID of the subnet. - `Comment string` An optional description of the subnet. - `CreatedAt Time` Timestamp of when the resource was created. - `DeletedAt Time` Timestamp of when the resource was deleted. If `null`, the resource has not been deleted. - `IsDefaultNetwork bool` If `true`, this is the default subnet for the account. There can only be one default subnet per account. - `Name string` A user-friendly name for the subnet. - `Network string` The private IPv4 or IPv6 range defining the subnet, in CIDR notation. - `SubnetType SubnetSubnetType` The type of subnet. - `const SubnetSubnetTypeCloudflareSource SubnetSubnetType = "cloudflare_source"` - `const SubnetSubnetTypeWARP SubnetSubnetType = "warp"` # Cloudflare Source ## Update Cloudflare Source Subnet `client.ZeroTrust.Networks.Subnets.CloudflareSource.Update(ctx, addressFamily, params) (*Subnet, error)` **patch** `/accounts/{account_id}/zerotrust/subnets/cloudflare_source/{address_family}` Updates the Cloudflare Source subnet of the given address family ### Parameters - `addressFamily NetworkSubnetCloudflareSourceUpdateParamsAddressFamily` IP address family, either `v4` (IPv4) or `v6` (IPv6) - `const NetworkSubnetCloudflareSourceUpdateParamsAddressFamilyV4 NetworkSubnetCloudflareSourceUpdateParamsAddressFamily = "v4"` - `const NetworkSubnetCloudflareSourceUpdateParamsAddressFamilyV6 NetworkSubnetCloudflareSourceUpdateParamsAddressFamily = "v6"` - `params NetworkSubnetCloudflareSourceUpdateParams` - `AccountID param.Field[string]` Path param: Cloudflare account ID - `Comment param.Field[string]` Body param: An optional description of the subnet. - `Name param.Field[string]` Body param: A user-friendly name for the subnet. - `Network param.Field[string]` Body param: The private IPv4 or IPv6 range defining the subnet, in CIDR notation. ### Returns - `type Subnet struct{…}` - `ID string` The UUID of the subnet. - `Comment string` An optional description of the subnet. - `CreatedAt Time` Timestamp of when the resource was created. - `DeletedAt Time` Timestamp of when the resource was deleted. If `null`, the resource has not been deleted. - `IsDefaultNetwork bool` If `true`, this is the default subnet for the account. There can only be one default subnet per account. - `Name string` A user-friendly name for the subnet. - `Network string` The private IPv4 or IPv6 range defining the subnet, in CIDR notation. - `SubnetType SubnetSubnetType` The type of subnet. - `const SubnetSubnetTypeCloudflareSource SubnetSubnetType = "cloudflare_source"` - `const SubnetSubnetTypeWARP SubnetSubnetType = "warp"` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/zero_trust" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) subnet, err := client.ZeroTrust.Networks.Subnets.CloudflareSource.Update( context.TODO(), zero_trust.NetworkSubnetCloudflareSourceUpdateParamsAddressFamilyV4, zero_trust.NetworkSubnetCloudflareSourceUpdateParams{ AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", subnet.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": "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", "comment": "example comment", "created_at": "2021-01-25T18:22:34.317854Z", "deleted_at": "2009-11-10T23:00:00.000000Z", "is_default_network": true, "name": "IPv4 Cloudflare Source IPs", "network": "100.64.0.0/12", "subnet_type": "cloudflare_source" }, "success": true } ``` # Hostname Routes ## List hostname routes `client.ZeroTrust.Networks.HostnameRoutes.List(ctx, params) (*V4PagePaginationArray[HostnameRoute], error)` **get** `/accounts/{account_id}/zerotrust/routes/hostname` Lists and filters hostname routes in an account. ### Parameters - `params NetworkHostnameRouteListParams` - `AccountID param.Field[string]` Path param: Cloudflare account ID - `ID param.Field[string]` Query param: The hostname route ID. - `Comment param.Field[string]` Query param: If set, only list hostname routes with the given comment. - `ExistedAt param.Field[string]` Query param: If provided, include only resources that were created (and not deleted) before this time. URL encoded. - `Hostname param.Field[string]` Query param: If set, only list hostname routes that contain a substring of the given value, the filter is case-insensitive. - `IsDeleted param.Field[bool]` Query param: If `true`, only return deleted hostname routes. If `false`, exclude deleted hostname routes. - `Page param.Field[float64]` Query param: Page number of paginated results. - `PerPage param.Field[float64]` Query param: Number of results to display. - `TunnelID param.Field[string]` Query param: If set, only list hostname routes that point to a specific tunnel. ### Returns - `type HostnameRoute struct{…}` - `ID string` The hostname route ID. - `Comment string` An optional description of the hostname route. - `CreatedAt Time` Timestamp of when the resource was created. - `DeletedAt Time` Timestamp of when the resource was deleted. If `null`, the resource has not been deleted. - `Hostname string` The hostname of the route. - `TunnelID string` UUID of the tunnel. - `TunnelName string` A user-friendly name for a tunnel. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/zero_trust" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) page, err := client.ZeroTrust.Networks.HostnameRoutes.List(context.TODO(), zero_trust.NetworkHostnameRouteListParams{ AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", page) } ``` #### 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": "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", "comment": "example comment", "created_at": "2021-01-25T18:22:34.317854Z", "deleted_at": "2009-11-10T23:00:00.000000Z", "hostname": "office-1.local", "tunnel_id": "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", "tunnel_name": "api-tunnel" } ], "success": true, "result_info": { "count": 1, "page": 1, "per_page": 20, "total_count": 2000 } } ``` ## Get hostname route `client.ZeroTrust.Networks.HostnameRoutes.Get(ctx, hostnameRouteID, query) (*HostnameRoute, error)` **get** `/accounts/{account_id}/zerotrust/routes/hostname/{hostname_route_id}` Get a hostname route. ### Parameters - `hostnameRouteID string` The hostname route ID. - `query NetworkHostnameRouteGetParams` - `AccountID param.Field[string]` Cloudflare account ID ### Returns - `type HostnameRoute struct{…}` - `ID string` The hostname route ID. - `Comment string` An optional description of the hostname route. - `CreatedAt Time` Timestamp of when the resource was created. - `DeletedAt Time` Timestamp of when the resource was deleted. If `null`, the resource has not been deleted. - `Hostname string` The hostname of the route. - `TunnelID string` UUID of the tunnel. - `TunnelName string` A user-friendly name for a tunnel. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/zero_trust" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) hostnameRoute, err := client.ZeroTrust.Networks.HostnameRoutes.Get( context.TODO(), "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", zero_trust.NetworkHostnameRouteGetParams{ AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", hostnameRoute.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": "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", "comment": "example comment", "created_at": "2021-01-25T18:22:34.317854Z", "deleted_at": "2009-11-10T23:00:00.000000Z", "hostname": "office-1.local", "tunnel_id": "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", "tunnel_name": "api-tunnel" }, "success": true } ``` ## Create hostname route `client.ZeroTrust.Networks.HostnameRoutes.New(ctx, params) (*HostnameRoute, error)` **post** `/accounts/{account_id}/zerotrust/routes/hostname` Create a hostname route. ### Parameters - `params NetworkHostnameRouteNewParams` - `AccountID param.Field[string]` Path param: Cloudflare account ID - `Comment param.Field[string]` Body param: An optional description of the hostname route. - `Hostname param.Field[string]` Body param: The hostname of the route. - `TunnelID param.Field[string]` Body param: UUID of the tunnel. ### Returns - `type HostnameRoute struct{…}` - `ID string` The hostname route ID. - `Comment string` An optional description of the hostname route. - `CreatedAt Time` Timestamp of when the resource was created. - `DeletedAt Time` Timestamp of when the resource was deleted. If `null`, the resource has not been deleted. - `Hostname string` The hostname of the route. - `TunnelID string` UUID of the tunnel. - `TunnelName string` A user-friendly name for a tunnel. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/zero_trust" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) hostnameRoute, err := client.ZeroTrust.Networks.HostnameRoutes.New(context.TODO(), zero_trust.NetworkHostnameRouteNewParams{ AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", hostnameRoute.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": "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", "comment": "example comment", "created_at": "2021-01-25T18:22:34.317854Z", "deleted_at": "2009-11-10T23:00:00.000000Z", "hostname": "office-1.local", "tunnel_id": "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", "tunnel_name": "api-tunnel" }, "success": true } ``` ## Update hostname route `client.ZeroTrust.Networks.HostnameRoutes.Edit(ctx, hostnameRouteID, params) (*HostnameRoute, error)` **patch** `/accounts/{account_id}/zerotrust/routes/hostname/{hostname_route_id}` Updates a hostname route. ### Parameters - `hostnameRouteID string` The hostname route ID. - `params NetworkHostnameRouteEditParams` - `AccountID param.Field[string]` Path param: Cloudflare account ID - `Comment param.Field[string]` Body param: An optional description of the hostname route. - `Hostname param.Field[string]` Body param: The hostname of the route. - `TunnelID param.Field[string]` Body param: UUID of the tunnel. ### Returns - `type HostnameRoute struct{…}` - `ID string` The hostname route ID. - `Comment string` An optional description of the hostname route. - `CreatedAt Time` Timestamp of when the resource was created. - `DeletedAt Time` Timestamp of when the resource was deleted. If `null`, the resource has not been deleted. - `Hostname string` The hostname of the route. - `TunnelID string` UUID of the tunnel. - `TunnelName string` A user-friendly name for a tunnel. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/zero_trust" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) hostnameRoute, err := client.ZeroTrust.Networks.HostnameRoutes.Edit( context.TODO(), "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", zero_trust.NetworkHostnameRouteEditParams{ AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", hostnameRoute.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": "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", "comment": "example comment", "created_at": "2021-01-25T18:22:34.317854Z", "deleted_at": "2009-11-10T23:00:00.000000Z", "hostname": "office-1.local", "tunnel_id": "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", "tunnel_name": "api-tunnel" }, "success": true } ``` ## Delete hostname route `client.ZeroTrust.Networks.HostnameRoutes.Delete(ctx, hostnameRouteID, body) (*HostnameRoute, error)` **delete** `/accounts/{account_id}/zerotrust/routes/hostname/{hostname_route_id}` Delete a hostname route. ### Parameters - `hostnameRouteID string` The hostname route ID. - `body NetworkHostnameRouteDeleteParams` - `AccountID param.Field[string]` Cloudflare account ID ### Returns - `type HostnameRoute struct{…}` - `ID string` The hostname route ID. - `Comment string` An optional description of the hostname route. - `CreatedAt Time` Timestamp of when the resource was created. - `DeletedAt Time` Timestamp of when the resource was deleted. If `null`, the resource has not been deleted. - `Hostname string` The hostname of the route. - `TunnelID string` UUID of the tunnel. - `TunnelName string` A user-friendly name for a tunnel. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/zero_trust" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) hostnameRoute, err := client.ZeroTrust.Networks.HostnameRoutes.Delete( context.TODO(), "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", zero_trust.NetworkHostnameRouteDeleteParams{ AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", hostnameRoute.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": "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", "comment": "example comment", "created_at": "2021-01-25T18:22:34.317854Z", "deleted_at": "2009-11-10T23:00:00.000000Z", "hostname": "office-1.local", "tunnel_id": "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", "tunnel_name": "api-tunnel" }, "success": true } ``` ## Domain Types ### Hostname Route - `type HostnameRoute struct{…}` - `ID string` The hostname route ID. - `Comment string` An optional description of the hostname route. - `CreatedAt Time` Timestamp of when the resource was created. - `DeletedAt Time` Timestamp of when the resource was deleted. If `null`, the resource has not been deleted. - `Hostname string` The hostname of the route. - `TunnelID string` UUID of the tunnel. - `TunnelName string` A user-friendly name for a tunnel.