api

package
v0.0.0-...-f7fc880 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2026 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultAuthTeamsListPageSize = 100

Default value for the maximum number of workspaces to return

Functions

func NewHTTPClient

func NewHTTPClient(opts HTTPClientOptions) *http.Client

New returns an http.Client based on a given Options input.

Types

type APIInterface

Interface that embeds all of the sub-interfaces for each file in this package. api.Client implements this interface, so it can be mocked out easily. TODO: consider renaming interfaces from '*Client' to an -er verb such as '*Manager'

Ref: https://go.dev/doc/effective_go#interface-names

type APIMock

type APIMock struct {
	mock.Mock
}

func (*APIMock) Activity

func (m *APIMock) Activity(ctx context.Context, token string, activityRequest types.ActivityRequest) (ActivityResult, error)

func (*APIMock) AddCollaborator

func (m *APIMock) AddCollaborator(ctx context.Context, token, appID string, slackUser types.SlackUser) error

func (*APIMock) AddDefaultMocks

func (m *APIMock) AddDefaultMocks()

func (*APIMock) AddVariable

func (m *APIMock) AddVariable(ctx context.Context, token, appID, name, value string) error

func (*APIMock) AppsAuthExternalClientSecretAdd

func (m *APIMock) AppsAuthExternalClientSecretAdd(ctx context.Context, token, appID, providerKey, clientSecret string) error

func (*APIMock) AppsAuthExternalDelete

func (m *APIMock) AppsAuthExternalDelete(ctx context.Context, token, appID, providerKey string, externalTokenID string) error

func (*APIMock) AppsAuthExternalList

func (m *APIMock) AppsAuthExternalList(ctx context.Context, token, appID string, includeWorkflows bool) (types.ExternalAuthorizationInfoLists, error)

func (*APIMock) AppsAuthExternalSelectAuth

func (m *APIMock) AppsAuthExternalSelectAuth(ctx context.Context, token, appID, providerKey, workflowID, externalTokenID string) error

func (*APIMock) AppsAuthExternalStart

func (m *APIMock) AppsAuthExternalStart(ctx context.Context, token, appID, providerKey string) (string, error)

func (*APIMock) AppsDatastoreBulkDelete

func (m *APIMock) AppsDatastoreBulkDelete(ctx context.Context, token string, request types.AppDatastoreBulkDelete) (types.AppDatastoreBulkDeleteResult, error)

func (*APIMock) AppsDatastoreBulkGet

func (m *APIMock) AppsDatastoreBulkGet(ctx context.Context, token string, request types.AppDatastoreBulkGet) (types.AppDatastoreBulkGetResult, error)

func (*APIMock) AppsDatastoreBulkPut

func (m *APIMock) AppsDatastoreBulkPut(ctx context.Context, token string, request types.AppDatastoreBulkPut) (types.AppDatastoreBulkPutResult, error)

func (*APIMock) AppsDatastoreCount

func (m *APIMock) AppsDatastoreCount(ctx context.Context, token string, query types.AppDatastoreCount) (types.AppDatastoreCountResult, error)

func (*APIMock) AppsDatastoreDelete

func (m *APIMock) AppsDatastoreDelete(ctx context.Context, token string, request types.AppDatastoreDelete) (types.AppDatastoreDeleteResult, error)

func (*APIMock) AppsDatastoreGet

func (m *APIMock) AppsDatastoreGet(ctx context.Context, token string, request types.AppDatastoreGet) (types.AppDatastoreGetResult, error)

func (*APIMock) AppsDatastorePut

func (m *APIMock) AppsDatastorePut(ctx context.Context, token string, request types.AppDatastorePut) (types.AppDatastorePutResult, error)

func (*APIMock) AppsDatastoreQuery

func (m *APIMock) AppsDatastoreQuery(ctx context.Context, token string, query types.AppDatastoreQuery) (types.AppDatastoreQueryResult, error)

func (*APIMock) AppsDatastoreUpdate

func (m *APIMock) AppsDatastoreUpdate(ctx context.Context, token string, request types.AppDatastoreUpdate) (types.AppDatastoreUpdateResult, error)

func (*APIMock) AuthTeamsList

func (m *APIMock) AuthTeamsList(ctx context.Context, token string, limit int) ([]types.TeamInfo, string, error)

func (*APIMock) CertifiedAppInstall

func (m *APIMock) CertifiedAppInstall(ctx context.Context, token string, certifiedAppID string) (CertifiedInstallResult, error)

func (*APIMock) ChannelsInfo

func (m *APIMock) ChannelsInfo(ctx context.Context, token, channelID string) (*types.ChannelInfo, error)

func (*APIMock) ConnectionsOpen

func (m *APIMock) ConnectionsOpen(ctx context.Context, token string) (AppsConnectionsOpenResult, error)

func (*APIMock) CreateApp

func (m *APIMock) CreateApp(ctx context.Context, token string, manifest types.AppManifest, enableDistribution bool) (CreateAppResult, error)

func (*APIMock) DeleteApp

func (m *APIMock) DeleteApp(ctx context.Context, token string, appID string) error

func (*APIMock) DeveloperAppInstall

func (m *APIMock) DeveloperAppInstall(ctx context.Context, IO iostreams.IOStreamer, token string, app types.App, botScopes []string, outgoingDomains []string, orgGrantWorkspaceID string, autoAAARequest bool) (DeveloperAppInstallResult, types.InstallState, error)

func (*APIMock) ExchangeAuthTicket

func (m *APIMock) ExchangeAuthTicket(ctx context.Context, ticket string, challenge string, cliVersion string) (ExchangeAuthTicketResult, error)

func (*APIMock) ExportAppManifest

func (m *APIMock) ExportAppManifest(ctx context.Context, token string, appID string) (ExportAppResult, error)

