proxy

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: May 24, 2022 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const PrevVersion = "prev_version"

Variables

This section is empty.

Functions

func CanDeploy added in v1.0.0

func CanDeploy(p Service, deployType apps.DeployType) error

CanDeploy returns the availability of deployType. allowed indicates that the type can be used in the current configuration. usable indicates that it is configured and can be accessed, or deployed to.

Types

type Admin added in v1.0.0

type Admin interface {
	DisableApp(*incoming.Request, apps.Context, apps.AppID) (string, error)
	EnableApp(*incoming.Request, apps.Context, apps.AppID) (string, error)
	InstallApp(_ *incoming.Request, _ apps.Context, _ apps.AppID, _ apps.DeployType, trustedApp bool, secret string) (*apps.App, string, error)
	UpdateAppListing(*incoming.Request, appclient.UpdateAppListingRequest) (*apps.Manifest, error)
	UninstallApp(*incoming.Request, apps.Context, apps.AppID) (string, error)
}

Admin defines the REST API methods to manipulate Apps.

type AppMetadataForClient added in v1.0.0

type AppMetadataForClient struct {
	BotUserID   string `json:"bot_user_id,omitempty"`
	BotUsername string `json:"bot_username,omitempty"`
}

type CallResponse added in v1.0.0

type CallResponse struct {
	apps.CallResponse

	// Used to provide info about the App to client, e.g. the bot user id
	AppMetadata AppMetadataForClient `json:"app_metadata"`
}

CallResponse contains everything the CallResponse struct contains, plus some additional data for the client, such as information about the App's bot account.

Apps will use the CallResponse struct to respond to a CallRequest, and the proxy will decorate the response using the CallResponse to provide additional information.

func NewProxyCallResponse added in v1.0.0

func NewProxyCallResponse(response apps.CallResponse) CallResponse

func (CallResponse) WithMetadata added in v1.0.0

func (r CallResponse) WithMetadata(metadata AppMetadataForClient) CallResponse

type Internal added in v1.0.0

type Internal interface {
	AddBuiltinUpstream(apps.AppID, upstream.Upstream)
	CanDeploy(apps.DeployType) (allowed, usable bool)
	GetAppBindings(*incoming.Request, apps.Context, apps.App) ([]apps.Binding, error)
	GetInstalledApp(*incoming.Request, apps.AppID) (*apps.App, error)
	GetInstalledApps(_ *incoming.Request, ping bool) (installed []apps.App, reachable map[apps.AppID]bool)
	GetListedApps(_ *incoming.Request, filter string, includePluginApps bool) []apps.ListedApp
	GetManifest(*incoming.Request, apps.AppID) (*apps.Manifest, error)
	SynchronizeInstalledApps() error
}

Internal implements go API used by other packages.

type Invoker added in v1.0.0

type Invoker interface {
	// REST API methods used by user agents (mobile, desktop, web).
	Call(*incoming.Request, apps.CallRequest) CallResponse
	CompleteRemoteOAuth2(_ *incoming.Request, _ apps.AppID, urlValues map[string]interface{}) error
	GetBindings(*incoming.Request, apps.Context) ([]apps.Binding, error)
	GetRemoteOAuth2ConnectURL(*incoming.Request, apps.AppID) (string, error)
	GetStatic(_ *incoming.Request, _ apps.AppID, path string) (io.ReadCloser, int, error)
}

Invoker implements operations that invoke the Apps.

type Notifier added in v1.0.0

type Notifier interface {
	Notify(apps.Context, apps.Subject) error
	NotifyRemoteWebhook(*incoming.Request, apps.AppID, apps.HTTPCallRequest) error
	// NotifyMessageHasBeenPosted(*model.Post, apps.Context) error
	NotifyUserHasJoinedChannel(apps.Context) error
	NotifyUserHasLeftChannel(apps.Context) error
	NotifyUserHasJoinedTeam(apps.Context) error
	NotifyUserHasLeftTeam(apps.Context) error
}

Notifier implements user-less notification sinks.

type Proxy

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

func NewService

func NewService(conf config.Service, store *store.Service, mutex *cluster.Mutex, httpOut httpout.Service, session session.Service, appservices appservices.Service) *Proxy

func (*Proxy) AddBuiltinUpstream

func (p *Proxy) AddBuiltinUpstream(appID apps.AppID, up upstream.Upstream)

func (*Proxy) Call

func (p *Proxy) Call(r *incoming.Request, creq apps.CallRequest) CallResponse

func (*Proxy) CanDeploy added in v1.0.0

