|
1 | | -**DEVELOPER INSTRUCTIONS:** |
| 1 | +# Yandex Cloud DNS for [`libdns`](https://github.com/libdns/libdns) |
2 | 2 |
|
3 | | -This repo is a template for developers to use when creating new [libdns](https://github.com/libdns/libdns) provider implementations. |
| 3 | +This package implements the [libdns interfaces](https://github.com/libdns/libdns) for [Yandex Cloud API](https://yandex.cloud/en/docs/dns/api-ref/) allowing you to manage DNS records. |
4 | 4 |
|
5 | | -Be sure to update: |
6 | 5 |
|
7 | | -- The package name |
8 | | -- The Go module name in go.mod |
9 | | -- The latest `libdns/libdns` version in go.mod |
10 | | -- All comments and documentation, including README below and godocs |
11 | | -- License (must be compatible with Apache/MIT) |
12 | | -- All "TODO:"s is in the code |
13 | | -- All methods that currently do nothing |
| 6 | +## Authenticate |
14 | 7 |
|
15 | | -Remove this section from the readme before publishing. |
| 8 | +To authenticate API you need to supply a Yandex Cloud IAM token. It will automatically ensure from Service Account authorization keys. |
16 | 9 |
|
17 | | ---- |
| 10 | +More info: <https://yandex.cloud/en/docs/dns/api-ref/authentication> |
18 | 11 |
|
19 | | -\<PROVIDER NAME\> for [`libdns`](https://github.com/libdns/libdns) |
20 | | -======================= |
21 | 12 |
|
22 | | -[](https://pkg.go.dev/github.com/libdns/TODO:PROVIDER_NAME) |
| 13 | +## Usage |
23 | 14 |
|
24 | | -This package implements the [libdns interfaces](https://github.com/libdns/libdns) for \<PROVIDER\>, allowing you to manage DNS records. |
| 15 | +```go |
| 16 | +package main |
25 | 17 |
|
26 | | -TODO: Show how to configure and use. Explain any caveats. |
| 18 | +import ( |
| 19 | + "context" |
| 20 | + "fmt" |
| 21 | + "os" |
| 22 | + "time" |
| 23 | + |
| 24 | + yandex_cloud "github.com/profcomff/libdns-yandex-cloud" |
| 25 | +) |
| 26 | + |
| 27 | +func main() { |
| 28 | + p := &yandex_cloud.Provider{ServiceAccountConfigPath: "./authorized_keys.json"} |
| 29 | + // File structure |
| 30 | + // { |
| 31 | + // "id": "...", |
| 32 | + // "service_account_id": "...", |
| 33 | + // "created_at": "2024-08-04T14:00:38.626813184Z", |
| 34 | + // "key_algorithm": "RSA_2048", |
| 35 | + // "public_key": "-----BEGIN PUBLIC KEY-----\n ... \n-----END PUBLIC KEY-----\n", |
| 36 | + // "private_key": "PLEASE DO NOT REMOVE THIS LINE! Yandex.Cloud SA Key ID <...>\n-----BEGIN PRIVATE KEY-----\n ... \n-----END PRIVATE KEY-----\n", |
| 37 | + // "dns_zone_id": "..." |
| 38 | + // } |
| 39 | + |
| 40 | + |
| 41 | + records, err := p.GetRecords(context.WithTimeout(context.Background(), time.Duration(15*time.Second)), "") |
| 42 | + if err != nil { |
| 43 | + fmt.Printf("Error: %s", err.Error()) |
| 44 | + return |
| 45 | + } |
| 46 | + |
| 47 | + fmt.Println(records) |
| 48 | +} |
| 49 | +``` |
0 commit comments