func (*APIMock) FunctionDistributionAddUsers

func (m *APIMock) FunctionDistributionAddUsers(ctx context.Context, callbackID, appID, users string) error

func (*APIMock) FunctionDistributionList

func (m *APIMock) FunctionDistributionList(ctx context.Context, callbackID, appID string) (types.Permission, []types.FunctionDistributionUser, error)

func (*APIMock) FunctionDistributionRemoveUsers

func (m *APIMock) FunctionDistributionRemoveUsers(ctx context.Context, callbackID, appID, users string) error

func (*APIMock) FunctionDistributionSet

func (m *APIMock) FunctionDistributionSet(ctx context.Context, callbackID, appID string, distributionType types.Permission, users string) ([]types.FunctionDistributionUser, error)

func (*APIMock) GenerateAuthTicket

func (m *APIMock) GenerateAuthTicket(ctx context.Context, cliVersion string, serviceTokenFlag bool) (GenerateAuthTicketResult, error)

func (*APIMock) GetAppStatus

func (m *APIMock) GetAppStatus(ctx context.Context, token string, appIDs []string, teamID string) (GetAppStatusResult, error)

func (*APIMock) GetPresignedS3PostParams

func (m *APIMock) GetPresignedS3PostParams(ctx context.Context, token string, appID string) (GenerateS3PresignedPostResult, error)

func (*APIMock) Host

func (m *APIMock) Host() string

func (*APIMock) Icon

func (m *APIMock) Icon(ctx context.Context, fs afero.Fs, token, appID, iconFilePath string) (IconResult, error)

func (*APIMock) ListCollaborators

func (m *APIMock) ListCollaborators(ctx context.Context, token, appID string) ([]types.SlackUser, error)

func (*APIMock) ListVariables

func (m *APIMock) ListVariables(ctx context.Context, token, appID string) ([]string, error)

func (*APIMock) RemoveCollaborator

func (m *APIMock) RemoveCollaborator(ctx context.Context, token, appID string, slackUser types.SlackUser) (slackerror.Warnings, error)

func (*APIMock) RemoveVariable

func (m *APIMock) RemoveVariable(ctx context.Context, token string, appID string, variableName string) error

func (*APIMock) RequestAppApproval

func (m *APIMock) RequestAppApproval(ctx context.Context, token string, appID string, teamID string, reason string, scopes string, outgoingDomains []string) (AppsApprovalsRequestsCreateResult, error)

func (*APIMock) RevokeToken

func (m *APIMock) RevokeToken(ctx context.Context, token string) error

func (*APIMock) RotateToken

func (m *APIMock) RotateToken(ctx context.Context, auth types.SlackAuth) (RotateTokenResult, error)

func (*APIMock) SetHost

func (m *APIMock) SetHost(host string)

func (*APIMock) StepsList

func (m *APIMock) StepsList(ctx context.Context, token string, workflow string, appID string) ([]StepVersion, error)

func (*APIMock) StepsResponsesExport

func (m *APIMock) StepsResponsesExport(ctx context.Context, token string, workflow string, appID string, stepID string) error

func (*APIMock) TeamsInfo

func (m *APIMock) TeamsInfo(ctx context.Context, token, teamID string) (*types.TeamInfo, error)

func (*APIMock) TriggerPermissionsAddEntities

func (m *APIMock) TriggerPermissionsAddEntities(ctx context.Context, token, triggerID, entities string, entityType string) error

func (*APIMock) TriggerPermissionsList

func (m *APIMock) TriggerPermissionsList(ctx context.Context, token, triggerID string) (types.Permission, []string, error)

func (*APIMock) TriggerPermissionsRemoveEntities

func (m *APIMock) TriggerPermissionsRemoveEntities(ctx context.Context, token, triggerID, entities string, entityType string) error

func (*APIMock) TriggerPermissionsSet

func (m *APIMock) TriggerPermissionsSet(ctx context.Context, token, triggerID, entities string, distributionType types.Permission, entityType string) ([]string, error)

func (*APIMock) UninstallApp

func (m *APIMock) UninstallApp(ctx context.Context, token string, appID, teamID string) error

func (*APIMock) UpdateApp

func (m *APIMock) UpdateApp(ctx context.Context, token string, appID string, manifest types.AppManifest, forceUpdate bool, continueWithBreakingChanges bool) (UpdateAppResult, error)

func (*APIMock) UpdateCollaborator

func (m *APIMock) UpdateCollaborator(ctx context.Context, token, appID string, slackUser types.SlackUser) error

func (*APIMock) UploadApp

func (m *APIMock) UploadApp(ctx context.Context, token, runtime, appID string, fileName string) error

func (*APIMock) UploadPackageToS3

func (m *APIMock) UploadPackageToS3(ctx context.Context, fs afero.Fs, appID string, uploadParams GenerateS3PresignedPostResult, archiveFilePath string) (string, error)

func (*APIMock) UsersInfo

func (m *APIMock) UsersInfo(ctx context.Context, token, userID string) (*types.UserInfo, error)

func (*APIMock) ValidateAppManifest

func (m *APIMock) ValidateAppManifest(ctx context.Context, token string, manifest types.AppManifest, appID string) (ValidateAppManifestResult, error)

func (*APIMock) ValidateSession

func (m *APIMock) ValidateSession(ctx context.Context, token string) (AuthSession, error)

func (*APIMock) WorkflowsTriggersCreate

func (m *APIMock) WorkflowsTriggersCreate(ctx context.Context, token string, createRequest TriggerRequest) (types.DeployedTrigger, error)

func (*APIMock) WorkflowsTriggersDelete

func (m *APIMock) WorkflowsTriggersDelete(ctx context.Context, token string, triggerID string) error

func (*APIMock) WorkflowsTriggersInfo

