coda

package module
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2021 License: MIT Imports: 13 Imported by: 1

README

go-coda

This is a simple golang wrapper around the Coda api, to allow for automations and more advanced tooling to be built on top of it. For example usage, see below.

usage

go-coda uses modules, and can be added to your project as shown below, then by running go test or go build to have the module downloaded and added to your go.mod file automatically.

import "phouse512/go-coda"

import "log"


func main() {
    codaClient := DefaultClient("sample-api-key")

    docs, err := codaClient.ListDocuments(codaClient.ListDocumentsPayload{})
    if err != nil {
        panic(err) 
    }

    log.Printf("All documents: %s", docs)
}

development

To work on the go-coda module locally, I recommend creating another test module that imports your local go-coda module so that you can test your changes. You can do that as follows:

$ go mod edit -replace github.com/phouse512/go-coda=/put/abs/path/to/local/module/here

Please note that that requires the test module to be initialized using go mod init.

Feel free to open a PR against the prod branch once you are happy with your changes.

Documentation

Index

Constants

View Source
const BaseUrl = "https://coda.io/apis/v1"

Variables

This section is empty.

Functions

This section is empty.

Types

type AddPermissionPayload

type AddPermissionPayload struct {
	Access        string    `json:"access"`
	Principal     Principal `json:"principal"`
	SuppressEmail bool      `json:"suppressEmail"`
}

type AddPermissionResponse

type AddPermissionResponse struct{}

type ApiError

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

func (ApiError) Error

func (e ApiError) Error() string

type CellParam

type CellParam struct {
	Column string      `json:"column"`
	Value  interface{} `json:"value"`
}

type Client

type Client struct {
	BaseURL    *url.URL
	UserAgent  string
	HttpClient *http.Client
}

func DefaultClient

func DefaultClient(apiKey string) *Client

func (*Client) AddPermission

func (c *Client) AddPermission(docId string, payload AddPermissionPayload) (AddPermissionResponse, error)

func (*Client) CreateDocument

func (c *Client) CreateDocument(payload CreateDocumentPayload) (CreateDocumentResponse, error)

func (*Client) DeleteDocument

func (c *Client) DeleteDocument(id string) (DeleteDocumentResponse, error)

func (*Client) DeletePermission

func (c *Client) DeletePermission(docId, permissionId string) (DeletePermissionResponse, error)

func (*Client) DeleteRow

func (c *Client) DeleteRow(docId string, tableIdOrName string, rowIdOrName string) (DeleteRowResponse, error)

func (*Client) DeleteRows

func (c *Client) DeleteRows(docId string, tableIdOrName string, deleteRowsParams DeleteRowsParameters) (DeleteRowsResponse, error)

func (*Client) GetACLMetadata

func (c *Client) GetACLMetadata(docId string) (GetACLResponse, error)

func (*Client) GetColumn

func (c *Client) GetColumn(docId string, tableIdOrName string, columnIdOrName string) (GetColumnResponse, error)

func (*Client) GetControl

func (c *Client) GetControl(docId string, controlIdOrName string) (GetControlResponse, error)

func (*Client) GetDoc

func (c *Client) GetDoc(id string) (GetDocumentResponse, error)

func (*Client) GetDocumentCategories

func (c *Client) GetDocumentCategories() (GetDocumentCategoriesResponse, error)

func (*Client) GetFormula

func (c *Client) GetFormula(docId string, formulaIdOrName string) (GetFormulaResponse, error)

func (*Client) GetMutationStatus

func (c *Client) GetMutationStatus(requestId string) (MutationStatusResponse, error)

func (*Client) GetPage

func (c *Client) GetPage(docId string, pageIdOrName string) (GetPageResponse, error)

func (*Client) GetTable

func (c *Client) GetTable(docId string, tableIdOrName string) (GetTableResponse, error)

func (*Client) GetTableRow

func (c *Client) GetTableRow(docId string, tableIdOrName string, rowIdOrName string, getRowParams GetRowParameters) (GetRowResponse, error)

func (*Client) GetUserInfo

func (c *Client) GetUserInfo() (UserInfoResponse, error)

func (*Client) GetView

func (c *Client) GetView(docId string, viewIdOrName string) (GetViewResponse, error)

func (*Client) InsertRows

func (c *Client) InsertRows(docId string, tableIdOrName string, disableParsing bool, insertRowParams InsertRowsParameters) (InsertRowsResponse, error)

func (*Client) ListACLs

func (c *Client) ListACLs(docId string, paginationPayload PaginationPayload) (ListACLResponse, error)

func (*Client) ListColumns

func (c *Client) ListColumns(docId string, tableIdOrName string, payload ListColumnsPayload) (ListColumnsResponse, error)

func (*Client) ListControls

func (c *Client) ListControls(docId string, payload ListControlsPayload) (ListControlsResponse, error)

func (*Client) ListDocuments

func (c *Client) ListDocuments(payload ListDocumentsPayload) (ListDocumentsResponse, error)

func (*Client) ListFormulas

func (c *Client) ListFormulas(docId string, payload ListFormulasPayload) (ListFormulasResponse, error)

func (*Client) ListPages

func (c *Client) ListPages(docId string, paginationPayload PaginationPayload) (ListPagesResponse, error)

func (*Client) ListTableRows

func (c *Client) ListTableRows(docId string, tableIdOrName string, listRowsParams ListRowsParameters) (ListRowsResponse, error)

func (*Client) ListTables

func (c *Client) ListTables(docId string, payload ListTablesPayload) (ListTablesResponse, error)

func (*Client) ListViewColumns

func (c *Client) ListViewColumns(docId string, viewIdOrName string, paginationPayload PaginationPayload) (ListColumnsResponse, error)

func (*Client) ListViewRows

func (c *Client) ListViewRows(docId string, viewIdOrName string, viewRowsParams ListViewRowsParameters) (ListViewRowsResponse, error)

func (*Client) ListViews

func (c *Client) ListViews(docId string, paginationPayload PaginationPayload) (ListViewsResponse, error)

func (*Client) PublishDocument

func (c *Client) PublishDocument(documentId string, payload PublishDocumentPayload) (PublishDocumentResponse, error)

func (*Client) PushButton

func (c *Client) PushButton(docId string, tableIdOrName string, rowIdOrName string, columnIdOrName string) (PushButtonResponse, error)
func (c *Client) ResolveBrowserLink(browserLinkParams ResolveBrowserLinkParameters) (ResolveBrowserLinkResponse, error)

func (*Client) UnpublishDocument

func (c *Client) UnpublishDocument(documentId string) error

func (*Client) UpdatePage

func (c *Client) UpdatePage(docId string, pageIdOrName string, pagePayload UpdatePagePayload) (RequestResponse, error)

func (*Client) UpdateRow

func (c *Client) UpdateRow(docId string, tableIdOrName string, rowIdOrName string, disableParsing bool, updateRowParams UpdateRowParameters) (UpdateRowResponse, error)

type Column

type Column struct {
	ColumnReference
	IsDisplay    bool           `json:"display"`
	IsCalculated bool           `json:"calculated"`
	Format       ColumnFormat   `json:"format"`
	Parent       TableReference `json:"parent"`
}

type ColumnFormat

type ColumnFormat struct {
	Type    string `json:"type"`
	IsArray bool   `json:"isArray"`
}

type ColumnReference

type ColumnReference struct {
	Id   string `json:"id"`
	Type string `json:"type"`
	Href string `json:"href"`
	Name string `json:"name"`
}

type Control

type Control struct {
	ControlReference
	ControlType string      `json:"controlType"`
	Value       interface{} `json:"value"`
}

type ControlReference

type ControlReference struct {
	Id     string        `json:"id"`
	Type   string        `json:"type"`
	Href   string        `json:"href"`
	Name   string        `json:"name"`
	Parent PageReference `json:"parent"`
}

type CreateDocumentPayload

type CreateDocumentPayload struct {
	Title     string `json:"title,omitempty"`
	SourceDoc string `json:"sourceDoc,omitempty"`
	Timezone  string `json:"timezone,omitempty"`
	FolderId  string `json:"folderId,omitempty"`
}

type CreateDocumentResponse

type CreateDocumentResponse struct {
	Document
}

type DeleteDocumentResponse

type DeleteDocumentResponse struct{}

type DeletePermissionResponse

type DeletePermissionResponse struct{}

type DeleteRowResponse

type DeleteRowResponse struct {
	Id        string `json:"id"`
	RequestId string `json:"requestId"`
}

type DeleteRowsParameters

type DeleteRowsParameters struct {
	RowIds []string `json:"rowIds"`
}

type DeleteRowsResponse

type DeleteRowsResponse struct {
	RowIds    []string `json:"rowIds"`
	RequestId string   `json:"requestId"`
}

type DocCategory

type DocCategory struct {
	Name string `json:"name"`
}

type DocPublished

type DocPublished struct {
	BrowserLink  string   `json:"browserLink"`
	Discoverable bool     `json:"discoverable"`
	EarnCredit   bool     `json:"earnCredit"`
	Mode         string   `json:"mode"`
	Categories   []string `json:"categories"`
	Description  string   `json:"description"`
	ImageLink    string   `json:"imageLink"`
}

type DocSize

type DocSize struct {
	TotalRowCount     int  `json:"totalRowCount"`
	TableAndViewCount int  `json:"tableAndViewCount"`
	PageCount         int  `json:"pageCount"`
	OverApiSizeLimit  bool `json:"overApiSizeLimit"`
}

type Document

type Document struct {
	Id          string  `json:"id"`
	Type        string  `json:"type"`
	Href        string  `json:"href"`
	BrowserLink string  `json:"browserLink"`
	Name        string  `json:"name"`
	Owner       string  `json:"email"`
	OwnerName   string  `json:"ownerName"`
	CreatedAt   string  `json:"createdAt"`
	UpdatedAt   string  `json:"updatedAt"`
	Icon        Icon    `json:"icon"`
	DocSize     DocSize `json:"docSize"`
	SourceDoc   struct {
		Id          string `json:"id"`
		Type        string `json:"type"`
		BrowserLink string `json:"browserLink"`
		Href        string `json:"href"`
	}
	Published DocPublished `json:"published"`
}

type ErrorResponse

type ErrorResponse struct {
	StatusCode    int    `json:"statusCode"`
	StatusMessage string `json:"statusMessage"`
	Message       string `json:"message"`
}

type Formula

type Formula struct {
	FormulaReference
	Value interface{} `json:"value"`
}

type FormulaReference

type FormulaReference struct {
	Id     string        `json:"id"`
	Type   string        `json:"type"`
	Href   string        `json:"href"`
	Name   string        `json:"name"`
	Parent PageReference `json:"parent"`
}

type GetACLResponse

type GetACLResponse struct {
	CanShare        bool `json:"canShare"`
	CanShareWithOrg bool `json:"canShareWithOrg"`
}

type GetColumnResponse

type GetColumnResponse struct {
	Column
}

type GetControlResponse

type GetControlResponse struct {
	Control
}

type GetDocumentCategoriesResponse

type GetDocumentCategoriesResponse struct {
	Categories []DocCategory `json:"items"`
}

type GetDocumentResponse

type GetDocumentResponse struct {
	Document
}

type GetFormulaResponse

type GetFormulaResponse struct {
	Formula
}

type GetPageResponse

type GetPageResponse struct {
	Page
}

type GetRowParameters

type GetRowParameters struct {
	UseColumnNames bool `json:"useColumnNames" url:"useColumnNames"`
}

type GetRowResponse

type GetRowResponse struct {
	Row
}

type GetTableResponse

type GetTableResponse struct {
	Table
}

type GetViewResponse

type GetViewResponse struct {
	View
}

type Icon

type Icon struct {
	Name        string `json:"name"`
	Type        string `json:"type"`
	BrowserLink string `json:"browserLink"`
}

type Image

type Image struct {
	BrowserLink string `json:"browserLink"`
	Type        string `json:"type"`
	Width       int    `json:"width"`
	Height      int    `json:"height"`
}

type InsertRowsParameters

type InsertRowsParameters struct {
	Rows       []RowParam `json:"rows"`
	KeyColumns []string   `json:"keyColumns,omitempty"`
}

type InsertRowsResponse

type InsertRowsResponse struct {
	RequestId string `json:"requestId"`
}

type InternalError added in v1.1.1

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

func (InternalError) Error added in v1.1.1

func (e InternalError) Error() string

type InvalidRequestError

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

Standard Bad Request 400 Error

func (InvalidRequestError) Error

func (e InvalidRequestError) Error() string

type InvalidTokenError

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

Invalid API Token

func (InvalidTokenError) Error

func (e InvalidTokenError) Error() string

type ListACLResponse

type ListACLResponse struct {
	Permissions []Permission `json:"items"`
	PaginationResponse
}

type ListColumnsPayload

type ListColumnsPayload struct {
	VisibleOnly bool `url:"visibleOnly,omitempty"`
	PaginationPayload
}

type ListColumnsResponse

type ListColumnsResponse struct {
	Columns []Column `json:"items"`
	PaginationResponse
}

type ListControlsPayload

type ListControlsPayload struct {
	SortBy string `json:"sortBy" url:"sortBy,omitEmpty"`
	PaginationPayload
}

type ListControlsResponse

type ListControlsResponse struct {
	Controls []ControlReference `json:"items"`
	PaginationResponse
}

type ListDocumentsPayload

type ListDocumentsPayload struct {
	IsOwner        bool   `url:"isOwner,omitempty"`
	Query          string `url:"query,omitempty"`
	SourceDocument string `url:"sourceDoc,omitempty"`
	IsStarred      bool   `url:"isStarred,omitempty"`
	InGallery      bool   `url:"inGallery,omitempty"`
	WorkspaceId    string `url:"workspaceId,omitempty"`
	FolderId       string `url:"folderId,omitempty"`
	PaginationPayload
}

type ListDocumentsResponse

type ListDocumentsResponse struct {
	Documents []Document `json:"items"`
	PaginationResponse
}

type ListFormulasPayload

type ListFormulasPayload struct {
	SortBy string `json:"sortBy" url:"sortBy,omitempty"`
	PaginationPayload
}

type ListFormulasResponse

type ListFormulasResponse struct {
	Formulas []FormulaReference `json:"items"`
	PaginationResponse
}

type ListPagesPayload

type ListPagesPayload struct {
	Limit     int    `url:"limit,omitempty"`
	PageToken string `url:"pageToken,omitempty"`
}

type ListPagesResponse

type ListPagesResponse struct {
	Pages []Page `json:"items"`
	PaginationResponse
}

type ListRowsParameters

type ListRowsParameters struct {
	Query          string `json:"query" url:"query"`
	SortBy         string `json:"sortBy" url:"sortBy"`
	UseColumnNames bool   `json:"useColumnNames" url:"useColumnNames"`
	ValueFormat    string `json:"valueFormat" url:"valueFormat"`
	VisibleOnly    bool   `json:"visibleOnly" url:"visibleOnly"`
	PaginationPayload
}

type ListRowsResponse

type ListRowsResponse struct {
	Rows []Row `json:"items"`
	PaginationResponse
}

type ListTablesPayload

type ListTablesPayload struct {
	SortBy     string `url:"sortBy,omitempty"`
	TableTypes string `url:"tableTypes,omitempty"`
	PaginationPayload
}

type ListTablesResponse

type ListTablesResponse struct {
	Tables []TableReference `json:"items"`
	PaginationResponse
}

type ListViewRowsParameters

type ListViewRowsParameters struct {
	Query          string `json:"query" url:"query"`
	SortBy         string `json:"sortBy" url:"sortBy"`
	UseColumnNames bool   `json:"useColumnNames" url:"useColumnNames"`
	ValueFormat    string `json:"valueFormat" url:"valueFormat"`
	PaginationPayload
}

type ListViewRowsResponse

type ListViewRowsResponse struct {
	Rows []Row `json:"items"`
	PaginationResponse
}

type ListViewsParameters

type ListViewsParameters struct {
	TableType string `url:"tableTypes"`
	PaginationPayload
}

type ListViewsResponse

type ListViewsResponse struct {
	Views []View `json:"items"`
	PaginationResponse
}

type MutationStatusResponse

type MutationStatusResponse struct {
	IsCompleted bool `json:"completed"`
}

type Page

type Page struct {
	PageReference
	Children []PageReference `json:"children"`
	Subtitle string          `json:"subtitle"`
	Icon     Icon            `json:"icon"`
	Image    Image           `json:"image"`
	Parent   PageReference   `json:"parent"`
}

type PageReference

type PageReference struct {
	Id          string `json:"id"`
	Type        string `json:"type"`
	BrowserLink string `json:"browserLink"`
	Href        string `json:"href"`
	Name        string `json:"name"`
}

type PaginationPayload

type PaginationPayload struct {
	Limit     int    `url:"limit,omitempty"`
	PageToken string `url:"pageToken,omitempty"`
}

type PaginationResponse

type PaginationResponse struct {
	Href          string `json:"href,omitempty"`
	NextPageToken string `json:"nextPageToken,omitempty"`
	NextPageLink  string `json:"nextPageLink,omitempty"`
}

type Permission

type Permission struct {
	Principal Principal `json:"principal"`
	Id        string    `json:"id"`
	Access    string    `json:"access"`
}

type Principal

type Principal struct {
	Email string `json:"email"`
	Type  string `json:"type"`
}

type PublishDocumentPayload

type PublishDocumentPayload struct {
	Slug          string   `json:"slug"`
	Discoverable  bool     `json:"discoverable"`
	EarnCredit    bool     `json:"earnCredit"`
	CategoryNames []string `json:"categoryNames"`
	Mode          string   `json:"mode"`
}

type PublishDocumentResponse

type PublishDocumentResponse struct {
	RequestId string `json:"requestId"`
}

type PushButtonResponse

type PushButtonResponse struct {
	RequestId string `json:"requestId"`
	RowId     string `json:"rowId"`
	ColumnId  string `json:"columnId"`
}

type RateLimitError

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

Rate Limit Error

func (RateLimitError) Error

func (e RateLimitError) Error() string

type RequestResponse

type RequestResponse struct {
	RequestId string `json:"requestId"`
	Id        string `json:"id"`
}

type ResolveBrowserLinkParameters

type ResolveBrowserLinkParameters struct {
	Url               string `json:"url" url:"url"`
	DegradeGracefully bool   `json:"degradeGracefully" url:"degradeGracefully,omitempty"`
}

type ResolveBrowserLinkResponse

type ResolveBrowserLinkResponse struct {
	Type        string   `json:"type"`
	Href        string   `json:"href"`
	Resource    Resource `json:"resource"`
	BrowserLink string   `json:"browserLink"`
}

type Resource

type Resource struct {
	Id   string `json:"id"`
	Href string `json:"href"`
	Type string `json:"type"`
	Name string `json:"name"`
}

type ResourceDeletedError

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

func (ResourceDeletedError) Error

func (e ResourceDeletedError) Error() string

type ResourceNotFoundError

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

func (ResourceNotFoundError) Error

func (e ResourceNotFoundError) Error() string

type Row

type Row struct {
	Id          string                 `json:"id"`
	Type        string                 `json:"type"`
	Href        string                 `json:"href"`
	Name        string                 `json:"name"`
	Index       int                    `json:"index"`
	BrowserLink string                 `json:"browserLink"`
	CreatedAt   string                 `json:"createdAt"`
	UpdatedAt   string                 `json:"updatedAt"`
	Values      map[string]interface{} `json:"values"`
	Parent      struct {
		Id   string `json:"id"`
		Type string `json:"type"`
		Href string `json"href"`
	} `json:"parent"`
}

type RowParam

type RowParam struct {
	Cells []CellParam `json:"cells"`
}

type RowQueryParams

type RowQueryParams struct {
	DisableParsing bool `url:"disableParsing"`
}

type Table

type Table struct {
	TableReference
	DisplayColumn Column `json:"displayColumn"`
	RowCount      int    `json:"rowCount"`
	Sorts         []struct {
		Column    Column `json:"column"`
		Direction string `json:"direction"`
	} `json:"sorts"`
	Layout      string         `json:"layout"`
	CreatedAt   string         `json:"createdAt"`
	UpdatedAt   string         `json:"updatedAt"`
	ParentTable TableReference `json:"parentTable"`
	Filter      TableFilter    `json:"filter"`
}

type TableFilter

type TableFilter struct {
	Valid           bool `json:"valid"`
	IsVolatile      bool `json:"isVolatile"`
	HasUserFormula  bool `json:"hasUserFormula"`
	HasTodayFormula bool `json:"hasTodayFormula"`
	HasNowFormula   bool `json:"hasNowFormula"`
}

type TableReference

type TableReference struct {
	Id          string        `json:"id"`
	Type        string        `json:"type"`
	TableType   string        `json:"tableType"`
	BrowserLink string        `json:"browserLink"`
	Href        string        `json:"href"`
	Name        string        `json:"name"`
	Parent      PageReference `json:"parent"`
}

type UnauthorizedError

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

func (UnauthorizedError) Error

func (e UnauthorizedError) Error() string

type UpdatePagePayload

type UpdatePagePayload struct {
	Name     string `json:"name"`
	Subtitle string `json:"subtitle"`
	IconName string `json:"iconName"`
	ImageUrl string `json:"imageUrl"`
}

type UpdateRowParameters

type UpdateRowParameters struct {
	Row RowParam `json:"row"`
}

type UpdateRowResponse

type UpdateRowResponse struct {
	Id        string `json:"id"`
	RequestId string `json:"requestId"`
}

type UserInfoResponse

type UserInfoResponse struct {
	Name        string `json:"name"`
	LoginId     string `json:"loginId"`
	Type        string `json:"type"`
	Scoped      bool   `json:"scoped"`
	TokenName   string `json:"tokenName"`
	Href        string `json:"href"`
	PictureLink string `json:"pictureLink"`
}

type View

type View struct {
	Id            string `json:"id"`
	Type          string `json:"type"`
	Href          string `json:"href"`
	Name          string `json:"name"`
	BrowserLink   string `json:"browserLink"`
	DisplayColumn Column `json:"displayColumn"`
	RowCount      int    `json:"rowCount"`
	Sorts         []struct {
		Column    Column `json:"column"`
		Direction string `json:"direction"`
	}
	Layout    string `json:"layout"`
	CreatedAt string `json:"createdAt"`
	UpdatedAt string `json:"updatedAt"`
}

Jump to

Keyboard shortcuts

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