pshdlApi

package
v0.0.0-...-b87703a Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2014 License: MIT Imports: 17 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckResponse

func CheckResponse(r *http.Response) error

CheckResponse checks the API response for errors, and returns them if present. A response is considered an error if it has a status code outside the 200 range. API error responses are expected to have either no response body, or a JSON response body that maps to ErrorResponse. Any other response body will be silently ignored.

Types

type ByDir

type ByDir []Port

func (ByDir) Len

func (a ByDir) Len() int

func (ByDir) Less

func (a ByDir) Less(i, j int) bool

func (ByDir) Swap

func (a ByDir) Swap(i, j int)

type ByName

type ByName []Port

func (ByName) Len

func (a ByName) Len() int

func (ByName) Less

func (a ByName) Less(i, j int) bool

func (ByName) Swap

func (a ByName) Swap(i, j int)

type Client

type Client struct {

	// User agent used when communicating with the PSHDL REST API.
	UserAgent string

	// Services used for talking to different parts of the PSHDL REST API.
	Workspace *WorkspaceService
	Compiler  *CompilerService
	Streaming *StreamingService
	// contains filtered or unexported fields
}

A Client manages communication with the Pshdl Rest API.

func NewClient

func NewClient(httpClient *http.Client) *Client

NewClient returns a new PSHDL REST API client. If a nil httpClient is provided, http.DefaultClient will be used.

func NewClientWithID

func NewClientWithID(httpClient *http.Client, id string) *Client

NewClientWithID returns a new PSHDL REST API client. If a nil httpClient is provided, http.DefaultClient will be used.

func (*Client) Do

func (c *Client) Do(req *http.Request, v interface{}) (resp *http.Response, err error)

Do sends an API request and returns the API response. The API response is decoded and stored in the value pointed to by v, or returned as an error if an API error has occurred.

func (*Client) DoPlain

func (c *Client) DoPlain(req *http.Request) (data []byte, resp *http.Response, err error)

DoPlain sends an API request and returns the API response as a slice of bytes.

func (*Client) NewReaderRequest

func (c *Client) NewReaderRequest(method, urlStr string, body io.Reader, ctype string) (req *http.Request, err error)

NewReaderRequest creates an API request. Uses a io.Reader and ctype instead of marshaling json.

func (*Client) NewRequest

func (c *Client) NewRequest(method, urlStr string, body interface{}) (req *http.Request, err error)

NewRequest creates an API request. A relative URL can be provided in urlStr, in which case it is resolved relative to the baseURL of the Client. Relative URLs should always be specified without a preceding slash. If specified, the value pointed to by body is JSON encoded and included as the request body.

type CompilerCEvent

type CompilerCEvent struct {
	PshdlEventMetaInfo
	Contents []struct {
		Created  int
		Problems []Problem
		Files    []Record
	}
}

P:COMPILER:C

func (*CompilerCEvent) GetFiles

func (ev *CompilerCEvent) GetFiles() []Record

func (*CompilerCEvent) GetSubject

func (ev *CompilerCEvent) GetSubject() string

type CompilerService

type CompilerService struct {

	// current workspace Id
	ID string
	// contains filtered or unexported fields
}

CompilerService handles communication with the compiler related methods of the PsHdl REST API.

func (*CompilerService) RequestSimCode

func (s *CompilerService) RequestSimCode(ct SimCodeType, moduleName string) (uris []string, err error)

RequestSimCode sends a request for simulation code if successfull, it returns the url for downloading the file

func (*CompilerService) Validate

func (s *CompilerService) Validate() (*Workspace, error)

Validate sends a request for Validation of the workspace TODO: Return result of validation

type CompilerVhdlEvent

type CompilerVhdlEvent struct {
	PshdlEventMetaInfo
	Contents []struct {
		Created  int
		Problems []Problem
		Files    []Record
	}
}

P:COMPILER:VHDL

func (*CompilerVhdlEvent) GetFiles

func (ev *CompilerVhdlEvent) GetFiles() (rec []Record)

func (*CompilerVhdlEvent) GetSubject

func (ev *CompilerVhdlEvent) GetSubject() string

type ErrorResponse

type ErrorResponse struct {
	Response *http.Response // HTTP response that caused this error
	Message  interface{}
}

An ErrorResponse reports one or more errors caused by an API request.

PSHDL REST API docs: http://developer.github.com/v3/#client-errors

func (*ErrorResponse) Error

func (r *ErrorResponse) Error() string

type File

type File struct {
	Info struct {
		Created  float64   `json:"created"`
		Files    []Record  `json:"files"`
		Problems []Problem `json:"problems"`
	} `json:"info"`
	ModuleInfos []ModuleInfos `json:"moduleInfos"`
	Record      Record        `json:"record"`
	Syntax      string        `json:"syntax"`
	Type        string        `json:"type"`
}

File describes the current state of a pshdl file in a workspace

type ModuleInfos

type ModuleInfos struct {
	Instances []string `json:"instances"`
	Name      string   `json:"name"`
	Ports     []Port   `json:"ports"`
	Type      string   `json:"type"`
}

ModuleInfos describes ports and names of a module

func (ModuleInfos) String

func (mi ModuleInfos) String() (s string)

type PingEvent

type PingEvent struct {
	PshdlEventMetaInfo
}