func (m *APIMock) WorkflowsTriggersInfo(ctx context.Context, token string, triggerID string) (types.DeployedTrigger, error)

func (*APIMock) WorkflowsTriggersList

func (m *APIMock) WorkflowsTriggersList(ctx context.Context, token string, listArgs TriggerListRequest) ([]types.DeployedTrigger, string, error)

func (*APIMock) WorkflowsTriggersUpdate

func (m *APIMock) WorkflowsTriggersUpdate(ctx context.Context, token string, updateRequest TriggerUpdateRequest) (types.DeployedTrigger, error)

type Activity

type Activity struct {
	TraceID       string                 `json:"trace_id,omitempty"`
	Level         types.ActivityLevel    `json:"level,omitempty"`
	EventType     types.EventType        `json:"event_type,omitempty"`
	Source        string                 `json:"source,omitempty"`
	ComponentType string                 `json:"component_type,omitempty"`
	ComponentID   string                 `json:"component_id,omitempty"`
	Payload       map[string]interface{} `json:"payload,omitempty"`
	Created       int64                  `json:"created,omitempty"`
}

func (*Activity) CreatedPretty

func (a *Activity) CreatedPretty() string

type ActivityClient

type ActivityClient interface {
	Activity(ctx context.Context, token string, activityRequest types.ActivityRequest) (ActivityResult, error)
}

type ActivityResult

type ActivityResult struct {
	Activities []Activity `json:"activities,omitempty"`
	NextCursor string
}

type AppStatusResultAppInfo

type AppStatusResultAppInfo struct {
	AppID            string                  `json:"app_id"`
	Installed        bool                    `json:"is_installed"`
	Hosted           bool                    `json:"is_hosted"`
	EnterpriseGrants []types.EnterpriseGrant `json:"enterprise_grants,omitempty"`
}

type AppsApprovalsRequestsCreateResult

type AppsApprovalsRequestsCreateResult struct {
	RequestID string `json:"request_id"`
}

type AppsClient

type AppsClient interface {
	CertifiedAppInstall(ctx context.Context, token string, certifiedAppID string) (CertifiedInstallResult, error)
	ConnectionsOpen(ctx context.Context, token string) (AppsConnectionsOpenResult, error)
	CreateApp(ctx context.Context, token string, manifest types.AppManifest, enableDistribution bool) (CreateAppResult, error)
	DeleteApp(ctx context.Context, token string, appID string) error
	DeveloperAppInstall(ctx context.Context, IO iostreams.IOStreamer, token string, app types.App, botScopes []string, outgoingDomains []string, orgGrantWorkspaceID string, autoRequestAAA bool) (DeveloperAppInstallResult, types.InstallState, error)
	ExportAppManifest(ctx context.Context, token string, appID string) (ExportAppResult, error)
	GetAppStatus(ctx context.Context, token string, appIDs []string, teamID string) (GetAppStatusResult, error)
	GetPresignedS3PostParams(ctx context.Context, token string, appID string) (GenerateS3PresignedPostResult, error)
	Host() string
	Icon(ctx context.Context, fs afero.Fs, token, appID, iconFilePath string) (IconResult, error)
	RequestAppApproval(ctx context.Context, token string, appID string, teamID string, reason string, scopes string, outgoingDomains []string) (AppsApprovalsRequestsCreateResult, error)
	SetHost(host string)
	UninstallApp(ctx context.Context, token string, appID, teamID string) error
	UpdateApp(ctx context.Context, token string, appID string, manifest types.AppManifest, forceUpdate bool, continueWithBreakingChanges bool) (UpdateAppResult, error)
	UploadApp(ctx context.Context, token, runtime, appID string, fileName string) error
	UploadPackageToS3(ctx context.Context, fs afero.Fs, appID string, uploadParams GenerateS3PresignedPostResult, archiveFilePath string) (string, error)
	ValidateAppManifest(ctx context.Context, token string, manifest types.AppManifest, appID string) (ValidateAppManifestResult, error)
}

AppsClient is the interface for app-related API calls

type AppsConnectionsOpenResult

type AppsConnectionsOpenResult struct {
	URL string `json:"url"`
}

GenerateS3PresignedPost details to be saved

type AuthClient

type AuthClient interface {
	ExchangeAuthTicket(ctx context.Context, ticket string, challenge string, cliVersion string) (ExchangeAuthTicketResult, error)
	GenerateAuthTicket(ctx context.Context, cliVersion string, serviceTokenFlag bool) (GenerateAuthTicketResult, error)
	RotateToken(ctx context.Context, auth types.SlackAuth) (RotateTokenResult, error)
}

type AuthSession

type AuthSession struct {
	UserName            *string `json:"user,omitempty"`
	UserID              *string `json:"user_id,omitempty"`
	TeamID              *string `json:"team_id,omitempty"`
	TeamName            *string `json:"team,omitempty"`
	EnterpriseID        *string `json:"enterprise_id,omitempty"`
	IsEnterpriseInstall *bool   `json:"is_enterprise_install,omitempty"`
	URL                 *string `json:"url,omitempty"`
}

No guaranteed properties in API response so omitempty is used

type AuthTeamsListResponse

type AuthTeamsListResponse struct {
	Teams            []types.TeamInfo `json:"teams"`
	ResponseMetadata struct {
		NextCursor string `json:"next_cursor"`
	} `json:"response_metadata"`
	// contains filtered or unexported fields
}

type CertifiedInstallResult

type CertifiedInstallResult struct{}

This API returns null

type ChannelClient

type ChannelClient interface {
	ChannelsInfo(ctx context.Context, token, channelID string) (*types.ChannelInfo, error)
}

type ChannelInfoResponse

type ChannelInfoResponse struct {
	Channel types.ChannelInfo `json:"channel"`
	// contains filtered or unexported fields
}

type Client

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

