Skip to content
The official gridscale API client written in Go
Go
Branch: develop
Clone or download
Latest commit ed14c64 Sep 16, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples Update examples Sep 12, 2019
.gitignore Added .gitignore file Nov 28, 2018
.travis.yml Add install section Aug 22, 2019
CHANGELOG.md Fix typo Sep 5, 2019
CONTRIBUTING.md add CONTRIBUTING infos Jul 16, 2019
CONTRIBUTORS.md add tom to the contributors Aug 7, 2019
LICENSE.md Added LICENSE.md with MIT license Dec 12, 2018
README.md Merge branch 'develop' into event Aug 30, 2019
client.go move version const to config.go Sep 9, 2019
common.go gofmt Sep 5, 2019
common_test.go Update common_test.go Sep 5, 2019
config.go unexported Config's properties Sep 12, 2019
event.go add events getter implementation Aug 26, 2019
event_test.go `t.Errorf` replaced by `assert.Nil` Sep 2, 2019
firewall.go gofmt Sep 5, 2019
firewall_test.go gain more percent of test coverage Sep 3, 2019
ip.go fix bugs when marshaling JSON into IP struct Sep 11, 2019
ip_test.go fix bug in IP test. Sep 11, 2019
isoimage.go now validating uuid before executing any futher actions Sep 5, 2019
isoimage_test.go `t.Errorf` replaced by `assert.Nil` Sep 2, 2019
label.go
label_test.go gain more percent of test coverage Sep 3, 2019
loadbalancer.go `LocationSite` is type string Sep 11, 2019
loadbalancer_test.go gain more percent of test coverage Sep 3, 2019
location.go now validating uuid before executing any futher actions Sep 5, 2019
location_test.go gain more percent of test coverage Sep 3, 2019
network.go now validating uuid before executing any futher actions Sep 5, 2019
network_test.go gain more percent of test coverage Sep 3, 2019
objectstorage.go add strings.TrimSpace(id) to object storage's access key query and de… Sep 5, 2019
objectstorage_test.go gain more percent of test coverage Sep 3, 2019
paas.go Fixed a paas creation response's bug Sep 13, 2019
paas_test.go Fixed a paas creation response's bug Sep 13, 2019
request.go log retry number Sep 16, 2019
server.go gofmt Sep 5, 2019
server_test.go retryable "execute" when server returns >= 500code Sep 11, 2019
serverip.go gain more percent of test coverage Sep 3, 2019
serverip_test.go gain more percent of test coverage Sep 3, 2019
serverisoimage.go now validating uuid before executing any futher actions Sep 5, 2019
serverisoimage_test.go gain more percent of test coverage Sep 3, 2019
servernetwork.go conflict fixed Sep 11, 2019
servernetwork_test.go
serverstorage.go gofmt Sep 5, 2019
serverstorage_test.go gain more percent of test coverage Sep 3, 2019
snapshot.go gofmt Sep 5, 2019
snapshot_test.go gain more percent of test coverage Sep 3, 2019
snapshotscheduler.go gofmt Sep 5, 2019
snapshotscheduler_test.go gain more percent of test coverage Sep 3, 2019
sshkey.go gofmt Sep 5, 2019
sshkey_test.go gain more percent of test coverage Sep 3, 2019
storage.go now validating uuid before executing any futher actions Sep 5, 2019
storage_test.go gain more percent of test coverage Sep 3, 2019
template.go now validating uuid before executing any futher actions Sep 5, 2019
template_test.go gain more percent of test coverage Sep 3, 2019
testcommon.go Update testcommon.go Sep 12, 2019

README.md

The gridscale Go Client

Build Status Go Report Card

This is a client for the gridscale API. It can be used to make an application interact with the gridscale cloud platform to create and manage resources.

Preparation for Use

To be able to use this client a number of steps need to be taken. First a gridscale account will be required, which can be created here. Then an API-token should be created.

Installation

First the Go programming language will need to be installed. This can be done by using the official Go installation guide or by using the packages provided by your distribution.

Downloading the gridscale Go client can be done with the following go command:

go get "github.com/gridscale/gsclient-go"

Using the gridscale Client

To be able to use the gridscale Go client in an application it can be imported in a go file. This can be done with the following code:

import (
	"github.com/gridscale/gsclient-go"
)

To get access to the functions of the Go client, a Client type needs to be created. This requires a Config type. Both of these can be created with the following code:

config := gsclient.NewConfiguration("User-UUID", "API-token")
client := gsclient.NewClient(config)

Make sure to replace the user-UUID and API-token strings with valid credentials or variables containing valid credentials. It is recommended to use environment variables for them.

Using API endpoints

