zones

package
v1.10.3 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2020 License: Apache-2.0 Imports: 5 Imported by: 2

Documentation

Overview

Package zones provides information and interaction with the zone API resource for the Enterprise Cloud DNS service.

Example to List Zones

listOpts := zones.ListOpts{
	Email: "jdoe@example.com",
}

allPages, err := zones.List(dnsClient, listOpts).AllPages()
if err != nil {
	panic(err)
}

allZones, err := zones.ExtractZones(allPages)
if err != nil {
	panic(err)
}

for _, zone := range allZones {
	fmt.Printf("%+v\n", zone)
}

Example to Create a Zone

createOpts := zones.CreateOpts{
	Name:        "example.com.",
	Email:       "jdoe@example.com",
	Type:        "PRIMARY",
	TTL:         7200,
	Description: "This is a zone.",
}

zone, err := zones.Create(dnsClient, createOpts).Extract()
if err != nil {
	panic(err)
}

Example to Delete a Zone

zoneID := "99d10f68-5623-4491-91a0-6daafa32b60e"
err := zones.Delete(dnsClient, zoneID).ExtractErr()
if err != nil {
	panic(err)
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func List

List implements a zone List request.

Types

type CreateOpts

type CreateOpts struct {
	// Description of the zone.
	Description string `json:"description,omitempty"`

	// Email contact of the zone.
	Email string `json:"email,omitempty"`

	// Name of the zone.
	Name string `json:"name" required:"true"`

	// Masters specifies zone masters if this is a secondary zone.
	Masters []string `json:"masters,omitempty"`

	// TTL is the time to live of the zone.
	TTL int `json:"-"`

	// Type specifies if this is a primary or secondary zone.
	Type string `json:"type,omitempty"`
}

CreateOpts specifies the attributes used to create a zone.

func (CreateOpts) ToZoneCreateMap

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

ToZoneCreateMap formats an CreateOpts structure into a request body.

type CreateOptsBuilder

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

CreateOptsBuilder allows extensions to add additional attributes to the Create request.

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 *eclcloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult)

Create implements a zone create request.

func (CreateResult) Extract

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

Extract interprets a GetResult, CreateResult or UpdateResult as a Zone. An error is returned if the original call or the extraction failed.

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 *eclcloud.ServiceClient, zoneID string) (r DeleteResult)

Delete implements a zone delete request.

func (DeleteResult) Extract

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

Extract interprets a GetResult, CreateResult or UpdateResult as a Zone. An error is returned if the original call or the extraction failed.

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 *eclcloud.ServiceClient, zoneID string) (r GetResult)

Get returns information about a zone, given its ID.

func (GetResult) Extract

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

Extract interprets a GetResult, CreateResult or UpdateResult as a Zone. An error is returned if the original call or the extraction failed.

type ListOpts

type ListOpts struct {
	// Domain name of zone for partial-match search.
	DomainName string `q:"domain_name"`
	// Sorts the response by the attribute value. A valid value is only domain_name.
	SortKey string `q:"sort_key"`
	// Sorts the response by the requested sort direction.
	// A valid value is asc (ascending) or desc (descending). Default is asc.
	SortDir string `q:"sort_dir"`
	// UUID of the zone at which you want to set a marker.
	Marker string `q:"marker"`
	// Integer value for the limit of values to return.
	Limit int `q:"limit"`
}

ListOpts allows the filtering and sorting of paginated collections through the API. Filtering is achieved by passing in struct field values that map to the server attributes you want to see returned. Marker and Limit are used for pagination.

func (ListOpts) ToZoneListQuery

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

ToZoneListQuery formats a ListOpts into a query string.

type ListOptsBuilder

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

ListOptsBuilder allows extensions to add parameters to the List request.

type UpdateOpts

type UpdateOpts struct {
	// Description of the zone.
	Description *string `json:"description,omitempty"`

	// TTL is the time to live of the zone.
	TTL *int `json:"ttl,omitempty"`

	// Masters specifies zone masters if this is a secondary zone.
	Masters *[]string `json:"masters,omitempty"`

	// Email contact of the zone.
	Email *string `json:"email,omitempty"`
}

UpdateOpts specifies the attributes to update a zone.

func (UpdateOpts) ToZoneUpdateMap

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

ToZoneUpdateMap formats an UpdateOpts structure into a request body.

type UpdateOptsBuilder

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

UpdateOptsBuilder allows extensions to add additional attributes to the Update request.

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 *eclcloud.ServiceClient, zoneID string, opts UpdateOptsBuilder) (r UpdateResult)

Update implements a zone update request.

func (UpdateResult) Extract

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

Extract interprets a GetResult, CreateResult or UpdateResult as a Zone. An error is returned if the original call or the extraction failed.

type Zone

type Zone struct {
	// ID uniquely identifies this zone amongst all other zones, including those
	// not accessible to the current tenant.
	ID string `json:"id"`

	// PoolID is the ID for the pool hosting this zone.
	PoolID string `json:"pool_id"`

	// ProjectID identifies the project/tenant owning this resource.
	ProjectID string `json:"project_id"`

	// Name is the DNS Name for the zone.
	Name string `json:"name"`

	// Email for the zone. Used in SOA records for the zone.
	Email string `json:"email"`

	// TTL is the Time to Live for the zone.
	TTL int `json:"ttl"`

	// Serial is the current serial number for the zone.
	Serial int `json:"-"`

	// Status is the status of the resource.
	Status string `json:"status"`

	// Description for this zone.
	Description string `json:"description"`

	// Masters is the servers for slave servers to get DNS information from.
	Masters []string `json:"masters"`

	// Type of zone. Primary is controlled by Designate.
	// Secondary zones are slaved from another DNS Server.
	// Defaults to Primary.
	Type string `json:"type"`

	// TransferredAt is the last time an update was retrieved from the
	// master servers.
	TransferredAt time.Time `json:"-"`

	// Version of the resource.
	Version int `json:"version"`

	// CreatedAt is the date when the zone was created.
	CreatedAt time.Time `json:"-"`

	// UpdatedAt is the date when the last change was made to the zone.
	UpdatedAt time.Time `json:"-"`

	// Action for the zone.
	Action string `json:"action"`

	// Attributes for the zone.
	Attributes []string `json:"attributes"`

	// Links includes HTTP references to the itself, useful for passing along
	// to other APIs that might want a server reference.
	Links map[string]interface{} `json:"links"`
}

Zone represents a DNS zone.

func ExtractZones

func ExtractZones(r pagination.Page) ([]Zone, error)

ExtractZones extracts a slice of Zones from a List result.

func (*Zone) UnmarshalJSON

func (r *Zone) UnmarshalJSON(b []byte) error

type ZonePage

type ZonePage struct {
	pagination.LinkedPageBase
}

ZonePage is a single page of Zone results.

func (ZonePage) IsEmpty

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

IsEmpty returns true if the page contains no results.

Directories

Path Synopsis
zones unit tests
zones unit tests

Jump to

Keyboard shortcuts

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