func (*PingEvent) GetFiles

func (ev *PingEvent) GetFiles() []Record

func (*PingEvent) GetSubject

func (ev *PingEvent) GetSubject() string

type Port

type Port struct {
	Annotations []string      `json:"annotations"`
	Dimensions  []interface{} `json:"dimensions"`
	Dir         string        `json:"dir"`
	Name        string        `json:"name"`
	Primitive   string        `json:"primitive"`
	Width       float64       `json:"width"`
}

type Problem

type Problem struct {
	Advise struct {
		Explanation string   `json:"explanation"`
		Message     string   `json:"message"`
		Solutions   []string `json:"solutions"`
	} `json:"advise"`
	ErrorCode string `json:"errorCode"`
	Location  struct {
		Length       float64 `json:"length"`
		Line         float64 `json:"line"`
		OffsetInLine float64 `json:"offsetInLine"`
		TotalOffset  float64 `json:"totalOffset"`
	} `json:"location"`
	Pid      float64 `json:"pid"`
	Severity string  `json:"severity"`
}

Problem is a result of a workspace validation with error describtions and solution hints

type PshdlEventMetaInfo

type PshdlEventMetaInfo struct {
	Subject   string
	MsgType   string
	TimeStamp int
}

type Record

type Record struct {
	FileURI      string  `json:"fileURI"`
	Hash         string  `json:"hash"`
	LastModified float64 `json:"lastModified"` //TODO Float?!
	RelPath      string  `json:"relPath"`
}

Record desribes where a File is stored and some information about it

type SimCodeType

type SimCodeType int

SimCodeType represents the different types of simulation code that can be generated by the API

const (
	SimPsex SimCodeType = iota
	SimJava
	SimC
	SimGo
	SimDart
	SimJavaScript
)

The different types of sim code

type StreamingClientEvent

type StreamingClientEvent struct {
	ID        string `json:"clientID"`
	Timestamp int64  `json:"timeStamp"`
	Subject   string `json:"subject"`
}

type StreamingEvent

type StreamingEvent interface {
	GetSubject() string
	GetFiles() []Record
}

type StreamingService

type StreamingService struct {

	// current workspace Id
	ID string
	// contains filtered or unexported fields
}

StreamingService handles communication with the streaming related methods of the PsHdl REST API.

func (*StreamingService) OpenEventStream

func (s *StreamingService) OpenEventStream() (<-chan StreamingEvent, error)

func (*StreamingService) SendClientConnected

func (s *StreamingService) SendClientConnected() error

type Workspace

type Workspace struct {
	Files          []File  `json:"files"`
	ID             string  `json:"id"`
	JSONVersion    string  `json:"jsonVersion"`
	LastValidation float64 `json:"lastValidation"`
	Validated      bool    `json:"validated"`
}

Workspace represents a workspace on the API

type WorkspaceService

type WorkspaceService struct {

	// current workspace ID
	ID string
	// contains filtered or unexported fields
}

WorkspaceService handles communication with the workspace related methods of the PsHdl REST API.

func (*WorkspaceService) Create

func (s *WorkspaceService) Create() (*Workspace, *http.Response, error)

Create creates a new Workspace on the Rest API Currently using form encoded post, want json..!

func (*WorkspaceService) Delete

func (s *WorkspaceService) Delete(fname string) (bool, *http.Response, error)

Delete removes the file `fname` from the specified workspace

func (*WorkspaceService) DownloadRecord

func (s *WorkspaceService) DownloadRecord(rec Record) error

DownloadRecord returns a copy of fname

func (*WorkspaceService) DownloadRecords

func (s *WorkspaceService) DownloadRecords(recs []Record) error

DownloadRecords starts DownloadRecord for each Record in its own goroutine and waits until all are finished or one of them returns an error

func (*WorkspaceService) GetInfo

func (s *WorkspaceService) GetInfo() (*Workspace, *http.Response, error)

GetInfo gets all the info there is to get for a PSHDL Workspace

func (*WorkspaceService) UploadFile

func (s *WorkspaceService) UploadFile(fname string, fbuf io.Reader) error

UploadFile adds a file with fname to the Workspace specified by ID

type WorskpaceDeletedEvent

type WorskpaceDeletedEvent struct {
	PshdlEventMetaInfo
	Contents File
}

P:WORKSPACE:DELETED

func (*WorskpaceDeletedEvent) GetFiles

func (ev *WorskpaceDeletedEvent) GetFiles() []Record

func (*WorskpaceDeletedEvent) GetSubject

func (ev *WorskpaceDeletedEvent) GetSubject() string

type WorskpaceUpdatedEvent

type WorskpaceUpdatedEvent struct {
	PshdlEventMetaInfo
	Contents []File
}

P:WORKSPACE:ADDED P:WORKSPACE:UPDATED

func (*WorskpaceUpdatedEvent) DownloadFiles

func (ev *WorskpaceUpdatedEvent) DownloadFiles(ws WorkspaceService) error

func (*WorskpaceUpdatedEvent) GetFiles

func (ev *WorskpaceUpdatedEvent) GetFiles() []Record

func (*WorskpaceUpdatedEvent) GetSubject

func (ev *WorskpaceUpdatedEvent) GetSubject() string

Jump to

Keyboard shortcuts

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