https://github.com/dstdfx/go-gcore
Unofficial Go library for accessing the G-Core CDN API
https://github.com/dstdfx/go-gcore
cdn-api gcore go http-client
Last synced: 6 months ago
JSON representation
Unofficial Go library for accessing the G-Core CDN API
- Host: GitHub
- URL: https://github.com/dstdfx/go-gcore
- Owner: dstdfx
- License: mit
- Created: 2018-04-11T14:16:25.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-07-23T08:22:54.000Z (over 6 years ago)
- Last Synced: 2024-11-13T22:35:07.190Z (12 months ago)
- Topics: cdn-api, gcore, go, http-client
- Language: Go
- Size: 911 KB
- Stars: 5
- Watchers: 2
- Forks: 2
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-golang-repositories - go-gcore - Core CDN API (Repositories)
README
# go-gcore
[](https://travis-ci.org/dstdfx/go-gcore)
[](https://goreportcard.com/report/github.com/dstdfx/go-gcore)
[](https://coveralls.io/github/dstdfx/go-gcore?branch=master)
Unofficial Go library for accessing the G-Core CDN API
It contains some parts of common and reseller G-Core CDN API.
Official docs are outdated, but anyway it's good to take a look at:
- https://docs.gcorelabs.com/cdn/
## Authentication ##
Before you start you need to have a G-Core account, you can sign in [here](https://gcorelabs.com).
To use a common G-Core API (basic account) construct a new Common client, then use the various services on the client to
access different parts of the G-Core API. For example, authenticate as a common user and get account info:
```go
// Your registration credentials
authOpts := gcore.AuthOptions{
Username: "username",
Password: "password",
}
// Create a new Common client instance
client := gcore.NewCommonClient()
// Get a token
// Empty context just for the sake of simplicity here
if err := client.Authenticate(context.Background(), authOpts); err != nil {
panic(err)
}
// Get account details
account, _, err := client.Account.Details(context.Background())
if err != nil {
panic(err)
}
fmt.Printf("%+v\n", account)
```
To use a reseller G-Core API construct a new Reseller client, then use the various services on the client to
access different parts of the G-Core Reseller API. For example, authenticate as a reseller and get a list of activated clients:
```go
// Your reseller registration credentials
authOpts := gcore.AuthOptions{
Username: "username",
Password: "password",
}
// Create a new Reseller client instance
client := gcore.NewResellerClient()
// Get a token
// Empty context just for the sake of simplicity here
if err := client.Authenticate(context.Background(), authOpts); err != nil {
panic(err)
}
listOpts := gcore.ListOpts{
Activated: true,
}
// Get a list of activated clients assigned to this reseller account
clients, _, err := client.Clients.List(context.Background(), listOpts)
if err != nil {
panic(err)
}
fmt.Printf("%+v\n", clients)
```
## License ##
This library is distributed under the MIT license found in the [LICENSE](./LICENSE) file.