kubesphere.io/api@v0.0.0-20231107125330-c9a03957060c/notification/v2beta2/router_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  type Channel struct {
    24  	Tenant string `json:"tenant"`
    25  	// Receiver type, known values are dingtalk, email, feishu, slack, sms, pushover, webhook, wechat.
    26  	Type []string `json:"type,omitempty"`
    27  }
    28  
    29  type ReceiverSelector struct {
    30  	Name      []string              `json:"name,omitempty"`
    31  	RegexName string                `json:"regexName,omitempty"`
    32  	Selector  *metav1.LabelSelector `json:"selector,omitempty"`
    33  	Channels  []Channel             `json:"channels,omitempty"`
    34  	// Receiver type, known values are dingtalk, email, feishu, slack, sms, pushover, webhook, wechat.
    35  	Type string `json:"type,omitempty"`
    36  }
    37  
    38  // RouterSpec defines the desired state of Router
    39  type RouterSpec struct {
    40  	// whether the router is enabled
    41  	Enabled       *bool                 `json:"enabled,omitempty"`
    42  	AlertSelector *metav1.LabelSelector `json:"alertSelector"`
    43  	// Receivers which need to receive the matched alert.
    44  	Receivers ReceiverSelector `json:"receivers"`
    45  }
    46  
    47  // RouterStatus defines the observed state of Router
    48  type RouterStatus struct {
    49  }
    50  
    51  // +kubebuilder:object:root=true
    52  // +kubebuilder:resource:scope=Cluster,categories=notification-manager
    53  // +kubebuilder:subresource:status
    54  // +kubebuilder:storageversion
    55  // +genclient
    56  // +genclient:nonNamespaced
    57  // Router is the Schema for the router API
    58  type Router struct {
    59  	metav1.TypeMeta   `json:",inline"`
    60  	metav1.ObjectMeta `json:"metadata,omitempty"`
    61  
    62  	Spec   RouterSpec   `json:"spec,omitempty"`
    63  	Status RouterStatus `json:"status,omitempty"`
    64  }
    65  
    66  // +kubebuilder:object:root=true
    67  
    68  // RouterList contains a list of Router
    69  type RouterList struct {
    70  	metav1.TypeMeta `json:",inline"`
    71  	metav1.ListMeta `json:"metadata,omitempty"`
    72  	Items           []Router `json:"items"`
    73  }
    74  
    75  func init() {
    76  	SchemeBuilder.Register(&Router{}, &RouterList{})
    77  }