Debian Codegraph @

storage/2018-11-09/queue/queues/resource_id.go

raw symbols SCIP
1 package queuesscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-11-09/queue/queues`/
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 Queue
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/2018-11-09/queue/queues`/Client#) GetResourceIDscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-11-09/queue/queues`/Client#GetResourceID().(accountName, queueName string) string {
14 domain := endpointsscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/internal/endpoints`/.GetQueueEndpointscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/internal/endpoints`/GetQueueEndpoint().(client.BaseURIscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-11-09/queue/queues`/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, queueName)
16 }
17
18 type ResourceIDscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-11-09/queue/queues`/ResourceID# struct {
19 AccountNamescip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-11-09/queue/queues`/ResourceID#AccountName. string
20 QueueNamescip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-11-09/queue/queues`/ResourceID#QueueName. string
21 }
22
23 // ParseResourceID parses the Resource ID and returns an Object which
24 // can be used to interact with a Queue within a Storage Account
25 func ParseResourceIDscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-11-09/queue/queues`/ParseResourceID().(id string) (*ResourceIDscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-11-09/queue/queues`/ResourceID#, error) {
26 // example: https://foo.queue.core.windows.net/Bar
27 if id == "" {
28 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")
29 }
30
31 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)
32 if err != nil {
33 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)
34 }
35
36 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.)
37 if err != nil {
38 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)
39 }
40
41 queueName := 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., "/")
42 return &ResourceIDscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-11-09/queue/queues`/ResourceID#{
43 AccountNamescip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-11-09/queue/queues`/ResourceID#AccountName.: *accountName,
44 QueueNamescip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-11-09/queue/queues`/ResourceID#QueueName.: queueName,
45 }, nil
46 }