Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expand Documentation #3

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 25 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@

[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/ppmathis/cloudns-go/LICENSE.txt)
[![Documentation](http://img.shields.io/badge/docs-godoc.org-blue.svg)](https://godoc.org/github.com/ppmathis/cloudns-go)
[![Go Compatibility](https://img.shields.io/badge/golang-1.16+-brightgreen.svg)](#)
[![Go Compatibility](https://img.shields.io/badge/golang-1.16+-brightgreen.svg)](https://go.dev/dl/)
[![GitHub issues](https://img.shields.io/github/issues/ppmathis/cloudns-go.svg)](https://github.com/ppmathis/cloudns-go/issues)
[![Code Coverage](https://codecov.io/gh/ppmathis/cloudns-go/branch/main/graph/badge.svg?token=DMZR0O1H69)](https://codecov.io/gh/ppmathis/cloudns-go)
[![Copyright](https://img.shields.io/badge/copyright-Pascal_Mathis-lightgrey.svg)](#)
[![Copyright](https://img.shields.io/badge/copyright-Pascal_Mathis-lightgrey.svg)](LICENSE.txt)

## Summary

This is an unofficial library for the ClouDNS HTTP API written in Go. Currently all operations related to account,
zone and record management have been fully implemented. Further information about the API can be found at the
[official ClouDNS website](https://www.cloudns.net/).

## Quick Start

Initialize cloudns-go by creating a new API client instance with your preferred choice of credentials, which is a
combination of the API user password and an user ID, sub-user ID or sub-user name:

Expand All @@ -37,31 +39,37 @@ which currently consists of:
You can find more information about the specific methods and structures of cloudns-go by visiting the
[official documentation on godoc.org](https://godoc.org/github.com/ppmathis/cloudns-go).


## Example

```go
package main

import (
"context"
"fmt"
"github.com/ppmathis/cloudns-go"
"context"
"fmt"
"github.com/ppmathis/cloudns-go"
)

func main() {
client, _ := cloudns.New(
cloudns.AuthUserID(42, "cloudns-rocks"),
)
client, _ := cloudns.New(
cloudns.AuthUserID(42, "cloudns-rocks"),
)

zone, _ := client.Zones.Get(context.TODO(), "api-example.com")
result1, _ := client.Zones.SetActive(context.TODO(), zone.Name, true)
zone, _ := client.Zones.Get(context.TODO(), "api-example.com")
result1, _ := client.Zones.SetActive(context.TODO(), zone.Name, true)

record := cloudns.NewRecord(cloudns.RecordTypeA, "localhost", "1.2.3.4", 3600)
result2, _ := client.Records.Create(context.TODO(), zone.Name, record)
record := cloudns.NewRecord(cloudns.RecordTypeA, "localhost", "1.2.3.4", 3600)
result2, _ := client.Records.Create(context.TODO(), zone.Name, record)

fmt.Printf("Zone: %+v\n", zone)
fmt.Printf("Record: %+v\n", record)
fmt.Printf("Result of `Zones.SetActive()`: %+v\n", result1)
fmt.Printf("Result of `Records.Create()`: %+v\n", result2)
fmt.Printf("Zone: %+v\n", zone)
fmt.Printf("Record: %+v\n", record)
fmt.Printf("Result of `Zones.SetActive()`: %+v\n", result1)
fmt.Printf("Result of `Records.Create()`: %+v\n", result2)
}
```

## Tutorials

Visit the [tutorials section of the
repository](./tutorials/) for in depth
explanations on select elements of cloudns-go.
14 changes: 14 additions & 0 deletions tutorials/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Tutorials

A selection of features from cloudns-go are explained in the following
tutorials, organized by topic:

## [Authentication](./authentication)

+ [Authentication with User ID](./authentication/user-id.md)
+ [Authentication with Sub-User ID](./authentication/sub-user-id.md)
+ [Authentication with Sub-User Name](./authentication/sub-user-name.md)

## Zones

## Records
8 changes: 8 additions & 0 deletions tutorials/authentication/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Authentication Tutorials

A selection of features relating to authentication are explained in the
following tutorials:

+ [Authentication with User ID](./user-id.md)
+ [Authentication with Sub-User ID](./sub-user-id.md)
+ [Authentication with Sub-User Name](./sub-user-name.md)
20 changes: 20 additions & 0 deletions tutorials/authentication/sub-user-id.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Sub User ID Authentication

To create a new cloudns-go client with sub user ID authentication, you must
first collect the sub user ID and password from the ClouDNS control panel.

We will then pass the result of the `cloudns.AuthSubUserID()` function to the
`cloudns.New()` function.

```go
client, err := cloudns.New(
cloudns.AuthSubUserID(12345, "JohnsPassword"),
)

if error != nil {
fmt.Println("Error creating client:", err)
}
```

An if-statement similar to the one above can be used to check if a client was
successfully created.
20 changes: 20 additions & 0 deletions tutorials/authentication/sub-user-name.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Sub-User Name Authentication

To create a new cloudns-go client with sub-user name authentication, you must
first collect the sub-user name and password from the ClouDNS control panel.

We will then pass the result of the `cloudns.AuthSubUserName()` function to the
`cloudns.New()` function.

```go
client, err := cloudns.New(
cloudns.AuthSubUserName("john_doe", "JohnsPassword"),
)

if error != nil {
fmt.Println("Error creating client:", err)
}
```

An if-statement similar to the one above can be used to check if a client was
successfully created.
20 changes: 20 additions & 0 deletions tutorials/authentication/user-id.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# User ID Authentication

To create a new cloudns-go client with user ID authentication, you must
first collect the user ID and password from the ClouDNS control panel.

We will then pass the result of the `cloudns.AuthUserID()` function to the
`cloudns.New()` function.

```go
client, err := cloudns.New(
cloudns.AuthUserID(12345, "JohnsPassword"),
)

if error != nil {
fmt.Println("Error creating client:", err)
}
```

An if-statement similar to the one above can be used to check if a client was
successfully created.