@@ -179,6 +179,48 @@ func Delete(ctx context.Context, client *gophercloud.ServiceClient, zoneID strin
179179 return
180180}
181181
182+ // ListSharesOptsBuilder allows extensions to add additional parameters to the List
183+ // request.
184+ type ListSharesOptsBuilder interface {
185+ ToZoneListSharesHeadersMap () (map [string ]string , error )
186+ }
187+
188+ // ListSharesOpts is a structure that holds parameters for listing zone shares.
189+ type ListSharesOpts struct {
190+ AllProjects bool `h:"X-Auth-All-Projects"`
191+ }
192+
193+ // ToZoneListSharesHeadersMap formats a ListSharesOpts into header parameters.
194+ func (opts ListSharesOpts ) ToZoneListSharesHeadersMap () (map [string ]string , error ) {
195+ return gophercloud .BuildHeaders (opts )
196+ }
197+
198+ // ListShares implements a zone list shares request.
199+ func ListShares (client * gophercloud.ServiceClient , zoneID string , opts ListSharesOptsBuilder ) pagination.Pager {
200+ var h map [string ]string
201+ var err error
202+
203+ if opts != nil {
204+ h , err = opts .ToZoneListSharesHeadersMap ()
205+ if err != nil {
206+ return pagination.Pager {Err : err }
207+ }
208+ }
209+
210+ pager := pagination .NewPager (client , sharesBaseURL (client , zoneID ), func (r pagination.PageResult ) pagination.Page {
211+ return ZoneSharePage {pagination.LinkedPageBase {PageResult : r }}
212+ })
213+ pager .Headers = h
214+ return pager
215+ }
216+
217+ // GetShare returns information about a shared zone, given its ID.
218+ func GetShare (ctx context.Context , client * gophercloud.ServiceClient , zoneID , shareID string ) (r ZoneShareResult ) {
219+ resp , err := client .Get (ctx , shareURL (client , zoneID , shareID ), & r .Body , nil )
220+ _ , r .Header , r .Err = gophercloud .ParseResponse (resp , err )
221+ return
222+ }
223+
182224// request body for sharing a zone.
183225type ShareOptsBuilder interface {
184226 ToShareMap () (map [string ]interface {}, error )
@@ -198,14 +240,14 @@ func (opts ShareZoneOpts) ToShareMap() (map[string]interface{}, error) {
198240}
199241
200242// Share shares a zone with another project.
201- func Share (ctx context.Context , client * gophercloud.ServiceClient , zoneID string , opts ShareOptsBuilder ) (r gophercloud. ErrResult ) {
243+ func Share (ctx context.Context , client * gophercloud.ServiceClient , zoneID string , opts ShareOptsBuilder ) (r ZoneShareResult ) {
202244 body , err := gophercloud .BuildRequestBody (opts , "" )
203245 if err != nil {
204246 r .Err = err
205247 return
206248 }
207249
208- resp , err := client .Post (ctx , zoneShareURL (client , zoneID ), body , nil , & gophercloud.RequestOpts {
250+ resp , err := client .Post (ctx , sharesBaseURL (client , zoneID ), body , & r . Body , & gophercloud.RequestOpts {
209251 OkCodes : []int {201 },
210252 })
211253 _ , r .Header , r .Err = gophercloud .ParseResponse (resp , err )
@@ -214,7 +256,7 @@ func Share(ctx context.Context, client *gophercloud.ServiceClient, zoneID string
214256
215257// Unshare removes a share for a zone.
216258func Unshare (ctx context.Context , client * gophercloud.ServiceClient , zoneID , shareID string ) (r gophercloud.ErrResult ) {
217- resp , err := client .Delete (ctx , zoneUnshareURL (client , zoneID , shareID ), & gophercloud.RequestOpts {
259+ resp , err := client .Delete (ctx , shareURL (client , zoneID , shareID ), & gophercloud.RequestOpts {
218260 OkCodes : []int {204 },
219261 })
220262 _ , r .Header , r .Err = gophercloud .ParseResponse (resp , err )
0 commit comments