Client provides an http connection for communicating with the Slack API.

func NewClient

func NewClient(client *http.Client, host string, io iostreams.IOStreamer) *Client

NewClient accepts an httpClient to facilitate making http requests to Slack. Client does not attempt to evaluate the response body, leaving that to the caller.

func NewFakeClient

func NewFakeClient(t *testing.T, params FakeClientParams) (*Client, func())

NewFakeClient returns a *Client that is wired up to expect the specific request to a particular method, and if it receives it, returns a predefined response.

func (*Client) Activity

func (c *Client) Activity(ctx context.Context, token string, activityRequest types.ActivityRequest) (ActivityResult, error)

Get the recent activity for an app

func (*Client) AddCollaborator

func (c *Client) AddCollaborator(ctx context.Context, token, appID string, slackUser types.SlackUser) error

AddCollaborator adds an app collaborator

func (*Client) AddVariable

func (c *Client) AddVariable(ctx context.Context, token, appID, name, value string) error

AddVariables adds/updates one or more environment variables

func (*Client) AppsAuthExternalClientSecretAdd

func (c *Client) AppsAuthExternalClientSecretAdd(ctx context.Context, token, appID, providerKey string, clientSecret string) error

func (*Client) AppsAuthExternalDelete

func (c *Client) AppsAuthExternalDelete(ctx context.Context, token, appID, providerKey string, externalTokenID string) error

func (*Client) AppsAuthExternalList

func (c *Client) AppsAuthExternalList(ctx context.Context, token, appID string, includeWorkflows bool) (types.ExternalAuthorizationInfoLists, error)

func (*Client) AppsAuthExternalSelectAuth

func (c *Client) AppsAuthExternalSelectAuth(ctx context.Context, token, appID, providerKey, workflowID, externalTokenID string) error

func (*Client) AppsAuthExternalStart

func (c *Client) AppsAuthExternalStart(ctx context.Context, token, appID, providerKey string) (string, error)

func (*Client) AppsDatastoreBulkDelete

func (c *Client) AppsDatastoreBulkDelete(ctx context.Context, token string, request types.AppDatastoreBulkDelete) (types.AppDatastoreBulkDeleteResult, error)

func (*Client) AppsDatastoreBulkGet

func (c *Client) AppsDatastoreBulkGet(ctx context.Context, token string, request types.AppDatastoreBulkGet) (types.AppDatastoreBulkGetResult, error)

func (*Client) AppsDatastoreBulkPut

func (c *Client) AppsDatastoreBulkPut(ctx context.Context, token string, request types.AppDatastoreBulkPut) (types.AppDatastoreBulkPutResult, error)

func (*Client) AppsDatastoreCount

func (c *Client) AppsDatastoreCount(ctx context.Context, token string, count types.AppDatastoreCount) (types.AppDatastoreCountResult, error)

func (*Client) AppsDatastoreDelete

func (c *Client) AppsDatastoreDelete(ctx context.Context, token string, request types.AppDatastoreDelete) (types.AppDatastoreDeleteResult, error)

func (*Client) AppsDatastoreGet

func (c *Client) AppsDatastoreGet(ctx context.Context, token string, request types.AppDatastoreGet) (types.AppDatastoreGetResult, error)

func (*Client) AppsDatastorePut

func (c *Client) AppsDatastorePut(ctx context.Context, token string, request types.AppDatastorePut) (types.AppDatastorePutResult, error)

func (*Client) AppsDatastoreQuery

func (c *Client) AppsDatastoreQuery(ctx context.Context, token string, query types.AppDatastoreQuery) (types.AppDatastoreQueryResult, error)

func (*Client) AppsDatastoreUpdate

func (c *Client) AppsDatastoreUpdate(ctx context.Context, token string, request types.AppDatastoreUpdate) (types.AppDatastoreUpdateResult, error)

func (*Client) AuthTeamsList

func (c *Client) AuthTeamsList(ctx context.Context, token string, limit int) ([]types.TeamInfo, string, error)

AuthTeamsList returns a list of workspaces that the user has access to through the token as well as a pagination cursor if the org has more workspaces than returned in this request. Used to retrieve enterprise workspaces that belong to an org. Specify the maximum number of workspaces to return via the `limit` param (value between 1 and 1000).

func (*Client) CertifiedAppInstall

func (c *Client) CertifiedAppInstall(ctx context.Context, token string, certifiedAppID string) (CertifiedInstallResult, error)

CertifiedAppInstall requests the installation of a certified app in order for its connectors to be usable

func (*Client) ChannelsInfo

func (c *Client) ChannelsInfo(ctx context.Context, token, channelID string) (*types.ChannelInfo, error)

ChannelInfo returns information about the channel such as channel name

func (*Client) ConnectionsOpen

func (c *Client) ConnectionsOpen(ctx context.Context, token string) (AppsConnectionsOpenResult, error)

func (*Client) CreateApp

func (c *Client) CreateApp(ctx context.Context, token string, manifest types.AppManifest, enableDistribution bool) (CreateAppResult, error)

CreateApp creates a new Slack app

func (*Client) DeleteApp

func (c *Client) DeleteApp(ctx context.Context, token string, appID string) error

DeleteApp fully deletes the Slack app identified by appID

func (*Client) DeveloperAppInstall

func (c *Client) DeveloperAppInstall(ctx context.Context, IO iostreams.IOStreamer, token string, app types.App, botScopes []string, outgoingDomains []string, orgGrantWorkspaceID string, autoRequestAAAFlag bool) (DeveloperAppInstallResult, types.InstallState, error)

func (*Client) DoWithRetry

func (c *Client) DoWithRetry(ctx context.Context, request *http.Request, span opentracing.Span, skipDebugLog bool, sURL *url.URL) ([]byte, error)

