...

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

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

View as plain text