github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/cce/v3/addons/urls.go (about)

     1  package addons
     2  
     3  import (
     4  	"fmt"
     5  	"strings"
     6  
     7  	"github.com/opentelekomcloud/gophertelekomcloud"
     8  )
     9  
    10  const (
    11  	rootPath      = "addons"
    12  	templatesPath = "addontemplates"
    13  )
    14  
    15  func rootURL(client *golangsdk.ServiceClient, clusterID string) string {
    16  	return CCEServiceURL(client, clusterID, rootPath)
    17  }
    18  
    19  func resourceURL(client *golangsdk.ServiceClient, id, clusterID string) string {
    20  	return CCEServiceURL(client, clusterID, rootPath, id+"?cluster_id="+clusterID)
    21  }
    22  
    23  func CCEServiceURL(client *golangsdk.ServiceClient, clusterID string, parts ...string) string {
    24  	rbUrl := fmt.Sprintf("https://%s.%s", clusterID, client.ResourceBaseURL()[8:])
    25  	return rbUrl + strings.Join(parts, "/")
    26  }
    27  
    28  func templatesURL(client *golangsdk.ServiceClient, clusterID string) string {
    29  	return CCEServiceURL(client, clusterID, templatesPath)
    30  }
    31  
    32  func instanceURL(client *golangsdk.ServiceClient, clusterID string) string {
    33  	return fmt.Sprintf("%s?cluster_id=%s", CCEServiceURL(client, clusterID, rootPath), clusterID)
    34  }
    35  
    36  // GET /api/v3/addontemplates
    37  func addonTemplatesURL(client *golangsdk.ServiceClient) string {
    38  	return client.ServiceURL(templatesPath)
    39  }