...

Source file src/github.com/Azure/azure-sdk-for-go/services/solutions/mgmt/2018-02-01/managedapplications/applications.go

Documentation: github.com/Azure/azure-sdk-for-go/services/solutions/mgmt/2018-02-01/managedapplications

     1  package managedapplications
     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  // ApplicationsClient is the ARM applications
    19  type ApplicationsClient struct {
    20  	BaseClient
    21  }
    22  
    23  // NewApplicationsClient creates an instance of the ApplicationsClient client.
    24  func NewApplicationsClient(subscriptionID string) ApplicationsClient {
    25  	return NewApplicationsClientWithBaseURI(DefaultBaseURI, subscriptionID)
    26  }
    27  
    28  // NewApplicationsClientWithBaseURI creates an instance of the ApplicationsClient client using a custom endpoint.  Use
    29  // this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack).
    30  func NewApplicationsClientWithBaseURI(baseURI string, subscriptionID string) ApplicationsClient {
    31  	return ApplicationsClient{NewWithBaseURI(baseURI, subscriptionID)}
    32  }
    33  
    34  // CreateOrUpdate creates or updates a managed application.
    35  // Parameters:
    36  // resourceGroupName - the name of the resource group. The name is case insensitive.
    37  // applicationName - the name of the managed application.
    38  // parameters - parameters supplied to the create or update a managed application.
    39  func (client ApplicationsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, applicationName string, parameters Application) (result ApplicationsCreateOrUpdateFuture, err error) {
    40  	if tracing.IsEnabled() {
    41  		ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationsClient.CreateOrUpdate")
    42  		defer func() {
    43  			sc := -1
    44  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
    45  				sc = result.FutureAPI.Response().StatusCode
    46  			}
    47  			tracing.EndSpan(ctx, sc, err)
    48  		}()
    49  	}
    50  	if err := validation.Validate([]validation.Validation{
    51  		{TargetValue: resourceGroupName,
    52  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
    53  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
    54  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
    55  		{TargetValue: applicationName,
    56  			Constraints: []validation.Constraint{{Target: "applicationName", Name: validation.MaxLength, Rule: 64, Chain: nil},
    57  				{Target: "applicationName", Name: validation.MinLength, Rule: 3, Chain: nil}}},
    58  		{TargetValue: parameters,
    59  			Constraints: []validation.Constraint{{Target: "parameters.ApplicationProperties", Name: validation.Null, Rule: true,
    60  				Chain: []validation.Constraint{{Target: "parameters.ApplicationProperties.CustomerSupport", Name: validation.Null, Rule: false,
    61  					Chain: []validation.Constraint{{Target: "parameters.ApplicationProperties.CustomerSupport.Email", Name: validation.Null, Rule: true, Chain: nil},
    62  						{Target: "parameters.ApplicationProperties.CustomerSupport.Phone", Name: validation.Null, Rule: true, Chain: nil},
    63  					}},
    64  				}},
    65  				{Target: "parameters.Plan", Name: validation.Null, Rule: false,
    66  					Chain: []validation.Constraint{{Target: "parameters.Plan.Name", Name: validation.Null, Rule: true, Chain: nil},
    67  						{Target: "parameters.Plan.Publisher", Name: validation.Null, Rule: true, Chain: nil},
    68  						{Target: "parameters.Plan.Product", Name: validation.Null, Rule: true, Chain: nil},
    69  						{Target: "parameters.Plan.Version", Name: validation.Null, Rule: true, Chain: nil},
    70  					}},
    71  				{Target: "parameters.Kind", Name: validation.Null, Rule: true,
    72  					Chain: []validation.Constraint{{Target: "parameters.Kind", Name: validation.Pattern, Rule: `^[-\w\._,\(\)]+$`, Chain: nil}}}}}}); err != nil {
    73  		return result, validation.NewError("managedapplications.ApplicationsClient", "CreateOrUpdate", err.Error())
    74  	}
    75  
    76  	req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, applicationName, parameters)
    77  	if err != nil {
    78  		err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "CreateOrUpdate", nil, "Failure preparing request")
    79  		return
    80  	}
    81  
    82  	result, err = client.CreateOrUpdateSender(req)
    83  	if err != nil {
    84  		err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "CreateOrUpdate", result.Response(), "Failure sending request")
    85  		return
    86  	}
    87  
    88  	return
    89  }
    90  
    91  // CreateOrUpdatePreparer prepares the CreateOrUpdate request.
    92  func (client ApplicationsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, applicationName string, parameters Application) (*http.Request, error) {
    93  	pathParameters := map[string]interface{}{
    94  		"applicationName":   autorest.Encode("path", applicationName),
    95  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
    96  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
    97  	}
    98  
    99  	const APIVersion = "2018-02-01"
   100  	queryParameters := map[string]interface{}{
   101  		"api-version": APIVersion,
   102  	}
   103  
   104  	preparer := autorest.CreatePreparer(
   105  		autorest.AsContentType("application/json; charset=utf-8"),
   106  		autorest.AsPut(),
   107  		autorest.WithBaseURL(client.BaseURI),
   108  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}", pathParameters),
   109  		autorest.WithJSON(parameters),
   110  		autorest.WithQueryParameters(queryParameters))
   111  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   112  }
   113  
   114  // CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
   115  // http.Response Body if it receives an error.
   116  func (client ApplicationsClient) CreateOrUpdateSender(req *http.Request) (future ApplicationsCreateOrUpdateFuture, err error) {
   117  	var resp *http.Response
   118  	future.FutureAPI = &azure.Future{}
   119  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   120  	if err != nil {
   121  		return
   122  	}
   123  	var azf azure.Future
   124  	azf, err = azure.NewFutureFromResponse(resp)
   125  	future.FutureAPI = &azf
   126  	future.Result = future.result
   127  	return
   128  }
   129  
   130  // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
   131  // closes the http.Response Body.
   132  func (client ApplicationsClient) CreateOrUpdateResponder(resp *http.Response) (result Application, err error) {
   133  	err = autorest.Respond(
   134  		resp,
   135  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
   136  		autorest.ByUnmarshallingJSON(&result),
   137  		autorest.ByClosing())
   138  	result.Response = autorest.Response{Response: resp}
   139  	return
   140  }
   141  
   142  // CreateOrUpdateByID creates or updates a managed application.
   143  // Parameters:
   144  // applicationID - the fully qualified ID of the managed application, including the managed application name
   145  // and the managed application resource type. Use the format,
   146  // /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}
   147  // parameters - parameters supplied to the create or update a managed application.
   148  func (client ApplicationsClient) CreateOrUpdateByID(ctx context.Context, applicationID string, parameters Application) (result ApplicationsCreateOrUpdateByIDFuture, err error) {
   149  	if tracing.IsEnabled() {
   150  		ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationsClient.CreateOrUpdateByID")
   151  		defer func() {
   152  			sc := -1
   153  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   154  				sc = result.FutureAPI.Response().StatusCode
   155  			}
   156  			tracing.EndSpan(ctx, sc, err)
   157  		}()
   158  	}
   159  	if err := validation.Validate([]validation.Validation{
   160  		{TargetValue: parameters,
   161  			Constraints: []validation.Constraint{{Target: "parameters.ApplicationProperties", Name: validation.Null, Rule: true,
   162  				Chain: []validation.Constraint{{Target: "parameters.ApplicationProperties.CustomerSupport", Name: validation.Null, Rule: false,
   163  					Chain: []validation.Constraint{{Target: "parameters.ApplicationProperties.CustomerSupport.Email", Name: validation.Null, Rule: true, Chain: nil},
   164  						{Target: "parameters.ApplicationProperties.CustomerSupport.Phone", Name: validation.Null, Rule: true, Chain: nil},
   165  					}},
   166  				}},
   167  				{Target: "parameters.Plan", Name: validation.Null, Rule: false,
   168  					Chain: []validation.Constraint{{Target: "parameters.Plan.Name", Name: validation.Null, Rule: true, Chain: nil},
   169  						{Target: "parameters.Plan.Publisher", Name: validation.Null, Rule: true, Chain: nil},
   170  						{Target: "parameters.Plan.Product", Name: validation.Null, Rule: true, Chain: nil},
   171  						{Target: "parameters.Plan.Version", Name: validation.Null, Rule: true, Chain: nil},
   172  					}},
   173  				{Target: "parameters.Kind", Name: validation.Null, Rule: true,
   174  					Chain: []validation.Constraint{{Target: "parameters.Kind", Name: validation.Pattern, Rule: `^[-\w\._,\(\)]+$`, Chain: nil}}}}}}); err != nil {
   175  		return result, validation.NewError("managedapplications.ApplicationsClient", "CreateOrUpdateByID", err.Error())
   176  	}
   177  
   178  	req, err := client.CreateOrUpdateByIDPreparer(ctx, applicationID, parameters)
   179  	if err != nil {
   180  		err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "CreateOrUpdateByID", nil, "Failure preparing request")
   181  		return
   182  	}
   183  
   184  	result, err = client.CreateOrUpdateByIDSender(req)
   185  	if err != nil {
   186  		err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "CreateOrUpdateByID", result.Response(), "Failure sending request")
   187  		return
   188  	}
   189  
   190  	return
   191  }
   192  
   193  // CreateOrUpdateByIDPreparer prepares the CreateOrUpdateByID request.
   194  func (client ApplicationsClient) CreateOrUpdateByIDPreparer(ctx context.Context, applicationID string, parameters Application) (*http.Request, error) {
   195  	pathParameters := map[string]interface{}{
   196  		"applicationId": applicationID,
   197  	}
   198  
   199  	const APIVersion = "2018-02-01"
   200  	queryParameters := map[string]interface{}{
   201  		"api-version": APIVersion,
   202  	}
   203  
   204  	preparer := autorest.CreatePreparer(
   205  		autorest.AsContentType("application/json; charset=utf-8"),
   206  		autorest.AsPut(),
   207  		autorest.WithBaseURL(client.BaseURI),
   208  		autorest.WithPathParameters("/{applicationId}", pathParameters),
   209  		autorest.WithJSON(parameters),
   210  		autorest.WithQueryParameters(queryParameters))
   211  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   212  }
   213  
   214  // CreateOrUpdateByIDSender sends the CreateOrUpdateByID request. The method will close the
   215  // http.Response Body if it receives an error.
   216  func (client ApplicationsClient) CreateOrUpdateByIDSender(req *http.Request) (future ApplicationsCreateOrUpdateByIDFuture, err error) {
   217  	var resp *http.Response
   218  	future.FutureAPI = &azure.Future{}
   219  	resp, err = client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   220  	if err != nil {
   221  		return
   222  	}
   223  	var azf azure.Future
   224  	azf, err = azure.NewFutureFromResponse(resp)
   225  	future.FutureAPI = &azf
   226  	future.Result = future.result
   227  	return
   228  }
   229  
   230  // CreateOrUpdateByIDResponder handles the response to the CreateOrUpdateByID request. The method always
   231  // closes the http.Response Body.
   232  func (client ApplicationsClient) CreateOrUpdateByIDResponder(resp *http.Response) (result Application, err error) {
   233  	err = autorest.Respond(
   234  		resp,
   235  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
   236  		autorest.ByUnmarshallingJSON(&result),
   237  		autorest.ByClosing())
   238  	result.Response = autorest.Response{Response: resp}
   239  	return
   240  }
   241  
   242  // Delete deletes the managed application.
   243  // Parameters:
   244  // resourceGroupName - the name of the resource group. The name is case insensitive.
   245  // applicationName - the name of the managed application.
   246  func (client ApplicationsClient) Delete(ctx context.Context, resourceGroupName string, applicationName string) (result ApplicationsDeleteFuture, err error) {
   247  	if tracing.IsEnabled() {
   248  		ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationsClient.Delete")
   249  		defer func() {
   250  			sc := -1
   251  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   252  				sc = result.FutureAPI.Response().StatusCode
   253  			}
   254  			tracing.EndSpan(ctx, sc, err)
   255  		}()
   256  	}
   257  	if err := validation.Validate([]validation.Validation{
   258  		{TargetValue: resourceGroupName,
   259  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
   260  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
   261  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
   262  		{TargetValue: applicationName,
   263  			Constraints: []validation.Constraint{{Target: "applicationName", Name: validation.MaxLength, Rule: 64, Chain: nil},
   264  				{Target: "applicationName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil {
   265  		return result, validation.NewError("managedapplications.ApplicationsClient", "Delete", err.Error())
   266  	}
   267  
   268  	req, err := client.DeletePreparer(ctx, resourceGroupName, applicationName)
   269  	if err != nil {
   270  		err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "Delete", nil, "Failure preparing request")
   271  		return
   272  	}
   273  
   274  	result, err = client.DeleteSender(req)
   275  	if err != nil {
   276  		err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "Delete", result.Response(), "Failure sending request")
   277  		return
   278  	}
   279  
   280  	return
   281  }
   282  
   283  // DeletePreparer prepares the Delete request.
   284  func (client ApplicationsClient) DeletePreparer(ctx context.Context, resourceGroupName string, applicationName string) (*http.Request, error) {
   285  	pathParameters := map[string]interface{}{
   286  		"applicationName":   autorest.Encode("path", applicationName),
   287  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   288  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   289  	}
   290  
   291  	const APIVersion = "2018-02-01"
   292  	queryParameters := map[string]interface{}{
   293  		"api-version": APIVersion,
   294  	}
   295  
   296  	preparer := autorest.CreatePreparer(
   297  		autorest.AsDelete(),
   298  		autorest.WithBaseURL(client.BaseURI),
   299  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}", pathParameters),
   300  		autorest.WithQueryParameters(queryParameters))
   301  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   302  }
   303  
   304  // DeleteSender sends the Delete request. The method will close the
   305  // http.Response Body if it receives an error.
   306  func (client ApplicationsClient) DeleteSender(req *http.Request) (future ApplicationsDeleteFuture, err error) {
   307  	var resp *http.Response
   308  	future.FutureAPI = &azure.Future{}
   309  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   310  	if err != nil {
   311  		return
   312  	}
   313  	var azf azure.Future
   314  	azf, err = azure.NewFutureFromResponse(resp)
   315  	future.FutureAPI = &azf
   316  	future.Result = future.result
   317  	return
   318  }
   319  
   320  // DeleteResponder handles the response to the Delete request. The method always
   321  // closes the http.Response Body.
   322  func (client ApplicationsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
   323  	err = autorest.Respond(
   324  		resp,
   325  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
   326  		autorest.ByClosing())
   327  	result.Response = resp
   328  	return
   329  }
   330  
   331  // DeleteByID deletes the managed application.
   332  // Parameters:
   333  // applicationID - the fully qualified ID of the managed application, including the managed application name
   334  // and the managed application resource type. Use the format,
   335  // /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}
   336  func (client ApplicationsClient) DeleteByID(ctx context.Context, applicationID string) (result ApplicationsDeleteByIDFuture, err error) {
   337  	if tracing.IsEnabled() {
   338  		ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationsClient.DeleteByID")
   339  		defer func() {
   340  			sc := -1
   341  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   342  				sc = result.FutureAPI.Response().StatusCode
   343  			}
   344  			tracing.EndSpan(ctx, sc, err)
   345  		}()
   346  	}
   347  	req, err := client.DeleteByIDPreparer(ctx, applicationID)
   348  	if err != nil {
   349  		err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "DeleteByID", nil, "Failure preparing request")
   350  		return
   351  	}
   352  
   353  	result, err = client.DeleteByIDSender(req)
   354  	if err != nil {
   355  		err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "DeleteByID", result.Response(), "Failure sending request")
   356  		return
   357  	}
   358  
   359  	return
   360  }
   361  
   362  // DeleteByIDPreparer prepares the DeleteByID request.
   363  func (client ApplicationsClient) DeleteByIDPreparer(ctx context.Context, applicationID string) (*http.Request, error) {
   364  	pathParameters := map[string]interface{}{
   365  		"applicationId": applicationID,
   366  	}
   367  
   368  	const APIVersion = "2018-02-01"
   369  	queryParameters := map[string]interface{}{
   370  		"api-version": APIVersion,
   371  	}
   372  
   373  	preparer := autorest.CreatePreparer(
   374  		autorest.AsDelete(),
   375  		autorest.WithBaseURL(client.BaseURI),
   376  		autorest.WithPathParameters("/{applicationId}", pathParameters),
   377  		autorest.WithQueryParameters(queryParameters))
   378  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   379  }
   380  
   381  // DeleteByIDSender sends the DeleteByID request. The method will close the
   382  // http.Response Body if it receives an error.
   383  func (client ApplicationsClient) DeleteByIDSender(req *http.Request) (future ApplicationsDeleteByIDFuture, err error) {
   384  	var resp *http.Response
   385  	future.FutureAPI = &azure.Future{}
   386  	resp, err = client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   387  	if err != nil {
   388  		return
   389  	}
   390  	var azf azure.Future
   391  	azf, err = azure.NewFutureFromResponse(resp)
   392  	future.FutureAPI = &azf
   393  	future.Result = future.result
   394  	return
   395  }
   396  
   397  // DeleteByIDResponder handles the response to the DeleteByID request. The method always
   398  // closes the http.Response Body.
   399  func (client ApplicationsClient) DeleteByIDResponder(resp *http.Response) (result autorest.Response, err error) {
   400  	err = autorest.Respond(
   401  		resp,
   402  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
   403  		autorest.ByClosing())
   404  	result.Response = resp
   405  	return
   406  }
   407  
   408  // Get gets the managed application.
   409  // Parameters:
   410  // resourceGroupName - the name of the resource group. The name is case insensitive.
   411  // applicationName - the name of the managed application.
   412  func (client ApplicationsClient) Get(ctx context.Context, resourceGroupName string, applicationName string) (result Application, err error) {
   413  	if tracing.IsEnabled() {
   414  		ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationsClient.Get")
   415  		defer func() {
   416  			sc := -1
   417  			if result.Response.Response != nil {
   418  				sc = result.Response.Response.StatusCode
   419  			}
   420  			tracing.EndSpan(ctx, sc, err)
   421  		}()
   422  	}
   423  	if err := validation.Validate([]validation.Validation{
   424  		{TargetValue: resourceGroupName,
   425  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
   426  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
   427  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
   428  		{TargetValue: applicationName,
   429  			Constraints: []validation.Constraint{{Target: "applicationName", Name: validation.MaxLength, Rule: 64, Chain: nil},
   430  				{Target: "applicationName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil {
   431  		return result, validation.NewError("managedapplications.ApplicationsClient", "Get", err.Error())
   432  	}
   433  
   434  	req, err := client.GetPreparer(ctx, resourceGroupName, applicationName)
   435  	if err != nil {
   436  		err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "Get", nil, "Failure preparing request")
   437  		return
   438  	}
   439  
   440  	resp, err := client.GetSender(req)
   441  	if err != nil {
   442  		result.Response = autorest.Response{Response: resp}
   443  		err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "Get", resp, "Failure sending request")
   444  		return
   445  	}
   446  
   447  	result, err = client.GetResponder(resp)
   448  	if err != nil {
   449  		err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "Get", resp, "Failure responding to request")
   450  		return
   451  	}
   452  
   453  	return
   454  }
   455  
   456  // GetPreparer prepares the Get request.
   457  func (client ApplicationsClient) GetPreparer(ctx context.Context, resourceGroupName string, applicationName string) (*http.Request, error) {
   458  	pathParameters := map[string]interface{}{
   459  		"applicationName":   autorest.Encode("path", applicationName),
   460  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   461  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   462  	}
   463  
   464  	const APIVersion = "2018-02-01"
   465  	queryParameters := map[string]interface{}{
   466  		"api-version": APIVersion,
   467  	}
   468  
   469  	preparer := autorest.CreatePreparer(
   470  		autorest.AsGet(),
   471  		autorest.WithBaseURL(client.BaseURI),
   472  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}", pathParameters),
   473  		autorest.WithQueryParameters(queryParameters))
   474  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   475  }
   476  
   477  // GetSender sends the Get request. The method will close the
   478  // http.Response Body if it receives an error.
   479  func (client ApplicationsClient) GetSender(req *http.Request) (*http.Response, error) {
   480  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   481  }
   482  
   483  // GetResponder handles the response to the Get request. The method always
   484  // closes the http.Response Body.
   485  func (client ApplicationsClient) GetResponder(resp *http.Response) (result Application, err error) {
   486  	err = autorest.Respond(
   487  		resp,
   488  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNotFound),
   489  		autorest.ByUnmarshallingJSON(&result),
   490  		autorest.ByClosing())
   491  	result.Response = autorest.Response{Response: resp}
   492  	return
   493  }
   494  
   495  // GetByID gets the managed application.
   496  // Parameters:
   497  // applicationID - the fully qualified ID of the managed application, including the managed application name
   498  // and the managed application resource type. Use the format,
   499  // /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}
   500  func (client ApplicationsClient) GetByID(ctx context.Context, applicationID string) (result Application, err error) {
   501  	if tracing.IsEnabled() {
   502  		ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationsClient.GetByID")
   503  		defer func() {
   504  			sc := -1
   505  			if result.Response.Response != nil {
   506  				sc = result.Response.Response.StatusCode
   507  			}
   508  			tracing.EndSpan(ctx, sc, err)
   509  		}()
   510  	}
   511  	req, err := client.GetByIDPreparer(ctx, applicationID)
   512  	if err != nil {
   513  		err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "GetByID", nil, "Failure preparing request")
   514  		return
   515  	}
   516  
   517  	resp, err := client.GetByIDSender(req)
   518  	if err != nil {
   519  		result.Response = autorest.Response{Response: resp}
   520  		err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "GetByID", resp, "Failure sending request")
   521  		return
   522  	}
   523  
   524  	result, err = client.GetByIDResponder(resp)
   525  	if err != nil {
   526  		err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "GetByID", resp, "Failure responding to request")
   527  		return
   528  	}
   529  
   530  	return
   531  }
   532  
   533  // GetByIDPreparer prepares the GetByID request.
   534  func (client ApplicationsClient) GetByIDPreparer(ctx context.Context, applicationID string) (*http.Request, error) {
   535  	pathParameters := map[string]interface{}{
   536  		"applicationId": applicationID,
   537  	}
   538  
   539  	const APIVersion = "2018-02-01"
   540  	queryParameters := map[string]interface{}{
   541  		"api-version": APIVersion,
   542  	}
   543  
   544  	preparer := autorest.CreatePreparer(
   545  		autorest.AsGet(),
   546  		autorest.WithBaseURL(client.BaseURI),
   547  		autorest.WithPathParameters("/{applicationId}", pathParameters),
   548  		autorest.WithQueryParameters(queryParameters))
   549  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   550  }
   551  
   552  // GetByIDSender sends the GetByID request. The method will close the
   553  // http.Response Body if it receives an error.
   554  func (client ApplicationsClient) GetByIDSender(req *http.Request) (*http.Response, error) {
   555  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   556  }
   557  
   558  // GetByIDResponder handles the response to the GetByID request. The method always
   559  // closes the http.Response Body.
   560  func (client ApplicationsClient) GetByIDResponder(resp *http.Response) (result Application, err error) {
   561  	err = autorest.Respond(
   562  		resp,
   563  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNotFound),
   564  		autorest.ByUnmarshallingJSON(&result),
   565  		autorest.ByClosing())
   566  	result.Response = autorest.Response{Response: resp}
   567  	return
   568  }
   569  
   570  // ListByResourceGroup lists all the applications within a resource group.
   571  // Parameters:
   572  // resourceGroupName - the name of the resource group. The name is case insensitive.
   573  func (client ApplicationsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result ApplicationListResultPage, err error) {
   574  	if tracing.IsEnabled() {
   575  		ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationsClient.ListByResourceGroup")
   576  		defer func() {
   577  			sc := -1
   578  			if result.alr.Response.Response != nil {
   579  				sc = result.alr.Response.Response.StatusCode
   580  			}
   581  			tracing.EndSpan(ctx, sc, err)
   582  		}()
   583  	}
   584  	if err := validation.Validate([]validation.Validation{
   585  		{TargetValue: resourceGroupName,
   586  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
   587  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
   588  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil {
   589  		return result, validation.NewError("managedapplications.ApplicationsClient", "ListByResourceGroup", err.Error())
   590  	}
   591  
   592  	result.fn = client.listByResourceGroupNextResults
   593  	req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName)
   594  	if err != nil {
   595  		err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "ListByResourceGroup", nil, "Failure preparing request")
   596  		return
   597  	}
   598  
   599  	resp, err := client.ListByResourceGroupSender(req)
   600  	if err != nil {
   601  		result.alr.Response = autorest.Response{Response: resp}
   602  		err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "ListByResourceGroup", resp, "Failure sending request")
   603  		return
   604  	}
   605  
   606  	result.alr, err = client.ListByResourceGroupResponder(resp)
   607  	if err != nil {
   608  		err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "ListByResourceGroup", resp, "Failure responding to request")
   609  		return
   610  	}
   611  	if result.alr.hasNextLink() && result.alr.IsEmpty() {
   612  		err = result.NextWithContext(ctx)
   613  		return
   614  	}
   615  
   616  	return
   617  }
   618  
   619  // ListByResourceGroupPreparer prepares the ListByResourceGroup request.
   620  func (client ApplicationsClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) {
   621  	pathParameters := map[string]interface{}{
   622  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   623  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   624  	}
   625  
   626  	const APIVersion = "2018-02-01"
   627  	queryParameters := map[string]interface{}{
   628  		"api-version": APIVersion,
   629  	}
   630  
   631  	preparer := autorest.CreatePreparer(
   632  		autorest.AsGet(),
   633  		autorest.WithBaseURL(client.BaseURI),
   634  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications", pathParameters),
   635  		autorest.WithQueryParameters(queryParameters))
   636  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   637  }
   638  
   639  // ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the
   640  // http.Response Body if it receives an error.
   641  func (client ApplicationsClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) {
   642  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   643  }
   644  
   645  // ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always
   646  // closes the http.Response Body.
   647  func (client ApplicationsClient) ListByResourceGroupResponder(resp *http.Response) (result ApplicationListResult, err error) {
   648  	err = autorest.Respond(
   649  		resp,
   650  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   651  		autorest.ByUnmarshallingJSON(&result),
   652  		autorest.ByClosing())
   653  	result.Response = autorest.Response{Response: resp}
   654  	return
   655  }
   656  
   657  // listByResourceGroupNextResults retrieves the next set of results, if any.
   658  func (client ApplicationsClient) listByResourceGroupNextResults(ctx context.Context, lastResults ApplicationListResult) (result ApplicationListResult, err error) {
   659  	req, err := lastResults.applicationListResultPreparer(ctx)
   660  	if err != nil {
   661  		return result, autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request")
   662  	}
   663  	if req == nil {
   664  		return
   665  	}
   666  	resp, err := client.ListByResourceGroupSender(req)
   667  	if err != nil {
   668  		result.Response = autorest.Response{Response: resp}
   669  		return result, autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "listByResourceGroupNextResults", resp, "Failure sending next results request")
   670  	}
   671  	result, err = client.ListByResourceGroupResponder(resp)
   672  	if err != nil {
   673  		err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request")
   674  	}
   675  	return
   676  }
   677  
   678  // ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required.
   679  func (client ApplicationsClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result ApplicationListResultIterator, err error) {
   680  	if tracing.IsEnabled() {
   681  		ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationsClient.ListByResourceGroup")
   682  		defer func() {
   683  			sc := -1
   684  			if result.Response().Response.Response != nil {
   685  				sc = result.page.Response().Response.Response.StatusCode
   686  			}
   687  			tracing.EndSpan(ctx, sc, err)
   688  		}()
   689  	}
   690  	result.page, err = client.ListByResourceGroup(ctx, resourceGroupName)
   691  	return
   692  }
   693  
   694  // ListBySubscription lists all the applications within a subscription.
   695  func (client ApplicationsClient) ListBySubscription(ctx context.Context) (result ApplicationListResultPage, err error) {
   696  	if tracing.IsEnabled() {
   697  		ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationsClient.ListBySubscription")
   698  		defer func() {
   699  			sc := -1
   700  			if result.alr.Response.Response != nil {
   701  				sc = result.alr.Response.Response.StatusCode
   702  			}
   703  			tracing.EndSpan(ctx, sc, err)
   704  		}()
   705  	}
   706  	result.fn = client.listBySubscriptionNextResults
   707  	req, err := client.ListBySubscriptionPreparer(ctx)
   708  	if err != nil {
   709  		err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "ListBySubscription", nil, "Failure preparing request")
   710  		return
   711  	}
   712  
   713  	resp, err := client.ListBySubscriptionSender(req)
   714  	if err != nil {
   715  		result.alr.Response = autorest.Response{Response: resp}
   716  		err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "ListBySubscription", resp, "Failure sending request")
   717  		return
   718  	}
   719  
   720  	result.alr, err = client.ListBySubscriptionResponder(resp)
   721  	if err != nil {
   722  		err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "ListBySubscription", resp, "Failure responding to request")
   723  		return
   724  	}
   725  	if result.alr.hasNextLink() && result.alr.IsEmpty() {
   726  		err = result.NextWithContext(ctx)
   727  		return
   728  	}
   729  
   730  	return
   731  }
   732  
   733  // ListBySubscriptionPreparer prepares the ListBySubscription request.
   734  func (client ApplicationsClient) ListBySubscriptionPreparer(ctx context.Context) (*http.Request, error) {
   735  	pathParameters := map[string]interface{}{
   736  		"subscriptionId": autorest.Encode("path", client.SubscriptionID),
   737  	}
   738  
   739  	const APIVersion = "2018-02-01"
   740  	queryParameters := map[string]interface{}{
   741  		"api-version": APIVersion,
   742  	}
   743  
   744  	preparer := autorest.CreatePreparer(
   745  		autorest.AsGet(),
   746  		autorest.WithBaseURL(client.BaseURI),
   747  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applications", pathParameters),
   748  		autorest.WithQueryParameters(queryParameters))
   749  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   750  }
   751  
   752  // ListBySubscriptionSender sends the ListBySubscription request. The method will close the
   753  // http.Response Body if it receives an error.
   754  func (client ApplicationsClient) ListBySubscriptionSender(req *http.Request) (*http.Response, error) {
   755  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   756  }
   757  
   758  // ListBySubscriptionResponder handles the response to the ListBySubscription request. The method always
   759  // closes the http.Response Body.
   760  func (client ApplicationsClient) ListBySubscriptionResponder(resp *http.Response) (result ApplicationListResult, err error) {
   761  	err = autorest.Respond(
   762  		resp,
   763  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   764  		autorest.ByUnmarshallingJSON(&result),
   765  		autorest.ByClosing())
   766  	result.Response = autorest.Response{Response: resp}
   767  	return
   768  }
   769  
   770  // listBySubscriptionNextResults retrieves the next set of results, if any.
   771  func (client ApplicationsClient) listBySubscriptionNextResults(ctx context.Context, lastResults ApplicationListResult) (result ApplicationListResult, err error) {
   772  	req, err := lastResults.applicationListResultPreparer(ctx)
   773  	if err != nil {
   774  		return result, autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "listBySubscriptionNextResults", nil, "Failure preparing next results request")
   775  	}
   776  	if req == nil {
   777  		return
   778  	}
   779  	resp, err := client.ListBySubscriptionSender(req)
   780  	if err != nil {
   781  		result.Response = autorest.Response{Response: resp}
   782  		return result, autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "listBySubscriptionNextResults", resp, "Failure sending next results request")
   783  	}
   784  	result, err = client.ListBySubscriptionResponder(resp)
   785  	if err != nil {
   786  		err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "listBySubscriptionNextResults", resp, "Failure responding to next results request")
   787  	}
   788  	return
   789  }
   790  
   791  // ListBySubscriptionComplete enumerates all values, automatically crossing page boundaries as required.
   792  func (client ApplicationsClient) ListBySubscriptionComplete(ctx context.Context) (result ApplicationListResultIterator, err error) {
   793  	if tracing.IsEnabled() {
   794  		ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationsClient.ListBySubscription")
   795  		defer func() {
   796  			sc := -1
   797  			if result.Response().Response.Response != nil {
   798  				sc = result.page.Response().Response.Response.StatusCode
   799  			}
   800  			tracing.EndSpan(ctx, sc, err)
   801  		}()
   802  	}
   803  	result.page, err = client.ListBySubscription(ctx)
   804  	return
   805  }
   806  
   807  // RefreshPermissions refresh Permissions for application.
   808  // Parameters:
   809  // resourceGroupName - the name of the resource group. The name is case insensitive.
   810  // applicationName - the name of the managed application.
   811  func (client ApplicationsClient) RefreshPermissions(ctx context.Context, resourceGroupName string, applicationName string) (result ApplicationsRefreshPermissionsFuture, err error) {
   812  	if tracing.IsEnabled() {
   813  		ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationsClient.RefreshPermissions")
   814  		defer func() {
   815  			sc := -1
   816  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   817  				sc = result.FutureAPI.Response().StatusCode
   818  			}
   819  			tracing.EndSpan(ctx, sc, err)
   820  		}()
   821  	}
   822  	if err := validation.Validate([]validation.Validation{
   823  		{TargetValue: resourceGroupName,
   824  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
   825  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
   826  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
   827  		{TargetValue: applicationName,
   828  			Constraints: []validation.Constraint{{Target: "applicationName", Name: validation.MaxLength, Rule: 64, Chain: nil},
   829  				{Target: "applicationName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil {
   830  		return result, validation.NewError("managedapplications.ApplicationsClient", "RefreshPermissions", err.Error())
   831  	}
   832  
   833  	req, err := client.RefreshPermissionsPreparer(ctx, resourceGroupName, applicationName)
   834  	if err != nil {
   835  		err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "RefreshPermissions", nil, "Failure preparing request")
   836  		return
   837  	}
   838  
   839  	result, err = client.RefreshPermissionsSender(req)
   840  	if err != nil {
   841  		err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "RefreshPermissions", result.Response(), "Failure sending request")
   842  		return
   843  	}
   844  
   845  	return
   846  }
   847  
   848  // RefreshPermissionsPreparer prepares the RefreshPermissions request.
   849  func (client ApplicationsClient) RefreshPermissionsPreparer(ctx context.Context, resourceGroupName string, applicationName string) (*http.Request, error) {
   850  	pathParameters := map[string]interface{}{
   851  		"applicationName":   autorest.Encode("path", applicationName),
   852  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   853  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   854  	}
   855  
   856  	const APIVersion = "2018-02-01"
   857  	queryParameters := map[string]interface{}{
   858  		"api-version": APIVersion,
   859  	}
   860  
   861  	preparer := autorest.CreatePreparer(
   862  		autorest.AsPost(),
   863  		autorest.WithBaseURL(client.BaseURI),
   864  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/refreshPermissions", pathParameters),
   865  		autorest.WithQueryParameters(queryParameters))
   866  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   867  }
   868  
   869  // RefreshPermissionsSender sends the RefreshPermissions request. The method will close the
   870  // http.Response Body if it receives an error.
   871  func (client ApplicationsClient) RefreshPermissionsSender(req *http.Request) (future ApplicationsRefreshPermissionsFuture, err error) {
   872  	var resp *http.Response
   873  	future.FutureAPI = &azure.Future{}
   874  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   875  	if err != nil {
   876  		return
   877  	}
   878  	var azf azure.Future
   879  	azf, err = azure.NewFutureFromResponse(resp)
   880  	future.FutureAPI = &azf
   881  	future.Result = future.result
   882  	return
   883  }
   884  
   885  // RefreshPermissionsResponder handles the response to the RefreshPermissions request. The method always
   886  // closes the http.Response Body.
   887  func (client ApplicationsClient) RefreshPermissionsResponder(resp *http.Response) (result autorest.Response, err error) {
   888  	err = autorest.Respond(
   889  		resp,
   890  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
   891  		autorest.ByClosing())
   892  	result.Response = resp
   893  	return
   894  }
   895  
   896  // Update updates an existing managed application.
   897  // Parameters:
   898  // resourceGroupName - the name of the resource group. The name is case insensitive.
   899  // applicationName - the name of the managed application.
   900  // parameters - parameters supplied to update an existing managed application.
   901  func (client ApplicationsClient) Update(ctx context.Context, resourceGroupName string, applicationName string, parameters *ApplicationPatchable) (result ApplicationsUpdateFuture, err error) {
   902  	if tracing.IsEnabled() {
   903  		ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationsClient.Update")
   904  		defer func() {
   905  			sc := -1
   906  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   907  				sc = result.FutureAPI.Response().StatusCode
   908  			}
   909  			tracing.EndSpan(ctx, sc, err)
   910  		}()
   911  	}
   912  	if err := validation.Validate([]validation.Validation{
   913  		{TargetValue: resourceGroupName,
   914  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
   915  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
   916  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
   917  		{TargetValue: applicationName,
   918  			Constraints: []validation.Constraint{{Target: "applicationName", Name: validation.MaxLength, Rule: 64, Chain: nil},
   919  				{Target: "applicationName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil {
   920  		return result, validation.NewError("managedapplications.ApplicationsClient", "Update", err.Error())
   921  	}
   922  
   923  	req, err := client.UpdatePreparer(ctx, resourceGroupName, applicationName, parameters)
   924  	if err != nil {
   925  		err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "Update", nil, "Failure preparing request")
   926  		return
   927  	}
   928  
   929  	result, err = client.UpdateSender(req)
   930  	if err != nil {
   931  		err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "Update", result.Response(), "Failure sending request")
   932  		return
   933  	}
   934  
   935  	return
   936  }
   937  
   938  // UpdatePreparer prepares the Update request.
   939  func (client ApplicationsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, applicationName string, parameters *ApplicationPatchable) (*http.Request, error) {
   940  	pathParameters := map[string]interface{}{
   941  		"applicationName":   autorest.Encode("path", applicationName),
   942  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   943  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   944  	}
   945  
   946  	const APIVersion = "2018-02-01"
   947  	queryParameters := map[string]interface{}{
   948  		"api-version": APIVersion,
   949  	}
   950  
   951  	preparer := autorest.CreatePreparer(
   952  		autorest.AsContentType("application/json; charset=utf-8"),
   953  		autorest.AsPatch(),
   954  		autorest.WithBaseURL(client.BaseURI),
   955  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}", pathParameters),
   956  		autorest.WithQueryParameters(queryParameters))
   957  	if parameters != nil {
   958  		preparer = autorest.DecoratePreparer(preparer,
   959  			autorest.WithJSON(parameters))
   960  	}
   961  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   962  }
   963  
   964  // UpdateSender sends the Update request. The method will close the
   965  // http.Response Body if it receives an error.
   966  func (client ApplicationsClient) UpdateSender(req *http.Request) (future ApplicationsUpdateFuture, err error) {
   967  	var resp *http.Response
   968  	future.FutureAPI = &azure.Future{}
   969  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   970  	if err != nil {
   971  		return
   972  	}
   973  	var azf azure.Future
   974  	azf, err = azure.NewFutureFromResponse(resp)
   975  	future.FutureAPI = &azf
   976  	future.Result = future.result
   977  	return
   978  }
   979  
   980  // UpdateResponder handles the response to the Update request. The method always
   981  // closes the http.Response Body.
   982  func (client ApplicationsClient) UpdateResponder(resp *http.Response) (result ApplicationPatchable, err error) {
   983  	err = autorest.Respond(
   984  		resp,
   985  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
   986  		autorest.ByUnmarshallingJSON(&result),
   987  		autorest.ByClosing())
   988  	result.Response = autorest.Response{Response: resp}
   989  	return
   990  }
   991  
   992  // UpdateByID updates an existing managed application.
   993  // Parameters:
   994  // applicationID - the fully qualified ID of the managed application, including the managed application name
   995  // and the managed application resource type. Use the format,
   996  // /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}
   997  // parameters - parameters supplied to update an existing managed application.
   998  func (client ApplicationsClient) UpdateByID(ctx context.Context, applicationID string, parameters *ApplicationPatchable) (result ApplicationsUpdateByIDFuture, err error) {
   999  	if tracing.IsEnabled() {
  1000  		ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationsClient.UpdateByID")
  1001  		defer func() {
  1002  			sc := -1
  1003  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
  1004  				sc = result.FutureAPI.Response().StatusCode
  1005  			}
  1006  			tracing.EndSpan(ctx, sc, err)
  1007  		}()
  1008  	}
  1009  	req, err := client.UpdateByIDPreparer(ctx, applicationID, parameters)
  1010  	if err != nil {
  1011  		err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "UpdateByID", nil, "Failure preparing request")
  1012  		return
  1013  	}
  1014  
  1015  	result, err = client.UpdateByIDSender(req)
  1016  	if err != nil {
  1017  		err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "UpdateByID", result.Response(), "Failure sending request")
  1018  		return
  1019  	}
  1020  
  1021  	return
  1022  }
  1023  
  1024  // UpdateByIDPreparer prepares the UpdateByID request.
  1025  func (client ApplicationsClient) UpdateByIDPreparer(ctx context.Context, applicationID string, parameters *ApplicationPatchable) (*http.Request, error) {
  1026  	pathParameters := map[string]interface{}{
  1027  		"applicationId": applicationID,
  1028  	}
  1029  
  1030  	const APIVersion = "2018-02-01"
  1031  	queryParameters := map[string]interface{}{
  1032  		"api-version": APIVersion,
  1033  	}
  1034  
  1035  	preparer := autorest.CreatePreparer(
  1036  		autorest.AsContentType("application/json; charset=utf-8"),
  1037  		autorest.AsPatch(),
  1038  		autorest.WithBaseURL(client.BaseURI),
  1039  		autorest.WithPathParameters("/{applicationId}", pathParameters),
  1040  		autorest.WithQueryParameters(queryParameters))
  1041  	if parameters != nil {
  1042  		preparer = autorest.DecoratePreparer(preparer,
  1043  			autorest.WithJSON(parameters))
  1044  	}
  1045  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
  1046  }
  1047  
  1048  // UpdateByIDSender sends the UpdateByID request. The method will close the
  1049  // http.Response Body if it receives an error.
  1050  func (client ApplicationsClient) UpdateByIDSender(req *http.Request) (future ApplicationsUpdateByIDFuture, err error) {
  1051  	var resp *http.Response
  1052  	future.FutureAPI = &azure.Future{}
  1053  	resp, err = client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
  1054  	if err != nil {
  1055  		return
  1056  	}
  1057  	var azf azure.Future
  1058  	azf, err = azure.NewFutureFromResponse(resp)
  1059  	future.FutureAPI = &azf
  1060  	future.Result = future.result
  1061  	return
  1062  }
  1063  
  1064  // UpdateByIDResponder handles the response to the UpdateByID request. The method always
  1065  // closes the http.Response Body.
  1066  func (client ApplicationsClient) UpdateByIDResponder(resp *http.Response) (result ApplicationPatchable, err error) {
  1067  	err = autorest.Respond(
  1068  		resp,
  1069  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
  1070  		autorest.ByUnmarshallingJSON(&result),
  1071  		autorest.ByClosing())
  1072  	result.Response = autorest.Response{Response: resp}
  1073  	return
  1074  }
  1075  

View as plain text