proxy

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: May 26, 2023 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.

func SortTopBindings added in v1.2.0

func SortTopBindings(in []apps.Binding) (out []apps.Binding)

SortTopBindings ensures that the top-level bindings are sorted by Location, and their sub-bindings are sorted by their AppID. The children of those are left untouched.

Types

type API added in v1.2.0

type API interface {
	// REST API methods used by user agents (mobile, desktop, web).
	GetApp(*incoming.Request) (*apps.App, error)
	GetBindings(*incoming.Request, apps.Context) ([]apps.Binding, error)
	InvokeCall(*incoming.Request, apps.CallRequest) (*apps.App, apps.CallResponse)
	InvokeCompleteRemoteOAuth2(_ *incoming.Request, urlValues map[string]interface{}) error
	InvokeGetBindings(*incoming.Request, apps.Context) ([]apps.Binding, error)
	InvokeGetRemoteOAuth2ConnectURL(*incoming.Request) (string, error)
	InvokeGetStatic(_ *incoming.Request, path string) (io.ReadCloser, int, error)
	InvokeRemoteWebhook(*incoming.Request, apps.HTTPCallRequest) error
	ValidateWebhookAuthentication(*incoming.Request, apps.HTTPCallRequest) error
}

API implements user-level operations, usually invoked from httpin handlers. These methods expect the acting user, to and from apps to be set in the request.

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, bool) (string, error)
}

Admin defines the REST API methods to manipulate Apps. Since they operate in "admin" space, they accept a separate appID parameter rather than expecting a ToApp too be set in the request.

type ExpandGetter added in v1.2.1

type ExpandGetter interface {
	GetChannel(channelID string) (*model.Channel, error)
	GetChannelMember(channelID, userID string) (*model.ChannelMember, error)
	GetPost(postID string) (*model.Post, error)
	GetTeam(teamID string) (*model.Team, error)
	GetTeamMember(teamID, userID string) (*model.TeamMember, error)
	GetUser(userID string) (*model.User, error)
}

type Internal added in v1.0.0

type Internal interface {
	AddBuiltinUpstream(apps.AppID, upstream.Upstream)
	CanDeploy(apps.DeployType) (allowed, usable bool)
	NewIncomingRequest() *incoming.Request
	SynchronizeInstalledApps() error

	GetInstalledApp(_ apps.AppID, checkEnabled bool) (*apps.App, error)
	GetInstalledApps() []apps.App
	PingInstalledApps(context.Context) (installed []apps.App, reachable map[apps.AppID]bool)
	GetListedApps(filter string, includePluginApps bool) []apps.ListedApp
	GetManifest(apps.AppID) (*apps.Manifest, error)
}

Internal implements go API used by other plugin-apps packages. When relevant, they rely on the ActingUser set in the request, but usually have the app id parameters passed in explicitly, using request for logging.

type Notifier added in v1.0.0

type Notifier interface {
	NotifyUserCreated(userID string)
	NotifyUserChannel(member *model.ChannelMember, actor *model.User, joined bool)
	NotifyUserTeam(member *model.TeamMember, actor *model.User, joined bool)
	NotifyChannelCreated(teamID, channelID string)
}

Notifier implements subscription notifications, each one may be going out to multiple apps. Notify functions create their own app requests.

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) 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) 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, err error)

func (*Proxy) GetApp added in v1.2.0

func (p *Proxy) GetApp(r *incoming.Request) (*apps.App, error)

func (*Proxy) GetBindings

func (p *Proxy) GetBindings(r *incoming.Request, cc apps.Context) (ret []apps.Binding, err 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(appID apps.AppID, checkEnabled bool) (*apps.App, error)

func (*Proxy) GetInstalledApps

func (p *Proxy) GetInstalledApps() []apps.App

func (*Proxy) GetListedApps

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

func (*Proxy) GetManifest

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

func (*Proxy) InstallApp

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

InstallApp installs an App.

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

func (*Proxy) InvokeCall added in v1.2.0

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

func (*Proxy) InvokeCompleteRemoteOAuth2 added in v1.2.0

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

func (*Proxy) InvokeGetBindings added in v1.2.0

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

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

func (*Proxy) InvokeGetRemoteOAuth2ConnectURL added in v1.2.0

func (p *Proxy) InvokeGetRemoteOAuth2ConnectURL(r *incoming.Request) (string, error)

InvokeGetRemoteOAuth2ConnectURL returns the URL for the user to open, that would start the OAuth2 authentication flow. r.ActingUser and r.ToApp must be already set.

func (*Proxy) InvokeGetStatic added in v1.2.0

func (p *Proxy) InvokeGetStatic(r *incoming.Request, path string) (io.ReadCloser, int, error)

func (*Proxy) InvokeRemoteWebhook added in v1.2.0

func (p *Proxy) InvokeRemoteWebhook(r *incoming.Request, httpCallRequest apps.HTTPCallRequest) error

func (*Proxy) NewIncomingRequest added in v1.2.0

func (p *Proxy) NewIncomingRequest() *incoming.Request

func (*Proxy) NotifyChannelCreated added in v1.2.0

func (p *Proxy) NotifyChannelCreated(teamID, channelID string)

NotifyChannelCreated handles plugin's ChannelHasBeenCreated callback. It emits "channel_created" notifications to subscribed apps.

func (*Proxy) NotifyUserChannel added in v1.2.1

func (p *Proxy) NotifyUserChannel(member *model.ChannelMember, actor *model.User, joined bool)

func (*Proxy) NotifyUserCreated added in v1.2.0

func (p *Proxy) NotifyUserCreated(userID string)

NotifyUserCreated handles plugin's UserHasBeenCreated callback. It emits "user_created" notifications to subscribed apps.

func (*Proxy) NotifyUserTeam added in v1.2.1

func (p *Proxy) NotifyUserTeam(member *model.TeamMember, actor *model.User, joined bool)

func (*Proxy) PingInstalledApps added in v1.2.0

func (p *Proxy) PingInstalledApps(ctx context.Context) (installed []apps.App, reachable map[apps.AppID]bool)

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, force bool) (text string, err error)

func (*Proxy) UpdateAppListing added in v1.0.0

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

func (*Proxy) ValidateWebhookAuthentication added in v1.2.0

func (p *Proxy) ValidateWebhookAuthentication(r *incoming.Request, httpCallRequest apps.HTTPCallRequest) error

type Service

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

	Admin
	Internal
	API
	Notifier
}

Jump to

Keyboard shortcuts

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