blob: 790ea41f409fd055c6dec975a3a566f741cee5e7 [file] [log] [blame]
Jon Perritt0037e632015-01-19 11:15:58 -07001package serviceassets
2
3import (
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.
10type DeleteOptsBuilder interface {
11 ToCDNAssetDeleteParams() (string, error)
12}
13
14// DeleteOpts is a structure that holds options for deleting CDN service assets.
15type 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.
24func (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.
34func 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}