...

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

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

     1  package managedapplications
     2  
     3  // Copyright (c) Microsoft Corporation. All rights reserved.
     4  // Licensed under the MIT License. See License.txt in the project root for license information.
     5  //
     6  // Code generated by Microsoft (R) AutoRest Code Generator.
     7  // Changes may cause incorrect behavior and will be lost if the code is regenerated.
     8  
     9  import (
    10  	"context"
    11  	"github.com/Azure/go-autorest/autorest"
    12  	"github.com/Azure/go-autorest/autorest/azure"
    13  	"github.com/Azure/go-autorest/autorest/validation"
    14  	"github.com/Azure/go-autorest/tracing"
    15  	"net/http"
    16  )
    17  
    18  // JitRequestsClient is the ARM applications
    19  type JitRequestsClient struct {
    20  	BaseClient
    21  }
    22  
    23  // NewJitRequestsClient creates an instance of the JitRequestsClient client.
    24  func NewJitRequestsClient(subscriptionID string) JitRequestsClient {
    25  	return NewJitRequestsClientWithBaseURI(DefaultBaseURI, subscriptionID)
    26  }
    27  
    28  // NewJitRequestsClientWithBaseURI creates an instance of the JitRequestsClient 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 NewJitRequestsClientWithBaseURI(baseURI string, subscriptionID string) JitRequestsClient {
    31  	return JitRequestsClient{NewWithBaseURI(baseURI, subscriptionID)}
    32  }
    33  
    34  // CreateOrUpdate creates or updates the JIT request.
    35  // Parameters:
    36  // resourceGroupName - the name of the resource group. The name is case insensitive.
    37  // jitRequestName - the name of the JIT request.
    38  // parameters - parameters supplied to the update JIT request.
    39  func (client JitRequestsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, jitRequestName string, parameters JitRequestDefinition) (result JitRequestsCreateOrUpdateFuture, err error) {
    40  	if tracing.IsEnabled() {
    41  		ctx = tracing.StartSpan(ctx, fqdn+"/JitRequestsClient.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: parameters,
    56  			Constraints: []validation.Constraint{{Target: "parameters.JitRequestProperties", Name: validation.Null, Rule: false,
    57  				Chain: []validation.Constraint{{Target: "parameters.JitRequestProperties.ApplicationResourceID", Name: validation.Null, Rule: true, Chain: nil},
    58  					{Target: "parameters.JitRequestProperties.JitAuthorizationPolicies", Name: validation.Null, Rule: true, Chain: nil},
    59  					{Target: "parameters.JitRequestProperties.JitSchedulingPolicy", Name: validation.Null, Rule: true,
    60  						Chain: []validation.Constraint{{Target: "parameters.JitRequestProperties.JitSchedulingPolicy.Duration", Name: validation.Null, Rule: true, Chain: nil},
    61  							{Target: "parameters.JitRequestProperties.JitSchedulingPolicy.StartTime", Name: validation.Null, Rule: true, Chain: nil},
    62  						}},
    63  				}}}}}); err != nil {
    64  		return result, validation.NewError("managedapplications.JitRequestsClient", "CreateOrUpdate", err.Error())
    65  	}
    66  
    67  	req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, jitRequestName, parameters)
    68  	if err != nil {
    69  		err = autorest.NewErrorWithError(err, "managedapplications.JitRequestsClient", "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.JitRequestsClient", "CreateOrUpdate", result.Response(), "Failure sending request")
    76  		return
    77  	}
    78  
    79  	return
    80  }
    81  
    82  // CreateOrUpdatePreparer prepares the CreateOrUpdate request.
    83  func (client JitRequestsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, jitRequestName string, parameters JitRequestDefinition) (*http.Request, error) {
    84  	pathParameters := map[string]interface{}{
    85  		"jitRequestName":    autorest.Encode("path", jitRequestName),
    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/jitRequests/{jitRequestName}", 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 JitRequestsClient) CreateOrUpdateSender(req *http.Request) (future JitRequestsCreateOrUpdateFuture, 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 JitRequestsClient) CreateOrUpdateResponder(resp *http.Response) (result JitRequestDefinition, 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  // Delete deletes the JIT request.
   134  // Parameters:
   135  // resourceGroupName - the name of the resource group. The name is case insensitive.
   136  // jitRequestName - the name of the JIT request.
   137  func (client JitRequestsClient) Delete(ctx context.Context, resourceGroupName string, jitRequestName string) (result autorest.Response, err error) {
   138  	if tracing.IsEnabled() {
   139  		ctx = tracing.StartSpan(ctx, fqdn+"/JitRequestsClient.Delete")
   140  		defer func() {
   141  			sc := -1
   142  			if result.Response != nil {
   143  				sc = result.Response.StatusCode
   144  			}
   145  			tracing.EndSpan(ctx, sc, err)
   146  		}()
   147  	}
   148  	if err := validation.Validate([]validation.Validation{
   149  		{TargetValue: resourceGroupName,
   150  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
   151  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
   152  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil {
   153  		return result, validation.NewError("managedapplications.JitRequestsClient", "Delete", err.Error())
   154  	}
   155  
   156  	req, err := client.DeletePreparer(ctx, resourceGroupName, jitRequestName)
   157  	if err != nil {
   158  		err = autorest.NewErrorWithError(err, "managedapplications.JitRequestsClient", "Delete", nil, "Failure preparing request")
   159  		return
   160  	}
   161  
   162  	resp, err := client.DeleteSender(req)
   163  	if err != nil {
   164  		result.Response = resp
   165  		err = autorest.NewErrorWithError(err, "managedapplications.JitRequestsClient", "Delete", resp, "Failure sending request")
   166  		return
   167  	}
   168  
   169  	result, err = client.DeleteResponder(resp)
   170  	if err != nil {
   171  		err = autorest.NewErrorWithError(err, "managedapplications.JitRequestsClient", "Delete", resp, "Failure responding to request")
   172  		return
   173  	}
   174  
   175  	return
   176  }
   177  
   178  // DeletePreparer prepares the Delete request.
   179  func (client JitRequestsClient) DeletePreparer(ctx context.Context, resourceGroupName string, jitRequestName string) (*http.Request, error) {
   180  	pathParameters := map[string]interface{}{
   181  		"jitRequestName":    autorest.Encode("path", jitRequestName),
   182  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   183  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   184  	}
   185  
   186  	const APIVersion = "2019-07-01"
   187  	queryParameters := map[string]interface{}{
   188  		"api-version": APIVersion,
   189  	}
   190  
   191  	preparer := autorest.CreatePreparer(
   192  		autorest.AsDelete(),
   193  		autorest.WithBaseURL(client.BaseURI),
   194  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}", pathParameters),
   195  		autorest.WithQueryParameters(queryParameters))
   196  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   197  }
   198  
   199  // DeleteSender sends the Delete request. The method will close the
   200  // http.Response Body if it receives an error.
   201  func (client JitRequestsClient) DeleteSender(req *http.Request) (*http.Response, error) {
   202  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   203  }
   204  
   205  // DeleteResponder handles the response to the Delete request. The method always
   206  // closes the http.Response Body.
   207  func (client JitRequestsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
   208  	err = autorest.Respond(
   209  		resp,
   210  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
   211  		autorest.ByClosing())
   212  	result.Response = resp
   213  	return
   214  }
   215  
   216  // Get gets the JIT request.
   217  // Parameters:
   218  // resourceGroupName - the name of the resource group. The name is case insensitive.
   219  // jitRequestName - the name of the JIT request.
   220  func (client JitRequestsClient) Get(ctx context.Context, resourceGroupName string, jitRequestName string) (result JitRequestDefinition, err error) {
   221  	if tracing.IsEnabled() {
   222  		ctx = tracing.StartSpan(ctx, fqdn+"/JitRequestsClient.Get")
   223  		defer func() {
   224  			sc := -1
   225  			if result.Response.Response != nil {
   226  				sc = result.Response.Response.StatusCode
   227  			}
   228  			tracing.EndSpan(ctx, sc, err)
   229  		}()
   230  	}
   231  	if err := validation.Validate([]validation.Validation{
   232  		{TargetValue: resourceGroupName,
   233  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
   234  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
   235  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil {
   236  		return result, validation.NewError("managedapplications.JitRequestsClient", "Get", err.Error())
   237  	}
   238  
   239  	req, err := client.GetPreparer(ctx, resourceGroupName, jitRequestName)
   240  	if err != nil {
   241  		err = autorest.NewErrorWithError(err, "managedapplications.JitRequestsClient", "Get", nil, "Failure preparing request")
   242  		return
   243  	}
   244  
   245  	resp, err := client.GetSender(req)
   246  	if err != nil {
   247  		result.Response = autorest.Response{Response: resp}
   248  		err = autorest.NewErrorWithError(err, "managedapplications.JitRequestsClient", "Get", resp, "Failure sending request")
   249  		return
   250  	}
   251  
   252  	result, err = client.GetResponder(resp)
   253  	if err != nil {
   254  		err = autorest.NewErrorWithError(err, "managedapplications.JitRequestsClient", "Get", resp, "Failure responding to request")
   255  		return
   256  	}
   257  
   258  	return
   259  }
   260  
   261  // GetPreparer prepares the Get request.
   262  func (client JitRequestsClient) GetPreparer(ctx context.Context, resourceGroupName string, jitRequestName string) (*http.Request, error) {
   263  	pathParameters := map[string]interface{}{
   264  		"jitRequestName":    autorest.Encode("path", jitRequestName),
   265  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   266  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   267  	}
   268  
   269  	const APIVersion = "2019-07-01"
   270  	queryParameters := map[string]interface{}{
   271  		"api-version": APIVersion,
   272  	}
   273  
   274  	preparer := autorest.CreatePreparer(
   275  		autorest.AsGet(),
   276  		autorest.WithBaseURL(client.BaseURI),
   277  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}", pathParameters),
   278  		autorest.WithQueryParameters(queryParameters))
   279  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   280  }
   281  
   282  // GetSender sends the Get request. The method will close the
   283  // http.Response Body if it receives an error.
   284  func (client JitRequestsClient) GetSender(req *http.Request) (*http.Response, error) {
   285  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   286  }
   287  
   288  // GetResponder handles the response to the Get request. The method always
   289  // closes the http.Response Body.
   290  func (client JitRequestsClient) GetResponder(resp *http.Response) (result JitRequestDefinition, err error) {
   291  	err = autorest.Respond(
   292  		resp,
   293  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNotFound),
   294  		autorest.ByUnmarshallingJSON(&result),
   295  		autorest.ByClosing())
   296  	result.Response = autorest.Response{Response: resp}
   297  	return
   298  }
   299  
   300  // ListByResourceGroup retrieves all JIT requests within the resource group.
   301  // Parameters:
   302  // resourceGroupName - the name of the resource group. The name is case insensitive.
   303  func (client JitRequestsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result JitRequestDefinitionListResult, err error) {
   304  	if tracing.IsEnabled() {
   305  		ctx = tracing.StartSpan(ctx, fqdn+"/JitRequestsClient.ListByResourceGroup")
   306  		defer func() {
   307  			sc := -1
   308  			if result.Response.Response != nil {
   309  				sc = result.Response.Response.StatusCode
   310  			}
   311  			tracing.EndSpan(ctx, sc, err)
   312  		}()
   313  	}
   314  	if err := validation.Validate([]validation.Validation{
   315  		{TargetValue: resourceGroupName,
   316  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
   317  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
   318  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil {
   319  		return result, validation.NewError("managedapplications.JitRequestsClient", "ListByResourceGroup", err.Error())
   320  	}
   321  
   322  	req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName)
   323  	if err != nil {
   324  		err = autorest.NewErrorWithError(err, "managedapplications.JitRequestsClient", "ListByResourceGroup", nil, "Failure preparing request")
   325  		return
   326  	}
   327  
   328  	resp, err := client.ListByResourceGroupSender(req)
   329  	if err != nil {
   330  		result.Response = autorest.Response{Response: resp}
   331  		err = autorest.NewErrorWithError(err, "managedapplications.JitRequestsClient", "ListByResourceGroup", resp, "Failure sending request")
   332  		return
   333  	}
   334  
   335  	result, err = client.ListByResourceGroupResponder(resp)
   336  	if err != nil {
   337  		err = autorest.NewErrorWithError(err, "managedapplications.JitRequestsClient", "ListByResourceGroup", resp, "Failure responding to request")
   338  		return
   339  	}
   340  
   341  	return
   342  }
   343  
   344  // ListByResourceGroupPreparer prepares the ListByResourceGroup request.
   345  func (client JitRequestsClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) {
   346  	pathParameters := map[string]interface{}{
   347  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   348  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   349  	}
   350  
   351  	const APIVersion = "2019-07-01"
   352  	queryParameters := map[string]interface{}{
   353  		"api-version": APIVersion,
   354  	}
   355  
   356  	preparer := autorest.CreatePreparer(
   357  		autorest.AsGet(),
   358  		autorest.WithBaseURL(client.BaseURI),
   359  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests", pathParameters),
   360  		autorest.WithQueryParameters(queryParameters))
   361  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   362  }
   363  
   364  // ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the
   365  // http.Response Body if it receives an error.
   366  func (client JitRequestsClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) {
   367  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   368  }
   369  
   370  // ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always
   371  // closes the http.Response Body.
   372  func (client JitRequestsClient) ListByResourceGroupResponder(resp *http.Response) (result JitRequestDefinitionListResult, err error) {
   373  	err = autorest.Respond(
   374  		resp,
   375  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   376  		autorest.ByUnmarshallingJSON(&result),
   377  		autorest.ByClosing())
   378  	result.Response = autorest.Response{Response: resp}
   379  	return
   380  }
   381  
   382  // ListBySubscription lists all JIT requests within the subscription.
   383  func (client JitRequestsClient) ListBySubscription(ctx context.Context) (result JitRequestDefinitionListResult, err error) {
   384  	if tracing.IsEnabled() {
   385  		ctx = tracing.StartSpan(ctx, fqdn+"/JitRequestsClient.ListBySubscription")
   386  		defer func() {
   387  			sc := -1
   388  			if result.Response.Response != nil {
   389  				sc = result.Response.Response.StatusCode
   390  			}
   391  			tracing.EndSpan(ctx, sc, err)
   392  		}()
   393  	}
   394  	req, err := client.ListBySubscriptionPreparer(ctx)
   395  	if err != nil {
   396  		err = autorest.NewErrorWithError(err, "managedapplications.JitRequestsClient", "ListBySubscription", nil, "Failure preparing request")
   397  		return
   398  	}
   399  
   400  	resp, err := client.ListBySubscriptionSender(req)
   401  	if err != nil {
   402  		result.Response = autorest.Response{Response: resp}
   403  		err = autorest.NewErrorWithError(err, "managedapplications.JitRequestsClient", "ListBySubscription", resp, "Failure sending request")
   404  		return
   405  	}
   406  
   407  	result, err = client.ListBySubscriptionResponder(resp)
   408  	if err != nil {
   409  		err = autorest.NewErrorWithError(err, "managedapplications.JitRequestsClient", "ListBySubscription", resp, "Failure responding to request")
   410  		return
   411  	}
   412  
   413  	return
   414  }
   415  
   416  // ListBySubscriptionPreparer prepares the ListBySubscription request.
   417  func (client JitRequestsClient) ListBySubscriptionPreparer(ctx context.Context) (*http.Request, error) {
   418  	pathParameters := map[string]interface{}{
   419  		"subscriptionId": autorest.Encode("path", client.SubscriptionID),
   420  	}
   421  
   422  	const APIVersion = "2019-07-01"
   423  	queryParameters := map[string]interface{}{
   424  		"api-version": APIVersion,
   425  	}
   426  
   427  	preparer := autorest.CreatePreparer(
   428  		autorest.AsGet(),
   429  		autorest.WithBaseURL(client.BaseURI),
   430  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/jitRequests", pathParameters),
   431  		autorest.WithQueryParameters(queryParameters))
   432  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   433  }
   434  
   435  // ListBySubscriptionSender sends the ListBySubscription request. The method will close the
   436  // http.Response Body if it receives an error.
   437  func (client JitRequestsClient) ListBySubscriptionSender(req *http.Request) (*http.Response, error) {
   438  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   439  }
   440  
   441  // ListBySubscriptionResponder handles the response to the ListBySubscription request. The method always
   442  // closes the http.Response Body.
   443  func (client JitRequestsClient) ListBySubscriptionResponder(resp *http.Response) (result JitRequestDefinitionListResult, err error) {
   444  	err = autorest.Respond(
   445  		resp,
   446  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   447  		autorest.ByUnmarshallingJSON(&result),
   448  		autorest.ByClosing())
   449  	result.Response = autorest.Response{Response: resp}
   450  	return
   451  }
   452  
   453  // Update updates the JIT request.
   454  // Parameters:
   455  // resourceGroupName - the name of the resource group. The name is case insensitive.
   456  // jitRequestName - the name of the JIT request.
   457  // parameters - parameters supplied to the update JIT request.
   458  func (client JitRequestsClient) Update(ctx context.Context, resourceGroupName string, jitRequestName string, parameters JitRequestPatchable) (result JitRequestDefinition, err error) {
   459  	if tracing.IsEnabled() {
   460  		ctx = tracing.StartSpan(ctx, fqdn+"/JitRequestsClient.Update")
   461  		defer func() {
   462  			sc := -1
   463  			if result.Response.Response != nil {
   464  				sc = result.Response.Response.StatusCode
   465  			}
   466  			tracing.EndSpan(ctx, sc, err)
   467  		}()
   468  	}
   469  	if err := validation.Validate([]validation.Validation{
   470  		{TargetValue: resourceGroupName,
   471  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
   472  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
   473  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil {
   474  		return result, validation.NewError("managedapplications.JitRequestsClient", "Update", err.Error())
   475  	}
   476  
   477  	req, err := client.UpdatePreparer(ctx, resourceGroupName, jitRequestName, parameters)
   478  	if err != nil {
   479  		err = autorest.NewErrorWithError(err, "managedapplications.JitRequestsClient", "Update", nil, "Failure preparing request")
   480  		return
   481  	}
   482  
   483  	resp, err := client.UpdateSender(req)
   484  	if err != nil {
   485  		result.Response = autorest.Response{Response: resp}
   486  		err = autorest.NewErrorWithError(err, "managedapplications.JitRequestsClient", "Update", resp, "Failure sending request")
   487  		return
   488  	}
   489  
   490  	result, err = client.UpdateResponder(resp)
   491  	if err != nil {
   492  		err = autorest.NewErrorWithError(err, "managedapplications.JitRequestsClient", "Update", resp, "Failure responding to request")
   493  		return
   494  	}
   495  
   496  	return
   497  }
   498  
   499  // UpdatePreparer prepares the Update request.
   500  func (client JitRequestsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, jitRequestName string, parameters JitRequestPatchable) (*http.Request, error) {
   501  	pathParameters := map[string]interface{}{
   502  		"jitRequestName":    autorest.Encode("path", jitRequestName),
   503  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   504  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   505  	}
   506  
   507  	const APIVersion = "2019-07-01"
   508  	queryParameters := map[string]interface{}{
   509  		"api-version": APIVersion,
   510  	}
   511  
   512  	preparer := autorest.CreatePreparer(
   513  		autorest.AsContentType("application/json; charset=utf-8"),
   514  		autorest.AsPatch(),
   515  		autorest.WithBaseURL(client.BaseURI),
   516  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}", pathParameters),
   517  		autorest.WithJSON(parameters),
   518  		autorest.WithQueryParameters(queryParameters))
   519  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   520  }
   521  
   522  // UpdateSender sends the Update request. The method will close the
   523  // http.Response Body if it receives an error.
   524  func (client JitRequestsClient) UpdateSender(req *http.Request) (*http.Response, error) {
   525  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   526  }
   527  
   528  // UpdateResponder handles the response to the Update request. The method always
   529  // closes the http.Response Body.
   530  func (client JitRequestsClient) UpdateResponder(resp *http.Response) (result JitRequestDefinition, err error) {
   531  	err = autorest.Respond(
   532  		resp,
   533  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   534  		autorest.ByUnmarshallingJSON(&result),
   535  		autorest.ByClosing())
   536  	result.Response = autorest.Response{Response: resp}
   537  	return
   538  }
   539  

View as plain text