zones

package
v0.0.0-...-ae37572 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 6, 2020 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

When users need to access a server on the Internet, an IP address is required. However, it is hard to memorize an IP address. Therefore, a domain name easy to memorize is used to identify the IP address. After registering a domain name, you get the right to use it but users cannot access the website, send or receive emails using your domain name until the name is resolved. Domain name resolution is to map domain names to IP addresses. In this case, to access a website on the Internet, visitors only need to enter a domain name in the browser address bar, instead of an IP address.

Sample Code, Create a private zone.

result, err := zones.Create(client, zones.CreateOpts{
    Name:        "www.ba1.com.",
    Description: "My Zone",
    ZoneType:    "private",
    Email:       "test@test.com",
    Ttl:         3600,
    Router: struct {
        RouterId     string `json:"router_id,omitempty"`
        RouterRegion string `json:"router_region,omitempty"`
    }{
        RouterId:     "773c3c42-d315-417b-9063-87091713148c",
        RouterRegion: "cn-north-1",
    },
}).Extract()

if err != nil {
    panic(err)
}

Sample Code, Delete a zone.

result, err := zones.Delete(client, "ff80808262baef150162bbf1bc4a167a").Extract()
if err != nil {
    panic(err)
}

Sample Code, Query a zone.

result, err := zones.Get(client, "ff80808262baef150162bbf1bc4a167a").Extract()
if err != nil {
    panic(err)
}

Sample Code, Query zones in list.

allPages, err := zones.List(client, zones.ListOpts{
    Limit: "2",
    Type:  "private",
}).AllPages()

result, err := zones.ExtractList(allPages.(zones.ListPage))

if err != nil {
    panic(err)
}

Sample Code, Query name servers in a zone.

result, err := zones.ListNameServers(client, "ff80808262baef150162bbf1bc4a167a").Extract()
if err != nil {
    panic(err)
}

Sample Code, Associate a zone with a VPC.

result, err := zones.AssociateRouter(client, "ff80808262baef150162bbf1bc4a167a", zones.AssociateRouterOpts{
    Router: struct {
        RouterId     string `json:"router_id,omitempty"`
        RouterRegion string `json:"router_region,omitempty"`
    }{
        RouterId:     "773c3c42-d315-417b-9063-87091713148c",
        RouterRegion: "cn-north-1",
    },
}).Extract()

if err != nil {
    panic(err)
}

Sample Code, Disassociate a VPC from a zone.

result, err := zones.DisassociateRouter(client, "ff80808262baef150162bbf1bc4a167a", zones.DisassociateRouterOpts{
    Router: struct {
        RouterId     string `json:"router_id,omitempty"`
        RouterRegion string `json:"router_region,omitempty"`
    }{
        RouterId:     "773c3c42-d315-417b-9063-87091713148c",
        RouterRegion: "cn-north-1",
    },
}).Extract()

