Documentation ¶
Index ¶
- Constants
- func BuildRequestDetailMessage(o RequestDetailMessageOpts) (summary string, msg slack.Message)
- func BuildRequestReviewMessage(o RequestMessageOpts) (summary string, msg slack.Message)
- func SendMessage(ctx context.Context, slackClient *slack.Client, ...) (timestamp string, error error)
- func SendMessageBlocks(ctx context.Context, slackClient *slack.Client, userEmail string, ...) (timestamp string, error error)
- type RequestDetailMessageOpts
- type RequestMessageOpts
- type SlackDirectMessage
- type SlackIncomingWebhook
- type SlackNotifier
- func (n *SlackNotifier) HandleEvent(ctx context.Context, event events.CloudWatchEvent) (err error)
- func (n *SlackNotifier) HandleGrantEvent(ctx context.Context, log *zap.SugaredLogger, event events.CloudWatchEvent) error
- func (n *SlackNotifier) HandleRequestEvent(ctx context.Context, log *zap.SugaredLogger, event events.CloudWatchEvent) error
- func (n *SlackNotifier) Init(ctx context.Context, config *deploy.Notifications) error
- func (n *SlackNotifier) RenderRequestArguments(ctx context.Context, log *zap.SugaredLogger, request access.Request, ...) ([]types.With, error)
- func (n *SlackNotifier) SendDMWithLogOnError(ctx context.Context, log *zap.SugaredLogger, userId, msg, fallback string) (timestamp string)
- func (sl *SlackNotifier) SendTestMessage(ctx context.Context, email string) error
- func (n *SlackNotifier) SendUpdatesForRequest(ctx context.Context, log *zap.SugaredLogger, request access.Request, ...)
- func (n *SlackNotifier) UpdateMessageBlockForReviewer(ctx context.Context, reviewer access.Reviewer, message slack.Message) error
Constants ¶
const NotificationsTypeSlack = "slack"
Variables ¶
This section is empty.
Functions ¶
func BuildRequestDetailMessage ¶ added in v0.11.1
func BuildRequestDetailMessage(o RequestDetailMessageOpts) (summary string, msg slack.Message)
Builds a contextual request detail message, with an optional HeadingMessage to be rendered in the header, this is fired after a request has been reviewed
func BuildRequestReviewMessage ¶ added in v0.12.0
func BuildRequestReviewMessage(o RequestMessageOpts) (summary string, msg slack.Message)
*
- BuildRequestReviewMessage builds a slack message for a request review based on the contextual RequestMessageOpts
func SendMessage ¶
func SendMessage(ctx context.Context, slackClient *slack.Client, userID, message, summary string, accessory *slack.Accessory) (timestamp string, error error)
SendMessage is a utility for sending DMs to users by ID
The message may be markdown formatted. The summary must be plaintext and is used as the fallback message in Slack notifications.
func SendMessageBlocks ¶
func SendMessageBlocks(ctx context.Context, slackClient *slack.Client, userEmail string, message slack.Message, summary string) (timestamp string, error error)
SendMessageBlocks is a utility for sending DMs to users by ID
The message is in Slack message block format. The summary must be plaintext and is used as the fallback message in Slack notifications. The mesage is addressed to userEmail (therefore this is for DMs only, no webhook support)
Types ¶
type RequestDetailMessageOpts ¶ added in v0.11.1
type RequestMessageOpts ¶
type RequestMessageOpts struct { Request access.Request RequestArguments []types.With Rule rule.AccessRule ReviewURLs notifiers.ReviewURLs // optional field that will replace the default requestor email with a slack @mention RequestorSlackID string RequestorEmail string WasReviewed bool RequestReviewer *identity.User //Optional field for a user or group to be tagged in the message. MentionUser string IsWebhook bool }
type SlackDirectMessage ¶
type SlackDirectMessage struct {
// contains filtered or unexported fields
}
func (*SlackDirectMessage) Config ¶
func (s *SlackDirectMessage) Config() gconfig.Config
func (*SlackDirectMessage) TestConfig ¶
func (s *SlackDirectMessage) TestConfig(ctx context.Context) error
type SlackIncomingWebhook ¶
type SlackIncomingWebhook struct {
// contains filtered or unexported fields
}
func (*SlackIncomingWebhook) Config ¶
func (s *SlackIncomingWebhook) Config() gconfig.Config
func (*SlackIncomingWebhook) SendWebhookMessage ¶
type SlackNotifier ¶
type SlackNotifier struct { DB ddb.Storage FrontendURL string // contains filtered or unexported fields }
SlackNotifier provides handler methods for sending notifications to Slack based on events. It has config for sending Slack DMs and/or messaging via Incoming Webhooks.
func (*SlackNotifier) HandleEvent ¶
func (n *SlackNotifier) HandleEvent(ctx context.Context, event events.CloudWatchEvent) (err error)
func (*SlackNotifier) HandleGrantEvent ¶
func (n *SlackNotifier) HandleGrantEvent(ctx context.Context, log *zap.SugaredLogger, event events.CloudWatchEvent) error
func (*SlackNotifier) HandleRequestEvent ¶
func (n *SlackNotifier) HandleRequestEvent(ctx context.Context, log *zap.SugaredLogger, event events.CloudWatchEvent) error
func (*SlackNotifier) Init ¶
func (n *SlackNotifier) Init(ctx context.Context, config *deploy.Notifications) error
func (*SlackNotifier) RenderRequestArguments ¶
func (n *SlackNotifier) RenderRequestArguments(ctx context.Context, log *zap.SugaredLogger, request access.Request, rule rule.AccessRule) ([]types.With, error)
This method maps request arguments in a deprecated way. it should be replaced eventually with a cache lookup for the options available for the access rule
func (*SlackNotifier) SendDMWithLogOnError ¶
func (n *SlackNotifier) SendDMWithLogOnError(ctx context.Context, log *zap.SugaredLogger, userId, msg, fallback string) (timestamp string)
SendDMWithLogOnError attempts to fetch a user from cognito to get their email, then tries to send them a message in slack, this is used to send PMs to users for updated access details
This will log any errors and continue
func (*SlackNotifier) SendTestMessage ¶
func (sl *SlackNotifier) SendTestMessage(ctx context.Context, email string) error
SendTestMessage is a helper used for customers to test their slack integration settings
func (*SlackNotifier) SendUpdatesForRequest ¶
func (n *SlackNotifier) SendUpdatesForRequest(ctx context.Context, log *zap.SugaredLogger, request access.Request, requestEvent gevent.RequestEventPayload, rule rule.AccessRule, requestingUser *identity.User)
func (*SlackNotifier) UpdateMessageBlockForReviewer ¶
func (n *SlackNotifier) UpdateMessageBlockForReviewer(ctx context.Context, reviewer access.Reviewer, message slack.Message) error
UpdateMessageBlocks is a utility for updating DMs to users by ID
The message is in Slack message block format. userId is the reviewer