From 8f1b73b7c75c046adb8f87f1c8aaff5d96617148 Mon Sep 17 00:00:00 2001 From: Bill Wert Date: Mon, 9 Sep 2024 17:40:56 -0700 Subject: [PATCH 1/9] Add WithResponse methods Add missing withResponse methods for sending/receiving with a `RequestOptions`. Also ensure HTTP timeouts are set properly. --- .../EventGridReceiverAsyncClient.java | 188 ++++++++++++++- .../namespaces/EventGridReceiverClient.java | 224 +++++++++++++++++- .../EventGridSenderAsyncClient.java | 55 ++++- .../namespaces/EventGridSenderClient.java | 52 +++- .../src/main/java/module-info.java | 2 + .../namespaces/EventGridAsyncClientTests.java | 105 ++++---- .../namespaces/EventGridClientTestBase.java | 40 ++-- .../namespaces/EventGridClientTests.java | 17 +- 8 files changed, 551 insertions(+), 132 deletions(-) diff --git a/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridReceiverAsyncClient.java b/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridReceiverAsyncClient.java index 36c1049af441..715d77cc3c74 100644 --- a/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridReceiverAsyncClient.java +++ b/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridReceiverAsyncClient.java @@ -13,7 +13,9 @@ import com.azure.core.exception.ResourceNotFoundException; import com.azure.core.http.rest.RequestOptions; import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.SimpleResponse; import com.azure.core.util.BinaryData; +import com.azure.core.util.Context; import com.azure.core.util.FluxUtil; import com.azure.messaging.eventgrid.namespaces.implementation.EventGridReceiverClientImpl; import com.azure.messaging.eventgrid.namespaces.implementation.models.AcknowledgeRequest; @@ -71,7 +73,7 @@ public final class EventGridReceiverAsyncClient { * * You can add these to a request with {@link RequestOptions#addQueryParam} *

Response Body Schema

- * + * *
{@code
      * {
      *     value (Required): [
@@ -119,7 +121,7 @@ Mono> receiveWithResponse(String topicName, String eventSub
      * along with other failed lock tokens with their corresponding error information. Successfully acknowledged events
      * will no longer be available to be received by any consumer.
      * 

Request Body Schema

- * + * *
{@code
      * {
      *     lockTokens (Required): [
@@ -127,9 +129,9 @@ Mono> receiveWithResponse(String topicName, String eventSub
      *     ]
      * }
      * }
- * + * *

Response Body Schema

- * + * *
{@code
      * {
      *     failedLockTokens (Required): [
@@ -187,7 +189,7 @@ Mono> acknowledgeWithResponse(String topicName, String even
      * 
      * You can add these to a request with {@link RequestOptions#addQueryParam}
      * 

Request Body Schema

- * + * *
{@code
      * {
      *     lockTokens (Required): [
@@ -195,9 +197,9 @@ Mono> acknowledgeWithResponse(String topicName, String even
      *     ]
      * }
      * }
- * + * *

Response Body Schema

- * + * *
{@code
      * {
      *     failedLockTokens (Required): [
@@ -246,7 +248,7 @@ Mono> releaseWithResponse(String topicName, String eventSub
      * with other failed lock tokens with their corresponding error information. Successfully rejected events will be
      * dead-lettered and can no longer be received by a consumer.
      * 

Request Body Schema

- * + * *
{@code
      * {
      *     lockTokens (Required): [
@@ -254,9 +256,9 @@ Mono> releaseWithResponse(String topicName, String eventSub
      *     ]
      * }
      * }
- * + * *

Response Body Schema

- * + * *
{@code
      * {
      *     failedLockTokens (Required): [
@@ -305,7 +307,7 @@ Mono> rejectWithResponse(String topicName, String eventSubs
      * along with other failed lock tokens with their corresponding error information. Successfully renewed locks will
      * ensure that the associated event is only available to the consumer that holds the renewed lock.
      * 

Request Body Schema

- * + * *
{@code
      * {
      *     lockTokens (Required): [
@@ -313,9 +315,9 @@ Mono> rejectWithResponse(String topicName, String eventSubs
      *     ]
      * }
      * }
- * + * *

Response Body Schema

- * + * *
{@code
      * {
      *     failedLockTokens (Required): [
@@ -385,12 +387,48 @@ public Mono receive(Integer maxEvents, Duration maxWaitTime) {
             requestOptions.addQueryParam("maxEvents", String.valueOf(maxEvents), false);
         }
         if (maxWaitTime != null) {
+            // Ensure the http client timeout is longer than the maxWaitTime
+            addTimeoutToContext(requestOptions, maxWaitTime);
             requestOptions.addQueryParam("maxWaitTime", String.valueOf(maxWaitTime.getSeconds()), false);
         }
         return receiveWithResponse(topicName, subscriptionName, requestOptions).flatMap(FluxUtil::toMono)
             .map(protocolMethodData -> protocolMethodData.toObject(ReceiveResult.class));
     }
 
+    /**
+     * Receive a batch of Cloud Events from a subscription.
+     *
+     * @param maxEvents Max Events count to be received. Minimum value is 1, while maximum value is 100 events. If not
+     * specified, the default value is 1.
+     * @param maxWaitTime Max wait time value for receive operation in Seconds. It is the time in seconds that the
+     * server approximately waits for the availability of an event and responds to the request. If an event is
+     * available, the broker responds immediately to the client. Minimum value is 10 seconds, while maximum value is 120
+     * seconds. If not specified, the default value is 60 seconds.
+     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
+     * @throws IllegalArgumentException thrown if parameters fail the validation.
+     * @throws HttpResponseException thrown if the request is rejected by server.
+     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+     * @return details of the Receive operation response on successful completion of {@link Mono} along with {@link Response}.
+     */
+    @ServiceMethod(returns = ReturnType.SINGLE)
+    public Mono> receiveWithResponse(Integer maxEvents, Duration maxWaitTime,
+        RequestOptions requestOptions) {
+        // Generated convenience method for receiveWithResponse
+        if (maxEvents != null) {
+            requestOptions.addQueryParam("maxEvents", String.valueOf(maxEvents), false);
+        }
+        if (maxWaitTime != null) {
+            // Ensure the http client timeout is longer than the maxWaitTime
+            addTimeoutToContext(requestOptions, maxWaitTime);
+            requestOptions.addQueryParam("maxWaitTime", String.valueOf(maxWaitTime.getSeconds()), false);
+        }
+        return receiveWithResponse(topicName, subscriptionName, requestOptions)
+            .map(response -> new SimpleResponse<>(response, response.getValue().toObject(ReceiveResult.class)));
+    }
+
     /**
      * Receive a Cloud Event from a subscription. This method will wait 60 seconds for a response.
      *
@@ -434,6 +472,31 @@ public Mono acknowledge(List lockTokens) {
             .map(protocolMethodData -> protocolMethodData.toObject(AcknowledgeResult.class));
     }
 
+    /**
+     * Acknowledge a batch of Cloud Events. The response will include the set of successfully acknowledged lock tokens,
+     * along with other failed lock tokens with their corresponding error information. Successfully acknowledged events
+     * will no longer be available to be received by any consumer.
+     *
+     * @param lockTokens Array of lock tokens.
+     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
+     * @throws IllegalArgumentException thrown if parameters fail the validation.
+     * @throws HttpResponseException thrown if the request is rejected by server.
+     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+     * @return the result of the Acknowledge operation on successful completion of {@link Mono} along with {@link Response}.
+     */
+    @ServiceMethod(returns = ReturnType.SINGLE)
+    public Mono> acknowledgeWithResponse(List lockTokens,
+        RequestOptions requestOptions) {
+        // Generated convenience method for acknowledgeWithResponse
+        AcknowledgeRequest requestObj = new AcknowledgeRequest(lockTokens);
+        BinaryData request = BinaryData.fromObject(requestObj);
+        return acknowledgeWithResponse(topicName, subscriptionName, request, requestOptions)
+            .map(response -> new SimpleResponse<>(response, response.getValue().toObject(AcknowledgeResult.class)));
+    }
+
     /**
      * Release a batch of Cloud Events. The response will include the set of successfully released lock tokens, along
      * with other failed lock tokens with their corresponding error information. Successfully released events can be
@@ -462,6 +525,35 @@ public Mono release(List lockTokens, ReleaseDelay release
             .map(protocolMethodData -> protocolMethodData.toObject(ReleaseResult.class));
     }
 
+    /**
+     * Release a batch of Cloud Events. The response will include the set of successfully released lock tokens, along
+     * with other failed lock tokens with their corresponding error information. Successfully released events can be
+     * received by consumers.
+     *
+     * @param lockTokens Array of lock tokens.
+     * @param releaseDelay Release cloud events with the specified delay in seconds.
+     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
+     * @throws IllegalArgumentException thrown if parameters fail the validation.
+     * @throws HttpResponseException thrown if the request is rejected by server.
+     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+     * @return the result of the Release operation on successful completion of {@link Mono} along with {@link Response}.
+     */
+    @ServiceMethod(returns = ReturnType.SINGLE)
+    public Mono> releaseWithResponse(List lockTokens, ReleaseDelay releaseDelay,
+        RequestOptions requestOptions) {
+        // Generated convenience method for releaseWithResponse
+        ReleaseRequest requestObj = new ReleaseRequest(lockTokens);
+        BinaryData request = BinaryData.fromObject(requestObj);
+        if (releaseDelay != null) {
+            requestOptions.addQueryParam("releaseDelayInSeconds", releaseDelay.toString(), false);
+        }
+        return releaseWithResponse(topicName, subscriptionName, request, requestOptions)
+            .map(response -> new SimpleResponse<>(response, response.getValue().toObject(ReleaseResult.class)));
+    }
+
     /**
      * Release a batch of Cloud Events. The response will include the set of successfully released lock tokens, along
      * with other failed lock tokens with their corresponding error information. Successfully released events can be
@@ -510,6 +602,30 @@ public Mono reject(List lockTokens) {
             .map(protocolMethodData -> protocolMethodData.toObject(RejectResult.class));
     }
 
+    /**
+     * Reject a batch of Cloud Events. The response will include the set of successfully rejected lock tokens, along
+     * with other failed lock tokens with their corresponding error information. Successfully rejected events will be
+     * dead-lettered and can no longer be received by a consumer.
+     *
+     * @param lockTokens Array of lock tokens.
+     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
+     * @throws IllegalArgumentException thrown if parameters fail the validation.
+     * @throws HttpResponseException thrown if the request is rejected by server.
+     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+     * @return the result of the Reject operation on successful completion of {@link Mono} along with {@link Response}.
+     */
+    @ServiceMethod(returns = ReturnType.SINGLE)
+    public Mono> rejectWithResponse(List lockTokens, RequestOptions requestOptions) {
+        // Generated convenience method for rejectWithResponse
+        RejectRequest requestObj = new RejectRequest(lockTokens);
+        BinaryData request = BinaryData.fromObject(requestObj);
+        return rejectWithResponse(topicName, subscriptionName, request, requestOptions)
+            .map(response -> new SimpleResponse<>(response, response.getValue().toObject(RejectResult.class)));
+    }
+
     /**
      * Renew locks for a batch of Cloud Events. The response will include the set of successfully renewed lock tokens,
      * along with other failed lock tokens with their corresponding error information. Successfully renewed locks will
@@ -534,6 +650,36 @@ public Mono renewLocks(List lockTokens) {
             .map(protocolMethodData -> protocolMethodData.toObject(RenewLocksResult.class));
     }
 
+    /**
+     * Renew locks for a batch of Cloud Events. The response will include the set of successfully renewed lock tokens,
+     * along with other failed lock tokens with their corresponding error information. Successfully renewed locks will
+     * ensure that the associated event is only available to the consumer that holds the renewed lock.
+     *
+     * @param lockTokens Array of lock tokens.
+     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
+     * @throws IllegalArgumentException thrown if parameters fail the validation.
+     * @throws HttpResponseException thrown if the request is rejected by server.
+     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+     * @return the result of the RenewLock operation on successful completion of {@link Mono} along with {@link Response}.
+     */
+    @ServiceMethod(returns = ReturnType.SINGLE)
+    public Mono> renewLocksWithResponse(List lockTokens,
+        RequestOptions requestOptions) {
+        // Generated convenience method for renewLocksWithResponse
+        RenewLocksRequest requestObj = new RenewLocksRequest(lockTokens);
+        BinaryData request = BinaryData.fromObject(requestObj);
+        return renewLocksWithResponse(topicName, subscriptionName, request, requestOptions)
+            .map(protocolMethodData -> new SimpleResponse<>(protocolMethodData,
+                protocolMethodData.getValue().toObject(RenewLocksResult.class)));
+    }
+
+    /**
+     * Gets the topicName for this client.
+     * @return the topic name.
+    
     /**
      * Gets the topicName for this client.
      *
@@ -551,4 +697,20 @@ public String getTopicName() {
     public String getSubscriptionName() {
         return subscriptionName;
     }
+
+    /**
+     * Adds a timeout (maxWaitTime) to a context.
+     * @param requestOptions The request options to update.
+     * @param timeout The timeout to add.
+     * @return The updated context.
+     */
+    private void addTimeoutToContext(RequestOptions requestOptions, Duration timeout) {
+        Context context = requestOptions.getContext();
+        if (context == null) {
+            context = new Context("azure-response-timeout", timeout.plusSeconds(5));
+        } else {
+            context = context.addData("azure-response-timeout", timeout.plusSeconds(5));
+        }
+        requestOptions.setContext(context);
+    }
 }
diff --git a/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridReceiverClient.java b/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridReceiverClient.java
index 8e236a4aae4b..9f57dd1d86e3 100644
--- a/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridReceiverClient.java
+++ b/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridReceiverClient.java
@@ -13,7 +13,9 @@
 import com.azure.core.exception.ResourceNotFoundException;
 import com.azure.core.http.rest.RequestOptions;
 import com.azure.core.http.rest.Response;
+import com.azure.core.http.rest.SimpleResponse;
 import com.azure.core.util.BinaryData;
+import com.azure.core.util.Context;
 import com.azure.messaging.eventgrid.namespaces.implementation.EventGridReceiverClientImpl;
 import com.azure.messaging.eventgrid.namespaces.implementation.models.AcknowledgeRequest;
 import com.azure.messaging.eventgrid.namespaces.implementation.models.RejectRequest;
@@ -69,7 +71,7 @@ public final class EventGridReceiverClient {
      * 
      * You can add these to a request with {@link RequestOptions#addQueryParam}
      * 

Response Body Schema

- * + * *
{@code
      * {
      *     value (Required): [
@@ -116,7 +118,7 @@ Response receiveWithResponse(String topicName, String eventSubscript
      * along with other failed lock tokens with their corresponding error information. Successfully acknowledged events
      * will no longer be available to be received by any consumer.
      * 

Request Body Schema

- * + * *
{@code
      * {
      *     lockTokens (Required): [
@@ -124,9 +126,9 @@ Response receiveWithResponse(String topicName, String eventSubscript
      *     ]
      * }
      * }
- * + * *

Response Body Schema

- * + * *
{@code
      * {
      *     failedLockTokens (Required): [
@@ -183,7 +185,7 @@ Response acknowledgeWithResponse(String topicName, String eventSubsc
      * 
      * You can add these to a request with {@link RequestOptions#addQueryParam}
      * 

Request Body Schema

- * + * *
{@code
      * {
      *     lockTokens (Required): [
@@ -191,9 +193,9 @@ Response acknowledgeWithResponse(String topicName, String eventSubsc
      *     ]
      * }
      * }
- * + * *

Response Body Schema

- * + * *
{@code
      * {
      *     failedLockTokens (Required): [
@@ -241,7 +243,7 @@ Response releaseWithResponse(String topicName, String eventSubscript
      * with other failed lock tokens with their corresponding error information. Successfully rejected events will be
      * dead-lettered and can no longer be received by a consumer.
      * 

Request Body Schema

- * + * *
{@code
      * {
      *     lockTokens (Required): [
@@ -249,9 +251,9 @@ Response releaseWithResponse(String topicName, String eventSubscript
      *     ]
      * }
      * }
- * + * *

Response Body Schema

- * + * *
{@code
      * {
      *     failedLockTokens (Required): [
@@ -299,7 +301,7 @@ Response rejectWithResponse(String topicName, String eventSubscripti
      * along with other failed lock tokens with their corresponding error information. Successfully renewed locks will
      * ensure that the associated event is only available to the consumer that holds the renewed lock.
      * 

Request Body Schema

- * + * *
{@code
      * {
      *     lockTokens (Required): [
@@ -307,9 +309,9 @@ Response rejectWithResponse(String topicName, String eventSubscripti
      *     ]
      * }
      * }
- * + * *

Response Body Schema

- * + * *
{@code
      * {
      *     failedLockTokens (Required): [
@@ -378,12 +380,48 @@ public ReceiveResult receive(Integer maxEvents, Duration maxWaitTime) {
             requestOptions.addQueryParam("maxEvents", String.valueOf(maxEvents), false);
         }
         if (maxWaitTime != null) {
+            // Ensure the http client timeout is longer than the maxWaitTime
+            addTimeoutToContext(requestOptions, maxWaitTime);
             requestOptions.addQueryParam("maxWaitTime", String.valueOf(maxWaitTime.getSeconds()), false);
         }
         return receiveWithResponse(topicName, subscriptionName, requestOptions).getValue()
             .toObject(ReceiveResult.class);
     }
 
+    /**
+     * Receive a batch of Cloud Events from a subscription.
+     *
+     * @param maxEvents Max Events count to be received. Minimum value is 1, while maximum value is 100 events. If not
+     * specified, the default value is 1.
+     * @param maxWaitTime Max wait time value for receive operation in Seconds. It is the time in seconds that the
+     * server approximately waits for the availability of an event and responds to the request. If an event is
+     * available, the broker responds immediately to the client. Minimum value is 10 seconds, while maximum value is 120
+     * seconds. If not specified, the default value is 60 seconds.
+     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
+     * @throws IllegalArgumentException thrown if parameters fail the validation.
+     * @throws HttpResponseException thrown if the request is rejected by server.
+     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+     * @return details of the Receive operation response along with {@link Response}.
+     */
+    @ServiceMethod(returns = ReturnType.SINGLE)
+    public Response receiveWithResponse(Integer maxEvents, Duration maxWaitTime,
+        RequestOptions requestOptions) {
+        // Generated convenience method for receiveWithResponse
+        if (maxEvents != null) {
+            requestOptions.addQueryParam("maxEvents", String.valueOf(maxEvents), false);
+        }
+        if (maxWaitTime != null) {
+            // Ensure the http client timeout is longer than the maxWaitTime
+            addTimeoutToContext(requestOptions, maxWaitTime);
+            requestOptions.addQueryParam("maxWaitTime", String.valueOf(maxWaitTime.getSeconds()), false);
+        }
+        Response response = receiveWithResponse(topicName, subscriptionName, requestOptions);
+        return new SimpleResponse<>(response, response.getValue().toObject(ReceiveResult.class));
+    }
+
     /**
      * Receive a Cloud Event from a subscription. This method will wait 60 seconds for a response.
      *
@@ -403,6 +441,25 @@ public ReceiveResult receive() {
             .toObject(ReceiveResult.class);
     }
 
+    /**
+     * Receive a Cloud Event from a subscription. This method will wait 60 seconds for a response.
+     *
+     * @throws IllegalArgumentException thrown if parameters fail the validation.
+     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
+     * @throws HttpResponseException thrown if the request is rejected by server.
+     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+     * @return details of the Receive operation response along with {@link Response}.
+     */
+    @ServiceMethod(returns = ReturnType.SINGLE)
+    public Response receiveWithResponse(RequestOptions requestOptions) {
+        // Generated convenience method for receiveWithResponse
+        Response response = receiveWithResponse(topicName, subscriptionName, requestOptions);
+        return new SimpleResponse<>(response, response.getValue().toObject(ReceiveResult.class));
+    }
+
     /**
      * Acknowledge a batch of Cloud Events. The response will include the set of successfully acknowledged lock tokens,
      * along with other failed lock tokens with their corresponding error information. Successfully acknowledged events
@@ -427,6 +484,30 @@ public AcknowledgeResult acknowledge(List lockTokens) {
             .toObject(AcknowledgeResult.class);
     }
 
+    /**
+     * Acknowledge a batch of Cloud Events. The response will include the set of successfully acknowledged lock tokens,
+     * along with other failed lock tokens with their corresponding error information. Successfully acknowledged events
+     * will no longer be available to be received by any consumer.
+     *
+     * @param lockTokens Array of lock tokens.
+     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
+     * @throws IllegalArgumentException thrown if parameters fail the validation.
+     * @throws HttpResponseException thrown if the request is rejected by server.
+     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+     * @return the result of the Acknowledge operation along with {@link Response}.
+     */
+    @ServiceMethod(returns = ReturnType.SINGLE)
+    public Response acknowledgeWithResponse(List lockTokens, RequestOptions requestOptions) {
+        // Generated convenience method for acknowledgeWithResponse
+        AcknowledgeRequest requestObj = new AcknowledgeRequest(lockTokens);
+        BinaryData request = BinaryData.fromObject(requestObj);
+        Response response = acknowledgeWithResponse(topicName, subscriptionName, request, requestOptions);
+        return new SimpleResponse<>(response, response.getValue().toObject(AcknowledgeResult.class));
+    }
+
     /**
      * Release a batch of Cloud Events. The response will include the set of successfully released lock tokens, along
      * with other failed lock tokens with their corresponding error information. Successfully released events can be
@@ -455,6 +536,35 @@ public ReleaseResult release(List lockTokens, ReleaseDelay releaseDelay)
             .toObject(ReleaseResult.class);
     }
 
+    /**
+     * Release a batch of Cloud Events. The response will include the set of successfully released lock tokens, along
+     * with other failed lock tokens with their corresponding error information. Successfully released events can be
+     * received by consumers.
+     *
+     * @param lockTokens Array of lock tokens.
+     * @param releaseDelay Release cloud events with the specified delay in seconds.
+     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
+     * @throws IllegalArgumentException thrown if parameters fail the validation.
+     * @throws HttpResponseException thrown if the request is rejected by server.
+     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+     * @return the result of the Release operation along with {@link Response}.
+     */
+    @ServiceMethod(returns = ReturnType.SINGLE)
+    public Response releaseWithResponse(List lockTokens, ReleaseDelay releaseDelay,
+        RequestOptions requestOptions) {
+        // Generated convenience method for releaseWithResponse
+        ReleaseRequest requestObj = new ReleaseRequest(lockTokens);
+        BinaryData request = BinaryData.fromObject(requestObj);
+        if (releaseDelay != null) {
+            requestOptions.addQueryParam("releaseDelayInSeconds", releaseDelay.toString(), false);
+        }
+        Response response = releaseWithResponse(topicName, subscriptionName, request, requestOptions);
+        return new SimpleResponse<>(response, response.getValue().toObject(ReleaseResult.class));
+    }
+
     /**
      * Release a batch of Cloud Events. The response will include the set of successfully released lock tokens, along
      * with other failed lock tokens with their corresponding error information. Successfully released events can be
@@ -479,6 +589,30 @@ public ReleaseResult release(List lockTokens) {
             .toObject(ReleaseResult.class);
     }
 
+    /**
+     * Release a batch of Cloud Events. The response will include the set of successfully released lock tokens, along
+     * with other failed lock tokens with their corresponding error information. Successfully released events can be
+     * received by consumers.
+     *
+     * @param lockTokens Array of lock tokens.
+     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
+     * @throws IllegalArgumentException thrown if parameters fail the validation.
+     * @throws HttpResponseException thrown if the request is rejected by server.
+     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+     * @return the result of the Release operation along with {@link Response}.
+     */
+    @ServiceMethod(returns = ReturnType.SINGLE)
+    public Response releaseWithResponse(List lockTokens, RequestOptions requestOptions) {
+        // Generated convenience method for releaseWithResponse
+        ReleaseRequest requestObj = new ReleaseRequest(lockTokens);
+        BinaryData request = BinaryData.fromObject(requestObj);
+        Response response = releaseWithResponse(topicName, subscriptionName, request, requestOptions);
+        return new SimpleResponse<>(response, response.getValue().toObject(ReleaseResult.class));
+    }
+
     /**
      * Reject a batch of Cloud Events. The response will include the set of successfully rejected lock tokens, along
      * with other failed lock tokens with their corresponding error information. Successfully rejected events will be
@@ -503,6 +637,30 @@ public RejectResult reject(List lockTokens) {
             .toObject(RejectResult.class);
     }
 
+    /**
+     * Reject a batch of Cloud Events. The response will include the set of successfully rejected lock tokens, along
+     * with other failed lock tokens with their corresponding error information. Successfully rejected events will be
+     * dead-lettered and can no longer be received by a consumer.
+     *
+     * @param lockTokens Array of lock tokens.
+     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
+     * @throws IllegalArgumentException thrown if parameters fail the validation.
+     * @throws HttpResponseException thrown if the request is rejected by server.
+     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+     * @return the result of the Reject operation along with {@link Response}.
+     */
+    @ServiceMethod(returns = ReturnType.SINGLE)
+    public Response rejectWithResponse(List lockTokens, RequestOptions requestOptions) {
+        // Generated convenience method for rejectWithResponse
+        RejectRequest requestObj = new RejectRequest(lockTokens);
+        BinaryData request = BinaryData.fromObject(requestObj);
+        Response response = rejectWithResponse(topicName, subscriptionName, request, requestOptions);
+        return new SimpleResponse<>(response, response.getValue().toObject(RejectResult.class));
+    }
+
     /**
      * Renew locks for a batch of Cloud Events. The response will include the set of successfully renewed lock tokens,
      * along with other failed lock tokens with their corresponding error information. Successfully renewed locks will
@@ -527,6 +685,30 @@ public RenewLocksResult renewLocks(List lockTokens) {
             .toObject(RenewLocksResult.class);
     }
 
+    /**
+     * Renew locks for a batch of Cloud Events. The response will include the set of successfully renewed lock tokens,
+     * along with other failed lock tokens with their corresponding error information. Successfully renewed locks will
+     * ensure that the associated event is only available to the consumer that holds the renewed lock.
+     *
+     * @param lockTokens Array of lock tokens.
+     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
+     * @throws IllegalArgumentException thrown if parameters fail the validation.
+     * @throws HttpResponseException thrown if the request is rejected by server.
+     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+     * @return the result of the RenewLock operation along with {@link Response}.
+     */
+    @ServiceMethod(returns = ReturnType.SINGLE)
+    public Response renewLocksWithResponse(List lockTokens, RequestOptions requestOptions) {
+        // Generated convenience method for renewLocksWithResponse
+        RenewLocksRequest requestObj = new RenewLocksRequest(lockTokens);
+        BinaryData request = BinaryData.fromObject(requestObj);
+        Response response = renewLocksWithResponse(topicName, subscriptionName, request, requestOptions);
+        return new SimpleResponse<>(response, response.getValue().toObject(RenewLocksResult.class));
+    }
+
     /**
      * Gets the topicName for this client.
      *
@@ -544,4 +726,20 @@ public String getTopicName() {
     public String getSubscriptionName() {
         return subscriptionName;
     }
+
+    /**
+     * Adds a timeout (maxWaitTime) to a context.
+     * @param requestOptions The request options to update.
+     * @param timeout The timeout to add.
+     * @return The updated context.
+     */
+    private void addTimeoutToContext(RequestOptions requestOptions, Duration timeout) {
+        Context context = requestOptions.getContext();
+        if (context == null) {
+            context = new Context("azure-response-timeout", timeout.plusSeconds(5));
+        } else {
+            context = context.addData("azure-response-timeout", timeout.plusSeconds(5));
+        }
+        requestOptions.setContext(context);
+    }
 }
diff --git a/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridSenderAsyncClient.java b/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridSenderAsyncClient.java
index 25768f7118be..1e0966667b1b 100644
--- a/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridSenderAsyncClient.java
+++ b/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridSenderAsyncClient.java
@@ -13,6 +13,7 @@
 import com.azure.core.exception.ResourceNotFoundException;
 import com.azure.core.http.rest.RequestOptions;
 import com.azure.core.http.rest.Response;
+import com.azure.core.http.rest.SimpleResponse;
 import com.azure.core.util.BinaryData;
 import com.azure.messaging.eventgrid.namespaces.implementation.EventGridSenderClientImpl;
 import java.util.List;
@@ -44,7 +45,7 @@ public final class EventGridSenderAsyncClient {
     /**
      * Publish a single Cloud Event to a namespace topic.
      * 

Request Body Schema

- * + * *
{@code
      * {
      *     id: String (Required)
@@ -59,9 +60,9 @@ public final class EventGridSenderAsyncClient {
      *     subject: String (Optional)
      * }
      * }
- * + * *

Response Body Schema

- * + * *
{@code
      * { }
      * }
@@ -84,7 +85,7 @@ Mono> sendWithResponse(String topicName, BinaryData event, /** * Publish a batch of Cloud Events to a namespace topic. *

Request Body Schema

- * + * *
{@code
      * [
      *      (Required){
@@ -101,9 +102,9 @@ Mono> sendWithResponse(String topicName, BinaryData event,
      *     }
      * ]
      * }
- * + * *

Response Body Schema

- * + * *
{@code
      * { }
      * }
@@ -143,6 +144,27 @@ public Mono send(CloudEvent event) { return sendWithResponse(topicName, BinaryData.fromObject(event), requestOptions).then(); } + /** + * Publish a single Cloud Event to a namespace topic. + * + * @param event Single Cloud Event being published. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the result of the Publish operation on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> sendWithResponse(CloudEvent event, RequestOptions requestOptions) { + // Generated convenience method for sendWithResponse + return sendWithResponse(topicName, BinaryData.fromObject(event), requestOptions).map(response -> { + return new SimpleResponse<>(response, null); + }); + } + /** * Publish a batch of Cloud Events to a namespace topic. * @@ -162,6 +184,27 @@ public Mono send(List events) { return sendEventsWithResponse(topicName, BinaryData.fromObject(events), requestOptions).then(); } + /** + * Publish a batch of Cloud Events to a namespace topic. + * + * @param events Array of Cloud Events being published. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the result of the Publish operation on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> sendWithResponse(List events, RequestOptions requestOptions) { + // Generated convenience method for sendEventsWithResponse + return sendEventsWithResponse(topicName, BinaryData.fromObject(events), requestOptions).map(response -> { + return new SimpleResponse<>(response, null); + }); + } + /** * Gets the topicName for this client. * diff --git a/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridSenderClient.java b/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridSenderClient.java index f1407dadab37..b2caf5585dfd 100644 --- a/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridSenderClient.java +++ b/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridSenderClient.java @@ -13,6 +13,7 @@ import com.azure.core.exception.ResourceNotFoundException; import com.azure.core.http.rest.RequestOptions; import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.SimpleResponse; import com.azure.core.util.BinaryData; import com.azure.messaging.eventgrid.namespaces.implementation.EventGridSenderClientImpl; import java.util.List; @@ -43,7 +44,7 @@ public final class EventGridSenderClient { /** * Publish a single Cloud Event to a namespace topic. *

Request Body Schema

- * + * *
{@code
      * {
      *     id: String (Required)
@@ -58,9 +59,9 @@ public final class EventGridSenderClient {
      *     subject: String (Optional)
      * }
      * }
- * + * *

Response Body Schema

- * + * *
{@code
      * { }
      * }
@@ -83,7 +84,7 @@ Response sendWithResponse(String topicName, BinaryData event, Reques /** * Publish a batch of Cloud Events to a namespace topic. *

Request Body Schema

- * + * *
{@code
      * [
      *      (Required){
@@ -100,9 +101,9 @@ Response sendWithResponse(String topicName, BinaryData event, Reques
      *     }
      * ]
      * }
- * + * *

Response Body Schema

- * + * *
{@code
      * { }
      * }
@@ -140,6 +141,25 @@ public void send(CloudEvent event) { sendWithResponse(topicName, BinaryData.fromObject(event), requestOptions); } + /** + * Publish a single Cloud Event to a namespace topic. + * + * @param event Array of Cloud Events being published. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @return The {@link Response} of the send operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response sendWithResponse(CloudEvent event, RequestOptions requestOptions) { + Response response = sendWithResponse(topicName, BinaryData.fromObject(event), requestOptions); + return new SimpleResponse<>(response, null); + } + /** * Publish a batch of Cloud Events to a namespace topic. * @@ -158,6 +178,26 @@ public void send(List events) { sendEventsWithResponse(topicName, BinaryData.fromObject(events), requestOptions); } + /** + * Publish a batch of Cloud Events to a namespace topic. + * + * @param events Array of Cloud Events being published. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @return The {@link Response} of the send operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response sendWithResponse(List events, RequestOptions requestOptions) { + Response response + = sendEventsWithResponse(topicName, BinaryData.fromObject(events), requestOptions); + return new SimpleResponse<>(response, null); + } + /** * Gets the topicName for this client. * diff --git a/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/module-info.java b/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/module-info.java index 05327b4d74f9..a2266eeb53e0 100644 --- a/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/module-info.java +++ b/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/module-info.java @@ -4,8 +4,10 @@ module com.azure.messaging.eventgrid.namespaces { requires transitive com.azure.core; + exports com.azure.messaging.eventgrid.namespaces; exports com.azure.messaging.eventgrid.namespaces.models; + opens com.azure.messaging.eventgrid.namespaces.implementation.models to com.azure.core; opens com.azure.messaging.eventgrid.namespaces.models to com.azure.core; } diff --git a/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/test/java/com/azure/messaging/eventgrid/namespaces/EventGridAsyncClientTests.java b/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/test/java/com/azure/messaging/eventgrid/namespaces/EventGridAsyncClientTests.java index 7ab2569ffb6a..8b701f1dfb35 100644 --- a/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/test/java/com/azure/messaging/eventgrid/namespaces/EventGridAsyncClientTests.java +++ b/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/test/java/com/azure/messaging/eventgrid/namespaces/EventGridAsyncClientTests.java @@ -16,7 +16,6 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; - public class EventGridAsyncClientTests extends EventGridClientTestBase { @Override @@ -43,18 +42,14 @@ void send() { EventGridSenderAsyncClient client = buildSenderAsyncClient(); - client.send(getCloudEvent()) - .as(StepVerifier::create) - .verifyComplete(); + client.send(getCloudEvent()).as(StepVerifier::create).verifyComplete(); } @Test void sendBatch() { EventGridSenderAsyncClient client = buildSenderAsyncClient(); - client.send(Arrays.asList(getCloudEvent(), getCloudEvent())) - .as(StepVerifier::create) - .verifyComplete(); + client.send(Arrays.asList(getCloudEvent(), getCloudEvent())).as(StepVerifier::create).verifyComplete(); } @Test @@ -79,37 +74,30 @@ void acknowledgeBatch() { EventGridReceiverAsyncClient client = buildReceiverAsyncClient(); EventGridSenderAsyncClient senderClient = buildSenderAsyncClient(); - senderClient.send(getCloudEvent()).then(client.receive(1, Duration.ofSeconds(10))) - .flatMap(receiveResult -> { - return client.acknowledge(Arrays.asList(receiveResult.getDetails().get(0).getBrokerProperties().getLockToken())); - }) - .as(StepVerifier::create) - .assertNext(receiveResult -> { - assertNotNull(receiveResult); - assertTrue(receiveResult.getFailedLockTokens().isEmpty()); - assertFalse(receiveResult.getSucceededLockTokens().isEmpty()); - }) - .verifyComplete(); + senderClient.send(getCloudEvent()).then(client.receive(1, Duration.ofSeconds(10))).flatMap(receiveResult -> { + return client + .acknowledge(Arrays.asList(receiveResult.getDetails().get(0).getBrokerProperties().getLockToken())); + }).as(StepVerifier::create).assertNext(receiveResult -> { + assertNotNull(receiveResult); + assertTrue(receiveResult.getFailedLockTokens().isEmpty()); + assertFalse(receiveResult.getSucceededLockTokens().isEmpty()); + }).verifyComplete(); } - @Test void releaseBatch() { EventGridReceiverAsyncClient client = buildReceiverAsyncClient(); EventGridSenderAsyncClient senderClient = buildSenderAsyncClient(); - senderClient.send(getCloudEvent()).then(client.receive(1, Duration.ofSeconds(10))) - .flatMap(receiveResult -> { - return client.release(Arrays.asList(receiveResult.getDetails().get(0).getBrokerProperties().getLockToken())); - }) - .as(StepVerifier::create) - .assertNext(result -> { - assertNotNull(result); - assertTrue(result.getFailedLockTokens().isEmpty()); - assertFalse(result.getSucceededLockTokens().isEmpty()); - }) - .verifyComplete(); + senderClient.send(getCloudEvent()).then(client.receive(1, Duration.ofSeconds(10))).flatMap(receiveResult -> { + return client + .release(Arrays.asList(receiveResult.getDetails().get(0).getBrokerProperties().getLockToken())); + }).as(StepVerifier::create).assertNext(result -> { + assertNotNull(result); + assertTrue(result.getFailedLockTokens().isEmpty()); + assertFalse(result.getSucceededLockTokens().isEmpty()); + }).verifyComplete(); } @Test @@ -118,18 +106,14 @@ void releaseBatchWithDelay() { EventGridReceiverAsyncClient client = buildReceiverAsyncClient(); EventGridSenderAsyncClient senderClient = buildSenderAsyncClient(); - senderClient.send(getCloudEvent()).then(client.receive(1, Duration.ofSeconds(10))) - .flatMap(receiveResult -> { - return client.release(Arrays.asList(receiveResult.getDetails().get(0).getBrokerProperties().getLockToken()), ReleaseDelay.TEN_SECONDS); - }) - .as(StepVerifier::create) - .assertNext(result -> { - assertNotNull(result); - assertTrue(result.getFailedLockTokens().isEmpty()); - assertFalse(result.getSucceededLockTokens().isEmpty()); - }) - .verifyComplete(); - + senderClient.send(getCloudEvent()).then(client.receive(1, Duration.ofSeconds(10))).flatMap(receiveResult -> { + return client.release(Arrays.asList(receiveResult.getDetails().get(0).getBrokerProperties().getLockToken()), + ReleaseDelay.TEN_SECONDS); + }).as(StepVerifier::create).assertNext(result -> { + assertNotNull(result); + assertTrue(result.getFailedLockTokens().isEmpty()); + assertFalse(result.getSucceededLockTokens().isEmpty()); + }).verifyComplete(); } @@ -139,17 +123,13 @@ void rejectBatch() { EventGridReceiverAsyncClient client = buildReceiverAsyncClient(); EventGridSenderAsyncClient senderClient = buildSenderAsyncClient(); - senderClient.send(getCloudEvent()).then(client.receive(1, Duration.ofSeconds(10))) - .flatMap(receiveResult -> { - return client.reject(Arrays.asList(receiveResult.getDetails().get(0).getBrokerProperties().getLockToken())); - }) - .as(StepVerifier::create) - .assertNext(result -> { - assertNotNull(result); - assertTrue(result.getFailedLockTokens().isEmpty()); - assertFalse(result.getSucceededLockTokens().isEmpty()); - }) - .verifyComplete(); + senderClient.send(getCloudEvent()).then(client.receive(1, Duration.ofSeconds(10))).flatMap(receiveResult -> { + return client.reject(Arrays.asList(receiveResult.getDetails().get(0).getBrokerProperties().getLockToken())); + }).as(StepVerifier::create).assertNext(result -> { + assertNotNull(result); + assertTrue(result.getFailedLockTokens().isEmpty()); + assertFalse(result.getSucceededLockTokens().isEmpty()); + }).verifyComplete(); } @Test @@ -158,16 +138,13 @@ void renewBatch() { EventGridReceiverAsyncClient client = buildReceiverAsyncClient(); EventGridSenderAsyncClient senderClient = buildSenderAsyncClient(); - senderClient.send(getCloudEvent()).then(client.receive(1, Duration.ofSeconds(10))) - .flatMap(receiveResult -> { - return client.renewLocks(Arrays.asList(receiveResult.getDetails().get(0).getBrokerProperties().getLockToken())); - }) - .as(StepVerifier::create) - .assertNext(result -> { - assertNotNull(result); - assertTrue(result.getFailedLockTokens().isEmpty()); - assertFalse(result.getSucceededLockTokens().isEmpty()); - }) - .verifyComplete(); + senderClient.send(getCloudEvent()).then(client.receive(1, Duration.ofSeconds(10))).flatMap(receiveResult -> { + return client + .renewLocks(Arrays.asList(receiveResult.getDetails().get(0).getBrokerProperties().getLockToken())); + }).as(StepVerifier::create).assertNext(result -> { + assertNotNull(result); + assertTrue(result.getFailedLockTokens().isEmpty()); + assertFalse(result.getSucceededLockTokens().isEmpty()); + }).verifyComplete(); } } diff --git a/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/test/java/com/azure/messaging/eventgrid/namespaces/EventGridClientTestBase.java b/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/test/java/com/azure/messaging/eventgrid/namespaces/EventGridClientTestBase.java index 93d8d7194f4f..43960812b445 100644 --- a/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/test/java/com/azure/messaging/eventgrid/namespaces/EventGridClientTestBase.java +++ b/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/test/java/com/azure/messaging/eventgrid/namespaces/EventGridClientTestBase.java @@ -40,13 +40,14 @@ public class EventGridClientTestBase extends TestProxyTestBase { static final String DUMMY_CHANNEL_NAME = "dummy-channel"; - public static final String TOPIC_NAME = Configuration.getGlobalConfiguration().get(EVENTGRID_TOPIC_NAME, "testtopic1"); - public static final String EVENT_SUBSCRIPTION_NAME = Configuration.getGlobalConfiguration().get(EVENTGRID_EVENT_SUBSCRIPTION_NAME, "testsubscription1"); + public static final String TOPIC_NAME + = Configuration.getGlobalConfiguration().get(EVENTGRID_TOPIC_NAME, "testtopic1"); + public static final String EVENT_SUBSCRIPTION_NAME + = Configuration.getGlobalConfiguration().get(EVENTGRID_EVENT_SUBSCRIPTION_NAME, "testsubscription1"); EventGridReceiverClientBuilder receiverBuilder; EventGridSenderClientBuilder senderBuilder; - protected void makeBuilders(boolean sync) { receiverBuilder = buildReceiverClientBuilder(); senderBuilder = buildSenderClientBuilder(); @@ -59,17 +60,12 @@ protected void makeBuilders(boolean sync) { } if (interceptorManager.isRecordMode()) { - receiverBuilder.addPolicy(interceptorManager.getRecordPolicy()) - .retryPolicy(new RetryPolicy()); - senderBuilder.addPolicy(interceptorManager.getRecordPolicy()) - .retryPolicy(new RetryPolicy()); + receiverBuilder.addPolicy(interceptorManager.getRecordPolicy()).retryPolicy(new RetryPolicy()); + senderBuilder.addPolicy(interceptorManager.getRecordPolicy()).retryPolicy(new RetryPolicy()); } setupSanitizers(); } - - - @Override protected void afterTest() { StepVerifier.resetDefaultTimeout(); @@ -86,8 +82,7 @@ void setupSanitizers() { } EventGridReceiverClientBuilder buildReceiverClientBuilder() { - return new EventGridReceiverClientBuilder() - .httpClient(HttpClient.createDefault()) + return new EventGridReceiverClientBuilder().httpClient(HttpClient.createDefault()) .httpLogOptions(new HttpLogOptions()) .subscriptionName(EVENT_SUBSCRIPTION_NAME) .topicName(TOPIC_NAME) @@ -95,8 +90,7 @@ EventGridReceiverClientBuilder buildReceiverClientBuilder() { } EventGridSenderClientBuilder buildSenderClientBuilder() { - return new EventGridSenderClientBuilder() - .httpClient(HttpClient.createDefault()) + return new EventGridSenderClientBuilder().httpClient(HttpClient.createDefault()) .httpLogOptions(new HttpLogOptions()) .topicName(TOPIC_NAME) .endpoint(getTopicEndpoint(EVENTGRID_ENDPOINT)); @@ -134,21 +128,19 @@ CloudEvent getCloudEvent() { put("Field2", "Value2"); put("Field3", "Value3"); } - }), CloudEventDataFormat.JSON, "application/json") - .setSubject("Test") - .setTime(testResourceNamer.now()) - .setId(testResourceNamer.randomUuid()); + }), CloudEventDataFormat.JSON, "application/json").setSubject("Test") + .setTime(testResourceNamer.now()) + .setId(testResourceNamer.randomUuid()); } CloudEvent getCloudEvent(int i) { return new CloudEvent("/microsoft/testEvent", "Microsoft.MockPublisher.TestEvent", BinaryData.fromObject(new TestData().setName("Hello " + i)), CloudEventDataFormat.JSON, null) - .setSubject("Test " + i) - .setTime(testResourceNamer.now()) - .setId(testResourceNamer.randomUuid()); + .setSubject("Test " + i) + .setTime(testResourceNamer.now()) + .setId(testResourceNamer.randomUuid()); } - String getEndpoint(String liveEnvName) { if (interceptorManager.isPlaybackMode()) { return DUMMY_ENDPOINT; @@ -177,8 +169,8 @@ AzureKeyCredential getKey(String liveEnvName) { } HttpClient buildAssertingClient(HttpClient httpClient, boolean sync) { - AssertingHttpClientBuilder builder = new AssertingHttpClientBuilder(httpClient) - .skipRequest((ignored1, ignored2) -> false); + AssertingHttpClientBuilder builder + = new AssertingHttpClientBuilder(httpClient).skipRequest((ignored1, ignored2) -> false); if (sync) { builder.assertSync(); } else { diff --git a/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/test/java/com/azure/messaging/eventgrid/namespaces/EventGridClientTests.java b/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/test/java/com/azure/messaging/eventgrid/namespaces/EventGridClientTests.java index 3c32d13fb21d..da9a960e03c9 100644 --- a/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/test/java/com/azure/messaging/eventgrid/namespaces/EventGridClientTests.java +++ b/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/test/java/com/azure/messaging/eventgrid/namespaces/EventGridClientTests.java @@ -41,7 +41,6 @@ EventGridSenderClient buildSenderClient() { return senderBuilder.credential(getKey(EVENTGRID_KEY)).buildClient(); } - @Test void send() { EventGridSenderClient client = buildSenderClient(); @@ -71,7 +70,8 @@ void acknowledgeBatch() { senderClient.send(getCloudEvent()); ReceiveResult receiveResult = client.receive(1, Duration.ofSeconds(10)); - AcknowledgeResult acknowledgeResult = client.acknowledge(Collections.singletonList(receiveResult.getDetails().get(0).getBrokerProperties().getLockToken())); + AcknowledgeResult acknowledgeResult = client.acknowledge( + Collections.singletonList(receiveResult.getDetails().get(0).getBrokerProperties().getLockToken())); assertNotNull(acknowledgeResult); assertFalse(acknowledgeResult.getSucceededLockTokens().isEmpty()); } @@ -83,7 +83,8 @@ void releaseBatch() { senderClient.send(getCloudEvent()); ReceiveResult receiveResult = client.receive(1, Duration.ofSeconds(10)); - ReleaseResult releaseResult = client.release(Collections.singletonList(receiveResult.getDetails().get(0).getBrokerProperties().getLockToken())); + ReleaseResult releaseResult = client + .release(Collections.singletonList(receiveResult.getDetails().get(0).getBrokerProperties().getLockToken())); assertNotNull(releaseResult); assertFalse(releaseResult.getSucceededLockTokens().isEmpty()); } @@ -94,7 +95,9 @@ void releaseBatchWithDelay() { EventGridReceiverClient client = buildReceiverClient(); senderClient.send(getCloudEvent()); ReceiveResult receiveResult = client.receive(1, Duration.ofSeconds(10)); - ReleaseResult releaseResult = client.release(Collections.singletonList(receiveResult.getDetails().get(0).getBrokerProperties().getLockToken()), ReleaseDelay.TEN_SECONDS); + ReleaseResult releaseResult = client.release( + Collections.singletonList(receiveResult.getDetails().get(0).getBrokerProperties().getLockToken()), + ReleaseDelay.TEN_SECONDS); assertNotNull(releaseResult); assertFalse(releaseResult.getSucceededLockTokens().isEmpty()); } @@ -105,7 +108,8 @@ void rejectBatch() { EventGridReceiverClient client = buildReceiverClient(); senderClient.send(getCloudEvent()); ReceiveResult receiveResult = client.receive(1, Duration.ofSeconds(10)); - RejectResult rejectResult = client.reject(Collections.singletonList(receiveResult.getDetails().get(0).getBrokerProperties().getLockToken())); + RejectResult rejectResult = client + .reject(Collections.singletonList(receiveResult.getDetails().get(0).getBrokerProperties().getLockToken())); assertNotNull(rejectResult); assertFalse(rejectResult.getSucceededLockTokens().isEmpty()); } @@ -116,7 +120,8 @@ void renewBatchOfEvents() { EventGridReceiverClient client = buildReceiverClient(); senderClient.send(getCloudEvent()); ReceiveResult receiveResult = client.receive(1, Duration.ofSeconds(10)); - RenewLocksResult renewResult = client.renewLocks(Collections.singletonList(receiveResult.getDetails().get(0).getBrokerProperties().getLockToken())); + RenewLocksResult renewResult = client.renewLocks( + Collections.singletonList(receiveResult.getDetails().get(0).getBrokerProperties().getLockToken())); assertNotNull(renewResult); assertFalse(renewResult.getSucceededLockTokens().isEmpty()); } From 6c0975c984601b219fcfe3963abffb16e6d210cc Mon Sep 17 00:00:00 2001 From: Bill Wert Date: Mon, 16 Sep 2024 17:53:10 -0700 Subject: [PATCH 2/9] remove a couple extra methods --- .../namespaces/EventGridReceiverClient.java | 43 ------------------- 1 file changed, 43 deletions(-) diff --git a/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridReceiverClient.java b/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridReceiverClient.java index 9f57dd1d86e3..8827fbc8396a 100644 --- a/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridReceiverClient.java +++ b/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridReceiverClient.java @@ -441,25 +441,6 @@ public ReceiveResult receive() { .toObject(ReceiveResult.class); } - /** - * Receive a Cloud Event from a subscription. This method will wait 60 seconds for a response. - * - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @param requestOptions The options to configure the HTTP request before HTTP client sends it. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return details of the Receive operation response along with {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response receiveWithResponse(RequestOptions requestOptions) { - // Generated convenience method for receiveWithResponse - Response response = receiveWithResponse(topicName, subscriptionName, requestOptions); - return new SimpleResponse<>(response, response.getValue().toObject(ReceiveResult.class)); - } - /** * Acknowledge a batch of Cloud Events. The response will include the set of successfully acknowledged lock tokens, * along with other failed lock tokens with their corresponding error information. Successfully acknowledged events @@ -589,30 +570,6 @@ public ReleaseResult release(List lockTokens) { .toObject(ReleaseResult.class); } - /** - * Release a batch of Cloud Events. The response will include the set of successfully released lock tokens, along - * with other failed lock tokens with their corresponding error information. Successfully released events can be - * received by consumers. - * - * @param lockTokens Array of lock tokens. - * @param requestOptions The options to configure the HTTP request before HTTP client sends it. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the result of the Release operation along with {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response releaseWithResponse(List lockTokens, RequestOptions requestOptions) { - // Generated convenience method for releaseWithResponse - ReleaseRequest requestObj = new ReleaseRequest(lockTokens); - BinaryData request = BinaryData.fromObject(requestObj); - Response response = releaseWithResponse(topicName, subscriptionName, request, requestOptions); - return new SimpleResponse<>(response, response.getValue().toObject(ReleaseResult.class)); - } - /** * Reject a batch of Cloud Events. The response will include the set of successfully rejected lock tokens, along * with other failed lock tokens with their corresponding error information. Successfully rejected events will be From adb650997760d1647a46f5ab645c0b2631d58c0d Mon Sep 17 00:00:00 2001 From: Bill Wert Date: Tue, 17 Sep 2024 11:54:19 -0700 Subject: [PATCH 3/9] make `addTimeoutToContext` helper method package-private --- .../EventGridReceiverAsyncClient.java | 20 ++----------------- .../namespaces/EventGridReceiverClient.java | 2 +- 2 files changed, 3 insertions(+), 19 deletions(-) diff --git a/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridReceiverAsyncClient.java b/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridReceiverAsyncClient.java index 715d77cc3c74..08ef748bc490 100644 --- a/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridReceiverAsyncClient.java +++ b/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridReceiverAsyncClient.java @@ -388,7 +388,7 @@ public Mono receive(Integer maxEvents, Duration maxWaitTime) { } if (maxWaitTime != null) { // Ensure the http client timeout is longer than the maxWaitTime - addTimeoutToContext(requestOptions, maxWaitTime); + EventGridReceiverClient.addTimeoutToContext(requestOptions, maxWaitTime); requestOptions.addQueryParam("maxWaitTime", String.valueOf(maxWaitTime.getSeconds()), false); } return receiveWithResponse(topicName, subscriptionName, requestOptions).flatMap(FluxUtil::toMono) @@ -422,7 +422,7 @@ public Mono> receiveWithResponse(Integer maxEvents, Dura } if (maxWaitTime != null) { // Ensure the http client timeout is longer than the maxWaitTime - addTimeoutToContext(requestOptions, maxWaitTime); + EventGridReceiverClient.addTimeoutToContext(requestOptions, maxWaitTime); requestOptions.addQueryParam("maxWaitTime", String.valueOf(maxWaitTime.getSeconds()), false); } return receiveWithResponse(topicName, subscriptionName, requestOptions) @@ -697,20 +697,4 @@ public String getTopicName() { public String getSubscriptionName() { return subscriptionName; } - - /** - * Adds a timeout (maxWaitTime) to a context. - * @param requestOptions The request options to update. - * @param timeout The timeout to add. - * @return The updated context. - */ - private void addTimeoutToContext(RequestOptions requestOptions, Duration timeout) { - Context context = requestOptions.getContext(); - if (context == null) { - context = new Context("azure-response-timeout", timeout.plusSeconds(5)); - } else { - context = context.addData("azure-response-timeout", timeout.plusSeconds(5)); - } - requestOptions.setContext(context); - } } diff --git a/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridReceiverClient.java b/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridReceiverClient.java index 8827fbc8396a..76eb304a37f0 100644 --- a/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridReceiverClient.java +++ b/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridReceiverClient.java @@ -690,7 +690,7 @@ public String getSubscriptionName() { * @param timeout The timeout to add. * @return The updated context. */ - private void addTimeoutToContext(RequestOptions requestOptions, Duration timeout) { + static void addTimeoutToContext(RequestOptions requestOptions, Duration timeout) { Context context = requestOptions.getContext(); if (context == null) { context = new Context("azure-response-timeout", timeout.plusSeconds(5)); From 5c05225f9008820aad0baac48d65502cbab6a12f Mon Sep 17 00:00:00 2001 From: Bill Wert Date: Tue, 17 Sep 2024 11:55:01 -0700 Subject: [PATCH 4/9] remove extra comments --- .../namespaces/EventGridReceiverAsyncClient.java | 11 ----------- .../namespaces/EventGridReceiverClient.java | 12 ------------ .../namespaces/EventGridSenderAsyncClient.java | 4 ---- .../eventgrid/namespaces/EventGridSenderClient.java | 2 -- 4 files changed, 29 deletions(-) diff --git a/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridReceiverAsyncClient.java b/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridReceiverAsyncClient.java index 08ef748bc490..2d8f80efc6c9 100644 --- a/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridReceiverAsyncClient.java +++ b/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridReceiverAsyncClient.java @@ -416,7 +416,6 @@ public Mono receive(Integer maxEvents, Duration maxWaitTime) { @ServiceMethod(returns = ReturnType.SINGLE) public Mono> receiveWithResponse(Integer maxEvents, Duration maxWaitTime, RequestOptions requestOptions) { - // Generated convenience method for receiveWithResponse if (maxEvents != null) { requestOptions.addQueryParam("maxEvents", String.valueOf(maxEvents), false); } @@ -442,7 +441,6 @@ public Mono> receiveWithResponse(Integer maxEvents, Dura */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono receive() { - // Generated convenience method for receiveWithResponse RequestOptions requestOptions = new RequestOptions(); return receiveWithResponse(topicName, subscriptionName, requestOptions).flatMap(FluxUtil::toMono) .map(protocolMethodData -> protocolMethodData.toObject(ReceiveResult.class)); @@ -464,7 +462,6 @@ public Mono receive() { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono acknowledge(List lockTokens) { - // Generated convenience method for acknowledgeWithResponse RequestOptions requestOptions = new RequestOptions(); AcknowledgeRequest requestObj = new AcknowledgeRequest(lockTokens); BinaryData request = BinaryData.fromObject(requestObj); @@ -490,7 +487,6 @@ public Mono acknowledge(List lockTokens) { @ServiceMethod(returns = ReturnType.SINGLE) public Mono> acknowledgeWithResponse(List lockTokens, RequestOptions requestOptions) { - // Generated convenience method for acknowledgeWithResponse AcknowledgeRequest requestObj = new AcknowledgeRequest(lockTokens); BinaryData request = BinaryData.fromObject(requestObj); return acknowledgeWithResponse(topicName, subscriptionName, request, requestOptions) @@ -514,7 +510,6 @@ public Mono> acknowledgeWithResponse(List lo */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono release(List lockTokens, ReleaseDelay releaseDelay) { - // Generated convenience method for releaseWithResponse RequestOptions requestOptions = new RequestOptions(); ReleaseRequest requestObj = new ReleaseRequest(lockTokens); BinaryData request = BinaryData.fromObject(requestObj); @@ -544,7 +539,6 @@ public Mono release(List lockTokens, ReleaseDelay release @ServiceMethod(returns = ReturnType.SINGLE) public Mono> releaseWithResponse(List lockTokens, ReleaseDelay releaseDelay, RequestOptions requestOptions) { - // Generated convenience method for releaseWithResponse ReleaseRequest requestObj = new ReleaseRequest(lockTokens); BinaryData request = BinaryData.fromObject(requestObj); if (releaseDelay != null) { @@ -570,7 +564,6 @@ public Mono> releaseWithResponse(List lockTokens */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono release(List lockTokens) { - // Generated convenience method for releaseWithResponse RequestOptions requestOptions = new RequestOptions(); ReleaseRequest requestObj = new ReleaseRequest(lockTokens); BinaryData request = BinaryData.fromObject(requestObj); @@ -594,7 +587,6 @@ public Mono release(List lockTokens) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono reject(List lockTokens) { - // Generated convenience method for rejectWithResponse RequestOptions requestOptions = new RequestOptions(); RejectRequest requestObj = new RejectRequest(lockTokens); BinaryData request = BinaryData.fromObject(requestObj); @@ -619,7 +611,6 @@ public Mono reject(List lockTokens) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> rejectWithResponse(List lockTokens, RequestOptions requestOptions) { - // Generated convenience method for rejectWithResponse RejectRequest requestObj = new RejectRequest(lockTokens); BinaryData request = BinaryData.fromObject(requestObj); return rejectWithResponse(topicName, subscriptionName, request, requestOptions) @@ -642,7 +633,6 @@ public Mono> rejectWithResponse(List lockTokens, */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono renewLocks(List lockTokens) { - // Generated convenience method for renewLocksWithResponse RequestOptions requestOptions = new RequestOptions(); RenewLocksRequest requestObj = new RenewLocksRequest(lockTokens); BinaryData request = BinaryData.fromObject(requestObj); @@ -668,7 +658,6 @@ public Mono renewLocks(List lockTokens) { @ServiceMethod(returns = ReturnType.SINGLE) public Mono> renewLocksWithResponse(List lockTokens, RequestOptions requestOptions) { - // Generated convenience method for renewLocksWithResponse RenewLocksRequest requestObj = new RenewLocksRequest(lockTokens); BinaryData request = BinaryData.fromObject(requestObj); return renewLocksWithResponse(topicName, subscriptionName, request, requestOptions) diff --git a/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridReceiverClient.java b/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridReceiverClient.java index 76eb304a37f0..6b20f6022bde 100644 --- a/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridReceiverClient.java +++ b/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridReceiverClient.java @@ -374,7 +374,6 @@ Response renewLocksWithResponse(String topicName, String eventSubscr */ @ServiceMethod(returns = ReturnType.SINGLE) public ReceiveResult receive(Integer maxEvents, Duration maxWaitTime) { - // Generated convenience method for receiveWithResponse RequestOptions requestOptions = new RequestOptions(); if (maxEvents != null) { requestOptions.addQueryParam("maxEvents", String.valueOf(maxEvents), false); @@ -409,7 +408,6 @@ public ReceiveResult receive(Integer maxEvents, Duration maxWaitTime) { @ServiceMethod(returns = ReturnType.SINGLE) public Response receiveWithResponse(Integer maxEvents, Duration maxWaitTime, RequestOptions requestOptions) { - // Generated convenience method for receiveWithResponse if (maxEvents != null) { requestOptions.addQueryParam("maxEvents", String.valueOf(maxEvents), false); } @@ -435,7 +433,6 @@ public Response receiveWithResponse(Integer maxEvents, Duration m */ @ServiceMethod(returns = ReturnType.SINGLE) public ReceiveResult receive() { - // Generated convenience method for receiveWithResponse RequestOptions requestOptions = new RequestOptions(); return receiveWithResponse(topicName, subscriptionName, requestOptions).getValue() .toObject(ReceiveResult.class); @@ -457,7 +454,6 @@ public ReceiveResult receive() { */ @ServiceMethod(returns = ReturnType.SINGLE) public AcknowledgeResult acknowledge(List lockTokens) { - // Generated convenience method for acknowledgeWithResponse RequestOptions requestOptions = new RequestOptions(); AcknowledgeRequest requestObj = new AcknowledgeRequest(lockTokens); BinaryData request = BinaryData.fromObject(requestObj); @@ -482,7 +478,6 @@ public AcknowledgeResult acknowledge(List lockTokens) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Response acknowledgeWithResponse(List lockTokens, RequestOptions requestOptions) { - // Generated convenience method for acknowledgeWithResponse AcknowledgeRequest requestObj = new AcknowledgeRequest(lockTokens); BinaryData request = BinaryData.fromObject(requestObj); Response response = acknowledgeWithResponse(topicName, subscriptionName, request, requestOptions); @@ -506,7 +501,6 @@ public Response acknowledgeWithResponse(List lockToke */ @ServiceMethod(returns = ReturnType.SINGLE) public ReleaseResult release(List lockTokens, ReleaseDelay releaseDelay) { - // Generated convenience method for releaseWithResponse RequestOptions requestOptions = new RequestOptions(); ReleaseRequest requestObj = new ReleaseRequest(lockTokens); BinaryData request = BinaryData.fromObject(requestObj); @@ -536,7 +530,6 @@ public ReleaseResult release(List lockTokens, ReleaseDelay releaseDelay) @ServiceMethod(returns = ReturnType.SINGLE) public Response releaseWithResponse(List lockTokens, ReleaseDelay releaseDelay, RequestOptions requestOptions) { - // Generated convenience method for releaseWithResponse ReleaseRequest requestObj = new ReleaseRequest(lockTokens); BinaryData request = BinaryData.fromObject(requestObj); if (releaseDelay != null) { @@ -562,7 +555,6 @@ public Response releaseWithResponse(List lockTokens, Rele */ @ServiceMethod(returns = ReturnType.SINGLE) public ReleaseResult release(List lockTokens) { - // Generated convenience method for releaseWithResponse RequestOptions requestOptions = new RequestOptions(); ReleaseRequest requestObj = new ReleaseRequest(lockTokens); BinaryData request = BinaryData.fromObject(requestObj); @@ -586,7 +578,6 @@ public ReleaseResult release(List lockTokens) { */ @ServiceMethod(returns = ReturnType.SINGLE) public RejectResult reject(List lockTokens) { - // Generated convenience method for rejectWithResponse RequestOptions requestOptions = new RequestOptions(); RejectRequest requestObj = new RejectRequest(lockTokens); BinaryData request = BinaryData.fromObject(requestObj); @@ -611,7 +602,6 @@ public RejectResult reject(List lockTokens) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Response rejectWithResponse(List lockTokens, RequestOptions requestOptions) { - // Generated convenience method for rejectWithResponse RejectRequest requestObj = new RejectRequest(lockTokens); BinaryData request = BinaryData.fromObject(requestObj); Response response = rejectWithResponse(topicName, subscriptionName, request, requestOptions); @@ -634,7 +624,6 @@ public Response rejectWithResponse(List lockTokens, Reques */ @ServiceMethod(returns = ReturnType.SINGLE) public RenewLocksResult renewLocks(List lockTokens) { - // Generated convenience method for renewLocksWithResponse RequestOptions requestOptions = new RequestOptions(); RenewLocksRequest requestObj = new RenewLocksRequest(lockTokens); BinaryData request = BinaryData.fromObject(requestObj); @@ -659,7 +648,6 @@ public RenewLocksResult renewLocks(List lockTokens) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Response renewLocksWithResponse(List lockTokens, RequestOptions requestOptions) { - // Generated convenience method for renewLocksWithResponse RenewLocksRequest requestObj = new RenewLocksRequest(lockTokens); BinaryData request = BinaryData.fromObject(requestObj); Response response = renewLocksWithResponse(topicName, subscriptionName, request, requestOptions); diff --git a/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridSenderAsyncClient.java b/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridSenderAsyncClient.java index 1e0966667b1b..c2ae74930801 100644 --- a/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridSenderAsyncClient.java +++ b/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridSenderAsyncClient.java @@ -139,7 +139,6 @@ Mono> sendEventsWithResponse(String topicName, BinaryData e */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono send(CloudEvent event) { - // Generated convenience method for sendWithResponse RequestOptions requestOptions = new RequestOptions(); return sendWithResponse(topicName, BinaryData.fromObject(event), requestOptions).then(); } @@ -159,7 +158,6 @@ public Mono send(CloudEvent event) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> sendWithResponse(CloudEvent event, RequestOptions requestOptions) { - // Generated convenience method for sendWithResponse return sendWithResponse(topicName, BinaryData.fromObject(event), requestOptions).map(response -> { return new SimpleResponse<>(response, null); }); @@ -179,7 +177,6 @@ public Mono> sendWithResponse(CloudEvent event, RequestOptions re */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono send(List events) { - // Generated convenience method for sendEventsWithResponse RequestOptions requestOptions = new RequestOptions(); return sendEventsWithResponse(topicName, BinaryData.fromObject(events), requestOptions).then(); } @@ -199,7 +196,6 @@ public Mono send(List events) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> sendWithResponse(List events, RequestOptions requestOptions) { - // Generated convenience method for sendEventsWithResponse return sendEventsWithResponse(topicName, BinaryData.fromObject(events), requestOptions).map(response -> { return new SimpleResponse<>(response, null); }); diff --git a/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridSenderClient.java b/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridSenderClient.java index b2caf5585dfd..c1aa9c559c36 100644 --- a/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridSenderClient.java +++ b/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridSenderClient.java @@ -136,7 +136,6 @@ Response sendEventsWithResponse(String topicName, BinaryData events, */ @ServiceMethod(returns = ReturnType.SINGLE) public void send(CloudEvent event) { - // Generated convenience method for sendWithResponse RequestOptions requestOptions = new RequestOptions(); sendWithResponse(topicName, BinaryData.fromObject(event), requestOptions); } @@ -173,7 +172,6 @@ public Response sendWithResponse(CloudEvent event, RequestOptions requestO */ @ServiceMethod(returns = ReturnType.SINGLE) public void send(List events) { - // Generated convenience method for sendEventsWithResponse RequestOptions requestOptions = new RequestOptions(); sendEventsWithResponse(topicName, BinaryData.fromObject(events), requestOptions); } From 82e8bc0517403ce7d5b5786345fb6d67d0fe5df3 Mon Sep 17 00:00:00 2001 From: Bill Wert Date: Tue, 17 Sep 2024 12:02:29 -0700 Subject: [PATCH 5/9] fix comment --- .../eventgrid/namespaces/EventGridReceiverAsyncClient.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridReceiverAsyncClient.java b/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridReceiverAsyncClient.java index 2d8f80efc6c9..cc2162f6a871 100644 --- a/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridReceiverAsyncClient.java +++ b/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridReceiverAsyncClient.java @@ -665,10 +665,6 @@ public Mono> renewLocksWithResponse(List lock protocolMethodData.getValue().toObject(RenewLocksResult.class))); } - /** - * Gets the topicName for this client. - * @return the topic name. - /** * Gets the topicName for this client. * From 1f4e1bd484ce213ceb18cd9b0a071b7835030eee Mon Sep 17 00:00:00 2001 From: Bill Wert Date: Tue, 17 Sep 2024 12:04:07 -0700 Subject: [PATCH 6/9] just call the other method --- .../eventgrid/namespaces/EventGridReceiverAsyncClient.java | 5 ++--- .../eventgrid/namespaces/EventGridReceiverClient.java | 4 +--- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridReceiverAsyncClient.java b/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridReceiverAsyncClient.java index cc2162f6a871..3558efbeb585 100644 --- a/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridReceiverAsyncClient.java +++ b/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridReceiverAsyncClient.java @@ -387,9 +387,8 @@ public Mono receive(Integer maxEvents, Duration maxWaitTime) { requestOptions.addQueryParam("maxEvents", String.valueOf(maxEvents), false); } if (maxWaitTime != null) { - // Ensure the http client timeout is longer than the maxWaitTime - EventGridReceiverClient.addTimeoutToContext(requestOptions, maxWaitTime); - requestOptions.addQueryParam("maxWaitTime", String.valueOf(maxWaitTime.getSeconds()), false); + return receiveWithResponse(maxEvents, maxWaitTime, new RequestOptions()) + .map(Response::getValue); } return receiveWithResponse(topicName, subscriptionName, requestOptions).flatMap(FluxUtil::toMono) .map(protocolMethodData -> protocolMethodData.toObject(ReceiveResult.class)); diff --git a/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridReceiverClient.java b/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridReceiverClient.java index 6b20f6022bde..8ceb894d0236 100644 --- a/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridReceiverClient.java +++ b/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridReceiverClient.java @@ -379,9 +379,7 @@ public ReceiveResult receive(Integer maxEvents, Duration maxWaitTime) { requestOptions.addQueryParam("maxEvents", String.valueOf(maxEvents), false); } if (maxWaitTime != null) { - // Ensure the http client timeout is longer than the maxWaitTime - addTimeoutToContext(requestOptions, maxWaitTime); - requestOptions.addQueryParam("maxWaitTime", String.valueOf(maxWaitTime.getSeconds()), false); + return receiveWithResponse(maxEvents, maxWaitTime, new RequestOptions()).getValue(); } return receiveWithResponse(topicName, subscriptionName, requestOptions).getValue() .toObject(ReceiveResult.class); From ffd89b0a51a268217a0b8ed0bfe1fc5fd254cc18 Mon Sep 17 00:00:00 2001 From: Bill Wert Date: Tue, 17 Sep 2024 12:04:44 -0700 Subject: [PATCH 7/9] Add a little buffer to the http timeout in the default case. --- .../eventgrid/namespaces/EventGridReceiverAsyncClient.java | 3 +++ .../eventgrid/namespaces/EventGridReceiverClient.java | 3 +++ 2 files changed, 6 insertions(+) diff --git a/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridReceiverAsyncClient.java b/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridReceiverAsyncClient.java index 3558efbeb585..c9970f98ea51 100644 --- a/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridReceiverAsyncClient.java +++ b/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridReceiverAsyncClient.java @@ -422,6 +422,9 @@ public Mono> receiveWithResponse(Integer maxEvents, Dura // Ensure the http client timeout is longer than the maxWaitTime EventGridReceiverClient.addTimeoutToContext(requestOptions, maxWaitTime); requestOptions.addQueryParam("maxWaitTime", String.valueOf(maxWaitTime.getSeconds()), false); + } else { + // Extend the timeout with a buffer past the default maxWaitTime. + EventGridReceiverClient.addTimeoutToContext(requestOptions, Duration.ofSeconds(65)); } return receiveWithResponse(topicName, subscriptionName, requestOptions) .map(response -> new SimpleResponse<>(response, response.getValue().toObject(ReceiveResult.class))); diff --git a/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridReceiverClient.java b/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridReceiverClient.java index 8ceb894d0236..e3e2c347a706 100644 --- a/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridReceiverClient.java +++ b/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridReceiverClient.java @@ -413,6 +413,9 @@ public Response receiveWithResponse(Integer maxEvents, Duration m // Ensure the http client timeout is longer than the maxWaitTime addTimeoutToContext(requestOptions, maxWaitTime); requestOptions.addQueryParam("maxWaitTime", String.valueOf(maxWaitTime.getSeconds()), false); + } else { + // Extend the timeout with a buffer past the default maxWaitTime. + addTimeoutToContext(requestOptions, Duration.ofSeconds(65)); } Response response = receiveWithResponse(topicName, subscriptionName, requestOptions); return new SimpleResponse<>(response, response.getValue().toObject(ReceiveResult.class)); From 4ccd4b4c9ebf22f51b4d3c3fcc5efc6207ec281f Mon Sep 17 00:00:00 2001 From: Bill Wert Date: Tue, 17 Sep 2024 12:35:01 -0700 Subject: [PATCH 8/9] run tsp-client update to pick up formatting fixes --- .../EventGridReceiverAsyncClient.java | 39 ++++++++++--------- .../namespaces/EventGridReceiverClient.java | 27 ++++++------- .../EventGridSenderAsyncClient.java | 36 ++++++++--------- .../namespaces/EventGridSenderClient.java | 12 +++--- .../src/main/java/module-info.java | 2 - 5 files changed, 58 insertions(+), 58 deletions(-) diff --git a/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridReceiverAsyncClient.java b/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridReceiverAsyncClient.java index c9970f98ea51..f7f594db78e7 100644 --- a/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridReceiverAsyncClient.java +++ b/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridReceiverAsyncClient.java @@ -15,7 +15,6 @@ import com.azure.core.http.rest.Response; import com.azure.core.http.rest.SimpleResponse; import com.azure.core.util.BinaryData; -import com.azure.core.util.Context; import com.azure.core.util.FluxUtil; import com.azure.messaging.eventgrid.namespaces.implementation.EventGridReceiverClientImpl; import com.azure.messaging.eventgrid.namespaces.implementation.models.AcknowledgeRequest; @@ -73,7 +72,7 @@ public final class EventGridReceiverAsyncClient { * * You can add these to a request with {@link RequestOptions#addQueryParam} *

Response Body Schema

- * + * *
{@code
      * {
      *     value (Required): [
@@ -121,7 +120,7 @@ Mono> receiveWithResponse(String topicName, String eventSub
      * along with other failed lock tokens with their corresponding error information. Successfully acknowledged events
      * will no longer be available to be received by any consumer.
      * 

Request Body Schema

- * + * *
{@code
      * {
      *     lockTokens (Required): [
@@ -129,9 +128,9 @@ Mono> receiveWithResponse(String topicName, String eventSub
      *     ]
      * }
      * }
- * + * *

Response Body Schema

- * + * *
{@code
      * {
      *     failedLockTokens (Required): [
@@ -189,7 +188,7 @@ Mono> acknowledgeWithResponse(String topicName, String even
      * 
      * You can add these to a request with {@link RequestOptions#addQueryParam}
      * 

Request Body Schema

- * + * *
{@code
      * {
      *     lockTokens (Required): [
@@ -197,9 +196,9 @@ Mono> acknowledgeWithResponse(String topicName, String even
      *     ]
      * }
      * }
- * + * *

Response Body Schema

- * + * *
{@code
      * {
      *     failedLockTokens (Required): [
@@ -248,7 +247,7 @@ Mono> releaseWithResponse(String topicName, String eventSub
      * with other failed lock tokens with their corresponding error information. Successfully rejected events will be
      * dead-lettered and can no longer be received by a consumer.
      * 

Request Body Schema

- * + * *
{@code
      * {
      *     lockTokens (Required): [
@@ -256,9 +255,9 @@ Mono> releaseWithResponse(String topicName, String eventSub
      *     ]
      * }
      * }
- * + * *

Response Body Schema

- * + * *
{@code
      * {
      *     failedLockTokens (Required): [
@@ -307,7 +306,7 @@ Mono> rejectWithResponse(String topicName, String eventSubs
      * along with other failed lock tokens with their corresponding error information. Successfully renewed locks will
      * ensure that the associated event is only available to the consumer that holds the renewed lock.
      * 

Request Body Schema

- * + * *
{@code
      * {
      *     lockTokens (Required): [
@@ -315,9 +314,9 @@ Mono> rejectWithResponse(String topicName, String eventSubs
      *     ]
      * }
      * }
- * + * *

Response Body Schema

- * + * *
{@code
      * {
      *     failedLockTokens (Required): [
@@ -387,8 +386,7 @@ public Mono receive(Integer maxEvents, Duration maxWaitTime) {
             requestOptions.addQueryParam("maxEvents", String.valueOf(maxEvents), false);
         }
         if (maxWaitTime != null) {
-            return receiveWithResponse(maxEvents, maxWaitTime, new RequestOptions())
-                .map(Response::getValue);
+            return receiveWithResponse(maxEvents, maxWaitTime, new RequestOptions()).map(Response::getValue);
         }
         return receiveWithResponse(topicName, subscriptionName, requestOptions).flatMap(FluxUtil::toMono)
             .map(protocolMethodData -> protocolMethodData.toObject(ReceiveResult.class));
@@ -410,7 +408,8 @@ public Mono receive(Integer maxEvents, Duration maxWaitTime) {
      * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
      * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
      * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
-     * @return details of the Receive operation response on successful completion of {@link Mono} along with {@link Response}.
+     * @return details of the Receive operation response on successful completion of {@link Mono} along with
+     * {@link Response}.
      */
     @ServiceMethod(returns = ReturnType.SINGLE)
     public Mono> receiveWithResponse(Integer maxEvents, Duration maxWaitTime,
@@ -484,7 +483,8 @@ public Mono acknowledge(List lockTokens) {
      * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
      * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
      * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
-     * @return the result of the Acknowledge operation on successful completion of {@link Mono} along with {@link Response}.
+     * @return the result of the Acknowledge operation on successful completion of {@link Mono} along with
+     * {@link Response}.
      */
     @ServiceMethod(returns = ReturnType.SINGLE)
     public Mono> acknowledgeWithResponse(List lockTokens,
@@ -655,7 +655,8 @@ public Mono renewLocks(List lockTokens) {
      * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
      * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
      * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
-     * @return the result of the RenewLock operation on successful completion of {@link Mono} along with {@link Response}.
+     * @return the result of the RenewLock operation on successful completion of {@link Mono} along with
+     * {@link Response}.
      */
     @ServiceMethod(returns = ReturnType.SINGLE)
     public Mono> renewLocksWithResponse(List lockTokens,
diff --git a/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridReceiverClient.java b/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridReceiverClient.java
index e3e2c347a706..ad98850b553c 100644
--- a/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridReceiverClient.java
+++ b/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridReceiverClient.java
@@ -71,7 +71,7 @@ public final class EventGridReceiverClient {
      * 
      * You can add these to a request with {@link RequestOptions#addQueryParam}
      * 

Response Body Schema

- * + * *
{@code
      * {
      *     value (Required): [
@@ -118,7 +118,7 @@ Response receiveWithResponse(String topicName, String eventSubscript
      * along with other failed lock tokens with their corresponding error information. Successfully acknowledged events
      * will no longer be available to be received by any consumer.
      * 

Request Body Schema

- * + * *
{@code
      * {
      *     lockTokens (Required): [
@@ -126,9 +126,9 @@ Response receiveWithResponse(String topicName, String eventSubscript
      *     ]
      * }
      * }
- * + * *

Response Body Schema

- * + * *
{@code
      * {
      *     failedLockTokens (Required): [
@@ -185,7 +185,7 @@ Response acknowledgeWithResponse(String topicName, String eventSubsc
      * 
      * You can add these to a request with {@link RequestOptions#addQueryParam}
      * 

Request Body Schema

- * + * *
{@code
      * {
      *     lockTokens (Required): [
@@ -193,9 +193,9 @@ Response acknowledgeWithResponse(String topicName, String eventSubsc
      *     ]
      * }
      * }
- * + * *

Response Body Schema

- * + * *
{@code
      * {
      *     failedLockTokens (Required): [
@@ -243,7 +243,7 @@ Response releaseWithResponse(String topicName, String eventSubscript
      * with other failed lock tokens with their corresponding error information. Successfully rejected events will be
      * dead-lettered and can no longer be received by a consumer.
      * 

Request Body Schema

- * + * *
{@code
      * {
      *     lockTokens (Required): [
@@ -251,9 +251,9 @@ Response releaseWithResponse(String topicName, String eventSubscript
      *     ]
      * }
      * }
- * + * *

Response Body Schema

- * + * *
{@code
      * {
      *     failedLockTokens (Required): [
@@ -301,7 +301,7 @@ Response rejectWithResponse(String topicName, String eventSubscripti
      * along with other failed lock tokens with their corresponding error information. Successfully renewed locks will
      * ensure that the associated event is only available to the consumer that holds the renewed lock.
      * 

Request Body Schema

- * + * *
{@code
      * {
      *     lockTokens (Required): [
@@ -309,9 +309,9 @@ Response rejectWithResponse(String topicName, String eventSubscripti
      *     ]
      * }
      * }
- * + * *

Response Body Schema

- * + * *
{@code
      * {
      *     failedLockTokens (Required): [
@@ -675,6 +675,7 @@ public String getSubscriptionName() {
 
     /**
      * Adds a timeout (maxWaitTime) to a context.
+     * 
      * @param requestOptions The request options to update.
      * @param timeout The timeout to add.
      * @return The updated context.
diff --git a/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridSenderAsyncClient.java b/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridSenderAsyncClient.java
index c2ae74930801..f67577e06f60 100644
--- a/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridSenderAsyncClient.java
+++ b/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridSenderAsyncClient.java
@@ -45,7 +45,7 @@ public final class EventGridSenderAsyncClient {
     /**
      * Publish a single Cloud Event to a namespace topic.
      * 

Request Body Schema

- * + * *
{@code
      * {
      *     id: String (Required)
@@ -60,9 +60,9 @@ public final class EventGridSenderAsyncClient {
      *     subject: String (Optional)
      * }
      * }
- * + * *

Response Body Schema

- * + * *
{@code
      * { }
      * }
@@ -85,7 +85,7 @@ Mono> sendWithResponse(String topicName, BinaryData event, /** * Publish a batch of Cloud Events to a namespace topic. *

Request Body Schema

- * + * *
{@code
      * [
      *      (Required){
@@ -102,9 +102,9 @@ Mono> sendWithResponse(String topicName, BinaryData event,
      *     }
      * ]
      * }
- * + * *

Response Body Schema

- * + * *
{@code
      * { }
      * }
@@ -144,18 +144,18 @@ public Mono send(CloudEvent event) { } /** - * Publish a single Cloud Event to a namespace topic. - * - * @param event Single Cloud Event being published. - * @param requestOptions The options to configure the HTTP request before HTTP client sends it. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the result of the Publish operation on successful completion of {@link Mono}. - */ + * Publish a single Cloud Event to a namespace topic. + * + * @param event Single Cloud Event being published. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the result of the Publish operation on successful completion of {@link Mono}. + */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> sendWithResponse(CloudEvent event, RequestOptions requestOptions) { return sendWithResponse(topicName, BinaryData.fromObject(event), requestOptions).map(response -> { diff --git a/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridSenderClient.java b/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridSenderClient.java index c1aa9c559c36..ccdbbf691bf9 100644 --- a/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridSenderClient.java +++ b/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridSenderClient.java @@ -44,7 +44,7 @@ public final class EventGridSenderClient { /** * Publish a single Cloud Event to a namespace topic. *

Request Body Schema

- * + * *
{@code
      * {
      *     id: String (Required)
@@ -59,9 +59,9 @@ public final class EventGridSenderClient {
      *     subject: String (Optional)
      * }
      * }
- * + * *

Response Body Schema

- * + * *
{@code
      * { }
      * }
@@ -84,7 +84,7 @@ Response sendWithResponse(String topicName, BinaryData event, Reques /** * Publish a batch of Cloud Events to a namespace topic. *

Request Body Schema

- * + * *
{@code
      * [
      *      (Required){
@@ -101,9 +101,9 @@ Response sendWithResponse(String topicName, BinaryData event, Reques
      *     }
      * ]
      * }
- * + * *

Response Body Schema

- * + * *
{@code
      * { }
      * }
diff --git a/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/module-info.java b/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/module-info.java index a2266eeb53e0..05327b4d74f9 100644 --- a/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/module-info.java +++ b/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/module-info.java @@ -4,10 +4,8 @@ module com.azure.messaging.eventgrid.namespaces { requires transitive com.azure.core; - exports com.azure.messaging.eventgrid.namespaces; exports com.azure.messaging.eventgrid.namespaces.models; - opens com.azure.messaging.eventgrid.namespaces.implementation.models to com.azure.core; opens com.azure.messaging.eventgrid.namespaces.models to com.azure.core; } From b04958eef1d87ce66561b6ed2a6df94d7b73a07b Mon Sep 17 00:00:00 2001 From: Bill Wert Date: Thu, 19 Sep 2024 15:10:39 -0700 Subject: [PATCH 9/9] add a comment about how fractional seconds are handled. --- .../EventGridReceiverAsyncClient.java | 30 ++++++++--------- .../namespaces/EventGridReceiverClient.java | 32 +++++++++---------- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridReceiverAsyncClient.java b/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridReceiverAsyncClient.java index f7f594db78e7..a1e68bd07238 100644 --- a/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridReceiverAsyncClient.java +++ b/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridReceiverAsyncClient.java @@ -72,7 +72,7 @@ public final class EventGridReceiverAsyncClient { * * You can add these to a request with {@link RequestOptions#addQueryParam} *

Response Body Schema

- * + * *
{@code
      * {
      *     value (Required): [
@@ -120,7 +120,7 @@ Mono> receiveWithResponse(String topicName, String eventSub
      * along with other failed lock tokens with their corresponding error information. Successfully acknowledged events
      * will no longer be available to be received by any consumer.
      * 

Request Body Schema

- * + * *
{@code
      * {
      *     lockTokens (Required): [
@@ -128,9 +128,9 @@ Mono> receiveWithResponse(String topicName, String eventSub
      *     ]
      * }
      * }
- * + * *

Response Body Schema

- * + * *
{@code
      * {
      *     failedLockTokens (Required): [
@@ -188,7 +188,7 @@ Mono> acknowledgeWithResponse(String topicName, String even
      * 
      * You can add these to a request with {@link RequestOptions#addQueryParam}
      * 

Request Body Schema

- * + * *
{@code
      * {
      *     lockTokens (Required): [
@@ -196,9 +196,9 @@ Mono> acknowledgeWithResponse(String topicName, String even
      *     ]
      * }
      * }
- * + * *

Response Body Schema

- * + * *
{@code
      * {
      *     failedLockTokens (Required): [
@@ -247,7 +247,7 @@ Mono> releaseWithResponse(String topicName, String eventSub
      * with other failed lock tokens with their corresponding error information. Successfully rejected events will be
      * dead-lettered and can no longer be received by a consumer.
      * 

Request Body Schema

- * + * *
{@code
      * {
      *     lockTokens (Required): [
@@ -255,9 +255,9 @@ Mono> releaseWithResponse(String topicName, String eventSub
      *     ]
      * }
      * }
- * + * *

Response Body Schema

- * + * *
{@code
      * {
      *     failedLockTokens (Required): [
@@ -306,7 +306,7 @@ Mono> rejectWithResponse(String topicName, String eventSubs
      * along with other failed lock tokens with their corresponding error information. Successfully renewed locks will
      * ensure that the associated event is only available to the consumer that holds the renewed lock.
      * 

Request Body Schema

- * + * *
{@code
      * {
      *     lockTokens (Required): [
@@ -314,9 +314,9 @@ Mono> rejectWithResponse(String topicName, String eventSubs
      *     ]
      * }
      * }
- * + * *

Response Body Schema

- * + * *
{@code
      * {
      *     failedLockTokens (Required): [
@@ -369,7 +369,7 @@ Mono> renewLocksWithResponse(String topicName, String event
      * @param maxWaitTime Max wait time value for receive operation in Seconds. It is the time in seconds that the
      * server approximately waits for the availability of an event and responds to the request. If an event is
      * available, the broker responds immediately to the client. Minimum value is 10 seconds, while maximum value is 120
-     * seconds. If not specified, the default value is 60 seconds.
+     * seconds. If not specified, the default value is 60 seconds. Fractional seconds are ignored and rounded down.
      * @throws IllegalArgumentException thrown if parameters fail the validation.
      * @throws HttpResponseException thrown if the request is rejected by server.
      * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
@@ -400,7 +400,7 @@ public Mono receive(Integer maxEvents, Duration maxWaitTime) {
      * @param maxWaitTime Max wait time value for receive operation in Seconds. It is the time in seconds that the
      * server approximately waits for the availability of an event and responds to the request. If an event is
      * available, the broker responds immediately to the client. Minimum value is 10 seconds, while maximum value is 120
-     * seconds. If not specified, the default value is 60 seconds.
+     * seconds. If not specified, the default value is 60 seconds. Fractional seconds are ignored and rounded down.
      * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
      * @throws IllegalArgumentException thrown if parameters fail the validation.
      * @throws HttpResponseException thrown if the request is rejected by server.
diff --git a/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridReceiverClient.java b/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridReceiverClient.java
index ad98850b553c..9a0bf9eabfef 100644
--- a/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridReceiverClient.java
+++ b/sdk/eventgrid/azure-messaging-eventgrid-namespaces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridReceiverClient.java
@@ -71,7 +71,7 @@ public final class EventGridReceiverClient {
      * 
      * You can add these to a request with {@link RequestOptions#addQueryParam}
      * 

Response Body Schema

- * + * *
{@code
      * {
      *     value (Required): [
@@ -118,7 +118,7 @@ Response receiveWithResponse(String topicName, String eventSubscript
      * along with other failed lock tokens with their corresponding error information. Successfully acknowledged events
      * will no longer be available to be received by any consumer.
      * 

Request Body Schema

- * + * *
{@code
      * {
      *     lockTokens (Required): [
@@ -126,9 +126,9 @@ Response receiveWithResponse(String topicName, String eventSubscript
      *     ]
      * }
      * }
- * + * *

Response Body Schema

- * + * *
{@code
      * {
      *     failedLockTokens (Required): [
@@ -185,7 +185,7 @@ Response acknowledgeWithResponse(String topicName, String eventSubsc
      * 
      * You can add these to a request with {@link RequestOptions#addQueryParam}
      * 

Request Body Schema

- * + * *
{@code
      * {
      *     lockTokens (Required): [
@@ -193,9 +193,9 @@ Response acknowledgeWithResponse(String topicName, String eventSubsc
      *     ]
      * }
      * }
- * + * *

Response Body Schema

- * + * *
{@code
      * {
      *     failedLockTokens (Required): [
@@ -243,7 +243,7 @@ Response releaseWithResponse(String topicName, String eventSubscript
      * with other failed lock tokens with their corresponding error information. Successfully rejected events will be
      * dead-lettered and can no longer be received by a consumer.
      * 

Request Body Schema

- * + * *
{@code
      * {
      *     lockTokens (Required): [
@@ -251,9 +251,9 @@ Response releaseWithResponse(String topicName, String eventSubscript
      *     ]
      * }
      * }
- * + * *

Response Body Schema

- * + * *
{@code
      * {
      *     failedLockTokens (Required): [
@@ -301,7 +301,7 @@ Response rejectWithResponse(String topicName, String eventSubscripti
      * along with other failed lock tokens with their corresponding error information. Successfully renewed locks will
      * ensure that the associated event is only available to the consumer that holds the renewed lock.
      * 

Request Body Schema

- * + * *
{@code
      * {
      *     lockTokens (Required): [
@@ -309,9 +309,9 @@ Response rejectWithResponse(String topicName, String eventSubscripti
      *     ]
      * }
      * }
- * + * *

Response Body Schema

- * + * *
{@code
      * {
      *     failedLockTokens (Required): [
@@ -363,7 +363,7 @@ Response renewLocksWithResponse(String topicName, String eventSubscr
      * @param maxWaitTime Max wait time value for receive operation in Seconds. It is the time in seconds that the
      * server approximately waits for the availability of an event and responds to the request. If an event is
      * available, the broker responds immediately to the client. Minimum value is 10 seconds, while maximum value is 120
-     * seconds. If not specified, the default value is 60 seconds.
+     * seconds. If not specified, the default value is 60 seconds. Fractional seconds are ignored and rounded down.
      * @throws IllegalArgumentException thrown if parameters fail the validation.
      * @throws HttpResponseException thrown if the request is rejected by server.
      * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
@@ -393,7 +393,7 @@ public ReceiveResult receive(Integer maxEvents, Duration maxWaitTime) {
      * @param maxWaitTime Max wait time value for receive operation in Seconds. It is the time in seconds that the
      * server approximately waits for the availability of an event and responds to the request. If an event is
      * available, the broker responds immediately to the client. Minimum value is 10 seconds, while maximum value is 120
-     * seconds. If not specified, the default value is 60 seconds.
+     * seconds. If not specified, the default value is 60 seconds. Fractional seconds are ignored and rounded down.
      * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
      * @throws IllegalArgumentException thrown if parameters fail the validation.
      * @throws HttpResponseException thrown if the request is rejected by server.
@@ -675,7 +675,7 @@ public String getSubscriptionName() {
 
     /**
      * Adds a timeout (maxWaitTime) to a context.
-     * 
+     *
      * @param requestOptions The request options to update.
      * @param timeout The timeout to add.
      * @return The updated context.