zones

package
v0.5.21 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2022 License: Apache-2.0 Imports: 5 Imported by: 3

Documentation

Overview

Package zones provides information and interaction with the zone API resource for the OpenStack 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

func List(client *golangsdk.ServiceClient, opts ListOptsBuilder) pagination.Pager

List implements a zone List request.

Types

type AssociateResult

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

AssociateResult is the response from AssociateZone

func AssociateZone

func AssociateZone(client *golangsdk.ServiceClient, zoneID string, opts RouterOptsBuilder) (r AssociateResult)

AssociateZone associate a Router with a Zone.

func (AssociateResult) Extract

func (r AssociateResult) 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 CreateOpts

type CreateOpts struct {
	// Email contact of the zone.
	Email string `json:"email,omitempty"`

	// Description of the zone.
	Description string `json:"description,omitempty"`

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

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

	ZoneType string `json:"zone_type,omitempty"`

	Router *RouterOpts `json:"router,omitempty"`

	Tags []tags.ResourceTag `json:"tags,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 *golangsdk.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 *golangsdk.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 DisassociateResult

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

DisassociateResult is the response from DisassociateZone

func DisassociateZone

func DisassociateZone(client *golangsdk.ServiceClient, zoneID string, opts RouterOptsBuilder) (r DisassociateResult)

DisassociateZone disassociate a Router with a Zone.

func (DisassociateResult) Extract

func (r DisassociateResult) 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 *golangsdk.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 {
	// Integer value for the limit of values to return.
	Limit int `q:"limit"`

	// UUID of the zone at which you want to set a marker.
	Marker string `q:"marker"`

	Description string `q:"description"`
	Email       string `q:"email"`
	Name        string `q:"name"`
	SortDir     string `q:"sort_dir"`
	SortKey     string `q:"sort_key"`
	Status      string `q:"status"`
	TTL         int    `q:"ttl"`
	Type        string `q:"type"`
	QueryTags   string `q:"tags"`

	Tags []tags.ResourceTag
}

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. https://developer.openstack.org/api-ref/dns/

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 RouterOpts

type RouterOpts struct {
	// Router ID
	RouterID string `json:"router_id" required:"true"`

	// Router Region
	RouterRegion string `json:"router_region,omitempty"`
}

RouterOpts specifies the required information to associate/disassociate a Router with a Zone.

func (RouterOpts) ToRouterMap

func (opts RouterOpts) ToRouterMap() (map[string]interface{}, error)

ToRouterMap constructs a request body from RouterOpts.

type RouterOptsBuilder

type RouterOptsBuilder interface {
	ToRouterMap() (map[string]interface{}, error)
}

RouterOptsBuilder allows adding parameters to the associate/disassociate Zone request.

type RouterResult

type RouterResult struct {
	RouterID     string `json:"router_id"`
	RouterRegion string `json:"router_region"`
	Status       string `json:"status"`
}

type UpdateOpts

type UpdateOpts struct {
	// Email contact of the zone.
	Email string `json:"email,omitempty"`

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

	// Description of the zone.
	Description string `json:"description,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 *golangsdk.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"`

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

	// 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:"serial"`

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

	ZoneType string `json:"zone_type"`

	RecordNum int `json:"record_num"`

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

	// CreatedAt is the date when the zone was created.
	CreatedAt string `json:"created_at"`

	// UpdatedAt is the date when the last change was made to the zone.
	UpdatedAt string `json:"updated_at"`

	// 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"`

	// Routers associate with the Zone
	Routers []RouterResult `json:"routers"`
}

Zone represents a DNS zone.

func ExtractZones

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

ExtractZones extracts a slice of Zones from a List result.

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