SnapshotResource IOperationSource <SnapshotResource> .CreateResult(Response response, CancellationToken cancellationToken)
        {
            using var document = JsonDocument.Parse(response.ContentStream);
            var data = SnapshotData.DeserializeSnapshotData(document.RootElement);

            return(new SnapshotResource(_client, data));
        }
Esempio n. 2
0
        public async Task <Response <SnapshotData> > GetAsync(string resourceGroupName, string snapshotName, CancellationToken cancellationToken = default)
        {
            if (resourceGroupName == null)
            {
                throw new ArgumentNullException(nameof(resourceGroupName));
            }
            if (snapshotName == null)
            {
                throw new ArgumentNullException(nameof(snapshotName));
            }

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

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

                value = SnapshotData.DeserializeSnapshotData(document.RootElement);
                return(Response.FromValue(value, message.Response));
            }