From b01307af52978ac4ce826c07f7c7d6bcb6c9fe92 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Thu, 12 Jan 2023 09:37:46 +0000 Subject: [PATCH] CodeGen from PR 22146 in Azure/azure-rest-api-specs fix cadl sample (#22146) * fix * Update Widgets_ListWidgetsSample.json * Update Widgets_ListWidgetsSample.json --- eng/versioning/version_client.txt | 1 + pom.xml | 1 + .../azure-contoso-widgetmanager/CHANGELOG.md | 13 + .../azure-contoso-widgetmanager/README.md | 63 ++ .../azure-contoso-widgetmanager/pom.xml | 91 ++ .../WidgetManagerAsyncClient.java | 381 +++++++ .../widgetmanager/WidgetManagerClient.java | 317 ++++++ .../WidgetManagerClientBuilder.java | 273 +++++ .../WidgetManagerServiceVersion.java | 34 + .../WidgetManagerClientImpl.java | 960 ++++++++++++++++++ .../models/CustomPageWidget.java | 55 + .../implementation/models/package-info.java | 6 + .../implementation/package-info.java | 6 + .../models/FakedSharedModel.java | 58 ++ .../widgetmanager/models/OperationState.java | 44 + .../models/OperationStatusError.java | 73 ++ ...ourceOperationStatusWidgetWidgetError.java | 85 ++ .../contoso/widgetmanager/models/Widget.java | 79 ++ .../widgetmanager/models/package-info.java | 6 + .../contoso/widgetmanager/package-info.java | 6 + .../src/main/java/module-info.java | 17 + .../azure-contoso-widgetmanager.properties | 2 + .../contoso/widgetmanager/ReadmeSamples.java | 12 + sdk/contosowidgetmanager/ci.yml | 47 + sdk/contosowidgetmanager/pom.xml | 15 + 25 files changed, 2645 insertions(+) create mode 100644 sdk/contosowidgetmanager/azure-contoso-widgetmanager/CHANGELOG.md create mode 100644 sdk/contosowidgetmanager/azure-contoso-widgetmanager/README.md create mode 100644 sdk/contosowidgetmanager/azure-contoso-widgetmanager/pom.xml create mode 100644 sdk/contosowidgetmanager/azure-contoso-widgetmanager/src/main/java/com/azure/contoso/widgetmanager/WidgetManagerAsyncClient.java create mode 100644 sdk/contosowidgetmanager/azure-contoso-widgetmanager/src/main/java/com/azure/contoso/widgetmanager/WidgetManagerClient.java create mode 100644 sdk/contosowidgetmanager/azure-contoso-widgetmanager/src/main/java/com/azure/contoso/widgetmanager/WidgetManagerClientBuilder.java create mode 100644 sdk/contosowidgetmanager/azure-contoso-widgetmanager/src/main/java/com/azure/contoso/widgetmanager/WidgetManagerServiceVersion.java create mode 100644 sdk/contosowidgetmanager/azure-contoso-widgetmanager/src/main/java/com/azure/contoso/widgetmanager/implementation/WidgetManagerClientImpl.java create mode 100644 sdk/contosowidgetmanager/azure-contoso-widgetmanager/src/main/java/com/azure/contoso/widgetmanager/implementation/models/CustomPageWidget.java create mode 100644 sdk/contosowidgetmanager/azure-contoso-widgetmanager/src/main/java/com/azure/contoso/widgetmanager/implementation/models/package-info.java create mode 100644 sdk/contosowidgetmanager/azure-contoso-widgetmanager/src/main/java/com/azure/contoso/widgetmanager/implementation/package-info.java create mode 100644 sdk/contosowidgetmanager/azure-contoso-widgetmanager/src/main/java/com/azure/contoso/widgetmanager/models/FakedSharedModel.java create mode 100644 sdk/contosowidgetmanager/azure-contoso-widgetmanager/src/main/java/com/azure/contoso/widgetmanager/models/OperationState.java create mode 100644 sdk/contosowidgetmanager/azure-contoso-widgetmanager/src/main/java/com/azure/contoso/widgetmanager/models/OperationStatusError.java create mode 100644 sdk/contosowidgetmanager/azure-contoso-widgetmanager/src/main/java/com/azure/contoso/widgetmanager/models/ResourceOperationStatusWidgetWidgetError.java create mode 100644 sdk/contosowidgetmanager/azure-contoso-widgetmanager/src/main/java/com/azure/contoso/widgetmanager/models/Widget.java create mode 100644 sdk/contosowidgetmanager/azure-contoso-widgetmanager/src/main/java/com/azure/contoso/widgetmanager/models/package-info.java create mode 100644 sdk/contosowidgetmanager/azure-contoso-widgetmanager/src/main/java/com/azure/contoso/widgetmanager/package-info.java create mode 100644 sdk/contosowidgetmanager/azure-contoso-widgetmanager/src/main/java/module-info.java create mode 100644 sdk/contosowidgetmanager/azure-contoso-widgetmanager/src/main/resources/azure-contoso-widgetmanager.properties create mode 100644 sdk/contosowidgetmanager/azure-contoso-widgetmanager/src/samples/java/com/azure/contoso/widgetmanager/ReadmeSamples.java create mode 100644 sdk/contosowidgetmanager/ci.yml create mode 100644 sdk/contosowidgetmanager/pom.xml diff --git a/eng/versioning/version_client.txt b/eng/versioning/version_client.txt index a7e4cf4fa076b..ee7384e9bfb70 100644 --- a/eng/versioning/version_client.txt +++ b/eng/versioning/version_client.txt @@ -177,6 +177,7 @@ com.azure:perf-test-core;1.0.0-beta.1;1.0.0-beta.1 com.azure:azure-communication-email;1.0.0-beta.1;1.0.0-beta.2 com.azure:azure-developer-loadtesting;1.0.0-beta.1;1.0.0-beta.2 com.azure:azure-identity-extensions;1.1.0;1.2.0-beta.1 +com.azure:azure-contoso-widgetmanager;1.0.0-beta.1;1.0.0-beta.1 com.azure.spring:azure-spring-cloud-appconfiguration-config-web;2.10.0;2.11.0-beta.1 com.azure.spring:azure-spring-cloud-appconfiguration-config;2.10.0;2.11.0-beta.1 com.azure.spring:azure-spring-cloud-feature-management-web;2.9.0;2.10.0-beta.1 diff --git a/pom.xml b/pom.xml index 5081c08637ea1..6d4bba9378be3 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..2e53bd789aeb8 --- /dev/null +++ b/sdk/contosowidgetmanager/azure-contoso-widgetmanager/pom.xml @@ -0,0 +1,91 @@ + + 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 Management + 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 + true + + + + com.azure + azure-core + 1.35.0 + + + com.azure + azure-core-http-netty + 1.12.8 + + + 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.5.1 + test + + + com.azure + azure-core-test + 1.14.0 + test + + + com.azure + azure-identity + 1.7.3 + 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..f59f6cc6444a6 --- /dev/null +++ b/sdk/contosowidgetmanager/azure-contoso-widgetmanager/src/main/java/com/azure/contoso/widgetmanager/WidgetManagerAsyncClient.java @@ -0,0 +1,381 @@ +// 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)
+     *         createdDate: 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: ResponseError (Optional)
+     *     result (Optional): {
+     *         name: String (Required)
+     *         manufacturerId: String (Required)
+     *         sharedModel (Optional): {
+     *             tag: String (Required)
+     *             createdDate: 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)
+     *         createdDate: OffsetDateTime (Required)
+     *     }
+     * }
+     * }
+ * + *

