github.com/chnsz/golangsdk@v0.0.0-20240506093406-85a3fbfa605b/openstack/eg/v1/subscriptions/results.go (about) 1 package subscriptions 2 3 import "github.com/chnsz/golangsdk/pagination" 4 5 // Subscription is the structure that represents the event subscription detail. 6 type Subscription struct { 7 // The ID of the event subscription. 8 ID string `json:"id"` 9 // The name of the event subscription. 10 Name string `json:"name"` 11 // The description of the event subscription. 12 Description string `json:"description"` 13 // The type of the event subscription. 14 // + EVENT 15 // + SCHEDULED 16 Type string `json:"type"` 17 // The status of the event subscription. 18 Status string `json:"status"` 19 // The ID of the event channel to which the event subscription belongs. 20 ChannelId string `json:"channel_id"` 21 // The name of the event channel to which the event subscription belongs. 22 ChannelName string `json:"channel_name"` 23 // The list of used resources. 24 Used []UsedInfo `json:"used"` 25 // The list of the event sources. 26 Sources []map[string]interface{} `json:"sources"` 27 // The list of the event targets. 28 Targets []map[string]interface{} `json:"targets"` 29 // The creation time, in UTC format. 30 CreatedTime string `json:"created_time"` 31 // The update time, in UTC format. 32 UpdatedTime string `json:"updated_time"` 33 } 34 35 // UsedInfo is the structure that represents the detail of the used resources. 36 type UsedInfo struct { 37 // Associated resource ID. 38 ResourceId string `json:"resource_id"` 39 // The name of the tenant that owns the resource. 40 Owner string `json:"owner"` 41 // The description. 42 Description string `json:"description"` 43 } 44 45 // SubscriptionPage is a single page maximum result representing a query by offset page. 46 type SubscriptionPage struct { 47 pagination.OffsetPageBase 48 } 49 50 // IsEmpty checks whether a SubscriptionPage struct is empty. 51 func (b SubscriptionPage) IsEmpty() (bool, error) { 52 arr, err := ExtractSubscriptions(b) 53 return len(arr) == 0, err 54 } 55 56 // ExtractSubscriptions is a method to extract the list of subscriptions. 57 func ExtractSubscriptions(r pagination.Page) ([]Subscription, error) { 58 var s []Subscription 59 err := r.(SubscriptionPage).Result.ExtractIntoSlicePtr(&s, "items") 60 return s, err 61 }