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: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotStarted     = errors.New("SERVICE.PORTAL_API.NOT_STARTED")
	ErrAlreadyStarted = errors.New("SERVICE.PORTAL_API.ALREAD_STARTED")
)

Functions

func FromWorkspaceSnapshot

func FromWorkspaceSnapshot(snapshot *WorkspaceSnapshot, id string) *entities.WorkspaceSnapshot

func RegisterAccountRoutes

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

func RegisterAnalyticsRoutes

func RegisterAnalyticsRoutes(router gin.IRoutes, service *portal)

func RegisterApplicationRoutes

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

func RegisterEndpointRoutes

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

func RegisterHealthcheck

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

func RegisterWorkspaceCredentialsRoutes

func RegisterWorkspaceCredentialsRoutes(router gin.IRoutes, service *portal)

func RegisterWorkspaceResolver

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

func RegisterWorkspaceRoutes

func RegisterWorkspaceRoutes(router gin.IRoutes, service *portal)

func UseAccountGet

func UseAccountGet(service *portal) gin.HandlerFunc

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

func UseAnalyticsGetOverview

func UseAnalyticsGetOverview(service *portal) gin.HandlerFunc

UseAnalyticsGetOverview @Tags analytics @Router /analytics/overview [get] @Success 200 {object} AnalyticsGetOverviewRes @Failure default {object} gateway.Err @Security Authorization @Security WorkspaceId

func UseApplicationGetMessage

func UseApplicationGetMessage(service *portal) gin.HandlerFunc

UseApplicationGetMessage @Tags application @Router /application/{app_id}/message/{msg_id} [get] @Success 200 {object} ApplicationGetMessageRes @Failure default {object} gateway.Err @Security Authorization @Security WorkspaceId

func UseApplicationListMessage

func UseApplicationListMessage(service *portal) gin.HandlerFunc

UseApplicationListMessage @Tags application @Router /application/{app_id}/message [get] @Param _limit query int false "limit returning records" default(10) @Param _start query int64 false "starting time to scan in milliseconds" example(1669914060000) @Param _end query int64 false "ending time to scan in milliseconds" example(1985533260000) @Success 200 {object} ApplicationListMessageRes @Failure default {object} gateway.Err @Security Authorization @Security WorkspaceId

func UseEndpointGetMessage

func UseEndpointGetMessage(service *portal) gin.HandlerFunc

UseEndpointGetMessage @Tags endpoint @Router /endpoint/{ep_id}/message/{msg_id} [get] @Success 200 {object} EndpointGetMessageRes @Failure default {object} gateway.Err @Security Authorization @Security WorkspaceId

func UseEndpointListMessage

func UseEndpointListMessage(service *portal) gin.HandlerFunc

UseEndpointListMessage @Tags endpoint @Router /endpoint/{ep_id}/message [get] @Param _limit query int false "limit returning records" default(10) @Param _start query int64 false "starting time to scan in milliseconds" example(1669914060000) @Param _end query int64 false "ending time to scan in milliseconds" example(1985533260000) @Success 200 {object} EndpointListMessageRes @Failure default {object} gateway.Err @Security Authorization @Security WorkspaceId

func UseWorkspaceCreate

func UseWorkspaceCreate(service *portal) gin.HandlerFunc

UseWorkspaceCreate @Tags workspace @Router /workspace [post] @Param payload body WorkspaceCreateReq true "workspace payload" @Success 200 {object} WorkspaceCreateRes @Failure default {object} gateway.Err @Security Authorization

func UseWorkspaceCredentialsCreate

func UseWorkspaceCredentialsCreate(service *portal) gin.HandlerFunc

UseWorkspaceCredentialsCreate @Tags credentials @Router /credentials [post] @Param payload body WorkspaceCredentialsCreateReq true "credentials payload" @Success 200 {object} WorkspaceCredentialsCreateRes @Failure default {object} gateway.Err @Security Authorization @Security WorkspaceId

func UseWorkspaceCredentialsExpire

func UseWorkspaceCredentialsExpire(service *portal) gin.HandlerFunc

