github.com/chnsz/golangsdk@v0.0.0-20240506093406-85a3fbfa605b/openstack/eg/v1/source/custom/results.go (about) 1 package custom 2 3 import "github.com/chnsz/golangsdk/pagination" 4 5 // Source is the structure that represents the event source detail. 6 type Source struct { 7 // The ID of the event source. 8 ID string `json:"id"` 9 // The name of the event source. 10 Name string `json:"name"` 11 // The description of the event source. 12 Description string `json:"description"` 13 // The type of the event source provider. 14 // + OFFICIAL: official cloud service event source. 15 // + CUSTOM: the user-defined event source. 16 // + PARTNER: partner event source. 17 ProviderType string `json:"provider_type"` 18 // The list of event types provided by the event source. 19 // Only the official cloud service event source provides event types. 20 EventTypes []EventType `json:"event_types"` 21 // The creation time, in UTC format. 22 CreatedTime string `json:"created_time"` 23 // The update time, in UTC format. 24 UpdatedTime string `json:"updated_time"` 25 // The ID of the event channel to which the event source belongs. 26 ChannelId string `json:"channel_id"` 27 // The name of the event channel to which the event source belongs. 28 ChannelName string `json:"channel_name"` 29 // The type of the event source. 30 // + APPLICATION (default) 31 // + RABBITMQ 32 // + ROCKETMQ 33 Type string `json:"type"` 34 // The configuration detail of the event source, in JSON format. 35 Detail interface{} `json:"detail"` 36 // The status of the event source 37 Status string `json:"status"` 38 } 39 40 // EventType is the structure that represents the event type that provided by the event source. 41 type EventType struct { 42 // The name of the event type. 43 Name string `json:"name"` 44 // The description of the event type. 45 Description string `json:"description"` 46 } 47 48 // SourcePage is a single page maximum result representing a query by offset page. 49 type SourcePage struct { 50 pagination.OffsetPageBase 51 } 52 53 // IsEmpty checks whether a SourcePage struct is empty. 54 func (b SourcePage) IsEmpty() (bool, error) { 55 arr, err := ExtractSources(b) 56 return len(arr) == 0, err 57 } 58 59 // ExtractSources is a method to extract the list of custom event sources. 60 func ExtractSources(r pagination.Page) ([]Source, error) { 61 var s []Source 62 err := r.(SourcePage).Result.ExtractIntoSlicePtr(&s, "items") 63 return s, err 64 }