DoWithRetry will execute the request and retry failed requests if the status indicates the request may be retryable and a Retry-After header is present.

func (*Client) ExchangeAuthTicket

func (c *Client) ExchangeAuthTicket(ctx context.Context, ticket string, challenge string, cliVersion string) (ExchangeAuthTicketResult, error)

ExchangeAuthTicket

func (*Client) ExportAppManifest

func (c *Client) ExportAppManifest(ctx context.Context, token, appID string) (ExportAppResult, error)

ExportAppManifest calls "apps.manifest.export" to gather manifest details

func (*Client) FunctionDistributionAddUsers

func (c *Client) FunctionDistributionAddUsers(ctx context.Context, callbackID, appID, users string) error

FunctionDistributionAddUsers adds the given entities to the access list for functions with distribution type 'named_entities'.

func (*Client) FunctionDistributionList

func (c *Client) FunctionDistributionList(ctx context.Context, callbackID, appID string) (types.Permission, []types.FunctionDistributionUser, error)

FunctionDistributionList returns the distribution type. If type is 'named_entities', the IDs of entities that have access are also returned.

func (*Client) FunctionDistributionRemoveUsers

func (c *Client) FunctionDistributionRemoveUsers(ctx context.Context, callbackID, appID, users string) error

FunctionDistributionRemoveUsers removes the given entities from the access list for functions with distribution type 'named_entities'.

func (*Client) FunctionDistributionSet

func (c *Client) FunctionDistributionSet(ctx context.Context, callbackID, appID string, distributionType types.Permission, users string) ([]types.FunctionDistributionUser, error)

FunctionDistributionSet sets the distribution type for the given function. One can also pass in a list of users to assign access to if distribution type is named_entities.

func (*Client) GenerateAuthTicket

func (c *Client) GenerateAuthTicket(ctx context.Context, cliVersion string, serviceTokenFlag bool) (GenerateAuthTicketResult, error)

GenerateAuthTicket

func (*Client) GetAppStatus

func (c *Client) GetAppStatus(ctx context.Context, token string, appIDs []string, teamID string) (GetAppStatusResult, error)

GetAppStatus fetches information about the given apps's installation

func (*Client) GetPresignedS3PostParams

func (c *Client) GetPresignedS3PostParams(ctx context.Context, token string, appID string) (GenerateS3PresignedPostResult, error)

func (*Client) Host

func (c *Client) Host() string

Host returns the configured host value

func (*Client) Icon

func (c *Client) Icon(ctx context.Context, fs afero.Fs, token, appID, iconFilePath string) (IconResult, error)

Icon updates a Slack App's icon

func (*Client) ListCollaborators

func (c *Client) ListCollaborators(ctx context.Context, token, appID string) ([]types.SlackUser, error)

ListCollaborators lists app collaborators

func (*Client) ListVariables

func (c *Client) ListVariables(ctx context.Context, token, appID string) ([]string, error)

ListVariables adds/updates an environment variable

func (*Client) RemoveCollaborator

func (c *Client) RemoveCollaborator(ctx context.Context, token, appID string, slackUser types.SlackUser) (slackerror.Warnings, error)

RemoveCollaborator removes an app collaborator

func (*Client) RemoveVariable

func (c *Client) RemoveVariable(ctx context.Context, token string, appID string, variableName string) error

RemoveVariable removes an environment variable

func (*Client) RequestAppApproval

func (c *Client) RequestAppApproval(ctx context.Context, token string, appID string, teamID string, reason string, scopes string, outgoingDomains []string) (AppsApprovalsRequestsCreateResult, error)

RequestAppApproval creates a new app approval request to slack

func (*Client) RevokeToken

func (c *Client) RevokeToken(ctx context.Context, token string) error

RevokeToken sends a given token to the Slack API for revocation

func (*Client) RotateToken

func (c *Client) RotateToken(ctx context.Context, auth types.SlackAuth) (RotateTokenResult, error)

RotateToken calls tooling.tokens.rotate

func (*Client) SetHost

func (c *Client) SetHost(host string)

SetHost sets the host value

func (*Client) StepsList

func (c *Client) StepsList(ctx context.Context, token string, workflow string, appID string) ([]StepVersion, error)

func (*Client) StepsResponsesExport

func (c *Client) StepsResponsesExport(ctx context.Context, token string, workflow string, appID string, stepID string) error

func (*Client) TeamsInfo

func (c *Client) TeamsInfo(ctx context.Context, token, teamID string) (*types.TeamInfo, error)

TeamInfo returns information about the team such as team name

func (*Client) TriggerPermissionsAddEntities

func (c *Client) TriggerPermissionsAddEntities(ctx context.Context, token, triggerID, entities string, entityType string) error

TriggerPermissionsAddEntities adds the given entities to the access list for triggers with access type 'named_entities'.

func (*Client) TriggerPermissionsList

func (c *Client) TriggerPermissionsList(ctx context.Context, token, triggerID string) (types.Permission, []string, error)

TriggerPermissionsList returns the access type. If type is 'named_entities', the IDs of entities that have access are also returned.

func (*Client) TriggerPermissionsRemoveEntities

func (c *Client) TriggerPermissionsRemoveEntities(ctx context.Context, token, triggerID, entities string, entityType string) error

TriggerPermissionsRemoveEntities removes the given entities from the access list for triggers with access type 'named_entities'.

func (*Client) TriggerPermissionsSet

func (c *Client) TriggerPermissionsSet(ctx context.Context, token, triggerID, entities string, permissionType types.Permission, entityType string) ([]string, error)

TriggerPermissionsSet sets the access type for the given trigger. One can also pass in a list of entities to assign access to if access type is named_entities.

func (*Client) UninstallApp

func (c *Client) UninstallApp(ctx context.Context, token string, appID, teamID string) error

UninstallApp uninstalls a Slack app from its team

