public async Task <ResponseWithHeaders <ContainerRegistryBlobUploadChunkHeaders> > UploadChunkAsync(string nextLink, Stream value, CancellationToken cancellationToken = default) { if (nextLink == null) { throw new ArgumentNullException(nameof(nextLink)); } if (value == null) { throw new ArgumentNullException(nameof(value)); } using var message = CreateUploadChunkRequest(nextLink, value); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); var headers = new ContainerRegistryBlobUploadChunkHeaders(message.Response); switch (message.Response.Status) { case 202: return(ResponseWithHeaders.FromValue(headers, message.Response)); default: throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); } }
public ResponseWithHeaders <Stream, ContainerRegistryBlobDeleteBlobHeaders> DeleteBlob(string name, string digest, CancellationToken cancellationToken = default) { if (name == null) { throw new ArgumentNullException(nameof(name)); } if (digest == null) { throw new ArgumentNullException(nameof(digest)); } using var message = CreateDeleteBlobRequest(name, digest); _pipeline.Send(message, cancellationToken); var headers = new ContainerRegistryBlobDeleteBlobHeaders(message.Response); switch (message.Response.Status) { case 202: { var value = message.ExtractResponseContent(); return(ResponseWithHeaders.FromValue(value, headers, message.Response)); } default: throw ClientDiagnostics.CreateRequestFailedException(message.Response); } }
public async Task <ResponseWithHeaders <ContainerRegistryBlobCompleteUploadHeaders> > CompleteUploadAsync(string digest, string location, Stream value = null, CancellationToken cancellationToken = default) { if (digest == null) { throw new ArgumentNullException(nameof(digest)); } if (location == null) { throw new ArgumentNullException(nameof(location)); } using var message = CreateCompleteUploadRequest(digest, location, value); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); var headers = new ContainerRegistryBlobCompleteUploadHeaders(message.Response); switch (message.Response.Status) { case 201: return(ResponseWithHeaders.FromValue(headers, message.Response)); default: throw await ClientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); } }
public async Task <ResponseWithHeaders <AssetConversion, RemoteRenderingCreateConversionHeaders> > CreateConversionAsync(Guid accountId, string conversionId, CreateConversionSettings body, CancellationToken cancellationToken = default) { if (conversionId == null) { throw new ArgumentNullException(nameof(conversionId)); } if (body == null) { throw new ArgumentNullException(nameof(body)); } using var message = CreateCreateConversionRequest(accountId, conversionId, body); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); var headers = new RemoteRenderingCreateConversionHeaders(message.Response); switch (message.Response.Status) { case 200: case 201: { AssetConversion value = default; using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); value = AssetConversion.DeserializeAssetConversion(document.RootElement); return(ResponseWithHeaders.FromValue(value, headers, message.Response)); }
public async Task <ResponseWithHeaders <IReadOnlyDictionary <string, string>, TestProxyStartPlaybackHeaders> > StartPlaybackAsync(StartInformation body, CancellationToken cancellationToken = default) { if (body == null) { throw new ArgumentNullException(nameof(body)); } using var message = CreateStartPlaybackRequest(body); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); var headers = new TestProxyStartPlaybackHeaders(message.Response); switch (message.Response.Status) { case 200: { IReadOnlyDictionary <string, string> value = default; using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); Dictionary <string, string> dictionary = new Dictionary <string, string>(); foreach (var property in document.RootElement.EnumerateObject()) { dictionary.Add(property.Name, property.Value.GetString()); } value = dictionary; return(ResponseWithHeaders.FromValue(value, headers, message.Response)); }
public ResponseWithHeaders <Stream, ServiceSubmitBatchHeaders> SubmitBatch(long contentLength, string multipartContentType, Stream body, int?timeout = null, CancellationToken cancellationToken = default) { if (multipartContentType == null) { throw new ArgumentNullException(nameof(multipartContentType)); } if (body == null) { throw new ArgumentNullException(nameof(body)); } using var message = CreateSubmitBatchRequest(contentLength, multipartContentType, body, timeout); _pipeline.Send(message, cancellationToken); var headers = new ServiceSubmitBatchHeaders(message.Response); switch (message.Response.Status) { case 202: { var value = message.ExtractResponseContent(); return(ResponseWithHeaders.FromValue(value, headers, message.Response)); } default: throw ClientDiagnostics.CreateRequestFailedException(message.Response); } }
public ResponseWithHeaders <IReadOnlyList <QueueSignedIdentifier>, QueueGetAccessPolicyHeaders> GetAccessPolicy(int?timeout = null, CancellationToken cancellationToken = default) { using var message = CreateGetAccessPolicyRequest(timeout); _pipeline.Send(message, cancellationToken); var headers = new QueueGetAccessPolicyHeaders(message.Response); switch (message.Response.Status) { case 200: { IReadOnlyList <QueueSignedIdentifier> value = default; var document = XDocument.Load(message.Response.ContentStream, LoadOptions.PreserveWhitespace); if (document.Element("SignedIdentifiers") is XElement signedIdentifiersElement) { var array = new List <QueueSignedIdentifier>(); foreach (var e in signedIdentifiersElement.Elements("SignedIdentifier")) { array.Add(QueueSignedIdentifier.DeserializeQueueSignedIdentifier(e)); } value = array; } return(ResponseWithHeaders.FromValue(value, headers, message.Response)); } default: throw ClientDiagnostics.CreateRequestFailedException(message.Response); } }
public async ValueTask <ResponseWithHeaders <AddHeaders> > AddAsync(CertificateAddParameter certificate, CertificateAddOptions certificateAddOptions, CancellationToken cancellationToken = default) { if (certificate == null) { throw new ArgumentNullException(nameof(certificate)); } using var scope = clientDiagnostics.CreateScope("CertificateClient.Add"); scope.Start(); try { using var message = CreateAddRequest(certificate, certificateAddOptions); await pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); var headers = new AddHeaders(message.Response); switch (message.Response.Status) { case 201: return(ResponseWithHeaders.FromValue(headers, message.Response)); default: throw await clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); } } catch (Exception e) { scope.Failed(e); throw; } }
public async Task <ResponseWithHeaders <Stream, ContainerSubmitBatchHeaders> > SubmitBatchAsync(string containerName, long contentLength, string multipartContentType, Stream body, int?timeout = null, CancellationToken cancellationToken = default) { if (containerName == null) { throw new ArgumentNullException(nameof(containerName)); } if (multipartContentType == null) { throw new ArgumentNullException(nameof(multipartContentType)); } if (body == null) { throw new ArgumentNullException(nameof(body)); } using var message = CreateSubmitBatchRequest(containerName, contentLength, multipartContentType, body, timeout); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); var headers = new ContainerSubmitBatchHeaders(message.Response); switch (message.Response.Status) { case 202: { var value = message.ExtractResponseContent(); return(ResponseWithHeaders.FromValue(value, headers, message.Response)); } default: throw await ClientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); } }
public ResponseWithHeaders <StorageServiceStats, ServiceGetStatisticsHeaders> GetStatistics(int?timeout = null, string requestId = null, CancellationToken cancellationToken = default) { using var scope = _clientDiagnostics.CreateScope("ServiceClient.GetStatistics"); scope.Start(); try { using var message = CreateGetStatisticsRequest(timeout, requestId); _pipeline.Send(message, cancellationToken); var headers = new ServiceGetStatisticsHeaders(message.Response); switch (message.Response.Status) { case 200: { StorageServiceStats value = default; var document = XDocument.Load(message.Response.ContentStream, LoadOptions.PreserveWhitespace); if (document.Element("StorageServiceStats") is XElement storageServiceStatsElement) { value = StorageServiceStats.DeserializeStorageServiceStats(storageServiceStatsElement); } return(ResponseWithHeaders.FromValue(value, headers, message.Response)); } default: throw _clientDiagnostics.CreateRequestFailedException(message.Response); } } catch (Exception e) { scope.Failed(e); throw; } }
public async ValueTask <ResponseWithHeaders <ServiceSetPropertiesHeaders> > SetPropertiesAsync(StorageServiceProperties storageServiceProperties, int?timeout = null, string requestId = null, CancellationToken cancellationToken = default) { if (storageServiceProperties == null) { throw new ArgumentNullException(nameof(storageServiceProperties)); } using var scope = _clientDiagnostics.CreateScope("ServiceClient.SetProperties"); scope.Start(); try { using var message = CreateSetPropertiesRequest(storageServiceProperties, timeout, requestId); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); var headers = new ServiceSetPropertiesHeaders(message.Response); switch (message.Response.Status) { case 202: return(ResponseWithHeaders.FromValue(headers, message.Response)); default: throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); } } catch (Exception e) { scope.Failed(e); throw; } }
public async Task <ResponseWithHeaders <IReadOnlyList <DequeuedMessageItem>, MessagesDequeueHeaders> > DequeueAsync(int?numberOfMessages = null, int?visibilitytimeout = null, int?timeout = null, CancellationToken cancellationToken = default) { using var message = CreateDequeueRequest(numberOfMessages, visibilitytimeout, timeout); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); var headers = new MessagesDequeueHeaders(message.Response); switch (message.Response.Status) { case 200: { IReadOnlyList <DequeuedMessageItem> value = default; var document = XDocument.Load(message.Response.ContentStream, LoadOptions.PreserveWhitespace); if (document.Element("QueueMessagesList") is XElement queueMessagesListElement) { var array = new List <DequeuedMessageItem>(); foreach (var e in queueMessagesListElement.Elements("QueueMessage")) { array.Add(DequeuedMessageItem.DeserializeDequeuedMessageItem(e)); } value = array; } return(ResponseWithHeaders.FromValue(value, headers, message.Response)); } default: throw await ClientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); } }
public ResponseWithHeaders <IReadOnlyList <PeekedMessageItem>, MessagesPeekHeaders> Peek(int?numberOfMessages = null, int?timeout = null, CancellationToken cancellationToken = default) { using var message = CreatePeekRequest(numberOfMessages, timeout); _pipeline.Send(message, cancellationToken); var headers = new MessagesPeekHeaders(message.Response); switch (message.Response.Status) { case 200: { IReadOnlyList <PeekedMessageItem> value = default; var document = XDocument.Load(message.Response.ContentStream, LoadOptions.PreserveWhitespace); if (document.Element("QueueMessagesList") is XElement queueMessagesListElement) { var array = new List <PeekedMessageItem>(); foreach (var e in queueMessagesListElement.Elements("QueueMessage")) { array.Add(PeekedMessageItem.DeserializePeekedMessageItem(e)); } value = array; } return(ResponseWithHeaders.FromValue(value, headers, message.Response)); } default: throw ClientDiagnostics.CreateRequestFailedException(message.Response); } }
public ResponseWithHeaders <IReadOnlyList <SendReceipt>, MessagesEnqueueHeaders> Enqueue(QueueMessage queueMessage, int?visibilitytimeout = null, int?messageTimeToLive = null, int?timeout = null, CancellationToken cancellationToken = default) { if (queueMessage == null) { throw new ArgumentNullException(nameof(queueMessage)); } using var message = CreateEnqueueRequest(queueMessage, visibilitytimeout, messageTimeToLive, timeout); _pipeline.Send(message, cancellationToken); var headers = new MessagesEnqueueHeaders(message.Response); switch (message.Response.Status) { case 201: { IReadOnlyList <SendReceipt> value = default; var document = XDocument.Load(message.Response.ContentStream, LoadOptions.PreserveWhitespace); if (document.Element("QueueMessagesList") is XElement queueMessagesListElement) { var array = new List <SendReceipt>(); foreach (var e in queueMessagesListElement.Elements("QueueMessage")) { array.Add(SendReceipt.DeserializeSendReceipt(e)); } value = array; } return(ResponseWithHeaders.FromValue(value, headers, message.Response)); } default: throw ClientDiagnostics.CreateRequestFailedException(message.Response); } }
internal async ValueTask <ResponseWithHeaders <AnalyzeWithCustomModelHeaders> > AnalyzeWithCustomModelAsync(Guid modelId, bool?includeTextDetails, Stream stream, ContentType contentType, CancellationToken cancellationToken = default) { using var scope = clientDiagnostics.CreateScope("AllOperations.AnalyzeWithCustomModel"); scope.Start(); try { using var message = RestClient.CreateAnalyzeWithCustomModelRequest(modelId, includeTextDetails, stream, contentType); await pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { case 202: var headers = new AnalyzeWithCustomModelHeaders(message.Response); return(ResponseWithHeaders.FromValue(headers, message.Response)); default: throw await clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); } } catch (Exception e) { scope.Failed(e); throw; } }
public async Task <ResponseWithHeaders <ContainerRegistryBlobCheckChunkExistsHeaders> > CheckChunkExistsAsync(string name, string digest, string range, CancellationToken cancellationToken = default) { if (name == null) { throw new ArgumentNullException(nameof(name)); } if (digest == null) { throw new ArgumentNullException(nameof(digest)); } if (range == null) { throw new ArgumentNullException(nameof(range)); } using var message = CreateCheckChunkExistsRequest(name, digest, range); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); var headers = new ContainerRegistryBlobCheckChunkExistsHeaders(message.Response); switch (message.Response.Status) { case 200: return(ResponseWithHeaders.FromValue(headers, message.Response)); default: throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); } }
public async Task <ResponseWithHeaders <PhoneNumbersSearchAvailablePhoneNumbersHeaders> > SearchAvailablePhoneNumbersAsync(string countryCode, PhoneNumberSearchRequest body, CancellationToken cancellationToken = default) { if (countryCode == null) { throw new ArgumentNullException(nameof(countryCode)); } if (body == null) { throw new ArgumentNullException(nameof(body)); } using var message = CreateSearchAvailablePhoneNumbersRequest(countryCode, body); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); var headers = new PhoneNumbersSearchAvailablePhoneNumbersHeaders(message.Response); switch (message.Response.Status) { case 202: return(ResponseWithHeaders.FromValue(headers, message.Response)); default: throw await ClientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); } }
public async Task <ResponseWithHeaders <FullBackupDetailsInternal, ServiceFullBackupHeaders> > FullBackupAsync(string vaultBaseUrl, SASTokenParameter azureStorageBlobContainerUri = null, CancellationToken cancellationToken = default) { if (vaultBaseUrl == null) { throw new ArgumentNullException(nameof(vaultBaseUrl)); } using var message = CreateFullBackupRequest(vaultBaseUrl, azureStorageBlobContainerUri); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); var headers = new ServiceFullBackupHeaders(message.Response); switch (message.Response.Status) { case 202: { FullBackupDetailsInternal value = default; using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); if (document.RootElement.ValueKind == JsonValueKind.Null) { value = null; } else { value = FullBackupDetailsInternal.DeserializeFullBackupDetailsInternal(document.RootElement); } return(ResponseWithHeaders.FromValue(value, headers, message.Response)); }
public async Task <ResponseWithHeaders <IReadOnlyList <TwinData>, QueryGetTwinsHeaders> > GetTwinsAsync(QuerySpecification querySpecification, string xMsContinuation = null, string xMsMaxItemCount = null, CancellationToken cancellationToken = default) { if (querySpecification == null) { throw new ArgumentNullException(nameof(querySpecification)); } using var message = CreateGetTwinsRequest(querySpecification, xMsContinuation, xMsMaxItemCount); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); var headers = new QueryGetTwinsHeaders(message.Response); switch (message.Response.Status) { case 200: { IReadOnlyList <TwinData> value = default; using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); List <TwinData> array = new List <TwinData>(); foreach (var item in document.RootElement.EnumerateArray()) { array.Add(TwinData.DeserializeTwinData(item)); } value = array; return(ResponseWithHeaders.FromValue(value, headers, message.Response)); }
public async Task <ResponseWithHeaders <MessageIdUpdateHeaders> > UpdateAsync(string messageid, string popReceipt, int visibilitytimeout, int?timeout = null, QueueMessage queueMessage = null, CancellationToken cancellationToken = default) { if (messageid == null) { throw new ArgumentNullException(nameof(messageid)); } if (popReceipt == null) { throw new ArgumentNullException(nameof(popReceipt)); } using var message = CreateUpdateRequest(messageid, popReceipt, visibilitytimeout, timeout, queueMessage); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); var headers = new MessageIdUpdateHeaders(message.Response); switch (message.Response.Status) { case 204: return(ResponseWithHeaders.FromValue(headers, message.Response)); default: throw await ClientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); } }
internal async Task <ResponseWithHeaders <QueryResult <T>, QueryQueryTwinsHeaders> > QueryTwinsAsync <T>( QuerySpecification querySpecification, QueryOptions queryTwinsOptions = null, ObjectSerializer objectSerializer = null, CancellationToken cancellationToken = default) { if (querySpecification == null) { throw new ArgumentNullException(nameof(querySpecification)); } if (objectSerializer == null) { throw new ArgumentNullException(nameof(objectSerializer)); } using HttpMessage message = CreateQueryTwinsRequest(querySpecification, queryTwinsOptions); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); var headers = new QueryQueryTwinsHeaders(message.Response); switch (message.Response.Status) { case 200: { using JsonDocument document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); QueryResult <T> value = QueryResult <T> .DeserializeQueryResult(document.RootElement, objectSerializer); return(ResponseWithHeaders.FromValue(value, headers, message.Response)); }
public async Task <ResponseWithHeaders <SchemaId, SchemaQueryIdByContentHeaders> > QueryIdByContentAsync(string groupName, string schemaName, SerializationType serializationType, string schemaContent, CancellationToken cancellationToken = default) { if (groupName == null) { throw new ArgumentNullException(nameof(groupName)); } if (schemaName == null) { throw new ArgumentNullException(nameof(schemaName)); } if (schemaContent == null) { throw new ArgumentNullException(nameof(schemaContent)); } using var message = CreateQueryIdByContentRequest(groupName, schemaName, serializationType, schemaContent); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); var headers = new SchemaQueryIdByContentHeaders(message.Response); switch (message.Response.Status) { case 200: { SchemaId value = default; using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); value = SchemaId.DeserializeSchemaId(document.RootElement); return(ResponseWithHeaders.FromValue(value, headers, message.Response)); }
public ResponseWithHeaders <ListSharesResponse, ServiceListSharesSegmentHeaders> ListSharesSegmentNextPage(string nextLink, string prefix = null, string marker = null, int?maxresults = null, IEnumerable <ListSharesIncludeType> include = null, int?timeout = null, CancellationToken cancellationToken = default) { if (nextLink == null) { throw new ArgumentNullException(nameof(nextLink)); } using var message = CreateListSharesSegmentNextPageRequest(nextLink, prefix, marker, maxresults, include, timeout); _pipeline.Send(message, cancellationToken); var headers = new ServiceListSharesSegmentHeaders(message.Response); switch (message.Response.Status) { case 200: { ListSharesResponse value = default; var document = XDocument.Load(message.Response.ContentStream, LoadOptions.PreserveWhitespace); if (document.Element("EnumerationResults") is XElement enumerationResultsElement) { value = ListSharesResponse.DeserializeListSharesResponse(enumerationResultsElement); } return(ResponseWithHeaders.FromValue(value, headers, message.Response)); } default: throw ClientDiagnostics.CreateRequestFailedException(message.Response); } }
public async Task <ResponseWithHeaders <string, SchemaGetByIdHeaders> > GetByIdAsync(string schemaId, CancellationToken cancellationToken = default) { if (schemaId == null) { throw new ArgumentNullException(nameof(schemaId)); } using var message = CreateGetByIdRequest(schemaId); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); var headers = new SchemaGetByIdHeaders(message.Response); switch (message.Response.Status) { case 200: { StreamReader streamReader = new StreamReader(message.Response.ContentStream); string value = await streamReader.ReadToEndAsync().ConfigureAwait(false); return(ResponseWithHeaders.FromValue(value, headers, message.Response)); } default: throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); } }
public ResponseWithHeaders <ContainerRegistryBlobCheckBlobExistsHeaders> CheckBlobExists(string name, string digest, CancellationToken cancellationToken = default) { if (name == null) { throw new ArgumentNullException(nameof(name)); } if (digest == null) { throw new ArgumentNullException(nameof(digest)); } using var message = CreateCheckBlobExistsRequest(name, digest); _pipeline.Send(message, cancellationToken); var headers = new ContainerRegistryBlobCheckBlobExistsHeaders(message.Response); switch (message.Response.Status) { case 200: case 307: return(ResponseWithHeaders.FromValue(headers, message.Response)); default: throw ClientDiagnostics.CreateRequestFailedException(message.Response); } }
// TODO: Is it ok that includeTextDetails is missing here? Or is it an issue with the Swagger? // This is missing from the swagger -- following up with service team. public async ValueTask <ResponseWithHeaders <AnalyzeLayoutAsyncHeaders> > AnalyzeLayoutAsyncAsync(Stream stream, ContentType contentType, CancellationToken cancellationToken = default) { using var scope = clientDiagnostics.CreateScope("AllOperations.AnalyzeLayoutAsync"); scope.Start(); try { using var message = RestClient.CreateAnalyzeLayoutAsyncRequest(stream, contentType); await pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { case 202: var headers = new AnalyzeLayoutAsyncHeaders(message.Response); return(ResponseWithHeaders.FromValue(headers, message.Response)); default: throw await clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); } } catch (Exception e) { scope.Failed(e); throw; } }
public ResponseWithHeaders <ContainerRegistryBlobMountBlobHeaders> MountBlob(string name, string @from, string mount, CancellationToken cancellationToken = default) { if (name == null) { throw new ArgumentNullException(nameof(name)); } if (@from == null) { throw new ArgumentNullException(nameof(@from)); } if (mount == null) { throw new ArgumentNullException(nameof(mount)); } using var message = CreateMountBlobRequest(name, @from, mount); _pipeline.Send(message, cancellationToken); var headers = new ContainerRegistryBlobMountBlobHeaders(message.Response); switch (message.Response.Status) { case 201: return(ResponseWithHeaders.FromValue(headers, message.Response)); default: throw ClientDiagnostics.CreateRequestFailedException(message.Response); } }
internal ResponseWithHeaders <AnalyzeWithCustomModelHeaders> AnalyzeWithCustomModel(Guid modelId, bool?includeTextDetails, Stream stream, ContentType contentType, CancellationToken cancellationToken = default) { using var scope = clientDiagnostics.CreateScope("AllOperations.AnalyzeWithCustomModel"); scope.Start(); try { // TODO: Could refactor this so different AnalyzeWithCustomModels overload call the same implementation with different request messages. using var message = RestClient.CreateAnalyzeWithCustomModelRequest(modelId, includeTextDetails, stream, contentType); pipeline.Send(message, cancellationToken); switch (message.Response.Status) { case 202: var headers = new AnalyzeWithCustomModelHeaders(message.Response); return(ResponseWithHeaders.FromValue(headers, message.Response)); default: throw clientDiagnostics.CreateRequestFailedException(message.Response); } } catch (Exception e) { scope.Failed(e); throw; } }
public async Task <ResponseWithHeaders <Stream, ContainerRegistryBlobGetChunkHeaders> > GetChunkAsync(string name, string digest, string range, CancellationToken cancellationToken = default) { if (name == null) { throw new ArgumentNullException(nameof(name)); } if (digest == null) { throw new ArgumentNullException(nameof(digest)); } if (range == null) { throw new ArgumentNullException(nameof(range)); } using var message = CreateGetChunkRequest(name, digest, range); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); var headers = new ContainerRegistryBlobGetChunkHeaders(message.Response); switch (message.Response.Status) { case 206: { var value = message.ExtractResponseContent(); return(ResponseWithHeaders.FromValue(value, headers, message.Response)); } default: throw await ClientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); } }
public async ValueTask <ResponseWithHeaders <TableQueryResponse, TableInternalQueryHeaders> > QueryAsync(string requestId = null, QueryOptions queryOptions = null, CancellationToken cancellationToken = default) { using var scope = _clientDiagnostics.CreateScope("TableInternalClient.Query"); scope.Start(); try { using var message = CreateQueryRequest(requestId, queryOptions); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); var headers = new TableInternalQueryHeaders(message.Response); switch (message.Response.Status) { case 200: { TableQueryResponse value = default; using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); if (document.RootElement.ValueKind == JsonValueKind.Null) { value = null; } else { value = TableQueryResponse.DeserializeTableQueryResponse(document.RootElement); } return(ResponseWithHeaders.FromValue(value, headers, message.Response)); }