models

package
v0.3.11-8 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2024 License: Apache-2.0 Imports: 55 Imported by: 4

Documentation

Index

Constants

View Source
const (
	DefaultResourceCreateDelete       = "resource create or delete"
	DefaultResourceChangeConfig       = "resource change config"
	DefaultResourceUpdate             = "resource update"
	DefaultResourceReleaseDue1Day     = "resource release due 1 day"
	DefaultResourceReleaseDue3Day     = "resource release due 3 day"
	DefaultResourceReleaseDue30Day    = "resource release due 30 day"
	DefaultResourceRelease            = "resource release"
	DefaultScheduledTaskExecute       = "scheduled task execute"
	DefaultScalingPolicyExecute       = "scaling policy execute"
	DefaultSnapshotPolicyExecute      = "snapshot policy execute"
	DefaultResourceOperationFailed    = "resource operation failed"
	DefaultResourceOperationSuccessed = "resource operation successed"
	DefaultResourceSync               = "resource sync"
	DefaultSystemExceptionEvent       = "system exception event"
	DefaultChecksumTestFailed         = "checksum test failed"
	DefaultUserLock                   = "user lock"
	DefaultActionLogExceedCount       = "action log exceed count"
	DefaultSyncAccountStatus          = "cloud account sync status"
	DefaultPasswordExpireDue1Day      = "password expire due 1 day"
	DefaultPasswordExpireDue7Day      = "password expire due 7 day"
	DefaultPasswordExpire             = "password expire"
	DefaultNetOutOfSync               = "net out of sync"
	DefaultMysqlOutOfSync             = "mysql out of sync"
	DefaultServiceAbnormal            = "service abnormal"
	DefaultServerPanicked             = "server panicked"
	DefaultAttachOrDetach             = "resource attach or detach"
	DefaultIsolatedDeviceChanged      = "isolated device changed"
	DefaultStatusChanged              = "resource status changed"
)
View Source
const (
	CONTACTTYPE_ALL = "all"
)
View Source
const (
	ReceiverIdDefault = "default"
)
View Source
const (
	SendByContact = "send_by_contact"
)

Variables

View Source
var (
	ErrContactNotFound = errors.New("Contact Not Found")
	ErrVeritying       = errors.New("During the verification process, please do not try again")

	ErrDial         = errors.New("Dial Failed")
	ErrGetConfig    = errors.New("Get Config Failed")
	ErrUpdateConfig = errors.New("Update Config Failed")
)
View Source
var (
	PersonalConfigContactTypes = []string{
		api.EMAIL,
		api.MOBILE,
		api.DINGTALK,
		api.FEISHU,
		api.WORKWX,
	}
	RobotContactTypes = []string{
		api.FEISHU_ROBOT,
		api.DINGTALK_ROBOT,
		api.WORKWX_ROBOT,
	}
	SystemConfigContactTypes = append(
		RobotContactTypes,
		api.WEBCONSOLE,
		api.WEBHOOK,
	)
)
View Source
var ConfigMap map[string]SConfig
View Source
var ErrVerifyFrequently = errors.Wrap(httperrors.ErrTooManyRequests, "Send validation messages too frequently")
View Source
var LaxMobileRegexp = regexp.MustCompile(`[0-9]{6,14}`)

Functions

func GetRobotTypeById

func GetRobotTypeById(id string) (string, error)

func GetRobotTypes

func GetRobotTypes() []string

func GetSenderTypes

func GetSenderTypes() []string

func GetValidPersonalSenderTypes

func GetValidPersonalSenderTypes() []string

func InitDB

func InitDB() error

func InitEmailQueue

func InitEmailQueue()

func InitEventLog

func InitEventLog()

func InitNotificationLog

func InitNotificationLog()

func InitReceiverProject

func InitReceiverProject(ctx context.Context, userCred mcclient.TokenCredential, isStart bool)

func Register

func Register(driver ISenderDriver)

func SMSRegister

func SMSRegister(driver ISmsDriver)

Types

type IReceiver

type IReceiver interface {
	IsRobot() bool
	IsReceiver() bool
	IsEnabled() bool
	GetDomainId() string
	IsEnabledContactType(string) (bool, error)
	IsVerifiedContactType(string) (bool, error)
	GetContact(string) (string, error)
	GetTemplateLang(context.Context) (string, error)
}

type ISenderDriver

type ISenderDriver interface {
	GetSenderType() string
	Send(ctx context.Context, args api.SendParams) error
	ValidateConfig(ctx context.Context, args api.NotifyConfig) (string, error)
	ContactByMobile(ctx context.Context, mobile, domainId string) (string, error)
	IsRobot() bool
	IsPersonal() bool
	IsSystemConfigContactType() bool
	IsValid() bool
	IsPullType() bool
	GetAccessToken(ctx context.Context, domainId string) error
	RegisterConfig(config SConfig)
}

func GetDriver

func GetDriver(sendType string) ISenderDriver

type ISmsDriver

type ISmsDriver interface {
	Name() string
	Send(args api.SSMSSendParams, isVerify bool, config *api.NotifyConfig) error
	Verify(config *api.NotifyConfig) error
}

func GetSMSDriver

func GetSMSDriver(smsDriver string) ISmsDriver

type SCompanyInfo

type SCompanyInfo struct {
	LoginLogoFormat string `json:"login_logo_format"`
	Copyright       string `json:"copyright"`
	Name            string `json:"name"`
}

type SConfig

type SConfig struct {
	db.SDomainLevelResourceBase

	Type        string                    `width:"15" nullable:"false" create:"required" get:"domain" list:"domain" index:"true"`
	Content     *api.SNotifyConfigContent `nullable:"false" create:"required" update:"domain" get:"domain" list:"domain"`
	Attribution string                    `width:"8" nullable:"false" default:"system" get:"domain" list:"domain" create:"optional"`
}

func (*SConfig) CustomizeDelete

func (c *SConfig) CustomizeDelete(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) error

func (*SConfig) Delete

func (c *SConfig) Delete(ctx context.Context, userCred mcclient.TokenCredential) error

func (*SConfig) GetNotifyConfig

func (c *SConfig) GetNotifyConfig() api.NotifyConfig

func (*SConfig) GetReceivers

func (self *SConfig) GetReceivers() ([]SReceiver, error)

func (*SConfig) PostCreate

func (*SConfig) PostUpdate

func (c *SConfig) PostUpdate(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject)

func (*SConfig) PreDelete

func (c *SConfig) PreDelete(ctx context.Context, userCred mcclient.TokenCredential)

func (*SConfig) RealDelete

func (c *SConfig) RealDelete(ctx context.Context, userCred mcclient.TokenCredential) error

func (*SConfig) StartRepullSubcontactTask

func (c *SConfig) StartRepullSubcontactTask(ctx context.Context, userCred mcclient.TokenCredential, del bool) error

func (*SConfig) ValidateUpdateData

func (c *SConfig) ValidateUpdateData(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, input api.ConfigUpdateInput) (api.ConfigUpdateInput, error)

type SConfigManager

type SConfigManager struct {
	db.SDomainLevelResourceBaseManager
}
var ConfigManager *SConfigManager

func (*SConfigManager) Config

func (self *SConfigManager) Config(contactType, domainId string, attribution string) (*SConfig, error)

func (*SConfigManager) Configs

func (self *SConfigManager) Configs(contactType string) ([]SConfig, error)

Fetch all SConfig struct which type is contactType.

func (*SConfigManager) FetchCustomizeColumns

func (cm *SConfigManager) FetchCustomizeColumns(
	ctx context.Context,
	userCred mcclient.TokenCredential,
	query jsonutils.JSONObject,
	objs []interface{},
	fields stringutils2.SSortedStrings,
	isList bool,
) []api.ConfigDetails

func (*SConfigManager) GetPropertyCapability

func (manager *SConfigManager) GetPropertyCapability(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject) (jsonutils.JSONObject, error)

func (*SConfigManager) HasSystemConfig

func (self *SConfigManager) HasSystemConfig(contactType string) (bool, error)

func (*SConfigManager) InitializeData

func (confManager *SConfigManager) InitializeData() error

func (*SConfigManager) ListItemExportKeys

func (manager *SConfigManager) ListItemExportKeys(ctx context.Context, q *sqlchemy.SQuery, userCred mcclient.TokenCredential, keys stringutils2.SSortedStrings) (*sqlchemy.SQuery, error)

func (*SConfigManager) ListItemFilter

func (self *SConfigManager) ListItemFilter(ctx context.Context, q *sqlchemy.SQuery, userCred mcclient.TokenCredential, input api.ConfigListInput) (*sqlchemy.SQuery, error)

func (*SConfigManager) OrderByExtraFields

func (cm *SConfigManager) OrderByExtraFields(ctx context.Context, q *sqlchemy.SQuery, userCred mcclient.TokenCredential, query api.ConfigListInput) (*sqlchemy.SQuery, error)

func (*SConfigManager) PerformValidate

func (*SConfigManager) QueryDistinctExtraField

func (cm *SConfigManager) QueryDistinctExtraField(q *sqlchemy.SQuery, field string) (*sqlchemy.SQuery, error)

func (*SConfigManager) ValidateCreateData

type SContact

type SContact struct {
	SReceiverBase
	// contains filtered or unexported fields
}

func (*SContact) GetContact

func (s *SContact) GetContact(_ string) (string, error)

func (*SContact) IsReceiver

func (s *SContact) IsReceiver() bool

func (*SContact) IsRobot

func (s *SContact) IsRobot() bool

type SEmailQueue

type SEmailQueue struct {
	db.SLogBase

	RecvAt time.Time `nullable:"false" created_at:"true" index:"true" get:"user" list:"user" json:"recv_at"`

	Dest    string `width:"256" charset:"ascii" nullable:"false" list:"user" create:"admin_required"`
	Subject string `width:"256" charset:"utf8" nullable:"false" list:"user" create:"admin_required"`
	DestCc  string `width:"256" charset:"ascii" nullable:"false" list:"user" create:"admin_optional"`
	DestBcc string `width:"256" charset:"ascii" nullable:"false" list:"user" create:"admin_optional"`

	SessionId string `width:"256" charset:"utf8" nullable:"false" list:"user" create:"admin_optional"`

	Content     jsonutils.JSONObject `length:"long" charset:"utf8" nullable:"false" list:"user" create:"admin_required"`
	MoreDetails jsonutils.JSONObject `length:"long" charset:"utf8" nullable:"true" list:"user" create:"admin_optional"`

	ProjectId string `width:"128" charset:"ascii" list:"user" create:"admin_optional" index:"true"`
	Project   string `width:"128" charset:"utf8" list:"user" create:"admin_optional"`

	ProjectDomainId string `name:"project_domain_id" default:"default" width:"128" charset:"ascii" list:"user" create:"admin_optional"`
	ProjectDomain   string `name:"project_domain" default:"Default" width:"128" charset:"utf8" list:"user" create:"admin_optional"`

	UserId   string `width:"128" charset:"ascii" list:"user" create:"admin_required"`
	User     string `width:"128" charset:"utf8" list:"user" create:"admin_required"`
	DomainId string `width:"128" charset:"ascii" list:"user" create:"admin_optional"`
	Domain   string `width:"128" charset:"utf8" list:"user" create:"admin_optional"`
	Roles    string `width:"64" charset:"utf8" list:"user" create:"admin_optional"`
}

func (*SEmailQueue) Dump

func (eq *SEmailQueue) Dump() string

func (*SEmailQueue) GetRecordTime

func (e *SEmailQueue) GetRecordTime() time.Time

func (*SEmailQueue) PerformSend

func (*SEmailQueue) PostCreate

func (eq *SEmailQueue) PostCreate(
	ctx context.Context,
	userCred mcclient.TokenCredential,
	ownerId mcclient.IIdentityProvider,
	query jsonutils.JSONObject,
	data jsonutils.JSONObject,
)

func (*SEmailQueue) Run

func (eq *SEmailQueue) Run()

type SEmailQueueManager

type SEmailQueueManager struct {
	db.SLogBaseManager
}
var EmailQueueManager *SEmailQueueManager

func (*SEmailQueueManager) FetchCustomizeColumns

func (manager *SEmailQueueManager) FetchCustomizeColumns(
	ctx context.Context,
	userCred mcclient.TokenCredential,
	query jsonutils.JSONObject,
	objs []interface{},
	fields stringutils2.SSortedStrings,
	isList bool,
) []api.EmailQueueDetails

func (*SEmailQueueManager) ListItemFilter

func (manager *SEmailQueueManager) ListItemFilter(
	ctx context.Context,
	q *sqlchemy.SQuery,
	userCred mcclient.TokenCredential,
	query api.EmailQueueListInput,
) (*sqlchemy.SQuery, error)

宿主机/物理机列表

func (*SEmailQueueManager) ValidateCreateData

type SEmailQueueStatus

type SEmailQueueStatus struct {
	db.SModelBase

	Id int64 `primary:"true" list:"user"`

	SentAt time.Time `list:"user"`

	Status string `width:"16" charset:"ascii" default:"queued" list:"user"`

	Results string `list:"user" charset:"utf8"`
}

type SEmailQueueStatusManager

type SEmailQueueStatusManager struct {
	db.SModelBaseManager
}
var EmailQueueStatusManager *SEmailQueueStatusManager

type SEvent

type SEvent struct {
	db.SLogBase

	// 资源创建时间
	CreatedAt time.Time `nullable:"false" created_at:"true" index:"true" get:"user" list:"user" json:"created_at"`

	Message      string `length:"medium"`
	Event        string `width:"64" nullable:"true"`
	ResourceType string `width:"64" nullable:"true"`
	Action       string `width:"64" nullable:"true"`
	AdvanceDays  int
	TopicId      string `width:"128" nullable:"true" index:"true"`
}

func (*SEvent) GetRecordTime

func (e *SEvent) GetRecordTime() time.Time

type SEventDisplay

type SEventDisplay struct {
	ResourceTypeDisplay string
	ActionDisplay       string
	AdvanceDays         int
	// contains filtered or unexported fields
}

type SEventManager

type SEventManager struct {
	db.SLogBaseManager
}
var EventManager *SEventManager

func (*SEventManager) CreateEvent

func (e *SEventManager) CreateEvent(ctx context.Context, event, topicId, message, action, resourceType string, advanceDays int) (*SEvent, error)

func (*SEventManager) GetEvent

func (e *SEventManager) GetEvent(id string) (*SEvent, error)

type SNotification

type SNotification struct {
	db.SStatusStandaloneResourceBase

	ContactType string `width:"128" nullable:"true" create:"optional" list:"user" get:"user"`
	// swagger:ignore
	Topic    string `width:"128" nullable:"true" create:"required" list:"user" get:"user"`
	Priority string `width:"16" nullable:"true" create:"optional" list:"user" get:"user"`
	// swagger:ignore
	Message string `create:"required"`
	// swagger:ignore
	TopicType string `json:"topic_type" width:"20" nullable:"true" update:"user" list:"user"`
	// swagger:ignore
	TopicId    string    `width:"128" nullable:"true" list:"user" get:"user"`
	ReceivedAt time.Time `nullable:"true" list:"user" get:"user"`
	EventId    string    `width:"128" nullable:"true"`

	SendTimes int
}

站内信

func (*SNotification) AddOne

func (n *SNotification) AddOne() error

func (*SNotification) Create

func (n *SNotification) Create(ctx context.Context, userCred mcclient.TokenCredential, receiverIds map[string]uint32, contacts []string) error

func (*SNotification) CustomizeCreate

func (*SNotification) GetNotOKReceivers

func (n *SNotification) GetNotOKReceivers() ([]SReceiver, error)

func (*SNotification) GetTemplate

func (n *SNotification) GetTemplate(ctx context.Context, topicId, lang string, no api.SsNotification) (api.SendParams, error)

获取消息文案

func (*SNotification) Notification

func (n *SNotification) Notification(robotUseTemplate bool) (api.SsNotification, error)

func (*SNotification) PostCreate

func (*SNotification) ReceiverNotificationsNotOK

func (n *SNotification) ReceiverNotificationsNotOK() ([]SReceiverNotification, error)

func (*SNotification) TaskInsert

func (n *SNotification) TaskInsert() error

type SNotificationGroup

