api

package
v0.0.0-...-bac1ed6 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2020 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package api implements the HTTP API of the bookmarks-application.

the purpose of this application is to provide bookmarks management independent of browsers

Terms Of Service:

Schemes: https
Host: bookmarks.binggl.net
BasePath: /api/v1
Version: 1.0.0
License: Apache 2.0 https://opensource.org/licenses/Apache-2.0

Consumes:
- application/json

Produces:
- application/json

swagger:meta

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BookMarkRequestSwagger

type BookMarkRequestSwagger struct {
	// In: body
	Body Bookmark
}

swagger:parameters CreateBookmark UpdateBookmark

type BookmarResultResponse

type BookmarResultResponse struct {
	*BookmarkResult
}

BookmarResultResponse returns BookmarResult

func (BookmarResultResponse) Render

Render the specific response

type Bookmark

type Bookmark struct {
	ID          string     `json:"id"`
	Path        string     `json:"path"`
	DisplayName string     `json:"displayName"`
	URL         string     `json:"url"`
	SortOrder   int        `json:"sortOrder"`
	Type        NodeType   `json:"type"`
	Created     time.Time  `json:"created"`
	Modified    *time.Time `json:"modified,omitempty"`
	ChildCount  int        `json:"childCount"`
	AccessCount int        `json:"accessCount"`
	Favicon     string     `json:"favicon"`
}

Bookmark is the model provided via the REST API swagger:model

type BookmarkList

type BookmarkList struct {
	Success bool       `json:"success"`
	Count   int        `json:"count"`
	Message string     `json:"message"`
	Value   []Bookmark `json:"value"`
}

BookmarkList is a collection of Bookmarks swagger:model

type BookmarkListResponse

type BookmarkListResponse struct {
	*BookmarkList
}

BookmarkListResponse returns a list of Bookmark Items

func (BookmarkListResponse) Render

Render the specific response

type BookmarkRequest

type BookmarkRequest struct {
	*Bookmark
}

BookmarkRequest is the request payload for Bookmark data model.

func (*BookmarkRequest) Bind

func (b *BookmarkRequest) Bind(r *http.Request) error

Bind assigns the the provided data to a BookmarkRequest

func (*BookmarkRequest) String

func (b *BookmarkRequest) String() string

String returns a string representation of a BookmarkRequest

type BookmarkResponse

type BookmarkResponse struct {
	*Bookmark
}

BookmarkResponse is the response payload for the Bookmark data model.

func (BookmarkResponse) Render

Render the specific response

type BookmarkResult

type BookmarkResult struct {
	Success bool     `json:"success"`
	Message string   `json:"message"`
	Value   Bookmark `json:"value"`
}

BookmarkResult has additional information about a Bookmark swagger:model

type BookmarksAPI

type BookmarksAPI struct {
	handler.Handler
	Repository     store.Repository
	BasePath       string
	FaviconPath    string
	DefaultFavicon string
}

BookmarksAPI implement the handler for the API

func (*BookmarksAPI) Create

func (b *BookmarksAPI) Create(user security.User, w http.ResponseWriter, r *http.Request) error

swagger:operation POST /api/v1/bookmarks bookmarks CreateBookmark

create a bookmark

use the supplied payload to create a new bookmark

--- consumes: - application/json produces: - application/json responses:

'200':
  description: Result
  schema:
    "$ref": "#/definitions/Result"
'400':
  description: ProblemDetail
  schema:
    "$ref": "#/definitions/ProblemDetail"
'401':
  description: ProblemDetail
  schema:
    "$ref": "#/definitions/ProblemDetail"
'403':
  description: ProblemDetail
  schema:
    "$ref": "#/definitions/ProblemDetail"

func (*BookmarksAPI) Delete

func (b *BookmarksAPI) Delete(user security.User, w http.ResponseWriter, r *http.Request) error

swagger:operation Delete /api/v1/bookmarks/{id} bookmarks DeleteBookmark

delete a bookmark

delete the bookmark identified by the supplied id

--- produces: - application/json parameters:

  • name: id in: path

responses:

'200':
  description: Result
  schema:
    "$ref": "#/definitions/Result"
'400':
  description: ProblemDetail
  schema:
    "$ref": "#/definitions/ProblemDetail"
'401':
  description: ProblemDetail
  schema:
    "$ref": "#/definitions/ProblemDetail"
'403':
  description: ProblemDetail
  schema:
    "$ref": "#/definitions/ProblemDetail"

func (*BookmarksAPI) FetchAndForward

func (b *BookmarksAPI) FetchAndForward(user security.User, w http.ResponseWriter, r *http.Request) error

swagger:operation GET /api/v1/bookmarks/fetch bookmarks FetchAndForward

forward to the bookmark

fetch the URL of the specified bookmark and forward to the destination

--- produces: - application/json parameters:

  • name: id in: path

