recordsets

package
v2.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

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

Example to List RecordSets by Zone

listOpts := recordsets.ListOpts{
	Type: "A",
}

zoneID := "fff121f5-c506-410a-a69e-2d73ef9cbdbd"

allPages, err := recordsets.ListByZone(dnsClient, zoneID, listOpts).AllPages()
if err != nil {
	panic(err)
}

allRRs, err := recordsets.ExtractRecordSets(allPages()
if err != nil {
	panic(err)
}

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

Example to Create a RecordSet

createOpts := recordsets.CreateOpts{
	Name:        "example.com.",
	Type:        "A",
	TTL:         3600,
	Description: "This is a recordset.",
	Records:     []string{"10.1.0.2"},
}

zoneID := "fff121f5-c506-410a-a69e-2d73ef9cbdbd"

rr, err := recordsets.Create(dnsClient, zoneID, createOpts).Extract()
if err != nil {
	panic(err)
}

Example to Delete a RecordSet

zoneID := "fff121f5-c506-410a-a69e-2d73ef9cbdbd"
recordsetID := "d96ed01a-b439-4eb8-9b90-7a9f71017f7b"

err := recordsets.Delete(dnsClient, zoneID, recordsetID).ExtractErr()
if err != nil {
	panic(err)
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListByZone

func ListByZone(client *eclcloud.ServiceClient, zoneID string, opts ListOptsBuilder) pagination.Pager

ListByZone implements the recordset list request.

Types

type CreateOpts

type CreateOpts struct {
	// Name is the name of the RecordSet.
	Name string `json:"name" required:"true"`

	// Description is a description of the RecordSet.
	Description string `json:"description,omitempty"`

	// Records are the DNS records of the RecordSet.
	Records []string `json:"records,omitempty"`

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

	// Type is the record type of the RecordSet.
	Type string `json:"type" required:"true"`
}

CreateOpts specifies the base attributes that may be used to create a RecordSet.

func (CreateOpts) ToRecordSetCreateMap

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

ToRecordSetCreateMap formats an CreateOpts structure into a request body.

type CreateOptsBuilder

type CreateOptsBuilder interface {
	ToRecordSetCreateMap() (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 operation. Call its Extract method to interpret the result as a RecordSet.

func Create

func Create(client *eclcloud.ServiceClient, zoneID string, opts CreateOptsBuilder) (r CreateResult)

Create creates a recordset in a given zone.

func (CreateResult) Extract

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

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

func (CreateResult) ExtractCreatedRecordSet

func (r CreateResult) ExtractCreatedRecordSet() (*RecordSet, error)

type DeleteResult

type DeleteResult struct {
	eclcloud.ErrResult
}

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

func Delete

func Delete(client *eclcloud.ServiceClient, zoneID string, rrsetID string) (r DeleteResult)

Delete removes an existing RecordSet.

type GetResult

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

GetResult is the result of a Get operation. Call its Extract method to interpret the result as a RecordSet.

func Get

func Get(client *eclcloud.ServiceClient, zoneID string, rrsetID string) (r GetResult)

Get implements the recordset Get request.

func (GetResult) Extract

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

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

func (GetResult) ExtractCreatedRecordSet

func (r GetResult) ExtractCreatedRecordSet() (*RecordSet, error)

type ListOpts

type ListOpts struct {
	ZoneID string `q:"zone_id"`

	// Domain name of zone for partial-match search.
	DomainName string `q:"data"`

	SortKey string `q:"sort_key"`
	SortDir string `q:"sort_dir"`

	// UUID of the recordset 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) ToRecordSetListQuery

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

ToRecordSetListQuery formats a ListOpts into a query string.

type ListOptsBuilder

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

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

type RecordSet

type RecordSet struct {
	// ID is the unique ID of the recordset
	ID string `json:"id"`

	// ZoneID is the ID of the zone the recordset belongs to.
	ZoneID string `json:"zone_id"`

	// Name is the name of the recordset.
	Name string `json:"name"`

	// Type is the RRTYPE of the recordset.
	Type string `json:"type"`

	// Records are the DNS records of the recordset.
	// This is original code.
	// Records []string `json:"records"`
	//
	// But in ECL2.0, record set will be returned as simple string
	// e.g.
	// Usual response(like creation) reccordset: "[10.0.0.1]"
	// Update response(like creation) reccordset: "10.0.0.1]"
	Records interface{} `json:"records"`

	// TTL is the time to live of the recordset.
	TTL int `json:"ttl"`

	// Description is the description of the recordset.
	Description string `json:"description"`

	// Version is the revision of the recordset.
	Version int `json:"version"`

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

	// UpdatedAt is the date when the recordset was updated.
	UpdatedAt time.Time `json:"-"`

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

	// Current action in progress on the resource.
	// This parameter is not currently supported. it always return an empty.
	Action string `json:"action"`

	// Links includes HTTP references to the itself,
	// useful for passing along to other APIs that might want a recordset
	// reference.
	Links []eclcloud.Link `json:"-"`
}

RecordSet represents a DNS Record Set.

func ExtractRecordSets

func ExtractRecordSets(r pagination.Page) ([]RecordSet, error)

ExtractRecordSets extracts a slice of RecordSets from a List result.

func (*RecordSet) UnmarshalJSON

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

type RecordSetPage

type RecordSetPage struct {
	pagination.LinkedPageBase
}

RecordSetPage is a single page of RecordSet results.

func (RecordSetPage) IsEmpty

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

IsEmpty returns true if the page contains no results.

type UpdateOpts

type UpdateOpts struct {
	// Name is the name of the RecordSet.
	Name *string `json:"name,omitempty"`

	// Description is a description of the RecordSet.
	Description *string `json:"description,omitempty"`

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

	// Records are the DNS records of the RecordSet.
	Records *[]string `json:"records,omitempty"`
}

UpdateOpts specifies the base attributes that may be updated on an existing RecordSet.

func (UpdateOpts) ToRecordSetUpdateMap

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

ToRecordSetUpdateMap formats an UpdateOpts structure into a request body.

type UpdateOptsBuilder

type UpdateOptsBuilder interface {
	ToRecordSetUpdateMap() (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 result of an Update operation. Call its Extract method to interpret the result as a RecordSet.

func Update

func Update(client *eclcloud.ServiceClient, zoneID string, rrsetID string, opts UpdateOptsBuilder) (r UpdateResult)

Update updates a recordset in a given zone

func (UpdateResult) Extract

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

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

func (UpdateResult) ExtractCreatedRecordSet

func (r UpdateResult) ExtractCreatedRecordSet() (*RecordSet, error)

Directories

Path Synopsis
recordsets unit tests
recordsets unit tests

Jump to

Keyboard shortcuts

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