Documentation
¶
Index ¶
- Constants
- func BuildFilter(filterJSON string, queryCSV string) (any, string, error)
- func BuildRuleParam(eventKey string, opts RuleOptions) (ruleType string, ruleParam map[string]any, err error)
- func CanonicalJSON(v any) (string, error)
- func IdempotencyKey(identity Identity, eventKey, ruleType string, ruleParam map[string]any, ...) string
- func IsPublic(eventKey string) bool
- func IsSchemaPending(err error) bool
- func PublicAvailabilityError(eventKey string) error
- func RemoveRunStates(workDir string, subscribeIDs []string) error
- func UpsertRunState(workDir string, st RunState) error
- type APIError
- type Client
- func (c *Client) CreateSubscription(ctx context.Context, req CreateSubscriptionRequest) (*Subscription, error)
- func (c *Client) DeleteSubscription(ctx context.Context, subscribeID string) error
- func (c *Client) GetSubscription(ctx context.Context, subscribeID string) (*Subscription, error)
- func (c *Client) ListSubscriptions(ctx context.Context, opts ListOptions) ([]Subscription, error)
- type CreateSubscriptionRequest
- type Definition
- type Identity
- type ListOptions
- type RuleOptions
- type RunState
- type SchemaDocument
- type SchemaPendingError
- type Subscription
Constants ¶
View Source
const ( EventMention = "user_im_message_receive_at" EventSingleChat = "user_im_message_receive_o2o" EventInChat = "user_im_message_receive_group" EventFromUser = "user_im_message_receive_user" )
View Source
const ( StatusEnabled = "enabled" StatusPending = "pending" )
View Source
const ( StateFileName = "personal_subscriptions.json" StateLockFileName = "personal_subscriptions.lock" )
View Source
const DefaultBasePath = "/dws"
Variables ¶
This section is empty.
Functions ¶
func BuildRuleParam ¶
func CanonicalJSON ¶
func IdempotencyKey ¶
func IsSchemaPending ¶
func PublicAvailabilityError ¶
func RemoveRunStates ¶
func UpsertRunState ¶
Types ¶
type APIError ¶
type Client ¶
func (*Client) CreateSubscription ¶
func (c *Client) CreateSubscription(ctx context.Context, req CreateSubscriptionRequest) (*Subscription, error)
func (*Client) DeleteSubscription ¶
func (*Client) GetSubscription ¶
func (*Client) ListSubscriptions ¶
func (c *Client) ListSubscriptions(ctx context.Context, opts ListOptions) ([]Subscription, error)
type CreateSubscriptionRequest ¶
type CreateSubscriptionRequest struct {
EventKey string `json:"event_key"`
RuleType string `json:"rule_type"`
Name string `json:"name,omitempty"`
RuleParam map[string]any `json:"rule_param"`
Filter any `json:"filter,omitempty"`
Delivery map[string]any `json:"delivery"`
TTLSeconds int64 `json:"ttl_seconds,omitempty"`
IdempotencyKey string `json:"idempotency_key,omitempty"`
}
type Definition ¶
type Definition struct {
EventKey string `json:"event_key"`
DisplayName string `json:"display_name"`
Description string `json:"description"`
Category string `json:"category"`
RuleType string `json:"rule_type"`
Status string `json:"status"`
RequiredParams []string `json:"required_params"`
Auth map[string]any `json:"auth,omitempty"`
Public bool `json:"-"`
}
func Catalog ¶
func Catalog(category string, enabledOnly, includePending bool) []Definition
func Definitions ¶
func Definitions() []Definition
func Lookup ¶
func Lookup(eventKey string) (Definition, bool)
type Identity ¶
type ListOptions ¶
type RuleOptions ¶
type RunState ¶
type RunState struct {
SubscribeID string `json:"subscribe_id"`
EventKey string `json:"event_key,omitempty"`
RuleType string `json:"rule_type,omitempty"`
ClientID string `json:"client_id,omitempty"`
SourceID string `json:"source_id,omitempty"`
IdentityHash string `json:"identity_hash,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
func LoadRunStates ¶
type SchemaDocument ¶
type SchemaDocument struct {
EventKey string `json:"event_key"`
DisplayName string `json:"display_name"`
Description string `json:"description"`
Category string `json:"category"`
RuleType string `json:"rule_type"`
RequiredParams []string `json:"required_params"`
JQRootPath string `json:"jq_root_path"`
Schema map[string]any `json:"schema"`
}
func BuildSchemaDocument ¶
func BuildSchemaDocument(def Definition) SchemaDocument
type SchemaPendingError ¶
type SchemaPendingError struct {
EventKey string
}
func (*SchemaPendingError) Error ¶
func (e *SchemaPendingError) Error() string
type Subscription ¶
type Subscription struct {
SubscribeID string `json:"subscribe_id"`
EventKey string `json:"event_key,omitempty"`
RuleType string `json:"rule_type,omitempty"`
Status string `json:"status,omitempty"`
SourceID string `json:"source_id,omitempty"`
CreatedAt string `json:"created_at,omitempty"`
ExpiresAt *time.Time `json:"expires_at,omitempty"`
}
Click to show internal directories.
Click to hide internal directories.