{"id":23564176,"url":"https://github.com/selectel/domains-go","last_synced_at":"2025-04-30T16:17:38.846Z","repository":{"id":56361317,"uuid":"260468198","full_name":"selectel/domains-go","owner":"selectel","description":"Go SDK for Selectel Domains API","archived":false,"fork":false,"pushed_at":"2024-06-06T10:28:13.000Z","size":83,"stargazers_count":7,"open_issues_count":1,"forks_count":5,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-30T16:17:32.083Z","etag":null,"topics":["dns","go","go-sdk","selectel-dns"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/selectel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-05-01T13:40:25.000Z","updated_at":"2024-07-21T11:30:47.000Z","dependencies_parsed_at":"2024-04-23T15:28:24.883Z","dependency_job_id":"49ee6a86-77a6-4504-a138-fc495bb3619a","html_url":"https://github.com/selectel/domains-go","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/selectel%2Fdomains-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/selectel%2Fdomains-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/selectel%2Fdomains-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/selectel%2Fdomains-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/selectel","download_url":"https://codeload.github.com/selectel/domains-go/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251739677,"owners_count":21635893,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dns","go","go-sdk","selectel-dns"],"created_at":"2024-12-26T17:13:13.489Z","updated_at":"2025-04-30T16:17:38.817Z","avatar_url":"https://github.com/selectel.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# domains-go: Go SDK for Selectel Domains API\n[![Go.dev reference](https://img.shields.io/badge/go.dev-reference-007d9c?logo=go\u0026logoColor=white\u0026style=flat-square)](https://pkg.go.dev/github.com/selectel/domains-go/)\n[![Go Report Card](https://goreportcard.com/badge/github.com/selectel/domains-go)](https://goreportcard.com/report/github.com/selectel/domains-go)\n[![Build Status](https://travis-ci.com/selectel/domains-go.svg?branch=master)](https://travis-ci.com/selectel/domains-go)\n[![Coverage Status](https://coveralls.io/repos/github/selectel/domains-go/badge.svg?branch=master)](https://coveralls.io/github/selectel/domains-go?branch=master)\n\nPackage domains-go provides Go SDK to work with the Selectel Domains API.\n\n## Contents\n\n* [Documentation](#documentation)\n* [Installation](#installation)\n* [Authentication](#authentication)\n* [Usage example](#usage-example)\n* [Current version vs Legacy version](#current-version-vs-legacy-version)\n* [Usage legacy example](#usage-legacy-example)\n\n## Documentation\n\nThe Go library documentation is available at [go.dev](https://pkg.go.dev/github.com/selectel/domains-go/).\n\n## What this library is capable of\n\nYou can use this library to work with the following objects of the Selectel Domains API:\n\n* [zone](https://pkg.go.dev/github.com/selectel/domains-go/pkg/v2/#Zone)\n* [rrset](https://pkg.go.dev/github.com/selectel/domains-go/pkg/v2/#RRSet)\n\n## Getting started\n\n### Installation\n\nYou can install needed `domains-go` packages via `go get` command:\n\n```bash\ngo get github.com/selectel/domains-go\n```\n\n### Authentication\n\nTo work with the Selectel Domains API you first need to:\n\n* Create a Selectel account: [registration page](https://my.selectel.ru/registration).\n* For **current** version create an [Keystone Project Token](https://developers.selectel.com/docs/control-panel/authorization/#project-token)\n* For **legacy** version create an [Selectel Token](https://developers.selectel.com/docs/control-panel/authorization/#selectel-token-api-key)\n\n❗️IMPORTANT❗️  \n`Selectel Token` and `Keystone Project Token` are **different** tokens!  \nAbove we mentioned how to get keystone project token, how to obtain selectel token read [here](https://developers.selectel.com/docs/control-panel/authorization)\n\n### Usage example\n\n```go\npackage main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"log\"\n\t\"net/http\"\n\n\tv2 \"github.com/selectel/domains-go/pkg/v2\"\n)\n\nfunc main() {\n\t// Keystone project token. Read more in authorization.\n\ttoken := \"gAAAAABeVNzu-...\"\n\n\t// Domains API V2 endpoint to work with\n\tendpoint := \"https://api.selectel.ru/domains/v2\"\n\n\thttpClient := \u0026http.Client{}\n\tuserAgent := \"domains-go-v2\"\n\thdrs := http.Header{}\n\thdrs.Add(\"X-Auth-Token\", token)\n\thdrs.Add(\"User-Agent\", userAgent)\n\t// Initialize the Domains API V2 client\n\tclient := v2.NewClient(endpoint, httpClient, hdrs)\n\n\tcreateZoneOpts := \u0026v2.Zone{\n\t\tName: \"domains-go-v2.ru.\",\n\t}\n\n\t// Create zone\n\tselectelCreatedZone, err := client.CreateZone(context.Background(), createZoneOpts)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tfmt.Printf(\"Created zone: %+v\\n\", selectelCreatedZone)\n\n\tlistZonesOpts := \u0026map[string]string{}\n\t// List zones\n\tselectelZones, err := client.ListZones(context.Background(), listZonesOpts)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tfor _, zone := range selectelZones.GetItems() {\n\t\tfmt.Printf(\"%+v\\n\", zone)\n\t}\n\n\tcreateRrsetOpts := \u0026v2.RRSet{\n\t\tName: \"txt.domains-go-v2.ru.\",\n\t\tType: v2.TXT,\n\t\tTTL:  60,\n\t\tRecords: []v2.RecordItem{\n\t\t\t// Only for TXT Rrset escaping quotes\n\t\t\t{Content: \"\\\"Hello world!\\\"\"},\n\t\t},\n\t}\n\n\t// Create rrset type TXT\n\tselectelCreatedRrset, err := client.CreateRRSet(context.Background(), selectelCreatedZone.ID, createRrsetOpts)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tfmt.Printf(\"Created rrset: %+v\\n\", selectelCreatedRrset)\n}\n```\n\n## Current version vs Legacy version\n\nCurrent version is `github.com/selectel/domains-go/pkg/v2`  \nLegacy version is `github.com/selectel/domains-go/pkg/v1`  \n\nThey are not compatible. They utilize different API and created zones live on different authoritative servers.\nZone created in v2 API with current version is entirely new zone, and not available via v1 api and vice versa.  \n\nIf you are going to create new zone, we strongly recommend to use `github.com/selectel/domains-go/pkg/v2`.  \nIf you have zones in v1, you still can manage them with `github.com/selectel/domains-go/pkg/v1`.\n\nLegacy version following objects of the Selectel Domains API v1:\n\n* [domain](https://pkg.go.dev/github.com/selectel/domains-go/pkg/v1/domain)\n* [record](https://pkg.go.dev/github.com/selectel/domains-go/pkg/v1/record)\n\nCurrent version following objects of the Selectel Domains API v2:\n\n* [zone](https://pkg.go.dev/github.com/selectel/domains-go/pkg/v2/#Zone)\n* [rrset](https://pkg.go.dev/github.com/selectel/domains-go/pkg/v2/#RRSet)\n\n### Usage legacy example\n\n❗️IMPORTANT❗️\nWe are not recommending using this example.\n\n```go\npackage main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"log\"\n\n\tv1 \"github.com/selectel/domains-go/pkg/v1\"\n\t\"github.com/selectel/domains-go/pkg/v1/domain\"\n\t\"github.com/selectel/domains-go/pkg/v1/record\"\n)\n\nfunc main() {\n\t// Token to work with Selectel Cloud project\n\ttoken := \"gAAAAABeVNzu-...\"\n\n\t// Domains API V1 endpoint to work with\n\tendpoint := \"https://api.selectel.ru/domains/v1\"\n\n\t// Initialize the Domains API V1 client\n\tclient := v1.NewDomainsClientV1(token, endpoint)\n\n\tcreateDomainOpts := \u0026domain.CreateOpts{\n\t\tName: \"testdomain.xyz\",\n\t}\n\n\t// Create domain\n\tselectelDomain, _, err := domain.Create(context.Background(), client, createDomainOpts)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tfmt.Printf(\"Created domain: %+v\\n\", selectelDomain)\n\n\t// List domains\n\tselectelDomains, _, err := domain.List(context.Background(), client)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tfor _, d := range selectelDomains {\n\t\tfmt.Printf(\"%+v\\n\", d)\n\t}\n\n\tcreateRecordOpts := \u0026record.CreateOpts{\n\t\tName:    \"share.testdomain.xyz\",\n\t\tType:    record.TypeCNAME,\n\t\tTTL:     60,\n\t\tContent: \"origin.example.com\",\n\t}\n\n\t// Create domain record\n\tdomainRecord, _, err := record.Create(context.Background(), client, selectelDomain.ID, createRecordOpts)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tfmt.Printf(\"Created record: %+v\\n\", domainRecord)\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fselectel%2Fdomains-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fselectel%2Fdomains-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fselectel%2Fdomains-go/lists"}