rest

package
v0.0.0-...-d386c04 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2024 License: BSD-3-Clause Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotStarted     = errors.New("SERVICE.SDK_API.NOT_STARTED")
	ErrAlreadyStarted = errors.New("SERVICE.SDK_API.ALREAD_STARTED")
)
View Source
var AuthzEngineInternal = "sdk.internal"

Functions

func RegisterAccountRoutes

func RegisterAccountRoutes(router gin.IRoutes, service *sdk)

func RegisterApplicationRoutes

func RegisterApplicationRoutes(router gin.IRoutes, service *sdk)

func RegisterEndpointRoutes

func RegisterEndpointRoutes(router gin.IRoutes, service *sdk)

func RegisterEndpointRuleRoutes

func RegisterEndpointRuleRoutes(router gin.IRoutes, service *sdk)

func RegisterHealthcheck

func RegisterHealthcheck(router gin.IRoutes, service *sdk)

func RegisterMessageRoutes

func RegisterMessageRoutes(router gin.IRoutes, service *sdk)

func RegisterWorkspaceResolver

func RegisterWorkspaceResolver(uc usecase.Sdk) func(ctx context.Context, acc *authenticator.Account, id string) (*entities.Workspace, error)

func UseAccountGet

func UseAccountGet(service *sdk) gin.HandlerFunc

UseAccountGet @Tags account @Router /account/me [get] @Success 200 {object} AccountGetRes @Failure default {object} gateway.Err @Security Authorization

func UseApplicationCreate

func UseApplicationCreate(service *sdk) gin.HandlerFunc

UseApplicationCreate @Tags application @Router /application [post] @Param payload body ApplicationCreateReq true "application payload" @Success 201 {object} ApplicationCreateRes @Failure default {object} gateway.Err @Security Authorization @Security WorkspaceId

func UseApplicationDelete

func UseApplicationDelete(service *sdk) gin.HandlerFunc

UseApplicationDelete @Tags application @Router /application/{app_id} [delete] @Param app_id path string true "application id" @Success 200 {object} ApplicationDeleteRes @Failure default {object} gateway.Err @Security Authorization @Security WorkspaceId

func UseApplicationGet

func UseApplicationGet(service *sdk) gin.HandlerFunc

UseApplicationGet @Tags application @Router /application/{app_id} [get] @Param app_id path string true "application id" @Success 200 {object} ApplicationGetRes @Failure default {object} gateway.Err @Security Authorization @Security WorkspaceId

func UseApplicationList

func UseApplicationList(service *sdk) gin.HandlerFunc

UseApplicationList @Tags application @Router /application [get] @Param id query []string false "list by ids" @Param _q query string false "search keyword" @Param _limit query int false "limit returning records" default(10) @Param _page query int false "current requesting page" default(0) @Success 200 {object} ApplicationListRes @Failure default {object} gateway.Err @Security Authorization @Security WorkspaceId

func UseApplicationUpdate

func UseApplicationUpdate(service *sdk) gin.HandlerFunc

UseApplicationUpdate @Tags application @Router /application/{app_id} [patch] @Param app_id path string true "application id" @Param payload body ApplicationUpdateReq true "application payload" @Success 200 {object} ApplicationUpdateRes @Failure default {object} gateway.Err @Security Authorization @Security WorkspaceId

func UseEndpointCreate

func UseEndpointCreate(service *sdk) gin.HandlerFunc

UseEndpointCreate @Tags endpoint @Router /endpoint [post] @Param payload body EndpointCreateReq true "endpoint payload" @Success 201 {object} EndpointCreateRes @Failure default {object} gateway.Err @Security Authorization @Security WorkspaceId

func UseEndpointDelete

func UseEndpointDelete(service *sdk) gin.HandlerFunc

UseEndpointDelete @Tags endpoint @Router /endpoint/{ep_id} [delete] @Param ep_id path string true "endpoint id" @Success 200 {object} EndpointDeleteRes @Failure default {object} gateway.Err @Security Authorization @Security WorkspaceId

func UseEndpointGet

func UseEndpointGet(service *sdk) gin.HandlerFunc

UseEndpointGet @Tags endpoint @Router /endpoint/{ep_id} [get] @Param ep_id path string true "endpoint id" @Success 200 {object} EndpointGetRes @Failure default {object} gateway.Err @Security Authorization @Security WorkspaceId

func UseEndpointGetSecret

func UseEndpointGetSecret(service *sdk) gin.HandlerFunc

UseEndpointGetSecret @Tags endpoint @Router /endpoint/{ep_id}/secret [get] @Param ep_id path string true "endpoint id" @Success 200 {object} EndpointGetSecretRes @Failure default {object} gateway.Err @Security Authorization @Security WorkspaceId

func UseEndpointList

func UseEndpointList(service *sdk) gin.HandlerFunc

