public async Task <Response <FlowLog> > GetAsync(string resourceGroupName, string networkWatcherName, string flowLogName, CancellationToken cancellationToken = default) { if (resourceGroupName == null) { throw new ArgumentNullException(nameof(resourceGroupName)); } if (networkWatcherName == null) { throw new ArgumentNullException(nameof(networkWatcherName)); } if (flowLogName == null) { throw new ArgumentNullException(nameof(flowLogName)); } using var message = CreateGetRequest(resourceGroupName, networkWatcherName, flowLogName); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { case 200: { FlowLog value = default; using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); value = FlowLog.DeserializeFlowLog(document.RootElement); return(Response.FromValue(value, message.Response)); }
public virtual FlowLogsCreateOrUpdateOperation StartCreateOrUpdate(string resourceGroupName, string networkWatcherName, string flowLogName, FlowLog parameters, CancellationToken cancellationToken = default) { if (resourceGroupName == null) { throw new ArgumentNullException(nameof(resourceGroupName)); } if (networkWatcherName == null) { throw new ArgumentNullException(nameof(networkWatcherName)); } if (flowLogName == null) { throw new ArgumentNullException(nameof(flowLogName)); } if (parameters == null) { throw new ArgumentNullException(nameof(parameters)); } using var scope = _clientDiagnostics.CreateScope("FlowLogsOperations.StartCreateOrUpdate"); scope.Start(); try { var originalResponse = RestClient.CreateOrUpdate(resourceGroupName, networkWatcherName, flowLogName, parameters, cancellationToken); return(new FlowLogsCreateOrUpdateOperation(_clientDiagnostics, _pipeline, RestClient.CreateCreateOrUpdateRequest(resourceGroupName, networkWatcherName, flowLogName, parameters).Request, originalResponse)); } catch (Exception e) { scope.Failed(e); throw; } }
public async Task <Response> CreateOrUpdateAsync(string resourceGroupName, string networkWatcherName, string flowLogName, FlowLog parameters, CancellationToken cancellationToken = default) { if (resourceGroupName == null) { throw new ArgumentNullException(nameof(resourceGroupName)); } if (networkWatcherName == null) { throw new ArgumentNullException(nameof(networkWatcherName)); } if (flowLogName == null) { throw new ArgumentNullException(nameof(flowLogName)); } if (parameters == null) { throw new ArgumentNullException(nameof(parameters)); } using var message = CreateCreateOrUpdateRequest(resourceGroupName, networkWatcherName, flowLogName, parameters); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { case 200: case 201: return(message.Response); default: throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); } }
internal HttpMessage CreateCreateOrUpdateRequest(string resourceGroupName, string networkWatcherName, string flowLogName, FlowLog parameters) { 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.Network/networkWatchers/", false); uri.AppendPath(networkWatcherName, true); uri.AppendPath("/flowLogs/", false); uri.AppendPath(flowLogName, true); uri.AppendQuery("api-version", "2020-04-01", true); request.Uri = uri; request.Headers.Add("Accept", "application/json"); request.Headers.Add("Content-Type", "application/json"); var content = new Utf8JsonRequestContent(); content.JsonWriter.WriteObjectValue(parameters); request.Content = content; return(message); }