Skip to content

Commit

Permalink
CodeGen from PR 24596 in Azure/azure-rest-api-specs
Browse files Browse the repository at this point in the history
Merge 7ec1fe0e9cb54a8e6f59960de7bb18fcbfbc554a into baab681702af69fd815cd7dc9310ed1438bd0ef7
  • Loading branch information
SDKAuto committed Jun 26, 2023
1 parent 0f515aa commit dcbfa9d
Show file tree
Hide file tree
Showing 9 changed files with 97 additions and 270 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
import com.azure.ai.openai.models.CompletionsOptions;
import com.azure.ai.openai.models.Embeddings;
import com.azure.ai.openai.models.EmbeddingsOptions;
import com.azure.ai.openai.models.ImageGenerationOptions;
import com.azure.ai.openai.models.ImageOperationResponse;
import com.azure.ai.openai.models.ImageOperationStatus;
import com.azure.core.annotation.Generated;
import com.azure.core.annotation.ReturnType;
import com.azure.core.annotation.ServiceClient;
Expand All @@ -24,7 +22,6 @@
import com.azure.core.exception.HttpResponseException;
import com.azure.core.exception.ResourceModifiedException;
import com.azure.core.exception.ResourceNotFoundException;
import com.azure.core.experimental.models.PollResult;
import com.azure.core.http.rest.RequestOptions;
import com.azure.core.http.rest.Response;
import com.azure.core.util.BinaryData;
Expand Down Expand Up @@ -482,7 +479,7 @@ public Flux<ChatCompletions> getChatCompletionsStream(
* }
* ]
* }
* status: String(notRunning/running/succeeded/canceled/failed/deleted) (Required)
* status: String(notRunning/running/succeeded/canceled/failed) (Required)
* error (Optional): (recursive schema, see error above)
* }
* }</pre>
Expand Down Expand Up @@ -548,7 +545,7 @@ public Mono<Response<BinaryData>> getImageOperationStatusWithResponse(
*/
@Generated
@ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
public PollerFlux<BinaryData, BinaryData> beginStartGenerateImage(
PollerFlux<BinaryData, BinaryData> beginStartGenerateImage(
BinaryData imageGenerationOptions, RequestOptions requestOptions) {
return this.serviceClient.beginStartGenerateImageAsync(imageGenerationOptions, requestOptions);
}
Expand All @@ -574,26 +571,4 @@ public Mono<ImageOperationResponse> getImageOperationStatus(String operationId)
.flatMap(FluxUtil::toMono)
.map(protocolMethodData -> protocolMethodData.toObject(ImageOperationResponse.class));
}

/**
* Starts the generation of a batch of images from a text caption.
*
* @param imageGenerationOptions Represents the request data used to generate images.
* @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 {@link PollerFlux} for polling of status details for long running operations.
*/
@Generated
@ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
public PollerFlux<PollResult, ImageOperationStatus> beginStartGenerateImage(
ImageGenerationOptions imageGenerationOptions) {
// Generated convenience method for beginStartGenerateImageWithModel
RequestOptions requestOptions = new RequestOptions();
return serviceClient.beginStartGenerateImageWithModelAsync(
BinaryData.fromObject(imageGenerationOptions), requestOptions);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
import com.azure.ai.openai.models.CompletionsOptions;
import com.azure.ai.openai.models.Embeddings;
import com.azure.ai.openai.models.EmbeddingsOptions;
import com.azure.ai.openai.models.ImageGenerationOptions;
import com.azure.ai.openai.models.ImageOperationResponse;
import com.azure.ai.openai.models.ImageOperationStatus;
import com.azure.core.annotation.Generated;
import com.azure.core.annotation.ReturnType;
import com.azure.core.annotation.ServiceClient;
Expand All @@ -24,7 +22,6 @@
import com.azure.core.exception.HttpResponseException;
import com.azure.core.exception.ResourceModifiedException;
import com.azure.core.exception.ResourceNotFoundException;
import com.azure.core.experimental.models.PollResult;
import com.azure.core.http.rest.RequestOptions;
import com.azure.core.http.rest.Response;
import com.azure.core.util.BinaryData;
Expand Down Expand Up @@ -474,7 +471,7 @@ public IterableStream<ChatCompletions> getChatCompletionsStream(
* }
* ]
* }
* status: String(notRunning/running/succeeded/canceled/failed/deleted) (Required)
* status: String(notRunning/running/succeeded/canceled/failed) (Required)
* error (Optional): (recursive schema, see error above)
* }
* }</pre>
Expand Down Expand Up @@ -538,7 +535,7 @@ public Response<BinaryData> getImageOperationStatusWithResponse(String operation
*/
@Generated
@ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
public SyncPoller<BinaryData, BinaryData> beginStartGenerateImage(
SyncPoller<BinaryData, BinaryData> beginStartGenerateImage(
BinaryData imageGenerationOptions, RequestOptions requestOptions) {
return this.serviceClient.beginStartGenerateImage(imageGenerationOptions, requestOptions);
}
Expand All @@ -564,26 +561,4 @@ public ImageOperationResponse getImageOperationStatus(String operationId) {
.getValue()
.toObject(ImageOperationResponse.class);
}

/**
* Starts the generation of a batch of images from a text caption.
*
* @param imageGenerationOptions Represents the request data used to generate images.
* @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 {@link SyncPoller} for polling of status details for long running operations.
*/
@Generated
@ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
public SyncPoller<PollResult, ImageOperationStatus> beginStartGenerateImage(
ImageGenerationOptions imageGenerationOptions) {
// Generated convenience method for beginStartGenerateImageWithModel
RequestOptions requestOptions = new RequestOptions();
return serviceClient.beginStartGenerateImageWithModel(
BinaryData.fromObject(imageGenerationOptions), requestOptions);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
package com.azure.ai.openai.implementation;

import com.azure.ai.openai.OpenAIServiceVersion;
import com.azure.ai.openai.models.ImageOperationStatus;
import com.azure.core.annotation.BodyParam;
import com.azure.core.annotation.ExpectedResponses;
import com.azure.core.annotation.Get;
Expand All @@ -23,7 +22,6 @@
import com.azure.core.exception.HttpResponseException;
import com.azure.core.exception.ResourceModifiedException;
import com.azure.core.exception.ResourceNotFoundException;
import com.azure.core.experimental.models.PollResult;
import com.azure.core.http.HttpPipeline;
import com.azure.core.http.HttpPipelineBuilder;
import com.azure.core.http.policy.CookiePolicy;
Expand Down Expand Up @@ -548,7 +546,7 @@ public Response<BinaryData> getEmbeddingsWithResponse(
* int (Required)
* ]
* }
* finish_reason: String(stopped/tokenLimitReached/contentFiltered) (Required)
* finish_reason: String(stop/length/content_filter) (Required)
* }
* ]
* usage (Required): {
Expand Down Expand Up @@ -645,7 +643,7 @@ public Mono<Response<BinaryData>> getCompletionsWithResponseAsync(
* int (Required)
* ]
* }
* finish_reason: String(stopped/tokenLimitReached/contentFiltered) (Required)
* finish_reason: String(stop/length/content_filter) (Required)
* }
* ]
* usage (Required): {
Expand Down Expand Up @@ -726,7 +724,7 @@ public Response<BinaryData> getCompletionsWithResponse(
* content: String (Optional)
* }
* index: int (Required)
* finish_reason: String(stopped/tokenLimitReached/contentFiltered) (Required)
* finish_reason: String(stop/length/content_filter) (Required)
* delta (Optional): (recursive schema, see delta above)
* }
* ]
Expand Down Expand Up @@ -811,7 +809,7 @@ public Mono<Response<BinaryData>> getChatCompletionsWithResponseAsync(
* content: String (Optional)
* }
* index: int (Required)
* finish_reason: String(stopped/tokenLimitReached/contentFiltered) (Required)
* finish_reason: String(stop/length/content_filter) (Required)
* delta (Optional): (recursive schema, see delta above)
* }
* ]
Expand Down Expand Up @@ -878,7 +876,7 @@ public Response<BinaryData> getChatCompletionsWithResponse(
* }
* ]
* }
* status: String(notRunning/running/succeeded/canceled/failed/deleted) (Required)
* status: String(notRunning/running/succeeded/canceled/failed) (Required)
* error (Optional): (recursive schema, see error above)
* }
* }</pre>
Expand Down Expand Up @@ -937,7 +935,7 @@ public Mono<Response<BinaryData>> getImageOperationStatusWithResponseAsync(
* }
* ]
* }
* status: String(notRunning/running/succeeded/canceled/failed/deleted) (Required)
* status: String(notRunning/running/succeeded/canceled/failed) (Required)
* error (Optional): (recursive schema, see error above)
* }
* }</pre>
Expand Down Expand Up @@ -1196,124 +1194,4 @@ public SyncPoller<BinaryData, BinaryData> beginStartGenerateImage(
TypeReference.createInstance(BinaryData.class),
TypeReference.createInstance(BinaryData.class));
}

