diff --git a/src/Microsoft.Identity.Abstractions/DownstreamApi/IDownstreamApi.HttpMethods.cs b/src/Microsoft.Identity.Abstractions/DownstreamApi/IDownstreamApi.HttpMethods.cs index 4e470f0..be67979 100644 --- a/src/Microsoft.Identity.Abstractions/DownstreamApi/IDownstreamApi.HttpMethods.cs +++ b/src/Microsoft.Identity.Abstractions/DownstreamApi/IDownstreamApi.HttpMethods.cs @@ -54,13 +54,790 @@ public partial interface IDownstreamApi ClaimsPrincipal? user = null, CancellationToken cancellationToken = default)where TOutput : class; +#if NET8_0_OR_GREATER + /// + /// Calls, using , a downstream API returning data. + /// By default the returned data is deserialized from JSON but you can provide your own deserializer in the action + /// you pass-in through the parameter. + /// + /// Generic output type. + + /// JSON serialization metadata for TOutput + /// 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. + /// [Optional] 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. + /// + /// a Task + /// + /// + /// var result = await _downstreamApi.GetForUserAsync<IEnumerable<MyItem>>( + /// "MyService", + /// options => + /// { + /// options.RelativePath = $"api/todolist"; + /// }); + /// + /// + public Task GetForUserAsync( + string? serviceName, + JsonTypeInfo outputJsonTypeInfo, + Action? downstreamApiOptionsOverride = null, + ClaimsPrincipal? user = null, + CancellationToken cancellationToken = default)where TOutput : class; +#endif + + /// + /// Calls, using , a downstream API with some input data and returning data. + /// By default the input data is serialized in JSON and the returned data is deserialized from JSON but you can provide your own serializer and your own deserializer in the action + /// you pass-in through the parameter. + /// + /// Generic input type. + /// Generic 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. + /// Data sent to the downstream web API, through the body or the HTTP request. + /// [Optional] 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. + /// + /// The value returned by the downstream web API. + /// + /// + /// var result = await _downstreamApi.GetForUserAsync<MyItem, IEnumerable<MyItem>>( + /// "MyService", + /// myItem, + /// options => + /// { + /// options.RelativePath = $"api/todolist/{myItem.Id}"; + /// }); + /// + /// +#if NET6_0_OR_GREATER + [RequiresUnreferencedCode("This method's implementations also use generic types and are not trim-friendly.")] +#endif + public Task GetForUserAsync( + string? serviceName, + TInput input, + Action? downstreamApiOptionsOverride = null, + ClaimsPrincipal? user = null, + CancellationToken cancellationToken = default)where TOutput : class; + +#if NET8_0_OR_GREATER + /// + /// Calls, using , a downstream API with some input data and returning data. + /// By default the input data is serialized in JSON and the returned data is deserialized from JSON but you can provide your own serializer and your own deserializer in the action + /// you pass-in through the parameter. + /// + /// Generic input type. + /// Generic output type. + + /// JSON serialization metadata for TInput + /// JSON serialization metadata for TOutput + /// 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. + /// Data sent to the downstream web API, through the body or the HTTP request. + /// [Optional] 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. + /// + /// The value returned by the downstream web API. + /// + /// + /// var result = await _downstreamApi.GetForUserAsync<MyItem, IEnumerable<MyItem>>( + /// "MyService", + /// myItem, + /// options => + /// { + /// options.RelativePath = $"api/todolist/{myItem.Id}"; + /// }); + /// + /// + public Task GetForUserAsync( + string? serviceName, + TInput input, + JsonTypeInfo inputJsonTypeInfo, + JsonTypeInfo outputJsonTypeInfo, + Action? downstreamApiOptionsOverride = null, + ClaimsPrincipal? user = null, + CancellationToken cancellationToken = default)where TOutput : class; +#endif + + /// + /// Calls, using , a downstream API returning data. + /// By default the returned data is deserialized from JSON but you can provide your own deserializer in the action + /// you pass-in through the parameter. + /// + /// Generic 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. + /// [Optional] Overrides the options proposed in the configuration described + /// by . + /// + /// a Task + /// + /// + /// var result = await _downstreamApi.GetForAppAsync<IEnumerable<MyItem>>( + /// "MyService", + /// options => + /// { + /// options.RelativePath = $"api/todolist"; + /// }); + /// + /// +#if NET6_0_OR_GREATER + [RequiresUnreferencedCode("This method's implementations also use generic types and are not trim-friendly.")] +#endif + public Task GetForAppAsync( + string? serviceName, + Action? downstreamApiOptionsOverride = null, + CancellationToken cancellationToken = default)where TOutput : class; + +#if NET8_0_OR_GREATER + /// + /// Calls, using , a downstream API returning data. + /// By default the returned data is deserialized from JSON but you can provide your own deserializer in the action + /// you pass-in through the parameter. + /// + /// Generic output type. + + /// JSON serialization metadata for TOutput + /// 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. + /// [Optional] Overrides the options proposed in the configuration described + /// by . + /// + /// a Task + /// + /// + /// var result = await _downstreamApi.GetForAppAsync<IEnumerable<MyItem>>( + /// "MyService", + /// options => + /// { + /// options.RelativePath = $"api/todolist"; + /// }); + /// + /// + public Task GetForAppAsync( + string? serviceName, + JsonTypeInfo outputJsonTypeInfo, + Action? downstreamApiOptionsOverride = null, + CancellationToken cancellationToken = default)where TOutput : class; +#endif + + /// + /// Calls, using , a downstream API with some input data and returning data. + /// By default the input data is serialized in JSON and the returned data is deserialized from JSON but you can provide your own serializer and your own deserializer in the action + /// you pass-in through the parameter. + /// + /// Generic input type. + /// Generic 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. + /// Data sent to the downstream web API, through the body or the HTTP request. + /// [Optional] Overrides the options proposed in the configuration described + /// by . + /// + /// The value returned by the downstream web API. + /// + /// + /// var result = await _downstreamApi.GetForAppAsync<MyItem, IEnumerable<MyItem>>( + /// "MyService", + /// myItem, + /// options => + /// { + /// options.RelativePath = $"api/todolist/{myItem.Id}"; + /// }); + /// + /// +#if NET6_0_OR_GREATER + [RequiresUnreferencedCode("This method's implementations also use generic types and are not trim-friendly.")] +#endif + public Task GetForAppAsync( + string? serviceName, + TInput input, + Action? downstreamApiOptionsOverride = null, + CancellationToken cancellationToken = default)where TOutput : class; + +#if NET8_0_OR_GREATER /// /// Calls, using , a downstream API with some input data and returning data. /// By default the input data is serialized in JSON and the returned data is deserialized from JSON but you can provide your own serializer and your own deserializer in the action /// you pass-in through the parameter. /// /// Generic input type. - /// Generic output type. + /// Generic output type. + + /// JSON serialization metadata for TInput + /// JSON serialization metadata for TOutput + /// 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. + /// Data sent to the downstream web API, through the body or the HTTP request. + /// [Optional] Overrides the options proposed in the configuration described + /// by . + /// + /// The value returned by the downstream web API. + /// + /// + /// var result = await _downstreamApi.GetForAppAsync<MyItem, IEnumerable<MyItem>>( + /// "MyService", + /// myItem, + /// options => + /// { + /// options.RelativePath = $"api/todolist/{myItem.Id}"; + /// }); + /// + /// + public Task GetForAppAsync( + string? serviceName, + TInput input, + JsonTypeInfo inputJsonTypeInfo, + JsonTypeInfo outputJsonTypeInfo, + Action? downstreamApiOptionsOverride = null, + CancellationToken cancellationToken = default)where TOutput : class; +#endif + + /// + /// Calls, using , a downstream API with some input data . + /// By default the input data is serialized in JSON but you can provide your own serializer in the action + /// you pass-in through the parameter. + /// + /// Generic input 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. + /// Data sent to the downstream web API, through the body or the HTTP request. + /// [Optional] 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. + /// + /// The value returned by the downstream web API. + /// + /// + /// await _downstreamApi.PostForUserAsync<MyItem>( + /// "MyService", + /// myItem, + /// options => + /// { + /// options.RelativePath = $"api/todolist/{myItem.Id}"; + /// }); + /// + /// +#if NET6_0_OR_GREATER + [RequiresUnreferencedCode("This method's implementations also use generic types and are not trim-friendly.")] +#endif + public Task PostForUserAsync( + string? serviceName, + TInput input, + Action? downstreamApiOptionsOverride = null, + ClaimsPrincipal? user = null, + CancellationToken cancellationToken = default); + +#if NET8_0_OR_GREATER + /// + /// Calls, using , a downstream API with some input data . + /// By default the input data is serialized in JSON but you can provide your own serializer in the action + /// you pass-in through the parameter. + /// + /// Generic input type. + + /// JSON serialization metadata for TInput + /// 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. + /// Data sent to the downstream web API, through the body or the HTTP request. + /// [Optional] 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. + /// + /// The value returned by the downstream web API. + /// + /// + /// await _downstreamApi.PostForUserAsync<MyItem>( + /// "MyService", + /// myItem, + /// options => + /// { + /// options.RelativePath = $"api/todolist/{myItem.Id}"; + /// }); + /// + /// + public Task PostForUserAsync( + string? serviceName, + TInput input, + JsonTypeInfo inputJsonTypeInfo, + Action? downstreamApiOptionsOverride = null, + ClaimsPrincipal? user = null, + CancellationToken cancellationToken = default); +#endif + + /// + /// Calls, using , a downstream API with some input data and returning data. + /// By default the input data is serialized in JSON and the returned data is deserialized from JSON but you can provide your own serializer and your own deserializer in the action + /// you pass-in through the parameter. + /// + /// Generic input type. + /// Generic 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. + /// Data sent to the downstream web API, through the body or the HTTP request. + /// [Optional] 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. + /// + /// The value returned by the downstream web API. + /// + /// + /// var result = await _downstreamApi.PostForUserAsync<MyItem, IEnumerable<MyItem>>( + /// "MyService", + /// myItem, + /// options => + /// { + /// options.RelativePath = $"api/todolist/{myItem.Id}"; + /// }); + /// + /// +#if NET6_0_OR_GREATER + [RequiresUnreferencedCode("This method's implementations also use generic types and are not trim-friendly.")] +#endif + public Task PostForUserAsync( + string? serviceName, + TInput input, + Action? downstreamApiOptionsOverride = null, + ClaimsPrincipal? user = null, + CancellationToken cancellationToken = default)where TOutput : class; + +#if NET8_0_OR_GREATER + /// + /// Calls, using , a downstream API with some input data and returning data. + /// By default the input data is serialized in JSON and the returned data is deserialized from JSON but you can provide your own serializer and your own deserializer in the action + /// you pass-in through the parameter. + /// + /// Generic input type. + /// Generic output type. + + /// JSON serialization metadata for TInput + /// JSON serialization metadata for TOutput + /// 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. + /// Data sent to the downstream web API, through the body or the HTTP request. + /// [Optional] 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. + /// + /// The value returned by the downstream web API. + /// + /// + /// var result = await _downstreamApi.PostForUserAsync<MyItem, IEnumerable<MyItem>>( + /// "MyService", + /// myItem, + /// options => + /// { + /// options.RelativePath = $"api/todolist/{myItem.Id}"; + /// }); + /// + /// + public Task PostForUserAsync( + string? serviceName, + TInput input, + JsonTypeInfo inputJsonTypeInfo, + JsonTypeInfo outputJsonTypeInfo, + Action? downstreamApiOptionsOverride = null, + ClaimsPrincipal? user = null, + CancellationToken cancellationToken = default)where TOutput : class; +#endif + + /// + /// Calls, using , a downstream API with some input data . + /// By default the input data is serialized in JSON but you can provide your own serializer in the action + /// you pass-in through the parameter. + /// + /// Generic input 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. + /// Data sent to the downstream web API, through the body or the HTTP request. + /// [Optional] Overrides the options proposed in the configuration described + /// by . + /// + /// The value returned by the downstream web API. + /// + /// + /// await _downstreamApi.PostForAppAsync<MyItem>( + /// "MyService", + /// myItem, + /// options => + /// { + /// options.RelativePath = $"api/todolist/{myItem.Id}"; + /// }); + /// + /// +#if NET6_0_OR_GREATER + [RequiresUnreferencedCode("This method's implementations also use generic types and are not trim-friendly.")] +#endif + public Task PostForAppAsync( + string? serviceName, + TInput input, + Action? downstreamApiOptionsOverride = null, + CancellationToken cancellationToken = default); + +#if NET8_0_OR_GREATER + /// + /// Calls, using , a downstream API with some input data . + /// By default the input data is serialized in JSON but you can provide your own serializer in the action + /// you pass-in through the parameter. + /// + /// Generic input type. + + /// JSON serialization metadata for TInput + /// 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. + /// Data sent to the downstream web API, through the body or the HTTP request. + /// [Optional] Overrides the options proposed in the configuration described + /// by . + /// + /// The value returned by the downstream web API. + /// + /// + /// await _downstreamApi.PostForAppAsync<MyItem>( + /// "MyService", + /// myItem, + /// options => + /// { + /// options.RelativePath = $"api/todolist/{myItem.Id}"; + /// }); + /// + /// + public Task PostForAppAsync( + string? serviceName, + TInput input, + JsonTypeInfo inputJsonTypeInfo, + Action? downstreamApiOptionsOverride = null, + CancellationToken cancellationToken = default); +#endif + + /// + /// Calls, using , a downstream API with some input data and returning data. + /// By default the input data is serialized in JSON and the returned data is deserialized from JSON but you can provide your own serializer and your own deserializer in the action + /// you pass-in through the parameter. + /// + /// Generic input type. + /// Generic 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. + /// Data sent to the downstream web API, through the body or the HTTP request. + /// [Optional] Overrides the options proposed in the configuration described + /// by . + /// + /// The value returned by the downstream web API. + /// + /// + /// var result = await _downstreamApi.PostForAppAsync<MyItem, IEnumerable<MyItem>>( + /// "MyService", + /// myItem, + /// options => + /// { + /// options.RelativePath = $"api/todolist/{myItem.Id}"; + /// }); + /// + /// +#if NET6_0_OR_GREATER + [RequiresUnreferencedCode("This method's implementations also use generic types and are not trim-friendly.")] +#endif + public Task PostForAppAsync( + string? serviceName, + TInput input, + Action? downstreamApiOptionsOverride = null, + CancellationToken cancellationToken = default)where TOutput : class; + +#if NET8_0_OR_GREATER + /// + /// Calls, using , a downstream API with some input data and returning data. + /// By default the input data is serialized in JSON and the returned data is deserialized from JSON but you can provide your own serializer and your own deserializer in the action + /// you pass-in through the parameter. + /// + /// Generic input type. + /// Generic output type. + + /// JSON serialization metadata for TInput + /// JSON serialization metadata for TOutput + /// 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. + /// Data sent to the downstream web API, through the body or the HTTP request. + /// [Optional] Overrides the options proposed in the configuration described + /// by . + /// + /// The value returned by the downstream web API. + /// + /// + /// var result = await _downstreamApi.PostForAppAsync<MyItem, IEnumerable<MyItem>>( + /// "MyService", + /// myItem, + /// options => + /// { + /// options.RelativePath = $"api/todolist/{myItem.Id}"; + /// }); + /// + /// + public Task PostForAppAsync( + string? serviceName, + TInput input, + JsonTypeInfo inputJsonTypeInfo, + JsonTypeInfo outputJsonTypeInfo, + Action? downstreamApiOptionsOverride = null, + CancellationToken cancellationToken = default)where TOutput : class; +#endif + + /// + /// Calls, using , a downstream API with some input data . + /// By default the input data is serialized in JSON but you can provide your own serializer in the action + /// you pass-in through the parameter. + /// + /// Generic input 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. + /// Data sent to the downstream web API, through the body or the HTTP request. + /// [Optional] 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. + /// + /// The value returned by the downstream web API. + /// + /// + /// await _downstreamApi.PutForUserAsync<MyItem>( + /// "MyService", + /// myItem, + /// options => + /// { + /// options.RelativePath = $"api/todolist/{myItem.Id}"; + /// }); + /// + /// +#if NET6_0_OR_GREATER + [RequiresUnreferencedCode("This method's implementations also use generic types and are not trim-friendly.")] +#endif + public Task PutForUserAsync( + string? serviceName, + TInput input, + Action? downstreamApiOptionsOverride = null, + ClaimsPrincipal? user = null, + CancellationToken cancellationToken = default); + +#if NET8_0_OR_GREATER + /// + /// Calls, using , a downstream API with some input data . + /// By default the input data is serialized in JSON but you can provide your own serializer in the action + /// you pass-in through the parameter. + /// + /// Generic input type. + + /// JSON serialization metadata for TInput + /// 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. + /// Data sent to the downstream web API, through the body or the HTTP request. + /// [Optional] 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. + /// + /// The value returned by the downstream web API. + /// + /// + /// await _downstreamApi.PutForUserAsync<MyItem>( + /// "MyService", + /// myItem, + /// options => + /// { + /// options.RelativePath = $"api/todolist/{myItem.Id}"; + /// }); + /// + /// + public Task PutForUserAsync( + string? serviceName, + TInput input, + JsonTypeInfo inputJsonTypeInfo, + Action? downstreamApiOptionsOverride = null, + ClaimsPrincipal? user = null, + CancellationToken cancellationToken = default); +#endif + + /// + /// Calls, using , a downstream API with some input data and returning data. + /// By default the input data is serialized in JSON and the returned data is deserialized from JSON but you can provide your own serializer and your own deserializer in the action + /// you pass-in through the parameter. + /// + /// Generic input type. + /// Generic 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. + /// Data sent to the downstream web API, through the body or the HTTP request. + /// [Optional] 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. + /// + /// The value returned by the downstream web API. + /// + /// + /// var result = await _downstreamApi.PutForUserAsync<MyItem, IEnumerable<MyItem>>( + /// "MyService", + /// myItem, + /// options => + /// { + /// options.RelativePath = $"api/todolist/{myItem.Id}"; + /// }); + /// + /// +#if NET6_0_OR_GREATER + [RequiresUnreferencedCode("This method's implementations also use generic types and are not trim-friendly.")] +#endif + public Task PutForUserAsync( + string? serviceName, + TInput input, + Action? downstreamApiOptionsOverride = null, + ClaimsPrincipal? user = null, + CancellationToken cancellationToken = default)where TOutput : class; + +#if NET8_0_OR_GREATER + /// + /// Calls, using , a downstream API with some input data and returning data. + /// By default the input data is serialized in JSON and the returned data is deserialized from JSON but you can provide your own serializer and your own deserializer in the action + /// you pass-in through the parameter. + /// + /// Generic input type. + /// Generic output type. + + /// JSON serialization metadata for TInput + /// JSON serialization metadata for TOutput + /// 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. + /// Data sent to the downstream web API, through the body or the HTTP request. + /// [Optional] 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. + /// + /// The value returned by the downstream web API. + /// + /// + /// var result = await _downstreamApi.PutForUserAsync<MyItem, IEnumerable<MyItem>>( + /// "MyService", + /// myItem, + /// options => + /// { + /// options.RelativePath = $"api/todolist/{myItem.Id}"; + /// }); + /// + /// + public Task PutForUserAsync( + string? serviceName, + TInput input, + JsonTypeInfo inputJsonTypeInfo, + JsonTypeInfo outputJsonTypeInfo, + Action? downstreamApiOptionsOverride = null, + ClaimsPrincipal? user = null, + CancellationToken cancellationToken = default)where TOutput : class; +#endif + + /// + /// Calls, using , a downstream API with some input data . + /// By default the input data is serialized in JSON but you can provide your own serializer in the action + /// you pass-in through the parameter. + /// + /// Generic input 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. + /// Data sent to the downstream web API, through the body or the HTTP request. + /// [Optional] Overrides the options proposed in the configuration described + /// by . + /// + /// The value returned by the downstream web API. + /// + /// + /// await _downstreamApi.PutForAppAsync<MyItem>( + /// "MyService", + /// myItem, + /// options => + /// { + /// options.RelativePath = $"api/todolist/{myItem.Id}"; + /// }); + /// + /// +#if NET6_0_OR_GREATER + [RequiresUnreferencedCode("This method's implementations also use generic types and are not trim-friendly.")] +#endif + public Task PutForAppAsync( + string? serviceName, + TInput input, + Action? downstreamApiOptionsOverride = null, + CancellationToken cancellationToken = default); + +#if NET8_0_OR_GREATER + /// + /// Calls, using , a downstream API with some input data . + /// By default the input data is serialized in JSON but you can provide your own serializer in the action + /// you pass-in through the parameter. + /// + /// Generic input type. + + /// JSON serialization metadata for TInput /// 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 @@ -68,14 +845,11 @@ public partial interface IDownstreamApi /// Data sent to the downstream web API, through the body or the HTTP request. /// [Optional] 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. /// /// The value returned by the downstream web API. /// /// - /// var result = await _downstreamApi.GetForUserAsync<MyItem, IEnumerable<MyItem>>( + /// await _downstreamApi.PutForAppAsync<MyItem>( /// "MyService", /// myItem, /// options => @@ -84,55 +858,61 @@ public partial interface IDownstreamApi /// }); /// /// -#if NET6_0_OR_GREATER - [RequiresUnreferencedCode("This method's implementations also use generic types and are not trim-friendly.")] -#endif - public Task GetForUserAsync( + public Task PutForAppAsync( string? serviceName, TInput input, + JsonTypeInfo inputJsonTypeInfo, Action? downstreamApiOptionsOverride = null, - ClaimsPrincipal? user = null, - CancellationToken cancellationToken = default)where TOutput : class; + CancellationToken cancellationToken = default); +#endif /// - /// Calls, using , a downstream API returning data. - /// By default the returned data is deserialized from JSON but you can provide your own deserializer in the action + /// Calls, using , a downstream API with some input data and returning data. + /// By default the input data is serialized in JSON and the returned data is deserialized from JSON but you can provide your own serializer and your own deserializer in the action /// you pass-in through the parameter. /// + /// Generic input type. /// Generic 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. + /// Data sent to the downstream web API, through the body or the HTTP request. /// [Optional] Overrides the options proposed in the configuration described /// by . /// - /// a Task + /// The value returned by the downstream web API. /// /// - /// var result = await _downstreamApi.GetForAppAsync<IEnumerable<MyItem>>( + /// var result = await _downstreamApi.PutForAppAsync<MyItem, IEnumerable<MyItem>>( /// "MyService", + /// myItem, /// options => /// { - /// options.RelativePath = $"api/todolist"; + /// options.RelativePath = $"api/todolist/{myItem.Id}"; /// }); /// /// #if NET6_0_OR_GREATER [RequiresUnreferencedCode("This method's implementations also use generic types and are not trim-friendly.")] #endif - public Task GetForAppAsync( + public Task PutForAppAsync( string? serviceName, + TInput input, Action? downstreamApiOptionsOverride = null, CancellationToken cancellationToken = default)where TOutput : class; +#if NET8_0_OR_GREATER /// - /// Calls, using , a downstream API with some input data and returning data. + /// Calls, using , a downstream API with some input data and returning data. /// By default the input data is serialized in JSON and the returned data is deserialized from JSON but you can provide your own serializer and your own deserializer in the action /// you pass-in through the parameter. /// /// Generic input type. /// Generic output type. + + /// JSON serialization metadata for TInput + /// JSON serialization metadata for TOutput /// 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 @@ -144,7 +924,7 @@ public partial interface IDownstreamApi /// The value returned by the downstream web API. /// /// - /// var result = await _downstreamApi.GetForAppAsync<MyItem, IEnumerable<MyItem>>( + /// var result = await _downstreamApi.PutForAppAsync<MyItem, IEnumerable<MyItem>>( /// "MyService", /// myItem, /// options => @@ -153,17 +933,19 @@ public partial interface IDownstreamApi /// }); /// /// -#if NET6_0_OR_GREATER - [RequiresUnreferencedCode("This method's implementations also use generic types and are not trim-friendly.")] -#endif - public Task GetForAppAsync( + public Task PutForAppAsync( string? serviceName, TInput input, + JsonTypeInfo inputJsonTypeInfo, + JsonTypeInfo outputJsonTypeInfo, Action? downstreamApiOptionsOverride = null, CancellationToken cancellationToken = default)where TOutput : class; +#endif + +#if NETSTANDARD2_1_OR_GREATER /// - /// Calls, using , a downstream API with some input data . + /// Calls, using , a downstream API with some input data . /// By default the input data is serialized in JSON but you can provide your own serializer in the action /// you pass-in through the parameter. /// @@ -182,7 +964,7 @@ public partial interface IDownstreamApi /// The value returned by the downstream web API. /// /// - /// await _downstreamApi.PostForUserAsync<MyItem>( + /// await _downstreamApi.PatchForUserAsync<MyItem>( /// "MyService", /// myItem, /// options => @@ -194,20 +976,22 @@ public partial interface IDownstreamApi #if NET6_0_OR_GREATER [RequiresUnreferencedCode("This method's implementations also use generic types and are not trim-friendly.")] #endif - public Task PostForUserAsync( + public Task PatchForUserAsync( string? serviceName, TInput input, Action? downstreamApiOptionsOverride = null, ClaimsPrincipal? user = null, CancellationToken cancellationToken = default); +#if NET8_0_OR_GREATER /// - /// Calls, using , a downstream API with some input data and returning data. - /// By default the input data is serialized in JSON and the returned data is deserialized from JSON but you can provide your own serializer and your own deserializer in the action + /// Calls, using , a downstream API with some input data . + /// By default the input data is serialized in JSON but you can provide your own serializer in the action /// you pass-in through the parameter. /// /// Generic input type. - /// Generic output type. + + /// JSON serialization metadata for TInput /// 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 @@ -222,7 +1006,7 @@ public Task PostForUserAsync( /// The value returned by the downstream web API. /// /// - /// var result = await _downstreamApi.PostForUserAsync<MyItem, IEnumerable<MyItem>>( + /// await _downstreamApi.PatchForUserAsync<MyItem>( /// "MyService", /// myItem, /// options => @@ -231,22 +1015,22 @@ public Task PostForUserAsync( /// }); /// /// -#if NET6_0_OR_GREATER - [RequiresUnreferencedCode("This method's implementations also use generic types and are not trim-friendly.")] -#endif - public Task PostForUserAsync( + public Task PatchForUserAsync( string? serviceName, TInput input, + JsonTypeInfo inputJsonTypeInfo, Action? downstreamApiOptionsOverride = null, ClaimsPrincipal? user = null, - CancellationToken cancellationToken = default)where TOutput : class; + CancellationToken cancellationToken = default); +#endif /// - /// Calls, using , a downstream API with some input data . - /// By default the input data is serialized in JSON but you can provide your own serializer in the action + /// Calls, using , a downstream API with some input data and returning data. + /// By default the input data is serialized in JSON and the returned data is deserialized from JSON but you can provide your own serializer and your own deserializer in the action /// you pass-in through the parameter. /// /// Generic input type. + /// Generic 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 @@ -254,11 +1038,14 @@ public Task PostForUserAsync( /// Data sent to the downstream web API, through the body or the HTTP request. /// [Optional] 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. /// /// The value returned by the downstream web API. /// /// - /// await _downstreamApi.PostForAppAsync<MyItem>( + /// var result = await _downstreamApi.PatchForUserAsync<MyItem, IEnumerable<MyItem>>( /// "MyService", /// myItem, /// options => @@ -270,19 +1057,24 @@ public Task PostForUserAsync( #if NET6_0_OR_GREATER [RequiresUnreferencedCode("This method's implementations also use generic types and are not trim-friendly.")] #endif - public Task PostForAppAsync( + public Task PatchForUserAsync( string? serviceName, TInput input, Action? downstreamApiOptionsOverride = null, - CancellationToken cancellationToken = default); + ClaimsPrincipal? user = null, + CancellationToken cancellationToken = default)where TOutput : class; +#if NET8_0_OR_GREATER /// - /// Calls, using , a downstream API with some input data and returning data. + /// Calls, using , a downstream API with some input data and returning data. /// By default the input data is serialized in JSON and the returned data is deserialized from JSON but you can provide your own serializer and your own deserializer in the action /// you pass-in through the parameter. /// /// Generic input type. /// Generic output type. + + /// JSON serialization metadata for TInput + /// JSON serialization metadata for TOutput /// 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 @@ -290,11 +1082,14 @@ public Task PostForAppAsync( /// Data sent to the downstream web API, through the body or the HTTP request. /// [Optional] 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. /// /// The value returned by the downstream web API. /// /// - /// var result = await _downstreamApi.PostForAppAsync<MyItem, IEnumerable<MyItem>>( + /// var result = await _downstreamApi.PatchForUserAsync<MyItem, IEnumerable<MyItem>>( /// "MyService", /// myItem, /// options => @@ -303,17 +1098,18 @@ public Task PostForAppAsync( /// }); /// /// -#if NET6_0_OR_GREATER - [RequiresUnreferencedCode("This method's implementations also use generic types and are not trim-friendly.")] -#endif - public Task PostForAppAsync( + public Task PatchForUserAsync( string? serviceName, TInput input, + JsonTypeInfo inputJsonTypeInfo, + JsonTypeInfo outputJsonTypeInfo, Action? downstreamApiOptionsOverride = null, + ClaimsPrincipal? user = null, CancellationToken cancellationToken = default)where TOutput : class; +#endif /// - /// Calls, using , a downstream API with some input data . + /// Calls, using , a downstream API with some input data . /// By default the input data is serialized in JSON but you can provide your own serializer in the action /// you pass-in through the parameter. /// @@ -325,14 +1121,11 @@ public Task PostForAppAsync( /// Data sent to the downstream web API, through the body or the HTTP request. /// [Optional] 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. /// /// The value returned by the downstream web API. /// /// - /// await _downstreamApi.PutForUserAsync<MyItem>( + /// await _downstreamApi.PatchForAppAsync<MyItem>( /// "MyService", /// myItem, /// options => @@ -344,20 +1137,21 @@ public Task PostForAppAsync( #if NET6_0_OR_GREATER [RequiresUnreferencedCode("This method's implementations also use generic types and are not trim-friendly.")] #endif - public Task PutForUserAsync( + public Task PatchForAppAsync( string? serviceName, TInput input, Action? downstreamApiOptionsOverride = null, - ClaimsPrincipal? user = null, CancellationToken cancellationToken = default); +#if NET8_0_OR_GREATER /// - /// Calls, using , a downstream API with some input data and returning data. - /// By default the input data is serialized in JSON and the returned data is deserialized from JSON but you can provide your own serializer and your own deserializer in the action + /// Calls, using , a downstream API with some input data . + /// By default the input data is serialized in JSON but you can provide your own serializer in the action /// you pass-in through the parameter. /// /// Generic input type. - /// Generic output type. + + /// JSON serialization metadata for TInput /// 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 @@ -365,14 +1159,11 @@ public Task PutForUserAsync( /// Data sent to the downstream web API, through the body or the HTTP request. /// [Optional] 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. /// /// The value returned by the downstream web API. /// /// - /// var result = await _downstreamApi.PutForUserAsync<MyItem, IEnumerable<MyItem>>( + /// await _downstreamApi.PatchForAppAsync<MyItem>( /// "MyService", /// myItem, /// options => @@ -381,22 +1172,21 @@ public Task PutForUserAsync( /// }); /// /// -#if NET6_0_OR_GREATER - [RequiresUnreferencedCode("This method's implementations also use generic types and are not trim-friendly.")] -#endif - public Task PutForUserAsync( + public Task PatchForAppAsync( string? serviceName, TInput input, + JsonTypeInfo inputJsonTypeInfo, Action? downstreamApiOptionsOverride = null, - ClaimsPrincipal? user = null, - CancellationToken cancellationToken = default)where TOutput : class; + CancellationToken cancellationToken = default); +#endif /// - /// Calls, using , a downstream API with some input data . - /// By default the input data is serialized in JSON but you can provide your own serializer in the action + /// Calls, using , a downstream API with some input data and returning data. + /// By default the input data is serialized in JSON and the returned data is deserialized from JSON but you can provide your own serializer and your own deserializer in the action /// you pass-in through the parameter. /// /// Generic input type. + /// Generic 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 @@ -408,7 +1198,7 @@ public Task PutForUserAsync( /// The value returned by the downstream web API. /// /// - /// await _downstreamApi.PutForAppAsync<MyItem>( + /// var result = await _downstreamApi.PatchForAppAsync<MyItem, IEnumerable<MyItem>>( /// "MyService", /// myItem, /// options => @@ -420,19 +1210,23 @@ public Task PutForUserAsync( #if NET6_0_OR_GREATER [RequiresUnreferencedCode("This method's implementations also use generic types and are not trim-friendly.")] #endif - public Task PutForAppAsync( + public Task PatchForAppAsync( string? serviceName, TInput input, Action? downstreamApiOptionsOverride = null, - CancellationToken cancellationToken = default); + CancellationToken cancellationToken = default)where TOutput : class; +#if NET8_0_OR_GREATER /// - /// Calls, using , a downstream API with some input data and returning data. + /// Calls, using , a downstream API with some input data and returning data. /// By default the input data is serialized in JSON and the returned data is deserialized from JSON but you can provide your own serializer and your own deserializer in the action /// you pass-in through the parameter. /// /// Generic input type. /// Generic output type. + + /// JSON serialization metadata for TInput + /// JSON serialization metadata for TOutput /// 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 @@ -444,7 +1238,7 @@ public Task PutForAppAsync( /// The value returned by the downstream web API. /// /// - /// var result = await _downstreamApi.PutForAppAsync<MyItem, IEnumerable<MyItem>>( + /// var result = await _downstreamApi.PatchForAppAsync<MyItem, IEnumerable<MyItem>>( /// "MyService", /// myItem, /// options => @@ -453,19 +1247,19 @@ public Task PutForAppAsync( /// }); /// /// -#if NET6_0_OR_GREATER - [RequiresUnreferencedCode("This method's implementations also use generic types and are not trim-friendly.")] -#endif - public Task PutForAppAsync( + public Task PatchForAppAsync( string? serviceName, TInput input, + JsonTypeInfo inputJsonTypeInfo, + JsonTypeInfo outputJsonTypeInfo, Action? downstreamApiOptionsOverride = null, CancellationToken cancellationToken = default)where TOutput : class; +#endif -#if NETSTANDARD2_1_OR_GREATER +#endif // NETSTANDARD2_1_OR_GREATER /// - /// Calls, using , a downstream API with some input data . + /// Calls, using , a downstream API with some input data . /// By default the input data is serialized in JSON but you can provide your own serializer in the action /// you pass-in through the parameter. /// @@ -484,7 +1278,7 @@ public Task PutForAppAsync( /// The value returned by the downstream web API. /// /// - /// await _downstreamApi.PatchForUserAsync<MyItem>( + /// await _downstreamApi.DeleteForUserAsync<MyItem>( /// "MyService", /// myItem, /// options => @@ -496,20 +1290,22 @@ public Task PutForAppAsync( #if NET6_0_OR_GREATER [RequiresUnreferencedCode("This method's implementations also use generic types and are not trim-friendly.")] #endif - public Task PatchForUserAsync( + public Task DeleteForUserAsync( string? serviceName, TInput input, Action? downstreamApiOptionsOverride = null, ClaimsPrincipal? user = null, CancellationToken cancellationToken = default); +#if NET8_0_OR_GREATER /// - /// Calls, using , a downstream API with some input data and returning data. - /// By default the input data is serialized in JSON and the returned data is deserialized from JSON but you can provide your own serializer and your own deserializer in the action + /// Calls, using , a downstream API with some input data . + /// By default the input data is serialized in JSON but you can provide your own serializer in the action /// you pass-in through the parameter. /// /// Generic input type. - /// Generic output type. + + /// JSON serialization metadata for TInput /// 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 @@ -524,7 +1320,7 @@ public Task PatchForUserAsync( /// The value returned by the downstream web API. /// /// - /// var result = await _downstreamApi.PatchForUserAsync<MyItem, IEnumerable<MyItem>>( + /// await _downstreamApi.DeleteForUserAsync<MyItem>( /// "MyService", /// myItem, /// options => @@ -533,22 +1329,22 @@ public Task PatchForUserAsync( /// }); /// /// -#if NET6_0_OR_GREATER - [RequiresUnreferencedCode("This method's implementations also use generic types and are not trim-friendly.")] -#endif - public Task PatchForUserAsync( + public Task DeleteForUserAsync( string? serviceName, TInput input, + JsonTypeInfo inputJsonTypeInfo, Action? downstreamApiOptionsOverride = null, ClaimsPrincipal? user = null, - CancellationToken cancellationToken = default)where TOutput : class; + CancellationToken cancellationToken = default); +#endif /// - /// Calls, using , a downstream API with some input data . - /// By default the input data is serialized in JSON but you can provide your own serializer in the action + /// Calls, using , a downstream API with some input data and returning data. + /// By default the input data is serialized in JSON and the returned data is deserialized from JSON but you can provide your own serializer and your own deserializer in the action /// you pass-in through the parameter. /// /// Generic input type. + /// Generic 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 @@ -556,11 +1352,14 @@ public Task PatchForUserAsync( /// Data sent to the downstream web API, through the body or the HTTP request. /// [Optional] 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. /// /// The value returned by the downstream web API. /// /// - /// await _downstreamApi.PatchForAppAsync<MyItem>( + /// var result = await _downstreamApi.DeleteForUserAsync<MyItem, IEnumerable<MyItem>>( /// "MyService", /// myItem, /// options => @@ -572,19 +1371,24 @@ public Task PatchForUserAsync( #if NET6_0_OR_GREATER [RequiresUnreferencedCode("This method's implementations also use generic types and are not trim-friendly.")] #endif - public Task PatchForAppAsync( + public Task DeleteForUserAsync( string? serviceName, TInput input, Action? downstreamApiOptionsOverride = null, - CancellationToken cancellationToken = default); + ClaimsPrincipal? user = null, + CancellationToken cancellationToken = default)where TOutput : class; +#if NET8_0_OR_GREATER /// - /// Calls, using , a downstream API with some input data and returning data. + /// Calls, using , a downstream API with some input data and returning data. /// By default the input data is serialized in JSON and the returned data is deserialized from JSON but you can provide your own serializer and your own deserializer in the action /// you pass-in through the parameter. /// /// Generic input type. /// Generic output type. + + /// JSON serialization metadata for TInput + /// JSON serialization metadata for TOutput /// 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 @@ -592,11 +1396,14 @@ public Task PatchForAppAsync( /// Data sent to the downstream web API, through the body or the HTTP request. /// [Optional] 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. /// /// The value returned by the downstream web API. /// /// - /// var result = await _downstreamApi.PatchForAppAsync<MyItem, IEnumerable<MyItem>>( + /// var result = await _downstreamApi.DeleteForUserAsync<MyItem, IEnumerable<MyItem>>( /// "MyService", /// myItem, /// options => @@ -605,16 +1412,15 @@ public Task PatchForAppAsync( /// }); /// /// -#if NET6_0_OR_GREATER - [RequiresUnreferencedCode("This method's implementations also use generic types and are not trim-friendly.")] -#endif - public Task PatchForAppAsync( + public Task DeleteForUserAsync( string? serviceName, TInput input, + JsonTypeInfo inputJsonTypeInfo, + JsonTypeInfo outputJsonTypeInfo, Action? downstreamApiOptionsOverride = null, + ClaimsPrincipal? user = null, CancellationToken cancellationToken = default)where TOutput : class; - -#endif // NETSTANDARD2_1_OR_GREATER +#endif /// /// Calls, using , a downstream API with some input data . @@ -629,14 +1435,11 @@ public Task PatchForAppAsync( /// Data sent to the downstream web API, through the body or the HTTP request. /// [Optional] 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. /// /// The value returned by the downstream web API. /// /// - /// await _downstreamApi.DeleteForUserAsync<MyItem>( + /// await _downstreamApi.DeleteForAppAsync<MyItem>( /// "MyService", /// myItem, /// options => @@ -648,20 +1451,21 @@ public Task PatchForAppAsync( #if NET6_0_OR_GREATER [RequiresUnreferencedCode("This method's implementations also use generic types and are not trim-friendly.")] #endif - public Task DeleteForUserAsync( + public Task DeleteForAppAsync( string? serviceName, TInput input, Action? downstreamApiOptionsOverride = null, - ClaimsPrincipal? user = null, CancellationToken cancellationToken = default); +#if NET8_0_OR_GREATER /// - /// Calls, using , a downstream API with some input data and returning data. - /// By default the input data is serialized in JSON and the returned data is deserialized from JSON but you can provide your own serializer and your own deserializer in the action + /// Calls, using , a downstream API with some input data . + /// By default the input data is serialized in JSON but you can provide your own serializer in the action /// you pass-in through the parameter. /// /// Generic input type. - /// Generic output type. + + /// JSON serialization metadata for TInput /// 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 @@ -669,14 +1473,11 @@ public Task DeleteForUserAsync( /// Data sent to the downstream web API, through the body or the HTTP request. /// [Optional] 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. /// /// The value returned by the downstream web API. /// /// - /// var result = await _downstreamApi.DeleteForUserAsync<MyItem, IEnumerable<MyItem>>( + /// await _downstreamApi.DeleteForAppAsync<MyItem>( /// "MyService", /// myItem, /// options => @@ -685,22 +1486,21 @@ public Task DeleteForUserAsync( /// }); /// /// -#if NET6_0_OR_GREATER - [RequiresUnreferencedCode("This method's implementations also use generic types and are not trim-friendly.")] -#endif - public Task DeleteForUserAsync( + public Task DeleteForAppAsync( string? serviceName, TInput input, + JsonTypeInfo inputJsonTypeInfo, Action? downstreamApiOptionsOverride = null, - ClaimsPrincipal? user = null, - CancellationToken cancellationToken = default)where TOutput : class; + CancellationToken cancellationToken = default); +#endif /// - /// Calls, using , a downstream API with some input data . - /// By default the input data is serialized in JSON but you can provide your own serializer in the action + /// Calls, using , a downstream API with some input data and returning data. + /// By default the input data is serialized in JSON and the returned data is deserialized from JSON but you can provide your own serializer and your own deserializer in the action /// you pass-in through the parameter. /// /// Generic input type. + /// Generic 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 @@ -712,7 +1512,7 @@ public Task DeleteForUserAsync( /// The value returned by the downstream web API. /// /// - /// await _downstreamApi.DeleteForAppAsync<MyItem>( + /// var result = await _downstreamApi.DeleteForAppAsync<MyItem, IEnumerable<MyItem>>( /// "MyService", /// myItem, /// options => @@ -724,12 +1524,13 @@ public Task DeleteForUserAsync( #if NET6_0_OR_GREATER [RequiresUnreferencedCode("This method's implementations also use generic types and are not trim-friendly.")] #endif - public Task DeleteForAppAsync( + public Task DeleteForAppAsync( string? serviceName, TInput input, Action? downstreamApiOptionsOverride = null, - CancellationToken cancellationToken = default); + CancellationToken cancellationToken = default)where TOutput : class; +#if NET8_0_OR_GREATER /// /// Calls, using , a downstream API with some input data and returning data. /// By default the input data is serialized in JSON and the returned data is deserialized from JSON but you can provide your own serializer and your own deserializer in the action @@ -737,6 +1538,9 @@ public Task DeleteForAppAsync( /// /// Generic input type. /// Generic output type. + + /// JSON serialization metadata for TInput + /// JSON serialization metadata for TOutput /// 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 @@ -757,13 +1561,13 @@ public Task DeleteForAppAsync( /// }); /// /// -#if NET6_0_OR_GREATER - [RequiresUnreferencedCode("This method's implementations also use generic types and are not trim-friendly.")] -#endif public Task DeleteForAppAsync( string? serviceName, TInput input, + JsonTypeInfo inputJsonTypeInfo, + JsonTypeInfo outputJsonTypeInfo, Action? downstreamApiOptionsOverride = null, CancellationToken cancellationToken = default)where TOutput : class; +#endif } } diff --git a/src/Microsoft.Identity.Abstractions/DownstreamApi/IDownstreamApi.HttpMethods.tt b/src/Microsoft.Identity.Abstractions/DownstreamApi/IDownstreamApi.HttpMethods.tt index f9eb7fd..bd65cfa 100644 --- a/src/Microsoft.Identity.Abstractions/DownstreamApi/IDownstreamApi.HttpMethods.tt +++ b/src/Microsoft.Identity.Abstractions/DownstreamApi/IDownstreamApi.HttpMethods.tt @@ -106,6 +106,70 @@ namespace Microsoft.Identity.Abstractions ClaimsPrincipal? user = null, <# } #> CancellationToken cancellationToken = default)<#= hasOutput?"where TOutput : class;" :";" #> + +#if NET8_0_OR_GREATER + /// + /// Calls, using , a downstream API <#= hasInput ? "with some input data " : ""#><#= hasInput&&hasOutput ? "and " : ""#><#= hasOutput ? "returning data" : ""#>. + /// By default <#= hasInput ? "the input data is serialized in JSON " : ""#><#= hasInput&&hasOutput ? "and " : ""#><#= hasOutput ? "the returned data is deserialized from JSON" : ""#> but you can provide <#= hasInput ? "your own serializer " : ""#><#= hasInput&&hasOutput ? "and " : ""#><#= hasOutput ? "your own deserializer " : ""#>in the action + /// you pass-in through the parameter. + /// +<# if (hasInput){ #> + /// Generic input type. +<# } #> +<# if (hasOutput){ #> + /// Generic output type. +<# } #> + +<# if (hasInput){ #> + /// JSON serialization metadata for TInput +<# } #> +<# if (hasOutput){ #> + /// JSON serialization metadata for TOutput +<# } #> + /// 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. +<# if (hasInput){ #> + /// Data sent to the downstream web API, through the body or the HTTP request. +<# } #> + /// [Optional] Overrides the options proposed in the configuration described + /// by . +<# if (!hasApp){ #> + /// [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. +<# } #> + /// + /// <#= hasInput? "The value returned by the downstream web API." : "a Task" #> + /// + /// + /// <#= hasOutput?"var result =" : "" #> await _downstreamApi.<#= httpMethod #>For<#= token #>Async<#= sampleCodeTemplate #>( + /// "MyService", +<# if (hasInput){ #> + /// myItem, +<# } #> + /// options => + /// { + /// options.RelativePath = $"api/todolist<#= hasInput? "/{myItem.Id}": ""#>"; + /// }); + /// + /// + public <#= returnType #> <#= httpMethod #>For<#= token #>Async<#= template #>( + string? serviceName, +<# if (hasInput){ #> + TInput input, + JsonTypeInfo inputJsonTypeInfo, +<# } #> +<# if (hasOutput){ #> + JsonTypeInfo outputJsonTypeInfo, +<# } #> + Action? downstreamApiOptionsOverride = null, +<# if (!hasApp){ #> + ClaimsPrincipal? user = null, +<# } #> + CancellationToken cancellationToken = default)<#= hasOutput?"where TOutput : class;" :";" #> +#endif <# } }