# Sites ## List Sites `client.MagicTransit.Sites.List(ctx, params) (*SinglePage[Site], error)` **get** `/accounts/{account_id}/magic/sites` Lists Sites associated with an account. Use connectorid query param to return sites where connectorid matches either site.ConnectorID or site.SecondaryConnectorID. ### Parameters - `params SiteListParams` - `AccountID param.Field[string]` Path param: Identifier - `Connectorid param.Field[string]` Query param: Identifier ### Returns - `type Site struct{…}` - `ID string` Identifier - `ConnectorID string` Magic Connector identifier tag. - `Description string` - `HaMode bool` Site high availability mode. If set to true, the site can have two connectors and runs in high availability mode. - `Location SiteLocation` Location of site in latitude and longitude. - `Lat string` Latitude - `Lon string` Longitude - `Name string` The name of the site. - `SecondaryConnectorID string` Magic Connector identifier tag. Used when high availability mode is on. ### 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"), ) page, err := client.MagicTransit.Sites.List(context.TODO(), magic_transit.SiteListParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) 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": "023e105f4ecef8ad9ca31a8372d0c353", "connector_id": "ac60d3d0435248289d446cedd870bcf4", "description": "description", "ha_mode": true, "location": { "lat": "37.6192", "lon": "122.3816" }, "name": "site_1", "secondary_connector_id": "8d67040d3835dbcf46ce29da440dc482" } ], "success": true } ``` ## Site Details `client.MagicTransit.Sites.Get(ctx, siteID, params) (*Site, error)` **get** `/accounts/{account_id}/magic/sites/{site_id}` Get a specific Site. ### Parameters - `siteID string` Identifier - `params SiteGetParams` - `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 Site struct{…}` - `ID string` Identifier - `ConnectorID string` Magic Connector identifier tag. - `Description string` - `HaMode bool` Site high availability mode. If set to true, the site can have two connectors and runs in high availability mode. - `Location SiteLocation` Location of site in latitude and longitude. - `Lat string` Latitude - `Lon string` Longitude - `Name string` The name of the site. - `SecondaryConnectorID string` Magic Connector identifier tag. Used when high availability mode is on. ### 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"), ) site, err := client.MagicTransit.Sites.Get( context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", magic_transit.SiteGetParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", site.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": "023e105f4ecef8ad9ca31a8372d0c353", "connector_id": "ac60d3d0435248289d446cedd870bcf4", "description": "description", "ha_mode": true, "location": { "lat": "37.6192", "lon": "122.3816" }, "name": "site_1", "secondary_connector_id": "8d67040d3835dbcf46ce29da440dc482" }, "success": true } ``` ## Create a new Site `client.MagicTransit.Sites.New(ctx, params) (*Site, error)` **post** `/accounts/{account_id}/magic/sites` Creates a new Site ### Parameters - `params SiteNewParams` - `AccountID param.Field[string]` Path param: Identifier - `Name param.Field[string]` Body param: The name of the site. - `ConnectorID param.Field[string]` Body param: Magic Connector identifier tag. - `Description param.Field[string]` Body param - `HaMode param.Field[bool]` Body param: Site high availability mode. If set to true, the site can have two connectors and runs in high availability mode. - `Location param.Field[SiteLocation]` Body param: Location of site in latitude and longitude. - `SecondaryConnectorID param.Field[string]` Body param: Magic Connector identifier tag. Used when high availability mode is on. ### Returns - `type Site struct{…}` - `ID string` Identifier - `ConnectorID string` Magic Connector identifier tag. - `Description string` - `HaMode bool` Site high availability mode. If set to true, the site can have two connectors and runs in high availability mode. - `Location SiteLocation` Location of site in latitude and longitude. - `Lat string` Latitude - `Lon string` Longitude - `Name string` The name of the site. - `SecondaryConnectorID string` Magic Connector identifier tag. Used when high availability mode is on. ### 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"), ) site, err := client.MagicTransit.Sites.New(context.TODO(), magic_transit.SiteNewParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Name: cloudflare.F("site_1"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", site.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": "023e105f4ecef8ad9ca31a8372d0c353", "connector_id": "ac60d3d0435248289d446cedd870bcf4", "description": "description", "ha_mode": true, "location": { "lat": "37.6192", "lon": "122.3816" }, "name": "site_1", "secondary_connector_id": "8d67040d3835dbcf46ce29da440dc482" }, "success": true } ``` ## Update Site `client.MagicTransit.Sites.Update(ctx, siteID, params) (*Site, error)` **put** `/accounts/{account_id}/magic/sites/{site_id}` Update a specific Site. ### Parameters - `siteID string` Identifier - `params SiteUpdateParams` - `AccountID param.Field[string]` Path param: Identifier - `ConnectorID param.Field[string]` Body param: Magic Connector identifier tag. - `Description param.Field[string]` Body param - `Location param.Field[SiteLocation]` Body param: Location of site in latitude and longitude. - `Name param.Field[string]` Body param: The name of the site. - `SecondaryConnectorID param.Field[string]` Body param: Magic Connector identifier tag. Used when high availability mode is on. ### Returns - `type Site struct{…}` - `ID string` Identifier - `ConnectorID string` Magic Connector identifier tag. - `Description string` - `HaMode bool` Site high availability mode. If set to true, the site can have two connectors and runs in high availability mode. - `Location SiteLocation` Location of site in latitude and longitude. - `Lat string` Latitude - `Lon string` Longitude - `Name string` The name of the site. - `SecondaryConnectorID string` Magic Connector identifier tag. Used when high availability mode is on. ### 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"), ) site, err := client.MagicTransit.Sites.Update( context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", magic_transit.SiteUpdateParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", site.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": "023e105f4ecef8ad9ca31a8372d0c353", "connector_id": "ac60d3d0435248289d446cedd870bcf4", "description": "description", "ha_mode": true, "location": { "lat": "37.6192", "lon": "122.3816" }, "name": "site_1", "secondary_connector_id": "8d67040d3835dbcf46ce29da440dc482" }, "success": true } ``` ## Patch Site `client.MagicTransit.Sites.Edit(ctx, siteID, params) (*Site, error)` **patch** `/accounts/{account_id}/magic/sites/{site_id}` Patch a specific Site. ### Parameters - `siteID string` Identifier - `params SiteEditParams` - `AccountID param.Field[string]` Path param: Identifier - `ConnectorID param.Field[string]` Body param: Magic Connector identifier tag. - `Description param.Field[string]` Body param - `Location param.Field[SiteLocation]` Body param: Location of site in latitude and longitude. - `Name param.Field[string]` Body param: The name of the site. - `SecondaryConnectorID param.Field[string]` Body param: Magic Connector identifier tag. Used when high availability mode is on. ### Returns - `type Site struct{…}` - `ID string` Identifier - `ConnectorID string` Magic Connector identifier tag. - `Description string` - `HaMode bool` Site high availability mode. If set to true, the site can have two connectors and runs in high availability mode. - `Location SiteLocation` Location of site in latitude and longitude. - `Lat string` Latitude - `Lon string` Longitude - `Name string` The name of the site. - `SecondaryConnectorID string` Magic Connector identifier tag. Used when high availability mode is on. ### 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"), ) site, err := client.MagicTransit.Sites.Edit( context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", magic_transit.SiteEditParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", site.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": "023e105f4ecef8ad9ca31a8372d0c353", "connector_id": "ac60d3d0435248289d446cedd870bcf4", "description": "description", "ha_mode": true, "location": { "lat": "37.6192", "lon": "122.3816" }, "name": "site_1", "secondary_connector_id": "8d67040d3835dbcf46ce29da440dc482" }, "success": true } ``` ## Delete Site `client.MagicTransit.Sites.Delete(ctx, siteID, body) (*Site, error)` **delete** `/accounts/{account_id}/magic/sites/{site_id}` Remove a specific Site. ### Parameters - `siteID string` Identifier - `body SiteDeleteParams` - `AccountID param.Field[string]` Identifier ### Returns - `type Site struct{…}` - `ID string` Identifier - `ConnectorID string` Magic Connector identifier tag. - `Description string` - `HaMode bool` Site high availability mode. If set to true, the site can have two connectors and runs in high availability mode. - `Location SiteLocation` Location of site in latitude and longitude. - `Lat string` Latitude - `Lon string` Longitude - `Name string` The name of the site. - `SecondaryConnectorID string` Magic Connector identifier tag. Used when high availability mode is on. ### 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"), ) site, err := client.MagicTransit.Sites.Delete( context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", magic_transit.SiteDeleteParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", site.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": "023e105f4ecef8ad9ca31a8372d0c353", "connector_id": "ac60d3d0435248289d446cedd870bcf4", "description": "description", "ha_mode": true, "location": { "lat": "37.6192", "lon": "122.3816" }, "name": "site_1", "secondary_connector_id": "8d67040d3835dbcf46ce29da440dc482" }, "success": true } ``` ## Domain Types ### Site - `type Site struct{…}` - `ID string` Identifier - `ConnectorID string` Magic Connector identifier tag. - `Description string` - `HaMode bool` Site high availability mode. If set to true, the site can have two connectors and runs in high availability mode. - `Location SiteLocation` Location of site in latitude and longitude. - `Lat string` Latitude - `Lon string` Longitude - `Name string` The name of the site. - `SecondaryConnectorID string` Magic Connector identifier tag. Used when high availability mode is on. ### Site Location - `type SiteLocation struct{…}` Location of site in latitude and longitude. - `Lat string` Latitude - `Lon string` Longitude # App Configuration # ACLs ## List Site ACLs `client.MagicTransit.Sites.ACLs.List(ctx, siteID, query) (*SinglePage[ACL], error)` **get** `/accounts/{account_id}/magic/sites/{site_id}/acls` Lists Site ACLs associated with an account. ### Parameters - `siteID string` Identifier - `query SiteACLListParams` - `AccountID param.Field[string]` Identifier ### Returns - `type ACL struct{…}` Bidirectional ACL policy for network traffic within a site. - `ID string` Identifier - `Description string` Description for the ACL. - `ForwardLocally bool` The desired forwarding action for this ACL policy. If set to "false", the policy will forward traffic to Cloudflare. If set to "true", the policy will forward traffic locally on the Magic Connector. If not included in request, will default to false. - `LAN1 ACLConfiguration` - `LANID string` The identifier for the LAN you want to create an ACL policy with. - `LANName string` The name of the LAN based on the provided lan_id. - `PortRanges []string` Array of port ranges on the provided LAN that will be included in the ACL. If no ports or port rangess are provided, communication on any port on this LAN is allowed. - `Ports []int64` Array of ports on the provided LAN that will be included in the ACL. If no ports or port ranges are provided, communication on any port on this LAN is allowed. - `Subnets []Subnet` Array of subnet IPs within the LAN that will be included in the ACL. If no subnets are provided, communication on any subnets on this LAN are allowed. - `LAN2 ACLConfiguration` - `Name string` The name of the ACL. - `Protocols []AllowedProtocol` - `const AllowedProtocolTCP AllowedProtocol = "tcp"` - `const AllowedProtocolUdp AllowedProtocol = "udp"` - `const AllowedProtocolIcmp AllowedProtocol = "icmp"` - `Unidirectional bool` The desired traffic direction for this ACL policy. If set to "false", the policy will allow bidirectional traffic. If set to "true", the policy will only allow traffic in one direction. If not included in request, will default to false. ### 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"), ) page, err := client.MagicTransit.Sites.ACLs.List( context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", magic_transit.SiteACLListParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) 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": "023e105f4ecef8ad9ca31a8372d0c353", "description": "Allows local traffic between PIN pads and cash register.", "forward_locally": true, "lan_1": { "lan_id": "lan_id", "lan_name": "lan_name", "port_ranges": [ "8080-9000" ], "ports": [ 1 ], "subnets": [ "192.0.2.1" ] }, "lan_2": { "lan_id": "lan_id", "lan_name": "lan_name", "port_ranges": [ "8080-9000" ], "ports": [ 1 ], "subnets": [ "192.0.2.1" ] }, "name": "PIN Pad - Cash Register", "protocols": [ "tcp" ], "unidirectional": true } ], "success": true } ``` ## Site ACL Details `client.MagicTransit.Sites.ACLs.Get(ctx, siteID, aclID, query) (*ACL, error)` **get** `/accounts/{account_id}/magic/sites/{site_id}/acls/{acl_id}` Get a specific Site ACL. ### Parameters - `siteID string` Identifier - `aclID string` Identifier - `query SiteACLGetParams` - `AccountID param.Field[string]` Identifier ### Returns - `type ACL struct{…}` Bidirectional ACL policy for network traffic within a site. - `ID string` Identifier - `Description string` Description for the ACL. - `ForwardLocally bool` The desired forwarding action for this ACL policy. If set to "false", the policy will forward traffic to Cloudflare. If set to "true", the policy will forward traffic locally on the Magic Connector. If not included in request, will default to false. - `LAN1 ACLConfiguration` - `LANID string` The identifier for the LAN you want to create an ACL policy with. - `LANName string` The name of the LAN based on the provided lan_id. - `PortRanges []string` Array of port ranges on the provided LAN that will be included in the ACL. If no ports or port rangess are provided, communication on any port on this LAN is allowed. - `Ports []int64` Array of ports on the provided LAN that will be included in the ACL. If no ports or port ranges are provided, communication on any port on this LAN is allowed. - `Subnets []Subnet` Array of subnet IPs within the LAN that will be included in the ACL. If no subnets are provided, communication on any subnets on this LAN are allowed. - `LAN2 ACLConfiguration` - `Name string` The name of the ACL. - `Protocols []AllowedProtocol` - `const AllowedProtocolTCP AllowedProtocol = "tcp"` - `const AllowedProtocolUdp AllowedProtocol = "udp"` - `const AllowedProtocolIcmp AllowedProtocol = "icmp"` - `Unidirectional bool` The desired traffic direction for this ACL policy. If set to "false", the policy will allow bidirectional traffic. If set to "true", the policy will only allow traffic in one direction. If not included in request, will default to false. ### 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"), ) acl, err := client.MagicTransit.Sites.ACLs.Get( context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", "023e105f4ecef8ad9ca31a8372d0c353", magic_transit.SiteACLGetParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", acl.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": "023e105f4ecef8ad9ca31a8372d0c353", "description": "Allows local traffic between PIN pads and cash register.", "forward_locally": true, "lan_1": { "lan_id": "lan_id", "lan_name": "lan_name", "port_ranges": [ "8080-9000" ], "ports": [ 1 ], "subnets": [ "192.0.2.1" ] }, "lan_2": { "lan_id": "lan_id", "lan_name": "lan_name", "port_ranges": [ "8080-9000" ], "ports": [ 1 ], "subnets": [ "192.0.2.1" ] }, "name": "PIN Pad - Cash Register", "protocols": [ "tcp" ], "unidirectional": true }, "success": true } ``` ## Create a new Site ACL `client.MagicTransit.Sites.ACLs.New(ctx, siteID, params) (*ACL, error)` **post** `/accounts/{account_id}/magic/sites/{site_id}/acls` Creates a new Site ACL. ### Parameters - `siteID string` Identifier - `params SiteACLNewParams` - `AccountID param.Field[string]` Path param: Identifier - `LAN1 param.Field[ACLConfiguration]` Body param - `LAN2 param.Field[ACLConfiguration]` Body param - `Name param.Field[string]` Body param: The name of the ACL. - `Description param.Field[string]` Body param: Description for the ACL. - `ForwardLocally param.Field[bool]` Body param: The desired forwarding action for this ACL policy. If set to "false", the policy will forward traffic to Cloudflare. If set to "true", the policy will forward traffic locally on the Magic Connector. If not included in request, will default to false. - `Protocols param.Field[[]AllowedProtocol]` Body param - `const AllowedProtocolTCP AllowedProtocol = "tcp"` - `const AllowedProtocolUdp AllowedProtocol = "udp"` - `const AllowedProtocolIcmp AllowedProtocol = "icmp"` - `Unidirectional param.Field[bool]` Body param: The desired traffic direction for this ACL policy. If set to "false", the policy will allow bidirectional traffic. If set to "true", the policy will only allow traffic in one direction. If not included in request, will default to false. ### Returns - `type ACL struct{…}` Bidirectional ACL policy for network traffic within a site. - `ID string` Identifier - `Description string` Description for the ACL. - `ForwardLocally bool` The desired forwarding action for this ACL policy. If set to "false", the policy will forward traffic to Cloudflare. If set to "true", the policy will forward traffic locally on the Magic Connector. If not included in request, will default to false. - `LAN1 ACLConfiguration` - `LANID string` The identifier for the LAN you want to create an ACL policy with. - `LANName string` The name of the LAN based on the provided lan_id. - `PortRanges []string` Array of port ranges on the provided LAN that will be included in the ACL. If no ports or port rangess are provided, communication on any port on this LAN is allowed. - `Ports []int64` Array of ports on the provided LAN that will be included in the ACL. If no ports or port ranges are provided, communication on any port on this LAN is allowed. - `Subnets []Subnet` Array of subnet IPs within the LAN that will be included in the ACL. If no subnets are provided, communication on any subnets on this LAN are allowed. - `LAN2 ACLConfiguration` - `Name string` The name of the ACL. - `Protocols []AllowedProtocol` - `const AllowedProtocolTCP AllowedProtocol = "tcp"` - `const AllowedProtocolUdp AllowedProtocol = "udp"` - `const AllowedProtocolIcmp AllowedProtocol = "icmp"` - `Unidirectional bool` The desired traffic direction for this ACL policy. If set to "false", the policy will allow bidirectional traffic. If set to "true", the policy will only allow traffic in one direction. If not included in request, will default to false. ### 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"), ) acl, err := client.MagicTransit.Sites.ACLs.New( context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", magic_transit.SiteACLNewParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), LAN1: cloudflare.F(magic_transit.ACLConfigurationParam{ LANID: cloudflare.F("lan_id"), }), LAN2: cloudflare.F(magic_transit.ACLConfigurationParam{ LANID: cloudflare.F("lan_id"), }), Name: cloudflare.F("PIN Pad - Cash Register"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", acl.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": "023e105f4ecef8ad9ca31a8372d0c353", "description": "Allows local traffic between PIN pads and cash register.", "forward_locally": true, "lan_1": { "lan_id": "lan_id", "lan_name": "lan_name", "port_ranges": [ "8080-9000" ], "ports": [ 1 ], "subnets": [ "192.0.2.1" ] }, "lan_2": { "lan_id": "lan_id", "lan_name": "lan_name", "port_ranges": [ "8080-9000" ], "ports": [ 1 ], "subnets": [ "192.0.2.1" ] }, "name": "PIN Pad - Cash Register", "protocols": [ "tcp" ], "unidirectional": true }, "success": true } ``` ## Update Site ACL `client.MagicTransit.Sites.ACLs.Update(ctx, siteID, aclID, params) (*ACL, error)` **put** `/accounts/{account_id}/magic/sites/{site_id}/acls/{acl_id}` Update a specific Site ACL. ### Parameters - `siteID string` Identifier - `aclID string` Identifier - `params SiteACLUpdateParams` - `AccountID param.Field[string]` Path param: Identifier - `Description param.Field[string]` Body param: Description for the ACL. - `ForwardLocally param.Field[bool]` Body param: The desired forwarding action for this ACL policy. If set to "false", the policy will forward traffic to Cloudflare. If set to "true", the policy will forward traffic locally on the Magic Connector. If not included in request, will default to false. - `LAN1 param.Field[ACLConfiguration]` Body param - `LAN2 param.Field[ACLConfiguration]` Body param - `Name param.Field[string]` Body param: The name of the ACL. - `Protocols param.Field[[]AllowedProtocol]` Body param - `const AllowedProtocolTCP AllowedProtocol = "tcp"` - `const AllowedProtocolUdp AllowedProtocol = "udp"` - `const AllowedProtocolIcmp AllowedProtocol = "icmp"` - `Unidirectional param.Field[bool]` Body param: The desired traffic direction for this ACL policy. If set to "false", the policy will allow bidirectional traffic. If set to "true", the policy will only allow traffic in one direction. If not included in request, will default to false. ### Returns - `type ACL struct{…}` Bidirectional ACL policy for network traffic within a site. - `ID string` Identifier - `Description string` Description for the ACL. - `ForwardLocally bool` The desired forwarding action for this ACL policy. If set to "false", the policy will forward traffic to Cloudflare. If set to "true", the policy will forward traffic locally on the Magic Connector. If not included in request, will default to false. - `LAN1 ACLConfiguration` - `LANID string` The identifier for the LAN you want to create an ACL policy with. - `LANName string` The name of the LAN based on the provided lan_id. - `PortRanges []string` Array of port ranges on the provided LAN that will be included in the ACL. If no ports or port rangess are provided, communication on any port on this LAN is allowed. - `Ports []int64` Array of ports on the provided LAN that will be included in the ACL. If no ports or port ranges are provided, communication on any port on this LAN is allowed. - `Subnets []Subnet` Array of subnet IPs within the LAN that will be included in the ACL. If no subnets are provided, communication on any subnets on this LAN are allowed. - `LAN2 ACLConfiguration` - `Name string` The name of the ACL. - `Protocols []AllowedProtocol` - `const AllowedProtocolTCP AllowedProtocol = "tcp"` - `const AllowedProtocolUdp AllowedProtocol = "udp"` - `const AllowedProtocolIcmp AllowedProtocol = "icmp"` - `Unidirectional bool` The desired traffic direction for this ACL policy. If set to "false", the policy will allow bidirectional traffic. If set to "true", the policy will only allow traffic in one direction. If not included in request, will default to false. ### 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"), ) acl, err := client.MagicTransit.Sites.ACLs.Update( context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", "023e105f4ecef8ad9ca31a8372d0c353", magic_transit.SiteACLUpdateParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", acl.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": "023e105f4ecef8ad9ca31a8372d0c353", "description": "Allows local traffic between PIN pads and cash register.", "forward_locally": true, "lan_1": { "lan_id": "lan_id", "lan_name": "lan_name", "port_ranges": [ "8080-9000" ], "ports": [ 1 ], "subnets": [ "192.0.2.1" ] }, "lan_2": { "lan_id": "lan_id", "lan_name": "lan_name", "port_ranges": [ "8080-9000" ], "ports": [ 1 ], "subnets": [ "192.0.2.1" ] }, "name": "PIN Pad - Cash Register", "protocols": [ "tcp" ], "unidirectional": true }, "success": true } ``` ## Patch Site ACL `client.MagicTransit.Sites.ACLs.Edit(ctx, siteID, aclID, params) (*ACL, error)` **patch** `/accounts/{account_id}/magic/sites/{site_id}/acls/{acl_id}` Patch a specific Site ACL. ### Parameters - `siteID string` Identifier - `aclID string` Identifier - `params SiteACLEditParams` - `AccountID param.Field[string]` Path param: Identifier - `Description param.Field[string]` Body param: Description for the ACL. - `ForwardLocally param.Field[bool]` Body param: The desired forwarding action for this ACL policy. If set to "false", the policy will forward traffic to Cloudflare. If set to "true", the policy will forward traffic locally on the Magic Connector. If not included in request, will default to false. - `LAN1 param.Field[ACLConfiguration]` Body param - `LAN2 param.Field[ACLConfiguration]` Body param - `Name param.Field[string]` Body param: The name of the ACL. - `Protocols param.Field[[]AllowedProtocol]` Body param - `const AllowedProtocolTCP AllowedProtocol = "tcp"` - `const AllowedProtocolUdp AllowedProtocol = "udp"` - `const AllowedProtocolIcmp AllowedProtocol = "icmp"` - `Unidirectional param.Field[bool]` Body param: The desired traffic direction for this ACL policy. If set to "false", the policy will allow bidirectional traffic. If set to "true", the policy will only allow traffic in one direction. If not included in request, will default to false. ### Returns - `type ACL struct{…}` Bidirectional ACL policy for network traffic within a site. - `ID string` Identifier - `Description string` Description for the ACL. - `ForwardLocally bool` The desired forwarding action for this ACL policy. If set to "false", the policy will forward traffic to Cloudflare. If set to "true", the policy will forward traffic locally on the Magic Connector. If not included in request, will default to false. - `LAN1 ACLConfiguration` - `LANID string` The identifier for the LAN you want to create an ACL policy with. - `LANName string` The name of the LAN based on the provided lan_id. - `PortRanges []string` Array of port ranges on the provided LAN that will be included in the ACL. If no ports or port rangess are provided, communication on any port on this LAN is allowed. - `Ports []int64` Array of ports on the provided LAN that will be included in the ACL. If no ports or port ranges are provided, communication on any port on this LAN is allowed. - `Subnets []Subnet` Array of subnet IPs within the LAN that will be included in the ACL. If no subnets are provided, communication on any subnets on this LAN are allowed. - `LAN2 ACLConfiguration` - `Name string` The name of the ACL. - `Protocols []AllowedProtocol` - `const AllowedProtocolTCP AllowedProtocol = "tcp"` - `const AllowedProtocolUdp AllowedProtocol = "udp"` - `const AllowedProtocolIcmp AllowedProtocol = "icmp"` - `Unidirectional bool` The desired traffic direction for this ACL policy. If set to "false", the policy will allow bidirectional traffic. If set to "true", the policy will only allow traffic in one direction. If not included in request, will default to false. ### 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"), ) acl, err := client.MagicTransit.Sites.ACLs.Edit( context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", "023e105f4ecef8ad9ca31a8372d0c353", magic_transit.SiteACLEditParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", acl.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": "023e105f4ecef8ad9ca31a8372d0c353", "description": "Allows local traffic between PIN pads and cash register.", "forward_locally": true, "lan_1": { "lan_id": "lan_id", "lan_name": "lan_name", "port_ranges": [ "8080-9000" ], "ports": [ 1 ], "subnets": [ "192.0.2.1" ] }, "lan_2": { "lan_id": "lan_id", "lan_name": "lan_name", "port_ranges": [ "8080-9000" ], "ports": [ 1 ], "subnets": [ "192.0.2.1" ] }, "name": "PIN Pad - Cash Register", "protocols": [ "tcp" ], "unidirectional": true }, "success": true } ``` ## Delete Site ACL `client.MagicTransit.Sites.ACLs.Delete(ctx, siteID, aclID, body) (*ACL, error)` **delete** `/accounts/{account_id}/magic/sites/{site_id}/acls/{acl_id}` Remove a specific Site ACL. ### Parameters - `siteID string` Identifier - `aclID string` Identifier - `body SiteACLDeleteParams` - `AccountID param.Field[string]` Identifier ### Returns - `type ACL struct{…}` Bidirectional ACL policy for network traffic within a site. - `ID string` Identifier - `Description string` Description for the ACL. - `ForwardLocally bool` The desired forwarding action for this ACL policy. If set to "false", the policy will forward traffic to Cloudflare. If set to "true", the policy will forward traffic locally on the Magic Connector. If not included in request, will default to false. - `LAN1 ACLConfiguration` - `LANID string` The identifier for the LAN you want to create an ACL policy with. - `LANName string` The name of the LAN based on the provided lan_id. - `PortRanges []string` Array of port ranges on the provided LAN that will be included in the ACL. If no ports or port rangess are provided, communication on any port on this LAN is allowed. - `Ports []int64` Array of ports on the provided LAN that will be included in the ACL. If no ports or port ranges are provided, communication on any port on this LAN is allowed. - `Subnets []Subnet` Array of subnet IPs within the LAN that will be included in the ACL. If no subnets are provided, communication on any subnets on this LAN are allowed. - `LAN2 ACLConfiguration` - `Name string` The name of the ACL. - `Protocols []AllowedProtocol` - `const AllowedProtocolTCP AllowedProtocol = "tcp"` - `const AllowedProtocolUdp AllowedProtocol = "udp"` - `const AllowedProtocolIcmp AllowedProtocol = "icmp"` - `Unidirectional bool` The desired traffic direction for this ACL policy. If set to "false", the policy will allow bidirectional traffic. If set to "true", the policy will only allow traffic in one direction. If not included in request, will default to false. ### 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"), ) acl, err := client.MagicTransit.Sites.ACLs.Delete( context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", "023e105f4ecef8ad9ca31a8372d0c353", magic_transit.SiteACLDeleteParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", acl.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": "023e105f4ecef8ad9ca31a8372d0c353", "description": "Allows local traffic between PIN pads and cash register.", "forward_locally": true, "lan_1": { "lan_id": "lan_id", "lan_name": "lan_name", "port_ranges": [ "8080-9000" ], "ports": [ 1 ], "subnets": [ "192.0.2.1" ] }, "lan_2": { "lan_id": "lan_id", "lan_name": "lan_name", "port_ranges": [ "8080-9000" ], "ports": [ 1 ], "subnets": [ "192.0.2.1" ] }, "name": "PIN Pad - Cash Register", "protocols": [ "tcp" ], "unidirectional": true }, "success": true } ``` ## Domain Types ### ACL - `type ACL struct{…}` Bidirectional ACL policy for network traffic within a site. - `ID string` Identifier - `Description string` Description for the ACL. - `ForwardLocally bool` The desired forwarding action for this ACL policy. If set to "false", the policy will forward traffic to Cloudflare. If set to "true", the policy will forward traffic locally on the Magic Connector. If not included in request, will default to false. - `LAN1 ACLConfiguration` - `LANID string` The identifier for the LAN you want to create an ACL policy with. - `LANName string` The name of the LAN based on the provided lan_id. - `PortRanges []string` Array of port ranges on the provided LAN that will be included in the ACL. If no ports or port rangess are provided, communication on any port on this LAN is allowed. - `Ports []int64` Array of ports on the provided LAN that will be included in the ACL. If no ports or port ranges are provided, communication on any port on this LAN is allowed. - `Subnets []Subnet` Array of subnet IPs within the LAN that will be included in the ACL. If no subnets are provided, communication on any subnets on this LAN are allowed. - `LAN2 ACLConfiguration` - `Name string` The name of the ACL. - `Protocols []AllowedProtocol` - `const AllowedProtocolTCP AllowedProtocol = "tcp"` - `const AllowedProtocolUdp AllowedProtocol = "udp"` - `const AllowedProtocolIcmp AllowedProtocol = "icmp"` - `Unidirectional bool` The desired traffic direction for this ACL policy. If set to "false", the policy will allow bidirectional traffic. If set to "true", the policy will only allow traffic in one direction. If not included in request, will default to false. ### ACL Configuration - `type ACLConfiguration struct{…}` - `LANID string` The identifier for the LAN you want to create an ACL policy with. - `LANName string` The name of the LAN based on the provided lan_id. - `PortRanges []string` Array of port ranges on the provided LAN that will be included in the ACL. If no ports or port rangess are provided, communication on any port on this LAN is allowed. - `Ports []int64` Array of ports on the provided LAN that will be included in the ACL. If no ports or port ranges are provided, communication on any port on this LAN is allowed. - `Subnets []Subnet` Array of subnet IPs within the LAN that will be included in the ACL. If no subnets are provided, communication on any subnets on this LAN are allowed. ### Allowed Protocol - `type AllowedProtocol string` Array of allowed communication protocols between configured LANs. If no protocols are provided, all protocols are allowed. - `const AllowedProtocolTCP AllowedProtocol = "tcp"` - `const AllowedProtocolUdp AllowedProtocol = "udp"` - `const AllowedProtocolIcmp AllowedProtocol = "icmp"` ### Subnet - `type Subnet string` A valid IPv4 address. # LANs ## List Site LANs `client.MagicTransit.Sites.LANs.List(ctx, siteID, query) (*SinglePage[LAN], error)` **get** `/accounts/{account_id}/magic/sites/{site_id}/lans` Lists Site LANs associated with an account. ### Parameters - `siteID string` Identifier - `query SiteLANListParams` - `AccountID param.Field[string]` Identifier ### Returns - `type LAN struct{…}` - `ID string` Identifier - `BondID int64` - `HaLink bool` mark true to use this LAN for HA probing. only works for site with HA turned on. only one LAN can be set as the ha_link. - `IsBreakout bool` mark true to use this LAN for source-based breakout traffic - `IsPrioritized bool` mark true to use this LAN for source-based prioritized traffic - `Name string` - `Nat Nat` - `StaticPrefix string` A valid CIDR notation representing an IP range. - `Physport int64` - `RoutedSubnets []RoutedSubnet` - `NextHop string` A valid IPv4 address. - `Prefix string` A valid CIDR notation representing an IP range. - `Nat Nat` - `SiteID string` Identifier - `StaticAddressing LANStaticAddressing` If the site is not configured in high availability mode, this configuration is optional (if omitted, use DHCP). However, if in high availability mode, static_address is required along with secondary and virtual address. - `Address string` A valid CIDR notation representing an IP range. - `DHCPRelay DHCPRelay` - `ServerAddresses []string` List of DHCP server IPs. - `DHCPServer DHCPServer` - `DHCPPoolEnd string` A valid IPv4 address. - `DHCPPoolStart string` A valid IPv4 address. - `DNSServer string` A valid IPv4 address. - `DNSServers []string` - `Reservations map[string, string]` Mapping of MAC addresses to IP addresses - `SecondaryAddress string` A valid CIDR notation representing an IP range. - `VirtualAddress string` A valid CIDR notation representing an IP range. - `VlanTag int64` VLAN ID. Use zero for untagged. ### 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"), ) page, err := client.MagicTransit.Sites.LANs.List( context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", magic_transit.SiteLANListParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) 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": "023e105f4ecef8ad9ca31a8372d0c353", "bond_id": 2, "ha_link": true, "is_breakout": true, "is_prioritized": true, "name": "name", "nat": { "static_prefix": "192.0.2.0/24" }, "physport": 1, "routed_subnets": [ { "next_hop": "192.0.2.1", "prefix": "192.0.2.0/24", "nat": { "static_prefix": "192.0.2.0/24" } } ], "site_id": "023e105f4ecef8ad9ca31a8372d0c353", "static_addressing": { "address": "192.0.2.0/24", "dhcp_relay": { "server_addresses": [ "192.0.2.1" ] }, "dhcp_server": { "dhcp_pool_end": "192.0.2.1", "dhcp_pool_start": "192.0.2.1", "dns_server": "192.0.2.1", "dns_servers": [ "192.0.2.1" ], "reservations": { "00:11:22:33:44:55": "192.0.2.100", "AA:BB:CC:DD:EE:FF": "192.168.1.101" } }, "secondary_address": "192.0.2.0/24", "virtual_address": "192.0.2.0/24" }, "vlan_tag": 42 } ], "success": true } ``` ## Site LAN Details `client.MagicTransit.Sites.LANs.Get(ctx, siteID, lanID, query) (*LAN, error)` **get** `/accounts/{account_id}/magic/sites/{site_id}/lans/{lan_id}` Get a specific Site LAN. ### Parameters - `siteID string` Identifier - `lanID string` Identifier - `query SiteLANGetParams` - `AccountID param.Field[string]` Identifier ### Returns - `type LAN struct{…}` - `ID string` Identifier - `BondID int64` - `HaLink bool` mark true to use this LAN for HA probing. only works for site with HA turned on. only one LAN can be set as the ha_link. - `IsBreakout bool` mark true to use this LAN for source-based breakout traffic - `IsPrioritized bool` mark true to use this LAN for source-based prioritized traffic - `Name string` - `Nat Nat` - `StaticPrefix string` A valid CIDR notation representing an IP range. - `Physport int64` - `RoutedSubnets []RoutedSubnet` - `NextHop string` A valid IPv4 address. - `Prefix string` A valid CIDR notation representing an IP range. - `Nat Nat` - `SiteID string` Identifier - `StaticAddressing LANStaticAddressing` If the site is not configured in high availability mode, this configuration is optional (if omitted, use DHCP). However, if in high availability mode, static_address is required along with secondary and virtual address. - `Address string` A valid CIDR notation representing an IP range. - `DHCPRelay DHCPRelay` - `ServerAddresses []string` List of DHCP server IPs. - `DHCPServer DHCPServer` - `DHCPPoolEnd string` A valid IPv4 address. - `DHCPPoolStart string` A valid IPv4 address. - `DNSServer string` A valid IPv4 address. - `DNSServers []string` - `Reservations map[string, string]` Mapping of MAC addresses to IP addresses - `SecondaryAddress string` A valid CIDR notation representing an IP range. - `VirtualAddress string` A valid CIDR notation representing an IP range. - `VlanTag int64` VLAN ID. Use zero for untagged. ### 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"), ) lan, err := client.MagicTransit.Sites.LANs.Get( context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", "023e105f4ecef8ad9ca31a8372d0c353", magic_transit.SiteLANGetParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", lan.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": "023e105f4ecef8ad9ca31a8372d0c353", "bond_id": 2, "ha_link": true, "is_breakout": true, "is_prioritized": true, "name": "name", "nat": { "static_prefix": "192.0.2.0/24" }, "physport": 1, "routed_subnets": [ { "next_hop": "192.0.2.1", "prefix": "192.0.2.0/24", "nat": { "static_prefix": "192.0.2.0/24" } } ], "site_id": "023e105f4ecef8ad9ca31a8372d0c353", "static_addressing": { "address": "192.0.2.0/24", "dhcp_relay": { "server_addresses": [ "192.0.2.1" ] }, "dhcp_server": { "dhcp_pool_end": "192.0.2.1", "dhcp_pool_start": "192.0.2.1", "dns_server": "192.0.2.1", "dns_servers": [ "192.0.2.1" ], "reservations": { "00:11:22:33:44:55": "192.0.2.100", "AA:BB:CC:DD:EE:FF": "192.168.1.101" } }, "secondary_address": "192.0.2.0/24", "virtual_address": "192.0.2.0/24" }, "vlan_tag": 42 }, "success": true } ``` ## Create a new Site LAN `client.MagicTransit.Sites.LANs.New(ctx, siteID, params) (*SinglePage[LAN], error)` **post** `/accounts/{account_id}/magic/sites/{site_id}/lans` Creates a new Site LAN. If the site is in high availability mode, static_addressing is required along with secondary and virtual address. ### Parameters - `siteID string` Identifier - `params SiteLANNewParams` - `AccountID param.Field[string]` Path param: Identifier - `BondID param.Field[int64]` Body param - `HaLink param.Field[bool]` Body param: mark true to use this LAN for HA probing. only works for site with HA turned on. only one LAN can be set as the ha_link. - `IsBreakout param.Field[bool]` Body param: mark true to use this LAN for source-based breakout traffic - `IsPrioritized param.Field[bool]` Body param: mark true to use this LAN for source-based prioritized traffic - `Name param.Field[string]` Body param - `Nat param.Field[Nat]` Body param - `Physport param.Field[int64]` Body param - `RoutedSubnets param.Field[[]RoutedSubnet]` Body param - `NextHop string` A valid IPv4 address. - `Prefix string` A valid CIDR notation representing an IP range. - `Nat Nat` - `StaticPrefix string` A valid CIDR notation representing an IP range. - `StaticAddressing param.Field[LANStaticAddressing]` Body param: If the site is not configured in high availability mode, this configuration is optional (if omitted, use DHCP). However, if in high availability mode, static_address is required along with secondary and virtual address. - `VlanTag param.Field[int64]` Body param: VLAN ID. Use zero for untagged. ### Returns - `type LAN struct{…}` - `ID string` Identifier - `BondID int64` - `HaLink bool` mark true to use this LAN for HA probing. only works for site with HA turned on. only one LAN can be set as the ha_link. - `IsBreakout bool` mark true to use this LAN for source-based breakout traffic - `IsPrioritized bool` mark true to use this LAN for source-based prioritized traffic - `Name string` - `Nat Nat` - `StaticPrefix string` A valid CIDR notation representing an IP range. - `Physport int64` - `RoutedSubnets []RoutedSubnet` - `NextHop string` A valid IPv4 address. - `Prefix string` A valid CIDR notation representing an IP range. - `Nat Nat` - `SiteID string` Identifier - `StaticAddressing LANStaticAddressing` If the site is not configured in high availability mode, this configuration is optional (if omitted, use DHCP). However, if in high availability mode, static_address is required along with secondary and virtual address. - `Address string` A valid CIDR notation representing an IP range. - `DHCPRelay DHCPRelay` - `ServerAddresses []string` List of DHCP server IPs. - `DHCPServer DHCPServer` - `DHCPPoolEnd string` A valid IPv4 address. - `DHCPPoolStart string` A valid IPv4 address. - `DNSServer string` A valid IPv4 address. - `DNSServers []string` - `Reservations map[string, string]` Mapping of MAC addresses to IP addresses - `SecondaryAddress string` A valid CIDR notation representing an IP range. - `VirtualAddress string` A valid CIDR notation representing an IP range. - `VlanTag int64` VLAN ID. Use zero for untagged. ### 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"), ) page, err := client.MagicTransit.Sites.LANs.New( context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", magic_transit.SiteLANNewParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) 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": "023e105f4ecef8ad9ca31a8372d0c353", "bond_id": 2, "ha_link": true, "is_breakout": true, "is_prioritized": true, "name": "name", "nat": { "static_prefix": "192.0.2.0/24" }, "physport": 1, "routed_subnets": [ { "next_hop": "192.0.2.1", "prefix": "192.0.2.0/24", "nat": { "static_prefix": "192.0.2.0/24" } } ], "site_id": "023e105f4ecef8ad9ca31a8372d0c353", "static_addressing": { "address": "192.0.2.0/24", "dhcp_relay": { "server_addresses": [ "192.0.2.1" ] }, "dhcp_server": { "dhcp_pool_end": "192.0.2.1", "dhcp_pool_start": "192.0.2.1", "dns_server": "192.0.2.1", "dns_servers": [ "192.0.2.1" ], "reservations": { "00:11:22:33:44:55": "192.0.2.100", "AA:BB:CC:DD:EE:FF": "192.168.1.101" } }, "secondary_address": "192.0.2.0/24", "virtual_address": "192.0.2.0/24" }, "vlan_tag": 42 } ], "success": true } ``` ## Update Site LAN `client.MagicTransit.Sites.LANs.Update(ctx, siteID, lanID, params) (*LAN, error)` **put** `/accounts/{account_id}/magic/sites/{site_id}/lans/{lan_id}` Update a specific Site LAN. ### Parameters - `siteID string` Identifier - `lanID string` Identifier - `params SiteLANUpdateParams` - `AccountID param.Field[string]` Path param: Identifier - `BondID param.Field[int64]` Body param - `IsBreakout param.Field[bool]` Body param: mark true to use this LAN for source-based breakout traffic - `IsPrioritized param.Field[bool]` Body param: mark true to use this LAN for source-based prioritized traffic - `Name param.Field[string]` Body param - `Nat param.Field[Nat]` Body param - `Physport param.Field[int64]` Body param - `RoutedSubnets param.Field[[]RoutedSubnet]` Body param - `NextHop string` A valid IPv4 address. - `Prefix string` A valid CIDR notation representing an IP range. - `Nat Nat` - `StaticPrefix string` A valid CIDR notation representing an IP range. - `StaticAddressing param.Field[LANStaticAddressing]` Body param: If the site is not configured in high availability mode, this configuration is optional (if omitted, use DHCP). However, if in high availability mode, static_address is required along with secondary and virtual address. - `VlanTag param.Field[int64]` Body param: VLAN ID. Use zero for untagged. ### Returns - `type LAN struct{…}` - `ID string` Identifier - `BondID int64` - `HaLink bool` mark true to use this LAN for HA probing. only works for site with HA turned on. only one LAN can be set as the ha_link. - `IsBreakout bool` mark true to use this LAN for source-based breakout traffic - `IsPrioritized bool` mark true to use this LAN for source-based prioritized traffic - `Name string` - `Nat Nat` - `StaticPrefix string` A valid CIDR notation representing an IP range. - `Physport int64` - `RoutedSubnets []RoutedSubnet` - `NextHop string` A valid IPv4 address. - `Prefix string` A valid CIDR notation representing an IP range. - `Nat Nat` - `SiteID string` Identifier - `StaticAddressing LANStaticAddressing` If the site is not configured in high availability mode, this configuration is optional (if omitted, use DHCP). However, if in high availability mode, static_address is required along with secondary and virtual address. - `Address string` A valid CIDR notation representing an IP range. - `DHCPRelay DHCPRelay` - `ServerAddresses []string` List of DHCP server IPs. - `DHCPServer DHCPServer` - `DHCPPoolEnd string` A valid IPv4 address. - `DHCPPoolStart string` A valid IPv4 address. - `DNSServer string` A valid IPv4 address. - `DNSServers []string` - `Reservations map[string, string]` Mapping of MAC addresses to IP addresses - `SecondaryAddress string` A valid CIDR notation representing an IP range. - `VirtualAddress string` A valid CIDR notation representing an IP range. - `VlanTag int64` VLAN ID. Use zero for untagged. ### 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"), ) lan, err := client.MagicTransit.Sites.LANs.Update( context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", "023e105f4ecef8ad9ca31a8372d0c353", magic_transit.SiteLANUpdateParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", lan.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": "023e105f4ecef8ad9ca31a8372d0c353", "bond_id": 2, "ha_link": true, "is_breakout": true, "is_prioritized": true, "name": "name", "nat": { "static_prefix": "192.0.2.0/24" }, "physport": 1, "routed_subnets": [ { "next_hop": "192.0.2.1", "prefix": "192.0.2.0/24", "nat": { "static_prefix": "192.0.2.0/24" } } ], "site_id": "023e105f4ecef8ad9ca31a8372d0c353", "static_addressing": { "address": "192.0.2.0/24", "dhcp_relay": { "server_addresses": [ "192.0.2.1" ] }, "dhcp_server": { "dhcp_pool_end": "192.0.2.1", "dhcp_pool_start": "192.0.2.1", "dns_server": "192.0.2.1", "dns_servers": [ "192.0.2.1" ], "reservations": { "00:11:22:33:44:55": "192.0.2.100", "AA:BB:CC:DD:EE:FF": "192.168.1.101" } }, "secondary_address": "192.0.2.0/24", "virtual_address": "192.0.2.0/24" }, "vlan_tag": 42 }, "success": true } ``` ## Patch Site LAN `client.MagicTransit.Sites.LANs.Edit(ctx, siteID, lanID, params) (*LAN, error)` **patch** `/accounts/{account_id}/magic/sites/{site_id}/lans/{lan_id}` Patch a specific Site LAN. ### Parameters - `siteID string` Identifier - `lanID string` Identifier - `params SiteLANEditParams` - `AccountID param.Field[string]` Path param: Identifier - `BondID param.Field[int64]` Body param - `IsBreakout param.Field[bool]` Body param: mark true to use this LAN for source-based breakout traffic - `IsPrioritized param.Field[bool]` Body param: mark true to use this LAN for source-based prioritized traffic - `Name param.Field[string]` Body param - `Nat param.Field[Nat]` Body param - `Physport param.Field[int64]` Body param - `RoutedSubnets param.Field[[]RoutedSubnet]` Body param - `NextHop string` A valid IPv4 address. - `Prefix string` A valid CIDR notation representing an IP range. - `Nat Nat` - `StaticPrefix string` A valid CIDR notation representing an IP range. - `StaticAddressing param.Field[LANStaticAddressing]` Body param: If the site is not configured in high availability mode, this configuration is optional (if omitted, use DHCP). However, if in high availability mode, static_address is required along with secondary and virtual address. - `VlanTag param.Field[int64]` Body param: VLAN ID. Use zero for untagged. ### Returns - `type LAN struct{…}` - `ID string` Identifier - `BondID int64` - `HaLink bool` mark true to use this LAN for HA probing. only works for site with HA turned on. only one LAN can be set as the ha_link. - `IsBreakout bool` mark true to use this LAN for source-based breakout traffic - `IsPrioritized bool` mark true to use this LAN for source-based prioritized traffic - `Name string` - `Nat Nat` - `StaticPrefix string` A valid CIDR notation representing an IP range. - `Physport int64` - `RoutedSubnets []RoutedSubnet` - `NextHop string` A valid IPv4 address. - `Prefix string` A valid CIDR notation representing an IP range. - `Nat Nat` - `SiteID string` Identifier - `StaticAddressing LANStaticAddressing` If the site is not configured in high availability mode, this configuration is optional (if omitted, use DHCP). However, if in high availability mode, static_address is required along with secondary and virtual address. - `Address string` A valid CIDR notation representing an IP range. - `DHCPRelay DHCPRelay` - `ServerAddresses []string` List of DHCP server IPs. - `DHCPServer DHCPServer` - `DHCPPoolEnd string` A valid IPv4 address. - `DHCPPoolStart string` A valid IPv4 address. - `DNSServer string` A valid IPv4 address. - `DNSServers []string` - `Reservations map[string, string]` Mapping of MAC addresses to IP addresses - `SecondaryAddress string` A valid CIDR notation representing an IP range. - `VirtualAddress string` A valid CIDR notation representing an IP range. - `VlanTag int64` VLAN ID. Use zero for untagged. ### 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"), ) lan, err := client.MagicTransit.Sites.LANs.Edit( context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", "023e105f4ecef8ad9ca31a8372d0c353", magic_transit.SiteLANEditParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", lan.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": "023e105f4ecef8ad9ca31a8372d0c353", "bond_id": 2, "ha_link": true, "is_breakout": true, "is_prioritized": true, "name": "name", "nat": { "static_prefix": "192.0.2.0/24" }, "physport": 1, "routed_subnets": [ { "next_hop": "192.0.2.1", "prefix": "192.0.2.0/24", "nat": { "static_prefix": "192.0.2.0/24" } } ], "site_id": "023e105f4ecef8ad9ca31a8372d0c353", "static_addressing": { "address": "192.0.2.0/24", "dhcp_relay": { "server_addresses": [ "192.0.2.1" ] }, "dhcp_server": { "dhcp_pool_end": "192.0.2.1", "dhcp_pool_start": "192.0.2.1", "dns_server": "192.0.2.1", "dns_servers": [ "192.0.2.1" ], "reservations": { "00:11:22:33:44:55": "192.0.2.100", "AA:BB:CC:DD:EE:FF": "192.168.1.101" } }, "secondary_address": "192.0.2.0/24", "virtual_address": "192.0.2.0/24" }, "vlan_tag": 42 }, "success": true } ``` ## Delete Site LAN `client.MagicTransit.Sites.LANs.Delete(ctx, siteID, lanID, body) (*LAN, error)` **delete** `/accounts/{account_id}/magic/sites/{site_id}/lans/{lan_id}` Remove a specific Site LAN. ### Parameters - `siteID string` Identifier - `lanID string` Identifier - `body SiteLANDeleteParams` - `AccountID param.Field[string]` Identifier ### Returns - `type LAN struct{…}` - `ID string` Identifier - `BondID int64` - `HaLink bool` mark true to use this LAN for HA probing. only works for site with HA turned on. only one LAN can be set as the ha_link. - `IsBreakout bool` mark true to use this LAN for source-based breakout traffic - `IsPrioritized bool` mark true to use this LAN for source-based prioritized traffic - `Name string` - `Nat Nat` - `StaticPrefix string` A valid CIDR notation representing an IP range. - `Physport int64` - `RoutedSubnets []RoutedSubnet` - `NextHop string` A valid IPv4 address. - `Prefix string` A valid CIDR notation representing an IP range. - `Nat Nat` - `SiteID string` Identifier - `StaticAddressing LANStaticAddressing` If the site is not configured in high availability mode, this configuration is optional (if omitted, use DHCP). However, if in high availability mode, static_address is required along with secondary and virtual address. - `Address string` A valid CIDR notation representing an IP range. - `DHCPRelay DHCPRelay` - `ServerAddresses []string` List of DHCP server IPs. - `DHCPServer DHCPServer` - `DHCPPoolEnd string` A valid IPv4 address. - `DHCPPoolStart string` A valid IPv4 address. - `DNSServer string` A valid IPv4 address. - `DNSServers []string` - `Reservations map[string, string]` Mapping of MAC addresses to IP addresses - `SecondaryAddress string` A valid CIDR notation representing an IP range. - `VirtualAddress string` A valid CIDR notation representing an IP range. - `VlanTag int64` VLAN ID. Use zero for untagged. ### 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"), ) lan, err := client.MagicTransit.Sites.LANs.Delete( context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", "023e105f4ecef8ad9ca31a8372d0c353", magic_transit.SiteLANDeleteParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", lan.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": "023e105f4ecef8ad9ca31a8372d0c353", "bond_id": 2, "ha_link": true, "is_breakout": true, "is_prioritized": true, "name": "name", "nat": { "static_prefix": "192.0.2.0/24" }, "physport": 1, "routed_subnets": [ { "next_hop": "192.0.2.1", "prefix": "192.0.2.0/24", "nat": { "static_prefix": "192.0.2.0/24" } } ], "site_id": "023e105f4ecef8ad9ca31a8372d0c353", "static_addressing": { "address": "192.0.2.0/24", "dhcp_relay": { "server_addresses": [ "192.0.2.1" ] }, "dhcp_server": { "dhcp_pool_end": "192.0.2.1", "dhcp_pool_start": "192.0.2.1", "dns_server": "192.0.2.1", "dns_servers": [ "192.0.2.1" ], "reservations": { "00:11:22:33:44:55": "192.0.2.100", "AA:BB:CC:DD:EE:FF": "192.168.1.101" } }, "secondary_address": "192.0.2.0/24", "virtual_address": "192.0.2.0/24" }, "vlan_tag": 42 }, "success": true } ``` ## Domain Types ### DHCP Relay - `type DHCPRelay struct{…}` - `ServerAddresses []string` List of DHCP server IPs. ### DHCP Server - `type DHCPServer struct{…}` - `DHCPPoolEnd string` A valid IPv4 address. - `DHCPPoolStart string` A valid IPv4 address. - `DNSServer string` A valid IPv4 address. - `DNSServers []string` - `Reservations map[string, string]` Mapping of MAC addresses to IP addresses ### LAN - `type LAN struct{…}` - `ID string` Identifier - `BondID int64` - `HaLink bool` mark true to use this LAN for HA probing. only works for site with HA turned on. only one LAN can be set as the ha_link. - `IsBreakout bool` mark true to use this LAN for source-based breakout traffic - `IsPrioritized bool` mark true to use this LAN for source-based prioritized traffic - `Name string` - `Nat Nat` - `StaticPrefix string` A valid CIDR notation representing an IP range. - `Physport int64` - `RoutedSubnets []RoutedSubnet` - `NextHop string` A valid IPv4 address. - `Prefix string` A valid CIDR notation representing an IP range. - `Nat Nat` - `SiteID string` Identifier - `StaticAddressing LANStaticAddressing` If the site is not configured in high availability mode, this configuration is optional (if omitted, use DHCP). However, if in high availability mode, static_address is required along with secondary and virtual address. - `Address string` A valid CIDR notation representing an IP range. - `DHCPRelay DHCPRelay` - `ServerAddresses []string` List of DHCP server IPs. - `DHCPServer DHCPServer` - `DHCPPoolEnd string` A valid IPv4 address. - `DHCPPoolStart string` A valid IPv4 address. - `DNSServer string` A valid IPv4 address. - `DNSServers []string` - `Reservations map[string, string]` Mapping of MAC addresses to IP addresses - `SecondaryAddress string` A valid CIDR notation representing an IP range. - `VirtualAddress string` A valid CIDR notation representing an IP range. - `VlanTag int64` VLAN ID. Use zero for untagged. ### LAN Static Addressing - `type LANStaticAddressing struct{…}` If the site is not configured in high availability mode, this configuration is optional (if omitted, use DHCP). However, if in high availability mode, static_address is required along with secondary and virtual address. - `Address string` A valid CIDR notation representing an IP range. - `DHCPRelay DHCPRelay` - `ServerAddresses []string` List of DHCP server IPs. - `DHCPServer DHCPServer` - `DHCPPoolEnd string` A valid IPv4 address. - `DHCPPoolStart string` A valid IPv4 address. - `DNSServer string` A valid IPv4 address. - `DNSServers []string` - `Reservations map[string, string]` Mapping of MAC addresses to IP addresses - `SecondaryAddress string` A valid CIDR notation representing an IP range. - `VirtualAddress string` A valid CIDR notation representing an IP range. ### Nat - `type Nat struct{…}` - `StaticPrefix string` A valid CIDR notation representing an IP range. ### Routed Subnet - `type RoutedSubnet struct{…}` - `NextHop string` A valid IPv4 address. - `Prefix string` A valid CIDR notation representing an IP range. - `Nat Nat` - `StaticPrefix string` A valid CIDR notation representing an IP range. # WANs ## List Site WANs `client.MagicTransit.Sites.WANs.List(ctx, siteID, query) (*SinglePage[WAN], error)` **get** `/accounts/{account_id}/magic/sites/{site_id}/wans` Lists Site WANs associated with an account. ### Parameters - `siteID string` Identifier - `query SiteWANListParams` - `AccountID param.Field[string]` Identifier ### Returns - `type WAN struct{…}` - `ID string` Identifier - `HealthCheckRate WANHealthCheckRate` Magic WAN health check rate for tunnels created on this link. The default value is `mid`. - `const WANHealthCheckRateLow WANHealthCheckRate = "low"` - `const WANHealthCheckRateMid WANHealthCheckRate = "mid"` - `const WANHealthCheckRateHigh WANHealthCheckRate = "high"` - `Name string` - `Physport int64` - `Priority int64` Priority of WAN for traffic loadbalancing. - `SiteID string` Identifier - `StaticAddressing WANStaticAddressing` (optional) if omitted, use DHCP. Submit secondary_address when site is in high availability mode. - `Address string` A valid CIDR notation representing an IP range. - `GatewayAddress string` A valid IPv4 address. - `SecondaryAddress string` A valid CIDR notation representing an IP range. - `VlanTag int64` VLAN ID. Use zero for untagged. ### 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"), ) page, err := client.MagicTransit.Sites.WANs.List( context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", magic_transit.SiteWANListParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) 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": "023e105f4ecef8ad9ca31a8372d0c353", "health_check_rate": "low", "name": "name", "physport": 1, "priority": 0, "site_id": "023e105f4ecef8ad9ca31a8372d0c353", "static_addressing": { "address": "192.0.2.0/24", "gateway_address": "192.0.2.1", "secondary_address": "192.0.2.0/24" }, "vlan_tag": 42 } ], "success": true } ``` ## Site WAN Details `client.MagicTransit.Sites.WANs.Get(ctx, siteID, wanID, query) (*WAN, error)` **get** `/accounts/{account_id}/magic/sites/{site_id}/wans/{wan_id}` Get a specific Site WAN. ### Parameters - `siteID string` Identifier - `wanID string` Identifier - `query SiteWANGetParams` - `AccountID param.Field[string]` Identifier ### Returns - `type WAN struct{…}` - `ID string` Identifier - `HealthCheckRate WANHealthCheckRate` Magic WAN health check rate for tunnels created on this link. The default value is `mid`. - `const WANHealthCheckRateLow WANHealthCheckRate = "low"` - `const WANHealthCheckRateMid WANHealthCheckRate = "mid"` - `const WANHealthCheckRateHigh WANHealthCheckRate = "high"` - `Name string` - `Physport int64` - `Priority int64` Priority of WAN for traffic loadbalancing. - `SiteID string` Identifier - `StaticAddressing WANStaticAddressing` (optional) if omitted, use DHCP. Submit secondary_address when site is in high availability mode. - `Address string` A valid CIDR notation representing an IP range. - `GatewayAddress string` A valid IPv4 address. - `SecondaryAddress string` A valid CIDR notation representing an IP range. - `VlanTag int64` VLAN ID. Use zero for untagged. ### 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"), ) wan, err := client.MagicTransit.Sites.WANs.Get( context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", "023e105f4ecef8ad9ca31a8372d0c353", magic_transit.SiteWANGetParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", wan.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": "023e105f4ecef8ad9ca31a8372d0c353", "health_check_rate": "low", "name": "name", "physport": 1, "priority": 0, "site_id": "023e105f4ecef8ad9ca31a8372d0c353", "static_addressing": { "address": "192.0.2.0/24", "gateway_address": "192.0.2.1", "secondary_address": "192.0.2.0/24" }, "vlan_tag": 42 }, "success": true } ``` ## Create a new Site WAN `client.MagicTransit.Sites.WANs.New(ctx, siteID, params) (*SinglePage[WAN], error)` **post** `/accounts/{account_id}/magic/sites/{site_id}/wans` Creates a new Site WAN. ### Parameters - `siteID string` Identifier - `params SiteWANNewParams` - `AccountID param.Field[string]` Path param: Identifier - `Physport param.Field[int64]` Body param - `Name param.Field[string]` Body param - `Priority param.Field[int64]` Body param - `StaticAddressing param.Field[WANStaticAddressing]` Body param: (optional) if omitted, use DHCP. Submit secondary_address when site is in high availability mode. - `VlanTag param.Field[int64]` Body param: VLAN ID. Use zero for untagged. ### Returns - `type WAN struct{…}` - `ID string` Identifier - `HealthCheckRate WANHealthCheckRate` Magic WAN health check rate for tunnels created on this link. The default value is `mid`. - `const WANHealthCheckRateLow WANHealthCheckRate = "low"` - `const WANHealthCheckRateMid WANHealthCheckRate = "mid"` - `const WANHealthCheckRateHigh WANHealthCheckRate = "high"` - `Name string` - `Physport int64` - `Priority int64` Priority of WAN for traffic loadbalancing. - `SiteID string` Identifier - `StaticAddressing WANStaticAddressing` (optional) if omitted, use DHCP. Submit secondary_address when site is in high availability mode. - `Address string` A valid CIDR notation representing an IP range. - `GatewayAddress string` A valid IPv4 address. - `SecondaryAddress string` A valid CIDR notation representing an IP range. - `VlanTag int64` VLAN ID. Use zero for untagged. ### 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"), ) page, err := client.MagicTransit.Sites.WANs.New( context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", magic_transit.SiteWANNewParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Physport: cloudflare.F(int64(1)), }, ) 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": "023e105f4ecef8ad9ca31a8372d0c353", "health_check_rate": "low", "name": "name", "physport": 1, "priority": 0, "site_id": "023e105f4ecef8ad9ca31a8372d0c353", "static_addressing": { "address": "192.0.2.0/24", "gateway_address": "192.0.2.1", "secondary_address": "192.0.2.0/24" }, "vlan_tag": 42 } ], "success": true } ``` ## Update Site WAN `client.MagicTransit.Sites.WANs.Update(ctx, siteID, wanID, params) (*WAN, error)` **put** `/accounts/{account_id}/magic/sites/{site_id}/wans/{wan_id}` Update a specific Site WAN. ### Parameters - `siteID string` Identifier - `wanID string` Identifier - `params SiteWANUpdateParams` - `AccountID param.Field[string]` Path param: Identifier - `Name param.Field[string]` Body param - `Physport param.Field[int64]` Body param - `Priority param.Field[int64]` Body param - `StaticAddressing param.Field[WANStaticAddressing]` Body param: (optional) if omitted, use DHCP. Submit secondary_address when site is in high availability mode. - `VlanTag param.Field[int64]` Body param: VLAN ID. Use zero for untagged. ### Returns - `type WAN struct{…}` - `ID string` Identifier - `HealthCheckRate WANHealthCheckRate` Magic WAN health check rate for tunnels created on this link. The default value is `mid`. - `const WANHealthCheckRateLow WANHealthCheckRate = "low"` - `const WANHealthCheckRateMid WANHealthCheckRate = "mid"` - `const WANHealthCheckRateHigh WANHealthCheckRate = "high"` - `Name string` - `Physport int64` - `Priority int64` Priority of WAN for traffic loadbalancing. - `SiteID string` Identifier - `StaticAddressing WANStaticAddressing` (optional) if omitted, use DHCP. Submit secondary_address when site is in high availability mode. - `Address string` A valid CIDR notation representing an IP range. - `GatewayAddress string` A valid IPv4 address. - `SecondaryAddress string` A valid CIDR notation representing an IP range. - `VlanTag int64` VLAN ID. Use zero for untagged. ### 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"), ) wan, err := client.MagicTransit.Sites.WANs.Update( context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", "023e105f4ecef8ad9ca31a8372d0c353", magic_transit.SiteWANUpdateParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", wan.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": "023e105f4ecef8ad9ca31a8372d0c353", "health_check_rate": "low", "name": "name", "physport": 1, "priority": 0, "site_id": "023e105f4ecef8ad9ca31a8372d0c353", "static_addressing": { "address": "192.0.2.0/24", "gateway_address": "192.0.2.1", "secondary_address": "192.0.2.0/24" }, "vlan_tag": 42 }, "success": true } ``` ## Patch Site WAN `client.MagicTransit.Sites.WANs.Edit(ctx, siteID, wanID, params) (*WAN, error)` **patch** `/accounts/{account_id}/magic/sites/{site_id}/wans/{wan_id}` Patch a specific Site WAN. ### Parameters - `siteID string` Identifier - `wanID string` Identifier - `params SiteWANEditParams` - `AccountID param.Field[string]` Path param: Identifier - `Name param.Field[string]` Body param - `Physport param.Field[int64]` Body param - `Priority param.Field[int64]` Body param - `StaticAddressing param.Field[WANStaticAddressing]` Body param: (optional) if omitted, use DHCP. Submit secondary_address when site is in high availability mode. - `VlanTag param.Field[int64]` Body param: VLAN ID. Use zero for untagged. ### Returns - `type WAN struct{…}` - `ID string` Identifier - `HealthCheckRate WANHealthCheckRate` Magic WAN health check rate for tunnels created on this link. The default value is `mid`. - `const WANHealthCheckRateLow WANHealthCheckRate = "low"` - `const WANHealthCheckRateMid WANHealthCheckRate = "mid"` - `const WANHealthCheckRateHigh WANHealthCheckRate = "high"` - `Name string` - `Physport int64` - `Priority int64` Priority of WAN for traffic loadbalancing. - `SiteID string` Identifier - `StaticAddressing WANStaticAddressing` (optional) if omitted, use DHCP. Submit secondary_address when site is in high availability mode. - `Address string` A valid CIDR notation representing an IP range. - `GatewayAddress string` A valid IPv4 address. - `SecondaryAddress string` A valid CIDR notation representing an IP range. - `VlanTag int64` VLAN ID. Use zero for untagged. ### 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"), ) wan, err := client.MagicTransit.Sites.WANs.Edit( context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", "023e105f4ecef8ad9ca31a8372d0c353", magic_transit.SiteWANEditParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", wan.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": "023e105f4ecef8ad9ca31a8372d0c353", "health_check_rate": "low", "name": "name", "physport": 1, "priority": 0, "site_id": "023e105f4ecef8ad9ca31a8372d0c353", "static_addressing": { "address": "192.0.2.0/24", "gateway_address": "192.0.2.1", "secondary_address": "192.0.2.0/24" }, "vlan_tag": 42 }, "success": true } ``` ## Delete Site WAN `client.MagicTransit.Sites.WANs.Delete(ctx, siteID, wanID, body) (*WAN, error)` **delete** `/accounts/{account_id}/magic/sites/{site_id}/wans/{wan_id}` Remove a specific Site WAN. ### Parameters - `siteID string` Identifier - `wanID string` Identifier - `body SiteWANDeleteParams` - `AccountID param.Field[string]` Identifier ### Returns - `type WAN struct{…}` - `ID string` Identifier - `HealthCheckRate WANHealthCheckRate` Magic WAN health check rate for tunnels created on this link. The default value is `mid`. - `const WANHealthCheckRateLow WANHealthCheckRate = "low"` - `const WANHealthCheckRateMid WANHealthCheckRate = "mid"` - `const WANHealthCheckRateHigh WANHealthCheckRate = "high"` - `Name string` - `Physport int64` - `Priority int64` Priority of WAN for traffic loadbalancing. - `SiteID string` Identifier - `StaticAddressing WANStaticAddressing` (optional) if omitted, use DHCP. Submit secondary_address when site is in high availability mode. - `Address string` A valid CIDR notation representing an IP range. - `GatewayAddress string` A valid IPv4 address. - `SecondaryAddress string` A valid CIDR notation representing an IP range. - `VlanTag int64` VLAN ID. Use zero for untagged. ### 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"), ) wan, err := client.MagicTransit.Sites.WANs.Delete( context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", "023e105f4ecef8ad9ca31a8372d0c353", magic_transit.SiteWANDeleteParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", wan.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": "023e105f4ecef8ad9ca31a8372d0c353", "health_check_rate": "low", "name": "name", "physport": 1, "priority": 0, "site_id": "023e105f4ecef8ad9ca31a8372d0c353", "static_addressing": { "address": "192.0.2.0/24", "gateway_address": "192.0.2.1", "secondary_address": "192.0.2.0/24" }, "vlan_tag": 42 }, "success": true } ``` ## Domain Types ### WAN - `type WAN struct{…}` - `ID string` Identifier - `HealthCheckRate WANHealthCheckRate` Magic WAN health check rate for tunnels created on this link. The default value is `mid`. - `const WANHealthCheckRateLow WANHealthCheckRate = "low"` - `const WANHealthCheckRateMid WANHealthCheckRate = "mid"` - `const WANHealthCheckRateHigh WANHealthCheckRate = "high"` - `Name string` - `Physport int64` - `Priority int64` Priority of WAN for traffic loadbalancing. - `SiteID string` Identifier - `StaticAddressing WANStaticAddressing` (optional) if omitted, use DHCP. Submit secondary_address when site is in high availability mode. - `Address string` A valid CIDR notation representing an IP range. - `GatewayAddress string` A valid IPv4 address. - `SecondaryAddress string` A valid CIDR notation representing an IP range. - `VlanTag int64` VLAN ID. Use zero for untagged. ### WAN Static Addressing - `type WANStaticAddressing struct{…}` (optional) if omitted, use DHCP. Submit secondary_address when site is in high availability mode. - `Address string` A valid CIDR notation representing an IP range. - `GatewayAddress string` A valid IPv4 address. - `SecondaryAddress string` A valid CIDR notation representing an IP range.