github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/ces/v1/events/ListEvents.go (about) 1 package events 2 3 import ( 4 golangsdk "github.com/opentelekomcloud/gophertelekomcloud" 5 "github.com/opentelekomcloud/gophertelekomcloud/internal/extract" 6 ) 7 8 type ListEventsOpts struct { 9 // Specifies the event type. Possible types are EVENT.SYS (system event) and EVENT.CUSTOM (custom event). 10 EventType string `q:"event_type,omitempty"` 11 // Specifies the event name. The name can be a system event name or a custom event name. 12 EventName string `q:"event_name,omitempty"` 13 // Specifies the start time of the query. The time is a UNIX timestamp and the unit is ms. Example: 1605952700911 14 From int64 `q:"from,omitempty"` 15 // Specifies the end time of the query. The time is a UNIX timestamp and the unit is ms. 16 // from must be smaller than to. For example, set to 1606557500911. 17 To int64 `q:"to,omitempty"` 18 // Specifies the start value of pagination. The value is an integer. The default value is 0. 19 Start int `q:"start,omitempty"` 20 // Specifies the maximum number of events that can be queried at a time. Supported range: 1 to 100 (default) 21 Limit int `q:"limit,omitempty"` 22 } 23 24 func ListEvents(client *golangsdk.ServiceClient, opts ListEventsOpts) (*ListEventsResponse, error) { 25 url, err := golangsdk.NewURLBuilder().WithEndpoints("events").WithQueryParams(&opts).Build() 26 if err != nil { 27 return nil, err 28 } 29 30 // GET /V1.0/{project_id}/events 31 raw, err := client.Get(client.ServiceURL(url.String()), nil, nil) 32 if err != nil { 33 return nil, err 34 } 35 36 var res ListEventsResponse 37 err = extract.Into(raw.Body, &res) 38 return &res, err 39 } 40 41 type ListEventsResponse struct { 42 // Specifies one or more pieces of event data. 43 Events []EventInfo `json:"events,omitempty"` 44 // Specifies the number of metadata records in the query result. 45 MetaData TotalMetaData `json:"meta_data,omitempty"` 46 } 47 48 type EventInfo struct { 49 // Specifies the event name. 50 EventName string `json:"event_name,omitempty"` 51 // Specifies the event type. 52 EventType string `json:"event_type,omitempty"` 53 // Specifies the number of occurrences of this event within the specified query time range. 54 EventCount int `json:"event_count,omitempty"` 55 // Specifies when the event last occurred. 56 LatestOccurTime int64 `json:"latest_occur_time,omitempty"` 57 // Specifies the event source. If the event is a system event, the value is the namespace of each service. 58 // To view the namespace of each service, see A.1 Services Interconnected with Cloud Eye. 59 // If the event is a custom event, the event source is defined by the user. 60 LatestEventSource string `json:"latest_event_source,omitempty"` 61 }