internal HttpMessage CreateCreateOrUpdateRequest(string resourceGroupName, string galleryName, string galleryApplicationName, GalleryApplication galleryApplication) { var message = _pipeline.CreateMessage(); var request = message.Request; request.Method = RequestMethod.Put; 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", "2019-12-01", true); request.Uri = uri; request.Headers.Add("Content-Type", "application/json"); var content = new Utf8JsonRequestContent(); content.JsonWriter.WriteObjectValue(galleryApplication); request.Content = content; return(message); }
public static GalleryApplication GetGalleryApplication(this ArmClient armClient, ResourceIdentifier id) { GalleryApplication.ValidateResourceId(id); return(armClient.UseClientContext((uri, credential, clientOptions, pipeline) => new GalleryApplication(clientOptions, credential, uri, pipeline, id))); }
public Response CreateOrUpdate(string resourceGroupName, string galleryName, string galleryApplicationName, GalleryApplication galleryApplication, CancellationToken cancellationToken = default) { if (resourceGroupName == null) { throw new ArgumentNullException(nameof(resourceGroupName)); } if (galleryName == null) { throw new ArgumentNullException(nameof(galleryName)); } if (galleryApplicationName == null) { throw new ArgumentNullException(nameof(galleryApplicationName)); } if (galleryApplication == null) { throw new ArgumentNullException(nameof(galleryApplication)); } using var message = CreateCreateOrUpdateRequest(resourceGroupName, galleryName, galleryApplicationName, galleryApplication); _pipeline.Send(message, cancellationToken); switch (message.Response.Status) { case 200: case 201: case 202: return(message.Response); default: throw _clientDiagnostics.CreateRequestFailedException(message.Response); } }
public virtual GalleryApplicationsCreateOrUpdateOperation StartCreateOrUpdate(string resourceGroupName, string galleryName, string galleryApplicationName, GalleryApplication galleryApplication, CancellationToken cancellationToken = default) { if (resourceGroupName == null) { throw new ArgumentNullException(nameof(resourceGroupName)); } if (galleryName == null) { throw new ArgumentNullException(nameof(galleryName)); } if (galleryApplicationName == null) { throw new ArgumentNullException(nameof(galleryApplicationName)); } if (galleryApplication == null) { throw new ArgumentNullException(nameof(galleryApplication)); } using var scope = _clientDiagnostics.CreateScope("GalleryApplicationsOperations.StartCreateOrUpdate"); scope.Start(); try { var originalResponse = RestClient.CreateOrUpdate(resourceGroupName, galleryName, galleryApplicationName, galleryApplication, cancellationToken); return(new GalleryApplicationsCreateOrUpdateOperation(_clientDiagnostics, _pipeline, RestClient.CreateCreateOrUpdateRequest(resourceGroupName, galleryName, galleryApplicationName, galleryApplication).Request, originalResponse)); } catch (Exception e) { scope.Failed(e); throw; } }