diff --git a/eng/versioning/version_client.txt b/eng/versioning/version_client.txt index a2277ce3b9ee..ecb70d198e27 100644 --- a/eng/versioning/version_client.txt +++ b/eng/versioning/version_client.txt @@ -256,6 +256,7 @@ com.azure.spring:spring-cloud-azure-stream-binder-servicebus-core;5.21.0;5.22.0- com.azure.spring:spring-cloud-azure-stream-binder-servicebus;5.21.0;5.22.0-beta.1 com.azure.spring:spring-cloud-azure-testcontainers;5.21.0;5.22.0-beta.1 com.azure:azure-spring-data-cosmos;5.21.0;5.22.0-beta.1 +com.azure:azure-apicenter;1.0.0-beta.1;1.0.0-beta.1 com.azure.resourcemanager:azure-resourcemanager;2.49.0;2.50.0-beta.1 com.azure.resourcemanager:azure-resourcemanager-appplatform;2.49.0;2.50.0-beta.1 com.azure.resourcemanager:azure-resourcemanager-appservice;2.49.0;2.50.0-beta.1 diff --git a/sdk/apicenter/azure-apicenter/CHANGELOG.md b/sdk/apicenter/azure-apicenter/CHANGELOG.md new file mode 100644 index 000000000000..2456158d259d --- /dev/null +++ b/sdk/apicenter/azure-apicenter/CHANGELOG.md @@ -0,0 +1,16 @@ +# Release History + +## 1.0.0-beta.1 (Unreleased) + +- Azure DataApi client library for Java. This package contains Microsoft Azure DataApi client library. + +### Features Added + +### Breaking Changes + +### Bugs Fixed + +### Other Changes +### Features Added + +- Initial release for the azure-apicenter Java SDK. diff --git a/sdk/apicenter/azure-apicenter/README.md b/sdk/apicenter/azure-apicenter/README.md new file mode 100644 index 000000000000..7bff495f4ca2 --- /dev/null +++ b/sdk/apicenter/azure-apicenter/README.md @@ -0,0 +1,78 @@ +# Azure DataApi client library for Java + +Azure DataApi client library for Java. + +This package contains Microsoft Azure DataApi 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-apicenter;current}) +```xml + + com.azure + azure-apicenter + 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.apicenter.readme +``` + +### Service API versions + +The client library targets the latest service API version by default. +The service client builder accepts an optional service API version parameter to specify which API version to communicate. + +#### Select a service API version + +You have the flexibility to explicitly select a supported service API version when initializing a service client via the service client builder. +This ensures that the client can communicate with services using the specified API version. + +When selecting an API version, it is important to verify that there are no breaking changes compared to the latest API version. +If there are significant differences, API calls may fail due to incompatibility. + +Always ensure that the chosen API version is fully supported and operational for your specific use case and that it aligns with the service's versioning policy. + +## 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://learn.microsoft.com/azure/developer/java/fundamentals/ +[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/apicenter/azure-apicenter/assets.json b/sdk/apicenter/azure-apicenter/assets.json new file mode 100644 index 000000000000..d5929d4b90ab --- /dev/null +++ b/sdk/apicenter/azure-apicenter/assets.json @@ -0,0 +1 @@ +{"AssetsRepo":"Azure/azure-sdk-assets","AssetsRepoPrefixPath":"java","TagPrefix":"java/apicenter/azure-apicenter","Tag":""} \ No newline at end of file diff --git a/sdk/apicenter/azure-apicenter/pom.xml b/sdk/apicenter/azure-apicenter/pom.xml new file mode 100644 index 000000000000..f463990ed068 --- /dev/null +++ b/sdk/apicenter/azure-apicenter/pom.xml @@ -0,0 +1,71 @@ + + + 4.0.0 + + com.azure + azure-client-sdk-parent + 1.7.0 + ../../parents/azure-client-sdk-parent + + + com.azure + azure-apicenter + 1.0.0-beta.1 + jar + + Microsoft Azure SDK for DataApi + This package contains Microsoft Azure DataApi client library. + https://github.com/Azure/azure-sdk-for-java + + + + The MIT License (MIT) + http://opensource.org/licenses/MIT + repo + + + + + https://github.com/Azure/azure-sdk-for-java + scm:git:git@github.com:Azure/azure-sdk-for-java.git + scm:git:git@github.com:Azure/azure-sdk-for-java.git + HEAD + + + + microsoft + Microsoft + + + + UTF-8 + + + + com.azure + azure-core + 1.55.3 + + + com.azure + azure-core-http-netty + 1.15.11 + + + com.azure + azure-core-test + 1.27.0-beta.8 + test + + + com.azure + azure-identity + 1.15.4 + test + + + diff --git a/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/ApiDefinitionsAsyncClient.java b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/ApiDefinitionsAsyncClient.java new file mode 100644 index 000000000000..afce90c8b794 --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/ApiDefinitionsAsyncClient.java @@ -0,0 +1,387 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.apicenter; + +import com.azure.apicenter.implementation.ApiDefinitionsImpl; +import com.azure.apicenter.models.ApiDefinition; +import com.azure.apicenter.models.ApiSpecExportResult; +import com.azure.apicenter.models.ResourceOperationStatusApiSpecExportResultApiSpecExportResultError; +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.PollOperationDetails; +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 DataApiClient type. + */ +@ServiceClient(builder = DataApiClientBuilder.class, isAsync = true) +public final class ApiDefinitionsAsyncClient { + @Generated + private final ApiDefinitionsImpl serviceClient; + + /** + * Initializes an instance of ApiDefinitionsAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ApiDefinitionsAsyncClient(ApiDefinitionsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * List a collection of API definitions. + *

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)
+     *     title: String (Required)
+     *     description: String (Optional)
+     *     specification (Optional): {
+     *         name: String (Required)
+     *         version: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param workspaceName Workspace identifier. + * @param apiName Api identifier. + * @param versionName Version identifier. + * @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 ApiDefinition items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listDefinitions(String workspaceName, String apiName, String versionName, + RequestOptions requestOptions) { + return this.serviceClient.listDefinitionsAsync(workspaceName, apiName, versionName, requestOptions); + } + + /** + * Get an API definition. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *     title: String (Required)
+     *     description: String (Optional)
+     *     specification (Optional): {
+     *         name: String (Required)
+     *         version: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param workspaceName Workspace identifier. + * @param apiName Api identifier. + * @param versionName Version identifier. + * @param definitionName Definition identifier. + * @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 an API definition along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getDefinitionWithResponse(String workspaceName, String apiName, + String versionName, String definitionName, RequestOptions requestOptions) { + return this.serviceClient.getDefinitionWithResponseAsync(workspaceName, apiName, versionName, definitionName, + requestOptions); + } + + /** + * Gets status of a an API specification export operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     status: String(NotStarted/Running/Succeeded/Failed/Canceled) (Required)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *         innererror (Optional): {
+     *             code: String (Optional)
+     *             innererror (Optional): (recursive schema, see innererror above)
+     *         }
+     *     }
+     *     result (Optional): {
+     *         definitionName: String (Required)
+     *         value: String (Required)
+     *         format: String(link) (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param workspaceName Workspace identifier. + * @param apiName Api identifier. + * @param versionName Version identifier. + * @param definitionName API definition identifier. + * @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 an API specification export operation along with {@link Response} on successful completion of + * {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getExportSpecificationOperationStatusWithResponse(String workspaceName, + String apiName, String versionName, String definitionName, String operationId, RequestOptions requestOptions) { + return this.serviceClient.getExportSpecificationOperationStatusWithResponseAsync(workspaceName, apiName, + versionName, definitionName, operationId, requestOptions); + } + + /** + * Export an API specification asynchronously. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     status: String(NotStarted/Running/Succeeded/Failed/Canceled) (Required)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *         innererror (Optional): {
+     *             code: String (Optional)
+     *             innererror (Optional): (recursive schema, see innererror above)
+     *         }
+     *     }
+     *     result (Optional): {
+     *         definitionName: String (Required)
+     *         value: String (Required)
+     *         format: String(link) (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param workspaceName Workspace identifier. + * @param apiName Api identifier. + * @param versionName Version identifier. + * @param definitionName API definition identifier. + * @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 beginExportSpecification(String workspaceName, String apiName, + String versionName, String definitionName, RequestOptions requestOptions) { + return this.serviceClient.beginExportSpecificationAsync(workspaceName, apiName, versionName, definitionName, + requestOptions); + } + + /** + * List a collection of API definitions. + * + * @param workspaceName Workspace identifier. + * @param apiName Api identifier. + * @param versionName Version identifier. + * @param top The number of result items to return. + * @param skip The number of result items to skip. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return paged collection of ApiDefinition items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listDefinitions(String workspaceName, String apiName, String versionName, + Integer top, Integer skip) { + // Generated convenience method for listDefinitions + RequestOptions requestOptions = new RequestOptions(); + if (top != null) { + requestOptions.addQueryParam("top", String.valueOf(top), false); + } + if (skip != null) { + requestOptions.addQueryParam("skip", String.valueOf(skip), false); + } + PagedFlux pagedFluxResponse = listDefinitions(workspaceName, apiName, versionName, requestOptions); + return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> { + Flux> flux = (continuationTokenParam == null) + ? pagedFluxResponse.byPage().take(1) + : pagedFluxResponse.byPage(continuationTokenParam).take(1); + return flux.map(pagedResponse -> new PagedResponseBase(pagedResponse.getRequest(), + pagedResponse.getStatusCode(), pagedResponse.getHeaders(), + pagedResponse.getValue() + .stream() + .map(protocolMethodData -> protocolMethodData.toObject(ApiDefinition.class)) + .collect(Collectors.toList()), + pagedResponse.getContinuationToken(), null)); + }); + } + + /** + * List a collection of API definitions. + * + * @param workspaceName Workspace identifier. + * @param apiName Api identifier. + * @param versionName Version identifier. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return paged collection of ApiDefinition items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listDefinitions(String workspaceName, String apiName, String versionName) { + // Generated convenience method for listDefinitions + RequestOptions requestOptions = new RequestOptions(); + PagedFlux pagedFluxResponse = listDefinitions(workspaceName, apiName, versionName, requestOptions); + return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> { + Flux> flux = (continuationTokenParam == null) + ? pagedFluxResponse.byPage().take(1) + : pagedFluxResponse.byPage(continuationTokenParam).take(1); + return flux.map(pagedResponse -> new PagedResponseBase(pagedResponse.getRequest(), + pagedResponse.getStatusCode(), pagedResponse.getHeaders(), + pagedResponse.getValue() + .stream() + .map(protocolMethodData -> protocolMethodData.toObject(ApiDefinition.class)) + .collect(Collectors.toList()), + pagedResponse.getContinuationToken(), null)); + }); + } + + /** + * Get an API definition. + * + * @param workspaceName Workspace identifier. + * @param apiName Api identifier. + * @param versionName Version identifier. + * @param definitionName Definition identifier. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an API definition on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getDefinition(String workspaceName, String apiName, String versionName, + String definitionName) { + // Generated convenience method for getDefinitionWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getDefinitionWithResponse(workspaceName, apiName, versionName, definitionName, requestOptions) + .flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(ApiDefinition.class)); + } + + /** + * Gets status of a an API specification export operation. + * + * @param workspaceName Workspace identifier. + * @param apiName Api identifier. + * @param versionName Version identifier. + * @param definitionName API definition identifier. + * @param operationId The unique ID of the operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return status of a an API specification export operation on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono + getExportSpecificationOperationStatus(String workspaceName, String apiName, String versionName, + String definitionName, String operationId) { + // Generated convenience method for getExportSpecificationOperationStatusWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getExportSpecificationOperationStatusWithResponse(workspaceName, apiName, versionName, definitionName, + operationId, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData + .toObject(ResourceOperationStatusApiSpecExportResultApiSpecExportResultError.class)); + } + + /** + * Export an API specification asynchronously. + * + * @param workspaceName Workspace identifier. + * @param apiName Api identifier. + * @param versionName Version identifier. + * @param definitionName API definition identifier. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link PollerFlux} for polling of provides status details for long running operations. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginExportSpecification(String workspaceName, + String apiName, String versionName, String definitionName) { + // Generated convenience method for beginExportSpecificationWithModel + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.beginExportSpecificationWithModelAsync(workspaceName, apiName, versionName, definitionName, + requestOptions); + } +} diff --git a/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/ApiDefinitionsClient.java b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/ApiDefinitionsClient.java new file mode 100644 index 000000000000..d641ad5b0edf --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/ApiDefinitionsClient.java @@ -0,0 +1,355 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.apicenter; + +import com.azure.apicenter.implementation.ApiDefinitionsImpl; +import com.azure.apicenter.models.ApiDefinition; +import com.azure.apicenter.models.ApiSpecExportResult; +import com.azure.apicenter.models.ResourceOperationStatusApiSpecExportResultApiSpecExportResultError; +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.PollOperationDetails; +import com.azure.core.util.polling.SyncPoller; + +/** + * Initializes a new instance of the synchronous DataApiClient type. + */ +@ServiceClient(builder = DataApiClientBuilder.class) +public final class ApiDefinitionsClient { + @Generated + private final ApiDefinitionsImpl serviceClient; + + /** + * Initializes an instance of ApiDefinitionsClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ApiDefinitionsClient(ApiDefinitionsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * List a collection of API definitions. + *

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)
+     *     title: String (Required)
+     *     description: String (Optional)
+     *     specification (Optional): {
+     *         name: String (Required)
+     *         version: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param workspaceName Workspace identifier. + * @param apiName Api identifier. + * @param versionName Version identifier. + * @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 ApiDefinition items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listDefinitions(String workspaceName, String apiName, String versionName, + RequestOptions requestOptions) { + return this.serviceClient.listDefinitions(workspaceName, apiName, versionName, requestOptions); + } + + /** + * Get an API definition. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *     title: String (Required)
+     *     description: String (Optional)
+     *     specification (Optional): {
+     *         name: String (Required)
+     *         version: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param workspaceName Workspace identifier. + * @param apiName Api identifier. + * @param versionName Version identifier. + * @param definitionName Definition identifier. + * @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 an API definition along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getDefinitionWithResponse(String workspaceName, String apiName, String versionName, + String definitionName, RequestOptions requestOptions) { + return this.serviceClient.getDefinitionWithResponse(workspaceName, apiName, versionName, definitionName, + requestOptions); + } + + /** + * Gets status of a an API specification export operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     status: String(NotStarted/Running/Succeeded/Failed/Canceled) (Required)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *         innererror (Optional): {
+     *             code: String (Optional)
+     *             innererror (Optional): (recursive schema, see innererror above)
+     *         }
+     *     }
+     *     result (Optional): {
+     *         definitionName: String (Required)
+     *         value: String (Required)
+     *         format: String(link) (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param workspaceName Workspace identifier. + * @param apiName Api identifier. + * @param versionName Version identifier. + * @param definitionName API definition identifier. + * @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 an API specification export operation along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getExportSpecificationOperationStatusWithResponse(String workspaceName, String apiName, + String versionName, String definitionName, String operationId, RequestOptions requestOptions) { + return this.serviceClient.getExportSpecificationOperationStatusWithResponse(workspaceName, apiName, versionName, + definitionName, operationId, requestOptions); + } + + /** + * Export an API specification asynchronously. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     status: String(NotStarted/Running/Succeeded/Failed/Canceled) (Required)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *         innererror (Optional): {
+     *             code: String (Optional)
+     *             innererror (Optional): (recursive schema, see innererror above)
+     *         }
+     *     }
+     *     result (Optional): {
+     *         definitionName: String (Required)
+     *         value: String (Required)
+     *         format: String(link) (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param workspaceName Workspace identifier. + * @param apiName Api identifier. + * @param versionName Version identifier. + * @param definitionName API definition identifier. + * @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 beginExportSpecification(String workspaceName, String apiName, + String versionName, String definitionName, RequestOptions requestOptions) { + return this.serviceClient.beginExportSpecification(workspaceName, apiName, versionName, definitionName, + requestOptions); + } + + /** + * List a collection of API definitions. + * + * @param workspaceName Workspace identifier. + * @param apiName Api identifier. + * @param versionName Version identifier. + * @param top The number of result items to return. + * @param skip The number of result items to skip. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return paged collection of ApiDefinition items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listDefinitions(String workspaceName, String apiName, String versionName, + Integer top, Integer skip) { + // Generated convenience method for listDefinitions + RequestOptions requestOptions = new RequestOptions(); + if (top != null) { + requestOptions.addQueryParam("top", String.valueOf(top), false); + } + if (skip != null) { + requestOptions.addQueryParam("skip", String.valueOf(skip), false); + } + return serviceClient.listDefinitions(workspaceName, apiName, versionName, requestOptions) + .mapPage(bodyItemValue -> bodyItemValue.toObject(ApiDefinition.class)); + } + + /** + * List a collection of API definitions. + * + * @param workspaceName Workspace identifier. + * @param apiName Api identifier. + * @param versionName Version identifier. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return paged collection of ApiDefinition items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listDefinitions(String workspaceName, String apiName, String versionName) { + // Generated convenience method for listDefinitions + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.listDefinitions(workspaceName, apiName, versionName, requestOptions) + .mapPage(bodyItemValue -> bodyItemValue.toObject(ApiDefinition.class)); + } + + /** + * Get an API definition. + * + * @param workspaceName Workspace identifier. + * @param apiName Api identifier. + * @param versionName Version identifier. + * @param definitionName Definition identifier. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an API definition. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public ApiDefinition getDefinition(String workspaceName, String apiName, String versionName, + String definitionName) { + // Generated convenience method for getDefinitionWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getDefinitionWithResponse(workspaceName, apiName, versionName, definitionName, requestOptions).getValue() + .toObject(ApiDefinition.class); + } + + /** + * Gets status of a an API specification export operation. + * + * @param workspaceName Workspace identifier. + * @param apiName Api identifier. + * @param versionName Version identifier. + * @param definitionName API definition identifier. + * @param operationId The unique ID of the operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return status of a an API specification export operation. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public ResourceOperationStatusApiSpecExportResultApiSpecExportResultError getExportSpecificationOperationStatus( + String workspaceName, String apiName, String versionName, String definitionName, String operationId) { + // Generated convenience method for getExportSpecificationOperationStatusWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getExportSpecificationOperationStatusWithResponse(workspaceName, apiName, versionName, definitionName, + operationId, requestOptions).getValue() + .toObject(ResourceOperationStatusApiSpecExportResultApiSpecExportResultError.class); + } + + /** + * Export an API specification asynchronously. + * + * @param workspaceName Workspace identifier. + * @param apiName Api identifier. + * @param versionName Version identifier. + * @param definitionName API definition identifier. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of provides status details for long running operations. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginExportSpecification(String workspaceName, + String apiName, String versionName, String definitionName) { + // Generated convenience method for beginExportSpecificationWithModel + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.beginExportSpecificationWithModel(workspaceName, apiName, versionName, definitionName, + requestOptions); + } +} diff --git a/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/ApiDeploymentsAsyncClient.java b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/ApiDeploymentsAsyncClient.java new file mode 100644 index 000000000000..bd3926437a2d --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/ApiDeploymentsAsyncClient.java @@ -0,0 +1,231 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.apicenter; + +import com.azure.apicenter.implementation.ApiDeploymentsImpl; +import com.azure.apicenter.models.ApiDeployment; +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 java.util.stream.Collectors; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous DataApiClient type. + */ +@ServiceClient(builder = DataApiClientBuilder.class, isAsync = true) +public final class ApiDeploymentsAsyncClient { + @Generated + private final ApiDeploymentsImpl serviceClient; + + /** + * Initializes an instance of ApiDeploymentsAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ApiDeploymentsAsyncClient(ApiDeploymentsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * List a collection of API deployments. + *

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)
+     *     title: String (Required)
+     *     description: String (Optional)
+     *     environment: String (Required)
+     *     server (Required): {
+     *         runtimeUris (Required): [
+     *             String (Required)
+     *         ]
+     *     }
+     *     customProperties (Optional): {
+     *     }
+     *     recommended: Boolean (Optional)
+     * }
+     * }
+     * 
+ * + * @param workspaceName Workspace identifier. + * @param apiName Api identifier. + * @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 ApiDeployment items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listDeployments(String workspaceName, String apiName, RequestOptions requestOptions) { + return this.serviceClient.listDeploymentsAsync(workspaceName, apiName, requestOptions); + } + + /** + * Get an API deployment. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *     title: String (Required)
+     *     description: String (Optional)
+     *     environment: String (Required)
+     *     server (Required): {
+     *         runtimeUris (Required): [
+     *             String (Required)
+     *         ]
+     *     }
+     *     customProperties (Optional): {
+     *     }
+     *     recommended: Boolean (Optional)
+     * }
+     * }
+     * 
+ * + * @param workspaceName Workspace identifier. + * @param apiName Api identifier. + * @param deploymentName Deployment identifier. + * @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 an API deployment along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getDeploymentWithResponse(String workspaceName, String apiName, + String deploymentName, RequestOptions requestOptions) { + return this.serviceClient.getDeploymentWithResponseAsync(workspaceName, apiName, deploymentName, + requestOptions); + } + + /** + * List a collection of API deployments. + * + * @param workspaceName Workspace identifier. + * @param apiName Api identifier. + * @param top The number of result items to return. + * @param skip The number of result items to skip. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return paged collection of ApiDeployment items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listDeployments(String workspaceName, String apiName, Integer top, Integer skip) { + // Generated convenience method for listDeployments + RequestOptions requestOptions = new RequestOptions(); + if (top != null) { + requestOptions.addQueryParam("top", String.valueOf(top), false); + } + if (skip != null) { + requestOptions.addQueryParam("skip", String.valueOf(skip), false); + } + PagedFlux pagedFluxResponse = listDeployments(workspaceName, apiName, requestOptions); + return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> { + Flux> flux = (continuationTokenParam == null) + ? pagedFluxResponse.byPage().take(1) + : pagedFluxResponse.byPage(continuationTokenParam).take(1); + return flux.map(pagedResponse -> new PagedResponseBase(pagedResponse.getRequest(), + pagedResponse.getStatusCode(), pagedResponse.getHeaders(), + pagedResponse.getValue() + .stream() + .map(protocolMethodData -> protocolMethodData.toObject(ApiDeployment.class)) + .collect(Collectors.toList()), + pagedResponse.getContinuationToken(), null)); + }); + } + + /** + * List a collection of API deployments. + * + * @param workspaceName Workspace identifier. + * @param apiName Api identifier. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return paged collection of ApiDeployment items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listDeployments(String workspaceName, String apiName) { + // Generated convenience method for listDeployments + RequestOptions requestOptions = new RequestOptions(); + PagedFlux pagedFluxResponse = listDeployments(workspaceName, apiName, requestOptions); + return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> { + Flux> flux = (continuationTokenParam == null) + ? pagedFluxResponse.byPage().take(1) + : pagedFluxResponse.byPage(continuationTokenParam).take(1); + return flux.map(pagedResponse -> new PagedResponseBase(pagedResponse.getRequest(), + pagedResponse.getStatusCode(), pagedResponse.getHeaders(), + pagedResponse.getValue() + .stream() + .map(protocolMethodData -> protocolMethodData.toObject(ApiDeployment.class)) + .collect(Collectors.toList()), + pagedResponse.getContinuationToken(), null)); + }); + } + + /** + * Get an API deployment. + * + * @param workspaceName Workspace identifier. + * @param apiName Api identifier. + * @param deploymentName Deployment identifier. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an API deployment on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getDeployment(String workspaceName, String apiName, String deploymentName) { + // Generated convenience method for getDeploymentWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getDeploymentWithResponse(workspaceName, apiName, deploymentName, requestOptions) + .flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(ApiDeployment.class)); + } +} diff --git a/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/ApiDeploymentsClient.java b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/ApiDeploymentsClient.java new file mode 100644 index 000000000000..e0f418a8497e --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/ApiDeploymentsClient.java @@ -0,0 +1,203 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.apicenter; + +import com.azure.apicenter.implementation.ApiDeploymentsImpl; +import com.azure.apicenter.models.ApiDeployment; +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; + +/** + * Initializes a new instance of the synchronous DataApiClient type. + */ +@ServiceClient(builder = DataApiClientBuilder.class) +public final class ApiDeploymentsClient { + @Generated + private final ApiDeploymentsImpl serviceClient; + + /** + * Initializes an instance of ApiDeploymentsClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ApiDeploymentsClient(ApiDeploymentsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * List a collection of API deployments. + *

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)
+     *     title: String (Required)
+     *     description: String (Optional)
+     *     environment: String (Required)
+     *     server (Required): {
+     *         runtimeUris (Required): [
+     *             String (Required)
+     *         ]
+     *     }
+     *     customProperties (Optional): {
+     *     }
+     *     recommended: Boolean (Optional)
+     * }
+     * }
+     * 
+ * + * @param workspaceName Workspace identifier. + * @param apiName Api identifier. + * @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 ApiDeployment items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listDeployments(String workspaceName, String apiName, + RequestOptions requestOptions) { + return this.serviceClient.listDeployments(workspaceName, apiName, requestOptions); + } + + /** + * Get an API deployment. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *     title: String (Required)
+     *     description: String (Optional)
+     *     environment: String (Required)
+     *     server (Required): {
+     *         runtimeUris (Required): [
+     *             String (Required)
+     *         ]
+     *     }
+     *     customProperties (Optional): {
+     *     }
+     *     recommended: Boolean (Optional)
+     * }
+     * }
+     * 
+ * + * @param workspaceName Workspace identifier. + * @param apiName Api identifier. + * @param deploymentName Deployment identifier. + * @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 an API deployment along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getDeploymentWithResponse(String workspaceName, String apiName, String deploymentName, + RequestOptions requestOptions) { + return this.serviceClient.getDeploymentWithResponse(workspaceName, apiName, deploymentName, requestOptions); + } + + /** + * List a collection of API deployments. + * + * @param workspaceName Workspace identifier. + * @param apiName Api identifier. + * @param top The number of result items to return. + * @param skip The number of result items to skip. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return paged collection of ApiDeployment items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listDeployments(String workspaceName, String apiName, Integer top, + Integer skip) { + // Generated convenience method for listDeployments + RequestOptions requestOptions = new RequestOptions(); + if (top != null) { + requestOptions.addQueryParam("top", String.valueOf(top), false); + } + if (skip != null) { + requestOptions.addQueryParam("skip", String.valueOf(skip), false); + } + return serviceClient.listDeployments(workspaceName, apiName, requestOptions) + .mapPage(bodyItemValue -> bodyItemValue.toObject(ApiDeployment.class)); + } + + /** + * List a collection of API deployments. + * + * @param workspaceName Workspace identifier. + * @param apiName Api identifier. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return paged collection of ApiDeployment items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listDeployments(String workspaceName, String apiName) { + // Generated convenience method for listDeployments + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.listDeployments(workspaceName, apiName, requestOptions) + .mapPage(bodyItemValue -> bodyItemValue.toObject(ApiDeployment.class)); + } + + /** + * Get an API deployment. + * + * @param workspaceName Workspace identifier. + * @param apiName Api identifier. + * @param deploymentName Deployment identifier. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an API deployment. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public ApiDeployment getDeployment(String workspaceName, String apiName, String deploymentName) { + // Generated convenience method for getDeploymentWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getDeploymentWithResponse(workspaceName, apiName, deploymentName, requestOptions).getValue() + .toObject(ApiDeployment.class); + } +} diff --git a/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/ApiVersionsAsyncClient.java b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/ApiVersionsAsyncClient.java new file mode 100644 index 000000000000..9a64678e4fc3 --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/ApiVersionsAsyncClient.java @@ -0,0 +1,211 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.apicenter; + +import com.azure.apicenter.implementation.ApiVersionsImpl; +import com.azure.apicenter.models.ApiVersion; +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 java.util.stream.Collectors; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous DataApiClient type. + */ +@ServiceClient(builder = DataApiClientBuilder.class, isAsync = true) +public final class ApiVersionsAsyncClient { + @Generated + private final ApiVersionsImpl serviceClient; + + /** + * Initializes an instance of ApiVersionsAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ApiVersionsAsyncClient(ApiVersionsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * List a collection of API versions. + *

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)
+     *     title: String (Required)
+     *     lifecycleStage: String(design/development/testing/preview/production/deprecated/retired) (Required)
+     * }
+     * }
+     * 
+ * + * @param workspaceName Workspace identifier. + * @param apiName Api identifier. + * @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 ApiVersion items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listVersions(String workspaceName, String apiName, RequestOptions requestOptions) { + return this.serviceClient.listVersionsAsync(workspaceName, apiName, requestOptions); + } + + /** + * Get an API version. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *     title: String (Required)
+     *     lifecycleStage: String(design/development/testing/preview/production/deprecated/retired) (Required)
+     * }
+     * }
+     * 
+ * + * @param workspaceName Workspace identifier. + * @param apiName Api identifier. + * @param versionName Version identifier. + * @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 an API version along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getVersionWithResponse(String workspaceName, String apiName, String versionName, + RequestOptions requestOptions) { + return this.serviceClient.getVersionWithResponseAsync(workspaceName, apiName, versionName, requestOptions); + } + + /** + * List a collection of API versions. + * + * @param workspaceName Workspace identifier. + * @param apiName Api identifier. + * @param top The number of result items to return. + * @param skip The number of result items to skip. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return paged collection of ApiVersion items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listVersions(String workspaceName, String apiName, Integer top, Integer skip) { + // Generated convenience method for listVersions + RequestOptions requestOptions = new RequestOptions(); + if (top != null) { + requestOptions.addQueryParam("top", String.valueOf(top), false); + } + if (skip != null) { + requestOptions.addQueryParam("skip", String.valueOf(skip), false); + } + PagedFlux pagedFluxResponse = listVersions(workspaceName, apiName, requestOptions); + return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> { + Flux> flux = (continuationTokenParam == null) + ? pagedFluxResponse.byPage().take(1) + : pagedFluxResponse.byPage(continuationTokenParam).take(1); + return flux.map(pagedResponse -> new PagedResponseBase(pagedResponse.getRequest(), + pagedResponse.getStatusCode(), pagedResponse.getHeaders(), + pagedResponse.getValue() + .stream() + .map(protocolMethodData -> protocolMethodData.toObject(ApiVersion.class)) + .collect(Collectors.toList()), + pagedResponse.getContinuationToken(), null)); + }); + } + + /** + * List a collection of API versions. + * + * @param workspaceName Workspace identifier. + * @param apiName Api identifier. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return paged collection of ApiVersion items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listVersions(String workspaceName, String apiName) { + // Generated convenience method for listVersions + RequestOptions requestOptions = new RequestOptions(); + PagedFlux pagedFluxResponse = listVersions(workspaceName, apiName, requestOptions); + return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> { + Flux> flux = (continuationTokenParam == null) + ? pagedFluxResponse.byPage().take(1) + : pagedFluxResponse.byPage(continuationTokenParam).take(1); + return flux.map(pagedResponse -> new PagedResponseBase(pagedResponse.getRequest(), + pagedResponse.getStatusCode(), pagedResponse.getHeaders(), + pagedResponse.getValue() + .stream() + .map(protocolMethodData -> protocolMethodData.toObject(ApiVersion.class)) + .collect(Collectors.toList()), + pagedResponse.getContinuationToken(), null)); + }); + } + + /** + * Get an API version. + * + * @param workspaceName Workspace identifier. + * @param apiName Api identifier. + * @param versionName Version identifier. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an API version on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getVersion(String workspaceName, String apiName, String versionName) { + // Generated convenience method for getVersionWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getVersionWithResponse(workspaceName, apiName, versionName, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(ApiVersion.class)); + } +} diff --git a/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/ApiVersionsClient.java b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/ApiVersionsClient.java new file mode 100644 index 000000000000..91c4c4405558 --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/ApiVersionsClient.java @@ -0,0 +1,183 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.apicenter; + +import com.azure.apicenter.implementation.ApiVersionsImpl; +import com.azure.apicenter.models.ApiVersion; +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; + +/** + * Initializes a new instance of the synchronous DataApiClient type. + */ +@ServiceClient(builder = DataApiClientBuilder.class) +public final class ApiVersionsClient { + @Generated + private final ApiVersionsImpl serviceClient; + + /** + * Initializes an instance of ApiVersionsClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ApiVersionsClient(ApiVersionsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * List a collection of API versions. + *

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)
+     *     title: String (Required)
+     *     lifecycleStage: String(design/development/testing/preview/production/deprecated/retired) (Required)
+     * }
+     * }
+     * 
+ * + * @param workspaceName Workspace identifier. + * @param apiName Api identifier. + * @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 ApiVersion items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listVersions(String workspaceName, String apiName, RequestOptions requestOptions) { + return this.serviceClient.listVersions(workspaceName, apiName, requestOptions); + } + + /** + * Get an API version. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *     title: String (Required)
+     *     lifecycleStage: String(design/development/testing/preview/production/deprecated/retired) (Required)
+     * }
+     * }
+     * 
+ * + * @param workspaceName Workspace identifier. + * @param apiName Api identifier. + * @param versionName Version identifier. + * @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 an API version along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getVersionWithResponse(String workspaceName, String apiName, String versionName, + RequestOptions requestOptions) { + return this.serviceClient.getVersionWithResponse(workspaceName, apiName, versionName, requestOptions); + } + + /** + * List a collection of API versions. + * + * @param workspaceName Workspace identifier. + * @param apiName Api identifier. + * @param top The number of result items to return. + * @param skip The number of result items to skip. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return paged collection of ApiVersion items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listVersions(String workspaceName, String apiName, Integer top, Integer skip) { + // Generated convenience method for listVersions + RequestOptions requestOptions = new RequestOptions(); + if (top != null) { + requestOptions.addQueryParam("top", String.valueOf(top), false); + } + if (skip != null) { + requestOptions.addQueryParam("skip", String.valueOf(skip), false); + } + return serviceClient.listVersions(workspaceName, apiName, requestOptions) + .mapPage(bodyItemValue -> bodyItemValue.toObject(ApiVersion.class)); + } + + /** + * List a collection of API versions. + * + * @param workspaceName Workspace identifier. + * @param apiName Api identifier. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return paged collection of ApiVersion items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listVersions(String workspaceName, String apiName) { + // Generated convenience method for listVersions + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.listVersions(workspaceName, apiName, requestOptions) + .mapPage(bodyItemValue -> bodyItemValue.toObject(ApiVersion.class)); + } + + /** + * Get an API version. + * + * @param workspaceName Workspace identifier. + * @param apiName Api identifier. + * @param versionName Version identifier. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an API version. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public ApiVersion getVersion(String workspaceName, String apiName, String versionName) { + // Generated convenience method for getVersionWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getVersionWithResponse(workspaceName, apiName, versionName, requestOptions).getValue() + .toObject(ApiVersion.class); + } +} diff --git a/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/ApisAsyncClient.java b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/ApisAsyncClient.java new file mode 100644 index 000000000000..a0a390deeb81 --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/ApisAsyncClient.java @@ -0,0 +1,384 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.apicenter; + +import com.azure.apicenter.implementation.ApisImpl; +import com.azure.apicenter.models.Api; +import com.azure.apicenter.models.PagedApiAll; +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 java.util.stream.Collectors; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous DataApiClient type. + */ +@ServiceClient(builder = DataApiClientBuilder.class, isAsync = true) +public final class ApisAsyncClient { + @Generated + private final ApisImpl serviceClient; + + /** + * Initializes an instance of ApisAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ApisAsyncClient(ApisImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * List a collection of APIs. + *

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)
+     *     title: String (Required)
+     *     summary: String (Optional)
+     *     description: String (Optional)
+     *     kind: String(rest/graphql/grpc/soap/webhook/websocket) (Required)
+     *     lifecycleStage: String(design/development/testing/preview/production/deprecated/retired) (Optional)
+     *     termsOfService (Optional): {
+     *         url: String (Required)
+     *     }
+     *     license (Optional): {
+     *         name: String (Required)
+     *         url: String (Optional)
+     *         identifier: String (Optional)
+     *     }
+     *     externalDocumentation (Optional): [
+     *          (Optional){
+     *             title: String (Required)
+     *             description: String (Required)
+     *             url: String (Required)
+     *         }
+     *     ]
+     *     contacts (Optional): [
+     *          (Optional){
+     *             name: String (Required)
+     *             url: String (Optional)
+     *             email: String (Optional)
+     *         }
+     *     ]
+     *     customProperties (Optional): {
+     *     }
+     *     lastUpdated: OffsetDateTime (Optional)
+     * }
+     * }
+     * 
+ * + * @param workspaceName Workspace identifier. + * @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 Api items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux list(String workspaceName, RequestOptions requestOptions) { + return this.serviceClient.listAsync(workspaceName, requestOptions); + } + + /** + * List a collection of APIs across workspaces. + *

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
+     * {
+     *     value (Required): [
+     *          (Required){
+     *             name: String (Required)
+     *             title: String (Required)
+     *             summary: String (Optional)
+     *             description: String (Optional)
+     *             kind: String(rest/graphql/grpc/soap/webhook/websocket) (Required)
+     *             lifecycleStage: String(design/development/testing/preview/production/deprecated/retired) (Optional)
+     *             termsOfService (Optional): {
+     *                 url: String (Required)
+     *             }
+     *             license (Optional): {
+     *                 name: String (Required)
+     *                 url: String (Optional)
+     *                 identifier: String (Optional)
+     *             }
+     *             externalDocumentation (Optional): [
+     *                  (Optional){
+     *                     title: String (Required)
+     *                     description: String (Required)
+     *                     url: String (Required)
+     *                 }
+     *             ]
+     *             contacts (Optional): [
+     *                  (Optional){
+     *                     name: String (Required)
+     *                     url: String (Optional)
+     *                     email: String (Optional)
+     *                 }
+     *             ]
+     *             customProperties (Optional): {
+     *             }
+     *             lastUpdated: OffsetDateTime (Optional)
+     *         }
+     *     ]
+     *     nextLink: String (Optional)
+     * }
+     * }
+     * 
+ * + * @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 API items across workspaces along with {@link Response} on successful completion of + * {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> listAllWithResponse(RequestOptions requestOptions) { + return this.serviceClient.listAllWithResponseAsync(requestOptions); + } + + /** + * Get an API. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *     title: String (Required)
+     *     summary: String (Optional)
+     *     description: String (Optional)
+     *     kind: String(rest/graphql/grpc/soap/webhook/websocket) (Required)
+     *     lifecycleStage: String(design/development/testing/preview/production/deprecated/retired) (Optional)
+     *     termsOfService (Optional): {
+     *         url: String (Required)
+     *     }
+     *     license (Optional): {
+     *         name: String (Required)
+     *         url: String (Optional)
+     *         identifier: String (Optional)
+     *     }
+     *     externalDocumentation (Optional): [
+     *          (Optional){
+     *             title: String (Required)
+     *             description: String (Required)
+     *             url: String (Required)
+     *         }
+     *     ]
+     *     contacts (Optional): [
+     *          (Optional){
+     *             name: String (Required)
+     *             url: String (Optional)
+     *             email: String (Optional)
+     *         }
+     *     ]
+     *     customProperties (Optional): {
+     *     }
+     *     lastUpdated: OffsetDateTime (Optional)
+     * }
+     * }
+     * 
+ * + * @param workspaceName Workspace identifier. + * @param apiName Api identifier. + * @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 an API along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(String workspaceName, String apiName, + RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(workspaceName, apiName, requestOptions); + } + + /** + * List a collection of APIs. + * + * @param workspaceName Workspace identifier. + * @param top The number of result items to return. + * @param skip The number of result items to skip. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return paged collection of Api items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux list(String workspaceName, Integer top, Integer skip) { + // Generated convenience method for list + RequestOptions requestOptions = new RequestOptions(); + if (top != null) { + requestOptions.addQueryParam("top", String.valueOf(top), false); + } + if (skip != null) { + requestOptions.addQueryParam("skip", String.valueOf(skip), false); + } + PagedFlux pagedFluxResponse = list(workspaceName, requestOptions); + return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> { + Flux> flux = (continuationTokenParam == null) + ? pagedFluxResponse.byPage().take(1) + : pagedFluxResponse.byPage(continuationTokenParam).take(1); + return flux.map(pagedResponse -> new PagedResponseBase(pagedResponse.getRequest(), + pagedResponse.getStatusCode(), pagedResponse.getHeaders(), + pagedResponse.getValue() + .stream() + .map(protocolMethodData -> protocolMethodData.toObject(Api.class)) + .collect(Collectors.toList()), + pagedResponse.getContinuationToken(), null)); + }); + } + + /** + * List a collection of APIs. + * + * @param workspaceName Workspace identifier. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return paged collection of Api items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux list(String workspaceName) { + // Generated convenience method for list + RequestOptions requestOptions = new RequestOptions(); + PagedFlux pagedFluxResponse = list(workspaceName, requestOptions); + return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> { + Flux> flux = (continuationTokenParam == null) + ? pagedFluxResponse.byPage().take(1) + : pagedFluxResponse.byPage(continuationTokenParam).take(1); + return flux.map(pagedResponse -> new PagedResponseBase(pagedResponse.getRequest(), + pagedResponse.getStatusCode(), pagedResponse.getHeaders(), + pagedResponse.getValue() + .stream() + .map(protocolMethodData -> protocolMethodData.toObject(Api.class)) + .collect(Collectors.toList()), + pagedResponse.getContinuationToken(), null)); + }); + } + + /** + * List a collection of APIs across workspaces. + * + * @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 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 API items across workspaces on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono listAll(Integer top, Integer skip, Integer maxPageSize) { + // Generated convenience method for listAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (top != null) { + requestOptions.addQueryParam("top", String.valueOf(top), false); + } + if (skip != null) { + requestOptions.addQueryParam("skip", String.valueOf(skip), false); + } + if (maxPageSize != null) { + requestOptions.addQueryParam("maxpagesize", String.valueOf(maxPageSize), false); + } + return listAllWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(PagedApiAll.class)); + } + + /** + * List a collection of APIs across workspaces. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return paged collection of API items across workspaces on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono listAll() { + // Generated convenience method for listAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + return listAllWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(PagedApiAll.class)); + } + + /** + * Get an API. + * + * @param workspaceName Workspace identifier. + * @param apiName Api identifier. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an API on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get(String workspaceName, String apiName) { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(workspaceName, apiName, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Api.class)); + } +} diff --git a/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/ApisClient.java b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/ApisClient.java new file mode 100644 index 000000000000..5dfd0fa3fa0e --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/ApisClient.java @@ -0,0 +1,351 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.apicenter; + +import com.azure.apicenter.implementation.ApisImpl; +import com.azure.apicenter.models.Api; +import com.azure.apicenter.models.PagedApiAll; +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; + +/** + * Initializes a new instance of the synchronous DataApiClient type. + */ +@ServiceClient(builder = DataApiClientBuilder.class) +public final class ApisClient { + @Generated + private final ApisImpl serviceClient; + + /** + * Initializes an instance of ApisClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ApisClient(ApisImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * List a collection of APIs. + *

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)
+     *     title: String (Required)
+     *     summary: String (Optional)
+     *     description: String (Optional)
+     *     kind: String(rest/graphql/grpc/soap/webhook/websocket) (Required)
+     *     lifecycleStage: String(design/development/testing/preview/production/deprecated/retired) (Optional)
+     *     termsOfService (Optional): {
+     *         url: String (Required)
+     *     }
+     *     license (Optional): {
+     *         name: String (Required)
+     *         url: String (Optional)
+     *         identifier: String (Optional)
+     *     }
+     *     externalDocumentation (Optional): [
+     *          (Optional){
+     *             title: String (Required)
+     *             description: String (Required)
+     *             url: String (Required)
+     *         }
+     *     ]
+     *     contacts (Optional): [
+     *          (Optional){
+     *             name: String (Required)
+     *             url: String (Optional)
+     *             email: String (Optional)
+     *         }
+     *     ]
+     *     customProperties (Optional): {
+     *     }
+     *     lastUpdated: OffsetDateTime (Optional)
+     * }
+     * }
+     * 
+ * + * @param workspaceName Workspace identifier. + * @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 Api items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(String workspaceName, RequestOptions requestOptions) { + return this.serviceClient.list(workspaceName, requestOptions); + } + + /** + * List a collection of APIs across workspaces. + *

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
+     * {
+     *     value (Required): [
+     *          (Required){
+     *             name: String (Required)
+     *             title: String (Required)
+     *             summary: String (Optional)
+     *             description: String (Optional)
+     *             kind: String(rest/graphql/grpc/soap/webhook/websocket) (Required)
+     *             lifecycleStage: String(design/development/testing/preview/production/deprecated/retired) (Optional)
+     *             termsOfService (Optional): {
+     *                 url: String (Required)
+     *             }
+     *             license (Optional): {
+     *                 name: String (Required)
+     *                 url: String (Optional)
+     *                 identifier: String (Optional)
+     *             }
+     *             externalDocumentation (Optional): [
+     *                  (Optional){
+     *                     title: String (Required)
+     *                     description: String (Required)
+     *                     url: String (Required)
+     *                 }
+     *             ]
+     *             contacts (Optional): [
+     *                  (Optional){
+     *                     name: String (Required)
+     *                     url: String (Optional)
+     *                     email: String (Optional)
+     *                 }
+     *             ]
+     *             customProperties (Optional): {
+     *             }
+     *             lastUpdated: OffsetDateTime (Optional)
+     *         }
+     *     ]
+     *     nextLink: String (Optional)
+     * }
+     * }
+     * 
+ * + * @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 API items across workspaces along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response listAllWithResponse(RequestOptions requestOptions) { + return this.serviceClient.listAllWithResponse(requestOptions); + } + + /** + * Get an API. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *     title: String (Required)
+     *     summary: String (Optional)
+     *     description: String (Optional)
+     *     kind: String(rest/graphql/grpc/soap/webhook/websocket) (Required)
+     *     lifecycleStage: String(design/development/testing/preview/production/deprecated/retired) (Optional)
+     *     termsOfService (Optional): {
+     *         url: String (Required)
+     *     }
+     *     license (Optional): {
+     *         name: String (Required)
+     *         url: String (Optional)
+     *         identifier: String (Optional)
+     *     }
+     *     externalDocumentation (Optional): [
+     *          (Optional){
+     *             title: String (Required)
+     *             description: String (Required)
+     *             url: String (Required)
+     *         }
+     *     ]
+     *     contacts (Optional): [
+     *          (Optional){
+     *             name: String (Required)
+     *             url: String (Optional)
+     *             email: String (Optional)
+     *         }
+     *     ]
+     *     customProperties (Optional): {
+     *     }
+     *     lastUpdated: OffsetDateTime (Optional)
+     * }
+     * }
+     * 
+ * + * @param workspaceName Workspace identifier. + * @param apiName Api identifier. + * @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 an API along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(String workspaceName, String apiName, RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(workspaceName, apiName, requestOptions); + } + + /** + * List a collection of APIs. + * + * @param workspaceName Workspace identifier. + * @param top The number of result items to return. + * @param skip The number of result items to skip. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return paged collection of Api items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(String workspaceName, Integer top, Integer skip) { + // Generated convenience method for list + RequestOptions requestOptions = new RequestOptions(); + if (top != null) { + requestOptions.addQueryParam("top", String.valueOf(top), false); + } + if (skip != null) { + requestOptions.addQueryParam("skip", String.valueOf(skip), false); + } + return serviceClient.list(workspaceName, requestOptions) + .mapPage(bodyItemValue -> bodyItemValue.toObject(Api.class)); + } + + /** + * List a collection of APIs. + * + * @param workspaceName Workspace identifier. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return paged collection of Api items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(String workspaceName) { + // Generated convenience method for list + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.list(workspaceName, requestOptions) + .mapPage(bodyItemValue -> bodyItemValue.toObject(Api.class)); + } + + /** + * List a collection of APIs across workspaces. + * + * @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 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 API items across workspaces. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public PagedApiAll listAll(Integer top, Integer skip, Integer maxPageSize) { + // Generated convenience method for listAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (top != null) { + requestOptions.addQueryParam("top", String.valueOf(top), false); + } + if (skip != null) { + requestOptions.addQueryParam("skip", String.valueOf(skip), false); + } + if (maxPageSize != null) { + requestOptions.addQueryParam("maxpagesize", String.valueOf(maxPageSize), false); + } + return listAllWithResponse(requestOptions).getValue().toObject(PagedApiAll.class); + } + + /** + * List a collection of APIs across workspaces. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return paged collection of API items across workspaces. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public PagedApiAll listAll() { + // Generated convenience method for listAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + return listAllWithResponse(requestOptions).getValue().toObject(PagedApiAll.class); + } + + /** + * Get an API. + * + * @param workspaceName Workspace identifier. + * @param apiName Api identifier. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an API. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Api get(String workspaceName, String apiName) { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(workspaceName, apiName, requestOptions).getValue().toObject(Api.class); + } +} diff --git a/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/DataApiClientBuilder.java b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/DataApiClientBuilder.java new file mode 100644 index 000000000000..42bbacd624b3 --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/DataApiClientBuilder.java @@ -0,0 +1,443 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.apicenter; + +import com.azure.apicenter.implementation.DataApiClientImpl; +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.HttpTrait; +import com.azure.core.client.traits.TokenCredentialTrait; +import com.azure.core.credential.TokenCredential; +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.BearerTokenAuthenticationPolicy; +import com.azure.core.http.policy.HttpLogOptions; +import com.azure.core.http.policy.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpPipelinePolicy; +import com.azure.core.http.policy.HttpPolicyProviders; +import com.azure.core.http.policy.RequestIdPolicy; +import com.azure.core.http.policy.RetryOptions; +import com.azure.core.http.policy.RetryPolicy; +import com.azure.core.http.policy.UserAgentPolicy; +import com.azure.core.util.ClientOptions; +import com.azure.core.util.Configuration; +import com.azure.core.util.CoreUtils; +import com.azure.core.util.builder.ClientBuilderUtil; +import com.azure.core.util.logging.ClientLogger; +import com.azure.core.util.serializer.JacksonAdapter; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the DataApiClient type. + */ +@ServiceClientBuilder( + serviceClients = { + ApisClient.class, + ApiDefinitionsClient.class, + ApiDeploymentsClient.class, + EnvironmentsClient.class, + ApiVersionsClient.class, + ApisAsyncClient.class, + ApiDefinitionsAsyncClient.class, + ApiDeploymentsAsyncClient.class, + EnvironmentsAsyncClient.class, + ApiVersionsAsyncClient.class }) +public final class DataApiClientBuilder implements HttpTrait, + ConfigurationTrait, TokenCredentialTrait { + @Generated + private static final String SDK_NAME = "name"; + + @Generated + private static final String SDK_VERSION = "version"; + + @Generated + private static final String[] DEFAULT_SCOPES = new String[] { "https://azure-apicenter.net/user_impersonation" }; + + @Generated + private static final Map PROPERTIES = CoreUtils.getProperties("azure-apicenter.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the DataApiClientBuilder. + */ + @Generated + public DataApiClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public DataApiClientBuilder pipeline(HttpPipeline pipeline) { + if (this.pipeline != null && pipeline == null) { + LOGGER.atInfo().log("HttpPipeline is being set to 'null' when it was previously configured."); + } + this.pipeline = pipeline; + return this; + } + + /* + * The HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public DataApiClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public DataApiClientBuilder 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 DataApiClientBuilder 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 DataApiClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public DataApiClientBuilder 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 DataApiClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The TokenCredential used for authentication. + */ + @Generated + private TokenCredential tokenCredential; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public DataApiClientBuilder credential(TokenCredential tokenCredential) { + this.tokenCredential = tokenCredential; + return this; + } + + /* + * Region-unique API Center service name + */ + @Generated + private String serviceName; + + /** + * Sets Region-unique API Center service name. + * + * @param serviceName the serviceName value. + * @return the DataApiClientBuilder. + */ + @Generated + public DataApiClientBuilder serviceName(String serviceName) { + this.serviceName = serviceName; + return this; + } + + /* + * Region name + */ + @Generated + private String region; + + /** + * Sets Region name. + * + * @param region the region value. + * @return the DataApiClientBuilder. + */ + @Generated + public DataApiClientBuilder region(String region) { + this.region = region; + return this; + } + + /* + * Service version + */ + @Generated + private DataApiServiceVersion serviceVersion; + + /** + * Sets Service version. + * + * @param serviceVersion the serviceVersion value. + * @return the DataApiClientBuilder. + */ + @Generated + public DataApiClientBuilder serviceVersion(DataApiServiceVersion 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 DataApiClientBuilder. + */ + @Generated + public DataApiClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of DataApiClientImpl with the provided parameters. + * + * @return an instance of DataApiClientImpl. + */ + @Generated + private DataApiClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + DataApiServiceVersion localServiceVersion + = (serviceVersion != null) ? serviceVersion : DataApiServiceVersion.getLatest(); + DataApiClientImpl client = new DataApiClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), + this.serviceName, this.region, localServiceVersion); + return client; + } + + @Generated + private void validateClient() { + // This method is invoked from 'buildInnerClient'/'buildClient' method. + // Developer can customize this method, to validate that the necessary conditions are met for the new client. + Objects.requireNonNull(serviceName, "'serviceName' cannot be null."); + Objects.requireNonNull(region, "'region' cannot be null."); + } + + @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 = CoreUtils.createHttpHeadersFromClientOptions(localClientOptions); + if (headers != null) { + policies.add(new AddHeadersPolicy(headers)); + } + this.pipelinePolicies.stream() + .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_CALL) + .forEach(p -> policies.add(p)); + HttpPolicyProviders.addBeforeRetryPolicies(policies); + policies.add(ClientBuilderUtil.validateAndGetRetryPolicy(retryPolicy, retryOptions, new RetryPolicy())); + policies.add(new AddDatePolicy()); + if (tokenCredential != null) { + policies.add(new BearerTokenAuthenticationPolicy(tokenCredential, DEFAULT_SCOPES)); + } + this.pipelinePolicies.stream() + .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_RETRY) + .forEach(p -> policies.add(p)); + HttpPolicyProviders.addAfterRetryPolicies(policies); + policies.add(new HttpLoggingPolicy(localHttpLogOptions)); + HttpPipeline httpPipeline = new HttpPipelineBuilder().policies(policies.toArray(new HttpPipelinePolicy[0])) + .httpClient(httpClient) + .clientOptions(localClientOptions) + .build(); + return httpPipeline; + } + + /** + * Builds an instance of ApisAsyncClient class. + * + * @return an instance of ApisAsyncClient. + */ + @Generated + public ApisAsyncClient buildApisAsyncClient() { + return new ApisAsyncClient(buildInnerClient().getApis()); + } + + /** + * Builds an instance of ApiDefinitionsAsyncClient class. + * + * @return an instance of ApiDefinitionsAsyncClient. + */ + @Generated + public ApiDefinitionsAsyncClient buildApiDefinitionsAsyncClient() { + return new ApiDefinitionsAsyncClient(buildInnerClient().getApiDefinitions()); + } + + /** + * Builds an instance of ApiDeploymentsAsyncClient class. + * + * @return an instance of ApiDeploymentsAsyncClient. + */ + @Generated + public ApiDeploymentsAsyncClient buildApiDeploymentsAsyncClient() { + return new ApiDeploymentsAsyncClient(buildInnerClient().getApiDeployments()); + } + + /** + * Builds an instance of EnvironmentsAsyncClient class. + * + * @return an instance of EnvironmentsAsyncClient. + */ + @Generated + public EnvironmentsAsyncClient buildEnvironmentsAsyncClient() { + return new EnvironmentsAsyncClient(buildInnerClient().getEnvironments()); + } + + /** + * Builds an instance of ApiVersionsAsyncClient class. + * + * @return an instance of ApiVersionsAsyncClient. + */ + @Generated + public ApiVersionsAsyncClient buildApiVersionsAsyncClient() { + return new ApiVersionsAsyncClient(buildInnerClient().getApiVersions()); + } + + /** + * Builds an instance of ApisClient class. + * + * @return an instance of ApisClient. + */ + @Generated + public ApisClient buildApisClient() { + return new ApisClient(buildInnerClient().getApis()); + } + + /** + * Builds an instance of ApiDefinitionsClient class. + * + * @return an instance of ApiDefinitionsClient. + */ + @Generated + public ApiDefinitionsClient buildApiDefinitionsClient() { + return new ApiDefinitionsClient(buildInnerClient().getApiDefinitions()); + } + + /** + * Builds an instance of ApiDeploymentsClient class. + * + * @return an instance of ApiDeploymentsClient. + */ + @Generated + public ApiDeploymentsClient buildApiDeploymentsClient() { + return new ApiDeploymentsClient(buildInnerClient().getApiDeployments()); + } + + /** + * Builds an instance of EnvironmentsClient class. + * + * @return an instance of EnvironmentsClient. + */ + @Generated + public EnvironmentsClient buildEnvironmentsClient() { + return new EnvironmentsClient(buildInnerClient().getEnvironments()); + } + + /** + * Builds an instance of ApiVersionsClient class. + * + * @return an instance of ApiVersionsClient. + */ + @Generated + public ApiVersionsClient buildApiVersionsClient() { + return new ApiVersionsClient(buildInnerClient().getApiVersions()); + } + + private static final ClientLogger LOGGER = new ClientLogger(DataApiClientBuilder.class); +} diff --git a/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/DataApiServiceVersion.java b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/DataApiServiceVersion.java new file mode 100644 index 000000000000..9adfc8c14b15 --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/DataApiServiceVersion.java @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.apicenter; + +import com.azure.core.util.ServiceVersion; + +/** + * Service version of DataApiClient. + */ +public enum DataApiServiceVersion implements ServiceVersion { + /** + * Enum value 2024-02-01-preview. + */ + V2024_02_01_PREVIEW("2024-02-01-preview"); + + private final String version; + + DataApiServiceVersion(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 DataApiServiceVersion}. + */ + public static DataApiServiceVersion getLatest() { + return V2024_02_01_PREVIEW; + } +} diff --git a/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/EnvironmentsAsyncClient.java b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/EnvironmentsAsyncClient.java new file mode 100644 index 000000000000..16f64bdbf628 --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/EnvironmentsAsyncClient.java @@ -0,0 +1,345 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.apicenter; + +import com.azure.apicenter.implementation.EnvironmentsImpl; +import com.azure.apicenter.models.Environment; +import com.azure.apicenter.models.PagedEnvironmentAll; +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 java.util.stream.Collectors; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous DataApiClient type. + */ +@ServiceClient(builder = DataApiClientBuilder.class, isAsync = true) +public final class EnvironmentsAsyncClient { + @Generated + private final EnvironmentsImpl serviceClient; + + /** + * Initializes an instance of EnvironmentsAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + EnvironmentsAsyncClient(EnvironmentsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * List a collection of environments. + *

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)
+     *     title: String (Required)
+     *     kind: String(development/testing/staging/production) (Required)
+     *     description: String (Optional)
+     *     server (Optional): {
+     *         type: String (Required)
+     *         managementPortalUris (Required): [
+     *             String (Required)
+     *         ]
+     *     }
+     *     onboarding (Optional): {
+     *         instructions: String (Required)
+     *         developerPortalUris (Required): [
+     *             String (Required)
+     *         ]
+     *     }
+     *     customProperties (Optional): {
+     *     }
+     * }
+     * }
+     * 
+ * + * @param workspaceName Workspace identifier. + * @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 Environment items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux list(String workspaceName, RequestOptions requestOptions) { + return this.serviceClient.listAsync(workspaceName, requestOptions); + } + + /** + * List a collection of environments across workspaces. + *

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
+     * {
+     *     value (Required): [
+     *          (Required){
+     *             name: String (Required)
+     *             title: String (Required)
+     *             kind: String(development/testing/staging/production) (Required)
+     *             description: String (Optional)
+     *             server (Optional): {
+     *                 type: String (Required)
+     *                 managementPortalUris (Required): [
+     *                     String (Required)
+     *                 ]
+     *             }
+     *             onboarding (Optional): {
+     *                 instructions: String (Required)
+     *                 developerPortalUris (Required): [
+     *                     String (Required)
+     *                 ]
+     *             }
+     *             customProperties (Optional): {
+     *             }
+     *         }
+     *     ]
+     *     nextLink: String (Optional)
+     * }
+     * }
+     * 
+ * + * @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 Environment items across workspaces along with {@link Response} on successful + * completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> listAllWithResponse(RequestOptions requestOptions) { + return this.serviceClient.listAllWithResponseAsync(requestOptions); + } + + /** + * Get an environment. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *     title: String (Required)
+     *     kind: String(development/testing/staging/production) (Required)
+     *     description: String (Optional)
+     *     server (Optional): {
+     *         type: String (Required)
+     *         managementPortalUris (Required): [
+     *             String (Required)
+     *         ]
+     *     }
+     *     onboarding (Optional): {
+     *         instructions: String (Required)
+     *         developerPortalUris (Required): [
+     *             String (Required)
+     *         ]
+     *     }
+     *     customProperties (Optional): {
+     *     }
+     * }
+     * }
+     * 
+ * + * @param workspaceName Workspace identifier. + * @param environmentName Environment identifier. + * @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 an environment along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(String workspaceName, String environmentName, + RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(workspaceName, environmentName, requestOptions); + } + + /** + * List a collection of environments. + * + * @param workspaceName Workspace identifier. + * @param top The number of result items to return. + * @param skip The number of result items to skip. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return paged collection of Environment items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux list(String workspaceName, Integer top, Integer skip) { + // Generated convenience method for list + RequestOptions requestOptions = new RequestOptions(); + if (top != null) { + requestOptions.addQueryParam("top", String.valueOf(top), false); + } + if (skip != null) { + requestOptions.addQueryParam("skip", String.valueOf(skip), false); + } + PagedFlux pagedFluxResponse = list(workspaceName, requestOptions); + return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> { + Flux> flux = (continuationTokenParam == null) + ? pagedFluxResponse.byPage().take(1) + : pagedFluxResponse.byPage(continuationTokenParam).take(1); + return flux.map(pagedResponse -> new PagedResponseBase(pagedResponse.getRequest(), + pagedResponse.getStatusCode(), pagedResponse.getHeaders(), + pagedResponse.getValue() + .stream() + .map(protocolMethodData -> protocolMethodData.toObject(Environment.class)) + .collect(Collectors.toList()), + pagedResponse.getContinuationToken(), null)); + }); + } + + /** + * List a collection of environments. + * + * @param workspaceName Workspace identifier. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return paged collection of Environment items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux list(String workspaceName) { + // Generated convenience method for list + RequestOptions requestOptions = new RequestOptions(); + PagedFlux pagedFluxResponse = list(workspaceName, requestOptions); + return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> { + Flux> flux = (continuationTokenParam == null) + ? pagedFluxResponse.byPage().take(1) + : pagedFluxResponse.byPage(continuationTokenParam).take(1); + return flux.map(pagedResponse -> new PagedResponseBase(pagedResponse.getRequest(), + pagedResponse.getStatusCode(), pagedResponse.getHeaders(), + pagedResponse.getValue() + .stream() + .map(protocolMethodData -> protocolMethodData.toObject(Environment.class)) + .collect(Collectors.toList()), + pagedResponse.getContinuationToken(), null)); + }); + } + + /** + * List a collection of environments across workspaces. + * + * @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 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 Environment items across workspaces on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono listAll(Integer top, Integer skip, Integer maxPageSize) { + // Generated convenience method for listAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (top != null) { + requestOptions.addQueryParam("top", String.valueOf(top), false); + } + if (skip != null) { + requestOptions.addQueryParam("skip", String.valueOf(skip), false); + } + if (maxPageSize != null) { + requestOptions.addQueryParam("maxpagesize", String.valueOf(maxPageSize), false); + } + return listAllWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(PagedEnvironmentAll.class)); + } + + /** + * List a collection of environments across workspaces. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return paged collection of Environment items across workspaces on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono listAll() { + // Generated convenience method for listAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + return listAllWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(PagedEnvironmentAll.class)); + } + + /** + * Get an environment. + * + * @param workspaceName Workspace identifier. + * @param environmentName Environment identifier. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an environment on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get(String workspaceName, String environmentName) { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(workspaceName, environmentName, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Environment.class)); + } +} diff --git a/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/EnvironmentsClient.java b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/EnvironmentsClient.java new file mode 100644 index 000000000000..270ba848874e --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/EnvironmentsClient.java @@ -0,0 +1,313 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.apicenter; + +import com.azure.apicenter.implementation.EnvironmentsImpl; +import com.azure.apicenter.models.Environment; +import com.azure.apicenter.models.PagedEnvironmentAll; +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; + +/** + * Initializes a new instance of the synchronous DataApiClient type. + */ +@ServiceClient(builder = DataApiClientBuilder.class) +public final class EnvironmentsClient { + @Generated + private final EnvironmentsImpl serviceClient; + + /** + * Initializes an instance of EnvironmentsClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + EnvironmentsClient(EnvironmentsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * List a collection of environments. + *

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)
+     *     title: String (Required)
+     *     kind: String(development/testing/staging/production) (Required)
+     *     description: String (Optional)
+     *     server (Optional): {
+     *         type: String (Required)
+     *         managementPortalUris (Required): [
+     *             String (Required)
+     *         ]
+     *     }
+     *     onboarding (Optional): {
+     *         instructions: String (Required)
+     *         developerPortalUris (Required): [
+     *             String (Required)
+     *         ]
+     *     }
+     *     customProperties (Optional): {
+     *     }
+     * }
+     * }
+     * 
+ * + * @param workspaceName Workspace identifier. + * @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 Environment items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(String workspaceName, RequestOptions requestOptions) { + return this.serviceClient.list(workspaceName, requestOptions); + } + + /** + * List a collection of environments across workspaces. + *

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
+     * {
+     *     value (Required): [
+     *          (Required){
+     *             name: String (Required)
+     *             title: String (Required)
+     *             kind: String(development/testing/staging/production) (Required)
+     *             description: String (Optional)
+     *             server (Optional): {
+     *                 type: String (Required)
+     *                 managementPortalUris (Required): [
+     *                     String (Required)
+     *                 ]
+     *             }
+     *             onboarding (Optional): {
+     *                 instructions: String (Required)
+     *                 developerPortalUris (Required): [
+     *                     String (Required)
+     *                 ]
+     *             }
+     *             customProperties (Optional): {
+     *             }
+     *         }
+     *     ]
+     *     nextLink: String (Optional)
+     * }
+     * }
+     * 
+ * + * @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 Environment items across workspaces along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response listAllWithResponse(RequestOptions requestOptions) { + return this.serviceClient.listAllWithResponse(requestOptions); + } + + /** + * Get an environment. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *     title: String (Required)
+     *     kind: String(development/testing/staging/production) (Required)
+     *     description: String (Optional)
+     *     server (Optional): {
+     *         type: String (Required)
+     *         managementPortalUris (Required): [
+     *             String (Required)
+     *         ]
+     *     }
+     *     onboarding (Optional): {
+     *         instructions: String (Required)
+     *         developerPortalUris (Required): [
+     *             String (Required)
+     *         ]
+     *     }
+     *     customProperties (Optional): {
+     *     }
+     * }
+     * }
+     * 
+ * + * @param workspaceName Workspace identifier. + * @param environmentName Environment identifier. + * @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 an environment along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(String workspaceName, String environmentName, + RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(workspaceName, environmentName, requestOptions); + } + + /** + * List a collection of environments. + * + * @param workspaceName Workspace identifier. + * @param top The number of result items to return. + * @param skip The number of result items to skip. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return paged collection of Environment items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(String workspaceName, Integer top, Integer skip) { + // Generated convenience method for list + RequestOptions requestOptions = new RequestOptions(); + if (top != null) { + requestOptions.addQueryParam("top", String.valueOf(top), false); + } + if (skip != null) { + requestOptions.addQueryParam("skip", String.valueOf(skip), false); + } + return serviceClient.list(workspaceName, requestOptions) + .mapPage(bodyItemValue -> bodyItemValue.toObject(Environment.class)); + } + + /** + * List a collection of environments. + * + * @param workspaceName Workspace identifier. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return paged collection of Environment items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(String workspaceName) { + // Generated convenience method for list + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.list(workspaceName, requestOptions) + .mapPage(bodyItemValue -> bodyItemValue.toObject(Environment.class)); + } + + /** + * List a collection of environments across workspaces. + * + * @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 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 Environment items across workspaces. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public PagedEnvironmentAll listAll(Integer top, Integer skip, Integer maxPageSize) { + // Generated convenience method for listAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (top != null) { + requestOptions.addQueryParam("top", String.valueOf(top), false); + } + if (skip != null) { + requestOptions.addQueryParam("skip", String.valueOf(skip), false); + } + if (maxPageSize != null) { + requestOptions.addQueryParam("maxpagesize", String.valueOf(maxPageSize), false); + } + return listAllWithResponse(requestOptions).getValue().toObject(PagedEnvironmentAll.class); + } + + /** + * List a collection of environments across workspaces. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return paged collection of Environment items across workspaces. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public PagedEnvironmentAll listAll() { + // Generated convenience method for listAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + return listAllWithResponse(requestOptions).getValue().toObject(PagedEnvironmentAll.class); + } + + /** + * Get an environment. + * + * @param workspaceName Workspace identifier. + * @param environmentName Environment identifier. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an environment. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Environment get(String workspaceName, String environmentName) { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(workspaceName, environmentName, requestOptions).getValue().toObject(Environment.class); + } +} diff --git a/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/implementation/ApiDefinitionsImpl.java b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/implementation/ApiDefinitionsImpl.java new file mode 100644 index 000000000000..fd956435c6fb --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/implementation/ApiDefinitionsImpl.java @@ -0,0 +1,1046 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.apicenter.implementation; + +import com.azure.apicenter.DataApiServiceVersion; +import com.azure.apicenter.models.ApiSpecExportResult; +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.PathParam; +import com.azure.core.annotation.Post; +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.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.UrlBuilder; +import com.azure.core.util.polling.PollOperationDetails; +import com.azure.core.util.polling.PollerFlux; +import com.azure.core.util.polling.PollingStrategyOptions; +import com.azure.core.util.polling.SyncPoller; +import com.azure.core.util.serializer.TypeReference; +import java.time.Duration; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in ApiDefinitions. + */ +public final class ApiDefinitionsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final ApiDefinitionsService service; + + /** + * The service client containing this operation class. + */ + private final DataApiClientImpl client; + + /** + * Initializes an instance of ApiDefinitionsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + ApiDefinitionsImpl(DataApiClientImpl client) { + this.service + = RestProxy.create(ApiDefinitionsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public DataApiServiceVersion getServiceVersion() { + return client.getServiceVersion(); + } + + /** + * The interface defining all the services for DataApiClientApiDefinitions to be used by the proxy service to + * perform REST calls. + */ + @Host("https://{serviceName}.data.{region}.azure-apicenter.ms") + @ServiceInterface(name = "DataApiClientApiDefi") + public interface ApiDefinitionsService { + @Get("/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}/definitions") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> listDefinitions(@HostParam("serviceName") String serviceName, + @HostParam("region") String region, @QueryParam("api-version") String apiVersion, + @PathParam("workspaceName") String workspaceName, @PathParam("apiName") String apiName, + @PathParam("versionName") String versionName, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}/definitions") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response listDefinitionsSync(@HostParam("serviceName") String serviceName, + @HostParam("region") String region, @QueryParam("api-version") String apiVersion, + @PathParam("workspaceName") String workspaceName, @PathParam("apiName") String apiName, + @PathParam("versionName") String versionName, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}/definitions/{definitionName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getDefinition(@HostParam("serviceName") String serviceName, + @HostParam("region") String region, @QueryParam("api-version") String apiVersion, + @PathParam("workspaceName") String workspaceName, @PathParam("apiName") String apiName, + @PathParam("versionName") String versionName, @PathParam("definitionName") String definitionName, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}/definitions/{definitionName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getDefinitionSync(@HostParam("serviceName") String serviceName, + @HostParam("region") String region, @QueryParam("api-version") String apiVersion, + @PathParam("workspaceName") String workspaceName, @PathParam("apiName") String apiName, + @PathParam("versionName") String versionName, @PathParam("definitionName") String definitionName, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}/definitions/{definitionName}/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> getExportSpecificationOperationStatus(@HostParam("serviceName") String serviceName, + @HostParam("region") String region, @QueryParam("api-version") String apiVersion, + @PathParam("workspaceName") String workspaceName, @PathParam("apiName") String apiName, + @PathParam("versionName") String versionName, @PathParam("definitionName") String definitionName, + @PathParam("operationId") String operationId, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}/definitions/{definitionName}/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) + Response getExportSpecificationOperationStatusSync(@HostParam("serviceName") String serviceName, + @HostParam("region") String region, @QueryParam("api-version") String apiVersion, + @PathParam("workspaceName") String workspaceName, @PathParam("apiName") String apiName, + @PathParam("versionName") String versionName, @PathParam("definitionName") String definitionName, + @PathParam("operationId") String operationId, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Post("/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}/definitions/{definitionName}:exportSpecification") + @ExpectedResponses({ 202 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> exportSpecification(@HostParam("serviceName") String serviceName, + @HostParam("region") String region, @QueryParam("api-version") String apiVersion, + @PathParam("workspaceName") String workspaceName, @PathParam("apiName") String apiName, + @PathParam("versionName") String versionName, @PathParam("definitionName") String definitionName, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Post("/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}/definitions/{definitionName}:exportSpecification") + @ExpectedResponses({ 202 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response exportSpecificationSync(@HostParam("serviceName") String serviceName, + @HostParam("region") String region, @QueryParam("api-version") String apiVersion, + @PathParam("workspaceName") String workspaceName, @PathParam("apiName") String apiName, + @PathParam("versionName") String versionName, @PathParam("definitionName") String definitionName, + @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> listDefinitionsNext(@PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("serviceName") String serviceName, @HostParam("region") String region, + @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) + Response listDefinitionsNextSync(@PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("serviceName") String serviceName, @HostParam("region") String region, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + } + + /** + * List a collection of API definitions. + *

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)
+     *     title: String (Required)
+     *     description: String (Optional)
+     *     specification (Optional): {
+     *         name: String (Required)
+     *         version: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param workspaceName Workspace identifier. + * @param apiName Api identifier. + * @param versionName Version identifier. + * @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 ApiDefinition items along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listDefinitionsSinglePageAsync(String workspaceName, String apiName, + String versionName, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.listDefinitions(this.client.getServiceName(), this.client.getRegion(), + this.client.getServiceVersion().getVersion(), workspaceName, apiName, versionName, accept, + requestOptions, context)) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null)); + } + + /** + * List a collection of API definitions. + *

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)
+     *     title: String (Required)
+     *     description: String (Optional)
+     *     specification (Optional): {
+     *         name: String (Required)
+     *         version: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param workspaceName Workspace identifier. + * @param apiName Api identifier. + * @param versionName Version identifier. + * @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 ApiDefinition items as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listDefinitionsAsync(String workspaceName, String apiName, String versionName, + RequestOptions requestOptions) { + RequestOptions requestOptionsForNextPage = new RequestOptions(); + requestOptionsForNextPage.setContext( + requestOptions != null && requestOptions.getContext() != null ? requestOptions.getContext() : Context.NONE); + return new PagedFlux<>((pageSize) -> { + RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions; + if (pageSize != null) { + requestOptionsLocal.addRequestCallback(requestLocal -> { + UrlBuilder urlBuilder = UrlBuilder.parse(requestLocal.getUrl()); + urlBuilder.setQueryParameter("maxpagesize", String.valueOf(pageSize)); + requestLocal.setUrl(urlBuilder.toString()); + }); + } + return listDefinitionsSinglePageAsync(workspaceName, apiName, versionName, requestOptionsLocal); + }, (nextLink, pageSize) -> { + RequestOptions requestOptionsLocal = new RequestOptions(); + requestOptionsLocal.setContext(requestOptionsForNextPage.getContext()); + if (pageSize != null) { + requestOptionsLocal.addRequestCallback(requestLocal -> { + UrlBuilder urlBuilder = UrlBuilder.parse(requestLocal.getUrl()); + urlBuilder.setQueryParameter("maxpagesize", String.valueOf(pageSize)); + requestLocal.setUrl(urlBuilder.toString()); + }); + } + return listDefinitionsNextSinglePageAsync(nextLink, requestOptionsLocal); + }); + } + + /** + * List a collection of API definitions. + *

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)
+     *     title: String (Required)
+     *     description: String (Optional)
+     *     specification (Optional): {
+     *         name: String (Required)
+     *         version: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param workspaceName Workspace identifier. + * @param apiName Api identifier. + * @param versionName Version identifier. + * @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 ApiDefinition items along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listDefinitionsSinglePage(String workspaceName, String apiName, + String versionName, RequestOptions requestOptions) { + final String accept = "application/json"; + Response res = service.listDefinitionsSync(this.client.getServiceName(), this.client.getRegion(), + this.client.getServiceVersion().getVersion(), workspaceName, apiName, versionName, accept, requestOptions, + Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null); + } + + /** + * List a collection of API definitions. + *

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)
+     *     title: String (Required)
+     *     description: String (Optional)
+     *     specification (Optional): {
+     *         name: String (Required)
+     *         version: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param workspaceName Workspace identifier. + * @param apiName Api identifier. + * @param versionName Version identifier. + * @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 ApiDefinition items as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listDefinitions(String workspaceName, String apiName, String versionName, + RequestOptions requestOptions) { + RequestOptions requestOptionsForNextPage = new RequestOptions(); + requestOptionsForNextPage.setContext( + requestOptions != null && requestOptions.getContext() != null ? requestOptions.getContext() : Context.NONE); + return new PagedIterable<>((pageSize) -> { + RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions; + if (pageSize != null) { + requestOptionsLocal.addRequestCallback(requestLocal -> { + UrlBuilder urlBuilder = UrlBuilder.parse(requestLocal.getUrl()); + urlBuilder.setQueryParameter("maxpagesize", String.valueOf(pageSize)); + requestLocal.setUrl(urlBuilder.toString()); + }); + } + return listDefinitionsSinglePage(workspaceName, apiName, versionName, requestOptionsLocal); + }, (nextLink, pageSize) -> { + RequestOptions requestOptionsLocal = new RequestOptions(); + requestOptionsLocal.setContext(requestOptionsForNextPage.getContext()); + if (pageSize != null) { + requestOptionsLocal.addRequestCallback(requestLocal -> { + UrlBuilder urlBuilder = UrlBuilder.parse(requestLocal.getUrl()); + urlBuilder.setQueryParameter("maxpagesize", String.valueOf(pageSize)); + requestLocal.setUrl(urlBuilder.toString()); + }); + } + return listDefinitionsNextSinglePage(nextLink, requestOptionsLocal); + }); + } + + /** + * Get an API definition. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *     title: String (Required)
+     *     description: String (Optional)
+     *     specification (Optional): {
+     *         name: String (Required)
+     *         version: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param workspaceName Workspace identifier. + * @param apiName Api identifier. + * @param versionName Version identifier. + * @param definitionName Definition identifier. + * @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 an API definition along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getDefinitionWithResponseAsync(String workspaceName, String apiName, + String versionName, String definitionName, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.getDefinition(this.client.getServiceName(), + this.client.getRegion(), this.client.getServiceVersion().getVersion(), workspaceName, apiName, versionName, + definitionName, accept, requestOptions, context)); + } + + /** + * Get an API definition. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *     title: String (Required)
+     *     description: String (Optional)
+     *     specification (Optional): {
+     *         name: String (Required)
+     *         version: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param workspaceName Workspace identifier. + * @param apiName Api identifier. + * @param versionName Version identifier. + * @param definitionName Definition identifier. + * @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 an API definition along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getDefinitionWithResponse(String workspaceName, String apiName, String versionName, + String definitionName, RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getDefinitionSync(this.client.getServiceName(), this.client.getRegion(), + this.client.getServiceVersion().getVersion(), workspaceName, apiName, versionName, definitionName, accept, + requestOptions, Context.NONE); + } + + /** + * Gets status of a an API specification export operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     status: String(NotStarted/Running/Succeeded/Failed/Canceled) (Required)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *         innererror (Optional): {
+     *             code: String (Optional)
+     *             innererror (Optional): (recursive schema, see innererror above)
+     *         }
+     *     }
+     *     result (Optional): {
+     *         definitionName: String (Required)
+     *         value: String (Required)
+     *         format: String(link) (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param workspaceName Workspace identifier. + * @param apiName Api identifier. + * @param versionName Version identifier. + * @param definitionName API definition identifier. + * @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 an API specification export operation along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getExportSpecificationOperationStatusWithResponseAsync(String workspaceName, + String apiName, String versionName, String definitionName, String operationId, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getExportSpecificationOperationStatus(this.client.getServiceName(), + this.client.getRegion(), this.client.getServiceVersion().getVersion(), workspaceName, apiName, + versionName, definitionName, operationId, accept, requestOptions, context)); + } + + /** + * Gets status of a an API specification export operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     status: String(NotStarted/Running/Succeeded/Failed/Canceled) (Required)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *         innererror (Optional): {
+     *             code: String (Optional)
+     *             innererror (Optional): (recursive schema, see innererror above)
+     *         }
+     *     }
+     *     result (Optional): {
+     *         definitionName: String (Required)
+     *         value: String (Required)
+     *         format: String(link) (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param workspaceName Workspace identifier. + * @param apiName Api identifier. + * @param versionName Version identifier. + * @param definitionName API definition identifier. + * @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 an API specification export operation along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getExportSpecificationOperationStatusWithResponse(String workspaceName, String apiName, + String versionName, String definitionName, String operationId, RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getExportSpecificationOperationStatusSync(this.client.getServiceName(), this.client.getRegion(), + this.client.getServiceVersion().getVersion(), workspaceName, apiName, versionName, definitionName, + operationId, accept, requestOptions, Context.NONE); + } + + /** + * Export an API specification asynchronously. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     status: String(NotStarted/Running/Succeeded/Failed/Canceled) (Required)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *         innererror (Optional): {
+     *             code: String (Optional)
+     *             innererror (Optional): (recursive schema, see innererror above)
+     *         }
+     *     }
+     *     result (Optional): {
+     *         definitionName: String (Required)
+     *         value: String (Required)
+     *         format: String(link) (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param workspaceName Workspace identifier. + * @param apiName Api identifier. + * @param versionName Version identifier. + * @param definitionName API definition identifier. + * @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> exportSpecificationWithResponseAsync(String workspaceName, String apiName, + String versionName, String definitionName, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.exportSpecification(this.client.getServiceName(), + this.client.getRegion(), this.client.getServiceVersion().getVersion(), workspaceName, apiName, versionName, + definitionName, accept, requestOptions, context)); + } + + /** + * Export an API specification asynchronously. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     status: String(NotStarted/Running/Succeeded/Failed/Canceled) (Required)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *         innererror (Optional): {
+     *             code: String (Optional)
+     *             innererror (Optional): (recursive schema, see innererror above)
+     *         }
+     *     }
+     *     result (Optional): {
+     *         definitionName: String (Required)
+     *         value: String (Required)
+     *         format: String(link) (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param workspaceName Workspace identifier. + * @param apiName Api identifier. + * @param versionName Version identifier. + * @param definitionName API definition identifier. + * @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}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Response exportSpecificationWithResponse(String workspaceName, String apiName, + String versionName, String definitionName, RequestOptions requestOptions) { + final String accept = "application/json"; + return service.exportSpecificationSync(this.client.getServiceName(), this.client.getRegion(), + this.client.getServiceVersion().getVersion(), workspaceName, apiName, versionName, definitionName, accept, + requestOptions, Context.NONE); + } + + /** + * Export an API specification asynchronously. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     status: String(NotStarted/Running/Succeeded/Failed/Canceled) (Required)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *         innererror (Optional): {
+     *             code: String (Optional)
+     *             innererror (Optional): (recursive schema, see innererror above)
+     *         }
+     *     }
+     *     result (Optional): {
+     *         definitionName: String (Required)
+     *         value: String (Required)
+     *         format: String(link) (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param workspaceName Workspace identifier. + * @param apiName Api identifier. + * @param versionName Version identifier. + * @param definitionName API definition identifier. + * @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 beginExportSpecificationAsync(String workspaceName, String apiName, + String versionName, String definitionName, RequestOptions requestOptions) { + return PollerFlux.create(Duration.ofSeconds(1), + () -> this.exportSpecificationWithResponseAsync(workspaceName, apiName, versionName, definitionName, + requestOptions), + new com.azure.apicenter.implementation.OperationLocationPollingStrategy<>( + new PollingStrategyOptions(this.client.getHttpPipeline()) + + .setContext(requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE) + .setServiceVersion(this.client.getServiceVersion().getVersion()), + "result"), + TypeReference.createInstance(BinaryData.class), TypeReference.createInstance(BinaryData.class)); + } + + /** + * Export an API specification asynchronously. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     status: String(NotStarted/Running/Succeeded/Failed/Canceled) (Required)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *         innererror (Optional): {
+     *             code: String (Optional)
+     *             innererror (Optional): (recursive schema, see innererror above)
+     *         }
+     *     }
+     *     result (Optional): {
+     *         definitionName: String (Required)
+     *         value: String (Required)
+     *         format: String(link) (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param workspaceName Workspace identifier. + * @param apiName Api identifier. + * @param versionName Version identifier. + * @param definitionName API definition identifier. + * @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 beginExportSpecification(String workspaceName, String apiName, + String versionName, String definitionName, RequestOptions requestOptions) { + return SyncPoller.createPoller(Duration.ofSeconds(1), + () -> this.exportSpecificationWithResponse(workspaceName, apiName, versionName, definitionName, + requestOptions), + new com.azure.apicenter.implementation.SyncOperationLocationPollingStrategy<>( + new PollingStrategyOptions(this.client.getHttpPipeline()) + + .setContext(requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE) + .setServiceVersion(this.client.getServiceVersion().getVersion()), + "result"), + TypeReference.createInstance(BinaryData.class), TypeReference.createInstance(BinaryData.class)); + } + + /** + * Export an API specification asynchronously. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     status: String(NotStarted/Running/Succeeded/Failed/Canceled) (Required)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *         innererror (Optional): {
+     *             code: String (Optional)
+     *             innererror (Optional): (recursive schema, see innererror above)
+     *         }
+     *     }
+     *     result (Optional): {
+     *         definitionName: String (Required)
+     *         value: String (Required)
+     *         format: String(link) (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param workspaceName Workspace identifier. + * @param apiName Api identifier. + * @param versionName Version identifier. + * @param definitionName API definition identifier. + * @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 beginExportSpecificationWithModelAsync( + String workspaceName, String apiName, String versionName, String definitionName, + RequestOptions requestOptions) { + return PollerFlux.create(Duration.ofSeconds(1), + () -> this.exportSpecificationWithResponseAsync(workspaceName, apiName, versionName, definitionName, + requestOptions), + new com.azure.apicenter.implementation.OperationLocationPollingStrategy<>( + new PollingStrategyOptions(this.client.getHttpPipeline()) + + .setContext(requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE) + .setServiceVersion(this.client.getServiceVersion().getVersion()), + "result"), + TypeReference.createInstance(PollOperationDetails.class), + TypeReference.createInstance(ApiSpecExportResult.class)); + } + + /** + * Export an API specification asynchronously. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     status: String(NotStarted/Running/Succeeded/Failed/Canceled) (Required)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *         innererror (Optional): {
+     *             code: String (Optional)
+     *             innererror (Optional): (recursive schema, see innererror above)
+     *         }
+     *     }
+     *     result (Optional): {
+     *         definitionName: String (Required)
+     *         value: String (Required)
+     *         format: String(link) (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param workspaceName Workspace identifier. + * @param apiName Api identifier. + * @param versionName Version identifier. + * @param definitionName API definition identifier. + * @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 beginExportSpecificationWithModel(String workspaceName, + String apiName, String versionName, String definitionName, RequestOptions requestOptions) { + return SyncPoller.createPoller(Duration.ofSeconds(1), + () -> this.exportSpecificationWithResponse(workspaceName, apiName, versionName, definitionName, + requestOptions), + new com.azure.apicenter.implementation.SyncOperationLocationPollingStrategy<>( + new PollingStrategyOptions(this.client.getHttpPipeline()) + + .setContext(requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE) + .setServiceVersion(this.client.getServiceVersion().getVersion()), + "result"), + TypeReference.createInstance(PollOperationDetails.class), + TypeReference.createInstance(ApiSpecExportResult.class)); + } + + /** + * Get the next page of items. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *     title: String (Required)
+     *     description: String (Optional)
+     *     specification (Optional): {
+     *         name: String (Required)
+     *         version: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param nextLink The URL to get the next list of items. + * @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 ApiDefinition items along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listDefinitionsNextSinglePageAsync(String nextLink, + RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.listDefinitionsNext(nextLink, this.client.getServiceName(), + this.client.getRegion(), accept, requestOptions, context)) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null)); + } + + /** + * Get the next page of items. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *     title: String (Required)
+     *     description: String (Optional)
+     *     specification (Optional): {
+     *         name: String (Required)
+     *         version: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param nextLink The URL to get the next list of items. + * @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 ApiDefinition items along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listDefinitionsNextSinglePage(String nextLink, RequestOptions requestOptions) { + final String accept = "application/json"; + Response res = service.listDefinitionsNextSync(nextLink, this.client.getServiceName(), + this.client.getRegion(), accept, requestOptions, Context.NONE); + return 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/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/implementation/ApiDeploymentsImpl.java b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/implementation/ApiDeploymentsImpl.java new file mode 100644 index 000000000000..de86c2a9942b --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/implementation/ApiDeploymentsImpl.java @@ -0,0 +1,578 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.apicenter.implementation; + +import com.azure.apicenter.DataApiServiceVersion; +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.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.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.UrlBuilder; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in ApiDeployments. + */ +public final class ApiDeploymentsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final ApiDeploymentsService service; + + /** + * The service client containing this operation class. + */ + private final DataApiClientImpl client; + + /** + * Initializes an instance of ApiDeploymentsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + ApiDeploymentsImpl(DataApiClientImpl client) { + this.service + = RestProxy.create(ApiDeploymentsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public DataApiServiceVersion getServiceVersion() { + return client.getServiceVersion(); + } + + /** + * The interface defining all the services for DataApiClientApiDeployments to be used by the proxy service to + * perform REST calls. + */ + @Host("https://{serviceName}.data.{region}.azure-apicenter.ms") + @ServiceInterface(name = "DataApiClientApiDepl") + public interface ApiDeploymentsService { + @Get("/workspaces/{workspaceName}/apis/{apiName}/deployments") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> listDeployments(@HostParam("serviceName") String serviceName, + @HostParam("region") String region, @QueryParam("api-version") String apiVersion, + @PathParam("workspaceName") String workspaceName, @PathParam("apiName") String apiName, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/workspaces/{workspaceName}/apis/{apiName}/deployments") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response listDeploymentsSync(@HostParam("serviceName") String serviceName, + @HostParam("region") String region, @QueryParam("api-version") String apiVersion, + @PathParam("workspaceName") String workspaceName, @PathParam("apiName") String apiName, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/workspaces/{workspaceName}/apis/{apiName}/deployments/{deploymentName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getDeployment(@HostParam("serviceName") String serviceName, + @HostParam("region") String region, @QueryParam("api-version") String apiVersion, + @PathParam("workspaceName") String workspaceName, @PathParam("apiName") String apiName, + @PathParam("deploymentName") String deploymentName, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/workspaces/{workspaceName}/apis/{apiName}/deployments/{deploymentName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getDeploymentSync(@HostParam("serviceName") String serviceName, + @HostParam("region") String region, @QueryParam("api-version") String apiVersion, + @PathParam("workspaceName") String workspaceName, @PathParam("apiName") String apiName, + @PathParam("deploymentName") String deploymentName, @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> listDeploymentsNext(@PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("serviceName") String serviceName, @HostParam("region") String region, + @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) + Response listDeploymentsNextSync(@PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("serviceName") String serviceName, @HostParam("region") String region, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + } + + /** + * List a collection of API deployments. + *

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)
+     *     title: String (Required)
+     *     description: String (Optional)
+     *     environment: String (Required)
+     *     server (Required): {
+     *         runtimeUris (Required): [
+     *             String (Required)
+     *         ]
+     *     }
+     *     customProperties (Optional): {
+     *     }
+     *     recommended: Boolean (Optional)
+     * }
+     * }
+     * 
+ * + * @param workspaceName Workspace identifier. + * @param apiName Api identifier. + * @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 ApiDeployment items along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listDeploymentsSinglePageAsync(String workspaceName, String apiName, + RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.listDeployments(this.client.getServiceName(), this.client.getRegion(), + this.client.getServiceVersion().getVersion(), workspaceName, apiName, accept, requestOptions, context)) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null)); + } + + /** + * List a collection of API deployments. + *

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)
+     *     title: String (Required)
+     *     description: String (Optional)
+     *     environment: String (Required)
+     *     server (Required): {
+     *         runtimeUris (Required): [
+     *             String (Required)
+     *         ]
+     *     }
+     *     customProperties (Optional): {
+     *     }
+     *     recommended: Boolean (Optional)
+     * }
+     * }
+     * 
+ * + * @param workspaceName Workspace identifier. + * @param apiName Api identifier. + * @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 ApiDeployment items as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listDeploymentsAsync(String workspaceName, String apiName, + RequestOptions requestOptions) { + RequestOptions requestOptionsForNextPage = new RequestOptions(); + requestOptionsForNextPage.setContext( + requestOptions != null && requestOptions.getContext() != null ? requestOptions.getContext() : Context.NONE); + return new PagedFlux<>((pageSize) -> { + RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions; + if (pageSize != null) { + requestOptionsLocal.addRequestCallback(requestLocal -> { + UrlBuilder urlBuilder = UrlBuilder.parse(requestLocal.getUrl()); + urlBuilder.setQueryParameter("maxpagesize", String.valueOf(pageSize)); + requestLocal.setUrl(urlBuilder.toString()); + }); + } + return listDeploymentsSinglePageAsync(workspaceName, apiName, requestOptionsLocal); + }, (nextLink, pageSize) -> { + RequestOptions requestOptionsLocal = new RequestOptions(); + requestOptionsLocal.setContext(requestOptionsForNextPage.getContext()); + if (pageSize != null) { + requestOptionsLocal.addRequestCallback(requestLocal -> { + UrlBuilder urlBuilder = UrlBuilder.parse(requestLocal.getUrl()); + urlBuilder.setQueryParameter("maxpagesize", String.valueOf(pageSize)); + requestLocal.setUrl(urlBuilder.toString()); + }); + } + return listDeploymentsNextSinglePageAsync(nextLink, requestOptionsLocal); + }); + } + + /** + * List a collection of API deployments. + *

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)
+     *     title: String (Required)
+     *     description: String (Optional)
+     *     environment: String (Required)
+     *     server (Required): {
+     *         runtimeUris (Required): [
+     *             String (Required)
+     *         ]
+     *     }
+     *     customProperties (Optional): {
+     *     }
+     *     recommended: Boolean (Optional)
+     * }
+     * }
+     * 
+ * + * @param workspaceName Workspace identifier. + * @param apiName Api identifier. + * @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 ApiDeployment items along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listDeploymentsSinglePage(String workspaceName, String apiName, + RequestOptions requestOptions) { + final String accept = "application/json"; + Response res = service.listDeploymentsSync(this.client.getServiceName(), this.client.getRegion(), + this.client.getServiceVersion().getVersion(), workspaceName, apiName, accept, requestOptions, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null); + } + + /** + * List a collection of API deployments. + *

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)
+     *     title: String (Required)
+     *     description: String (Optional)
+     *     environment: String (Required)
+     *     server (Required): {
+     *         runtimeUris (Required): [
+     *             String (Required)
+     *         ]
+     *     }
+     *     customProperties (Optional): {
+     *     }
+     *     recommended: Boolean (Optional)
+     * }
+     * }
+     * 
+ * + * @param workspaceName Workspace identifier. + * @param apiName Api identifier. + * @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 ApiDeployment items as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listDeployments(String workspaceName, String apiName, + RequestOptions requestOptions) { + RequestOptions requestOptionsForNextPage = new RequestOptions(); + requestOptionsForNextPage.setContext( + requestOptions != null && requestOptions.getContext() != null ? requestOptions.getContext() : Context.NONE); + return new PagedIterable<>((pageSize) -> { + RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions; + if (pageSize != null) { + requestOptionsLocal.addRequestCallback(requestLocal -> { + UrlBuilder urlBuilder = UrlBuilder.parse(requestLocal.getUrl()); + urlBuilder.setQueryParameter("maxpagesize", String.valueOf(pageSize)); + requestLocal.setUrl(urlBuilder.toString()); + }); + } + return listDeploymentsSinglePage(workspaceName, apiName, requestOptionsLocal); + }, (nextLink, pageSize) -> { + RequestOptions requestOptionsLocal = new RequestOptions(); + requestOptionsLocal.setContext(requestOptionsForNextPage.getContext()); + if (pageSize != null) { + requestOptionsLocal.addRequestCallback(requestLocal -> { + UrlBuilder urlBuilder = UrlBuilder.parse(requestLocal.getUrl()); + urlBuilder.setQueryParameter("maxpagesize", String.valueOf(pageSize)); + requestLocal.setUrl(urlBuilder.toString()); + }); + } + return listDeploymentsNextSinglePage(nextLink, requestOptionsLocal); + }); + } + + /** + * Get an API deployment. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *     title: String (Required)
+     *     description: String (Optional)
+     *     environment: String (Required)
+     *     server (Required): {
+     *         runtimeUris (Required): [
+     *             String (Required)
+     *         ]
+     *     }
+     *     customProperties (Optional): {
+     *     }
+     *     recommended: Boolean (Optional)
+     * }
+     * }
+     * 
+ * + * @param workspaceName Workspace identifier. + * @param apiName Api identifier. + * @param deploymentName Deployment identifier. + * @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 an API deployment along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getDeploymentWithResponseAsync(String workspaceName, String apiName, + String deploymentName, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.getDeployment(this.client.getServiceName(), + this.client.getRegion(), this.client.getServiceVersion().getVersion(), workspaceName, apiName, + deploymentName, accept, requestOptions, context)); + } + + /** + * Get an API deployment. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *     title: String (Required)
+     *     description: String (Optional)
+     *     environment: String (Required)
+     *     server (Required): {
+     *         runtimeUris (Required): [
+     *             String (Required)
+     *         ]
+     *     }
+     *     customProperties (Optional): {
+     *     }
+     *     recommended: Boolean (Optional)
+     * }
+     * }
+     * 
+ * + * @param workspaceName Workspace identifier. + * @param apiName Api identifier. + * @param deploymentName Deployment identifier. + * @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 an API deployment along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getDeploymentWithResponse(String workspaceName, String apiName, String deploymentName, + RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getDeploymentSync(this.client.getServiceName(), this.client.getRegion(), + this.client.getServiceVersion().getVersion(), workspaceName, apiName, deploymentName, accept, + requestOptions, Context.NONE); + } + + /** + * Get the next page of items. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *     title: String (Required)
+     *     description: String (Optional)
+     *     environment: String (Required)
+     *     server (Required): {
+     *         runtimeUris (Required): [
+     *             String (Required)
+     *         ]
+     *     }
+     *     customProperties (Optional): {
+     *     }
+     *     recommended: Boolean (Optional)
+     * }
+     * }
+     * 
+ * + * @param nextLink The URL to get the next list of items. + * @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 ApiDeployment items along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listDeploymentsNextSinglePageAsync(String nextLink, + RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.listDeploymentsNext(nextLink, this.client.getServiceName(), + this.client.getRegion(), accept, requestOptions, context)) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null)); + } + + /** + * Get the next page of items. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *     title: String (Required)
+     *     description: String (Optional)
+     *     environment: String (Required)
+     *     server (Required): {
+     *         runtimeUris (Required): [
+     *             String (Required)
+     *         ]
+     *     }
+     *     customProperties (Optional): {
+     *     }
+     *     recommended: Boolean (Optional)
+     * }
+     * }
+     * 
+ * + * @param nextLink The URL to get the next list of items. + * @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 ApiDeployment items along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listDeploymentsNextSinglePage(String nextLink, RequestOptions requestOptions) { + final String accept = "application/json"; + Response res = service.listDeploymentsNextSync(nextLink, this.client.getServiceName(), + this.client.getRegion(), accept, requestOptions, Context.NONE); + return 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/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/implementation/ApiVersionsImpl.java b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/implementation/ApiVersionsImpl.java new file mode 100644 index 000000000000..4b561021cd4e --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/implementation/ApiVersionsImpl.java @@ -0,0 +1,505 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.apicenter.implementation; + +import com.azure.apicenter.DataApiServiceVersion; +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.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.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.UrlBuilder; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in ApiVersions. + */ +public final class ApiVersionsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final ApiVersionsService service; + + /** + * The service client containing this operation class. + */ + private final DataApiClientImpl client; + + /** + * Initializes an instance of ApiVersionsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + ApiVersionsImpl(DataApiClientImpl client) { + this.service + = RestProxy.create(ApiVersionsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public DataApiServiceVersion getServiceVersion() { + return client.getServiceVersion(); + } + + /** + * The interface defining all the services for DataApiClientApiVersions to be used by the proxy service to perform + * REST calls. + */ + @Host("https://{serviceName}.data.{region}.azure-apicenter.ms") + @ServiceInterface(name = "DataApiClientApiVers") + public interface ApiVersionsService { + @Get("/workspaces/{workspaceName}/apis/{apiName}/versions") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> listVersions(@HostParam("serviceName") String serviceName, + @HostParam("region") String region, @QueryParam("api-version") String apiVersion, + @PathParam("workspaceName") String workspaceName, @PathParam("apiName") String apiName, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/workspaces/{workspaceName}/apis/{apiName}/versions") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response listVersionsSync(@HostParam("serviceName") String serviceName, + @HostParam("region") String region, @QueryParam("api-version") String apiVersion, + @PathParam("workspaceName") String workspaceName, @PathParam("apiName") String apiName, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getVersion(@HostParam("serviceName") String serviceName, + @HostParam("region") String region, @QueryParam("api-version") String apiVersion, + @PathParam("workspaceName") String workspaceName, @PathParam("apiName") String apiName, + @PathParam("versionName") String versionName, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getVersionSync(@HostParam("serviceName") String serviceName, + @HostParam("region") String region, @QueryParam("api-version") String apiVersion, + @PathParam("workspaceName") String workspaceName, @PathParam("apiName") String apiName, + @PathParam("versionName") String versionName, @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> listVersionsNext(@PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("serviceName") String serviceName, @HostParam("region") String region, + @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) + Response listVersionsNextSync(@PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("serviceName") String serviceName, @HostParam("region") String region, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + } + + /** + * List a collection of API versions. + *

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)
+     *     title: String (Required)
+     *     lifecycleStage: String(design/development/testing/preview/production/deprecated/retired) (Required)
+     * }
+     * }
+     * 
+ * + * @param workspaceName Workspace identifier. + * @param apiName Api identifier. + * @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 ApiVersion items along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listVersionsSinglePageAsync(String workspaceName, String apiName, + RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.listVersions(this.client.getServiceName(), this.client.getRegion(), + this.client.getServiceVersion().getVersion(), workspaceName, apiName, accept, requestOptions, context)) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null)); + } + + /** + * List a collection of API versions. + *

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)
+     *     title: String (Required)
+     *     lifecycleStage: String(design/development/testing/preview/production/deprecated/retired) (Required)
+     * }
+     * }
+     * 
+ * + * @param workspaceName Workspace identifier. + * @param apiName Api identifier. + * @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 ApiVersion items as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listVersionsAsync(String workspaceName, String apiName, + RequestOptions requestOptions) { + RequestOptions requestOptionsForNextPage = new RequestOptions(); + requestOptionsForNextPage.setContext( + requestOptions != null && requestOptions.getContext() != null ? requestOptions.getContext() : Context.NONE); + return new PagedFlux<>((pageSize) -> { + RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions; + if (pageSize != null) { + requestOptionsLocal.addRequestCallback(requestLocal -> { + UrlBuilder urlBuilder = UrlBuilder.parse(requestLocal.getUrl()); + urlBuilder.setQueryParameter("maxpagesize", String.valueOf(pageSize)); + requestLocal.setUrl(urlBuilder.toString()); + }); + } + return listVersionsSinglePageAsync(workspaceName, apiName, requestOptionsLocal); + }, (nextLink, pageSize) -> { + RequestOptions requestOptionsLocal = new RequestOptions(); + requestOptionsLocal.setContext(requestOptionsForNextPage.getContext()); + if (pageSize != null) { + requestOptionsLocal.addRequestCallback(requestLocal -> { + UrlBuilder urlBuilder = UrlBuilder.parse(requestLocal.getUrl()); + urlBuilder.setQueryParameter("maxpagesize", String.valueOf(pageSize)); + requestLocal.setUrl(urlBuilder.toString()); + }); + } + return listVersionsNextSinglePageAsync(nextLink, requestOptionsLocal); + }); + } + + /** + * List a collection of API versions. + *

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)
+     *     title: String (Required)
+     *     lifecycleStage: String(design/development/testing/preview/production/deprecated/retired) (Required)
+     * }
+     * }
+     * 
+ * + * @param workspaceName Workspace identifier. + * @param apiName Api identifier. + * @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 ApiVersion items along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listVersionsSinglePage(String workspaceName, String apiName, + RequestOptions requestOptions) { + final String accept = "application/json"; + Response res = service.listVersionsSync(this.client.getServiceName(), this.client.getRegion(), + this.client.getServiceVersion().getVersion(), workspaceName, apiName, accept, requestOptions, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null); + } + + /** + * List a collection of API versions. + *

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)
+     *     title: String (Required)
+     *     lifecycleStage: String(design/development/testing/preview/production/deprecated/retired) (Required)
+     * }
+     * }
+     * 
+ * + * @param workspaceName Workspace identifier. + * @param apiName Api identifier. + * @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 ApiVersion items as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listVersions(String workspaceName, String apiName, RequestOptions requestOptions) { + RequestOptions requestOptionsForNextPage = new RequestOptions(); + requestOptionsForNextPage.setContext( + requestOptions != null && requestOptions.getContext() != null ? requestOptions.getContext() : Context.NONE); + return new PagedIterable<>((pageSize) -> { + RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions; + if (pageSize != null) { + requestOptionsLocal.addRequestCallback(requestLocal -> { + UrlBuilder urlBuilder = UrlBuilder.parse(requestLocal.getUrl()); + urlBuilder.setQueryParameter("maxpagesize", String.valueOf(pageSize)); + requestLocal.setUrl(urlBuilder.toString()); + }); + } + return listVersionsSinglePage(workspaceName, apiName, requestOptionsLocal); + }, (nextLink, pageSize) -> { + RequestOptions requestOptionsLocal = new RequestOptions(); + requestOptionsLocal.setContext(requestOptionsForNextPage.getContext()); + if (pageSize != null) { + requestOptionsLocal.addRequestCallback(requestLocal -> { + UrlBuilder urlBuilder = UrlBuilder.parse(requestLocal.getUrl()); + urlBuilder.setQueryParameter("maxpagesize", String.valueOf(pageSize)); + requestLocal.setUrl(urlBuilder.toString()); + }); + } + return listVersionsNextSinglePage(nextLink, requestOptionsLocal); + }); + } + + /** + * Get an API version. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *     title: String (Required)
+     *     lifecycleStage: String(design/development/testing/preview/production/deprecated/retired) (Required)
+     * }
+     * }
+     * 
+ * + * @param workspaceName Workspace identifier. + * @param apiName Api identifier. + * @param versionName Version identifier. + * @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 an API version along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getVersionWithResponseAsync(String workspaceName, String apiName, + String versionName, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.getVersion(this.client.getServiceName(), this.client.getRegion(), + this.client.getServiceVersion().getVersion(), workspaceName, apiName, versionName, accept, requestOptions, + context)); + } + + /** + * Get an API version. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *     title: String (Required)
+     *     lifecycleStage: String(design/development/testing/preview/production/deprecated/retired) (Required)
+     * }
+     * }
+     * 
+ * + * @param workspaceName Workspace identifier. + * @param apiName Api identifier. + * @param versionName Version identifier. + * @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 an API version along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getVersionWithResponse(String workspaceName, String apiName, String versionName, + RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getVersionSync(this.client.getServiceName(), this.client.getRegion(), + this.client.getServiceVersion().getVersion(), workspaceName, apiName, versionName, accept, requestOptions, + Context.NONE); + } + + /** + * Get the next page of items. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *     title: String (Required)
+     *     lifecycleStage: String(design/development/testing/preview/production/deprecated/retired) (Required)
+     * }
+     * }
+     * 
+ * + * @param nextLink The URL to get the next list of items. + * @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 ApiVersion items along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listVersionsNextSinglePageAsync(String nextLink, + RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.listVersionsNext(nextLink, this.client.getServiceName(), + this.client.getRegion(), accept, requestOptions, context)) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null)); + } + + /** + * Get the next page of items. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *     title: String (Required)
+     *     lifecycleStage: String(design/development/testing/preview/production/deprecated/retired) (Required)
+     * }
+     * }
+     * 
+ * + * @param nextLink The URL to get the next list of items. + * @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 ApiVersion items along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listVersionsNextSinglePage(String nextLink, RequestOptions requestOptions) { + final String accept = "application/json"; + Response res = service.listVersionsNextSync(nextLink, this.client.getServiceName(), + this.client.getRegion(), accept, requestOptions, Context.NONE); + return 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/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/implementation/ApisImpl.java b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/implementation/ApisImpl.java new file mode 100644 index 000000000000..f20c3b06140a --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/implementation/ApisImpl.java @@ -0,0 +1,871 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.apicenter.implementation; + +import com.azure.apicenter.DataApiServiceVersion; +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.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.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.UrlBuilder; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in Apis. + */ +public final class ApisImpl { + /** + * The proxy service used to perform REST calls. + */ + private final ApisService service; + + /** + * The service client containing this operation class. + */ + private final DataApiClientImpl client; + + /** + * Initializes an instance of ApisImpl. + * + * @param client the instance of the service client containing this operation class. + */ + ApisImpl(DataApiClientImpl client) { + this.service = RestProxy.create(ApisService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public DataApiServiceVersion getServiceVersion() { + return client.getServiceVersion(); + } + + /** + * The interface defining all the services for DataApiClientApis to be used by the proxy service to perform REST + * calls. + */ + @Host("https://{serviceName}.data.{region}.azure-apicenter.ms") + @ServiceInterface(name = "DataApiClientApis") + public interface ApisService { + @Get("/workspaces/{workspaceName}/apis") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> list(@HostParam("serviceName") String serviceName, + @HostParam("region") String region, @QueryParam("api-version") String apiVersion, + @PathParam("workspaceName") String workspaceName, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/workspaces/{workspaceName}/apis") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response listSync(@HostParam("serviceName") String serviceName, @HostParam("region") String region, + @QueryParam("api-version") String apiVersion, @PathParam("workspaceName") String workspaceName, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/apis") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> listAll(@HostParam("serviceName") String serviceName, + @HostParam("region") String region, @QueryParam("api-version") String apiVersion, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/apis") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response listAllSync(@HostParam("serviceName") String serviceName, + @HostParam("region") String region, @QueryParam("api-version") String apiVersion, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/workspaces/{workspaceName}/apis/{apiName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("serviceName") String serviceName, @HostParam("region") String region, + @QueryParam("api-version") String apiVersion, @PathParam("workspaceName") String workspaceName, + @PathParam("apiName") String apiName, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Get("/workspaces/{workspaceName}/apis/{apiName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("serviceName") String serviceName, @HostParam("region") String region, + @QueryParam("api-version") String apiVersion, @PathParam("workspaceName") String workspaceName, + @PathParam("apiName") String apiName, @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> listNext(@PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("serviceName") String serviceName, @HostParam("region") String region, + @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) + Response listNextSync(@PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("serviceName") String serviceName, @HostParam("region") String region, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + } + + /** + * List a collection of APIs. + *

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)
+     *     title: String (Required)
+     *     summary: String (Optional)
+     *     description: String (Optional)
+     *     kind: String(rest/graphql/grpc/soap/webhook/websocket) (Required)
+     *     lifecycleStage: String(design/development/testing/preview/production/deprecated/retired) (Optional)
+     *     termsOfService (Optional): {
+     *         url: String (Required)
+     *     }
+     *     license (Optional): {
+     *         name: String (Required)
+     *         url: String (Optional)
+     *         identifier: String (Optional)
+     *     }
+     *     externalDocumentation (Optional): [
+     *          (Optional){
+     *             title: String (Required)
+     *             description: String (Required)
+     *             url: String (Required)
+     *         }
+     *     ]
+     *     contacts (Optional): [
+     *          (Optional){
+     *             name: String (Required)
+     *             url: String (Optional)
+     *             email: String (Optional)
+     *         }
+     *     ]
+     *     customProperties (Optional): {
+     *     }
+     *     lastUpdated: OffsetDateTime (Optional)
+     * }
+     * }
+     * 
+ * + * @param workspaceName Workspace identifier. + * @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 Api items along with {@link PagedResponse} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listSinglePageAsync(String workspaceName, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.list(this.client.getServiceName(), this.client.getRegion(), + this.client.getServiceVersion().getVersion(), workspaceName, accept, requestOptions, context)) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null)); + } + + /** + * List a collection of APIs. + *

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)
+     *     title: String (Required)
+     *     summary: String (Optional)
+     *     description: String (Optional)
+     *     kind: String(rest/graphql/grpc/soap/webhook/websocket) (Required)
+     *     lifecycleStage: String(design/development/testing/preview/production/deprecated/retired) (Optional)
+     *     termsOfService (Optional): {
+     *         url: String (Required)
+     *     }
+     *     license (Optional): {
+     *         name: String (Required)
+     *         url: String (Optional)
+     *         identifier: String (Optional)
+     *     }
+     *     externalDocumentation (Optional): [
+     *          (Optional){
+     *             title: String (Required)
+     *             description: String (Required)
+     *             url: String (Required)
+     *         }
+     *     ]
+     *     contacts (Optional): [
+     *          (Optional){
+     *             name: String (Required)
+     *             url: String (Optional)
+     *             email: String (Optional)
+     *         }
+     *     ]
+     *     customProperties (Optional): {
+     *     }
+     *     lastUpdated: OffsetDateTime (Optional)
+     * }
+     * }
+     * 
+ * + * @param workspaceName Workspace identifier. + * @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 Api items as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listAsync(String workspaceName, RequestOptions requestOptions) { + RequestOptions requestOptionsForNextPage = new RequestOptions(); + requestOptionsForNextPage.setContext( + requestOptions != null && requestOptions.getContext() != null ? requestOptions.getContext() : Context.NONE); + return new PagedFlux<>((pageSize) -> { + RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions; + if (pageSize != null) { + requestOptionsLocal.addRequestCallback(requestLocal -> { + UrlBuilder urlBuilder = UrlBuilder.parse(requestLocal.getUrl()); + urlBuilder.setQueryParameter("maxpagesize", String.valueOf(pageSize)); + requestLocal.setUrl(urlBuilder.toString()); + }); + } + return listSinglePageAsync(workspaceName, requestOptionsLocal); + }, (nextLink, pageSize) -> { + RequestOptions requestOptionsLocal = new RequestOptions(); + requestOptionsLocal.setContext(requestOptionsForNextPage.getContext()); + if (pageSize != null) { + requestOptionsLocal.addRequestCallback(requestLocal -> { + UrlBuilder urlBuilder = UrlBuilder.parse(requestLocal.getUrl()); + urlBuilder.setQueryParameter("maxpagesize", String.valueOf(pageSize)); + requestLocal.setUrl(urlBuilder.toString()); + }); + } + return listNextSinglePageAsync(nextLink, requestOptionsLocal); + }); + } + + /** + * List a collection of APIs. + *

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)
+     *     title: String (Required)
+     *     summary: String (Optional)
+     *     description: String (Optional)
+     *     kind: String(rest/graphql/grpc/soap/webhook/websocket) (Required)
+     *     lifecycleStage: String(design/development/testing/preview/production/deprecated/retired) (Optional)
+     *     termsOfService (Optional): {
+     *         url: String (Required)
+     *     }
+     *     license (Optional): {
+     *         name: String (Required)
+     *         url: String (Optional)
+     *         identifier: String (Optional)
+     *     }
+     *     externalDocumentation (Optional): [
+     *          (Optional){
+     *             title: String (Required)
+     *             description: String (Required)
+     *             url: String (Required)
+     *         }
+     *     ]
+     *     contacts (Optional): [
+     *          (Optional){
+     *             name: String (Required)
+     *             url: String (Optional)
+     *             email: String (Optional)
+     *         }
+     *     ]
+     *     customProperties (Optional): {
+     *     }
+     *     lastUpdated: OffsetDateTime (Optional)
+     * }
+     * }
+     * 
+ * + * @param workspaceName Workspace identifier. + * @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 Api items along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listSinglePage(String workspaceName, RequestOptions requestOptions) { + final String accept = "application/json"; + Response res = service.listSync(this.client.getServiceName(), this.client.getRegion(), + this.client.getServiceVersion().getVersion(), workspaceName, accept, requestOptions, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null); + } + + /** + * List a collection of APIs. + *

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)
+     *     title: String (Required)
+     *     summary: String (Optional)
+     *     description: String (Optional)
+     *     kind: String(rest/graphql/grpc/soap/webhook/websocket) (Required)
+     *     lifecycleStage: String(design/development/testing/preview/production/deprecated/retired) (Optional)
+     *     termsOfService (Optional): {
+     *         url: String (Required)
+     *     }
+     *     license (Optional): {
+     *         name: String (Required)
+     *         url: String (Optional)
+     *         identifier: String (Optional)
+     *     }
+     *     externalDocumentation (Optional): [
+     *          (Optional){
+     *             title: String (Required)
+     *             description: String (Required)
+     *             url: String (Required)
+     *         }
+     *     ]
+     *     contacts (Optional): [
+     *          (Optional){
+     *             name: String (Required)
+     *             url: String (Optional)
+     *             email: String (Optional)
+     *         }
+     *     ]
+     *     customProperties (Optional): {
+     *     }
+     *     lastUpdated: OffsetDateTime (Optional)
+     * }
+     * }
+     * 
+ * + * @param workspaceName Workspace identifier. + * @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 Api items as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(String workspaceName, RequestOptions requestOptions) { + RequestOptions requestOptionsForNextPage = new RequestOptions(); + requestOptionsForNextPage.setContext( + requestOptions != null && requestOptions.getContext() != null ? requestOptions.getContext() : Context.NONE); + return new PagedIterable<>((pageSize) -> { + RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions; + if (pageSize != null) { + requestOptionsLocal.addRequestCallback(requestLocal -> { + UrlBuilder urlBuilder = UrlBuilder.parse(requestLocal.getUrl()); + urlBuilder.setQueryParameter("maxpagesize", String.valueOf(pageSize)); + requestLocal.setUrl(urlBuilder.toString()); + }); + } + return listSinglePage(workspaceName, requestOptionsLocal); + }, (nextLink, pageSize) -> { + RequestOptions requestOptionsLocal = new RequestOptions(); + requestOptionsLocal.setContext(requestOptionsForNextPage.getContext()); + if (pageSize != null) { + requestOptionsLocal.addRequestCallback(requestLocal -> { + UrlBuilder urlBuilder = UrlBuilder.parse(requestLocal.getUrl()); + urlBuilder.setQueryParameter("maxpagesize", String.valueOf(pageSize)); + requestLocal.setUrl(urlBuilder.toString()); + }); + } + return listNextSinglePage(nextLink, requestOptionsLocal); + }); + } + + /** + * List a collection of APIs across workspaces. + *

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
+     * {
+     *     value (Required): [
+     *          (Required){
+     *             name: String (Required)
+     *             title: String (Required)
+     *             summary: String (Optional)
+     *             description: String (Optional)
+     *             kind: String(rest/graphql/grpc/soap/webhook/websocket) (Required)
+     *             lifecycleStage: String(design/development/testing/preview/production/deprecated/retired) (Optional)
+     *             termsOfService (Optional): {
+     *                 url: String (Required)
+     *             }
+     *             license (Optional): {
+     *                 name: String (Required)
+     *                 url: String (Optional)
+     *                 identifier: String (Optional)
+     *             }
+     *             externalDocumentation (Optional): [
+     *                  (Optional){
+     *                     title: String (Required)
+     *                     description: String (Required)
+     *                     url: String (Required)
+     *                 }
+     *             ]
+     *             contacts (Optional): [
+     *                  (Optional){
+     *                     name: String (Required)
+     *                     url: String (Optional)
+     *                     email: String (Optional)
+     *                 }
+     *             ]
+     *             customProperties (Optional): {
+     *             }
+     *             lastUpdated: OffsetDateTime (Optional)
+     *         }
+     *     ]
+     *     nextLink: String (Optional)
+     * }
+     * }
+     * 
+ * + * @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 API items across workspaces along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> listAllWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.listAll(this.client.getServiceName(), this.client.getRegion(), + this.client.getServiceVersion().getVersion(), accept, requestOptions, context)); + } + + /** + * List a collection of APIs across workspaces. + *

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
+     * {
+     *     value (Required): [
+     *          (Required){
+     *             name: String (Required)
+     *             title: String (Required)
+     *             summary: String (Optional)
+     *             description: String (Optional)
+     *             kind: String(rest/graphql/grpc/soap/webhook/websocket) (Required)
+     *             lifecycleStage: String(design/development/testing/preview/production/deprecated/retired) (Optional)
+     *             termsOfService (Optional): {
+     *                 url: String (Required)
+     *             }
+     *             license (Optional): {
+     *                 name: String (Required)
+     *                 url: String (Optional)
+     *                 identifier: String (Optional)
+     *             }
+     *             externalDocumentation (Optional): [
+     *                  (Optional){
+     *                     title: String (Required)
+     *                     description: String (Required)
+     *                     url: String (Required)
+     *                 }
+     *             ]
+     *             contacts (Optional): [
+     *                  (Optional){
+     *                     name: String (Required)
+     *                     url: String (Optional)
+     *                     email: String (Optional)
+     *                 }
+     *             ]
+     *             customProperties (Optional): {
+     *             }
+     *             lastUpdated: OffsetDateTime (Optional)
+     *         }
+     *     ]
+     *     nextLink: String (Optional)
+     * }
+     * }
+     * 
+ * + * @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 API items across workspaces along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response listAllWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.listAllSync(this.client.getServiceName(), this.client.getRegion(), + this.client.getServiceVersion().getVersion(), accept, requestOptions, Context.NONE); + } + + /** + * Get an API. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *     title: String (Required)
+     *     summary: String (Optional)
+     *     description: String (Optional)
+     *     kind: String(rest/graphql/grpc/soap/webhook/websocket) (Required)
+     *     lifecycleStage: String(design/development/testing/preview/production/deprecated/retired) (Optional)
+     *     termsOfService (Optional): {
+     *         url: String (Required)
+     *     }
+     *     license (Optional): {
+     *         name: String (Required)
+     *         url: String (Optional)
+     *         identifier: String (Optional)
+     *     }
+     *     externalDocumentation (Optional): [
+     *          (Optional){
+     *             title: String (Required)
+     *             description: String (Required)
+     *             url: String (Required)
+     *         }
+     *     ]
+     *     contacts (Optional): [
+     *          (Optional){
+     *             name: String (Required)
+     *             url: String (Optional)
+     *             email: String (Optional)
+     *         }
+     *     ]
+     *     customProperties (Optional): {
+     *     }
+     *     lastUpdated: OffsetDateTime (Optional)
+     * }
+     * }
+     * 
+ * + * @param workspaceName Workspace identifier. + * @param apiName Api identifier. + * @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 an API along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(String workspaceName, String apiName, + RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getServiceName(), this.client.getRegion(), + this.client.getServiceVersion().getVersion(), workspaceName, apiName, accept, requestOptions, context)); + } + + /** + * Get an API. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *     title: String (Required)
+     *     summary: String (Optional)
+     *     description: String (Optional)
+     *     kind: String(rest/graphql/grpc/soap/webhook/websocket) (Required)
+     *     lifecycleStage: String(design/development/testing/preview/production/deprecated/retired) (Optional)
+     *     termsOfService (Optional): {
+     *         url: String (Required)
+     *     }
+     *     license (Optional): {
+     *         name: String (Required)
+     *         url: String (Optional)
+     *         identifier: String (Optional)
+     *     }
+     *     externalDocumentation (Optional): [
+     *          (Optional){
+     *             title: String (Required)
+     *             description: String (Required)
+     *             url: String (Required)
+     *         }
+     *     ]
+     *     contacts (Optional): [
+     *          (Optional){
+     *             name: String (Required)
+     *             url: String (Optional)
+     *             email: String (Optional)
+     *         }
+     *     ]
+     *     customProperties (Optional): {
+     *     }
+     *     lastUpdated: OffsetDateTime (Optional)
+     * }
+     * }
+     * 
+ * + * @param workspaceName Workspace identifier. + * @param apiName Api identifier. + * @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 an API along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(String workspaceName, String apiName, RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getServiceName(), this.client.getRegion(), + this.client.getServiceVersion().getVersion(), workspaceName, apiName, accept, requestOptions, Context.NONE); + } + + /** + * Get the next page of items. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *     title: String (Required)
+     *     summary: String (Optional)
+     *     description: String (Optional)
+     *     kind: String(rest/graphql/grpc/soap/webhook/websocket) (Required)
+     *     lifecycleStage: String(design/development/testing/preview/production/deprecated/retired) (Optional)
+     *     termsOfService (Optional): {
+     *         url: String (Required)
+     *     }
+     *     license (Optional): {
+     *         name: String (Required)
+     *         url: String (Optional)
+     *         identifier: String (Optional)
+     *     }
+     *     externalDocumentation (Optional): [
+     *          (Optional){
+     *             title: String (Required)
+     *             description: String (Required)
+     *             url: String (Required)
+     *         }
+     *     ]
+     *     contacts (Optional): [
+     *          (Optional){
+     *             name: String (Required)
+     *             url: String (Optional)
+     *             email: String (Optional)
+     *         }
+     *     ]
+     *     customProperties (Optional): {
+     *     }
+     *     lastUpdated: OffsetDateTime (Optional)
+     * }
+     * }
+     * 
+ * + * @param nextLink The URL to get the next list of items. + * @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 Api items along with {@link PagedResponse} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listNextSinglePageAsync(String nextLink, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.listNext(nextLink, this.client.getServiceName(), this.client.getRegion(), + accept, requestOptions, context)) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null)); + } + + /** + * Get the next page of items. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *     title: String (Required)
+     *     summary: String (Optional)
+     *     description: String (Optional)
+     *     kind: String(rest/graphql/grpc/soap/webhook/websocket) (Required)
+     *     lifecycleStage: String(design/development/testing/preview/production/deprecated/retired) (Optional)
+     *     termsOfService (Optional): {
+     *         url: String (Required)
+     *     }
+     *     license (Optional): {
+     *         name: String (Required)
+     *         url: String (Optional)
+     *         identifier: String (Optional)
+     *     }
+     *     externalDocumentation (Optional): [
+     *          (Optional){
+     *             title: String (Required)
+     *             description: String (Required)
+     *             url: String (Required)
+     *         }
+     *     ]
+     *     contacts (Optional): [
+     *          (Optional){
+     *             name: String (Required)
+     *             url: String (Optional)
+     *             email: String (Optional)
+     *         }
+     *     ]
+     *     customProperties (Optional): {
+     *     }
+     *     lastUpdated: OffsetDateTime (Optional)
+     * }
+     * }
+     * 
+ * + * @param nextLink The URL to get the next list of items. + * @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 Api items along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listNextSinglePage(String nextLink, RequestOptions requestOptions) { + final String accept = "application/json"; + Response res = service.listNextSync(nextLink, this.client.getServiceName(), this.client.getRegion(), + accept, requestOptions, Context.NONE); + return 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/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/implementation/DataApiClientImpl.java b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/implementation/DataApiClientImpl.java new file mode 100644 index 000000000000..6f63f6345939 --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/implementation/DataApiClientImpl.java @@ -0,0 +1,206 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.apicenter.implementation; + +import com.azure.apicenter.DataApiServiceVersion; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpPipelineBuilder; +import com.azure.core.http.policy.RetryPolicy; +import com.azure.core.http.policy.UserAgentPolicy; +import com.azure.core.util.serializer.JacksonAdapter; +import com.azure.core.util.serializer.SerializerAdapter; + +/** + * Initializes a new instance of the DataApiClient type. + */ +public final class DataApiClientImpl { + /** + * Region-unique API Center service name. + */ + private final String serviceName; + + /** + * Gets Region-unique API Center service name. + * + * @return the serviceName value. + */ + public String getServiceName() { + return this.serviceName; + } + + /** + * Region name. + */ + private final String region; + + /** + * Gets Region name. + * + * @return the region value. + */ + public String getRegion() { + return this.region; + } + + /** + * Service version. + */ + private final DataApiServiceVersion serviceVersion; + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public DataApiServiceVersion 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; + } + + /** + * The ApisImpl object to access its operations. + */ + private final ApisImpl apis; + + /** + * Gets the ApisImpl object to access its operations. + * + * @return the ApisImpl object. + */ + public ApisImpl getApis() { + return this.apis; + } + + /** + * The ApiDefinitionsImpl object to access its operations. + */ + private final ApiDefinitionsImpl apiDefinitions; + + /** + * Gets the ApiDefinitionsImpl object to access its operations. + * + * @return the ApiDefinitionsImpl object. + */ + public ApiDefinitionsImpl getApiDefinitions() { + return this.apiDefinitions; + } + + /** + * The ApiDeploymentsImpl object to access its operations. + */ + private final ApiDeploymentsImpl apiDeployments; + + /** + * Gets the ApiDeploymentsImpl object to access its operations. + * + * @return the ApiDeploymentsImpl object. + */ + public ApiDeploymentsImpl getApiDeployments() { + return this.apiDeployments; + } + + /** + * The EnvironmentsImpl object to access its operations. + */ + private final EnvironmentsImpl environments; + + /** + * Gets the EnvironmentsImpl object to access its operations. + * + * @return the EnvironmentsImpl object. + */ + public EnvironmentsImpl getEnvironments() { + return this.environments; + } + + /** + * The ApiVersionsImpl object to access its operations. + */ + private final ApiVersionsImpl apiVersions; + + /** + * Gets the ApiVersionsImpl object to access its operations. + * + * @return the ApiVersionsImpl object. + */ + public ApiVersionsImpl getApiVersions() { + return this.apiVersions; + } + + /** + * Initializes an instance of DataApiClient client. + * + * @param serviceName Region-unique API Center service name. + * @param region Region name. + * @param serviceVersion Service version. + */ + public DataApiClientImpl(String serviceName, String region, DataApiServiceVersion serviceVersion) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), serviceName, region, serviceVersion); + } + + /** + * Initializes an instance of DataApiClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param serviceName Region-unique API Center service name. + * @param region Region name. + * @param serviceVersion Service version. + */ + public DataApiClientImpl(HttpPipeline httpPipeline, String serviceName, String region, + DataApiServiceVersion serviceVersion) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), serviceName, region, serviceVersion); + } + + /** + * Initializes an instance of DataApiClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param serializerAdapter The serializer to serialize an object into a string. + * @param serviceName Region-unique API Center service name. + * @param region Region name. + * @param serviceVersion Service version. + */ + public DataApiClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String serviceName, + String region, DataApiServiceVersion serviceVersion) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.serviceName = serviceName; + this.region = region; + this.serviceVersion = serviceVersion; + this.apis = new ApisImpl(this); + this.apiDefinitions = new ApiDefinitionsImpl(this); + this.apiDeployments = new ApiDeploymentsImpl(this); + this.environments = new EnvironmentsImpl(this); + this.apiVersions = new ApiVersionsImpl(this); + } +} diff --git a/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/implementation/EnvironmentsImpl.java b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/implementation/EnvironmentsImpl.java new file mode 100644 index 000000000000..d499a54aad38 --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/implementation/EnvironmentsImpl.java @@ -0,0 +1,747 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.apicenter.implementation; + +import com.azure.apicenter.DataApiServiceVersion; +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.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.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.UrlBuilder; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in Environments. + */ +public final class EnvironmentsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final EnvironmentsService service; + + /** + * The service client containing this operation class. + */ + private final DataApiClientImpl client; + + /** + * Initializes an instance of EnvironmentsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + EnvironmentsImpl(DataApiClientImpl client) { + this.service + = RestProxy.create(EnvironmentsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public DataApiServiceVersion getServiceVersion() { + return client.getServiceVersion(); + } + + /** + * The interface defining all the services for DataApiClientEnvironments to be used by the proxy service to perform + * REST calls. + */ + @Host("https://{serviceName}.data.{region}.azure-apicenter.ms") + @ServiceInterface(name = "DataApiClientEnviron") + public interface EnvironmentsService { + @Get("/workspaces/{workspaceName}/environments") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> list(@HostParam("serviceName") String serviceName, + @HostParam("region") String region, @QueryParam("api-version") String apiVersion, + @PathParam("workspaceName") String workspaceName, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/workspaces/{workspaceName}/environments") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response listSync(@HostParam("serviceName") String serviceName, @HostParam("region") String region, + @QueryParam("api-version") String apiVersion, @PathParam("workspaceName") String workspaceName, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/environments") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> listAll(@HostParam("serviceName") String serviceName, + @HostParam("region") String region, @QueryParam("api-version") String apiVersion, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/environments") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response listAllSync(@HostParam("serviceName") String serviceName, + @HostParam("region") String region, @QueryParam("api-version") String apiVersion, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/workspaces/{workspaceName}/environments/{environmentName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("serviceName") String serviceName, @HostParam("region") String region, + @QueryParam("api-version") String apiVersion, @PathParam("workspaceName") String workspaceName, + @PathParam("environmentName") String environmentName, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/workspaces/{workspaceName}/environments/{environmentName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("serviceName") String serviceName, @HostParam("region") String region, + @QueryParam("api-version") String apiVersion, @PathParam("workspaceName") String workspaceName, + @PathParam("environmentName") String environmentName, @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> listNext(@PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("serviceName") String serviceName, @HostParam("region") String region, + @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) + Response listNextSync(@PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("serviceName") String serviceName, @HostParam("region") String region, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + } + + /** + * List a collection of environments. + *

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)
+     *     title: String (Required)
+     *     kind: String(development/testing/staging/production) (Required)
+     *     description: String (Optional)
+     *     server (Optional): {
+     *         type: String (Required)
+     *         managementPortalUris (Required): [
+     *             String (Required)
+     *         ]
+     *     }
+     *     onboarding (Optional): {
+     *         instructions: String (Required)
+     *         developerPortalUris (Required): [
+     *             String (Required)
+     *         ]
+     *     }
+     *     customProperties (Optional): {
+     *     }
+     * }
+     * }
+     * 
+ * + * @param workspaceName Workspace identifier. + * @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 Environment items along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listSinglePageAsync(String workspaceName, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.list(this.client.getServiceName(), this.client.getRegion(), + this.client.getServiceVersion().getVersion(), workspaceName, accept, requestOptions, context)) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null)); + } + + /** + * List a collection of environments. + *

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)
+     *     title: String (Required)
+     *     kind: String(development/testing/staging/production) (Required)
+     *     description: String (Optional)
+     *     server (Optional): {
+     *         type: String (Required)
+     *         managementPortalUris (Required): [
+     *             String (Required)
+     *         ]
+     *     }
+     *     onboarding (Optional): {
+     *         instructions: String (Required)
+     *         developerPortalUris (Required): [
+     *             String (Required)
+     *         ]
+     *     }
+     *     customProperties (Optional): {
+     *     }
+     * }
+     * }
+     * 
+ * + * @param workspaceName Workspace identifier. + * @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 Environment items as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listAsync(String workspaceName, RequestOptions requestOptions) { + RequestOptions requestOptionsForNextPage = new RequestOptions(); + requestOptionsForNextPage.setContext( + requestOptions != null && requestOptions.getContext() != null ? requestOptions.getContext() : Context.NONE); + return new PagedFlux<>((pageSize) -> { + RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions; + if (pageSize != null) { + requestOptionsLocal.addRequestCallback(requestLocal -> { + UrlBuilder urlBuilder = UrlBuilder.parse(requestLocal.getUrl()); + urlBuilder.setQueryParameter("maxpagesize", String.valueOf(pageSize)); + requestLocal.setUrl(urlBuilder.toString()); + }); + } + return listSinglePageAsync(workspaceName, requestOptionsLocal); + }, (nextLink, pageSize) -> { + RequestOptions requestOptionsLocal = new RequestOptions(); + requestOptionsLocal.setContext(requestOptionsForNextPage.getContext()); + if (pageSize != null) { + requestOptionsLocal.addRequestCallback(requestLocal -> { + UrlBuilder urlBuilder = UrlBuilder.parse(requestLocal.getUrl()); + urlBuilder.setQueryParameter("maxpagesize", String.valueOf(pageSize)); + requestLocal.setUrl(urlBuilder.toString()); + }); + } + return listNextSinglePageAsync(nextLink, requestOptionsLocal); + }); + } + + /** + * List a collection of environments. + *

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)
+     *     title: String (Required)
+     *     kind: String(development/testing/staging/production) (Required)
+     *     description: String (Optional)
+     *     server (Optional): {
+     *         type: String (Required)
+     *         managementPortalUris (Required): [
+     *             String (Required)
+     *         ]
+     *     }
+     *     onboarding (Optional): {
+     *         instructions: String (Required)
+     *         developerPortalUris (Required): [
+     *             String (Required)
+     *         ]
+     *     }
+     *     customProperties (Optional): {
+     *     }
+     * }
+     * }
+     * 
+ * + * @param workspaceName Workspace identifier. + * @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 Environment items along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listSinglePage(String workspaceName, RequestOptions requestOptions) { + final String accept = "application/json"; + Response res = service.listSync(this.client.getServiceName(), this.client.getRegion(), + this.client.getServiceVersion().getVersion(), workspaceName, accept, requestOptions, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null); + } + + /** + * List a collection of environments. + *

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)
+     *     title: String (Required)
+     *     kind: String(development/testing/staging/production) (Required)
+     *     description: String (Optional)
+     *     server (Optional): {
+     *         type: String (Required)
+     *         managementPortalUris (Required): [
+     *             String (Required)
+     *         ]
+     *     }
+     *     onboarding (Optional): {
+     *         instructions: String (Required)
+     *         developerPortalUris (Required): [
+     *             String (Required)
+     *         ]
+     *     }
+     *     customProperties (Optional): {
+     *     }
+     * }
+     * }
+     * 
+ * + * @param workspaceName Workspace identifier. + * @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 Environment items as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(String workspaceName, RequestOptions requestOptions) { + RequestOptions requestOptionsForNextPage = new RequestOptions(); + requestOptionsForNextPage.setContext( + requestOptions != null && requestOptions.getContext() != null ? requestOptions.getContext() : Context.NONE); + return new PagedIterable<>((pageSize) -> { + RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions; + if (pageSize != null) { + requestOptionsLocal.addRequestCallback(requestLocal -> { + UrlBuilder urlBuilder = UrlBuilder.parse(requestLocal.getUrl()); + urlBuilder.setQueryParameter("maxpagesize", String.valueOf(pageSize)); + requestLocal.setUrl(urlBuilder.toString()); + }); + } + return listSinglePage(workspaceName, requestOptionsLocal); + }, (nextLink, pageSize) -> { + RequestOptions requestOptionsLocal = new RequestOptions(); + requestOptionsLocal.setContext(requestOptionsForNextPage.getContext()); + if (pageSize != null) { + requestOptionsLocal.addRequestCallback(requestLocal -> { + UrlBuilder urlBuilder = UrlBuilder.parse(requestLocal.getUrl()); + urlBuilder.setQueryParameter("maxpagesize", String.valueOf(pageSize)); + requestLocal.setUrl(urlBuilder.toString()); + }); + } + return listNextSinglePage(nextLink, requestOptionsLocal); + }); + } + + /** + * List a collection of environments across workspaces. + *

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
+     * {
+     *     value (Required): [
+     *          (Required){
+     *             name: String (Required)
+     *             title: String (Required)
+     *             kind: String(development/testing/staging/production) (Required)
+     *             description: String (Optional)
+     *             server (Optional): {
+     *                 type: String (Required)
+     *                 managementPortalUris (Required): [
+     *                     String (Required)
+     *                 ]
+     *             }
+     *             onboarding (Optional): {
+     *                 instructions: String (Required)
+     *                 developerPortalUris (Required): [
+     *                     String (Required)
+     *                 ]
+     *             }
+     *             customProperties (Optional): {
+     *             }
+     *         }
+     *     ]
+     *     nextLink: String (Optional)
+     * }
+     * }
+     * 
+ * + * @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 Environment items across workspaces along with {@link Response} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> listAllWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.listAll(this.client.getServiceName(), this.client.getRegion(), + this.client.getServiceVersion().getVersion(), accept, requestOptions, context)); + } + + /** + * List a collection of environments across workspaces. + *

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
+     * {
+     *     value (Required): [
+     *          (Required){
+     *             name: String (Required)
+     *             title: String (Required)
+     *             kind: String(development/testing/staging/production) (Required)
+     *             description: String (Optional)
+     *             server (Optional): {
+     *                 type: String (Required)
+     *                 managementPortalUris (Required): [
+     *                     String (Required)
+     *                 ]
+     *             }
+     *             onboarding (Optional): {
+     *                 instructions: String (Required)
+     *                 developerPortalUris (Required): [
+     *                     String (Required)
+     *                 ]
+     *             }
+     *             customProperties (Optional): {
+     *             }
+     *         }
+     *     ]
+     *     nextLink: String (Optional)
+     * }
+     * }
+     * 
+ * + * @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 Environment items across workspaces along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response listAllWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.listAllSync(this.client.getServiceName(), this.client.getRegion(), + this.client.getServiceVersion().getVersion(), accept, requestOptions, Context.NONE); + } + + /** + * Get an environment. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *     title: String (Required)
+     *     kind: String(development/testing/staging/production) (Required)
+     *     description: String (Optional)
+     *     server (Optional): {
+     *         type: String (Required)
+     *         managementPortalUris (Required): [
+     *             String (Required)
+     *         ]
+     *     }
+     *     onboarding (Optional): {
+     *         instructions: String (Required)
+     *         developerPortalUris (Required): [
+     *             String (Required)
+     *         ]
+     *     }
+     *     customProperties (Optional): {
+     *     }
+     * }
+     * }
+     * 
+ * + * @param workspaceName Workspace identifier. + * @param environmentName Environment identifier. + * @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 an environment along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(String workspaceName, String environmentName, + RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getServiceName(), this.client.getRegion(), + this.client.getServiceVersion().getVersion(), workspaceName, environmentName, accept, requestOptions, + context)); + } + + /** + * Get an environment. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *     title: String (Required)
+     *     kind: String(development/testing/staging/production) (Required)
+     *     description: String (Optional)
+     *     server (Optional): {
+     *         type: String (Required)
+     *         managementPortalUris (Required): [
+     *             String (Required)
+     *         ]
+     *     }
+     *     onboarding (Optional): {
+     *         instructions: String (Required)
+     *         developerPortalUris (Required): [
+     *             String (Required)
+     *         ]
+     *     }
+     *     customProperties (Optional): {
+     *     }
+     * }
+     * }
+     * 
+ * + * @param workspaceName Workspace identifier. + * @param environmentName Environment identifier. + * @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 an environment along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(String workspaceName, String environmentName, + RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getServiceName(), this.client.getRegion(), + this.client.getServiceVersion().getVersion(), workspaceName, environmentName, accept, requestOptions, + Context.NONE); + } + + /** + * Get the next page of items. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *     title: String (Required)
+     *     kind: String(development/testing/staging/production) (Required)
+     *     description: String (Optional)
+     *     server (Optional): {
+     *         type: String (Required)
+     *         managementPortalUris (Required): [
+     *             String (Required)
+     *         ]
+     *     }
+     *     onboarding (Optional): {
+     *         instructions: String (Required)
+     *         developerPortalUris (Required): [
+     *             String (Required)
+     *         ]
+     *     }
+     *     customProperties (Optional): {
+     *     }
+     * }
+     * }
+     * 
+ * + * @param nextLink The URL to get the next list of items. + * @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 Environment items along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listNextSinglePageAsync(String nextLink, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.listNext(nextLink, this.client.getServiceName(), this.client.getRegion(), + accept, requestOptions, context)) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null)); + } + + /** + * Get the next page of items. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *     title: String (Required)
+     *     kind: String(development/testing/staging/production) (Required)
+     *     description: String (Optional)
+     *     server (Optional): {
+     *         type: String (Required)
+     *         managementPortalUris (Required): [
+     *             String (Required)
+     *         ]
+     *     }
+     *     onboarding (Optional): {
+     *         instructions: String (Required)
+     *         developerPortalUris (Required): [
+     *             String (Required)
+     *         ]
+     *     }
+     *     customProperties (Optional): {
+     *     }
+     * }
+     * }
+     * 
+ * + * @param nextLink The URL to get the next list of items. + * @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 Environment items along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listNextSinglePage(String nextLink, RequestOptions requestOptions) { + final String accept = "application/json"; + Response res = service.listNextSync(nextLink, this.client.getServiceName(), this.client.getRegion(), + accept, requestOptions, Context.NONE); + return 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/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/implementation/OperationLocationPollingStrategy.java b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/implementation/OperationLocationPollingStrategy.java new file mode 100644 index 000000000000..a7c58c208eed --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/implementation/OperationLocationPollingStrategy.java @@ -0,0 +1,140 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.apicenter.implementation; + +import com.azure.core.exception.AzureException; +import com.azure.core.http.HttpHeader; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; +import com.azure.core.util.logging.ClientLogger; +import com.azure.core.util.polling.LongRunningOperationStatus; +import com.azure.core.util.polling.OperationResourcePollingStrategy; +import com.azure.core.util.polling.PollResponse; +import com.azure.core.util.polling.PollingContext; +import com.azure.core.util.polling.PollingStrategyOptions; +import com.azure.core.util.serializer.JsonSerializerProviders; +import com.azure.core.util.serializer.ObjectSerializer; +import com.azure.core.util.serializer.TypeReference; +import java.time.Duration; +import java.time.OffsetDateTime; +import reactor.core.publisher.Mono; + +// DO NOT modify this helper class + +/** + * Implements an operation location polling strategy, from Operation-Location. + * + * @param the type of the response type from a polling call, or BinaryData if raw response body should be kept + * @param the type of the final result object to deserialize into, or BinaryData if raw response body should be + * kept + */ +public final class OperationLocationPollingStrategy extends OperationResourcePollingStrategy { + + private static final ClientLogger LOGGER = new ClientLogger(OperationLocationPollingStrategy.class); + + private final ObjectSerializer serializer; + private final String endpoint; + private final String propertyName; + + /** + * Creates an instance of the operation resource polling strategy. + * + * @param pollingStrategyOptions options to configure this polling strategy. + * @throws NullPointerException if {@code pollingStrategyOptions} is null. + */ + public OperationLocationPollingStrategy(PollingStrategyOptions pollingStrategyOptions) { + this(pollingStrategyOptions, null); + } + + /** + * Creates an instance of the operation resource polling strategy. + * + * @param pollingStrategyOptions options to configure this polling strategy. + * @param propertyName the name of the property to extract final result. + * @throws NullPointerException if {@code pollingStrategyOptions} is null. + */ + public OperationLocationPollingStrategy(PollingStrategyOptions pollingStrategyOptions, String propertyName) { + super(PollingUtils.OPERATION_LOCATION_HEADER, pollingStrategyOptions); + this.propertyName = propertyName; + this.endpoint = pollingStrategyOptions.getEndpoint(); + this.serializer = pollingStrategyOptions.getSerializer() != null + ? pollingStrategyOptions.getSerializer() + : JsonSerializerProviders.createInstance(true); + } + + /** + * {@inheritDoc} + */ + @Override + public Mono> onInitialResponse(Response response, PollingContext pollingContext, + TypeReference pollResponseType) { + // Response is Response + + HttpHeader operationLocationHeader = response.getHeaders().get(PollingUtils.OPERATION_LOCATION_HEADER); + if (operationLocationHeader != null) { + pollingContext.setData(PollingUtils.OPERATION_LOCATION_HEADER.getCaseSensitiveName(), + PollingUtils.getAbsolutePath(operationLocationHeader.getValue(), endpoint, LOGGER)); + } + final String httpMethod = response.getRequest().getHttpMethod().name(); + pollingContext.setData(PollingUtils.HTTP_METHOD, httpMethod); + pollingContext.setData(PollingUtils.REQUEST_URL, response.getRequest().getUrl().toString()); + + if (response.getStatusCode() == 200 + || response.getStatusCode() == 201 + || response.getStatusCode() == 202 + || response.getStatusCode() == 204) { + final Duration retryAfter + = PollingUtils.getRetryAfterFromHeaders(response.getHeaders(), OffsetDateTime::now); + final Mono> pollResponseMono + = PollingUtils.deserializeResponse((BinaryData) response.getValue(), serializer, pollResponseType) + .onErrorResume(exception -> { + LOGGER.info("Failed to parse initial response."); + return Mono.empty(); + }) + .map(value -> new PollResponse<>(LongRunningOperationStatus.IN_PROGRESS, value, retryAfter)); + return pollResponseMono.switchIfEmpty( + Mono.fromSupplier(() -> new PollResponse<>(LongRunningOperationStatus.IN_PROGRESS, null, retryAfter))); + } else { + return Mono + .error( + new AzureException(String.format( + "Operation failed or cancelled with status code %d," + + ", '%s' header: %s, and response body: %s", + response.getStatusCode(), PollingUtils.OPERATION_LOCATION_HEADER, operationLocationHeader, + response.getValue()))); + } + } + + /** + * {@inheritDoc} + */ + @Override + public Mono getResult(PollingContext pollingContext, TypeReference resultType) { + if (pollingContext.getLatestResponse().getStatus() == LongRunningOperationStatus.FAILED) { + return Mono.error(new AzureException("Long running operation failed.")); + } else if (pollingContext.getLatestResponse().getStatus() == LongRunningOperationStatus.USER_CANCELLED) { + return Mono.error(new AzureException("Long running operation cancelled.")); + } + if (propertyName != null) { + // take the last poll response body from PollingContext, + // and de-serialize the property as final result + BinaryData latestResponseBody + = BinaryData.fromString(pollingContext.getData(PollingUtils.POLL_RESPONSE_BODY)); + return PollingUtils + .deserializeResponse(latestResponseBody, serializer, PollingUtils.POST_POLL_RESULT_TYPE_REFERENCE) + .flatMap(value -> { + if (value.get(propertyName) != null) { + return BinaryData.fromObjectAsync(value.get(propertyName)) + .flatMap(result -> PollingUtils.deserializeResponse(result, serializer, resultType)); + } else { + return Mono.error(new AzureException("Cannot get final result")); + } + }) + .switchIfEmpty(Mono.error(new AzureException("Cannot get final result"))); + } else { + return super.getResult(pollingContext, resultType); + } + } +} diff --git a/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/implementation/PollingUtils.java b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/implementation/PollingUtils.java new file mode 100644 index 000000000000..514363a78afe --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/implementation/PollingUtils.java @@ -0,0 +1,151 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.apicenter.implementation; + +import com.azure.core.http.HttpHeaderName; +import com.azure.core.http.HttpHeaders; +import com.azure.core.util.BinaryData; +import com.azure.core.util.CoreUtils; +import com.azure.core.util.DateTimeRfc1123; +import com.azure.core.util.logging.ClientLogger; +import com.azure.core.util.serializer.ObjectSerializer; +import com.azure.core.util.serializer.TypeReference; +import java.net.URI; +import java.net.URISyntaxException; +import java.time.DateTimeException; +import java.time.Duration; +import java.time.OffsetDateTime; +import java.time.temporal.ChronoUnit; +import java.util.Map; +import java.util.function.Function; +import java.util.function.Supplier; +import reactor.core.publisher.Mono; + +// DO NOT modify this helper class + +final class PollingUtils { + + public static final TypeReference> POST_POLL_RESULT_TYPE_REFERENCE + = new TypeReference>() { + }; + + public static final HttpHeaderName OPERATION_LOCATION_HEADER = HttpHeaderName.fromString("Operation-Location"); + + public static final String HTTP_METHOD = "httpMethod"; + public static final String REQUEST_URL = "requestURL"; + public static final String POLL_RESPONSE_BODY = "pollResponseBody"; + + private static final String FORWARD_SLASH = "/"; + + public static String getAbsolutePath(String path, String endpoint, ClientLogger logger) { + try { + URI uri = new URI(path); + if (!uri.isAbsolute()) { + if (CoreUtils.isNullOrEmpty(endpoint)) { + throw logger.logExceptionAsError(new IllegalArgumentException( + "Relative path requires endpoint to be non-null and non-empty to create an absolute path.")); + } + + if (endpoint.endsWith(FORWARD_SLASH) && path.startsWith(FORWARD_SLASH)) { + return endpoint + path.substring(1); + } else if (!endpoint.endsWith(FORWARD_SLASH) && !path.startsWith(FORWARD_SLASH)) { + return endpoint + FORWARD_SLASH + path; + } else { + return endpoint + path; + } + } + } catch (URISyntaxException ex) { + throw logger.logExceptionAsWarning(new IllegalArgumentException("'path' must be a valid URI.", ex)); + } + return path; + } + + public static T deserializeResponseSync(BinaryData binaryData, ObjectSerializer serializer, + TypeReference typeReference) { + T value; + if (binaryData == null) { + value = null; + } else if (typeReference.getJavaClass().isAssignableFrom(BinaryData.class)) { + // T is BinaryData + value = typeReference.getJavaClass().cast(binaryData.toReplayableBinaryData()); + } else { + value = binaryData.toObject(typeReference, serializer); + } + return value; + } + + @SuppressWarnings("unchecked") + public static Mono deserializeResponse(BinaryData binaryData, ObjectSerializer serializer, + TypeReference typeReference) { + Mono value; + if (binaryData == null) { + value = Mono.empty(); + } else if (typeReference.getJavaClass().isAssignableFrom(BinaryData.class)) { + // T is BinaryData + value = (Mono) binaryData.toReplayableBinaryDataAsync(); + } else { + value = binaryData.toObjectAsync(typeReference, serializer); + } + return value; + } + + private static final HttpHeaderName RETRY_AFTER_MS_HEADER = HttpHeaderName.fromString("retry-after-ms"); + private static final HttpHeaderName X_MS_RETRY_AFTER_MS_HEADER = HttpHeaderName.fromString("x-ms-retry-after-ms"); + + public static Duration getRetryAfterFromHeaders(HttpHeaders headers, Supplier nowSupplier) { + // Found 'x-ms-retry-after-ms' header, use a Duration of milliseconds based on the value. + Duration retryDelay = tryGetRetryDelay(headers, X_MS_RETRY_AFTER_MS_HEADER, s -> tryGetDelayMillis(s)); + if (retryDelay != null) { + return retryDelay; + } + + // Found 'retry-after-ms' header, use a Duration of milliseconds based on the value. + retryDelay = tryGetRetryDelay(headers, RETRY_AFTER_MS_HEADER, s -> tryGetDelayMillis(s)); + if (retryDelay != null) { + return retryDelay; + } + + // Found 'Retry-After' header. First, attempt to resolve it as a Duration of seconds. If that fails, then + // attempt to resolve it as an HTTP date (RFC1123). + retryDelay = tryGetRetryDelay(headers, HttpHeaderName.RETRY_AFTER, + headerValue -> tryParseLongOrDateTime(headerValue, nowSupplier)); + + // Either the retry delay will have been found or it'll be null, null indicates no retry after. + return retryDelay; + } + + private static Duration tryGetRetryDelay(HttpHeaders headers, HttpHeaderName headerName, + Function delayParser) { + String headerValue = headers.getValue(headerName); + + return CoreUtils.isNullOrEmpty(headerValue) ? null : delayParser.apply(headerValue); + } + + private static Duration tryParseLongOrDateTime(String value, Supplier nowSupplier) { + long delaySeconds; + try { + OffsetDateTime retryAfter = new DateTimeRfc1123(value).getDateTime(); + + delaySeconds = nowSupplier.get().until(retryAfter, ChronoUnit.SECONDS); + } catch (DateTimeException ex) { + delaySeconds = tryParseLong(value); + } + + return (delaySeconds >= 0) ? Duration.ofSeconds(delaySeconds) : null; + } + + private static long tryParseLong(String value) { + try { + return Long.parseLong(value); + } catch (NumberFormatException ex) { + return -1; + } + } + + private static Duration tryGetDelayMillis(String value) { + long delayMillis = tryParseLong(value); + return (delayMillis >= 0) ? Duration.ofMillis(delayMillis) : null; + } +} diff --git a/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/implementation/SyncOperationLocationPollingStrategy.java b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/implementation/SyncOperationLocationPollingStrategy.java new file mode 100644 index 000000000000..29492eaaf833 --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/implementation/SyncOperationLocationPollingStrategy.java @@ -0,0 +1,133 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.apicenter.implementation; + +import com.azure.core.exception.AzureException; +import com.azure.core.http.HttpHeader; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; +import com.azure.core.util.logging.ClientLogger; +import com.azure.core.util.polling.LongRunningOperationStatus; +import com.azure.core.util.polling.PollResponse; +import com.azure.core.util.polling.PollingContext; +import com.azure.core.util.polling.PollingStrategyOptions; +import com.azure.core.util.polling.SyncOperationResourcePollingStrategy; +import com.azure.core.util.serializer.JsonSerializerProviders; +import com.azure.core.util.serializer.ObjectSerializer; +import com.azure.core.util.serializer.TypeReference; +import java.io.UncheckedIOException; +import java.time.Duration; +import java.time.OffsetDateTime; +import java.util.Map; + +// DO NOT modify this helper class + +/** + * Implements a synchronous operation location polling strategy, from Operation-Location. + * + * @param the type of the response type from a polling call, or BinaryData if raw response body should be kept + * @param the type of the final result object to deserialize into, or BinaryData if raw response body should be + * kept + */ +public final class SyncOperationLocationPollingStrategy extends SyncOperationResourcePollingStrategy { + + private static final ClientLogger LOGGER = new ClientLogger(SyncOperationLocationPollingStrategy.class); + + private final ObjectSerializer serializer; + private final String endpoint; + private final String propertyName; + + /** + * Creates an instance of the operation resource polling strategy. + * + * @param pollingStrategyOptions options to configure this polling strategy. + * @throws NullPointerException if {@code pollingStrategyOptions} is null. + */ + public SyncOperationLocationPollingStrategy(PollingStrategyOptions pollingStrategyOptions) { + this(pollingStrategyOptions, null); + } + + /** + * Creates an instance of the operation resource polling strategy. + * + * @param pollingStrategyOptions options to configure this polling strategy. + * @param propertyName the name of the property to extract final result. + * @throws NullPointerException if {@code pollingStrategyOptions} is null. + */ + public SyncOperationLocationPollingStrategy(PollingStrategyOptions pollingStrategyOptions, String propertyName) { + super(PollingUtils.OPERATION_LOCATION_HEADER, pollingStrategyOptions); + this.propertyName = propertyName; + this.endpoint = pollingStrategyOptions.getEndpoint(); + this.serializer = pollingStrategyOptions.getSerializer() != null + ? pollingStrategyOptions.getSerializer() + : JsonSerializerProviders.createInstance(true); + } + + /** + * {@inheritDoc} + */ + @Override + public PollResponse onInitialResponse(Response response, PollingContext pollingContext, + TypeReference pollResponseType) { + // Response is Response + + HttpHeader operationLocationHeader = response.getHeaders().get(PollingUtils.OPERATION_LOCATION_HEADER); + if (operationLocationHeader != null) { + pollingContext.setData(PollingUtils.OPERATION_LOCATION_HEADER.getCaseSensitiveName(), + PollingUtils.getAbsolutePath(operationLocationHeader.getValue(), endpoint, LOGGER)); + } + final String httpMethod = response.getRequest().getHttpMethod().name(); + pollingContext.setData(PollingUtils.HTTP_METHOD, httpMethod); + pollingContext.setData(PollingUtils.REQUEST_URL, response.getRequest().getUrl().toString()); + + if (response.getStatusCode() == 200 + || response.getStatusCode() == 201 + || response.getStatusCode() == 202 + || response.getStatusCode() == 204) { + final Duration retryAfter + = PollingUtils.getRetryAfterFromHeaders(response.getHeaders(), OffsetDateTime::now); + T initialResponseType = null; + try { + initialResponseType = PollingUtils.deserializeResponseSync((BinaryData) response.getValue(), serializer, + pollResponseType); + } catch (UncheckedIOException e) { + LOGGER.info("Failed to parse initial response."); + } + return new PollResponse<>(LongRunningOperationStatus.IN_PROGRESS, initialResponseType, retryAfter); + } + + throw LOGGER.logExceptionAsError(new AzureException( + String.format("Operation failed or cancelled with status code %d, '%s' header: %s, and response body: %s", + response.getStatusCode(), PollingUtils.OPERATION_LOCATION_HEADER, operationLocationHeader, + response.getValue()))); + } + + /** + * {@inheritDoc} + */ + public U getResult(PollingContext pollingContext, TypeReference resultType) { + if (pollingContext.getLatestResponse().getStatus() == LongRunningOperationStatus.FAILED) { + throw LOGGER.logExceptionAsError(new AzureException("Long running operation failed.")); + } else if (pollingContext.getLatestResponse().getStatus() == LongRunningOperationStatus.USER_CANCELLED) { + throw LOGGER.logExceptionAsError(new AzureException("Long running operation cancelled.")); + } + if (propertyName != null) { + // take the last poll response body from PollingContext, + // and de-serialize the property as final result + BinaryData latestResponseBody + = BinaryData.fromString(pollingContext.getData(PollingUtils.POLL_RESPONSE_BODY)); + Map pollResult = PollingUtils.deserializeResponseSync(latestResponseBody, serializer, + PollingUtils.POST_POLL_RESULT_TYPE_REFERENCE); + if (pollResult != null && pollResult.get(propertyName) != null) { + return PollingUtils.deserializeResponseSync(BinaryData.fromObject(pollResult.get(propertyName)), + serializer, resultType); + } else { + throw LOGGER.logExceptionAsError(new AzureException("Cannot get final result")); + } + } else { + return super.getResult(pollingContext, resultType); + } + } +} diff --git a/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/implementation/package-info.java b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/implementation/package-info.java new file mode 100644 index 000000000000..4e3a2e145bfa --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/implementation/package-info.java @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the implementations for DataApi. + * Data API introduces endpoints to manage your API Center resources. + */ +package com.azure.apicenter.implementation; diff --git a/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/models/Api.java b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/models/Api.java new file mode 100644 index 000000000000..87a344187f6a --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/models/Api.java @@ -0,0 +1,319 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.apicenter.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.core.util.CoreUtils; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.time.OffsetDateTime; +import java.util.List; + +/** + * API resource model. + */ +@Immutable +public final class Api implements JsonSerializable { + /* + * Api identifier. + */ + @Generated + private String name; + + /* + * The name of the API. + */ + @Generated + private final String title; + + /* + * Short description of the API. + */ + @Generated + private String summary; + + /* + * The description of the API + */ + @Generated + private String description; + + /* + * Kind of API. For example, REST or GraphQL. + */ + @Generated + private final ApiKind kind; + + /* + * Current lifecycle stage of the API. + */ + @Generated + private LifecycleStage lifecycleStage; + + /* + * Terms of service for the API. + */ + @Generated + private TermsOfService termsOfService; + + /* + * The license information for the API. + */ + @Generated + private License license; + + /* + * External documentation + */ + @Generated + private List externalDocumentation; + + /* + * Points of contact for the API. + */ + @Generated + private List contacts; + + /* + * The custom metadata defined for API entities. + */ + @Generated + private ApiCustomProperties customProperties; + + /* + * Last updated date and time. + */ + @Generated + private OffsetDateTime lastUpdated; + + /** + * Creates an instance of Api class. + * + * @param title the title value to set. + * @param kind the kind value to set. + */ + @Generated + private Api(String title, ApiKind kind) { + this.title = title; + this.kind = kind; + } + + /** + * Get the name property: Api identifier. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * Get the title property: The name of the API. + * + * @return the title value. + */ + @Generated + public String getTitle() { + return this.title; + } + + /** + * Get the summary property: Short description of the API. + * + * @return the summary value. + */ + @Generated + public String getSummary() { + return this.summary; + } + + /** + * Get the description property: The description of the API. + * + * @return the description value. + */ + @Generated + public String getDescription() { + return this.description; + } + + /** + * Get the kind property: Kind of API. For example, REST or GraphQL. + * + * @return the kind value. + */ + @Generated + public ApiKind getKind() { + return this.kind; + } + + /** + * Get the lifecycleStage property: Current lifecycle stage of the API. + * + * @return the lifecycleStage value. + */ + @Generated + public LifecycleStage getLifecycleStage() { + return this.lifecycleStage; + } + + /** + * Get the termsOfService property: Terms of service for the API. + * + * @return the termsOfService value. + */ + @Generated + public TermsOfService getTermsOfService() { + return this.termsOfService; + } + + /** + * Get the license property: The license information for the API. + * + * @return the license value. + */ + @Generated + public License getLicense() { + return this.license; + } + + /** + * Get the externalDocumentation property: External documentation. + * + * @return the externalDocumentation value. + */ + @Generated + public List getExternalDocumentation() { + return this.externalDocumentation; + } + + /** + * Get the contacts property: Points of contact for the API. + * + * @return the contacts value. + */ + @Generated + public List getContacts() { + return this.contacts; + } + + /** + * Get the customProperties property: The custom metadata defined for API entities. + * + * @return the customProperties value. + */ + @Generated + public ApiCustomProperties getCustomProperties() { + return this.customProperties; + } + + /** + * Get the lastUpdated property: Last updated date and time. + * + * @return the lastUpdated value. + */ + @Generated + public OffsetDateTime getLastUpdated() { + return this.lastUpdated; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("title", this.title); + jsonWriter.writeStringField("kind", this.kind == null ? null : this.kind.toString()); + jsonWriter.writeStringField("summary", this.summary); + jsonWriter.writeStringField("description", this.description); + jsonWriter.writeJsonField("termsOfService", this.termsOfService); + jsonWriter.writeJsonField("license", this.license); + jsonWriter.writeArrayField("externalDocumentation", this.externalDocumentation, + (writer, element) -> writer.writeJson(element)); + jsonWriter.writeArrayField("contacts", this.contacts, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeJsonField("customProperties", this.customProperties); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Api from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Api if the JsonReader was pointing to an instance of it, or null if it was pointing to + * JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the Api. + */ + @Generated + public static Api fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + String title = null; + ApiKind kind = null; + String summary = null; + String description = null; + LifecycleStage lifecycleStage = null; + TermsOfService termsOfService = null; + License license = null; + List externalDocumentation = null; + List contacts = null; + ApiCustomProperties customProperties = null; + OffsetDateTime lastUpdated = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else if ("title".equals(fieldName)) { + title = reader.getString(); + } else if ("kind".equals(fieldName)) { + kind = ApiKind.fromString(reader.getString()); + } else if ("summary".equals(fieldName)) { + summary = reader.getString(); + } else if ("description".equals(fieldName)) { + description = reader.getString(); + } else if ("lifecycleStage".equals(fieldName)) { + lifecycleStage = LifecycleStage.fromString(reader.getString()); + } else if ("termsOfService".equals(fieldName)) { + termsOfService = TermsOfService.fromJson(reader); + } else if ("license".equals(fieldName)) { + license = License.fromJson(reader); + } else if ("externalDocumentation".equals(fieldName)) { + externalDocumentation = reader.readArray(reader1 -> ExternalDocumentation.fromJson(reader1)); + } else if ("contacts".equals(fieldName)) { + contacts = reader.readArray(reader1 -> Contact.fromJson(reader1)); + } else if ("customProperties".equals(fieldName)) { + customProperties = ApiCustomProperties.fromJson(reader); + } else if ("lastUpdated".equals(fieldName)) { + lastUpdated = reader + .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString())); + } else { + reader.skipChildren(); + } + } + Api deserializedApi = new Api(title, kind); + deserializedApi.name = name; + deserializedApi.summary = summary; + deserializedApi.description = description; + deserializedApi.lifecycleStage = lifecycleStage; + deserializedApi.termsOfService = termsOfService; + deserializedApi.license = license; + deserializedApi.externalDocumentation = externalDocumentation; + deserializedApi.contacts = contacts; + deserializedApi.customProperties = customProperties; + deserializedApi.lastUpdated = lastUpdated; + + return deserializedApi; + }); + } +} diff --git a/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/models/ApiCustomProperties.java b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/models/ApiCustomProperties.java new file mode 100644 index 000000000000..c1adf5c4d843 --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/models/ApiCustomProperties.java @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.apicenter.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The ApiCustomProperties model. + */ +@Immutable +public final class ApiCustomProperties implements JsonSerializable { + /** + * Creates an instance of ApiCustomProperties class. + */ + @Generated + private ApiCustomProperties() { + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ApiCustomProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ApiCustomProperties if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the ApiCustomProperties. + */ + @Generated + public static ApiCustomProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ApiCustomProperties deserializedApiCustomProperties = new ApiCustomProperties(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + reader.skipChildren(); + } + + return deserializedApiCustomProperties; + }); + } +} diff --git a/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/models/ApiDefinition.java b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/models/ApiDefinition.java new file mode 100644 index 000000000000..86f19fced4a8 --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/models/ApiDefinition.java @@ -0,0 +1,147 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.apicenter.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * API definition resource model. + */ +@Immutable +public final class ApiDefinition implements JsonSerializable { + /* + * Definition identifier. + */ + @Generated + private String name; + + /* + * The name of the API definition. + */ + @Generated + private final String title; + + /* + * The description of the API definition. + */ + @Generated + private String description; + + /* + * The API specification details. + */ + @Generated + private ApiSpecification specification; + + /** + * Creates an instance of ApiDefinition class. + * + * @param title the title value to set. + */ + @Generated + private ApiDefinition(String title) { + this.title = title; + } + + /** + * Get the name property: Definition identifier. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * Get the title property: The name of the API definition. + * + * @return the title value. + */ + @Generated + public String getTitle() { + return this.title; + } + + /** + * Get the description property: The description of the API definition. + * + * @return the description value. + */ + @Generated + public String getDescription() { + return this.description; + } + + /** + * Get the specification property: The API specification details. + * + * @return the specification value. + */ + @Generated + public ApiSpecification getSpecification() { + return this.specification; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("title", this.title); + jsonWriter.writeStringField("description", this.description); + jsonWriter.writeJsonField("specification", this.specification); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ApiDefinition from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ApiDefinition if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the ApiDefinition. + */ + @Generated + public static ApiDefinition fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + String title = null; + String description = null; + ApiSpecification specification = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else if ("title".equals(fieldName)) { + title = reader.getString(); + } else if ("description".equals(fieldName)) { + description = reader.getString(); + } else if ("specification".equals(fieldName)) { + specification = ApiSpecification.fromJson(reader); + } else { + reader.skipChildren(); + } + } + ApiDefinition deserializedApiDefinition = new ApiDefinition(title); + deserializedApiDefinition.name = name; + deserializedApiDefinition.description = description; + deserializedApiDefinition.specification = specification; + + return deserializedApiDefinition; + }); + } +} diff --git a/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/models/ApiDeployment.java b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/models/ApiDeployment.java new file mode 100644 index 000000000000..9c7620675ac2 --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/models/ApiDeployment.java @@ -0,0 +1,212 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.apicenter.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * API deployment resource model. + */ +@Immutable +public final class ApiDeployment implements JsonSerializable { + /* + * Deployment identifier. + */ + @Generated + private String name; + + /* + * The name of the deployment. + */ + @Generated + private final String title; + + /* + * The description of the deployment. + */ + @Generated + private String description; + + /* + * The name of the deployment environment. + */ + @Generated + private final String environment; + + /* + * The server information of the API deployment. + */ + @Generated + private final ApiDeploymentServer server; + + /* + * The custom metadata defined for API deployment entities. + */ + @Generated + private ApiDeploymentCustomProperties customProperties; + + /* + * Indicates if this is currently recommended deployment. + */ + @Generated + private Boolean recommended; + + /** + * Creates an instance of ApiDeployment class. + * + * @param title the title value to set. + * @param environment the environment value to set. + * @param server the server value to set. + */ + @Generated + private ApiDeployment(String title, String environment, ApiDeploymentServer server) { + this.title = title; + this.environment = environment; + this.server = server; + } + + /** + * Get the name property: Deployment identifier. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * Get the title property: The name of the deployment. + * + * @return the title value. + */ + @Generated + public String getTitle() { + return this.title; + } + + /** + * Get the description property: The description of the deployment. + * + * @return the description value. + */ + @Generated + public String getDescription() { + return this.description; + } + + /** + * Get the environment property: The name of the deployment environment. + * + * @return the environment value. + */ + @Generated + public String getEnvironment() { + return this.environment; + } + + /** + * Get the server property: The server information of the API deployment. + * + * @return the server value. + */ + @Generated + public ApiDeploymentServer getServer() { + return this.server; + } + + /** + * Get the customProperties property: The custom metadata defined for API deployment entities. + * + * @return the customProperties value. + */ + @Generated + public ApiDeploymentCustomProperties getCustomProperties() { + return this.customProperties; + } + + /** + * Get the recommended property: Indicates if this is currently recommended deployment. + * + * @return the recommended value. + */ + @Generated + public Boolean isRecommended() { + return this.recommended; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("title", this.title); + jsonWriter.writeStringField("environment", this.environment); + jsonWriter.writeJsonField("server", this.server); + jsonWriter.writeStringField("description", this.description); + jsonWriter.writeJsonField("customProperties", this.customProperties); + jsonWriter.writeBooleanField("recommended", this.recommended); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ApiDeployment from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ApiDeployment if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the ApiDeployment. + */ + @Generated + public static ApiDeployment fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + String title = null; + String environment = null; + ApiDeploymentServer server = null; + String description = null; + ApiDeploymentCustomProperties customProperties = null; + Boolean recommended = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else if ("title".equals(fieldName)) { + title = reader.getString(); + } else if ("environment".equals(fieldName)) { + environment = reader.getString(); + } else if ("server".equals(fieldName)) { + server = ApiDeploymentServer.fromJson(reader); + } else if ("description".equals(fieldName)) { + description = reader.getString(); + } else if ("customProperties".equals(fieldName)) { + customProperties = ApiDeploymentCustomProperties.fromJson(reader); + } else if ("recommended".equals(fieldName)) { + recommended = reader.getNullable(JsonReader::getBoolean); + } else { + reader.skipChildren(); + } + } + ApiDeployment deserializedApiDeployment = new ApiDeployment(title, environment, server); + deserializedApiDeployment.name = name; + deserializedApiDeployment.description = description; + deserializedApiDeployment.customProperties = customProperties; + deserializedApiDeployment.recommended = recommended; + + return deserializedApiDeployment; + }); + } +} diff --git a/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/models/ApiDeploymentCustomProperties.java b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/models/ApiDeploymentCustomProperties.java new file mode 100644 index 000000000000..b3b074edd8d2 --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/models/ApiDeploymentCustomProperties.java @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.apicenter.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The ApiDeploymentCustomProperties model. + */ +@Immutable +public final class ApiDeploymentCustomProperties implements JsonSerializable { + /** + * Creates an instance of ApiDeploymentCustomProperties class. + */ + @Generated + private ApiDeploymentCustomProperties() { + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ApiDeploymentCustomProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ApiDeploymentCustomProperties if the JsonReader was pointing to an instance of it, or null + * if it was pointing to JSON null. + * @throws IOException If an error occurs while reading the ApiDeploymentCustomProperties. + */ + @Generated + public static ApiDeploymentCustomProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ApiDeploymentCustomProperties deserializedApiDeploymentCustomProperties + = new ApiDeploymentCustomProperties(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + reader.skipChildren(); + } + + return deserializedApiDeploymentCustomProperties; + }); + } +} diff --git a/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/models/ApiDeploymentServer.java b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/models/ApiDeploymentServer.java new file mode 100644 index 000000000000..3fc19bf90f0a --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/models/ApiDeploymentServer.java @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.apicenter.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * Api Deployment Server. + */ +@Immutable +public final class ApiDeploymentServer implements JsonSerializable { + /* + * Base runtime URIs for this deployment. + */ + @Generated + private final List runtimeUris; + + /** + * Creates an instance of ApiDeploymentServer class. + * + * @param runtimeUris the runtimeUris value to set. + */ + @Generated + private ApiDeploymentServer(List runtimeUris) { + this.runtimeUris = runtimeUris; + } + + /** + * Get the runtimeUris property: Base runtime URIs for this deployment. + * + * @return the runtimeUris value. + */ + @Generated + public List getRuntimeUris() { + return this.runtimeUris; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("runtimeUris", this.runtimeUris, (writer, element) -> writer.writeString(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ApiDeploymentServer from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ApiDeploymentServer if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the ApiDeploymentServer. + */ + @Generated + public static ApiDeploymentServer fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + List runtimeUris = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("runtimeUris".equals(fieldName)) { + runtimeUris = reader.readArray(reader1 -> reader1.getString()); + } else { + reader.skipChildren(); + } + } + return new ApiDeploymentServer(runtimeUris); + }); + } +} diff --git a/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/models/ApiKind.java b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/models/ApiKind.java new file mode 100644 index 000000000000..ded21a48c8ce --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/models/ApiKind.java @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.apicenter.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * API kind. + */ +public final class ApiKind extends ExpandableStringEnum { + /** + * REST API. + */ + @Generated + public static final ApiKind REST = fromString("rest"); + + /** + * GraphQL API. + */ + @Generated + public static final ApiKind GRAPHQL = fromString("graphql"); + + /** + * GRPC API. + */ + @Generated + public static final ApiKind GRPC = fromString("grpc"); + + /** + * SOAP API. + */ + @Generated + public static final ApiKind SOAP = fromString("soap"); + + /** + * Webhook API. + */ + @Generated + public static final ApiKind WEBHOOK = fromString("webhook"); + + /** + * Websocket API. + */ + @Generated + public static final ApiKind WEBSOCKET = fromString("websocket"); + + /** + * Creates a new instance of ApiKind value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public ApiKind() { + } + + /** + * Creates or finds a ApiKind from its string representation. + * + * @param name a name to look for. + * @return the corresponding ApiKind. + */ + @Generated + public static ApiKind fromString(String name) { + return fromString(name, ApiKind.class); + } + + /** + * Gets known ApiKind values. + * + * @return known ApiKind values. + */ + @Generated + public static Collection values() { + return values(ApiKind.class); + } +} diff --git a/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/models/ApiSpecExportResult.java b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/models/ApiSpecExportResult.java new file mode 100644 index 000000000000..ba40bbae1940 --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/models/ApiSpecExportResult.java @@ -0,0 +1,127 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.apicenter.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Export specification result model. + */ +@Immutable +public final class ApiSpecExportResult implements JsonSerializable { + /* + * API definition identifier. + */ + @Generated + private String definitionName; + + /* + * The result of the specification export. + */ + @Generated + private final String value; + + /* + * The format of the specification export result. + */ + @Generated + private final ApiSpecExportResultFormat format; + + /** + * Creates an instance of ApiSpecExportResult class. + * + * @param value the value value to set. + * @param format the format value to set. + */ + @Generated + private ApiSpecExportResult(String value, ApiSpecExportResultFormat format) { + this.value = value; + this.format = format; + } + + /** + * Get the definitionName property: API definition identifier. + * + * @return the definitionName value. + */ + @Generated + public String getDefinitionName() { + return this.definitionName; + } + + /** + * Get the value property: The result of the specification export. + * + * @return the value value. + */ + @Generated + public String getValue() { + return this.value; + } + + /** + * Get the format property: The format of the specification export result. + * + * @return the format value. + */ + @Generated + public ApiSpecExportResultFormat getFormat() { + return this.format; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("value", this.value); + jsonWriter.writeStringField("format", this.format == null ? null : this.format.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ApiSpecExportResult from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ApiSpecExportResult if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the ApiSpecExportResult. + */ + @Generated + public static ApiSpecExportResult fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String definitionName = null; + String value = null; + ApiSpecExportResultFormat format = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("definitionName".equals(fieldName)) { + definitionName = reader.getString(); + } else if ("value".equals(fieldName)) { + value = reader.getString(); + } else if ("format".equals(fieldName)) { + format = ApiSpecExportResultFormat.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + ApiSpecExportResult deserializedApiSpecExportResult = new ApiSpecExportResult(value, format); + deserializedApiSpecExportResult.definitionName = definitionName; + + return deserializedApiSpecExportResult; + }); + } +} diff --git a/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/models/ApiSpecExportResultFormat.java b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/models/ApiSpecExportResultFormat.java new file mode 100644 index 000000000000..a8ca60539f18 --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/models/ApiSpecExportResultFormat.java @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.apicenter.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Export specification result format. + */ +public final class ApiSpecExportResultFormat extends ExpandableStringEnum { + /** + * Link format. + */ + @Generated + public static final ApiSpecExportResultFormat LINK = fromString("link"); + + /** + * Creates a new instance of ApiSpecExportResultFormat value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public ApiSpecExportResultFormat() { + } + + /** + * Creates or finds a ApiSpecExportResultFormat from its string representation. + * + * @param name a name to look for. + * @return the corresponding ApiSpecExportResultFormat. + */ + @Generated + public static ApiSpecExportResultFormat fromString(String name) { + return fromString(name, ApiSpecExportResultFormat.class); + } + + /** + * Gets known ApiSpecExportResultFormat values. + * + * @return known ApiSpecExportResultFormat values. + */ + @Generated + public static Collection values() { + return values(ApiSpecExportResultFormat.class); + } +} diff --git a/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/models/ApiSpecification.java b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/models/ApiSpecification.java new file mode 100644 index 000000000000..8e831495b1c5 --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/models/ApiSpecification.java @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.apicenter.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * API specification. + */ +@Immutable +public final class ApiSpecification implements JsonSerializable { + /* + * API specification name, e.g. 'swagger' or 'openapi'. + */ + @Generated + private final String name; + + /* + * API specification version, e.g. '3.0.1'. + */ + @Generated + private final String version; + + /** + * Creates an instance of ApiSpecification class. + * + * @param name the name value to set. + * @param version the version value to set. + */ + @Generated + private ApiSpecification(String name, String version) { + this.name = name; + this.version = version; + } + + /** + * Get the name property: API specification name, e.g. 'swagger' or 'openapi'. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * Get the version property: API specification version, e.g. '3.0.1'. + * + * @return the version value. + */ + @Generated + public String getVersion() { + return this.version; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + jsonWriter.writeStringField("version", this.version); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ApiSpecification from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ApiSpecification if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the ApiSpecification. + */ + @Generated + public static ApiSpecification fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + String version = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else if ("version".equals(fieldName)) { + version = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new ApiSpecification(name, version); + }); + } +} diff --git a/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/models/ApiVersion.java b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/models/ApiVersion.java new file mode 100644 index 000000000000..c1b31776d9eb --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/models/ApiVersion.java @@ -0,0 +1,128 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.apicenter.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * API version resource model. + */ +@Immutable +public final class ApiVersion implements JsonSerializable { + /* + * Version identifier. + */ + @Generated + private String name; + + /* + * Version title. + */ + @Generated + private final String title; + + /* + * Current lifecycle stage of the API version. + */ + @Generated + private final LifecycleStage lifecycleStage; + + /** + * Creates an instance of ApiVersion class. + * + * @param title the title value to set. + * @param lifecycleStage the lifecycleStage value to set. + */ + @Generated + private ApiVersion(String title, LifecycleStage lifecycleStage) { + this.title = title; + this.lifecycleStage = lifecycleStage; + } + + /** + * Get the name property: Version identifier. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * Get the title property: Version title. + * + * @return the title value. + */ + @Generated + public String getTitle() { + return this.title; + } + + /** + * Get the lifecycleStage property: Current lifecycle stage of the API version. + * + * @return the lifecycleStage value. + */ + @Generated + public LifecycleStage getLifecycleStage() { + return this.lifecycleStage; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("title", this.title); + jsonWriter.writeStringField("lifecycleStage", + this.lifecycleStage == null ? null : this.lifecycleStage.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ApiVersion from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ApiVersion if the JsonReader was pointing to an instance of it, or null if it was pointing + * to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the ApiVersion. + */ + @Generated + public static ApiVersion fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + String title = null; + LifecycleStage lifecycleStage = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else if ("title".equals(fieldName)) { + title = reader.getString(); + } else if ("lifecycleStage".equals(fieldName)) { + lifecycleStage = LifecycleStage.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + ApiVersion deserializedApiVersion = new ApiVersion(title, lifecycleStage); + deserializedApiVersion.name = name; + + return deserializedApiVersion; + }); + } +} diff --git a/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/models/Contact.java b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/models/Contact.java new file mode 100644 index 000000000000..e80679178ba0 --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/models/Contact.java @@ -0,0 +1,127 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.apicenter.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * API contact information. + */ +@Immutable +public final class Contact implements JsonSerializable { + /* + * Name of the contact. + */ + @Generated + private final String name; + + /* + * URL for the contact. + */ + @Generated + private String url; + + /* + * Email address for the contact. + */ + @Generated + private String email; + + /** + * Creates an instance of Contact class. + * + * @param name the name value to set. + */ + @Generated + private Contact(String name) { + this.name = name; + } + + /** + * Get the name property: Name of the contact. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * Get the url property: URL for the contact. + * + * @return the url value. + */ + @Generated + public String getUrl() { + return this.url; + } + + /** + * Get the email property: Email address for the contact. + * + * @return the email value. + */ + @Generated + public String getEmail() { + return this.email; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + jsonWriter.writeStringField("url", this.url); + jsonWriter.writeStringField("email", this.email); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Contact from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Contact if the JsonReader was pointing to an instance of it, or null if it was pointing to + * JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the Contact. + */ + @Generated + public static Contact fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + String url = null; + String email = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else if ("url".equals(fieldName)) { + url = reader.getString(); + } else if ("email".equals(fieldName)) { + email = reader.getString(); + } else { + reader.skipChildren(); + } + } + Contact deserializedContact = new Contact(name); + deserializedContact.url = url; + deserializedContact.email = email; + + return deserializedContact; + }); + } +} diff --git a/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/models/Environment.java b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/models/Environment.java new file mode 100644 index 000000000000..f7fc7b796881 --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/models/Environment.java @@ -0,0 +1,211 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.apicenter.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Environment resource model. + */ +@Immutable +public final class Environment implements JsonSerializable { + /* + * Environment identifier. + */ + @Generated + private String name; + + /* + * The name of the environment. + */ + @Generated + private final String title; + + /* + * Kind of deployment environment. + */ + @Generated + private final EnvironmentKind kind; + + /* + * Description of the environment. + */ + @Generated + private String description; + + /* + * Server information of the environment. + */ + @Generated + private EnvironmentServer server; + + /* + * Onboarding information for this environment. + */ + @Generated + private EnvironmentOnboardingModel onboarding; + + /* + * The custom metadata defined for environment entities. + */ + @Generated + private EnvironmentCustomProperties customProperties; + + /** + * Creates an instance of Environment class. + * + * @param title the title value to set. + * @param kind the kind value to set. + */ + @Generated + private Environment(String title, EnvironmentKind kind) { + this.title = title; + this.kind = kind; + } + + /** + * Get the name property: Environment identifier. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * Get the title property: The name of the environment. + * + * @return the title value. + */ + @Generated + public String getTitle() { + return this.title; + } + + /** + * Get the kind property: Kind of deployment environment. + * + * @return the kind value. + */ + @Generated + public EnvironmentKind getKind() { + return this.kind; + } + + /** + * Get the description property: Description of the environment. + * + * @return the description value. + */ + @Generated + public String getDescription() { + return this.description; + } + + /** + * Get the server property: Server information of the environment. + * + * @return the server value. + */ + @Generated + public EnvironmentServer getServer() { + return this.server; + } + + /** + * Get the onboarding property: Onboarding information for this environment. + * + * @return the onboarding value. + */ + @Generated + public EnvironmentOnboardingModel getOnboarding() { + return this.onboarding; + } + + /** + * Get the customProperties property: The custom metadata defined for environment entities. + * + * @return the customProperties value. + */ + @Generated + public EnvironmentCustomProperties getCustomProperties() { + return this.customProperties; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("title", this.title); + jsonWriter.writeStringField("kind", this.kind == null ? null : this.kind.toString()); + jsonWriter.writeStringField("description", this.description); + jsonWriter.writeJsonField("server", this.server); + jsonWriter.writeJsonField("onboarding", this.onboarding); + jsonWriter.writeJsonField("customProperties", this.customProperties); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Environment from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Environment if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the Environment. + */ + @Generated + public static Environment fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + String title = null; + EnvironmentKind kind = null; + String description = null; + EnvironmentServer server = null; + EnvironmentOnboardingModel onboarding = null; + EnvironmentCustomProperties customProperties = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else if ("title".equals(fieldName)) { + title = reader.getString(); + } else if ("kind".equals(fieldName)) { + kind = EnvironmentKind.fromString(reader.getString()); + } else if ("description".equals(fieldName)) { + description = reader.getString(); + } else if ("server".equals(fieldName)) { + server = EnvironmentServer.fromJson(reader); + } else if ("onboarding".equals(fieldName)) { + onboarding = EnvironmentOnboardingModel.fromJson(reader); + } else if ("customProperties".equals(fieldName)) { + customProperties = EnvironmentCustomProperties.fromJson(reader); + } else { + reader.skipChildren(); + } + } + Environment deserializedEnvironment = new Environment(title, kind); + deserializedEnvironment.name = name; + deserializedEnvironment.description = description; + deserializedEnvironment.server = server; + deserializedEnvironment.onboarding = onboarding; + deserializedEnvironment.customProperties = customProperties; + + return deserializedEnvironment; + }); + } +} diff --git a/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/models/EnvironmentCustomProperties.java b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/models/EnvironmentCustomProperties.java new file mode 100644 index 000000000000..7a6009a20f0d --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/models/EnvironmentCustomProperties.java @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.apicenter.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The EnvironmentCustomProperties model. + */ +@Immutable +public final class EnvironmentCustomProperties implements JsonSerializable { + /** + * Creates an instance of EnvironmentCustomProperties class. + */ + @Generated + private EnvironmentCustomProperties() { + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of EnvironmentCustomProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of EnvironmentCustomProperties if the JsonReader was pointing to an instance of it, or null + * if it was pointing to JSON null. + * @throws IOException If an error occurs while reading the EnvironmentCustomProperties. + */ + @Generated + public static EnvironmentCustomProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + EnvironmentCustomProperties deserializedEnvironmentCustomProperties = new EnvironmentCustomProperties(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + reader.skipChildren(); + } + + return deserializedEnvironmentCustomProperties; + }); + } +} diff --git a/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/models/EnvironmentKind.java b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/models/EnvironmentKind.java new file mode 100644 index 000000000000..289aae6d78ba --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/models/EnvironmentKind.java @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.apicenter.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Environment kind. + */ +public final class EnvironmentKind extends ExpandableStringEnum { + /** + * Environment is in the development stage. + */ + @Generated + public static final EnvironmentKind DEVELOPMENT = fromString("development"); + + /** + * Environment is in the testing stage. + */ + @Generated + public static final EnvironmentKind TESTING = fromString("testing"); + + /** + * Environment is in the staging stage. + */ + @Generated + public static final EnvironmentKind STAGING = fromString("staging"); + + /** + * Environment is in the production stage. + */ + @Generated + public static final EnvironmentKind PRODUCTION = fromString("production"); + + /** + * Creates a new instance of EnvironmentKind value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public EnvironmentKind() { + } + + /** + * Creates or finds a EnvironmentKind from its string representation. + * + * @param name a name to look for. + * @return the corresponding EnvironmentKind. + */ + @Generated + public static EnvironmentKind fromString(String name) { + return fromString(name, EnvironmentKind.class); + } + + /** + * Gets known EnvironmentKind values. + * + * @return known EnvironmentKind values. + */ + @Generated + public static Collection values() { + return values(EnvironmentKind.class); + } +} diff --git a/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/models/EnvironmentOnboardingModel.java b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/models/EnvironmentOnboardingModel.java new file mode 100644 index 000000000000..dfecdf13ab04 --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/models/EnvironmentOnboardingModel.java @@ -0,0 +1,107 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.apicenter.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * Environment Onboarding Model. + */ +@Immutable +public final class EnvironmentOnboardingModel implements JsonSerializable { + /* + * Instructions how to onboard to the environment. + */ + @Generated + private final String instructions; + + /* + * Developer portal URIs of the environment. + */ + @Generated + private final List developerPortalUris; + + /** + * Creates an instance of EnvironmentOnboardingModel class. + * + * @param instructions the instructions value to set. + * @param developerPortalUris the developerPortalUris value to set. + */ + @Generated + private EnvironmentOnboardingModel(String instructions, List developerPortalUris) { + this.instructions = instructions; + this.developerPortalUris = developerPortalUris; + } + + /** + * Get the instructions property: Instructions how to onboard to the environment. + * + * @return the instructions value. + */ + @Generated + public String getInstructions() { + return this.instructions; + } + + /** + * Get the developerPortalUris property: Developer portal URIs of the environment. + * + * @return the developerPortalUris value. + */ + @Generated + public List getDeveloperPortalUris() { + return this.developerPortalUris; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("instructions", this.instructions); + jsonWriter.writeArrayField("developerPortalUris", this.developerPortalUris, + (writer, element) -> writer.writeString(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of EnvironmentOnboardingModel from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of EnvironmentOnboardingModel if the JsonReader was pointing to an instance of it, or null if + * it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the EnvironmentOnboardingModel. + */ + @Generated + public static EnvironmentOnboardingModel fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String instructions = null; + List developerPortalUris = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("instructions".equals(fieldName)) { + instructions = reader.getString(); + } else if ("developerPortalUris".equals(fieldName)) { + developerPortalUris = reader.readArray(reader1 -> reader1.getString()); + } else { + reader.skipChildren(); + } + } + return new EnvironmentOnboardingModel(instructions, developerPortalUris); + }); + } +} diff --git a/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/models/EnvironmentServer.java b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/models/EnvironmentServer.java new file mode 100644 index 000000000000..7b8776bdea28 --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/models/EnvironmentServer.java @@ -0,0 +1,107 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.apicenter.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * Environment Server. + */ +@Immutable +public final class EnvironmentServer implements JsonSerializable { + /* + * Type of the server that represents the environment. + */ + @Generated + private final String type; + + /* + * URIs of the server's management portal. + */ + @Generated + private final List managementPortalUris; + + /** + * Creates an instance of EnvironmentServer class. + * + * @param type the type value to set. + * @param managementPortalUris the managementPortalUris value to set. + */ + @Generated + private EnvironmentServer(String type, List managementPortalUris) { + this.type = type; + this.managementPortalUris = managementPortalUris; + } + + /** + * Get the type property: Type of the server that represents the environment. + * + * @return the type value. + */ + @Generated + public String getType() { + return this.type; + } + + /** + * Get the managementPortalUris property: URIs of the server's management portal. + * + * @return the managementPortalUris value. + */ + @Generated + public List getManagementPortalUris() { + return this.managementPortalUris; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("type", this.type); + jsonWriter.writeArrayField("managementPortalUris", this.managementPortalUris, + (writer, element) -> writer.writeString(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of EnvironmentServer from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of EnvironmentServer if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the EnvironmentServer. + */ + @Generated + public static EnvironmentServer fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String type = null; + List managementPortalUris = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("type".equals(fieldName)) { + type = reader.getString(); + } else if ("managementPortalUris".equals(fieldName)) { + managementPortalUris = reader.readArray(reader1 -> reader1.getString()); + } else { + reader.skipChildren(); + } + } + return new EnvironmentServer(type, managementPortalUris); + }); + } +} diff --git a/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/models/ExternalDocumentation.java b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/models/ExternalDocumentation.java new file mode 100644 index 000000000000..a437538a41e0 --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/models/ExternalDocumentation.java @@ -0,0 +1,127 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.apicenter.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Api External Documentation Model. + */ +@Immutable +public final class ExternalDocumentation implements JsonSerializable { + /* + * Title of the documentation. + */ + @Generated + private final String title; + + /* + * Description of the documentation. + */ + @Generated + private final String description; + + /* + * URL pointing to the documentation. + */ + @Generated + private final String url; + + /** + * Creates an instance of ExternalDocumentation class. + * + * @param title the title value to set. + * @param description the description value to set. + * @param url the url value to set. + */ + @Generated + private ExternalDocumentation(String title, String description, String url) { + this.title = title; + this.description = description; + this.url = url; + } + + /** + * Get the title property: Title of the documentation. + * + * @return the title value. + */ + @Generated + public String getTitle() { + return this.title; + } + + /** + * Get the description property: Description of the documentation. + * + * @return the description value. + */ + @Generated + public String getDescription() { + return this.description; + } + + /** + * Get the url property: URL pointing to the documentation. + * + * @return the url value. + */ + @Generated + public String getUrl() { + return this.url; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("title", this.title); + jsonWriter.writeStringField("description", this.description); + jsonWriter.writeStringField("url", this.url); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ExternalDocumentation from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ExternalDocumentation if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the ExternalDocumentation. + */ + @Generated + public static ExternalDocumentation fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String title = null; + String description = null; + String url = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("title".equals(fieldName)) { + title = reader.getString(); + } else if ("description".equals(fieldName)) { + description = reader.getString(); + } else if ("url".equals(fieldName)) { + url = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new ExternalDocumentation(title, description, url); + }); + } +} diff --git a/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/models/License.java b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/models/License.java new file mode 100644 index 000000000000..28de54f1ff68 --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/models/License.java @@ -0,0 +1,129 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.apicenter.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * API License Model. + */ +@Immutable +public final class License implements JsonSerializable { + /* + * Name of the license. + */ + @Generated + private final String name; + + /* + * URL pointing to the license details. The URL field is mutually exclusive of the identifier field. + */ + @Generated + private String url; + + /* + * SPDX license information for the API. The identifier field is mutually exclusive of the URL field. + */ + @Generated + private String identifier; + + /** + * Creates an instance of License class. + * + * @param name the name value to set. + */ + @Generated + private License(String name) { + this.name = name; + } + + /** + * Get the name property: Name of the license. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * Get the url property: URL pointing to the license details. The URL field is mutually exclusive of the identifier + * field. + * + * @return the url value. + */ + @Generated + public String getUrl() { + return this.url; + } + + /** + * Get the identifier property: SPDX license information for the API. The identifier field is mutually exclusive of + * the URL field. + * + * @return the identifier value. + */ + @Generated + public String getIdentifier() { + return this.identifier; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + jsonWriter.writeStringField("url", this.url); + jsonWriter.writeStringField("identifier", this.identifier); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of License from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of License if the JsonReader was pointing to an instance of it, or null if it was pointing to + * JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the License. + */ + @Generated + public static License fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + String url = null; + String identifier = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else if ("url".equals(fieldName)) { + url = reader.getString(); + } else if ("identifier".equals(fieldName)) { + identifier = reader.getString(); + } else { + reader.skipChildren(); + } + } + License deserializedLicense = new License(name); + deserializedLicense.url = url; + deserializedLicense.identifier = identifier; + + return deserializedLicense; + }); + } +} diff --git a/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/models/LifecycleStage.java b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/models/LifecycleStage.java new file mode 100644 index 000000000000..93be22aaf81f --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/models/LifecycleStage.java @@ -0,0 +1,87 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.apicenter.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * API Lifecycle Stage. + */ +public final class LifecycleStage extends ExpandableStringEnum { + /** + * API is in the design stage. + */ + @Generated + public static final LifecycleStage DESIGN = fromString("design"); + + /** + * API is in the development stage. + */ + @Generated + public static final LifecycleStage DEVELOPMENT = fromString("development"); + + /** + * API is in the testing stage. + */ + @Generated + public static final LifecycleStage TESTING = fromString("testing"); + + /** + * API is in the preview stage. + */ + @Generated + public static final LifecycleStage PREVIEW = fromString("preview"); + + /** + * API is in the production stage. + */ + @Generated + public static final LifecycleStage PRODUCTION = fromString("production"); + + /** + * API is in the deprecated stage. + */ + @Generated + public static final LifecycleStage DEPRECATED = fromString("deprecated"); + + /** + * API is in the retired stage. + */ + @Generated + public static final LifecycleStage RETIRED = fromString("retired"); + + /** + * Creates a new instance of LifecycleStage value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public LifecycleStage() { + } + + /** + * Creates or finds a LifecycleStage from its string representation. + * + * @param name a name to look for. + * @return the corresponding LifecycleStage. + */ + @Generated + public static LifecycleStage fromString(String name) { + return fromString(name, LifecycleStage.class); + } + + /** + * Gets known LifecycleStage values. + * + * @return known LifecycleStage values. + */ + @Generated + public static Collection values() { + return values(LifecycleStage.class); + } +} diff --git a/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/models/OperationState.java b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/models/OperationState.java new file mode 100644 index 000000000000..63dcc730e44d --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/models/OperationState.java @@ -0,0 +1,75 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.apicenter.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Enum describing allowed operation states. + */ +public final class OperationState extends ExpandableStringEnum { + /** + * The operation has not started. + */ + @Generated + public static final OperationState NOT_STARTED = fromString("NotStarted"); + + /** + * The operation is in progress. + */ + @Generated + public static final OperationState RUNNING = fromString("Running"); + + /** + * The operation has completed successfully. + */ + @Generated + public static final OperationState SUCCEEDED = fromString("Succeeded"); + + /** + * The operation has failed. + */ + @Generated + public static final OperationState FAILED = fromString("Failed"); + + /** + * The operation has been canceled by the user. + */ + @Generated + public static final OperationState CANCELED = fromString("Canceled"); + + /** + * Creates a new instance of OperationState value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public OperationState() { + } + + /** + * Creates or finds a OperationState from its string representation. + * + * @param name a name to look for. + * @return the corresponding OperationState. + */ + @Generated + public static OperationState fromString(String name) { + return fromString(name, OperationState.class); + } + + /** + * Gets known OperationState values. + * + * @return known OperationState values. + */ + @Generated + public static Collection values() { + return values(OperationState.class); + } +} diff --git a/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/models/PagedApiAll.java b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/models/PagedApiAll.java new file mode 100644 index 000000000000..b94460a715fa --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/models/PagedApiAll.java @@ -0,0 +1,107 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.apicenter.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * Paged collection of API items across workspaces. + */ +@Immutable +public final class PagedApiAll implements JsonSerializable { + /* + * The Api items on this page + */ + @Generated + private final List value; + + /* + * The link to the next page of items + */ + @Generated + private String nextLink; + + /** + * Creates an instance of PagedApiAll class. + * + * @param value the value value to set. + */ + @Generated + private PagedApiAll(List value) { + this.value = value; + } + + /** + * Get the value property: The Api items on this page. + * + * @return the value value. + */ + @Generated + public List getValue() { + return this.value; + } + + /** + * Get the nextLink property: The link to the next page of items. + * + * @return the nextLink value. + */ + @Generated + public String getNextLink() { + return this.nextLink; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("value", this.value, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeStringField("nextLink", this.nextLink); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of PagedApiAll from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of PagedApiAll if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the PagedApiAll. + */ + @Generated + public static PagedApiAll fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + List value = null; + String nextLink = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("value".equals(fieldName)) { + value = reader.readArray(reader1 -> Api.fromJson(reader1)); + } else if ("nextLink".equals(fieldName)) { + nextLink = reader.getString(); + } else { + reader.skipChildren(); + } + } + PagedApiAll deserializedPagedApiAll = new PagedApiAll(value); + deserializedPagedApiAll.nextLink = nextLink; + + return deserializedPagedApiAll; + }); + } +} diff --git a/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/models/PagedEnvironmentAll.java b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/models/PagedEnvironmentAll.java new file mode 100644 index 000000000000..c4f9f030d21c --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/models/PagedEnvironmentAll.java @@ -0,0 +1,107 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.apicenter.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * Paged collection of Environment items across workspaces. + */ +@Immutable +public final class PagedEnvironmentAll implements JsonSerializable { + /* + * The Environment items on this page + */ + @Generated + private final List value; + + /* + * The link to the next page of items + */ + @Generated + private String nextLink; + + /** + * Creates an instance of PagedEnvironmentAll class. + * + * @param value the value value to set. + */ + @Generated + private PagedEnvironmentAll(List value) { + this.value = value; + } + + /** + * Get the value property: The Environment items on this page. + * + * @return the value value. + */ + @Generated + public List getValue() { + return this.value; + } + + /** + * Get the nextLink property: The link to the next page of items. + * + * @return the nextLink value. + */ + @Generated + public String getNextLink() { + return this.nextLink; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("value", this.value, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeStringField("nextLink", this.nextLink); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of PagedEnvironmentAll from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of PagedEnvironmentAll if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the PagedEnvironmentAll. + */ + @Generated + public static PagedEnvironmentAll fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + List value = null; + String nextLink = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("value".equals(fieldName)) { + value = reader.readArray(reader1 -> Environment.fromJson(reader1)); + } else if ("nextLink".equals(fieldName)) { + nextLink = reader.getString(); + } else { + reader.skipChildren(); + } + } + PagedEnvironmentAll deserializedPagedEnvironmentAll = new PagedEnvironmentAll(value); + deserializedPagedEnvironmentAll.nextLink = nextLink; + + return deserializedPagedEnvironmentAll; + }); + } +} diff --git a/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/models/ResourceOperationStatusApiSpecExportResultApiSpecExportResultError.java b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/models/ResourceOperationStatusApiSpecExportResultApiSpecExportResultError.java new file mode 100644 index 000000000000..fce80a310838 --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/models/ResourceOperationStatusApiSpecExportResultApiSpecExportResultError.java @@ -0,0 +1,152 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.apicenter.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.core.models.ResponseError; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Provides status details for long running operations. + */ +@Immutable +public final class ResourceOperationStatusApiSpecExportResultApiSpecExportResultError + implements JsonSerializable { + /* + * The unique ID of the operation. + */ + @Generated + private String id; + + /* + * The status of the operation + */ + @Generated + private final OperationState status; + + /* + * Error object that describes the error when status is "Failed". + */ + @Generated + private ResponseError error; + + /* + * The result of the operation. + */ + @Generated + private ApiSpecExportResult result; + + /** + * Creates an instance of ResourceOperationStatusApiSpecExportResultApiSpecExportResultError class. + * + * @param status the status value to set. + */ + @Generated + private ResourceOperationStatusApiSpecExportResultApiSpecExportResultError(OperationState status) { + this.status = status; + } + + /** + * Get the id property: The unique ID of the operation. + * + * @return the id value. + */ + @Generated + public String getId() { + return this.id; + } + + /** + * Get the status property: The status of the operation. + * + * @return the status value. + */ + @Generated + public OperationState getStatus() { + return this.status; + } + + /** + * Get the error property: Error object that describes the error when status is "Failed". + * + * @return the error value. + */ + @Generated + public ResponseError getError() { + return this.error; + } + + /** + * Get the result property: The result of the operation. + * + * @return the result value. + */ + @Generated + public ApiSpecExportResult getResult() { + return this.result; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("status", this.status == null ? null : this.status.toString()); + jsonWriter.writeJsonField("error", this.error); + jsonWriter.writeJsonField("result", this.result); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ResourceOperationStatusApiSpecExportResultApiSpecExportResultError from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ResourceOperationStatusApiSpecExportResultApiSpecExportResultError if the JsonReader was + * pointing to an instance of it, or null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the + * ResourceOperationStatusApiSpecExportResultApiSpecExportResultError. + */ + @Generated + public static ResourceOperationStatusApiSpecExportResultApiSpecExportResultError fromJson(JsonReader jsonReader) + throws IOException { + return jsonReader.readObject(reader -> { + String id = null; + OperationState status = null; + ResponseError error = null; + ApiSpecExportResult result = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + id = reader.getString(); + } else if ("status".equals(fieldName)) { + status = OperationState.fromString(reader.getString()); + } else if ("error".equals(fieldName)) { + error = ResponseError.fromJson(reader); + } else if ("result".equals(fieldName)) { + result = ApiSpecExportResult.fromJson(reader); + } else { + reader.skipChildren(); + } + } + ResourceOperationStatusApiSpecExportResultApiSpecExportResultError deserializedResourceOperationStatusApiSpecExportResultApiSpecExportResultError + = new ResourceOperationStatusApiSpecExportResultApiSpecExportResultError(status); + deserializedResourceOperationStatusApiSpecExportResultApiSpecExportResultError.id = id; + deserializedResourceOperationStatusApiSpecExportResultApiSpecExportResultError.error = error; + deserializedResourceOperationStatusApiSpecExportResultApiSpecExportResultError.result = result; + + return deserializedResourceOperationStatusApiSpecExportResultApiSpecExportResultError; + }); + } +} diff --git a/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/models/TermsOfService.java b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/models/TermsOfService.java new file mode 100644 index 000000000000..744d23537651 --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/models/TermsOfService.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.apicenter.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * API Terms of Service. + */ +@Immutable +public final class TermsOfService implements JsonSerializable { + /* + * URL pointing to the terms of service. + */ + @Generated + private final String url; + + /** + * Creates an instance of TermsOfService class. + * + * @param url the url value to set. + */ + @Generated + private TermsOfService(String url) { + this.url = url; + } + + /** + * Get the url property: URL pointing to the terms of service. + * + * @return the url value. + */ + @Generated + public String getUrl() { + return this.url; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("url", this.url); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of TermsOfService from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of TermsOfService if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the TermsOfService. + */ + @Generated + public static TermsOfService fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String url = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("url".equals(fieldName)) { + url = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new TermsOfService(url); + }); + } +} diff --git a/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/models/package-info.java b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/models/package-info.java new file mode 100644 index 000000000000..702e5c349960 --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/models/package-info.java @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the data models for DataApi. + * Data API introduces endpoints to manage your API Center resources. + */ +package com.azure.apicenter.models; diff --git a/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/package-info.java b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/package-info.java new file mode 100644 index 000000000000..98d3c987f6a7 --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/main/java/com/azure/apicenter/package-info.java @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the classes for DataApi. + * Data API introduces endpoints to manage your API Center resources. + */ +package com.azure.apicenter; diff --git a/sdk/apicenter/azure-apicenter/src/main/java/module-info.java b/sdk/apicenter/azure-apicenter/src/main/java/module-info.java new file mode 100644 index 000000000000..42b1b4c36a78 --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/main/java/module-info.java @@ -0,0 +1,12 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +module com.azure.apicenter { + requires transitive com.azure.core; + + exports com.azure.apicenter; + exports com.azure.apicenter.models; + + opens com.azure.apicenter.models to com.azure.core; +} diff --git a/sdk/apicenter/azure-apicenter/src/main/resources/META-INF/azure-apicenter_apiview_properties.json b/sdk/apicenter/azure-apicenter/src/main/resources/META-INF/azure-apicenter_apiview_properties.json new file mode 100644 index 000000000000..4f6f2f7e28b6 --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/main/resources/META-INF/azure-apicenter_apiview_properties.json @@ -0,0 +1,87 @@ +{ + "flavor": "azure", + "CrossLanguageDefinitionId": { + "com.azure.apicenter.ApiDefinitionsAsyncClient": "ApiCenter.DataApi.ApiDefinitions", + "com.azure.apicenter.ApiDefinitionsAsyncClient.beginExportSpecification": "ApiCenter.DataApi.ApiDefinitions.exportSpecification", + "com.azure.apicenter.ApiDefinitionsAsyncClient.beginExportSpecificationWithModel": "ApiCenter.DataApi.ApiDefinitions.exportSpecification", + "com.azure.apicenter.ApiDefinitionsAsyncClient.getDefinition": "ApiCenter.DataApi.ApiDefinitions.getDefinition", + "com.azure.apicenter.ApiDefinitionsAsyncClient.getDefinitionWithResponse": "ApiCenter.DataApi.ApiDefinitions.getDefinition", + "com.azure.apicenter.ApiDefinitionsAsyncClient.getExportSpecificationOperationStatus": "ApiCenter.DataApi.ApiDefinitions.getExportSpecificationOperationStatus", + "com.azure.apicenter.ApiDefinitionsAsyncClient.getExportSpecificationOperationStatusWithResponse": "ApiCenter.DataApi.ApiDefinitions.getExportSpecificationOperationStatus", + "com.azure.apicenter.ApiDefinitionsAsyncClient.listDefinitions": "ApiCenter.DataApi.ApiDefinitions.listDefinitions", + "com.azure.apicenter.ApiDefinitionsClient": "ApiCenter.DataApi.ApiDefinitions", + "com.azure.apicenter.ApiDefinitionsClient.beginExportSpecification": "ApiCenter.DataApi.ApiDefinitions.exportSpecification", + "com.azure.apicenter.ApiDefinitionsClient.beginExportSpecificationWithModel": "ApiCenter.DataApi.ApiDefinitions.exportSpecification", + "com.azure.apicenter.ApiDefinitionsClient.getDefinition": "ApiCenter.DataApi.ApiDefinitions.getDefinition", + "com.azure.apicenter.ApiDefinitionsClient.getDefinitionWithResponse": "ApiCenter.DataApi.ApiDefinitions.getDefinition", + "com.azure.apicenter.ApiDefinitionsClient.getExportSpecificationOperationStatus": "ApiCenter.DataApi.ApiDefinitions.getExportSpecificationOperationStatus", + "com.azure.apicenter.ApiDefinitionsClient.getExportSpecificationOperationStatusWithResponse": "ApiCenter.DataApi.ApiDefinitions.getExportSpecificationOperationStatus", + "com.azure.apicenter.ApiDefinitionsClient.listDefinitions": "ApiCenter.DataApi.ApiDefinitions.listDefinitions", + "com.azure.apicenter.ApiDeploymentsAsyncClient": "ApiCenter.DataApi.ApiDeployments", + "com.azure.apicenter.ApiDeploymentsAsyncClient.getDeployment": "ApiCenter.DataApi.ApiDeployments.getDeployment", + "com.azure.apicenter.ApiDeploymentsAsyncClient.getDeploymentWithResponse": "ApiCenter.DataApi.ApiDeployments.getDeployment", + "com.azure.apicenter.ApiDeploymentsAsyncClient.listDeployments": "ApiCenter.DataApi.ApiDeployments.listDeployments", + "com.azure.apicenter.ApiDeploymentsClient": "ApiCenter.DataApi.ApiDeployments", + "com.azure.apicenter.ApiDeploymentsClient.getDeployment": "ApiCenter.DataApi.ApiDeployments.getDeployment", + "com.azure.apicenter.ApiDeploymentsClient.getDeploymentWithResponse": "ApiCenter.DataApi.ApiDeployments.getDeployment", + "com.azure.apicenter.ApiDeploymentsClient.listDeployments": "ApiCenter.DataApi.ApiDeployments.listDeployments", + "com.azure.apicenter.ApiVersionsAsyncClient": "ApiCenter.DataApi.ApiVersions", + "com.azure.apicenter.ApiVersionsAsyncClient.getVersion": "ApiCenter.DataApi.ApiVersions.getVersion", + "com.azure.apicenter.ApiVersionsAsyncClient.getVersionWithResponse": "ApiCenter.DataApi.ApiVersions.getVersion", + "com.azure.apicenter.ApiVersionsAsyncClient.listVersions": "ApiCenter.DataApi.ApiVersions.listVersions", + "com.azure.apicenter.ApiVersionsClient": "ApiCenter.DataApi.ApiVersions", + "com.azure.apicenter.ApiVersionsClient.getVersion": "ApiCenter.DataApi.ApiVersions.getVersion", + "com.azure.apicenter.ApiVersionsClient.getVersionWithResponse": "ApiCenter.DataApi.ApiVersions.getVersion", + "com.azure.apicenter.ApiVersionsClient.listVersions": "ApiCenter.DataApi.ApiVersions.listVersions", + "com.azure.apicenter.ApisAsyncClient": "ApiCenter.DataApi.Apis", + "com.azure.apicenter.ApisAsyncClient.get": "ApiCenter.DataApi.Apis.get", + "com.azure.apicenter.ApisAsyncClient.getWithResponse": "ApiCenter.DataApi.Apis.get", + "com.azure.apicenter.ApisAsyncClient.list": "ApiCenter.DataApi.Apis.list", + "com.azure.apicenter.ApisAsyncClient.listAll": "ApiCenter.DataApi.Apis.listAll", + "com.azure.apicenter.ApisAsyncClient.listAllWithResponse": "ApiCenter.DataApi.Apis.listAll", + "com.azure.apicenter.ApisClient": "ApiCenter.DataApi.Apis", + "com.azure.apicenter.ApisClient.get": "ApiCenter.DataApi.Apis.get", + "com.azure.apicenter.ApisClient.getWithResponse": "ApiCenter.DataApi.Apis.get", + "com.azure.apicenter.ApisClient.list": "ApiCenter.DataApi.Apis.list", + "com.azure.apicenter.ApisClient.listAll": "ApiCenter.DataApi.Apis.listAll", + "com.azure.apicenter.ApisClient.listAllWithResponse": "ApiCenter.DataApi.Apis.listAll", + "com.azure.apicenter.DataApiClientBuilder": "ApiCenter.DataApi", + "com.azure.apicenter.EnvironmentsAsyncClient": "ApiCenter.DataApi.Environments", + "com.azure.apicenter.EnvironmentsAsyncClient.get": "ApiCenter.DataApi.Environments.get", + "com.azure.apicenter.EnvironmentsAsyncClient.getWithResponse": "ApiCenter.DataApi.Environments.get", + "com.azure.apicenter.EnvironmentsAsyncClient.list": "ApiCenter.DataApi.Environments.list", + "com.azure.apicenter.EnvironmentsAsyncClient.listAll": "ApiCenter.DataApi.Environments.listAll", + "com.azure.apicenter.EnvironmentsAsyncClient.listAllWithResponse": "ApiCenter.DataApi.Environments.listAll", + "com.azure.apicenter.EnvironmentsClient": "ApiCenter.DataApi.Environments", + "com.azure.apicenter.EnvironmentsClient.get": "ApiCenter.DataApi.Environments.get", + "com.azure.apicenter.EnvironmentsClient.getWithResponse": "ApiCenter.DataApi.Environments.get", + "com.azure.apicenter.EnvironmentsClient.list": "ApiCenter.DataApi.Environments.list", + "com.azure.apicenter.EnvironmentsClient.listAll": "ApiCenter.DataApi.Environments.listAll", + "com.azure.apicenter.EnvironmentsClient.listAllWithResponse": "ApiCenter.DataApi.Environments.listAll", + "com.azure.apicenter.models.Api": "ApiCenter.DataApi.Api", + "com.azure.apicenter.models.ApiCustomProperties": "ApiCenter.DataApi.Api.customProperties.anonymous", + "com.azure.apicenter.models.ApiDefinition": "ApiCenter.DataApi.ApiDefinition", + "com.azure.apicenter.models.ApiDeployment": "ApiCenter.DataApi.ApiDeployment", + "com.azure.apicenter.models.ApiDeploymentCustomProperties": "ApiCenter.DataApi.ApiDeployment.customProperties.anonymous", + "com.azure.apicenter.models.ApiDeploymentServer": "ApiCenter.DataApi.ApiDeploymentServer", + "com.azure.apicenter.models.ApiKind": "ApiCenter.DataApi.ApiKind", + "com.azure.apicenter.models.ApiSpecExportResult": "ApiCenter.DataApi.ApiSpecExportResult", + "com.azure.apicenter.models.ApiSpecExportResultFormat": "ApiCenter.DataApi.ApiSpecExportResultFormat", + "com.azure.apicenter.models.ApiSpecification": "ApiCenter.DataApi.ApiSpecification", + "com.azure.apicenter.models.ApiVersion": "ApiCenter.DataApi.ApiVersion", + "com.azure.apicenter.models.Contact": "ApiCenter.DataApi.Contact", + "com.azure.apicenter.models.Environment": "ApiCenter.DataApi.Environment", + "com.azure.apicenter.models.EnvironmentCustomProperties": "ApiCenter.DataApi.Environment.customProperties.anonymous", + "com.azure.apicenter.models.EnvironmentKind": "ApiCenter.DataApi.EnvironmentKind", + "com.azure.apicenter.models.EnvironmentOnboardingModel": "ApiCenter.DataApi.EnvironmentOnboardingModel", + "com.azure.apicenter.models.EnvironmentServer": "ApiCenter.DataApi.EnvironmentServer", + "com.azure.apicenter.models.ExternalDocumentation": "ApiCenter.DataApi.ExternalDocumentation", + "com.azure.apicenter.models.License": "ApiCenter.DataApi.License", + "com.azure.apicenter.models.LifecycleStage": "ApiCenter.DataApi.LifecycleStage", + "com.azure.apicenter.models.OperationState": "Azure.Core.Foundations.OperationState", + "com.azure.apicenter.models.PagedApiAll": "ApiCenter.DataApi.PagedApiAll", + "com.azure.apicenter.models.PagedEnvironmentAll": "ApiCenter.DataApi.PagedEnvironmentAll", + "com.azure.apicenter.models.ResourceOperationStatusApiSpecExportResultApiSpecExportResultError": "Azure.Core.ResourceOperationStatus", + "com.azure.apicenter.models.TermsOfService": "ApiCenter.DataApi.TermsOfService" + } +} diff --git a/sdk/apicenter/azure-apicenter/src/main/resources/azure-apicenter.properties b/sdk/apicenter/azure-apicenter/src/main/resources/azure-apicenter.properties new file mode 100644 index 000000000000..ca812989b4f2 --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/main/resources/azure-apicenter.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/sdk/apicenter/azure-apicenter/src/samples/java/com/azure/apicenter/ReadmeSamples.java b/sdk/apicenter/azure-apicenter/src/samples/java/com/azure/apicenter/ReadmeSamples.java new file mode 100644 index 000000000000..7d4c47e6b0c9 --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/samples/java/com/azure/apicenter/ReadmeSamples.java @@ -0,0 +1,12 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.apicenter; + +public final class ReadmeSamples { + public void readmeSamples() { + // BEGIN: com.azure.apicenter.readme + // END: com.azure.apicenter.readme + } +} diff --git a/sdk/apicenter/azure-apicenter/src/samples/java/com/azure/apicenter/generated/ApiDefinitionsExportSpecification.java b/sdk/apicenter/azure-apicenter/src/samples/java/com/azure/apicenter/generated/ApiDefinitionsExportSpecification.java new file mode 100644 index 000000000000..6ed123523de4 --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/samples/java/com/azure/apicenter/generated/ApiDefinitionsExportSpecification.java @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.apicenter.generated; + +import com.azure.apicenter.ApiDefinitionsClient; +import com.azure.apicenter.DataApiClientBuilder; +import com.azure.apicenter.models.ApiSpecExportResult; +import com.azure.core.util.Configuration; +import com.azure.core.util.polling.PollOperationDetails; +import com.azure.core.util.polling.SyncPoller; +import com.azure.identity.DefaultAzureCredentialBuilder; + +public class ApiDefinitionsExportSpecification { + public static void main(String[] args) { + ApiDefinitionsClient apiDefinitionsClient + = new DataApiClientBuilder().credential(new DefaultAzureCredentialBuilder().build()) + .serviceName(Configuration.getGlobalConfiguration().get("SERVICENAME")) + .region(Configuration.getGlobalConfiguration().get("REGION")) + .buildApiDefinitionsClient(); + // BEGIN:com.azure.apicenter.generated.apidefinitionsexportspecification.apidefinitionsexportspecification + SyncPoller response + = apiDefinitionsClient.beginExportSpecification("default", "echo-api", "2023-01-01", "default"); + // END:com.azure.apicenter.generated.apidefinitionsexportspecification.apidefinitionsexportspecification + } +} diff --git a/sdk/apicenter/azure-apicenter/src/samples/java/com/azure/apicenter/generated/ApiDefinitionsGetDefinition.java b/sdk/apicenter/azure-apicenter/src/samples/java/com/azure/apicenter/generated/ApiDefinitionsGetDefinition.java new file mode 100644 index 000000000000..21a9f97a8fea --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/samples/java/com/azure/apicenter/generated/ApiDefinitionsGetDefinition.java @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.apicenter.generated; + +import com.azure.apicenter.ApiDefinitionsClient; +import com.azure.apicenter.DataApiClientBuilder; +import com.azure.apicenter.models.ApiDefinition; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; + +public class ApiDefinitionsGetDefinition { + public static void main(String[] args) { + ApiDefinitionsClient apiDefinitionsClient + = new DataApiClientBuilder().credential(new DefaultAzureCredentialBuilder().build()) + .serviceName(Configuration.getGlobalConfiguration().get("SERVICENAME")) + .region(Configuration.getGlobalConfiguration().get("REGION")) + .buildApiDefinitionsClient(); + // BEGIN:com.azure.apicenter.generated.apidefinitionsgetdefinition.apidefinitionsgetdefinition + ApiDefinition response = apiDefinitionsClient.getDefinition("default", "echo-api", "2023-01-01", "default"); + // END:com.azure.apicenter.generated.apidefinitionsgetdefinition.apidefinitionsgetdefinition + } +} diff --git a/sdk/apicenter/azure-apicenter/src/samples/java/com/azure/apicenter/generated/ApiDefinitionsGetExportSpecificationOperationStatus.java b/sdk/apicenter/azure-apicenter/src/samples/java/com/azure/apicenter/generated/ApiDefinitionsGetExportSpecificationOperationStatus.java new file mode 100644 index 000000000000..e6b7d9a0fcd6 --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/samples/java/com/azure/apicenter/generated/ApiDefinitionsGetExportSpecificationOperationStatus.java @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.apicenter.generated; + +import com.azure.apicenter.ApiDefinitionsClient; +import com.azure.apicenter.DataApiClientBuilder; +import com.azure.apicenter.models.ResourceOperationStatusApiSpecExportResultApiSpecExportResultError; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; + +public class ApiDefinitionsGetExportSpecificationOperationStatus { + public static void main(String[] args) { + ApiDefinitionsClient apiDefinitionsClient + = new DataApiClientBuilder().credential(new DefaultAzureCredentialBuilder().build()) + .serviceName(Configuration.getGlobalConfiguration().get("SERVICENAME")) + .region(Configuration.getGlobalConfiguration().get("REGION")) + .buildApiDefinitionsClient(); + // BEGIN:com.azure.apicenter.generated.apidefinitionsgetexportspecificationoperationstatus.apidefinitionsgetexportspecificationoperationstatus + ResourceOperationStatusApiSpecExportResultApiSpecExportResultError response + = apiDefinitionsClient.getExportSpecificationOperationStatus("default", "echo-api", "2023-01-01", "default", + "00000000-0000-0000-0000-000000000001"); + // END:com.azure.apicenter.generated.apidefinitionsgetexportspecificationoperationstatus.apidefinitionsgetexportspecificationoperationstatus + } +} diff --git a/sdk/apicenter/azure-apicenter/src/samples/java/com/azure/apicenter/generated/ApiDefinitionsListDefinitions.java b/sdk/apicenter/azure-apicenter/src/samples/java/com/azure/apicenter/generated/ApiDefinitionsListDefinitions.java new file mode 100644 index 000000000000..7e79aa9b4423 --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/samples/java/com/azure/apicenter/generated/ApiDefinitionsListDefinitions.java @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.apicenter.generated; + +import com.azure.apicenter.ApiDefinitionsClient; +import com.azure.apicenter.DataApiClientBuilder; +import com.azure.apicenter.models.ApiDefinition; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; + +public class ApiDefinitionsListDefinitions { + public static void main(String[] args) { + ApiDefinitionsClient apiDefinitionsClient + = new DataApiClientBuilder().credential(new DefaultAzureCredentialBuilder().build()) + .serviceName(Configuration.getGlobalConfiguration().get("SERVICENAME")) + .region(Configuration.getGlobalConfiguration().get("REGION")) + .buildApiDefinitionsClient(); + // BEGIN:com.azure.apicenter.generated.apidefinitionslistdefinitions.apidefinitionslistdefinitions + PagedIterable response + = apiDefinitionsClient.listDefinitions("default", "echo-api", "2023-01-01", null, null); + // END:com.azure.apicenter.generated.apidefinitionslistdefinitions.apidefinitionslistdefinitions + } +} diff --git a/sdk/apicenter/azure-apicenter/src/samples/java/com/azure/apicenter/generated/ApiDeploymentsGetDeployment.java b/sdk/apicenter/azure-apicenter/src/samples/java/com/azure/apicenter/generated/ApiDeploymentsGetDeployment.java new file mode 100644 index 000000000000..7af8745d95e7 --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/samples/java/com/azure/apicenter/generated/ApiDeploymentsGetDeployment.java @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.apicenter.generated; + +import com.azure.apicenter.ApiDeploymentsClient; +import com.azure.apicenter.DataApiClientBuilder; +import com.azure.apicenter.models.ApiDeployment; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; + +public class ApiDeploymentsGetDeployment { + public static void main(String[] args) { + ApiDeploymentsClient apiDeploymentsClient + = new DataApiClientBuilder().credential(new DefaultAzureCredentialBuilder().build()) + .serviceName(Configuration.getGlobalConfiguration().get("SERVICENAME")) + .region(Configuration.getGlobalConfiguration().get("REGION")) + .buildApiDeploymentsClient(); + // BEGIN:com.azure.apicenter.generated.apideploymentsgetdeployment.apideploymentsgetdeployment + ApiDeployment response + = apiDeploymentsClient.getDeployment("eeoezynpqqgtykbukjcelrwvomtccvbjwntxfqh", "lauuo", "ffc"); + // END:com.azure.apicenter.generated.apideploymentsgetdeployment.apideploymentsgetdeployment + } +} diff --git a/sdk/apicenter/azure-apicenter/src/samples/java/com/azure/apicenter/generated/ApiDeploymentsListDeployments.java b/sdk/apicenter/azure-apicenter/src/samples/java/com/azure/apicenter/generated/ApiDeploymentsListDeployments.java new file mode 100644 index 000000000000..852a11c2d622 --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/samples/java/com/azure/apicenter/generated/ApiDeploymentsListDeployments.java @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.apicenter.generated; + +import com.azure.apicenter.ApiDeploymentsClient; +import com.azure.apicenter.DataApiClientBuilder; +import com.azure.apicenter.models.ApiDeployment; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; + +public class ApiDeploymentsListDeployments { + public static void main(String[] args) { + ApiDeploymentsClient apiDeploymentsClient + = new DataApiClientBuilder().credential(new DefaultAzureCredentialBuilder().build()) + .serviceName(Configuration.getGlobalConfiguration().get("SERVICENAME")) + .region(Configuration.getGlobalConfiguration().get("REGION")) + .buildApiDeploymentsClient(); + // BEGIN:com.azure.apicenter.generated.apideploymentslistdeployments.apideploymentslistdeployments + PagedIterable response = apiDeploymentsClient.listDeployments("default", "echo-api", null, null); + // END:com.azure.apicenter.generated.apideploymentslistdeployments.apideploymentslistdeployments + } +} diff --git a/sdk/apicenter/azure-apicenter/src/samples/java/com/azure/apicenter/generated/ApiVersionsGetVersion.java b/sdk/apicenter/azure-apicenter/src/samples/java/com/azure/apicenter/generated/ApiVersionsGetVersion.java new file mode 100644 index 000000000000..b4dcfb064a21 --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/samples/java/com/azure/apicenter/generated/ApiVersionsGetVersion.java @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.apicenter.generated; + +import com.azure.apicenter.ApiVersionsClient; +import com.azure.apicenter.DataApiClientBuilder; +import com.azure.apicenter.models.ApiVersion; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; + +public class ApiVersionsGetVersion { + public static void main(String[] args) { + ApiVersionsClient apiVersionsClient + = new DataApiClientBuilder().credential(new DefaultAzureCredentialBuilder().build()) + .serviceName(Configuration.getGlobalConfiguration().get("SERVICENAME")) + .region(Configuration.getGlobalConfiguration().get("REGION")) + .buildApiVersionsClient(); + // BEGIN:com.azure.apicenter.generated.apiversionsgetversion.apiversionsgetversion + ApiVersion response = apiVersionsClient.getVersion("default", "echo-api", "2023-01-01"); + // END:com.azure.apicenter.generated.apiversionsgetversion.apiversionsgetversion + } +} diff --git a/sdk/apicenter/azure-apicenter/src/samples/java/com/azure/apicenter/generated/ApiVersionsListVersions.java b/sdk/apicenter/azure-apicenter/src/samples/java/com/azure/apicenter/generated/ApiVersionsListVersions.java new file mode 100644 index 000000000000..d8ac6ad66378 --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/samples/java/com/azure/apicenter/generated/ApiVersionsListVersions.java @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.apicenter.generated; + +import com.azure.apicenter.ApiVersionsClient; +import com.azure.apicenter.DataApiClientBuilder; +import com.azure.apicenter.models.ApiVersion; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; + +public class ApiVersionsListVersions { + public static void main(String[] args) { + ApiVersionsClient apiVersionsClient + = new DataApiClientBuilder().credential(new DefaultAzureCredentialBuilder().build()) + .serviceName(Configuration.getGlobalConfiguration().get("SERVICENAME")) + .region(Configuration.getGlobalConfiguration().get("REGION")) + .buildApiVersionsClient(); + // BEGIN:com.azure.apicenter.generated.apiversionslistversions.apiversionslistversions + PagedIterable response = apiVersionsClient.listVersions("default", "echo-api", null, null); + // END:com.azure.apicenter.generated.apiversionslistversions.apiversionslistversions + } +} diff --git a/sdk/apicenter/azure-apicenter/src/samples/java/com/azure/apicenter/generated/ApisGet.java b/sdk/apicenter/azure-apicenter/src/samples/java/com/azure/apicenter/generated/ApisGet.java new file mode 100644 index 000000000000..f8df1463a4bf --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/samples/java/com/azure/apicenter/generated/ApisGet.java @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.apicenter.generated; + +import com.azure.apicenter.ApisClient; +import com.azure.apicenter.DataApiClientBuilder; +import com.azure.apicenter.models.Api; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; + +public class ApisGet { + public static void main(String[] args) { + ApisClient apisClient = new DataApiClientBuilder().credential(new DefaultAzureCredentialBuilder().build()) + .serviceName(Configuration.getGlobalConfiguration().get("SERVICENAME")) + .region(Configuration.getGlobalConfiguration().get("REGION")) + .buildApisClient(); + // BEGIN:com.azure.apicenter.generated.apisget.apisget + Api response = apisClient.get("default", "echo-api"); + // END:com.azure.apicenter.generated.apisget.apisget + } +} diff --git a/sdk/apicenter/azure-apicenter/src/samples/java/com/azure/apicenter/generated/ApisList.java b/sdk/apicenter/azure-apicenter/src/samples/java/com/azure/apicenter/generated/ApisList.java new file mode 100644 index 000000000000..57aef1ec1ed7 --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/samples/java/com/azure/apicenter/generated/ApisList.java @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.apicenter.generated; + +import com.azure.apicenter.ApisClient; +import com.azure.apicenter.DataApiClientBuilder; +import com.azure.apicenter.models.Api; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; + +public class ApisList { + public static void main(String[] args) { + ApisClient apisClient = new DataApiClientBuilder().credential(new DefaultAzureCredentialBuilder().build()) + .serviceName(Configuration.getGlobalConfiguration().get("SERVICENAME")) + .region(Configuration.getGlobalConfiguration().get("REGION")) + .buildApisClient(); + // BEGIN:com.azure.apicenter.generated.apislist.apislist + PagedIterable response = apisClient.list("default", null, null); + // END:com.azure.apicenter.generated.apislist.apislist + } +} diff --git a/sdk/apicenter/azure-apicenter/src/samples/java/com/azure/apicenter/generated/ApisListAll.java b/sdk/apicenter/azure-apicenter/src/samples/java/com/azure/apicenter/generated/ApisListAll.java new file mode 100644 index 000000000000..402ad3d4a268 --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/samples/java/com/azure/apicenter/generated/ApisListAll.java @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.apicenter.generated; + +import com.azure.apicenter.ApisClient; +import com.azure.apicenter.DataApiClientBuilder; +import com.azure.apicenter.models.PagedApiAll; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; + +public class ApisListAll { + public static void main(String[] args) { + ApisClient apisClient = new DataApiClientBuilder().credential(new DefaultAzureCredentialBuilder().build()) + .serviceName(Configuration.getGlobalConfiguration().get("SERVICENAME")) + .region(Configuration.getGlobalConfiguration().get("REGION")) + .buildApisClient(); + // BEGIN:com.azure.apicenter.generated.apislistall.apislistall + PagedApiAll response = apisClient.listAll(null, null, null); + // END:com.azure.apicenter.generated.apislistall.apislistall + } +} diff --git a/sdk/apicenter/azure-apicenter/src/samples/java/com/azure/apicenter/generated/EnvironmentsGet.java b/sdk/apicenter/azure-apicenter/src/samples/java/com/azure/apicenter/generated/EnvironmentsGet.java new file mode 100644 index 000000000000..8002283856d0 --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/samples/java/com/azure/apicenter/generated/EnvironmentsGet.java @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.apicenter.generated; + +import com.azure.apicenter.DataApiClientBuilder; +import com.azure.apicenter.EnvironmentsClient; +import com.azure.apicenter.models.Environment; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; + +public class EnvironmentsGet { + public static void main(String[] args) { + EnvironmentsClient environmentsClient + = new DataApiClientBuilder().credential(new DefaultAzureCredentialBuilder().build()) + .serviceName(Configuration.getGlobalConfiguration().get("SERVICENAME")) + .region(Configuration.getGlobalConfiguration().get("REGION")) + .buildEnvironmentsClient(); + // BEGIN:com.azure.apicenter.generated.environmentsget.environmentsget + Environment response = environmentsClient.get("default", "production"); + // END:com.azure.apicenter.generated.environmentsget.environmentsget + } +} diff --git a/sdk/apicenter/azure-apicenter/src/samples/java/com/azure/apicenter/generated/EnvironmentsList.java b/sdk/apicenter/azure-apicenter/src/samples/java/com/azure/apicenter/generated/EnvironmentsList.java new file mode 100644 index 000000000000..6b5b692b5f0e --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/samples/java/com/azure/apicenter/generated/EnvironmentsList.java @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.apicenter.generated; + +import com.azure.apicenter.DataApiClientBuilder; +import com.azure.apicenter.EnvironmentsClient; +import com.azure.apicenter.models.Environment; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; + +public class EnvironmentsList { + public static void main(String[] args) { + EnvironmentsClient environmentsClient + = new DataApiClientBuilder().credential(new DefaultAzureCredentialBuilder().build()) + .serviceName(Configuration.getGlobalConfiguration().get("SERVICENAME")) + .region(Configuration.getGlobalConfiguration().get("REGION")) + .buildEnvironmentsClient(); + // BEGIN:com.azure.apicenter.generated.environmentslist.environmentslist + PagedIterable response = environmentsClient.list("default", null, null); + // END:com.azure.apicenter.generated.environmentslist.environmentslist + } +} diff --git a/sdk/apicenter/azure-apicenter/src/samples/java/com/azure/apicenter/generated/EnvironmentsListAll.java b/sdk/apicenter/azure-apicenter/src/samples/java/com/azure/apicenter/generated/EnvironmentsListAll.java new file mode 100644 index 000000000000..25002d235cc4 --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/samples/java/com/azure/apicenter/generated/EnvironmentsListAll.java @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.apicenter.generated; + +import com.azure.apicenter.DataApiClientBuilder; +import com.azure.apicenter.EnvironmentsClient; +import com.azure.apicenter.models.PagedEnvironmentAll; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; + +public class EnvironmentsListAll { + public static void main(String[] args) { + EnvironmentsClient environmentsClient + = new DataApiClientBuilder().credential(new DefaultAzureCredentialBuilder().build()) + .serviceName(Configuration.getGlobalConfiguration().get("SERVICENAME")) + .region(Configuration.getGlobalConfiguration().get("REGION")) + .buildEnvironmentsClient(); + // BEGIN:com.azure.apicenter.generated.environmentslistall.environmentslistall + PagedEnvironmentAll response = environmentsClient.listAll(null, null, null); + // END:com.azure.apicenter.generated.environmentslistall.environmentslistall + } +} diff --git a/sdk/apicenter/azure-apicenter/src/test/java/com/azure/apicenter/generated/ApiDefinitionsExportSpecificationTests.java b/sdk/apicenter/azure-apicenter/src/test/java/com/azure/apicenter/generated/ApiDefinitionsExportSpecificationTests.java new file mode 100644 index 000000000000..a2462465dfdd --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/test/java/com/azure/apicenter/generated/ApiDefinitionsExportSpecificationTests.java @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.apicenter.generated; + +import com.azure.apicenter.models.ApiSpecExportResult; +import com.azure.core.util.polling.LongRunningOperationStatus; +import com.azure.core.util.polling.PollOperationDetails; +import com.azure.core.util.polling.SyncPoller; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +@Disabled +public final class ApiDefinitionsExportSpecificationTests extends DataApiClientTestBase { + @Test + @Disabled + public void testApiDefinitionsExportSpecificationTests() { + // method invocation + SyncPoller response = setPlaybackSyncPollerPollInterval( + apiDefinitionsClient.beginExportSpecification("default", "echo-api", "2023-01-01", "default")); + + // response assertion + Assertions.assertEquals(LongRunningOperationStatus.SUCCESSFULLY_COMPLETED, + response.waitForCompletion().getStatus()); + } +} diff --git a/sdk/apicenter/azure-apicenter/src/test/java/com/azure/apicenter/generated/ApiDefinitionsGetDefinitionTests.java b/sdk/apicenter/azure-apicenter/src/test/java/com/azure/apicenter/generated/ApiDefinitionsGetDefinitionTests.java new file mode 100644 index 000000000000..1a521afdc904 --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/test/java/com/azure/apicenter/generated/ApiDefinitionsGetDefinitionTests.java @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.apicenter.generated; + +import com.azure.apicenter.models.ApiDefinition; +import com.azure.apicenter.models.ApiSpecification; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +@Disabled +public final class ApiDefinitionsGetDefinitionTests extends DataApiClientTestBase { + @Test + @Disabled + public void testApiDefinitionsGetDefinitionTests() { + // method invocation + ApiDefinition response = apiDefinitionsClient.getDefinition("default", "echo-api", "2023-01-01", "default"); + + // response assertion + Assertions.assertNotNull(response); + // verify property "name" + Assertions.assertEquals("default", response.getName()); + // verify property "title" + Assertions.assertEquals("Default", response.getTitle()); + // verify property "description" + Assertions.assertEquals("Default API definition.", response.getDescription()); + // verify property "specification" + ApiSpecification responseSpecification = response.getSpecification(); + Assertions.assertNotNull(responseSpecification); + Assertions.assertEquals("openapi", responseSpecification.getName()); + Assertions.assertEquals("3.0.1", responseSpecification.getVersion()); + } +} diff --git a/sdk/apicenter/azure-apicenter/src/test/java/com/azure/apicenter/generated/ApiDefinitionsGetExportSpecificationOperationStatusTests.java b/sdk/apicenter/azure-apicenter/src/test/java/com/azure/apicenter/generated/ApiDefinitionsGetExportSpecificationOperationStatusTests.java new file mode 100644 index 000000000000..289256578af9 --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/test/java/com/azure/apicenter/generated/ApiDefinitionsGetExportSpecificationOperationStatusTests.java @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.apicenter.generated; + +import com.azure.apicenter.models.ApiSpecExportResult; +import com.azure.apicenter.models.ApiSpecExportResultFormat; +import com.azure.apicenter.models.OperationState; +import com.azure.apicenter.models.ResourceOperationStatusApiSpecExportResultApiSpecExportResultError; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +@Disabled +public final class ApiDefinitionsGetExportSpecificationOperationStatusTests extends DataApiClientTestBase { + @Test + @Disabled + public void testApiDefinitionsGetExportSpecificationOperationStatusTests() { + // method invocation + ResourceOperationStatusApiSpecExportResultApiSpecExportResultError response + = apiDefinitionsClient.getExportSpecificationOperationStatus("default", "echo-api", "2023-01-01", "default", + "00000000-0000-0000-0000-000000000001"); + + // response assertion + Assertions.assertNotNull(response); + // verify property "status" + Assertions.assertEquals(OperationState.SUCCEEDED, response.getStatus()); + // verify property "result" + ApiSpecExportResult responseResult = response.getResult(); + Assertions.assertNotNull(responseResult); + Assertions.assertEquals("{ ... }", responseResult.getValue()); + Assertions.assertEquals(ApiSpecExportResultFormat.LINK, responseResult.getFormat()); + } +} diff --git a/sdk/apicenter/azure-apicenter/src/test/java/com/azure/apicenter/generated/ApiDefinitionsListDefinitionsTests.java b/sdk/apicenter/azure-apicenter/src/test/java/com/azure/apicenter/generated/ApiDefinitionsListDefinitionsTests.java new file mode 100644 index 000000000000..542d905eb9fb --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/test/java/com/azure/apicenter/generated/ApiDefinitionsListDefinitionsTests.java @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.apicenter.generated; + +import com.azure.apicenter.models.ApiDefinition; +import com.azure.apicenter.models.ApiSpecification; +import com.azure.core.http.rest.PagedIterable; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +@Disabled +public final class ApiDefinitionsListDefinitionsTests extends DataApiClientTestBase { + @Test + @Disabled + public void testApiDefinitionsListDefinitionsTests() { + // method invocation + PagedIterable response + = apiDefinitionsClient.listDefinitions("default", "echo-api", "2023-01-01", null, null); + + // response assertion + Assertions.assertEquals(200, response.iterableByPage().iterator().next().getStatusCode()); + ApiDefinition firstItem = response.iterator().next(); + Assertions.assertNotNull(firstItem); + // verify property "name" + Assertions.assertEquals("default", firstItem.getName()); + // verify property "title" + Assertions.assertEquals("Default", firstItem.getTitle()); + // verify property "description" + Assertions.assertEquals("Default API definition.", firstItem.getDescription()); + // verify property "specification" + ApiSpecification firstItemSpecification = firstItem.getSpecification(); + Assertions.assertNotNull(firstItemSpecification); + Assertions.assertEquals("openapi", firstItemSpecification.getName()); + Assertions.assertEquals("3.0.1", firstItemSpecification.getVersion()); + } +} diff --git a/sdk/apicenter/azure-apicenter/src/test/java/com/azure/apicenter/generated/ApiDeploymentsGetDeploymentTests.java b/sdk/apicenter/azure-apicenter/src/test/java/com/azure/apicenter/generated/ApiDeploymentsGetDeploymentTests.java new file mode 100644 index 000000000000..71f0f21bab87 --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/test/java/com/azure/apicenter/generated/ApiDeploymentsGetDeploymentTests.java @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.apicenter.generated; + +import com.azure.apicenter.models.ApiDeployment; +import com.azure.apicenter.models.ApiDeploymentServer; +import java.util.List; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +@Disabled +public final class ApiDeploymentsGetDeploymentTests extends DataApiClientTestBase { + @Test + @Disabled + public void testApiDeploymentsGetDeploymentTests() { + // method invocation + ApiDeployment response + = apiDeploymentsClient.getDeployment("eeoezynpqqgtykbukjcelrwvomtccvbjwntxfqh", "lauuo", "ffc"); + + // response assertion + Assertions.assertNotNull(response); + // verify property "name" + Assertions.assertEquals("production", response.getName()); + // verify property "title" + Assertions.assertEquals("Production", response.getTitle()); + // verify property "description" + Assertions.assertEquals("Production deployment (Public Cloud)", response.getDescription()); + // verify property "environment" + Assertions.assertEquals("public", response.getEnvironment()); + // verify property "server" + ApiDeploymentServer responseServer = response.getServer(); + Assertions.assertNotNull(responseServer); + List responseServerRuntimeUris = responseServer.getRuntimeUris(); + Assertions.assertEquals("https://contoso.azure-api.net", responseServerRuntimeUris.iterator().next()); + // verify property "recommended" + Assertions.assertEquals(true, response.isRecommended()); + } +} diff --git a/sdk/apicenter/azure-apicenter/src/test/java/com/azure/apicenter/generated/ApiDeploymentsListDeploymentsTests.java b/sdk/apicenter/azure-apicenter/src/test/java/com/azure/apicenter/generated/ApiDeploymentsListDeploymentsTests.java new file mode 100644 index 000000000000..a63b89ab5253 --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/test/java/com/azure/apicenter/generated/ApiDeploymentsListDeploymentsTests.java @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.apicenter.generated; + +import com.azure.apicenter.models.ApiDeployment; +import com.azure.apicenter.models.ApiDeploymentServer; +import com.azure.core.http.rest.PagedIterable; +import java.util.List; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +@Disabled +public final class ApiDeploymentsListDeploymentsTests extends DataApiClientTestBase { + @Test + @Disabled + public void testApiDeploymentsListDeploymentsTests() { + // method invocation + PagedIterable response = apiDeploymentsClient.listDeployments("default", "echo-api", null, null); + + // response assertion + Assertions.assertEquals(200, response.iterableByPage().iterator().next().getStatusCode()); + ApiDeployment firstItem = response.iterator().next(); + Assertions.assertNotNull(firstItem); + // verify property "name" + Assertions.assertEquals("production", firstItem.getName()); + // verify property "title" + Assertions.assertEquals("Production", firstItem.getTitle()); + // verify property "description" + Assertions.assertEquals("Production deployment (Public Cloud)", firstItem.getDescription()); + // verify property "environment" + Assertions.assertEquals("public", firstItem.getEnvironment()); + // verify property "server" + ApiDeploymentServer firstItemServer = firstItem.getServer(); + Assertions.assertNotNull(firstItemServer); + List firstItemServerRuntimeUris = firstItemServer.getRuntimeUris(); + Assertions.assertEquals("https://contoso.azure-api.net", firstItemServerRuntimeUris.iterator().next()); + // verify property "recommended" + Assertions.assertEquals(true, firstItem.isRecommended()); + } +} diff --git a/sdk/apicenter/azure-apicenter/src/test/java/com/azure/apicenter/generated/ApiVersionsGetVersionTests.java b/sdk/apicenter/azure-apicenter/src/test/java/com/azure/apicenter/generated/ApiVersionsGetVersionTests.java new file mode 100644 index 000000000000..f7b50066a487 --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/test/java/com/azure/apicenter/generated/ApiVersionsGetVersionTests.java @@ -0,0 +1,30 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.apicenter.generated; + +import com.azure.apicenter.models.ApiVersion; +import com.azure.apicenter.models.LifecycleStage; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +@Disabled +public final class ApiVersionsGetVersionTests extends DataApiClientTestBase { + @Test + @Disabled + public void testApiVersionsGetVersionTests() { + // method invocation + ApiVersion response = apiVersionsClient.getVersion("default", "echo-api", "2023-01-01"); + + // response assertion + Assertions.assertNotNull(response); + // verify property "name" + Assertions.assertEquals("2023-01-01", response.getName()); + // verify property "title" + Assertions.assertEquals("2023-01-01", response.getTitle()); + // verify property "lifecycleStage" + Assertions.assertEquals(LifecycleStage.DESIGN, response.getLifecycleStage()); + } +} diff --git a/sdk/apicenter/azure-apicenter/src/test/java/com/azure/apicenter/generated/ApiVersionsListVersionsTests.java b/sdk/apicenter/azure-apicenter/src/test/java/com/azure/apicenter/generated/ApiVersionsListVersionsTests.java new file mode 100644 index 000000000000..832ce14dee02 --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/test/java/com/azure/apicenter/generated/ApiVersionsListVersionsTests.java @@ -0,0 +1,33 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.apicenter.generated; + +import com.azure.apicenter.models.ApiVersion; +import com.azure.apicenter.models.LifecycleStage; +import com.azure.core.http.rest.PagedIterable; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +@Disabled +public final class ApiVersionsListVersionsTests extends DataApiClientTestBase { + @Test + @Disabled + public void testApiVersionsListVersionsTests() { + // method invocation + PagedIterable response = apiVersionsClient.listVersions("default", "echo-api", null, null); + + // response assertion + Assertions.assertEquals(200, response.iterableByPage().iterator().next().getStatusCode()); + ApiVersion firstItem = response.iterator().next(); + Assertions.assertNotNull(firstItem); + // verify property "name" + Assertions.assertEquals("2023-01-01", firstItem.getName()); + // verify property "title" + Assertions.assertEquals("2023-01-01", firstItem.getTitle()); + // verify property "lifecycleStage" + Assertions.assertEquals(LifecycleStage.DESIGN, firstItem.getLifecycleStage()); + } +} diff --git a/sdk/apicenter/azure-apicenter/src/test/java/com/azure/apicenter/generated/ApisGetTests.java b/sdk/apicenter/azure-apicenter/src/test/java/com/azure/apicenter/generated/ApisGetTests.java new file mode 100644 index 000000000000..464098eebed7 --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/test/java/com/azure/apicenter/generated/ApisGetTests.java @@ -0,0 +1,66 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.apicenter.generated; + +import com.azure.apicenter.models.Api; +import com.azure.apicenter.models.ApiKind; +import com.azure.apicenter.models.Contact; +import com.azure.apicenter.models.ExternalDocumentation; +import com.azure.apicenter.models.License; +import com.azure.apicenter.models.LifecycleStage; +import com.azure.apicenter.models.TermsOfService; +import java.util.List; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +@Disabled +public final class ApisGetTests extends DataApiClientTestBase { + @Test + @Disabled + public void testApisGetTests() { + // method invocation + Api response = apisClient.get("default", "echo-api"); + + // response assertion + Assertions.assertNotNull(response); + // verify property "name" + Assertions.assertEquals("echo-api", response.getName()); + // verify property "title" + Assertions.assertEquals("Echo API", response.getTitle()); + // verify property "description" + Assertions.assertEquals("A simple HTTP request/response service.", response.getDescription()); + // verify property "kind" + Assertions.assertEquals(ApiKind.REST, response.getKind()); + // verify property "lifecycleStage" + Assertions.assertEquals(LifecycleStage.DESIGN, response.getLifecycleStage()); + // verify property "termsOfService" + TermsOfService responseTermsOfService = response.getTermsOfService(); + Assertions.assertNotNull(responseTermsOfService); + Assertions.assertEquals("https://contoso.com/terms-of-service", responseTermsOfService.getUrl()); + // verify property "license" + License responseLicense = response.getLicense(); + Assertions.assertNotNull(responseLicense); + Assertions.assertEquals("default", responseLicense.getName()); + Assertions.assertEquals("https://contoso.com/license", responseLicense.getUrl()); + // verify property "externalDocumentation" + List responseExternalDocumentation = response.getExternalDocumentation(); + ExternalDocumentation responseExternalDocumentationFirstItem = responseExternalDocumentation.iterator().next(); + Assertions.assertNotNull(responseExternalDocumentationFirstItem); + Assertions.assertEquals("Onboarding docs", responseExternalDocumentationFirstItem.getTitle()); + Assertions.assertEquals("Learn how to onboard to the Echo API.", + responseExternalDocumentationFirstItem.getDescription()); + Assertions.assertEquals("https://docs.contoso.com", responseExternalDocumentationFirstItem.getUrl()); + // verify property "contacts" + List responseContacts = response.getContacts(); + Contact responseContactsFirstItem = responseContacts.iterator().next(); + Assertions.assertNotNull(responseContactsFirstItem); + Assertions.assertEquals("Contoso support", responseContactsFirstItem.getName()); + Assertions.assertEquals("https://support.contoso.com", responseContactsFirstItem.getUrl()); + Assertions.assertEquals("support@contoso.com", responseContactsFirstItem.getEmail()); + // verify property "lastUpdated" + Assertions.assertNotNull(response.getLastUpdated()); + } +} diff --git a/sdk/apicenter/azure-apicenter/src/test/java/com/azure/apicenter/generated/ApisListAllTests.java b/sdk/apicenter/azure-apicenter/src/test/java/com/azure/apicenter/generated/ApisListAllTests.java new file mode 100644 index 000000000000..b915346ab7b0 --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/test/java/com/azure/apicenter/generated/ApisListAllTests.java @@ -0,0 +1,66 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.apicenter.generated; + +import com.azure.apicenter.models.Api; +import com.azure.apicenter.models.ApiKind; +import com.azure.apicenter.models.Contact; +import com.azure.apicenter.models.ExternalDocumentation; +import com.azure.apicenter.models.License; +import com.azure.apicenter.models.LifecycleStage; +import com.azure.apicenter.models.PagedApiAll; +import com.azure.apicenter.models.TermsOfService; +import java.util.List; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +@Disabled +public final class ApisListAllTests extends DataApiClientTestBase { + @Test + @Disabled + public void testApisListAllTests() { + // method invocation + PagedApiAll response = apisClient.listAll(null, null, null); + + // response assertion + Assertions.assertNotNull(response); + // verify property "value" + List responseValue = response.getValue(); + Api responseValueFirstItem = responseValue.iterator().next(); + Assertions.assertNotNull(responseValueFirstItem); + Assertions.assertEquals("echo-api", responseValueFirstItem.getName()); + Assertions.assertEquals("Echo API", responseValueFirstItem.getTitle()); + Assertions.assertEquals("A simple HTTP request/response service.", responseValueFirstItem.getDescription()); + Assertions.assertEquals(ApiKind.REST, responseValueFirstItem.getKind()); + Assertions.assertEquals(LifecycleStage.DESIGN, responseValueFirstItem.getLifecycleStage()); + TermsOfService responseValueFirstItemTermsOfService = responseValueFirstItem.getTermsOfService(); + Assertions.assertNotNull(responseValueFirstItemTermsOfService); + Assertions.assertEquals("https://contoso.com/terms-of-service", responseValueFirstItemTermsOfService.getUrl()); + License responseValueFirstItemLicense = responseValueFirstItem.getLicense(); + Assertions.assertNotNull(responseValueFirstItemLicense); + Assertions.assertEquals("default", responseValueFirstItemLicense.getName()); + Assertions.assertEquals("https://contoso.com/license", responseValueFirstItemLicense.getUrl()); + List responseValueFirstItemExternalDocumentation + = responseValueFirstItem.getExternalDocumentation(); + ExternalDocumentation responseValueFirstItemExternalDocumentationFirstItem + = responseValueFirstItemExternalDocumentation.iterator().next(); + Assertions.assertNotNull(responseValueFirstItemExternalDocumentationFirstItem); + Assertions.assertEquals("Onboarding docs", responseValueFirstItemExternalDocumentationFirstItem.getTitle()); + Assertions.assertEquals("Learn how to onboard to the Echo API.", + responseValueFirstItemExternalDocumentationFirstItem.getDescription()); + Assertions.assertEquals("https://docs.contoso.com", + responseValueFirstItemExternalDocumentationFirstItem.getUrl()); + List responseValueFirstItemContacts = responseValueFirstItem.getContacts(); + Contact responseValueFirstItemContactsFirstItem = responseValueFirstItemContacts.iterator().next(); + Assertions.assertNotNull(responseValueFirstItemContactsFirstItem); + Assertions.assertEquals("Contoso support", responseValueFirstItemContactsFirstItem.getName()); + Assertions.assertEquals("https://support.contoso.com", responseValueFirstItemContactsFirstItem.getUrl()); + Assertions.assertEquals("support@contoso.com", responseValueFirstItemContactsFirstItem.getEmail()); + Assertions.assertNotNull(responseValueFirstItem.getLastUpdated()); + // verify property "nextLink" + Assertions.assertEquals("https://microsoft.com/a", response.getNextLink()); + } +} diff --git a/sdk/apicenter/azure-apicenter/src/test/java/com/azure/apicenter/generated/ApisListTests.java b/sdk/apicenter/azure-apicenter/src/test/java/com/azure/apicenter/generated/ApisListTests.java new file mode 100644 index 000000000000..d175be8bd130 --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/test/java/com/azure/apicenter/generated/ApisListTests.java @@ -0,0 +1,70 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.apicenter.generated; + +import com.azure.apicenter.models.Api; +import com.azure.apicenter.models.ApiKind; +import com.azure.apicenter.models.Contact; +import com.azure.apicenter.models.ExternalDocumentation; +import com.azure.apicenter.models.License; +import com.azure.apicenter.models.LifecycleStage; +import com.azure.apicenter.models.TermsOfService; +import com.azure.core.http.rest.PagedIterable; +import java.util.List; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +@Disabled +public final class ApisListTests extends DataApiClientTestBase { + @Test + @Disabled + public void testApisListTests() { + // method invocation + PagedIterable response = apisClient.list("default", null, null); + + // response assertion + Assertions.assertEquals(200, response.iterableByPage().iterator().next().getStatusCode()); + Api firstItem = response.iterator().next(); + Assertions.assertNotNull(firstItem); + // verify property "name" + Assertions.assertEquals("echo-api", firstItem.getName()); + // verify property "title" + Assertions.assertEquals("Echo API", firstItem.getTitle()); + // verify property "description" + Assertions.assertEquals("A simple HTTP request/response service.", firstItem.getDescription()); + // verify property "kind" + Assertions.assertEquals(ApiKind.REST, firstItem.getKind()); + // verify property "lifecycleStage" + Assertions.assertEquals(LifecycleStage.DESIGN, firstItem.getLifecycleStage()); + // verify property "termsOfService" + TermsOfService firstItemTermsOfService = firstItem.getTermsOfService(); + Assertions.assertNotNull(firstItemTermsOfService); + Assertions.assertEquals("https://contoso.com/terms-of-service", firstItemTermsOfService.getUrl()); + // verify property "license" + License firstItemLicense = firstItem.getLicense(); + Assertions.assertNotNull(firstItemLicense); + Assertions.assertEquals("default", firstItemLicense.getName()); + Assertions.assertEquals("https://contoso.com/license", firstItemLicense.getUrl()); + // verify property "externalDocumentation" + List firstItemExternalDocumentation = firstItem.getExternalDocumentation(); + ExternalDocumentation firstItemExternalDocumentationFirstItem + = firstItemExternalDocumentation.iterator().next(); + Assertions.assertNotNull(firstItemExternalDocumentationFirstItem); + Assertions.assertEquals("Onboarding docs", firstItemExternalDocumentationFirstItem.getTitle()); + Assertions.assertEquals("Learn how to onboard to the Echo API.", + firstItemExternalDocumentationFirstItem.getDescription()); + Assertions.assertEquals("https://docs.contoso.com", firstItemExternalDocumentationFirstItem.getUrl()); + // verify property "contacts" + List firstItemContacts = firstItem.getContacts(); + Contact firstItemContactsFirstItem = firstItemContacts.iterator().next(); + Assertions.assertNotNull(firstItemContactsFirstItem); + Assertions.assertEquals("Contoso support", firstItemContactsFirstItem.getName()); + Assertions.assertEquals("https://support.contoso.com", firstItemContactsFirstItem.getUrl()); + Assertions.assertEquals("support@contoso.com", firstItemContactsFirstItem.getEmail()); + // verify property "lastUpdated" + Assertions.assertNotNull(firstItem.getLastUpdated()); + } +} diff --git a/sdk/apicenter/azure-apicenter/src/test/java/com/azure/apicenter/generated/DataApiClientTestBase.java b/sdk/apicenter/azure-apicenter/src/test/java/com/azure/apicenter/generated/DataApiClientTestBase.java new file mode 100644 index 000000000000..ef0e33b6f6df --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/test/java/com/azure/apicenter/generated/DataApiClientTestBase.java @@ -0,0 +1,114 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.apicenter.generated; + +// The Java test files under 'generated' package are generated for your reference. +// If you wish to modify these files, please copy them out of the 'generated' package, and modify there. +// See https://aka.ms/azsdk/dpg/java/tests for guide on adding a test. + +import com.azure.apicenter.ApiDefinitionsClient; +import com.azure.apicenter.ApiDeploymentsClient; +import com.azure.apicenter.ApiVersionsClient; +import com.azure.apicenter.ApisClient; +import com.azure.apicenter.DataApiClientBuilder; +import com.azure.apicenter.EnvironmentsClient; +import com.azure.core.http.policy.HttpLogDetailLevel; +import com.azure.core.http.policy.HttpLogOptions; +import com.azure.core.test.TestMode; +import com.azure.core.test.TestProxyTestBase; +import com.azure.core.test.utils.MockTokenCredential; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; + +class DataApiClientTestBase extends TestProxyTestBase { + protected ApisClient apisClient; + + protected ApiDefinitionsClient apiDefinitionsClient; + + protected ApiDeploymentsClient apiDeploymentsClient; + + protected EnvironmentsClient environmentsClient; + + protected ApiVersionsClient apiVersionsClient; + + @Override + protected void beforeTest() { + DataApiClientBuilder apisClientbuilder = new DataApiClientBuilder() + .serviceName(Configuration.getGlobalConfiguration().get("SERVICENAME", "servicename")) + .region(Configuration.getGlobalConfiguration().get("REGION", "region")) + .httpClient(getHttpClientOrUsePlayback(getHttpClients().findFirst().orElse(null))) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + apisClientbuilder.credential(new MockTokenCredential()); + } else if (getTestMode() == TestMode.RECORD) { + apisClientbuilder.addPolicy(interceptorManager.getRecordPolicy()) + .credential(new DefaultAzureCredentialBuilder().build()); + } else if (getTestMode() == TestMode.LIVE) { + apisClientbuilder.credential(new DefaultAzureCredentialBuilder().build()); + } + apisClient = apisClientbuilder.buildApisClient(); + + DataApiClientBuilder apiDefinitionsClientbuilder = new DataApiClientBuilder() + .serviceName(Configuration.getGlobalConfiguration().get("SERVICENAME", "servicename")) + .region(Configuration.getGlobalConfiguration().get("REGION", "region")) + .httpClient(getHttpClientOrUsePlayback(getHttpClients().findFirst().orElse(null))) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + apiDefinitionsClientbuilder.credential(new MockTokenCredential()); + } else if (getTestMode() == TestMode.RECORD) { + apiDefinitionsClientbuilder.addPolicy(interceptorManager.getRecordPolicy()) + .credential(new DefaultAzureCredentialBuilder().build()); + } else if (getTestMode() == TestMode.LIVE) { + apiDefinitionsClientbuilder.credential(new DefaultAzureCredentialBuilder().build()); + } + apiDefinitionsClient = apiDefinitionsClientbuilder.buildApiDefinitionsClient(); + + DataApiClientBuilder apiDeploymentsClientbuilder = new DataApiClientBuilder() + .serviceName(Configuration.getGlobalConfiguration().get("SERVICENAME", "servicename")) + .region(Configuration.getGlobalConfiguration().get("REGION", "region")) + .httpClient(getHttpClientOrUsePlayback(getHttpClients().findFirst().orElse(null))) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + apiDeploymentsClientbuilder.credential(new MockTokenCredential()); + } else if (getTestMode() == TestMode.RECORD) { + apiDeploymentsClientbuilder.addPolicy(interceptorManager.getRecordPolicy()) + .credential(new DefaultAzureCredentialBuilder().build()); + } else if (getTestMode() == TestMode.LIVE) { + apiDeploymentsClientbuilder.credential(new DefaultAzureCredentialBuilder().build()); + } + apiDeploymentsClient = apiDeploymentsClientbuilder.buildApiDeploymentsClient(); + + DataApiClientBuilder environmentsClientbuilder = new DataApiClientBuilder() + .serviceName(Configuration.getGlobalConfiguration().get("SERVICENAME", "servicename")) + .region(Configuration.getGlobalConfiguration().get("REGION", "region")) + .httpClient(getHttpClientOrUsePlayback(getHttpClients().findFirst().orElse(null))) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + environmentsClientbuilder.credential(new MockTokenCredential()); + } else if (getTestMode() == TestMode.RECORD) { + environmentsClientbuilder.addPolicy(interceptorManager.getRecordPolicy()) + .credential(new DefaultAzureCredentialBuilder().build()); + } else if (getTestMode() == TestMode.LIVE) { + environmentsClientbuilder.credential(new DefaultAzureCredentialBuilder().build()); + } + environmentsClient = environmentsClientbuilder.buildEnvironmentsClient(); + + DataApiClientBuilder apiVersionsClientbuilder = new DataApiClientBuilder() + .serviceName(Configuration.getGlobalConfiguration().get("SERVICENAME", "servicename")) + .region(Configuration.getGlobalConfiguration().get("REGION", "region")) + .httpClient(getHttpClientOrUsePlayback(getHttpClients().findFirst().orElse(null))) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + apiVersionsClientbuilder.credential(new MockTokenCredential()); + } else if (getTestMode() == TestMode.RECORD) { + apiVersionsClientbuilder.addPolicy(interceptorManager.getRecordPolicy()) + .credential(new DefaultAzureCredentialBuilder().build()); + } else if (getTestMode() == TestMode.LIVE) { + apiVersionsClientbuilder.credential(new DefaultAzureCredentialBuilder().build()); + } + apiVersionsClient = apiVersionsClientbuilder.buildApiVersionsClient(); + + } +} diff --git a/sdk/apicenter/azure-apicenter/src/test/java/com/azure/apicenter/generated/EnvironmentsGetTests.java b/sdk/apicenter/azure-apicenter/src/test/java/com/azure/apicenter/generated/EnvironmentsGetTests.java new file mode 100644 index 000000000000..44b79c70ae86 --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/test/java/com/azure/apicenter/generated/EnvironmentsGetTests.java @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.apicenter.generated; + +import com.azure.apicenter.models.Environment; +import com.azure.apicenter.models.EnvironmentKind; +import com.azure.apicenter.models.EnvironmentOnboardingModel; +import com.azure.apicenter.models.EnvironmentServer; +import java.util.List; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +@Disabled +public final class EnvironmentsGetTests extends DataApiClientTestBase { + @Test + @Disabled + public void testEnvironmentsGetTests() { + // method invocation + Environment response = environmentsClient.get("default", "production"); + + // response assertion + Assertions.assertNotNull(response); + // verify property "name" + Assertions.assertEquals("public", response.getName()); + // verify property "title" + Assertions.assertEquals("Public", response.getTitle()); + // verify property "kind" + Assertions.assertEquals(EnvironmentKind.PRODUCTION, response.getKind()); + // verify property "description" + Assertions.assertEquals("Public Cloud environment.", response.getDescription()); + // verify property "server" + EnvironmentServer responseServer = response.getServer(); + Assertions.assertNotNull(responseServer); + Assertions.assertEquals("Azure API Management", responseServer.getType()); + List responseServerManagementPortalUris = responseServer.getManagementPortalUris(); + Assertions.assertEquals("https://portal.azure.com", responseServerManagementPortalUris.iterator().next()); + // verify property "onboarding" + EnvironmentOnboardingModel responseOnboarding = response.getOnboarding(); + Assertions.assertNotNull(responseOnboarding); + Assertions.assertEquals("https://aka.ms/apim-devportal", responseOnboarding.getInstructions()); + List responseOnboardingDeveloperPortalUris = responseOnboarding.getDeveloperPortalUris(); + Assertions.assertEquals("https://contoso.developer.azure-api.net", + responseOnboardingDeveloperPortalUris.iterator().next()); + } +} diff --git a/sdk/apicenter/azure-apicenter/src/test/java/com/azure/apicenter/generated/EnvironmentsListAllTests.java b/sdk/apicenter/azure-apicenter/src/test/java/com/azure/apicenter/generated/EnvironmentsListAllTests.java new file mode 100644 index 000000000000..57fb68156ba8 --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/test/java/com/azure/apicenter/generated/EnvironmentsListAllTests.java @@ -0,0 +1,52 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.apicenter.generated; + +import com.azure.apicenter.models.Environment; +import com.azure.apicenter.models.EnvironmentKind; +import com.azure.apicenter.models.EnvironmentOnboardingModel; +import com.azure.apicenter.models.EnvironmentServer; +import com.azure.apicenter.models.PagedEnvironmentAll; +import java.util.List; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +@Disabled +public final class EnvironmentsListAllTests extends DataApiClientTestBase { + @Test + @Disabled + public void testEnvironmentsListAllTests() { + // method invocation + PagedEnvironmentAll response = environmentsClient.listAll(null, null, null); + + // response assertion + Assertions.assertNotNull(response); + // verify property "value" + List responseValue = response.getValue(); + Environment responseValueFirstItem = responseValue.iterator().next(); + Assertions.assertNotNull(responseValueFirstItem); + Assertions.assertEquals("public", responseValueFirstItem.getName()); + Assertions.assertEquals("Public", responseValueFirstItem.getTitle()); + Assertions.assertEquals(EnvironmentKind.PRODUCTION, responseValueFirstItem.getKind()); + Assertions.assertEquals("Public Cloud environment.", responseValueFirstItem.getDescription()); + EnvironmentServer responseValueFirstItemServer = responseValueFirstItem.getServer(); + Assertions.assertNotNull(responseValueFirstItemServer); + Assertions.assertEquals("Azure API Management", responseValueFirstItemServer.getType()); + List responseValueFirstItemServerManagementPortalUris + = responseValueFirstItemServer.getManagementPortalUris(); + Assertions.assertEquals("https://portal.azure.com", + responseValueFirstItemServerManagementPortalUris.iterator().next()); + EnvironmentOnboardingModel responseValueFirstItemOnboarding = responseValueFirstItem.getOnboarding(); + Assertions.assertNotNull(responseValueFirstItemOnboarding); + Assertions.assertEquals("https://aka.ms/apim-devportal", responseValueFirstItemOnboarding.getInstructions()); + List responseValueFirstItemOnboardingDeveloperPortalUris + = responseValueFirstItemOnboarding.getDeveloperPortalUris(); + Assertions.assertEquals("https://contoso.developer.azure-api.net", + responseValueFirstItemOnboardingDeveloperPortalUris.iterator().next()); + // verify property "nextLink" + Assertions.assertEquals("https://...", response.getNextLink()); + } +} diff --git a/sdk/apicenter/azure-apicenter/src/test/java/com/azure/apicenter/generated/EnvironmentsListTests.java b/sdk/apicenter/azure-apicenter/src/test/java/com/azure/apicenter/generated/EnvironmentsListTests.java new file mode 100644 index 000000000000..2e123949c98b --- /dev/null +++ b/sdk/apicenter/azure-apicenter/src/test/java/com/azure/apicenter/generated/EnvironmentsListTests.java @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.apicenter.generated; + +import com.azure.apicenter.models.Environment; +import com.azure.apicenter.models.EnvironmentKind; +import com.azure.apicenter.models.EnvironmentOnboardingModel; +import com.azure.apicenter.models.EnvironmentServer; +import com.azure.core.http.rest.PagedIterable; +import java.util.List; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +@Disabled +public final class EnvironmentsListTests extends DataApiClientTestBase { + @Test + @Disabled + public void testEnvironmentsListTests() { + // method invocation + PagedIterable response = environmentsClient.list("default", null, null); + + // response assertion + Assertions.assertEquals(200, response.iterableByPage().iterator().next().getStatusCode()); + Environment firstItem = response.iterator().next(); + Assertions.assertNotNull(firstItem); + // verify property "name" + Assertions.assertEquals("public", firstItem.getName()); + // verify property "title" + Assertions.assertEquals("Public", firstItem.getTitle()); + // verify property "kind" + Assertions.assertEquals(EnvironmentKind.PRODUCTION, firstItem.getKind()); + // verify property "description" + Assertions.assertEquals("Public Cloud environment.", firstItem.getDescription()); + // verify property "server" + EnvironmentServer firstItemServer = firstItem.getServer(); + Assertions.assertNotNull(firstItemServer); + Assertions.assertEquals("Azure API Management", firstItemServer.getType()); + List firstItemServerManagementPortalUris = firstItemServer.getManagementPortalUris(); + Assertions.assertEquals("https://portal.azure.com", firstItemServerManagementPortalUris.iterator().next()); + // verify property "onboarding" + EnvironmentOnboardingModel firstItemOnboarding = firstItem.getOnboarding(); + Assertions.assertNotNull(firstItemOnboarding); + Assertions.assertEquals("https://aka.ms/apim-devportal", firstItemOnboarding.getInstructions()); + List firstItemOnboardingDeveloperPortalUris = firstItemOnboarding.getDeveloperPortalUris(); + Assertions.assertEquals("https://contoso.developer.azure-api.net", + firstItemOnboardingDeveloperPortalUris.iterator().next()); + } +} diff --git a/sdk/apicenter/azure-apicenter/tsp-location.yaml b/sdk/apicenter/azure-apicenter/tsp-location.yaml new file mode 100644 index 000000000000..382418cecf17 --- /dev/null +++ b/sdk/apicenter/azure-apicenter/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/apicenter/ApiCenter.DataApi +commit: eaaef41ddeb7e5e2f4025c7ce714c4a36f06dcd5 +repo: Azure/azure-rest-api-specs +additionalDirectories: diff --git a/sdk/apicenter/ci.yml b/sdk/apicenter/ci.yml index da239c439b82..16ad816686d6 100644 --- a/sdk/apicenter/ci.yml +++ b/sdk/apicenter/ci.yml @@ -34,6 +34,10 @@ parameters: displayName: azure-resourcemanager-apicenter type: boolean default: false + - name: release_azureapicenter + displayName: azure-apicenter + type: boolean + default: true extends: template: ../../eng/pipelines/templates/stages/archetype-sdk-client.yml @@ -44,3 +48,7 @@ extends: groupId: com.azure.resourcemanager safeName: azureresourcemanagerapicenter releaseInBatch: ${{ parameters.release_azureresourcemanagerapicenter }} + - name: azure-apicenter + groupId: com.azure + safeName: azureapicenter + releaseInBatch: ${{ parameters.release_azureapicenter }} diff --git a/sdk/apicenter/pom.xml b/sdk/apicenter/pom.xml index 9a0ee6e03cdf..bb67650262e1 100644 --- a/sdk/apicenter/pom.xml +++ b/sdk/apicenter/pom.xml @@ -10,6 +10,7 @@ 1.0.0 + azure-apicenter azure-resourcemanager-apicenter