if err != nil {
    panic(err)
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssociateRouterURL

func AssociateRouterURL(c *gophercloud.ServiceClient, zoneId string) string

func CreateURL

func CreateURL(c *gophercloud.ServiceClient) string

func DeleteURL

func DeleteURL(c *gophercloud.ServiceClient, zoneId string) string

func DisassociateRouterURL

func DisassociateRouterURL(c *gophercloud.ServiceClient, zoneId string) string

func GetURL

func GetURL(c *gophercloud.ServiceClient, zoneId string) string

func List

Query zones in list.

func ListNameServersURL

func ListNameServersURL(c *gophercloud.ServiceClient, zoneId string) string

func ListURL

func ListURL(c *gophercloud.ServiceClient) string

func UpdateURL

func UpdateURL(c *gophercloud.ServiceClient, zoneId string) string

Types

type AssociateRouterOpts

type AssociateRouterOpts struct {
	// Router information (VPC associated with the zone)
	Router Router `json:"router"`
}

func (AssociateRouterOpts) ToZonesAssociateRouterMap

func (opts AssociateRouterOpts) ToZonesAssociateRouterMap() (map[string]interface{}, error)

type AssociateRouterOptsBuilder

type AssociateRouterOptsBuilder interface {
	ToZonesAssociateRouterMap() (map[string]interface{}, error)
}

type AssociateRouterResponse

type AssociateRouterResponse struct {
	// Router ID (VPC ID)
	RouterId string `json:"router_id"`

	// Region of the router (VPC).If it is left blank, the region of
	// the project in the token takes effect by default.
	RouterRegion string `json:"router_region"`

	// Task status.The value can be PENDING_CREATE, PENDING_DELETE,
	// ACTIVE, or ERROR.
	Status string `json:"status"`
}

Router, Router (VPC) information associated with the private zone.

type AssociateRouterResult

type AssociateRouterResult struct {
	// contains filtered or unexported fields
}

func (AssociateRouterResult) Extract

type CreateOpts

type CreateOpts struct {
	// Mail address of the administrator managing the zone
	Email string `json:"email,omitempty"`

	// Description of the domain name, which cannot exceed 255
	// characters
	Description string `json:"description,omitempty"`

	// Name of the zone to be created,If the domain name is ended with
	// a dot (.), it cannot exceed 254 characters.Otherwise, the domain name cannot exceed
	// 253 characters.
	Name string `json:"name" required:"true"`

	// Zone type. The value must be private, indicating that private
	// network domain names accessible only to hosts in specified VPCs will be queried.
	ZoneType string `json:"zone_type" required:"true"`

	// Caching period of the SOA record set (in seconds).The default
	// value is 300s.The value range is 300–2147483647.
	TTL int `json:"ttl,omitempty"`

	// Router information (VPC associated with the private zone)
	Router RouterCreateOpts `json:"router"`
}

func (CreateOpts) ToZonesCreateMap

func (opts CreateOpts) ToZonesCreateMap() (map[string]interface{}, error)

type CreateOptsBuilder

type CreateOptsBuilder interface {
	ToZonesCreateMap() (map[string]interface{}, error)
}

type CreateResult

type CreateResult struct {
	// contains filtered or unexported fields
}

CreateResult is the result of a Create request. Call its Extract method to interpret the result as a Zone.

func Create

func Create(client *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult)

func (CreateResult) Extract

func (r CreateResult) Extract() (*ZoneCreateResponse, error)

type DeleteResult

type DeleteResult struct {
	// contains filtered or unexported fields
}

DeleteResult is the result of a Delete request. Call its ExtractErr method to determine if the request succeeded or failed.

func Delete

func Delete(client *gophercloud.ServiceClient, zoneId string) (r DeleteResult)

func (DeleteResult) Extract

func (r DeleteResult) Extract() (*Zone, error)

type DisassociateRouterOpts

type DisassociateRouterOpts struct {
	// Router information (VPC associated with the zone)
	Router Router `json:"router"`
}

func (DisassociateRouterOpts) ToZonesDisassociateRouterMap

func (opts DisassociateRouterOpts) ToZonesDisassociateRouterMap() (map[string]interface{}, error)

type DisassociateRouterOptsBuilder

type DisassociateRouterOptsBuilder interface {
	ToZonesDisassociateRouterMap() (map[string]interface{}, error)
}

type DisassociateRouterResponse

type DisassociateRouterResponse struct {
	// Router ID (VPC ID)
	RouterId string `json:"router_id"`

	// Region of the router (VPC).If it is left blank, the region of
	// the project in the token takes effect by default.
	RouterRegion string `json:"router_region"`

	// Task status.The value can be PENDING_CREATE, PENDING_DELETE,
	// ACTIVE, or ERROR.
	Status string `json:"status"`
}

Router, Router (VPC) information associated with the private zone.

type DisassociateRouterResult

type DisassociateRouterResult struct {
	// contains filtered or unexported fields
}

func (DisassociateRouterResult) Extract

type GetResult

type GetResult struct {
	// contains filtered or unexported fields
}

GetResult is the result of a Get request. Call its Extract method to interpret the result as a Zone.

func Get

func Get(client *gophercloud.ServiceClient, zoneId string) (r GetResult)

func (GetResult) Extract

func (r GetResult) Extract() (*Zone, error)
type Link struct {
	Href string `json:"href"`
	Rel  string `json:"rel"`
	Self string `json:"self"`
	Next string `json:"next"`
}

type ListNameServersResponse

type ListNameServersResponse struct {
	// Name server list object
	Nameservers []NameServer `json:"nameservers"`
}

type ListNameServersResult

type ListNameServersResult struct {
	// contains filtered or unexported fields
}

func ListNameServers

func ListNameServers(client *gophercloud.ServiceClient, zoneId string) (r ListNameServersResult)

func (ListNameServersResult) Extract

type ListOpts

type ListOpts struct {
	// Number of resources returned on each page.Value range:
	// 0–500.Commonly used values are 10, 20, and 50.
	Limit int `q:"limit"`

	// Start resource ID of pagination query.If the parameter is left
	// blank, only resources on the first page are queried.
	Marker string `q:"marker"`

	// Zone type, which can be public or private.public: Public zones
	// are queried.private: Private zones are queried.If the value is left blank, public
	// zones are queried by default.
	Type string `q:"type"`
}

func (ListOpts) ToListQuery

func (opts ListOpts) ToListQuery() (string, error)

type ListOptsBuilder

type ListOptsBuilder interface {
	ToListQuery() (string, error)
}

type ListZoneResponse

type ListZoneResponse struct {
	// Link of the current resource or other related resources.When a
	// response is broken into pages, a next link is provided to retrieve all results.
	Links Link `json:"links"`
	// Zone list object
	Zones []Zone `json:"zones"`

	// Number of resources that meet the filter condition
	Metadata Metadata `json:"metadata"`
}

func ExtractZones

func ExtractZones(r pagination.Page) (*ListZoneResponse, error)

type Metadata

type Metadata struct {
	// Total number of resources
	TotalCount int `json:"total_count"`
}

type NameServer

type NameServer struct {
	// IP address of a name server
	Address string `json:"address"`

	// Priority of a name server.For example, if the priority of a
	// name server is 1, it is used to resolve domain names in first priority.
	Priority int `json:"priority"`
}

type Router

type Router struct {
	// Router ID (VPC ID)
	RouterId string `json:"router_id" required:"true"`

	// Region of the router (VPC).If it is left blank, the region of
	// the project in the token takes effect by default.
	RouterRegion string `json:"router_region,omitempty"`
}

Router, Router (VPC) information associated with the private zone.

type RouterCreateOpts

type RouterCreateOpts struct {
	// Router ID (VPC ID)
	RouterId string `json:"router_id" required:"true"`

	// Region of the router (VPC).If it is left blank, the region of
	// the project in the token takes effect by default.
	RouterRegion string `json:"router_region,omitempty"`
}

RouterCreateOpts,the parameters of the zone create, Router (VPC) information associated with the private zone.

type UpdateOpts

type UpdateOpts struct {
	// Mail address of the administrator managing the zone
	Email string `json:"email,omitempty"`

	// Caching period of the SOA record set (in seconds).The default
	// value is 300s.The value range is 300–2147483647.
	TTL int `json:"ttl,omitempty"`

	// Description of the domain name, which cannot exceed 255
	// characters
	Description string `json:"description,omitempty"`
}

func (UpdateOpts) ToZonesUpdateMap

func (opts UpdateOpts) ToZonesUpdateMap() (map[string]interface{}, error)

type UpdateOptsBuilder

type UpdateOptsBuilder interface {
	ToZonesUpdateMap() (map[string]interface{}, error)
}

type UpdateResult

type UpdateResult struct {
	// contains filtered or unexported fields
}

UpdateResult is the result of an Update request. Call its Extract method to interpret the result as a Zone.

func Update

func Update(client *gophercloud.ServiceClient, opts UpdateOptsBuilder, ZoneID string) (r UpdateResult)

func (UpdateResult) Extract

func (r UpdateResult) Extract() (*Zone, error)

type Zone

type Zone struct {
	// Zone ID, which is a UUID used to identify the zone
	ID string `json:"id"`

	// Zone name
	Name string `json:"name"`

	// Zone description
	Description string `json:"description"`

	// Mail address of the administrator managing the zone
	Email string `json:"email"`

	// Zone type, which can be  or
	ZoneType string `json:"zone_type"`

	// TTL value of the SOA record set in the zone
	TTL int `json:"ttl"`

	// Serial number in the SOA record set in the zone, which
	// identifies the change on the primary DNS server
	Serial int `json:"serial"`

	// Resource status.The value can be PENDING_CREATE, ACTIVE,
	// PENDING_DELETE, or ERROR.
	Status string `json:"status"`

	// Number of record sets in the zone
	RecordNum int `json:"record_num"`

	// Pool ID of the zone, which is assigned by the system
	PoolId string `json:"pool_id"`

	// Project ID of the zone
	ProjectId string `json:"project_id"`

	// Time when the zone was created
	CreatedAt string `json:"created_at"`

	// Time when the zone was updated
	UpdatedAt string `json:"updated_at"`

	// Link of the current resource or other related resources.When a
	// response is broken into pages, a next link is provided to retrieve all results.
	Links Link `json:"links"`

	// Master DNS servers, from which the slave servers get DNS
	// information
	Masters []string `json:"masters"`

	// Routers (VPCs associated with the zone)
	Routers []AssociateRouterResponse `json:"routers"`
}

type ZoneCreateResponse

type ZoneCreateResponse struct {
	// Zone ID, which is a UUID used to identify the zone
	ID string `json:"id"`

	// Zone name
	Name string `json:"name"`

	// Zone description
	Description string `json:"description"`

	// Mail address of the administrator managing the zone
	Email string `json:"email"`

	// Zone type, which can be  or
	ZoneType string `json:"zone_type"`

	// TTL value of the SOA record set in the zone
	TTL int `json:"ttl"`

	// Serial number in the SOA record set in the zone, which
	// identifies the change on the primary DNS server
	Serial int `json:"serial"`

	// Resource status.The value can be PENDING_CREATE, ACTIVE,
	// PENDING_DELETE, or ERROR.
	Status string `json:"status"`

	// Number of record sets in the zone
	RecordNum int `json:"record_num"`

	// Pool ID of the zone, which is assigned by the system
	PoolId string `json:"pool_id"`

	// Project ID of the zone
	ProjectId string `json:"project_id"`

	// Time when the zone was created
	CreatedAt string `json:"created_at"`

	// Time when the zone was updated
	UpdatedAt string `json:"updated_at"`

	// Link of the current resource or other related resources.When a
	// response is broken into pages, a next link is provided to retrieve all results.
	Links Link `json:"links"`

	// Master DNS servers, from which the slave servers get DNS
	// information
	Masters []string `json:"masters"`

	// Routers (VPCs associated with the zone)
	Router AssociateRouterResponse `json:"router"`
}

ZoneCreateResponse,The response of the zone creation.

type ZonePage

type ZonePage struct {
	pagination.LinkedPageBase
}

func (ZonePage) IsEmpty

func (r ZonePage) IsEmpty() (bool, error)

Directories

Path Synopsis
zones unit tests package testing import ( "fmt" "net/http" "testing" "time" "github.com/dynuc/gophercloud" "github.com/dynuc/gophercloud/openstack/dns/v2/zones" th "github.com/dynuc/gophercloud/testhelper" "github.com/dynuc/gophercloud/testhelper/client" ) // List Output is a sample response to a List call.
zones unit tests package testing import ( "fmt" "net/http" "testing" "time" "github.com/dynuc/gophercloud" "github.com/dynuc/gophercloud/openstack/dns/v2/zones" th "github.com/dynuc/gophercloud/testhelper" "github.com/dynuc/gophercloud/testhelper/client" ) // List Output is a sample response to a List call.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL