api

package
v0.0.0-...-fcdd166 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2017 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAccessToken

func GetAccessToken(config *Config) (string, error)

func RemoveTokenInfos

func RemoveTokenInfos() error

func SaveTokenInfos

func SaveTokenInfos(infos *TokenInfos) error

Types

type ApiInfoResponse

type ApiInfoResponse struct {
	Name        string `json:name`
	Description string `json:description`
	Version     string `json:version`
	APIVersion  string `json:apiVersion`
	Env         string `json:env`
	Links       struct {
		AuthRealm *Href `json:"auth-realm"`
	} `json:"_links"`
}

type AuthRealmResponse

type AuthRealmResponse struct {
	Realm        string `json:realm`
	TokenService string `json:"token-service"`
}

func GetAuthRealm

func GetAuthRealm(authRealm string) (*AuthRealmResponse, error)

type Client

type Client struct {
	Config *Config
}

func NewAPIClient

func NewAPIClient(endpoint string) (*Client, error)

NewAPIClient returns new API client instance

func (*Client) CreateDocument

func (k *Client) CreateDocument(doc *DocumentResponse) (*DocumentResponse, error)

func (*Client) CreateJob

func (k *Client) CreateJob(job *JobRequest) (*JobResponse, error)

func (*Client) CreateLabel

func (k *Client) CreateLabel(label *LabelResponse) (*LabelResponse, error)

func (*Client) CreateWebhook

func (k *Client) CreateWebhook(webhook *WebhookResponse) (*WebhookResponse, error)

CreateWebhook Create a webhook

func (*Client) Delete

func (k *Client) Delete(url string, query *url.Values) (*http.Response, error)

Delete Trigger HTTP DELETE

func (*Client) DestroyDocument

func (k *Client) DestroyDocument(docid string) error

func (*Client) DestroyLabel

func (k *Client) DestroyLabel(id string) error

func (*Client) Do

func (k *Client) Do(r *Request) (*http.Response, error)

Do HTTP request

func (*Client) DownloadExport

func (k *Client) DownloadExport(out *os.File) error

DownloadExport Download export file

func (*Client) EmptyGraveyard

func (k *Client) EmptyGraveyard() error

func (*Client) Get

func (k *Client) Get(url string, query *url.Values) (*http.Response, error)

Get Trigger HTTP GET

func (*Client) GetApiInfo

func (k *Client) GetApiInfo() (*ApiInfoResponse, error)

func (*Client) GetDocument

func (k *Client) GetDocument(docid string) (*DocumentResponse, error)

func (*Client) GetDocuments

func (k *Client) GetDocuments(query string, order string, size int, from int) ([]DocumentResponse, error)

func (*Client) GetExportStatus

func (k *Client) GetExportStatus(out io.Writer) error

GetExportStatus Get export status

func (*Client) GetGraveyard

func (k *Client) GetGraveyard() ([]DocumentResponse, error)

func (*Client) GetJob

func (k *Client) GetJob(id string) (*JobResponse, error)

func (*Client) GetJobsInfos

func (k *Client) GetJobsInfos() (*JobsInfosResponse, error)

func (*Client) GetLabel

func (k *Client) GetLabel(id string) (*LabelResponse, error)

func (*Client) GetLabels

func (k *Client) GetLabels() ([]LabelResponse, error)

func (*Client) GetProfile

func (k *Client) GetProfile() (*ProfileResponse, error)

func (*Client) GetServerInfos

func (k *Client) GetServerInfos() (*ServerInfosResponse, error)

func (*Client) GetUser

func (k *Client) GetUser(uid string) (*UserResponse, error)

func (*Client) GetUsers

func (k *Client) GetUsers() ([]UserResponse, error)

func (*Client) GetWebhook

func (k *Client) GetWebhook(id string) (*WebhookResponse, error)

GetWebhook Get a webhook

func (*Client) GetWebhooks

func (k *Client) GetWebhooks() ([]WebhookResponse, error)

GetWebhooks Get webhook list

func (*Client) Login

func (k *Client) Login(username string, password string) (*TokenInfos, error)

func (*Client) Post

func (k *Client) Post(url string, query *url.Values, body io.Reader) (*http.Response, error)

Post Trigger HTTP POST

func (*Client) PostForm

func (k *Client) PostForm(url string, query *url.Values, form *url.Values) (*http.Response, error)

PostForm Trigger HTTP POST form

func (*Client) Put

func (k *Client) Put(url string, query *url.Values, body io.Reader) (*http.Response, error)

Put Trigger HTTP PUT

func (*Client) RemoveDocument

func (k *Client) RemoveDocument(docid string) error

func (*Client) RemoveLabel

func (k *Client) RemoveLabel(id string) error

func (*Client) RemoveWebhook

func (k *Client) RemoveWebhook(id string) error

RemoveWebhook Delete a webhook

