internal HttpMessage CreateUpdateRequest(string subscriptionId, string resourceGroupName, string galleryName, string galleryApplicationName, GalleryApplicationPatch patch) { var message = _pipeline.CreateMessage(); var request = message.Request; request.Method = RequestMethod.Patch; var uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); uri.AppendPath(subscriptionId, true); uri.AppendPath("/resourceGroups/", false); uri.AppendPath(resourceGroupName, true); uri.AppendPath("/providers/Microsoft.Compute/galleries/", false); uri.AppendPath(galleryName, true); uri.AppendPath("/applications/", false); uri.AppendPath(galleryApplicationName, true); uri.AppendQuery("api-version", _apiVersion, true); request.Uri = uri; request.Headers.Add("Accept", "application/json"); request.Headers.Add("Content-Type", "application/json"); var content = new Utf8JsonRequestContent(); content.JsonWriter.WriteObjectValue(patch); request.Content = content; _userAgent.Apply(message); return(message); }
public Response Update(string subscriptionId, string resourceGroupName, string galleryName, string galleryApplicationName, GalleryApplicationPatch patch, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); Argument.AssertNotNullOrEmpty(galleryName, nameof(galleryName)); Argument.AssertNotNullOrEmpty(galleryApplicationName, nameof(galleryApplicationName)); Argument.AssertNotNull(patch, nameof(patch)); using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, galleryName, galleryApplicationName, patch); _pipeline.Send(message, cancellationToken); switch (message.Response.Status) { case 200: return(message.Response); default: throw new RequestFailedException(message.Response); } }
public virtual ArmOperation <GalleryApplicationResource> Update(WaitUntil waitUntil, GalleryApplicationPatch patch, CancellationToken cancellationToken = default) { Argument.AssertNotNull(patch, nameof(patch)); using var scope = _galleryApplicationClientDiagnostics.CreateScope("GalleryApplicationResource.Update"); scope.Start(); try { var response = _galleryApplicationRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, patch, cancellationToken); var operation = new ComputeArmOperation <GalleryApplicationResource>(new GalleryApplicationOperationSource(Client), _galleryApplicationClientDiagnostics, Pipeline, _galleryApplicationRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, patch).Request, response, OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) { operation.WaitForCompletion(cancellationToken); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }