...

Source file src/github.com/Azure/azure-sdk-for-go/services/preview/solutions/mgmt/2020-08-21-preview/managedapplications/applications.go

Documentation: github.com/Azure/azure-sdk-for-go/services/preview/solutions/mgmt/2020-08-21-preview/managedapplications

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

View as plain text