# Regional Hostnames ## List Regional Hostnames `client.Addressing.RegionalHostnames.List(ctx, query) (*SinglePage[RegionalHostnameListResponse], error)` **get** `/zones/{zone_id}/addressing/regional_hostnames` List all Regional Hostnames within a zone. ### Parameters - `query RegionalHostnameListParams` - `ZoneID param.Field[string]` Identifier. ### Returns - `type RegionalHostnameListResponse struct{…}` - `CreatedOn Time` When the regional hostname was created - `Hostname string` DNS hostname to be regionalized, must be a subdomain of the zone. Wildcards are supported for one level, e.g `*.example.com` - `RegionKey string` Identifying key for the region - `Routing string` Configure which routing method to use for the regional hostname ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/addressing" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) page, err := client.Addressing.RegionalHostnames.List(context.TODO(), addressing.RegionalHostnameListParams{ ZoneID: 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" } } ], "success": true, "result": [ { "created_on": "2014-01-01T05:20:00.12345Z", "hostname": "foo.example.com", "region_key": "ca", "routing": "dns" } ], "result_info": { "count": 1, "page": 1, "per_page": 20, "total_count": 2000, "total_pages": 100 } } ``` ## Fetch Regional Hostname `client.Addressing.RegionalHostnames.Get(ctx, hostname, query) (*RegionalHostnameGetResponse, error)` **get** `/zones/{zone_id}/addressing/regional_hostnames/{hostname}` Fetch the configuration for a specific Regional Hostname, within a zone. ### Parameters - `hostname string` DNS hostname to be regionalized, must be a subdomain of the zone. Wildcards are supported for one level, e.g `*.example.com` - `query RegionalHostnameGetParams` - `ZoneID param.Field[string]` Identifier. ### Returns - `type RegionalHostnameGetResponse struct{…}` - `CreatedOn Time` When the regional hostname was created - `Hostname string` DNS hostname to be regionalized, must be a subdomain of the zone. Wildcards are supported for one level, e.g `*.example.com` - `RegionKey string` Identifying key for the region - `Routing string` Configure which routing method to use for the regional hostname ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/addressing" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) regionalHostname, err := client.Addressing.RegionalHostnames.Get( context.TODO(), "foo.example.com", addressing.RegionalHostnameGetParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", regionalHostname.CreatedOn) } ``` #### 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" } } ], "success": true, "result": { "created_on": "2014-01-01T05:20:00.12345Z", "hostname": "foo.example.com", "region_key": "ca", "routing": "dns" } } ``` ## Create Regional Hostname `client.Addressing.RegionalHostnames.New(ctx, params) (*RegionalHostnameNewResponse, error)` **post** `/zones/{zone_id}/addressing/regional_hostnames` Create a new Regional Hostname entry. Cloudflare will only use data centers that are physically located within the chosen region to decrypt and service HTTPS traffic. Learn more about [Regional Services](https://developers.cloudflare.com/data-localization/regional-services/get-started/). ### Parameters - `params RegionalHostnameNewParams` - `ZoneID param.Field[string]` Path param: Identifier. - `Hostname param.Field[string]` Body param: DNS hostname to be regionalized, must be a subdomain of the zone. Wildcards are supported for one level, e.g `*.example.com` - `RegionKey param.Field[string]` Body param: Identifying key for the region - `Routing param.Field[string]` Body param: Configure which routing method to use for the regional hostname ### Returns - `type RegionalHostnameNewResponse struct{…}` - `CreatedOn Time` When the regional hostname was created - `Hostname string` DNS hostname to be regionalized, must be a subdomain of the zone. Wildcards are supported for one level, e.g `*.example.com` - `RegionKey string` Identifying key for the region - `Routing string` Configure which routing method to use for the regional hostname ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/addressing" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) regionalHostname, err := client.Addressing.RegionalHostnames.New(context.TODO(), addressing.RegionalHostnameNewParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Hostname: cloudflare.F("foo.example.com"), RegionKey: cloudflare.F("ca"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", regionalHostname.CreatedOn) } ``` #### 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" } } ], "success": true, "result": { "created_on": "2014-01-01T05:20:00.12345Z", "hostname": "foo.example.com", "region_key": "ca", "routing": "dns" } } ``` ## Update Regional Hostname `client.Addressing.RegionalHostnames.Edit(ctx, hostname, params) (*RegionalHostnameEditResponse, error)` **patch** `/zones/{zone_id}/addressing/regional_hostnames/{hostname}` Update the configuration for a specific Regional Hostname. Only the region_key of a hostname is mutable. ### Parameters - `hostname string` DNS hostname to be regionalized, must be a subdomain of the zone. Wildcards are supported for one level, e.g `*.example.com` - `params RegionalHostnameEditParams` - `ZoneID param.Field[string]` Path param: Identifier. - `RegionKey param.Field[string]` Body param: Identifying key for the region ### Returns - `type RegionalHostnameEditResponse struct{…}` - `CreatedOn Time` When the regional hostname was created - `Hostname string` DNS hostname to be regionalized, must be a subdomain of the zone. Wildcards are supported for one level, e.g `*.example.com` - `RegionKey string` Identifying key for the region - `Routing string` Configure which routing method to use for the regional hostname ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/addressing" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) response, err := client.Addressing.RegionalHostnames.Edit( context.TODO(), "foo.example.com", addressing.RegionalHostnameEditParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), RegionKey: cloudflare.F("ca"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", response.CreatedOn) } ``` #### 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" } } ], "success": true, "result": { "created_on": "2014-01-01T05:20:00.12345Z", "hostname": "foo.example.com", "region_key": "ca", "routing": "dns" } } ``` ## Delete Regional Hostname `client.Addressing.RegionalHostnames.Delete(ctx, hostname, body) (*RegionalHostnameDeleteResponse, error)` **delete** `/zones/{zone_id}/addressing/regional_hostnames/{hostname}` Delete the region configuration for a specific Regional Hostname. ### Parameters - `hostname string` DNS hostname to be regionalized, must be a subdomain of the zone. Wildcards are supported for one level, e.g `*.example.com` - `body RegionalHostnameDeleteParams` - `ZoneID param.Field[string]` Identifier. ### Returns - `type RegionalHostnameDeleteResponse struct{…}` - `Errors []RegionalHostnameDeleteResponseError` - `Code int64` - `Message string` - `DocumentationURL string` - `Source RegionalHostnameDeleteResponseErrorsSource` - `Pointer string` - `Messages []RegionalHostnameDeleteResponseMessage` - `Code int64` - `Message string` - `DocumentationURL string` - `Source RegionalHostnameDeleteResponseMessagesSource` - `Pointer string` - `Success RegionalHostnameDeleteResponseSuccess` Whether the API call was successful. - `const RegionalHostnameDeleteResponseSuccessTrue RegionalHostnameDeleteResponseSuccess = true` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/addressing" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) regionalHostname, err := client.Addressing.RegionalHostnames.Delete( context.TODO(), "foo.example.com", addressing.RegionalHostnameDeleteParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", regionalHostname.Errors) } ``` #### 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" } } ], "success": true } ``` # Regions ## List Regions `client.Addressing.RegionalHostnames.Regions.List(ctx, query) (*SinglePage[RegionalHostnameRegionListResponse], error)` **get** `/accounts/{account_id}/addressing/regional_hostnames/regions` List all Regional Services regions available for use by this account. ### Parameters - `query RegionalHostnameRegionListParams` - `AccountID param.Field[string]` Identifier. ### Returns - `type RegionalHostnameRegionListResponse struct{…}` - `Key string` Identifying key for the region - `Label string` Human-readable text label for the region ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/addressing" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) page, err := client.Addressing.RegionalHostnames.Regions.List(context.TODO(), addressing.RegionalHostnameRegionListParams{ 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" } } ], "success": true, "result": [ { "key": "ca", "label": "Canada" } ], "result_info": { "count": 1, "page": 1, "per_page": 20, "total_count": 2000, "total_pages": 100 } } ```