type SNotificationGroup struct {
	db.SModelBase

	Id       string `width:"128" nullable:"false" create:"required" list:"user"  index:"true" get:"user"`
	GroupKey string `width:"128" nullable:"false" create:"required" list:"user" get:"user"`
	Title    string
	// swagger:ignore
	Message     string `length:"medium"`
	ReceiverId  string `width:"128" nullable:"false" create:"required" list:"user" get:"user"`
	Body        jsonutils.JSONObject
	Header      jsonutils.JSONObject
	MsgKey      string
	ContactType string `width:"32" nullable:"false" create:"required" list:"user" get:"user"`
	Contact     string `width:"128" nullable:"false" create:"required" list:"user" get:"user"`
	CreatedAt   time.Time
	DomainId    string `width:"128" nullable:"false" create:"required" list:"user" get:"user"`
}

站内信

type SNotificationGroupManager

type SNotificationGroupManager struct {
	db.SModelBaseManager
}
var NotificationGroupManager *SNotificationGroupManager

func (*SNotificationGroupManager) TaskCreate

func (ng *SNotificationGroupManager) TaskCreate(ctx context.Context, contactType string, args apis.SendParams) error

func (*SNotificationGroupManager) TaskSend

type SNotificationLog

type SNotificationLog struct {
	db.SLogBase

	ContactType string `width:"128" nullable:"true" create:"optional" list:"user" get:"user"`
	// swagger:ignore
	Topic    string `width:"128" nullable:"true" create:"required" list:"user" get:"user"`
	Priority string `width:"16" nullable:"true" create:"optional" list:"user" get:"user"`
	// swagger:ignore
	Message string `create:"required"`
	// swagger:ignore
	TopicType  string    `json:"topic_type" width:"20" nullable:"true" update:"user" list:"user"`
	ReceivedAt time.Time `nullable:"true" list:"user" get:"user"`
	EventId    string    `width:"128" nullable:"true"`

	SendTimes int
}

站内信

type SNotificationLogManager

type SNotificationLogManager struct {
	db.SLogBaseManager
}
var NotificationLogManager *SNotificationLogManager

type SNotificationManager

type SNotificationManager struct {
	db.SStatusStandaloneResourceBaseManager
}
var NotificationManager *SNotificationManager

func (*SNotificationManager) FetchCustomizeColumns

func (nm *SNotificationManager) FetchCustomizeColumns(
	ctx context.Context,
	userCred mcclient.TokenCredential,
	query jsonutils.JSONObject,
	objs []interface{},
	fields stringutils2.SSortedStrings,
	isList bool,
) []api.NotificationDetails

func (*SNotificationManager) FetchOwnerId

func (*SNotificationManager) InitializeData

func (nm *SNotificationManager) InitializeData() error

func (*SNotificationManager) ListItemFilter

通知消息列表

func (*SNotificationManager) NamespaceScope

func (nm *SNotificationManager) NamespaceScope() rbacscope.TRbacScope

func (*SNotificationManager) PerformEventNotify

TODO: support project and domain

func (*SNotificationManager) ReSend

func (nm *SNotificationManager) ReSend(ctx context.Context, userCred mcclient.TokenCredential, isStart bool)

func (*SNotificationManager) ResourceScope

func (nm *SNotificationManager) ResourceScope() rbacscope.TRbacScope

type SReceiver

type SReceiver struct {
	db.SVirtualResourceBase
	db.SEnabledResourceBase

	Email string `width:"128" nullable:"false" create:"optional" update:"user" get:"user" list:"user"`
	// swagger:ignore
	Mobile string `width:"32" nullable:"false" create:"optional"`
	Lang   string `width:"8" charset:"ascii" nullable:"false" list:"user" update:"user"`

	// swagger:ignore
	EnabledEmail tristate.TriState `default:"false" update:"user"`
	// swagger:ignore
	VerifiedEmail tristate.TriState `default:"false" update:"user"`

	// swagger:ignore
	EnabledMobile tristate.TriState `default:"false" update:"user"`
	// swagger:ignore
	VerifiedMobile tristate.TriState `default:"false" update:"user"`
}

接收人

func (*SReceiver) CustomizeCreate

func (r *SReceiver) CustomizeCreate(ctx context.Context, userCred mcclient.TokenCredential, ownerId mcclient.IIdentityProvider, query jsonutils.JSONObject, data jsonutils.JSONObject) error

func (*SReceiver) Delete

func (r *SReceiver) Delete(ctx context.Context, userCred mcclient.TokenCredential) error

func (*SReceiver) GetContact

func (r *SReceiver) GetContact(cType string) (string, error)

func (*SReceiver) GetDomainId

func (r *SReceiver) GetDomainId() string

func (*SReceiver) GetEnabledContactTypes

func (r *SReceiver) GetEnabledContactTypes() ([]string, error)

func (*SReceiver) GetName

func (r *SReceiver) GetName() string

func (*SReceiver) GetNotifyReceiver

func (self *SReceiver) GetNotifyReceiver() api.SNotifyReceiver

func (*SReceiver) GetSubContacts

func (self *SReceiver) GetSubContacts() ([]SSubContact, error)

func (*SReceiver) GetTemplateLang

func (r *SReceiver) GetTemplateLang(ctx context.Context) (string, error)

func (*SReceiver) GetVerifiedContactTypes

func (r *SReceiver) GetVerifiedContactTypes() ([]string, error)

func (*SReceiver) IsEnabled

func (r *SReceiver) IsEnabled() bool

func (*SReceiver) IsEnabledContactType

func (r *SReceiver) IsEnabledContactType(ct string) (bool, error)

func (*SReceiver) IsOwner

func (r *SReceiver) IsOwner(userCred mcclient.TokenCredential) bool

func (*SReceiver) IsReceiver

func (r *SReceiver) IsReceiver() bool

func (*SReceiver) IsRobot

func (r *SReceiver) IsRobot() bool

func (*SReceiver) IsVerifiedContactType

func (r *SReceiver) IsVerifiedContactType(ct string) (bool, error)

func (*SReceiver) MarkContactTypeUnVerified

func (r *SReceiver) MarkContactTypeUnVerified(ctx context.Context, contactType string, note string) error

func (*SReceiver) MarkContactTypeVerified

func (r *SReceiver) MarkContactTypeVerified(ctx context.Context, contactType string) error

func (*SReceiver) PerformDisable

func (*SReceiver) PerformEnable

func (*SReceiver) PerformEnableContactType

func (*SReceiver) PerformGetSubscription

获取用户订阅

func (*SReceiver) PerformTriggerVerify

func (*SReceiver) PerformVerify

func (*SReceiver) PostCreate

func (*SReceiver) PostUpdate

func (r *SReceiver) PostUpdate(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject)

func (*SReceiver) PreUpdate

func (r *SReceiver) PreUpdate(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject)

func (*SReceiver) SetContact

func (r *SReceiver) SetContact(cType string, contact string) error

func (*SReceiver) StartSubcontactPullTask

func (r *SReceiver) StartSubcontactPullTask(ctx context.Context, userCred mcclient.TokenCredential, contactTypes []string, parentTaskId string) error

func (*SReceiver) Sync

func (r *SReceiver) Sync(ctx context.Context) error

func (*SReceiver) ValidateUpdateData

type SReceiverBase

type SReceiverBase struct {
}

func (SReceiverBase) GetDomainId

func (s SReceiverBase) GetDomainId() string

func (SReceiverBase) GetTemplateLang

func (s SReceiverBase) GetTemplateLang(ctx context.Context) (string, error)

func (SReceiverBase) IsEnabled

func (s SReceiverBase) IsEnabled() bool

func (SReceiverBase) IsEnabledContactType

func (s SReceiverBase) IsEnabledContactType(_ string) (bool, error)

func (SReceiverBase) IsVerifiedContactType

func (s SReceiverBase) IsVerifiedContactType(_ string) (bool, error)

type SReceiverManager

var ReceiverManager *SReceiverManager

func (*SReceiverManager) CreateByInsertOrUpdate

func (rm *SReceiverManager) CreateByInsertOrUpdate() bool

func (*SReceiverManager) FetchByIDs

func (rm *SReceiverManager) FetchByIDs(ctx context.Context, ids ...string) ([]SReceiver, error)

func (*SReceiverManager) FetchByIdOrNames

func (rm *SReceiverManager) FetchByIdOrNames(ctx context.Context, idOrNames ...string) ([]SReceiver, error)

func (*SReceiverManager) FetchCustomizeColumns

func (rm *SReceiverManager) FetchCustomizeColumns(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, objs []interface{}, fields stringutils2.SSortedStrings, isList bool) []api.ReceiverDetails

func (*SReceiverManager) FetchEnableReceiversByIdOrNames

func (rm *SReceiverManager) FetchEnableReceiversByIdOrNames(ctx context.Context, idOrNames ...string) ([]SReceiver, error)

func (*SReceiverManager) FetchOwnerId

func (*SReceiverManager) FetchSubContacts

func (rm *SReceiverManager) FetchSubContacts(ids []string) (map[string][]SSubContact, error)

func (*SReceiverManager) GetPropertyRoleContactType

func (manager *SReceiverManager) GetPropertyRoleContactType(ctx context.Context, userCred mcclient.TokenCredential, input api.SRoleContactInput) (jsonutils.JSONObject, error)

func (*SReceiverManager) InitializeData

func (rm *SReceiverManager) InitializeData() error

func (*SReceiverManager) ListItemFilter

func (*SReceiverManager) OnAdd

func (rm *SReceiverManager) OnAdd(obj *jsonutils.JSONDict)

Implemente interface EventHandler

func (*SReceiverManager) OnDelete

func (rm *SReceiverManager) OnDelete(obj *jsonutils.JSONDict)

func (*SReceiverManager) OnUpdate

func (rm *SReceiverManager) OnUpdate(oldObj, newObj *jsonutils.JSONDict)

func (*SReceiverManager) OrderByExtraFields

func (rm *SReceiverManager) OrderByExtraFields(ctx context.Context, q *sqlchemy.SQuery, userCred mcclient.TokenCredential, query api.ReceiverListInput) (*sqlchemy.SQuery, error)

func (*SReceiverManager) PerformIntellijGet

func (*SReceiverManager) QueryDistinctExtraField

func (rm *SReceiverManager) QueryDistinctExtraField(q *sqlchemy.SQuery, field string) (*sqlchemy.SQuery, error)

func (*SReceiverManager) ResourceScope

func (rm *SReceiverManager) ResourceScope() rbacscope.TRbacScope

func (*SReceiverManager) StartWatchUserInKeystone

func (rm *SReceiverManager) StartWatchUserInKeystone() error

监听User变化

func (*SReceiverManager) SyncUserFromKeystone

func (manager *SReceiverManager) SyncUserFromKeystone(ctx context.Context, userCred mcclient.TokenCredential, isStart bool)

func (*SReceiverManager) ValidateCreateData

