iland

package module
v0.0.0-...-99258d2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 1, 2018 License: BSD-3-Clause Imports: 9 Imported by: 0

README

ReportCard GoDoc

iland-sdk

iland cloud golang SDK

Introduction

This library provides a pure Golang interface for the iland cloud API https://api.ilandcloud.com/

Getting the code

The code is hosted at https://github.com/ilanddev/golang-sdk

Check out the latest development version anonymously with:

$ git clone https://github.com/ilanddev/golang-sdk.git
$ cd golang-sdk

Installation

$ go get github.com/ilanddev/golang-sdk

Documentation

Overview

Package iland provides a basic API wrapper for accessing the iland cloud API.

The package handles API token retrieval and renewal behind the scenes.

There are methods for performing the following types of HTTP requests:

GET
POST
PUT
DELETE

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	Error         string `json:"error"`
	Message       string `json:"message"`
	DetailMessage string `json:"detail_message"`
}

APIError holds messages and details around errors from the iland cloud API.

type Client

type Client struct {
	Config          *Config
	Token           *Token
	TokenExpireTime time.Time
}

Client is an iland cloud SDK client.

func NewClient

func NewClient(cfg *Config) *Client

NewClient cretes a new iland API Client to interact with the iland cloud API.

func (*Client) Delete

func (c *Client) Delete(relPath string) (string, error)

Delete performs a DELETE request to the iland cloud API to the given relative path.

func (*Client) Get

func (c *Client) Get(relPath string) (string, error)

Get performs a GET request to the iland cloud API to the given relative path.

func (*Client) Post

func (c *Client) Post(relPath, jsonStr string) (string, error)

Post performs a POST request to the iland cloud API to the given relative path and using the given JSON payload.

func (*Client) Put

func (c *Client) Put(relPath, jsonStr string) (string, error)

Put performs a PUT request to the iland cloud API to the given relative path and using the given JSON payload.

type Config

type Config struct {
	APIBaseURL   string
	AccessURL    string
	RefreshURL   string
	ClientID     string
	ClientSecret string
	Username     string
	Password     string
}

Config object to hold properties related to API access. You pass this to the NewClient method to create a new iland cloud API client.

type RefreshTokenRequest

type RefreshTokenRequest struct {
	ClientID     string `json:"client_id"`
	ClientSecret string `json:"client_secret"`
	RefreshToken string `json:"refresh_token"`
	GrantType    string `json:"grant_type"`
}

RefreshTokenRequest object for holding params required for requesting a new iland cloud API token.

type Token

type Token struct {
	AccessToken  string `json:"access_token"`
	ExpiresIn    int64  `json:"expires_in"`
	RefreshToken string `json:"refresh_token"`
}

Token object for holding access token and expiration time of iland cloud API token.

type TokenRequest

type TokenRequest struct {
	ClientID     string `json:"client_id"`
	ClientSecret string `json:"client_secret"`
	Username     string `json:"username"`
	Password     string `json:"password"`
	GrantType    string `json:"grant_type"`
}

TokenRequest object for holding params required for requesting a new iland cloud API token.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL