|
13 | 13 | import com.azure.ai.openai.models.CompletionsOptions;
|
14 | 14 | import com.azure.ai.openai.models.Embeddings;
|
15 | 15 | import com.azure.ai.openai.models.EmbeddingsOptions;
|
| 16 | +import com.azure.ai.openai.models.ImageGenerationOptions; |
| 17 | +import com.azure.ai.openai.models.ImageOperationResponse; |
| 18 | +import com.azure.ai.openai.models.ImageOperationStatus; |
16 | 19 | import com.azure.core.annotation.Generated;
|
17 | 20 | import com.azure.core.annotation.ReturnType;
|
18 | 21 | import com.azure.core.annotation.ServiceClient;
|
|
21 | 24 | import com.azure.core.exception.HttpResponseException;
|
22 | 25 | import com.azure.core.exception.ResourceModifiedException;
|
23 | 26 | import com.azure.core.exception.ResourceNotFoundException;
|
| 27 | +import com.azure.core.experimental.models.PollResult; |
24 | 28 | import com.azure.core.http.rest.RequestOptions;
|
25 | 29 | import com.azure.core.http.rest.Response;
|
26 | 30 | import com.azure.core.util.BinaryData;
|
27 | 31 | import com.azure.core.util.FluxUtil;
|
| 32 | +import com.azure.core.util.polling.PollerFlux; |
28 | 33 | import java.nio.ByteBuffer;
|
29 | 34 | import reactor.core.publisher.Flux;
|
30 | 35 | import reactor.core.publisher.Mono;
|
@@ -446,4 +451,149 @@ public Flux<ChatCompletions> getChatCompletionsStream(
|
446 | 451 | this.serviceClient = null;
|
447 | 452 | openAIServiceClient = serviceClient;
|
448 | 453 | }
|
| 454 | + |
| 455 | + /** |
| 456 | + * Returns the status of the images operation. |
| 457 | + * |
| 458 | + * <p><strong>Response Body Schema</strong> |
| 459 | + * |
| 460 | + * <pre>{@code |
| 461 | + * { |
| 462 | + * id: String (Required) |
| 463 | + * created: long (Required) |
| 464 | + * expires: Long (Optional) |
| 465 | + * result (Optional): { |
| 466 | + * created: long (Required) |
| 467 | + * data (Required): [ |
| 468 | + * (Required){ |
| 469 | + * url: String (Optional) |
| 470 | + * error (Optional): { |
| 471 | + * code: String (Required) |
| 472 | + * message: String (Required) |
| 473 | + * target: String (Optional) |
| 474 | + * details (Optional): [ |
| 475 | + * (recursive schema, see above) |
| 476 | + * ] |
| 477 | + * innererror (Optional): { |
| 478 | + * code: String (Optional) |
| 479 | + * innererror (Optional): (recursive schema, see innererror above) |
| 480 | + * } |
| 481 | + * } |
| 482 | + * } |
| 483 | + * ] |
| 484 | + * } |
| 485 | + * status: String(notRunning/running/succeeded/canceled/failed/deleted) (Required) |
| 486 | + * error (Optional): (recursive schema, see error above) |
| 487 | + * } |
| 488 | + * }</pre> |
| 489 | + * |
| 490 | + * @param operationId . |
| 491 | + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. |
| 492 | + * @throws HttpResponseException thrown if the request is rejected by server. |
| 493 | + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. |
| 494 | + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. |
| 495 | + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. |
| 496 | + * @return the result of the operation if the operation succeeded along with {@link Response} on successful |
| 497 | + * completion of {@link Mono}. |
| 498 | + */ |
| 499 | + @Generated |
| 500 | + @ServiceMethod(returns = ReturnType.SINGLE) |
| 501 | + public Mono<Response<BinaryData>> getImageOperationStatusWithResponse( |
| 502 | + String operationId, RequestOptions requestOptions) { |
| 503 | + return this.serviceClient.getImageOperationStatusWithResponseAsync(operationId, requestOptions); |
| 504 | + } |
| 505 | + |
| 506 | + /** |
| 507 | + * Starts the generation of a batch of images from a text caption. |
| 508 | + * |
| 509 | + * <p><strong>Request Body Schema</strong> |
| 510 | + * |
| 511 | + * <pre>{@code |
| 512 | + * { |
| 513 | + * prompt: String (Required) |
| 514 | + * n: Integer (Optional) |
| 515 | + * size: String(256x256/512x512/1024x1024) (Optional) |
| 516 | + * user: String (Optional) |
| 517 | + * } |
| 518 | + * }</pre> |
| 519 | + * |
| 520 | + * <p><strong>Response Body Schema</strong> |
| 521 | + * |
| 522 | + * <pre>{@code |
| 523 | + * { |
| 524 | + * id: String (Required) |
| 525 | + * status: String (Required) |
| 526 | + * error (Optional): { |
| 527 | + * code: String (Required) |
| 528 | + * message: String (Required) |
| 529 | + * target: String (Optional) |
| 530 | + * details (Optional): [ |
| 531 | + * (recursive schema, see above) |
| 532 | + * ] |
| 533 | + * innererror (Optional): { |
| 534 | + * code: String (Optional) |
| 535 | + * innererror (Optional): (recursive schema, see innererror above) |
| 536 | + * } |
| 537 | + * } |
| 538 | + * } |
| 539 | + * }</pre> |
| 540 | + * |
| 541 | + * @param imageGenerationOptions Represents the request data used to generate images. |
| 542 | + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. |
| 543 | + * @throws HttpResponseException thrown if the request is rejected by server. |
| 544 | + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. |
| 545 | + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. |
| 546 | + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. |
| 547 | + * @return the {@link PollerFlux} for polling of status details for long running operations. |
| 548 | + */ |
| 549 | + @Generated |
| 550 | + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) |
| 551 | + public PollerFlux<BinaryData, BinaryData> beginStartGenerateImage( |
| 552 | + BinaryData imageGenerationOptions, RequestOptions requestOptions) { |
| 553 | + return this.serviceClient.beginStartGenerateImageAsync(imageGenerationOptions, requestOptions); |
| 554 | + } |
| 555 | + |
| 556 | + /** |
| 557 | + * Returns the status of the images operation. |
| 558 | + * |
| 559 | + * @param operationId . |
| 560 | + * @throws IllegalArgumentException thrown if parameters fail the validation. |
| 561 | + * @throws HttpResponseException thrown if the request is rejected by server. |
| 562 | + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. |
| 563 | + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. |
| 564 | + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. |
| 565 | + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. |
| 566 | + * @return the result of the operation if the operation succeeded on successful completion of {@link Mono}. |
| 567 | + */ |
| 568 | + @Generated |
| 569 | + @ServiceMethod(returns = ReturnType.SINGLE) |
| 570 | + public Mono<ImageOperationResponse> getImageOperationStatus(String operationId) { |
| 571 | + // Generated convenience method for getImageOperationStatusWithResponse |
| 572 | + RequestOptions requestOptions = new RequestOptions(); |
| 573 | + return getImageOperationStatusWithResponse(operationId, requestOptions) |
| 574 | + .flatMap(FluxUtil::toMono) |
| 575 | + .map(protocolMethodData -> protocolMethodData.toObject(ImageOperationResponse.class)); |
| 576 | + } |
| 577 | + |
| 578 | + /** |
| 579 | + * Starts the generation of a batch of images from a text caption. |
| 580 | + * |
| 581 | + * @param imageGenerationOptions Represents the request data used to generate images. |
| 582 | + * @throws IllegalArgumentException thrown if parameters fail the validation. |
| 583 | + * @throws HttpResponseException thrown if the request is rejected by server. |
| 584 | + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. |
| 585 | + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. |
| 586 | + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. |
| 587 | + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. |
| 588 | + * @return the {@link PollerFlux} for polling of status details for long running operations. |
| 589 | + */ |
| 590 | + @Generated |
| 591 | + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) |
| 592 | + public PollerFlux<PollResult, ImageOperationStatus> beginStartGenerateImage( |
| 593 | + ImageGenerationOptions imageGenerationOptions) { |
| 594 | + // Generated convenience method for beginStartGenerateImageWithModel |
| 595 | + RequestOptions requestOptions = new RequestOptions(); |
| 596 | + return serviceClient.beginStartGenerateImageWithModelAsync( |
| 597 | + BinaryData.fromObject(imageGenerationOptions), requestOptions); |
| 598 | + } |
449 | 599 | }
|
0 commit comments