github.com/chnsz/golangsdk@v0.0.0-20240506093406-85a3fbfa605b/openstack/apigw/dedicated/v2/endpoints/results.go (about) 1 package endpoints 2 3 import "github.com/chnsz/golangsdk/pagination" 4 5 // CreateResp is the structure that represents the response to adding permission records. 6 type createResp struct { 7 // The permission list of endpoint service. 8 Permissions []string `json:"permissions"` 9 } 10 11 // EndpointPermission is the structure that represents the permission detail. 12 type EndpointPermission struct { 13 // The permission ID. 14 ID string `json:"id"` 15 // The permission of endpoint service. 16 Permission string `json:"permission"` 17 // The creation time, in UTC format. 18 CreatedAt string `json:"created_at"` 19 } 20 21 // PermissionPage is a single page maximum result representing a query by offset page. 22 type PermissionPage struct { 23 pagination.OffsetPageBase 24 } 25 26 // IsEmpty checks whether a PermissionPage struct is empty. 27 func (b PermissionPage) IsEmpty() (bool, error) { 28 arr, err := ExtractPermissions(b) 29 return len(arr) == 0, err 30 } 31 32 // ExtractPermissions is a method to extract the list of permissions for specified endpoint service. 33 func ExtractPermissions(r pagination.Page) ([]EndpointPermission, error) { 34 var s []EndpointPermission 35 err := r.(PermissionPage).Result.ExtractIntoSlicePtr(&s, "permissions") 36 return s, err 37 }