| 1 | package endpoints |
| 2 | |
| 3 | import ( |
| 4 | "fmt" |
| 5 | "strings" |
| 6 | ) |
| 7 | |
| 8 | func GetAccountNameFromEndpoint(endpoint string) (*string, error) { |
| 9 | segments := strings.Split(endpoint, ".") |
| 10 | if len(segments) == 0 { |
| 11 | return nil, fmt.Errorf("The Endpoint contained no segments") |
| 12 | } |
| 13 | return &segments[0], nil |
| 14 | } |
| 15 | |
| 16 | // GetBlobEndpoint returns the endpoint for Blob API Operations on this storage account |
| 17 | func GetBlobEndpoint(baseUri string, accountName string) string { |
| 18 | return fmt.Sprintf("https://%s.blob.%s", accountName, baseUri) |
| 19 | } |
| 20 | |
| 21 | // GetDataLakeStoreEndpoint returns the endpoint for Data Lake Store API Operations on this storage account |
| 22 | func GetDataLakeStoreEndpoint(baseUri string, accountName string) string { |
| 23 | return fmt.Sprintf("https://%s.dfs.%s", accountName, baseUri) |
| 24 | } |
| 25 | |
| 26 | // GetFileEndpoint returns the endpoint for File Share API Operations on this storage account |
| 27 | func GetFileEndpoint(baseUri string, accountName string) string { |
| 28 | return fmt.Sprintf("https://%s.file.%s", accountName, baseUri) |
| 29 | } |
| 30 | |
| 31 | // GetQueueEndpoint returns the endpoint for Queue API Operations on this storage account |
| 32 | func GetQueueEndpoint(baseUri string, accountName string) string { |
| 33 | return fmt.Sprintf("https://%s.queue.%s", accountName, baseUri) |
| 34 | } |
| 35 | |
| 36 | // GetTableEndpoint returns the endpoint for Table API Operations on this storage account |
| 37 | func GetTableEndpoint(baseUri string, accountName string) string { |
| 38 | return fmt.Sprintf("https://%s.table.%s", accountName, baseUri) |
| 39 | } |