endpoints

package
v0.0.0-...-e43fd8c Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2017 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PublicBorgSnippet = "borg"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Endpoints

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

Endpoints represents all endpoints of the http server

func NewEndpoints

func NewEndpoints(
	oauthCfg *oauth2.Config,
	client *elastic.Client,
	a *ga.Client,
	db *gorm.DB,
) *Endpoints

NewEndpoints is just below the http handlers

func (Endpoints) CreateOrganization

func (e Endpoints) CreateOrganization(
	db *gorm.DB,
	userId string,
	name string,
) (*domain.Organization, error)
func (e Endpoints) CreateOrganizationJoinLink(
	db *gorm.DB,
	userId string,
	organizationId string,
	ttl int64,
) (*domain.OrganizationJoinLink, error)

func (Endpoints) CreateSnippet

func (e Endpoints) CreateSnippet(snipp *types.Problem, index string, userId string) error

CreateSnippet saves a snippet, generates id

func (e Endpoints) DeleteOrganizationJoinLink(
	db *gorm.DB,
	userId string,
	organizationJoinLinkId string,
) error

func (Endpoints) ExpelUserFromOrganization

func (e Endpoints) ExpelUserFromOrganization(
	db *gorm.DB,
	userId string,
	userIdToExpel string,
	organizationId string,
) error

func (*Endpoints) GetLatestSnippets

func (e *Endpoints) GetLatestSnippets(index string) ([]types.Problem, error)

GetLatestSnippets in reverse chronological order

func (e Endpoints) GetOrganizationJoinLink(
	db *gorm.DB,
	organizationJoinLinkId string,
) (domain.OrganizationJoinLink, error)

func (Endpoints) GetOrganizationJoinLinkForOrganization

func (e Endpoints) GetOrganizationJoinLinkForOrganization(
	db *gorm.DB,
	userId string,
	organizationId string,
) (*domain.OrganizationJoinLink, error)

func (Endpoints) GetSnippet

func (e Endpoints) GetSnippet(index string, id string) (*types.Problem, error)

GetSnippet by id

func (*Endpoints) GetUser

func (e *Endpoints) GetUser(token string) (*domain.User, error)

GetUser by token

func (*Endpoints) GithubAuth

func (e *Endpoints) GithubAuth(code string) (*domain.User, *domain.AccessToken, error)

GithubAuth exchanges a github code for a token, registers and returns a User

func (Endpoints) GrantAdminRightToUser

func (e Endpoints) GrantAdminRightToUser(
	db *gorm.DB,
	userId string,
	userIdToAdmin string,
	organizationId string,
) error

func (Endpoints) JoinOrganization

func (e Endpoints) JoinOrganization(
	db *gorm.DB,
	userId string,
	organizationJoinLinkId string,
) error

func (Endpoints) LeaveOrganization

func (e Endpoints) LeaveOrganization(
	db *gorm.DB,
	userId string,
	organizationId string,
) error

func (Endpoints) ListUserOrganizations

func (e Endpoints) ListUserOrganizations(db *gorm.DB, userId string) ([]domain.Organization, error)

func (*Endpoints) Query

func (e *Endpoints) Query(q string, size int, private bool) ([]types.Problem, error)

Query the borg

func (Endpoints) Slack

func (e Endpoints) Slack(text string) (string, error)

TODO: Return a specific message if there is no results

func (Endpoints) UpdateSnippet

func (e Endpoints) UpdateSnippet(snipp *types.Problem, index string, userId string) error

UpdateSnippet saves a snippet

func (Endpoints) Worked

func (e Endpoints) Worked(id, query string) error

Worked tells the borg server that a result works for a given query

type SlackAttachments

type SlackAttachments struct {
	Title     string   `json:"title"`
	TitleLink string   `json:"title_link"`
	Text      string   `json:"text"`
	Mrkdwn_in []string `json:"mrkdwn_in"`
	Color     string   `json:"color"`
}

type SlackMessage

type SlackMessage struct {
	Text        string             `json:"text"`
	Mrkdwn      bool               `json:"mrkdwn"`
	Attachments []SlackAttachments `json:"attachments"`
}

TODO: Should I leave the structs here or move them to types package ?

Jump to

Keyboard shortcuts

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