Documentation
¶
Index ¶
- Constants
- type AppConfig
- type Channel
- type Client
- func (c *Client) ExchangeAuth(ctx context.Context, authCode, clientID, clientSecret string) (Credential, error)
- func (c *Client) GetWorkspaceChannels(ctx context.Context, token secret.MaskableString) ([]Channel, error)
- func (c *Client) Notify(ctx context.Context, conf NotificationConfig, message Message) error
- type ClientOption
- type Credential
- type Encryptor
- type GoSlackCaller
- type Message
- type MessageAttachment
- type NotificationConfig
- type PluginService
- func (s *PluginService) BuildData(ctx context.Context, configurations map[string]interface{}) (map[string]interface{}, error)
- func (s *PluginService) GetSystemDefaultTemplate() string
- func (s *PluginService) PostHookDBTransformConfigs(ctx context.Context, configurations map[string]interface{}) (map[string]interface{}, error)
- func (s *PluginService) PostHookQueueTransformConfigs(ctx context.Context, notificationConfigMap map[string]interface{}) (map[string]interface{}, error)
- func (s *PluginService) PreHookDBTransformConfigs(ctx context.Context, configurations map[string]interface{}) (map[string]interface{}, error)
- func (s *PluginService) PreHookQueueTransformConfigs(ctx context.Context, notificationConfigMap map[string]interface{}) (map[string]interface{}, error)
- func (s *PluginService) Send(ctx context.Context, notificationMessage notification.Message) (bool, error)
- type ReceiverConfig
- type ReceiverData
- type ServiceOption
- type SlackCaller
- type SlackCredentialConfig
- type SubscriptionConfig
Constants ¶
const ( TypeChannelChannel = "channel" TypeChannelUser = "user" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AppConfig ¶ added in v0.5.0
type AppConfig struct {
APIHost string `mapstructure:"api_host"`
Retry retry.Config `mapstructure:"retry"`
HTTPClient httpclient.Config `mapstructure:"http_client"`
}
AppConfig is a config loaded when siren is started
type Client ¶ added in v0.5.0
type Client struct {
// contains filtered or unexported fields
}
func NewClient ¶ added in v0.5.0
func NewClient(cfg AppConfig, opts ...ClientOption) *Client
NewClient is a constructor to create slack client. this version uses go-slack client and this construction wraps the client.
func (*Client) ExchangeAuth ¶ added in v0.5.0
func (c *Client) ExchangeAuth(ctx context.Context, authCode, clientID, clientSecret string) (Credential, error)
ExchangeAuth submits client ID, client secret, and auth code and retrieve acces token and team name
func (*Client) GetWorkspaceChannels ¶ added in v0.5.0
func (c *Client) GetWorkspaceChannels(ctx context.Context, token secret.MaskableString) ([]Channel, error)
GetWorkspaceChannels fetches list of joined channel of a client
type ClientOption ¶ added in v0.5.0
type ClientOption func(*Client)
func ClientWithHTTPClient ¶ added in v0.5.0
func ClientWithHTTPClient(httpClient *httpclient.Client) ClientOption
ClientWithHTTPClient assigns custom http client when creating a slack client
func ClientWithRetrier ¶ added in v0.5.0
func ClientWithRetrier(runner retry.Runner) ClientOption
ClientWithRetrier wraps client call with retrier
type Credential ¶ added in v0.5.0
type Credential struct {
AccessToken secret.MaskableString
TeamName string
}
type Encryptor ¶ added in v0.5.0
type Encryptor interface {
Encrypt(str secret.MaskableString) (secret.MaskableString, error)
Decrypt(str secret.MaskableString) (secret.MaskableString, error)
}
type GoSlackCaller ¶ added in v0.5.0
type GoSlackCaller interface {
GetConversationsForUserContext(ctx context.Context, params *goslack.GetConversationsForUserParameters) (channels []goslack.Channel, nextCursor string, err error)
GetUserByEmailContext(ctx context.Context, email string) (*goslack.User, error)
SendMessageContext(ctx context.Context, channel string, options ...goslack.MsgOption) (string, string, string, error)
}
type Message ¶ added in v0.5.0
type Message struct {
Channel string `yaml:"channel,omitempty" json:"channel,omitempty" mapstructure:"channel"`
Text string `yaml:"text,omitempty" json:"text,omitempty" mapstructure:"text"`
Username string `yaml:"username,omitempty" json:"username,omitempty" mapstructure:"username"`
IconEmoji string `yaml:"icon_emoji,omitempty" json:"icon_emoji,omitempty" mapstructure:"icon_emoji"`
IconURL string `yaml:"icon_url,omitempty" json:"icon_url,omitempty" mapstructure:"icon_url"`
LinkNames bool `yaml:"link_names,omitempty" json:"link_names,omitempty" mapstructure:"link_names"`
Attachments []MessageAttachment `yaml:"attachments,omitempty" json:"attachments,omitempty" mapstructure:"attachments"`
}
TODO support block-kit messages
type MessageAttachment ¶ added in v0.5.0
type MessageAttachment map[string]interface{}
func (MessageAttachment) ToGoSlack ¶ added in v0.5.0
func (ma MessageAttachment) ToGoSlack() (*goslack.Attachment, error)
type NotificationConfig ¶ added in v0.5.0
type NotificationConfig struct {
ReceiverConfig `mapstructure:",squash"`
SubscriptionConfig `mapstructure:",squash"`
}
NotificationConfig has all configs needed to send notification
func (*NotificationConfig) AsMap ¶ added in v0.5.0
func (c *NotificationConfig) AsMap() map[string]interface{}
func (*NotificationConfig) Validate ¶ added in v0.5.0
func (c *NotificationConfig) Validate() error
Validate validates whether notification config contains required fields or not channel_name is not mandatory because in NotifyToReceiver flow, channel_name is being passed from the request (not from the config)
type PluginService ¶ added in v0.5.0
type PluginService struct {
base.UnimplementedService
// contains filtered or unexported fields
}
PluginService is a plugin service layer for slack
func NewPluginService ¶ added in v0.5.0
func NewPluginService(cfg AppConfig, cryptoClient Encryptor, opts ...ServiceOption) *PluginService
NewPluginService returns slack plugin service struct. This service implement [receiver.Resolver] and notification.Notifier interface.
func (*PluginService) BuildData ¶ added in v0.5.0
func (s *PluginService) BuildData(ctx context.Context, configurations map[string]interface{}) (map[string]interface{}, error)
BuildData populates receiver data field based on config
func (*PluginService) GetSystemDefaultTemplate ¶ added in v0.5.0
func (s *PluginService) GetSystemDefaultTemplate() string
func (*PluginService) PostHookDBTransformConfigs ¶ added in v0.5.0
func (s *PluginService) PostHookDBTransformConfigs(ctx context.Context, configurations map[string]interface{}) (map[string]interface{}, error)
PostHookTransformConfigs do transformation in post-hook service lifecycle
func (*PluginService) PostHookQueueTransformConfigs ¶ added in v0.5.0
func (*PluginService) PreHookDBTransformConfigs ¶ added in v0.5.0
func (*PluginService) PreHookQueueTransformConfigs ¶ added in v0.5.0
func (*PluginService) Send ¶ added in v0.5.0
func (s *PluginService) Send(ctx context.Context, notificationMessage notification.Message) (bool, error)
type ReceiverConfig ¶ added in v0.5.0
type ReceiverConfig struct {
Token secret.MaskableString `json:"token" mapstructure:"token"`
Workspace string `json:"workspace" mapstructure:"workspace"`
}
ReceiverConfig is a stored config for a slack receiver
func (*ReceiverConfig) AsMap ¶ added in v0.5.0
func (c *ReceiverConfig) AsMap() map[string]interface{}
func (*ReceiverConfig) Validate ¶ added in v0.5.0
func (c *ReceiverConfig) Validate() error
type ReceiverData ¶ added in v0.5.0
type ReceiverData struct {
Channels string `json:"channels" mapstructure:"channels"`
}
ReceiverData is a stored data for a slack receiver
func (*ReceiverData) AsMap ¶ added in v0.5.0
func (c *ReceiverData) AsMap() map[string]interface{}
type ServiceOption ¶ added in v0.5.0
type ServiceOption func(*PluginService)
func WithHTTPClient ¶ added in v0.5.0
func WithHTTPClient(httpClient *httpclient.Client) ServiceOption
WithHTTPClient assigns custom http client when creating a slack service
func WithRetrier ¶ added in v0.5.0
func WithRetrier(runner retry.Runner) ServiceOption
WithRetrier wraps client call with retrier
func WithSlackClient ¶ added in v0.5.0
func WithSlackClient(client SlackCaller) ServiceOption
type SlackCaller ¶ added in v0.5.0
type SlackCredentialConfig ¶ added in v0.5.0
type SlackCredentialConfig struct {
ClientID string `mapstructure:"client_id"`
ClientSecret string `mapstructure:"client_secret"`
AuthCode string `mapstructure:"auth_code"`
}
SlackCredentialConfig is config that needs to be passed when a new slack receiver is being added
func (*SlackCredentialConfig) Validate ¶ added in v0.5.0
func (c *SlackCredentialConfig) Validate() error
type SubscriptionConfig ¶ added in v0.5.0
type SubscriptionConfig struct {
ChannelName string `json:"channel_name" mapstructure:"channel_name"`
ChannelType string `json:"channel_type" mapstructure:"channel_type"`
}
SubscriptionConfig is a stored config for a subscription of a slack receiver
func (*SubscriptionConfig) AsMap ¶ added in v0.5.0
func (c *SubscriptionConfig) AsMap() map[string]interface{}