blob: d3cc1ceaf798bff5cb055ff2f8b166c821b51669 [file] [log] [blame]
jrperrittc5c590a2016-11-04 14:41:15 -05001package members
2
3import (
jrperrittc5c590a2016-11-04 14:41:15 -05004 "time"
5
6 "github.com/gophercloud/gophercloud"
7 "github.com/gophercloud/gophercloud/pagination"
8)
9
10// Member model
11type Member struct {
jrperritt98d01622017-01-12 14:24:42 -060012 CreatedAt time.Time `json:"created_at"`
jrperrittc5c590a2016-11-04 14:41:15 -050013 ImageID string `json:"image_id"`
14 MemberID string `json:"member_id"`
15 Schema string `json:"schema"`
16 Status string `json:"status"`
jrperritt98d01622017-01-12 14:24:42 -060017 UpdatedAt time.Time `json:"updated_at"`
jrperrittc5c590a2016-11-04 14:41:15 -050018}
19
20// Extract Member model from request if possible
21func (r commonResult) Extract() (*Member, error) {
22 var s *Member
23 err := r.ExtractInto(&s)
24 return s, err
25}
26
27// MemberPage is a single page of Members results.
28type MemberPage struct {
29 pagination.SinglePageBase
30}
31
32// ExtractMembers returns a slice of Members contained in a single page of results.
33func ExtractMembers(r pagination.Page) ([]Member, error) {
34 var s struct {
35 Members []Member `json:"members"`
36 }
37 err := r.(MemberPage).ExtractInto(&s)
38 return s.Members, err
39}
40
41// IsEmpty determines whether or not a page of Members contains any results.
42func (r MemberPage) IsEmpty() (bool, error) {
43 members, err := ExtractMembers(r)
44 return len(members) == 0, err
45}
46
47type commonResult struct {
48 gophercloud.Result
49}
50
51// CreateResult result model
52type CreateResult struct {
53 commonResult
54}
55
56// DetailsResult model
57type DetailsResult struct {
58 commonResult
59}
60
61// UpdateResult model
62type UpdateResult struct {
63 commonResult
64}
65
66// DeleteResult model
67type DeleteResult struct {
68 gophercloud.ErrResult
69}