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 ¶
- func List(client *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager
- func ListShares(client *gophercloud.ServiceClient, zoneID string, opts ListSharesOptsBuilder) pagination.Pager
- func Unshare(ctx context.Context, client *gophercloud.ServiceClient, zoneID, shareID string) (r gophercloud.ErrResult)
- type CreateOpts
- type CreateOptsBuilder
- type CreateResult
- type DeleteResult
- type ErrResult
- type GetResult
- type ListOpts
- type ListOptsBuilder
- type ListSharesOpts
- type ListSharesOptsBuilder
- type ShareOptsBuilder
- type ShareZoneOpts
- type UpdateOpts
- type UpdateOptsBuilder
- type UpdateResult
- type Zone
- type ZonePage
- type ZoneShare
- type ZoneSharePage
- type ZoneShareResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func List ¶
func List(client *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager
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 ¶
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(ctx context.Context, client *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult)
Create implements a zone create request.
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.
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.
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 ¶
ToZoneListQuery formats a ListOpts into a query string.
type ListOptsBuilder ¶
ListOptsBuilder allows extensions to add parameters to the List request.
type ListSharesOpts ¶ added in v2.8.0
type ListSharesOpts struct {
}
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 {
}
ListSharesOptsBuilder allows extensions to add additional parameters to the List request.
type ShareOptsBuilder ¶ added in v2.5.0
type ShareOptsBuilder interface {
}
request body for sharing a zone.
type ShareZoneOpts ¶ added in v2.5.0
type ShareZoneOpts struct {
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 ¶
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.
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 ¶
type ZonePage ¶
type ZonePage struct {
pagination.LinkedPageBase
}
ZonePage is a single page of Zone results.
type ZoneShare ¶ added in v2.8.0
type ZoneShare struct {
ID string `json:"id"`
ZoneID string `json:"zone_id"`
ProjectID string `json:"project_id"`
TargetProjectID string `json:"target_project_id"`
CreatedAt time.Time `json:"-"`
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
type ZoneSharePage ¶ added in v2.8.0
type ZoneSharePage struct {
}
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 {
}
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.