responses:

'302':
  description: Found, redirect to URL
'400':
  description: ProblemDetail
  schema:
    "$ref": "#/definitions/ProblemDetail"
'404':
  description: ProblemDetail
  schema:
    "$ref": "#/definitions/ProblemDetail"
'401':
  description: ProblemDetail
  schema:
    "$ref": "#/definitions/ProblemDetail"
'403':
  description: ProblemDetail
  schema:
    "$ref": "#/definitions/ProblemDetail"

func (*BookmarksAPI) GetAllPaths

func (b *BookmarksAPI) GetAllPaths(user security.User, w http.ResponseWriter, r *http.Request) error

swagger:operation GET /api/v1/bookmarks/allpaths bookmarks GetAllPaths

return all paths

determine all available paths for the given user

--- produces: - application/json responses:

'200':
  description: BookmarksPathsResponse
  schema:
    "$ref": "#/definitions/BookmarksPathsResponse"
'400':
  description: ProblemDetail
  schema:
    "$ref": "#/definitions/ProblemDetail"
'404':
  description: ProblemDetail
  schema:
    "$ref": "#/definitions/ProblemDetail"
'401':
  description: ProblemDetail
  schema:
    "$ref": "#/definitions/ProblemDetail"
'403':
  description: ProblemDetail
  schema:
    "$ref": "#/definitions/ProblemDetail"

func (*BookmarksAPI) GetBookmarkByID

func (b *BookmarksAPI) GetBookmarkByID(user security.User, w http.ResponseWriter, r *http.Request) error

swagger:operation GET /api/v1/bookmarks/{id} bookmarks GetBookmarkByID

get a bookmark by id

returns a single bookmark specified by it's ID

--- produces: - application/json parameters:

  • name: id in: path

responses:

'200':
  description: Bookmark
  schema:
    "$ref": "#/definitions/Bookmark"
'400':
  description: ProblemDetail
  schema:
    "$ref": "#/definitions/ProblemDetail"
'404':
  description: ProblemDetail
  schema:
    "$ref": "#/definitions/ProblemDetail"
'401':
  description: ProblemDetail
  schema:
    "$ref": "#/definitions/ProblemDetail"
'403':
  description: ProblemDetail
  schema:
    "$ref": "#/definitions/ProblemDetail"

func (*BookmarksAPI) GetBookmarksByName

func (b *BookmarksAPI) GetBookmarksByName(user security.User, w http.ResponseWriter, r *http.Request) error

swagger:operation GET /api/v1/bookmarks/byname bookmarks GetBookmarksByName

get bookmarks by name

search for bookmarks by name and return a list of search-results

--- produces: - application/json parameters:

  • name: name in: query

responses:

'200':
  description: BookmarkList
  schema:
    "$ref": "#/definitions/BookmarkList"
'400':
  description: ProblemDetail
  schema:
    "$ref": "#/definitions/ProblemDetail"
'401':
  description: ProblemDetail
  schema:
    "$ref": "#/definitions/ProblemDetail"
'403':
  description: ProblemDetail
  schema:
    "$ref": "#/definitions/ProblemDetail"

func (*BookmarksAPI) GetBookmarksByPath

func (b *BookmarksAPI) GetBookmarksByPath(user security.User, w http.ResponseWriter, r *http.Request) error

swagger:operation GET /api/v1/bookmarks/bypath bookmarks GetBookmarksByPath

get bookmarks by path

returns a list of bookmarks for a given path

--- produces: - application/json parameters:

  • name: path in: query

responses:

'200':
  description: BookmarkList
  schema:
    "$ref": "#/definitions/BookmarkList"
'400':
  description: ProblemDetail
  schema:
    "$ref": "#/definitions/ProblemDetail"
'401':
  description: ProblemDetail
  schema:
    "$ref": "#/definitions/ProblemDetail"
'403':
  description: ProblemDetail
  schema:
    "$ref": "#/definitions/ProblemDetail"

func (*BookmarksAPI) GetBookmarksFolderByPath

func (b *BookmarksAPI) GetBookmarksFolderByPath(user security.User, w http.ResponseWriter, r *http.Request) error

swagger:operation GET /api/v1/bookmarks/folder bookmarks GetBookmarksFolderByPath

get bookmark folder by path

returns the folder identified by the given path

--- produces: - application/json parameters:

  • name: path in: query

responses:

'200':
  description: BookmarkResult
  schema:
    "$ref": "#/definitions/BookmarkResult"
'400':
  description: ProblemDetail
  schema:
    "$ref": "#/definitions/ProblemDetail"
'404':
  description: ProblemDetail
  schema:
    "$ref": "#/definitions/ProblemDetail"
'401':
  description: ProblemDetail
  schema:
    "$ref": "#/definitions/ProblemDetail"
