...

Source file src/github.com/Azure/azure-sdk-for-go/services/preview/solutions/mgmt/2018-09-01-preview/managedapplications/applicationdefinitions.go

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

View as plain text