...

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

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

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

View as plain text