client

package
v0.0.0-...-89bf0d2 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2018 License: MIT Imports: 6 Imported by: 2

README

Usher Client Package

Installation
go get -u github.com/spy16/usher
Usage
package main

import (
    "fmt"
    "errors"
    "github.com/spy16/usher"
    "github.com/spy16/usher/client"
)

func main() {
    cl := client.New("http://localhost:8080")
    
    
    // Get object of type `Artist` with name
    // `Imagine Dragons` from Usher server.
    artistObj := &usher.Object{}
    artistID := usher.ObjectID{
        Kind: "Artist",
        Name: "Imagine Dragons",
    }
    if err := cl.Get(artistID, artistObj); err != nil {
        panic(errors.New(err.Message))
    }
    fmt.Println(artistObj)


    // Get object of type `Song` with name
    // `Battle Symphony` under artist `Linkin Park`
    // from Usher server.
    songObj := &usher.Object{}
    songID := usher.ObjectID{
        Kind: "Song",
        Name: "Battle Symphony",
        Parents: usher.ParentRefs{
            {Kind:"Artist", Name:"Linkin Park"},
        },
    }
    if err := cl.Get(songID, songObj); err != nil {
        panic(errors.New(err.Message))
    }
    fmt.Println(songObj)


}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIClient

type APIClient struct {
	// contains filtered or unexported fields
}

APIClient is the Usher API Client Type.

func New

func New(host string) *APIClient

New initializes the APIClient.

func (*APIClient) Create

func (cl *APIClient) Create(obj *usher.Object) *usher.Error

Create ships the given object to Usher server for storage.

func (*APIClient) Delete

func (cl *APIClient) Delete(id usher.ObjectID, obj *usher.Object) *usher.Error

Delete removes an object from Usher server.

func (*APIClient) Exists

func (cl *APIClient) Exists(id usher.ObjectID) *usher.Error

Exists makes a HEAD request to check if the object exists.

func (*APIClient) Get

func (cl *APIClient) Get(id usher.ObjectID, obj *usher.Object) *usher.Error

Get fetches an object by the id.

func (*APIClient) GetAll

func (cl *APIClient) GetAll(query usher.Query, objList *[]usher.Object) *usher.Error

GetAll makes a get request on the collection and returns an array of objects matching the query.

func (*APIClient) PartialUpdate

func (cl *APIClient) PartialUpdate(id usher.ObjectID, updates []usher.UpdateClause, obj *usher.Object) *usher.Error

func (*APIClient) SetBasicAuth

func (cl *APIClient) SetBasicAuth(username string, password string)

SetBasicAuth sets username and password to be used as basic auth credentials.

func (*APIClient) Update

func (cl *APIClient) Update(id usher.ObjectID, newObj *usher.Object) *usher.Error

Update performs a complete replace of the object on Usher server.

Jump to

Keyboard shortcuts

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