jrperritt | c5c590a | 2016-11-04 14:41:15 -0500 | [diff] [blame] | 1 | package images |
| 2 | |
| 3 | import ( |
| 4 | "strings" |
| 5 | |
Krzysztof Szukiełojć | 3f41d08 | 2017-05-07 14:43:06 +0200 | [diff] [blame^] | 6 | "gerrit.mcp.mirantis.net/debian/gophercloud.git" |
jrperritt | c5c590a | 2016-11-04 14:41:15 -0500 | [diff] [blame] | 7 | ) |
| 8 | |
| 9 | // `listURL` is a pure function. `listURL(c)` is a URL for which a GET |
| 10 | // request will respond with a list of images in the service `c`. |
| 11 | func listURL(c *gophercloud.ServiceClient) string { |
| 12 | return c.ServiceURL("images") |
| 13 | } |
| 14 | |
| 15 | func createURL(c *gophercloud.ServiceClient) string { |
| 16 | return c.ServiceURL("images") |
| 17 | } |
| 18 | |
| 19 | // `imageURL(c,i)` is the URL for the image identified by ID `i` in |
| 20 | // the service `c`. |
| 21 | func imageURL(c *gophercloud.ServiceClient, imageID string) string { |
| 22 | return c.ServiceURL("images", imageID) |
| 23 | } |
| 24 | |
| 25 | // `getURL(c,i)` is a URL for which a GET request will respond with |
| 26 | // information about the image identified by ID `i` in the service |
| 27 | // `c`. |
| 28 | func getURL(c *gophercloud.ServiceClient, imageID string) string { |
| 29 | return imageURL(c, imageID) |
| 30 | } |
| 31 | |
| 32 | func updateURL(c *gophercloud.ServiceClient, imageID string) string { |
| 33 | return imageURL(c, imageID) |
| 34 | } |
| 35 | |
| 36 | func deleteURL(c *gophercloud.ServiceClient, imageID string) string { |
| 37 | return imageURL(c, imageID) |
| 38 | } |
| 39 | |
| 40 | // builds next page full url based on current url |
| 41 | func nextPageURL(currentURL string, next string) string { |
| 42 | base := currentURL[:strings.Index(currentURL, "/images")] |
| 43 | return base + next |
| 44 | } |