type SReceiverNotification

type SReceiverNotification struct {
	db.SJointResourceBase

	ReceiverID     string `width:"128" charset:"ascii" nullable:"false" index:"true"`
	NotificationID string `width:"128" charset:"ascii" nullable:"false" index:"true"`
	// ignore if ReceiverID is not empty or default
	Contact      string `width:"128" index:"true"`
	ReceiverType string `width:"16"`
	SendAt       time.Time
	SendBy       string `width:"128"`
	Status       string `width:"36" charset:"ascii"`
	FailedReason string `width:"1024"`
	// minutes
	GroupTimes uint32
}

+onecloud:swagger-gen-ignore

func (*SReceiverNotification) AfterSend

func (rn *SReceiverNotification) AfterSend(ctx context.Context, success bool, reason string) error

func (*SReceiverNotification) BeforeSend

func (rn *SReceiverNotification) BeforeSend(ctx context.Context, sendTime time.Time) error

func (*SReceiverNotification) GetReceiver

func (self *SReceiverNotification) GetReceiver() (*SReceiver, error)

func (*SReceiverNotification) Receiver

func (rn *SReceiverNotification) Receiver() (IReceiver, error)

type SReceiverNotificationManager

type SReceiverNotificationManager struct {
	db.SJointResourceBaseManager
}
var ReceiverNotificationManager *SReceiverNotificationManager

func (*SReceiverNotificationManager) Create

func (rnm *SReceiverNotificationManager) Create(ctx context.Context, userCred mcclient.TokenCredential, receiverID string, groupTimes uint32, notificationID string) (*SReceiverNotification, error)

func (*SReceiverNotificationManager) CreateContact

func (rnm *SReceiverNotificationManager) CreateContact(ctx context.Context, userCred mcclient.TokenCredential, contact, notificationID string) (*SReceiverNotification, error)

func (*SReceiverNotificationManager) CreateRobot

func (rnm *SReceiverNotificationManager) CreateRobot(ctx context.Context, userCred mcclient.TokenCredential, RobotID string, groupTimes uint32, notificationID string) (*SReceiverNotification, error)

func (*SReceiverNotificationManager) GetMasterFieldName

func (rnm *SReceiverNotificationManager) GetMasterFieldName() string

func (*SReceiverNotificationManager) GetSlaveFieldName

func (rnm *SReceiverNotificationManager) GetSlaveFieldName() string

func (*SReceiverNotificationManager) InitializeData

func (self *SReceiverNotificationManager) InitializeData() error

func (*SReceiverNotificationManager) SetHandlerProcessTimeout

func (rnm *SReceiverNotificationManager) SetHandlerProcessTimeout(info *appsrv.SHandlerInfo, r *http.Request) time.Duration

type SRobot

type SRobot struct {
	db.SSharableVirtualResourceBase
	db.SEnabledResourceBase

	Type        string               `width:"16" nullable:"false" create:"required" get:"user" list:"user" index:"true"`
	Address     string               `nullable:"false" create:"required" update:"user" get:"user" list:"user"`
	Lang        string               `width:"16" nullable:"false" create:"required" update:"user" get:"user" list:"user"`
	Header      jsonutils.JSONObject `length:"long" charset:"utf8" nullable:"true" list:"user" create:"optional" update:"user"`
	Body        jsonutils.JSONObject `length:"long" charset:"utf8" nullable:"true" list:"user" create:"optional" update:"user"`
	MsgKey      string               `width:"16" nullable:"true"  update:"user" get:"user" list:"user"`
	UseTemplate tristate.TriState    `default:"false" list:"domain" update:"user" create:"admin_optional"`
}

func (*SRobot) CustomizeCreate

func (r *SRobot) CustomizeCreate(ctx context.Context, userCred mcclient.TokenCredential, ownerId mcclient.IIdentityProvider, query jsonutils.JSONObject, data jsonutils.JSONObject) error

func (*SRobot) GetContact

func (r *SRobot) GetContact(ctype string) (string, error)

func (*SRobot) GetDomainId

func (r *SRobot) GetDomainId() string

func (*SRobot) GetName

func (r *SRobot) GetName() string

func (*SRobot) GetTemplateLang

func (r *SRobot) GetTemplateLang(ctx context.Context) (string, error)

func (*SRobot) IsEnabled

func (r *SRobot) IsEnabled() bool

func (*SRobot) IsEnabledContactType

func (r *SRobot) IsEnabledContactType(ctype string) (bool, error)

func (*SRobot) IsReceiver

func (r *SRobot) IsReceiver() bool

func (*SRobot) IsRobot

func (r *SRobot) IsRobot() bool

func (*SRobot) IsVerifiedContactType

func (r *SRobot) IsVerifiedContactType(ctype string) (bool, error)

func (*SRobot) PerformDisable

func (*SRobot) PerformEnable

func (*SRobot) PostDelete

func (r *SRobot) PostDelete(ctx context.Context, userCred mcclient.TokenCredential)

func (*SRobot) PostUpdate

func (r *SRobot) PostUpdate(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject)

func (*SRobot) ValidateUpdateData

func (r *SRobot) ValidateUpdateData(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, input api.RobotUpdateInput) (api.RobotUpdateInput, error)

type SRobotManager

var RobotManager *SRobotManager

func (*SRobotManager) FetchByIdOrNames

func (rm *SRobotManager) FetchByIdOrNames(ctx context.Context, idOrNames ...string) ([]SRobot, error)

func (*SRobotManager) FetchCustomizeColumns

