Jon Perritt | 0037e63 | 2015-01-19 11:15:58 -0700 | [diff] [blame^] | 1 | package serviceassets |
| 2 | |
| 3 | import ( |
| 4 | "github.com/racker/perigee" |
| 5 | "github.com/rackspace/gophercloud" |
| 6 | ) |
| 7 | |
| 8 | // DeleteOptsBuilder allows extensions to add additional parameters to the Delete |
| 9 | // request. |
| 10 | type DeleteOptsBuilder interface { |
| 11 | ToCDNAssetDeleteParams() (string, error) |
| 12 | } |
| 13 | |
| 14 | // DeleteOpts is a structure that holds options for deleting CDN service assets. |
| 15 | type DeleteOpts struct { |
| 16 | // If all is set to true, specifies that the delete occurs against all of the |
| 17 | // assets for the service. |
| 18 | All bool `q:"all"` |
| 19 | // Specifies the relative URL of the asset to be deleted. |
| 20 | URL string `q:"url"` |
| 21 | } |
| 22 | |
| 23 | // ToCDNAssetDeleteParams formats a DeleteOpts into a query string. |
| 24 | func (opts DeleteOpts) ToCDNAssetDeleteParams() (string, error) { |
| 25 | q, err := gophercloud.BuildQueryString(opts) |
| 26 | if err != nil { |
| 27 | return "", err |
| 28 | } |
| 29 | return q.String(), nil |
| 30 | } |
| 31 | |
| 32 | // Delete accepts a unique ID and deletes the CDN service asset associated with |
| 33 | // it. |
| 34 | func Delete(c *gophercloud.ServiceClient, id string, opts DeleteOptsBuilder) DeleteResult { |
| 35 | var res DeleteResult |
| 36 | _, res.Err = perigee.Request("DELETE", deleteURL(c, id), perigee.Options{ |
| 37 | MoreHeaders: c.AuthenticatedHeaders(), |
| 38 | OkCodes: []int{202}, |
| 39 | }) |
| 40 | return res |
| 41 | } |