Debian Codegraph @

storage/2020-08-04/file/shares/acl_get.go

raw
1 package shares
2
3 import (
4 "context"
5 "net/http"
6 "strings"
7
8 "github.com/Azure/go-autorest/autorest"
9 "github.com/Azure/go-autorest/autorest/azure"
10 "github.com/Azure/go-autorest/autorest/validation"
11 "github.com/tombuildsstuff/giovanni/storage/internal/endpoints"
12 )
13
14 type GetACLResult struct {
15 autorest.Response
16
17 SignedIdentifiers []SignedIdentifier `xml:"SignedIdentifier"`
18 }
19
20 // GetACL get the Access Control List for the specified Storage Share
21 func (client Client) GetACL(ctx context.Context, accountName, shareName string) (result GetACLResult, err error) {
22 if accountName == "" {
23 return result, validation.NewError("shares.Client", "GetACL", "`accountName` cannot be an empty string.")
24 }
25 if shareName == "" {
26 return result, validation.NewError("shares.Client", "GetACL", "`shareName` cannot be an empty string.")
27 }
28 if strings.ToLower(shareName) != shareName {
29 return result, validation.NewError("shares.Client", "GetACL", "`shareName` must be a lower-cased string.")
30 }
31
32 req, err := client.GetACLPreparer(ctx, accountName, shareName)
33 if err != nil {
34 err = autorest.NewErrorWithError(err, "shares.Client", "GetACL", nil, "Failure preparing request")
35 return
36 }
37
38 resp, err := client.GetACLSender(req)
39 if err != nil {
40 result.Response = autorest.Response{Response: resp}
41 err = autorest.NewErrorWithError(err, "shares.Client", "GetACL", resp, "Failure sending request")
42 return
43 }
44
45 result, err = client.GetACLResponder(resp)
46 if err != nil {
47 err = autorest.NewErrorWithError(err, "shares.Client", "GetACL", resp, "Failure responding to request")
48 return
49 }
50
51 return
52 }
53
54 // GetACLPreparer prepares the GetACL request.
55 func (client Client) GetACLPreparer(ctx context.Context, accountName, shareName string) (*http.Request, error) {
56 pathParameters := map[string]interface{}{
57 "shareName": autorest.Encode("path", shareName),
58 }
59
60 queryParameters := map[string]interface{}{
61 "restype": autorest.Encode("query", "share"),
62 "comp": autorest.Encode("query", "acl"),
63 }
64
65 headers := map[string]interface{}{
66 "x-ms-version": APIVersion,
67 }
68
69 preparer := autorest.CreatePreparer(
70 autorest.AsContentType("application/xml; charset=utf-8"),
71 autorest.AsGet(),
72 autorest.WithBaseURL(endpoints.GetFileEndpoint(client.BaseURI, accountName)),
73 autorest.WithPathParameters("/{shareName}", pathParameters),
74 autorest.WithQueryParameters(queryParameters),
75 autorest.WithHeaders(headers))
76 return preparer.Prepare((&http.Request{}).WithContext(ctx))
77 }
78
79 // GetACLSender sends the GetACL request. The method will close the
80 // http.Response Body if it receives an error.
81 func (client Client) GetACLSender(req *http.Request) (*http.Response, error) {
82 return autorest.SendWithSender(client, req,
83 azure.DoRetryWithRegistration(client.Client))
84 }
85
86 // GetACLResponder handles the response to the GetACL request. The method always
87 // closes the http.Response Body.
88 func (client Client) GetACLResponder(resp *http.Response) (result GetACLResult, err error) {
89 err = autorest.Respond(
90 resp,
91 client.ByInspecting(),
92 azure.WithErrorUnlessStatusCode(http.StatusOK),
93 autorest.ByUnmarshallingXML(&result),
94 autorest.ByClosing())
95 result.Response = autorest.Response{Response: resp}
96
97 return
98 }