cloudant

package module
v0.0.0-...-3e6b12e Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2014 License: GPL-2.0 Imports: 8 Imported by: 2

README

go-cloudant: A Cloudant API wrapper for Go

Supports go 1.2 or later

Documentation

(coming soon)

Installation

go get -u github.com/obieq/go-cloudant

Client

import "github.com/obieq/go-cloudant"

var client *Client = NewClient("Your Cloudant URI", "Your Cloudant API Key", "Your Cloudant API Password")

Examples

(coming soon)

Detailed examples can be found in the test files

Tests

100% code coverage via ginkgo and gomega

go test -cover
      or
ginkgo -cover

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultTransport *httpclient.Transport = &httpclient.Transport{
		ConnectTimeout:        1 * time.Second,
		RequestTimeout:        5 * time.Second,
		ResponseHeaderTimeout: 5 * time.Second,
	}
)

Functions

This section is empty.

Types

type Client

type Client struct {
	PrintResponses bool
	// contains filtered or unexported fields
}

func NewClient

func NewClient(rootUri string, apiKey string, apiPassword string) *Client

func NewClientWithTransport

func NewClientWithTransport(rootUri string, apiKey string, apiPassword string, transport *httpclient.Transport) *Client

Like NewClient, except that it allows a specific http.Transport to be provided for use, rather than DefaultTransport.

func (*Client) CreateDatabase

func (client *Client) CreateDatabase(name string) (CloudantDocumentResponse, error)

func (*Client) DeleteDatabase

func (client *Client) DeleteDatabase(name string) (CloudantDocumentResponse, error)

func (*Client) GetClusterInfo

func (client *Client) GetClusterInfo() (ClusterInfo, error)

func (*Client) GetDatabase

func (client *Client) GetDatabase(name string) Database

func (*Client) ListDatabases

func (client *Client) ListDatabases() ([]string, error)

type CloudantDocument

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

func (*CloudantDocument) Id

func (doc *CloudantDocument) Id() string

func (*CloudantDocument) Revision

func (doc *CloudantDocument) Revision() string

func (*CloudantDocument) SetId

func (doc *CloudantDocument) SetId(id string)

type CloudantDocumentInterfacer

type CloudantDocumentInterfacer interface {
	Id() string
	SetId(string)
	Revision() string
}

type CloudantDocumentResponse

type CloudantDocumentResponse struct {
	Id       string `json:"id"`
	Revision string `json:"rev"`
	Ok       string `json:"ok"`
	Result   string `json:"result"`
}

type CloudantError

type CloudantError struct {
	// The status string returned from the HTTP call.
	Status string `json:"-"`

	// The status, as an integer, returned from the HTTP call.
	StatusCode int `json:"-"`

	// The Cloudant error id.
	Code string `json:"error"`

	// The Cloudant error reason.
	Detail string `json:"reason"`
}

An implementation of 'error' that exposes all the cloudant specific error details.

func NotFoundError

func NotFoundError() *CloudantError

func (*CloudantError) Error

func (e *CloudantError) Error() string

type ClusterInfo

type ClusterInfo struct {
	Couchdb       string `json:"couchdb"`
	Version       string `json:"version"`
	CloudantBuild string `json:"cloudant_build"`
}

type Database

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

func NewDatabase

func NewDatabase(name string, client *Client) *Database

func (*Database) Client

func (db *Database) Client() *Client

func (*Database) CreateDocument

func (db *Database) CreateDocument(doc interface{}, isBatch bool) (CloudantDocumentResponse, error)

func (*Database) CreateIndex

func (db *Database) CreateIndex(fields []string, opts map[string]string) (CloudantDocumentResponse, error)

Create an index on the specified field names

http://docs.cloudant.com/api/cloudant-query.html?highlight=query#creating-a-new-index

Options:
  1) ddoc_name:  name of the design document.  auto-generated if not specified
  2) index_name: name of the index auto-generate if not specified
  3) type:       currently, only supported type is json (default).
                 per the docs, full text and geospatial will be available at some point

func (*Database) DeleteDocument

func (db *Database) DeleteDocument(id string, revision string) (CloudantDocumentResponse, error)

func (*Database) DeleteIndexByName

func (db *Database) DeleteIndexByName(name string) (CloudantDocumentResponse, error)

func (*Database) GetDesignDocument

func (db *Database) GetDesignDocument(id string) (*DesignDocument, error)

func (*Database) GetDocument

func (db *Database) GetDocument(id string, doc interface{}) error

func (*Database) GetIndexByDDocName

func (db *Database) GetIndexByDDocName(ddocId string) (*DesignDocument, error)

func (*Database) GetIndexByName

func (db *Database) GetIndexByName(name string) (*Index, error)

func (*Database) GetIndices

func (db *Database) GetIndices() ([]Index, error)

func (*Database) Name

func (db *Database) Name() string

func (*Database) Query

func (db *Database) Query(q *Query, results interface{}) error

func (*Database) UpdateDocument

func (db *Database) UpdateDocument(doc CloudantDocumentInterfacer, isBatch bool) (CloudantDocumentResponse, error)

type DesignDocument

type DesignDocument struct {
	CloudantDocument
	Language string                        `json:"language"`
	Views    map[string]designDocumentView `json:"views"`
}

Container for cloudant design document information http://docs.cloudant.com/api/design-documents-get-put-delete-copy.html

func (*DesignDocument) ViewKeys

func (ddoc *DesignDocument) ViewKeys() []string

type Index

type Index struct {
	DDocId     string          `json:"ddoc"`
	Name       string          `json:"name"`
	Type       string          `json:"type"`
	Definition indexDefinition `json:"def"`
}

Container for cloudant index information http://docs.cloudant.com/api/cloudant-query.html?highlight=query#list-all-indexes

type Query

type Query struct {
	Selector map[string]interface{} `json:"selector"`
	Sorters  []map[string]string    `json:"sort"`
	Limit    int                    `json:"limit"`
	Skip     int                    `json:"skip"`
}

Container for cloudant query selectors http://docs.cloudant.com/api/cloudant-query.html?highlight=query#selector-syntax

func NewQuery

func NewQuery() *Query

func (*Query) Sort

func (q *Query) Sort(field string, isAscending bool)

type QueryResults

type QueryResults struct {
	Docs interface{} `json:"docs"`
}

Jump to

Keyboard shortcuts

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