...

Source file src/github.com/Azure/azure-sdk-for-go/services/storagesync/mgmt/2018-07-01/storagesync/serverendpoints.go

Documentation: github.com/Azure/azure-sdk-for-go/services/storagesync/mgmt/2018-07-01/storagesync

     1  package storagesync
     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  // ServerEndpointsClient is the microsoft Storage Sync Service API
    19  type ServerEndpointsClient struct {
    20  	BaseClient
    21  }
    22  
    23  // NewServerEndpointsClient creates an instance of the ServerEndpointsClient client.
    24  func NewServerEndpointsClient(subscriptionID string) ServerEndpointsClient {
    25  	return NewServerEndpointsClientWithBaseURI(DefaultBaseURI, subscriptionID)
    26  }
    27  
    28  // NewServerEndpointsClientWithBaseURI creates an instance of the ServerEndpointsClient client using a custom endpoint.
    29  // Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack).
    30  func NewServerEndpointsClientWithBaseURI(baseURI string, subscriptionID string) ServerEndpointsClient {
    31  	return ServerEndpointsClient{NewWithBaseURI(baseURI, subscriptionID)}
    32  }
    33  
    34  // Create create a new ServerEndpoint.
    35  // Parameters:
    36  // resourceGroupName - the name of the resource group. The name is case insensitive.
    37  // storageSyncServiceName - name of Storage Sync Service resource.
    38  // syncGroupName - name of Sync Group resource.
    39  // serverEndpointName - name of Server Endpoint object.
    40  // parameters - body of Server Endpoint object.
    41  func (client ServerEndpointsClient) Create(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string, serverEndpointName string, parameters ServerEndpointCreateParameters) (result ServerEndpointsCreateFuture, err error) {
    42  	if tracing.IsEnabled() {
    43  		ctx = tracing.StartSpan(ctx, fqdn+"/ServerEndpointsClient.Create")
    44  		defer func() {
    45  			sc := -1
    46  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
    47  				sc = result.FutureAPI.Response().StatusCode
    48  			}
    49  			tracing.EndSpan(ctx, sc, err)
    50  		}()
    51  	}
    52  	if err := validation.Validate([]validation.Validation{
    53  		{TargetValue: client.SubscriptionID,
    54  			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
    55  		{TargetValue: resourceGroupName,
    56  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
    57  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
    58  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
    59  		{TargetValue: parameters,
    60  			Constraints: []validation.Constraint{{Target: "parameters.ServerEndpointCreateParametersProperties", Name: validation.Null, Rule: false,
    61  				Chain: []validation.Constraint{{Target: "parameters.ServerEndpointCreateParametersProperties.VolumeFreeSpacePercent", Name: validation.Null, Rule: false,
    62  					Chain: []validation.Constraint{{Target: "parameters.ServerEndpointCreateParametersProperties.VolumeFreeSpacePercent", Name: validation.InclusiveMaximum, Rule: int64(100), Chain: nil},
    63  						{Target: "parameters.ServerEndpointCreateParametersProperties.VolumeFreeSpacePercent", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil},
    64  					}},
    65  					{Target: "parameters.ServerEndpointCreateParametersProperties.TierFilesOlderThanDays", Name: validation.Null, Rule: false,
    66  						Chain: []validation.Constraint{{Target: "parameters.ServerEndpointCreateParametersProperties.TierFilesOlderThanDays", Name: validation.InclusiveMaximum, Rule: int64(2147483647), Chain: nil},
    67  							{Target: "parameters.ServerEndpointCreateParametersProperties.TierFilesOlderThanDays", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil},
    68  						}},
    69  				}}}}}); err != nil {
    70  		return result, validation.NewError("storagesync.ServerEndpointsClient", "Create", err.Error())
    71  	}
    72  
    73  	req, err := client.CreatePreparer(ctx, resourceGroupName, storageSyncServiceName, syncGroupName, serverEndpointName, parameters)
    74  	if err != nil {
    75  		err = autorest.NewErrorWithError(err, "storagesync.ServerEndpointsClient", "Create", nil, "Failure preparing request")
    76  		return
    77  	}
    78  
    79  	result, err = client.CreateSender(req)
    80  	if err != nil {
    81  		err = autorest.NewErrorWithError(err, "storagesync.ServerEndpointsClient", "Create", result.Response(), "Failure sending request")
    82  		return
    83  	}
    84  
    85  	return
    86  }
    87  
    88  // CreatePreparer prepares the Create request.
    89  func (client ServerEndpointsClient) CreatePreparer(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string, serverEndpointName string, parameters ServerEndpointCreateParameters) (*http.Request, error) {
    90  	pathParameters := map[string]interface{}{
    91  		"resourceGroupName":      autorest.Encode("path", resourceGroupName),
    92  		"serverEndpointName":     autorest.Encode("path", serverEndpointName),
    93  		"storageSyncServiceName": autorest.Encode("path", storageSyncServiceName),
    94  		"subscriptionId":         autorest.Encode("path", client.SubscriptionID),
    95  		"syncGroupName":          autorest.Encode("path", syncGroupName),
    96  	}
    97  
    98  	const APIVersion = "2018-07-01"
    99  	queryParameters := map[string]interface{}{
   100  		"api-version": APIVersion,
   101  	}
   102  
   103  	preparer := autorest.CreatePreparer(
   104  		autorest.AsContentType("application/json; charset=utf-8"),
   105  		autorest.AsPut(),
   106  		autorest.WithBaseURL(client.BaseURI),
   107  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/serverEndpoints/{serverEndpointName}", pathParameters),
   108  		autorest.WithJSON(parameters),
   109  		autorest.WithQueryParameters(queryParameters))
   110  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   111  }
   112  
   113  // CreateSender sends the Create request. The method will close the
   114  // http.Response Body if it receives an error.
   115  func (client ServerEndpointsClient) CreateSender(req *http.Request) (future ServerEndpointsCreateFuture, err error) {
   116  	var resp *http.Response
   117  	future.FutureAPI = &azure.Future{}
   118  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   119  	if err != nil {
   120  		return
   121  	}
   122  	var azf azure.Future
   123  	azf, err = azure.NewFutureFromResponse(resp)
   124  	future.FutureAPI = &azf
   125  	future.Result = future.result
   126  	return
   127  }
   128  
   129  // CreateResponder handles the response to the Create request. The method always
   130  // closes the http.Response Body.
   131  func (client ServerEndpointsClient) CreateResponder(resp *http.Response) (result ServerEndpoint, err error) {
   132  	err = autorest.Respond(
   133  		resp,
   134  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
   135  		autorest.ByUnmarshallingJSON(&result),
   136  		autorest.ByClosing())
   137  	result.Response = autorest.Response{Response: resp}
   138  	return
   139  }
   140  
   141  // Delete delete a given ServerEndpoint.
   142  // Parameters:
   143  // resourceGroupName - the name of the resource group. The name is case insensitive.
   144  // storageSyncServiceName - name of Storage Sync Service resource.
   145  // syncGroupName - name of Sync Group resource.
   146  // serverEndpointName - name of Server Endpoint object.
   147  func (client ServerEndpointsClient) Delete(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string, serverEndpointName string) (result ServerEndpointsDeleteFuture, err error) {
   148  	if tracing.IsEnabled() {
   149  		ctx = tracing.StartSpan(ctx, fqdn+"/ServerEndpointsClient.Delete")
   150  		defer func() {
   151  			sc := -1
   152  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   153  				sc = result.FutureAPI.Response().StatusCode
   154  			}
   155  			tracing.EndSpan(ctx, sc, err)
   156  		}()
   157  	}
   158  	if err := validation.Validate([]validation.Validation{
   159  		{TargetValue: client.SubscriptionID,
   160  			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
   161  		{TargetValue: resourceGroupName,
   162  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
   163  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
   164  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil {
   165  		return result, validation.NewError("storagesync.ServerEndpointsClient", "Delete", err.Error())
   166  	}
   167  
   168  	req, err := client.DeletePreparer(ctx, resourceGroupName, storageSyncServiceName, syncGroupName, serverEndpointName)
   169  	if err != nil {
   170  		err = autorest.NewErrorWithError(err, "storagesync.ServerEndpointsClient", "Delete", nil, "Failure preparing request")
   171  		return
   172  	}
   173  
   174  	result, err = client.DeleteSender(req)
   175  	if err != nil {
   176  		err = autorest.NewErrorWithError(err, "storagesync.ServerEndpointsClient", "Delete", result.Response(), "Failure sending request")
   177  		return
   178  	}
   179  
   180  	return
   181  }
   182  
   183  // DeletePreparer prepares the Delete request.
   184  func (client ServerEndpointsClient) DeletePreparer(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string, serverEndpointName string) (*http.Request, error) {
   185  	pathParameters := map[string]interface{}{
   186  		"resourceGroupName":      autorest.Encode("path", resourceGroupName),
   187  		"serverEndpointName":     autorest.Encode("path", serverEndpointName),
   188  		"storageSyncServiceName": autorest.Encode("path", storageSyncServiceName),
   189  		"subscriptionId":         autorest.Encode("path", client.SubscriptionID),
   190  		"syncGroupName":          autorest.Encode("path", syncGroupName),
   191  	}
   192  
   193  	const APIVersion = "2018-07-01"
   194  	queryParameters := map[string]interface{}{
   195  		"api-version": APIVersion,
   196  	}
   197  
   198  	preparer := autorest.CreatePreparer(
   199  		autorest.AsDelete(),
   200  		autorest.WithBaseURL(client.BaseURI),
   201  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/serverEndpoints/{serverEndpointName}", pathParameters),
   202  		autorest.WithQueryParameters(queryParameters))
   203  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   204  }
   205  
   206  // DeleteSender sends the Delete request. The method will close the
   207  // http.Response Body if it receives an error.
   208  func (client ServerEndpointsClient) DeleteSender(req *http.Request) (future ServerEndpointsDeleteFuture, err error) {
   209  	var resp *http.Response
   210  	future.FutureAPI = &azure.Future{}
   211  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   212  	if err != nil {
   213  		return
   214  	}
   215  	var azf azure.Future
   216  	azf, err = azure.NewFutureFromResponse(resp)
   217  	future.FutureAPI = &azf
   218  	future.Result = future.result
   219  	return
   220  }
   221  
   222  // DeleteResponder handles the response to the Delete request. The method always
   223  // closes the http.Response Body.
   224  func (client ServerEndpointsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
   225  	err = autorest.Respond(
   226  		resp,
   227  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
   228  		autorest.ByClosing())
   229  	result.Response = resp
   230  	return
   231  }
   232  
   233  // Get get a ServerEndpoint.
   234  // Parameters:
   235  // resourceGroupName - the name of the resource group. The name is case insensitive.
   236  // storageSyncServiceName - name of Storage Sync Service resource.
   237  // syncGroupName - name of Sync Group resource.
   238  // serverEndpointName - name of Server Endpoint object.
   239  func (client ServerEndpointsClient) Get(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string, serverEndpointName string) (result ServerEndpoint, err error) {
   240  	if tracing.IsEnabled() {
   241  		ctx = tracing.StartSpan(ctx, fqdn+"/ServerEndpointsClient.Get")
   242  		defer func() {
   243  			sc := -1
   244  			if result.Response.Response != nil {
   245  				sc = result.Response.Response.StatusCode
   246  			}
   247  			tracing.EndSpan(ctx, sc, err)
   248  		}()
   249  	}
   250  	if err := validation.Validate([]validation.Validation{
   251  		{TargetValue: client.SubscriptionID,
   252  			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
   253  		{TargetValue: resourceGroupName,
   254  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
   255  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
   256  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil {
   257  		return result, validation.NewError("storagesync.ServerEndpointsClient", "Get", err.Error())
   258  	}
   259  
   260  	req, err := client.GetPreparer(ctx, resourceGroupName, storageSyncServiceName, syncGroupName, serverEndpointName)
   261  	if err != nil {
   262  		err = autorest.NewErrorWithError(err, "storagesync.ServerEndpointsClient", "Get", nil, "Failure preparing request")
   263  		return
   264  	}
   265  
   266  	resp, err := client.GetSender(req)
   267  	if err != nil {
   268  		result.Response = autorest.Response{Response: resp}
   269  		err = autorest.NewErrorWithError(err, "storagesync.ServerEndpointsClient", "Get", resp, "Failure sending request")
   270  		return
   271  	}
   272  
   273  	result, err = client.GetResponder(resp)
   274  	if err != nil {
   275  		err = autorest.NewErrorWithError(err, "storagesync.ServerEndpointsClient", "Get", resp, "Failure responding to request")
   276  		return
   277  	}
   278  
   279  	return
   280  }
   281  
   282  // GetPreparer prepares the Get request.
   283  func (client ServerEndpointsClient) GetPreparer(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string, serverEndpointName string) (*http.Request, error) {
   284  	pathParameters := map[string]interface{}{
   285  		"resourceGroupName":      autorest.Encode("path", resourceGroupName),
   286  		"serverEndpointName":     autorest.Encode("path", serverEndpointName),
   287  		"storageSyncServiceName": autorest.Encode("path", storageSyncServiceName),
   288  		"subscriptionId":         autorest.Encode("path", client.SubscriptionID),
   289  		"syncGroupName":          autorest.Encode("path", syncGroupName),
   290  	}
   291  
   292  	const APIVersion = "2018-07-01"
   293  	queryParameters := map[string]interface{}{
   294  		"api-version": APIVersion,
   295  	}
   296  
   297  	preparer := autorest.CreatePreparer(
   298  		autorest.AsGet(),
   299  		autorest.WithBaseURL(client.BaseURI),
   300  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/serverEndpoints/{serverEndpointName}", pathParameters),
   301  		autorest.WithQueryParameters(queryParameters))
   302  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   303  }
   304  
   305  // GetSender sends the Get request. The method will close the
   306  // http.Response Body if it receives an error.
   307  func (client ServerEndpointsClient) GetSender(req *http.Request) (*http.Response, error) {
   308  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   309  }
   310  
   311  // GetResponder handles the response to the Get request. The method always
   312  // closes the http.Response Body.
   313  func (client ServerEndpointsClient) GetResponder(resp *http.Response) (result ServerEndpoint, err error) {
   314  	err = autorest.Respond(
   315  		resp,
   316  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   317  		autorest.ByUnmarshallingJSON(&result),
   318  		autorest.ByClosing())
   319  	result.Response = autorest.Response{Response: resp}
   320  	return
   321  }
   322  
   323  // ListBySyncGroup get a ServerEndpoint list.
   324  // Parameters:
   325  // resourceGroupName - the name of the resource group. The name is case insensitive.
   326  // storageSyncServiceName - name of Storage Sync Service resource.
   327  // syncGroupName - name of Sync Group resource.
   328  func (client ServerEndpointsClient) ListBySyncGroup(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string) (result ServerEndpointArray, err error) {
   329  	if tracing.IsEnabled() {
   330  		ctx = tracing.StartSpan(ctx, fqdn+"/ServerEndpointsClient.ListBySyncGroup")
   331  		defer func() {
   332  			sc := -1
   333  			if result.Response.Response != nil {
   334  				sc = result.Response.Response.StatusCode
   335  			}
   336  			tracing.EndSpan(ctx, sc, err)
   337  		}()
   338  	}
   339  	if err := validation.Validate([]validation.Validation{
   340  		{TargetValue: client.SubscriptionID,
   341  			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
   342  		{TargetValue: resourceGroupName,
   343  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
   344  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
   345  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil {
   346  		return result, validation.NewError("storagesync.ServerEndpointsClient", "ListBySyncGroup", err.Error())
   347  	}
   348  
   349  	req, err := client.ListBySyncGroupPreparer(ctx, resourceGroupName, storageSyncServiceName, syncGroupName)
   350  	if err != nil {
   351  		err = autorest.NewErrorWithError(err, "storagesync.ServerEndpointsClient", "ListBySyncGroup", nil, "Failure preparing request")
   352  		return
   353  	}
   354  
   355  	resp, err := client.ListBySyncGroupSender(req)
   356  	if err != nil {
   357  		result.Response = autorest.Response{Response: resp}
   358  		err = autorest.NewErrorWithError(err, "storagesync.ServerEndpointsClient", "ListBySyncGroup", resp, "Failure sending request")
   359  		return
   360  	}
   361  
   362  	result, err = client.ListBySyncGroupResponder(resp)
   363  	if err != nil {
   364  		err = autorest.NewErrorWithError(err, "storagesync.ServerEndpointsClient", "ListBySyncGroup", resp, "Failure responding to request")
   365  		return
   366  	}
   367  
   368  	return
   369  }
   370  
   371  // ListBySyncGroupPreparer prepares the ListBySyncGroup request.
   372  func (client ServerEndpointsClient) ListBySyncGroupPreparer(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string) (*http.Request, error) {
   373  	pathParameters := map[string]interface{}{
   374  		"resourceGroupName":      autorest.Encode("path", resourceGroupName),
   375  		"storageSyncServiceName": autorest.Encode("path", storageSyncServiceName),
   376  		"subscriptionId":         autorest.Encode("path", client.SubscriptionID),
   377  		"syncGroupName":          autorest.Encode("path", syncGroupName),
   378  	}
   379  
   380  	const APIVersion = "2018-07-01"
   381  	queryParameters := map[string]interface{}{
   382  		"api-version": APIVersion,
   383  	}
   384  
   385  	preparer := autorest.CreatePreparer(
   386  		autorest.AsGet(),
   387  		autorest.WithBaseURL(client.BaseURI),
   388  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/serverEndpoints", pathParameters),
   389  		autorest.WithQueryParameters(queryParameters))
   390  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   391  }
   392  
   393  // ListBySyncGroupSender sends the ListBySyncGroup request. The method will close the
   394  // http.Response Body if it receives an error.
   395  func (client ServerEndpointsClient) ListBySyncGroupSender(req *http.Request) (*http.Response, error) {
   396  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   397  }
   398  
   399  // ListBySyncGroupResponder handles the response to the ListBySyncGroup request. The method always
   400  // closes the http.Response Body.
   401  func (client ServerEndpointsClient) ListBySyncGroupResponder(resp *http.Response) (result ServerEndpointArray, err error) {
   402  	err = autorest.Respond(
   403  		resp,
   404  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   405  		autorest.ByUnmarshallingJSON(&result),
   406  		autorest.ByClosing())
   407  	result.Response = autorest.Response{Response: resp}
   408  	return
   409  }
   410  
   411  // RecallAction recall a server endpoint.
   412  // Parameters:
   413  // resourceGroupName - the name of the resource group. The name is case insensitive.
   414  // storageSyncServiceName - name of Storage Sync Service resource.
   415  // syncGroupName - name of Sync Group resource.
   416  // serverEndpointName - name of Server Endpoint object.
   417  // parameters - body of Recall Action object.
   418  func (client ServerEndpointsClient) RecallAction(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string, serverEndpointName string, parameters RecallActionParameters) (result ServerEndpointsRecallActionFuture, err error) {
   419  	if tracing.IsEnabled() {
   420  		ctx = tracing.StartSpan(ctx, fqdn+"/ServerEndpointsClient.RecallAction")
   421  		defer func() {
   422  			sc := -1
   423  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   424  				sc = result.FutureAPI.Response().StatusCode
   425  			}
   426  			tracing.EndSpan(ctx, sc, err)
   427  		}()
   428  	}
   429  	if err := validation.Validate([]validation.Validation{
   430  		{TargetValue: client.SubscriptionID,
   431  			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
   432  		{TargetValue: resourceGroupName,
   433  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
   434  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
   435  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil {
   436  		return result, validation.NewError("storagesync.ServerEndpointsClient", "RecallAction", err.Error())
   437  	}
   438  
   439  	req, err := client.RecallActionPreparer(ctx, resourceGroupName, storageSyncServiceName, syncGroupName, serverEndpointName, parameters)
   440  	if err != nil {
   441  		err = autorest.NewErrorWithError(err, "storagesync.ServerEndpointsClient", "RecallAction", nil, "Failure preparing request")
   442  		return
   443  	}
   444  
   445  	result, err = client.RecallActionSender(req)
   446  	if err != nil {
   447  		err = autorest.NewErrorWithError(err, "storagesync.ServerEndpointsClient", "RecallAction", result.Response(), "Failure sending request")
   448  		return
   449  	}
   450  
   451  	return
   452  }
   453  
   454  // RecallActionPreparer prepares the RecallAction request.
   455  func (client ServerEndpointsClient) RecallActionPreparer(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string, serverEndpointName string, parameters RecallActionParameters) (*http.Request, error) {
   456  	pathParameters := map[string]interface{}{
   457  		"resourceGroupName":      autorest.Encode("path", resourceGroupName),
   458  		"serverEndpointName":     autorest.Encode("path", serverEndpointName),
   459  		"storageSyncServiceName": autorest.Encode("path", storageSyncServiceName),
   460  		"subscriptionId":         autorest.Encode("path", client.SubscriptionID),
   461  		"syncGroupName":          autorest.Encode("path", syncGroupName),
   462  	}
   463  
   464  	const APIVersion = "2018-07-01"
   465  	queryParameters := map[string]interface{}{
   466  		"api-version": APIVersion,
   467  	}
   468  
   469  	preparer := autorest.CreatePreparer(
   470  		autorest.AsContentType("application/json; charset=utf-8"),
   471  		autorest.AsPost(),
   472  		autorest.WithBaseURL(client.BaseURI),
   473  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/serverEndpoints/{serverEndpointName}/recallAction", pathParameters),
   474  		autorest.WithJSON(parameters),
   475  		autorest.WithQueryParameters(queryParameters))
   476  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   477  }
   478  
   479  // RecallActionSender sends the RecallAction request. The method will close the
   480  // http.Response Body if it receives an error.
   481  func (client ServerEndpointsClient) RecallActionSender(req *http.Request) (future ServerEndpointsRecallActionFuture, err error) {
   482  	var resp *http.Response
   483  	future.FutureAPI = &azure.Future{}
   484  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   485  	if err != nil {
   486  		return
   487  	}
   488  	var azf azure.Future
   489  	azf, err = azure.NewFutureFromResponse(resp)
   490  	future.FutureAPI = &azf
   491  	future.Result = future.result
   492  	return
   493  }
   494  
   495  // RecallActionResponder handles the response to the RecallAction request. The method always
   496  // closes the http.Response Body.
   497  func (client ServerEndpointsClient) RecallActionResponder(resp *http.Response) (result autorest.Response, err error) {
   498  	err = autorest.Respond(
   499  		resp,
   500  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
   501  		autorest.ByClosing())
   502  	result.Response = resp
   503  	return
   504  }
   505  
   506  // Update patch a given ServerEndpoint.
   507  // Parameters:
   508  // resourceGroupName - the name of the resource group. The name is case insensitive.
   509  // storageSyncServiceName - name of Storage Sync Service resource.
   510  // syncGroupName - name of Sync Group resource.
   511  // serverEndpointName - name of Server Endpoint object.
   512  // parameters - any of the properties applicable in PUT request.
   513  func (client ServerEndpointsClient) Update(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string, serverEndpointName string, parameters *ServerEndpointUpdateParameters) (result ServerEndpointsUpdateFuture, err error) {
   514  	if tracing.IsEnabled() {
   515  		ctx = tracing.StartSpan(ctx, fqdn+"/ServerEndpointsClient.Update")
   516  		defer func() {
   517  			sc := -1
   518  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   519  				sc = result.FutureAPI.Response().StatusCode
   520  			}
   521  			tracing.EndSpan(ctx, sc, err)
   522  		}()
   523  	}
   524  	if err := validation.Validate([]validation.Validation{
   525  		{TargetValue: client.SubscriptionID,
   526  			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
   527  		{TargetValue: resourceGroupName,
   528  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
   529  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
   530  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil {
   531  		return result, validation.NewError("storagesync.ServerEndpointsClient", "Update", err.Error())
   532  	}
   533  
   534  	req, err := client.UpdatePreparer(ctx, resourceGroupName, storageSyncServiceName, syncGroupName, serverEndpointName, parameters)
   535  	if err != nil {
   536  		err = autorest.NewErrorWithError(err, "storagesync.ServerEndpointsClient", "Update", nil, "Failure preparing request")
   537  		return
   538  	}
   539  
   540  	result, err = client.UpdateSender(req)
   541  	if err != nil {
   542  		err = autorest.NewErrorWithError(err, "storagesync.ServerEndpointsClient", "Update", result.Response(), "Failure sending request")
   543  		return
   544  	}
   545  
   546  	return
   547  }
   548  
   549  // UpdatePreparer prepares the Update request.
   550  func (client ServerEndpointsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string, serverEndpointName string, parameters *ServerEndpointUpdateParameters) (*http.Request, error) {
   551  	pathParameters := map[string]interface{}{
   552  		"resourceGroupName":      autorest.Encode("path", resourceGroupName),
   553  		"serverEndpointName":     autorest.Encode("path", serverEndpointName),
   554  		"storageSyncServiceName": autorest.Encode("path", storageSyncServiceName),
   555  		"subscriptionId":         autorest.Encode("path", client.SubscriptionID),
   556  		"syncGroupName":          autorest.Encode("path", syncGroupName),
   557  	}
   558  
   559  	const APIVersion = "2018-07-01"
   560  	queryParameters := map[string]interface{}{
   561  		"api-version": APIVersion,
   562  	}
   563  
   564  	preparer := autorest.CreatePreparer(
   565  		autorest.AsContentType("application/json; charset=utf-8"),
   566  		autorest.AsPatch(),
   567  		autorest.WithBaseURL(client.BaseURI),
   568  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/serverEndpoints/{serverEndpointName}", pathParameters),
   569  		autorest.WithQueryParameters(queryParameters))
   570  	if parameters != nil {
   571  		preparer = autorest.DecoratePreparer(preparer,
   572  			autorest.WithJSON(parameters))
   573  	}
   574  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   575  }
   576  
   577  // UpdateSender sends the Update request. The method will close the
   578  // http.Response Body if it receives an error.
   579  func (client ServerEndpointsClient) UpdateSender(req *http.Request) (future ServerEndpointsUpdateFuture, err error) {
   580  	var resp *http.Response
   581  	future.FutureAPI = &azure.Future{}
   582  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   583  	if err != nil {
   584  		return
   585  	}
   586  	var azf azure.Future
   587  	azf, err = azure.NewFutureFromResponse(resp)
   588  	future.FutureAPI = &azf
   589  	future.Result = future.result
   590  	return
   591  }
   592  
   593  // UpdateResponder handles the response to the Update request. The method always
   594  // closes the http.Response Body.
   595  func (client ServerEndpointsClient) UpdateResponder(resp *http.Response) (result ServerEndpoint, err error) {
   596  	err = autorest.Respond(
   597  		resp,
   598  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
   599  		autorest.ByUnmarshallingJSON(&result),
   600  		autorest.ByClosing())
   601  	result.Response = autorest.Response{Response: resp}
   602  	return
   603  }
   604  

View as plain text