func (*Client) UpdateApp

func (c *Client) UpdateApp(ctx context.Context, token string, appID string, manifest types.AppManifest, forceUpdate bool, continueWithBreakingChanges bool) (UpdateAppResult, error)

UpdateApp updates a Slack app

func (*Client) UpdateCollaborator

func (c *Client) UpdateCollaborator(ctx context.Context, token, appID string, slackUser types.SlackUser) error

UpdateCollaborator updates an app collaborator

func (*Client) UploadApp

func (c *Client) UploadApp(ctx context.Context, token, runtime, appID string, fileName string) error

UploadApp takes a manifest and creates a new app

func (*Client) UploadPackageToS3

func (c *Client) UploadPackageToS3(ctx context.Context, fs afero.Fs, appID string, uploadParams GenerateS3PresignedPostResult, archiveFilePath string) (string, error)

UploadPackageToS3 uploads an archive file to S3, given the provided upload params. TODO: Should be moved out of Client, since it just reuses the httpclient instance directly

func (*Client) UsersInfo

func (c *Client) UsersInfo(ctx context.Context, token, userID string) (*types.UserInfo, error)

UsersInfo returns information about the user such as email address

func (*Client) ValidateAppManifest

func (c *Client) ValidateAppManifest(ctx context.Context, token string, manifest types.AppManifest, appID string) (ValidateAppManifestResult, error)

ValidateAppManifest validates a new Slack app

func (*Client) ValidateSession

func (c *Client) ValidateSession(ctx context.Context, token string) (AuthSession, error)

ValidateSession ensures that a given token has a valid session with the Slack API. cookie only required if token is a xoxc token otherwise "" is okay

func (*Client) WorkflowsTriggersCreate

func (c *Client) WorkflowsTriggersCreate(ctx context.Context, token string, trigger TriggerRequest) (types.DeployedTrigger, error)

WorkflowsTriggersCreate will create a new trigger using the method workflows.trigger.create

func (*Client) WorkflowsTriggersDelete

func (c *Client) WorkflowsTriggersDelete(ctx context.Context, token string, triggerID string) error

WorkflowsTriggersDelete will delete an existing trigger using the method workflows.trigger.delete

func (*Client) WorkflowsTriggersInfo

func (c *Client) WorkflowsTriggersInfo(ctx context.Context, token, triggerID string) (types.DeployedTrigger, error)

WorkflowsTriggersInfo will retrieve information on an existing trigger

func (*Client) WorkflowsTriggersList

func (c *Client) WorkflowsTriggersList(ctx context.Context, token string, listArgs TriggerListRequest) ([]types.DeployedTrigger, string, error)

WorkflowsTriggersList will list the existing triggers

func (*Client) WorkflowsTriggersUpdate

func (c *Client) WorkflowsTriggersUpdate(ctx context.Context, token string, trigger TriggerUpdateRequest) (types.DeployedTrigger, error)

WorkflowsTriggersUpdate will update an existing trigger using the method workflows.trigger.update

type CollaboratorsClient

type CollaboratorsClient interface {
	AddCollaborator(ctx context.Context, token, appID string, slackUser types.SlackUser) error
	ListCollaborators(ctx context.Context, token, appID string) ([]types.SlackUser, error)
	RemoveCollaborator(ctx context.Context, token, appID string, slackUser types.SlackUser) (slackerror.Warnings, error)
	UpdateCollaborator(ctx context.Context, token, appID string, slackUser types.SlackUser) error
}

type CreateAppResult

type CreateAppResult struct {
	AppID             string      `json:"app_id,omitempty"`
	Credentials       Credentials `json:"credentials,omitempty"`
	OAuthAuthorizeURL string      `json:"oauth_authorize_url,omitempty"`
}

CreateAppResult details to be saved

type Credentials

type Credentials struct {
	ClientID          string `json:"client_id,omitempty"`
	ClientSecret      string `json:"client_secret,omitempty"`
	VerificationToken string `json:"verification_token,omitempty"`
	SigningSecret     string `json:"signing_secret,omitempty"`
}

App Credentials to be saved

type DatastoresClient

type DatastoresClient interface {
	AppsDatastorePut(ctx context.Context, token string, request types.AppDatastorePut) (types.AppDatastorePutResult, error)
	AppsDatastoreBulkPut(ctx context.Context, token string, request types.AppDatastoreBulkPut) (types.AppDatastoreBulkPutResult, error)
	AppsDatastoreUpdate(ctx context.Context, token string, request types.AppDatastoreUpdate) (types.AppDatastoreUpdateResult, error)
	AppsDatastoreQuery(ctx context.Context, token string, query types.AppDatastoreQuery) (types.AppDatastoreQueryResult, error)
	AppsDatastoreCount(ctx context.Context, token string, query types.AppDatastoreCount) (types.AppDatastoreCountResult, error)
	AppsDatastoreDelete(ctx context.Context, token string, request types.AppDatastoreDelete) (types.AppDatastoreDeleteResult, error)
	AppsDatastoreBulkDelete(ctx context.Context, token string, request types.AppDatastoreBulkDelete) (types.AppDatastoreBulkDeleteResult, error)
	AppsDatastoreGet(ctx context.Context, token string, request types.AppDatastoreGet) (types.AppDatastoreGetResult, error)
	AppsDatastoreBulkGet(ctx context.Context, token string, request types.AppDatastoreBulkGet) (types.AppDatastoreBulkGetResult, error)
}

type DeveloperAppInstallResult

type DeveloperAppInstallResult struct {
	AppID           string `json:"app_id,omitempty"`
	APIAccessTokens struct {
		Bot      string `json:"bot,omitempty"`
		AppLevel string `json:"app_level,omitempty"`
		User     string `json:"user,omitempty"`
	} `json:"api_access_tokens,omitempty"`
}

