domains-go

module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2022 License: Apache-2.0

README

domains-go: Go SDK for Selectel Domains API

Go.dev reference Go Report Card Build Status Coverage Status

Package domains-go provides Go SDK to work with the Selectel Domains API.

Documentation

The Go library documentation is available at go.dev.

What this library is capable of

You can use this library to work with the following objects of the Selectel Domains API:

Getting started

Installation

You can install needed domains-go packages via go get command:

go get github.com/selectel/domains-go/pkg/v1/domain github.com/selectel/domains-go/pkg/v1/record
Authentication

To work with the Selectel Domains API you first need to:

Usage example
package main

import (
	"context"
	"fmt"
	"log"

	v1 "github.com/selectel/domains-go/pkg/v1"
	"github.com/selectel/domains-go/pkg/v1/domain"
	"github.com/selectel/domains-go/pkg/v1/record"
)

func main() {
	// Token to work with Selectel Cloud project
	token := "gAAAAABeVNzu-..."

	// Domains API V1 endpoint to work with
	endpoint := "https://api.selectel.ru/domains/v1"

	// Initialize the Domains API V1 client
	client := v1.NewDomainsClientV1(token, endpoint)

	createDomainOpts := &domain.CreateOpts{
		Name: "testdomain.xyz",
	}

	// Create domain
	selectelDomain, _, err := domain.Create(context.Background(), client, createDomainOpts)
	if err != nil {
		log.Fatal(err)
	}

	fmt.Printf("Created domain: %+v\n", selectelDomain)

	// List domains
	selectelDomains, _, err := domain.List(context.Background(), client)
	if err != nil {
		log.Fatal(err)
	}

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

	createRecordOpts := &record.CreateOpts{
		Name:    "share.testdomain.xyz",
		Type:    record.TypeCNAME,
		TTL:     60,
		Content: "origin.example.com",
	}

	// Create domain record
	domainRecord, _, err := record.Create(context.Background(), client, selectelDomain.ID, createRecordOpts)
	if err != nil {
		log.Fatal(err)
	}

	fmt.Printf("Created record: %+v\n", domainRecord)
}

Directories

Path Synopsis
pkg
v1
Package v1 provides a library to work with the Selectel Domains API V1.
Package v1 provides a library to work with the Selectel Domains API V1.
v1/domain
Package domain provides the ability to interact with domains through the Selectel Domains API V1.
Package domain provides the ability to interact with domains through the Selectel Domains API V1.
v1/record
Package record provides the ability to interact with domain records through the Selectel Domains API V1.
Package record provides the ability to interact with domain records through the Selectel Domains API V1.

Jump to

Keyboard shortcuts

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