After having created a Client type, as shown above, it will be possible to interact with the API. An example would be the Servers Get endpoint:

servers := client.GetServerList()

For creating and updating/patching objects in gridscale, it will be required to use the respective CreateRequest and UpdateRequest types. For creating an SSH-key that would be SshkeyCreateRequest and SshkeyUpdateRequest. Here an example:

requestBody := gsclient.IPCreateRequest {
	Family: 6,
	Name:   "IPTest",
}

client.CreateIP(requestBody)

What options are available for each create and update request can be found in the source code. After installing it should be located in:

~/go/src/github.com/gridscale/gsclient-go

Examples

Examples on how to use each resource can be found in the examples folder:

  • Firewall (firewall.go)
  • IP (ip.go)
  • ISO-image (isoimage.go)
  • Loadbalancer (loadbalancer.go)
  • Network (network.go)
  • Object Storage (objectstorage.go)
  • PaaS service (paas.go)
  • Server (server.go)
  • Storage (storage.go)
  • Storage snapshot (snapshot.go)
  • Storage snapshot schedule (snapshotschedule.go)
  • SSH-key (sshkey.go)
  • Template (template.go)

Implemented API Endpoints

Not all endpoints have been implemented in this client, but new ones will be added in the future. Here is the current list of implemented endpoints and their respective function written like endpoint (function):

  • Servers
    • Servers Get (GetServerList)
    • Server Get (GetServer)
    • Server Create (CreateServer)
    • Server Patch (UpdateServer)
    • Server Delete (DeleteServer)
    • Server Events Get (GetServerEventList)
    • Server Metrics Get (GetServerMetricList)
    • ACPI Shutdown (ShutdownServer)
    • Server On/Off (StartServer, StopServer)
    • Server's Storages Get (GetServerStorageList)
    • Server's Storage Get (GetServerStorage)
    • Server's Storage Create (CreateServerStorage)
    • Server's Storage Update (UpdateServerStorage)
    • Server's Storage Delete (DeleteServerStorage)
    • Link Storage (LinkStorage)
    • Unlink Storage (UnlinkStorage)
    • Server's Networks Get (GetServerNetworkList)
    • Server's Network Get (GetServerNetwork)
    • Server's Network Create (CreateServerNetwork)
    • Server's Network Update (UpdateServerNetwork)
    • Server's Network Delete (DeleteServerNetwork)
    • Link Network (LinkNetwork)
    • Unlink Network (UnlinkNetwork)
    • Server's IPs Get (GetServerNetworkList)
    • Server's IP Get (GetServerNetwork)
    • Server's IP Create (CreateServerNetwork)
    • Server's IP Update (UpdateServerNetwork)
    • Server's IP Delete (DeleteServerNetwork)
    • Link IP (LinkIP)
    • Unlink IP (UnlinkIP)
    • Server's ISO-Images Get (GetServerIsoImageList)
    • Server's ISO-Image Get (GetServerIsoImage)
    • Server's ISO-Image Create (CreateServerIsoImage)
    • Server's ISO-Image Update (UpdateServerIsoImage)
    • Server's ISO-Image Delete (DeleteServerIsoImage)
    • Link ISO-Image (LinkIsoimage)
    • Unlink ISO-Image (UnlinkIsoimage)
  • Storages
    • Storages Get (GetStorageList)
    • Storage Get (GetStorage)
    • Storage Create (CreateStorage)
    • Storage Patch (UpdateStorage)
    • Storage Delete (DeleteStorage)
    • Storage's events Get (GetStorageEventList)
  • Networks
    • Networks Get (GetNetworkList)
    • Network Get (GetNetwork)
    • Network Create (CreateNetwork)
    • Network Patch (UpdateNetwork)
    • Network Delete (DeleteNetwork)
    • Network Events Get (GetNetworkEventList)
    • (GetNetworkPublic) No official endpoint, but gives the Public Network
  • Loadbalancers
    • LoadBalancers Get (GetLoadBalancerList)
    • LoadBalancer Get (GetLoadBalancer)
    • LoadBalancer Create (CreateLoadBalancer)
    • LoadBalancer Patch (UpdateLoadBalancer)
    • LoadBalancer Delete (DeleteLoadBalancer)
    • LoadBalancerEvents Get (GetLoadBalancerEventList)
  • IPs
    • IPs Get (GetIPList)
    • IP Get (GetIP)
    • IP Create (CreateIP)
    • IP Patch (UpdateIP)
    • IP Delete (DeleteIP)
    • IP Events Get (GetIPEventList)
    • IP Version Get (GetIPVersion)
  • SSH-Keys
    • SSH-Keys Get (GetSshkeyList)
    • SSH-Key Get (GetSshkey)
    • SSH-Key Create (CreateSshkey)
    • SSH-Key Patch (UpdateSshkey)
    • SSH-Key Delete (DeleteSshkey)
    • SSH-Key's events Get (GetSshkeyEventList)
  • Template
    • Templates Get (GetTemplateList)
    • Template Get (GetTemplate)
    • (GetTemplateByName) No official endpoint, but gives a template which matches the exact name given.
    • Template Create (CreateTemplate)
    • Template Update (UpdateTemplate)
    • Template Delete (DeleteTemplate)
    • Template's events Get (GetTemplateEventList)
  • PaaS
    • PaaS services Get (GetPaaSServiceList)
    • PaaS service Get (GetPaaSService)
    • PaaS service Create (CreatePaaSService)
    • PaaS service Update (UpdatePaaSService)
    • PaaS service Delete (DeletePaaSService)
    • PaaS service metrics Get (GetPaaSServiceMetrics)
    • PaaS service templates Get (GetPaaSTemplateList)
    • PaaS service security zones Get (GetPaaSSecurityZoneList)
    • Paas service security zone Get (GetPaaSSecurityZone)
    • PaaS service security zone Create (CreatePaaSSecurityZone)
    • PaaS service security zone Update (UpdatePaaSSecurityZone)
    • PaaS service security zone Delete (DeletePaaSSecurityZone)
  • ISO Image
    • ISO Images Get (GetISOImageList)
    • ISO Image Get (GetISOImage)
    • ISO Image Create (CreateISOImage)
    • ISO Image Update (UpdateISOImage)
    • ISO Image Delete (DeleteISOImage)
    • ISO Image Events Get (GetISOImageEventList)
  • Object Storage
    • Object Storage's Access Keys Get (GetObjectStorageAccessKeyList)
    • Object Storage's Access Key Get (GetObjectStorageAccessKey)
    • Object Storage's Access Key Create (CreateObjectStorageAccessKey)
    • Object Storage's Access Key Delete (DeleteObjectStorageAccessKey)
    • Object Storage's Buckets Get (GetObjectStorageBucketList)
  • Storage Snapshot Scheduler
    • Storage Snapshot Schedules Get (GetStorageSnapshotScheduleList)
    • Storage Snapshot Schedule Get (GetStorageSnapshotSchedule)
    • Storage Snapshot Schedule Create (CreateStorageSnapshotSchedule)
    • Storage Snapshot Schedule Update (UpdateStorageSnapshotSchedule)
    • Storage Snapshot Schedule Delete (DeleteStorageSnapshotSchedule)
  • Storage Snapshot
    • Storage Snapshots Get (GetStorageSnapshotList)
    • Storage Snapshot Get (GetStorageSnapshot)
    • Storage Snapshot Create (CreateStorageSnapshot)
    • Storage Snapshot Update (UpdateStorageSnapshot)
    • Storage Snapshot Delete (DeleteStorageSnapshot)
    • Storage Rollback (RollbackStorage)
    • Storage Snapshot Export to S3 (ExportStorageSnapshotToS3)
  • Firewall
    • Firewalls Get (GetFirewallList)
    • Firewall Get (GetFirewall)
    • Firewall Create (CreateFirewall)
    • Firewall Update (UpdateFirewall)
    • Firewall Delete (DeleteFirewall)
    • Firewall Events Get (GetFirewallEventList)
  • Event
    • Events Get (GetEventList)
  • Label
    • Labels Get (GetLabelList)
    • Label Create (CreateLabel)
    • Label Delete (DeleteLabel)
  • Location
    • Locations Get (GetLocationList)
    • Location Get (GetLocation)
    • Location IPs Get (GetIPsByLocation)
    • Location ISO Images Get (GetISOImagesByLocation)
    • Location Networks Get (GetNetworksByLocation)
    • Location Servers Get (GetServersByLocation)
    • Location Snapshots Get (GetSnapshotsByLocation)
    • Location Storages Get (GetStoragesByLocation)
    • Location Templates Get (GetTemplatesByLocation)
  • Deleted
    • Deleted IPs Get (GetDeletedIPs)
    • Deleted ISO Images Get (GetDeletedISOImages)
    • Deleted Networks Get (GetDeletedNetworks)
    • Deleted Servers Get (GetDeletedServers)
    • Deleted Snapshots Get (GetDeletedSnapshots)
    • Deleted Storages Get (GetDeletedStorages)
    • Deleted Templates Get (GetDeletedTemplates)
    • Deleted PaaS Services Get (GetDeletedPaaSServices)

Note: The functions in this list can be called with a Client type.

Known Issues

The following issues are known to us:

  • L3security isn't read in the network relation of a server.
You can’t perform that action at this time.