diff --git a/sdk/data/aztables/CHANGELOG.md b/sdk/data/aztables/CHANGELOG.md index c83749081251..23082a0c0d2b 100644 --- a/sdk/data/aztables/CHANGELOG.md +++ b/sdk/data/aztables/CHANGELOG.md @@ -1,14 +1,9 @@ # Release History -## 0.4.1 (Unreleased) - -### Features Added - -### Breaking Changes - -### Bugs Fixed +## 0.5.0 (2022-01-12) ### Other Changes +* Updates `azcore` dependency from `v0.20.0` to `v0.21.0` ## 0.4.0 (2021-11-09) diff --git a/sdk/data/autorest.md b/sdk/data/aztables/autorest.md similarity index 93% rename from sdk/data/autorest.md rename to sdk/data/aztables/autorest.md index 8660db4aa221..fa709d82ef7f 100644 --- a/sdk/data/autorest.md +++ b/sdk/data/aztables/autorest.md @@ -11,10 +11,10 @@ version: "^3.0.0" input-file: https://github.com/Azure/azure-rest-api-specs/blob/d744b6bcb95ab4034832ded556dbbe58f4287c5b/specification/cosmos-db/data-plane/Microsoft.Tables/preview/2019-02-02/table.json license-header: MICROSOFT_MIT_NO_VERSION clear-output-folder: false -output-folder: aztables/internal +output-folder: internal tag: package-2019-02 credential-scope: none -use: "@autorest/go@4.0.0-preview.27" +use: "@autorest/go@4.0.0-preview.35" module-version: 0.1.0 security: "AADToken" security-scopes: "https://storage.azure.com/.default" diff --git a/sdk/data/aztables/client.go b/sdk/data/aztables/client.go index d9f116f381f9..9d044116eeee 100644 --- a/sdk/data/aztables/client.go +++ b/sdk/data/aztables/client.go @@ -105,7 +105,7 @@ type CreateTableResponse struct { RawResponse *http.Response } -func createTableResponseFromGen(g *generated.TableCreateResponse) CreateTableResponse { +func createTableResponseFromGen(g *generated.TableClientCreateResponse) CreateTableResponse { if g == nil { return CreateTableResponse{} } @@ -183,7 +183,7 @@ type ListEntitiesResponse struct { } // transforms a generated query response into the ListEntitiesPaged -func newListEntitiesPage(resp *generated.TableQueryEntitiesResponse) (ListEntitiesPage, error) { +func newListEntitiesPage(resp *generated.TableClientQueryEntitiesResponse) (ListEntitiesPage, error) { marshalledValue := make([][]byte, 0) for _, e := range resp.TableEntityQueryResponse.Value { m, err := json.Marshal(e) @@ -231,7 +231,7 @@ type ListEntitiesPager interface { type tableEntityQueryResponsePager struct { tableClient *Client current *ListEntitiesPage - tableQueryOptions *generated.TableQueryEntitiesOptions + tableQueryOptions *generated.TableClientQueryEntitiesOptions listOptions *ListEntitiesOptions err error } @@ -251,7 +251,7 @@ func (p *tableEntityQueryResponsePager) NextPage(ctx context.Context) bool { if p.err != nil || (p.current != nil && p.current.ContinuationNextPartitionKey == nil && p.current.ContinuationNextRowKey == nil) { return false } - var resp generated.TableQueryEntitiesResponse + var resp generated.TableClientQueryEntitiesResponse resp, p.err = p.tableClient.client.QueryEntities( ctx, generated.Enum1Three0, @@ -301,7 +301,7 @@ func (t *Client) List(listOptions *ListEntitiesOptions) ListEntitiesPager { return &tableEntityQueryResponsePager{ tableClient: t, listOptions: listOptions, - tableQueryOptions: &generated.TableQueryEntitiesOptions{ + tableQueryOptions: &generated.TableClientQueryEntitiesOptions{ NextPartitionKey: listOptions.PartitionKey, NextRowKey: listOptions.RowKey, }, @@ -312,8 +312,8 @@ func (t *Client) List(listOptions *ListEntitiesOptions) ListEntitiesPager { type GetEntityOptions struct { } -func (g *GetEntityOptions) toGenerated() (*generated.TableQueryEntityWithPartitionAndRowKeyOptions, *generated.QueryOptions) { - return &generated.TableQueryEntityWithPartitionAndRowKeyOptions{}, &generated.QueryOptions{Format: generated.ODataMetadataFormatApplicationJSONODataMinimalmetadata.ToPtr()} +func (g *GetEntityOptions) toGenerated() (*generated.TableClientQueryEntityWithPartitionAndRowKeyOptions, *generated.QueryOptions) { + return &generated.TableClientQueryEntityWithPartitionAndRowKeyOptions{}, &generated.QueryOptions{Format: generated.ODataMetadataFormatApplicationJSONODataMinimalmetadata.ToPtr()} } // GetEntityResponse is the return type for a GetEntity operation. The individual entities are stored in the Value property @@ -329,7 +329,7 @@ type GetEntityResponse struct { } // newGetEntityResponse transforms a generated response to the GetEntityResponse type -func newGetEntityResponse(g generated.TableQueryEntityWithPartitionAndRowKeyResponse) (GetEntityResponse, error) { +func newGetEntityResponse(g generated.TableClientQueryEntityWithPartitionAndRowKeyResponse) (GetEntityResponse, error) { marshalledValue, err := json.Marshal(g.Value) if err != nil { return GetEntityResponse{}, err @@ -371,7 +371,7 @@ type AddEntityResponse struct { ETag azcore.ETag } -func addEntityResponseFromGenerated(g *generated.TableInsertEntityResponse) AddEntityResponse { +func addEntityResponseFromGenerated(g *generated.TableClientInsertEntityResponse) AddEntityResponse { if g == nil { return AddEntityResponse{} } @@ -395,7 +395,7 @@ func (t *Client) AddEntity(ctx context.Context, entity []byte, options *AddEntit if err != nil { return AddEntityResponse{}, err } - resp, err := t.client.InsertEntity(ctx, generated.Enum1Three0, t.name, &generated.TableInsertEntityOptions{TableEntityProperties: mapEntity, ResponsePreference: generated.ResponseFormatReturnNoContent.ToPtr()}, nil) + resp, err := t.client.InsertEntity(ctx, generated.Enum1Three0, t.name, &generated.TableClientInsertEntityOptions{TableEntityProperties: mapEntity, ResponsePreference: generated.ResponseFormatReturnNoContent.ToPtr()}, nil) if err != nil { err = checkEntityForPkRk(&mapEntity, err) return AddEntityResponse{}, err @@ -407,15 +407,15 @@ type DeleteEntityOptions struct { IfMatch *azcore.ETag } -func (d *DeleteEntityOptions) toGenerated() *generated.TableDeleteEntityOptions { - return &generated.TableDeleteEntityOptions{} +func (d *DeleteEntityOptions) toGenerated() *generated.TableClientDeleteEntityOptions { + return &generated.TableClientDeleteEntityOptions{} } type DeleteEntityResponse struct { RawResponse *http.Response } -func deleteEntityResponseFromGenerated(g *generated.TableDeleteEntityResponse) DeleteEntityResponse { +func deleteEntityResponseFromGenerated(g *generated.TableClientDeleteEntityResponse) DeleteEntityResponse { if g == nil { return DeleteEntityResponse{} } @@ -442,21 +442,21 @@ type UpdateEntityOptions struct { UpdateMode EntityUpdateMode } -func (u *UpdateEntityOptions) toGeneratedMergeEntity(m map[string]interface{}) *generated.TableMergeEntityOptions { +func (u *UpdateEntityOptions) toGeneratedMergeEntity(m map[string]interface{}) *generated.TableClientMergeEntityOptions { if u == nil { - return &generated.TableMergeEntityOptions{} + return &generated.TableClientMergeEntityOptions{} } - return &generated.TableMergeEntityOptions{ + return &generated.TableClientMergeEntityOptions{ IfMatch: to.StringPtr(string(*u.IfMatch)), TableEntityProperties: m, } } -func (u *UpdateEntityOptions) toGeneratedUpdateEntity(m map[string]interface{}) *generated.TableUpdateEntityOptions { +func (u *UpdateEntityOptions) toGeneratedUpdateEntity(m map[string]interface{}) *generated.TableClientUpdateEntityOptions { if u == nil { - return &generated.TableUpdateEntityOptions{} + return &generated.TableClientUpdateEntityOptions{} } - return &generated.TableUpdateEntityOptions{ + return &generated.TableClientUpdateEntityOptions{ IfMatch: to.StringPtr(string(*u.IfMatch)), TableEntityProperties: m, } @@ -467,7 +467,7 @@ type UpdateEntityResponse struct { ETag azcore.ETag } -func updateEntityResponseFromMergeGenerated(g *generated.TableMergeEntityResponse) UpdateEntityResponse { +func updateEntityResponseFromMergeGenerated(g *generated.TableClientMergeEntityResponse) UpdateEntityResponse { if g == nil { return UpdateEntityResponse{} } @@ -482,7 +482,7 @@ func updateEntityResponseFromMergeGenerated(g *generated.TableMergeEntityRespons } } -func updateEntityResponseFromUpdateGenerated(g *generated.TableUpdateEntityResponse) UpdateEntityResponse { +func updateEntityResponseFromUpdateGenerated(g *generated.TableClientUpdateEntityResponse) UpdateEntityResponse { if g == nil { return UpdateEntityResponse{} } @@ -566,7 +566,7 @@ type InsertEntityResponse struct { ETag azcore.ETag } -func insertEntityFromGeneratedMerge(g *generated.TableMergeEntityResponse) InsertEntityResponse { +func insertEntityFromGeneratedMerge(g *generated.TableClientMergeEntityResponse) InsertEntityResponse { if g == nil { return InsertEntityResponse{} } @@ -581,7 +581,7 @@ func insertEntityFromGeneratedMerge(g *generated.TableMergeEntityResponse) Inser } } -func insertEntityFromGeneratedUpdate(g *generated.TableUpdateEntityResponse) InsertEntityResponse { +func insertEntityFromGeneratedUpdate(g *generated.TableClientUpdateEntityResponse) InsertEntityResponse { if g == nil { return InsertEntityResponse{} } @@ -626,7 +626,7 @@ func (t *Client) InsertEntity(ctx context.Context, entity []byte, options *Inser t.name, partKey, rowkey, - &generated.TableMergeEntityOptions{TableEntityProperties: mapEntity}, + &generated.TableClientMergeEntityOptions{TableEntityProperties: mapEntity}, &generated.QueryOptions{}, ) return insertEntityFromGeneratedMerge(&resp), err @@ -637,7 +637,7 @@ func (t *Client) InsertEntity(ctx context.Context, entity []byte, options *Inser t.name, partKey, rowkey, - &generated.TableUpdateEntityOptions{TableEntityProperties: mapEntity}, + &generated.TableClientUpdateEntityOptions{TableEntityProperties: mapEntity}, &generated.QueryOptions{}, ) return insertEntityFromGeneratedUpdate(&resp), err @@ -651,8 +651,8 @@ func (t *Client) InsertEntity(ctx context.Context, entity []byte, options *Inser type GetAccessPolicyOptions struct { } -func (g *GetAccessPolicyOptions) toGenerated() *generated.TableGetAccessPolicyOptions { - return &generated.TableGetAccessPolicyOptions{} +func (g *GetAccessPolicyOptions) toGenerated() *generated.TableClientGetAccessPolicyOptions { + return &generated.TableClientGetAccessPolicyOptions{} } type GetAccessPolicyResponse struct { @@ -660,7 +660,7 @@ type GetAccessPolicyResponse struct { SignedIdentifiers []*SignedIdentifier } -func getAccessPolicyResponseFromGenerated(g *generated.TableGetAccessPolicyResponse) GetAccessPolicyResponse { +func getAccessPolicyResponseFromGenerated(g *generated.TableClientGetAccessPolicyResponse) GetAccessPolicyResponse { if g == nil { return GetAccessPolicyResponse{} } @@ -689,7 +689,7 @@ type SetAccessPolicyResponse struct { RawResponse *http.Response } -func setAccessPolicyResponseFromGenerated(g *generated.TableSetAccessPolicyResponse) SetAccessPolicyResponse { +func setAccessPolicyResponseFromGenerated(g *generated.TableClientSetAccessPolicyResponse) SetAccessPolicyResponse { if g == nil { return SetAccessPolicyResponse{} } @@ -697,12 +697,12 @@ func setAccessPolicyResponseFromGenerated(g *generated.TableSetAccessPolicyRespo RawResponse: g.RawResponse, } } -func (s *SetAccessPolicyOptions) toGenerated() *generated.TableSetAccessPolicyOptions { +func (s *SetAccessPolicyOptions) toGenerated() *generated.TableClientSetAccessPolicyOptions { var sis []*generated.SignedIdentifier for _, t := range s.TableACL { sis = append(sis, toGeneratedSignedIdentifier(t)) } - return &generated.TableSetAccessPolicyOptions{ + return &generated.TableClientSetAccessPolicyOptions{ TableACL: sis, } } diff --git a/sdk/data/aztables/go.mod b/sdk/data/aztables/go.mod index b6338e702884..ade2f87f4fa8 100644 --- a/sdk/data/aztables/go.mod +++ b/sdk/data/aztables/go.mod @@ -3,8 +3,8 @@ module github.com/Azure/azure-sdk-for-go/sdk/data/aztables go 1.16 require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v0.20.0 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.12.0 - github.com/Azure/azure-sdk-for-go/sdk/internal v0.8.1 + github.com/Azure/azure-sdk-for-go/sdk/azcore v0.21.0 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.13.0 + github.com/Azure/azure-sdk-for-go/sdk/internal v0.8.3 github.com/stretchr/testify v1.7.0 ) diff --git a/sdk/data/aztables/go.sum b/sdk/data/aztables/go.sum index bb3880362bcf..09fe7359f65e 100644 --- a/sdk/data/aztables/go.sum +++ b/sdk/data/aztables/go.sum @@ -1,17 +1,26 @@ -github.com/Azure/azure-sdk-for-go/sdk/azcore v0.20.0 h1:KQgdWmEOmaJKxaUUZwHAYh12t+b+ZJf8q3friycK1kA= -github.com/Azure/azure-sdk-for-go/sdk/azcore v0.20.0/go.mod h1:ZPW/Z0kLCTdDZaDbYTetxc9Cxl/2lNqxYHYNOF2bti0= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.12.0 h1:VBvHGLJbaY0+c66NZHdS9cgjHVYSH6DDa0XJMyrblsI= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.12.0/go.mod h1:GJzjM4SR9T0KyX5gKCVyz1ytD8FeWeUPCwtFCt1AyfE= -github.com/Azure/azure-sdk-for-go/sdk/internal v0.8.1 h1:BUYIbDf/mMZ8945v3QkG3OuqGVyS4Iek0AOLwdRAYoc= -github.com/Azure/azure-sdk-for-go/sdk/internal v0.8.1/go.mod h1:KLF4gFr6DcKFZwSuH8w8yEK6DpFl3LP5rhdvAb7Yz5I= +github.com/Azure/azure-sdk-for-go/sdk/azcore v0.21.0 h1:8wVJL0HUP5yDFXvotdewORTw7Yu88JbreWN/mobSvsQ= +github.com/Azure/azure-sdk-for-go/sdk/azcore v0.21.0/go.mod h1:fBF9PQNqB8scdgpZ3ufzaLntG0AG7C1WjPMsiFOmfHM= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.13.0 h1:bLRntPH25SkY1uZ/YZW+dmxNky9r1fAHvDFrzluo+4Q= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.13.0/go.mod h1:TmXReXZ9yPp5D5TBRMTAtyz+UyOl15Py4hL5E5p6igQ= +github.com/Azure/azure-sdk-for-go/sdk/internal v0.8.3 h1:E+m3SkZCN0Bf5q7YdTs5lSm2CYY3CK4spn5OmUIiQtk= +github.com/Azure/azure-sdk-for-go/sdk/internal v0.8.3/go.mod h1:KLF4gFr6DcKFZwSuH8w8yEK6DpFl3LP5rhdvAb7Yz5I= +github.com/AzureAD/microsoft-authentication-library-for-go v0.4.0 h1:WVsrXCnHlDDX8ls+tootqRE87/hL9S/g4ewig9RsD/c= +github.com/AzureAD/microsoft-authentication-library-for-go v0.4.0/go.mod h1:Vt9sXTKwMyGcOxSmLDMnGPgqsUg7m8pe215qMLrDXw4= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dnaeon/go-vcr v1.1.0 h1:ReYa/UBrRyQdant9B4fNHGoCNKw6qh6P0fsdGmZpR7c= github.com/dnaeon/go-vcr v1.1.0/go.mod h1:M7tiix8f0r6mKKJ3Yq/kqU1OYf3MnfmBWVbPx/yU9ko= +github.com/golang-jwt/jwt v3.2.1+incompatible h1:73Z+4BJcrTC+KczS6WvTPvRGOp1WmfEP4Q1lOd9Z/+c= +github.com/golang-jwt/jwt v3.2.1+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= +github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= +github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= +github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5/go.mod h1:caMODM3PzxT8aQXRPkAt8xlV/e7d7w8GM5g0fa5F0D8= -github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4 h1:49lOXmGaUpV9Fz3gd7TFZY106KVlPVa5jcYD1gaQf98= -github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4/go.mod h1:4OwLy04Bl9Ef3GJJCoec+30X3LQs/0/m4HFRt/2LUSA= +github.com/montanaflynn/stats v0.6.6/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow= +github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 h1:Qj1ukM4GlMWXNdMBuXcXfz/Kw9s1qm0CLY32QxuSImI= +github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4/go.mod h1:N6UoU20jOqggOuDwUaBQpluzLNDqif3kq9z2wpdYEfQ= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= @@ -23,18 +32,23 @@ golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897 h1:pLI5jrR7OSLijeIDcmRxNm golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20201010224723-4f7140c49acb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20210610132358-84b48f89b13b h1:k+E048sYJHyVnsr1GDrRZWQ32D2C7lWs9JRc0bel53A= golang.org/x/net v0.0.0-20210610132358-84b48f89b13b/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f h1:OfiFi4JbukWwe3lzw+xunroH1mnC1e2Gy5cxNJApiSY= +golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20211019181941-9d821ace8654 h1:id054HUawV2/6IGm2IV8KZQjqtwAOo2CYlOToYqa0d0= +golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/sdk/data/aztables/internal/connection.go b/sdk/data/aztables/internal/connection.go index 5ee284118407..ba574b8414bc 100644 --- a/sdk/data/aztables/internal/connection.go +++ b/sdk/data/aztables/internal/connection.go @@ -25,7 +25,7 @@ func NewConnection(endpoint string, options *azcore.ClientOptions) *Connection { if options != nil { cp = *options } - return &Connection{u: endpoint, p: runtime.NewPipeline(module, version, nil, nil, &cp)} + return &Connection{u: endpoint, p: runtime.NewPipeline(moduleName, moduleVersion, runtime.PipelineOptions{}, &cp)} } // Endpoint returns the connection's endpoint. diff --git a/sdk/data/aztables/internal/constants.go b/sdk/data/aztables/internal/constants.go index 4db7b14bdcf7..42a02c017b63 100644 --- a/sdk/data/aztables/internal/constants.go +++ b/sdk/data/aztables/internal/constants.go @@ -9,8 +9,8 @@ package internal const ( - module = "aztables" - version = "v0.4.1" + moduleName = "internal" + moduleVersion = "v0.5.0" ) type Enum0 string diff --git a/sdk/data/aztables/internal/models.go b/sdk/data/aztables/internal/models.go index b14b5a2119be..a5c54b3c6df0 100644 --- a/sdk/data/aztables/internal/models.go +++ b/sdk/data/aztables/internal/models.go @@ -11,10 +11,9 @@ package internal import ( "encoding/json" "encoding/xml" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" "reflect" "time" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore" ) // AccessPolicy - An Access policy. @@ -62,10 +61,10 @@ func (a *AccessPolicy) UnmarshalXML(d *xml.Decoder, start xml.StartElement) erro return nil } -// CorsRule - CORS is an HTTP feature that enables a web application running under one domain to access resources in another domain. Web browsers implement -// a security restriction known as same-origin policy that -// prevents a web page from calling APIs in a different domain; CORS provides a secure way to allow one domain (the origin domain) to call APIs in another -// domain. +// CorsRule - CORS is an HTTP feature that enables a web application running under one domain to access resources in another +// domain. Web browsers implement a security restriction known as same-origin policy that +// prevents a web page from calling APIs in a different domain; CORS provides a secure way to allow one domain (the origin +// domain) to call APIs in another domain. type CorsRule struct { // REQUIRED; The request headers that the origin domain may specify on the CORS request. AllowedHeaders *string `xml:"AllowedHeaders"` @@ -73,13 +72,14 @@ type CorsRule struct { // REQUIRED; The methods (HTTP request verbs) that the origin domain may use for a CORS request. (comma separated) AllowedMethods *string `xml:"AllowedMethods"` - // REQUIRED; The origin domains that are permitted to make a request against the service via CORS. The origin domain is the domain from which the request - // originates. Note that the origin must be an exact - // case-sensitive match with the origin that the user age sends to the service. You can also use the wildcard character '*' to allow all origin domains - // to make requests via CORS. + // REQUIRED; The origin domains that are permitted to make a request against the service via CORS. The origin domain is the + // domain from which the request originates. Note that the origin must be an exact + // case-sensitive match with the origin that the user age sends to the service. You can also use the wildcard character '*' + // to allow all origin domains to make requests via CORS. AllowedOrigins *string `xml:"AllowedOrigins"` - // REQUIRED; The response headers that may be sent in the response to the CORS request and exposed by the browser to the request issuer. + // REQUIRED; The response headers that may be sent in the response to the CORS request and exposed by the browser to the request + // issuer. ExposedHeaders *string `xml:"ExposedHeaders"` // REQUIRED; The maximum amount time that a browser should cache the preflight OPTIONS request. @@ -87,8 +87,8 @@ type CorsRule struct { } type GeoReplication struct { - // REQUIRED; A GMT date/time value, to the second. All primary writes preceding this value are guaranteed to be available for read operations at the secondary. - // Primary writes after this point in time may or may + // REQUIRED; A GMT date/time value, to the second. All primary writes preceding this value are guaranteed to be available + // for read operations at the secondary. Primary writes after this point in time may or may // not be available for reads. LastSyncTime *time.Time `xml:"LastSyncTime"` @@ -157,13 +157,14 @@ type Metrics struct { Version *string `xml:"Version"` } -// QueryOptions contains a group of parameters for the Table.Query method. +// QueryOptions contains a group of parameters for the TableClient.Query method. type QueryOptions struct { // OData filter expression. Filter *string // Specifies the media type for the response. Format *ODataMetadataFormat - // Select expression using OData notation. Limits the columns on each record to just those requested, e.g. "$select=PolicyAssignmentId, ResourceId". + // Select expression using OData notation. Limits the columns on each record to just those requested, e.g. "$select=PolicyAssignmentId, + // ResourceId". Select *string // Maximum number of records to return. Top *int32 @@ -174,29 +175,33 @@ type RetentionPolicy struct { // REQUIRED; Indicates whether a retention policy is enabled for the service. Enabled *bool `xml:"Enabled"` - // Indicates the number of days that metrics or logging or soft-deleted data should be retained. All data older than this value will be deleted. + // Indicates the number of days that metrics or logging or soft-deleted data should be retained. All data older than this + // value will be deleted. Days *int32 `xml:"Days"` } -// ServiceGetPropertiesOptions contains the optional parameters for the Service.GetProperties method. -type ServiceGetPropertiesOptions struct { - // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when analytics logging is enabled. +// ServiceClientGetPropertiesOptions contains the optional parameters for the ServiceClient.GetProperties method. +type ServiceClientGetPropertiesOptions struct { + // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when analytics + // logging is enabled. RequestID *string // The timeout parameter is expressed in seconds. Timeout *int32 } -// ServiceGetStatisticsOptions contains the optional parameters for the Service.GetStatistics method. -type ServiceGetStatisticsOptions struct { - // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when analytics logging is enabled. +// ServiceClientGetStatisticsOptions contains the optional parameters for the ServiceClient.GetStatistics method. +type ServiceClientGetStatisticsOptions struct { + // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when analytics + // logging is enabled. RequestID *string // The timeout parameter is expressed in seconds. Timeout *int32 } -// ServiceSetPropertiesOptions contains the optional parameters for the Service.SetProperties method. -type ServiceSetPropertiesOptions struct { - // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when analytics logging is enabled. +// ServiceClientSetPropertiesOptions contains the optional parameters for the ServiceClient.SetProperties method. +type ServiceClientSetPropertiesOptions struct { + // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when analytics + // logging is enabled. RequestID *string // The timeout parameter is expressed in seconds. Timeout *int32 @@ -211,58 +216,48 @@ type SignedIdentifier struct { ID *string `xml:"Id"` } -// TableCreateOptions contains the optional parameters for the Table.Create method. -type TableCreateOptions struct { - // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when analytics logging is enabled. +// TableClientCreateOptions contains the optional parameters for the TableClient.Create method. +type TableClientCreateOptions struct { + // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when analytics + // logging is enabled. RequestID *string - // Specifies whether the response should include the inserted entity in the payload. Possible values are return-no-content and return-content. + // Specifies whether the response should include the inserted entity in the payload. Possible values are return-no-content + // and return-content. ResponsePreference *ResponseFormat } -// TableDeleteEntityOptions contains the optional parameters for the Table.DeleteEntity method. -type TableDeleteEntityOptions struct { - // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when analytics logging is enabled. +// TableClientDeleteEntityOptions contains the optional parameters for the TableClient.DeleteEntity method. +type TableClientDeleteEntityOptions struct { + // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when analytics + // logging is enabled. RequestID *string // The timeout parameter is expressed in seconds. Timeout *int32 } -// TableDeleteOptions contains the optional parameters for the Table.Delete method. -type TableDeleteOptions struct { - // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when analytics logging is enabled. +// TableClientDeleteOptions contains the optional parameters for the TableClient.Delete method. +type TableClientDeleteOptions struct { + // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when analytics + // logging is enabled. RequestID *string } -// TableEntityQueryResponse - The properties for the table entity query response. -type TableEntityQueryResponse struct { - // The metadata response of the table. - ODataMetadata *string `json:"odata.metadata,omitempty"` - - // List of table entities. - Value []map[string]interface{} `json:"value,omitempty"` -} - -// MarshalJSON implements the json.Marshaller interface for type TableEntityQueryResponse. -func (t TableEntityQueryResponse) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "odata.metadata", t.ODataMetadata) - populate(objectMap, "value", t.Value) - return json.Marshal(objectMap) -} - -// TableGetAccessPolicyOptions contains the optional parameters for the Table.GetAccessPolicy method. -type TableGetAccessPolicyOptions struct { - // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when analytics logging is enabled. +// TableClientGetAccessPolicyOptions contains the optional parameters for the TableClient.GetAccessPolicy method. +type TableClientGetAccessPolicyOptions struct { + // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when analytics + // logging is enabled. RequestID *string // The timeout parameter is expressed in seconds. Timeout *int32 } -// TableInsertEntityOptions contains the optional parameters for the Table.InsertEntity method. -type TableInsertEntityOptions struct { - // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when analytics logging is enabled. +// TableClientInsertEntityOptions contains the optional parameters for the TableClient.InsertEntity method. +type TableClientInsertEntityOptions struct { + // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when analytics + // logging is enabled. RequestID *string - // Specifies whether the response should include the inserted entity in the payload. Possible values are return-no-content and return-content. + // Specifies whether the response should include the inserted entity in the payload. Possible values are return-no-content + // and return-content. ResponsePreference *ResponseFormat // The properties for the table entity. TableEntityProperties map[string]interface{} @@ -270,13 +265,15 @@ type TableInsertEntityOptions struct { Timeout *int32 } -// TableMergeEntityOptions contains the optional parameters for the Table.MergeEntity method. -type TableMergeEntityOptions struct { - // Match condition for an entity to be updated. If specified and a matching entity is not found, an error will be raised. To force an unconditional update, - // set to the wildcard character (*). If not specified, an insert will be performed when no existing entity is found to update and a merge will be performed - // if an existing entity is found. +// TableClientMergeEntityOptions contains the optional parameters for the TableClient.MergeEntity method. +type TableClientMergeEntityOptions struct { + // Match condition for an entity to be updated. If specified and a matching entity is not found, an error will be raised. + // To force an unconditional update, set to the wildcard character (*). If not + // specified, an insert will be performed when no existing entity is found to update and a merge will be performed if an existing + // entity is found. IfMatch *string - // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when analytics logging is enabled. + // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when analytics + // logging is enabled. RequestID *string // The properties for the table entity. TableEntityProperties map[string]interface{} @@ -284,38 +281,86 @@ type TableMergeEntityOptions struct { Timeout *int32 } -// TableProperties - The properties for creating a table. -type TableProperties struct { - // The name of the table to create. - TableName *string `json:"TableName,omitempty"` -} - -// TableQueryEntitiesOptions contains the optional parameters for the Table.QueryEntities method. -type TableQueryEntitiesOptions struct { +// TableClientQueryEntitiesOptions contains the optional parameters for the TableClient.QueryEntities method. +type TableClientQueryEntitiesOptions struct { // An entity query continuation token from a previous call. NextPartitionKey *string // An entity query continuation token from a previous call. NextRowKey *string - // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when analytics logging is enabled. + // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when analytics + // logging is enabled. RequestID *string // The timeout parameter is expressed in seconds. Timeout *int32 } -// TableQueryEntityWithPartitionAndRowKeyOptions contains the optional parameters for the Table.QueryEntityWithPartitionAndRowKey method. -type TableQueryEntityWithPartitionAndRowKeyOptions struct { - // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when analytics logging is enabled. +// TableClientQueryEntityWithPartitionAndRowKeyOptions contains the optional parameters for the TableClient.QueryEntityWithPartitionAndRowKey +// method. +type TableClientQueryEntityWithPartitionAndRowKeyOptions struct { + // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when analytics + // logging is enabled. RequestID *string // The timeout parameter is expressed in seconds. Timeout *int32 } -// TableQueryOptions contains the optional parameters for the Table.Query method. -type TableQueryOptions struct { +// TableClientQueryOptions contains the optional parameters for the TableClient.Query method. +type TableClientQueryOptions struct { // A table query continuation token from a previous call. NextTableName *string - // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when analytics logging is enabled. + // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when analytics + // logging is enabled. + RequestID *string +} + +// TableClientSetAccessPolicyOptions contains the optional parameters for the TableClient.SetAccessPolicy method. +type TableClientSetAccessPolicyOptions struct { + // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when analytics + // logging is enabled. RequestID *string + // The acls for the table. + TableACL []*SignedIdentifier + // The timeout parameter is expressed in seconds. + Timeout *int32 +} + +// TableClientUpdateEntityOptions contains the optional parameters for the TableClient.UpdateEntity method. +type TableClientUpdateEntityOptions struct { + // Match condition for an entity to be updated. If specified and a matching entity is not found, an error will be raised. + // To force an unconditional update, set to the wildcard character (*). If not + // specified, an insert will be performed when no existing entity is found to update and a replace will be performed if an + // existing entity is found. + IfMatch *string + // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when analytics + // logging is enabled. + RequestID *string + // The properties for the table entity. + TableEntityProperties map[string]interface{} + // The timeout parameter is expressed in seconds. + Timeout *int32 +} + +// TableEntityQueryResponse - The properties for the table entity query response. +type TableEntityQueryResponse struct { + // The metadata response of the table. + ODataMetadata *string `json:"odata.metadata,omitempty"` + + // List of table entities. + Value []map[string]interface{} `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type TableEntityQueryResponse. +func (t TableEntityQueryResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "odata.metadata", t.ODataMetadata) + populate(objectMap, "value", t.Value) + return json.Marshal(objectMap) +} + +// TableProperties - The properties for creating a table. +type TableProperties struct { + // The name of the table to create. + TableName *string `json:"TableName,omitempty"` } // TableQueryResponse - The properties for the table query response. @@ -337,9 +382,20 @@ func (t TableQueryResponse) MarshalJSON() ([]byte, error) { // TableResponse - The response for a single table. type TableResponse struct { - TableResponseProperties + // The edit link of the table. + ODataEditLink *string `json:"odata.editLink,omitempty"` + + // The id of the table. + ODataID *string `json:"odata.id,omitempty"` + // The metadata response of the table. ODataMetadata *string `json:"odata.metadata,omitempty"` + + // The odata type of the table. + ODataType *string `json:"odata.type,omitempty"` + + // The name of the table. + TableName *string `json:"TableName,omitempty"` } // TableResponseProperties - The properties for the table response. @@ -358,19 +414,11 @@ type TableResponseProperties struct { } // TableServiceError - Table Service error. -// Implements the error and azcore.HTTPResponse interfaces. type TableServiceError struct { - raw string // The error message. Message *string `json:"Message,omitempty"` } -// Error implements the error interface for type TableServiceError. -// The contents of the error text are not contractual and subject to change. -func (e TableServiceError) Error() string { - return e.raw -} - // TableServiceProperties - Table Service Properties. type TableServiceProperties struct { // The set of CORS rules. @@ -408,30 +456,6 @@ type TableServiceStats struct { GeoReplication *GeoReplication `xml:"GeoReplication"` } -// TableSetAccessPolicyOptions contains the optional parameters for the Table.SetAccessPolicy method. -type TableSetAccessPolicyOptions struct { - // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when analytics logging is enabled. - RequestID *string - // The acls for the table. - TableACL []*SignedIdentifier - // The timeout parameter is expressed in seconds. - Timeout *int32 -} - -// TableUpdateEntityOptions contains the optional parameters for the Table.UpdateEntity method. -type TableUpdateEntityOptions struct { - // Match condition for an entity to be updated. If specified and a matching entity is not found, an error will be raised. To force an unconditional update, - // set to the wildcard character (*). If not specified, an insert will be performed when no existing entity is found to update and a replace will be performed - // if an existing entity is found. - IfMatch *string - // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when analytics logging is enabled. - RequestID *string - // The properties for the table entity. - TableEntityProperties map[string]interface{} - // The timeout parameter is expressed in seconds. - Timeout *int32 -} - func populate(m map[string]interface{}, k string, v interface{}) { if v == nil { return diff --git a/sdk/data/aztables/internal/response_types.go b/sdk/data/aztables/internal/response_types.go index 5b7a0c119bbf..0db035fc4366 100644 --- a/sdk/data/aztables/internal/response_types.go +++ b/sdk/data/aztables/internal/response_types.go @@ -13,15 +13,15 @@ import ( "time" ) -// ServiceGetPropertiesResponse contains the response from method Service.GetProperties. -type ServiceGetPropertiesResponse struct { - ServiceGetPropertiesResult +// ServiceClientGetPropertiesResponse contains the response from method ServiceClient.GetProperties. +type ServiceClientGetPropertiesResponse struct { + ServiceClientGetPropertiesResult // RawResponse contains the underlying HTTP response. RawResponse *http.Response } -// ServiceGetPropertiesResult contains the result from method Service.GetProperties. -type ServiceGetPropertiesResult struct { +// ServiceClientGetPropertiesResult contains the result from method ServiceClient.GetProperties. +type ServiceClientGetPropertiesResult struct { TableServiceProperties // ClientRequestID contains the information returned from the x-ms-client-request-id header response. ClientRequestID *string `xml:"ClientRequestID"` @@ -33,15 +33,15 @@ type ServiceGetPropertiesResult struct { Version *string `xml:"Version"` } -// ServiceGetStatisticsResponse contains the response from method Service.GetStatistics. -type ServiceGetStatisticsResponse struct { - ServiceGetStatisticsResult +// ServiceClientGetStatisticsResponse contains the response from method ServiceClient.GetStatistics. +type ServiceClientGetStatisticsResponse struct { + ServiceClientGetStatisticsResult // RawResponse contains the underlying HTTP response. RawResponse *http.Response } -// ServiceGetStatisticsResult contains the result from method Service.GetStatistics. -type ServiceGetStatisticsResult struct { +// ServiceClientGetStatisticsResult contains the result from method ServiceClient.GetStatistics. +type ServiceClientGetStatisticsResult struct { TableServiceStats // ClientRequestID contains the information returned from the x-ms-client-request-id header response. ClientRequestID *string `xml:"ClientRequestID"` @@ -56,15 +56,15 @@ type ServiceGetStatisticsResult struct { Version *string `xml:"Version"` } -// ServiceSetPropertiesResponse contains the response from method Service.SetProperties. -type ServiceSetPropertiesResponse struct { - ServiceSetPropertiesResult +// ServiceClientSetPropertiesResponse contains the response from method ServiceClient.SetProperties. +type ServiceClientSetPropertiesResponse struct { + ServiceClientSetPropertiesResult // RawResponse contains the underlying HTTP response. RawResponse *http.Response } -// ServiceSetPropertiesResult contains the result from method Service.SetProperties. -type ServiceSetPropertiesResult struct { +// ServiceClientSetPropertiesResult contains the result from method ServiceClient.SetProperties. +type ServiceClientSetPropertiesResult struct { // ClientRequestID contains the information returned from the x-ms-client-request-id header response. ClientRequestID *string @@ -75,15 +75,15 @@ type ServiceSetPropertiesResult struct { Version *string } -// TableCreateResponse contains the response from method Table.Create. -type TableCreateResponse struct { - TableCreateResult +// TableClientCreateResponse contains the response from method TableClient.Create. +type TableClientCreateResponse struct { + TableClientCreateResult // RawResponse contains the underlying HTTP response. RawResponse *http.Response } -// TableCreateResult contains the result from method Table.Create. -type TableCreateResult struct { +// TableClientCreateResult contains the result from method TableClient.Create. +type TableClientCreateResult struct { TableResponse // ClientRequestID contains the information returned from the x-ms-client-request-id header response. ClientRequestID *string @@ -101,15 +101,15 @@ type TableCreateResult struct { Version *string } -// TableDeleteEntityResponse contains the response from method Table.DeleteEntity. -type TableDeleteEntityResponse struct { - TableDeleteEntityResult +// TableClientDeleteEntityResponse contains the response from method TableClient.DeleteEntity. +type TableClientDeleteEntityResponse struct { + TableClientDeleteEntityResult // RawResponse contains the underlying HTTP response. RawResponse *http.Response } -// TableDeleteEntityResult contains the result from method Table.DeleteEntity. -type TableDeleteEntityResult struct { +// TableClientDeleteEntityResult contains the result from method TableClient.DeleteEntity. +type TableClientDeleteEntityResult struct { // ClientRequestID contains the information returned from the x-ms-client-request-id header response. ClientRequestID *string @@ -123,15 +123,15 @@ type TableDeleteEntityResult struct { Version *string } -// TableDeleteResponse contains the response from method Table.Delete. -type TableDeleteResponse struct { - TableDeleteResult +// TableClientDeleteResponse contains the response from method TableClient.Delete. +type TableClientDeleteResponse struct { + TableClientDeleteResult // RawResponse contains the underlying HTTP response. RawResponse *http.Response } -// TableDeleteResult contains the result from method Table.Delete. -type TableDeleteResult struct { +// TableClientDeleteResult contains the result from method TableClient.Delete. +type TableClientDeleteResult struct { // ClientRequestID contains the information returned from the x-ms-client-request-id header response. ClientRequestID *string @@ -145,15 +145,15 @@ type TableDeleteResult struct { Version *string } -// TableGetAccessPolicyResponse contains the response from method Table.GetAccessPolicy. -type TableGetAccessPolicyResponse struct { - TableGetAccessPolicyResult +// TableClientGetAccessPolicyResponse contains the response from method TableClient.GetAccessPolicy. +type TableClientGetAccessPolicyResponse struct { + TableClientGetAccessPolicyResult // RawResponse contains the underlying HTTP response. RawResponse *http.Response } -// TableGetAccessPolicyResult contains the result from method Table.GetAccessPolicy. -type TableGetAccessPolicyResult struct { +// TableClientGetAccessPolicyResult contains the result from method TableClient.GetAccessPolicy. +type TableClientGetAccessPolicyResult struct { // ClientRequestID contains the information returned from the x-ms-client-request-id header response. ClientRequestID *string `xml:"ClientRequestID"` @@ -170,15 +170,15 @@ type TableGetAccessPolicyResult struct { Version *string `xml:"Version"` } -// TableInsertEntityResponse contains the response from method Table.InsertEntity. -type TableInsertEntityResponse struct { - TableInsertEntityResult +// TableClientInsertEntityResponse contains the response from method TableClient.InsertEntity. +type TableClientInsertEntityResponse struct { + TableClientInsertEntityResult // RawResponse contains the underlying HTTP response. RawResponse *http.Response } -// TableInsertEntityResult contains the result from method Table.InsertEntity. -type TableInsertEntityResult struct { +// TableClientInsertEntityResult contains the result from method TableClient.InsertEntity. +type TableClientInsertEntityResult struct { // ClientRequestID contains the information returned from the x-ms-client-request-id header response. ClientRequestID *string @@ -204,15 +204,15 @@ type TableInsertEntityResult struct { Version *string } -// TableMergeEntityResponse contains the response from method Table.MergeEntity. -type TableMergeEntityResponse struct { - TableMergeEntityResult +// TableClientMergeEntityResponse contains the response from method TableClient.MergeEntity. +type TableClientMergeEntityResponse struct { + TableClientMergeEntityResult // RawResponse contains the underlying HTTP response. RawResponse *http.Response } -// TableMergeEntityResult contains the result from method Table.MergeEntity. -type TableMergeEntityResult struct { +// TableClientMergeEntityResult contains the result from method TableClient.MergeEntity. +type TableClientMergeEntityResult struct { // ClientRequestID contains the information returned from the x-ms-client-request-id header response. ClientRequestID *string @@ -229,15 +229,15 @@ type TableMergeEntityResult struct { Version *string } -// TableQueryEntitiesResponse contains the response from method Table.QueryEntities. -type TableQueryEntitiesResponse struct { - TableQueryEntitiesResult +// TableClientQueryEntitiesResponse contains the response from method TableClient.QueryEntities. +type TableClientQueryEntitiesResponse struct { + TableClientQueryEntitiesResult // RawResponse contains the underlying HTTP response. RawResponse *http.Response } -// TableQueryEntitiesResult contains the result from method Table.QueryEntities. -type TableQueryEntitiesResult struct { +// TableClientQueryEntitiesResult contains the result from method TableClient.QueryEntities. +type TableClientQueryEntitiesResult struct { TableEntityQueryResponse // ClientRequestID contains the information returned from the x-ms-client-request-id header response. ClientRequestID *string @@ -258,15 +258,15 @@ type TableQueryEntitiesResult struct { XMSContinuationNextRowKey *string } -// TableQueryEntityWithPartitionAndRowKeyResponse contains the response from method Table.QueryEntityWithPartitionAndRowKey. -type TableQueryEntityWithPartitionAndRowKeyResponse struct { - TableQueryEntityWithPartitionAndRowKeyResult +// TableClientQueryEntityWithPartitionAndRowKeyResponse contains the response from method TableClient.QueryEntityWithPartitionAndRowKey. +type TableClientQueryEntityWithPartitionAndRowKeyResponse struct { + TableClientQueryEntityWithPartitionAndRowKeyResult // RawResponse contains the underlying HTTP response. RawResponse *http.Response } -// TableQueryEntityWithPartitionAndRowKeyResult contains the result from method Table.QueryEntityWithPartitionAndRowKey. -type TableQueryEntityWithPartitionAndRowKeyResult struct { +// TableClientQueryEntityWithPartitionAndRowKeyResult contains the result from method TableClient.QueryEntityWithPartitionAndRowKey. +type TableClientQueryEntityWithPartitionAndRowKeyResult struct { // ClientRequestID contains the information returned from the x-ms-client-request-id header response. ClientRequestID *string @@ -292,15 +292,15 @@ type TableQueryEntityWithPartitionAndRowKeyResult struct { XMSContinuationNextRowKey *string } -// TableQueryResponseEnvelope contains the response from method Table.Query. -type TableQueryResponseEnvelope struct { - TableQueryResult +// TableClientQueryResponse contains the response from method TableClient.Query. +type TableClientQueryResponse struct { + TableClientQueryResult // RawResponse contains the underlying HTTP response. RawResponse *http.Response } -// TableQueryResult contains the result from method Table.Query. -type TableQueryResult struct { +// TableClientQueryResult contains the result from method TableClient.Query. +type TableClientQueryResult struct { TableQueryResponse // ClientRequestID contains the information returned from the x-ms-client-request-id header response. ClientRequestID *string @@ -318,15 +318,15 @@ type TableQueryResult struct { XMSContinuationNextTableName *string } -// TableSetAccessPolicyResponse contains the response from method Table.SetAccessPolicy. -type TableSetAccessPolicyResponse struct { - TableSetAccessPolicyResult +// TableClientSetAccessPolicyResponse contains the response from method TableClient.SetAccessPolicy. +type TableClientSetAccessPolicyResponse struct { + TableClientSetAccessPolicyResult // RawResponse contains the underlying HTTP response. RawResponse *http.Response } -// TableSetAccessPolicyResult contains the result from method Table.SetAccessPolicy. -type TableSetAccessPolicyResult struct { +// TableClientSetAccessPolicyResult contains the result from method TableClient.SetAccessPolicy. +type TableClientSetAccessPolicyResult struct { // ClientRequestID contains the information returned from the x-ms-client-request-id header response. ClientRequestID *string @@ -340,15 +340,15 @@ type TableSetAccessPolicyResult struct { Version *string } -// TableUpdateEntityResponse contains the response from method Table.UpdateEntity. -type TableUpdateEntityResponse struct { - TableUpdateEntityResult +// TableClientUpdateEntityResponse contains the response from method TableClient.UpdateEntity. +type TableClientUpdateEntityResponse struct { + TableClientUpdateEntityResult // RawResponse contains the underlying HTTP response. RawResponse *http.Response } -// TableUpdateEntityResult contains the result from method Table.UpdateEntity. -type TableUpdateEntityResult struct { +// TableClientUpdateEntityResult contains the result from method TableClient.UpdateEntity. +type TableClientUpdateEntityResult struct { // ClientRequestID contains the information returned from the x-ms-client-request-id header response. ClientRequestID *string diff --git a/sdk/data/aztables/internal/service_client.go b/sdk/data/aztables/internal/service_client.go index 8c7a58aa7351..5c94c0915a27 100644 --- a/sdk/data/aztables/internal/service_client.go +++ b/sdk/data/aztables/internal/service_client.go @@ -10,7 +10,7 @@ package internal import ( "context" - "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -21,35 +21,52 @@ import ( // ServiceClient contains the methods for the Service group. // Don't use this type directly, use NewServiceClient() instead. type ServiceClient struct { - con *Connection - version Enum0 + endpoint string + version Enum0 + pl runtime.Pipeline } // NewServiceClient creates a new instance of ServiceClient with the specified values. -func NewServiceClient(con *Connection, version Enum0) *ServiceClient { - return &ServiceClient{con: con, version: version} +// endpoint - The URL of the service account or table that is the target of the desired operation. +// version - Specifies the version of the operation to use for this request. +// options - pass nil to accept the default values. +func NewServiceClient(endpoint string, version Enum0, options *azcore.ClientOptions) *ServiceClient { + cp := azcore.ClientOptions{} + if options != nil { + cp = *options + } + client := &ServiceClient{ + endpoint: endpoint, + version: version, + pl: runtime.NewPipeline(moduleName, moduleVersion, runtime.PipelineOptions{}, &cp), + } + return client } -// GetProperties - Gets the properties of an account's Table service, including properties for Analytics and CORS (Cross-Origin Resource Sharing) rules. -// If the operation fails it returns the *TableServiceError error type. -func (client *ServiceClient) GetProperties(ctx context.Context, restype Enum5, comp Enum6, options *ServiceGetPropertiesOptions) (ServiceGetPropertiesResponse, error) { +// GetProperties - Gets the properties of an account's Table service, including properties for Analytics and CORS (Cross-Origin +// Resource Sharing) rules. +// If the operation fails it returns an *azcore.ResponseError type. +// restype - Required query string to set the service properties. +// comp - Required query string to set the service properties. +// options - ServiceClientGetPropertiesOptions contains the optional parameters for the ServiceClient.GetProperties method. +func (client *ServiceClient) GetProperties(ctx context.Context, restype Enum5, comp Enum6, options *ServiceClientGetPropertiesOptions) (ServiceClientGetPropertiesResponse, error) { req, err := client.getPropertiesCreateRequest(ctx, restype, comp, options) if err != nil { - return ServiceGetPropertiesResponse{}, err + return ServiceClientGetPropertiesResponse{}, err } - resp, err := client.con.Pipeline().Do(req) + resp, err := client.pl.Do(req) if err != nil { - return ServiceGetPropertiesResponse{}, err + return ServiceClientGetPropertiesResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return ServiceGetPropertiesResponse{}, client.getPropertiesHandleError(resp) + return ServiceClientGetPropertiesResponse{}, runtime.NewResponseError(resp) } return client.getPropertiesHandleResponse(resp) } // getPropertiesCreateRequest creates the GetProperties request. -func (client *ServiceClient) getPropertiesCreateRequest(ctx context.Context, restype Enum5, comp Enum6, options *ServiceGetPropertiesOptions) (*policy.Request, error) { - req, err := runtime.NewRequest(ctx, http.MethodGet, client.con.Endpoint()) +func (client *ServiceClient) getPropertiesCreateRequest(ctx context.Context, restype Enum5, comp Enum6, options *ServiceClientGetPropertiesOptions) (*policy.Request, error) { + req, err := runtime.NewRequest(ctx, http.MethodGet, client.endpoint) if err != nil { return nil, err } @@ -69,8 +86,8 @@ func (client *ServiceClient) getPropertiesCreateRequest(ctx context.Context, res } // getPropertiesHandleResponse handles the GetProperties response. -func (client *ServiceClient) getPropertiesHandleResponse(resp *http.Response) (ServiceGetPropertiesResponse, error) { - result := ServiceGetPropertiesResponse{RawResponse: resp} +func (client *ServiceClient) getPropertiesHandleResponse(resp *http.Response) (ServiceClientGetPropertiesResponse, error) { + result := ServiceClientGetPropertiesResponse{RawResponse: resp} if val := resp.Header.Get("x-ms-client-request-id"); val != "" { result.ClientRequestID = &val } @@ -81,45 +98,35 @@ func (client *ServiceClient) getPropertiesHandleResponse(resp *http.Response) (S result.Version = &val } if err := runtime.UnmarshalAsXML(resp, &result.TableServiceProperties); err != nil { - return ServiceGetPropertiesResponse{}, err + return ServiceClientGetPropertiesResponse{}, err } return result, nil } -// getPropertiesHandleError handles the GetProperties error response. -func (client *ServiceClient) getPropertiesHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := TableServiceError{raw: string(body)} - if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - -// GetStatistics - Retrieves statistics related to replication for the Table service. It is only available on the secondary location endpoint when read-access -// geo-redundant replication is enabled for the account. -// If the operation fails it returns the *TableServiceError error type. -func (client *ServiceClient) GetStatistics(ctx context.Context, restype Enum5, comp Enum7, options *ServiceGetStatisticsOptions) (ServiceGetStatisticsResponse, error) { +// GetStatistics - Retrieves statistics related to replication for the Table service. It is only available on the secondary +// location endpoint when read-access geo-redundant replication is enabled for the account. +// If the operation fails it returns an *azcore.ResponseError type. +// restype - Required query string to get service stats. +// comp - Required query string to get service stats. +// options - ServiceClientGetStatisticsOptions contains the optional parameters for the ServiceClient.GetStatistics method. +func (client *ServiceClient) GetStatistics(ctx context.Context, restype Enum5, comp Enum7, options *ServiceClientGetStatisticsOptions) (ServiceClientGetStatisticsResponse, error) { req, err := client.getStatisticsCreateRequest(ctx, restype, comp, options) if err != nil { - return ServiceGetStatisticsResponse{}, err + return ServiceClientGetStatisticsResponse{}, err } - resp, err := client.con.Pipeline().Do(req) + resp, err := client.pl.Do(req) if err != nil { - return ServiceGetStatisticsResponse{}, err + return ServiceClientGetStatisticsResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return ServiceGetStatisticsResponse{}, client.getStatisticsHandleError(resp) + return ServiceClientGetStatisticsResponse{}, runtime.NewResponseError(resp) } return client.getStatisticsHandleResponse(resp) } // getStatisticsCreateRequest creates the GetStatistics request. -func (client *ServiceClient) getStatisticsCreateRequest(ctx context.Context, restype Enum5, comp Enum7, options *ServiceGetStatisticsOptions) (*policy.Request, error) { - req, err := runtime.NewRequest(ctx, http.MethodGet, client.con.Endpoint()) +func (client *ServiceClient) getStatisticsCreateRequest(ctx context.Context, restype Enum5, comp Enum7, options *ServiceClientGetStatisticsOptions) (*policy.Request, error) { + req, err := runtime.NewRequest(ctx, http.MethodGet, client.endpoint) if err != nil { return nil, err } @@ -139,8 +146,8 @@ func (client *ServiceClient) getStatisticsCreateRequest(ctx context.Context, res } // getStatisticsHandleResponse handles the GetStatistics response. -func (client *ServiceClient) getStatisticsHandleResponse(resp *http.Response) (ServiceGetStatisticsResponse, error) { - result := ServiceGetStatisticsResponse{RawResponse: resp} +func (client *ServiceClient) getStatisticsHandleResponse(resp *http.Response) (ServiceClientGetStatisticsResponse, error) { + result := ServiceClientGetStatisticsResponse{RawResponse: resp} if val := resp.Header.Get("x-ms-client-request-id"); val != "" { result.ClientRequestID = &val } @@ -153,50 +160,41 @@ func (client *ServiceClient) getStatisticsHandleResponse(resp *http.Response) (S if val := resp.Header.Get("Date"); val != "" { date, err := time.Parse(time.RFC1123, val) if err != nil { - return ServiceGetStatisticsResponse{}, err + return ServiceClientGetStatisticsResponse{}, err } result.Date = &date } if err := runtime.UnmarshalAsXML(resp, &result.TableServiceStats); err != nil { - return ServiceGetStatisticsResponse{}, err + return ServiceClientGetStatisticsResponse{}, err } return result, nil } -// getStatisticsHandleError handles the GetStatistics error response. -func (client *ServiceClient) getStatisticsHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := TableServiceError{raw: string(body)} - if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - -// SetProperties - Sets properties for an account's Table service endpoint, including properties for Analytics and CORS (Cross-Origin Resource Sharing) -// rules. -// If the operation fails it returns the *TableServiceError error type. -func (client *ServiceClient) SetProperties(ctx context.Context, restype Enum5, comp Enum6, tableServiceProperties TableServiceProperties, options *ServiceSetPropertiesOptions) (ServiceSetPropertiesResponse, error) { +// SetProperties - Sets properties for an account's Table service endpoint, including properties for Analytics and CORS (Cross-Origin +// Resource Sharing) rules. +// If the operation fails it returns an *azcore.ResponseError type. +// restype - Required query string to set the service properties. +// comp - Required query string to set the service properties. +// tableServiceProperties - The Table Service properties. +// options - ServiceClientSetPropertiesOptions contains the optional parameters for the ServiceClient.SetProperties method. +func (client *ServiceClient) SetProperties(ctx context.Context, restype Enum5, comp Enum6, tableServiceProperties TableServiceProperties, options *ServiceClientSetPropertiesOptions) (ServiceClientSetPropertiesResponse, error) { req, err := client.setPropertiesCreateRequest(ctx, restype, comp, tableServiceProperties, options) if err != nil { - return ServiceSetPropertiesResponse{}, err + return ServiceClientSetPropertiesResponse{}, err } - resp, err := client.con.Pipeline().Do(req) + resp, err := client.pl.Do(req) if err != nil { - return ServiceSetPropertiesResponse{}, err + return ServiceClientSetPropertiesResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusAccepted) { - return ServiceSetPropertiesResponse{}, client.setPropertiesHandleError(resp) + return ServiceClientSetPropertiesResponse{}, runtime.NewResponseError(resp) } return client.setPropertiesHandleResponse(resp) } // setPropertiesCreateRequest creates the SetProperties request. -func (client *ServiceClient) setPropertiesCreateRequest(ctx context.Context, restype Enum5, comp Enum6, tableServiceProperties TableServiceProperties, options *ServiceSetPropertiesOptions) (*policy.Request, error) { - req, err := runtime.NewRequest(ctx, http.MethodPut, client.con.Endpoint()) +func (client *ServiceClient) setPropertiesCreateRequest(ctx context.Context, restype Enum5, comp Enum6, tableServiceProperties TableServiceProperties, options *ServiceClientSetPropertiesOptions) (*policy.Request, error) { + req, err := runtime.NewRequest(ctx, http.MethodPut, client.endpoint) if err != nil { return nil, err } @@ -216,8 +214,8 @@ func (client *ServiceClient) setPropertiesCreateRequest(ctx context.Context, res } // setPropertiesHandleResponse handles the SetProperties response. -func (client *ServiceClient) setPropertiesHandleResponse(resp *http.Response) (ServiceSetPropertiesResponse, error) { - result := ServiceSetPropertiesResponse{RawResponse: resp} +func (client *ServiceClient) setPropertiesHandleResponse(resp *http.Response) (ServiceClientSetPropertiesResponse, error) { + result := ServiceClientSetPropertiesResponse{RawResponse: resp} if val := resp.Header.Get("x-ms-client-request-id"); val != "" { result.ClientRequestID = &val } @@ -229,16 +227,3 @@ func (client *ServiceClient) setPropertiesHandleResponse(resp *http.Response) (S } return result, nil } - -// setPropertiesHandleError handles the SetProperties error response. -func (client *ServiceClient) setPropertiesHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := TableServiceError{raw: string(body)} - if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} diff --git a/sdk/data/aztables/internal/table_client.go b/sdk/data/aztables/internal/table_client.go index 348b26c9f147..d0726cb95858 100644 --- a/sdk/data/aztables/internal/table_client.go +++ b/sdk/data/aztables/internal/table_client.go @@ -12,50 +12,66 @@ import ( "context" "encoding/xml" "errors" - "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" "net/url" "strconv" "strings" "time" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" ) // TableClient contains the methods for the Table group. // Don't use this type directly, use NewTableClient() instead. type TableClient struct { - con *Connection - version Enum0 + endpoint string + version Enum0 + pl runtime.Pipeline } // NewTableClient creates a new instance of TableClient with the specified values. -func NewTableClient(con *Connection, version Enum0) *TableClient { - return &TableClient{con: con, version: version} +// endpoint - The URL of the service account or table that is the target of the desired operation. +// version - Specifies the version of the operation to use for this request. +// options - pass nil to accept the default values. +func NewTableClient(endpoint string, version Enum0, options *azcore.ClientOptions) *TableClient { + cp := azcore.ClientOptions{} + if options != nil { + cp = *options + } + client := &TableClient{ + endpoint: endpoint, + version: version, + pl: runtime.NewPipeline(moduleName, moduleVersion, runtime.PipelineOptions{}, &cp), + } + return client } // Create - Creates a new table under the given account. -// If the operation fails it returns the *TableServiceError error type. -func (client *TableClient) Create(ctx context.Context, dataServiceVersion Enum1, tableProperties TableProperties, tableCreateOptions *TableCreateOptions, queryOptions *QueryOptions) (TableCreateResponse, error) { - req, err := client.createCreateRequest(ctx, dataServiceVersion, tableProperties, tableCreateOptions, queryOptions) +// If the operation fails it returns an *azcore.ResponseError type. +// dataServiceVersion - Specifies the data service version. +// tableProperties - The Table properties. +// TableClientCreateOptions - TableClientCreateOptions contains the optional parameters for the TableClient.Create method. +// QueryOptions - QueryOptions contains a group of parameters for the TableClient.Query method. +func (client *TableClient) Create(ctx context.Context, dataServiceVersion Enum1, tableProperties TableProperties, tableClientCreateOptions *TableClientCreateOptions, queryOptions *QueryOptions) (TableClientCreateResponse, error) { + req, err := client.createCreateRequest(ctx, dataServiceVersion, tableProperties, tableClientCreateOptions, queryOptions) if err != nil { - return TableCreateResponse{}, err + return TableClientCreateResponse{}, err } - resp, err := client.con.Pipeline().Do(req) + resp, err := client.pl.Do(req) if err != nil { - return TableCreateResponse{}, err + return TableClientCreateResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusCreated, http.StatusNoContent) { - return TableCreateResponse{}, client.createHandleError(resp) + return TableClientCreateResponse{}, runtime.NewResponseError(resp) } return client.createHandleResponse(resp) } // createCreateRequest creates the Create request. -func (client *TableClient) createCreateRequest(ctx context.Context, dataServiceVersion Enum1, tableProperties TableProperties, tableCreateOptions *TableCreateOptions, queryOptions *QueryOptions) (*policy.Request, error) { +func (client *TableClient) createCreateRequest(ctx context.Context, dataServiceVersion Enum1, tableProperties TableProperties, tableClientCreateOptions *TableClientCreateOptions, queryOptions *QueryOptions) (*policy.Request, error) { urlPath := "/Tables" - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.con.Endpoint(), urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.endpoint, urlPath)) if err != nil { return nil, err } @@ -65,20 +81,20 @@ func (client *TableClient) createCreateRequest(ctx context.Context, dataServiceV } req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header.Set("x-ms-version", string(client.version)) - if tableCreateOptions != nil && tableCreateOptions.RequestID != nil { - req.Raw().Header.Set("x-ms-client-request-id", *tableCreateOptions.RequestID) + if tableClientCreateOptions != nil && tableClientCreateOptions.RequestID != nil { + req.Raw().Header.Set("x-ms-client-request-id", *tableClientCreateOptions.RequestID) } req.Raw().Header.Set("DataServiceVersion", string(dataServiceVersion)) - if tableCreateOptions != nil && tableCreateOptions.ResponsePreference != nil { - req.Raw().Header.Set("Prefer", string(*tableCreateOptions.ResponsePreference)) + if tableClientCreateOptions != nil && tableClientCreateOptions.ResponsePreference != nil { + req.Raw().Header.Set("Prefer", string(*tableClientCreateOptions.ResponsePreference)) } req.Raw().Header.Set("Accept", "application/json;odata=minimalmetadata") return req, runtime.MarshalAsJSON(req, tableProperties) } // createHandleResponse handles the Create response. -func (client *TableClient) createHandleResponse(resp *http.Response) (TableCreateResponse, error) { - result := TableCreateResponse{RawResponse: resp} +func (client *TableClient) createHandleResponse(resp *http.Response) (TableClientCreateResponse, error) { + result := TableClientCreateResponse{RawResponse: resp} if val := resp.Header.Get("x-ms-client-request-id"); val != "" { result.ClientRequestID = &val } @@ -91,7 +107,7 @@ func (client *TableClient) createHandleResponse(resp *http.Response) (TableCreat if val := resp.Header.Get("Date"); val != "" { date, err := time.Parse(time.RFC1123, val) if err != nil { - return TableCreateResponse{}, err + return TableClientCreateResponse{}, err } result.Date = &date } @@ -99,49 +115,38 @@ func (client *TableClient) createHandleResponse(resp *http.Response) (TableCreat result.PreferenceApplied = &val } if err := runtime.UnmarshalAsJSON(resp, &result.TableResponse); err != nil { - return TableCreateResponse{}, err + return TableClientCreateResponse{}, err } return result, nil } -// createHandleError handles the Create error response. -func (client *TableClient) createHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := TableServiceError{raw: string(body)} - if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // Delete - Operation permanently deletes the specified table. -// If the operation fails it returns the *TableServiceError error type. -func (client *TableClient) Delete(ctx context.Context, table string, options *TableDeleteOptions) (TableDeleteResponse, error) { +// If the operation fails it returns an *azcore.ResponseError type. +// table - The name of the table. +// options - TableClientDeleteOptions contains the optional parameters for the TableClient.Delete method. +func (client *TableClient) Delete(ctx context.Context, table string, options *TableClientDeleteOptions) (TableClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, table, options) if err != nil { - return TableDeleteResponse{}, err + return TableClientDeleteResponse{}, err } - resp, err := client.con.Pipeline().Do(req) + resp, err := client.pl.Do(req) if err != nil { - return TableDeleteResponse{}, err + return TableClientDeleteResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusNoContent) { - return TableDeleteResponse{}, client.deleteHandleError(resp) + return TableClientDeleteResponse{}, runtime.NewResponseError(resp) } return client.deleteHandleResponse(resp) } // deleteCreateRequest creates the Delete request. -func (client *TableClient) deleteCreateRequest(ctx context.Context, table string, options *TableDeleteOptions) (*policy.Request, error) { +func (client *TableClient) deleteCreateRequest(ctx context.Context, table string, options *TableClientDeleteOptions) (*policy.Request, error) { urlPath := "/Tables('{table}')" if table == "" { return nil, errors.New("parameter table cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{table}", url.PathEscape(table)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.con.Endpoint(), urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.endpoint, urlPath)) if err != nil { return nil, err } @@ -154,8 +159,8 @@ func (client *TableClient) deleteCreateRequest(ctx context.Context, table string } // deleteHandleResponse handles the Delete response. -func (client *TableClient) deleteHandleResponse(resp *http.Response) (TableDeleteResponse, error) { - result := TableDeleteResponse{RawResponse: resp} +func (client *TableClient) deleteHandleResponse(resp *http.Response) (TableClientDeleteResponse, error) { + result := TableClientDeleteResponse{RawResponse: resp} if val := resp.Header.Get("x-ms-client-request-id"); val != "" { result.ClientRequestID = &val } @@ -168,45 +173,41 @@ func (client *TableClient) deleteHandleResponse(resp *http.Response) (TableDelet if val := resp.Header.Get("Date"); val != "" { date, err := time.Parse(time.RFC1123, val) if err != nil { - return TableDeleteResponse{}, err + return TableClientDeleteResponse{}, err } result.Date = &date } return result, nil } -// deleteHandleError handles the Delete error response. -func (client *TableClient) deleteHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := TableServiceError{raw: string(body)} - if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // DeleteEntity - Deletes the specified entity in a table. -// If the operation fails it returns the *TableServiceError error type. -func (client *TableClient) DeleteEntity(ctx context.Context, dataServiceVersion Enum1, table string, partitionKey string, rowKey string, ifMatch string, tableDeleteEntityOptions *TableDeleteEntityOptions, queryOptions *QueryOptions) (TableDeleteEntityResponse, error) { - req, err := client.DeleteEntityCreateRequest(ctx, dataServiceVersion, table, partitionKey, rowKey, ifMatch, tableDeleteEntityOptions, queryOptions) +// If the operation fails it returns an *azcore.ResponseError type. +// dataServiceVersion - Specifies the data service version. +// table - The name of the table. +// partitionKey - The partition key of the entity. +// rowKey - The row key of the entity. +// ifMatch - Match condition for an entity to be deleted. If specified and a matching entity is not found, an error will be +// raised. To force an unconditional delete, set to the wildcard character (*). +// TableClientDeleteEntityOptions - TableClientDeleteEntityOptions contains the optional parameters for the TableClient.DeleteEntity +// method. +// QueryOptions - QueryOptions contains a group of parameters for the TableClient.Query method. +func (client *TableClient) DeleteEntity(ctx context.Context, dataServiceVersion Enum1, table string, partitionKey string, rowKey string, ifMatch string, tableClientDeleteEntityOptions *TableClientDeleteEntityOptions, queryOptions *QueryOptions) (TableClientDeleteEntityResponse, error) { + req, err := client.DeleteEntityCreateRequest(ctx, dataServiceVersion, table, partitionKey, rowKey, ifMatch, tableClientDeleteEntityOptions, queryOptions) if err != nil { - return TableDeleteEntityResponse{}, err + return TableClientDeleteEntityResponse{}, err } - resp, err := client.con.Pipeline().Do(req) + resp, err := client.pl.Do(req) if err != nil { - return TableDeleteEntityResponse{}, err + return TableClientDeleteEntityResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusNoContent) { - return TableDeleteEntityResponse{}, client.deleteEntityHandleError(resp) + return TableClientDeleteEntityResponse{}, runtime.NewResponseError(resp) } return client.deleteEntityHandleResponse(resp) } -// DeleteEntityCreateRequest creates the DeleteEntity request. -func (client *TableClient) DeleteEntityCreateRequest(ctx context.Context, dataServiceVersion Enum1, table string, partitionKey string, rowKey string, ifMatch string, tableDeleteEntityOptions *TableDeleteEntityOptions, queryOptions *QueryOptions) (*policy.Request, error) { +// deleteEntityCreateRequest creates the DeleteEntity request. +func (client *TableClient) DeleteEntityCreateRequest(ctx context.Context, dataServiceVersion Enum1, table string, partitionKey string, rowKey string, ifMatch string, tableClientDeleteEntityOptions *TableClientDeleteEntityOptions, queryOptions *QueryOptions) (*policy.Request, error) { urlPath := "/{table}(PartitionKey='{partitionKey}',RowKey='{rowKey}')" if table == "" { return nil, errors.New("parameter table cannot be empty") @@ -220,21 +221,21 @@ func (client *TableClient) DeleteEntityCreateRequest(ctx context.Context, dataSe return nil, errors.New("parameter rowKey cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{rowKey}", url.PathEscape(rowKey)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.con.Endpoint(), urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.endpoint, urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - if tableDeleteEntityOptions != nil && tableDeleteEntityOptions.Timeout != nil { - reqQP.Set("timeout", strconv.FormatInt(int64(*tableDeleteEntityOptions.Timeout), 10)) + if tableClientDeleteEntityOptions != nil && tableClientDeleteEntityOptions.Timeout != nil { + reqQP.Set("timeout", strconv.FormatInt(int64(*tableClientDeleteEntityOptions.Timeout), 10)) } if queryOptions != nil && queryOptions.Format != nil { reqQP.Set("$format", string(*queryOptions.Format)) } req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header.Set("x-ms-version", string(client.version)) - if tableDeleteEntityOptions != nil && tableDeleteEntityOptions.RequestID != nil { - req.Raw().Header.Set("x-ms-client-request-id", *tableDeleteEntityOptions.RequestID) + if tableClientDeleteEntityOptions != nil && tableClientDeleteEntityOptions.RequestID != nil { + req.Raw().Header.Set("x-ms-client-request-id", *tableClientDeleteEntityOptions.RequestID) } req.Raw().Header.Set("DataServiceVersion", string(dataServiceVersion)) req.Raw().Header.Set("If-Match", ifMatch) @@ -243,8 +244,8 @@ func (client *TableClient) DeleteEntityCreateRequest(ctx context.Context, dataSe } // deleteEntityHandleResponse handles the DeleteEntity response. -func (client *TableClient) deleteEntityHandleResponse(resp *http.Response) (TableDeleteEntityResponse, error) { - result := TableDeleteEntityResponse{RawResponse: resp} +func (client *TableClient) deleteEntityHandleResponse(resp *http.Response) (TableClientDeleteEntityResponse, error) { + result := TableClientDeleteEntityResponse{RawResponse: resp} if val := resp.Header.Get("x-ms-client-request-id"); val != "" { result.ClientRequestID = &val } @@ -257,51 +258,42 @@ func (client *TableClient) deleteEntityHandleResponse(resp *http.Response) (Tabl if val := resp.Header.Get("Date"); val != "" { date, err := time.Parse(time.RFC1123, val) if err != nil { - return TableDeleteEntityResponse{}, err + return TableClientDeleteEntityResponse{}, err } result.Date = &date } return result, nil } -// deleteEntityHandleError handles the DeleteEntity error response. -func (client *TableClient) deleteEntityHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := TableServiceError{raw: string(body)} - if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - -// GetAccessPolicy - Retrieves details about any stored access policies specified on the table that may be used with Shared Access Signatures. -// If the operation fails it returns the *TableServiceError error type. -func (client *TableClient) GetAccessPolicy(ctx context.Context, table string, comp Enum4, options *TableGetAccessPolicyOptions) (TableGetAccessPolicyResponse, error) { +// GetAccessPolicy - Retrieves details about any stored access policies specified on the table that may be used with Shared +// Access Signatures. +// If the operation fails it returns an *azcore.ResponseError type. +// table - The name of the table. +// comp - Required query string to handle stored access policies for the table that may be used with Shared Access Signatures. +// options - TableClientGetAccessPolicyOptions contains the optional parameters for the TableClient.GetAccessPolicy method. +func (client *TableClient) GetAccessPolicy(ctx context.Context, table string, comp Enum4, options *TableClientGetAccessPolicyOptions) (TableClientGetAccessPolicyResponse, error) { req, err := client.getAccessPolicyCreateRequest(ctx, table, comp, options) if err != nil { - return TableGetAccessPolicyResponse{}, err + return TableClientGetAccessPolicyResponse{}, err } - resp, err := client.con.Pipeline().Do(req) + resp, err := client.pl.Do(req) if err != nil { - return TableGetAccessPolicyResponse{}, err + return TableClientGetAccessPolicyResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return TableGetAccessPolicyResponse{}, client.getAccessPolicyHandleError(resp) + return TableClientGetAccessPolicyResponse{}, runtime.NewResponseError(resp) } return client.getAccessPolicyHandleResponse(resp) } // getAccessPolicyCreateRequest creates the GetAccessPolicy request. -func (client *TableClient) getAccessPolicyCreateRequest(ctx context.Context, table string, comp Enum4, options *TableGetAccessPolicyOptions) (*policy.Request, error) { +func (client *TableClient) getAccessPolicyCreateRequest(ctx context.Context, table string, comp Enum4, options *TableClientGetAccessPolicyOptions) (*policy.Request, error) { urlPath := "/{table}" if table == "" { return nil, errors.New("parameter table cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{table}", url.PathEscape(table)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.con.Endpoint(), urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.endpoint, urlPath)) if err != nil { return nil, err } @@ -320,8 +312,8 @@ func (client *TableClient) getAccessPolicyCreateRequest(ctx context.Context, tab } // getAccessPolicyHandleResponse handles the GetAccessPolicy response. -func (client *TableClient) getAccessPolicyHandleResponse(resp *http.Response) (TableGetAccessPolicyResponse, error) { - result := TableGetAccessPolicyResponse{RawResponse: resp} +func (client *TableClient) getAccessPolicyHandleResponse(resp *http.Response) (TableClientGetAccessPolicyResponse, error) { + result := TableClientGetAccessPolicyResponse{RawResponse: resp} if val := resp.Header.Get("x-ms-client-request-id"); val != "" { result.ClientRequestID = &val } @@ -334,83 +326,75 @@ func (client *TableClient) getAccessPolicyHandleResponse(resp *http.Response) (T if val := resp.Header.Get("Date"); val != "" { date, err := time.Parse(time.RFC1123, val) if err != nil { - return TableGetAccessPolicyResponse{}, err + return TableClientGetAccessPolicyResponse{}, err } result.Date = &date } if err := runtime.UnmarshalAsXML(resp, &result); err != nil { - return TableGetAccessPolicyResponse{}, err + return TableClientGetAccessPolicyResponse{}, err } return result, nil } -// getAccessPolicyHandleError handles the GetAccessPolicy error response. -func (client *TableClient) getAccessPolicyHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := TableServiceError{raw: string(body)} - if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // InsertEntity - Insert entity in a table. -// If the operation fails it returns the *TableServiceError error type. -func (client *TableClient) InsertEntity(ctx context.Context, dataServiceVersion Enum1, table string, tableInsertEntityOptions *TableInsertEntityOptions, queryOptions *QueryOptions) (TableInsertEntityResponse, error) { - req, err := client.InsertEntityCreateRequest(ctx, dataServiceVersion, table, tableInsertEntityOptions, queryOptions) +// If the operation fails it returns an *azcore.ResponseError type. +// dataServiceVersion - Specifies the data service version. +// table - The name of the table. +// TableClientInsertEntityOptions - TableClientInsertEntityOptions contains the optional parameters for the TableClient.InsertEntity +// method. +// QueryOptions - QueryOptions contains a group of parameters for the TableClient.Query method. +func (client *TableClient) InsertEntity(ctx context.Context, dataServiceVersion Enum1, table string, tableClientInsertEntityOptions *TableClientInsertEntityOptions, queryOptions *QueryOptions) (TableClientInsertEntityResponse, error) { + req, err := client.InsertEntityCreateRequest(ctx, dataServiceVersion, table, tableClientInsertEntityOptions, queryOptions) if err != nil { - return TableInsertEntityResponse{}, err + return TableClientInsertEntityResponse{}, err } - resp, err := client.con.Pipeline().Do(req) + resp, err := client.pl.Do(req) if err != nil { - return TableInsertEntityResponse{}, err + return TableClientInsertEntityResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusCreated, http.StatusNoContent) { - return TableInsertEntityResponse{}, client.insertEntityHandleError(resp) + return TableClientInsertEntityResponse{}, runtime.NewResponseError(resp) } return client.insertEntityHandleResponse(resp) } -// InsertEntityCreateRequest creates the InsertEntity request. -func (client *TableClient) InsertEntityCreateRequest(ctx context.Context, dataServiceVersion Enum1, table string, tableInsertEntityOptions *TableInsertEntityOptions, queryOptions *QueryOptions) (*policy.Request, error) { +// insertEntityCreateRequest creates the InsertEntity request. +func (client *TableClient) InsertEntityCreateRequest(ctx context.Context, dataServiceVersion Enum1, table string, tableClientInsertEntityOptions *TableClientInsertEntityOptions, queryOptions *QueryOptions) (*policy.Request, error) { urlPath := "/{table}" if table == "" { return nil, errors.New("parameter table cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{table}", url.PathEscape(table)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.con.Endpoint(), urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.endpoint, urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - if tableInsertEntityOptions != nil && tableInsertEntityOptions.Timeout != nil { - reqQP.Set("timeout", strconv.FormatInt(int64(*tableInsertEntityOptions.Timeout), 10)) + if tableClientInsertEntityOptions != nil && tableClientInsertEntityOptions.Timeout != nil { + reqQP.Set("timeout", strconv.FormatInt(int64(*tableClientInsertEntityOptions.Timeout), 10)) } if queryOptions != nil && queryOptions.Format != nil { reqQP.Set("$format", string(*queryOptions.Format)) } req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header.Set("x-ms-version", string(client.version)) - if tableInsertEntityOptions != nil && tableInsertEntityOptions.RequestID != nil { - req.Raw().Header.Set("x-ms-client-request-id", *tableInsertEntityOptions.RequestID) + if tableClientInsertEntityOptions != nil && tableClientInsertEntityOptions.RequestID != nil { + req.Raw().Header.Set("x-ms-client-request-id", *tableClientInsertEntityOptions.RequestID) } req.Raw().Header.Set("DataServiceVersion", string(dataServiceVersion)) - if tableInsertEntityOptions != nil && tableInsertEntityOptions.ResponsePreference != nil { - req.Raw().Header.Set("Prefer", string(*tableInsertEntityOptions.ResponsePreference)) + if tableClientInsertEntityOptions != nil && tableClientInsertEntityOptions.ResponsePreference != nil { + req.Raw().Header.Set("Prefer", string(*tableClientInsertEntityOptions.ResponsePreference)) } req.Raw().Header.Set("Accept", "application/json;odata=minimalmetadata") - if tableInsertEntityOptions != nil && tableInsertEntityOptions.TableEntityProperties != nil { - return req, runtime.MarshalAsJSON(req, tableInsertEntityOptions.TableEntityProperties) + if tableClientInsertEntityOptions != nil && tableClientInsertEntityOptions.TableEntityProperties != nil { + return req, runtime.MarshalAsJSON(req, tableClientInsertEntityOptions.TableEntityProperties) } return req, nil } // insertEntityHandleResponse handles the InsertEntity response. -func (client *TableClient) insertEntityHandleResponse(resp *http.Response) (TableInsertEntityResponse, error) { - result := TableInsertEntityResponse{RawResponse: resp} +func (client *TableClient) insertEntityHandleResponse(resp *http.Response) (TableClientInsertEntityResponse, error) { + result := TableClientInsertEntityResponse{RawResponse: resp} if val := resp.Header.Get("x-ms-client-request-id"); val != "" { result.ClientRequestID = &val } @@ -423,7 +407,7 @@ func (client *TableClient) insertEntityHandleResponse(resp *http.Response) (Tabl if val := resp.Header.Get("Date"); val != "" { date, err := time.Parse(time.RFC1123, val) if err != nil { - return TableInsertEntityResponse{}, err + return TableClientInsertEntityResponse{}, err } result.Date = &date } @@ -437,43 +421,37 @@ func (client *TableClient) insertEntityHandleResponse(resp *http.Response) (Tabl result.ContentType = &val } if err := runtime.UnmarshalAsJSON(resp, &result.Value); err != nil { - return TableInsertEntityResponse{}, err + return TableClientInsertEntityResponse{}, err } return result, nil } -// insertEntityHandleError handles the InsertEntity error response. -func (client *TableClient) insertEntityHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := TableServiceError{raw: string(body)} - if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // MergeEntity - Merge entity in a table. -// If the operation fails it returns the *TableServiceError error type. -func (client *TableClient) MergeEntity(ctx context.Context, dataServiceVersion Enum1, table string, partitionKey string, rowKey string, tableMergeEntityOptions *TableMergeEntityOptions, queryOptions *QueryOptions) (TableMergeEntityResponse, error) { - req, err := client.MergeEntityCreateRequest(ctx, dataServiceVersion, table, partitionKey, rowKey, tableMergeEntityOptions, queryOptions) +// If the operation fails it returns an *azcore.ResponseError type. +// dataServiceVersion - Specifies the data service version. +// table - The name of the table. +// partitionKey - The partition key of the entity. +// rowKey - The row key of the entity. +// TableClientMergeEntityOptions - TableClientMergeEntityOptions contains the optional parameters for the TableClient.MergeEntity +// method. +// QueryOptions - QueryOptions contains a group of parameters for the TableClient.Query method. +func (client *TableClient) MergeEntity(ctx context.Context, dataServiceVersion Enum1, table string, partitionKey string, rowKey string, tableClientMergeEntityOptions *TableClientMergeEntityOptions, queryOptions *QueryOptions) (TableClientMergeEntityResponse, error) { + req, err := client.MergeEntityCreateRequest(ctx, dataServiceVersion, table, partitionKey, rowKey, tableClientMergeEntityOptions, queryOptions) if err != nil { - return TableMergeEntityResponse{}, err + return TableClientMergeEntityResponse{}, err } - resp, err := client.con.Pipeline().Do(req) + resp, err := client.pl.Do(req) if err != nil { - return TableMergeEntityResponse{}, err + return TableClientMergeEntityResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusNoContent) { - return TableMergeEntityResponse{}, client.mergeEntityHandleError(resp) + return TableClientMergeEntityResponse{}, runtime.NewResponseError(resp) } return client.mergeEntityHandleResponse(resp) } -// MergeEntityCreateRequest creates the MergeEntity request. -func (client *TableClient) MergeEntityCreateRequest(ctx context.Context, dataServiceVersion Enum1, table string, partitionKey string, rowKey string, tableMergeEntityOptions *TableMergeEntityOptions, queryOptions *QueryOptions) (*policy.Request, error) { +// mergeEntityCreateRequest creates the MergeEntity request. +func (client *TableClient) MergeEntityCreateRequest(ctx context.Context, dataServiceVersion Enum1, table string, partitionKey string, rowKey string, tableClientMergeEntityOptions *TableClientMergeEntityOptions, queryOptions *QueryOptions) (*policy.Request, error) { urlPath := "/{table}(PartitionKey='{partitionKey}',RowKey='{rowKey}')" if table == "" { return nil, errors.New("parameter table cannot be empty") @@ -487,36 +465,36 @@ func (client *TableClient) MergeEntityCreateRequest(ctx context.Context, dataSer return nil, errors.New("parameter rowKey cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{rowKey}", url.PathEscape(rowKey)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.con.Endpoint(), urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.endpoint, urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - if tableMergeEntityOptions != nil && tableMergeEntityOptions.Timeout != nil { - reqQP.Set("timeout", strconv.FormatInt(int64(*tableMergeEntityOptions.Timeout), 10)) + if tableClientMergeEntityOptions != nil && tableClientMergeEntityOptions.Timeout != nil { + reqQP.Set("timeout", strconv.FormatInt(int64(*tableClientMergeEntityOptions.Timeout), 10)) } if queryOptions != nil && queryOptions.Format != nil { reqQP.Set("$format", string(*queryOptions.Format)) } req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header.Set("x-ms-version", string(client.version)) - if tableMergeEntityOptions != nil && tableMergeEntityOptions.RequestID != nil { - req.Raw().Header.Set("x-ms-client-request-id", *tableMergeEntityOptions.RequestID) + if tableClientMergeEntityOptions != nil && tableClientMergeEntityOptions.RequestID != nil { + req.Raw().Header.Set("x-ms-client-request-id", *tableClientMergeEntityOptions.RequestID) } req.Raw().Header.Set("DataServiceVersion", string(dataServiceVersion)) - if tableMergeEntityOptions != nil && tableMergeEntityOptions.IfMatch != nil { - req.Raw().Header.Set("If-Match", *tableMergeEntityOptions.IfMatch) + if tableClientMergeEntityOptions != nil && tableClientMergeEntityOptions.IfMatch != nil { + req.Raw().Header.Set("If-Match", *tableClientMergeEntityOptions.IfMatch) } req.Raw().Header.Set("Accept", "application/json") - if tableMergeEntityOptions != nil && tableMergeEntityOptions.TableEntityProperties != nil { - return req, runtime.MarshalAsJSON(req, tableMergeEntityOptions.TableEntityProperties) + if tableClientMergeEntityOptions != nil && tableClientMergeEntityOptions.TableEntityProperties != nil { + return req, runtime.MarshalAsJSON(req, tableClientMergeEntityOptions.TableEntityProperties) } return req, nil } // mergeEntityHandleResponse handles the MergeEntity response. -func (client *TableClient) mergeEntityHandleResponse(resp *http.Response) (TableMergeEntityResponse, error) { - result := TableMergeEntityResponse{RawResponse: resp} +func (client *TableClient) mergeEntityHandleResponse(resp *http.Response) (TableClientMergeEntityResponse, error) { + result := TableClientMergeEntityResponse{RawResponse: resp} if val := resp.Header.Get("x-ms-client-request-id"); val != "" { result.ClientRequestID = &val } @@ -529,7 +507,7 @@ func (client *TableClient) mergeEntityHandleResponse(resp *http.Response) (Table if val := resp.Header.Get("Date"); val != "" { date, err := time.Parse(time.RFC1123, val) if err != nil { - return TableMergeEntityResponse{}, err + return TableClientMergeEntityResponse{}, err } result.Date = &date } @@ -539,40 +517,30 @@ func (client *TableClient) mergeEntityHandleResponse(resp *http.Response) (Table return result, nil } -// mergeEntityHandleError handles the MergeEntity error response. -func (client *TableClient) mergeEntityHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := TableServiceError{raw: string(body)} - if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // Query - Queries tables under the given account. -// If the operation fails it returns a generic error. -func (client *TableClient) Query(ctx context.Context, dataServiceVersion Enum1, tableQueryOptions *TableQueryOptions, queryOptions *QueryOptions) (TableQueryResponseEnvelope, error) { - req, err := client.queryCreateRequest(ctx, dataServiceVersion, tableQueryOptions, queryOptions) +// If the operation fails it returns an *azcore.ResponseError type. +// dataServiceVersion - Specifies the data service version. +// TableClientQueryOptions - TableClientQueryOptions contains the optional parameters for the TableClient.Query method. +// QueryOptions - QueryOptions contains a group of parameters for the TableClient.Query method. +func (client *TableClient) Query(ctx context.Context, dataServiceVersion Enum1, tableClientQueryOptions *TableClientQueryOptions, queryOptions *QueryOptions) (TableClientQueryResponse, error) { + req, err := client.queryCreateRequest(ctx, dataServiceVersion, tableClientQueryOptions, queryOptions) if err != nil { - return TableQueryResponseEnvelope{}, err + return TableClientQueryResponse{}, err } - resp, err := client.con.Pipeline().Do(req) + resp, err := client.pl.Do(req) if err != nil { - return TableQueryResponseEnvelope{}, err + return TableClientQueryResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return TableQueryResponseEnvelope{}, client.queryHandleError(resp) + return TableClientQueryResponse{}, runtime.NewResponseError(resp) } return client.queryHandleResponse(resp) } // queryCreateRequest creates the Query request. -func (client *TableClient) queryCreateRequest(ctx context.Context, dataServiceVersion Enum1, tableQueryOptions *TableQueryOptions, queryOptions *QueryOptions) (*policy.Request, error) { +func (client *TableClient) queryCreateRequest(ctx context.Context, dataServiceVersion Enum1, tableClientQueryOptions *TableClientQueryOptions, queryOptions *QueryOptions) (*policy.Request, error) { urlPath := "/Tables" - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.con.Endpoint(), urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.endpoint, urlPath)) if err != nil { return nil, err } @@ -589,13 +557,13 @@ func (client *TableClient) queryCreateRequest(ctx context.Context, dataServiceVe if queryOptions != nil && queryOptions.Filter != nil { reqQP.Set("$filter", *queryOptions.Filter) } - if tableQueryOptions != nil && tableQueryOptions.NextTableName != nil { - reqQP.Set("NextTableName", *tableQueryOptions.NextTableName) + if tableClientQueryOptions != nil && tableClientQueryOptions.NextTableName != nil { + reqQP.Set("NextTableName", *tableClientQueryOptions.NextTableName) } req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header.Set("x-ms-version", string(client.version)) - if tableQueryOptions != nil && tableQueryOptions.RequestID != nil { - req.Raw().Header.Set("x-ms-client-request-id", *tableQueryOptions.RequestID) + if tableClientQueryOptions != nil && tableClientQueryOptions.RequestID != nil { + req.Raw().Header.Set("x-ms-client-request-id", *tableClientQueryOptions.RequestID) } req.Raw().Header.Set("DataServiceVersion", string(dataServiceVersion)) req.Raw().Header.Set("Accept", "application/json;odata=minimalmetadata") @@ -603,8 +571,8 @@ func (client *TableClient) queryCreateRequest(ctx context.Context, dataServiceVe } // queryHandleResponse handles the Query response. -func (client *TableClient) queryHandleResponse(resp *http.Response) (TableQueryResponseEnvelope, error) { - result := TableQueryResponseEnvelope{RawResponse: resp} +func (client *TableClient) queryHandleResponse(resp *http.Response) (TableClientQueryResponse, error) { + result := TableClientQueryResponse{RawResponse: resp} if val := resp.Header.Get("x-ms-client-request-id"); val != "" { result.ClientRequestID = &val } @@ -617,7 +585,7 @@ func (client *TableClient) queryHandleResponse(resp *http.Response) (TableQueryR if val := resp.Header.Get("Date"); val != "" { date, err := time.Parse(time.RFC1123, val) if err != nil { - return TableQueryResponseEnvelope{}, err + return TableClientQueryResponse{}, err } result.Date = &date } @@ -625,54 +593,47 @@ func (client *TableClient) queryHandleResponse(resp *http.Response) (TableQueryR result.XMSContinuationNextTableName = &val } if err := runtime.UnmarshalAsJSON(resp, &result.TableQueryResponse); err != nil { - return TableQueryResponseEnvelope{}, err + return TableClientQueryResponse{}, err } return result, nil } -// queryHandleError handles the Query error response. -func (client *TableClient) queryHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - if len(body) == 0 { - return runtime.NewResponseError(errors.New(resp.Status), resp) - } - return runtime.NewResponseError(errors.New(string(body)), resp) -} - // QueryEntities - Queries entities in a table. -// If the operation fails it returns the *TableServiceError error type. -func (client *TableClient) QueryEntities(ctx context.Context, dataServiceVersion Enum1, table string, tableQueryEntitiesOptions *TableQueryEntitiesOptions, queryOptions *QueryOptions) (TableQueryEntitiesResponse, error) { - req, err := client.queryEntitiesCreateRequest(ctx, dataServiceVersion, table, tableQueryEntitiesOptions, queryOptions) +// If the operation fails it returns an *azcore.ResponseError type. +// dataServiceVersion - Specifies the data service version. +// table - The name of the table. +// TableClientQueryEntitiesOptions - TableClientQueryEntitiesOptions contains the optional parameters for the TableClient.QueryEntities +// method. +// QueryOptions - QueryOptions contains a group of parameters for the TableClient.Query method. +func (client *TableClient) QueryEntities(ctx context.Context, dataServiceVersion Enum1, table string, tableClientQueryEntitiesOptions *TableClientQueryEntitiesOptions, queryOptions *QueryOptions) (TableClientQueryEntitiesResponse, error) { + req, err := client.queryEntitiesCreateRequest(ctx, dataServiceVersion, table, tableClientQueryEntitiesOptions, queryOptions) if err != nil { - return TableQueryEntitiesResponse{}, err + return TableClientQueryEntitiesResponse{}, err } - resp, err := client.con.Pipeline().Do(req) + resp, err := client.pl.Do(req) if err != nil { - return TableQueryEntitiesResponse{}, err + return TableClientQueryEntitiesResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return TableQueryEntitiesResponse{}, client.queryEntitiesHandleError(resp) + return TableClientQueryEntitiesResponse{}, runtime.NewResponseError(resp) } return client.queryEntitiesHandleResponse(resp) } // queryEntitiesCreateRequest creates the QueryEntities request. -func (client *TableClient) queryEntitiesCreateRequest(ctx context.Context, dataServiceVersion Enum1, table string, tableQueryEntitiesOptions *TableQueryEntitiesOptions, queryOptions *QueryOptions) (*policy.Request, error) { +func (client *TableClient) queryEntitiesCreateRequest(ctx context.Context, dataServiceVersion Enum1, table string, tableClientQueryEntitiesOptions *TableClientQueryEntitiesOptions, queryOptions *QueryOptions) (*policy.Request, error) { urlPath := "/{table}()" if table == "" { return nil, errors.New("parameter table cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{table}", url.PathEscape(table)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.con.Endpoint(), urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.endpoint, urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - if tableQueryEntitiesOptions != nil && tableQueryEntitiesOptions.Timeout != nil { - reqQP.Set("timeout", strconv.FormatInt(int64(*tableQueryEntitiesOptions.Timeout), 10)) + if tableClientQueryEntitiesOptions != nil && tableClientQueryEntitiesOptions.Timeout != nil { + reqQP.Set("timeout", strconv.FormatInt(int64(*tableClientQueryEntitiesOptions.Timeout), 10)) } if queryOptions != nil && queryOptions.Format != nil { reqQP.Set("$format", string(*queryOptions.Format)) @@ -686,16 +647,16 @@ func (client *TableClient) queryEntitiesCreateRequest(ctx context.Context, dataS if queryOptions != nil && queryOptions.Filter != nil { reqQP.Set("$filter", *queryOptions.Filter) } - if tableQueryEntitiesOptions != nil && tableQueryEntitiesOptions.NextPartitionKey != nil { - reqQP.Set("NextPartitionKey", *tableQueryEntitiesOptions.NextPartitionKey) + if tableClientQueryEntitiesOptions != nil && tableClientQueryEntitiesOptions.NextPartitionKey != nil { + reqQP.Set("NextPartitionKey", *tableClientQueryEntitiesOptions.NextPartitionKey) } - if tableQueryEntitiesOptions != nil && tableQueryEntitiesOptions.NextRowKey != nil { - reqQP.Set("NextRowKey", *tableQueryEntitiesOptions.NextRowKey) + if tableClientQueryEntitiesOptions != nil && tableClientQueryEntitiesOptions.NextRowKey != nil { + reqQP.Set("NextRowKey", *tableClientQueryEntitiesOptions.NextRowKey) } req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header.Set("x-ms-version", string(client.version)) - if tableQueryEntitiesOptions != nil && tableQueryEntitiesOptions.RequestID != nil { - req.Raw().Header.Set("x-ms-client-request-id", *tableQueryEntitiesOptions.RequestID) + if tableClientQueryEntitiesOptions != nil && tableClientQueryEntitiesOptions.RequestID != nil { + req.Raw().Header.Set("x-ms-client-request-id", *tableClientQueryEntitiesOptions.RequestID) } req.Raw().Header.Set("DataServiceVersion", string(dataServiceVersion)) req.Raw().Header.Set("Accept", "application/json;odata=minimalmetadata") @@ -703,8 +664,8 @@ func (client *TableClient) queryEntitiesCreateRequest(ctx context.Context, dataS } // queryEntitiesHandleResponse handles the QueryEntities response. -func (client *TableClient) queryEntitiesHandleResponse(resp *http.Response) (TableQueryEntitiesResponse, error) { - result := TableQueryEntitiesResponse{RawResponse: resp} +func (client *TableClient) queryEntitiesHandleResponse(resp *http.Response) (TableClientQueryEntitiesResponse, error) { + result := TableClientQueryEntitiesResponse{RawResponse: resp} if val := resp.Header.Get("x-ms-client-request-id"); val != "" { result.ClientRequestID = &val } @@ -717,7 +678,7 @@ func (client *TableClient) queryEntitiesHandleResponse(resp *http.Response) (Tab if val := resp.Header.Get("Date"); val != "" { date, err := time.Parse(time.RFC1123, val) if err != nil { - return TableQueryEntitiesResponse{}, err + return TableClientQueryEntitiesResponse{}, err } result.Date = &date } @@ -728,43 +689,37 @@ func (client *TableClient) queryEntitiesHandleResponse(resp *http.Response) (Tab result.XMSContinuationNextRowKey = &val } if err := runtime.UnmarshalAsJSON(resp, &result.TableEntityQueryResponse); err != nil { - return TableQueryEntitiesResponse{}, err + return TableClientQueryEntitiesResponse{}, err } return result, nil } -// queryEntitiesHandleError handles the QueryEntities error response. -func (client *TableClient) queryEntitiesHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := TableServiceError{raw: string(body)} - if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // QueryEntityWithPartitionAndRowKey - Queries a single entity in a table. -// If the operation fails it returns the *TableServiceError error type. -func (client *TableClient) QueryEntityWithPartitionAndRowKey(ctx context.Context, dataServiceVersion Enum1, table string, partitionKey string, rowKey string, tableQueryEntityWithPartitionAndRowKeyOptions *TableQueryEntityWithPartitionAndRowKeyOptions, queryOptions *QueryOptions) (TableQueryEntityWithPartitionAndRowKeyResponse, error) { - req, err := client.queryEntityWithPartitionAndRowKeyCreateRequest(ctx, dataServiceVersion, table, partitionKey, rowKey, tableQueryEntityWithPartitionAndRowKeyOptions, queryOptions) +// If the operation fails it returns an *azcore.ResponseError type. +// dataServiceVersion - Specifies the data service version. +// table - The name of the table. +// partitionKey - The partition key of the entity. +// rowKey - The row key of the entity. +// TableClientQueryEntityWithPartitionAndRowKeyOptions - TableClientQueryEntityWithPartitionAndRowKeyOptions contains the +// optional parameters for the TableClient.QueryEntityWithPartitionAndRowKey method. +// QueryOptions - QueryOptions contains a group of parameters for the TableClient.Query method. +func (client *TableClient) QueryEntityWithPartitionAndRowKey(ctx context.Context, dataServiceVersion Enum1, table string, partitionKey string, rowKey string, tableClientQueryEntityWithPartitionAndRowKeyOptions *TableClientQueryEntityWithPartitionAndRowKeyOptions, queryOptions *QueryOptions) (TableClientQueryEntityWithPartitionAndRowKeyResponse, error) { + req, err := client.queryEntityWithPartitionAndRowKeyCreateRequest(ctx, dataServiceVersion, table, partitionKey, rowKey, tableClientQueryEntityWithPartitionAndRowKeyOptions, queryOptions) if err != nil { - return TableQueryEntityWithPartitionAndRowKeyResponse{}, err + return TableClientQueryEntityWithPartitionAndRowKeyResponse{}, err } - resp, err := client.con.Pipeline().Do(req) + resp, err := client.pl.Do(req) if err != nil { - return TableQueryEntityWithPartitionAndRowKeyResponse{}, err + return TableClientQueryEntityWithPartitionAndRowKeyResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return TableQueryEntityWithPartitionAndRowKeyResponse{}, client.queryEntityWithPartitionAndRowKeyHandleError(resp) + return TableClientQueryEntityWithPartitionAndRowKeyResponse{}, runtime.NewResponseError(resp) } return client.queryEntityWithPartitionAndRowKeyHandleResponse(resp) } // queryEntityWithPartitionAndRowKeyCreateRequest creates the QueryEntityWithPartitionAndRowKey request. -func (client *TableClient) queryEntityWithPartitionAndRowKeyCreateRequest(ctx context.Context, dataServiceVersion Enum1, table string, partitionKey string, rowKey string, tableQueryEntityWithPartitionAndRowKeyOptions *TableQueryEntityWithPartitionAndRowKeyOptions, queryOptions *QueryOptions) (*policy.Request, error) { +func (client *TableClient) queryEntityWithPartitionAndRowKeyCreateRequest(ctx context.Context, dataServiceVersion Enum1, table string, partitionKey string, rowKey string, tableClientQueryEntityWithPartitionAndRowKeyOptions *TableClientQueryEntityWithPartitionAndRowKeyOptions, queryOptions *QueryOptions) (*policy.Request, error) { urlPath := "/{table}(PartitionKey='{partitionKey}',RowKey='{rowKey}')" if table == "" { return nil, errors.New("parameter table cannot be empty") @@ -778,13 +733,13 @@ func (client *TableClient) queryEntityWithPartitionAndRowKeyCreateRequest(ctx co return nil, errors.New("parameter rowKey cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{rowKey}", url.PathEscape(rowKey)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.con.Endpoint(), urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.endpoint, urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - if tableQueryEntityWithPartitionAndRowKeyOptions != nil && tableQueryEntityWithPartitionAndRowKeyOptions.Timeout != nil { - reqQP.Set("timeout", strconv.FormatInt(int64(*tableQueryEntityWithPartitionAndRowKeyOptions.Timeout), 10)) + if tableClientQueryEntityWithPartitionAndRowKeyOptions != nil && tableClientQueryEntityWithPartitionAndRowKeyOptions.Timeout != nil { + reqQP.Set("timeout", strconv.FormatInt(int64(*tableClientQueryEntityWithPartitionAndRowKeyOptions.Timeout), 10)) } if queryOptions != nil && queryOptions.Format != nil { reqQP.Set("$format", string(*queryOptions.Format)) @@ -797,8 +752,8 @@ func (client *TableClient) queryEntityWithPartitionAndRowKeyCreateRequest(ctx co } req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header.Set("x-ms-version", string(client.version)) - if tableQueryEntityWithPartitionAndRowKeyOptions != nil && tableQueryEntityWithPartitionAndRowKeyOptions.RequestID != nil { - req.Raw().Header.Set("x-ms-client-request-id", *tableQueryEntityWithPartitionAndRowKeyOptions.RequestID) + if tableClientQueryEntityWithPartitionAndRowKeyOptions != nil && tableClientQueryEntityWithPartitionAndRowKeyOptions.RequestID != nil { + req.Raw().Header.Set("x-ms-client-request-id", *tableClientQueryEntityWithPartitionAndRowKeyOptions.RequestID) } req.Raw().Header.Set("DataServiceVersion", string(dataServiceVersion)) req.Raw().Header.Set("Accept", "application/json;odata=minimalmetadata") @@ -806,8 +761,8 @@ func (client *TableClient) queryEntityWithPartitionAndRowKeyCreateRequest(ctx co } // queryEntityWithPartitionAndRowKeyHandleResponse handles the QueryEntityWithPartitionAndRowKey response. -func (client *TableClient) queryEntityWithPartitionAndRowKeyHandleResponse(resp *http.Response) (TableQueryEntityWithPartitionAndRowKeyResponse, error) { - result := TableQueryEntityWithPartitionAndRowKeyResponse{RawResponse: resp} +func (client *TableClient) queryEntityWithPartitionAndRowKeyHandleResponse(resp *http.Response) (TableClientQueryEntityWithPartitionAndRowKeyResponse, error) { + result := TableClientQueryEntityWithPartitionAndRowKeyResponse{RawResponse: resp} if val := resp.Header.Get("x-ms-client-request-id"); val != "" { result.ClientRequestID = &val } @@ -820,7 +775,7 @@ func (client *TableClient) queryEntityWithPartitionAndRowKeyHandleResponse(resp if val := resp.Header.Get("Date"); val != "" { date, err := time.Parse(time.RFC1123, val) if err != nil { - return TableQueryEntityWithPartitionAndRowKeyResponse{}, err + return TableClientQueryEntityWithPartitionAndRowKeyResponse{}, err } result.Date = &date } @@ -834,49 +789,39 @@ func (client *TableClient) queryEntityWithPartitionAndRowKeyHandleResponse(resp result.XMSContinuationNextRowKey = &val } if err := runtime.UnmarshalAsJSON(resp, &result.Value); err != nil { - return TableQueryEntityWithPartitionAndRowKeyResponse{}, err + return TableClientQueryEntityWithPartitionAndRowKeyResponse{}, err } return result, nil } -// queryEntityWithPartitionAndRowKeyHandleError handles the QueryEntityWithPartitionAndRowKey error response. -func (client *TableClient) queryEntityWithPartitionAndRowKeyHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := TableServiceError{raw: string(body)} - if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // SetAccessPolicy - Sets stored access policies for the table that may be used with Shared Access Signatures. -// If the operation fails it returns the *TableServiceError error type. -func (client *TableClient) SetAccessPolicy(ctx context.Context, table string, comp Enum4, options *TableSetAccessPolicyOptions) (TableSetAccessPolicyResponse, error) { +// If the operation fails it returns an *azcore.ResponseError type. +// table - The name of the table. +// comp - Required query string to handle stored access policies for the table that may be used with Shared Access Signatures. +// options - TableClientSetAccessPolicyOptions contains the optional parameters for the TableClient.SetAccessPolicy method. +func (client *TableClient) SetAccessPolicy(ctx context.Context, table string, comp Enum4, options *TableClientSetAccessPolicyOptions) (TableClientSetAccessPolicyResponse, error) { req, err := client.setAccessPolicyCreateRequest(ctx, table, comp, options) if err != nil { - return TableSetAccessPolicyResponse{}, err + return TableClientSetAccessPolicyResponse{}, err } - resp, err := client.con.Pipeline().Do(req) + resp, err := client.pl.Do(req) if err != nil { - return TableSetAccessPolicyResponse{}, err + return TableClientSetAccessPolicyResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusNoContent) { - return TableSetAccessPolicyResponse{}, client.setAccessPolicyHandleError(resp) + return TableClientSetAccessPolicyResponse{}, runtime.NewResponseError(resp) } return client.setAccessPolicyHandleResponse(resp) } // setAccessPolicyCreateRequest creates the SetAccessPolicy request. -func (client *TableClient) setAccessPolicyCreateRequest(ctx context.Context, table string, comp Enum4, options *TableSetAccessPolicyOptions) (*policy.Request, error) { +func (client *TableClient) setAccessPolicyCreateRequest(ctx context.Context, table string, comp Enum4, options *TableClientSetAccessPolicyOptions) (*policy.Request, error) { urlPath := "/{table}" if table == "" { return nil, errors.New("parameter table cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{table}", url.PathEscape(table)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.con.Endpoint(), urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.endpoint, urlPath)) if err != nil { return nil, err } @@ -902,8 +847,8 @@ func (client *TableClient) setAccessPolicyCreateRequest(ctx context.Context, tab } // setAccessPolicyHandleResponse handles the SetAccessPolicy response. -func (client *TableClient) setAccessPolicyHandleResponse(resp *http.Response) (TableSetAccessPolicyResponse, error) { - result := TableSetAccessPolicyResponse{RawResponse: resp} +func (client *TableClient) setAccessPolicyHandleResponse(resp *http.Response) (TableClientSetAccessPolicyResponse, error) { + result := TableClientSetAccessPolicyResponse{RawResponse: resp} if val := resp.Header.Get("x-ms-client-request-id"); val != "" { result.ClientRequestID = &val } @@ -916,45 +861,39 @@ func (client *TableClient) setAccessPolicyHandleResponse(resp *http.Response) (T if val := resp.Header.Get("Date"); val != "" { date, err := time.Parse(time.RFC1123, val) if err != nil { - return TableSetAccessPolicyResponse{}, err + return TableClientSetAccessPolicyResponse{}, err } result.Date = &date } return result, nil } -// setAccessPolicyHandleError handles the SetAccessPolicy error response. -func (client *TableClient) setAccessPolicyHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := TableServiceError{raw: string(body)} - if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // UpdateEntity - Update entity in a table. -// If the operation fails it returns the *TableServiceError error type. -func (client *TableClient) UpdateEntity(ctx context.Context, dataServiceVersion Enum1, table string, partitionKey string, rowKey string, tableUpdateEntityOptions *TableUpdateEntityOptions, queryOptions *QueryOptions) (TableUpdateEntityResponse, error) { - req, err := client.UpdateEntityCreateRequest(ctx, dataServiceVersion, table, partitionKey, rowKey, tableUpdateEntityOptions, queryOptions) +// If the operation fails it returns an *azcore.ResponseError type. +// dataServiceVersion - Specifies the data service version. +// table - The name of the table. +// partitionKey - The partition key of the entity. +// rowKey - The row key of the entity. +// TableClientUpdateEntityOptions - TableClientUpdateEntityOptions contains the optional parameters for the TableClient.UpdateEntity +// method. +// QueryOptions - QueryOptions contains a group of parameters for the TableClient.Query method. +func (client *TableClient) UpdateEntity(ctx context.Context, dataServiceVersion Enum1, table string, partitionKey string, rowKey string, tableClientUpdateEntityOptions *TableClientUpdateEntityOptions, queryOptions *QueryOptions) (TableClientUpdateEntityResponse, error) { + req, err := client.UpdateEntityCreateRequest(ctx, dataServiceVersion, table, partitionKey, rowKey, tableClientUpdateEntityOptions, queryOptions) if err != nil { - return TableUpdateEntityResponse{}, err + return TableClientUpdateEntityResponse{}, err } - resp, err := client.con.Pipeline().Do(req) + resp, err := client.pl.Do(req) if err != nil { - return TableUpdateEntityResponse{}, err + return TableClientUpdateEntityResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusNoContent) { - return TableUpdateEntityResponse{}, client.updateEntityHandleError(resp) + return TableClientUpdateEntityResponse{}, runtime.NewResponseError(resp) } return client.updateEntityHandleResponse(resp) } -// UpdateEntityCreateRequest creates the UpdateEntity request. -func (client *TableClient) UpdateEntityCreateRequest(ctx context.Context, dataServiceVersion Enum1, table string, partitionKey string, rowKey string, tableUpdateEntityOptions *TableUpdateEntityOptions, queryOptions *QueryOptions) (*policy.Request, error) { +// updateEntityCreateRequest creates the UpdateEntity request. +func (client *TableClient) UpdateEntityCreateRequest(ctx context.Context, dataServiceVersion Enum1, table string, partitionKey string, rowKey string, tableClientUpdateEntityOptions *TableClientUpdateEntityOptions, queryOptions *QueryOptions) (*policy.Request, error) { urlPath := "/{table}(PartitionKey='{partitionKey}',RowKey='{rowKey}')" if table == "" { return nil, errors.New("parameter table cannot be empty") @@ -968,36 +907,36 @@ func (client *TableClient) UpdateEntityCreateRequest(ctx context.Context, dataSe return nil, errors.New("parameter rowKey cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{rowKey}", url.PathEscape(rowKey)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.con.Endpoint(), urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.endpoint, urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - if tableUpdateEntityOptions != nil && tableUpdateEntityOptions.Timeout != nil { - reqQP.Set("timeout", strconv.FormatInt(int64(*tableUpdateEntityOptions.Timeout), 10)) + if tableClientUpdateEntityOptions != nil && tableClientUpdateEntityOptions.Timeout != nil { + reqQP.Set("timeout", strconv.FormatInt(int64(*tableClientUpdateEntityOptions.Timeout), 10)) } if queryOptions != nil && queryOptions.Format != nil { reqQP.Set("$format", string(*queryOptions.Format)) } req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header.Set("x-ms-version", string(client.version)) - if tableUpdateEntityOptions != nil && tableUpdateEntityOptions.RequestID != nil { - req.Raw().Header.Set("x-ms-client-request-id", *tableUpdateEntityOptions.RequestID) + if tableClientUpdateEntityOptions != nil && tableClientUpdateEntityOptions.RequestID != nil { + req.Raw().Header.Set("x-ms-client-request-id", *tableClientUpdateEntityOptions.RequestID) } req.Raw().Header.Set("DataServiceVersion", string(dataServiceVersion)) - if tableUpdateEntityOptions != nil && tableUpdateEntityOptions.IfMatch != nil { - req.Raw().Header.Set("If-Match", *tableUpdateEntityOptions.IfMatch) + if tableClientUpdateEntityOptions != nil && tableClientUpdateEntityOptions.IfMatch != nil { + req.Raw().Header.Set("If-Match", *tableClientUpdateEntityOptions.IfMatch) } req.Raw().Header.Set("Accept", "application/json") - if tableUpdateEntityOptions != nil && tableUpdateEntityOptions.TableEntityProperties != nil { - return req, runtime.MarshalAsJSON(req, tableUpdateEntityOptions.TableEntityProperties) + if tableClientUpdateEntityOptions != nil && tableClientUpdateEntityOptions.TableEntityProperties != nil { + return req, runtime.MarshalAsJSON(req, tableClientUpdateEntityOptions.TableEntityProperties) } return req, nil } // updateEntityHandleResponse handles the UpdateEntity response. -func (client *TableClient) updateEntityHandleResponse(resp *http.Response) (TableUpdateEntityResponse, error) { - result := TableUpdateEntityResponse{RawResponse: resp} +func (client *TableClient) updateEntityHandleResponse(resp *http.Response) (TableClientUpdateEntityResponse, error) { + result := TableClientUpdateEntityResponse{RawResponse: resp} if val := resp.Header.Get("x-ms-client-request-id"); val != "" { result.ClientRequestID = &val } @@ -1010,7 +949,7 @@ func (client *TableClient) updateEntityHandleResponse(resp *http.Response) (Tabl if val := resp.Header.Get("Date"); val != "" { date, err := time.Parse(time.RFC1123, val) if err != nil { - return TableUpdateEntityResponse{}, err + return TableClientUpdateEntityResponse{}, err } result.Date = &date } @@ -1019,16 +958,3 @@ func (client *TableClient) updateEntityHandleResponse(resp *http.Response) (Tabl } return result, nil } - -// updateEntityHandleError handles the UpdateEntity error response. -func (client *TableClient) updateEntityHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := TableServiceError{raw: string(body)} - if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} diff --git a/sdk/data/aztables/proxy_test.go b/sdk/data/aztables/proxy_test.go index 12664686d464..553d3e5a7987 100644 --- a/sdk/data/aztables/proxy_test.go +++ b/sdk/data/aztables/proxy_test.go @@ -42,7 +42,7 @@ func TestMain(m *testing.M) { // 3. Reset // TODO: Add after sanitizer PR if recording.GetRecordMode() != "live" { - err := recording.ResetSanitizers(nil) + err := recording.ResetProxy(nil) if err != nil { panic(err) } diff --git a/sdk/data/aztables/service_client.go b/sdk/data/aztables/service_client.go index ffdf83dcfeec..dde36f23d437 100644 --- a/sdk/data/aztables/service_client.go +++ b/sdk/data/aztables/service_client.go @@ -30,8 +30,8 @@ func NewServiceClient(serviceURL string, cred azcore.TokenCredential, options *C conOptions.PerRetryPolicies = append(conOptions.PerRetryPolicies, runtime.NewBearerTokenPolicy(cred, []string{"https://storage.azure.com/.default"}, nil)) con := generated.NewConnection(serviceURL, conOptions) return &ServiceClient{ - client: generated.NewTableClient(con, generated.Enum0TwoThousandNineteen0202), - service: generated.NewServiceClient(con, generated.Enum0TwoThousandNineteen0202), + client: generated.NewTableClient(serviceURL, generated.Enum0TwoThousandNineteen0202, conOptions), + service: generated.NewServiceClient(serviceURL, generated.Enum0TwoThousandNineteen0202, conOptions), con: con, }, nil } @@ -42,8 +42,8 @@ func NewServiceClientWithNoCredential(serviceURL string, options *ClientOptions) conOptions := getConnectionOptions(serviceURL, options) con := generated.NewConnection(serviceURL, conOptions) return &ServiceClient{ - client: generated.NewTableClient(con, generated.Enum0TwoThousandNineteen0202), - service: generated.NewServiceClient(con, generated.Enum0TwoThousandNineteen0202), + client: generated.NewTableClient(serviceURL, generated.Enum0TwoThousandNineteen0202, conOptions), + service: generated.NewServiceClient(serviceURL, generated.Enum0TwoThousandNineteen0202, conOptions), con: con, }, nil } @@ -55,8 +55,8 @@ func NewServiceClientWithSharedKey(serviceURL string, cred *SharedKeyCredential, con := generated.NewConnection(serviceURL, conOptions) return &ServiceClient{ - client: generated.NewTableClient(con, generated.Enum0TwoThousandNineteen0202), - service: generated.NewServiceClient(con, generated.Enum0TwoThousandNineteen0202), + client: generated.NewTableClient(serviceURL, generated.Enum0TwoThousandNineteen0202, conOptions), + service: generated.NewServiceClient(serviceURL, generated.Enum0TwoThousandNineteen0202, conOptions), cred: cred, con: con, }, nil @@ -88,8 +88,8 @@ func (t *ServiceClient) NewClient(tableName string) *Client { type CreateTableOptions struct { } -func (c *CreateTableOptions) toGenerated() *generated.TableCreateOptions { - return &generated.TableCreateOptions{} +func (c *CreateTableOptions) toGenerated() *generated.TableClientCreateOptions { + return &generated.TableClientCreateOptions{} } // Create creates a table with the specified name. @@ -105,8 +105,8 @@ func (t *ServiceClient) CreateTable(ctx context.Context, name string, options *C type DeleteTableOptions struct { } -func (c *DeleteTableOptions) toGenerated() *generated.TableDeleteOptions { - return &generated.TableDeleteOptions{} +func (c *DeleteTableOptions) toGenerated() *generated.TableClientDeleteOptions { + return &generated.TableClientDeleteOptions{} } // Response object from a ServiceClient.DeleteTable or Client.Delete operation @@ -114,7 +114,7 @@ type DeleteTableResponse struct { RawResponse *http.Response } -func deleteTableResponseFromGen(g *generated.TableDeleteResponse) DeleteTableResponse { +func deleteTableResponseFromGen(g *generated.TableClientDeleteResponse) DeleteTableResponse { if g == nil { return DeleteTableResponse{} } @@ -187,7 +187,7 @@ type ListTablesPage struct { Tables []*ResponseProperties `json:"value,omitempty"` } -func fromGeneratedTableQueryResponseEnvelope(g *generated.TableQueryResponseEnvelope) *ListTablesPage { +func fromGeneratedTableQueryResponseEnvelope(g *generated.TableClientQueryResponse) *ListTablesPage { if g == nil { return nil } @@ -237,8 +237,8 @@ func fromGeneratedTableResponseProperties(g *generated.TableResponseProperties) type tableQueryResponsePager struct { client *generated.TableClient - current *generated.TableQueryResponseEnvelope - tableQueryOptions *generated.TableQueryOptions + current *generated.TableClientQueryResponse + tableQueryOptions *generated.TableClientQueryOptions listOptions *ListTablesOptions err error } @@ -250,7 +250,7 @@ func (p *tableQueryResponsePager) NextPage(ctx context.Context) bool { if p.err != nil || (p.current != nil && p.current.XMSContinuationNextTableName == nil) { return false } - var resp generated.TableQueryResponseEnvelope + var resp generated.TableClientQueryResponse resp, p.err = p.client.Query(ctx, generated.Enum1Three0, p.tableQueryOptions, p.listOptions.toQueryOptions()) p.current = &resp p.tableQueryOptions.NextTableName = resp.XMSContinuationNextTableName @@ -281,7 +281,7 @@ func (t *ServiceClient) ListTables(listOptions *ListTablesOptions) ListTablesPag return &tableQueryResponsePager{ client: t.client, listOptions: listOptions, - tableQueryOptions: new(generated.TableQueryOptions), + tableQueryOptions: new(generated.TableClientQueryOptions), } } @@ -294,15 +294,15 @@ type GetStatisticsResponse struct { GeoReplication *GeoReplication `xml:"GeoReplication"` } -func getStatisticsResponseFromGenerated(g *generated.ServiceGetStatisticsResponse) GetStatisticsResponse { +func getStatisticsResponseFromGenerated(g *generated.ServiceClientGetStatisticsResponse) GetStatisticsResponse { return GetStatisticsResponse{ RawResponse: g.RawResponse, GeoReplication: fromGeneratedGeoReplication(g.GeoReplication), } } -func (g *GetStatisticsOptions) toGenerated() *generated.ServiceGetStatisticsOptions { - return &generated.ServiceGetStatisticsOptions{} +func (g *GetStatisticsOptions) toGenerated() *generated.ServiceClientGetStatisticsOptions { + return &generated.ServiceClientGetStatisticsOptions{} } // GetStatistics retrieves all the statistics for an account with Geo-redundancy established. @@ -317,8 +317,8 @@ func (t *ServiceClient) GetStatistics(ctx context.Context, options *GetStatistic type GetPropertiesOptions struct { } -func (g *GetPropertiesOptions) toGenerated() *generated.ServiceGetPropertiesOptions { - return &generated.ServiceGetPropertiesOptions{} +func (g *GetPropertiesOptions) toGenerated() *generated.ServiceClientGetPropertiesOptions { + return &generated.ServiceClientGetPropertiesOptions{} } type GetPropertiesResponse struct { @@ -336,7 +336,7 @@ type GetPropertiesResponse struct { MinuteMetrics *Metrics `xml:"MinuteMetrics"` } -func getPropertiesResponseFromGenerated(g *generated.ServiceGetPropertiesResponse) GetPropertiesResponse { +func getPropertiesResponseFromGenerated(g *generated.ServiceClientGetPropertiesResponse) GetPropertiesResponse { var cors []*CorsRule for _, c := range g.Cors { cors = append(cors, fromGeneratedCors(c)) @@ -361,15 +361,15 @@ func (t *ServiceClient) GetProperties(ctx context.Context, options *GetPropertie type SetPropertiesOptions struct{} -func (s *SetPropertiesOptions) toGenerated() *generated.ServiceSetPropertiesOptions { - return &generated.ServiceSetPropertiesOptions{} +func (s *SetPropertiesOptions) toGenerated() *generated.ServiceClientSetPropertiesOptions { + return &generated.ServiceClientSetPropertiesOptions{} } type SetPropertiesResponse struct { RawResponse *http.Response } -func setPropertiesResponseFromGenerated(g *generated.ServiceSetPropertiesResponse) SetPropertiesResponse { +func setPropertiesResponseFromGenerated(g *generated.ServiceClientSetPropertiesResponse) SetPropertiesResponse { return SetPropertiesResponse{ RawResponse: g.RawResponse, } diff --git a/sdk/data/aztables/transactional_batch.go b/sdk/data/aztables/transactional_batch.go index dd5eb547b74e..eda531968249 100644 --- a/sdk/data/aztables/transactional_batch.go +++ b/sdk/data/aztables/transactional_batch.go @@ -165,7 +165,7 @@ func (t *Client) submitTransactionInternal(ctx context.Context, transactionActio } if !runtime.HasStatusCode(resp, http.StatusAccepted, http.StatusNoContent) { - return TransactionResponse{}, runtime.NewResponseError(err, resp) + return TransactionResponse{}, runtime.NewResponseError(resp) } return *transactionResponse, nil } @@ -223,7 +223,7 @@ func buildTransactionResponse(req *policy.Request, resp *http.Response, itemCoun retError := newTableTransactionError(errorBody, resp) ret := retError.(*transactionError) ret.statusCode = r.StatusCode - return &result, runtime.NewResponseError(retError, resp) + return &result, runtime.NewResponseError(resp) } } innerResponses[i] = *r @@ -314,7 +314,7 @@ func (t *Client) generateEntitySubset(transactionAction *TransactionAction, writ entity[partitionKey].(string), entity[rowKey].(string), ifMatch, - &generated.TableDeleteEntityOptions{}, + &generated.TableClientDeleteEntityOptions{}, qo, ) if err != nil { @@ -325,7 +325,7 @@ func (t *Client) generateEntitySubset(transactionAction *TransactionAction, writ ctx, generated.Enum1Three0, t.name, - &generated.TableInsertEntityOptions{ + &generated.TableClientInsertEntityOptions{ TableEntityProperties: entity, ResponsePreference: generated.ResponseFormatReturnNoContent.ToPtr(), }, @@ -337,7 +337,7 @@ func (t *Client) generateEntitySubset(transactionAction *TransactionAction, writ case UpdateMerge: fallthrough case InsertMerge: - opts := &generated.TableMergeEntityOptions{TableEntityProperties: entity} + opts := &generated.TableClientMergeEntityOptions{TableEntityProperties: entity} if transactionAction.IfMatch != nil { opts.IfMatch = to.StringPtr(string(*transactionAction.IfMatch)) } @@ -359,7 +359,7 @@ func (t *Client) generateEntitySubset(transactionAction *TransactionAction, writ case UpdateReplace: fallthrough case InsertReplace: - opts := &generated.TableUpdateEntityOptions{TableEntityProperties: entity} + opts := &generated.TableClientUpdateEntityOptions{TableEntityProperties: entity} if transactionAction.IfMatch != nil { opts.IfMatch = to.StringPtr(string(*transactionAction.IfMatch)) }