Skip to content

Commit 2aa86f8

Browse files
authored
Update README.md
Initial update on repository transfer.
1 parent 6151bdd commit 2aa86f8

1 file changed

Lines changed: 24 additions & 26 deletions

File tree

README.md

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,35 @@
1-
# upcloud-go-sdk
1+
# UpCloud Go SDK
22

3-
[![Build Status](https://travis-ci.org/Jalle19/upcloud-go-sdk.svg?branch=master)](https://travis-ci.org/Jalle19/upcloud-go-sdk)
4-
[![Go Report Card](https://goreportcard.com/badge/github.com/Jalle19/upcloud-go-sdk)](https://goreportcard.com/report/github.com/Jalle19/upcloud-go-sdk)
3+
[![Build Status](https://travis-ci.org/UpCloudLtd/upcloud-go-sdk.svg?branch=master)](https://travis-ci.org/UpCloudLtd/upcloud-go-sdk)
4+
[![Go Report Card](https://goreportcard.com/badge/github.com/UpCloudLtd/upcloud-go-sdk)](https://goreportcard.com/report/github.com/UpCloudLtd/upcloud-go-sdk)
55
[![GoDoc](https://godoc.org/github.com/Jalle19/upcloud-go-sdk?status.svg)](https://godoc.org/github.com/Jalle19/upcloud-go-sdk)
66

7-
This is an SDK for interfacing with UpCloud's API using the Go programming language. It is loosely based on similar
8-
SDKs such as https://github.com/aws/aws-sdk-go.
7+
This is the SDK for interfacing with UpCloud's API using the Go programming language. The features in the development kit allow easy application creation and simplify UpCloud API integration when using Go.
98

109
## Installation and requirements
1110

12-
You'll need Go 1.6 or higher to use the SDK. You can use the following command to retrieve the SDK:
11+
You'll need Go 1.7 or higher to use the SDK. You can use the following command to retrieve the SDK:
1312

1413
```
15-
go get github.com/Jalle19/upcloud-go-sdk
14+
go get github.com/UpCloudLtd/upcloud-go-sdk
1615
```
1716

1817
## Usage
1918

20-
The general pattern for using the SDK goes like this:
19+
The general usage of the SDK adheres to the following pattern:
2120

22-
* Create a `client.Client`
23-
* Create a `service.Service` by passing the newly created client object to it
24-
* Interface with the API using the various methods of the service object. Methods that take parameters wrap them in
25-
request objects.
21+
* Authenticate by creating a `client.Client`
22+
* Create a `service.Service` by passing the newly created `client` object to it
23+
* Interface with the API using the various methods of the `service` object. Methods that take parameters wrap them in request objects.
2624

27-
The examples here only deal with how to use the SDK itself. For information on how to use the API in general, please
28-
consult the [official documentation](https://www.upcloud.com/api/).
25+
We recommend setting up a separate subaccount for API usage to allow better access control and security. You can find out more about creating subaccounts at the following support article for [Server Tags and Group Accounts](https://www.upcloud.com/support/server-tags-and-group-accounts/). We strongly recommend limiting the connections to a specific address or address range for security purposes.
26+
27+
The examples here only deal with how to use the SDK itself. For information on how to use the API in general, please consult the [UpCloud API documentation](https://www.upcloud.com/api/).
2928

3029
### Creating the client and the service
3130

3231
```go
33-
// Upcloud doesn't use dedicated API keys, instead you pass your account login credentials to the client
32+
// Authenticate by passing your account login credentials to the client
3433
c := client.New(user, password)
3534

3635
// It is generally a good idea to override the default timeout of the underlying HTTP client since some requests block for longer periods of time
@@ -42,8 +41,7 @@ svc := service.New(c)
4241

4342
### Validating credentials
4443

45-
The easiest way to check whether the client credentials are correct is to issue a call to `GetAccount()` (since it
46-
doesn't require any parameters).
44+
The easiest way to check whether the client credentials are correct is to issue a call to `GetAccount()`.
4745

4846
```go
4947
username := "completely"
@@ -60,9 +58,7 @@ if err != nil {
6058

6159
### Error handling
6260

63-
All `Service` methods return a result and an error object. You can differentiate between generic connection errors
64-
(like the API not being reachable) and service errors, which are errors returned in the response body by the API. This
65-
is useful if you want to gracefully recover from certain types of errors.
61+
All `Service` methods return a result and an error object. You can differentiate between generic connection errors (like the API not being reachable) and service errors, which are errors returned in the response body by the API. This is useful for gracefully recovering from certain types of errors.
6662

6763
```go
6864
username := "completely"
@@ -93,6 +89,8 @@ The rest of these examples assume you already have a service object configured a
9389
9490
### Retrieving a list of servers
9591
92+
The following example will retrieve a list of servers the account has access to.
93+
9694
```go
9795
// Retrieve the list of servers
9896
servers, err := svc.GetServers()
@@ -109,8 +107,10 @@ for _, server := range servers.Servers {
109107

110108
### Creating a new server
111109

110+
Since the request for creating a new server is asynchronous, the server will report its status as "maintenance" until the deployment has been fully completed.
111+
112112
```go
113-
// Create the server. The state will be "maintenance" since the request is asynchronous
113+
// Create the server
114114
serverDetails, err := svc.CreateServer(&request.CreateServerRequest{
115115
Zone: "fi-hel1",
116116
Title: "My new server",
@@ -163,8 +163,7 @@ fmt.Println("Server is now started")
163163

164164
### Templatizing a server's storage device
165165

166-
In this example we assume that there is a server represented by the variable `serverDetails` and that the server state
167-
is `stopped`. We also assume that we want to templatize the first storage device of the server only.
166+
In this example, we assume that there is a server represented by the variable `serverDetails` and that the server state is `stopped`. The next piece of code allows you to templatize the first storage device of the server.
168167

169168
```go
170169
// Loop through the storage devices
@@ -189,8 +188,7 @@ for i, storage := range serverDetails.StorageDevices {
189188

190189
### Create a manual backup
191190

192-
In this example, we assume that there is a storage device represented by `storageDetails` and that if it is attached
193-
to any server, the server is stopped.
191+
In this example, we assume that there is a storage device represented by `storageDetails` and that if it is attached to any server, the server is stopped.
194192

195193
```go
196194
backupDetails, err := svc.CreateBackup(&request.CreateBackupRequest{
@@ -207,7 +205,7 @@ fmt.Println(fmt.Sprintf("Backup of %s created as %s", storageDetails.UUID, backu
207205

208206
### Create a new firewall rule
209207

210-
In this example we assume that there is a server represented by the variable `serverDetails`.
208+
In this example, we assume that there is a server represented by the variable `serverDetails`.
211209

212210
```go
213211
firewallRule, err := svc.CreateFirewallRule(&request.CreateFirewallRuleRequest{

0 commit comments

Comments
 (0)