internal HttpMessage CreateListRequest(GetDigitalTwinsEventRoutesOptions eventRoutesListOptions) { var message = _pipeline.CreateMessage(); var request = message.Request; request.Method = RequestMethod.Get; var uri = new RawRequestUriBuilder(); uri.Reset(endpoint); uri.AppendPath("/eventroutes", false); uri.AppendQuery("api-version", apiVersion, true); request.Uri = uri; if (eventRoutesListOptions?.TraceParent != null) { request.Headers.Add("traceparent", eventRoutesListOptions.TraceParent); } if (eventRoutesListOptions?.TraceState != null) { request.Headers.Add("tracestate", eventRoutesListOptions.TraceState); } if (eventRoutesListOptions?.MaxItemsPerPage != null) { request.Headers.Add("max-items-per-page", eventRoutesListOptions.MaxItemsPerPage.Value); } request.Headers.Add("Accept", "application/json"); return(message); }
public async Task <Response <DigitalTwinsEventRouteCollection> > ListAsync(GetDigitalTwinsEventRoutesOptions eventRoutesListOptions = null, CancellationToken cancellationToken = default) { using var message = CreateListRequest(eventRoutesListOptions); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { case 200: { DigitalTwinsEventRouteCollection value = default; using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); value = DigitalTwinsEventRouteCollection.DeserializeDigitalTwinsEventRouteCollection(document.RootElement); return(Response.FromValue(value, message.Response)); }