github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/cts/v3/keyevent/List.go (about)

     1  package keyevent
     2  
     3  import (
     4  	golangsdk "github.com/opentelekomcloud/gophertelekomcloud"
     5  	"github.com/opentelekomcloud/gophertelekomcloud/internal/extract"
     6  )
     7  
     8  type ListNotificationsOpts struct {
     9  	// Notification type.
    10  	// Enumerated value:
    11  	// smn
    12  	NotificationType string
    13  	// Notification name. If this parameter is not specified, all key event notifications configured in the current tenant account are returned.
    14  	NotificationName string `q:"notification_name,omitempty"`
    15  }
    16  
    17  func List(client *golangsdk.ServiceClient, opts ListNotificationsOpts) ([]NotificationResponse, error) {
    18  	q, err := golangsdk.BuildQueryString(opts)
    19  	if err != nil {
    20  		return nil, err
    21  	}
    22  
    23  	// GET /v3/{project_id}/notifications/{notification_type}
    24  	url := client.ServiceURL("notifications", opts.NotificationType) + q.String()
    25  	raw, err := client.Get(url, nil, nil)
    26  	if err != nil {
    27  		return nil, err
    28  	}
    29  
    30  	var res []NotificationResponse
    31  	err = extract.IntoSlicePtr(raw.Body, &res, "notifications")
    32  	return res, err
    33  }
    34  
    35  type NotificationResponse struct {
    36  	// Notification name.
    37  	NotificationName string `json:"notification_name,omitempty"`
    38  	// Operation type. Possible options include complete and customized.
    39  	// Enumerated values:
    40  	// customized
    41  	// complete
    42  	OperationType string `json:"operation_type,omitempty"`
    43  	// Operation list.
    44  	Operations []Operations `json:"operations,omitempty"`
    45  	// List of users whose operations will trigger notifications.
    46  	// Currently, up to 50 users in 10 user groups can be configured.
    47  	NotifyUserList []NotificationUsers `json:"notify_user_list,omitempty"`
    48  	// Notification status. Possible options include enabled and disabled.
    49  	// Enumerated values:
    50  	// enabled
    51  	// disabled
    52  	Status string `json:"status,omitempty"`
    53  	// Unique resource ID of an SMN topic. You can obtain the ID by querying the topic list.
    54  	TopicId string `json:"topic_id,omitempty"`
    55  	// Unique notification ID.
    56  	NotificationId string `json:"notification_id,omitempty"`
    57  	// Notification type.
    58  	// Enumerated value:
    59  	// smn
    60  	NotificationType string `json:"notification_type,omitempty"`
    61  	// Project ID.
    62  	ProjectId string `json:"project_id,omitempty"`
    63  	// Time when a notification rule was created.
    64  	CreateTime int64 `json:"create_time,omitempty"`
    65  }