func (rm *SRobotManager) FetchCustomizeColumns(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, objs []interface{}, fields stringutils2.SSortedStrings, isList bool) []api.RobotDetails

func (*SRobotManager) ListItemFilter

func (rm *SRobotManager) ListItemFilter(ctx context.Context, q *sqlchemy.SQuery, userCred mcclient.TokenCredential, input api.RobotListInput) (*sqlchemy.SQuery, error)

func (*SRobotManager) ValidateCreateData

type SSubContact

type SSubContact struct {
	db.SStandaloneResourceBase

	// id of receiver user
	ReceiverID        string            `width:"128" nullable:"false" index:"true"`
	Type              string            `width:"16" nullable:"false" index:"true"`
	Contact           string            `width:"128" nullable:"false"`
	ParentContactType string            `width:"16" nullable:"false"`
	Enabled           tristate.TriState `default:"false"`
	Verified          tristate.TriState `default:"false"`
	VerifiedNote      string            `width:"1024"`
}

+onecloud:swagger-gen-ignore

func (*SSubContact) Disable

func (sc *SSubContact) Disable() error

func (*SSubContact) Disverify

func (sc *SSubContact) Disverify() error

func (*SSubContact) Enable

func (sc *SSubContact) Enable() error

func (*SSubContact) Update

func (sc *SSubContact) Update(contact *string, enabled *bool, verified *bool) error

func (*SSubContact) Verify

func (sc *SSubContact) Verify() error

type SSubContactManager

type SSubContactManager struct {
	db.SStandaloneResourceBaseManager
}
var SubContactManager *SSubContactManager

type SSubscriber

type SSubscriber struct {
	db.SStandaloneAnonResourceBase
	db.SEnabledResourceBase

	TopicId                 string `width:"128" charset:"ascii" nullable:"false" index:"true" get:"user" list:"user" create:"required"`
	Type                    string `width:"16" charset:"ascii" nullable:"false" index:"true" get:"user" list:"user" create:"required"`
	Identification          string `width:"128" charset:"ascii" nullable:"false" index:"true"`
	RoleScope               string `width:"8" charset:"ascii" nullable:"false" get:"user" list:"user" create:"optional"`
	ResourceScope           string `width:"8" charset:"ascii" nullable:"false" get:"user" list:"user" create:"required"`
	ResourceAttributionId   string `width:"128" charset:"ascii" nullable:"false" get:"user" list:"user" create:"optional"`
	ResourceAttributionName string `width:"128" charset:"utf8" list:"user" create:"optional"`
	Scope                   string `width:"128" charset:"ascii" nullable:"false" create:"required"`
	DomainId                string `width:"128" charset:"ascii" nullable:"false" create:"optional"`
	// minutes
	GroupTimes uint32 `nullable:"true" list:"user"  update:"user"`
}

消息订阅接收人

func (*SSubscriber) CustomizeCreate

func (*SSubscriber) CustomizeDelete

func (s *SSubscriber) CustomizeDelete(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) error

func (*SSubscriber) GetEnabledReceivers

func (self *SSubscriber) GetEnabledReceivers() ([]SReceiver, error)

func (*SSubscriber) GetRobot

func (self *SSubscriber) GetRobot() (*SRobot, error)

func (*SSubscriber) PerformChange

func (*SSubscriber) PerformDisable

func (*SSubscriber) PerformEnable

func (*SSubscriber) PerformSetReceiver

func (*SSubscriber) PostCreate

func (*SSubscriber) SetReceivers

func (sr *SSubscriber) SetReceivers(ctx context.Context, receiverIds []string) error

type SSubscriberDis

type SSubscriberDis struct {
	SSubscriber
	ReceiverName string `json:"receiver_name"`
	RoleName     string `json:"role_name"`
}

type SSubscriberManager

var SubscriberManager *SSubscriberManager

func (*SSubscriberManager) FetchCustomizeColumns

func (sm *SSubscriberManager) FetchCustomizeColumns(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, objs []interface{}, fields stringutils2.SSortedStrings, isList bool) []api.SubscriberDetails

func (*SSubscriberManager) InitializeData

func (sm *SSubscriberManager) InitializeData() error

func (*SSubscriberManager) ListItemFilter

func (*SSubscriberManager) QueryDistinctExtraField

func (sm *SSubscriberManager) QueryDistinctExtraField(q *sqlchemy.SQuery, field string) (*sqlchemy.SQuery, error)

func (*SSubscriberManager) ValidateCreateData

type SSubscriberReceiver

type SSubscriberReceiver struct {
	db.SJointResourceBase
	SubscriberId string `width:"36" charset:"ascii" nullable:"false" index:"true"`
	ReceiverId   string `width:"128" charset:"ascii" nullable:"false" index:"true"`
}

type SSubscriberReceiverManager

type SSubscriberReceiverManager struct {
	db.SJointResourceBaseManager
}
var SubscriberReceiverManager *SSubscriberReceiverManager

func (*SSubscriberReceiverManager) GetMasterFieldName

func (srm *SSubscriberReceiverManager) GetMasterFieldName() string

func (*SSubscriberReceiverManager) GetSlaveFieldName

func (srm *SSubscriberReceiverManager) GetSlaveFieldName() string

type STemplate