Response Body Schema + * + *

{@code
+     * {
+     *     name: String (Required)
+     *     manufacturerId: String (Required)
+     *     sharedModel (Optional): {
+     *         tag: String (Required)
+     *         createdDate: OffsetDateTime (Required)
+     *     }
+     * }
+     * }
+ * + * @param widgetName The widget name. + * @param widget A widget. + * @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 widget, RequestOptions requestOptions) { + return this.serviceClient.beginCreateOrUpdateWidgetAsync(widgetName, widget, requestOptions); + } + + /** + * Delete a Widget asynchronously. + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     id: String (Required)
+     *     status: String(InProgress/Succeeded/Failed/Canceled) (Required)
+     *     error: ResponseError (Optional)
+     * }
+     * }
+ * + * @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. + * + *

Query Parameters + * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
topIntegerNoThe number of result items to return.
skipIntegerNoThe number of result items to skip.
maxpagesizeIntegerNoThe maximum number of result items per page.
+ * + * You can add these to a request with {@link RequestOptions#addQueryParam} + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     name: String (Required)
+     *     manufacturerId: String (Required)
+     *     sharedModel (Optional): {
+     *         tag: String (Required)
+     *         createdDate: 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 com.azure.core.exception.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 com.azure.core.exception.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 com.azure.core.exception.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. + * + * @param top The number of result items to return. + * @param skip The number of result items to skip. + * @param maxPageSize The maximum number of result items per page. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.exception.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(Integer top, Integer skip, Integer maxPageSize) { + // Generated convenience method for listWidgets + RequestOptions requestOptions = new RequestOptions(); + if (top != null) { + requestOptions.addQueryParam("top", String.valueOf(top)); + } + if (skip != null) { + requestOptions.addQueryParam("skip", String.valueOf(skip)); + } + if (maxPageSize != null) { + requestOptions.addQueryParam("maxpagesize", String.valueOf(maxPageSize)); + } + 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)); + }); + } + + /** + * List Widget resources. + * + * @throws com.azure.core.exception.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..d8b4ab8d7c329 --- /dev/null +++ b/sdk/contosowidgetmanager/azure-contoso-widgetmanager/src/main/java/com/azure/contoso/widgetmanager/WidgetManagerClient.java @@ -0,0 +1,317 @@ +// 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)
+     *         createdDate: 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: ResponseError (Optional)
+     *     result (Optional): {
+     *         name: String (Required)
+     *         manufacturerId: String (Required)
+     *         sharedModel (Optional): {
+     *             tag: String (Required)
+     *             createdDate: 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)
+     *         createdDate: OffsetDateTime (Required)
+     *     }
+     * }
+     * }
+ * + *

Response Body Schema + * + *

{@code
+     * {
+     *     name: String (Required)
+     *     manufacturerId: String (Required)
+     *     sharedModel (Optional): {
+     *         tag: String (Required)
+     *         createdDate: OffsetDateTime (Required)
+     *     }
+     * }
+     * }
+ * + * @param widgetName The widget name. + * @param widget A widget. + * @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 widget, RequestOptions requestOptions) { + return this.client.beginCreateOrUpdateWidget(widgetName, widget, requestOptions).getSyncPoller(); + } + + /** + * Delete a Widget asynchronously. + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     id: String (Required)
+     *     status: String(InProgress/Succeeded/Failed/Canceled) (Required)
+     *     error: ResponseError (Optional)
+     * }
+     * }
+ * + * @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. + * + *

Query Parameters + * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
topIntegerNoThe number of result items to return.
skipIntegerNoThe number of result items to skip.
maxpagesizeIntegerNoThe maximum number of result items per page.
+ * + * You can add these to a request with {@link RequestOptions#addQueryParam} + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     name: String (Required)
+     *     manufacturerId: String (Required)
+     *     sharedModel (Optional): {
+     *         tag: String (Required)
+     *         createdDate: 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 com.azure.core.exception.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 com.azure.core.exception.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 com.azure.core.exception.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. + * + * @param top The number of result items to return. + * @param skip The number of result items to skip. + * @param maxPageSize The maximum number of result items per page. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.exception.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(Integer top, Integer skip, Integer maxPageSize) { + // Generated convenience method for listWidgets + return new PagedIterable<>(client.listWidgets(top, skip, maxPageSize)); + } + + /** + * List Widget resources. + * + * @throws com.azure.core.exception.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..3198dfcd6caa9 --- /dev/null +++ b/sdk/contosowidgetmanager/azure-contoso-widgetmanager/src/main/java/com/azure/contoso/widgetmanager/WidgetManagerClientBuilder.java @@ -0,0 +1,273 @@ +// 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.serializer.JacksonAdapter; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.stream.Collectors; + +/** 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) { + 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)); + } + policies.addAll( + this.pipelinePolicies.stream() + .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_CALL) + .collect(Collectors.toList())); + HttpPolicyProviders.addBeforeRetryPolicies(policies); + policies.add(ClientBuilderUtil.validateAndGetRetryPolicy(retryPolicy, retryOptions, new RetryPolicy())); + policies.add(new AddDatePolicy()); + policies.add(new CookiePolicy()); + policies.addAll( + this.pipelinePolicies.stream() + .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_RETRY) + .collect(Collectors.toList())); + 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())); + } +} 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..75625977b0667 --- /dev/null +++ b/sdk/contosowidgetmanager/azure-contoso-widgetmanager/src/main/java/com/azure/contoso/widgetmanager/implementation/WidgetManagerClientImpl.java @@ -0,0 +1,960 @@ +// 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.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, + @PathParam("widgetName") String widgetName, + @QueryParam("api-version") String apiVersion, + @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, + @PathParam("widgetName") String widgetName, + @PathParam("operationId") String operationId, + @QueryParam("api-version") String apiVersion, + @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, + @PathParam("widgetName") String widgetName, + @HeaderParam("Content-Type") String contentType, + @QueryParam("api-version") String apiVersion, + @HeaderParam("accept") String accept, + @BodyParam("application/merge-patch+json") BinaryData widget, + 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, + @PathParam("widgetName") String widgetName, + @QueryParam("api-version") String apiVersion, + @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)
+     *         createdDate: 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(), + widgetName, + this.getServiceVersion().getVersion(), + accept, + requestOptions, + context)); + } + + /** + * Fetch a Widget by name. + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     name: String (Required)
+     *     manufacturerId: String (Required)
+     *     sharedModel (Optional): {
+     *         tag: String (Required)
+     *         createdDate: 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: ResponseError (Optional)
+     *     result (Optional): {
+     *         name: String (Required)
+     *         manufacturerId: String (Required)
+     *         sharedModel (Optional): {
+     *             tag: String (Required)
+     *             createdDate: 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(), + widgetName, + operationId, + this.getServiceVersion().getVersion(), + accept, + requestOptions, + context)); + } + + /** + * Gets status of a Widget operation. + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     id: String (Required)
+     *     status: String(InProgress/Succeeded/Failed/Canceled) (Required)
+     *     error: ResponseError (Optional)
+     *     result (Optional): {
+     *         name: String (Required)
+     *         manufacturerId: String (Required)
+     *         sharedModel (Optional): {
+     *             tag: String (Required)
+     *             createdDate: 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)
+     *         createdDate: OffsetDateTime (Required)
+     *     }
+     * }
+     * }
+ * + *

Response Body Schema + * + *

{@code
+     * {
+     *     name: String (Required)
+     *     manufacturerId: String (Required)
+     *     sharedModel (Optional): {
+     *         tag: String (Required)
+     *         createdDate: OffsetDateTime (Required)
+     *     }
+     * }
+     * }
+ * + * @param widgetName The widget name. + * @param widget A widget. + * @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 widget, RequestOptions requestOptions) { + final String contentType = "application/merge-patch+json"; + final String accept = "application/json"; + return FluxUtil.withContext( + context -> + service.createOrUpdateWidget( + this.getEndpoint(), + widgetName, + contentType, + this.getServiceVersion().getVersion(), + accept, + widget, + requestOptions, + context)); + } + + /** + * Creates or updates a Widget asynchronously. + * + *

Request Body Schema + * + *

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

Response Body Schema + * + *

{@code
+     * {
+     *     name: String (Required)
+     *     manufacturerId: String (Required)
+     *     sharedModel (Optional): {
+     *         tag: String (Required)
+     *         createdDate: OffsetDateTime (Required)
+     *     }
+     * }
+     * }
+ * + * @param widgetName The widget name. + * @param widget A widget. + * @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 widget, RequestOptions requestOptions) { + return PollerFlux.create( + Duration.ofSeconds(1), + () -> this.createOrUpdateWidgetWithResponseAsync(widgetName, widget, requestOptions), + new DefaultPollingStrategy<>( + this.getHttpPipeline(), + "{endpoint}".replace("{endpoint}", this.getEndpoint()), + null, + 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)
+     *         createdDate: OffsetDateTime (Required)
+     *     }
+     * }
+     * }
+ * + *

Response Body Schema + * + *

{@code
+     * {
+     *     name: String (Required)
+     *     manufacturerId: String (Required)
+     *     sharedModel (Optional): {
+     *         tag: String (Required)
+     *         createdDate: OffsetDateTime (Required)
+     *     }
+     * }
+     * }
+ * + * @param widgetName The widget name. + * @param widget A widget. + * @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 widget, RequestOptions requestOptions) { + return this.beginCreateOrUpdateWidgetAsync(widgetName, widget, requestOptions).getSyncPoller(); + } + + /** + * Delete a Widget asynchronously. + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     id: String (Required)
+     *     status: String(InProgress/Succeeded/Failed/Canceled) (Required)
+     *     error: ResponseError (Optional)
+     * }
+     * }
+ * + * @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(), + widgetName, + this.getServiceVersion().getVersion(), + accept, + requestOptions, + context)); + } + + /** + * Delete a Widget asynchronously. + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     id: String (Required)
+     *     status: String(InProgress/Succeeded/Failed/Canceled) (Required)
+     *     error: ResponseError (Optional)
+     * }
+     * }
+ * + * @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<>( + this.getHttpPipeline(), + "{endpoint}".replace("{endpoint}", this.getEndpoint()), + null, + 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: ResponseError (Optional)
+     * }
+     * }
+ * + * @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: ResponseError (Optional)
+     * }
+     * }
+ * + * @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<>( + this.getHttpPipeline(), + "{endpoint}".replace("{endpoint}", this.getEndpoint()), + null, + 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: ResponseError (Optional)
+     * }
+     * }
+ * + * @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. + * + *

Query Parameters + * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
topIntegerNoThe number of result items to return.
skipIntegerNoThe number of result items to skip.
maxpagesizeIntegerNoThe maximum number of result items per page.
+ * + * You can add these to a request with {@link RequestOptions#addQueryParam} + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     name: String (Required)
+     *     manufacturerId: String (Required)
+     *     sharedModel (Optional): {
+     *         tag: String (Required)
+     *         createdDate: 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. + * + *

Query Parameters + * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
topIntegerNoThe number of result items to return.
skipIntegerNoThe number of result items to skip.
maxpagesizeIntegerNoThe maximum number of result items per page.
+ * + * You can add these to a request with {@link RequestOptions#addQueryParam} + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     name: String (Required)
+     *     manufacturerId: String (Required)
+     *     sharedModel (Optional): {
+     *         tag: String (Required)
+     *         createdDate: 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. + * + *

Query Parameters + * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
topIntegerNoThe number of result items to return.
skipIntegerNoThe number of result items to skip.
maxpagesizeIntegerNoThe maximum number of result items per page.
+ * + * You can add these to a request with {@link RequestOptions#addQueryParam} + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     name: String (Required)
+     *     manufacturerId: String (Required)
+     *     sharedModel (Optional): {
+     *         tag: String (Required)
+     *         createdDate: 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)
+     *         createdDate: 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/models/CustomPageWidget.java b/sdk/contosowidgetmanager/azure-contoso-widgetmanager/src/main/java/com/azure/contoso/widgetmanager/implementation/models/CustomPageWidget.java new file mode 100644 index 0000000000000..169aeb6a565df --- /dev/null +++ b/sdk/contosowidgetmanager/azure-contoso-widgetmanager/src/main/java/com/azure/contoso/widgetmanager/implementation/models/CustomPageWidget.java @@ -0,0 +1,55 @@ +// 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.models; + +import com.azure.contoso.widgetmanager.models.Widget; +import com.azure.core.annotation.Immutable; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +/** Paged collection of Widget items. */ +@Immutable +public final class CustomPageWidget { + /* + * The Widget items on this page + */ + @JsonProperty(value = "value", required = true) + private List value; + + /* + * The link to the next page of items + */ + @JsonProperty(value = "nextLink") + private String nextLink; + + /** + * Creates an instance of CustomPageWidget class. + * + * @param value the value value to set. + */ + @JsonCreator + private CustomPageWidget(@JsonProperty(value = "value", required = true) List value) { + this.value = value; + } + + /** + * Get the value property: The Widget items on this page. + * + * @return the value value. + */ + public List getValue() { + return this.value; + } + + /** + * Get the nextLink property: The link to the next page of items. + * + * @return the nextLink value. + */ + public String getNextLink() { + return this.nextLink; + } +} diff --git a/sdk/contosowidgetmanager/azure-contoso-widgetmanager/src/main/java/com/azure/contoso/widgetmanager/implementation/models/package-info.java b/sdk/contosowidgetmanager/azure-contoso-widgetmanager/src/main/java/com/azure/contoso/widgetmanager/implementation/models/package-info.java new file mode 100644 index 0000000000000..5d02aa203b03e --- /dev/null +++ b/sdk/contosowidgetmanager/azure-contoso-widgetmanager/src/main/java/com/azure/contoso/widgetmanager/implementation/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.implementation.models; 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..709c569680ad0 --- /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 = "createdDate", required = true) + private OffsetDateTime createdDate; + + /** + * Creates an instance of FakedSharedModel class. + * + * @param tag the tag value to set. + * @param createdDate the createdDate value to set. + */ + @JsonCreator + public FakedSharedModel( + @JsonProperty(value = "tag", required = true) String tag, + @JsonProperty(value = "createdDate", required = true) OffsetDateTime createdDate) { + this.tag = tag; + this.createdDate = createdDate; + } + + /** + * Get the tag property: The tag. + * + * @return the tag value. + */ + public String getTag() { + return this.tag; + } + + /** + * Get the createdDate property: The created date. + * + * @return the createdDate value. + */ + public OffsetDateTime getCreatedDate() { + return this.createdDate; + } +} 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..8c771febaec6d --- /dev/null +++ b/sdk/contosowidgetmanager/azure-contoso-widgetmanager/src/main/java/com/azure/contoso/widgetmanager/models/OperationState.java @@ -0,0 +1,44 @@ +// 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 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/OperationStatusError.java b/sdk/contosowidgetmanager/azure-contoso-widgetmanager/src/main/java/com/azure/contoso/widgetmanager/models/OperationStatusError.java new file mode 100644 index 0000000000000..ecf27e4c82bb4 --- /dev/null +++ b/sdk/contosowidgetmanager/azure-contoso-widgetmanager/src/main/java/com/azure/contoso/widgetmanager/models/OperationStatusError.java @@ -0,0 +1,73 @@ +// 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 OperationStatusError { + /* + * The unique ID of the operation. + */ + @JsonProperty(value = "id", required = true) + 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; + + /** + * Creates an instance of OperationStatusError class. + * + * @param id the id value to set. + * @param status the status value to set. + */ + @JsonCreator + private OperationStatusError( + @JsonProperty(value = "id", required = true) String id, + @JsonProperty(value = "status", required = true) OperationState status) { + this.id = id; + 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; + } +} 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..8a2b476c90cbd --- /dev/null +++ b/sdk/contosowidgetmanager/azure-contoso-widgetmanager/src/main/java/module-info.java @@ -0,0 +1,17 @@ +// 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; + opens com.azure.contoso.widgetmanager.implementation.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/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 + +