Golang Wrapper for ALSO Cloud Marketplace API
Swagger Specs for ALSO Cloud Marketplace Simple API are here: https://app.swaggerhub.com/apis/Marketplace_SimpleAPI/Marketplace_SimpleAPI/1.0.0
$ go get github.com/pitwch/go-also-cloud-wrapper/alsocloud
Configuration | Examples | Type | Note |
---|---|---|---|
Marketplace | https://marketplace.also.ch | string |
URL Marketplace (Country specific) |
apiUser | demo@example.com | string |
Username for Cloud Marketplace |
apiPassword | 1234 | string |
Password for Cloud Marketplace |
options | &also.Options{Timeout: 30} | *also.Options |
Options (see Chapter Options ) |
Example:
import (
also "github.com/pitwch/go-also-cloud-wrapper/alsocloud"
)
var alsocloud, err = also.NewClient(
"https://marketplace.also.ch",
"demo@example.com",
"1234",
&also.Options{Log: true, Timeout: 30},
)
Options are optional:
Option | Example | Note |
---|---|---|
APIPrefix | /SimpleAPI/SimpleAPIService.svc/rest | API - Prefix; Default = /SimpleAPI/SimpleAPIService.svc/rest |
LoginEndpoint | GetSessionToken | Endpoint for Login; Default = GetSessionToken |
UserAgent | go-also-cloud-wrapper | User Agent; Default = go-also-cloud-wrapper |
Timeout | 15 | Timeout in seconds |
VerifySSL | true | Check if SSL is valid |
Log | true | Activates Log Output; Default = false |
Client | urlfetch.Client(ctx) 1 | HTTP-Client; Default = http.DefaultClient |
1: urlfetch is used for Google App Engine Standard Instances but can be replaced by any HTTP-Client
Parameter | Typ | Note |
---|---|---|
endpoint | string |
Endpoint ALSO Cloud Marketplace; f.ex. GetCompany, GetUser... |
data | interface{} |
Date (automatic conversion to JSON) |
parameters | url.Values |
Parameters |
Get Company
import (
also "github.com/pitwch/go-also-cloud-wrapper/alsocloud"
)
//Create client
var alsocloud, err = also.NewClient(
alsocloud.Switzerland, //Using predefined Constant Switzerland.
"demo@example.com", //Plain URL would be possible "https://marketplace.also.ch"
"1234",
&px.Options{Log: true, Timeout: 30},
)
//Create context
ctx := context.Background()
//Query
res, _, _, err := alsocloud.Post(ctx, "GetCompany", nil)
buf := new(bytes.Buffer)
buf.ReadFrom(res)
resp := buf.String()
fmt.Printf(resp, err)
defer res.Close()
//returns {"ParentAccountId": 1234,"AccountId": 1234,"AccountState": "Active","CompanyName": "Demo"...
For a full list of options check GoDoc.