/**
* Starts the generation of a batch of images from a text caption.
*
* <p><strong>Request Body Schema</strong>
*
* <pre>{@code
* {
* prompt: String (Required)
* n: Integer (Optional)
* size: String(256x256/512x512/1024x1024) (Optional)
* user: String (Optional)
* }
* }</pre>
*
* <p><strong>Response Body Schema</strong>
*
* <pre>{@code
* {
* id: String (Required)
* status: String (Required)
* error (Optional): {
* code: String (Required)
* message: String (Required)
* target: String (Optional)
* details (Optional): [
* (recursive schema, see above)
* ]
* innererror (Optional): {
* code: String (Optional)
* innererror (Optional): (recursive schema, see innererror above)
* }
* }
* }
* }</pre>
*
* @param imageGenerationOptions Represents the request data used to generate images.
* @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.
* @return the {@link PollerFlux} for polling of status details for long running operations.
*/
@ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
public PollerFlux<PollResult, ImageOperationStatus> beginStartGenerateImageWithModelAsync(
BinaryData imageGenerationOptions, RequestOptions requestOptions) {
return PollerFlux.create(
Duration.ofSeconds(1),
() -> this.startGenerateImageWithResponseAsync(imageGenerationOptions, requestOptions),
new DefaultPollingStrategy<>(
new PollingStrategyOptions(this.getHttpPipeline())
.setEndpoint("{endpoint}/openai".replace("{endpoint}", this.getEndpoint()))
.setContext(
requestOptions != null && requestOptions.getContext() != null
? requestOptions.getContext()
: Context.NONE)),
TypeReference.createInstance(PollResult.class),
TypeReference.createInstance(ImageOperationStatus.class));
}

