zones

package
v2.12.0 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2026 License: Apache-2.0 Imports: 6 Imported by: 13

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(context.TODO())
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(context.TODO(), dnsClient, createOpts).Extract()
if err != nil {
	panic(err)
}

Example to Delete a Zone

zoneID := "99d10f68-5623-4491-91a0-6daafa32b60e"
err := zones.Delete(context.TODO(), 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.

func ListShares added in v2.8.0

func ListShares(client *gophercloud.ServiceClient, zoneID string, opts ListSharesOptsBuilder) pagination.Pager

ListShares implements a zone list shares request.

func Unshare added in v2.5.0

func Unshare(ctx context.Context, client *gophercloud.ServiceClient, zoneID, shareID string) (r gophercloud.ErrResult)

Unshare removes a share for a zone.

Types

type CreateOpts

type CreateOpts struct {
	// Attributes are settings that supply hints and filters for the zone.
	Attributes map[string]string `json:"attributes,omitempty"`

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

	// 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]any, error)

ToZoneCreateMap formats an CreateOpts structure into a request body.

type CreateOptsBuilder

type CreateOptsBuilder interface {
	ToZoneCreateMap() (map[string]any, 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

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(ctx context.Context, client *gophercloud.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 ErrResult added in v2.5.0

type ErrResult struct {
	gophercloud.ErrResult
}

ErrResult represents a generic error result.

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(ctx context.Context, client *gophercloud.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"`
}

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 ListSharesOpts added in v2.8.0

type ListSharesOpts struct {
	AllProjects bool `h:"X-Auth-All-Projects"`
}

ListSharesOpts is a structure that holds parameters for listing zone shares.

func (ListSharesOpts) ToZoneListSharesHeadersMap added in v2.8.0

func (opts ListSharesOpts) ToZoneListSharesHeadersMap() (map[string]string, error)

ToZoneListSharesHeadersMap formats a ListSharesOpts into header parameters.

type ListSharesOptsBuilder added in v2.8.0

type ListSharesOptsBuilder interface {
	ToZoneListSharesHeadersMap() (map[string]string, error)
}

ListSharesOptsBuilder allows extensions to add additional parameters to the List request.

type ShareOptsBuilder added in v2.5.0

type ShareOptsBuilder interface {
	ToShareMap() (map[string]interface{}, error)
}

request body for sharing a zone.

type ShareZoneOpts added in v2.5.0

type ShareZoneOpts struct {
	// TargetProjectID is the ID of the project to share the zone with.
	TargetProjectID string `json:"target_project_id" required:"true"`
}

ShareZoneOpts specifies the target project for sharing a zone.

func (ShareZoneOpts) ToShareMap added in v2.5.0

func (opts ShareZoneOpts) ToShareMap() (map[string]interface{}, error)

ToShareMap constructs a request body from a ShareZoneOpts.

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

	// Masters specifies zone masters if this is a secondary zone.
	Masters []string `json:"masters,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]any, error)

ToZoneUpdateMap formats an UpdateOpts structure into a request body.

type UpdateOptsBuilder

type UpdateOptsBuilder interface {
	ToZoneUpdateMap() (map[string]any, 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(ctx context.Context, client *gophercloud.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:"-"`

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

	// Action is the current action in progress on the resource.
	Action string `json:"action"`

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

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

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

	// 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 time.Time `json:"-"`

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

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

	// Links includes HTTP references to the itself, useful for passing along
	// to other APIs that might want a server reference.
	Links map[string]any `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.

type ZoneShare added in v2.8.0

type ZoneShare struct {
	// ID uniquely identifies this zone share.
	ID string `json:"id"`

	// ZoneID is the ID of the zone being shared.
	ZoneID string `json:"zone_id"`

	// ProjectID is the ID of the project with which the zone is shared.
	ProjectID string `json:"project_id"`

	// TargetProjectID is the ID of the project with which the zone is shared.
	TargetProjectID string `json:"target_project_id"`

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

	// UpdatedAt is the date when the zone share was last updated.
	UpdatedAt time.Time `json:"-"`
}

ZoneShare represents a shared zone.

func ExtractZoneShares added in v2.8.0

func ExtractZoneShares(r pagination.Page) ([]ZoneShare, error)

ExtractZoneShares extracts a slice of ZoneShares from a List result.

func (*ZoneShare) UnmarshalJSON added in v2.8.0

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

type ZoneSharePage added in v2.8.0

type ZoneSharePage struct {
	pagination.LinkedPageBase
}

ZoneSharePage is a single page of ZoneShare results.

func (ZoneSharePage) IsEmpty added in v2.8.0

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

IsEmpty returns true if the page contains no results.

type ZoneShareResult added in v2.8.0

type ZoneShareResult struct {
	gophercloud.Result
}

ZoneShareResult is the result of a GetZoneShare request.

func GetShare added in v2.8.0

func GetShare(ctx context.Context, client *gophercloud.ServiceClient, zoneID, shareID string) (r ZoneShareResult)

GetShare returns information about a shared zone, given its ID.

func Share added in v2.5.0

func Share(ctx context.Context, client *gophercloud.ServiceClient, zoneID string, opts ShareOptsBuilder) (r ZoneShareResult)

Share shares a zone with another project.

func (ZoneShareResult) Extract added in v2.8.0

func (r ZoneShareResult) Extract() (*ZoneShare, error)

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

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