Debian Codegraph @

storage/2020-08-04/table/tables/acl_get.go

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