...

Source file src/github.com/Azure/azure-sdk-for-go/services/solutions/mgmt/2019-07-01/managedapplications/applicationdefinitions.go

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

View as plain text