Skip to content

Leaseweb Dedicated & Virtual Servers V2 JSON-RPC API in Golang

License

Notifications You must be signed in to change notification settings

gadost/go-lwapi

Repository files navigation

go-lwapi

Leaseweb Dedicated & Virtual Servers V2 JSON-RPC API in Golang

Build Status GoDoc codecov Go Report Card

Install

go get -u github.com/gadost/go-lwapi@latest

Example

package main 

import (
    "github.com/gadost/go-lwapi"
)
func main() {
    // Dedicated Server AAPI
    api := lwapi.New("testtoken").DedicatedServers()

    resp, err := api.ServerReferenceUpdate(12345, &lwapi.Reference{Reference: "test-server"})
    ...

    // Virtual Server API
    api := lwapi.New("testtoken").VirtualServers()

    resp, err := api.VirtualServer(12345)
    ...
}

Query params

api := lwapi.New("testtoken").DedicatedServers()

q := make(map[string]interface{})
q["limit"] = 20
q["privateNetworkEnabled"] = "true"
q["ip"] = "127.0.0.1"

resp, err := api.Servers(q)
...

Time helper ISO-8601

 to := FormatISO8601(time.Now().Add(60*time.Day))

returns time in ISO-8601 format