@@ -84,12 +84,32 @@ func Delete(client *gophercloud.ServiceClient, imageID string, memberID string)
84
84
return res
85
85
}
86
86
87
- // Update fuction updates member
87
+ // UpdateOptsBuilder allows extensions to add additional attributes to the Update request.
88
+ type UpdateOptsBuilder interface {
89
+ ToMemberUpdateMap () map [string ]interface {}
90
+ }
91
+
92
+ // UpdateOpts implements UpdateOptsBuilder
93
+ type UpdateOpts struct {
94
+ Status string
95
+ }
96
+
97
+ // ToMemberUpdateMap formats an UpdateOpts structure into a request body.
98
+ func (opts UpdateOpts ) ToMemberUpdateMap () map [string ]interface {} {
99
+ m := make (map [string ]interface {})
100
+
101
+ if opts .Status != "" {
102
+ m ["status" ] = opts .Status
103
+ }
104
+
105
+ return m
106
+ }
107
+
108
+ // Update function updates member
88
109
// More details: http://developer.openstack.org/api-ref-image-v2.html#updateImageMember-v2
89
- func Update (client * gophercloud.ServiceClient , imageID string , memberID string , status string ) MemberUpdateResult {
110
+ func Update (client * gophercloud.ServiceClient , imageID string , memberID string , opts UpdateOptsBuilder ) MemberUpdateResult {
90
111
var res MemberUpdateResult
91
- body := map [string ]interface {}{}
92
- body ["status" ] = status
112
+ body := opts .ToMemberUpdateMap ()
93
113
_ , res .Err = client .Put (imageMemberURL (client , imageID , memberID ), body , & res .Body ,
94
114
& gophercloud.RequestOpts {OkCodes : []int {200 }})
95
115
return res
0 commit comments