github.com/chnsz/golangsdk@v0.0.0-20240506093406-85a3fbfa605b/openstack/eg/v1/channel/custom/results.go (about) 1 package custom 2 3 import "github.com/chnsz/golangsdk/pagination" 4 5 // Channel is the structure that represents the channel detail. 6 type Channel struct { 7 // The ID of the channel. 8 ID string `json:"id"` 9 // The name of the channel. 10 Name string `json:"name"` 11 // The description of the channel. 12 Description string `json:"description"` 13 // The type of the channel provider. 14 // + OFFICIAL: official cloud service channel. 15 // + CUSTOM: the user-defined channel. 16 // + PARTNER: partner channel. 17 ProviderType string `json:"provider_type"` 18 // The ID of the enterprise project to which the custom channel belongs. 19 EnterpriseProjectId string `json:"eps_id"` 20 // The creation time, in UTC format. 21 CreatedTime string `json:"created_time"` 22 // The update time, in UTC format. 23 UpdatedTime string `json:"updated_time"` 24 // The cross-account policy configuration. 25 Policy CrossAccountPolicy `json:"policy"` 26 } 27 28 // ChannelPage is a single page maximum result representing a query by offset page. 29 type ChannelPage struct { 30 pagination.OffsetPageBase 31 } 32 33 // IsEmpty checks whether a ChannelPage struct is empty. 34 func (b ChannelPage) IsEmpty() (bool, error) { 35 arr, err := ExtractChannels(b) 36 return len(arr) == 0, err 37 } 38 39 // ExtractChannels is a method to extract the list of custom channels. 40 func ExtractChannels(r pagination.Page) ([]Channel, error) { 41 var s []Channel 42 err := r.(ChannelPage).Result.ExtractIntoSlicePtr(&s, "items") 43 return s, err 44 }