github.com/chnsz/golangsdk@v0.0.0-20240506093406-85a3fbfa605b/openstack/workspace/v2/groups/results.go (about) 1 package groups 2 3 import "github.com/chnsz/golangsdk/pagination" 4 5 // UserGroup is the structure that represents the user group detail. 6 type UserGroup struct { 7 // The ID of user group. 8 ID string `json:"id"` 9 // The name of user group. 10 Name string `json:"name"` 11 // The type of user group. 12 Type string `json:"platform_type"` 13 // The description of user group. 14 Description string `json:"description"` 15 // The creation time of user group. 16 CreatedAt string `json:"create_time"` 17 // The number of users in the user group. 18 UserQuantity int `json:"user_quantity"` 19 // The domain ID of the user group. 20 RealmID string `json:"realm_id"` 21 // The specific name of user group. 22 GroupDN string `json:"group_dn"` 23 // The domain name of the user group. 24 Domain string `json:"domain"` 25 // The sID of user group. 26 SID string `json:"sid"` 27 // The number of desktops owned by all users in the user group. 28 TotalDesktops int `json:"total_desktops"` 29 } 30 31 // listUserResp is the structure that represents the API response of ListUser method request. 32 type listUserResp struct { 33 // Total number of users. 34 TotalCount int `json:"total_count"` 35 // User list. 36 Users []User `json:"users"` 37 } 38 39 // User is the structure that represents the user detail under a user group. 40 type User struct { 41 // The ID of user. 42 ID string `json:"id"` 43 // The name of user. 44 Name string `json:"user_name"` 45 // The email of user. 46 Email string `json:"user_email"` 47 // The phone of user. 48 Phone string `json:"user_phone"` 49 // The description of user . 50 Description string `json:"description"` 51 // The number of desktops the user has. 52 TotalDesktops int `json:"total_desktops"` 53 } 54 55 // UserGroupPage represents the response pages of the List method. 56 type UserGroupPage struct { 57 pagination.OffsetPageBase 58 } 59 60 // IsEmpty method checks whether the current user group page is empty. 61 func (b UserGroupPage) IsEmpty() (bool, error) { 62 arr, err := ExtractUserGroupPages(b) 63 return len(arr) == 0, err 64 } 65 66 // ExtractUserGroupPages is a method to extract the list of user group details. 67 func ExtractUserGroupPages(r pagination.Page) ([]UserGroup, error) { 68 var s []UserGroup 69 err := r.(UserGroupPage).Result.ExtractIntoSlicePtr(&s, "user_groups") 70 return s, err 71 }