kubesphere.io/api@v0.0.0-20231107125330-c9a03957060c/notification/v2beta2/config_types.go (about) 1 /* 2 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package v2beta2 18 19 import ( 20 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 21 ) 22 23 // DingTalkApplicationConfig it th configuration of conversation 24 type DingTalkApplicationConfig struct { 25 // The key of the application with which to send messages. 26 AppKey *Credential `json:"appkey"` 27 // The key in the secret to be used. Must be a valid secret key. 28 AppSecret *Credential `json:"appsecret"` 29 } 30 31 type DingTalkConfig struct { 32 Labels map[string]string `json:"labels,omitempty"` 33 // Only needed when send alerts to the conversation. 34 Conversation *DingTalkApplicationConfig `json:"conversation,omitempty"` 35 } 36 37 type ClientCertificate struct { 38 // The client cert file for the targets. 39 Cert *Credential `json:"cert"` 40 // The client key file for the targets. 41 Key *Credential `json:"key"` 42 } 43 44 // TLSConfig configures the options for TLS connections. 45 type TLSConfig struct { 46 // RootCA defines the root certificate authorities 47 // that clients use when verifying server certificates. 48 RootCA *Credential `json:"rootCA,omitempty"` 49 // The certificate of the client. 50 *ClientCertificate `json:"clientCertificate,omitempty"` 51 // Used to verify the hostname for the targets. 52 ServerName string `json:"serverName,omitempty"` 53 // Disable target certificate validation. 54 InsecureSkipVerify bool `json:"insecureSkipVerify,omitempty"` 55 } 56 57 // BasicAuth contains basic HTTP authentication credentials. 58 type BasicAuth struct { 59 Username string `json:"username"` 60 Password *Credential `json:"password,omitempty"` 61 } 62 63 // HTTPClientConfig configures an HTTP client. 64 type HTTPClientConfig struct { 65 // The HTTP basic authentication credentials for the targets. 66 BasicAuth *BasicAuth `json:"basicAuth,omitempty"` 67 // The bearer token for the targets. 68 BearerToken *Credential `json:"bearerToken,omitempty"` 69 // HTTP proxy server to use to connect to the targets. 70 ProxyURL string `json:"proxyUrl,omitempty"` 71 // TLSConfig to use to connect to the targets. 72 TLSConfig *TLSConfig `json:"tlsConfig,omitempty"` 73 } 74 75 type HostPort struct { 76 Host string `json:"host"` 77 Port int `json:"port"` 78 } 79 80 type EmailConfig struct { 81 Labels map[string]string `json:"labels,omitempty"` 82 // The sender address. 83 From string `json:"from"` 84 // The address of the SMTP server. 85 SmartHost HostPort `json:"smartHost"` 86 // The hostname to use when identifying to the SMTP server. 87 Hello *string `json:"hello,omitempty"` 88 // The username for CRAM-MD5, LOGIN and PLAIN authentications. 89 AuthUsername *string `json:"authUsername,omitempty"` 90 // The identity for PLAIN authentication. 91 AuthIdentify *string `json:"authIdentify,omitempty"` 92 // The secret contains the SMTP password for LOGIN and PLAIN authentications. 93 AuthPassword *Credential `json:"authPassword,omitempty"` 94 // The secret contains the SMTP secret for CRAM-MD5 authentication. 95 AuthSecret *Credential `json:"authSecret,omitempty"` 96 // The default SMTP TLS requirement. 97 RequireTLS *bool `json:"requireTLS,omitempty"` 98 TLS *TLSConfig `json:"tls,omitempty"` 99 } 100 101 type SlackConfig struct { 102 Labels map[string]string `json:"labels,omitempty"` 103 // The token of user or bot. 104 SlackTokenSecret *Credential `json:"slackTokenSecret"` 105 } 106 107 type WebhookConfig struct { 108 Labels map[string]string `json:"labels,omitempty"` 109 } 110 111 type WechatConfig struct { 112 Labels map[string]string `json:"labels,omitempty"` 113 // The WeChat API URL. 114 WechatApiUrl string `json:"wechatApiUrl,omitempty"` 115 // The corp id for authentication. 116 WechatApiCorpId string `json:"wechatApiCorpId"` 117 // The id of the application which sending message. 118 WechatApiAgentId string `json:"wechatApiAgentId"` 119 // The API key to use when talking to the WeChat API. 120 WechatApiSecret *Credential `json:"wechatApiSecret"` 121 } 122 123 // Sms Aliyun provider parameters 124 type AliyunSMS struct { 125 SignName string `json:"signName"` 126 TemplateCode string `json:"templateCode,omitempty"` 127 AccessKeyId *Credential `json:"accessKeyId"` 128 AccessKeySecret *Credential `json:"accessKeySecret"` 129 } 130 131 // Sms tencent provider parameters 132 type TencentSMS struct { 133 Sign string `json:"sign"` 134 TemplateID string `json:"templateID"` 135 SmsSdkAppid string `json:"smsSdkAppid"` 136 SecretId *Credential `json:"secretId"` 137 SecretKey *Credential `json:"secretKey"` 138 } 139 140 // Sms huawei provider parameters 141 type HuaweiSMS struct { 142 Url string `json:"url,omitempty"` 143 Signature string `json:"signature"` 144 TemplateId string `json:"templateId"` 145 Sender string `json:"sender"` 146 AppSecret *Credential `json:"appSecret"` 147 AppKey *Credential `json:"appKey"` 148 } 149 150 // Sms AWS provider parameters 151 type AWSSMS struct { 152 Region string `json:"region,omitempty"` 153 AccessKeyId *Credential `json:"accessKeyId"` 154 SecretAccessKey *Credential `json:"secretAccessKey"` 155 } 156 157 type Providers struct { 158 Aliyun *AliyunSMS `json:"aliyun,omitempty"` 159 Tencent *TencentSMS `json:"tencent,omitempty"` 160 Huawei *HuaweiSMS `json:"huawei,omitempty"` 161 AWS *AWSSMS `json:"aws,omitempty"` 162 } 163 164 type SmsConfig struct { 165 // The default sms provider, optional, use the first provider if not set 166 DefaultProvider string `json:"defaultProvider,omitempty"` 167 // All sms providers 168 Providers *Providers `json:"providers"` 169 } 170 171 type PushoverConfig struct { 172 Labels map[string]string `json:"labels,omitempty"` 173 // The token of a pushover application. 174 PushoverTokenSecret *Credential `json:"pushoverTokenSecret"` 175 } 176 177 // FeishuConfig is the configuration of feishu application 178 type FeishuConfig struct { 179 // The id of the application with which to send messages. 180 AppID *Credential `json:"appID"` 181 // The key in the secret to be used. Must be a valid secret key. 182 AppSecret *Credential `json:"appSecret"` 183 } 184 185 // ConfigSpec defines the desired state of Config 186 type ConfigSpec struct { 187 DingTalk *DingTalkConfig `json:"dingtalk,omitempty"` 188 Email *EmailConfig `json:"email,omitempty"` 189 Slack *SlackConfig `json:"slack,omitempty"` 190 Webhook *WebhookConfig `json:"webhook,omitempty"` 191 Wechat *WechatConfig `json:"wechat,omitempty"` 192 Sms *SmsConfig `json:"sms,omitempty"` 193 Pushover *PushoverConfig `json:"pushover,omitempty"` 194 Feishu *FeishuConfig `json:"feishu,omitempty"` 195 } 196 197 // ConfigStatus defines the observed state of Config 198 type ConfigStatus struct { 199 } 200 201 // +kubebuilder:object:root=true 202 // +kubebuilder:resource:scope=Cluster,shortName=nc,categories=notification-manager 203 // +kubebuilder:subresource:status 204 // +kubebuilder:storageversion 205 // +genclient 206 // +genclient:nonNamespaced 207 208 // Config is the Schema for the configs API 209 type Config struct { 210 metav1.TypeMeta `json:",inline"` 211 metav1.ObjectMeta `json:"metadata,omitempty"` 212 213 Spec ConfigSpec `json:"spec,omitempty"` 214 Status ConfigStatus `json:"status,omitempty"` 215 } 216 217 // +kubebuilder:object:root=true 218 219 // ConfigList contains a list of Config 220 type ConfigList struct { 221 metav1.TypeMeta `json:",inline"` 222 metav1.ListMeta `json:"metadata,omitempty"` 223 Items []Config `json:"items"` 224 } 225 226 func init() { 227 SchemeBuilder.Register(&Config{}, &ConfigList{}) 228 }