UseWorkspaceCredentialsExpire @Tags credentials @Router /credentials/{wsc_id}/expiration [put] @Param wsc_id path string true "credentials id" @Param payload body WorkspaceCredentialsExpireReq true "credentials payload" @Success 200 {object} WorkspaceCredentialsExpireRes @Failure default {object} gateway.Err @Security Authorization @Security WorkspaceId

func UseWorkspaceCredentialsGet

func UseWorkspaceCredentialsGet(service *portal) gin.HandlerFunc

UseWorkspaceCredentialsGet @Tags credentials @Router /credentials/{wsc_id} [get] @Param wsc_id path string true "credentials id" @Success 200 {object} WorkspaceCredentialsGetRes @Failure default {object} gateway.Err @Security Authorization @Security WorkspaceId

func UseWorkspaceCredentialsList

func UseWorkspaceCredentialsList(service *portal) gin.HandlerFunc

UseWorkspaceCredentialsList @Tags credentials @Router /credentials [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 "requesting page" default(0) @Success 200 {object} WorkspaceCredentialsListRes @Failure default {object} gateway.Err @Security Authorization @Security WorkspaceId

func UseWorkspaceCredentialsUpdate

func UseWorkspaceCredentialsUpdate(service *portal) gin.HandlerFunc

UseWorkspaceCredentialsUpdate @Tags credentials @Router /credentials/{wsc_id} [patch] @Param wsc_id path string true "credentials id" @Param payload body WorkspaceCredentialsUpdateReq true "credentials payload" @Success 200 {object} WorkspaceCredentialsUpdateRes @Failure default {object} gateway.Err @Security Authorization @Security WorkspaceId

func UseWorkspaceExport

func UseWorkspaceExport(service *portal) gin.HandlerFunc

UseWorkspaceExport @Tags workspace @Router /workspace/{ws_id}/transfer [get] @Param ws_id path string true "workspace id" @Success 200 {object} WorkspaceExportRes @Failure default {object} gateway.Err @Security Authorization

func UseWorkspaceGet

func UseWorkspaceGet(service *portal) gin.HandlerFunc

UseWorkspaceGet @Tags workspace @Router /workspace/{ws_id} [get] @Param ws_id path string true "workspace id" @Success 200 {object} WorkspaceGetRes @Failure default {object} gateway.Err @Security Authorization

func UseWorkspaceImport

func UseWorkspaceImport(service *portal) gin.HandlerFunc

UseWorkspaceImport @Tags workspace @Router /workspace/{ws_id}/transfer [post] @Param ws_id path string true "workspace id" @Param payload body WorkspaceImportReq true "import payload" @Success 200 {object} WorkspaceImportRes @Failure default {object} gateway.Err @Security Authorization

func UseWorkspaceList

func UseWorkspaceList(service *portal) gin.HandlerFunc

UseWorkspaceList @Tags workspace @Router /workspace [get] @Success 200 {object} WorkspaceGetRes @Failure default {object} gateway.Err @Security Authorization

func UseWorkspaceUpdate

func UseWorkspaceUpdate(service *portal) gin.HandlerFunc

UseWorkspaceUpdate @Tags workspace @Router /workspace/{ws_id} [patch] @Param ws_id path string true "workspace id" @Param payload body WorkspaceUpdateReq true "workspace payload" @Success 200 {object} WorkspaceUpdateRes @Failure default {object} gateway.Err @Security Authorization

Types

type AccountGetRes

type AccountGetRes struct {
	Account    *authenticator.Account `json:"account"`
	Workspaces []Workspace            `json:"workspaces"`

} // @name AccountGetRes

type AnalyticsGetOverviewRes

type AnalyticsGetOverviewRes struct {
	CredentialsCount int64 `json:"credentials_count"`
	ApplicationCount int64 `json:"application_count"`
	EndpointCount    int64 `json:"endpoint_count"`
	RuleCount        int64 `json:"rule_count"`

} // @name AnalyticsGetOverviewRes

type ApplicationGetMessageRes

type ApplicationGetMessageRes struct {
	*Message

} // @name ApplicationGetMessageRes

type ApplicationListMessageRes

type ApplicationListMessageRes struct {
	Data []Message `json:"data"`

} // @name ApplicationListMessageRes

type EndpointGetMessageRes

type EndpointGetMessageRes struct {
	*EndpointMessage

} // @name EndpointGetMessageRes

type EndpointListMessageRes

type EndpointListMessageRes struct {
	Data []EndpointMessage `json:"data"`

} // @name EndpointListMessageRes

type EndpointMessage

type EndpointMessage struct {
	*Message

	RequestCount     int    `json:"request_count"`
	RequestLatestTs  int64  `json:"request_latest_ts"`
	ResponseCount    int    `json:"response_count"`
	ResponseLatestTs int64  `json:"response_latest_ts"`
	SuccessId        string `json:"success_id"`

	Requests  []Request  `json:"requests"`
	Responses []Response `json:"responses"`

} // @name EndpointMessage

func ToEndpointMessage

func ToEndpointMessage(doc *entities.EndpointMessage, requests []entities.Request, responses []entities.Response) *EndpointMessage

type Message

type Message struct {
	Id        string `json:"id"`
	Timestamp int64  `json:"timestamp"`

	AppId    string `json:"app_id"`
	Type     string `json:"type"`
	Metadata string `json:"metadata"`

	Headers string `json:"headers"`
	Body    string `json:"body"`

} // @name Message

func ToMessage

func ToMessage(doc *entities.Message) *Message

type Request

type Request struct {
	Id        string `json:"id"`
	Timestamp int64  `json:"timestamp"`
	EpId      string `json:"ep_id"`
	MsgId     string `json:"msg_id"`

	AppId    string `json:"app_id"`
	Type     string `json:"type"`
	Metadata string `json:"metadata"`

	Headers string `json:"headers"`
	Body    string `json:"body"`
	Uri     string `json:"uri"`
	Method  string `json:"method"`

} // @name Request

type Response

type Response struct {
	Id        string `json:"id"`
	Timestamp int64  `json:"timestamp"`
	EpId      string `json:"ep_id"`
	MsgId     string `json:"msg_id"`
	ReqId     string `json:"req_id"`

	AppId    string `json:"app_id"`
	Type     string `json:"type"`
	Metadata string `json:"metadata"`

	Headers string `json:"headers"`
	Body    string `json:"body"`
	Uri     string `json:"uri"`
	Status  int    `json:"status"`
	Error   string `json:"error"`

} // @name Response

type Workspace

type Workspace struct {
	Id        string `json:"id"`
	CreatedAt int64  `json:"created_at"`
	UpdatedAt int64  `json:"updated_at"`

	OwnerId string `json:"owner_id"`
	Name    string `json:"name"`
	Tier    string `json:"tier"`

} // @name Workspace

func ToWorkspace

func ToWorkspace(doc *entities.Workspace) *Workspace

type WorkspaceCreateReq

type WorkspaceCreateReq struct {
	Name string `json:"name" default:"main"`

} // @name WorkspaceCreateReq

type WorkspaceCreateRes

type WorkspaceCreateRes struct {
	*Workspace

} // @name WorkspaceCreateRes

type WorkspaceCredentials

type WorkspaceCredentials struct {
	Id        string `json:"id"`
	CreatedAt int64  `json:"created_at"`
	UpdatedAt int64  `json:"updated_at"`

	WsId      string `json:"ws_id"`
	Name      string `json:"name"`
	ExpiredAt int64  `json:"expired_at"`

} // @name WorkspaceCredentials

type WorkspaceCredentialsCreateReq

type WorkspaceCredentialsCreateReq struct {
	Name      string `json:"name" default:"swagger demo"`
	ExpiredAt int64  `json:"expired_at" default:"1893456000000"`

} // @name WorkspaceCredentialsCreateReq

type WorkspaceCredentialsCreateRes

type WorkspaceCredentialsCreateRes struct {
	Id       string `json:"id"`
	Name     string `json:"name"`
	User     string `json:"user"`
	Password string `json:"password"`

} // @name WorkspaceCredentialsCreateRes

type WorkspaceCredentialsExpireReq

type WorkspaceCredentialsExpireReq struct {
	Duration int64 `json:"duration" default:"1800000"`

} // @name WorkspaceCredentialsExpireReq

type WorkspaceCredentialsExpireRes

type WorkspaceCredentialsExpireRes struct {
	Id        string `json:"id"`
	ExpiredAt int64  `json:"expired_at"`

} // @name WorkspaceCredentialsExpireRes

type WorkspaceCredentialsGetRes

type WorkspaceCredentialsGetRes struct {
	*WorkspaceCredentials

} // @name WorkspaceCredentialsGetRes

type WorkspaceCredentialsListRes

type WorkspaceCredentialsListRes struct {
	Data  []WorkspaceCredentials `json:"data"`
	Count int64                  `json:"count"`

} // @name WorkspaceCredentialsListRes

type WorkspaceCredentialsUpdateReq

type WorkspaceCredentialsUpdateReq struct {
	Name      string `json:"name" default:"swagger demo update"`
	ExpiredAt int64  `json:"expired_at" default:"1893456000000"`

} // @name WorkspaceCredentialsUpdateReq

type WorkspaceCredentialsUpdateRes

type WorkspaceCredentialsUpdateRes struct {
	*WorkspaceCredentials

} // @name WorkspaceCredentialsUpdateRes

type WorkspaceExportRes

type WorkspaceExportRes struct {
	*WorkspaceSnapshot

} // @name WorkspaceExportRes

type WorkspaceGetRes

type WorkspaceGetRes struct {
	*Workspace

} // @name WorkspaceGetRes

type WorkspaceImportReq

type WorkspaceImportReq struct {
	Snapshot *WorkspaceSnapshot `json:"snapshot" form:"snapshot" binding:"required"`

} // @name WorkspaceImportReq

type WorkspaceImportRes

type WorkspaceImportRes struct {
	AppIds []string `json:"app_id"`
	EpIds  []string `json:"ep_id"`
	EprIds []string `json:"epr_id"`

} // @name WorkspaceImportRes

type WorkspaceListRes

type WorkspaceListRes struct {
	Data  []Workspace `json:"data"`
	Count int64       `json:"count"`

} // @name WorkspaceListRes

type WorkspaceSnapshot

type WorkspaceSnapshot struct {
	Name         string                 `json:"name"`
	Applications []WorkspaceSnapshotApp `json:"applications"`

} // @name WorkspaceSnapshot

func ToWorkspaceSnapshot

func ToWorkspaceSnapshot(snapshot *entities.WorkspaceSnapshot) *WorkspaceSnapshot

type WorkspaceSnapshotApp

type WorkspaceSnapshotApp struct {
	Name      string                `json:"name"`
	Endpoints []WorkspaceSnapshotEp `json:"endpoints"`

} // @name WorkspaceSnapshotApp

type WorkspaceSnapshotEp

type WorkspaceSnapshotEp struct {
	Name   string                 `json:"name"`
	Method string                 `json:"method"`
	Uri    string                 `json:"uri"`
	Rules  []WorkspaceSnapshotEpr `json:"rules"`

} // @name WorkspaceSnapshotEp

type WorkspaceSnapshotEpr

type WorkspaceSnapshotEpr struct {
	Name                string `json:"name"`
	Priority            int32  `json:"priority"`
	Exclusionary        bool   `json:"exclusionary"`
	ConditionSource     string `json:"condition_source"`
	ConditionExpression string `json:"condition_expression"`

} // @name WorkspaceSnapshotEpr

type WorkspaceUpdateReq

type WorkspaceUpdateReq struct {
	Name string `json:"name" example:"another name"`

} // @name WorkspaceUpdateReq

type WorkspaceUpdateRes

type WorkspaceUpdateRes struct {
	*Workspace

} // @name WorkspaceUpdateRes

Jump to

Keyboard shortcuts

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