diff --git a/src/Microsoft.Identity.Abstractions/DownstreamApi/IDownstreamApi.cs b/src/Microsoft.Identity.Abstractions/DownstreamApi/IDownstreamApi.cs index 5334d7e..7b6e758 100644 --- a/src/Microsoft.Identity.Abstractions/DownstreamApi/IDownstreamApi.cs +++ b/src/Microsoft.Identity.Abstractions/DownstreamApi/IDownstreamApi.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.Diagnostics.CodeAnalysis; using System.Net.Http; using System.Security.Claims; using System.Threading; @@ -236,5 +235,136 @@ Task CallApiForAppAsync( Action? downstreamApiOptionsOverride = null, CancellationToken cancellationToken = default) where TOutput : class; + +#if NET8_0_OR_GREATER + /// + /// Calls a downstream API consuming JSON with some data and returns data. + /// + /// Input type. + /// Output type. + /// Name of the service describing the downstream API. There can + /// be several configuration named sections mapped to a , + /// each for one downstream API. You can pass-in null, but in that case + /// needs to be set. + /// Input parameter to the downstream web API. + /// JSON serialization metadata for TInput + /// JSON serialization metadata for TOutput + /// Overrides the options proposed in the configuration described + /// by . + /// [Optional] Claims representing a user. This is useful in platforms like Blazor + /// or Azure Signal R, where the HttpContext is not available. In other platforms, the library + /// will find the user from the HttpContext. + /// Cancellation token. + /// The value returned by the downstream web API. + /// + /// A list method that returns an IEnumerable<MyItem>>. + /// + /// public Task<IEnumerable<MyItem>> GetAsync() + /// { + /// return _downstreamWebApi.CallWebApiForUserAsync<object, IEnumerable<MyItem>>( + /// ServiceName, + /// null, + /// options => + /// { + /// options.RelativePath = $"api/todolist"; + /// }); + /// } + /// + /// + /// Example of editing. + /// + /// public Task<MyItem> EditAsync(MyItem myItem) + /// { + /// return _downstreamWebApi.CallWebApiForUserAsync<MyItem, MyItem>( + /// ServiceName, + /// nyItem, + /// options => + /// { + /// options.HttpMethod = HttpMethod.Patch; + /// options.RelativePath = $"api/todolist/{myItem.Id}"; + /// }); + /// } + /// + /// + Task CallApiForUserAsync( + string? serviceName, + TInput input, + JsonTypeInfo inputJsonTypeInfo, + JsonTypeInfo outputJsonTypeInfo, + Action? downstreamApiOptionsOverride = null, + ClaimsPrincipal? user = default, + CancellationToken cancellationToken = default) + where TOutput : class; + + /// + /// Call a web API endpoint with an HttpGet, and return strongly typed data. + /// + /// Output type. + /// Name of the service describing the downstream API. There can + /// be several configuration named sections mapped to a , + /// each for one downstream API. You can pass-in null, but in that case + /// needs to be set. + /// JSON serialization metadata for TOutput + /// Overrides the options proposed in the configuration described + /// by . + /// [Optional] Claims representing a user. This is useful in platforms like Blazor + /// or Azure Signal R, where the HttpContext is not available. In other platforms, the library + /// will find the user from the HttpContext. + /// Cancellation token. + /// The value returned by the downstream web API. + Task CallApiForUserAsync( + string serviceName, + JsonTypeInfo outputJsonTypeInfo, + Action? downstreamApiOptionsOverride = null, + ClaimsPrincipal? user = default, + CancellationToken cancellationToken = default) + where TOutput : class; + + /// + /// Calls a downstream API consuming JSON with some data and returns data. + /// + /// Input type. + /// Output type. + /// Name of the service describing the downstream API. There can + /// be several configuration named sections mapped to a , + /// each for one downstream API. You can pass-in null, but in that case + /// needs to be set. + /// Input parameter to the downstream web API. + /// JSON serialization metadata for TInput + /// JSON serialization metadata for TOutput + /// Overrides the options proposed in the configuration described + /// by . + /// Cancellation token. + /// The value returned by the downstream web API. + Task CallApiForAppAsync( + string? serviceName, + TInput input, + JsonTypeInfo inputJsonTypeInfo, + JsonTypeInfo outputJsonTypeInfo, + Action? downstreamApiOptionsOverride = null, + CancellationToken cancellationToken = default) + where TOutput : class; + + /// + /// Call a web API endpoint with an HttpGet, and return strongly typed data. + /// + /// Output type. + /// Name of the service describing the downstream API. There can + /// be several configuration named sections mapped to a , + /// each for one downstream API. You can pass-in null, but in that case + /// needs to be set. + /// JSON serialization metadata for TOutput + /// Overrides the options proposed in the configuration described + /// by . + /// Cancellation token. + /// The value returned by the downstream web API. + Task CallApiForAppAsync( + string serviceName, + JsonTypeInfo outputJsonTypeInfo, + Action? downstreamApiOptionsOverride = null, + CancellationToken cancellationToken = default) + where TOutput : class; +#endif } + }