'403':
  description: ProblemDetail
  schema:
    "$ref": "#/definitions/ProblemDetail"

func (*BookmarksAPI) GetFavicon

func (b *BookmarksAPI) GetFavicon(user security.User, w http.ResponseWriter, r *http.Request) error

swagger:operation GET /api/v1/bookmarks/favicon bookmarks GetFavicon

get the favicon from bookmark

return the stored favicon for the given bookmark or return the default favicon

--- produces: - application/json parameters:

  • name: id in: path

responses:

'200':
  description: Favicon as a file
'400':
  description: ProblemDetail
  schema:
    "$ref": "#/definitions/ProblemDetail"
'401':
  description: ProblemDetail
  schema:
    "$ref": "#/definitions/ProblemDetail"
'403':
  description: ProblemDetail
  schema:
    "$ref": "#/definitions/ProblemDetail"

func (*BookmarksAPI) GetMostVisited

func (b *BookmarksAPI) GetMostVisited(user security.User, w http.ResponseWriter, r *http.Request) error

swagger:operation GET /api/v1/bookmarks/mostvisited/{num} bookmarks GetMostVisited

get recent accessed bookmarks

return the most recently visited bookmarks

--- produces: - application/json parameters:

  • name: num in: path

responses:

'200':
  description: BookmarkList
  schema:
    "$ref": "#/definitions/BookmarkList"
'401':
  description: ProblemDetail
  schema:
    "$ref": "#/definitions/ProblemDetail"
'403':
  description: ProblemDetail
  schema:
    "$ref": "#/definitions/ProblemDetail"

func (*BookmarksAPI) Update

func (b *BookmarksAPI) Update(user security.User, w http.ResponseWriter, r *http.Request) error

swagger:operation PUT /api/v1/bookmarks bookmarks UpdateBookmark

update a bookmark

use the supplied payload to update a existing bookmark

--- consumes: - application/json produces: - application/json responses:

'200':
  description: Result
  schema:
    "$ref": "#/definitions/Result"
'400':
  description: ProblemDetail
  schema:
    "$ref": "#/definitions/ProblemDetail"
'401':
  description: ProblemDetail
  schema:
    "$ref": "#/definitions/ProblemDetail"
'403':
  description: ProblemDetail
  schema:
    "$ref": "#/definitions/ProblemDetail"

func (*BookmarksAPI) UpdateSortOrder

func (b *BookmarksAPI) UpdateSortOrder(user security.User, w http.ResponseWriter, r *http.Request) error

swagger:operation PUT /api/v1/bookmarks/sortorder bookmarks UpdateSortOrder

change the sortorder of bookmarks

provide a new sortorder for a list of IDS

--- consumes: - application/json produces: - application/json responses:

'200':
  description: Result
  schema:
    "$ref": "#/definitions/Result"
'400':
  description: ProblemDetail
  schema:
    "$ref": "#/definitions/ProblemDetail"
'401':
  description: ProblemDetail
  schema:
    "$ref": "#/definitions/ProblemDetail"
'403':
  description: ProblemDetail
  schema:
    "$ref": "#/definitions/ProblemDetail"

type BookmarksPathsResponse

type BookmarksPathsResponse struct {
	Paths []string `json:"paths"`
	Count int      `json:"count"`
}

BookmarksPathsResponse returns available Paths swagger:model

func (BookmarksPathsResponse) Render

Render the specific response

type BookmarksSortOrder

type BookmarksSortOrder struct {
	IDs       []string `json:"ids"`
	SortOrder []int    `json:"sortOrder"`
}

BookmarksSortOrder contains a sorting for a list of ids swagger:model

type BookmarksSortOrderRequest

type BookmarksSortOrderRequest struct {
	*BookmarksSortOrder
}

BookmarksSortOrderRequest is the request payload for Bookmark data model.

func (*BookmarksSortOrderRequest) Bind

Bind assigns the the provided data to a BookmarksSortOrderRequest

func (*BookmarksSortOrderRequest) String

func (b *BookmarksSortOrderRequest) String() string

String returns a string representation of a BookmarkRequest

type BookmarksSortOrderRequestSwagger

type BookmarksSortOrderRequestSwagger struct {
	// In: body
	Body BookmarksSortOrder
}

swagger:parameters UpdateSortOrder

type NodeType

type NodeType string

available node-types swagger:enum NodeType

const (
	Node   NodeType = "Node"
	Folder NodeType = "Folder"
)

type Result

type Result struct {
	Success bool   `json:"success"`
	Message string `json:"message"`
	Value   string `json:"value"`
}

Result is a generic response with a string value swagger:model

type ResultResponse

type ResultResponse struct {
	*Result
	Status int `json:"-"` // ignore this
}

ResultResponse returns Result

func (ResultResponse) Render

Render the specific response

Jump to

Keyboard shortcuts

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