diff --git a/eng/versioning/version_client.txt b/eng/versioning/version_client.txt index b04d701dd93c..ca4cabe608f1 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.22.0;5.23.0- com.azure.spring:spring-cloud-azure-stream-binder-servicebus;5.22.0;5.23.0-beta.1 com.azure.spring:spring-cloud-azure-testcontainers;5.22.0;5.23.0-beta.1 com.azure:azure-spring-data-cosmos;5.22.0;5.23.0-beta.1 +com.azure:azure-developer-playwright;1.0.0-beta.1;1.0.0-beta.1 com.azure.resourcemanager:azure-resourcemanager;2.50.0;2.51.0-beta.1 com.azure.resourcemanager:azure-resourcemanager-appplatform;2.50.0;2.51.0-beta.1 com.azure.resourcemanager:azure-resourcemanager-appservice;2.50.0;2.51.0-beta.1 diff --git a/pom.xml b/pom.xml index 59226c65adf6..7838598ddcaa 100644 --- a/pom.xml +++ b/pom.xml @@ -174,6 +174,7 @@ sdk/peering sdk/personalizer sdk/pineconevectordb + sdk/playwright sdk/playwrighttesting sdk/policyinsights sdk/portalservices diff --git a/sdk/playwright/azure-developer-playwright/CHANGELOG.md b/sdk/playwright/azure-developer-playwright/CHANGELOG.md new file mode 100644 index 000000000000..0f39b99b5064 --- /dev/null +++ b/sdk/playwright/azure-developer-playwright/CHANGELOG.md @@ -0,0 +1,16 @@ +# Release History + +## 1.0.0-beta.1 (Unreleased) + +- Azure Microsoft Playwright Service client library for Java. This package contains Microsoft Azure Microsoft Playwright Service client library. + +### Features Added + +### Breaking Changes + +### Bugs Fixed + +### Other Changes +### Features Added + +- Initial release for the azure-developer-playwright Java SDK. diff --git a/sdk/playwright/azure-developer-playwright/README.md b/sdk/playwright/azure-developer-playwright/README.md new file mode 100644 index 000000000000..bd593458d5c2 --- /dev/null +++ b/sdk/playwright/azure-developer-playwright/README.md @@ -0,0 +1,78 @@ +# Azure Microsoft Playwright Service client library for Java + +Azure Microsoft Playwright Service client library for Java. + +This package contains Microsoft Azure Microsoft Playwright Service 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-developer-playwright;current}) +```xml + + com.azure + azure-developer-playwright + 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.developer.playwright.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/playwright/azure-developer-playwright/assets.json b/sdk/playwright/azure-developer-playwright/assets.json new file mode 100644 index 000000000000..4bb0131d37c2 --- /dev/null +++ b/sdk/playwright/azure-developer-playwright/assets.json @@ -0,0 +1 @@ +{"AssetsRepo":"Azure/azure-sdk-assets","AssetsRepoPrefixPath":"java","TagPrefix":"java/playwright/azure-developer-playwright","Tag":""} \ No newline at end of file diff --git a/sdk/playwright/azure-developer-playwright/pom.xml b/sdk/playwright/azure-developer-playwright/pom.xml new file mode 100644 index 000000000000..0c997eba3bff --- /dev/null +++ b/sdk/playwright/azure-developer-playwright/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-developer-playwright + 1.0.0-beta.1 + jar + + Microsoft Azure SDK for Microsoft Playwright Service + This package contains Microsoft Azure Microsoft Playwright Service 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/playwright/azure-developer-playwright/src/main/java/com/azure/developer/playwright/AccessTokensAsyncClient.java b/sdk/playwright/azure-developer-playwright/src/main/java/com/azure/developer/playwright/AccessTokensAsyncClient.java new file mode 100644 index 000000000000..7600ef816a17 --- /dev/null +++ b/sdk/playwright/azure-developer-playwright/src/main/java/com/azure/developer/playwright/AccessTokensAsyncClient.java @@ -0,0 +1,289 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.developer.playwright; + +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.developer.playwright.implementation.AccessTokensImpl; +import com.azure.developer.playwright.models.AccessToken; +import java.util.stream.Collectors; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous PlaywrightClient type. + */ +@ServiceClient(builder = PlaywrightClientBuilder.class, isAsync = true) +public final class AccessTokensAsyncClient { + @Generated + private final AccessTokensImpl serviceClient; + + /** + * Initializes an instance of AccessTokensAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + AccessTokensAsyncClient(AccessTokensImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Creates an access-token for the workspace with given access-token id. Authorization required is Bearer JWT Access + * token provided by EntraID. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     jwtToken: String (Optional)
+     *     createdAt: OffsetDateTime (Required)
+     *     expiryAt: OffsetDateTime (Required)
+     *     state: String(Active/Expired) (Required)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     jwtToken: String (Optional)
+     *     createdAt: OffsetDateTime (Required)
+     *     expiryAt: OffsetDateTime (Required)
+     *     state: String(Active/Expired) (Required)
+     * }
+     * }
+     * 
+ * + * @param workspaceId The workspace id. + * @param accessTokenId The access-token id. + * @param resource The resource instance. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return model of an access-token linked to a workspace along with {@link Response} on successful completion of + * {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> createOrReplaceWithResponse(String workspaceId, String accessTokenId, + BinaryData resource, RequestOptions requestOptions) { + return this.serviceClient.createOrReplaceWithResponseAsync(workspaceId, accessTokenId, resource, + requestOptions); + } + + /** + * Gets an access-token for the workspace with given access-token id. Authorization required is Bearer JWT Access + * token provided by EntraID. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     jwtToken: String (Optional)
+     *     createdAt: OffsetDateTime (Required)
+     *     expiryAt: OffsetDateTime (Required)
+     *     state: String(Active/Expired) (Required)
+     * }
+     * }
+     * 
+ * + * @param workspaceId The workspace id. + * @param accessTokenId The access-token id. + * @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 access-token for the workspace with given access-token id along with {@link Response} on successful + * completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(String workspaceId, String accessTokenId, + RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(workspaceId, accessTokenId, requestOptions); + } + + /** + * Deletes an access-token for the workspace with given access-token id. Authorization required is Bearer JWT Access + * token provided by EntraID. + * + * @param workspaceId The workspace id. + * @param accessTokenId The access-token id. + * @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 Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> deleteWithResponse(String workspaceId, String accessTokenId, + RequestOptions requestOptions) { + return this.serviceClient.deleteWithResponseAsync(workspaceId, accessTokenId, requestOptions); + } + + /** + * Lists access-tokens for the given workspace id. It can use OData query params like $select, $filter, $orderby, + * $top and $skip. The default page size is 10. Use nextLink in response to fetch more objects in the list. + * Authorization required is Bearer JWT Access token provided by EntraID. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     jwtToken: String (Optional)
+     *     createdAt: OffsetDateTime (Required)
+     *     expiryAt: OffsetDateTime (Required)
+     *     state: String(Active/Expired) (Required)
+     * }
+     * }
+     * 
+ * + * @param workspaceId The workspace id. + * @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 AccessToken items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux list(String workspaceId, RequestOptions requestOptions) { + return this.serviceClient.listAsync(workspaceId, requestOptions); + } + + /** + * Creates an access-token for the workspace with given access-token id. Authorization required is Bearer JWT Access + * token provided by EntraID. + * + * @param workspaceId The workspace id. + * @param accessTokenId The access-token id. + * @param resource The resource instance. + * @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 model of an access-token linked to a workspace on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono createOrReplace(String workspaceId, String accessTokenId, AccessToken resource) { + // Generated convenience method for createOrReplaceWithResponse + RequestOptions requestOptions = new RequestOptions(); + return createOrReplaceWithResponse(workspaceId, accessTokenId, BinaryData.fromObject(resource), requestOptions) + .flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(AccessToken.class)); + } + + /** + * Gets an access-token for the workspace with given access-token id. Authorization required is Bearer JWT Access + * token provided by EntraID. + * + * @param workspaceId The workspace id. + * @param accessTokenId The access-token id. + * @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 access-token for the workspace with given access-token id on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get(String workspaceId, String accessTokenId) { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(workspaceId, accessTokenId, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(AccessToken.class)); + } + + /** + * Deletes an access-token for the workspace with given access-token id. Authorization required is Bearer JWT Access + * token provided by EntraID. + * + * @param workspaceId The workspace id. + * @param accessTokenId The access-token id. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono delete(String workspaceId, String accessTokenId) { + // Generated convenience method for deleteWithResponse + RequestOptions requestOptions = new RequestOptions(); + return deleteWithResponse(workspaceId, accessTokenId, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * Lists access-tokens for the given workspace id. It can use OData query params like $select, $filter, $orderby, + * $top and $skip. The default page size is 10. Use nextLink in response to fetch more objects in the list. + * Authorization required is Bearer JWT Access token provided by EntraID. + * + * @param workspaceId The workspace id. + * @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 AccessToken items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux list(String workspaceId) { + // Generated convenience method for list + RequestOptions requestOptions = new RequestOptions(); + PagedFlux pagedFluxResponse = list(workspaceId, 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(AccessToken.class)) + .collect(Collectors.toList()), + pagedResponse.getContinuationToken(), null)); + }); + } +} diff --git a/sdk/playwright/azure-developer-playwright/src/main/java/com/azure/developer/playwright/AccessTokensClient.java b/sdk/playwright/azure-developer-playwright/src/main/java/com/azure/developer/playwright/AccessTokensClient.java new file mode 100644 index 000000000000..4b950143993b --- /dev/null +++ b/sdk/playwright/azure-developer-playwright/src/main/java/com/azure/developer/playwright/AccessTokensClient.java @@ -0,0 +1,266 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.developer.playwright; + +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.developer.playwright.implementation.AccessTokensImpl; +import com.azure.developer.playwright.models.AccessToken; + +/** + * Initializes a new instance of the synchronous PlaywrightClient type. + */ +@ServiceClient(builder = PlaywrightClientBuilder.class) +public final class AccessTokensClient { + @Generated + private final AccessTokensImpl serviceClient; + + /** + * Initializes an instance of AccessTokensClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + AccessTokensClient(AccessTokensImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Creates an access-token for the workspace with given access-token id. Authorization required is Bearer JWT Access + * token provided by EntraID. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     jwtToken: String (Optional)
+     *     createdAt: OffsetDateTime (Required)
+     *     expiryAt: OffsetDateTime (Required)
+     *     state: String(Active/Expired) (Required)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     jwtToken: String (Optional)
+     *     createdAt: OffsetDateTime (Required)
+     *     expiryAt: OffsetDateTime (Required)
+     *     state: String(Active/Expired) (Required)
+     * }
+     * }
+     * 
+ * + * @param workspaceId The workspace id. + * @param accessTokenId The access-token id. + * @param resource The resource instance. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return model of an access-token linked to a workspace along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response createOrReplaceWithResponse(String workspaceId, String accessTokenId, + BinaryData resource, RequestOptions requestOptions) { + return this.serviceClient.createOrReplaceWithResponse(workspaceId, accessTokenId, resource, requestOptions); + } + + /** + * Gets an access-token for the workspace with given access-token id. Authorization required is Bearer JWT Access + * token provided by EntraID. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     jwtToken: String (Optional)
+     *     createdAt: OffsetDateTime (Required)
+     *     expiryAt: OffsetDateTime (Required)
+     *     state: String(Active/Expired) (Required)
+     * }
+     * }
+     * 
+ * + * @param workspaceId The workspace id. + * @param accessTokenId The access-token id. + * @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 access-token for the workspace with given access-token id along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(String workspaceId, String accessTokenId, + RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(workspaceId, accessTokenId, requestOptions); + } + + /** + * Deletes an access-token for the workspace with given access-token id. Authorization required is Bearer JWT Access + * token provided by EntraID. + * + * @param workspaceId The workspace id. + * @param accessTokenId The access-token id. + * @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 Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response deleteWithResponse(String workspaceId, String accessTokenId, RequestOptions requestOptions) { + return this.serviceClient.deleteWithResponse(workspaceId, accessTokenId, requestOptions); + } + + /** + * Lists access-tokens for the given workspace id. It can use OData query params like $select, $filter, $orderby, + * $top and $skip. The default page size is 10. Use nextLink in response to fetch more objects in the list. + * Authorization required is Bearer JWT Access token provided by EntraID. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     jwtToken: String (Optional)
+     *     createdAt: OffsetDateTime (Required)
+     *     expiryAt: OffsetDateTime (Required)
+     *     state: String(Active/Expired) (Required)
+     * }
+     * }
+     * 
+ * + * @param workspaceId The workspace id. + * @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 AccessToken items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(String workspaceId, RequestOptions requestOptions) { + return this.serviceClient.list(workspaceId, requestOptions); + } + + /** + * Creates an access-token for the workspace with given access-token id. Authorization required is Bearer JWT Access + * token provided by EntraID. + * + * @param workspaceId The workspace id. + * @param accessTokenId The access-token id. + * @param resource The resource instance. + * @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 model of an access-token linked to a workspace. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public AccessToken createOrReplace(String workspaceId, String accessTokenId, AccessToken resource) { + // Generated convenience method for createOrReplaceWithResponse + RequestOptions requestOptions = new RequestOptions(); + return createOrReplaceWithResponse(workspaceId, accessTokenId, BinaryData.fromObject(resource), requestOptions) + .getValue() + .toObject(AccessToken.class); + } + + /** + * Gets an access-token for the workspace with given access-token id. Authorization required is Bearer JWT Access + * token provided by EntraID. + * + * @param workspaceId The workspace id. + * @param accessTokenId The access-token id. + * @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 access-token for the workspace with given access-token id. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public AccessToken get(String workspaceId, String accessTokenId) { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(workspaceId, accessTokenId, requestOptions).getValue().toObject(AccessToken.class); + } + + /** + * Deletes an access-token for the workspace with given access-token id. Authorization required is Bearer JWT Access + * token provided by EntraID. + * + * @param workspaceId The workspace id. + * @param accessTokenId The access-token id. + * @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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void delete(String workspaceId, String accessTokenId) { + // Generated convenience method for deleteWithResponse + RequestOptions requestOptions = new RequestOptions(); + deleteWithResponse(workspaceId, accessTokenId, requestOptions).getValue(); + } + + /** + * Lists access-tokens for the given workspace id. It can use OData query params like $select, $filter, $orderby, + * $top and $skip. The default page size is 10. Use nextLink in response to fetch more objects in the list. + * Authorization required is Bearer JWT Access token provided by EntraID. + * + * @param workspaceId The workspace id. + * @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 AccessToken items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(String workspaceId) { + // Generated convenience method for list + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.list(workspaceId, requestOptions) + .mapPage(bodyItemValue -> bodyItemValue.toObject(AccessToken.class)); + } +} diff --git a/sdk/playwright/azure-developer-playwright/src/main/java/com/azure/developer/playwright/MicrosoftPlaywrightServiceVersion.java b/sdk/playwright/azure-developer-playwright/src/main/java/com/azure/developer/playwright/MicrosoftPlaywrightServiceVersion.java new file mode 100644 index 000000000000..289ae1ea7f39 --- /dev/null +++ b/sdk/playwright/azure-developer-playwright/src/main/java/com/azure/developer/playwright/MicrosoftPlaywrightServiceVersion.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.developer.playwright; + +import com.azure.core.util.ServiceVersion; + +/** + * Service version of Microsoft Playwright ServiceClient. + */ +public enum MicrosoftPlaywrightServiceVersion implements ServiceVersion { + /** + * Enum value 2025-07-01-preview. + */ + V2025_07_01_PREVIEW("2025-07-01-preview"); + + private final String version; + + MicrosoftPlaywrightServiceVersion(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 MicrosoftPlaywrightServiceVersion}. + */ + public static MicrosoftPlaywrightServiceVersion getLatest() { + return V2025_07_01_PREVIEW; + } +} diff --git a/sdk/playwright/azure-developer-playwright/src/main/java/com/azure/developer/playwright/PlaywrightClientBuilder.java b/sdk/playwright/azure-developer-playwright/src/main/java/com/azure/developer/playwright/PlaywrightClientBuilder.java new file mode 100644 index 000000000000..92b8734c78cb --- /dev/null +++ b/sdk/playwright/azure-developer-playwright/src/main/java/com/azure/developer/playwright/PlaywrightClientBuilder.java @@ -0,0 +1,359 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.developer.playwright; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.ServiceClientBuilder; +import com.azure.core.client.traits.ConfigurationTrait; +import com.azure.core.client.traits.EndpointTrait; +import com.azure.core.client.traits.HttpTrait; +import com.azure.core.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 com.azure.developer.playwright.implementation.PlaywrightClientImpl; +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 PlaywrightClient type. + */ +@ServiceClientBuilder( + serviceClients = { + AccessTokensClient.class, + WorkspacesClient.class, + AccessTokensAsyncClient.class, + WorkspacesAsyncClient.class }) +public final class PlaywrightClientBuilder + implements HttpTrait, ConfigurationTrait, + TokenCredentialTrait, EndpointTrait { + @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://playwright.microsoft.com/.default" }; + + @Generated + private static final Map PROPERTIES + = CoreUtils.getProperties("azure-developer-playwright.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the PlaywrightClientBuilder. + */ + @Generated + public PlaywrightClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public PlaywrightClientBuilder 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 PlaywrightClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public PlaywrightClientBuilder 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 PlaywrightClientBuilder 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 PlaywrightClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public PlaywrightClientBuilder 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 PlaywrightClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The TokenCredential used for authentication. + */ + @Generated + private TokenCredential tokenCredential; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public PlaywrightClientBuilder credential(TokenCredential tokenCredential) { + this.tokenCredential = tokenCredential; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public PlaywrightClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * Service version + */ + @Generated + private MicrosoftPlaywrightServiceVersion serviceVersion; + + /** + * Sets Service version. + * + * @param serviceVersion the serviceVersion value. + * @return the PlaywrightClientBuilder. + */ + @Generated + public PlaywrightClientBuilder serviceVersion(MicrosoftPlaywrightServiceVersion 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 PlaywrightClientBuilder. + */ + @Generated + public PlaywrightClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of PlaywrightClientImpl with the provided parameters. + * + * @return an instance of PlaywrightClientImpl. + */ + @Generated + private PlaywrightClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + MicrosoftPlaywrightServiceVersion localServiceVersion + = (serviceVersion != null) ? serviceVersion : MicrosoftPlaywrightServiceVersion.getLatest(); + PlaywrightClientImpl client = new PlaywrightClientImpl(localPipeline, + JacksonAdapter.createDefaultSerializerAdapter(), this.endpoint, 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(endpoint, "'endpoint' 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 AccessTokensAsyncClient class. + * + * @return an instance of AccessTokensAsyncClient. + */ + @Generated + public AccessTokensAsyncClient buildAccessTokensAsyncClient() { + return new AccessTokensAsyncClient(buildInnerClient().getAccessTokens()); + } + + /** + * Builds an instance of WorkspacesAsyncClient class. + * + * @return an instance of WorkspacesAsyncClient. + */ + @Generated + public WorkspacesAsyncClient buildWorkspacesAsyncClient() { + return new WorkspacesAsyncClient(buildInnerClient().getWorkspaces()); + } + + /** + * Builds an instance of AccessTokensClient class. + * + * @return an instance of AccessTokensClient. + */ + @Generated + public AccessTokensClient buildAccessTokensClient() { + return new AccessTokensClient(buildInnerClient().getAccessTokens()); + } + + /** + * Builds an instance of WorkspacesClient class. + * + * @return an instance of WorkspacesClient. + */ + @Generated + public WorkspacesClient buildWorkspacesClient() { + return new WorkspacesClient(buildInnerClient().getWorkspaces()); + } + + private static final ClientLogger LOGGER = new ClientLogger(PlaywrightClientBuilder.class); +} diff --git a/sdk/playwright/azure-developer-playwright/src/main/java/com/azure/developer/playwright/WorkspacesAsyncClient.java b/sdk/playwright/azure-developer-playwright/src/main/java/com/azure/developer/playwright/WorkspacesAsyncClient.java new file mode 100644 index 000000000000..e53d0a821531 --- /dev/null +++ b/sdk/playwright/azure-developer-playwright/src/main/java/com/azure/developer/playwright/WorkspacesAsyncClient.java @@ -0,0 +1,121 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.developer.playwright; + +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.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.util.FluxUtil; +import com.azure.developer.playwright.implementation.WorkspacesImpl; +import com.azure.developer.playwright.models.OS; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous PlaywrightClient type. + */ +@ServiceClient(builder = PlaywrightClientBuilder.class, isAsync = true) +public final class WorkspacesAsyncClient { + @Generated + private final WorkspacesImpl serviceClient; + + /** + * Initializes an instance of WorkspacesAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + WorkspacesAsyncClient(WorkspacesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Gets remote browsers corresponding to given workspace id and redirects the client for executing Playwright + * scripts. Authorization required is Bearer JWT Access token provided by EntraID or Playwright Service. + *

Query Parameters

+ * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
osStringNoThe os provided by client for remote script runs. Allowed values: + * "Linux", "Windows".
runIdStringNoThe runId provided by client to track remote script runs. It + * should match regex ^[a-zA-Z0-9-]{3,24}$
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @param workspaceId The workspace id. + * @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 remote browsers corresponding to given workspace id and redirects the client for executing Playwright + * scripts along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getBrowsersWithResponse(String workspaceId, RequestOptions requestOptions) { + return this.serviceClient.getBrowsersWithResponseAsync(workspaceId, requestOptions); + } + + /** + * Gets remote browsers corresponding to given workspace id and redirects the client for executing Playwright + * scripts. Authorization required is Bearer JWT Access token provided by EntraID or Playwright Service. + * + * @param workspaceId The workspace id. + * @param os The os provided by client for remote script runs. + * @param runId The runId provided by client to track remote script runs. It should match regex + * ^[a-zA-Z0-9-]{3,24}$. + * @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 remote browsers corresponding to given workspace id and redirects the client for executing Playwright + * scripts on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getBrowsers(String workspaceId, OS os, String runId) { + // Generated convenience method for getBrowsersWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (os != null) { + requestOptions.addQueryParam("os", os.toString(), false); + } + if (runId != null) { + requestOptions.addQueryParam("runId", runId, false); + } + return getBrowsersWithResponse(workspaceId, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * Gets remote browsers corresponding to given workspace id and redirects the client for executing Playwright + * scripts. Authorization required is Bearer JWT Access token provided by EntraID or Playwright Service. + * + * @param workspaceId The workspace id. + * @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 remote browsers corresponding to given workspace id and redirects the client for executing Playwright + * scripts on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getBrowsers(String workspaceId) { + // Generated convenience method for getBrowsersWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getBrowsersWithResponse(workspaceId, requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/sdk/playwright/azure-developer-playwright/src/main/java/com/azure/developer/playwright/WorkspacesClient.java b/sdk/playwright/azure-developer-playwright/src/main/java/com/azure/developer/playwright/WorkspacesClient.java new file mode 100644 index 000000000000..16fc550461ff --- /dev/null +++ b/sdk/playwright/azure-developer-playwright/src/main/java/com/azure/developer/playwright/WorkspacesClient.java @@ -0,0 +1,115 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.developer.playwright; + +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.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.developer.playwright.implementation.WorkspacesImpl; +import com.azure.developer.playwright.models.OS; + +/** + * Initializes a new instance of the synchronous PlaywrightClient type. + */ +@ServiceClient(builder = PlaywrightClientBuilder.class) +public final class WorkspacesClient { + @Generated + private final WorkspacesImpl serviceClient; + + /** + * Initializes an instance of WorkspacesClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + WorkspacesClient(WorkspacesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Gets remote browsers corresponding to given workspace id and redirects the client for executing Playwright + * scripts. Authorization required is Bearer JWT Access token provided by EntraID or Playwright Service. + *

Query Parameters

+ * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
osStringNoThe os provided by client for remote script runs. Allowed values: + * "Linux", "Windows".
runIdStringNoThe runId provided by client to track remote script runs. It + * should match regex ^[a-zA-Z0-9-]{3,24}$
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @param workspaceId The workspace id. + * @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 remote browsers corresponding to given workspace id and redirects the client for executing Playwright + * scripts along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getBrowsersWithResponse(String workspaceId, RequestOptions requestOptions) { + return this.serviceClient.getBrowsersWithResponse(workspaceId, requestOptions); + } + + /** + * Gets remote browsers corresponding to given workspace id and redirects the client for executing Playwright + * scripts. Authorization required is Bearer JWT Access token provided by EntraID or Playwright Service. + * + * @param workspaceId The workspace id. + * @param os The os provided by client for remote script runs. + * @param runId The runId provided by client to track remote script runs. It should match regex + * ^[a-zA-Z0-9-]{3,24}$. + * @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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void getBrowsers(String workspaceId, OS os, String runId) { + // Generated convenience method for getBrowsersWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (os != null) { + requestOptions.addQueryParam("os", os.toString(), false); + } + if (runId != null) { + requestOptions.addQueryParam("runId", runId, false); + } + getBrowsersWithResponse(workspaceId, requestOptions).getValue(); + } + + /** + * Gets remote browsers corresponding to given workspace id and redirects the client for executing Playwright + * scripts. Authorization required is Bearer JWT Access token provided by EntraID or Playwright Service. + * + * @param workspaceId The workspace id. + * @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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void getBrowsers(String workspaceId) { + // Generated convenience method for getBrowsersWithResponse + RequestOptions requestOptions = new RequestOptions(); + getBrowsersWithResponse(workspaceId, requestOptions).getValue(); + } +} diff --git a/sdk/playwright/azure-developer-playwright/src/main/java/com/azure/developer/playwright/implementation/AccessTokensImpl.java b/sdk/playwright/azure-developer-playwright/src/main/java/com/azure/developer/playwright/implementation/AccessTokensImpl.java new file mode 100644 index 000000000000..764d2315300a --- /dev/null +++ b/sdk/playwright/azure-developer-playwright/src/main/java/com/azure/developer/playwright/implementation/AccessTokensImpl.java @@ -0,0 +1,642 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.developer.playwright.implementation; + +import com.azure.core.annotation.BodyParam; +import com.azure.core.annotation.Delete; +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.PathParam; +import com.azure.core.annotation.Put; +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.developer.playwright.MicrosoftPlaywrightServiceVersion; +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 AccessTokens. + */ +public final class AccessTokensImpl { + /** + * The proxy service used to perform REST calls. + */ + private final AccessTokensService service; + + /** + * The service client containing this operation class. + */ + private final PlaywrightClientImpl client; + + /** + * Initializes an instance of AccessTokensImpl. + * + * @param client the instance of the service client containing this operation class. + */ + AccessTokensImpl(PlaywrightClientImpl client) { + this.service + = RestProxy.create(AccessTokensService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public MicrosoftPlaywrightServiceVersion getServiceVersion() { + return client.getServiceVersion(); + } + + /** + * The interface defining all the services for PlaywrightClientAccessTokens to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "PlaywrightClientAcce") + public interface AccessTokensService { + @Put("/playwrightworkspaces/{workspaceId}/access-tokens/{accessTokenId}") + @ExpectedResponses({ 200, 201 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> createOrReplace(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("workspaceId") String workspaceId, + @PathParam("accessTokenId") String accessTokenId, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData resource, + RequestOptions requestOptions, Context context); + + @Put("/playwrightworkspaces/{workspaceId}/access-tokens/{accessTokenId}") + @ExpectedResponses({ 200, 201 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response createOrReplaceSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("workspaceId") String workspaceId, + @PathParam("accessTokenId") String accessTokenId, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData resource, + RequestOptions requestOptions, Context context); + + @Get("/playwrightworkspaces/{workspaceId}/access-tokens/{accessTokenId}") + @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("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("workspaceId") String workspaceId, + @PathParam("accessTokenId") String accessTokenId, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/playwrightworkspaces/{workspaceId}/access-tokens/{accessTokenId}") + @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("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("workspaceId") String workspaceId, + @PathParam("accessTokenId") String accessTokenId, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Delete("/playwrightworkspaces/{workspaceId}/access-tokens/{accessTokenId}") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> delete(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("workspaceId") String workspaceId, + @PathParam("accessTokenId") String accessTokenId, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Delete("/playwrightworkspaces/{workspaceId}/access-tokens/{accessTokenId}") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response deleteSync(@HostParam("endpoint") String endpoint, @QueryParam("api-version") String apiVersion, + @PathParam("workspaceId") String workspaceId, @PathParam("accessTokenId") String accessTokenId, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/playwrightworkspaces/{workspaceId}/access-tokens") + @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("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("workspaceId") String workspaceId, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/playwrightworkspaces/{workspaceId}/access-tokens") + @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("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("workspaceId") String workspaceId, + @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("endpoint") String endpoint, @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("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + } + + /** + * Creates an access-token for the workspace with given access-token id. Authorization required is Bearer JWT Access + * token provided by EntraID. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     jwtToken: String (Optional)
+     *     createdAt: OffsetDateTime (Required)
+     *     expiryAt: OffsetDateTime (Required)
+     *     state: String(Active/Expired) (Required)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     jwtToken: String (Optional)
+     *     createdAt: OffsetDateTime (Required)
+     *     expiryAt: OffsetDateTime (Required)
+     *     state: String(Active/Expired) (Required)
+     * }
+     * }
+     * 
+ * + * @param workspaceId The workspace id. + * @param accessTokenId The access-token id. + * @param resource The resource instance. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return model of an access-token linked to a workspace along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> createOrReplaceWithResponseAsync(String workspaceId, String accessTokenId, + BinaryData resource, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext( + context -> service.createOrReplace(this.client.getEndpoint(), this.client.getServiceVersion().getVersion(), + workspaceId, accessTokenId, contentType, accept, resource, requestOptions, context)); + } + + /** + * Creates an access-token for the workspace with given access-token id. Authorization required is Bearer JWT Access + * token provided by EntraID. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     jwtToken: String (Optional)
+     *     createdAt: OffsetDateTime (Required)
+     *     expiryAt: OffsetDateTime (Required)
+     *     state: String(Active/Expired) (Required)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     jwtToken: String (Optional)
+     *     createdAt: OffsetDateTime (Required)
+     *     expiryAt: OffsetDateTime (Required)
+     *     state: String(Active/Expired) (Required)
+     * }
+     * }
+     * 
+ * + * @param workspaceId The workspace id. + * @param accessTokenId The access-token id. + * @param resource The resource instance. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return model of an access-token linked to a workspace along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response createOrReplaceWithResponse(String workspaceId, String accessTokenId, + BinaryData resource, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.createOrReplaceSync(this.client.getEndpoint(), this.client.getServiceVersion().getVersion(), + workspaceId, accessTokenId, contentType, accept, resource, requestOptions, Context.NONE); + } + + /** + * Gets an access-token for the workspace with given access-token id. Authorization required is Bearer JWT Access + * token provided by EntraID. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     jwtToken: String (Optional)
+     *     createdAt: OffsetDateTime (Required)
+     *     expiryAt: OffsetDateTime (Required)
+     *     state: String(Active/Expired) (Required)
+     * }
+     * }
+     * 
+ * + * @param workspaceId The workspace id. + * @param accessTokenId The access-token id. + * @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 access-token for the workspace with given access-token id along with {@link Response} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(String workspaceId, String accessTokenId, + RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), + this.client.getServiceVersion().getVersion(), workspaceId, accessTokenId, accept, requestOptions, context)); + } + + /** + * Gets an access-token for the workspace with given access-token id. Authorization required is Bearer JWT Access + * token provided by EntraID. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     jwtToken: String (Optional)
+     *     createdAt: OffsetDateTime (Required)
+     *     expiryAt: OffsetDateTime (Required)
+     *     state: String(Active/Expired) (Required)
+     * }
+     * }
+     * 
+ * + * @param workspaceId The workspace id. + * @param accessTokenId The access-token id. + * @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 access-token for the workspace with given access-token id along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(String workspaceId, String accessTokenId, + RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), this.client.getServiceVersion().getVersion(), workspaceId, + accessTokenId, accept, requestOptions, Context.NONE); + } + + /** + * Deletes an access-token for the workspace with given access-token id. Authorization required is Bearer JWT Access + * token provided by EntraID. + * + * @param workspaceId The workspace id. + * @param accessTokenId The access-token id. + * @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 Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> deleteWithResponseAsync(String workspaceId, String accessTokenId, + RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.delete(this.client.getEndpoint(), + this.client.getServiceVersion().getVersion(), workspaceId, accessTokenId, accept, requestOptions, context)); + } + + /** + * Deletes an access-token for the workspace with given access-token id. Authorization required is Bearer JWT Access + * token provided by EntraID. + * + * @param workspaceId The workspace id. + * @param accessTokenId The access-token id. + * @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 Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response deleteWithResponse(String workspaceId, String accessTokenId, RequestOptions requestOptions) { + final String accept = "application/json"; + return service.deleteSync(this.client.getEndpoint(), this.client.getServiceVersion().getVersion(), workspaceId, + accessTokenId, accept, requestOptions, Context.NONE); + } + + /** + * Lists access-tokens for the given workspace id. It can use OData query params like $select, $filter, $orderby, + * $top and $skip. The default page size is 10. Use nextLink in response to fetch more objects in the list. + * Authorization required is Bearer JWT Access token provided by EntraID. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     jwtToken: String (Optional)
+     *     createdAt: OffsetDateTime (Required)
+     *     expiryAt: OffsetDateTime (Required)
+     *     state: String(Active/Expired) (Required)
+     * }
+     * }
+     * 
+ * + * @param workspaceId The workspace id. + * @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 AccessToken items along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listSinglePageAsync(String workspaceId, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.list(this.client.getEndpoint(), + this.client.getServiceVersion().getVersion(), workspaceId, accept, requestOptions, context)) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null)); + } + + /** + * Lists access-tokens for the given workspace id. It can use OData query params like $select, $filter, $orderby, + * $top and $skip. The default page size is 10. Use nextLink in response to fetch more objects in the list. + * Authorization required is Bearer JWT Access token provided by EntraID. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     jwtToken: String (Optional)
+     *     createdAt: OffsetDateTime (Required)
+     *     expiryAt: OffsetDateTime (Required)
+     *     state: String(Active/Expired) (Required)
+     * }
+     * }
+     * 
+ * + * @param workspaceId The workspace id. + * @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 AccessToken items as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listAsync(String workspaceId, RequestOptions requestOptions) { + RequestOptions requestOptionsForNextPage = new RequestOptions(); + requestOptionsForNextPage.setContext( + requestOptions != null && requestOptions.getContext() != null ? requestOptions.getContext() : Context.NONE); + return new PagedFlux<>(() -> listSinglePageAsync(workspaceId, requestOptions), + nextLink -> listNextSinglePageAsync(nextLink, requestOptionsForNextPage)); + } + + /** + * Lists access-tokens for the given workspace id. It can use OData query params like $select, $filter, $orderby, + * $top and $skip. The default page size is 10. Use nextLink in response to fetch more objects in the list. + * Authorization required is Bearer JWT Access token provided by EntraID. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     jwtToken: String (Optional)
+     *     createdAt: OffsetDateTime (Required)
+     *     expiryAt: OffsetDateTime (Required)
+     *     state: String(Active/Expired) (Required)
+     * }
+     * }
+     * 
+ * + * @param workspaceId The workspace id. + * @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 AccessToken items along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listSinglePage(String workspaceId, RequestOptions requestOptions) { + final String accept = "application/json"; + Response res = service.listSync(this.client.getEndpoint(), + this.client.getServiceVersion().getVersion(), workspaceId, accept, requestOptions, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null); + } + + /** + * Lists access-tokens for the given workspace id. It can use OData query params like $select, $filter, $orderby, + * $top and $skip. The default page size is 10. Use nextLink in response to fetch more objects in the list. + * Authorization required is Bearer JWT Access token provided by EntraID. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     jwtToken: String (Optional)
+     *     createdAt: OffsetDateTime (Required)
+     *     expiryAt: OffsetDateTime (Required)
+     *     state: String(Active/Expired) (Required)
+     * }
+     * }
+     * 
+ * + * @param workspaceId The workspace id. + * @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 AccessToken items as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(String workspaceId, RequestOptions requestOptions) { + RequestOptions requestOptionsForNextPage = new RequestOptions(); + requestOptionsForNextPage.setContext( + requestOptions != null && requestOptions.getContext() != null ? requestOptions.getContext() : Context.NONE); + return new PagedIterable<>(() -> listSinglePage(workspaceId, requestOptions), + nextLink -> listNextSinglePage(nextLink, requestOptionsForNextPage)); + } + + /** + * Get the next page of items. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     jwtToken: String (Optional)
+     *     createdAt: OffsetDateTime (Required)
+     *     expiryAt: OffsetDateTime (Required)
+     *     state: String(Active/Expired) (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 AccessToken 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.getEndpoint(), 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
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     jwtToken: String (Optional)
+     *     createdAt: OffsetDateTime (Required)
+     *     expiryAt: OffsetDateTime (Required)
+     *     state: String(Active/Expired) (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 AccessToken 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.getEndpoint(), 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/playwright/azure-developer-playwright/src/main/java/com/azure/developer/playwright/implementation/PlaywrightClientImpl.java b/sdk/playwright/azure-developer-playwright/src/main/java/com/azure/developer/playwright/implementation/PlaywrightClientImpl.java new file mode 100644 index 000000000000..71ce9244e1cc --- /dev/null +++ b/sdk/playwright/azure-developer-playwright/src/main/java/com/azure/developer/playwright/implementation/PlaywrightClientImpl.java @@ -0,0 +1,148 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.developer.playwright.implementation; + +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; +import com.azure.developer.playwright.MicrosoftPlaywrightServiceVersion; + +/** + * Initializes a new instance of the PlaywrightClient type. + */ +public final class PlaywrightClientImpl { + /** + * Supported Playwright Service API Endpoints (protocol and hostname, for example: + * https://{region}.api.playwright.microsoft.com). + */ + private final String endpoint; + + /** + * Gets Supported Playwright Service API Endpoints (protocol and hostname, for example: + * https://{region}.api.playwright.microsoft.com). + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * Service version. + */ + private final MicrosoftPlaywrightServiceVersion serviceVersion; + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public MicrosoftPlaywrightServiceVersion 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 AccessTokensImpl object to access its operations. + */ + private final AccessTokensImpl accessTokens; + + /** + * Gets the AccessTokensImpl object to access its operations. + * + * @return the AccessTokensImpl object. + */ + public AccessTokensImpl getAccessTokens() { + return this.accessTokens; + } + + /** + * The WorkspacesImpl object to access its operations. + */ + private final WorkspacesImpl workspaces; + + /** + * Gets the WorkspacesImpl object to access its operations. + * + * @return the WorkspacesImpl object. + */ + public WorkspacesImpl getWorkspaces() { + return this.workspaces; + } + + /** + * Initializes an instance of PlaywrightClient client. + * + * @param endpoint Supported Playwright Service API Endpoints (protocol and hostname, for example: + * https://{region}.api.playwright.microsoft.com). + * @param serviceVersion Service version. + */ + public PlaywrightClientImpl(String endpoint, MicrosoftPlaywrightServiceVersion serviceVersion) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); + } + + /** + * Initializes an instance of PlaywrightClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Supported Playwright Service API Endpoints (protocol and hostname, for example: + * https://{region}.api.playwright.microsoft.com). + * @param serviceVersion Service version. + */ + public PlaywrightClientImpl(HttpPipeline httpPipeline, String endpoint, + MicrosoftPlaywrightServiceVersion serviceVersion) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); + } + + /** + * Initializes an instance of PlaywrightClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param serializerAdapter The serializer to serialize an object into a string. + * @param endpoint Supported Playwright Service API Endpoints (protocol and hostname, for example: + * https://{region}.api.playwright.microsoft.com). + * @param serviceVersion Service version. + */ + public PlaywrightClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint, + MicrosoftPlaywrightServiceVersion serviceVersion) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.serviceVersion = serviceVersion; + this.accessTokens = new AccessTokensImpl(this); + this.workspaces = new WorkspacesImpl(this); + } +} diff --git a/sdk/playwright/azure-developer-playwright/src/main/java/com/azure/developer/playwright/implementation/WorkspacesImpl.java b/sdk/playwright/azure-developer-playwright/src/main/java/com/azure/developer/playwright/implementation/WorkspacesImpl.java new file mode 100644 index 000000000000..f16caf920ee2 --- /dev/null +++ b/sdk/playwright/azure-developer-playwright/src/main/java/com/azure/developer/playwright/implementation/WorkspacesImpl.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.developer.playwright.implementation; + +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.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import com.azure.developer.playwright.MicrosoftPlaywrightServiceVersion; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in Workspaces. + */ +public final class WorkspacesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final WorkspacesService service; + + /** + * The service client containing this operation class. + */ + private final PlaywrightClientImpl client; + + /** + * Initializes an instance of WorkspacesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + WorkspacesImpl(PlaywrightClientImpl client) { + this.service + = RestProxy.create(WorkspacesService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public MicrosoftPlaywrightServiceVersion getServiceVersion() { + return client.getServiceVersion(); + } + + /** + * The interface defining all the services for PlaywrightClientWorkspaces to be used by the proxy service to perform + * REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "PlaywrightClientWork") + public interface WorkspacesService { + @Get("/playwrightworkspaces/{workspaceId}/browsers") + @ExpectedResponses({ 302 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getBrowsers(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("workspaceId") String workspaceId, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/playwrightworkspaces/{workspaceId}/browsers") + @ExpectedResponses({ 302 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getBrowsersSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("workspaceId") String workspaceId, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + } + + /** + * Gets remote browsers corresponding to given workspace id and redirects the client for executing Playwright + * scripts. Authorization required is Bearer JWT Access token provided by EntraID or Playwright Service. + *

Query Parameters

+ * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
osStringNoThe os provided by client for remote script runs. Allowed values: + * "Linux", "Windows".
runIdStringNoThe runId provided by client to track remote script runs. It + * should match regex ^[a-zA-Z0-9-]{3,24}$
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @param workspaceId The workspace id. + * @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 remote browsers corresponding to given workspace id and redirects the client for executing Playwright + * scripts along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getBrowsersWithResponseAsync(String workspaceId, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.getBrowsers(this.client.getEndpoint(), + this.client.getServiceVersion().getVersion(), workspaceId, accept, requestOptions, context)); + } + + /** + * Gets remote browsers corresponding to given workspace id and redirects the client for executing Playwright + * scripts. Authorization required is Bearer JWT Access token provided by EntraID or Playwright Service. + *

Query Parameters

+ * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
osStringNoThe os provided by client for remote script runs. Allowed values: + * "Linux", "Windows".
runIdStringNoThe runId provided by client to track remote script runs. It + * should match regex ^[a-zA-Z0-9-]{3,24}$
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @param workspaceId The workspace id. + * @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 remote browsers corresponding to given workspace id and redirects the client for executing Playwright + * scripts along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getBrowsersWithResponse(String workspaceId, RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getBrowsersSync(this.client.getEndpoint(), this.client.getServiceVersion().getVersion(), + workspaceId, accept, requestOptions, Context.NONE); + } +} diff --git a/sdk/playwright/azure-developer-playwright/src/main/java/com/azure/developer/playwright/implementation/package-info.java b/sdk/playwright/azure-developer-playwright/src/main/java/com/azure/developer/playwright/implementation/package-info.java new file mode 100644 index 000000000000..65b7c0ca3e28 --- /dev/null +++ b/sdk/playwright/azure-developer-playwright/src/main/java/com/azure/developer/playwright/implementation/package-info.java @@ -0,0 +1,10 @@ +// 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 MicrosoftPlaywrightService. + * + */ +package com.azure.developer.playwright.implementation; diff --git a/sdk/playwright/azure-developer-playwright/src/main/java/com/azure/developer/playwright/models/AccessToken.java b/sdk/playwright/azure-developer-playwright/src/main/java/com/azure/developer/playwright/models/AccessToken.java new file mode 100644 index 000000000000..aee4dddb5ce9 --- /dev/null +++ b/sdk/playwright/azure-developer-playwright/src/main/java/com/azure/developer/playwright/models/AccessToken.java @@ -0,0 +1,193 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.developer.playwright.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.time.format.DateTimeFormatter; + +/** + * Model of an access-token linked to a workspace. + */ +@Immutable +public final class AccessToken implements JsonSerializable { + /* + * The access-token id. + */ + @Generated + private String id; + + /* + * The access-token name. + */ + @Generated + private final String name; + + /* + * The access-token value in JWT format. + */ + @Generated + private String jwtToken; + + /* + * The access-token createdAt utcDateTime. + */ + @Generated + private OffsetDateTime createdAt; + + /* + * The access-token expiryAt utcDateTime. + */ + @Generated + private final OffsetDateTime expiryAt; + + /* + * The access-token state - Active | Expired. + */ + @Generated + private AccessTokenState state; + + /** + * Creates an instance of AccessToken class. + * + * @param name the name value to set. + * @param expiryAt the expiryAt value to set. + */ + @Generated + public AccessToken(String name, OffsetDateTime expiryAt) { + this.name = name; + this.expiryAt = expiryAt; + } + + /** + * Get the id property: The access-token id. + * + * @return the id value. + */ + @Generated + public String getId() { + return this.id; + } + + /** + * Get the name property: The access-token name. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * Get the jwtToken property: The access-token value in JWT format. + * + * @return the jwtToken value. + */ + @Generated + public String getJwtToken() { + return this.jwtToken; + } + + /** + * Get the createdAt property: The access-token createdAt utcDateTime. + * + * @return the createdAt value. + */ + @Generated + public OffsetDateTime getCreatedAt() { + return this.createdAt; + } + + /** + * Get the expiryAt property: The access-token expiryAt utcDateTime. + * + * @return the expiryAt value. + */ + @Generated + public OffsetDateTime getExpiryAt() { + return this.expiryAt; + } + + /** + * Get the state property: The access-token state - Active | Expired. + * + * @return the state value. + */ + @Generated + public AccessTokenState getState() { + return this.state; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + jsonWriter.writeStringField("expiryAt", + this.expiryAt == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.expiryAt)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of AccessToken from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of AccessToken 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 AccessToken. + */ + @Generated + public static AccessToken fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String id = null; + String name = null; + OffsetDateTime createdAt = null; + OffsetDateTime expiryAt = null; + AccessTokenState state = null; + String jwtToken = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + id = reader.getString(); + } else if ("name".equals(fieldName)) { + name = reader.getString(); + } else if ("createdAt".equals(fieldName)) { + createdAt = reader + .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString())); + } else if ("expiryAt".equals(fieldName)) { + expiryAt = reader + .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString())); + } else if ("state".equals(fieldName)) { + state = AccessTokenState.fromString(reader.getString()); + } else if ("jwtToken".equals(fieldName)) { + jwtToken = reader.getString(); + } else { + reader.skipChildren(); + } + } + AccessToken deserializedAccessToken = new AccessToken(name, expiryAt); + deserializedAccessToken.id = id; + deserializedAccessToken.createdAt = createdAt; + deserializedAccessToken.state = state; + deserializedAccessToken.jwtToken = jwtToken; + + return deserializedAccessToken; + }); + } +} diff --git a/sdk/playwright/azure-developer-playwright/src/main/java/com/azure/developer/playwright/models/AccessTokenState.java b/sdk/playwright/azure-developer-playwright/src/main/java/com/azure/developer/playwright/models/AccessTokenState.java new file mode 100644 index 000000000000..3b3a78b2eb71 --- /dev/null +++ b/sdk/playwright/azure-developer-playwright/src/main/java/com/azure/developer/playwright/models/AccessTokenState.java @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.developer.playwright.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * The access-token state. + */ +public final class AccessTokenState extends ExpandableStringEnum { + /** + * The access-token is Active. + */ + @Generated + public static final AccessTokenState ACTIVE = fromString("Active"); + + /** + * The access-token is Expired. + */ + @Generated + public static final AccessTokenState EXPIRED = fromString("Expired"); + + /** + * Creates a new instance of AccessTokenState value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public AccessTokenState() { + } + + /** + * Creates or finds a AccessTokenState from its string representation. + * + * @param name a name to look for. + * @return the corresponding AccessTokenState. + */ + @Generated + public static AccessTokenState fromString(String name) { + return fromString(name, AccessTokenState.class); + } + + /** + * Gets known AccessTokenState values. + * + * @return known AccessTokenState values. + */ + @Generated + public static Collection values() { + return values(AccessTokenState.class); + } +} diff --git a/sdk/playwright/azure-developer-playwright/src/main/java/com/azure/developer/playwright/models/OS.java b/sdk/playwright/azure-developer-playwright/src/main/java/com/azure/developer/playwright/models/OS.java new file mode 100644 index 000000000000..99614bf703d7 --- /dev/null +++ b/sdk/playwright/azure-developer-playwright/src/main/java/com/azure/developer/playwright/models/OS.java @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.developer.playwright.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * The os to configure for remote script runs. + */ +public final class OS extends ExpandableStringEnum { + /** + * Linux OS. + */ + @Generated + public static final OS LINUX = fromString("Linux"); + + /** + * Windows OS. + */ + @Generated + public static final OS WINDOWS = fromString("Windows"); + + /** + * Creates a new instance of OS value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public OS() { + } + + /** + * Creates or finds a OS from its string representation. + * + * @param name a name to look for. + * @return the corresponding OS. + */ + @Generated + public static OS fromString(String name) { + return fromString(name, OS.class); + } + + /** + * Gets known OS values. + * + * @return known OS values. + */ + @Generated + public static Collection values() { + return values(OS.class); + } +} diff --git a/sdk/playwright/azure-developer-playwright/src/main/java/com/azure/developer/playwright/models/package-info.java b/sdk/playwright/azure-developer-playwright/src/main/java/com/azure/developer/playwright/models/package-info.java new file mode 100644 index 000000000000..c074685f7352 --- /dev/null +++ b/sdk/playwright/azure-developer-playwright/src/main/java/com/azure/developer/playwright/models/package-info.java @@ -0,0 +1,10 @@ +// 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 MicrosoftPlaywrightService. + * + */ +package com.azure.developer.playwright.models; diff --git a/sdk/playwright/azure-developer-playwright/src/main/java/com/azure/developer/playwright/package-info.java b/sdk/playwright/azure-developer-playwright/src/main/java/com/azure/developer/playwright/package-info.java new file mode 100644 index 000000000000..3103ec84db95 --- /dev/null +++ b/sdk/playwright/azure-developer-playwright/src/main/java/com/azure/developer/playwright/package-info.java @@ -0,0 +1,10 @@ +// 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 MicrosoftPlaywrightService. + * + */ +package com.azure.developer.playwright; diff --git a/sdk/playwright/azure-developer-playwright/src/main/java/module-info.java b/sdk/playwright/azure-developer-playwright/src/main/java/module-info.java new file mode 100644 index 000000000000..8b85bd76f75c --- /dev/null +++ b/sdk/playwright/azure-developer-playwright/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.developer.playwright { + requires transitive com.azure.core; + + exports com.azure.developer.playwright; + exports com.azure.developer.playwright.models; + + opens com.azure.developer.playwright.models to com.azure.core; +} diff --git a/sdk/playwright/azure-developer-playwright/src/main/resources/META-INF/azure-developer-playwright_apiview_properties.json b/sdk/playwright/azure-developer-playwright/src/main/resources/META-INF/azure-developer-playwright_apiview_properties.json new file mode 100644 index 000000000000..18896829fe9e --- /dev/null +++ b/sdk/playwright/azure-developer-playwright/src/main/resources/META-INF/azure-developer-playwright_apiview_properties.json @@ -0,0 +1,31 @@ +{ + "flavor": "azure", + "CrossLanguageDefinitionId": { + "com.azure.developer.playwright.AccessTokensAsyncClient": "Playwright.AccessTokens", + "com.azure.developer.playwright.AccessTokensAsyncClient.createOrReplace": "Playwright.AccessTokens.createOrReplace", + "com.azure.developer.playwright.AccessTokensAsyncClient.createOrReplaceWithResponse": "Playwright.AccessTokens.createOrReplace", + "com.azure.developer.playwright.AccessTokensAsyncClient.delete": "Playwright.AccessTokens.delete", + "com.azure.developer.playwright.AccessTokensAsyncClient.deleteWithResponse": "Playwright.AccessTokens.delete", + "com.azure.developer.playwright.AccessTokensAsyncClient.get": "Playwright.AccessTokens.get", + "com.azure.developer.playwright.AccessTokensAsyncClient.getWithResponse": "Playwright.AccessTokens.get", + "com.azure.developer.playwright.AccessTokensAsyncClient.list": "Playwright.AccessTokens.list", + "com.azure.developer.playwright.AccessTokensClient": "Playwright.AccessTokens", + "com.azure.developer.playwright.AccessTokensClient.createOrReplace": "Playwright.AccessTokens.createOrReplace", + "com.azure.developer.playwright.AccessTokensClient.createOrReplaceWithResponse": "Playwright.AccessTokens.createOrReplace", + "com.azure.developer.playwright.AccessTokensClient.delete": "Playwright.AccessTokens.delete", + "com.azure.developer.playwright.AccessTokensClient.deleteWithResponse": "Playwright.AccessTokens.delete", + "com.azure.developer.playwright.AccessTokensClient.get": "Playwright.AccessTokens.get", + "com.azure.developer.playwright.AccessTokensClient.getWithResponse": "Playwright.AccessTokens.get", + "com.azure.developer.playwright.AccessTokensClient.list": "Playwright.AccessTokens.list", + "com.azure.developer.playwright.PlaywrightClientBuilder": "Playwright", + "com.azure.developer.playwright.WorkspacesAsyncClient": "Playwright.Workspaces", + "com.azure.developer.playwright.WorkspacesAsyncClient.getBrowsers": "Playwright.Workspaces.getBrowsers", + "com.azure.developer.playwright.WorkspacesAsyncClient.getBrowsersWithResponse": "Playwright.Workspaces.getBrowsers", + "com.azure.developer.playwright.WorkspacesClient": "Playwright.Workspaces", + "com.azure.developer.playwright.WorkspacesClient.getBrowsers": "Playwright.Workspaces.getBrowsers", + "com.azure.developer.playwright.WorkspacesClient.getBrowsersWithResponse": "Playwright.Workspaces.getBrowsers", + "com.azure.developer.playwright.models.AccessToken": "Playwright.AccessToken", + "com.azure.developer.playwright.models.AccessTokenState": "Playwright.AccessTokenState", + "com.azure.developer.playwright.models.OS": "Playwright.OS" + } +} diff --git a/sdk/playwright/azure-developer-playwright/src/main/resources/azure-developer-playwright.properties b/sdk/playwright/azure-developer-playwright/src/main/resources/azure-developer-playwright.properties new file mode 100644 index 000000000000..ca812989b4f2 --- /dev/null +++ b/sdk/playwright/azure-developer-playwright/src/main/resources/azure-developer-playwright.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/sdk/playwright/azure-developer-playwright/src/samples/java/com/azure/developer/playwright/ReadmeSamples.java b/sdk/playwright/azure-developer-playwright/src/samples/java/com/azure/developer/playwright/ReadmeSamples.java new file mode 100644 index 000000000000..263f4a2c0448 --- /dev/null +++ b/sdk/playwright/azure-developer-playwright/src/samples/java/com/azure/developer/playwright/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.developer.playwright; + +public final class ReadmeSamples { + public void readmeSamples() { + // BEGIN: com.azure.developer.playwright.readme + // END: com.azure.developer.playwright.readme + } +} diff --git a/sdk/playwright/azure-developer-playwright/src/samples/java/com/azure/developer/playwright/generated/AccessTokensCreateOrReplace.java b/sdk/playwright/azure-developer-playwright/src/samples/java/com/azure/developer/playwright/generated/AccessTokensCreateOrReplace.java new file mode 100644 index 000000000000..14526ba2d32a --- /dev/null +++ b/sdk/playwright/azure-developer-playwright/src/samples/java/com/azure/developer/playwright/generated/AccessTokensCreateOrReplace.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.developer.playwright.generated; + +import com.azure.core.util.Configuration; +import com.azure.developer.playwright.AccessTokensClient; +import com.azure.developer.playwright.PlaywrightClientBuilder; +import com.azure.developer.playwright.models.AccessToken; +import com.azure.identity.DefaultAzureCredentialBuilder; +import java.time.OffsetDateTime; + +public class AccessTokensCreateOrReplace { + public static void main(String[] args) { + AccessTokensClient accessTokensClient + = new PlaywrightClientBuilder().credential(new DefaultAzureCredentialBuilder().build()) + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT")) + .buildAccessTokensClient(); + // BEGIN:com.azure.developer.playwright.generated.accesstokenscreateorreplace.accesstokenscreateorreplace + AccessToken response = accessTokensClient.createOrReplace("00000000-0000-0000-0000-000000000000", + "00000000-0000-0000-0000-000000000000", + new AccessToken("sampleAccessToken", OffsetDateTime.parse("2022-09-28T12:32:33Z"))); + // END:com.azure.developer.playwright.generated.accesstokenscreateorreplace.accesstokenscreateorreplace + } +} diff --git a/sdk/playwright/azure-developer-playwright/src/samples/java/com/azure/developer/playwright/generated/AccessTokensDelete.java b/sdk/playwright/azure-developer-playwright/src/samples/java/com/azure/developer/playwright/generated/AccessTokensDelete.java new file mode 100644 index 000000000000..e8fe0b050dd9 --- /dev/null +++ b/sdk/playwright/azure-developer-playwright/src/samples/java/com/azure/developer/playwright/generated/AccessTokensDelete.java @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.developer.playwright.generated; + +import com.azure.core.util.Configuration; +import com.azure.developer.playwright.AccessTokensClient; +import com.azure.developer.playwright.PlaywrightClientBuilder; +import com.azure.identity.DefaultAzureCredentialBuilder; + +public class AccessTokensDelete { + public static void main(String[] args) { + AccessTokensClient accessTokensClient + = new PlaywrightClientBuilder().credential(new DefaultAzureCredentialBuilder().build()) + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT")) + .buildAccessTokensClient(); + // BEGIN:com.azure.developer.playwright.generated.accesstokensdelete.accesstokensdelete + accessTokensClient.delete("00000000-0000-0000-0000-000000000000", "00000000-0000-0000-0000-000000000000"); + // END:com.azure.developer.playwright.generated.accesstokensdelete.accesstokensdelete + } +} diff --git a/sdk/playwright/azure-developer-playwright/src/samples/java/com/azure/developer/playwright/generated/AccessTokensGet.java b/sdk/playwright/azure-developer-playwright/src/samples/java/com/azure/developer/playwright/generated/AccessTokensGet.java new file mode 100644 index 000000000000..eab1e58d005e --- /dev/null +++ b/sdk/playwright/azure-developer-playwright/src/samples/java/com/azure/developer/playwright/generated/AccessTokensGet.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.developer.playwright.generated; + +import com.azure.core.util.Configuration; +import com.azure.developer.playwright.AccessTokensClient; +import com.azure.developer.playwright.PlaywrightClientBuilder; +import com.azure.developer.playwright.models.AccessToken; +import com.azure.identity.DefaultAzureCredentialBuilder; + +public class AccessTokensGet { + public static void main(String[] args) { + AccessTokensClient accessTokensClient + = new PlaywrightClientBuilder().credential(new DefaultAzureCredentialBuilder().build()) + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT")) + .buildAccessTokensClient(); + // BEGIN:com.azure.developer.playwright.generated.accesstokensget.accesstokensget + AccessToken response + = accessTokensClient.get("00000000-0000-0000-0000-000000000000", "00000000-0000-0000-0000-000000000000"); + // END:com.azure.developer.playwright.generated.accesstokensget.accesstokensget + } +} diff --git a/sdk/playwright/azure-developer-playwright/src/samples/java/com/azure/developer/playwright/generated/AccessTokensList.java b/sdk/playwright/azure-developer-playwright/src/samples/java/com/azure/developer/playwright/generated/AccessTokensList.java new file mode 100644 index 000000000000..aa47ee5627ea --- /dev/null +++ b/sdk/playwright/azure-developer-playwright/src/samples/java/com/azure/developer/playwright/generated/AccessTokensList.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.developer.playwright.generated; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.util.Configuration; +import com.azure.developer.playwright.AccessTokensClient; +import com.azure.developer.playwright.PlaywrightClientBuilder; +import com.azure.developer.playwright.models.AccessToken; +import com.azure.identity.DefaultAzureCredentialBuilder; + +public class AccessTokensList { + public static void main(String[] args) { + AccessTokensClient accessTokensClient + = new PlaywrightClientBuilder().credential(new DefaultAzureCredentialBuilder().build()) + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT")) + .buildAccessTokensClient(); + // BEGIN:com.azure.developer.playwright.generated.accesstokenslist.accesstokenslist + PagedIterable response = accessTokensClient.list("00000000-0000-0000-0000-000000000000"); + // END:com.azure.developer.playwright.generated.accesstokenslist.accesstokenslist + } +} diff --git a/sdk/playwright/azure-developer-playwright/src/samples/java/com/azure/developer/playwright/generated/WorkspacesGetBrowsers.java b/sdk/playwright/azure-developer-playwright/src/samples/java/com/azure/developer/playwright/generated/WorkspacesGetBrowsers.java new file mode 100644 index 000000000000..3f96fb30d685 --- /dev/null +++ b/sdk/playwright/azure-developer-playwright/src/samples/java/com/azure/developer/playwright/generated/WorkspacesGetBrowsers.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.developer.playwright.generated; + +import com.azure.core.util.Configuration; +import com.azure.developer.playwright.PlaywrightClientBuilder; +import com.azure.developer.playwright.WorkspacesClient; +import com.azure.developer.playwright.models.OS; +import com.azure.identity.DefaultAzureCredentialBuilder; + +public class WorkspacesGetBrowsers { + public static void main(String[] args) { + WorkspacesClient workspacesClient + = new PlaywrightClientBuilder().credential(new DefaultAzureCredentialBuilder().build()) + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT")) + .buildWorkspacesClient(); + // BEGIN:com.azure.developer.playwright.generated.workspacesgetbrowsers.workspacesgetbrowsers + workspacesClient.getBrowsers("00000000-0000-0000-0000-000000000000", OS.LINUX, null); + // END:com.azure.developer.playwright.generated.workspacesgetbrowsers.workspacesgetbrowsers + } +} diff --git a/sdk/playwright/azure-developer-playwright/tsp-location.yaml b/sdk/playwright/azure-developer-playwright/tsp-location.yaml new file mode 100644 index 000000000000..b17de35c2c84 --- /dev/null +++ b/sdk/playwright/azure-developer-playwright/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/loadtestservice/Playwright +commit: f0143019cfea40b0257f746a6d512a83774e375e +repo: Azure/azure-rest-api-specs +additionalDirectories: diff --git a/sdk/playwright/ci.yml b/sdk/playwright/ci.yml new file mode 100644 index 000000000000..3d1fb913b20b --- /dev/null +++ b/sdk/playwright/ci.yml @@ -0,0 +1,46 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. + +trigger: + branches: + include: + - main + - hotfix/* + - release/* + paths: + include: + - sdk/playwright/ci.yml + - sdk/playwright/azure-developer-playwright/ + exclude: + - sdk/playwright/pom.xml + - sdk/playwright/azure-developer-playwright/pom.xml + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/playwright/ci.yml + - sdk/playwright/azure-developer-playwright/ + exclude: + - sdk/playwright/pom.xml + - sdk/playwright/azure-developer-playwright/pom.xml + +parameters: + - name: release_azuredeveloperplaywright + displayName: azure-developer-playwright + type: boolean + default: true + +extends: + template: ../../eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: playwright + Artifacts: + - name: azure-developer-playwright + groupId: com.azure + safeName: azuredeveloperplaywright + releaseInBatch: ${{ parameters.release_azuredeveloperplaywright }} diff --git a/sdk/playwright/pom.xml b/sdk/playwright/pom.xml new file mode 100644 index 000000000000..8ec8b8221d16 --- /dev/null +++ b/sdk/playwright/pom.xml @@ -0,0 +1,15 @@ + + + 4.0.0 + com.azure + azure-playwright-service + pom + 1.0.0 + + + azure-developer-playwright + +