Пример #1
0
        ConnectionMonitor IOperationSource <ConnectionMonitor> .CreateResult(Response response, CancellationToken cancellationToken)
        {
            using var document = JsonDocument.Parse(response.ContentStream);
            var data = ConnectionMonitorData.DeserializeConnectionMonitorData(document.RootElement);

            return(new ConnectionMonitor(_client, data));
        }
        public async Task <Response <ConnectionMonitorData> > GetAsync(string subscriptionId, string resourceGroupName, string networkWatcherName, string connectionMonitorName, CancellationToken cancellationToken = default)
        {
            if (subscriptionId == null)
            {
                throw new ArgumentNullException(nameof(subscriptionId));
            }
            if (resourceGroupName == null)
            {
                throw new ArgumentNullException(nameof(resourceGroupName));
            }
            if (networkWatcherName == null)
            {
                throw new ArgumentNullException(nameof(networkWatcherName));
            }
            if (connectionMonitorName == null)
            {
                throw new ArgumentNullException(nameof(connectionMonitorName));
            }

            using var message = CreateGetRequest(subscriptionId, resourceGroupName, networkWatcherName, connectionMonitorName);
            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);

            switch (message.Response.Status)
            {
            case 200:
            {
                ConnectionMonitorData value = default;
                using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false);

                value = ConnectionMonitorData.DeserializeConnectionMonitorData(document.RootElement);
                return(Response.FromValue(value, message.Response));
            }