/**
* Starts the generation of a batch of images from a text caption.
*
* <p><strong>Request Body Schema</strong>
*
* <pre>{@code
* {
* prompt: String (Required)
* n: Integer (Optional)
* size: String(256x256/512x512/1024x1024) (Optional)
* user: String (Optional)
* }
* }</pre>
*
* <p><strong>Response Body Schema</strong>
*
* <pre>{@code
* {
* id: String (Required)
* status: String (Required)
* error (Optional): {
* code: String (Required)
* message: String (Required)
* target: String (Optional)
* details (Optional): [
* (recursive schema, see above)
* ]
* innererror (Optional): {
* code: String (Optional)
* innererror (Optional): (recursive schema, see innererror above)
* }
* }
* }
* }</pre>
*
* @param imageGenerationOptions Represents the request data used to generate images.
* @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.
* @return the {@link SyncPoller} for polling of status details for long running operations.
*/
@ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
public SyncPoller<PollResult, ImageOperationStatus> beginStartGenerateImageWithModel(
BinaryData imageGenerationOptions, RequestOptions requestOptions) {
return SyncPoller.createPoller(
Duration.ofSeconds(1),
() -> this.startGenerateImageWithResponse(imageGenerationOptions, requestOptions),
new SyncDefaultPollingStrategy<>(
new PollingStrategyOptions(this.getHttpPipeline())
.setEndpoint("{endpoint}/openai".replace("{endpoint}", this.getEndpoint()))
.setContext(
requestOptions != null && requestOptions.getContext() != null
? requestOptions.getContext()
: Context.NONE)),
TypeReference.createInstance(PollResult.class),
TypeReference.createInstance(ImageOperationStatus.class));
}
}
Loading

0 comments on commit dcbfa9d

Please sign in to comment.