public async Task <Response <EnvironmentContainerResource> > CreateOrUpdateAsync(string name, string resourceGroupName, string workspaceName, EnvironmentContainerResource body = null, CancellationToken cancellationToken = default) { if (name == null) { throw new ArgumentNullException(nameof(name)); } if (resourceGroupName == null) { throw new ArgumentNullException(nameof(resourceGroupName)); } if (workspaceName == null) { throw new ArgumentNullException(nameof(workspaceName)); } using var message = CreateCreateOrUpdateRequest(name, resourceGroupName, workspaceName, body); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { case 200: case 201: { EnvironmentContainerResource value = default; using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); value = EnvironmentContainerResource.DeserializeEnvironmentContainerResource(document.RootElement); return(Response.FromValue(value, message.Response)); }
public virtual Response <EnvironmentContainerResource> CreateOrUpdate(string name, string resourceGroupName, string workspaceName, EnvironmentContainerResource body = null, CancellationToken cancellationToken = default) { using var scope = _clientDiagnostics.CreateScope("EnvironmentContainersOperations.CreateOrUpdate"); scope.Start(); try { return(RestClient.CreateOrUpdate(name, resourceGroupName, workspaceName, body, cancellationToken)); } catch (Exception e) { scope.Failed(e); throw; } }
internal HttpMessage CreateCreateOrUpdateRequest(string name, string resourceGroupName, string workspaceName, EnvironmentContainerResource body) { 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.MachineLearningServices/workspaces/", false); uri.AppendPath(workspaceName, true); uri.AppendPath("/environments/", false); uri.AppendPath(name, true); uri.AppendQuery("api-version", apiVersion, true); request.Uri = uri; request.Headers.Add("Accept", "application/json"); if (body != null) { request.Headers.Add("Content-Type", "application/json"); var content = new Utf8JsonRequestContent(); content.JsonWriter.WriteObjectValue(body); request.Content = content; } return(message); }