github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/ims/v2/cloudimages/urls.go (about) 1 package cloudimages 2 3 import ( 4 "net/url" 5 "strings" 6 7 "github.com/huaweicloud/golangsdk" 8 "github.com/huaweicloud/golangsdk/openstack/utils" 9 ) 10 11 // query images using search criteria and to display the images in a list 12 func listURL(c *golangsdk.ServiceClient) string { 13 return c.ServiceURL("cloudimages") 14 } 15 16 func createURL(c *golangsdk.ServiceClient) string { 17 return c.ServiceURL("cloudimages/action") 18 } 19 20 func createDataImageURL(c *golangsdk.ServiceClient) string { 21 return c.ServiceURL("cloudimages/dataimages/action") 22 } 23 24 // builds next page full url based on current url 25 func nextPageURL(serviceURL, requestedNext string) (string, error) { 26 base, err := utils.BaseEndpoint(serviceURL) 27 if err != nil { 28 return "", err 29 } 30 31 requestedNextURL, err := url.Parse(requestedNext) 32 if err != nil { 33 return "", err 34 } 35 36 base = golangsdk.NormalizeURL(base) 37 nextPath := base + strings.TrimPrefix(requestedNextURL.Path, "/") 38 39 nextURL, err := url.Parse(nextPath) 40 if err != nil { 41 return "", err 42 } 43 44 nextURL.RawQuery = requestedNextURL.RawQuery 45 return nextURL.String(), nil 46 }