github.com/gophercloud/gophercloud@v1.11.0/openstack/keymanager/v1/acls/results.go (about) 1 package acls 2 3 import ( 4 "encoding/json" 5 "time" 6 7 "github.com/gophercloud/gophercloud" 8 ) 9 10 // ACL represents an ACL on a resource. 11 type ACL map[string]ACLDetails 12 13 // ACLDetails represents the details of an ACL. 14 type ACLDetails struct { 15 // Created is when the ACL was created. 16 Created time.Time `json:"-"` 17 18 // ProjectAccess denotes project-level access of the resource. 19 ProjectAccess bool `json:"project-access"` 20 21 // Updated is when the ACL was updated 22 Updated time.Time `json:"-"` 23 24 // Users are the UserIDs who have access to the resource. 25 Users []string `json:"users"` 26 } 27 28 func (r *ACLDetails) UnmarshalJSON(b []byte) error { 29 type tmp ACLDetails 30 var s struct { 31 tmp 32 Created gophercloud.JSONRFC3339NoZ `json:"created"` 33 Updated gophercloud.JSONRFC3339NoZ `json:"updated"` 34 } 35 err := json.Unmarshal(b, &s) 36 if err != nil { 37 return err 38 } 39 *r = ACLDetails(s.tmp) 40 41 r.Created = time.Time(s.Created) 42 r.Updated = time.Time(s.Updated) 43 44 return nil 45 } 46 47 // ACLRef represents an ACL reference. 48 type ACLRef string 49 50 type commonResult struct { 51 gophercloud.Result 52 } 53 54 // Extract interprets any commonResult as an ACL. 55 func (r commonResult) Extract() (*ACL, error) { 56 var s *ACL 57 err := r.ExtractInto(&s) 58 return s, err 59 } 60 61 // ACLResult is the response from a Get operation. Call its Extract method 62 // to interpret it as an ACL. 63 type ACLResult struct { 64 commonResult 65 } 66 67 // ACLRefResult is the response from a Set or Update operation. Call its 68 // Extract method to interpret it as an ACLRef. 69 type ACLRefResult struct { 70 gophercloud.Result 71 } 72 73 func (r ACLRefResult) Extract() (*ACLRef, error) { 74 var s struct { 75 ACLRef ACLRef `json:"acl_ref"` 76 } 77 err := r.ExtractInto(&s) 78 return &s.ACLRef, err 79 } 80 81 // DeleteResult is the response from a Delete operation. Call its ExtractErr to 82 // determine if the request succeeded or failed. 83 type DeleteResult struct { 84 gophercloud.ErrResult 85 }