func (*Client) RestoreDocument

func (k *Client) RestoreDocument(docid string) (*DocumentResponse, error)

func (*Client) RestoreLabel

func (k *Client) RestoreLabel(id string) (*LabelResponse, error)

func (*Client) ScheduleExport

func (k *Client) ScheduleExport() error

ScheduleExport Schedule a new export

func (*Client) UpdateWebhook

func (k *Client) UpdateWebhook(id string, webhook *WebhookResponse) (*WebhookResponse, error)

UpdateWebhook Update a webhook

type Config

type Config struct {
	Endpoint     string
	ClientId     string
	ClientSecret string
	Credentials  *TokenInfos
}

type Credentials

type Credentials struct {
	Username string
	Password string
}

type DocumentResponse

type DocumentResponse struct {
	Id          string `json:"id,omitempty"`
	Title       string `json:"title,omitempty"`
	Content     string `json:"content,omitempty"`
	ContentType string `json:"contentType,omitempty"`
	Origin      string `json:"origin,omitempty"`
	Date        string `json:"date,omitempty"`
	Owner       string `json:"owner,omitempty"`
	Ghost       bool   `json:"ghost,omitempty"`
}

type DocumentsResponse

type DocumentsResponse struct {
	Documents []DocumentResponse `json:"hits"`
}

type Href

type Href struct {
	Href string `json:href`
}

type JobRequest

type JobRequest struct {
	Type string      `json:"type"`
	Data interface{} `json:"data"`
}

type JobResponse

type JobResponse struct {
	Id        string      `json:"id"`
	Type      string      `json:"type"`
	Data      interface{} `json:"data"`
	Priority  int         `json:"priority"`
	Progress  string      `json:"progress"`
	State     string      `json:"state"`
	CreatedAt string      `json:"created_at"`
	UpdatedAt string      `json:"updated_at"`
	Duration  string      `json:"duration"`
}

type JobsInfosResponse

type JobsInfosResponse struct {
	InactiveCount int `json:"inactiveCount"`
	CompleteCount int `json:"completeCount"`
	ActiveCount   int `json:"activeCount"`
	FailedCount   int `json:"failedCount"`
	WorkTime      int `json:"workTime"`
}

type LabelResponse

type LabelResponse struct {
	Id    string `json:"id,omitempty"`
	Label string `json:"label,omitempty"`
	Color string `json:"color,omitempty"`
	Date  string `json:"date,omitempty"`
	Owner string `json:"owner,omitempty"`
	Ghost bool   `json:"ghost,omitempty"`
}

type LabelsResponse

type LabelsResponse struct {
	Labels []LabelResponse
}

type ProfileResponse

type ProfileResponse struct {
	Admin bool   `json:admin`
	Date  string `json:date`
	Hash  string `json:hash`
	Name  string `json:name`
	Uid   string `json:uid`
}

type Request

type Request struct {
	Method string
	Url    string
	Query  *url.Values
	Body   io.Reader
	Form   *url.Values
}

type ServerInfosResponse

type ServerInfosResponse struct {
	NbUsers     int `json:nbUsers`
	NbDocuments int `json:nbDocuments`
}

type TokenInfos

type TokenInfos struct {
	TokenService     string `json:"token_service"`
	TokenType        string `json:"token_type"`
	AccessToken      string `json:"access_token"`
	RefreshToken     string `json:"refresh_token"`
	ExpiresIn        int    `json:"expires_in"`
	RefreshExpiresIn int    `json:"refresh_expires_in"`
}

func GetOfflineToken

func GetOfflineToken(tokenServiceUrl string, creds *Credentials) (*TokenInfos, error)

func LoadTokenInfos

func LoadTokenInfos() (*TokenInfos, error)

type UserResponse

type UserResponse struct {
	Id           string `json:"id"`
	Uid          string `json:"uid"`
	Name         string `json:"name"`
	Date         string `json:"date"`
	NbDocuments  int    `json:"nbDocuments"`
	NbLabels     int    `json:"nbLabels"`
	NbSharing    int    `json:"nbSharing"`
	StorageUsage int    `json:"storageUsage"`
}

type WebhookResponse

type WebhookResponse struct {
	ID               string   `json:"id,omitempty"`
	Owner            string   `json:"owner,omitempty"`
	URL              string   `json:"url,omitempty"`
	Secret           string   `json:"secret,omitempty"`
	Active           bool     `json:"active,omitempty"`
	Events           []string `json:"events,omitempty"`
	Labels           []string `json:"labels,omitempty"`
	CreationDate     string   `json:"cdate,omitempty"`
	ModificationDate string   `json:"mdate,omitempty"`
}

WebhookResponse Webhook object response

type WebhooksResponse

type WebhooksResponse struct {
	Webhooks []WebhookResponse
}

WebhooksResponse Webhook list response

Jump to

Keyboard shortcuts

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