selectelv2

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2024 License: MIT Imports: 12 Imported by: 1

README

Selectel DNS v2 for libdns

Go Reference

This package implements the libdns interfaces for Selectel DNS v2 API, allowing you to manage DNS records.

Authorize

To authorize you need to use Selectel Authorization.

Example

Minimal working example of getting DNS zone records.

package main

import (
	"context"
	"fmt"
	"os"

	"github.com/libdns/libdns/selectelv2"
)

func main() {

	provider = selectelv2.Provider{
		User:        os.Getenv("SELECTEL_USER"),
		Password:    os.Getenv("SELECTEL_PASSWORD"),
		AccountId:   os.Getenv("SELECTEL_ACCOUNT_ID"),
		ProjectName: os.Getenv("SELECTEL_PROJECT_NAME"),
		ZonesCache:  make(map[string]string),
	}
	zone = os.Getenv("SELECTEL_ZONE")
	ctx = context.Background()

	records, err := provider.GetRecords(ctx, zone)
	if err != nil {
        fmt.Printf("Error: %s", err)
        return
	}

	fmt.Println(records)
}

See also: provider_test.go

Always yours @jjazzme

Documentation

Overview

Package selectelv2 implements a DNS record management client compatible with the libdns interfaces for selectel v2.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Provider

type Provider struct {
	User          string `json:"user,omitempty"`
	Password      string `json:"password,omitempty"`
	AccountId     string `json:"account_id,omitempty"`
	ProjectName   string `json:"project_name,omitempty"`
	KeystoneToken string
	ZonesCache    map[string]string
	// contains filtered or unexported fields
}

Provider facilitates DNS record manipulation with <TODO: PROVIDER NAME>.

func (*Provider) AppendRecords

func (p *Provider) AppendRecords(ctx context.Context, zone string, records []libdns.Record) ([]libdns.Record, error)

AppendRecords adds records to the zone. It returns the records that were added.

func (*Provider) DeleteRecords

func (p *Provider) DeleteRecords(ctx context.Context, zone string, records []libdns.Record) ([]libdns.Record, error)

DeleteRecords deletes the records from the zone. It returns the records that were deleted.

func (*Provider) GetRecords

func (p *Provider) GetRecords(ctx context.Context, zone string) ([]libdns.Record, error)

GetRecords lists all the records in the zone.

func (*Provider) SetRecords

func (p *Provider) SetRecords(ctx context.Context, zone string, records []libdns.Record) ([]libdns.Record, error)

SetRecords sets the records in the zone, either by updating existing records or creating new ones. It returns the updated records.

type RValue

type RValue struct {
	Value string `json:"content"`
}

type Record

type Record struct {
	ID    string   `json:"id,omitempty"`
	Type  string   `json:"type"`
	Name  string   `json:"name"`
	Value []RValue `json:"records"`
	TTL   int      `json:"ttl"`
}

type Recordset

type Recordset struct {
	Records []Record `json:"result"`
}

type Zone

type Zone struct {
	Name string `json:"name"`

	// zoneId by selectel
	ID_ string `json:"id"`
}

type Zones

type Zones struct {
	Zones []Zone `json:"result"`
}

Jump to

Keyboard shortcuts

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