From 40942616bebcdef1e8038a7db2853ff54e82acea Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Tue, 7 Nov 2023 15:29:06 -0500 Subject: [PATCH 1/4] - adds constructor and configure methods to request information --- .../microsoft/kiota/RequestInformation.java | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/components/abstractions/src/main/java/com/microsoft/kiota/RequestInformation.java b/components/abstractions/src/main/java/com/microsoft/kiota/RequestInformation.java index e04714f67..949c3f1e1 100644 --- a/components/abstractions/src/main/java/com/microsoft/kiota/RequestInformation.java +++ b/components/abstractions/src/main/java/com/microsoft/kiota/RequestInformation.java @@ -38,6 +38,46 @@ public class RequestInformation { /** Creates a new instance of the request information class. */ public RequestInformation() { //Default constructor } + /** + * Creates a new instance of the request information class. + * @param method The HTTP method for the request. + * @param urlTemplate The url template for the request. + * @param pathParameters The path parameters for the request. + */ + public RequestInformation(final HttpMethod method, @Nonnull final String urlTemplate, @Nonnull final Map pathParameters) { + this.httpMethod = method; + this.urlTemplate = Objects.requireNonNull(urlTemplate); + this.pathParameters = Objects.requireNonNull(pathParameters); + } + /** + * Configures the request information based on the request configuration and the query parameters getter. + * @param The type of the request configuration. + * @param requestConfiguration The request configuration to apply to the request information. + * @param configurationFactory The factory to create the request configuration from. + */ + public void configure(@Nullable final java.util.function.Consumer requestConfiguration, @Nonnull final java.util.function.Supplier configurationFactory) { + configure(requestConfiguration, configurationFactory, null); + } + /** + * Configures the request information based on the request configuration and the query parameters getter. + * @param The type of the request configuration. + * @param requestConfiguration The request configuration to apply to the request information. + * @param configurationFactory The factory to create the request configuration from. + * @param queryParametersGetter The function to get the query parameters from the request configuration. + */ + public void configure(@Nullable final java.util.function.Consumer requestConfiguration, @Nonnull final java.util.function.Supplier configurationFactory, @Nullable final java.util.function.Function queryParametersGetter) { + Objects.requireNonNull(configurationFactory); + if (requestConfiguration == null) { + return; + } + final T requestConfig = configurationFactory.get(); + requestConfiguration.accept(requestConfig); + if (queryParametersGetter != null) { + addQueryParameters(queryParametersGetter.apply(requestConfig)); + } + headers.putAll(requestConfig.headers); + addRequestOptions(requestConfig.options); + } /** The url template for the current request */ @Nullable public String urlTemplate; From 1a091a7bc2cb3fc03f2f302bcb5401adfca01d70 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Tue, 7 Nov 2023 18:57:42 -0500 Subject: [PATCH 2/4] - fixes getter accesser parameter --- .../src/main/java/com/microsoft/kiota/RequestInformation.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/abstractions/src/main/java/com/microsoft/kiota/RequestInformation.java b/components/abstractions/src/main/java/com/microsoft/kiota/RequestInformation.java index 949c3f1e1..cce4ba4d7 100644 --- a/components/abstractions/src/main/java/com/microsoft/kiota/RequestInformation.java +++ b/components/abstractions/src/main/java/com/microsoft/kiota/RequestInformation.java @@ -65,7 +65,7 @@ public void configure(@Nullable final java. * @param configurationFactory The factory to create the request configuration from. * @param queryParametersGetter The function to get the query parameters from the request configuration. */ - public void configure(@Nullable final java.util.function.Consumer requestConfiguration, @Nonnull final java.util.function.Supplier configurationFactory, @Nullable final java.util.function.Function queryParametersGetter) { + public void configure(@Nullable final java.util.function.Consumer requestConfiguration, @Nonnull final java.util.function.Supplier configurationFactory, @Nullable final java.util.function.Function queryParametersGetter) { Objects.requireNonNull(configurationFactory); if (requestConfiguration == null) { return; From 243ec753f0517ee2c1b42f13213b781dd5606ca6 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Tue, 7 Nov 2023 19:07:05 -0500 Subject: [PATCH 3/4] - bumps minor version --- CHANGELOG.md | 6 ++++++ gradle.properties | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4beaee196..c328a8aa3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +## [0.9.0] - 2023-11-08 + +### Added + +- Added helper methods to request information to reduce the amount of generated code. + ## [0.8.0] - 2023-10-31 ### Added diff --git a/gradle.properties b/gradle.properties index e3b9cf6a5..50ae259c3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -25,7 +25,7 @@ org.gradle.caching=true mavenGroupId = com.microsoft.kiota mavenMajorVersion = 0 -mavenMinorVersion = 8 +mavenMinorVersion = 9 mavenPatchVersion = 0 mavenArtifactSuffix = From 4a18876cd2f948586269d0ff1e449ac3158a356f Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Tue, 7 Nov 2023 19:22:16 -0500 Subject: [PATCH 4/4] - adds missing nullabilty annotation --- .../src/main/java/com/microsoft/kiota/RequestInformation.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/abstractions/src/main/java/com/microsoft/kiota/RequestInformation.java b/components/abstractions/src/main/java/com/microsoft/kiota/RequestInformation.java index cce4ba4d7..170705deb 100644 --- a/components/abstractions/src/main/java/com/microsoft/kiota/RequestInformation.java +++ b/components/abstractions/src/main/java/com/microsoft/kiota/RequestInformation.java @@ -44,8 +44,8 @@ public RequestInformation() { //Default constructor * @param urlTemplate The url template for the request. * @param pathParameters The path parameters for the request. */ - public RequestInformation(final HttpMethod method, @Nonnull final String urlTemplate, @Nonnull final Map pathParameters) { - this.httpMethod = method; + public RequestInformation(@Nonnull final HttpMethod method, @Nonnull final String urlTemplate, @Nonnull final Map pathParameters) { + this.httpMethod = Objects.requireNonNull(method); this.urlTemplate = Objects.requireNonNull(urlTemplate); this.pathParameters = Objects.requireNonNull(pathParameters); }