UseEndpointList @Tags endpoint @Router /endpoint [get] @Param app_id query string false "application id" @Param id query []string false "list by ids" @Param _q query string false "search keyword" @Param _limit query int false "limit returning records" default(10) @Param _page query int false "current requesting page" default(0) @Success 200 {object} EndpointListRes @Failure default {object} gateway.Err @Security Authorization @Security WorkspaceId

func UseEndpointRuleCreate

func UseEndpointRuleCreate(service *sdk) gin.HandlerFunc

UseEndpointRuleCreate @Tags endpoint rule @Router /rule [post] @Param payload body EndpointRuleCreateReq true "rule payload" @Success 201 {object} EndpointRuleCreateRes @Failure default {object} gateway.Err @Security Authorization @Security WorkspaceId

func UseEndpointRuleDelete

func UseEndpointRuleDelete(service *sdk) gin.HandlerFunc

UseEndpointRuleDelete @Tags endpoint rule @Router /rule/{epr_id} [delete] @Param epr_id path string true "rule id" @Success 200 {object} EndpointRuleDeleteRes @Failure default {object} gateway.Err @Security Authorization @Security WorkspaceId

func UseEndpointRuleGet

func UseEndpointRuleGet(service *sdk) gin.HandlerFunc

UseEndpointRuleGet @Tags endpoint rule @Router /rule/{epr_id} [get] @Param epr_id path string true "rule id" @Success 200 {object} EndpointRuleGetRes @Failure default {object} gateway.Err @Security Authorization @Security WorkspaceId

func UseEndpointRuleList

func UseEndpointRuleList(service *sdk) gin.HandlerFunc

UseEndpointRuleList @Tags endpoint rule @Router /rule [get] @Param app_id query string false "application id" @Param ep_id query string false "endpoint id" @Param id query []string false "list by ids" @Param _q query string false "search keyword" @Param _limit query int false "limit returning records" default(10) @Param _page query int false "current requesting page" default(0) @Success 200 {object} EndpointRuleListRes @Failure default {object} gateway.Err @Security Authorization @Security WorkspaceId

func UseEndpointRuleUpdate

func UseEndpointRuleUpdate(service *sdk) gin.HandlerFunc

UseEndpointRuleUpdate @Tags endpoint rule @Router /rule/{epr_id} [patch] @Param epr_id path string true "rule id" @Param payload body EndpointRuleUpdateReq true "rule payload" @Success 200 {object} EndpointRuleUpdateRes @Failure default {object} gateway.Err @Security Authorization @Security WorkspaceId

func UseEndpointUpdate

func UseEndpointUpdate(service *sdk) gin.HandlerFunc

UseEndpointUpdate @Tags endpoint @Router /endpoint/{ep_id} [patch] @Param ep_id path string true "endpoint id" @Param payload body EndpointUpdateReq true "endpoint payload" @Success 200 {object} EndpointUpdateRes @Failure default {object} gateway.Err @Security Authorization @Security WorkspaceId

func UseMessageCreate

func UseMessageCreate(service *sdk) gin.HandlerFunc

UseMessageCreate @Tags message @Router /message [post] @Param payload body MessageCreateReq true "message payload" @Success 201 {object} MessageCreateRes @Failure default {object} gateway.Err @Security Authorization @Security WorkspaceId

Types

type Account

type Account struct {
	Sub      string            `json:"sub"`
	Name     string            `json:"name"`
	Metadata map[string]string `json:"metadata"`

} // @name Account

func ToAccount

func ToAccount(acc *authenticator.Account) *Account

type AccountGetRes

type AccountGetRes struct {
	Account *Account `json:"account"`

} // @name AccountGetRes

type Application

type Application struct {
	Id        string `json:"id"`
	CreatedAt int64  `json:"created_at"`
	UpdatedAt int64  `json:"updated_at"`
	WsId      string `json:"ws_id"`
	Name      string `json:"name"`

} // @name Application

func ToApplication

func ToApplication(doc *entities.Application) *Application

type ApplicationCreateReq

type ApplicationCreateReq struct {
	Name string `json:"name" default:"openapi"`

} // @name ApplicationCreateReq

type ApplicationCreateRes

type ApplicationCreateRes struct {
	*Application

} // @name ApplicationCreateRes

type ApplicationDeleteRes

type ApplicationDeleteRes struct {
	*Application

} // @name ApplicationDeleteRes

type ApplicationGetRes

type ApplicationGetRes struct {
	*Application

} // @name ApplicationGetRes

type ApplicationListRes

type ApplicationListRes struct {
	Data  []Application `json:"data"`
	Count int64         `json:"count"`

} // @name ApplicationListRes

type ApplicationUpdateReq

type ApplicationUpdateReq struct {
	Name string `json:"name"`

} // @name ApplicationUpdateReq

