diff --git a/eng/versioning/version_client.txt b/eng/versioning/version_client.txt index 71049ef257077..80e6666b9e3ad 100644 --- a/eng/versioning/version_client.txt +++ b/eng/versioning/version_client.txt @@ -187,6 +187,7 @@ com.azure:azure-communication-email;1.0.2;1.1.0-beta.1 com.azure:azure-developer-loadtesting;1.0.2;1.1.0-beta.1 com.azure:azure-identity-extensions;1.1.4;1.2.0-beta.2 com.azure:azure-analytics-purview-sharing;1.0.0-beta.1;1.0.0-beta.2 +com.azure:azure-contoso-widgetmanager;1.0.0-beta.1;1.0.0-beta.1 com.azure.spring:spring-cloud-azure-appconfiguration-config-web;4.8.0;4.9.0-beta.1 com.azure.spring:spring-cloud-azure-appconfiguration-config;4.8.0;4.9.0-beta.1 com.azure.spring:spring-cloud-azure-feature-management-web;4.8.0;4.9.0-beta.1 diff --git a/pom.xml b/pom.xml index b839c84e1c62f..939b444493cdb 100644 --- a/pom.xml +++ b/pom.xml @@ -46,6 +46,7 @@ sdk/connectedvmware sdk/consumption sdk/containerregistry + sdk/contosowidgetmanager sdk/core sdk/cosmos sdk/costmanagement diff --git a/sdk/contosowidgetmanager/azure-contoso-widgetmanager/CHANGELOG.md b/sdk/contosowidgetmanager/azure-contoso-widgetmanager/CHANGELOG.md new file mode 100644 index 0000000000000..6233cbd689319 --- /dev/null +++ b/sdk/contosowidgetmanager/azure-contoso-widgetmanager/CHANGELOG.md @@ -0,0 +1,13 @@ +# Release History + +## 1.0.0-beta.1 (Unreleased) + +- Azure WidgetManager client library for Java. This package contains Microsoft Azure WidgetManager client library. + +### Features Added + +### Breaking Changes + +### Bugs Fixed + +### Other Changes diff --git a/sdk/contosowidgetmanager/azure-contoso-widgetmanager/README.md b/sdk/contosowidgetmanager/azure-contoso-widgetmanager/README.md new file mode 100644 index 0000000000000..ff12d76a2623c --- /dev/null +++ b/sdk/contosowidgetmanager/azure-contoso-widgetmanager/README.md @@ -0,0 +1,63 @@ +# Azure WidgetManager client library for Java + +Azure WidgetManager client library for Java. + +This package contains Microsoft Azure WidgetManager client library. + +## Documentation + +Various documentation is available to help you get started + +- [API reference documentation][docs] +- [Product documentation][product_documentation] + +## Getting started + +### Prerequisites + +- [Java Development Kit (JDK)][jdk] with version 8 or above +- [Azure Subscription][azure_subscription] + +### Adding the package to your product + +[//]: # ({x-version-update-start;com.azure:azure-contoso-widgetmanager;current}) +```xml + + com.azure + azure-contoso-widgetmanager + 1.0.0-beta.1 + +``` +[//]: # ({x-version-update-end}) + +### Authentication + +[Azure Identity][azure_identity] package provides the default implementation for authenticating the client. + +## Key concepts + +## Examples + +```java com.azure.contoso.widgetmanager.readme +``` + +## Troubleshooting + +## Next steps + +## Contributing + +For details on contributing to this repository, see the [contributing guide](https://github.com/Azure/azure-sdk-for-java/blob/main/CONTRIBUTING.md). + +1. Fork it +1. Create your feature branch (`git checkout -b my-new-feature`) +1. Commit your changes (`git commit -am 'Add some feature'`) +1. Push to the branch (`git push origin my-new-feature`) +1. Create new Pull Request + + +[product_documentation]: https://azure.microsoft.com/services/ +[docs]: https://azure.github.io/azure-sdk-for-java/ +[jdk]: https://docs.microsoft.com/java/azure/jdk/ +[azure_subscription]: https://azure.microsoft.com/free/ +[azure_identity]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/identity/azure-identity diff --git a/sdk/contosowidgetmanager/azure-contoso-widgetmanager/pom.xml b/sdk/contosowidgetmanager/azure-contoso-widgetmanager/pom.xml new file mode 100644 index 0000000000000..d037df0cf45a0 --- /dev/null +++ b/sdk/contosowidgetmanager/azure-contoso-widgetmanager/pom.xml @@ -0,0 +1,95 @@ + + + 4.0.0 + + com.azure + azure-client-sdk-parent + 1.7.0 + ../../parents/azure-client-sdk-parent + + + com.azure + azure-contoso-widgetmanager + 1.0.0-beta.1 + jar + + Microsoft Azure SDK for WidgetManager + This package contains Microsoft Azure WidgetManager client library. + https://github.com/Azure/azure-sdk-for-java + + + + The MIT License (MIT) + http://opensource.org/licenses/MIT + repo + + + + + https://github.com/Azure/azure-sdk-for-java + scm:git:git@github.com:Azure/azure-sdk-for-java.git + scm:git:git@github.com:Azure/azure-sdk-for-java.git + HEAD + + + + microsoft + Microsoft + + + + UTF-8 + + + + com.azure + azure-core + 1.39.0 + + + com.azure + azure-core-http-netty + 1.13.3 + + + org.junit.jupiter + junit-jupiter-api + 5.9.1 + test + + + org.junit.jupiter + junit-jupiter-engine + 5.9.1 + test + + + org.mockito + mockito-core + 4.11.0 + test + + + com.azure + azure-core-test + 1.17.0 + test + + + com.azure + azure-identity + 1.9.0 + test + + + org.slf4j + slf4j-simple + 1.7.36 + test + + + diff --git a/sdk/contosowidgetmanager/azure-contoso-widgetmanager/src/main/java/com/azure/contoso/widgetmanager/WidgetManagerAsyncClient.java b/sdk/contosowidgetmanager/azure-contoso-widgetmanager/src/main/java/com/azure/contoso/widgetmanager/WidgetManagerAsyncClient.java new file mode 100644 index 0000000000000..9fe723a5086d1 --- /dev/null +++ b/sdk/contosowidgetmanager/azure-contoso-widgetmanager/src/main/java/com/azure/contoso/widgetmanager/WidgetManagerAsyncClient.java @@ -0,0 +1,339 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.contoso.widgetmanager; + +import com.azure.contoso.widgetmanager.implementation.WidgetManagerClientImpl; +import com.azure.contoso.widgetmanager.models.ResourceOperationStatusWidgetWidgetError; +import com.azure.contoso.widgetmanager.models.Widget; +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceClient; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; +import com.azure.core.util.FluxUtil; +import com.azure.core.util.polling.PollerFlux; +import java.util.stream.Collectors; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +/** Initializes a new instance of the asynchronous WidgetManagerClient type. */ +@ServiceClient(builder = WidgetManagerClientBuilder.class, isAsync = true) +public final class WidgetManagerAsyncClient { + @Generated private final WidgetManagerClientImpl serviceClient; + + /** + * Initializes an instance of WidgetManagerAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + WidgetManagerAsyncClient(WidgetManagerClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Fetch a Widget by name. + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     name: String (Required)
+     *     manufacturerId: String (Required)
+     *     sharedModel (Optional): {
+     *         tag: String (Required)
+     *         createdAt: OffsetDateTime (Required)
+     *     }
+     * }
+     * }
+ * + * @param widgetName The widget name. + * @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 a widget along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWidgetWithResponse(String widgetName, RequestOptions requestOptions) { + return this.serviceClient.getWidgetWithResponseAsync(widgetName, requestOptions); + } + + /** + * Gets status of a Widget operation. + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     id: String (Required)
+     *     status: String(InProgress/Succeeded/Failed/Canceled) (Required)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Required): [
+     *             (recursive schema, see above)
+     *         ]
+     *         innererror (Optional): {
+     *             code: String (Required)
+     *             innererror (Optional): (recursive schema, see innererror above)
+     *         }
+     *     }
+     *     result (Optional): {
+     *         name: String (Required)
+     *         manufacturerId: String (Required)
+     *         sharedModel (Optional): {
+     *             tag: String (Required)
+     *             createdAt: OffsetDateTime (Required)
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param widgetName The widget name. + * @param operationId The unique ID of the operation. + * @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 status of a Widget operation along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWidgetOperationStatusWithResponse( + String widgetName, String operationId, RequestOptions requestOptions) { + return this.serviceClient.getWidgetOperationStatusWithResponseAsync(widgetName, operationId, requestOptions); + } + + /** + * Creates or updates a Widget asynchronously. + * + *

Request Body Schema + * + *

{@code
+     * {
+     *     name: String (Required)
+     *     manufacturerId: String (Required)
+     *     sharedModel (Optional): {
+     *         tag: String (Required)
+     *         createdAt: OffsetDateTime (Required)
+     *     }
+     * }
+     * }
+ * + *

Response Body Schema + * + *

{@code
+     * {
+     *     name: String (Required)
+     *     manufacturerId: String (Required)
+     *     sharedModel (Optional): {
+     *         tag: String (Required)
+     *         createdAt: OffsetDateTime (Required)
+     *     }
+     * }
+     * }
+ * + * @param widgetName The widget name. + * @param resource The resource instance. + * @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 a widget. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginCreateOrUpdateWidget( + String widgetName, BinaryData resource, RequestOptions requestOptions) { + return this.serviceClient.beginCreateOrUpdateWidgetAsync(widgetName, resource, requestOptions); + } + + /** + * Delete a Widget asynchronously. + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     id: String (Required)
+     *     status: String(InProgress/Succeeded/Failed/Canceled) (Required)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Required): [
+     *             (recursive schema, see above)
+     *         ]
+     *         innererror (Optional): {
+     *             code: String (Required)
+     *             innererror (Optional): (recursive schema, see innererror above)
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param widgetName The widget name. + * @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 provides status details for long running operations. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginDeleteWidget(String widgetName, RequestOptions requestOptions) { + return this.serviceClient.beginDeleteWidgetAsync(widgetName, requestOptions); + } + + /** + * List Widget resources. + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     name: String (Required)
+     *     manufacturerId: String (Required)
+     *     sharedModel (Optional): {
+     *         tag: String (Required)
+     *         createdAt: OffsetDateTime (Required)
+     *     }
+     * }
+     * }
+ * + * @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 paged collection of Widget items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listWidgets(RequestOptions requestOptions) { + return this.serviceClient.listWidgetsAsync(requestOptions); + } + + /** + * Fetch a Widget by name. + * + * @param widgetName The widget name. + * @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 a widget on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getWidget(String widgetName) { + // Generated convenience method for getWidgetWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWidgetWithResponse(widgetName, requestOptions) + .flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Widget.class)); + } + + /** + * Gets status of a Widget operation. + * + * @param widgetName The widget name. + * @param operationId The unique ID of the 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. + * @return status of a Widget operation on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getWidgetOperationStatus( + String widgetName, String operationId) { + // Generated convenience method for getWidgetOperationStatusWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWidgetOperationStatusWithResponse(widgetName, operationId, requestOptions) + .flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(ResourceOperationStatusWidgetWidgetError.class)); + } + + /** + * Delete a Widget asynchronously. + * + * @param widgetName The widget name. + * @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 provides status details for long running operations. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginDeleteWidget(String widgetName) { + // Generated convenience method for beginDeleteWidgetWithModel + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.beginDeleteWidgetWithModelAsync(widgetName, requestOptions); + } + + /** + * List Widget resources. + * + * @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 paged collection of Widget items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listWidgets() { + // Generated convenience method for listWidgets + RequestOptions requestOptions = new RequestOptions(); + PagedFlux pagedFluxResponse = listWidgets(requestOptions); + return PagedFlux.create( + () -> + (continuationToken, pageSize) -> { + Flux> flux = + (continuationToken == null) + ? pagedFluxResponse.byPage().take(1) + : pagedFluxResponse.byPage(continuationToken).take(1); + return flux.map( + pagedResponse -> + new PagedResponseBase( + pagedResponse.getRequest(), + pagedResponse.getStatusCode(), + pagedResponse.getHeaders(), + pagedResponse.getValue().stream() + .map( + protocolMethodData -> + protocolMethodData.toObject(Widget.class)) + .collect(Collectors.toList()), + pagedResponse.getContinuationToken(), + null)); + }); + } +} diff --git a/sdk/contosowidgetmanager/azure-contoso-widgetmanager/src/main/java/com/azure/contoso/widgetmanager/WidgetManagerClient.java b/sdk/contosowidgetmanager/azure-contoso-widgetmanager/src/main/java/com/azure/contoso/widgetmanager/WidgetManagerClient.java new file mode 100644 index 0000000000000..41cf901db854f --- /dev/null +++ b/sdk/contosowidgetmanager/azure-contoso-widgetmanager/src/main/java/com/azure/contoso/widgetmanager/WidgetManagerClient.java @@ -0,0 +1,306 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.contoso.widgetmanager; + +import com.azure.contoso.widgetmanager.models.ResourceOperationStatusWidgetWidgetError; +import com.azure.contoso.widgetmanager.models.Widget; +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceClient; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; +import com.azure.core.util.polling.SyncPoller; + +/** Initializes a new instance of the synchronous WidgetManagerClient type. */ +@ServiceClient(builder = WidgetManagerClientBuilder.class) +public final class WidgetManagerClient { + @Generated private final WidgetManagerAsyncClient client; + + /** + * Initializes an instance of WidgetManagerClient class. + * + * @param client the async client. + */ + @Generated + WidgetManagerClient(WidgetManagerAsyncClient client) { + this.client = client; + } + + /** + * Fetch a Widget by name. + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     name: String (Required)
+     *     manufacturerId: String (Required)
+     *     sharedModel (Optional): {
+     *         tag: String (Required)
+     *         createdAt: OffsetDateTime (Required)
+     *     }
+     * }
+     * }
+ * + * @param widgetName The widget name. + * @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 a widget along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWidgetWithResponse(String widgetName, RequestOptions requestOptions) { + return this.client.getWidgetWithResponse(widgetName, requestOptions).block(); + } + + /** + * Gets status of a Widget operation. + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     id: String (Required)
+     *     status: String(InProgress/Succeeded/Failed/Canceled) (Required)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Required): [
+     *             (recursive schema, see above)
+     *         ]
+     *         innererror (Optional): {
+     *             code: String (Required)
+     *             innererror (Optional): (recursive schema, see innererror above)
+     *         }
+     *     }
+     *     result (Optional): {
+     *         name: String (Required)
+     *         manufacturerId: String (Required)
+     *         sharedModel (Optional): {
+     *             tag: String (Required)
+     *             createdAt: OffsetDateTime (Required)
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param widgetName The widget name. + * @param operationId The unique ID of the operation. + * @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 status of a Widget operation along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWidgetOperationStatusWithResponse( + String widgetName, String operationId, RequestOptions requestOptions) { + return this.client.getWidgetOperationStatusWithResponse(widgetName, operationId, requestOptions).block(); + } + + /** + * Creates or updates a Widget asynchronously. + * + *

Request Body Schema + * + *

{@code
+     * {
+     *     name: String (Required)
+     *     manufacturerId: String (Required)
+     *     sharedModel (Optional): {
+     *         tag: String (Required)
+     *         createdAt: OffsetDateTime (Required)
+     *     }
+     * }
+     * }
+ * + *

Response Body Schema + * + *

{@code
+     * {
+     *     name: String (Required)
+     *     manufacturerId: String (Required)
+     *     sharedModel (Optional): {
+     *         tag: String (Required)
+     *         createdAt: OffsetDateTime (Required)
+     *     }
+     * }
+     * }
+ * + * @param widgetName The widget name. + * @param resource The resource instance. + * @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 a widget. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginCreateOrUpdateWidget( + String widgetName, BinaryData resource, RequestOptions requestOptions) { + return this.client.beginCreateOrUpdateWidget(widgetName, resource, requestOptions).getSyncPoller(); + } + + /** + * Delete a Widget asynchronously. + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     id: String (Required)
+     *     status: String(InProgress/Succeeded/Failed/Canceled) (Required)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Required): [
+     *             (recursive schema, see above)
+     *         ]
+     *         innererror (Optional): {
+     *             code: String (Required)
+     *             innererror (Optional): (recursive schema, see innererror above)
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param widgetName The widget name. + * @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 provides status details for long running operations. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginDeleteWidget(String widgetName, RequestOptions requestOptions) { + return this.client.beginDeleteWidget(widgetName, requestOptions).getSyncPoller(); + } + + /** + * List Widget resources. + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     name: String (Required)
+     *     manufacturerId: String (Required)
+     *     sharedModel (Optional): {
+     *         tag: String (Required)
+     *         createdAt: OffsetDateTime (Required)
+     *     }
+     * }
+     * }
+ * + * @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 paged collection of Widget items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listWidgets(RequestOptions requestOptions) { + return new PagedIterable<>(this.client.listWidgets(requestOptions)); + } + + /** + * Fetch a Widget by name. + * + * @param widgetName The widget name. + * @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 a widget. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Widget getWidget(String widgetName) { + // Generated convenience method for getWidgetWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWidgetWithResponse(widgetName, requestOptions).getValue().toObject(Widget.class); + } + + /** + * Gets status of a Widget operation. + * + * @param widgetName The widget name. + * @param operationId The unique ID of the 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. + * @return status of a Widget operation. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public ResourceOperationStatusWidgetWidgetError getWidgetOperationStatus(String widgetName, String operationId) { + // Generated convenience method for getWidgetOperationStatusWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWidgetOperationStatusWithResponse(widgetName, operationId, requestOptions) + .getValue() + .toObject(ResourceOperationStatusWidgetWidgetError.class); + } + + /** + * Delete a Widget asynchronously. + * + * @param widgetName The widget name. + * @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 provides status details for long running operations. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginDeleteWidget(String widgetName) { + // Generated convenience method for beginDeleteWidgetWithModel + return client.beginDeleteWidget(widgetName).getSyncPoller(); + } + + /** + * List Widget resources. + * + * @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 paged collection of Widget items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listWidgets() { + // Generated convenience method for listWidgets + return new PagedIterable<>(client.listWidgets()); + } +} diff --git a/sdk/contosowidgetmanager/azure-contoso-widgetmanager/src/main/java/com/azure/contoso/widgetmanager/WidgetManagerClientBuilder.java b/sdk/contosowidgetmanager/azure-contoso-widgetmanager/src/main/java/com/azure/contoso/widgetmanager/WidgetManagerClientBuilder.java new file mode 100644 index 0000000000000..56cf9f37141a3 --- /dev/null +++ b/sdk/contosowidgetmanager/azure-contoso-widgetmanager/src/main/java/com/azure/contoso/widgetmanager/WidgetManagerClientBuilder.java @@ -0,0 +1,276 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.contoso.widgetmanager; + +import com.azure.contoso.widgetmanager.implementation.WidgetManagerClientImpl; +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.ServiceClientBuilder; +import com.azure.core.client.traits.ConfigurationTrait; +import com.azure.core.client.traits.EndpointTrait; +import com.azure.core.client.traits.HttpTrait; +import com.azure.core.http.HttpClient; +import com.azure.core.http.HttpHeaders; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpPipelineBuilder; +import com.azure.core.http.HttpPipelinePosition; +import com.azure.core.http.policy.AddDatePolicy; +import com.azure.core.http.policy.AddHeadersFromContextPolicy; +import com.azure.core.http.policy.AddHeadersPolicy; +import com.azure.core.http.policy.CookiePolicy; +import com.azure.core.http.policy.HttpLogOptions; +import com.azure.core.http.policy.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpPipelinePolicy; +import com.azure.core.http.policy.HttpPolicyProviders; +import com.azure.core.http.policy.RequestIdPolicy; +import com.azure.core.http.policy.RetryOptions; +import com.azure.core.http.policy.RetryPolicy; +import com.azure.core.http.policy.UserAgentPolicy; +import com.azure.core.util.ClientOptions; +import com.azure.core.util.Configuration; +import com.azure.core.util.CoreUtils; +import com.azure.core.util.builder.ClientBuilderUtil; +import com.azure.core.util.logging.ClientLogger; +import com.azure.core.util.serializer.JacksonAdapter; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** A builder for creating a new instance of the WidgetManagerClient type. */ +@ServiceClientBuilder(serviceClients = {WidgetManagerClient.class, WidgetManagerAsyncClient.class}) +public final class WidgetManagerClientBuilder + implements HttpTrait, + ConfigurationTrait, + EndpointTrait { + @Generated private static final String SDK_NAME = "name"; + + @Generated private static final String SDK_VERSION = "version"; + + @Generated + private static final Map PROPERTIES = + CoreUtils.getProperties("azure-contoso-widgetmanager.properties"); + + @Generated private final List pipelinePolicies; + + /** Create an instance of the WidgetManagerClientBuilder. */ + @Generated + public WidgetManagerClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated private HttpPipeline pipeline; + + /** {@inheritDoc}. */ + @Generated + @Override + public WidgetManagerClientBuilder pipeline(HttpPipeline pipeline) { + if (this.pipeline != null && pipeline == null) { + LOGGER.info("HttpPipeline is being set to 'null' when it was previously configured."); + } + this.pipeline = pipeline; + return this; + } + + /* + * The HTTP client used to send the request. + */ + @Generated private HttpClient httpClient; + + /** {@inheritDoc}. */ + @Generated + @Override + public WidgetManagerClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated private HttpLogOptions httpLogOptions; + + /** {@inheritDoc}. */ + @Generated + @Override + public WidgetManagerClientBuilder httpLogOptions(HttpLogOptions httpLogOptions) { + this.httpLogOptions = httpLogOptions; + return this; + } + + /* + * The client options such as application ID and custom headers to set on a request. + */ + @Generated private ClientOptions clientOptions; + + /** {@inheritDoc}. */ + @Generated + @Override + public WidgetManagerClientBuilder clientOptions(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + return this; + } + + /* + * The retry options to configure retry policy for failed requests. + */ + @Generated private RetryOptions retryOptions; + + /** {@inheritDoc}. */ + @Generated + @Override + public WidgetManagerClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** {@inheritDoc}. */ + @Generated + @Override + public WidgetManagerClientBuilder addPolicy(HttpPipelinePolicy customPolicy) { + Objects.requireNonNull(customPolicy, "'customPolicy' cannot be null."); + pipelinePolicies.add(customPolicy); + return this; + } + + /* + * The configuration store that is used during construction of the service client. + */ + @Generated private Configuration configuration; + + /** {@inheritDoc}. */ + @Generated + @Override + public WidgetManagerClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated private String endpoint; + + /** {@inheritDoc}. */ + @Generated + @Override + public WidgetManagerClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * Service version + */ + @Generated private WidgetManagerServiceVersion serviceVersion; + + /** + * Sets Service version. + * + * @param serviceVersion the serviceVersion value. + * @return the WidgetManagerClientBuilder. + */ + @Generated + public WidgetManagerClientBuilder serviceVersion(WidgetManagerServiceVersion serviceVersion) { + this.serviceVersion = serviceVersion; + return this; + } + + /* + * The retry policy that will attempt to retry failed requests, if applicable. + */ + @Generated private RetryPolicy retryPolicy; + + /** + * Sets The retry policy that will attempt to retry failed requests, if applicable. + * + * @param retryPolicy the retryPolicy value. + * @return the WidgetManagerClientBuilder. + */ + @Generated + public WidgetManagerClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of WidgetManagerClientImpl with the provided parameters. + * + * @return an instance of WidgetManagerClientImpl. + */ + @Generated + private WidgetManagerClientImpl buildInnerClient() { + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + WidgetManagerServiceVersion localServiceVersion = + (serviceVersion != null) ? serviceVersion : WidgetManagerServiceVersion.getLatest(); + WidgetManagerClientImpl client = + new WidgetManagerClientImpl( + localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, localServiceVersion); + return client; + } + + @Generated + private HttpPipeline createHttpPipeline() { + Configuration buildConfiguration = + (configuration == null) ? Configuration.getGlobalConfiguration() : configuration; + HttpLogOptions localHttpLogOptions = this.httpLogOptions == null ? new HttpLogOptions() : this.httpLogOptions; + ClientOptions localClientOptions = this.clientOptions == null ? new ClientOptions() : this.clientOptions; + List policies = new ArrayList<>(); + String clientName = PROPERTIES.getOrDefault(SDK_NAME, "UnknownName"); + String clientVersion = PROPERTIES.getOrDefault(SDK_VERSION, "UnknownVersion"); + String applicationId = CoreUtils.getApplicationId(localClientOptions, localHttpLogOptions); + policies.add(new UserAgentPolicy(applicationId, clientName, clientVersion, buildConfiguration)); + policies.add(new RequestIdPolicy()); + policies.add(new AddHeadersFromContextPolicy()); + HttpHeaders headers = new HttpHeaders(); + localClientOptions.getHeaders().forEach(header -> headers.set(header.getName(), header.getValue())); + if (headers.getSize() > 0) { + policies.add(new AddHeadersPolicy(headers)); + } + this.pipelinePolicies.stream() + .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_CALL) + .forEach(p -> policies.add(p)); + HttpPolicyProviders.addBeforeRetryPolicies(policies); + policies.add(ClientBuilderUtil.validateAndGetRetryPolicy(retryPolicy, retryOptions, new RetryPolicy())); + policies.add(new AddDatePolicy()); + policies.add(new CookiePolicy()); + this.pipelinePolicies.stream() + .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_RETRY) + .forEach(p -> policies.add(p)); + HttpPolicyProviders.addAfterRetryPolicies(policies); + policies.add(new HttpLoggingPolicy(httpLogOptions)); + HttpPipeline httpPipeline = + new HttpPipelineBuilder() + .policies(policies.toArray(new HttpPipelinePolicy[0])) + .httpClient(httpClient) + .clientOptions(localClientOptions) + .build(); + return httpPipeline; + } + + /** + * Builds an instance of WidgetManagerAsyncClient class. + * + * @return an instance of WidgetManagerAsyncClient. + */ + @Generated + public WidgetManagerAsyncClient buildAsyncClient() { + return new WidgetManagerAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of WidgetManagerClient class. + * + * @return an instance of WidgetManagerClient. + */ + @Generated + public WidgetManagerClient buildClient() { + return new WidgetManagerClient(new WidgetManagerAsyncClient(buildInnerClient())); + } + + private static final ClientLogger LOGGER = new ClientLogger(WidgetManagerClientBuilder.class); +} diff --git a/sdk/contosowidgetmanager/azure-contoso-widgetmanager/src/main/java/com/azure/contoso/widgetmanager/WidgetManagerServiceVersion.java b/sdk/contosowidgetmanager/azure-contoso-widgetmanager/src/main/java/com/azure/contoso/widgetmanager/WidgetManagerServiceVersion.java new file mode 100644 index 0000000000000..a1d02c76df588 --- /dev/null +++ b/sdk/contosowidgetmanager/azure-contoso-widgetmanager/src/main/java/com/azure/contoso/widgetmanager/WidgetManagerServiceVersion.java @@ -0,0 +1,34 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.contoso.widgetmanager; + +import com.azure.core.util.ServiceVersion; + +/** Service version of WidgetManagerClient. */ +public enum WidgetManagerServiceVersion implements ServiceVersion { + /** Enum value 2022-11-01-preview. */ + V2022_11_01_PREVIEW("2022-11-01-preview"); + + private final String version; + + WidgetManagerServiceVersion(String version) { + this.version = version; + } + + /** {@inheritDoc} */ + @Override + public String getVersion() { + return this.version; + } + + /** + * Gets the latest service version supported by this client library. + * + * @return The latest {@link WidgetManagerServiceVersion}. + */ + public static WidgetManagerServiceVersion getLatest() { + return V2022_11_01_PREVIEW; + } +} diff --git a/sdk/contosowidgetmanager/azure-contoso-widgetmanager/src/main/java/com/azure/contoso/widgetmanager/implementation/WidgetManagerClientImpl.java b/sdk/contosowidgetmanager/azure-contoso-widgetmanager/src/main/java/com/azure/contoso/widgetmanager/implementation/WidgetManagerClientImpl.java new file mode 100644 index 0000000000000..a8ec4827f336c --- /dev/null +++ b/sdk/contosowidgetmanager/azure-contoso-widgetmanager/src/main/java/com/azure/contoso/widgetmanager/implementation/WidgetManagerClientImpl.java @@ -0,0 +1,1002 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.contoso.widgetmanager.implementation; + +import com.azure.contoso.widgetmanager.WidgetManagerServiceVersion; +import com.azure.contoso.widgetmanager.models.ResourceOperationStatusWidgetWidgetError; +import com.azure.core.annotation.BodyParam; +import com.azure.core.annotation.Delete; +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Patch; +import com.azure.core.annotation.PathParam; +import com.azure.core.annotation.QueryParam; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpPipelineBuilder; +import com.azure.core.http.policy.CookiePolicy; +import com.azure.core.http.policy.RetryPolicy; +import com.azure.core.http.policy.UserAgentPolicy; +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.util.BinaryData; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import com.azure.core.util.polling.DefaultPollingStrategy; +import com.azure.core.util.polling.PollerFlux; +import com.azure.core.util.polling.PollingStrategyOptions; +import com.azure.core.util.polling.SyncPoller; +import com.azure.core.util.serializer.JacksonAdapter; +import com.azure.core.util.serializer.SerializerAdapter; +import com.azure.core.util.serializer.TypeReference; +import java.time.Duration; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import reactor.core.publisher.Mono; + +/** Initializes a new instance of the WidgetManagerClient type. */ +public final class WidgetManagerClientImpl { + /** The proxy service used to perform REST calls. */ + private final WidgetManagerClientService service; + + /** Server parameter. */ + private final String endpoint; + + /** + * Gets Server parameter. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** Service version. */ + private final WidgetManagerServiceVersion serviceVersion; + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public WidgetManagerServiceVersion getServiceVersion() { + return this.serviceVersion; + } + + /** The HTTP pipeline to send requests through. */ + private final HttpPipeline httpPipeline; + + /** + * Gets The HTTP pipeline to send requests through. + * + * @return the httpPipeline value. + */ + public HttpPipeline getHttpPipeline() { + return this.httpPipeline; + } + + /** The serializer to serialize an object into a string. */ + private final SerializerAdapter serializerAdapter; + + /** + * Gets The serializer to serialize an object into a string. + * + * @return the serializerAdapter value. + */ + public SerializerAdapter getSerializerAdapter() { + return this.serializerAdapter; + } + + /** + * Initializes an instance of WidgetManagerClient client. + * + * @param endpoint Server parameter. + * @param serviceVersion Service version. + */ + public WidgetManagerClientImpl(String endpoint, WidgetManagerServiceVersion serviceVersion) { + this( + new HttpPipelineBuilder() + .policies(new UserAgentPolicy(), new RetryPolicy(), new CookiePolicy()) + .build(), + JacksonAdapter.createDefaultSerializerAdapter(), + endpoint, + serviceVersion); + } + + /** + * Initializes an instance of WidgetManagerClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Server parameter. + * @param serviceVersion Service version. + */ + public WidgetManagerClientImpl( + HttpPipeline httpPipeline, String endpoint, WidgetManagerServiceVersion serviceVersion) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); + } + + /** + * Initializes an instance of WidgetManagerClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param serializerAdapter The serializer to serialize an object into a string. + * @param endpoint Server parameter. + * @param serviceVersion Service version. + */ + public WidgetManagerClientImpl( + HttpPipeline httpPipeline, + SerializerAdapter serializerAdapter, + String endpoint, + WidgetManagerServiceVersion serviceVersion) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.serviceVersion = serviceVersion; + this.service = + RestProxy.create(WidgetManagerClientService.class, this.httpPipeline, this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for WidgetManagerClient to be used by the proxy service to perform REST + * calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "WidgetManagerClient") + public interface WidgetManagerClientService { + @Get("/widgets/{widgetName}") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType( + value = ClientAuthenticationException.class, + code = {401}) + @UnexpectedResponseExceptionType( + value = ResourceNotFoundException.class, + code = {404}) + @UnexpectedResponseExceptionType( + value = ResourceModifiedException.class, + code = {409}) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getWidget( + @HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, + @PathParam("widgetName") String widgetName, + @HeaderParam("accept") String accept, + RequestOptions requestOptions, + Context context); + + @Get("/widgets/{widgetName}/operations/{operationId}") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType( + value = ClientAuthenticationException.class, + code = {401}) + @UnexpectedResponseExceptionType( + value = ResourceNotFoundException.class, + code = {404}) + @UnexpectedResponseExceptionType( + value = ResourceModifiedException.class, + code = {409}) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getWidgetOperationStatus( + @HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, + @PathParam("widgetName") String widgetName, + @PathParam("operationId") String operationId, + @HeaderParam("accept") String accept, + RequestOptions requestOptions, + Context context); + + @Patch("/widgets/{widgetName}") + @ExpectedResponses({200, 201}) + @UnexpectedResponseExceptionType( + value = ClientAuthenticationException.class, + code = {401}) + @UnexpectedResponseExceptionType( + value = ResourceNotFoundException.class, + code = {404}) + @UnexpectedResponseExceptionType( + value = ResourceModifiedException.class, + code = {409}) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> createOrUpdateWidget( + @HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, + @PathParam("widgetName") String widgetName, + @HeaderParam("Content-Type") String contentType, + @HeaderParam("accept") String accept, + @BodyParam("application/merge-patch+json") BinaryData resource, + RequestOptions requestOptions, + Context context); + + @Delete("/widgets/{widgetName}") + @ExpectedResponses({202}) + @UnexpectedResponseExceptionType( + value = ClientAuthenticationException.class, + code = {401}) + @UnexpectedResponseExceptionType( + value = ResourceNotFoundException.class, + code = {404}) + @UnexpectedResponseExceptionType( + value = ResourceModifiedException.class, + code = {409}) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> deleteWidget( + @HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, + @PathParam("widgetName") String widgetName, + @HeaderParam("accept") String accept, + RequestOptions requestOptions, + Context context); + + @Get("/widgets") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType( + value = ClientAuthenticationException.class, + code = {401}) + @UnexpectedResponseExceptionType( + value = ResourceNotFoundException.class, + code = {404}) + @UnexpectedResponseExceptionType( + value = ResourceModifiedException.class, + code = {409}) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> listWidgets( + @HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, + @HeaderParam("accept") String accept, + RequestOptions requestOptions, + Context context); + + @Get("{nextLink}") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType( + value = ClientAuthenticationException.class, + code = {401}) + @UnexpectedResponseExceptionType( + value = ResourceNotFoundException.class, + code = {404}) + @UnexpectedResponseExceptionType( + value = ResourceModifiedException.class, + code = {409}) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> listWidgetsNext( + @PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("endpoint") String endpoint, + @HeaderParam("accept") String accept, + RequestOptions requestOptions, + Context context); + } + + /** + * Fetch a Widget by name. + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     name: String (Required)
+     *     manufacturerId: String (Required)
+     *     sharedModel (Optional): {
+     *         tag: String (Required)
+     *         createdAt: OffsetDateTime (Required)
+     *     }
+     * }
+     * }
+ * + * @param widgetName The widget name. + * @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 a widget along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWidgetWithResponseAsync(String widgetName, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext( + context -> + service.getWidget( + this.getEndpoint(), + this.getServiceVersion().getVersion(), + widgetName, + accept, + requestOptions, + context)); + } + + /** + * Fetch a Widget by name. + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     name: String (Required)
+     *     manufacturerId: String (Required)
+     *     sharedModel (Optional): {
+     *         tag: String (Required)
+     *         createdAt: OffsetDateTime (Required)
+     *     }
+     * }
+     * }
+ * + * @param widgetName The widget name. + * @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 a widget along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWidgetWithResponse(String widgetName, RequestOptions requestOptions) { + return getWidgetWithResponseAsync(widgetName, requestOptions).block(); + } + + /** + * Gets status of a Widget operation. + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     id: String (Required)
+     *     status: String(InProgress/Succeeded/Failed/Canceled) (Required)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Required): [
+     *             (recursive schema, see above)
+     *         ]
+     *         innererror (Optional): {
+     *             code: String (Required)
+     *             innererror (Optional): (recursive schema, see innererror above)
+     *         }
+     *     }
+     *     result (Optional): {
+     *         name: String (Required)
+     *         manufacturerId: String (Required)
+     *         sharedModel (Optional): {
+     *             tag: String (Required)
+     *             createdAt: OffsetDateTime (Required)
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param widgetName The widget name. + * @param operationId The unique ID of the operation. + * @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 status of a Widget operation along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWidgetOperationStatusWithResponseAsync( + String widgetName, String operationId, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext( + context -> + service.getWidgetOperationStatus( + this.getEndpoint(), + this.getServiceVersion().getVersion(), + widgetName, + operationId, + accept, + requestOptions, + context)); + } + + /** + * Gets status of a Widget operation. + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     id: String (Required)
+     *     status: String(InProgress/Succeeded/Failed/Canceled) (Required)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Required): [
+     *             (recursive schema, see above)
+     *         ]
+     *         innererror (Optional): {
+     *             code: String (Required)
+     *             innererror (Optional): (recursive schema, see innererror above)
+     *         }
+     *     }
+     *     result (Optional): {
+     *         name: String (Required)
+     *         manufacturerId: String (Required)
+     *         sharedModel (Optional): {
+     *             tag: String (Required)
+     *             createdAt: OffsetDateTime (Required)
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param widgetName The widget name. + * @param operationId The unique ID of the operation. + * @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 status of a Widget operation along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWidgetOperationStatusWithResponse( + String widgetName, String operationId, RequestOptions requestOptions) { + return getWidgetOperationStatusWithResponseAsync(widgetName, operationId, requestOptions).block(); + } + + /** + * Creates or updates a Widget asynchronously. + * + *

Request Body Schema + * + *

{@code
+     * {
+     *     name: String (Required)
+     *     manufacturerId: String (Required)
+     *     sharedModel (Optional): {
+     *         tag: String (Required)
+     *         createdAt: OffsetDateTime (Required)
+     *     }
+     * }
+     * }
+ * + *

Response Body Schema + * + *

{@code
+     * {
+     *     name: String (Required)
+     *     manufacturerId: String (Required)
+     *     sharedModel (Optional): {
+     *         tag: String (Required)
+     *         createdAt: OffsetDateTime (Required)
+     *     }
+     * }
+     * }
+ * + * @param widgetName The widget name. + * @param resource The resource instance. + * @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 a widget along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> createOrUpdateWidgetWithResponseAsync( + String widgetName, BinaryData resource, RequestOptions requestOptions) { + final String contentType = "application/merge-patch+json"; + final String accept = "application/json"; + return FluxUtil.withContext( + context -> + service.createOrUpdateWidget( + this.getEndpoint(), + this.getServiceVersion().getVersion(), + widgetName, + contentType, + accept, + resource, + requestOptions, + context)); + } + + /** + * Creates or updates a Widget asynchronously. + * + *

Request Body Schema + * + *

{@code
+     * {
+     *     name: String (Required)
+     *     manufacturerId: String (Required)
+     *     sharedModel (Optional): {
+     *         tag: String (Required)
+     *         createdAt: OffsetDateTime (Required)
+     *     }
+     * }
+     * }
+ * + *

Response Body Schema + * + *

{@code
+     * {
+     *     name: String (Required)
+     *     manufacturerId: String (Required)
+     *     sharedModel (Optional): {
+     *         tag: String (Required)
+     *         createdAt: OffsetDateTime (Required)
+     *     }
+     * }
+     * }
+ * + * @param widgetName The widget name. + * @param resource The resource instance. + * @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 a widget. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginCreateOrUpdateWidgetAsync( + String widgetName, BinaryData resource, RequestOptions requestOptions) { + return PollerFlux.create( + Duration.ofSeconds(1), + () -> this.createOrUpdateWidgetWithResponseAsync(widgetName, resource, requestOptions), + new DefaultPollingStrategy<>( + new PollingStrategyOptions(this.getHttpPipeline()) + .setEndpoint("{endpoint}".replace("{endpoint}", this.getEndpoint())) + .setContext( + requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE)), + TypeReference.createInstance(BinaryData.class), + TypeReference.createInstance(BinaryData.class)); + } + + /** + * Creates or updates a Widget asynchronously. + * + *

Request Body Schema + * + *

{@code
+     * {
+     *     name: String (Required)
+     *     manufacturerId: String (Required)
+     *     sharedModel (Optional): {
+     *         tag: String (Required)
+     *         createdAt: OffsetDateTime (Required)
+     *     }
+     * }
+     * }
+ * + *

Response Body Schema + * + *

{@code
+     * {
+     *     name: String (Required)
+     *     manufacturerId: String (Required)
+     *     sharedModel (Optional): {
+     *         tag: String (Required)
+     *         createdAt: OffsetDateTime (Required)
+     *     }
+     * }
+     * }
+ * + * @param widgetName The widget name. + * @param resource The resource instance. + * @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 a widget. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginCreateOrUpdateWidget( + String widgetName, BinaryData resource, RequestOptions requestOptions) { + return this.beginCreateOrUpdateWidgetAsync(widgetName, resource, requestOptions).getSyncPoller(); + } + + /** + * Delete a Widget asynchronously. + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     id: String (Required)
+     *     status: String(InProgress/Succeeded/Failed/Canceled) (Required)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Required): [
+     *             (recursive schema, see above)
+     *         ]
+     *         innererror (Optional): {
+     *             code: String (Required)
+     *             innererror (Optional): (recursive schema, see innererror above)
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param widgetName The widget name. + * @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 provides status details for long running operations along with {@link Response} on successful completion + * of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> deleteWidgetWithResponseAsync(String widgetName, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext( + context -> + service.deleteWidget( + this.getEndpoint(), + this.getServiceVersion().getVersion(), + widgetName, + accept, + requestOptions, + context)); + } + + /** + * Delete a Widget asynchronously. + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     id: String (Required)
+     *     status: String(InProgress/Succeeded/Failed/Canceled) (Required)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Required): [
+     *             (recursive schema, see above)
+     *         ]
+     *         innererror (Optional): {
+     *             code: String (Required)
+     *             innererror (Optional): (recursive schema, see innererror above)
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param widgetName The widget name. + * @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 provides status details for long running operations. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginDeleteWidgetAsync(String widgetName, RequestOptions requestOptions) { + return PollerFlux.create( + Duration.ofSeconds(1), + () -> this.deleteWidgetWithResponseAsync(widgetName, requestOptions), + new DefaultPollingStrategy<>( + new PollingStrategyOptions(this.getHttpPipeline()) + .setEndpoint("{endpoint}".replace("{endpoint}", this.getEndpoint())) + .setContext( + requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE)), + TypeReference.createInstance(BinaryData.class), + TypeReference.createInstance(Void.class)); + } + + /** + * Delete a Widget asynchronously. + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     id: String (Required)
+     *     status: String(InProgress/Succeeded/Failed/Canceled) (Required)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Required): [
+     *             (recursive schema, see above)
+     *         ]
+     *         innererror (Optional): {
+     *             code: String (Required)
+     *             innererror (Optional): (recursive schema, see innererror above)
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param widgetName The widget name. + * @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 provides status details for long running operations. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginDeleteWidget(String widgetName, RequestOptions requestOptions) { + return this.beginDeleteWidgetAsync(widgetName, requestOptions).getSyncPoller(); + } + + /** + * Delete a Widget asynchronously. + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     id: String (Required)
+     *     status: String(InProgress/Succeeded/Failed/Canceled) (Required)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Required): [
+     *             (recursive schema, see above)
+     *         ]
+     *         innererror (Optional): {
+     *             code: String (Required)
+     *             innererror (Optional): (recursive schema, see innererror above)
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param widgetName The widget name. + * @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 provides status details for long running operations. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginDeleteWidgetWithModelAsync( + String widgetName, RequestOptions requestOptions) { + return PollerFlux.create( + Duration.ofSeconds(1), + () -> this.deleteWidgetWithResponseAsync(widgetName, requestOptions), + new DefaultPollingStrategy<>( + new PollingStrategyOptions(this.getHttpPipeline()) + .setEndpoint("{endpoint}".replace("{endpoint}", this.getEndpoint())) + .setContext( + requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE)), + TypeReference.createInstance(ResourceOperationStatusWidgetWidgetError.class), + TypeReference.createInstance(Void.class)); + } + + /** + * Delete a Widget asynchronously. + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     id: String (Required)
+     *     status: String(InProgress/Succeeded/Failed/Canceled) (Required)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Required): [
+     *             (recursive schema, see above)
+     *         ]
+     *         innererror (Optional): {
+     *             code: String (Required)
+     *             innererror (Optional): (recursive schema, see innererror above)
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param widgetName The widget name. + * @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 provides status details for long running operations. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginDeleteWidgetWithModel( + String widgetName, RequestOptions requestOptions) { + return this.beginDeleteWidgetWithModelAsync(widgetName, requestOptions).getSyncPoller(); + } + + /** + * List Widget resources. + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     name: String (Required)
+     *     manufacturerId: String (Required)
+     *     sharedModel (Optional): {
+     *         tag: String (Required)
+     *         createdAt: OffsetDateTime (Required)
+     *     }
+     * }
+     * }
+ * + * @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 paged collection of Widget items along with {@link PagedResponse} on successful completion of {@link + * Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listWidgetsSinglePageAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext( + context -> + service.listWidgets( + this.getEndpoint(), + this.getServiceVersion().getVersion(), + accept, + requestOptions, + context)) + .map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + getValues(res.getValue(), "value"), + getNextLink(res.getValue(), "nextLink"), + null)); + } + + /** + * List Widget resources. + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     name: String (Required)
+     *     manufacturerId: String (Required)
+     *     sharedModel (Optional): {
+     *         tag: String (Required)
+     *         createdAt: OffsetDateTime (Required)
+     *     }
+     * }
+     * }
+ * + * @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 paged collection of Widget items as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listWidgetsAsync(RequestOptions requestOptions) { + RequestOptions requestOptionsForNextPage = new RequestOptions(); + requestOptionsForNextPage.setContext( + requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE); + return new PagedFlux<>( + () -> listWidgetsSinglePageAsync(requestOptions), + nextLink -> listWidgetsNextSinglePageAsync(nextLink, requestOptionsForNextPage)); + } + + /** + * List Widget resources. + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     name: String (Required)
+     *     manufacturerId: String (Required)
+     *     sharedModel (Optional): {
+     *         tag: String (Required)
+     *         createdAt: OffsetDateTime (Required)
+     *     }
+     * }
+     * }
+ * + * @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 paged collection of Widget items as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listWidgets(RequestOptions requestOptions) { + return new PagedIterable<>(listWidgetsAsync(requestOptions)); + } + + /** + * Get the next page of items. + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     name: String (Required)
+     *     manufacturerId: String (Required)
+     *     sharedModel (Optional): {
+     *         tag: String (Required)
+     *         createdAt: OffsetDateTime (Required)
+     *     }
+     * }
+     * }
+ * + * @param nextLink The URL to get the next list of items + *

The nextLink parameter. + * @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 paged collection of Widget items along with {@link PagedResponse} on successful completion of {@link + * Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listWidgetsNextSinglePageAsync( + String nextLink, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext( + context -> + service.listWidgetsNext(nextLink, this.getEndpoint(), accept, requestOptions, context)) + .map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + getValues(res.getValue(), "value"), + getNextLink(res.getValue(), "nextLink"), + null)); + } + + private List getValues(BinaryData binaryData, String path) { + try { + Map obj = binaryData.toObject(Map.class); + List values = (List) obj.get(path); + return values.stream().map(BinaryData::fromObject).collect(Collectors.toList()); + } catch (RuntimeException e) { + return null; + } + } + + private String getNextLink(BinaryData binaryData, String path) { + try { + Map obj = binaryData.toObject(Map.class); + return (String) obj.get(path); + } catch (RuntimeException e) { + return null; + } + } +} diff --git a/sdk/contosowidgetmanager/azure-contoso-widgetmanager/src/main/java/com/azure/contoso/widgetmanager/implementation/package-info.java b/sdk/contosowidgetmanager/azure-contoso-widgetmanager/src/main/java/com/azure/contoso/widgetmanager/implementation/package-info.java new file mode 100644 index 0000000000000..08443e562bd16 --- /dev/null +++ b/sdk/contosowidgetmanager/azure-contoso-widgetmanager/src/main/java/com/azure/contoso/widgetmanager/implementation/package-info.java @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +/** Package containing the implementations for WidgetManager. */ +package com.azure.contoso.widgetmanager.implementation; diff --git a/sdk/contosowidgetmanager/azure-contoso-widgetmanager/src/main/java/com/azure/contoso/widgetmanager/models/FakedSharedModel.java b/sdk/contosowidgetmanager/azure-contoso-widgetmanager/src/main/java/com/azure/contoso/widgetmanager/models/FakedSharedModel.java new file mode 100644 index 0000000000000..82dd3a7887814 --- /dev/null +++ b/sdk/contosowidgetmanager/azure-contoso-widgetmanager/src/main/java/com/azure/contoso/widgetmanager/models/FakedSharedModel.java @@ -0,0 +1,58 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.contoso.widgetmanager.models; + +import com.azure.core.annotation.Immutable; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.time.OffsetDateTime; + +/** Faked shared model. */ +@Immutable +public final class FakedSharedModel { + /* + * The tag. + */ + @JsonProperty(value = "tag", required = true) + private String tag; + + /* + * The created date. + */ + @JsonProperty(value = "createdAt", required = true) + private OffsetDateTime createdAt; + + /** + * Creates an instance of FakedSharedModel class. + * + * @param tag the tag value to set. + * @param createdAt the createdAt value to set. + */ + @JsonCreator + public FakedSharedModel( + @JsonProperty(value = "tag", required = true) String tag, + @JsonProperty(value = "createdAt", required = true) OffsetDateTime createdAt) { + this.tag = tag; + this.createdAt = createdAt; + } + + /** + * Get the tag property: The tag. + * + * @return the tag value. + */ + public String getTag() { + return this.tag; + } + + /** + * Get the createdAt property: The created date. + * + * @return the createdAt value. + */ + public OffsetDateTime getCreatedAt() { + return this.createdAt; + } +} diff --git a/sdk/contosowidgetmanager/azure-contoso-widgetmanager/src/main/java/com/azure/contoso/widgetmanager/models/OperationState.java b/sdk/contosowidgetmanager/azure-contoso-widgetmanager/src/main/java/com/azure/contoso/widgetmanager/models/OperationState.java new file mode 100644 index 0000000000000..eb1bdc512d120 --- /dev/null +++ b/sdk/contosowidgetmanager/azure-contoso-widgetmanager/src/main/java/com/azure/contoso/widgetmanager/models/OperationState.java @@ -0,0 +1,52 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.contoso.widgetmanager.models; + +import com.azure.core.util.ExpandableStringEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import java.util.Collection; + +/** Defines values for OperationState. */ +public final class OperationState extends ExpandableStringEnum { + /** Static value InProgress for OperationState. */ + public static final OperationState IN_PROGRESS = fromString("InProgress"); + + /** Static value Succeeded for OperationState. */ + public static final OperationState SUCCEEDED = fromString("Succeeded"); + + /** Static value Failed for OperationState. */ + public static final OperationState FAILED = fromString("Failed"); + + /** Static value Canceled for OperationState. */ + public static final OperationState CANCELED = fromString("Canceled"); + + /** + * Creates a new instance of OperationState value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public OperationState() {} + + /** + * Creates or finds a OperationState from its string representation. + * + * @param name a name to look for. + * @return the corresponding OperationState. + */ + @JsonCreator + public static OperationState fromString(String name) { + return fromString(name, OperationState.class); + } + + /** + * Gets known OperationState values. + * + * @return known OperationState values. + */ + public static Collection values() { + return values(OperationState.class); + } +} diff --git a/sdk/contosowidgetmanager/azure-contoso-widgetmanager/src/main/java/com/azure/contoso/widgetmanager/models/ResourceOperationStatusWidgetWidgetError.java b/sdk/contosowidgetmanager/azure-contoso-widgetmanager/src/main/java/com/azure/contoso/widgetmanager/models/ResourceOperationStatusWidgetWidgetError.java new file mode 100644 index 0000000000000..2d5dd0ef81553 --- /dev/null +++ b/sdk/contosowidgetmanager/azure-contoso-widgetmanager/src/main/java/com/azure/contoso/widgetmanager/models/ResourceOperationStatusWidgetWidgetError.java @@ -0,0 +1,85 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.contoso.widgetmanager.models; + +import com.azure.core.annotation.Immutable; +import com.azure.core.models.ResponseError; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** Provides status details for long running operations. */ +@Immutable +public final class ResourceOperationStatusWidgetWidgetError { + /* + * The unique ID of the operation. + */ + @JsonProperty(value = "id", required = true, access = JsonProperty.Access.WRITE_ONLY) + private String id; + + /* + * The status of the operation + */ + @JsonProperty(value = "status", required = true) + private OperationState status; + + /* + * Error object that describes the error when status is "Failed". + */ + @JsonProperty(value = "error") + private ResponseError error; + + /* + * The result of the operation. + */ + @JsonProperty(value = "result") + private Widget result; + + /** + * Creates an instance of ResourceOperationStatusWidgetWidgetError class. + * + * @param status the status value to set. + */ + @JsonCreator + private ResourceOperationStatusWidgetWidgetError( + @JsonProperty(value = "status", required = true) OperationState status) { + this.status = status; + } + + /** + * Get the id property: The unique ID of the operation. + * + * @return the id value. + */ + public String getId() { + return this.id; + } + + /** + * Get the status property: The status of the operation. + * + * @return the status value. + */ + public OperationState getStatus() { + return this.status; + } + + /** + * Get the error property: Error object that describes the error when status is "Failed". + * + * @return the error value. + */ + public ResponseError getError() { + return this.error; + } + + /** + * Get the result property: The result of the operation. + * + * @return the result value. + */ + public Widget getResult() { + return this.result; + } +} diff --git a/sdk/contosowidgetmanager/azure-contoso-widgetmanager/src/main/java/com/azure/contoso/widgetmanager/models/Widget.java b/sdk/contosowidgetmanager/azure-contoso-widgetmanager/src/main/java/com/azure/contoso/widgetmanager/models/Widget.java new file mode 100644 index 0000000000000..70a7134dbc787 --- /dev/null +++ b/sdk/contosowidgetmanager/azure-contoso-widgetmanager/src/main/java/com/azure/contoso/widgetmanager/models/Widget.java @@ -0,0 +1,79 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.contoso.widgetmanager.models; + +import com.azure.core.annotation.Fluent; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** A widget. */ +@Fluent +public final class Widget { + /* + * The widget name. + */ + @JsonProperty(value = "name", required = true, access = JsonProperty.Access.WRITE_ONLY) + private String name; + + /* + * The ID of the widget's manufacturer. + */ + @JsonProperty(value = "manufacturerId", required = true) + private String manufacturerId; + + /* + * The faked shared model. + */ + @JsonProperty(value = "sharedModel") + private FakedSharedModel sharedModel; + + /** + * Creates an instance of Widget class. + * + * @param manufacturerId the manufacturerId value to set. + */ + @JsonCreator + public Widget(@JsonProperty(value = "manufacturerId", required = true) String manufacturerId) { + this.manufacturerId = manufacturerId; + } + + /** + * Get the name property: The widget name. + * + * @return the name value. + */ + public String getName() { + return this.name; + } + + /** + * Get the manufacturerId property: The ID of the widget's manufacturer. + * + * @return the manufacturerId value. + */ + public String getManufacturerId() { + return this.manufacturerId; + } + + /** + * Get the sharedModel property: The faked shared model. + * + * @return the sharedModel value. + */ + public FakedSharedModel getSharedModel() { + return this.sharedModel; + } + + /** + * Set the sharedModel property: The faked shared model. + * + * @param sharedModel the sharedModel value to set. + * @return the Widget object itself. + */ + public Widget setSharedModel(FakedSharedModel sharedModel) { + this.sharedModel = sharedModel; + return this; + } +} diff --git a/sdk/contosowidgetmanager/azure-contoso-widgetmanager/src/main/java/com/azure/contoso/widgetmanager/models/package-info.java b/sdk/contosowidgetmanager/azure-contoso-widgetmanager/src/main/java/com/azure/contoso/widgetmanager/models/package-info.java new file mode 100644 index 0000000000000..bb9a0b96c94ff --- /dev/null +++ b/sdk/contosowidgetmanager/azure-contoso-widgetmanager/src/main/java/com/azure/contoso/widgetmanager/models/package-info.java @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +/** Package containing the data models for WidgetManager. */ +package com.azure.contoso.widgetmanager.models; diff --git a/sdk/contosowidgetmanager/azure-contoso-widgetmanager/src/main/java/com/azure/contoso/widgetmanager/package-info.java b/sdk/contosowidgetmanager/azure-contoso-widgetmanager/src/main/java/com/azure/contoso/widgetmanager/package-info.java new file mode 100644 index 0000000000000..a00ca7941ed48 --- /dev/null +++ b/sdk/contosowidgetmanager/azure-contoso-widgetmanager/src/main/java/com/azure/contoso/widgetmanager/package-info.java @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +/** Package containing the classes for WidgetManager. */ +package com.azure.contoso.widgetmanager; diff --git a/sdk/contosowidgetmanager/azure-contoso-widgetmanager/src/main/java/module-info.java b/sdk/contosowidgetmanager/azure-contoso-widgetmanager/src/main/java/module-info.java new file mode 100644 index 0000000000000..1c6fbd2855de8 --- /dev/null +++ b/sdk/contosowidgetmanager/azure-contoso-widgetmanager/src/main/java/module-info.java @@ -0,0 +1,14 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +module com.azure.contoso.widgetmanager { + requires transitive com.azure.core; + + exports com.azure.contoso.widgetmanager; + exports com.azure.contoso.widgetmanager.models; + + opens com.azure.contoso.widgetmanager.models to + com.azure.core, + com.fasterxml.jackson.databind; +} diff --git a/sdk/contosowidgetmanager/azure-contoso-widgetmanager/src/main/resources/azure-contoso-widgetmanager.properties b/sdk/contosowidgetmanager/azure-contoso-widgetmanager/src/main/resources/azure-contoso-widgetmanager.properties new file mode 100644 index 0000000000000..ca812989b4f27 --- /dev/null +++ b/sdk/contosowidgetmanager/azure-contoso-widgetmanager/src/main/resources/azure-contoso-widgetmanager.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/sdk/contosowidgetmanager/azure-contoso-widgetmanager/src/samples/java/com/azure/contoso/widgetmanager/ReadmeSamples.java b/sdk/contosowidgetmanager/azure-contoso-widgetmanager/src/samples/java/com/azure/contoso/widgetmanager/ReadmeSamples.java new file mode 100644 index 0000000000000..f489316c3fbba --- /dev/null +++ b/sdk/contosowidgetmanager/azure-contoso-widgetmanager/src/samples/java/com/azure/contoso/widgetmanager/ReadmeSamples.java @@ -0,0 +1,12 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.contoso.widgetmanager; + +public final class ReadmeSamples { + public void readmeSamples() { + // BEGIN: com.azure.contoso.widgetmanager.readme + // END: com.azure.contoso.widgetmanager.readme + } +} diff --git a/sdk/contosowidgetmanager/azure-contoso-widgetmanager/src/test/java/com/azure/contoso/widgetmanager/generated/WidgetManagerClientTestBase.java b/sdk/contosowidgetmanager/azure-contoso-widgetmanager/src/test/java/com/azure/contoso/widgetmanager/generated/WidgetManagerClientTestBase.java new file mode 100644 index 0000000000000..cf40003f4331d --- /dev/null +++ b/sdk/contosowidgetmanager/azure-contoso-widgetmanager/src/test/java/com/azure/contoso/widgetmanager/generated/WidgetManagerClientTestBase.java @@ -0,0 +1,33 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.contoso.widgetmanager.generated; + +import com.azure.contoso.widgetmanager.WidgetManagerClient; +import com.azure.contoso.widgetmanager.WidgetManagerClientBuilder; +import com.azure.core.http.HttpClient; +import com.azure.core.http.policy.HttpLogDetailLevel; +import com.azure.core.http.policy.HttpLogOptions; +import com.azure.core.test.TestBase; +import com.azure.core.test.TestMode; +import com.azure.core.util.Configuration; + +class WidgetManagerClientTestBase extends TestBase { + protected WidgetManagerClient widgetManagerClient; + + @Override + protected void beforeTest() { + WidgetManagerClientBuilder widgetManagerClientbuilder = + new WidgetManagerClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + widgetManagerClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + widgetManagerClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + widgetManagerClient = widgetManagerClientbuilder.buildClient(); + } +} diff --git a/sdk/contosowidgetmanager/ci.yml b/sdk/contosowidgetmanager/ci.yml new file mode 100644 index 0000000000000..25b94d51ab304 --- /dev/null +++ b/sdk/contosowidgetmanager/ci.yml @@ -0,0 +1,47 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. + +trigger: + branches: + include: + - main + - hotfix/* + - release/* + paths: + include: + - sdk/contosowidgetmanager/ci.yml + - sdk/contosowidgetmanager/azure-contoso-widgetmanager/ + exclude: + - sdk/contosowidgetmanager/pom.xml + - sdk/contosowidgetmanager/azure-contoso-widgetmanager/pom.xml + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/contosowidgetmanager/ci.yml + - sdk/contosowidgetmanager/azure-contoso-widgetmanager/ + exclude: + - sdk/contosowidgetmanager/pom.xml + - sdk/contosowidgetmanager/azure-contoso-widgetmanager/pom.xml + +parameters: + - name: release_azurecontosowidgetmanager + displayName: azure-contoso-widgetmanager + type: boolean + default: true + +extends: + template: ../../eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: contosowidgetmanager + EnableBatchRelease: true + Artifacts: + - name: azure-contoso-widgetmanager + groupId: com.azure + safeName: azurecontosowidgetmanager + releaseInBatch: ${{ parameters.release_azurecontosowidgetmanager }} diff --git a/sdk/contosowidgetmanager/pom.xml b/sdk/contosowidgetmanager/pom.xml new file mode 100644 index 0000000000000..6d6c6b2185fdf --- /dev/null +++ b/sdk/contosowidgetmanager/pom.xml @@ -0,0 +1,15 @@ + + + 4.0.0 + com.azure + azure-contosowidgetmanager-service + pom + 1.0.0 + + + azure-contoso-widgetmanager + +