...

Source file src/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2021-12-01/compute/cloudserviceroleinstances.go

Documentation: github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2021-12-01/compute

     1  package compute
     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/tracing"
    14  	"net/http"
    15  )
    16  
    17  // CloudServiceRoleInstancesClient is the compute Client
    18  type CloudServiceRoleInstancesClient struct {
    19  	BaseClient
    20  }
    21  
    22  // NewCloudServiceRoleInstancesClient creates an instance of the CloudServiceRoleInstancesClient client.
    23  func NewCloudServiceRoleInstancesClient(subscriptionID string) CloudServiceRoleInstancesClient {
    24  	return NewCloudServiceRoleInstancesClientWithBaseURI(DefaultBaseURI, subscriptionID)
    25  }
    26  
    27  // NewCloudServiceRoleInstancesClientWithBaseURI creates an instance of the CloudServiceRoleInstancesClient client
    28  // using a custom endpoint.  Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign
    29  // clouds, Azure stack).
    30  func NewCloudServiceRoleInstancesClientWithBaseURI(baseURI string, subscriptionID string) CloudServiceRoleInstancesClient {
    31  	return CloudServiceRoleInstancesClient{NewWithBaseURI(baseURI, subscriptionID)}
    32  }
    33  
    34  // Delete deletes a role instance from a cloud service.
    35  // Parameters:
    36  // roleInstanceName - name of the role instance.
    37  func (client CloudServiceRoleInstancesClient) Delete(ctx context.Context, roleInstanceName string, resourceGroupName string, cloudServiceName string) (result CloudServiceRoleInstancesDeleteFuture, err error) {
    38  	if tracing.IsEnabled() {
    39  		ctx = tracing.StartSpan(ctx, fqdn+"/CloudServiceRoleInstancesClient.Delete")
    40  		defer func() {
    41  			sc := -1
    42  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
    43  				sc = result.FutureAPI.Response().StatusCode
    44  			}
    45  			tracing.EndSpan(ctx, sc, err)
    46  		}()
    47  	}
    48  	req, err := client.DeletePreparer(ctx, roleInstanceName, resourceGroupName, cloudServiceName)
    49  	if err != nil {
    50  		err = autorest.NewErrorWithError(err, "compute.CloudServiceRoleInstancesClient", "Delete", nil, "Failure preparing request")
    51  		return
    52  	}
    53  
    54  	result, err = client.DeleteSender(req)
    55  	if err != nil {
    56  		err = autorest.NewErrorWithError(err, "compute.CloudServiceRoleInstancesClient", "Delete", result.Response(), "Failure sending request")
    57  		return
    58  	}
    59  
    60  	return
    61  }
    62  
    63  // DeletePreparer prepares the Delete request.
    64  func (client CloudServiceRoleInstancesClient) DeletePreparer(ctx context.Context, roleInstanceName string, resourceGroupName string, cloudServiceName string) (*http.Request, error) {
    65  	pathParameters := map[string]interface{}{
    66  		"cloudServiceName":  autorest.Encode("path", cloudServiceName),
    67  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
    68  		"roleInstanceName":  autorest.Encode("path", roleInstanceName),
    69  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
    70  	}
    71  
    72  	const APIVersion = "2021-03-01"
    73  	queryParameters := map[string]interface{}{
    74  		"api-version": APIVersion,
    75  	}
    76  
    77  	preparer := autorest.CreatePreparer(
    78  		autorest.AsDelete(),
    79  		autorest.WithBaseURL(client.BaseURI),
    80  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances/{roleInstanceName}", pathParameters),
    81  		autorest.WithQueryParameters(queryParameters))
    82  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
    83  }
    84  
    85  // DeleteSender sends the Delete request. The method will close the
    86  // http.Response Body if it receives an error.
    87  func (client CloudServiceRoleInstancesClient) DeleteSender(req *http.Request) (future CloudServiceRoleInstancesDeleteFuture, err error) {
    88  	var resp *http.Response
    89  	future.FutureAPI = &azure.Future{}
    90  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
    91  	if err != nil {
    92  		return
    93  	}
    94  	var azf azure.Future
    95  	azf, err = azure.NewFutureFromResponse(resp)
    96  	future.FutureAPI = &azf
    97  	future.Result = future.result
    98  	return
    99  }
   100  
   101  // DeleteResponder handles the response to the Delete request. The method always
   102  // closes the http.Response Body.
   103  func (client CloudServiceRoleInstancesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
   104  	err = autorest.Respond(
   105  		resp,
   106  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
   107  		autorest.ByClosing())
   108  	result.Response = resp
   109  	return
   110  }
   111  
   112  // Get gets a role instance from a cloud service.
   113  // Parameters:
   114  // roleInstanceName - name of the role instance.
   115  // expand - the expand expression to apply to the operation. 'UserData' is not supported for cloud services.
   116  func (client CloudServiceRoleInstancesClient) Get(ctx context.Context, roleInstanceName string, resourceGroupName string, cloudServiceName string, expand InstanceViewTypes) (result RoleInstance, err error) {
   117  	if tracing.IsEnabled() {
   118  		ctx = tracing.StartSpan(ctx, fqdn+"/CloudServiceRoleInstancesClient.Get")
   119  		defer func() {
   120  			sc := -1
   121  			if result.Response.Response != nil {
   122  				sc = result.Response.Response.StatusCode
   123  			}
   124  			tracing.EndSpan(ctx, sc, err)
   125  		}()
   126  	}
   127  	req, err := client.GetPreparer(ctx, roleInstanceName, resourceGroupName, cloudServiceName, expand)
   128  	if err != nil {
   129  		err = autorest.NewErrorWithError(err, "compute.CloudServiceRoleInstancesClient", "Get", nil, "Failure preparing request")
   130  		return
   131  	}
   132  
   133  	resp, err := client.GetSender(req)
   134  	if err != nil {
   135  		result.Response = autorest.Response{Response: resp}
   136  		err = autorest.NewErrorWithError(err, "compute.CloudServiceRoleInstancesClient", "Get", resp, "Failure sending request")
   137  		return
   138  	}
   139  
   140  	result, err = client.GetResponder(resp)
   141  	if err != nil {
   142  		err = autorest.NewErrorWithError(err, "compute.CloudServiceRoleInstancesClient", "Get", resp, "Failure responding to request")
   143  		return
   144  	}
   145  
   146  	return
   147  }
   148  
   149  // GetPreparer prepares the Get request.
   150  func (client CloudServiceRoleInstancesClient) GetPreparer(ctx context.Context, roleInstanceName string, resourceGroupName string, cloudServiceName string, expand InstanceViewTypes) (*http.Request, error) {
   151  	pathParameters := map[string]interface{}{
   152  		"cloudServiceName":  autorest.Encode("path", cloudServiceName),
   153  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   154  		"roleInstanceName":  autorest.Encode("path", roleInstanceName),
   155  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   156  	}
   157  
   158  	const APIVersion = "2021-03-01"
   159  	queryParameters := map[string]interface{}{
   160  		"api-version": APIVersion,
   161  	}
   162  	if len(string(expand)) > 0 {
   163  		queryParameters["$expand"] = autorest.Encode("query", expand)
   164  	}
   165  
   166  	preparer := autorest.CreatePreparer(
   167  		autorest.AsGet(),
   168  		autorest.WithBaseURL(client.BaseURI),
   169  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances/{roleInstanceName}", pathParameters),
   170  		autorest.WithQueryParameters(queryParameters))
   171  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   172  }
   173  
   174  // GetSender sends the Get request. The method will close the
   175  // http.Response Body if it receives an error.
   176  func (client CloudServiceRoleInstancesClient) GetSender(req *http.Request) (*http.Response, error) {
   177  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   178  }
   179  
   180  // GetResponder handles the response to the Get request. The method always
   181  // closes the http.Response Body.
   182  func (client CloudServiceRoleInstancesClient) GetResponder(resp *http.Response) (result RoleInstance, err error) {
   183  	err = autorest.Respond(
   184  		resp,
   185  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   186  		autorest.ByUnmarshallingJSON(&result),
   187  		autorest.ByClosing())
   188  	result.Response = autorest.Response{Response: resp}
   189  	return
   190  }
   191  
   192  // GetInstanceView retrieves information about the run-time state of a role instance in a cloud service.
   193  // Parameters:
   194  // roleInstanceName - name of the role instance.
   195  func (client CloudServiceRoleInstancesClient) GetInstanceView(ctx context.Context, roleInstanceName string, resourceGroupName string, cloudServiceName string) (result RoleInstanceInstanceView, err error) {
   196  	if tracing.IsEnabled() {
   197  		ctx = tracing.StartSpan(ctx, fqdn+"/CloudServiceRoleInstancesClient.GetInstanceView")
   198  		defer func() {
   199  			sc := -1
   200  			if result.Response.Response != nil {
   201  				sc = result.Response.Response.StatusCode
   202  			}
   203  			tracing.EndSpan(ctx, sc, err)
   204  		}()
   205  	}
   206  	req, err := client.GetInstanceViewPreparer(ctx, roleInstanceName, resourceGroupName, cloudServiceName)
   207  	if err != nil {
   208  		err = autorest.NewErrorWithError(err, "compute.CloudServiceRoleInstancesClient", "GetInstanceView", nil, "Failure preparing request")
   209  		return
   210  	}
   211  
   212  	resp, err := client.GetInstanceViewSender(req)
   213  	if err != nil {
   214  		result.Response = autorest.Response{Response: resp}
   215  		err = autorest.NewErrorWithError(err, "compute.CloudServiceRoleInstancesClient", "GetInstanceView", resp, "Failure sending request")
   216  		return
   217  	}
   218  
   219  	result, err = client.GetInstanceViewResponder(resp)
   220  	if err != nil {
   221  		err = autorest.NewErrorWithError(err, "compute.CloudServiceRoleInstancesClient", "GetInstanceView", resp, "Failure responding to request")
   222  		return
   223  	}
   224  
   225  	return
   226  }
   227  
   228  // GetInstanceViewPreparer prepares the GetInstanceView request.
   229  func (client CloudServiceRoleInstancesClient) GetInstanceViewPreparer(ctx context.Context, roleInstanceName string, resourceGroupName string, cloudServiceName string) (*http.Request, error) {
   230  	pathParameters := map[string]interface{}{
   231  		"cloudServiceName":  autorest.Encode("path", cloudServiceName),
   232  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   233  		"roleInstanceName":  autorest.Encode("path", roleInstanceName),
   234  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   235  	}
   236  
   237  	const APIVersion = "2021-03-01"
   238  	queryParameters := map[string]interface{}{
   239  		"api-version": APIVersion,
   240  	}
   241  
   242  	preparer := autorest.CreatePreparer(
   243  		autorest.AsGet(),
   244  		autorest.WithBaseURL(client.BaseURI),
   245  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances/{roleInstanceName}/instanceView", pathParameters),
   246  		autorest.WithQueryParameters(queryParameters))
   247  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   248  }
   249  
   250  // GetInstanceViewSender sends the GetInstanceView request. The method will close the
   251  // http.Response Body if it receives an error.
   252  func (client CloudServiceRoleInstancesClient) GetInstanceViewSender(req *http.Request) (*http.Response, error) {
   253  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   254  }
   255  
   256  // GetInstanceViewResponder handles the response to the GetInstanceView request. The method always
   257  // closes the http.Response Body.
   258  func (client CloudServiceRoleInstancesClient) GetInstanceViewResponder(resp *http.Response) (result RoleInstanceInstanceView, err error) {
   259  	err = autorest.Respond(
   260  		resp,
   261  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   262  		autorest.ByUnmarshallingJSON(&result),
   263  		autorest.ByClosing())
   264  	result.Response = autorest.Response{Response: resp}
   265  	return
   266  }
   267  
   268  // GetRemoteDesktopFile gets a remote desktop file for a role instance in a cloud service.
   269  // Parameters:
   270  // roleInstanceName - name of the role instance.
   271  func (client CloudServiceRoleInstancesClient) GetRemoteDesktopFile(ctx context.Context, roleInstanceName string, resourceGroupName string, cloudServiceName string) (result ReadCloser, err error) {
   272  	if tracing.IsEnabled() {
   273  		ctx = tracing.StartSpan(ctx, fqdn+"/CloudServiceRoleInstancesClient.GetRemoteDesktopFile")
   274  		defer func() {
   275  			sc := -1
   276  			if result.Response.Response != nil {
   277  				sc = result.Response.Response.StatusCode
   278  			}
   279  			tracing.EndSpan(ctx, sc, err)
   280  		}()
   281  	}
   282  	req, err := client.GetRemoteDesktopFilePreparer(ctx, roleInstanceName, resourceGroupName, cloudServiceName)
   283  	if err != nil {
   284  		err = autorest.NewErrorWithError(err, "compute.CloudServiceRoleInstancesClient", "GetRemoteDesktopFile", nil, "Failure preparing request")
   285  		return
   286  	}
   287  
   288  	resp, err := client.GetRemoteDesktopFileSender(req)
   289  	if err != nil {
   290  		result.Response = autorest.Response{Response: resp}
   291  		err = autorest.NewErrorWithError(err, "compute.CloudServiceRoleInstancesClient", "GetRemoteDesktopFile", resp, "Failure sending request")
   292  		return
   293  	}
   294  
   295  	result, err = client.GetRemoteDesktopFileResponder(resp)
   296  	if err != nil {
   297  		err = autorest.NewErrorWithError(err, "compute.CloudServiceRoleInstancesClient", "GetRemoteDesktopFile", resp, "Failure responding to request")
   298  		return
   299  	}
   300  
   301  	return
   302  }
   303  
   304  // GetRemoteDesktopFilePreparer prepares the GetRemoteDesktopFile request.
   305  func (client CloudServiceRoleInstancesClient) GetRemoteDesktopFilePreparer(ctx context.Context, roleInstanceName string, resourceGroupName string, cloudServiceName string) (*http.Request, error) {
   306  	pathParameters := map[string]interface{}{
   307  		"cloudServiceName":  autorest.Encode("path", cloudServiceName),
   308  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   309  		"roleInstanceName":  autorest.Encode("path", roleInstanceName),
   310  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   311  	}
   312  
   313  	const APIVersion = "2021-03-01"
   314  	queryParameters := map[string]interface{}{
   315  		"api-version": APIVersion,
   316  	}
   317  
   318  	preparer := autorest.CreatePreparer(
   319  		autorest.AsGet(),
   320  		autorest.WithBaseURL(client.BaseURI),
   321  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances/{roleInstanceName}/remoteDesktopFile", pathParameters),
   322  		autorest.WithQueryParameters(queryParameters))
   323  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   324  }
   325  
   326  // GetRemoteDesktopFileSender sends the GetRemoteDesktopFile request. The method will close the
   327  // http.Response Body if it receives an error.
   328  func (client CloudServiceRoleInstancesClient) GetRemoteDesktopFileSender(req *http.Request) (*http.Response, error) {
   329  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   330  }
   331  
   332  // GetRemoteDesktopFileResponder handles the response to the GetRemoteDesktopFile request. The method always
   333  // closes the http.Response Body.
   334  func (client CloudServiceRoleInstancesClient) GetRemoteDesktopFileResponder(resp *http.Response) (result ReadCloser, err error) {
   335  	result.Value = &resp.Body
   336  	err = autorest.Respond(
   337  		resp,
   338  		azure.WithErrorUnlessStatusCode(http.StatusOK))
   339  	result.Response = autorest.Response{Response: resp}
   340  	return
   341  }
   342  
   343  // List gets the list of all role instances in a cloud service. Use nextLink property in the response to get the next
   344  // page of role instances. Do this till nextLink is null to fetch all the role instances.
   345  // Parameters:
   346  // expand - the expand expression to apply to the operation. 'UserData' is not supported for cloud services.
   347  func (client CloudServiceRoleInstancesClient) List(ctx context.Context, resourceGroupName string, cloudServiceName string, expand InstanceViewTypes) (result RoleInstanceListResultPage, err error) {
   348  	if tracing.IsEnabled() {
   349  		ctx = tracing.StartSpan(ctx, fqdn+"/CloudServiceRoleInstancesClient.List")
   350  		defer func() {
   351  			sc := -1
   352  			if result.rilr.Response.Response != nil {
   353  				sc = result.rilr.Response.Response.StatusCode
   354  			}
   355  			tracing.EndSpan(ctx, sc, err)
   356  		}()
   357  	}
   358  	result.fn = client.listNextResults
   359  	req, err := client.ListPreparer(ctx, resourceGroupName, cloudServiceName, expand)
   360  	if err != nil {
   361  		err = autorest.NewErrorWithError(err, "compute.CloudServiceRoleInstancesClient", "List", nil, "Failure preparing request")
   362  		return
   363  	}
   364  
   365  	resp, err := client.ListSender(req)
   366  	if err != nil {
   367  		result.rilr.Response = autorest.Response{Response: resp}
   368  		err = autorest.NewErrorWithError(err, "compute.CloudServiceRoleInstancesClient", "List", resp, "Failure sending request")
   369  		return
   370  	}
   371  
   372  	result.rilr, err = client.ListResponder(resp)
   373  	if err != nil {
   374  		err = autorest.NewErrorWithError(err, "compute.CloudServiceRoleInstancesClient", "List", resp, "Failure responding to request")
   375  		return
   376  	}
   377  	if result.rilr.hasNextLink() && result.rilr.IsEmpty() {
   378  		err = result.NextWithContext(ctx)
   379  		return
   380  	}
   381  
   382  	return
   383  }
   384  
   385  // ListPreparer prepares the List request.
   386  func (client CloudServiceRoleInstancesClient) ListPreparer(ctx context.Context, resourceGroupName string, cloudServiceName string, expand InstanceViewTypes) (*http.Request, error) {
   387  	pathParameters := map[string]interface{}{
   388  		"cloudServiceName":  autorest.Encode("path", cloudServiceName),
   389  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   390  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   391  	}
   392  
   393  	const APIVersion = "2021-03-01"
   394  	queryParameters := map[string]interface{}{
   395  		"api-version": APIVersion,
   396  	}
   397  	if len(string(expand)) > 0 {
   398  		queryParameters["$expand"] = autorest.Encode("query", expand)
   399  	}
   400  
   401  	preparer := autorest.CreatePreparer(
   402  		autorest.AsGet(),
   403  		autorest.WithBaseURL(client.BaseURI),
   404  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances", pathParameters),
   405  		autorest.WithQueryParameters(queryParameters))
   406  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   407  }
   408  
   409  // ListSender sends the List request. The method will close the
   410  // http.Response Body if it receives an error.
   411  func (client CloudServiceRoleInstancesClient) ListSender(req *http.Request) (*http.Response, error) {
   412  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   413  }
   414  
   415  // ListResponder handles the response to the List request. The method always
   416  // closes the http.Response Body.
   417  func (client CloudServiceRoleInstancesClient) ListResponder(resp *http.Response) (result RoleInstanceListResult, err error) {
   418  	err = autorest.Respond(
   419  		resp,
   420  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   421  		autorest.ByUnmarshallingJSON(&result),
   422  		autorest.ByClosing())
   423  	result.Response = autorest.Response{Response: resp}
   424  	return
   425  }
   426  
   427  // listNextResults retrieves the next set of results, if any.
   428  func (client CloudServiceRoleInstancesClient) listNextResults(ctx context.Context, lastResults RoleInstanceListResult) (result RoleInstanceListResult, err error) {
   429  	req, err := lastResults.roleInstanceListResultPreparer(ctx)
   430  	if err != nil {
   431  		return result, autorest.NewErrorWithError(err, "compute.CloudServiceRoleInstancesClient", "listNextResults", nil, "Failure preparing next results request")
   432  	}
   433  	if req == nil {
   434  		return
   435  	}
   436  	resp, err := client.ListSender(req)
   437  	if err != nil {
   438  		result.Response = autorest.Response{Response: resp}
   439  		return result, autorest.NewErrorWithError(err, "compute.CloudServiceRoleInstancesClient", "listNextResults", resp, "Failure sending next results request")
   440  	}
   441  	result, err = client.ListResponder(resp)
   442  	if err != nil {
   443  		err = autorest.NewErrorWithError(err, "compute.CloudServiceRoleInstancesClient", "listNextResults", resp, "Failure responding to next results request")
   444  	}
   445  	return
   446  }
   447  
   448  // ListComplete enumerates all values, automatically crossing page boundaries as required.
   449  func (client CloudServiceRoleInstancesClient) ListComplete(ctx context.Context, resourceGroupName string, cloudServiceName string, expand InstanceViewTypes) (result RoleInstanceListResultIterator, err error) {
   450  	if tracing.IsEnabled() {
   451  		ctx = tracing.StartSpan(ctx, fqdn+"/CloudServiceRoleInstancesClient.List")
   452  		defer func() {
   453  			sc := -1
   454  			if result.Response().Response.Response != nil {
   455  				sc = result.page.Response().Response.Response.StatusCode
   456  			}
   457  			tracing.EndSpan(ctx, sc, err)
   458  		}()
   459  	}
   460  	result.page, err = client.List(ctx, resourceGroupName, cloudServiceName, expand)
   461  	return
   462  }
   463  
   464  // Rebuild the Rebuild Role Instance asynchronous operation reinstalls the operating system on instances of web roles
   465  // or worker roles and initializes the storage resources that are used by them. If you do not want to initialize
   466  // storage resources, you can use Reimage Role Instance.
   467  // Parameters:
   468  // roleInstanceName - name of the role instance.
   469  func (client CloudServiceRoleInstancesClient) Rebuild(ctx context.Context, roleInstanceName string, resourceGroupName string, cloudServiceName string) (result CloudServiceRoleInstancesRebuildFuture, err error) {
   470  	if tracing.IsEnabled() {
   471  		ctx = tracing.StartSpan(ctx, fqdn+"/CloudServiceRoleInstancesClient.Rebuild")
   472  		defer func() {
   473  			sc := -1
   474  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   475  				sc = result.FutureAPI.Response().StatusCode
   476  			}
   477  			tracing.EndSpan(ctx, sc, err)
   478  		}()
   479  	}
   480  	req, err := client.RebuildPreparer(ctx, roleInstanceName, resourceGroupName, cloudServiceName)
   481  	if err != nil {
   482  		err = autorest.NewErrorWithError(err, "compute.CloudServiceRoleInstancesClient", "Rebuild", nil, "Failure preparing request")
   483  		return
   484  	}
   485  
   486  	result, err = client.RebuildSender(req)
   487  	if err != nil {
   488  		err = autorest.NewErrorWithError(err, "compute.CloudServiceRoleInstancesClient", "Rebuild", result.Response(), "Failure sending request")
   489  		return
   490  	}
   491  
   492  	return
   493  }
   494  
   495  // RebuildPreparer prepares the Rebuild request.
   496  func (client CloudServiceRoleInstancesClient) RebuildPreparer(ctx context.Context, roleInstanceName string, resourceGroupName string, cloudServiceName string) (*http.Request, error) {
   497  	pathParameters := map[string]interface{}{
   498  		"cloudServiceName":  autorest.Encode("path", cloudServiceName),
   499  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   500  		"roleInstanceName":  autorest.Encode("path", roleInstanceName),
   501  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   502  	}
   503  
   504  	const APIVersion = "2021-03-01"
   505  	queryParameters := map[string]interface{}{
   506  		"api-version": APIVersion,
   507  	}
   508  
   509  	preparer := autorest.CreatePreparer(
   510  		autorest.AsPost(),
   511  		autorest.WithBaseURL(client.BaseURI),
   512  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances/{roleInstanceName}/rebuild", pathParameters),
   513  		autorest.WithQueryParameters(queryParameters))
   514  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   515  }
   516  
   517  // RebuildSender sends the Rebuild request. The method will close the
   518  // http.Response Body if it receives an error.
   519  func (client CloudServiceRoleInstancesClient) RebuildSender(req *http.Request) (future CloudServiceRoleInstancesRebuildFuture, err error) {
   520  	var resp *http.Response
   521  	future.FutureAPI = &azure.Future{}
   522  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   523  	if err != nil {
   524  		return
   525  	}
   526  	var azf azure.Future
   527  	azf, err = azure.NewFutureFromResponse(resp)
   528  	future.FutureAPI = &azf
   529  	future.Result = future.result
   530  	return
   531  }
   532  
   533  // RebuildResponder handles the response to the Rebuild request. The method always
   534  // closes the http.Response Body.
   535  func (client CloudServiceRoleInstancesClient) RebuildResponder(resp *http.Response) (result autorest.Response, err error) {
   536  	err = autorest.Respond(
   537  		resp,
   538  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
   539  		autorest.ByClosing())
   540  	result.Response = resp
   541  	return
   542  }
   543  
   544  // Reimage the Reimage Role Instance asynchronous operation reinstalls the operating system on instances of web roles
   545  // or worker roles.
   546  // Parameters:
   547  // roleInstanceName - name of the role instance.
   548  func (client CloudServiceRoleInstancesClient) Reimage(ctx context.Context, roleInstanceName string, resourceGroupName string, cloudServiceName string) (result CloudServiceRoleInstancesReimageFuture, err error) {
   549  	if tracing.IsEnabled() {
   550  		ctx = tracing.StartSpan(ctx, fqdn+"/CloudServiceRoleInstancesClient.Reimage")
   551  		defer func() {
   552  			sc := -1
   553  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   554  				sc = result.FutureAPI.Response().StatusCode
   555  			}
   556  			tracing.EndSpan(ctx, sc, err)
   557  		}()
   558  	}
   559  	req, err := client.ReimagePreparer(ctx, roleInstanceName, resourceGroupName, cloudServiceName)
   560  	if err != nil {
   561  		err = autorest.NewErrorWithError(err, "compute.CloudServiceRoleInstancesClient", "Reimage", nil, "Failure preparing request")
   562  		return
   563  	}
   564  
   565  	result, err = client.ReimageSender(req)
   566  	if err != nil {
   567  		err = autorest.NewErrorWithError(err, "compute.CloudServiceRoleInstancesClient", "Reimage", result.Response(), "Failure sending request")
   568  		return
   569  	}
   570  
   571  	return
   572  }
   573  
   574  // ReimagePreparer prepares the Reimage request.
   575  func (client CloudServiceRoleInstancesClient) ReimagePreparer(ctx context.Context, roleInstanceName string, resourceGroupName string, cloudServiceName string) (*http.Request, error) {
   576  	pathParameters := map[string]interface{}{
   577  		"cloudServiceName":  autorest.Encode("path", cloudServiceName),
   578  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   579  		"roleInstanceName":  autorest.Encode("path", roleInstanceName),
   580  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   581  	}
   582  
   583  	const APIVersion = "2021-03-01"
   584  	queryParameters := map[string]interface{}{
   585  		"api-version": APIVersion,
   586  	}
   587  
   588  	preparer := autorest.CreatePreparer(
   589  		autorest.AsPost(),
   590  		autorest.WithBaseURL(client.BaseURI),
   591  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances/{roleInstanceName}/reimage", pathParameters),
   592  		autorest.WithQueryParameters(queryParameters))
   593  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   594  }
   595  
   596  // ReimageSender sends the Reimage request. The method will close the
   597  // http.Response Body if it receives an error.
   598  func (client CloudServiceRoleInstancesClient) ReimageSender(req *http.Request) (future CloudServiceRoleInstancesReimageFuture, err error) {
   599  	var resp *http.Response
   600  	future.FutureAPI = &azure.Future{}
   601  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   602  	if err != nil {
   603  		return
   604  	}
   605  	var azf azure.Future
   606  	azf, err = azure.NewFutureFromResponse(resp)
   607  	future.FutureAPI = &azf
   608  	future.Result = future.result
   609  	return
   610  }
   611  
   612  // ReimageResponder handles the response to the Reimage request. The method always
   613  // closes the http.Response Body.
   614  func (client CloudServiceRoleInstancesClient) ReimageResponder(resp *http.Response) (result autorest.Response, err error) {
   615  	err = autorest.Respond(
   616  		resp,
   617  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
   618  		autorest.ByClosing())
   619  	result.Response = resp
   620  	return
   621  }
   622  
   623  // Restart the Reboot Role Instance asynchronous operation requests a reboot of a role instance in the cloud service.
   624  // Parameters:
   625  // roleInstanceName - name of the role instance.
   626  func (client CloudServiceRoleInstancesClient) Restart(ctx context.Context, roleInstanceName string, resourceGroupName string, cloudServiceName string) (result CloudServiceRoleInstancesRestartFuture, err error) {
   627  	if tracing.IsEnabled() {
   628  		ctx = tracing.StartSpan(ctx, fqdn+"/CloudServiceRoleInstancesClient.Restart")
   629  		defer func() {
   630  			sc := -1
   631  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   632  				sc = result.FutureAPI.Response().StatusCode
   633  			}
   634  			tracing.EndSpan(ctx, sc, err)
   635  		}()
   636  	}
   637  	req, err := client.RestartPreparer(ctx, roleInstanceName, resourceGroupName, cloudServiceName)
   638  	if err != nil {
   639  		err = autorest.NewErrorWithError(err, "compute.CloudServiceRoleInstancesClient", "Restart", nil, "Failure preparing request")
   640  		return
   641  	}
   642  
   643  	result, err = client.RestartSender(req)
   644  	if err != nil {
   645  		err = autorest.NewErrorWithError(err, "compute.CloudServiceRoleInstancesClient", "Restart", result.Response(), "Failure sending request")
   646  		return
   647  	}
   648  
   649  	return
   650  }
   651  
   652  // RestartPreparer prepares the Restart request.
   653  func (client CloudServiceRoleInstancesClient) RestartPreparer(ctx context.Context, roleInstanceName string, resourceGroupName string, cloudServiceName string) (*http.Request, error) {
   654  	pathParameters := map[string]interface{}{
   655  		"cloudServiceName":  autorest.Encode("path", cloudServiceName),
   656  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   657  		"roleInstanceName":  autorest.Encode("path", roleInstanceName),
   658  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   659  	}
   660  
   661  	const APIVersion = "2021-03-01"
   662  	queryParameters := map[string]interface{}{
   663  		"api-version": APIVersion,
   664  	}
   665  
   666  	preparer := autorest.CreatePreparer(
   667  		autorest.AsPost(),
   668  		autorest.WithBaseURL(client.BaseURI),
   669  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances/{roleInstanceName}/restart", pathParameters),
   670  		autorest.WithQueryParameters(queryParameters))
   671  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   672  }
   673  
   674  // RestartSender sends the Restart request. The method will close the
   675  // http.Response Body if it receives an error.
   676  func (client CloudServiceRoleInstancesClient) RestartSender(req *http.Request) (future CloudServiceRoleInstancesRestartFuture, err error) {
   677  	var resp *http.Response
   678  	future.FutureAPI = &azure.Future{}
   679  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   680  	if err != nil {
   681  		return
   682  	}
   683  	var azf azure.Future
   684  	azf, err = azure.NewFutureFromResponse(resp)
   685  	future.FutureAPI = &azf
   686  	future.Result = future.result
   687  	return
   688  }
   689  
   690  // RestartResponder handles the response to the Restart request. The method always
   691  // closes the http.Response Body.
   692  func (client CloudServiceRoleInstancesClient) RestartResponder(resp *http.Response) (result autorest.Response, err error) {
   693  	err = autorest.Respond(
   694  		resp,
   695  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
   696  		autorest.ByClosing())
   697  	result.Response = resp
   698  	return
   699  }
   700  

View as plain text