Details related to successful installation

type ExchangeAuthTicketResult

type ExchangeAuthTicketResult struct {
	EnterpriseID        string `json:"enterprise_id,omitempty"`
	ExpiresAt           int    `json:"exp,omitempty"`
	IsEnterpriseInstall bool   `json:"is_enterprise_install,omitempty"`
	IsReady             bool   `json:"is_ready,omitempty"`
	RefreshToken        string `json:"refresh_token,omitempty"`
	TeamDomain          string `json:"team_domain"`
	TeamID              string `json:"team_id"`
	TeamName            string `json:"team_name"`
	Token               string `json:"token,omitempty"`
	UserID              string `json:"user_id"`
}

ExchangeAuthTicketResult details to be returned

type ExportAppResponse

type ExportAppResponse struct {
	ExportAppResult
	// contains filtered or unexported fields
}

type ExportAppResult

type ExportAppResult struct {
	Manifest types.SlackYaml `json:"manifest,omitempty"`
}

type ExternalAuthClient

type ExternalAuthClient interface {
	AppsAuthExternalStart(context.Context, string, string, string) (string, error)
	AppsAuthExternalDelete(context.Context, string, string, string, string) error
	AppsAuthExternalClientSecretAdd(context.Context, string, string, string, string) error
	AppsAuthExternalList(context.Context, string, string, bool) (types.ExternalAuthorizationInfoLists, error)
	AppsAuthExternalSelectAuth(context.Context, string, string, string, string, string) error
}

For easy mocking

type FakeClientParams

type FakeClientParams struct {
	// The API method we expect to call, like "apps.manifest.create"
	ExpectedMethod string
	// The JSON payload we send to the server. If empty, this assertion is skipped.
	ExpectedRequest string
	// Any querystring parameters we expect the client to append to the URL
	ExpectedQuerystring string
	// The response sent back from the server to the client.
	Response string
	// If > 0, the request terminates with this status code and no response body.
	StatusCode int
}

type FunctionDistributionAddUsersResponse

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

type FunctionDistributionClient

type FunctionDistributionClient interface {
	FunctionDistributionList(ctx context.Context, callbackID, appID string) (types.Permission, []types.FunctionDistributionUser, error)
	FunctionDistributionSet(ctx context.Context, callbackID, appID string, distributionType types.Permission, users string) ([]types.FunctionDistributionUser, error)
	FunctionDistributionAddUsers(ctx context.Context, callbackID, appID, users string) error
	FunctionDistributionRemoveUsers(ctx context.Context, callbackID, appID, users string) error
}

type FunctionDistributionListResponse

type FunctionDistributionListResponse struct {
	DistributionType string                           `json:"distribution_type"`
	Users            []types.FunctionDistributionUser `json:"users"`
	// contains filtered or unexported fields
}

type FunctionDistributionRemoveUsersResponse

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

type FunctionDistributionSetResponse

type FunctionDistributionSetResponse struct {
	DistributionType string                           `json:"distribution_type"`
	Users            []types.FunctionDistributionUser `json:"users"`
	// contains filtered or unexported fields
}

type GenerateAuthTicketResult

type GenerateAuthTicketResult struct {
	Ticket string `json:"ticket,omitempty"`
}

GenerateAuthTicketResult details to be returned

type GenerateS3PresignedPostResult

type GenerateS3PresignedPostResult struct {
	URL      string              `json:"url"`
	FileName string              `json:"file_name"`
	Fields   PresignedPostFields `json:"fields"`
}

GenerateS3PresignedPost details to be saved

type GetAppStatusResponse

type GetAppStatusResponse struct {
	GetAppStatusResult
	// contains filtered or unexported fields
}

type GetAppStatusResult

type GetAppStatusResult struct {
	Apps []AppStatusResultAppInfo `json:"apps"`
	Team struct {
		TeamID       string `json:"team_id"`
		TeamDomain   string `json:"team_domain"`
		IsEnterprise bool   `json:"is_enterprise"`
	} `json:"team"`
}

type HTTPClientOptions

type HTTPClientOptions struct {
	TotalTimeOut     time.Duration // total time for the life of the request.
	SkipTLSVerify    bool
	Retries          int            // how many times we should retry, if 0 no retry logic is added.
	Backoff          *time.Duration // constant duration to wait between requests.
	AttemptTimeout   *time.Duration // how long we give each attempt before we cancel the request.
	RetryErrorCodes  []string       // which slack application error codes we want to retry on.
	RetryStatusCodes []int          // which http status codes we want to retry on.
}

Options allows a user of this lib to customize their http Client.

type IconResult

type IconResult struct {
}

IconResult details to be saved

type Input

type Input struct {
	Value        string `json:"value,omitempty"`
	Customizable bool   `json:"customizable,omitempty"`
}

type Inputs

type Inputs map[string]*Input

type MissingParameterDetail

type MissingParameterDetail struct {
	Name string `json:"missing_parameter_name"`
	Type string `json:"missing_parameter_type"`
}

type PresignedPostFields

type PresignedPostFields struct {
	AmzCredentials    string `json:"X-Amz-Credential"`
	AmzAlgorithm      string `json:"X-Amz-Algorithm"`
	AmzFileKey        string `json:"key"`
	AmzFileCreateDate string `json:"X-Amz-Date"`
	AmzPolicy         string `json:"Policy"`
	AmzSignature      string `json:"X-Amz-Signature"`
	AmzToken          string `json:"X-Amz-Security-Token"`
}

S3 presigned post response to be saved

type RotateTokenResult

type RotateTokenResult struct {
	Token        string `json:"token,omitempty"`
	RefreshToken string `json:"refresh_token,omitempty"`
	TeamID       string `json:"team_id"`
	UserID       string `json:"user_id"`
	IssuedAt     int    `json:"iat"`
	ExpiresAt    int    `json:"exp"`
}