func (p *Proxy) CanDeploy(deployType apps.DeployType) (allowed, usable bool)

CanDeploy returns the availability of deployType. allowed indicates that the type can be used in the current configuration. usable indicates that it is configured and can be accessed, or deployed to.

func (*Proxy) CompleteRemoteOAuth2 added in v0.3.0

func (p *Proxy) CompleteRemoteOAuth2(r *incoming.Request, appID apps.AppID, urlValues map[string]interface{}) error

func (*Proxy) Configure added in v1.0.0

func (p *Proxy) Configure(conf config.Config, log utils.Logger) error

func (*Proxy) DisableApp

func (p *Proxy) DisableApp(r *incoming.Request, cc apps.Context, appID apps.AppID) (string, error)

func (*Proxy) EnableApp

func (p *Proxy) EnableApp(r *incoming.Request, cc apps.Context, appID apps.AppID) (string, error)

func (*Proxy) GetAppBindings added in v1.0.0

func (p *Proxy) GetAppBindings(r *incoming.Request, cc apps.Context, app apps.App) ([]apps.Binding, error)

GetAppBindings fetches bindings for a specific apps. We should avoid unnecessary logging here as this route is called very often.

func (*Proxy) GetBindings

func (p *Proxy) GetBindings(r *incoming.Request, cc apps.Context) ([]apps.Binding, error)

GetBindings fetches bindings for all apps. We should avoid unnecessary logging here as this route is called very often.

func (*Proxy) GetInstalledApp

func (p *Proxy) GetInstalledApp(_ *incoming.Request, appID apps.AppID) (*apps.App, error)

func (*Proxy) GetInstalledApps

func (p *Proxy) GetInstalledApps(r *incoming.Request, ping bool) (installed []apps.App, reachable map[apps.AppID]bool)

func (*Proxy) GetListedApps

func (p *Proxy) GetListedApps(_ *incoming.Request, filter string, includePluginApps bool) []apps.ListedApp

func (*Proxy) GetManifest

func (p *Proxy) GetManifest(_ *incoming.Request, appID apps.AppID) (*apps.Manifest, error)

func (*Proxy) GetRemoteOAuth2ConnectURL added in v0.3.0

func (p *Proxy) GetRemoteOAuth2ConnectURL(r *incoming.Request, appID apps.AppID) (string, error)

func (*Proxy) GetStatic added in v1.0.0

func (p *Proxy) GetStatic(r *incoming.Request, appID apps.AppID, path string) (io.ReadCloser, int, error)

func (*Proxy) InstallApp

func (p *Proxy) InstallApp(r *incoming.Request, cc apps.Context, appID apps.AppID, deployType apps.DeployType, trusted bool, secret string) (*apps.App, string, error)

InstallApp installs an App.

  • cc is the Context that will be passed down to the App's OnInstall callback.

func (*Proxy) Notify

func (p *Proxy) Notify(base apps.Context, subj apps.Subject) error

func (*Proxy) NotifyRemoteWebhook added in v0.3.0

func (p *Proxy) NotifyRemoteWebhook(r *incoming.Request, appID apps.AppID, httpCallRequest apps.HTTPCallRequest) error

func (*Proxy) NotifyUserHasJoinedChannel added in v1.0.0

func (p *Proxy) NotifyUserHasJoinedChannel(cc apps.Context) error

func (*Proxy) NotifyUserHasJoinedTeam added in v1.0.0

func (p *Proxy) NotifyUserHasJoinedTeam(cc apps.Context) error

func (*Proxy) NotifyUserHasLeftChannel added in v1.0.0

func (p *Proxy) NotifyUserHasLeftChannel(cc apps.Context) error

func (*Proxy) NotifyUserHasLeftTeam added in v1.0.0

func (p *Proxy) NotifyUserHasLeftTeam(cc apps.Context) error

func (*Proxy) SynchronizeInstalledApps

func (p *Proxy) SynchronizeInstalledApps() error

SynchronizeInstalledApps synchronizes installed apps with known manifests, performing OnVersionChanged call on the App as needed.

func (*Proxy) UninstallApp

func (p *Proxy) UninstallApp(r *incoming.Request, cc apps.Context, appID apps.AppID) (string, error)

func (*Proxy) UpdateAppListing added in v1.0.0

func (p *Proxy) UpdateAppListing(r *incoming.Request, req appclient.UpdateAppListingRequest) (*apps.Manifest, error)

type Service

type Service interface {
	// To update on configuration changes
	config.Configurable

	Admin
	Internal
	Invoker
	Notifier
}

Jump to

Keyboard shortcuts

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