Documentation ¶
Index ¶
- Constants
- type Action
- type AppConfig
- type CardElement
- type Channel
- type Client
- type ClientOption
- type Config
- type Element
- type Encryptor
- type Header
- type LarkCaller
- type LarkCredentialConfig
- type Message
- type MessageCard
- type NotificationConfig
- type PluginService
- func (s *PluginService) BuildData(ctx context.Context, configurations map[string]any) (map[string]any, error)
- func (s *PluginService) GetSystemDefaultTemplate() string
- func (s *PluginService) PostHookDBTransformConfigs(ctx context.Context, notificationConfigMap map[string]any) (map[string]any, error)
- func (s *PluginService) PostHookQueueTransformConfigs(ctx context.Context, notificationConfigMap map[string]any) (map[string]any, error)
- func (s *PluginService) PreHookDBTransformConfigs(ctx context.Context, configurations map[string]any) (map[string]any, error)
- func (s *PluginService) PreHookQueueTransformConfigs(ctx context.Context, configurations map[string]any) (map[string]any, error)
- func (s *PluginService) Send(ctx context.Context, notificationMessage notification.Message) (bool, error)
- type ReceiverConfig
- type ReceiverData
- type ServiceOption
- type SubscriptionConfig
- type Text
Constants ¶
const ( TypeChannelChannel = "channel" TypeChannelUser = "user" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AppConfig ¶
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 CardElement ¶
type CardElement struct { Title string `json:"title,omitempty"` Pretext string `json:"pretext,omitempty"` Text string `json:"text,omitempty"` Actions []Action `json:"actions,omitempty"` }
func (CardElement) ToLark ¶
func (ma CardElement) ToLark() (*CardElement, error)
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClient ¶
func NewClient(cfg AppConfig, opts ...ClientOption) *Client
NewClient is a constructor to create lark client. this version uses lark v3 SDK.
func (*Client) GetWorkspaceChannels ¶
func (c *Client) GetWorkspaceChannels(ctx context.Context, clientID, clientSecret secret.MaskableString) ([]Channel, error)
GetWorkspaceChannels fetches list of joined channel of a client
type ClientOption ¶
type ClientOption func(*Client)
func ClientWithHTTPClient ¶
func ClientWithHTTPClient(httpClient *httpclient.Client) ClientOption
ClientWithHTTPClient assigns custom http client when creating a lark client
func ClientWithRetrier ¶
func ClientWithRetrier(runner retry.Runner) ClientOption
ClientWithRetrier wraps client call with retrier
type Encryptor ¶
type Encryptor interface { Encrypt(str secret.MaskableString) (secret.MaskableString, error) Decrypt(str secret.MaskableString) (secret.MaskableString, error) }
type LarkCaller ¶
type LarkCredentialConfig ¶
type LarkCredentialConfig struct { ClientID string `mapstructure:"client_id"` ClientSecret string `mapstructure:"client_secret"` }
LarkCredentialConfig is config that needs to be passed when a new lark receiver is being added
func (*LarkCredentialConfig) Validate ¶
func (c *LarkCredentialConfig) Validate() error
type Message ¶
type Message struct { Color string `yaml:"templatecolor,omitempty" json:"templatecolor,omitempty" mapstructure:"templatecolor"` 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"` Elements []CardElement `yaml:"elements,omitempty" json:"attachments,omitempty" mapstructure:"elements"` }
func (Message) BuildLarkMessage ¶
type MessageCard ¶
type NotificationConfig ¶
type NotificationConfig struct { ReceiverConfig `mapstructure:",squash"` SubscriptionConfig `mapstructure:",squash"` }
NotificationConfig has all configs needed to send notification
func (*NotificationConfig) AsMap ¶
func (c *NotificationConfig) AsMap() map[string]any
func (*NotificationConfig) Validate ¶
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 ¶
type PluginService struct { base.UnimplementedService // contains filtered or unexported fields }
PluginService is a plugin service layer for lark
func NewPluginService ¶
func NewPluginService(cfg AppConfig, cryptoClient Encryptor, opts ...ServiceOption) *PluginService
NewPluginService returns lark plugin service struct. This service implement [receiver.Resolver] and notification.Notifier interface.
func (*PluginService) BuildData ¶
func (s *PluginService) BuildData(ctx context.Context, configurations map[string]any) (map[string]any, error)
BuildData populates receiver data field based on config
func (*PluginService) GetSystemDefaultTemplate ¶
func (s *PluginService) GetSystemDefaultTemplate() string
func (*PluginService) PostHookDBTransformConfigs ¶
func (*PluginService) PostHookQueueTransformConfigs ¶
func (*PluginService) PreHookDBTransformConfigs ¶
func (*PluginService) PreHookQueueTransformConfigs ¶
func (*PluginService) Send ¶
func (s *PluginService) Send(ctx context.Context, notificationMessage notification.Message) (bool, error)
type ReceiverConfig ¶
type ReceiverConfig struct { ClientID secret.MaskableString `mapstructure:"client_id"` ClientSecret secret.MaskableString `mapstructure:"client_secret"` }
ReceiverConfig is a stored config for a lark receiver
func (*ReceiverConfig) AsMap ¶
func (c *ReceiverConfig) AsMap() map[string]any
func (*ReceiverConfig) Validate ¶
func (c *ReceiverConfig) Validate() error
type ReceiverData ¶
type ReceiverData struct {
Channels string `json:"channels" mapstructure:"channels"`
}
ReceiverData is a stored data for a lark receiver
func (*ReceiverData) AsMap ¶
func (c *ReceiverData) AsMap() map[string]any
type ServiceOption ¶
type ServiceOption func(*PluginService)
func WithHTTPClient ¶
func WithHTTPClient(httpClient *httpclient.Client) ServiceOption
WithHTTPClient assigns custom http client when creating a lark service
func WithLarkClient ¶
func WithLarkClient(client LarkCaller) ServiceOption
func WithRetrier ¶
func WithRetrier(runner retry.Runner) ServiceOption
WithRetrier wraps client call with retrier
type SubscriptionConfig ¶
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 lark receiver
func (*SubscriptionConfig) AsMap ¶
func (c *SubscriptionConfig) AsMap() map[string]any