urls.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package messages
  2. import (
  3. "net/url"
  4. "devel.mephi.ru/iacherepanov/openstack-gophercloud"
  5. )
  6. const ApiVersion = "v2"
  7. const ApiName = "queues"
  8. func createURL(client *gophercloud.ServiceClient, queueName string) string {
  9. return client.ServiceURL(ApiVersion, ApiName, queueName, "messages")
  10. }
  11. func listURL(client *gophercloud.ServiceClient, queueName string) string {
  12. return client.ServiceURL(ApiVersion, ApiName, queueName, "messages")
  13. }
  14. func getURL(client *gophercloud.ServiceClient, queueName string) string {
  15. return client.ServiceURL(ApiVersion, ApiName, queueName, "messages")
  16. }
  17. // Builds next page full url based on current url.
  18. func nextPageURL(currentURL string, next string) (string, error) {
  19. base, err := url.Parse(currentURL)
  20. if err != nil {
  21. return "", err
  22. }
  23. rel, err := url.Parse(next)
  24. if err != nil {
  25. return "", err
  26. }
  27. return base.ResolveReference(rel).String(), nil
  28. }
  29. func deleteURL(client *gophercloud.ServiceClient, queueName string) string {
  30. return client.ServiceURL(ApiVersion, ApiName, queueName, "messages")
  31. }
  32. func DeleteMessageURL(client *gophercloud.ServiceClient, queueName string, messageID string) string {
  33. return client.ServiceURL(ApiVersion, ApiName, queueName, "messages", messageID)
  34. }
  35. func messageURL(client *gophercloud.ServiceClient, queueName string, messageID string) string {
  36. return client.ServiceURL(ApiVersion, ApiName, queueName, "messages", messageID)
  37. }