Debian Codegraph @

storage/2019-12-12/blob/containers/resource_id.go

raw symbols SCIP
1 package containersscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2019-12-12/blob/containers`/
2
3 import (
4 "fmtscip-go gomod github.com/golang/go/src go1.13 fmt/"
5 "net/urlscip-go gomod github.com/golang/go/src go1.13 `net/url`/"
6 "stringsscip-go gomod github.com/golang/go/src go1.13 strings/"
7
8 "github.com/tombuildsstuff/giovanni/storage/internal/endpointsscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/internal/endpoints`/"
9 )
10
11 // GetResourceID returns the Resource ID for the given Container
12 // This can be useful when, for example, you're using this as a unique identifier
13 func (client Clientscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2019-12-12/blob/containers`/Client#) GetResourceIDscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2019-12-12/blob/containers`/Client#GetResourceID().(accountName, containerName string) string {
14 domain := endpointsscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/internal/endpoints`/.GetBlobEndpointscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/internal/endpoints`/GetBlobEndpoint().(client.BaseURIscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2019-12-12/blob/containers`/Client#BaseURI., accountName)
15 return fmtscip-go gomod github.com/golang/go/src go1.13 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.13 fmt/Sprintf().("%s/%s", domain, containerName)
16 }
17
18 // GetResourceManagerResourceID returns the Resource Manager specific
19 // ResourceID for a specific Storage Container
20 func (client Clientscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2019-12-12/blob/containers`/Client#) GetResourceManagerResourceIDscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2019-12-12/blob/containers`/Client#GetResourceManagerResourceID().(subscriptionID, resourceGroup, accountName, containerName string) string {
21 fmtStr := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Storage/storageAccounts/%s/blobServices/default/containers/%s"
22 return fmtscip-go gomod github.com/golang/go/src go1.13 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.13 fmt/Sprintf().(fmtStr, subscriptionID, resourceGroup, accountName, containerName)
23 }
24
25 type ResourceIDscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2019-12-12/blob/containers`/ResourceID# struct {
26 AccountNamescip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2019-12-12/blob/containers`/ResourceID#AccountName. string
27 ContainerNamescip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2019-12-12/blob/containers`/ResourceID#ContainerName. string
28 }
29
30 // ParseResourceID parses the Resource ID and returns an object which can be used
31 // to interact with the Container Resource
32 func ParseResourceIDscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2019-12-12/blob/containers`/ParseResourceID().(id string) (*ResourceIDscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2019-12-12/blob/containers`/ResourceID#, error) {
33 // example: https://foo.blob.core.windows.net/Bar
34 if id == "" {
35 return nil, fmtscip-go gomod github.com/golang/go/src go1.13 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.13 fmt/Errorf().("`id` was empty")
36 }
37
38 uri, err := urlscip-go gomod github.com/golang/go/src go1.13 `net/url`/.Parsescip-go gomod github.com/golang/go/src go1.13 `net/url`/Parse().(id)
39 if err != nil {
40 return nil, fmtscip-go gomod github.com/golang/go/src go1.13 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.13 fmt/Errorf().("Error parsing ID as a URL: %s", err)
41 }
42
43 accountName, err := endpointsscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/internal/endpoints`/.GetAccountNameFromEndpointscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/internal/endpoints`/GetAccountNameFromEndpoint().(uri.Hostscip-go gomod github.com/golang/go/src go1.13 `net/url`/URL#Host.)
44 if err != nil {
45 return nil, fmtscip-go gomod github.com/golang/go/src go1.13 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.13 fmt/Errorf().("Error parsing Account Name: %s", err)
46 }
47
48 containerName := stringsscip-go gomod github.com/golang/go/src go1.13 strings/.TrimPrefixscip-go gomod github.com/golang/go/src go1.13 strings/TrimPrefix().(uri.Pathscip-go gomod github.com/golang/go/src go1.13 `net/url`/URL#Path., "/")
49 return &ResourceIDscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2019-12-12/blob/containers`/ResourceID#{
50 AccountNamescip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2019-12-12/blob/containers`/ResourceID#AccountName.: *accountName,
51 ContainerNamescip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2019-12-12/blob/containers`/ResourceID#ContainerName.: containerName,
52 }, nil
53 }