type STemplate struct {
	db.SStandaloneAnonResourceBase

	ContactType string `width:"16" nullable:"false" create:"required" update:"user" list:"user"`
	Topic       string `width:"128" nullable:"false" create:"required" update:"user" list:"user"`

	// title | content | remote
	TemplateType string `width:"10" nullable:"false" create:"required" update:"user" list:"user"`
	Content      string `length:"text" nullable:"true" create:"required" get:"user" list:"user" update:"user"`
	Lang         string `width:"8" charset:"ascii" nullable:"false" list:"user" update:"user" create:"optional"`
	Example      string `nullable:"true" create:"optional" get:"user" list:"user" update:"user"`
}

func (*STemplate) Execute

func (tm *STemplate) Execute(str string) (string, error)

func (*STemplate) ValidateUpdateData

type STemplateManager

type STemplateManager struct {
	db.SStandaloneAnonResourceBaseManager
}
var TemplateManager *STemplateManager

func (*STemplateManager) FillWithTemplate

func (tm *STemplateManager) FillWithTemplate(ctx context.Context, lang string, no api.SsNotification) (params api.SendParams, err error)

FillWithTemplate will return the title and content generated by corresponding template. Local cache about common template will be considered in case of performance issues.

func (*STemplateManager) GetCompanyInfo

func (tm *STemplateManager) GetCompanyInfo(ctx context.Context) (SCompanyInfo, error)

func (*STemplateManager) GetEmailUrl

func (tm *STemplateManager) GetEmailUrl() string

func (*STemplateManager) InitializeData

func (tm *STemplateManager) InitializeData() error

func (*STemplateManager) ListItemFilter

func (*STemplateManager) PerformSave

func (*STemplateManager) ValidateCreateData

type STopic

type STopic struct {
	db.SEnabledStatusStandaloneResourceBase

	Type        string               `width:"20" nullable:"false" create:"required" update:"user" list:"user"`
	Resources   uint64               `nullable:"false"`
	Actions     uint64               `nullable:"false"`
	Results     tristate.TriState    `default:"true"`
	TitleCn     string               `length:"medium" nullable:"true" charset:"utf8" list:"user" update:"user" create:"optional"`
	TitleEn     string               `length:"medium" nullable:"true" charset:"utf8" list:"user" update:"user" create:"optional"`
	ContentCn   string               `length:"medium" nullable:"true" charset:"utf8" list:"user" update:"user" create:"optional"`
	ContentEn   string               `length:"medium" nullable:"true" charset:"utf8" list:"user" update:"user" create:"optional"`
	GroupKeys   *api.STopicGroupKeys `nullable:"true" list:"user"  update:"user"`
	AdvanceDays []int                `nullable:"true" charset:"utf8" list:"user" update:"user" create:"optional"`

	WebconsoleDisable tristate.TriState
}

消息订阅

func (*STopic) CreateEvent

func (self *STopic) CreateEvent(ctx context.Context, resType, action, message string) (*SEvent, error)

func (*STopic) GetEnabledSubscribers

func (self *STopic) GetEnabledSubscribers(domainId, projectId string) ([]SSubscriber, error)

func (*STopic) PreCheckPerformAction

func (t *STopic) PreCheckPerformAction(
	ctx context.Context, userCred mcclient.TokenCredential,
	action string, query jsonutils.JSONObject, data jsonutils.JSONObject,
) error

func (*STopic) ValidateDeleteCondition

func (ss *STopic) ValidateDeleteCondition(ctx context.Context, info jsonutils.JSONObject) error

func (*STopic) ValidateUpdateData

func (ss *STopic) ValidateUpdateData(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, input api.TopicUpdateInput) (api.TopicUpdateInput, error)

type STopicManager

type STopicManager struct {
	db.SEnabledStatusStandaloneResourceBaseManager
}
var TopicManager *STopicManager

func (*STopicManager) FetchCustomizeColumns

func (sm *STopicManager) FetchCustomizeColumns(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, objs []interface{}, fields stringutils2.SSortedStrings, isList bool) []notify.TopicDetails

func (*STopicManager) GetTopicByEvent

func (sm *STopicManager) GetTopicByEvent(resourceType string, action notify.SAction, isFailed notify.SResult) (*STopic, error)

func (*STopicManager) GetTopicsByEvent

func (sm *STopicManager) GetTopicsByEvent(resourceType string, action notify.SAction, isFailed notify.SResult) ([]STopic, error)

func (*STopicManager) InitializeData

func (sm *STopicManager) InitializeData() error

func (*STopicManager) ListItemFilter

func (sm *STopicManager) ListItemFilter(ctx context.Context, q *sqlchemy.SQuery, userCred mcclient.TokenCredential, input notify.TopicListInput) (*sqlchemy.SQuery, error)

func (*STopicManager) TopicByEvent

func (sm *STopicManager) TopicByEvent(eventStr string) (*STopic, error)

func (*STopicManager) TopicsByEvent

func (sm *STopicManager) TopicsByEvent(eventStr string) ([]STopic, error)

func (*STopicManager) ValidateCreateData

type SVerification

type SVerification struct {
	db.SStandaloneResourceBase

	ReceiverId  string `width:"128" nullable:"false"`
	ContactType string `width:"16" nullable:"false"`
	Token       string `width:"200" nullable:"false"`
}

+onecloud:swagger-gen-ignore

type SVerificationManager

type SVerificationManager struct {
	db.SStandaloneResourceBaseManager
}
var VerificationManager *SVerificationManager

func (*SVerificationManager) Create

func (vm *SVerificationManager) Create(ctx context.Context, receiverId, contactType string) (*SVerification, error)

func (*SVerificationManager) Get

func (vm *SVerificationManager) Get(receiverId, contactType string) (*SVerification, error)

Jump to

Keyboard shortcuts

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