...

Source file src/github.com/Azure/azure-sdk-for-go/services/preview/storage/tables/2019-02-02-preview/storagetables/table.go

Documentation: github.com/Azure/azure-sdk-for-go/services/preview/storage/tables/2019-02-02-preview/storagetables

     1  package storagetables
     2  
     3  // Copyright (c) Microsoft Corporation. All rights reserved.
     4  // Licensed under the MIT License. See License.txt in the project root for license information.
     5  //
     6  // Code generated by Microsoft (R) AutoRest Code Generator.
     7  // Changes may cause incorrect behavior and will be lost if the code is regenerated.
     8  
     9  import (
    10  	"context"
    11  	"github.com/Azure/go-autorest/autorest"
    12  	"github.com/Azure/go-autorest/autorest/azure"
    13  	"github.com/Azure/go-autorest/autorest/validation"
    14  	"github.com/Azure/go-autorest/tracing"
    15  	"net/http"
    16  )
    17  
    18  // TableClient is the client for the Table methods of the Storagetables service.
    19  type TableClient struct {
    20  	BaseClient
    21  }
    22  
    23  // NewTableClient creates an instance of the TableClient client.
    24  func NewTableClient(URL string) TableClient {
    25  	return TableClient{New(URL)}
    26  }
    27  
    28  // Create creates a new table under the given account.
    29  // Parameters:
    30  // tableProperties - the Table properties.
    31  // requestID - provides a client-generated, opaque value with a 1 KB character limit that is recorded in the
    32  // analytics logs when analytics logging is enabled.
    33  // formatParameter - specifies the media type for the response.
    34  // responsePreference - specifies whether the response should include the inserted entity in the payload.
    35  // Possible values are return-no-content and return-content.
    36  func (client TableClient) Create(ctx context.Context, tableProperties TableProperties, requestID string, formatParameter OdataMetadataFormat, responsePreference ResponseFormat) (result TableResponse, err error) {
    37  	if tracing.IsEnabled() {
    38  		ctx = tracing.StartSpan(ctx, fqdn+"/TableClient.Create")
    39  		defer func() {
    40  			sc := -1
    41  			if result.Response.Response != nil {
    42  				sc = result.Response.Response.StatusCode
    43  			}
    44  			tracing.EndSpan(ctx, sc, err)
    45  		}()
    46  	}
    47  	req, err := client.CreatePreparer(ctx, tableProperties, requestID, formatParameter, responsePreference)
    48  	if err != nil {
    49  		err = autorest.NewErrorWithError(err, "storagetables.TableClient", "Create", nil, "Failure preparing request")
    50  		return
    51  	}
    52  
    53  	resp, err := client.CreateSender(req)
    54  	if err != nil {
    55  		result.Response = autorest.Response{Response: resp}
    56  		err = autorest.NewErrorWithError(err, "storagetables.TableClient", "Create", resp, "Failure sending request")
    57  		return
    58  	}
    59  
    60  	result, err = client.CreateResponder(resp)
    61  	if err != nil {
    62  		err = autorest.NewErrorWithError(err, "storagetables.TableClient", "Create", resp, "Failure responding to request")
    63  		return
    64  	}
    65  
    66  	return
    67  }
    68  
    69  // CreatePreparer prepares the Create request.
    70  func (client TableClient) CreatePreparer(ctx context.Context, tableProperties TableProperties, requestID string, formatParameter OdataMetadataFormat, responsePreference ResponseFormat) (*http.Request, error) {
    71  	urlParameters := map[string]interface{}{
    72  		"url": client.URL,
    73  	}
    74  
    75  	queryParameters := map[string]interface{}{}
    76  	if len(string(formatParameter)) > 0 {
    77  		queryParameters["$format"] = autorest.Encode("query", formatParameter)
    78  	}
    79  
    80  	preparer := autorest.CreatePreparer(
    81  		autorest.AsContentType("application/json;odata=nometadata; charset=utf-8"),
    82  		autorest.AsPost(),
    83  		autorest.WithCustomBaseURL("{url}", urlParameters),
    84  		autorest.WithPath("/Tables"),
    85  		autorest.WithJSON(tableProperties),
    86  		autorest.WithQueryParameters(queryParameters),
    87  		autorest.WithHeader("x-ms-version", "2019-02-02"),
    88  		autorest.WithHeader("DataServiceVersion", "3.0"))
    89  	if len(requestID) > 0 {
    90  		preparer = autorest.DecoratePreparer(preparer,
    91  			autorest.WithHeader("x-ms-client-request-id", autorest.String(requestID)))
    92  	}
    93  	if len(string(responsePreference)) > 0 {
    94  		preparer = autorest.DecoratePreparer(preparer,
    95  			autorest.WithHeader("Prefer", autorest.String(responsePreference)))
    96  	}
    97  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
    98  }
    99  
   100  // CreateSender sends the Create request. The method will close the
   101  // http.Response Body if it receives an error.
   102  func (client TableClient) CreateSender(req *http.Request) (*http.Response, error) {
   103  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   104  }
   105  
   106  // CreateResponder handles the response to the Create request. The method always
   107  // closes the http.Response Body.
   108  func (client TableClient) CreateResponder(resp *http.Response) (result TableResponse, err error) {
   109  	err = autorest.Respond(
   110  		resp,
   111  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusNoContent),
   112  		autorest.ByUnmarshallingJSON(&result),
   113  		autorest.ByClosing())
   114  	result.Response = autorest.Response{Response: resp}
   115  	return
   116  }
   117  
   118  // Delete operation permanently deletes the specified table.
   119  // Parameters:
   120  // table - the name of the table.
   121  // requestID - provides a client-generated, opaque value with a 1 KB character limit that is recorded in the
   122  // analytics logs when analytics logging is enabled.
   123  func (client TableClient) Delete(ctx context.Context, table string, requestID string) (result autorest.Response, err error) {
   124  	if tracing.IsEnabled() {
   125  		ctx = tracing.StartSpan(ctx, fqdn+"/TableClient.Delete")
   126  		defer func() {
   127  			sc := -1
   128  			if result.Response != nil {
   129  				sc = result.Response.StatusCode
   130  			}
   131  			tracing.EndSpan(ctx, sc, err)
   132  		}()
   133  	}
   134  	req, err := client.DeletePreparer(ctx, table, requestID)
   135  	if err != nil {
   136  		err = autorest.NewErrorWithError(err, "storagetables.TableClient", "Delete", nil, "Failure preparing request")
   137  		return
   138  	}
   139  
   140  	resp, err := client.DeleteSender(req)
   141  	if err != nil {
   142  		result.Response = resp
   143  		err = autorest.NewErrorWithError(err, "storagetables.TableClient", "Delete", resp, "Failure sending request")
   144  		return
   145  	}
   146  
   147  	result, err = client.DeleteResponder(resp)
   148  	if err != nil {
   149  		err = autorest.NewErrorWithError(err, "storagetables.TableClient", "Delete", resp, "Failure responding to request")
   150  		return
   151  	}
   152  
   153  	return
   154  }
   155  
   156  // DeletePreparer prepares the Delete request.
   157  func (client TableClient) DeletePreparer(ctx context.Context, table string, requestID string) (*http.Request, error) {
   158  	urlParameters := map[string]interface{}{
   159  		"url": client.URL,
   160  	}
   161  
   162  	pathParameters := map[string]interface{}{
   163  		"table": autorest.Encode("path", table),
   164  	}
   165  
   166  	preparer := autorest.CreatePreparer(
   167  		autorest.AsDelete(),
   168  		autorest.WithCustomBaseURL("{url}", urlParameters),
   169  		autorest.WithPathParameters("/Tables('{table}')", pathParameters),
   170  		autorest.WithHeader("x-ms-version", "2019-02-02"))
   171  	if len(requestID) > 0 {
   172  		preparer = autorest.DecoratePreparer(preparer,
   173  			autorest.WithHeader("x-ms-client-request-id", autorest.String(requestID)))
   174  	}
   175  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   176  }
   177  
   178  // DeleteSender sends the Delete request. The method will close the
   179  // http.Response Body if it receives an error.
   180  func (client TableClient) DeleteSender(req *http.Request) (*http.Response, error) {
   181  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   182  }
   183  
   184  // DeleteResponder handles the response to the Delete request. The method always
   185  // closes the http.Response Body.
   186  func (client TableClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
   187  	err = autorest.Respond(
   188  		resp,
   189  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
   190  		autorest.ByClosing())
   191  	result.Response = resp
   192  	return
   193  }
   194  
   195  // DeleteEntity deletes the specified entity in a table.
   196  // Parameters:
   197  // table - the name of the table.
   198  // partitionKey - the partition key of the entity.
   199  // rowKey - the row key of the entity.
   200  // ifMatch - match condition for an entity to be deleted. If specified and a matching entity is not found, an
   201  // error will be raised. To force an unconditional delete, set to the wildcard character (*).
   202  // timeout - the timeout parameter is expressed in seconds.
   203  // requestID - provides a client-generated, opaque value with a 1 KB character limit that is recorded in the
   204  // analytics logs when analytics logging is enabled.
   205  // formatParameter - specifies the media type for the response.
   206  func (client TableClient) DeleteEntity(ctx context.Context, table string, partitionKey string, rowKey string, ifMatch string, timeout *int32, requestID string, formatParameter OdataMetadataFormat) (result autorest.Response, err error) {
   207  	if tracing.IsEnabled() {
   208  		ctx = tracing.StartSpan(ctx, fqdn+"/TableClient.DeleteEntity")
   209  		defer func() {
   210  			sc := -1
   211  			if result.Response != nil {
   212  				sc = result.Response.StatusCode
   213  			}
   214  			tracing.EndSpan(ctx, sc, err)
   215  		}()
   216  	}
   217  	if err := validation.Validate([]validation.Validation{
   218  		{TargetValue: timeout,
   219  			Constraints: []validation.Constraint{{Target: "timeout", Name: validation.Null, Rule: false,
   220  				Chain: []validation.Constraint{{Target: "timeout", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil {
   221  		return result, validation.NewError("storagetables.TableClient", "DeleteEntity", err.Error())
   222  	}
   223  
   224  	req, err := client.DeleteEntityPreparer(ctx, table, partitionKey, rowKey, ifMatch, timeout, requestID, formatParameter)
   225  	if err != nil {
   226  		err = autorest.NewErrorWithError(err, "storagetables.TableClient", "DeleteEntity", nil, "Failure preparing request")
   227  		return
   228  	}
   229  
   230  	resp, err := client.DeleteEntitySender(req)
   231  	if err != nil {
   232  		result.Response = resp
   233  		err = autorest.NewErrorWithError(err, "storagetables.TableClient", "DeleteEntity", resp, "Failure sending request")
   234  		return
   235  	}
   236  
   237  	result, err = client.DeleteEntityResponder(resp)
   238  	if err != nil {
   239  		err = autorest.NewErrorWithError(err, "storagetables.TableClient", "DeleteEntity", resp, "Failure responding to request")
   240  		return
   241  	}
   242  
   243  	return
   244  }
   245  
   246  // DeleteEntityPreparer prepares the DeleteEntity request.
   247  func (client TableClient) DeleteEntityPreparer(ctx context.Context, table string, partitionKey string, rowKey string, ifMatch string, timeout *int32, requestID string, formatParameter OdataMetadataFormat) (*http.Request, error) {
   248  	urlParameters := map[string]interface{}{
   249  		"url": client.URL,
   250  	}
   251  
   252  	pathParameters := map[string]interface{}{
   253  		"partitionKey": autorest.Encode("path", partitionKey),
   254  		"rowKey":       autorest.Encode("path", rowKey),
   255  		"table":        autorest.Encode("path", table),
   256  	}
   257  
   258  	queryParameters := map[string]interface{}{}
   259  	if timeout != nil {
   260  		queryParameters["timeout"] = autorest.Encode("query", *timeout)
   261  	}
   262  	if len(string(formatParameter)) > 0 {
   263  		queryParameters["$format"] = autorest.Encode("query", formatParameter)
   264  	}
   265  
   266  	preparer := autorest.CreatePreparer(
   267  		autorest.AsDelete(),
   268  		autorest.WithCustomBaseURL("{url}", urlParameters),
   269  		autorest.WithPathParameters("/{table}(PartitionKey='{partitionKey}',RowKey='{rowKey}')", pathParameters),
   270  		autorest.WithQueryParameters(queryParameters),
   271  		autorest.WithHeader("x-ms-version", "2019-02-02"),
   272  		autorest.WithHeader("DataServiceVersion", "3.0"),
   273  		autorest.WithHeader("If-Match", autorest.String(ifMatch)))
   274  	if len(requestID) > 0 {
   275  		preparer = autorest.DecoratePreparer(preparer,
   276  			autorest.WithHeader("x-ms-client-request-id", autorest.String(requestID)))
   277  	}
   278  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   279  }
   280  
   281  // DeleteEntitySender sends the DeleteEntity request. The method will close the
   282  // http.Response Body if it receives an error.
   283  func (client TableClient) DeleteEntitySender(req *http.Request) (*http.Response, error) {
   284  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   285  }
   286  
   287  // DeleteEntityResponder handles the response to the DeleteEntity request. The method always
   288  // closes the http.Response Body.
   289  func (client TableClient) DeleteEntityResponder(resp *http.Response) (result autorest.Response, err error) {
   290  	err = autorest.Respond(
   291  		resp,
   292  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
   293  		autorest.ByClosing())
   294  	result.Response = resp
   295  	return
   296  }
   297  
   298  // GetAccessPolicy retrieves details about any stored access policies specified on the table that may be used with
   299  // Shared Access Signatures.
   300  // Parameters:
   301  // table - the name of the table.
   302  // timeout - the timeout parameter is expressed in seconds.
   303  // requestID - provides a client-generated, opaque value with a 1 KB character limit that is recorded in the
   304  // analytics logs when analytics logging is enabled.
   305  func (client TableClient) GetAccessPolicy(ctx context.Context, table string, timeout *int32, requestID string) (result ListSignedIdentifier, err error) {
   306  	if tracing.IsEnabled() {
   307  		ctx = tracing.StartSpan(ctx, fqdn+"/TableClient.GetAccessPolicy")
   308  		defer func() {
   309  			sc := -1
   310  			if result.Response.Response != nil {
   311  				sc = result.Response.Response.StatusCode
   312  			}
   313  			tracing.EndSpan(ctx, sc, err)
   314  		}()
   315  	}
   316  	if err := validation.Validate([]validation.Validation{
   317  		{TargetValue: timeout,
   318  			Constraints: []validation.Constraint{{Target: "timeout", Name: validation.Null, Rule: false,
   319  				Chain: []validation.Constraint{{Target: "timeout", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil {
   320  		return result, validation.NewError("storagetables.TableClient", "GetAccessPolicy", err.Error())
   321  	}
   322  
   323  	req, err := client.GetAccessPolicyPreparer(ctx, table, timeout, requestID)
   324  	if err != nil {
   325  		err = autorest.NewErrorWithError(err, "storagetables.TableClient", "GetAccessPolicy", nil, "Failure preparing request")
   326  		return
   327  	}
   328  
   329  	resp, err := client.GetAccessPolicySender(req)
   330  	if err != nil {
   331  		result.Response = autorest.Response{Response: resp}
   332  		err = autorest.NewErrorWithError(err, "storagetables.TableClient", "GetAccessPolicy", resp, "Failure sending request")
   333  		return
   334  	}
   335  
   336  	result, err = client.GetAccessPolicyResponder(resp)
   337  	if err != nil {
   338  		err = autorest.NewErrorWithError(err, "storagetables.TableClient", "GetAccessPolicy", resp, "Failure responding to request")
   339  		return
   340  	}
   341  
   342  	return
   343  }
   344  
   345  // GetAccessPolicyPreparer prepares the GetAccessPolicy request.
   346  func (client TableClient) GetAccessPolicyPreparer(ctx context.Context, table string, timeout *int32, requestID string) (*http.Request, error) {
   347  	urlParameters := map[string]interface{}{
   348  		"url": client.URL,
   349  	}
   350  
   351  	pathParameters := map[string]interface{}{
   352  		"table": autorest.Encode("path", table),
   353  	}
   354  
   355  	queryParameters := map[string]interface{}{
   356  		"comp": autorest.Encode("query", "acl"),
   357  	}
   358  	if timeout != nil {
   359  		queryParameters["timeout"] = autorest.Encode("query", *timeout)
   360  	}
   361  
   362  	preparer := autorest.CreatePreparer(
   363  		autorest.AsGet(),
   364  		autorest.WithCustomBaseURL("{url}", urlParameters),
   365  		autorest.WithPathParameters("/{table}", pathParameters),
   366  		autorest.WithQueryParameters(queryParameters),
   367  		autorest.WithHeader("x-ms-version", "2019-02-02"))
   368  	if len(requestID) > 0 {
   369  		preparer = autorest.DecoratePreparer(preparer,
   370  			autorest.WithHeader("x-ms-client-request-id", autorest.String(requestID)))
   371  	}
   372  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   373  }
   374  
   375  // GetAccessPolicySender sends the GetAccessPolicy request. The method will close the
   376  // http.Response Body if it receives an error.
   377  func (client TableClient) GetAccessPolicySender(req *http.Request) (*http.Response, error) {
   378  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   379  }
   380  
   381  // GetAccessPolicyResponder handles the response to the GetAccessPolicy request. The method always
   382  // closes the http.Response Body.
   383  func (client TableClient) GetAccessPolicyResponder(resp *http.Response) (result ListSignedIdentifier, err error) {
   384  	err = autorest.Respond(
   385  		resp,
   386  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   387  		autorest.ByUnmarshallingJSON(&result.Value),
   388  		autorest.ByClosing())
   389  	result.Response = autorest.Response{Response: resp}
   390  	return
   391  }
   392  
   393  // InsertEntity insert entity in a table.
   394  // Parameters:
   395  // table - the name of the table.
   396  // timeout - the timeout parameter is expressed in seconds.
   397  // requestID - provides a client-generated, opaque value with a 1 KB character limit that is recorded in the
   398  // analytics logs when analytics logging is enabled.
   399  // formatParameter - specifies the media type for the response.
   400  // tableEntityProperties - the properties for the table entity.
   401  // responsePreference - specifies whether the response should include the inserted entity in the payload.
   402  // Possible values are return-no-content and return-content.
   403  func (client TableClient) InsertEntity(ctx context.Context, table string, timeout *int32, requestID string, formatParameter OdataMetadataFormat, tableEntityProperties map[string]interface{}, responsePreference ResponseFormat) (result SetSetObject, err error) {
   404  	if tracing.IsEnabled() {
   405  		ctx = tracing.StartSpan(ctx, fqdn+"/TableClient.InsertEntity")
   406  		defer func() {
   407  			sc := -1
   408  			if result.Response.Response != nil {
   409  				sc = result.Response.Response.StatusCode
   410  			}
   411  			tracing.EndSpan(ctx, sc, err)
   412  		}()
   413  	}
   414  	if err := validation.Validate([]validation.Validation{
   415  		{TargetValue: timeout,
   416  			Constraints: []validation.Constraint{{Target: "timeout", Name: validation.Null, Rule: false,
   417  				Chain: []validation.Constraint{{Target: "timeout", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil {
   418  		return result, validation.NewError("storagetables.TableClient", "InsertEntity", err.Error())
   419  	}
   420  
   421  	req, err := client.InsertEntityPreparer(ctx, table, timeout, requestID, formatParameter, tableEntityProperties, responsePreference)
   422  	if err != nil {
   423  		err = autorest.NewErrorWithError(err, "storagetables.TableClient", "InsertEntity", nil, "Failure preparing request")
   424  		return
   425  	}
   426  
   427  	resp, err := client.InsertEntitySender(req)
   428  	if err != nil {
   429  		result.Response = autorest.Response{Response: resp}
   430  		err = autorest.NewErrorWithError(err, "storagetables.TableClient", "InsertEntity", resp, "Failure sending request")
   431  		return
   432  	}
   433  
   434  	result, err = client.InsertEntityResponder(resp)
   435  	if err != nil {
   436  		err = autorest.NewErrorWithError(err, "storagetables.TableClient", "InsertEntity", resp, "Failure responding to request")
   437  		return
   438  	}
   439  
   440  	return
   441  }
   442  
   443  // InsertEntityPreparer prepares the InsertEntity request.
   444  func (client TableClient) InsertEntityPreparer(ctx context.Context, table string, timeout *int32, requestID string, formatParameter OdataMetadataFormat, tableEntityProperties map[string]interface{}, responsePreference ResponseFormat) (*http.Request, error) {
   445  	urlParameters := map[string]interface{}{
   446  		"url": client.URL,
   447  	}
   448  
   449  	pathParameters := map[string]interface{}{
   450  		"table": autorest.Encode("path", table),
   451  	}
   452  
   453  	queryParameters := map[string]interface{}{}
   454  	if timeout != nil {
   455  		queryParameters["timeout"] = autorest.Encode("query", *timeout)
   456  	}
   457  	if len(string(formatParameter)) > 0 {
   458  		queryParameters["$format"] = autorest.Encode("query", formatParameter)
   459  	}
   460  
   461  	preparer := autorest.CreatePreparer(
   462  		autorest.AsContentType("application/json;odata=nometadata; charset=utf-8"),
   463  		autorest.AsPost(),
   464  		autorest.WithCustomBaseURL("{url}", urlParameters),
   465  		autorest.WithPathParameters("/{table}", pathParameters),
   466  		autorest.WithQueryParameters(queryParameters),
   467  		autorest.WithHeader("x-ms-version", "2019-02-02"),
   468  		autorest.WithHeader("DataServiceVersion", "3.0"))
   469  	if tableEntityProperties != nil && len(tableEntityProperties) > 0 {
   470  		preparer = autorest.DecoratePreparer(preparer,
   471  			autorest.WithJSON(tableEntityProperties))
   472  	}
   473  	if len(requestID) > 0 {
   474  		preparer = autorest.DecoratePreparer(preparer,
   475  			autorest.WithHeader("x-ms-client-request-id", autorest.String(requestID)))
   476  	}
   477  	if len(string(responsePreference)) > 0 {
   478  		preparer = autorest.DecoratePreparer(preparer,
   479  			autorest.WithHeader("Prefer", autorest.String(responsePreference)))
   480  	}
   481  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   482  }
   483  
   484  // InsertEntitySender sends the InsertEntity request. The method will close the
   485  // http.Response Body if it receives an error.
   486  func (client TableClient) InsertEntitySender(req *http.Request) (*http.Response, error) {
   487  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   488  }
   489  
   490  // InsertEntityResponder handles the response to the InsertEntity request. The method always
   491  // closes the http.Response Body.
   492  func (client TableClient) InsertEntityResponder(resp *http.Response) (result SetSetObject, err error) {
   493  	err = autorest.Respond(
   494  		resp,
   495  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusNoContent),
   496  		autorest.ByUnmarshallingJSON(&result.Value),
   497  		autorest.ByClosing())
   498  	result.Response = autorest.Response{Response: resp}
   499  	return
   500  }
   501  
   502  // MergeEntity merge entity in a table.
   503  // Parameters:
   504  // table - the name of the table.
   505  // partitionKey - the partition key of the entity.
   506  // rowKey - the row key of the entity.
   507  // timeout - the timeout parameter is expressed in seconds.
   508  // requestID - provides a client-generated, opaque value with a 1 KB character limit that is recorded in the
   509  // analytics logs when analytics logging is enabled.
   510  // formatParameter - specifies the media type for the response.
   511  // tableEntityProperties - the properties for the table entity.
   512  // ifMatch - match condition for an entity to be updated. If specified and a matching entity is not found, an
   513  // error will be raised. To force an unconditional update, set to the wildcard character (*). If not specified,
   514  // an insert will be performed when no existing entity is found to update and a merge will be performed if an
   515  // existing entity is found.
   516  func (client TableClient) MergeEntity(ctx context.Context, table string, partitionKey string, rowKey string, timeout *int32, requestID string, formatParameter OdataMetadataFormat, tableEntityProperties map[string]interface{}, ifMatch string) (result autorest.Response, err error) {
   517  	if tracing.IsEnabled() {
   518  		ctx = tracing.StartSpan(ctx, fqdn+"/TableClient.MergeEntity")
   519  		defer func() {
   520  			sc := -1
   521  			if result.Response != nil {
   522  				sc = result.Response.StatusCode
   523  			}
   524  			tracing.EndSpan(ctx, sc, err)
   525  		}()
   526  	}
   527  	if err := validation.Validate([]validation.Validation{
   528  		{TargetValue: timeout,
   529  			Constraints: []validation.Constraint{{Target: "timeout", Name: validation.Null, Rule: false,
   530  				Chain: []validation.Constraint{{Target: "timeout", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil {
   531  		return result, validation.NewError("storagetables.TableClient", "MergeEntity", err.Error())
   532  	}
   533  
   534  	req, err := client.MergeEntityPreparer(ctx, table, partitionKey, rowKey, timeout, requestID, formatParameter, tableEntityProperties, ifMatch)
   535  	if err != nil {
   536  		err = autorest.NewErrorWithError(err, "storagetables.TableClient", "MergeEntity", nil, "Failure preparing request")
   537  		return
   538  	}
   539  
   540  	resp, err := client.MergeEntitySender(req)
   541  	if err != nil {
   542  		result.Response = resp
   543  		err = autorest.NewErrorWithError(err, "storagetables.TableClient", "MergeEntity", resp, "Failure sending request")
   544  		return
   545  	}
   546  
   547  	result, err = client.MergeEntityResponder(resp)
   548  	if err != nil {
   549  		err = autorest.NewErrorWithError(err, "storagetables.TableClient", "MergeEntity", resp, "Failure responding to request")
   550  		return
   551  	}
   552  
   553  	return
   554  }
   555  
   556  // MergeEntityPreparer prepares the MergeEntity request.
   557  func (client TableClient) MergeEntityPreparer(ctx context.Context, table string, partitionKey string, rowKey string, timeout *int32, requestID string, formatParameter OdataMetadataFormat, tableEntityProperties map[string]interface{}, ifMatch string) (*http.Request, error) {
   558  	urlParameters := map[string]interface{}{
   559  		"url": client.URL,
   560  	}
   561  
   562  	pathParameters := map[string]interface{}{
   563  		"partitionKey": autorest.Encode("path", partitionKey),
   564  		"rowKey":       autorest.Encode("path", rowKey),
   565  		"table":        autorest.Encode("path", table),
   566  	}
   567  
   568  	queryParameters := map[string]interface{}{}
   569  	if timeout != nil {
   570  		queryParameters["timeout"] = autorest.Encode("query", *timeout)
   571  	}
   572  	if len(string(formatParameter)) > 0 {
   573  		queryParameters["$format"] = autorest.Encode("query", formatParameter)
   574  	}
   575  
   576  	preparer := autorest.CreatePreparer(
   577  		autorest.AsContentType("application/json; charset=utf-8"),
   578  		autorest.AsPatch(),
   579  		autorest.WithCustomBaseURL("{url}", urlParameters),
   580  		autorest.WithPathParameters("/{table}(PartitionKey='{partitionKey}',RowKey='{rowKey}')", pathParameters),
   581  		autorest.WithQueryParameters(queryParameters),
   582  		autorest.WithHeader("x-ms-version", "2019-02-02"),
   583  		autorest.WithHeader("DataServiceVersion", "3.0"))
   584  	if tableEntityProperties != nil && len(tableEntityProperties) > 0 {
   585  		preparer = autorest.DecoratePreparer(preparer,
   586  			autorest.WithJSON(tableEntityProperties))
   587  	}
   588  	if len(requestID) > 0 {
   589  		preparer = autorest.DecoratePreparer(preparer,
   590  			autorest.WithHeader("x-ms-client-request-id", autorest.String(requestID)))
   591  	}
   592  	if len(ifMatch) > 0 {
   593  		preparer = autorest.DecoratePreparer(preparer,
   594  			autorest.WithHeader("If-Match", autorest.String(ifMatch)))
   595  	}
   596  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   597  }
   598  
   599  // MergeEntitySender sends the MergeEntity request. The method will close the
   600  // http.Response Body if it receives an error.
   601  func (client TableClient) MergeEntitySender(req *http.Request) (*http.Response, error) {
   602  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   603  }
   604  
   605  // MergeEntityResponder handles the response to the MergeEntity request. The method always
   606  // closes the http.Response Body.
   607  func (client TableClient) MergeEntityResponder(resp *http.Response) (result autorest.Response, err error) {
   608  	err = autorest.Respond(
   609  		resp,
   610  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
   611  		autorest.ByClosing())
   612  	result.Response = resp
   613  	return
   614  }
   615  
   616  // Query queries tables under the given account.
   617  // Parameters:
   618  // requestID - provides a client-generated, opaque value with a 1 KB character limit that is recorded in the
   619  // analytics logs when analytics logging is enabled.
   620  // formatParameter - specifies the media type for the response.
   621  // top - maximum number of records to return.
   622  // selectParameter - select expression using OData notation. Limits the columns on each record to just those
   623  // requested, e.g. "$select=PolicyAssignmentId, ResourceId".
   624  // filter - oData filter expression.
   625  // nextTableName - a table query continuation token from a previous call.
   626  func (client TableClient) Query(ctx context.Context, requestID string, formatParameter OdataMetadataFormat, top *int32, selectParameter string, filter string, nextTableName string) (result TableQueryResponse, err error) {
   627  	if tracing.IsEnabled() {
   628  		ctx = tracing.StartSpan(ctx, fqdn+"/TableClient.Query")
   629  		defer func() {
   630  			sc := -1
   631  			if result.Response.Response != nil {
   632  				sc = result.Response.Response.StatusCode
   633  			}
   634  			tracing.EndSpan(ctx, sc, err)
   635  		}()
   636  	}
   637  	if err := validation.Validate([]validation.Validation{
   638  		{TargetValue: top,
   639  			Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false,
   640  				Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil {
   641  		return result, validation.NewError("storagetables.TableClient", "Query", err.Error())
   642  	}
   643  
   644  	req, err := client.QueryPreparer(ctx, requestID, formatParameter, top, selectParameter, filter, nextTableName)
   645  	if err != nil {
   646  		err = autorest.NewErrorWithError(err, "storagetables.TableClient", "Query", nil, "Failure preparing request")
   647  		return
   648  	}
   649  
   650  	resp, err := client.QuerySender(req)
   651  	if err != nil {
   652  		result.Response = autorest.Response{Response: resp}
   653  		err = autorest.NewErrorWithError(err, "storagetables.TableClient", "Query", resp, "Failure sending request")
   654  		return
   655  	}
   656  
   657  	result, err = client.QueryResponder(resp)
   658  	if err != nil {
   659  		err = autorest.NewErrorWithError(err, "storagetables.TableClient", "Query", resp, "Failure responding to request")
   660  		return
   661  	}
   662  
   663  	return
   664  }
   665  
   666  // QueryPreparer prepares the Query request.
   667  func (client TableClient) QueryPreparer(ctx context.Context, requestID string, formatParameter OdataMetadataFormat, top *int32, selectParameter string, filter string, nextTableName string) (*http.Request, error) {
   668  	urlParameters := map[string]interface{}{
   669  		"url": client.URL,
   670  	}
   671  
   672  	queryParameters := map[string]interface{}{}
   673  	if len(string(formatParameter)) > 0 {
   674  		queryParameters["$format"] = autorest.Encode("query", formatParameter)
   675  	}
   676  	if top != nil {
   677  		queryParameters["$top"] = autorest.Encode("query", *top)
   678  	}
   679  	if len(selectParameter) > 0 {
   680  		queryParameters["$select"] = autorest.Encode("query", selectParameter)
   681  	}
   682  	if len(filter) > 0 {
   683  		queryParameters["$filter"] = autorest.Encode("query", filter)
   684  	}
   685  	if len(nextTableName) > 0 {
   686  		queryParameters["NextTableName"] = autorest.Encode("query", nextTableName)
   687  	}
   688  
   689  	preparer := autorest.CreatePreparer(
   690  		autorest.AsGet(),
   691  		autorest.WithCustomBaseURL("{url}", urlParameters),
   692  		autorest.WithPath("/Tables"),
   693  		autorest.WithQueryParameters(queryParameters),
   694  		autorest.WithHeader("x-ms-version", "2019-02-02"),
   695  		autorest.WithHeader("DataServiceVersion", "3.0"))
   696  	if len(requestID) > 0 {
   697  		preparer = autorest.DecoratePreparer(preparer,
   698  			autorest.WithHeader("x-ms-client-request-id", autorest.String(requestID)))
   699  	}
   700  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   701  }
   702  
   703  // QuerySender sends the Query request. The method will close the
   704  // http.Response Body if it receives an error.
   705  func (client TableClient) QuerySender(req *http.Request) (*http.Response, error) {
   706  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   707  }
   708  
   709  // QueryResponder handles the response to the Query request. The method always
   710  // closes the http.Response Body.
   711  func (client TableClient) QueryResponder(resp *http.Response) (result TableQueryResponse, err error) {
   712  	err = autorest.Respond(
   713  		resp,
   714  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   715  		autorest.ByUnmarshallingJSON(&result),
   716  		autorest.ByClosing())
   717  	result.Response = autorest.Response{Response: resp}
   718  	return
   719  }
   720  
   721  // QueryEntities queries entities in a table.
   722  // Parameters:
   723  // table - the name of the table.
   724  // timeout - the timeout parameter is expressed in seconds.
   725  // requestID - provides a client-generated, opaque value with a 1 KB character limit that is recorded in the
   726  // analytics logs when analytics logging is enabled.
   727  // formatParameter - specifies the media type for the response.
   728  // top - maximum number of records to return.
   729  // selectParameter - select expression using OData notation. Limits the columns on each record to just those
   730  // requested, e.g. "$select=PolicyAssignmentId, ResourceId".
   731  // filter - oData filter expression.
   732  // nextPartitionKey - an entity query continuation token from a previous call.
   733  // nextRowKey - an entity query continuation token from a previous call.
   734  func (client TableClient) QueryEntities(ctx context.Context, table string, timeout *int32, requestID string, formatParameter OdataMetadataFormat, top *int32, selectParameter string, filter string, nextPartitionKey string, nextRowKey string) (result TableEntityQueryResponse, err error) {
   735  	if tracing.IsEnabled() {
   736  		ctx = tracing.StartSpan(ctx, fqdn+"/TableClient.QueryEntities")
   737  		defer func() {
   738  			sc := -1
   739  			if result.Response.Response != nil {
   740  				sc = result.Response.Response.StatusCode
   741  			}
   742  			tracing.EndSpan(ctx, sc, err)
   743  		}()
   744  	}
   745  	if err := validation.Validate([]validation.Validation{
   746  		{TargetValue: timeout,
   747  			Constraints: []validation.Constraint{{Target: "timeout", Name: validation.Null, Rule: false,
   748  				Chain: []validation.Constraint{{Target: "timeout", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}},
   749  		{TargetValue: top,
   750  			Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false,
   751  				Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil {
   752  		return result, validation.NewError("storagetables.TableClient", "QueryEntities", err.Error())
   753  	}
   754  
   755  	req, err := client.QueryEntitiesPreparer(ctx, table, timeout, requestID, formatParameter, top, selectParameter, filter, nextPartitionKey, nextRowKey)
   756  	if err != nil {
   757  		err = autorest.NewErrorWithError(err, "storagetables.TableClient", "QueryEntities", nil, "Failure preparing request")
   758  		return
   759  	}
   760  
   761  	resp, err := client.QueryEntitiesSender(req)
   762  	if err != nil {
   763  		result.Response = autorest.Response{Response: resp}
   764  		err = autorest.NewErrorWithError(err, "storagetables.TableClient", "QueryEntities", resp, "Failure sending request")
   765  		return
   766  	}
   767  
   768  	result, err = client.QueryEntitiesResponder(resp)
   769  	if err != nil {
   770  		err = autorest.NewErrorWithError(err, "storagetables.TableClient", "QueryEntities", resp, "Failure responding to request")
   771  		return
   772  	}
   773  
   774  	return
   775  }
   776  
   777  // QueryEntitiesPreparer prepares the QueryEntities request.
   778  func (client TableClient) QueryEntitiesPreparer(ctx context.Context, table string, timeout *int32, requestID string, formatParameter OdataMetadataFormat, top *int32, selectParameter string, filter string, nextPartitionKey string, nextRowKey string) (*http.Request, error) {
   779  	urlParameters := map[string]interface{}{
   780  		"url": client.URL,
   781  	}
   782  
   783  	pathParameters := map[string]interface{}{
   784  		"table": autorest.Encode("path", table),
   785  	}
   786  
   787  	queryParameters := map[string]interface{}{}
   788  	if timeout != nil {
   789  		queryParameters["timeout"] = autorest.Encode("query", *timeout)
   790  	}
   791  	if len(string(formatParameter)) > 0 {
   792  		queryParameters["$format"] = autorest.Encode("query", formatParameter)
   793  	}
   794  	if top != nil {
   795  		queryParameters["$top"] = autorest.Encode("query", *top)
   796  	}
   797  	if len(selectParameter) > 0 {
   798  		queryParameters["$select"] = autorest.Encode("query", selectParameter)
   799  	}
   800  	if len(filter) > 0 {
   801  		queryParameters["$filter"] = autorest.Encode("query", filter)
   802  	}
   803  	if len(nextPartitionKey) > 0 {
   804  		queryParameters["NextPartitionKey"] = autorest.Encode("query", nextPartitionKey)
   805  	}
   806  	if len(nextRowKey) > 0 {
   807  		queryParameters["NextRowKey"] = autorest.Encode("query", nextRowKey)
   808  	}
   809  
   810  	preparer := autorest.CreatePreparer(
   811  		autorest.AsGet(),
   812  		autorest.WithCustomBaseURL("{url}", urlParameters),
   813  		autorest.WithPathParameters("/{table}()", pathParameters),
   814  		autorest.WithQueryParameters(queryParameters),
   815  		autorest.WithHeader("x-ms-version", "2019-02-02"),
   816  		autorest.WithHeader("DataServiceVersion", "3.0"))
   817  	if len(requestID) > 0 {
   818  		preparer = autorest.DecoratePreparer(preparer,
   819  			autorest.WithHeader("x-ms-client-request-id", autorest.String(requestID)))
   820  	}
   821  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   822  }
   823  
   824  // QueryEntitiesSender sends the QueryEntities request. The method will close the
   825  // http.Response Body if it receives an error.
   826  func (client TableClient) QueryEntitiesSender(req *http.Request) (*http.Response, error) {
   827  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   828  }
   829  
   830  // QueryEntitiesResponder handles the response to the QueryEntities request. The method always
   831  // closes the http.Response Body.
   832  func (client TableClient) QueryEntitiesResponder(resp *http.Response) (result TableEntityQueryResponse, err error) {
   833  	err = autorest.Respond(
   834  		resp,
   835  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   836  		autorest.ByUnmarshallingJSON(&result),
   837  		autorest.ByClosing())
   838  	result.Response = autorest.Response{Response: resp}
   839  	return
   840  }
   841  
   842  // QueryEntitiesWithPartitionAndRowKey queries entities in a table.
   843  // Parameters:
   844  // table - the name of the table.
   845  // partitionKey - the partition key of the entity.
   846  // rowKey - the row key of the entity.
   847  // timeout - the timeout parameter is expressed in seconds.
   848  // requestID - provides a client-generated, opaque value with a 1 KB character limit that is recorded in the
   849  // analytics logs when analytics logging is enabled.
   850  // formatParameter - specifies the media type for the response.
   851  // selectParameter - select expression using OData notation. Limits the columns on each record to just those
   852  // requested, e.g. "$select=PolicyAssignmentId, ResourceId".
   853  // filter - oData filter expression.
   854  func (client TableClient) QueryEntitiesWithPartitionAndRowKey(ctx context.Context, table string, partitionKey string, rowKey string, timeout *int32, requestID string, formatParameter OdataMetadataFormat, selectParameter string, filter string) (result TableEntityQueryResponse, err error) {
   855  	if tracing.IsEnabled() {
   856  		ctx = tracing.StartSpan(ctx, fqdn+"/TableClient.QueryEntitiesWithPartitionAndRowKey")
   857  		defer func() {
   858  			sc := -1
   859  			if result.Response.Response != nil {
   860  				sc = result.Response.Response.StatusCode
   861  			}
   862  			tracing.EndSpan(ctx, sc, err)
   863  		}()
   864  	}
   865  	if err := validation.Validate([]validation.Validation{
   866  		{TargetValue: timeout,
   867  			Constraints: []validation.Constraint{{Target: "timeout", Name: validation.Null, Rule: false,
   868  				Chain: []validation.Constraint{{Target: "timeout", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil {
   869  		return result, validation.NewError("storagetables.TableClient", "QueryEntitiesWithPartitionAndRowKey", err.Error())
   870  	}
   871  
   872  	req, err := client.QueryEntitiesWithPartitionAndRowKeyPreparer(ctx, table, partitionKey, rowKey, timeout, requestID, formatParameter, selectParameter, filter)
   873  	if err != nil {
   874  		err = autorest.NewErrorWithError(err, "storagetables.TableClient", "QueryEntitiesWithPartitionAndRowKey", nil, "Failure preparing request")
   875  		return
   876  	}
   877  
   878  	resp, err := client.QueryEntitiesWithPartitionAndRowKeySender(req)
   879  	if err != nil {
   880  		result.Response = autorest.Response{Response: resp}
   881  		err = autorest.NewErrorWithError(err, "storagetables.TableClient", "QueryEntitiesWithPartitionAndRowKey", resp, "Failure sending request")
   882  		return
   883  	}
   884  
   885  	result, err = client.QueryEntitiesWithPartitionAndRowKeyResponder(resp)
   886  	if err != nil {
   887  		err = autorest.NewErrorWithError(err, "storagetables.TableClient", "QueryEntitiesWithPartitionAndRowKey", resp, "Failure responding to request")
   888  		return
   889  	}
   890  
   891  	return
   892  }
   893  
   894  // QueryEntitiesWithPartitionAndRowKeyPreparer prepares the QueryEntitiesWithPartitionAndRowKey request.
   895  func (client TableClient) QueryEntitiesWithPartitionAndRowKeyPreparer(ctx context.Context, table string, partitionKey string, rowKey string, timeout *int32, requestID string, formatParameter OdataMetadataFormat, selectParameter string, filter string) (*http.Request, error) {
   896  	urlParameters := map[string]interface{}{
   897  		"url": client.URL,
   898  	}
   899  
   900  	pathParameters := map[string]interface{}{
   901  		"partitionKey": autorest.Encode("path", partitionKey),
   902  		"rowKey":       autorest.Encode("path", rowKey),
   903  		"table":        autorest.Encode("path", table),
   904  	}
   905  
   906  	queryParameters := map[string]interface{}{}
   907  	if timeout != nil {
   908  		queryParameters["timeout"] = autorest.Encode("query", *timeout)
   909  	}
   910  	if len(string(formatParameter)) > 0 {
   911  		queryParameters["$format"] = autorest.Encode("query", formatParameter)
   912  	}
   913  	if len(selectParameter) > 0 {
   914  		queryParameters["$select"] = autorest.Encode("query", selectParameter)
   915  	}
   916  	if len(filter) > 0 {
   917  		queryParameters["$filter"] = autorest.Encode("query", filter)
   918  	}
   919  
   920  	preparer := autorest.CreatePreparer(
   921  		autorest.AsGet(),
   922  		autorest.WithCustomBaseURL("{url}", urlParameters),
   923  		autorest.WithPathParameters("/{table}(PartitionKey='{partitionKey}',RowKey='{rowKey}')", pathParameters),
   924  		autorest.WithQueryParameters(queryParameters),
   925  		autorest.WithHeader("x-ms-version", "2019-02-02"),
   926  		autorest.WithHeader("DataServiceVersion", "3.0"))
   927  	if len(requestID) > 0 {
   928  		preparer = autorest.DecoratePreparer(preparer,
   929  			autorest.WithHeader("x-ms-client-request-id", autorest.String(requestID)))
   930  	}
   931  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   932  }
   933  
   934  // QueryEntitiesWithPartitionAndRowKeySender sends the QueryEntitiesWithPartitionAndRowKey request. The method will close the
   935  // http.Response Body if it receives an error.
   936  func (client TableClient) QueryEntitiesWithPartitionAndRowKeySender(req *http.Request) (*http.Response, error) {
   937  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   938  }
   939  
   940  // QueryEntitiesWithPartitionAndRowKeyResponder handles the response to the QueryEntitiesWithPartitionAndRowKey request. The method always
   941  // closes the http.Response Body.
   942  func (client TableClient) QueryEntitiesWithPartitionAndRowKeyResponder(resp *http.Response) (result TableEntityQueryResponse, err error) {
   943  	err = autorest.Respond(
   944  		resp,
   945  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   946  		autorest.ByUnmarshallingJSON(&result),
   947  		autorest.ByClosing())
   948  	result.Response = autorest.Response{Response: resp}
   949  	return
   950  }
   951  
   952  // SetAccessPolicy sets stored access policies for the table that may be used with Shared Access Signatures.
   953  // Parameters:
   954  // table - the name of the table.
   955  // tableACL - the acls for the table.
   956  // timeout - the timeout parameter is expressed in seconds.
   957  // requestID - provides a client-generated, opaque value with a 1 KB character limit that is recorded in the
   958  // analytics logs when analytics logging is enabled.
   959  func (client TableClient) SetAccessPolicy(ctx context.Context, table string, tableACL []SignedIdentifier, timeout *int32, requestID string) (result autorest.Response, err error) {
   960  	if tracing.IsEnabled() {
   961  		ctx = tracing.StartSpan(ctx, fqdn+"/TableClient.SetAccessPolicy")
   962  		defer func() {
   963  			sc := -1
   964  			if result.Response != nil {
   965  				sc = result.Response.StatusCode
   966  			}
   967  			tracing.EndSpan(ctx, sc, err)
   968  		}()
   969  	}
   970  	if err := validation.Validate([]validation.Validation{
   971  		{TargetValue: timeout,
   972  			Constraints: []validation.Constraint{{Target: "timeout", Name: validation.Null, Rule: false,
   973  				Chain: []validation.Constraint{{Target: "timeout", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil {
   974  		return result, validation.NewError("storagetables.TableClient", "SetAccessPolicy", err.Error())
   975  	}
   976  
   977  	req, err := client.SetAccessPolicyPreparer(ctx, table, tableACL, timeout, requestID)
   978  	if err != nil {
   979  		err = autorest.NewErrorWithError(err, "storagetables.TableClient", "SetAccessPolicy", nil, "Failure preparing request")
   980  		return
   981  	}
   982  
   983  	resp, err := client.SetAccessPolicySender(req)
   984  	if err != nil {
   985  		result.Response = resp
   986  		err = autorest.NewErrorWithError(err, "storagetables.TableClient", "SetAccessPolicy", resp, "Failure sending request")
   987  		return
   988  	}
   989  
   990  	result, err = client.SetAccessPolicyResponder(resp)
   991  	if err != nil {
   992  		err = autorest.NewErrorWithError(err, "storagetables.TableClient", "SetAccessPolicy", resp, "Failure responding to request")
   993  		return
   994  	}
   995  
   996  	return
   997  }
   998  
   999  // SetAccessPolicyPreparer prepares the SetAccessPolicy request.
  1000  func (client TableClient) SetAccessPolicyPreparer(ctx context.Context, table string, tableACL []SignedIdentifier, timeout *int32, requestID string) (*http.Request, error) {
  1001  	urlParameters := map[string]interface{}{
  1002  		"url": client.URL,
  1003  	}
  1004  
  1005  	pathParameters := map[string]interface{}{
  1006  		"table": autorest.Encode("path", table),
  1007  	}
  1008  
  1009  	queryParameters := map[string]interface{}{
  1010  		"comp": autorest.Encode("query", "acl"),
  1011  	}
  1012  	if timeout != nil {
  1013  		queryParameters["timeout"] = autorest.Encode("query", *timeout)
  1014  	}
  1015  
  1016  	preparer := autorest.CreatePreparer(
  1017  		autorest.AsContentType("application/xml; charset=utf-8"),
  1018  		autorest.AsPut(),
  1019  		autorest.WithCustomBaseURL("{url}", urlParameters),
  1020  		autorest.WithPathParameters("/{table}", pathParameters),
  1021  		autorest.WithQueryParameters(queryParameters),
  1022  		autorest.WithHeader("x-ms-version", "2019-02-02"))
  1023  	if tableACL != nil && len(tableACL) > 0 {
  1024  		preparer = autorest.DecoratePreparer(preparer,
  1025  			autorest.WithJSON(tableACL))
  1026  	}
  1027  	if len(requestID) > 0 {
  1028  		preparer = autorest.DecoratePreparer(preparer,
  1029  			autorest.WithHeader("x-ms-client-request-id", autorest.String(requestID)))
  1030  	}
  1031  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
  1032  }
  1033  
  1034  // SetAccessPolicySender sends the SetAccessPolicy request. The method will close the
  1035  // http.Response Body if it receives an error.
  1036  func (client TableClient) SetAccessPolicySender(req *http.Request) (*http.Response, error) {
  1037  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
  1038  }
  1039  
  1040  // SetAccessPolicyResponder handles the response to the SetAccessPolicy request. The method always
  1041  // closes the http.Response Body.
  1042  func (client TableClient) SetAccessPolicyResponder(resp *http.Response) (result autorest.Response, err error) {
  1043  	err = autorest.Respond(
  1044  		resp,
  1045  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
  1046  		autorest.ByClosing())
  1047  	result.Response = resp
  1048  	return
  1049  }
  1050  
  1051  // UpdateEntity update entity in a table.
  1052  // Parameters:
  1053  // table - the name of the table.
  1054  // partitionKey - the partition key of the entity.
  1055  // rowKey - the row key of the entity.
  1056  // timeout - the timeout parameter is expressed in seconds.
  1057  // requestID - provides a client-generated, opaque value with a 1 KB character limit that is recorded in the
  1058  // analytics logs when analytics logging is enabled.
  1059  // formatParameter - specifies the media type for the response.
  1060  // tableEntityProperties - the properties for the table entity.
  1061  // ifMatch - match condition for an entity to be updated. If specified and a matching entity is not found, an
  1062  // error will be raised. To force an unconditional update, set to the wildcard character (*). If not specified,
  1063  // an insert will be performed when no existing entity is found to update and a replace will be performed if an
  1064  // existing entity is found.
  1065  func (client TableClient) UpdateEntity(ctx context.Context, table string, partitionKey string, rowKey string, timeout *int32, requestID string, formatParameter OdataMetadataFormat, tableEntityProperties map[string]interface{}, ifMatch string) (result autorest.Response, err error) {
  1066  	if tracing.IsEnabled() {
  1067  		ctx = tracing.StartSpan(ctx, fqdn+"/TableClient.UpdateEntity")
  1068  		defer func() {
  1069  			sc := -1
  1070  			if result.Response != nil {
  1071  				sc = result.Response.StatusCode
  1072  			}
  1073  			tracing.EndSpan(ctx, sc, err)
  1074  		}()
  1075  	}
  1076  	if err := validation.Validate([]validation.Validation{
  1077  		{TargetValue: timeout,
  1078  			Constraints: []validation.Constraint{{Target: "timeout", Name: validation.Null, Rule: false,
  1079  				Chain: []validation.Constraint{{Target: "timeout", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil {
  1080  		return result, validation.NewError("storagetables.TableClient", "UpdateEntity", err.Error())
  1081  	}
  1082  
  1083  	req, err := client.UpdateEntityPreparer(ctx, table, partitionKey, rowKey, timeout, requestID, formatParameter, tableEntityProperties, ifMatch)
  1084  	if err != nil {
  1085  		err = autorest.NewErrorWithError(err, "storagetables.TableClient", "UpdateEntity", nil, "Failure preparing request")
  1086  		return
  1087  	}
  1088  
  1089  	resp, err := client.UpdateEntitySender(req)
  1090  	if err != nil {
  1091  		result.Response = resp
  1092  		err = autorest.NewErrorWithError(err, "storagetables.TableClient", "UpdateEntity", resp, "Failure sending request")
  1093  		return
  1094  	}
  1095  
  1096  	result, err = client.UpdateEntityResponder(resp)
  1097  	if err != nil {
  1098  		err = autorest.NewErrorWithError(err, "storagetables.TableClient", "UpdateEntity", resp, "Failure responding to request")
  1099  		return
  1100  	}
  1101  
  1102  	return
  1103  }
  1104  
  1105  // UpdateEntityPreparer prepares the UpdateEntity request.
  1106  func (client TableClient) UpdateEntityPreparer(ctx context.Context, table string, partitionKey string, rowKey string, timeout *int32, requestID string, formatParameter OdataMetadataFormat, tableEntityProperties map[string]interface{}, ifMatch string) (*http.Request, error) {
  1107  	urlParameters := map[string]interface{}{
  1108  		"url": client.URL,
  1109  	}
  1110  
  1111  	pathParameters := map[string]interface{}{
  1112  		"partitionKey": autorest.Encode("path", partitionKey),
  1113  		"rowKey":       autorest.Encode("path", rowKey),
  1114  		"table":        autorest.Encode("path", table),
  1115  	}
  1116  
  1117  	queryParameters := map[string]interface{}{}
  1118  	if timeout != nil {
  1119  		queryParameters["timeout"] = autorest.Encode("query", *timeout)
  1120  	}
  1121  	if len(string(formatParameter)) > 0 {
  1122  		queryParameters["$format"] = autorest.Encode("query", formatParameter)
  1123  	}
  1124  
  1125  	preparer := autorest.CreatePreparer(
  1126  		autorest.AsContentType("application/json; charset=utf-8"),
  1127  		autorest.AsPut(),
  1128  		autorest.WithCustomBaseURL("{url}", urlParameters),
  1129  		autorest.WithPathParameters("/{table}(PartitionKey='{partitionKey}',RowKey='{rowKey}')", pathParameters),
  1130  		autorest.WithQueryParameters(queryParameters),
  1131  		autorest.WithHeader("x-ms-version", "2019-02-02"),
  1132  		autorest.WithHeader("DataServiceVersion", "3.0"))
  1133  	if tableEntityProperties != nil && len(tableEntityProperties) > 0 {
  1134  		preparer = autorest.DecoratePreparer(preparer,
  1135  			autorest.WithJSON(tableEntityProperties))
  1136  	}
  1137  	if len(requestID) > 0 {
  1138  		preparer = autorest.DecoratePreparer(preparer,
  1139  			autorest.WithHeader("x-ms-client-request-id", autorest.String(requestID)))
  1140  	}
  1141  	if len(ifMatch) > 0 {
  1142  		preparer = autorest.DecoratePreparer(preparer,
  1143  			autorest.WithHeader("If-Match", autorest.String(ifMatch)))
  1144  	}
  1145  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
  1146  }
  1147  
  1148  // UpdateEntitySender sends the UpdateEntity request. The method will close the
  1149  // http.Response Body if it receives an error.
  1150  func (client TableClient) UpdateEntitySender(req *http.Request) (*http.Response, error) {
  1151  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
  1152  }
  1153  
  1154  // UpdateEntityResponder handles the response to the UpdateEntity request. The method always
  1155  // closes the http.Response Body.
  1156  func (client TableClient) UpdateEntityResponder(resp *http.Response) (result autorest.Response, err error) {
  1157  	err = autorest.Respond(
  1158  		resp,
  1159  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
  1160  		autorest.ByClosing())
  1161  	result.Response = resp
  1162  	return
  1163  }
  1164  

View as plain text