...

Source file src/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2018-06-01/managedapplications/applicationdefinitions.go

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

     1  package managedapplications
     2  
     3  // Copyright (c) Microsoft Corporation. All rights reserved.
     4  // Licensed under the MIT License. See License.txt in the project root for license information.
     5  //
     6  // Code generated by Microsoft (R) AutoRest Code Generator.
     7  // Changes may cause incorrect behavior and will be lost if the code is regenerated.
     8  
     9  import (
    10  	"context"
    11  	"github.com/Azure/go-autorest/autorest"
    12  	"github.com/Azure/go-autorest/autorest/azure"
    13  	"github.com/Azure/go-autorest/autorest/validation"
    14  	"github.com/Azure/go-autorest/tracing"
    15  	"net/http"
    16  )
    17  
    18  // ApplicationDefinitionsClient is the ARM applications
    19  type ApplicationDefinitionsClient struct {
    20  	BaseClient
    21  }
    22  
    23  // NewApplicationDefinitionsClient creates an instance of the ApplicationDefinitionsClient client.
    24  func NewApplicationDefinitionsClient(subscriptionID string) ApplicationDefinitionsClient {
    25  	return NewApplicationDefinitionsClientWithBaseURI(DefaultBaseURI, subscriptionID)
    26  }
    27  
    28  // NewApplicationDefinitionsClientWithBaseURI creates an instance of the ApplicationDefinitionsClient client using a
    29  // custom endpoint.  Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds,
    30  // Azure stack).
    31  func NewApplicationDefinitionsClientWithBaseURI(baseURI string, subscriptionID string) ApplicationDefinitionsClient {
    32  	return ApplicationDefinitionsClient{NewWithBaseURI(baseURI, subscriptionID)}
    33  }
    34  
    35  // CreateOrUpdate creates a new managed application definition.
    36  // Parameters:
    37  // resourceGroupName - the name of the resource group. The name is case insensitive.
    38  // applicationDefinitionName - the name of the managed application definition.
    39  // parameters - parameters supplied to the create or update an managed application definition.
    40  func (client ApplicationDefinitionsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, applicationDefinitionName string, parameters ApplicationDefinition) (result ApplicationDefinitionsCreateOrUpdateFuture, err error) {
    41  	if tracing.IsEnabled() {
    42  		ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationDefinitionsClient.CreateOrUpdate")
    43  		defer func() {
    44  			sc := -1
    45  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
    46  				sc = result.FutureAPI.Response().StatusCode
    47  			}
    48  			tracing.EndSpan(ctx, sc, err)
    49  		}()
    50  	}
    51  	if err := validation.Validate([]validation.Validation{
    52  		{TargetValue: resourceGroupName,
    53  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
    54  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
    55  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}},
    56  		{TargetValue: applicationDefinitionName,
    57  			Constraints: []validation.Constraint{{Target: "applicationDefinitionName", Name: validation.MaxLength, Rule: 64, Chain: nil},
    58  				{Target: "applicationDefinitionName", Name: validation.MinLength, Rule: 3, Chain: nil}}},
    59  		{TargetValue: parameters,
    60  			Constraints: []validation.Constraint{{Target: "parameters.ApplicationDefinitionProperties", Name: validation.Null, Rule: true,
    61  				Chain: []validation.Constraint{{Target: "parameters.ApplicationDefinitionProperties.Authorizations", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil {
    62  		return result, validation.NewError("managedapplications.ApplicationDefinitionsClient", "CreateOrUpdate", err.Error())
    63  	}
    64  
    65  	req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, applicationDefinitionName, parameters)
    66  	if err != nil {
    67  		err = autorest.NewErrorWithError(err, "managedapplications.ApplicationDefinitionsClient", "CreateOrUpdate", nil, "Failure preparing request")
    68  		return
    69  	}
    70  
    71  	result, err = client.CreateOrUpdateSender(req)
    72  	if err != nil {
    73  		err = autorest.NewErrorWithError(err, "managedapplications.ApplicationDefinitionsClient", "CreateOrUpdate", result.Response(), "Failure sending request")
    74  		return
    75  	}
    76  
    77  	return
    78  }
    79  
    80  // CreateOrUpdatePreparer prepares the CreateOrUpdate request.
    81  func (client ApplicationDefinitionsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, applicationDefinitionName string, parameters ApplicationDefinition) (*http.Request, error) {
    82  	pathParameters := map[string]interface{}{
    83  		"applicationDefinitionName": autorest.Encode("path", applicationDefinitionName),
    84  		"resourceGroupName":         autorest.Encode("path", resourceGroupName),
    85  		"subscriptionId":            autorest.Encode("path", client.SubscriptionID),
    86  	}
    87  
    88  	const APIVersion = "2018-06-01"
    89  	queryParameters := map[string]interface{}{
    90  		"api-version": APIVersion,
    91  	}
    92  
    93  	preparer := autorest.CreatePreparer(
    94  		autorest.AsContentType("application/json; charset=utf-8"),
    95  		autorest.AsPut(),
    96  		autorest.WithBaseURL(client.BaseURI),
    97  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}", pathParameters),
    98  		autorest.WithJSON(parameters),
    99  		autorest.WithQueryParameters(queryParameters))
   100  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   101  }
   102  
   103  // CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
   104  // http.Response Body if it receives an error.
   105  func (client ApplicationDefinitionsClient) CreateOrUpdateSender(req *http.Request) (future ApplicationDefinitionsCreateOrUpdateFuture, err error) {
   106  	var resp *http.Response
   107  	future.FutureAPI = &azure.Future{}
   108  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   109  	if err != nil {
   110  		return
   111  	}
   112  	var azf azure.Future
   113  	azf, err = azure.NewFutureFromResponse(resp)
   114  	future.FutureAPI = &azf
   115  	future.Result = future.result
   116  	return
   117  }
   118  
   119  // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
   120  // closes the http.Response Body.
   121  func (client ApplicationDefinitionsClient) CreateOrUpdateResponder(resp *http.Response) (result ApplicationDefinition, err error) {
   122  	err = autorest.Respond(
   123  		resp,
   124  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
   125  		autorest.ByUnmarshallingJSON(&result),
   126  		autorest.ByClosing())
   127  	result.Response = autorest.Response{Response: resp}
   128  	return
   129  }
   130  
   131  // CreateOrUpdateByID creates a new managed application definition.
   132  // Parameters:
   133  // resourceGroupName - the name of the resource group. The name is case insensitive.
   134  // applicationDefinitionName - the name of the managed application definition.
   135  // parameters - parameters supplied to the create or update a managed application definition.
   136  func (client ApplicationDefinitionsClient) CreateOrUpdateByID(ctx context.Context, resourceGroupName string, applicationDefinitionName string, parameters ApplicationDefinition) (result ApplicationDefinitionsCreateOrUpdateByIDFuture, err error) {
   137  	if tracing.IsEnabled() {
   138  		ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationDefinitionsClient.CreateOrUpdateByID")
   139  		defer func() {
   140  			sc := -1
   141  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   142  				sc = result.FutureAPI.Response().StatusCode
   143  			}
   144  			tracing.EndSpan(ctx, sc, err)
   145  		}()
   146  	}
   147  	if err := validation.Validate([]validation.Validation{
   148  		{TargetValue: resourceGroupName,
   149  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
   150  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
   151  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
   152  		{TargetValue: applicationDefinitionName,
   153  			Constraints: []validation.Constraint{{Target: "applicationDefinitionName", Name: validation.MaxLength, Rule: 64, Chain: nil},
   154  				{Target: "applicationDefinitionName", Name: validation.MinLength, Rule: 3, Chain: nil}}},
   155  		{TargetValue: parameters,
   156  			Constraints: []validation.Constraint{{Target: "parameters.ApplicationDefinitionProperties", Name: validation.Null, Rule: true,
   157  				Chain: []validation.Constraint{{Target: "parameters.ApplicationDefinitionProperties.Authorizations", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil {
   158  		return result, validation.NewError("managedapplications.ApplicationDefinitionsClient", "CreateOrUpdateByID", err.Error())
   159  	}
   160  
   161  	req, err := client.CreateOrUpdateByIDPreparer(ctx, resourceGroupName, applicationDefinitionName, parameters)
   162  	if err != nil {
   163  		err = autorest.NewErrorWithError(err, "managedapplications.ApplicationDefinitionsClient", "CreateOrUpdateByID", nil, "Failure preparing request")
   164  		return
   165  	}
   166  
   167  	result, err = client.CreateOrUpdateByIDSender(req)
   168  	if err != nil {
   169  		err = autorest.NewErrorWithError(err, "managedapplications.ApplicationDefinitionsClient", "CreateOrUpdateByID", result.Response(), "Failure sending request")
   170  		return
   171  	}
   172  
   173  	return
   174  }
   175  
   176  // CreateOrUpdateByIDPreparer prepares the CreateOrUpdateByID request.
   177  func (client ApplicationDefinitionsClient) CreateOrUpdateByIDPreparer(ctx context.Context, resourceGroupName string, applicationDefinitionName string, parameters ApplicationDefinition) (*http.Request, error) {
   178  	pathParameters := map[string]interface{}{
   179  		"applicationDefinitionName": autorest.Encode("path", applicationDefinitionName),
   180  		"resourceGroupName":         autorest.Encode("path", resourceGroupName),
   181  		"subscriptionId":            autorest.Encode("path", client.SubscriptionID),
   182  	}
   183  
   184  	const APIVersion = "2018-06-01"
   185  	queryParameters := map[string]interface{}{
   186  		"api-version": APIVersion,
   187  	}
   188  
   189  	preparer := autorest.CreatePreparer(
   190  		autorest.AsContentType("application/json; charset=utf-8"),
   191  		autorest.AsPut(),
   192  		autorest.WithBaseURL(client.BaseURI),
   193  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}", pathParameters),
   194  		autorest.WithJSON(parameters),
   195  		autorest.WithQueryParameters(queryParameters))
   196  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   197  }
   198  
   199  // CreateOrUpdateByIDSender sends the CreateOrUpdateByID request. The method will close the
   200  // http.Response Body if it receives an error.
   201  func (client ApplicationDefinitionsClient) CreateOrUpdateByIDSender(req *http.Request) (future ApplicationDefinitionsCreateOrUpdateByIDFuture, err error) {
   202  	var resp *http.Response
   203  	future.FutureAPI = &azure.Future{}
   204  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   205  	if err != nil {
   206  		return
   207  	}
   208  	var azf azure.Future
   209  	azf, err = azure.NewFutureFromResponse(resp)
   210  	future.FutureAPI = &azf
   211  	future.Result = future.result
   212  	return
   213  }
   214  
   215  // CreateOrUpdateByIDResponder handles the response to the CreateOrUpdateByID request. The method always
   216  // closes the http.Response Body.
   217  func (client ApplicationDefinitionsClient) CreateOrUpdateByIDResponder(resp *http.Response) (result ApplicationDefinition, err error) {
   218  	err = autorest.Respond(
   219  		resp,
   220  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
   221  		autorest.ByUnmarshallingJSON(&result),
   222  		autorest.ByClosing())
   223  	result.Response = autorest.Response{Response: resp}
   224  	return
   225  }
   226  
   227  // Delete deletes the managed application definition.
   228  // Parameters:
   229  // resourceGroupName - the name of the resource group. The name is case insensitive.
   230  // applicationDefinitionName - the name of the managed application definition to delete.
   231  func (client ApplicationDefinitionsClient) Delete(ctx context.Context, resourceGroupName string, applicationDefinitionName string) (result ApplicationDefinitionsDeleteFuture, err error) {
   232  	if tracing.IsEnabled() {
   233  		ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationDefinitionsClient.Delete")
   234  		defer func() {
   235  			sc := -1
   236  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   237  				sc = result.FutureAPI.Response().StatusCode
   238  			}
   239  			tracing.EndSpan(ctx, sc, err)
   240  		}()
   241  	}
   242  	if err := validation.Validate([]validation.Validation{
   243  		{TargetValue: resourceGroupName,
   244  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
   245  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
   246  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}},
   247  		{TargetValue: applicationDefinitionName,
   248  			Constraints: []validation.Constraint{{Target: "applicationDefinitionName", Name: validation.MaxLength, Rule: 64, Chain: nil},
   249  				{Target: "applicationDefinitionName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil {
   250  		return result, validation.NewError("managedapplications.ApplicationDefinitionsClient", "Delete", err.Error())
   251  	}
   252  
   253  	req, err := client.DeletePreparer(ctx, resourceGroupName, applicationDefinitionName)
   254  	if err != nil {
   255  		err = autorest.NewErrorWithError(err, "managedapplications.ApplicationDefinitionsClient", "Delete", nil, "Failure preparing request")
   256  		return
   257  	}
   258  
   259  	result, err = client.DeleteSender(req)
   260  	if err != nil {
   261  		err = autorest.NewErrorWithError(err, "managedapplications.ApplicationDefinitionsClient", "Delete", result.Response(), "Failure sending request")
   262  		return
   263  	}
   264  
   265  	return
   266  }
   267  
   268  // DeletePreparer prepares the Delete request.
   269  func (client ApplicationDefinitionsClient) DeletePreparer(ctx context.Context, resourceGroupName string, applicationDefinitionName string) (*http.Request, error) {
   270  	pathParameters := map[string]interface{}{
   271  		"applicationDefinitionName": autorest.Encode("path", applicationDefinitionName),
   272  		"resourceGroupName":         autorest.Encode("path", resourceGroupName),
   273  		"subscriptionId":            autorest.Encode("path", client.SubscriptionID),
   274  	}
   275  
   276  	const APIVersion = "2018-06-01"
   277  	queryParameters := map[string]interface{}{
   278  		"api-version": APIVersion,
   279  	}
   280  
   281  	preparer := autorest.CreatePreparer(
   282  		autorest.AsDelete(),
   283  		autorest.WithBaseURL(client.BaseURI),
   284  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}", pathParameters),
   285  		autorest.WithQueryParameters(queryParameters))
   286  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   287  }
   288  
   289  // DeleteSender sends the Delete request. The method will close the
   290  // http.Response Body if it receives an error.
   291  func (client ApplicationDefinitionsClient) DeleteSender(req *http.Request) (future ApplicationDefinitionsDeleteFuture, err error) {
   292  	var resp *http.Response
   293  	future.FutureAPI = &azure.Future{}
   294  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   295  	if err != nil {
   296  		return
   297  	}
   298  	var azf azure.Future
   299  	azf, err = azure.NewFutureFromResponse(resp)
   300  	future.FutureAPI = &azf
   301  	future.Result = future.result
   302  	return
   303  }
   304  
   305  // DeleteResponder handles the response to the Delete request. The method always
   306  // closes the http.Response Body.
   307  func (client ApplicationDefinitionsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
   308  	err = autorest.Respond(
   309  		resp,
   310  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
   311  		autorest.ByClosing())
   312  	result.Response = resp
   313  	return
   314  }
   315  
   316  // DeleteByID deletes the managed application definition.
   317  // Parameters:
   318  // resourceGroupName - the name of the resource group. The name is case insensitive.
   319  // applicationDefinitionName - the name of the managed application definition.
   320  func (client ApplicationDefinitionsClient) DeleteByID(ctx context.Context, resourceGroupName string, applicationDefinitionName string) (result ApplicationDefinitionsDeleteByIDFuture, err error) {
   321  	if tracing.IsEnabled() {
   322  		ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationDefinitionsClient.DeleteByID")
   323  		defer func() {
   324  			sc := -1
   325  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   326  				sc = result.FutureAPI.Response().StatusCode
   327  			}
   328  			tracing.EndSpan(ctx, sc, err)
   329  		}()
   330  	}
   331  	if err := validation.Validate([]validation.Validation{
   332  		{TargetValue: resourceGroupName,
   333  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
   334  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
   335  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
   336  		{TargetValue: applicationDefinitionName,
   337  			Constraints: []validation.Constraint{{Target: "applicationDefinitionName", Name: validation.MaxLength, Rule: 64, Chain: nil},
   338  				{Target: "applicationDefinitionName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil {
   339  		return result, validation.NewError("managedapplications.ApplicationDefinitionsClient", "DeleteByID", err.Error())
   340  	}
   341  
   342  	req, err := client.DeleteByIDPreparer(ctx, resourceGroupName, applicationDefinitionName)
   343  	if err != nil {
   344  		err = autorest.NewErrorWithError(err, "managedapplications.ApplicationDefinitionsClient", "DeleteByID", nil, "Failure preparing request")
   345  		return
   346  	}
   347  
   348  	result, err = client.DeleteByIDSender(req)
   349  	if err != nil {
   350  		err = autorest.NewErrorWithError(err, "managedapplications.ApplicationDefinitionsClient", "DeleteByID", result.Response(), "Failure sending request")
   351  		return
   352  	}
   353  
   354  	return
   355  }
   356  
   357  // DeleteByIDPreparer prepares the DeleteByID request.
   358  func (client ApplicationDefinitionsClient) DeleteByIDPreparer(ctx context.Context, resourceGroupName string, applicationDefinitionName string) (*http.Request, error) {
   359  	pathParameters := map[string]interface{}{
   360  		"applicationDefinitionName": autorest.Encode("path", applicationDefinitionName),
   361  		"resourceGroupName":         autorest.Encode("path", resourceGroupName),
   362  		"subscriptionId":            autorest.Encode("path", client.SubscriptionID),
   363  	}
   364  
   365  	const APIVersion = "2018-06-01"
   366  	queryParameters := map[string]interface{}{
   367  		"api-version": APIVersion,
   368  	}
   369  
   370  	preparer := autorest.CreatePreparer(
   371  		autorest.AsDelete(),
   372  		autorest.WithBaseURL(client.BaseURI),
   373  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}", pathParameters),
   374  		autorest.WithQueryParameters(queryParameters))
   375  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   376  }
   377  
   378  // DeleteByIDSender sends the DeleteByID request. The method will close the
   379  // http.Response Body if it receives an error.
   380  func (client ApplicationDefinitionsClient) DeleteByIDSender(req *http.Request) (future ApplicationDefinitionsDeleteByIDFuture, err error) {
   381  	var resp *http.Response
   382  	future.FutureAPI = &azure.Future{}
   383  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   384  	if err != nil {
   385  		return
   386  	}
   387  	var azf azure.Future
   388  	azf, err = azure.NewFutureFromResponse(resp)
   389  	future.FutureAPI = &azf
   390  	future.Result = future.result
   391  	return
   392  }
   393  
   394  // DeleteByIDResponder handles the response to the DeleteByID request. The method always
   395  // closes the http.Response Body.
   396  func (client ApplicationDefinitionsClient) DeleteByIDResponder(resp *http.Response) (result autorest.Response, err error) {
   397  	err = autorest.Respond(
   398  		resp,
   399  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
   400  		autorest.ByClosing())
   401  	result.Response = resp
   402  	return
   403  }
   404  
   405  // Get gets the managed application definition.
   406  // Parameters:
   407  // resourceGroupName - the name of the resource group. The name is case insensitive.
   408  // applicationDefinitionName - the name of the managed application definition.
   409  func (client ApplicationDefinitionsClient) Get(ctx context.Context, resourceGroupName string, applicationDefinitionName string) (result ApplicationDefinition, err error) {
   410  	if tracing.IsEnabled() {
   411  		ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationDefinitionsClient.Get")
   412  		defer func() {
   413  			sc := -1
   414  			if result.Response.Response != nil {
   415  				sc = result.Response.Response.StatusCode
   416  			}
   417  			tracing.EndSpan(ctx, sc, err)
   418  		}()
   419  	}
   420  	if err := validation.Validate([]validation.Validation{
   421  		{TargetValue: resourceGroupName,
   422  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
   423  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
   424  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}},
   425  		{TargetValue: applicationDefinitionName,
   426  			Constraints: []validation.Constraint{{Target: "applicationDefinitionName", Name: validation.MaxLength, Rule: 64, Chain: nil},
   427  				{Target: "applicationDefinitionName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil {
   428  		return result, validation.NewError("managedapplications.ApplicationDefinitionsClient", "Get", err.Error())
   429  	}
   430  
   431  	req, err := client.GetPreparer(ctx, resourceGroupName, applicationDefinitionName)
   432  	if err != nil {
   433  		err = autorest.NewErrorWithError(err, "managedapplications.ApplicationDefinitionsClient", "Get", nil, "Failure preparing request")
   434  		return
   435  	}
   436  
   437  	resp, err := client.GetSender(req)
   438  	if err != nil {
   439  		result.Response = autorest.Response{Response: resp}
   440  		err = autorest.NewErrorWithError(err, "managedapplications.ApplicationDefinitionsClient", "Get", resp, "Failure sending request")
   441  		return
   442  	}
   443  
   444  	result, err = client.GetResponder(resp)
   445  	if err != nil {
   446  		err = autorest.NewErrorWithError(err, "managedapplications.ApplicationDefinitionsClient", "Get", resp, "Failure responding to request")
   447  		return
   448  	}
   449  
   450  	return
   451  }
   452  
   453  // GetPreparer prepares the Get request.
   454  func (client ApplicationDefinitionsClient) GetPreparer(ctx context.Context, resourceGroupName string, applicationDefinitionName string) (*http.Request, error) {
   455  	pathParameters := map[string]interface{}{
   456  		"applicationDefinitionName": autorest.Encode("path", applicationDefinitionName),
   457  		"resourceGroupName":         autorest.Encode("path", resourceGroupName),
   458  		"subscriptionId":            autorest.Encode("path", client.SubscriptionID),
   459  	}
   460  
   461  	const APIVersion = "2018-06-01"
   462  	queryParameters := map[string]interface{}{
   463  		"api-version": APIVersion,
   464  	}
   465  
   466  	preparer := autorest.CreatePreparer(
   467  		autorest.AsGet(),
   468  		autorest.WithBaseURL(client.BaseURI),
   469  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}", pathParameters),
   470  		autorest.WithQueryParameters(queryParameters))
   471  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   472  }
   473  
   474  // GetSender sends the Get request. The method will close the
   475  // http.Response Body if it receives an error.
   476  func (client ApplicationDefinitionsClient) GetSender(req *http.Request) (*http.Response, error) {
   477  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   478  }
   479  
   480  // GetResponder handles the response to the Get request. The method always
   481  // closes the http.Response Body.
   482  func (client ApplicationDefinitionsClient) GetResponder(resp *http.Response) (result ApplicationDefinition, err error) {
   483  	err = autorest.Respond(
   484  		resp,
   485  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNotFound),
   486  		autorest.ByUnmarshallingJSON(&result),
   487  		autorest.ByClosing())
   488  	result.Response = autorest.Response{Response: resp}
   489  	return
   490  }
   491  
   492  // GetByID gets the managed application definition.
   493  // Parameters:
   494  // resourceGroupName - the name of the resource group. The name is case insensitive.
   495  // applicationDefinitionName - the name of the managed application definition.
   496  func (client ApplicationDefinitionsClient) GetByID(ctx context.Context, resourceGroupName string, applicationDefinitionName string) (result ApplicationDefinition, err error) {
   497  	if tracing.IsEnabled() {
   498  		ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationDefinitionsClient.GetByID")
   499  		defer func() {
   500  			sc := -1
   501  			if result.Response.Response != nil {
   502  				sc = result.Response.Response.StatusCode
   503  			}
   504  			tracing.EndSpan(ctx, sc, err)
   505  		}()
   506  	}
   507  	if err := validation.Validate([]validation.Validation{
   508  		{TargetValue: resourceGroupName,
   509  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
   510  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
   511  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
   512  		{TargetValue: applicationDefinitionName,
   513  			Constraints: []validation.Constraint{{Target: "applicationDefinitionName", Name: validation.MaxLength, Rule: 64, Chain: nil},
   514  				{Target: "applicationDefinitionName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil {
   515  		return result, validation.NewError("managedapplications.ApplicationDefinitionsClient", "GetByID", err.Error())
   516  	}
   517  
   518  	req, err := client.GetByIDPreparer(ctx, resourceGroupName, applicationDefinitionName)
   519  	if err != nil {
   520  		err = autorest.NewErrorWithError(err, "managedapplications.ApplicationDefinitionsClient", "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.ApplicationDefinitionsClient", "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.ApplicationDefinitionsClient", "GetByID", resp, "Failure responding to request")
   534  		return
   535  	}
   536  
   537  	return
   538  }
   539  
   540  // GetByIDPreparer prepares the GetByID request.
   541  func (client ApplicationDefinitionsClient) GetByIDPreparer(ctx context.Context, resourceGroupName string, applicationDefinitionName string) (*http.Request, error) {
   542  	pathParameters := map[string]interface{}{
   543  		"applicationDefinitionName": autorest.Encode("path", applicationDefinitionName),
   544  		"resourceGroupName":         autorest.Encode("path", resourceGroupName),
   545  		"subscriptionId":            autorest.Encode("path", client.SubscriptionID),
   546  	}
   547  
   548  	const APIVersion = "2018-06-01"
   549  	queryParameters := map[string]interface{}{
   550  		"api-version": APIVersion,
   551  	}
   552  
   553  	preparer := autorest.CreatePreparer(
   554  		autorest.AsGet(),
   555  		autorest.WithBaseURL(client.BaseURI),
   556  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}", pathParameters),
   557  		autorest.WithQueryParameters(queryParameters))
   558  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   559  }
   560  
   561  // GetByIDSender sends the GetByID request. The method will close the
   562  // http.Response Body if it receives an error.
   563  func (client ApplicationDefinitionsClient) GetByIDSender(req *http.Request) (*http.Response, error) {
   564  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   565  }
   566  
   567  // GetByIDResponder handles the response to the GetByID request. The method always
   568  // closes the http.Response Body.
   569  func (client ApplicationDefinitionsClient) GetByIDResponder(resp *http.Response) (result ApplicationDefinition, err error) {
   570  	err = autorest.Respond(
   571  		resp,
   572  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNotFound),
   573  		autorest.ByUnmarshallingJSON(&result),
   574  		autorest.ByClosing())
   575  	result.Response = autorest.Response{Response: resp}
   576  	return
   577  }
   578  
   579  // ListByResourceGroup lists the managed application definitions in a resource group.
   580  // Parameters:
   581  // resourceGroupName - the name of the resource group. The name is case insensitive.
   582  func (client ApplicationDefinitionsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result ApplicationDefinitionListResultPage, err error) {
   583  	if tracing.IsEnabled() {
   584  		ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationDefinitionsClient.ListByResourceGroup")
   585  		defer func() {
   586  			sc := -1
   587  			if result.adlr.Response.Response != nil {
   588  				sc = result.adlr.Response.Response.StatusCode
   589  			}
   590  			tracing.EndSpan(ctx, sc, err)
   591  		}()
   592  	}
   593  	if err := validation.Validate([]validation.Validation{
   594  		{TargetValue: resourceGroupName,
   595  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
   596  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
   597  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}}}); err != nil {
   598  		return result, validation.NewError("managedapplications.ApplicationDefinitionsClient", "ListByResourceGroup", err.Error())
   599  	}
   600  
   601  	result.fn = client.listByResourceGroupNextResults
   602  	req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName)
   603  	if err != nil {
   604  		err = autorest.NewErrorWithError(err, "managedapplications.ApplicationDefinitionsClient", "ListByResourceGroup", nil, "Failure preparing request")
   605  		return
   606  	}
   607  
   608  	resp, err := client.ListByResourceGroupSender(req)
   609  	if err != nil {
   610  		result.adlr.Response = autorest.Response{Response: resp}
   611  		err = autorest.NewErrorWithError(err, "managedapplications.ApplicationDefinitionsClient", "ListByResourceGroup", resp, "Failure sending request")
   612  		return
   613  	}
   614  
   615  	result.adlr, err = client.ListByResourceGroupResponder(resp)
   616  	if err != nil {
   617  		err = autorest.NewErrorWithError(err, "managedapplications.ApplicationDefinitionsClient", "ListByResourceGroup", resp, "Failure responding to request")
   618  		return
   619  	}
   620  	if result.adlr.hasNextLink() && result.adlr.IsEmpty() {
   621  		err = result.NextWithContext(ctx)
   622  		return
   623  	}
   624  
   625  	return
   626  }
   627  
   628  // ListByResourceGroupPreparer prepares the ListByResourceGroup request.
   629  func (client ApplicationDefinitionsClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) {
   630  	pathParameters := map[string]interface{}{
   631  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   632  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   633  	}
   634  
   635  	const APIVersion = "2018-06-01"
   636  	queryParameters := map[string]interface{}{
   637  		"api-version": APIVersion,
   638  	}
   639  
   640  	preparer := autorest.CreatePreparer(
   641  		autorest.AsGet(),
   642  		autorest.WithBaseURL(client.BaseURI),
   643  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions", pathParameters),
   644  		autorest.WithQueryParameters(queryParameters))
   645  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   646  }
   647  
   648  // ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the
   649  // http.Response Body if it receives an error.
   650  func (client ApplicationDefinitionsClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) {
   651  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   652  }
   653  
   654  // ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always
   655  // closes the http.Response Body.
   656  func (client ApplicationDefinitionsClient) ListByResourceGroupResponder(resp *http.Response) (result ApplicationDefinitionListResult, err error) {
   657  	err = autorest.Respond(
   658  		resp,
   659  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   660  		autorest.ByUnmarshallingJSON(&result),
   661  		autorest.ByClosing())
   662  	result.Response = autorest.Response{Response: resp}
   663  	return
   664  }
   665  
   666  // listByResourceGroupNextResults retrieves the next set of results, if any.
   667  func (client ApplicationDefinitionsClient) listByResourceGroupNextResults(ctx context.Context, lastResults ApplicationDefinitionListResult) (result ApplicationDefinitionListResult, err error) {
   668  	req, err := lastResults.applicationDefinitionListResultPreparer(ctx)
   669  	if err != nil {
   670  		return result, autorest.NewErrorWithError(err, "managedapplications.ApplicationDefinitionsClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request")
   671  	}
   672  	if req == nil {
   673  		return
   674  	}
   675  	resp, err := client.ListByResourceGroupSender(req)
   676  	if err != nil {
   677  		result.Response = autorest.Response{Response: resp}
   678  		return result, autorest.NewErrorWithError(err, "managedapplications.ApplicationDefinitionsClient", "listByResourceGroupNextResults", resp, "Failure sending next results request")
   679  	}
   680  	result, err = client.ListByResourceGroupResponder(resp)
   681  	if err != nil {
   682  		err = autorest.NewErrorWithError(err, "managedapplications.ApplicationDefinitionsClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request")
   683  	}
   684  	return
   685  }
   686  
   687  // ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required.
   688  func (client ApplicationDefinitionsClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result ApplicationDefinitionListResultIterator, err error) {
   689  	if tracing.IsEnabled() {
   690  		ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationDefinitionsClient.ListByResourceGroup")
   691  		defer func() {
   692  			sc := -1
   693  			if result.Response().Response.Response != nil {
   694  				sc = result.page.Response().Response.Response.StatusCode
   695  			}
   696  			tracing.EndSpan(ctx, sc, err)
   697  		}()
   698  	}
   699  	result.page, err = client.ListByResourceGroup(ctx, resourceGroupName)
   700  	return
   701  }
   702  

View as plain text