Skip to content

Commit

Permalink
client, CoreUtils.randomUuid (Azure#2838)
Browse files Browse the repository at this point in the history
  • Loading branch information
weidongxu-microsoft authored Jun 26, 2024
1 parent 6ead6cd commit d4844d6
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ public void addImportsTo(Set<String> imports, boolean includeImplementationImpor

if (MethodUtil.isMethodIncludeRepeatableRequestHeaders(this.proxyMethod)) {
// Repeatable Requests
ClassType.UUID.addImportsTo(imports, false);
ClassType.CORE_UTILS.addImportsTo(imports, false);
ClassType.DATE_TIME.addImportsTo(imports, false);
ClassType.DATE_TIME_RFC_1123.addImportsTo(imports, false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ private static void requestOptionsSetHeaderIfAbsent(JavaBlock function, String v

protected static void addSpecialHeadersToLocalVariables(JavaBlock function, ClientMethod clientMethod) {
if (MethodUtil.isMethodIncludeRepeatableRequestHeaders(clientMethod.getProxyMethod())) {
function.line(String.format("String %1$s = UUID.randomUUID().toString();", MethodUtil.REPEATABILITY_REQUEST_ID_VARIABLE_NAME));
function.line(String.format("String %1$s = CoreUtils.randomUuid().toString();", MethodUtil.REPEATABILITY_REQUEST_ID_VARIABLE_NAME));
function.line(String.format("String %1$s = DateTimeRfc1123.toRfc1123String(OffsetDateTime.now());", MethodUtil.REPEATABILITY_FIRST_SENT_VARIABLE_NAME));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import com.azure.core.http.rest.RestProxy;
import com.azure.core.util.BinaryData;
import com.azure.core.util.Context;
import com.azure.core.util.CoreUtils;
import com.azure.core.util.DateTimeRfc1123;
import com.azure.core.util.FluxUtil;
import com.azure.core.util.polling.DefaultPollingStrategy;
Expand All @@ -43,7 +44,6 @@
import java.time.OffsetDateTime;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.stream.Collectors;
import reactor.core.publisher.Mono;

Expand Down Expand Up @@ -226,7 +226,7 @@ Response<BinaryData> paramRepeatabilityRequestPageableNextSync(
public Mono<Response<BinaryData>> paramRepeatabilityRequestWithResponseAsync(RequestOptions requestOptions) {
final String accept = "application/json";
RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions;
String repeatabilityRequestId = UUID.randomUUID().toString();
String repeatabilityRequestId = CoreUtils.randomUuid().toString();
String repeatabilityFirstSent = DateTimeRfc1123.toRfc1123String(OffsetDateTime.now());
requestOptionsLocal.addRequestCallback(requestLocal -> {
if (requestLocal.getHeaders().get(HttpHeaderName.fromString("repeatability-request-id")) == null) {
Expand Down Expand Up @@ -272,7 +272,7 @@ public Mono<Response<BinaryData>> paramRepeatabilityRequestWithResponseAsync(Req
public Response<BinaryData> paramRepeatabilityRequestWithResponse(RequestOptions requestOptions) {
final String accept = "application/json";
RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions;
String repeatabilityRequestId = UUID.randomUUID().toString();
String repeatabilityRequestId = CoreUtils.randomUuid().toString();
String repeatabilityFirstSent = DateTimeRfc1123.toRfc1123String(OffsetDateTime.now());
requestOptionsLocal.addRequestCallback(requestLocal -> {
if (requestLocal.getHeaders().get(HttpHeaderName.fromString("repeatability-request-id")) == null) {
Expand Down Expand Up @@ -317,7 +317,7 @@ public Response<BinaryData> paramRepeatabilityRequestWithResponse(RequestOptions
public Mono<Response<BinaryData>> paramRepeatabilityRequestPutWithResponseAsync(RequestOptions requestOptions) {
final String accept = "application/json";
RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions;
String repeatabilityRequestId = UUID.randomUUID().toString();
String repeatabilityRequestId = CoreUtils.randomUuid().toString();
String repeatabilityFirstSent = DateTimeRfc1123.toRfc1123String(OffsetDateTime.now());
requestOptionsLocal.addRequestCallback(requestLocal -> {
if (requestLocal.getHeaders().get(HttpHeaderName.fromString("repeatability-request-id")) == null) {
Expand Down Expand Up @@ -363,7 +363,7 @@ public Mono<Response<BinaryData>> paramRepeatabilityRequestPutWithResponseAsync(
public Response<BinaryData> paramRepeatabilityRequestPutWithResponse(RequestOptions requestOptions) {
final String accept = "application/json";
RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions;
String repeatabilityRequestId = UUID.randomUUID().toString();
String repeatabilityRequestId = CoreUtils.randomUuid().toString();
String repeatabilityFirstSent = DateTimeRfc1123.toRfc1123String(OffsetDateTime.now());
requestOptionsLocal.addRequestCallback(requestLocal -> {
if (requestLocal.getHeaders().get(HttpHeaderName.fromString("repeatability-request-id")) == null) {
Expand Down Expand Up @@ -452,7 +452,7 @@ public Response<BinaryData> paramRepeatabilityRequestGetWithResponse(RequestOpti
private Mono<Response<BinaryData>> paramRepeatabilityRequestLroWithResponseAsync(RequestOptions requestOptions) {
final String accept = "application/json";
RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions;
String repeatabilityRequestId = UUID.randomUUID().toString();
String repeatabilityRequestId = CoreUtils.randomUuid().toString();
String repeatabilityFirstSent = DateTimeRfc1123.toRfc1123String(OffsetDateTime.now());
requestOptionsLocal.addRequestCallback(requestLocal -> {
if (requestLocal.getHeaders().get(HttpHeaderName.fromString("repeatability-request-id")) == null) {
Expand Down Expand Up @@ -498,7 +498,7 @@ private Mono<Response<BinaryData>> paramRepeatabilityRequestLroWithResponseAsync
private Response<BinaryData> paramRepeatabilityRequestLroWithResponse(RequestOptions requestOptions) {
final String accept = "application/json";
RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions;
String repeatabilityRequestId = UUID.randomUUID().toString();
String repeatabilityRequestId = CoreUtils.randomUuid().toString();
String repeatabilityFirstSent = DateTimeRfc1123.toRfc1123String(OffsetDateTime.now());
requestOptionsLocal.addRequestCallback(requestLocal -> {
if (requestLocal.getHeaders().get(HttpHeaderName.fromString("repeatability-request-id")) == null) {
Expand Down Expand Up @@ -617,7 +617,7 @@ public SyncPoller<BinaryData, BinaryData> beginParamRepeatabilityRequestLro(Requ
paramRepeatabilityRequestPageableSinglePageAsync(RequestOptions requestOptions) {
final String accept = "application/json";
RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions;
String repeatabilityRequestId = UUID.randomUUID().toString();
String repeatabilityRequestId = CoreUtils.randomUuid().toString();
String repeatabilityFirstSent = DateTimeRfc1123.toRfc1123String(OffsetDateTime.now());
requestOptionsLocal.addRequestCallback(requestLocal -> {
if (requestLocal.getHeaders().get(HttpHeaderName.fromString("repeatability-request-id")) == null) {
Expand Down Expand Up @@ -699,7 +699,7 @@ public PagedFlux<BinaryData> paramRepeatabilityRequestPageableAsync(RequestOptio
private PagedResponse<BinaryData> paramRepeatabilityRequestPageableSinglePage(RequestOptions requestOptions) {
final String accept = "application/json";
RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions;
String repeatabilityRequestId = UUID.randomUUID().toString();
String repeatabilityRequestId = CoreUtils.randomUuid().toString();
String repeatabilityFirstSent = DateTimeRfc1123.toRfc1123String(OffsetDateTime.now());
requestOptionsLocal.addRequestCallback(requestLocal -> {
if (requestLocal.getHeaders().get(HttpHeaderName.fromString("repeatability-request-id")) == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@
import com.azure.core.http.rest.RestProxy;
import com.azure.core.util.BinaryData;
import com.azure.core.util.Context;
import com.azure.core.util.CoreUtils;
import com.azure.core.util.DateTimeRfc1123;
import com.azure.core.util.FluxUtil;
import com.azure.core.util.serializer.JacksonAdapter;
import com.azure.core.util.serializer.SerializerAdapter;
import java.time.OffsetDateTime;
import java.util.UUID;
import reactor.core.publisher.Mono;

/**
Expand Down Expand Up @@ -296,7 +296,7 @@ public Mono<Response<BinaryData>> repeatableActionWithResponseAsync(int id, Bina
RequestOptions requestOptions) {
final String accept = "application/json";
RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions;
String repeatabilityRequestId = UUID.randomUUID().toString();
String repeatabilityRequestId = CoreUtils.randomUuid().toString();
String repeatabilityFirstSent = DateTimeRfc1123.toRfc1123String(OffsetDateTime.now());
requestOptionsLocal.addRequestCallback(requestLocal -> {
if (requestLocal.getHeaders().get(HttpHeaderName.fromString("repeatability-request-id")) == null) {
Expand Down Expand Up @@ -355,7 +355,7 @@ public Response<BinaryData> repeatableActionWithResponse(int id, BinaryData user
RequestOptions requestOptions) {
final String accept = "application/json";
RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions;
String repeatabilityRequestId = UUID.randomUUID().toString();
String repeatabilityRequestId = CoreUtils.randomUuid().toString();
String repeatabilityFirstSent = DateTimeRfc1123.toRfc1123String(OffsetDateTime.now());
requestOptionsLocal.addRequestCallback(requestLocal -> {
if (requestLocal.getHeaders().get(HttpHeaderName.fromString("repeatability-request-id")) == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import com.azure.core.http.rest.RestProxy;
import com.azure.core.util.BinaryData;
import com.azure.core.util.Context;
import com.azure.core.util.CoreUtils;
import com.azure.core.util.DateTimeRfc1123;
import com.azure.core.util.FluxUtil;
import com.azure.core.util.polling.DefaultPollingStrategy;
Expand All @@ -47,7 +48,6 @@
import com.cadl.longrunning.models.PollResponse;
import java.time.Duration;
import java.time.OffsetDateTime;
import java.util.UUID;
import reactor.core.publisher.Mono;

/**
Expand Down Expand Up @@ -483,7 +483,7 @@ public Response<BinaryData> getJobWithResponse(String id, RequestOptions request
private Mono<Response<BinaryData>> createJobWithResponseAsync(BinaryData body, RequestOptions requestOptions) {
final String accept = "application/json";
RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions;
String repeatabilityRequestId = UUID.randomUUID().toString();
String repeatabilityRequestId = CoreUtils.randomUuid().toString();
String repeatabilityFirstSent = DateTimeRfc1123.toRfc1123String(OffsetDateTime.now());
requestOptionsLocal.addRequestCallback(requestLocal -> {
if (requestLocal.getHeaders().get(HttpHeaderName.fromString("repeatability-request-id")) == null) {
Expand Down Expand Up @@ -559,7 +559,7 @@ private Mono<Response<BinaryData>> createJobWithResponseAsync(BinaryData body, R
private Response<BinaryData> createJobWithResponse(BinaryData body, RequestOptions requestOptions) {
final String accept = "application/json";
RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions;
String repeatabilityRequestId = UUID.randomUUID().toString();
String repeatabilityRequestId = CoreUtils.randomUuid().toString();
String repeatabilityFirstSent = DateTimeRfc1123.toRfc1123String(OffsetDateTime.now());
requestOptionsLocal.addRequestCallback(requestLocal -> {
if (requestLocal.getHeaders().get(HttpHeaderName.fromString("repeatability-request-id")) == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import com.azure.core.http.rest.RestProxy;
import com.azure.core.util.BinaryData;
import com.azure.core.util.Context;
import com.azure.core.util.CoreUtils;
import com.azure.core.util.DateTimeRfc1123;
import com.azure.core.util.FluxUtil;
import com.azure.core.util.polling.PollerFlux;
Expand All @@ -40,7 +41,6 @@
import com.cadl.specialheaders.models.Resource;
import java.time.Duration;
import java.time.OffsetDateTime;
import java.util.UUID;
import reactor.core.publisher.Mono;

/**
Expand Down Expand Up @@ -274,7 +274,7 @@ public Mono<Response<BinaryData>> putWithResponseAsync(String name, BinaryData r
RequestOptions requestOptions) {
final String accept = "application/json";
RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions;
String repeatabilityRequestId = UUID.randomUUID().toString();
String repeatabilityRequestId = CoreUtils.randomUuid().toString();
String repeatabilityFirstSent = DateTimeRfc1123.toRfc1123String(OffsetDateTime.now());
requestOptionsLocal.addRequestCallback(requestLocal -> {
if (requestLocal.getHeaders().get(HttpHeaderName.fromString("repeatability-request-id")) == null) {
Expand Down Expand Up @@ -338,7 +338,7 @@ public Mono<Response<BinaryData>> putWithResponseAsync(String name, BinaryData r
public Response<BinaryData> putWithResponse(String name, BinaryData resource, RequestOptions requestOptions) {
final String accept = "application/json";
RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions;
String repeatabilityRequestId = UUID.randomUUID().toString();
String repeatabilityRequestId = CoreUtils.randomUuid().toString();
String repeatabilityFirstSent = DateTimeRfc1123.toRfc1123String(OffsetDateTime.now());
requestOptionsLocal.addRequestCallback(requestLocal -> {
if (requestLocal.getHeaders().get(HttpHeaderName.fromString("repeatability-request-id")) == null) {
Expand Down Expand Up @@ -390,7 +390,7 @@ public Response<BinaryData> putWithResponse(String name, BinaryData resource, Re
public Mono<Response<BinaryData>> postWithResponseAsync(String name, RequestOptions requestOptions) {
final String accept = "application/json";
RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions;
String repeatabilityRequestId = UUID.randomUUID().toString();
String repeatabilityRequestId = CoreUtils.randomUuid().toString();
String repeatabilityFirstSent = DateTimeRfc1123.toRfc1123String(OffsetDateTime.now());
requestOptionsLocal.addRequestCallback(requestLocal -> {
if (requestLocal.getHeaders().get(HttpHeaderName.fromString("repeatability-request-id")) == null) {
Expand Down Expand Up @@ -442,7 +442,7 @@ public Mono<Response<BinaryData>> postWithResponseAsync(String name, RequestOpti
public Response<BinaryData> postWithResponse(String name, RequestOptions requestOptions) {
final String accept = "application/json";
RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions;
String repeatabilityRequestId = UUID.randomUUID().toString();
String repeatabilityRequestId = CoreUtils.randomUuid().toString();
String repeatabilityFirstSent = DateTimeRfc1123.toRfc1123String(OffsetDateTime.now());
requestOptionsLocal.addRequestCallback(requestLocal -> {
if (requestLocal.getHeaders().get(HttpHeaderName.fromString("repeatability-request-id")) == null) {
Expand Down Expand Up @@ -508,7 +508,7 @@ private Mono<Response<BinaryData>> createLroWithResponseAsync(String name, Binar
final String contentType = "application/merge-patch+json";
final String accept = "application/json";
RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions;
String repeatabilityRequestId = UUID.randomUUID().toString();
String repeatabilityRequestId = CoreUtils.randomUuid().toString();
String repeatabilityFirstSent = DateTimeRfc1123.toRfc1123String(OffsetDateTime.now());
requestOptionsLocal.addRequestCallback(requestLocal -> {
if (requestLocal.getHeaders().get(HttpHeaderName.fromString("repeatability-request-id")) == null) {
Expand Down Expand Up @@ -575,7 +575,7 @@ private Response<BinaryData> createLroWithResponse(String name, BinaryData resou
final String contentType = "application/merge-patch+json";
final String accept = "application/json";
RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions;
String repeatabilityRequestId = UUID.randomUUID().toString();
String repeatabilityRequestId = CoreUtils.randomUuid().toString();
String repeatabilityFirstSent = DateTimeRfc1123.toRfc1123String(OffsetDateTime.now());
requestOptionsLocal.addRequestCallback(requestLocal -> {
if (requestLocal.getHeaders().get(HttpHeaderName.fromString("repeatability-request-id")) == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
import com.azure.core.http.rest.Response;
import com.azure.core.http.rest.RestProxy;
import com.azure.core.util.Context;
import com.azure.core.util.CoreUtils;
import com.azure.core.util.DateTimeRfc1123;
import com.azure.core.util.FluxUtil;
import com.azure.core.util.serializer.JacksonAdapter;
import com.azure.core.util.serializer.SerializerAdapter;
import java.time.OffsetDateTime;
import java.util.UUID;
import reactor.core.publisher.Mono;

/**
Expand Down Expand Up @@ -149,7 +149,7 @@ Response<Void> immediateSuccessSync(@HeaderParam("accept") String accept, Reques
public Mono<Response<Void>> immediateSuccessWithResponseAsync(RequestOptions requestOptions) {
final String accept = "application/json";
RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions;
String repeatabilityRequestId = UUID.randomUUID().toString();
String repeatabilityRequestId = CoreUtils.randomUuid().toString();
String repeatabilityFirstSent = DateTimeRfc1123.toRfc1123String(OffsetDateTime.now());
requestOptionsLocal.addRequestCallback(requestLocal -> {
if (requestLocal.getHeaders().get(HttpHeaderName.fromString("repeatability-request-id")) == null) {
Expand Down Expand Up @@ -189,7 +189,7 @@ public Mono<Response<Void>> immediateSuccessWithResponseAsync(RequestOptions req
public Response<Void> immediateSuccessWithResponse(RequestOptions requestOptions) {
final String accept = "application/json";
RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions;
String repeatabilityRequestId = UUID.randomUUID().toString();
String repeatabilityRequestId = CoreUtils.randomUuid().toString();
String repeatabilityFirstSent = DateTimeRfc1123.toRfc1123String(OffsetDateTime.now());
requestOptionsLocal.addRequestCallback(requestLocal -> {
if (requestLocal.getHeaders().get(HttpHeaderName.fromString("repeatability-request-id")) == null) {
Expand Down
Loading

0 comments on commit d4844d6

Please sign in to comment.