pb

package module
v0.0.0-...-626aa81 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2015 License: MIT Imports: 13 Imported by: 0

README

Pandora Bots API for Golang

Implementation of the public API as specified here.

Implemented features

Resource Description Supported
GET /bot/APP_ID List of bots true
PUT /bot/APP_ID/BOTNAME Create a bot true
DELETE /bot/APP_ID/BOTNAME Delete a bot true
GET bot/APP_ID/BOTNAME List of bot files true
PUT /bot/APP_ID/BOTNAME/FILE-KIND/FILENAME Upload a personality file true
PUT /bot/APP_ID/BOTNAME/properties Upload a properties/pdefaults file true
DELETE /bot/APP_ID/BOTNAME/FILE-KIND/FILENAME Delete personality file true
DELETE /bot/APP_ID/BOTNAME/FILE-KIND Delete a properties/pdefaults file true
GET /bot/APP_ID/BOTNAME/FILE-KIND/FILENAME Retrieve personality file true
GET /bot/APP_ID/BOTNAME/FILE-KIND Retrieve a properties/pdefaults file true
GET /bot/APP_ID/BOTNAME/verify Verify / compile a bot true
POST /talk/APP_ID/BOTNAME Talk with a bot (including debug parameters) true

Install

If you have a go workplace setup and working you can simply do:

go get github.com/demisto/pb-go

go install github.com/demisto/pb-go

Usage

In order how to use the pb-go module please have a look at the documentation and the cli directory. You need to have a PandoraBots application id and user key to start using the API.

Documentation

Overview

pb package implements pandorabots API as seen in https://developer.pandorabots.com/docs

Index

Constants

View Source
const (
	DefaultURL = "https://aiaas.pandorabots.com"
)

Variables

View Source
var (
	// The error raised when credentials are not provided
	ErrNoCred = errors.New("Missing application ID or user key")
)

Functions

func SetErrorLog

func SetErrorLog(logger *log.Logger) func(*Client) error

SetErrorLog sets the logger for critical messages. It is nil by default.

func SetTraceLog

func SetTraceLog(logger *log.Logger) func(*Client) error

SetTraceLog specifies the logger to use for output of trace messages like HTTP requests and responses. It is nil by default.

Types

type BotEntry

type BotEntry struct {
	Name        string `json:"botname"`
	Description string `json:"description"`
	Language    string `json:"language"`
	Compiled    string `json:"compiled"`
	Open        string `json:"open"`
}

type BotFile

type BotFile struct {
	Name      string    `json:"name"`
	Size      int64     `json:"size"`
	Modified  time.Time `json:"modified"`
	LoadOrder int       `json:"loadorder"`
	Items     int       `json:"items"`
}

type BotFiles

type BotFiles struct {
	Username      string    `json:"username"`
	Appname       string    `json:"appname"`
	Botname       string    `json:"botname"`
	Description   string    `json:"description"`
	Language      string    `json:"language"`
	Created       time.Time `json:"created"`
	Open          string    `json:"open"`
	Files         []BotFile `json:"files"`
	Sets          []BotFile `json:"sets"`
	Maps          []BotFile `json:"maps"`
	Substitutions []BotFile `json:"substitutions"`
	Properties    []BotFile `json:"properties"`
	Pdefaults     []BotFile `json:"pdefaults"`
}

type Client

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

Client interacts with the services provided by pandorabots.

func New

func New(options ...OptionFunc) (*Client, error)

New creates a new pandorabots client.

The caller can configure the new client by passing configuration options to the func.

Example:

client, err := pb.New(
  pb.SetErrorLog(log.New(os.Stderr, "PB: ", log.Lshortfile),
  pb.SetCredentials(appId, userKey))

If no URL is configured, Client uses DefaultURL by default.

If no HttpClient is configured, then http.DefaultClient is used. You can use your own http.Client with some http.Transport for advanced scenarios.

An error is also returned when some configuration option is invalid.

func (*Client) Talk

func (c *Client) Talk(name, input, clientName string, sessionId int, recent bool) (*Reply, error)

See https://developer.pandorabots.com/docs#!/pandorabots_api_swagger_1_2_beta/talkBot

func (*Client) TalkDebug

func (c *Client) TalkDebug(name, input, clientName string, sessionId int, recent bool, that, topic string, extra, reset, trace, reload bool) (*Reply, error)

See https://developer.pandorabots.com/docs#!/pandorabots_api_swagger_1_2_beta/debugBot

type OptionFunc

type OptionFunc func(*Client) error

OptionFunc is a function that configures a Client. It is used in New

func SetCredentials

func SetCredentials(appId, userKey string) OptionFunc

SetCredentials sets the app id and user key to use with pandorabots

func SetHttpClient

func SetHttpClient(httpClient *http.Client) OptionFunc

SetHttpClient can be used to specify the http.Client to use when making HTTP requests to pandorabots.

func SetUrl

func SetUrl(rawurl string) OptionFunc

SetUrl defines the URL endpoint for pandorabots

type Reply

type Reply struct {
	SessionId int      `json:"sessionid"`
	Responses []string `json:"responses"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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