type SessionsClient

type SessionsClient interface {
	ValidateSession(ctx context.Context, token string) (AuthSession, error)
	RevokeToken(ctx context.Context, token string) error
}

type Shortcut

type Shortcut struct {
	ButtonText string `json:"button_text,omitempty"`
}

type StepVersion

type StepVersion struct {
	Title                  string `json:"title"`
	WorkflowID             string `json:"workflow_id"`
	StepID                 string `json:"step_id"`
	IsDeleted              bool   `json:"is_deleted"`
	WorkflowVersionCreated string `json:"workflow_version_created"`
}

type StepsClient

type StepsClient interface {
	StepsList(ctx context.Context, token string, workflow string, appID string) ([]StepVersion, error)
	StepsResponsesExport(ctx context.Context, token string, workflow string, appID string, stepID string) error
}

type TeamClient

type TeamClient interface {
	TeamsInfo(ctx context.Context, token, teamID string) (*types.TeamInfo, error)
	AuthTeamsList(ctx context.Context, token string, limit int) ([]types.TeamInfo, string, error)
}

type TeamInfoResponse

type TeamInfoResponse struct {
	Team types.TeamInfo `json:"team"`
	// contains filtered or unexported fields
}

type TriggerAccessClient

type TriggerAccessClient interface {
	TriggerPermissionsList(ctx context.Context, token, triggerID string) (types.Permission, []string, error)
	TriggerPermissionsSet(ctx context.Context, token, triggerID, entities string, permissionType types.Permission, entityType string) ([]string, error)
	TriggerPermissionsAddEntities(ctx context.Context, token, triggerID, entities string, entityType string) error
	TriggerPermissionsRemoveEntities(ctx context.Context, token, triggerID, entities string, entityType string) error
}

type TriggerCreateOrUpdateError

type TriggerCreateOrUpdateError struct {
	Err                    error
	MissingParameterDetail MissingParameterDetail
}

func (*TriggerCreateOrUpdateError) Error

type TriggerListRequest

type TriggerListRequest struct {
	AppID  string `json:"app_id,omitempty"`
	Limit  int    `json:"limit,omitempty"`
	Cursor string `json:"cursor,omitempty"`
	Type   string `json:"type,omitempty"`
}

type TriggerPermissionsAddEntitiesResponse

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

type TriggerPermissionsListResponse

type TriggerPermissionsListResponse struct {
	PermissionType string   `json:"permission_type"`
	Users          []string `json:"user_ids"`
	Channels       []string `json:"channel_ids"`
	Teams          []string `json:"team_ids"`
	Organizations  []string `json:"org_ids"`
	// contains filtered or unexported fields
}

type TriggerPermissionsRemoveEntitiesResponse

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

type TriggerPermissionsSetResponse

type TriggerPermissionsSetResponse struct {
	PermissionType string   `json:"permission_type"`
	Users          []string `json:"user_ids"`
	Channels       []string `json:"channel_ids"`
	Teams          []string `json:"team_ids"`
	Organizations  []string `json:"org_ids"`
	// contains filtered or unexported fields
}

type TriggerRequest

type TriggerRequest struct {
	Type          string         `json:"type"`
	Name          string         `json:"name"`
	Description   string         `json:"description"`
	Shortcut      *Shortcut      `json:"shortcut,omitempty"`
	Workflow      string         `json:"workflow"`
	WorkflowAppID string         `json:"workflow_app_id"`
	Inputs        Inputs         `json:"inputs,omitempty"`
	Event         *types.RawJSON `json:"event,omitempty"`
	Schedule      *types.RawJSON `json:"schedule,omitempty"`
	WebHook       *types.RawJSON `json:"webhook,omitempty"`
	Service       *types.RawJSON `json:"service,omitempty"`
}

type TriggerUpdateRequest

type TriggerUpdateRequest struct {
	TriggerRequest
	TriggerID string `json:"trigger_id"`
}

type UpdateAppResult

type UpdateAppResult struct {
	AppID             string      `json:"app_id,omitempty"`
	Credentials       Credentials `json:"credentials,omitempty"` // but will undergo some slimming down in the near future (removal of credentials)
	OAuthAuthorizeURL string      `json:"oauth_authorize_url,omitempty"`
}

UpdateAppResult details returned

type UploadAppArgs

type UploadAppArgs struct {
	AppID       string `json:"app_id,omitempty"`
	ArchiveFile string `json:"file,omitempty"`
}

type UserClient

type UserClient interface {
	UsersInfo(ctx context.Context, token, userID string) (*types.UserInfo, error)
}

type UserInfoResponse

type UserInfoResponse struct {
	User types.UserInfo `json:"user"`
	// contains filtered or unexported fields
}

type ValidateAppManifestResult

type ValidateAppManifestResult struct {
	Warnings slackerror.Warnings
}

type VariablesClient

type VariablesClient interface {
	AddVariable(ctx context.Context, token, appID, name, value string) error
	ListVariables(ctx context.Context, token, appID string) ([]string, error)
	RemoveVariable(ctx context.Context, token string, appID string, variableName string) error
}

type WorkflowsClient

type WorkflowsClient interface {
	WorkflowsTriggersCreate(context.Context, string, TriggerRequest) (types.DeployedTrigger, error)
	WorkflowsTriggersUpdate(context.Context, string, TriggerUpdateRequest) (types.DeployedTrigger, error)
	WorkflowsTriggersDelete(context.Context, string, string) error
	WorkflowsTriggersInfo(context.Context, string, string) (types.DeployedTrigger, error)
	WorkflowsTriggersList(context.Context, string, TriggerListRequest) ([]types.DeployedTrigger, string, error)
}

For easy mocking

Jump to

Keyboard shortcuts

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