type ApplicationUpdateRes

type ApplicationUpdateRes struct {
	*Application

} // @name ApplicationUpdateRes

type Endpoint

type Endpoint struct {
	Id        string `json:"id"`
	CreatedAt int64  `json:"created_at"`
	UpdatedAt int64  `json:"updated_at"`
	AppId     string `json:"app_id"`
	Name      string `json:"name"`
	Method    string `json:"method"`
	Uri       string `json:"uri"`

} // @name Endpoint

func ToEndpoint

func ToEndpoint(doc *entities.Endpoint) *Endpoint

type EndpointCreateReq

type EndpointCreateReq struct {
	AppId string `json:"app_id"`
	Name  string `json:"name" default:"POST httpbin"`

	Method string `json:"method" example:"POST"`
	Uri    string `json:"uri" example:"https://httpbin.org/post"`

} // @name EndpointCreateReq

type EndpointCreateRes

type EndpointCreateRes struct {
	*Endpoint
	// To make the UI become friendly we will return the secret key after user create the new endpoint
	// but we don't want to return that key everytime user request for the endpoint
	// user must have specific permission to reveal the secret key of an endpoint
	SecretKey string `json:"secret_key"`

} // @name EndpointCreateRes

type EndpointDeleteRes

type EndpointDeleteRes struct {
	*Endpoint

} // @name EndpointDeleteRes

type EndpointGetRes

type EndpointGetRes struct {
	*Endpoint

} // @name EndpointGetRes

type EndpointGetSecretRes

type EndpointGetSecretRes struct {
	SecretKey string `json:"secret_key"`

} // @name EndpointGetSecretRes

type EndpointListRes

type EndpointListRes struct {
	Data  []Endpoint `json:"data"`
	Count int64      `json:"count"`

} // @name EndpointListRes

type EndpointRule

type EndpointRule struct {
	Id                  string `json:"id"`
	CreatedAt           int64  `json:"created_at"`
	UpdatedAt           int64  `json:"updated_at"`
	EpId                string `json:"ep_id"`
	Name                string `json:"name"`
	Priority            int32  `json:"priority"`
	Exclusionary        bool   `json:"exclusionary"`
	ConditionSource     string `json:"condition_source"`
	ConditionExpression string `json:"condition_expression"`

} // @name EndpointRule

func ToEndpointRule

func ToEndpointRule(doc *entities.EndpointRule) *EndpointRule

type EndpointRuleCreateReq

type EndpointRuleCreateReq struct {
	EpId string `json:"ep_id"`
	Name string `json:"name" default:"passthrough"`

	Priority            int32  `json:"priority" default:"100"`
	Exclusionary        bool   `json:"exclusionary" default:"false"`
	ConditionSource     string `json:"condition_source" default:"type"`
	ConditionExpression string `json:"condition_expression" default:"any::"`

} // @name EndpointRuleCreateReq

type EndpointRuleCreateRes

type EndpointRuleCreateRes struct {
	*EndpointRule

} // @name EndpointRuleCreateRes

type EndpointRuleDeleteRes

type EndpointRuleDeleteRes struct {
	*EndpointRule

} // @name EndpointRuleDeleteRes

type EndpointRuleGetRes

type EndpointRuleGetRes struct {
	*EndpointRule

} // @name EndpointRuleGetRes

type EndpointRuleListRes

type EndpointRuleListRes struct {
	Data  []EndpointRule `json:"data"`
	Count int64          `json:"count"`

} // @name EndpointRuleListRes

type EndpointRuleUpdateReq

type EndpointRuleUpdateReq struct {
	Name string `json:"name"`

	Priority            int32  `json:"priority"`
	Exclusionary        bool   `json:"exclusionary"`
	ConditionSource     string `json:"condition_source"`
	ConditionExpression string `json:"condition_expression"`

} // @name EndpointRuleUpdateReq

type EndpointRuleUpdateRes

type EndpointRuleUpdateRes struct {
	*EndpointRule

} // @name EndpointRuleUpdateRes

type EndpointUpdateReq

type EndpointUpdateReq struct {
	Name   string `json:"name"`
	Method string `json:"method"`

} // @name EndpointUpdateReq

type EndpointUpdateRes

type EndpointUpdateRes struct {
	*Endpoint

} // @name EndpointUpdateRes

type MessageCreateReq

type MessageCreateReq struct {
	AppId string `json:"app_id"`
	Type  string `json:"type" example:"testing.debug"`

	Body    string            `json:"body" default:"{\"ping\":true}"`
	Headers map[string]string `json:"headers"`

} // @name MessageCreateReq

type MessageCreateRes

type MessageCreateRes struct {
	Id string `json:"id"`

} // @name MessageCreateRes

Jump to

Keyboard shortcuts

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