diff --git a/eng/versioning/version_client.txt b/eng/versioning/version_client.txt index 4b157d8e86c0..2c69d6fda65a 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-analytics-onlineexperimentation;1.0.0-beta.1;1.0.0-beta.1 com.azure.resourcemanager:azure-resourcemanager;2.49.0;2.50.0-beta.1 com.azure.resourcemanager:azure-resourcemanager-appplatform;2.49.0;2.50.0-beta.1 com.azure.resourcemanager:azure-resourcemanager-appservice;2.49.0;2.50.0-beta.1 diff --git a/pom.xml b/pom.xml index e985a85808f9..d8ec2af49318 100644 --- a/pom.xml +++ b/pom.xml @@ -163,6 +163,7 @@ sdk/nginx sdk/notificationhubs sdk/oep + sdk/onlineexperimentation sdk/openai sdk/operationsmanagement sdk/oracledatabase diff --git a/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/CHANGELOG.md b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/CHANGELOG.md new file mode 100644 index 000000000000..8e1584e8e4d8 --- /dev/null +++ b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/CHANGELOG.md @@ -0,0 +1,16 @@ +# Release History + +## 1.0.0-beta.1 (Unreleased) + +- Azure OnlineExperimentation client library for Java. This package contains Microsoft Azure OnlineExperimentation client library. + +### Features Added + +### Breaking Changes + +### Bugs Fixed + +### Other Changes +### Features Added + +- Initial release for the azure-analytics-onlineexperimentation Java SDK. diff --git a/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/README.md b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/README.md new file mode 100644 index 000000000000..d195d8f367e3 --- /dev/null +++ b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/README.md @@ -0,0 +1,78 @@ +# Azure OnlineExperimentation client library for Java + +Azure OnlineExperimentation client library for Java. + +This package contains Microsoft Azure OnlineExperimentation 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-analytics-onlineexperimentation;current}) +```xml + + com.azure + azure-analytics-onlineexperimentation + 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.analytics.onlineexperimentation.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/onlineexperimentation/azure-analytics-onlineexperimentation/assets.json b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/assets.json new file mode 100644 index 000000000000..5c65cacb5675 --- /dev/null +++ b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/assets.json @@ -0,0 +1 @@ +{"AssetsRepo":"Azure/azure-sdk-assets","AssetsRepoPrefixPath":"java","TagPrefix":"java/onlineexperimentation/azure-analytics-onlineexperimentation","Tag":""} \ No newline at end of file diff --git a/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/pom.xml b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/pom.xml new file mode 100644 index 000000000000..16ac38818afc --- /dev/null +++ b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/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-analytics-onlineexperimentation + 1.0.0-beta.1 + jar + + Microsoft Azure SDK for OnlineExperimentation + This package contains Microsoft Azure OnlineExperimentation 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/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/OnlineExperimentationAsyncClient.java b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/OnlineExperimentationAsyncClient.java new file mode 100644 index 000000000000..e48a7118cfce --- /dev/null +++ b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/OnlineExperimentationAsyncClient.java @@ -0,0 +1,608 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.analytics.onlineexperimentation; + +import com.azure.analytics.onlineexperimentation.implementation.JsonMergePatchHelper; +import com.azure.analytics.onlineexperimentation.implementation.OnlineExperimentationClientImpl; +import com.azure.analytics.onlineexperimentation.models.ExperimentMetric; +import com.azure.analytics.onlineexperimentation.models.ExperimentMetricValidationResult; +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.HttpHeaderName; +import com.azure.core.http.RequestConditions; +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.DateTimeRfc1123; +import com.azure.core.util.FluxUtil; +import java.time.OffsetDateTime; +import java.util.stream.Collectors; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous OnlineExperimentationClient type. + */ +@ServiceClient(builder = OnlineExperimentationClientBuilder.class, isAsync = true) +public final class OnlineExperimentationAsyncClient { + @Generated + private final OnlineExperimentationClientImpl serviceClient; + + /** + * Initializes an instance of OnlineExperimentationAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + OnlineExperimentationAsyncClient(OnlineExperimentationClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Fetches an experiment metric by ID. + *

Header Parameters

+ * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     lifecycle: String(Active/Inactive) (Optional, Required on create)
+     *     displayName: String (Optional, Required on create)
+     *     description: String (Optional, Required on create)
+     *     categories (Optional, Required on create): [
+     *         String (Optional, Required on create)
+     *     ]
+     *     desiredDirection: String(Increase/Decrease/Neutral) (Optional, Required on create)
+     *     definition (Optional, Required on create): {
+     *         type: String(EventCount/UserCount/EventRate/UserRate/Sum/Average/Percentile) (Required)
+     *     }
+     *     eTag: String (Required)
+     *     lastModifiedAt: OffsetDateTime (Required)
+     * }
+     * }
+     * 
+ * + * @param experimentMetricId Identifier for this experiment metric. Must start with a lowercase letter and contain + * only lowercase letters, numbers, and underscores. + * @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 defines experiment metric metadata and computation details along with {@link Response} on successful + * completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getMetricWithResponse(String experimentMetricId, RequestOptions requestOptions) { + return this.serviceClient.getMetricWithResponseAsync(experimentMetricId, requestOptions); + } + + /** + * Creates or updates an experiment metric. + *

Header Parameters

+ * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     lifecycle: String(Active/Inactive) (Optional, Required on create)
+     *     displayName: String (Optional, Required on create)
+     *     description: String (Optional, Required on create)
+     *     categories (Optional, Required on create): [
+     *         String (Optional, Required on create)
+     *     ]
+     *     desiredDirection: String(Increase/Decrease/Neutral) (Optional, Required on create)
+     *     definition (Optional, Required on create): {
+     *         type: String(EventCount/UserCount/EventRate/UserRate/Sum/Average/Percentile) (Required)
+     *     }
+     *     eTag: String (Required)
+     *     lastModifiedAt: OffsetDateTime (Required)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     lifecycle: String(Active/Inactive) (Optional, Required on create)
+     *     displayName: String (Optional, Required on create)
+     *     description: String (Optional, Required on create)
+     *     categories (Optional, Required on create): [
+     *         String (Optional, Required on create)
+     *     ]
+     *     desiredDirection: String(Increase/Decrease/Neutral) (Optional, Required on create)
+     *     definition (Optional, Required on create): {
+     *         type: String(EventCount/UserCount/EventRate/UserRate/Sum/Average/Percentile) (Required)
+     *     }
+     *     eTag: String (Required)
+     *     lastModifiedAt: OffsetDateTime (Required)
+     * }
+     * }
+     * 
+ * + * @param experimentMetricId Identifier for this experiment metric. Must start with a lowercase letter and contain + * only lowercase letters, numbers, and underscores. + * @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 defines experiment metric metadata and computation details along with {@link Response} on successful + * completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> createOrUpdateMetricWithResponse(String experimentMetricId, BinaryData resource, + RequestOptions requestOptions) { + return this.serviceClient.createOrUpdateMetricWithResponseAsync(experimentMetricId, resource, requestOptions); + } + + /** + * Validates an experiment metric definition. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     lifecycle: String(Active/Inactive) (Optional, Required on create)
+     *     displayName: String (Optional, Required on create)
+     *     description: String (Optional, Required on create)
+     *     categories (Optional, Required on create): [
+     *         String (Optional, Required on create)
+     *     ]
+     *     desiredDirection: String(Increase/Decrease/Neutral) (Optional, Required on create)
+     *     definition (Optional, Required on create): {
+     *         type: String(EventCount/UserCount/EventRate/UserRate/Sum/Average/Percentile) (Required)
+     *     }
+     *     eTag: String (Required)
+     *     lastModifiedAt: OffsetDateTime (Required)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     isValid: boolean (Required)
+     *     diagnostics (Required): [
+     *          (Required){
+     *             message: String (Required)
+     *             code: String(FailedSchemaValidation/InvalidEventCondition/UnsupportedEventCondition/InvalidExperimentMetricDefinition) (Required)
+     *         }
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param body Experiment metric input to validate. + * @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 result of validating an experiment metric along with {@link Response} on successful completion of + * {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> validateMetricWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.validateMetricWithResponseAsync(body, requestOptions); + } + + /** + * Deletes an experiment metric. + *

Header Parameters

+ * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param experimentMetricId Identifier for this experiment metric. Must start with a lowercase letter and contain + * only lowercase letters, numbers, and underscores. + * @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> deleteMetricWithResponse(String experimentMetricId, RequestOptions requestOptions) { + return this.serviceClient.deleteMetricWithResponseAsync(experimentMetricId, requestOptions); + } + + /** + * Lists experiment metrics. + *

Query Parameters

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

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     lifecycle: String(Active/Inactive) (Optional, Required on create)
+     *     displayName: String (Optional, Required on create)
+     *     description: String (Optional, Required on create)
+     *     categories (Optional, Required on create): [
+     *         String (Optional, Required on create)
+     *     ]
+     *     desiredDirection: String(Increase/Decrease/Neutral) (Optional, Required on create)
+     *     definition (Optional, Required on create): {
+     *         type: String(EventCount/UserCount/EventRate/UserRate/Sum/Average/Percentile) (Required)
+     *     }
+     *     eTag: String (Required)
+     *     lastModifiedAt: OffsetDateTime (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of ExperimentMetric items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listMetrics(RequestOptions requestOptions) { + return this.serviceClient.listMetricsAsync(requestOptions); + } + + /** + * Fetches an experiment metric by ID. + * + * @param experimentMetricId Identifier for this experiment metric. Must start with a lowercase letter and contain + * only lowercase letters, numbers, and underscores. + * @param requestConditions Specifies HTTP options for conditional requests based on modification time. + * @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 defines experiment metric metadata and computation details on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getMetric(String experimentMetricId, RequestConditions requestConditions) { + // Generated convenience method for getMetricWithResponse + RequestOptions requestOptions = new RequestOptions(); + String ifMatch = requestConditions == null ? null : requestConditions.getIfMatch(); + String ifNoneMatch = requestConditions == null ? null : requestConditions.getIfNoneMatch(); + OffsetDateTime ifUnmodifiedSince = requestConditions == null ? null : requestConditions.getIfUnmodifiedSince(); + OffsetDateTime ifModifiedSince = requestConditions == null ? null : requestConditions.getIfModifiedSince(); + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + return getMetricWithResponse(experimentMetricId, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(ExperimentMetric.class)); + } + + /** + * Fetches an experiment metric by ID. + * + * @param experimentMetricId Identifier for this experiment metric. Must start with a lowercase letter and contain + * only lowercase letters, numbers, and underscores. + * @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 defines experiment metric metadata and computation details on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getMetric(String experimentMetricId) { + // Generated convenience method for getMetricWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getMetricWithResponse(experimentMetricId, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(ExperimentMetric.class)); + } + + /** + * Creates or updates an experiment metric. + * + * @param experimentMetricId Identifier for this experiment metric. Must start with a lowercase letter and contain + * only lowercase letters, numbers, and underscores. + * @param resource The resource instance. + * @param requestConditions Specifies HTTP options for conditional requests based on modification time. + * @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 defines experiment metric metadata and computation details on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono createOrUpdateMetric(String experimentMetricId, ExperimentMetric resource, + RequestConditions requestConditions) { + // Generated convenience method for createOrUpdateMetricWithResponse + RequestOptions requestOptions = new RequestOptions(); + String ifMatch = requestConditions == null ? null : requestConditions.getIfMatch(); + String ifNoneMatch = requestConditions == null ? null : requestConditions.getIfNoneMatch(); + OffsetDateTime ifUnmodifiedSince = requestConditions == null ? null : requestConditions.getIfUnmodifiedSince(); + OffsetDateTime ifModifiedSince = requestConditions == null ? null : requestConditions.getIfModifiedSince(); + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + JsonMergePatchHelper.getExperimentMetricAccessor().prepareModelForJsonMergePatch(resource, true); + BinaryData resourceInBinaryData = BinaryData.fromObject(resource); + // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. + resourceInBinaryData.getLength(); + JsonMergePatchHelper.getExperimentMetricAccessor().prepareModelForJsonMergePatch(resource, false); + return createOrUpdateMetricWithResponse(experimentMetricId, resourceInBinaryData, requestOptions) + .flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(ExperimentMetric.class)); + } + + /** + * Creates or updates an experiment metric. + * + * @param experimentMetricId Identifier for this experiment metric. Must start with a lowercase letter and contain + * only lowercase letters, numbers, and underscores. + * @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 defines experiment metric metadata and computation details on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono createOrUpdateMetric(String experimentMetricId, ExperimentMetric resource) { + // Generated convenience method for createOrUpdateMetricWithResponse + RequestOptions requestOptions = new RequestOptions(); + JsonMergePatchHelper.getExperimentMetricAccessor().prepareModelForJsonMergePatch(resource, true); + BinaryData resourceInBinaryData = BinaryData.fromObject(resource); + // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. + resourceInBinaryData.getLength(); + JsonMergePatchHelper.getExperimentMetricAccessor().prepareModelForJsonMergePatch(resource, false); + return createOrUpdateMetricWithResponse(experimentMetricId, resourceInBinaryData, requestOptions) + .flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(ExperimentMetric.class)); + } + + /** + * Validates an experiment metric definition. + * + * @param body Experiment metric input to validate. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the result of validating an experiment metric on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono validateMetric(ExperimentMetric body) { + // Generated convenience method for validateMetricWithResponse + RequestOptions requestOptions = new RequestOptions(); + return validateMetricWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(ExperimentMetricValidationResult.class)); + } + + /** + * Deletes an experiment metric. + * + * @param experimentMetricId Identifier for this experiment metric. Must start with a lowercase letter and contain + * only lowercase letters, numbers, and underscores. + * @param requestConditions Specifies HTTP options for conditional requests based on modification time. + * @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 deleteMetric(String experimentMetricId, RequestConditions requestConditions) { + // Generated convenience method for deleteMetricWithResponse + RequestOptions requestOptions = new RequestOptions(); + String ifMatch = requestConditions == null ? null : requestConditions.getIfMatch(); + String ifNoneMatch = requestConditions == null ? null : requestConditions.getIfNoneMatch(); + OffsetDateTime ifUnmodifiedSince = requestConditions == null ? null : requestConditions.getIfUnmodifiedSince(); + OffsetDateTime ifModifiedSince = requestConditions == null ? null : requestConditions.getIfModifiedSince(); + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + return deleteMetricWithResponse(experimentMetricId, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * Deletes an experiment metric. + * + * @param experimentMetricId Identifier for this experiment metric. Must start with a lowercase letter and contain + * only lowercase letters, numbers, and underscores. + * @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 deleteMetric(String experimentMetricId) { + // Generated convenience method for deleteMetricWithResponse + RequestOptions requestOptions = new RequestOptions(); + return deleteMetricWithResponse(experimentMetricId, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * Lists experiment metrics. + * + * @param top The number of result items to return. + * @param skip The number of result items to skip. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return paged collection of ExperimentMetric items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listMetrics(Integer top, Integer skip) { + // Generated convenience method for listMetrics + RequestOptions requestOptions = new RequestOptions(); + if (top != null) { + requestOptions.addQueryParam("top", String.valueOf(top), false); + } + if (skip != null) { + requestOptions.addQueryParam("skip", String.valueOf(skip), false); + } + PagedFlux pagedFluxResponse = listMetrics(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(ExperimentMetric.class)) + .collect(Collectors.toList()), + pagedResponse.getContinuationToken(), null)); + }); + } + + /** + * Lists experiment metrics. + * + * @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 ExperimentMetric items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listMetrics() { + // Generated convenience method for listMetrics + RequestOptions requestOptions = new RequestOptions(); + PagedFlux pagedFluxResponse = listMetrics(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(ExperimentMetric.class)) + .collect(Collectors.toList()), + pagedResponse.getContinuationToken(), null)); + }); + } +} diff --git a/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/OnlineExperimentationClient.java b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/OnlineExperimentationClient.java new file mode 100644 index 000000000000..a5acdca632e0 --- /dev/null +++ b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/OnlineExperimentationClient.java @@ -0,0 +1,571 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.analytics.onlineexperimentation; + +import com.azure.analytics.onlineexperimentation.implementation.JsonMergePatchHelper; +import com.azure.analytics.onlineexperimentation.implementation.OnlineExperimentationClientImpl; +import com.azure.analytics.onlineexperimentation.models.ExperimentMetric; +import com.azure.analytics.onlineexperimentation.models.ExperimentMetricValidationResult; +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.HttpHeaderName; +import com.azure.core.http.RequestConditions; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; +import com.azure.core.util.DateTimeRfc1123; +import java.time.OffsetDateTime; + +/** + * Initializes a new instance of the synchronous OnlineExperimentationClient type. + */ +@ServiceClient(builder = OnlineExperimentationClientBuilder.class) +public final class OnlineExperimentationClient { + @Generated + private final OnlineExperimentationClientImpl serviceClient; + + /** + * Initializes an instance of OnlineExperimentationClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + OnlineExperimentationClient(OnlineExperimentationClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Fetches an experiment metric by ID. + *

Header Parameters

+ * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     lifecycle: String(Active/Inactive) (Optional, Required on create)
+     *     displayName: String (Optional, Required on create)
+     *     description: String (Optional, Required on create)
+     *     categories (Optional, Required on create): [
+     *         String (Optional, Required on create)
+     *     ]
+     *     desiredDirection: String(Increase/Decrease/Neutral) (Optional, Required on create)
+     *     definition (Optional, Required on create): {
+     *         type: String(EventCount/UserCount/EventRate/UserRate/Sum/Average/Percentile) (Required)
+     *     }
+     *     eTag: String (Required)
+     *     lastModifiedAt: OffsetDateTime (Required)
+     * }
+     * }
+     * 
+ * + * @param experimentMetricId Identifier for this experiment metric. Must start with a lowercase letter and contain + * only lowercase letters, numbers, and underscores. + * @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 defines experiment metric metadata and computation details along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getMetricWithResponse(String experimentMetricId, RequestOptions requestOptions) { + return this.serviceClient.getMetricWithResponse(experimentMetricId, requestOptions); + } + + /** + * Creates or updates an experiment metric. + *

Header Parameters

+ * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     lifecycle: String(Active/Inactive) (Optional, Required on create)
+     *     displayName: String (Optional, Required on create)
+     *     description: String (Optional, Required on create)
+     *     categories (Optional, Required on create): [
+     *         String (Optional, Required on create)
+     *     ]
+     *     desiredDirection: String(Increase/Decrease/Neutral) (Optional, Required on create)
+     *     definition (Optional, Required on create): {
+     *         type: String(EventCount/UserCount/EventRate/UserRate/Sum/Average/Percentile) (Required)
+     *     }
+     *     eTag: String (Required)
+     *     lastModifiedAt: OffsetDateTime (Required)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     lifecycle: String(Active/Inactive) (Optional, Required on create)
+     *     displayName: String (Optional, Required on create)
+     *     description: String (Optional, Required on create)
+     *     categories (Optional, Required on create): [
+     *         String (Optional, Required on create)
+     *     ]
+     *     desiredDirection: String(Increase/Decrease/Neutral) (Optional, Required on create)
+     *     definition (Optional, Required on create): {
+     *         type: String(EventCount/UserCount/EventRate/UserRate/Sum/Average/Percentile) (Required)
+     *     }
+     *     eTag: String (Required)
+     *     lastModifiedAt: OffsetDateTime (Required)
+     * }
+     * }
+     * 
+ * + * @param experimentMetricId Identifier for this experiment metric. Must start with a lowercase letter and contain + * only lowercase letters, numbers, and underscores. + * @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 defines experiment metric metadata and computation details along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response createOrUpdateMetricWithResponse(String experimentMetricId, BinaryData resource, + RequestOptions requestOptions) { + return this.serviceClient.createOrUpdateMetricWithResponse(experimentMetricId, resource, requestOptions); + } + + /** + * Validates an experiment metric definition. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     lifecycle: String(Active/Inactive) (Optional, Required on create)
+     *     displayName: String (Optional, Required on create)
+     *     description: String (Optional, Required on create)
+     *     categories (Optional, Required on create): [
+     *         String (Optional, Required on create)
+     *     ]
+     *     desiredDirection: String(Increase/Decrease/Neutral) (Optional, Required on create)
+     *     definition (Optional, Required on create): {
+     *         type: String(EventCount/UserCount/EventRate/UserRate/Sum/Average/Percentile) (Required)
+     *     }
+     *     eTag: String (Required)
+     *     lastModifiedAt: OffsetDateTime (Required)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     isValid: boolean (Required)
+     *     diagnostics (Required): [
+     *          (Required){
+     *             message: String (Required)
+     *             code: String(FailedSchemaValidation/InvalidEventCondition/UnsupportedEventCondition/InvalidExperimentMetricDefinition) (Required)
+     *         }
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param body Experiment metric input to validate. + * @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 result of validating an experiment metric along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response validateMetricWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.validateMetricWithResponse(body, requestOptions); + } + + /** + * Deletes an experiment metric. + *

Header Parameters

+ * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param experimentMetricId Identifier for this experiment metric. Must start with a lowercase letter and contain + * only lowercase letters, numbers, and underscores. + * @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 deleteMetricWithResponse(String experimentMetricId, RequestOptions requestOptions) { + return this.serviceClient.deleteMetricWithResponse(experimentMetricId, requestOptions); + } + + /** + * Lists experiment metrics. + *

Query Parameters

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

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     lifecycle: String(Active/Inactive) (Optional, Required on create)
+     *     displayName: String (Optional, Required on create)
+     *     description: String (Optional, Required on create)
+     *     categories (Optional, Required on create): [
+     *         String (Optional, Required on create)
+     *     ]
+     *     desiredDirection: String(Increase/Decrease/Neutral) (Optional, Required on create)
+     *     definition (Optional, Required on create): {
+     *         type: String(EventCount/UserCount/EventRate/UserRate/Sum/Average/Percentile) (Required)
+     *     }
+     *     eTag: String (Required)
+     *     lastModifiedAt: OffsetDateTime (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of ExperimentMetric items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listMetrics(RequestOptions requestOptions) { + return this.serviceClient.listMetrics(requestOptions); + } + + /** + * Fetches an experiment metric by ID. + * + * @param experimentMetricId Identifier for this experiment metric. Must start with a lowercase letter and contain + * only lowercase letters, numbers, and underscores. + * @param requestConditions Specifies HTTP options for conditional requests based on modification time. + * @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 defines experiment metric metadata and computation details. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public ExperimentMetric getMetric(String experimentMetricId, RequestConditions requestConditions) { + // Generated convenience method for getMetricWithResponse + RequestOptions requestOptions = new RequestOptions(); + String ifMatch = requestConditions == null ? null : requestConditions.getIfMatch(); + String ifNoneMatch = requestConditions == null ? null : requestConditions.getIfNoneMatch(); + OffsetDateTime ifUnmodifiedSince = requestConditions == null ? null : requestConditions.getIfUnmodifiedSince(); + OffsetDateTime ifModifiedSince = requestConditions == null ? null : requestConditions.getIfModifiedSince(); + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + return getMetricWithResponse(experimentMetricId, requestOptions).getValue().toObject(ExperimentMetric.class); + } + + /** + * Fetches an experiment metric by ID. + * + * @param experimentMetricId Identifier for this experiment metric. Must start with a lowercase letter and contain + * only lowercase letters, numbers, and underscores. + * @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 defines experiment metric metadata and computation details. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public ExperimentMetric getMetric(String experimentMetricId) { + // Generated convenience method for getMetricWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getMetricWithResponse(experimentMetricId, requestOptions).getValue().toObject(ExperimentMetric.class); + } + + /** + * Creates or updates an experiment metric. + * + * @param experimentMetricId Identifier for this experiment metric. Must start with a lowercase letter and contain + * only lowercase letters, numbers, and underscores. + * @param resource The resource instance. + * @param requestConditions Specifies HTTP options for conditional requests based on modification time. + * @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 defines experiment metric metadata and computation details. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public ExperimentMetric createOrUpdateMetric(String experimentMetricId, ExperimentMetric resource, + RequestConditions requestConditions) { + // Generated convenience method for createOrUpdateMetricWithResponse + RequestOptions requestOptions = new RequestOptions(); + String ifMatch = requestConditions == null ? null : requestConditions.getIfMatch(); + String ifNoneMatch = requestConditions == null ? null : requestConditions.getIfNoneMatch(); + OffsetDateTime ifUnmodifiedSince = requestConditions == null ? null : requestConditions.getIfUnmodifiedSince(); + OffsetDateTime ifModifiedSince = requestConditions == null ? null : requestConditions.getIfModifiedSince(); + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + JsonMergePatchHelper.getExperimentMetricAccessor().prepareModelForJsonMergePatch(resource, true); + BinaryData resourceInBinaryData = BinaryData.fromObject(resource); + // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. + resourceInBinaryData.getLength(); + JsonMergePatchHelper.getExperimentMetricAccessor().prepareModelForJsonMergePatch(resource, false); + return createOrUpdateMetricWithResponse(experimentMetricId, resourceInBinaryData, requestOptions).getValue() + .toObject(ExperimentMetric.class); + } + + /** + * Creates or updates an experiment metric. + * + * @param experimentMetricId Identifier for this experiment metric. Must start with a lowercase letter and contain + * only lowercase letters, numbers, and underscores. + * @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 defines experiment metric metadata and computation details. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public ExperimentMetric createOrUpdateMetric(String experimentMetricId, ExperimentMetric resource) { + // Generated convenience method for createOrUpdateMetricWithResponse + RequestOptions requestOptions = new RequestOptions(); + JsonMergePatchHelper.getExperimentMetricAccessor().prepareModelForJsonMergePatch(resource, true); + BinaryData resourceInBinaryData = BinaryData.fromObject(resource); + // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. + resourceInBinaryData.getLength(); + JsonMergePatchHelper.getExperimentMetricAccessor().prepareModelForJsonMergePatch(resource, false); + return createOrUpdateMetricWithResponse(experimentMetricId, resourceInBinaryData, requestOptions).getValue() + .toObject(ExperimentMetric.class); + } + + /** + * Validates an experiment metric definition. + * + * @param body Experiment metric input to validate. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the result of validating an experiment metric. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public ExperimentMetricValidationResult validateMetric(ExperimentMetric body) { + // Generated convenience method for validateMetricWithResponse + RequestOptions requestOptions = new RequestOptions(); + return validateMetricWithResponse(BinaryData.fromObject(body), requestOptions).getValue() + .toObject(ExperimentMetricValidationResult.class); + } + + /** + * Deletes an experiment metric. + * + * @param experimentMetricId Identifier for this experiment metric. Must start with a lowercase letter and contain + * only lowercase letters, numbers, and underscores. + * @param requestConditions Specifies HTTP options for conditional requests based on modification time. + * @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 deleteMetric(String experimentMetricId, RequestConditions requestConditions) { + // Generated convenience method for deleteMetricWithResponse + RequestOptions requestOptions = new RequestOptions(); + String ifMatch = requestConditions == null ? null : requestConditions.getIfMatch(); + String ifNoneMatch = requestConditions == null ? null : requestConditions.getIfNoneMatch(); + OffsetDateTime ifUnmodifiedSince = requestConditions == null ? null : requestConditions.getIfUnmodifiedSince(); + OffsetDateTime ifModifiedSince = requestConditions == null ? null : requestConditions.getIfModifiedSince(); + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + deleteMetricWithResponse(experimentMetricId, requestOptions).getValue(); + } + + /** + * Deletes an experiment metric. + * + * @param experimentMetricId Identifier for this experiment metric. Must start with a lowercase letter and contain + * only lowercase letters, numbers, and underscores. + * @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 deleteMetric(String experimentMetricId) { + // Generated convenience method for deleteMetricWithResponse + RequestOptions requestOptions = new RequestOptions(); + deleteMetricWithResponse(experimentMetricId, requestOptions).getValue(); + } + + /** + * Lists experiment metrics. + * + * @param top The number of result items to return. + * @param skip The number of result items to skip. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return paged collection of ExperimentMetric items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listMetrics(Integer top, Integer skip) { + // Generated convenience method for listMetrics + RequestOptions requestOptions = new RequestOptions(); + if (top != null) { + requestOptions.addQueryParam("top", String.valueOf(top), false); + } + if (skip != null) { + requestOptions.addQueryParam("skip", String.valueOf(skip), false); + } + return serviceClient.listMetrics(requestOptions) + .mapPage(bodyItemValue -> bodyItemValue.toObject(ExperimentMetric.class)); + } + + /** + * Lists experiment metrics. + * + * @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 ExperimentMetric items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listMetrics() { + // Generated convenience method for listMetrics + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.listMetrics(requestOptions) + .mapPage(bodyItemValue -> bodyItemValue.toObject(ExperimentMetric.class)); + } +} diff --git a/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/OnlineExperimentationClientBuilder.java b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/OnlineExperimentationClientBuilder.java new file mode 100644 index 000000000000..371309618a66 --- /dev/null +++ b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/OnlineExperimentationClientBuilder.java @@ -0,0 +1,334 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.analytics.onlineexperimentation; + +import com.azure.analytics.onlineexperimentation.implementation.OnlineExperimentationClientImpl; +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 java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the OnlineExperimentationClient type. + */ +@ServiceClientBuilder(serviceClients = { OnlineExperimentationClient.class, OnlineExperimentationAsyncClient.class }) +public final class OnlineExperimentationClientBuilder + 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://exp.azure.net/.default" }; + + @Generated + private static final Map PROPERTIES + = CoreUtils.getProperties("azure-analytics-onlineexperimentation.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the OnlineExperimentationClientBuilder. + */ + @Generated + public OnlineExperimentationClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public OnlineExperimentationClientBuilder 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 OnlineExperimentationClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public OnlineExperimentationClientBuilder 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 OnlineExperimentationClientBuilder 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 OnlineExperimentationClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public OnlineExperimentationClientBuilder 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 OnlineExperimentationClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The TokenCredential used for authentication. + */ + @Generated + private TokenCredential tokenCredential; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public OnlineExperimentationClientBuilder credential(TokenCredential tokenCredential) { + this.tokenCredential = tokenCredential; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public OnlineExperimentationClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * Service version + */ + @Generated + private OnlineExperimentationServiceVersion serviceVersion; + + /** + * Sets Service version. + * + * @param serviceVersion the serviceVersion value. + * @return the OnlineExperimentationClientBuilder. + */ + @Generated + public OnlineExperimentationClientBuilder serviceVersion(OnlineExperimentationServiceVersion 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 OnlineExperimentationClientBuilder. + */ + @Generated + public OnlineExperimentationClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of OnlineExperimentationClientImpl with the provided parameters. + * + * @return an instance of OnlineExperimentationClientImpl. + */ + @Generated + private OnlineExperimentationClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + OnlineExperimentationServiceVersion localServiceVersion + = (serviceVersion != null) ? serviceVersion : OnlineExperimentationServiceVersion.getLatest(); + OnlineExperimentationClientImpl client = new OnlineExperimentationClientImpl(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 OnlineExperimentationAsyncClient class. + * + * @return an instance of OnlineExperimentationAsyncClient. + */ + @Generated + public OnlineExperimentationAsyncClient buildAsyncClient() { + return new OnlineExperimentationAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of OnlineExperimentationClient class. + * + * @return an instance of OnlineExperimentationClient. + */ + @Generated + public OnlineExperimentationClient buildClient() { + return new OnlineExperimentationClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(OnlineExperimentationClientBuilder.class); +} diff --git a/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/OnlineExperimentationServiceVersion.java b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/OnlineExperimentationServiceVersion.java new file mode 100644 index 000000000000..3f69a377e67d --- /dev/null +++ b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/OnlineExperimentationServiceVersion.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.analytics.onlineexperimentation; + +import com.azure.core.util.ServiceVersion; + +/** + * Service version of OnlineExperimentationClient. + */ +public enum OnlineExperimentationServiceVersion implements ServiceVersion { + /** + * Enum value 2025-05-31-preview. + */ + V2025_05_31_PREVIEW("2025-05-31-preview"); + + private final String version; + + OnlineExperimentationServiceVersion(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 OnlineExperimentationServiceVersion}. + */ + public static OnlineExperimentationServiceVersion getLatest() { + return V2025_05_31_PREVIEW; + } +} diff --git a/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/implementation/JsonMergePatchHelper.java b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/implementation/JsonMergePatchHelper.java new file mode 100644 index 000000000000..093d85d994cb --- /dev/null +++ b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/implementation/JsonMergePatchHelper.java @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.analytics.onlineexperimentation.implementation; + +import com.azure.analytics.onlineexperimentation.models.AggregatedValue; +import com.azure.analytics.onlineexperimentation.models.ExperimentMetric; +import com.azure.analytics.onlineexperimentation.models.ExperimentMetricDefinition; +import com.azure.analytics.onlineexperimentation.models.ObservedEvent; + +/** + * This is the Helper class to enable json merge patch serialization for a model. + */ +public class JsonMergePatchHelper { + private static ExperimentMetricAccessor experimentMetricAccessor; + + public interface ExperimentMetricAccessor { + ExperimentMetric prepareModelForJsonMergePatch(ExperimentMetric experimentMetric, + boolean jsonMergePatchEnabled); + + boolean isJsonMergePatch(ExperimentMetric experimentMetric); + } + + public static void setExperimentMetricAccessor(ExperimentMetricAccessor accessor) { + experimentMetricAccessor = accessor; + } + + public static ExperimentMetricAccessor getExperimentMetricAccessor() { + return experimentMetricAccessor; + } + + private static ExperimentMetricDefinitionAccessor experimentMetricDefinitionAccessor; + + public interface ExperimentMetricDefinitionAccessor { + ExperimentMetricDefinition prepareModelForJsonMergePatch(ExperimentMetricDefinition experimentMetricDefinition, + boolean jsonMergePatchEnabled); + + boolean isJsonMergePatch(ExperimentMetricDefinition experimentMetricDefinition); + } + + public static void setExperimentMetricDefinitionAccessor(ExperimentMetricDefinitionAccessor accessor) { + experimentMetricDefinitionAccessor = accessor; + } + + public static ExperimentMetricDefinitionAccessor getExperimentMetricDefinitionAccessor() { + return experimentMetricDefinitionAccessor; + } + + private static ObservedEventAccessor observedEventAccessor; + + public interface ObservedEventAccessor { + ObservedEvent prepareModelForJsonMergePatch(ObservedEvent observedEvent, boolean jsonMergePatchEnabled); + + boolean isJsonMergePatch(ObservedEvent observedEvent); + } + + public static void setObservedEventAccessor(ObservedEventAccessor accessor) { + observedEventAccessor = accessor; + } + + public static ObservedEventAccessor getObservedEventAccessor() { + return observedEventAccessor; + } + + private static AggregatedValueAccessor aggregatedValueAccessor; + + public interface AggregatedValueAccessor { + AggregatedValue prepareModelForJsonMergePatch(AggregatedValue aggregatedValue, boolean jsonMergePatchEnabled); + + boolean isJsonMergePatch(AggregatedValue aggregatedValue); + } + + public static void setAggregatedValueAccessor(AggregatedValueAccessor accessor) { + aggregatedValueAccessor = accessor; + } + + public static AggregatedValueAccessor getAggregatedValueAccessor() { + return aggregatedValueAccessor; + } +} diff --git a/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/implementation/OnlineExperimentationClientImpl.java b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/implementation/OnlineExperimentationClientImpl.java new file mode 100644 index 000000000000..35d8e470737c --- /dev/null +++ b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/implementation/OnlineExperimentationClientImpl.java @@ -0,0 +1,1080 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.analytics.onlineexperimentation.implementation; + +import com.azure.analytics.onlineexperimentation.OnlineExperimentationServiceVersion; +import com.azure.core.annotation.BodyParam; +import com.azure.core.annotation.Delete; +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Patch; +import com.azure.core.annotation.PathParam; +import com.azure.core.annotation.Post; +import com.azure.core.annotation.QueryParam; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.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.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.util.BinaryData; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import com.azure.core.util.UrlBuilder; +import com.azure.core.util.serializer.JacksonAdapter; +import com.azure.core.util.serializer.SerializerAdapter; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the OnlineExperimentationClient type. + */ +public final class OnlineExperimentationClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final OnlineExperimentationClientService service; + + /** + * Endpoint URL for the Online Experimentation workspace. + */ + private final String endpoint; + + /** + * Gets Endpoint URL for the Online Experimentation workspace. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * Service version. + */ + private final OnlineExperimentationServiceVersion serviceVersion; + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public OnlineExperimentationServiceVersion getServiceVersion() { + return this.serviceVersion; + } + + /** + * The HTTP pipeline to send requests through. + */ + private final HttpPipeline httpPipeline; + + /** + * Gets The HTTP pipeline to send requests through. + * + * @return the httpPipeline value. + */ + public HttpPipeline getHttpPipeline() { + return this.httpPipeline; + } + + /** + * The serializer to serialize an object into a string. + */ + private final SerializerAdapter serializerAdapter; + + /** + * Gets The serializer to serialize an object into a string. + * + * @return the serializerAdapter value. + */ + public SerializerAdapter getSerializerAdapter() { + return this.serializerAdapter; + } + + /** + * Initializes an instance of OnlineExperimentationClient client. + * + * @param endpoint Endpoint URL for the Online Experimentation workspace. + * @param serviceVersion Service version. + */ + public OnlineExperimentationClientImpl(String endpoint, OnlineExperimentationServiceVersion serviceVersion) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); + } + + /** + * Initializes an instance of OnlineExperimentationClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Endpoint URL for the Online Experimentation workspace. + * @param serviceVersion Service version. + */ + public OnlineExperimentationClientImpl(HttpPipeline httpPipeline, String endpoint, + OnlineExperimentationServiceVersion serviceVersion) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); + } + + /** + * Initializes an instance of OnlineExperimentationClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param serializerAdapter The serializer to serialize an object into a string. + * @param endpoint Endpoint URL for the Online Experimentation workspace. + * @param serviceVersion Service version. + */ + public OnlineExperimentationClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, + String endpoint, OnlineExperimentationServiceVersion serviceVersion) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.serviceVersion = serviceVersion; + this.service = RestProxy.create(OnlineExperimentationClientService.class, this.httpPipeline, + this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for OnlineExperimentationClient to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "OnlineExperimentatio") + public interface OnlineExperimentationClientService { + @Get("/experiment-metrics/{experimentMetricId}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getMetric(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("experimentMetricId") String experimentMetricId, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/experiment-metrics/{experimentMetricId}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getMetricSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("experimentMetricId") String experimentMetricId, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Patch("/experiment-metrics/{experimentMetricId}") + @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> createOrUpdateMetric(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("experimentMetricId") String experimentMetricId, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/merge-patch+json") BinaryData resource, RequestOptions requestOptions, + Context context); + + @Patch("/experiment-metrics/{experimentMetricId}") + @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 createOrUpdateMetricSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("experimentMetricId") String experimentMetricId, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/merge-patch+json") BinaryData resource, RequestOptions requestOptions, + Context context); + + @Post("/experiment-metrics:validate") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> validateMetric(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/experiment-metrics:validate") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response validateMetricSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Delete("/experiment-metrics/{experimentMetricId}") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> deleteMetric(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("experimentMetricId") String experimentMetricId, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Delete("/experiment-metrics/{experimentMetricId}") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response deleteMetricSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("experimentMetricId") String experimentMetricId, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/experiment-metrics") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> listMetrics(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/experiment-metrics") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response listMetricsSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> listMetricsNext(@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 listMetricsNextSync(@PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + } + + /** + * Fetches an experiment metric by ID. + *

Header Parameters

+ * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     lifecycle: String(Active/Inactive) (Optional, Required on create)
+     *     displayName: String (Optional, Required on create)
+     *     description: String (Optional, Required on create)
+     *     categories (Optional, Required on create): [
+     *         String (Optional, Required on create)
+     *     ]
+     *     desiredDirection: String(Increase/Decrease/Neutral) (Optional, Required on create)
+     *     definition (Optional, Required on create): {
+     *         type: String(EventCount/UserCount/EventRate/UserRate/Sum/Average/Percentile) (Required)
+     *     }
+     *     eTag: String (Required)
+     *     lastModifiedAt: OffsetDateTime (Required)
+     * }
+     * }
+     * 
+ * + * @param experimentMetricId Identifier for this experiment metric. Must start with a lowercase letter and contain + * only lowercase letters, numbers, and underscores. + * @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 defines experiment metric metadata and computation details along with {@link Response} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getMetricWithResponseAsync(String experimentMetricId, + RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.getMetric(this.getEndpoint(), + this.getServiceVersion().getVersion(), experimentMetricId, accept, requestOptions, context)); + } + + /** + * Fetches an experiment metric by ID. + *

Header Parameters

+ * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     lifecycle: String(Active/Inactive) (Optional, Required on create)
+     *     displayName: String (Optional, Required on create)
+     *     description: String (Optional, Required on create)
+     *     categories (Optional, Required on create): [
+     *         String (Optional, Required on create)
+     *     ]
+     *     desiredDirection: String(Increase/Decrease/Neutral) (Optional, Required on create)
+     *     definition (Optional, Required on create): {
+     *         type: String(EventCount/UserCount/EventRate/UserRate/Sum/Average/Percentile) (Required)
+     *     }
+     *     eTag: String (Required)
+     *     lastModifiedAt: OffsetDateTime (Required)
+     * }
+     * }
+     * 
+ * + * @param experimentMetricId Identifier for this experiment metric. Must start with a lowercase letter and contain + * only lowercase letters, numbers, and underscores. + * @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 defines experiment metric metadata and computation details along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getMetricWithResponse(String experimentMetricId, RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getMetricSync(this.getEndpoint(), this.getServiceVersion().getVersion(), experimentMetricId, + accept, requestOptions, Context.NONE); + } + + /** + * Creates or updates an experiment metric. + *

Header Parameters

+ * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     lifecycle: String(Active/Inactive) (Optional, Required on create)
+     *     displayName: String (Optional, Required on create)
+     *     description: String (Optional, Required on create)
+     *     categories (Optional, Required on create): [
+     *         String (Optional, Required on create)
+     *     ]
+     *     desiredDirection: String(Increase/Decrease/Neutral) (Optional, Required on create)
+     *     definition (Optional, Required on create): {
+     *         type: String(EventCount/UserCount/EventRate/UserRate/Sum/Average/Percentile) (Required)
+     *     }
+     *     eTag: String (Required)
+     *     lastModifiedAt: OffsetDateTime (Required)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     lifecycle: String(Active/Inactive) (Optional, Required on create)
+     *     displayName: String (Optional, Required on create)
+     *     description: String (Optional, Required on create)
+     *     categories (Optional, Required on create): [
+     *         String (Optional, Required on create)
+     *     ]
+     *     desiredDirection: String(Increase/Decrease/Neutral) (Optional, Required on create)
+     *     definition (Optional, Required on create): {
+     *         type: String(EventCount/UserCount/EventRate/UserRate/Sum/Average/Percentile) (Required)
+     *     }
+     *     eTag: String (Required)
+     *     lastModifiedAt: OffsetDateTime (Required)
+     * }
+     * }
+     * 
+ * + * @param experimentMetricId Identifier for this experiment metric. Must start with a lowercase letter and contain + * only lowercase letters, numbers, and underscores. + * @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 defines experiment metric metadata and computation details along with {@link Response} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> createOrUpdateMetricWithResponseAsync(String experimentMetricId, + BinaryData resource, RequestOptions requestOptions) { + final String contentType = "application/merge-patch+json"; + final String accept = "application/json"; + return FluxUtil.withContext( + context -> service.createOrUpdateMetric(this.getEndpoint(), this.getServiceVersion().getVersion(), + experimentMetricId, contentType, accept, resource, requestOptions, context)); + } + + /** + * Creates or updates an experiment metric. + *

Header Parameters

+ * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     lifecycle: String(Active/Inactive) (Optional, Required on create)
+     *     displayName: String (Optional, Required on create)
+     *     description: String (Optional, Required on create)
+     *     categories (Optional, Required on create): [
+     *         String (Optional, Required on create)
+     *     ]
+     *     desiredDirection: String(Increase/Decrease/Neutral) (Optional, Required on create)
+     *     definition (Optional, Required on create): {
+     *         type: String(EventCount/UserCount/EventRate/UserRate/Sum/Average/Percentile) (Required)
+     *     }
+     *     eTag: String (Required)
+     *     lastModifiedAt: OffsetDateTime (Required)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     lifecycle: String(Active/Inactive) (Optional, Required on create)
+     *     displayName: String (Optional, Required on create)
+     *     description: String (Optional, Required on create)
+     *     categories (Optional, Required on create): [
+     *         String (Optional, Required on create)
+     *     ]
+     *     desiredDirection: String(Increase/Decrease/Neutral) (Optional, Required on create)
+     *     definition (Optional, Required on create): {
+     *         type: String(EventCount/UserCount/EventRate/UserRate/Sum/Average/Percentile) (Required)
+     *     }
+     *     eTag: String (Required)
+     *     lastModifiedAt: OffsetDateTime (Required)
+     * }
+     * }
+     * 
+ * + * @param experimentMetricId Identifier for this experiment metric. Must start with a lowercase letter and contain + * only lowercase letters, numbers, and underscores. + * @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 defines experiment metric metadata and computation details along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response createOrUpdateMetricWithResponse(String experimentMetricId, BinaryData resource, + RequestOptions requestOptions) { + final String contentType = "application/merge-patch+json"; + final String accept = "application/json"; + return service.createOrUpdateMetricSync(this.getEndpoint(), this.getServiceVersion().getVersion(), + experimentMetricId, contentType, accept, resource, requestOptions, Context.NONE); + } + + /** + * Validates an experiment metric definition. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     lifecycle: String(Active/Inactive) (Optional, Required on create)
+     *     displayName: String (Optional, Required on create)
+     *     description: String (Optional, Required on create)
+     *     categories (Optional, Required on create): [
+     *         String (Optional, Required on create)
+     *     ]
+     *     desiredDirection: String(Increase/Decrease/Neutral) (Optional, Required on create)
+     *     definition (Optional, Required on create): {
+     *         type: String(EventCount/UserCount/EventRate/UserRate/Sum/Average/Percentile) (Required)
+     *     }
+     *     eTag: String (Required)
+     *     lastModifiedAt: OffsetDateTime (Required)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     isValid: boolean (Required)
+     *     diagnostics (Required): [
+     *          (Required){
+     *             message: String (Required)
+     *             code: String(FailedSchemaValidation/InvalidEventCondition/UnsupportedEventCondition/InvalidExperimentMetricDefinition) (Required)
+     *         }
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param body Experiment metric input to validate. + * @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 result of validating an experiment metric along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> validateMetricWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.validateMetric(this.getEndpoint(), + this.getServiceVersion().getVersion(), contentType, accept, body, requestOptions, context)); + } + + /** + * Validates an experiment metric definition. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     lifecycle: String(Active/Inactive) (Optional, Required on create)
+     *     displayName: String (Optional, Required on create)
+     *     description: String (Optional, Required on create)
+     *     categories (Optional, Required on create): [
+     *         String (Optional, Required on create)
+     *     ]
+     *     desiredDirection: String(Increase/Decrease/Neutral) (Optional, Required on create)
+     *     definition (Optional, Required on create): {
+     *         type: String(EventCount/UserCount/EventRate/UserRate/Sum/Average/Percentile) (Required)
+     *     }
+     *     eTag: String (Required)
+     *     lastModifiedAt: OffsetDateTime (Required)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     isValid: boolean (Required)
+     *     diagnostics (Required): [
+     *          (Required){
+     *             message: String (Required)
+     *             code: String(FailedSchemaValidation/InvalidEventCondition/UnsupportedEventCondition/InvalidExperimentMetricDefinition) (Required)
+     *         }
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param body Experiment metric input to validate. + * @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 result of validating an experiment metric along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response validateMetricWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.validateMetricSync(this.getEndpoint(), this.getServiceVersion().getVersion(), contentType, + accept, body, requestOptions, Context.NONE); + } + + /** + * Deletes an experiment metric. + *

Header Parameters

+ * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param experimentMetricId Identifier for this experiment metric. Must start with a lowercase letter and contain + * only lowercase letters, numbers, and underscores. + * @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> deleteMetricWithResponseAsync(String experimentMetricId, + RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.deleteMetric(this.getEndpoint(), + this.getServiceVersion().getVersion(), experimentMetricId, accept, requestOptions, context)); + } + + /** + * Deletes an experiment metric. + *

Header Parameters

+ * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param experimentMetricId Identifier for this experiment metric. Must start with a lowercase letter and contain + * only lowercase letters, numbers, and underscores. + * @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 deleteMetricWithResponse(String experimentMetricId, RequestOptions requestOptions) { + final String accept = "application/json"; + return service.deleteMetricSync(this.getEndpoint(), this.getServiceVersion().getVersion(), experimentMetricId, + accept, requestOptions, Context.NONE); + } + + /** + * Lists experiment metrics. + *

Query Parameters

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

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     lifecycle: String(Active/Inactive) (Optional, Required on create)
+     *     displayName: String (Optional, Required on create)
+     *     description: String (Optional, Required on create)
+     *     categories (Optional, Required on create): [
+     *         String (Optional, Required on create)
+     *     ]
+     *     desiredDirection: String(Increase/Decrease/Neutral) (Optional, Required on create)
+     *     definition (Optional, Required on create): {
+     *         type: String(EventCount/UserCount/EventRate/UserRate/Sum/Average/Percentile) (Required)
+     *     }
+     *     eTag: String (Required)
+     *     lastModifiedAt: OffsetDateTime (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of ExperimentMetric items along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listMetricsSinglePageAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.listMetrics(this.getEndpoint(), this.getServiceVersion().getVersion(), + accept, requestOptions, context)) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null)); + } + + /** + * Lists experiment metrics. + *

Query Parameters

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

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     lifecycle: String(Active/Inactive) (Optional, Required on create)
+     *     displayName: String (Optional, Required on create)
+     *     description: String (Optional, Required on create)
+     *     categories (Optional, Required on create): [
+     *         String (Optional, Required on create)
+     *     ]
+     *     desiredDirection: String(Increase/Decrease/Neutral) (Optional, Required on create)
+     *     definition (Optional, Required on create): {
+     *         type: String(EventCount/UserCount/EventRate/UserRate/Sum/Average/Percentile) (Required)
+     *     }
+     *     eTag: String (Required)
+     *     lastModifiedAt: OffsetDateTime (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of ExperimentMetric items as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listMetricsAsync(RequestOptions requestOptions) { + RequestOptions requestOptionsForNextPage = new RequestOptions(); + requestOptionsForNextPage.setContext( + requestOptions != null && requestOptions.getContext() != null ? requestOptions.getContext() : Context.NONE); + return new PagedFlux<>((pageSize) -> { + RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions; + if (pageSize != null) { + requestOptionsLocal.addRequestCallback(requestLocal -> { + UrlBuilder urlBuilder = UrlBuilder.parse(requestLocal.getUrl()); + urlBuilder.setQueryParameter("maxpagesize", String.valueOf(pageSize)); + requestLocal.setUrl(urlBuilder.toString()); + }); + } + return listMetricsSinglePageAsync(requestOptionsLocal); + }, (nextLink, pageSize) -> { + RequestOptions requestOptionsLocal = new RequestOptions(); + requestOptionsLocal.setContext(requestOptionsForNextPage.getContext()); + if (pageSize != null) { + requestOptionsLocal.addRequestCallback(requestLocal -> { + UrlBuilder urlBuilder = UrlBuilder.parse(requestLocal.getUrl()); + urlBuilder.setQueryParameter("maxpagesize", String.valueOf(pageSize)); + requestLocal.setUrl(urlBuilder.toString()); + }); + } + return listMetricsNextSinglePageAsync(nextLink, requestOptionsLocal); + }); + } + + /** + * Lists experiment metrics. + *

Query Parameters

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

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     lifecycle: String(Active/Inactive) (Optional, Required on create)
+     *     displayName: String (Optional, Required on create)
+     *     description: String (Optional, Required on create)
+     *     categories (Optional, Required on create): [
+     *         String (Optional, Required on create)
+     *     ]
+     *     desiredDirection: String(Increase/Decrease/Neutral) (Optional, Required on create)
+     *     definition (Optional, Required on create): {
+     *         type: String(EventCount/UserCount/EventRate/UserRate/Sum/Average/Percentile) (Required)
+     *     }
+     *     eTag: String (Required)
+     *     lastModifiedAt: OffsetDateTime (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of ExperimentMetric items along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listMetricsSinglePage(RequestOptions requestOptions) { + final String accept = "application/json"; + Response res = service.listMetricsSync(this.getEndpoint(), this.getServiceVersion().getVersion(), + accept, requestOptions, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null); + } + + /** + * Lists experiment metrics. + *

Query Parameters

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

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     lifecycle: String(Active/Inactive) (Optional, Required on create)
+     *     displayName: String (Optional, Required on create)
+     *     description: String (Optional, Required on create)
+     *     categories (Optional, Required on create): [
+     *         String (Optional, Required on create)
+     *     ]
+     *     desiredDirection: String(Increase/Decrease/Neutral) (Optional, Required on create)
+     *     definition (Optional, Required on create): {
+     *         type: String(EventCount/UserCount/EventRate/UserRate/Sum/Average/Percentile) (Required)
+     *     }
+     *     eTag: String (Required)
+     *     lastModifiedAt: OffsetDateTime (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of ExperimentMetric items as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listMetrics(RequestOptions requestOptions) { + RequestOptions requestOptionsForNextPage = new RequestOptions(); + requestOptionsForNextPage.setContext( + requestOptions != null && requestOptions.getContext() != null ? requestOptions.getContext() : Context.NONE); + return new PagedIterable<>((pageSize) -> { + RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions; + if (pageSize != null) { + requestOptionsLocal.addRequestCallback(requestLocal -> { + UrlBuilder urlBuilder = UrlBuilder.parse(requestLocal.getUrl()); + urlBuilder.setQueryParameter("maxpagesize", String.valueOf(pageSize)); + requestLocal.setUrl(urlBuilder.toString()); + }); + } + return listMetricsSinglePage(requestOptionsLocal); + }, (nextLink, pageSize) -> { + RequestOptions requestOptionsLocal = new RequestOptions(); + requestOptionsLocal.setContext(requestOptionsForNextPage.getContext()); + if (pageSize != null) { + requestOptionsLocal.addRequestCallback(requestLocal -> { + UrlBuilder urlBuilder = UrlBuilder.parse(requestLocal.getUrl()); + urlBuilder.setQueryParameter("maxpagesize", String.valueOf(pageSize)); + requestLocal.setUrl(urlBuilder.toString()); + }); + } + return listMetricsNextSinglePage(nextLink, requestOptionsLocal); + }); + } + + /** + * Get the next page of items. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     lifecycle: String(Active/Inactive) (Optional, Required on create)
+     *     displayName: String (Optional, Required on create)
+     *     description: String (Optional, Required on create)
+     *     categories (Optional, Required on create): [
+     *         String (Optional, Required on create)
+     *     ]
+     *     desiredDirection: String(Increase/Decrease/Neutral) (Optional, Required on create)
+     *     definition (Optional, Required on create): {
+     *         type: String(EventCount/UserCount/EventRate/UserRate/Sum/Average/Percentile) (Required)
+     *     }
+     *     eTag: String (Required)
+     *     lastModifiedAt: OffsetDateTime (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 ExperimentMetric items along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listMetricsNextSinglePageAsync(String nextLink, + RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> service.listMetricsNext(nextLink, this.getEndpoint(), accept, requestOptions, context)) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null)); + } + + /** + * Get the next page of items. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     lifecycle: String(Active/Inactive) (Optional, Required on create)
+     *     displayName: String (Optional, Required on create)
+     *     description: String (Optional, Required on create)
+     *     categories (Optional, Required on create): [
+     *         String (Optional, Required on create)
+     *     ]
+     *     desiredDirection: String(Increase/Decrease/Neutral) (Optional, Required on create)
+     *     definition (Optional, Required on create): {
+     *         type: String(EventCount/UserCount/EventRate/UserRate/Sum/Average/Percentile) (Required)
+     *     }
+     *     eTag: String (Required)
+     *     lastModifiedAt: OffsetDateTime (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 ExperimentMetric items along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listMetricsNextSinglePage(String nextLink, RequestOptions requestOptions) { + final String accept = "application/json"; + Response res + = service.listMetricsNextSync(nextLink, this.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/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/implementation/package-info.java b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/implementation/package-info.java new file mode 100644 index 000000000000..9912fe2f3dcd --- /dev/null +++ b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/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 OnlineExperimentation. + * + */ +package com.azure.analytics.onlineexperimentation.implementation; diff --git a/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/models/AggregatedValue.java b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/models/AggregatedValue.java new file mode 100644 index 000000000000..dd04969cf98b --- /dev/null +++ b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/models/AggregatedValue.java @@ -0,0 +1,222 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.analytics.onlineexperimentation.models; + +import com.azure.analytics.onlineexperimentation.implementation.JsonMergePatchHelper; +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.HashSet; +import java.util.Set; + +/** + * An event property value aggregated by a metric. + */ +@Fluent +public final class AggregatedValue implements JsonSerializable { + /* + * The name of the event. + */ + @Generated + private String eventName; + + /* + * [Optional] A condition to filter events. + */ + @Generated + private String filter; + + /* + * The key of the event property to aggregate. + */ + @Generated + private String eventProperty; + + /** + * Stores updated model property, the value is property name, not serialized name. + */ + @Generated + private final Set updatedProperties = new HashSet<>(); + + @Generated + private boolean jsonMergePatch; + + @Generated + private void serializeAsJsonMergePatch(boolean jsonMergePatch) { + this.jsonMergePatch = jsonMergePatch; + } + + static { + JsonMergePatchHelper.setAggregatedValueAccessor(new JsonMergePatchHelper.AggregatedValueAccessor() { + @Override + public AggregatedValue prepareModelForJsonMergePatch(AggregatedValue model, boolean jsonMergePatchEnabled) { + model.serializeAsJsonMergePatch(jsonMergePatchEnabled); + return model; + } + + @Override + public boolean isJsonMergePatch(AggregatedValue model) { + return model.jsonMergePatch; + } + }); + } + + /** + * Creates an instance of AggregatedValue class. + */ + @Generated + public AggregatedValue() { + } + + /** + * Get the eventName property: The name of the event. + * + * @return the eventName value. + */ + @Generated + public String getEventName() { + return this.eventName; + } + + /** + * Set the eventName property: The name of the event. + *

Required when create the resource.

+ * + * @param eventName the eventName value to set. + * @return the AggregatedValue object itself. + */ + @Generated + public AggregatedValue setEventName(String eventName) { + this.eventName = eventName; + this.updatedProperties.add("eventName"); + return this; + } + + /** + * Get the filter property: [Optional] A condition to filter events. + * + * @return the filter value. + */ + @Generated + public String getFilter() { + return this.filter; + } + + /** + * Set the filter property: [Optional] A condition to filter events. + * + * @param filter the filter value to set. + * @return the AggregatedValue object itself. + */ + @Generated + public AggregatedValue setFilter(String filter) { + this.filter = filter; + this.updatedProperties.add("filter"); + return this; + } + + /** + * Get the eventProperty property: The key of the event property to aggregate. + * + * @return the eventProperty value. + */ + @Generated + public String getEventProperty() { + return this.eventProperty; + } + + /** + * Set the eventProperty property: The key of the event property to aggregate. + *

Required when create the resource.

+ * + * @param eventProperty the eventProperty value to set. + * @return the AggregatedValue object itself. + */ + @Generated + public AggregatedValue setEventProperty(String eventProperty) { + this.eventProperty = eventProperty; + this.updatedProperties.add("eventProperty"); + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + if (jsonMergePatch) { + return toJsonMergePatch(jsonWriter); + } else { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("eventName", this.eventName); + jsonWriter.writeStringField("filter", this.filter); + jsonWriter.writeStringField("eventProperty", this.eventProperty); + return jsonWriter.writeEndObject(); + } + } + + @Generated + private JsonWriter toJsonMergePatch(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + if (updatedProperties.contains("eventName")) { + if (this.eventName == null) { + jsonWriter.writeNullField("eventName"); + } else { + jsonWriter.writeStringField("eventName", this.eventName); + } + } + if (updatedProperties.contains("filter")) { + if (this.filter == null) { + jsonWriter.writeNullField("filter"); + } else { + jsonWriter.writeStringField("filter", this.filter); + } + } + if (updatedProperties.contains("eventProperty")) { + if (this.eventProperty == null) { + jsonWriter.writeNullField("eventProperty"); + } else { + jsonWriter.writeStringField("eventProperty", this.eventProperty); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of AggregatedValue from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of AggregatedValue if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the AggregatedValue. + */ + @Generated + public static AggregatedValue fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + AggregatedValue deserializedAggregatedValue = new AggregatedValue(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("eventName".equals(fieldName)) { + deserializedAggregatedValue.eventName = reader.getString(); + } else if ("filter".equals(fieldName)) { + deserializedAggregatedValue.filter = reader.getString(); + } else if ("eventProperty".equals(fieldName)) { + deserializedAggregatedValue.eventProperty = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedAggregatedValue; + }); + } +} diff --git a/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/models/AverageMetricDefinition.java b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/models/AverageMetricDefinition.java new file mode 100644 index 000000000000..1867ccd99451 --- /dev/null +++ b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/models/AverageMetricDefinition.java @@ -0,0 +1,142 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.analytics.onlineexperimentation.models; + +import com.azure.analytics.onlineexperimentation.implementation.JsonMergePatchHelper; +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.HashSet; +import java.util.Set; + +/** + * The definition of an Average metric definition. Calculates the average value of a specified event property. + */ +@Fluent +public final class AverageMetricDefinition extends ExperimentMetricDefinition { + /* + * Discriminator property for ExperimentMetricDefinition. + */ + @Generated + private ExperimentMetricType type = ExperimentMetricType.AVERAGE; + + /* + * The value to aggregate. + */ + @Generated + private AggregatedValue value; + + /** + * Stores updated model property, the value is property name, not serialized name. + */ + @Generated + private final Set updatedProperties = new HashSet<>(); + + /** + * Creates an instance of AverageMetricDefinition class. + */ + @Generated + public AverageMetricDefinition() { + } + + /** + * Get the type property: Discriminator property for ExperimentMetricDefinition. + * + * @return the type value. + */ + @Generated + @Override + public ExperimentMetricType getType() { + return this.type; + } + + /** + * Get the value property: The value to aggregate. + * + * @return the value value. + */ + @Generated + public AggregatedValue getValue() { + return this.value; + } + + /** + * Set the value property: The value to aggregate. + *

Required when create the resource.

+ * + * @param value the value value to set. + * @return the AverageMetricDefinition object itself. + */ + @Generated + public AverageMetricDefinition setValue(AggregatedValue value) { + this.value = value; + this.updatedProperties.add("value"); + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + if (JsonMergePatchHelper.getExperimentMetricDefinitionAccessor().isJsonMergePatch(this)) { + return toJsonMergePatch(jsonWriter); + } else { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("type", this.type == null ? null : this.type.toString()); + jsonWriter.writeJsonField("value", this.value); + return jsonWriter.writeEndObject(); + } + } + + @Generated + private JsonWriter toJsonMergePatch(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("type", this.type.toString()); + if (updatedProperties.contains("value")) { + if (this.value == null) { + jsonWriter.writeNullField("value"); + } else { + JsonMergePatchHelper.getAggregatedValueAccessor().prepareModelForJsonMergePatch(this.value, true); + jsonWriter.writeJsonField("value", this.value); + JsonMergePatchHelper.getAggregatedValueAccessor().prepareModelForJsonMergePatch(this.value, false); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of AverageMetricDefinition from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of AverageMetricDefinition if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IOException If an error occurs while reading the AverageMetricDefinition. + */ + @Generated + public static AverageMetricDefinition fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + AverageMetricDefinition deserializedAverageMetricDefinition = new AverageMetricDefinition(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("type".equals(fieldName)) { + deserializedAverageMetricDefinition.type = ExperimentMetricType.fromString(reader.getString()); + } else if ("value".equals(fieldName)) { + deserializedAverageMetricDefinition.value = AggregatedValue.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedAverageMetricDefinition; + }); + } +} diff --git a/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/models/DesiredDirection.java b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/models/DesiredDirection.java new file mode 100644 index 000000000000..30f1a8c875f7 --- /dev/null +++ b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/models/DesiredDirection.java @@ -0,0 +1,64 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.analytics.onlineexperimentation.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Desired direction for an experiment metric value. + */ +public final class DesiredDirection extends ExpandableStringEnum { + /** + * An increase to the metric value is desired. E.g., Success rate, Total revenue. + */ + @Generated + public static final DesiredDirection INCREASE = fromString("Increase"); + + /** + * A decrease to the metric value is desired. E.g., Error rate, Latency. + */ + @Generated + public static final DesiredDirection DECREASE = fromString("Decrease"); + + /** + * Neither an increase nor a decrease to the metric value is desired, or the desired direction depends on other + * factors. E.g., Number of video play attempts, Number of user feedbacks. + */ + @Generated + public static final DesiredDirection NEUTRAL = fromString("Neutral"); + + /** + * Creates a new instance of DesiredDirection value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public DesiredDirection() { + } + + /** + * Creates or finds a DesiredDirection from its string representation. + * + * @param name a name to look for. + * @return the corresponding DesiredDirection. + */ + @Generated + public static DesiredDirection fromString(String name) { + return fromString(name, DesiredDirection.class); + } + + /** + * Gets known DesiredDirection values. + * + * @return known DesiredDirection values. + */ + @Generated + public static Collection values() { + return values(DesiredDirection.class); + } +} diff --git a/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/models/DiagnosticCode.java b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/models/DiagnosticCode.java new file mode 100644 index 000000000000..845c14e6df9e --- /dev/null +++ b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/models/DiagnosticCode.java @@ -0,0 +1,72 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.analytics.onlineexperimentation.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * The diagnostic error codes. + */ +public final class DiagnosticCode extends ExpandableStringEnum { + /** + * The metric definition does not conform to the required schema. + */ + @Generated + public static final DiagnosticCode FAILED_SCHEMA_VALIDATION = fromString("FailedSchemaValidation"); + + /** + * The filter condition is invalid. + */ + @Generated + public static final DiagnosticCode INVALID_EVENT_CONDITION = fromString("InvalidEventCondition"); + + /** + * The filter condition is valid but not currently supported. + */ + @Generated + public static final DiagnosticCode UNSUPPORTED_EVENT_CONDITION = fromString("UnsupportedEventCondition"); + + /** + * The provided metric definition is invalid. + * For example, defining a metric to calculate the average of a numeric property but + * including a filter condition that compares it to a string value creates a type mismatch. + */ + @Generated + public static final DiagnosticCode INVALID_EXPERIMENT_METRIC_DEFINITION + = fromString("InvalidExperimentMetricDefinition"); + + /** + * Creates a new instance of DiagnosticCode value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public DiagnosticCode() { + } + + /** + * Creates or finds a DiagnosticCode from its string representation. + * + * @param name a name to look for. + * @return the corresponding DiagnosticCode. + */ + @Generated + public static DiagnosticCode fromString(String name) { + return fromString(name, DiagnosticCode.class); + } + + /** + * Gets known DiagnosticCode values. + * + * @return known DiagnosticCode values. + */ + @Generated + public static Collection values() { + return values(DiagnosticCode.class); + } +} diff --git a/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/models/DiagnosticDetail.java b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/models/DiagnosticDetail.java new file mode 100644 index 000000000000..a2db49206b8d --- /dev/null +++ b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/models/DiagnosticDetail.java @@ -0,0 +1,98 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.analytics.onlineexperimentation.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Diagnostic details for validation errors. + */ +@Immutable +public final class DiagnosticDetail implements JsonSerializable { + /* + * A human-readable error message. + */ + @Generated + private String message; + + /* + * The diagnostic error code. + */ + @Generated + private DiagnosticCode code; + + /** + * Creates an instance of DiagnosticDetail class. + */ + @Generated + private DiagnosticDetail() { + } + + /** + * Get the message property: A human-readable error message. + * + * @return the message value. + */ + @Generated + public String getMessage() { + return this.message; + } + + /** + * Get the code property: The diagnostic error code. + * + * @return the code value. + */ + @Generated + public DiagnosticCode getCode() { + return this.code; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of DiagnosticDetail from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of DiagnosticDetail 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 DiagnosticDetail. + */ + @Generated + public static DiagnosticDetail fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + DiagnosticDetail deserializedDiagnosticDetail = new DiagnosticDetail(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("message".equals(fieldName)) { + deserializedDiagnosticDetail.message = reader.getString(); + } else if ("code".equals(fieldName)) { + deserializedDiagnosticDetail.code = DiagnosticCode.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + + return deserializedDiagnosticDetail; + }); + } +} diff --git a/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/models/EventCountMetricDefinition.java b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/models/EventCountMetricDefinition.java new file mode 100644 index 000000000000..6894a1b20526 --- /dev/null +++ b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/models/EventCountMetricDefinition.java @@ -0,0 +1,142 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.analytics.onlineexperimentation.models; + +import com.azure.analytics.onlineexperimentation.implementation.JsonMergePatchHelper; +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.HashSet; +import java.util.Set; + +/** + * The definition of an EventCount metric definition. Counts the occurrences of a specified event. + */ +@Fluent +public final class EventCountMetricDefinition extends ExperimentMetricDefinition { + /* + * Discriminator property for ExperimentMetricDefinition. + */ + @Generated + private ExperimentMetricType type = ExperimentMetricType.EVENT_COUNT; + + /* + * Event to observe. + */ + @Generated + private ObservedEvent event; + + /** + * Stores updated model property, the value is property name, not serialized name. + */ + @Generated + private final Set updatedProperties = new HashSet<>(); + + /** + * Creates an instance of EventCountMetricDefinition class. + */ + @Generated + public EventCountMetricDefinition() { + } + + /** + * Get the type property: Discriminator property for ExperimentMetricDefinition. + * + * @return the type value. + */ + @Generated + @Override + public ExperimentMetricType getType() { + return this.type; + } + + /** + * Get the event property: Event to observe. + * + * @return the event value. + */ + @Generated + public ObservedEvent getEvent() { + return this.event; + } + + /** + * Set the event property: Event to observe. + *

Required when create the resource.

+ * + * @param event the event value to set. + * @return the EventCountMetricDefinition object itself. + */ + @Generated + public EventCountMetricDefinition setEvent(ObservedEvent event) { + this.event = event; + this.updatedProperties.add("event"); + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + if (JsonMergePatchHelper.getExperimentMetricDefinitionAccessor().isJsonMergePatch(this)) { + return toJsonMergePatch(jsonWriter); + } else { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("type", this.type == null ? null : this.type.toString()); + jsonWriter.writeJsonField("event", this.event); + return jsonWriter.writeEndObject(); + } + } + + @Generated + private JsonWriter toJsonMergePatch(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("type", this.type.toString()); + if (updatedProperties.contains("event")) { + if (this.event == null) { + jsonWriter.writeNullField("event"); + } else { + JsonMergePatchHelper.getObservedEventAccessor().prepareModelForJsonMergePatch(this.event, true); + jsonWriter.writeJsonField("event", this.event); + JsonMergePatchHelper.getObservedEventAccessor().prepareModelForJsonMergePatch(this.event, false); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of EventCountMetricDefinition from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of EventCountMetricDefinition if the JsonReader was pointing to an instance of it, or null if + * it was pointing to JSON null. + * @throws IOException If an error occurs while reading the EventCountMetricDefinition. + */ + @Generated + public static EventCountMetricDefinition fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + EventCountMetricDefinition deserializedEventCountMetricDefinition = new EventCountMetricDefinition(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("type".equals(fieldName)) { + deserializedEventCountMetricDefinition.type = ExperimentMetricType.fromString(reader.getString()); + } else if ("event".equals(fieldName)) { + deserializedEventCountMetricDefinition.event = ObservedEvent.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedEventCountMetricDefinition; + }); + } +} diff --git a/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/models/EventRateMetricDefinition.java b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/models/EventRateMetricDefinition.java new file mode 100644 index 000000000000..dae643bc1795 --- /dev/null +++ b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/models/EventRateMetricDefinition.java @@ -0,0 +1,183 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.analytics.onlineexperimentation.models; + +import com.azure.analytics.onlineexperimentation.implementation.JsonMergePatchHelper; +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.HashSet; +import java.util.Set; + +/** + * The definition of an EventRate metric definition. Calculates the percentage of events satisfying a specified + * condition. + */ +@Fluent +public final class EventRateMetricDefinition extends ExperimentMetricDefinition { + /* + * Discriminator property for ExperimentMetricDefinition. + */ + @Generated + private ExperimentMetricType type = ExperimentMetricType.EVENT_RATE; + + /* + * Event to observe as the rate denominator. + */ + @Generated + private ObservedEvent event; + + /* + * The event contributes to the rate numerator if it satisfies this condition. + */ + @Generated + private String rateCondition; + + /** + * Stores updated model property, the value is property name, not serialized name. + */ + @Generated + private final Set updatedProperties = new HashSet<>(); + + /** + * Creates an instance of EventRateMetricDefinition class. + */ + @Generated + public EventRateMetricDefinition() { + } + + /** + * Get the type property: Discriminator property for ExperimentMetricDefinition. + * + * @return the type value. + */ + @Generated + @Override + public ExperimentMetricType getType() { + return this.type; + } + + /** + * Get the event property: Event to observe as the rate denominator. + * + * @return the event value. + */ + @Generated + public ObservedEvent getEvent() { + return this.event; + } + + /** + * Set the event property: Event to observe as the rate denominator. + *

Required when create the resource.

+ * + * @param event the event value to set. + * @return the EventRateMetricDefinition object itself. + */ + @Generated + public EventRateMetricDefinition setEvent(ObservedEvent event) { + this.event = event; + this.updatedProperties.add("event"); + return this; + } + + /** + * Get the rateCondition property: The event contributes to the rate numerator if it satisfies this condition. + * + * @return the rateCondition value. + */ + @Generated + public String getRateCondition() { + return this.rateCondition; + } + + /** + * Set the rateCondition property: The event contributes to the rate numerator if it satisfies this condition. + *

Required when create the resource.

+ * + * @param rateCondition the rateCondition value to set. + * @return the EventRateMetricDefinition object itself. + */ + @Generated + public EventRateMetricDefinition setRateCondition(String rateCondition) { + this.rateCondition = rateCondition; + this.updatedProperties.add("rateCondition"); + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + if (JsonMergePatchHelper.getExperimentMetricDefinitionAccessor().isJsonMergePatch(this)) { + return toJsonMergePatch(jsonWriter); + } else { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("type", this.type == null ? null : this.type.toString()); + jsonWriter.writeJsonField("event", this.event); + jsonWriter.writeStringField("rateCondition", this.rateCondition); + return jsonWriter.writeEndObject(); + } + } + + @Generated + private JsonWriter toJsonMergePatch(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("type", this.type.toString()); + if (updatedProperties.contains("event")) { + if (this.event == null) { + jsonWriter.writeNullField("event"); + } else { + JsonMergePatchHelper.getObservedEventAccessor().prepareModelForJsonMergePatch(this.event, true); + jsonWriter.writeJsonField("event", this.event); + JsonMergePatchHelper.getObservedEventAccessor().prepareModelForJsonMergePatch(this.event, false); + } + } + if (updatedProperties.contains("rateCondition")) { + if (this.rateCondition == null) { + jsonWriter.writeNullField("rateCondition"); + } else { + jsonWriter.writeStringField("rateCondition", this.rateCondition); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of EventRateMetricDefinition from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of EventRateMetricDefinition if the JsonReader was pointing to an instance of it, or null if + * it was pointing to JSON null. + * @throws IOException If an error occurs while reading the EventRateMetricDefinition. + */ + @Generated + public static EventRateMetricDefinition fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + EventRateMetricDefinition deserializedEventRateMetricDefinition = new EventRateMetricDefinition(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("type".equals(fieldName)) { + deserializedEventRateMetricDefinition.type = ExperimentMetricType.fromString(reader.getString()); + } else if ("event".equals(fieldName)) { + deserializedEventRateMetricDefinition.event = ObservedEvent.fromJson(reader); + } else if ("rateCondition".equals(fieldName)) { + deserializedEventRateMetricDefinition.rateCondition = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedEventRateMetricDefinition; + }); + } +} diff --git a/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/models/ExperimentMetric.java b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/models/ExperimentMetric.java new file mode 100644 index 000000000000..cd2921f058cc --- /dev/null +++ b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/models/ExperimentMetric.java @@ -0,0 +1,416 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.analytics.onlineexperimentation.models; + +import com.azure.analytics.onlineexperimentation.implementation.JsonMergePatchHelper; +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.core.util.CoreUtils; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.time.OffsetDateTime; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +/** + * Defines experiment metric metadata and computation details. + */ +@Fluent +public final class ExperimentMetric implements JsonSerializable { + /* + * Identifier for this experiment metric. Must start with a lowercase letter and contain only lowercase letters, + * numbers, and underscores. + */ + @Generated + private String id; + + /* + * Determines whether it is included in experiment analysis. + */ + @Generated + private LifecycleStage lifecycle; + + /* + * A user-friendly display name for the experiment metric shown in reports and dashboards. + */ + @Generated + private String displayName; + + /* + * A detailed description of the experiment metric. + */ + @Generated + private String description; + + /* + * Categories associated with the experiment metric. Used for organizing and filtering metrics. + */ + @Generated + private List categories; + + /* + * The desired direction for changes in the metric value. + */ + @Generated + private DesiredDirection desiredDirection; + + /* + * The metric definition specifying how the metric value is calculated from event data. + */ + @Generated + private ExperimentMetricDefinition definition; + + /* + * ETag of the experiment metric. + */ + @Generated + private String eTag; + + /* + * The timestamp (UTC) of the last modification to the experiment metric resource. + */ + @Generated + private OffsetDateTime lastModifiedAt; + + /** + * Stores updated model property, the value is property name, not serialized name. + */ + @Generated + private final Set updatedProperties = new HashSet<>(); + + @Generated + private boolean jsonMergePatch; + + @Generated + private void serializeAsJsonMergePatch(boolean jsonMergePatch) { + this.jsonMergePatch = jsonMergePatch; + } + + static { + JsonMergePatchHelper.setExperimentMetricAccessor(new JsonMergePatchHelper.ExperimentMetricAccessor() { + @Override + public ExperimentMetric prepareModelForJsonMergePatch(ExperimentMetric model, + boolean jsonMergePatchEnabled) { + model.serializeAsJsonMergePatch(jsonMergePatchEnabled); + return model; + } + + @Override + public boolean isJsonMergePatch(ExperimentMetric model) { + return model.jsonMergePatch; + } + }); + } + + /** + * Creates an instance of ExperimentMetric class. + */ + @Generated + public ExperimentMetric() { + } + + /** + * Get the id property: Identifier for this experiment metric. Must start with a lowercase letter and contain only + * lowercase letters, numbers, and underscores. + * + * @return the id value. + */ + @Generated + public String getId() { + return this.id; + } + + /** + * Get the lifecycle property: Determines whether it is included in experiment analysis. + * + * @return the lifecycle value. + */ + @Generated + public LifecycleStage getLifecycle() { + return this.lifecycle; + } + + /** + * Set the lifecycle property: Determines whether it is included in experiment analysis. + *

Required when create the resource.

+ * + * @param lifecycle the lifecycle value to set. + * @return the ExperimentMetric object itself. + */ + @Generated + public ExperimentMetric setLifecycle(LifecycleStage lifecycle) { + this.lifecycle = lifecycle; + this.updatedProperties.add("lifecycle"); + return this; + } + + /** + * Get the displayName property: A user-friendly display name for the experiment metric shown in reports and + * dashboards. + * + * @return the displayName value. + */ + @Generated + public String getDisplayName() { + return this.displayName; + } + + /** + * Set the displayName property: A user-friendly display name for the experiment metric shown in reports and + * dashboards. + *

Required when create the resource.

+ * + * @param displayName the displayName value to set. + * @return the ExperimentMetric object itself. + */ + @Generated + public ExperimentMetric setDisplayName(String displayName) { + this.displayName = displayName; + this.updatedProperties.add("displayName"); + return this; + } + + /** + * Get the description property: A detailed description of the experiment metric. + * + * @return the description value. + */ + @Generated + public String getDescription() { + return this.description; + } + + /** + * Set the description property: A detailed description of the experiment metric. + *

Required when create the resource.

+ * + * @param description the description value to set. + * @return the ExperimentMetric object itself. + */ + @Generated + public ExperimentMetric setDescription(String description) { + this.description = description; + this.updatedProperties.add("description"); + return this; + } + + /** + * Get the categories property: Categories associated with the experiment metric. Used for organizing and filtering + * metrics. + * + * @return the categories value. + */ + @Generated + public List getCategories() { + return this.categories; + } + + /** + * Set the categories property: Categories associated with the experiment metric. Used for organizing and filtering + * metrics. + *

Required when create the resource.

+ * + * @param categories the categories value to set. + * @return the ExperimentMetric object itself. + */ + @Generated + public ExperimentMetric setCategories(List categories) { + this.categories = categories; + this.updatedProperties.add("categories"); + return this; + } + + /** + * Get the desiredDirection property: The desired direction for changes in the metric value. + * + * @return the desiredDirection value. + */ + @Generated + public DesiredDirection getDesiredDirection() { + return this.desiredDirection; + } + + /** + * Set the desiredDirection property: The desired direction for changes in the metric value. + *

Required when create the resource.

+ * + * @param desiredDirection the desiredDirection value to set. + * @return the ExperimentMetric object itself. + */ + @Generated + public ExperimentMetric setDesiredDirection(DesiredDirection desiredDirection) { + this.desiredDirection = desiredDirection; + this.updatedProperties.add("desiredDirection"); + return this; + } + + /** + * Get the definition property: The metric definition specifying how the metric value is calculated from event data. + * + * @return the definition value. + */ + @Generated + public ExperimentMetricDefinition getDefinition() { + return this.definition; + } + + /** + * Set the definition property: The metric definition specifying how the metric value is calculated from event data. + *

Required when create the resource.

+ * + * @param definition the definition value to set. + * @return the ExperimentMetric object itself. + */ + @Generated + public ExperimentMetric setDefinition(ExperimentMetricDefinition definition) { + this.definition = definition; + this.updatedProperties.add("definition"); + return this; + } + + /** + * Get the eTag property: ETag of the experiment metric. + * + * @return the eTag value. + */ + @Generated + public String getETag() { + return this.eTag; + } + + /** + * Get the lastModifiedAt property: The timestamp (UTC) of the last modification to the experiment metric resource. + * + * @return the lastModifiedAt value. + */ + @Generated + public OffsetDateTime getLastModifiedAt() { + return this.lastModifiedAt; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + if (jsonMergePatch) { + return toJsonMergePatch(jsonWriter); + } else { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("lifecycle", this.lifecycle == null ? null : this.lifecycle.toString()); + jsonWriter.writeStringField("displayName", this.displayName); + jsonWriter.writeStringField("description", this.description); + jsonWriter.writeArrayField("categories", this.categories, (writer, element) -> writer.writeString(element)); + jsonWriter.writeStringField("desiredDirection", + this.desiredDirection == null ? null : this.desiredDirection.toString()); + jsonWriter.writeJsonField("definition", this.definition); + return jsonWriter.writeEndObject(); + } + } + + @Generated + private JsonWriter toJsonMergePatch(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + if (updatedProperties.contains("lifecycle")) { + if (this.lifecycle == null) { + jsonWriter.writeNullField("lifecycle"); + } else { + jsonWriter.writeStringField("lifecycle", this.lifecycle.toString()); + } + } + if (updatedProperties.contains("displayName")) { + if (this.displayName == null) { + jsonWriter.writeNullField("displayName"); + } else { + jsonWriter.writeStringField("displayName", this.displayName); + } + } + if (updatedProperties.contains("description")) { + if (this.description == null) { + jsonWriter.writeNullField("description"); + } else { + jsonWriter.writeStringField("description", this.description); + } + } + if (updatedProperties.contains("categories")) { + if (this.categories == null) { + jsonWriter.writeNullField("categories"); + } else { + jsonWriter.writeArrayField("categories", this.categories, + (writer, element) -> writer.writeString(element)); + } + } + if (updatedProperties.contains("desiredDirection")) { + if (this.desiredDirection == null) { + jsonWriter.writeNullField("desiredDirection"); + } else { + jsonWriter.writeStringField("desiredDirection", this.desiredDirection.toString()); + } + } + if (updatedProperties.contains("definition")) { + if (this.definition == null) { + jsonWriter.writeNullField("definition"); + } else { + JsonMergePatchHelper.getExperimentMetricDefinitionAccessor() + .prepareModelForJsonMergePatch(this.definition, true); + jsonWriter.writeJsonField("definition", this.definition); + JsonMergePatchHelper.getExperimentMetricDefinitionAccessor() + .prepareModelForJsonMergePatch(this.definition, false); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ExperimentMetric from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ExperimentMetric 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 ExperimentMetric. + */ + @Generated + public static ExperimentMetric fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ExperimentMetric deserializedExperimentMetric = new ExperimentMetric(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + deserializedExperimentMetric.id = reader.getString(); + } else if ("eTag".equals(fieldName)) { + deserializedExperimentMetric.eTag = reader.getString(); + } else if ("lastModifiedAt".equals(fieldName)) { + deserializedExperimentMetric.lastModifiedAt = reader + .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString())); + } else if ("lifecycle".equals(fieldName)) { + deserializedExperimentMetric.lifecycle = LifecycleStage.fromString(reader.getString()); + } else if ("displayName".equals(fieldName)) { + deserializedExperimentMetric.displayName = reader.getString(); + } else if ("description".equals(fieldName)) { + deserializedExperimentMetric.description = reader.getString(); + } else if ("categories".equals(fieldName)) { + List categories = reader.readArray(reader1 -> reader1.getString()); + deserializedExperimentMetric.categories = categories; + } else if ("desiredDirection".equals(fieldName)) { + deserializedExperimentMetric.desiredDirection = DesiredDirection.fromString(reader.getString()); + } else if ("definition".equals(fieldName)) { + deserializedExperimentMetric.definition = ExperimentMetricDefinition.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedExperimentMetric; + }); + } +} diff --git a/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/models/ExperimentMetricDefinition.java b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/models/ExperimentMetricDefinition.java new file mode 100644 index 000000000000..60da2befea50 --- /dev/null +++ b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/models/ExperimentMetricDefinition.java @@ -0,0 +1,163 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.analytics.onlineexperimentation.models; + +import com.azure.analytics.onlineexperimentation.implementation.JsonMergePatchHelper; +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.HashSet; +import java.util.Set; + +/** + * The metric definition, which determines how the metric value is calculated from event data. + */ +@Immutable +public class ExperimentMetricDefinition implements JsonSerializable { + /* + * Discriminator property for ExperimentMetricDefinition. + */ + @Generated + private ExperimentMetricType type = ExperimentMetricType.fromString("ExperimentMetricDefinition"); + + /** + * Stores updated model property, the value is property name, not serialized name. + */ + @Generated + private final Set updatedProperties = new HashSet<>(); + + @Generated + private boolean jsonMergePatch; + + @Generated + private void serializeAsJsonMergePatch(boolean jsonMergePatch) { + this.jsonMergePatch = jsonMergePatch; + } + + static { + JsonMergePatchHelper + .setExperimentMetricDefinitionAccessor(new JsonMergePatchHelper.ExperimentMetricDefinitionAccessor() { + @Override + public ExperimentMetricDefinition prepareModelForJsonMergePatch(ExperimentMetricDefinition model, + boolean jsonMergePatchEnabled) { + model.serializeAsJsonMergePatch(jsonMergePatchEnabled); + return model; + } + + @Override + public boolean isJsonMergePatch(ExperimentMetricDefinition model) { + return model.jsonMergePatch; + } + }); + } + + /** + * Creates an instance of ExperimentMetricDefinition class. + */ + @Generated + public ExperimentMetricDefinition() { + } + + /** + * Get the type property: Discriminator property for ExperimentMetricDefinition. + * + * @return the type value. + */ + @Generated + public ExperimentMetricType getType() { + return this.type; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + if (jsonMergePatch) { + return toJsonMergePatch(jsonWriter); + } else { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("type", this.type == null ? null : this.type.toString()); + return jsonWriter.writeEndObject(); + } + } + + @Generated + private JsonWriter toJsonMergePatch(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("type", this.type.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ExperimentMetricDefinition from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ExperimentMetricDefinition if the JsonReader was pointing to an instance of it, or null if + * it was pointing to JSON null. + * @throws IOException If an error occurs while reading the ExperimentMetricDefinition. + */ + @Generated + public static ExperimentMetricDefinition fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String discriminatorValue = null; + try (JsonReader readerToUse = reader.bufferObject()) { + readerToUse.nextToken(); // Prepare for reading + while (readerToUse.nextToken() != JsonToken.END_OBJECT) { + String fieldName = readerToUse.getFieldName(); + readerToUse.nextToken(); + if ("type".equals(fieldName)) { + discriminatorValue = readerToUse.getString(); + break; + } else { + readerToUse.skipChildren(); + } + } + // Use the discriminator value to determine which subtype should be deserialized. + if ("EventCount".equals(discriminatorValue)) { + return EventCountMetricDefinition.fromJson(readerToUse.reset()); + } else if ("UserCount".equals(discriminatorValue)) { + return UserCountMetricDefinition.fromJson(readerToUse.reset()); + } else if ("EventRate".equals(discriminatorValue)) { + return EventRateMetricDefinition.fromJson(readerToUse.reset()); + } else if ("UserRate".equals(discriminatorValue)) { + return UserRateMetricDefinition.fromJson(readerToUse.reset()); + } else if ("Sum".equals(discriminatorValue)) { + return SumMetricDefinition.fromJson(readerToUse.reset()); + } else if ("Average".equals(discriminatorValue)) { + return AverageMetricDefinition.fromJson(readerToUse.reset()); + } else if ("Percentile".equals(discriminatorValue)) { + return PercentileMetricDefinition.fromJson(readerToUse.reset()); + } else { + return fromJsonKnownDiscriminator(readerToUse.reset()); + } + } + }); + } + + @Generated + static ExperimentMetricDefinition fromJsonKnownDiscriminator(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ExperimentMetricDefinition deserializedExperimentMetricDefinition = new ExperimentMetricDefinition(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("type".equals(fieldName)) { + deserializedExperimentMetricDefinition.type = ExperimentMetricType.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + + return deserializedExperimentMetricDefinition; + }); + } +} diff --git a/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/models/ExperimentMetricType.java b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/models/ExperimentMetricType.java new file mode 100644 index 000000000000..4eaa40a49bac --- /dev/null +++ b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/models/ExperimentMetricType.java @@ -0,0 +1,89 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.analytics.onlineexperimentation.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * How the metric definition calculates metric values from event data. + */ +public final class ExperimentMetricType extends ExpandableStringEnum { + /** + * Counts the occurrences of an event. Experiment analysis accounts for unequal traffic allocation. + */ + @Generated + public static final ExperimentMetricType EVENT_COUNT = fromString("EventCount"); + + /** + * Counts the number of unique users who encounter an event. Experiment analysis accounts for unequal traffic + * allocation. + */ + @Generated + public static final ExperimentMetricType USER_COUNT = fromString("UserCount"); + + /** + * Calculates the percentage of events that satisfy a specified condition. + */ + @Generated + public static final ExperimentMetricType EVENT_RATE = fromString("EventRate"); + + /** + * Calculates the percentage of users who encounter a start event and subsequently encounter an end event. Users + * must encounter the start event before the end event to be counted. + */ + @Generated + public static final ExperimentMetricType USER_RATE = fromString("UserRate"); + + /** + * Calculates the sum of a specified event property. Experiment analysis accounts for unequal traffic allocation. + */ + @Generated + public static final ExperimentMetricType SUM = fromString("Sum"); + + /** + * Calculates the average value of a specified event property. + */ + @Generated + public static final ExperimentMetricType AVERAGE = fromString("Average"); + + /** + * Calculates a specified percentile of an event property. + */ + @Generated + public static final ExperimentMetricType PERCENTILE = fromString("Percentile"); + + /** + * Creates a new instance of ExperimentMetricType value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public ExperimentMetricType() { + } + + /** + * Creates or finds a ExperimentMetricType from its string representation. + * + * @param name a name to look for. + * @return the corresponding ExperimentMetricType. + */ + @Generated + public static ExperimentMetricType fromString(String name) { + return fromString(name, ExperimentMetricType.class); + } + + /** + * Gets known ExperimentMetricType values. + * + * @return known ExperimentMetricType values. + */ + @Generated + public static Collection values() { + return values(ExperimentMetricType.class); + } +} diff --git a/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/models/ExperimentMetricValidationResult.java b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/models/ExperimentMetricValidationResult.java new file mode 100644 index 000000000000..b880d1d5c527 --- /dev/null +++ b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/models/ExperimentMetricValidationResult.java @@ -0,0 +1,107 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.analytics.onlineexperimentation.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * The result of validating an experiment metric. + */ +@Immutable +public final class ExperimentMetricValidationResult implements JsonSerializable { + /* + * Indicates whether the experiment metric is valid. + */ + @Generated + private final boolean isValid; + + /* + * Diagnostic details from the validation process. + */ + @Generated + private List diagnostics; + + /** + * Creates an instance of ExperimentMetricValidationResult class. + * + * @param isValid the isValid value to set. + */ + @Generated + private ExperimentMetricValidationResult(boolean isValid) { + this.isValid = isValid; + } + + /** + * Get the isValid property: Indicates whether the experiment metric is valid. + * + * @return the isValid value. + */ + @Generated + public boolean isValid() { + return this.isValid; + } + + /** + * Get the diagnostics property: Diagnostic details from the validation process. + * + * @return the diagnostics value. + */ + @Generated + public List getDiagnostics() { + return this.diagnostics; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeBooleanField("isValid", this.isValid); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ExperimentMetricValidationResult from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ExperimentMetricValidationResult 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 ExperimentMetricValidationResult. + */ + @Generated + public static ExperimentMetricValidationResult fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + boolean isValid = false; + List diagnostics = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("isValid".equals(fieldName)) { + isValid = reader.getBoolean(); + } else if ("diagnostics".equals(fieldName)) { + diagnostics = reader.readArray(reader1 -> DiagnosticDetail.fromJson(reader1)); + } else { + reader.skipChildren(); + } + } + ExperimentMetricValidationResult deserializedExperimentMetricValidationResult + = new ExperimentMetricValidationResult(isValid); + deserializedExperimentMetricValidationResult.diagnostics = diagnostics; + + return deserializedExperimentMetricValidationResult; + }); + } +} diff --git a/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/models/LifecycleStage.java b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/models/LifecycleStage.java new file mode 100644 index 000000000000..c381e27ab06a --- /dev/null +++ b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/models/LifecycleStage.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.analytics.onlineexperimentation.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Lifecycle stages of an experiment metric, determining whether the metric is included in experiment analysis. + */ +public final class LifecycleStage extends ExpandableStringEnum { + /** + * The metric is included in experiment analysis. + */ + @Generated + public static final LifecycleStage ACTIVE = fromString("Active"); + + /** + * The metric is excluded from experiment analysis but remains available for future use. + */ + @Generated + public static final LifecycleStage INACTIVE = fromString("Inactive"); + + /** + * Creates a new instance of LifecycleStage value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public LifecycleStage() { + } + + /** + * Creates or finds a LifecycleStage from its string representation. + * + * @param name a name to look for. + * @return the corresponding LifecycleStage. + */ + @Generated + public static LifecycleStage fromString(String name) { + return fromString(name, LifecycleStage.class); + } + + /** + * Gets known LifecycleStage values. + * + * @return known LifecycleStage values. + */ + @Generated + public static Collection values() { + return values(LifecycleStage.class); + } +} diff --git a/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/models/ObservedEvent.java b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/models/ObservedEvent.java new file mode 100644 index 000000000000..b6fcfaf74181 --- /dev/null +++ b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/models/ObservedEvent.java @@ -0,0 +1,182 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.analytics.onlineexperimentation.models; + +import com.azure.analytics.onlineexperimentation.implementation.JsonMergePatchHelper; +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.HashSet; +import java.util.Set; + +/** + * An event observed by a metric. + */ +@Fluent +public final class ObservedEvent implements JsonSerializable { + /* + * The name of the event. + */ + @Generated + private String eventName; + + /* + * [Optional] A condition to filter events. + */ + @Generated + private String filter; + + /** + * Stores updated model property, the value is property name, not serialized name. + */ + @Generated + private final Set updatedProperties = new HashSet<>(); + + @Generated + private boolean jsonMergePatch; + + @Generated + private void serializeAsJsonMergePatch(boolean jsonMergePatch) { + this.jsonMergePatch = jsonMergePatch; + } + + static { + JsonMergePatchHelper.setObservedEventAccessor(new JsonMergePatchHelper.ObservedEventAccessor() { + @Override + public ObservedEvent prepareModelForJsonMergePatch(ObservedEvent model, boolean jsonMergePatchEnabled) { + model.serializeAsJsonMergePatch(jsonMergePatchEnabled); + return model; + } + + @Override + public boolean isJsonMergePatch(ObservedEvent model) { + return model.jsonMergePatch; + } + }); + } + + /** + * Creates an instance of ObservedEvent class. + */ + @Generated + public ObservedEvent() { + } + + /** + * Get the eventName property: The name of the event. + * + * @return the eventName value. + */ + @Generated + public String getEventName() { + return this.eventName; + } + + /** + * Set the eventName property: The name of the event. + *

Required when create the resource.

+ * + * @param eventName the eventName value to set. + * @return the ObservedEvent object itself. + */ + @Generated + public ObservedEvent setEventName(String eventName) { + this.eventName = eventName; + this.updatedProperties.add("eventName"); + return this; + } + + /** + * Get the filter property: [Optional] A condition to filter events. + * + * @return the filter value. + */ + @Generated + public String getFilter() { + return this.filter; + } + + /** + * Set the filter property: [Optional] A condition to filter events. + * + * @param filter the filter value to set. + * @return the ObservedEvent object itself. + */ + @Generated + public ObservedEvent setFilter(String filter) { + this.filter = filter; + this.updatedProperties.add("filter"); + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + if (jsonMergePatch) { + return toJsonMergePatch(jsonWriter); + } else { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("eventName", this.eventName); + jsonWriter.writeStringField("filter", this.filter); + return jsonWriter.writeEndObject(); + } + } + + @Generated + private JsonWriter toJsonMergePatch(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + if (updatedProperties.contains("eventName")) { + if (this.eventName == null) { + jsonWriter.writeNullField("eventName"); + } else { + jsonWriter.writeStringField("eventName", this.eventName); + } + } + if (updatedProperties.contains("filter")) { + if (this.filter == null) { + jsonWriter.writeNullField("filter"); + } else { + jsonWriter.writeStringField("filter", this.filter); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ObservedEvent from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ObservedEvent if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the ObservedEvent. + */ + @Generated + public static ObservedEvent fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ObservedEvent deserializedObservedEvent = new ObservedEvent(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("eventName".equals(fieldName)) { + deserializedObservedEvent.eventName = reader.getString(); + } else if ("filter".equals(fieldName)) { + deserializedObservedEvent.filter = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedObservedEvent; + }); + } +} diff --git a/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/models/PercentileMetricDefinition.java b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/models/PercentileMetricDefinition.java new file mode 100644 index 000000000000..2b547cd6a032 --- /dev/null +++ b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/models/PercentileMetricDefinition.java @@ -0,0 +1,178 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.analytics.onlineexperimentation.models; + +import com.azure.analytics.onlineexperimentation.implementation.JsonMergePatchHelper; +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.HashSet; +import java.util.Set; + +/** + * The definition of a Percentile metric definition. Calculates a specified percentile of an event property. + */ +@Fluent +public final class PercentileMetricDefinition extends ExperimentMetricDefinition { + /* + * Discriminator property for ExperimentMetricDefinition. + */ + @Generated + private ExperimentMetricType type = ExperimentMetricType.PERCENTILE; + + /* + * The value to aggregate, including the event name and property to measure. + */ + @Generated + private AggregatedValue value; + + /* + * The percentile to measure. + */ + @Generated + private double percentile; + + /** + * Stores updated model property, the value is property name, not serialized name. + */ + @Generated + private final Set updatedProperties = new HashSet<>(); + + /** + * Creates an instance of PercentileMetricDefinition class. + */ + @Generated + public PercentileMetricDefinition() { + } + + /** + * Get the type property: Discriminator property for ExperimentMetricDefinition. + * + * @return the type value. + */ + @Generated + @Override + public ExperimentMetricType getType() { + return this.type; + } + + /** + * Get the value property: The value to aggregate, including the event name and property to measure. + * + * @return the value value. + */ + @Generated + public AggregatedValue getValue() { + return this.value; + } + + /** + * Set the value property: The value to aggregate, including the event name and property to measure. + *

Required when create the resource.

+ * + * @param value the value value to set. + * @return the PercentileMetricDefinition object itself. + */ + @Generated + public PercentileMetricDefinition setValue(AggregatedValue value) { + this.value = value; + this.updatedProperties.add("value"); + return this; + } + + /** + * Get the percentile property: The percentile to measure. + * + * @return the percentile value. + */ + @Generated + public double getPercentile() { + return this.percentile; + } + + /** + * Set the percentile property: The percentile to measure. + *

Required when create the resource.

+ * + * @param percentile the percentile value to set. + * @return the PercentileMetricDefinition object itself. + */ + @Generated + public PercentileMetricDefinition setPercentile(double percentile) { + this.percentile = percentile; + this.updatedProperties.add("percentile"); + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + if (JsonMergePatchHelper.getExperimentMetricDefinitionAccessor().isJsonMergePatch(this)) { + return toJsonMergePatch(jsonWriter); + } else { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("type", this.type == null ? null : this.type.toString()); + jsonWriter.writeJsonField("value", this.value); + jsonWriter.writeDoubleField("percentile", this.percentile); + return jsonWriter.writeEndObject(); + } + } + + @Generated + private JsonWriter toJsonMergePatch(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("type", this.type.toString()); + if (updatedProperties.contains("value")) { + if (this.value == null) { + jsonWriter.writeNullField("value"); + } else { + JsonMergePatchHelper.getAggregatedValueAccessor().prepareModelForJsonMergePatch(this.value, true); + jsonWriter.writeJsonField("value", this.value); + JsonMergePatchHelper.getAggregatedValueAccessor().prepareModelForJsonMergePatch(this.value, false); + } + } + if (updatedProperties.contains("percentile")) { + jsonWriter.writeDoubleField("percentile", this.percentile); + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of PercentileMetricDefinition from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of PercentileMetricDefinition if the JsonReader was pointing to an instance of it, or null if + * it was pointing to JSON null. + * @throws IOException If an error occurs while reading the PercentileMetricDefinition. + */ + @Generated + public static PercentileMetricDefinition fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + PercentileMetricDefinition deserializedPercentileMetricDefinition = new PercentileMetricDefinition(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("type".equals(fieldName)) { + deserializedPercentileMetricDefinition.type = ExperimentMetricType.fromString(reader.getString()); + } else if ("value".equals(fieldName)) { + deserializedPercentileMetricDefinition.value = AggregatedValue.fromJson(reader); + } else if ("percentile".equals(fieldName)) { + deserializedPercentileMetricDefinition.percentile = reader.getDouble(); + } else { + reader.skipChildren(); + } + } + + return deserializedPercentileMetricDefinition; + }); + } +} diff --git a/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/models/SumMetricDefinition.java b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/models/SumMetricDefinition.java new file mode 100644 index 000000000000..0472d9ff2ca3 --- /dev/null +++ b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/models/SumMetricDefinition.java @@ -0,0 +1,143 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.analytics.onlineexperimentation.models; + +import com.azure.analytics.onlineexperimentation.implementation.JsonMergePatchHelper; +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.HashSet; +import java.util.Set; + +/** + * The definition of a Sum metric definition. Calculates the sum of a specified event property. Experiment analysis + * accounts for unequal traffic allocation. + */ +@Fluent +public final class SumMetricDefinition extends ExperimentMetricDefinition { + /* + * Discriminator property for ExperimentMetricDefinition. + */ + @Generated + private ExperimentMetricType type = ExperimentMetricType.SUM; + + /* + * The value to aggregate. + */ + @Generated + private AggregatedValue value; + + /** + * Stores updated model property, the value is property name, not serialized name. + */ + @Generated + private final Set updatedProperties = new HashSet<>(); + + /** + * Creates an instance of SumMetricDefinition class. + */ + @Generated + public SumMetricDefinition() { + } + + /** + * Get the type property: Discriminator property for ExperimentMetricDefinition. + * + * @return the type value. + */ + @Generated + @Override + public ExperimentMetricType getType() { + return this.type; + } + + /** + * Get the value property: The value to aggregate. + * + * @return the value value. + */ + @Generated + public AggregatedValue getValue() { + return this.value; + } + + /** + * Set the value property: The value to aggregate. + *

Required when create the resource.

+ * + * @param value the value value to set. + * @return the SumMetricDefinition object itself. + */ + @Generated + public SumMetricDefinition setValue(AggregatedValue value) { + this.value = value; + this.updatedProperties.add("value"); + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + if (JsonMergePatchHelper.getExperimentMetricDefinitionAccessor().isJsonMergePatch(this)) { + return toJsonMergePatch(jsonWriter); + } else { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("type", this.type == null ? null : this.type.toString()); + jsonWriter.writeJsonField("value", this.value); + return jsonWriter.writeEndObject(); + } + } + + @Generated + private JsonWriter toJsonMergePatch(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("type", this.type.toString()); + if (updatedProperties.contains("value")) { + if (this.value == null) { + jsonWriter.writeNullField("value"); + } else { + JsonMergePatchHelper.getAggregatedValueAccessor().prepareModelForJsonMergePatch(this.value, true); + jsonWriter.writeJsonField("value", this.value); + JsonMergePatchHelper.getAggregatedValueAccessor().prepareModelForJsonMergePatch(this.value, false); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SumMetricDefinition from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SumMetricDefinition if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the SumMetricDefinition. + */ + @Generated + public static SumMetricDefinition fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + SumMetricDefinition deserializedSumMetricDefinition = new SumMetricDefinition(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("type".equals(fieldName)) { + deserializedSumMetricDefinition.type = ExperimentMetricType.fromString(reader.getString()); + } else if ("value".equals(fieldName)) { + deserializedSumMetricDefinition.value = AggregatedValue.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedSumMetricDefinition; + }); + } +} diff --git a/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/models/UserCountMetricDefinition.java b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/models/UserCountMetricDefinition.java new file mode 100644 index 000000000000..ace81cacf1f7 --- /dev/null +++ b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/models/UserCountMetricDefinition.java @@ -0,0 +1,142 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.analytics.onlineexperimentation.models; + +import com.azure.analytics.onlineexperimentation.implementation.JsonMergePatchHelper; +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.HashSet; +import java.util.Set; + +/** + * The definition of a UserCount metric definition. Counts unique users who encounter a specified event. + */ +@Fluent +public final class UserCountMetricDefinition extends ExperimentMetricDefinition { + /* + * Discriminator property for ExperimentMetricDefinition. + */ + @Generated + private ExperimentMetricType type = ExperimentMetricType.USER_COUNT; + + /* + * Event to observe. + */ + @Generated + private ObservedEvent event; + + /** + * Stores updated model property, the value is property name, not serialized name. + */ + @Generated + private final Set updatedProperties = new HashSet<>(); + + /** + * Creates an instance of UserCountMetricDefinition class. + */ + @Generated + public UserCountMetricDefinition() { + } + + /** + * Get the type property: Discriminator property for ExperimentMetricDefinition. + * + * @return the type value. + */ + @Generated + @Override + public ExperimentMetricType getType() { + return this.type; + } + + /** + * Get the event property: Event to observe. + * + * @return the event value. + */ + @Generated + public ObservedEvent getEvent() { + return this.event; + } + + /** + * Set the event property: Event to observe. + *

Required when create the resource.

+ * + * @param event the event value to set. + * @return the UserCountMetricDefinition object itself. + */ + @Generated + public UserCountMetricDefinition setEvent(ObservedEvent event) { + this.event = event; + this.updatedProperties.add("event"); + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + if (JsonMergePatchHelper.getExperimentMetricDefinitionAccessor().isJsonMergePatch(this)) { + return toJsonMergePatch(jsonWriter); + } else { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("type", this.type == null ? null : this.type.toString()); + jsonWriter.writeJsonField("event", this.event); + return jsonWriter.writeEndObject(); + } + } + + @Generated + private JsonWriter toJsonMergePatch(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("type", this.type.toString()); + if (updatedProperties.contains("event")) { + if (this.event == null) { + jsonWriter.writeNullField("event"); + } else { + JsonMergePatchHelper.getObservedEventAccessor().prepareModelForJsonMergePatch(this.event, true); + jsonWriter.writeJsonField("event", this.event); + JsonMergePatchHelper.getObservedEventAccessor().prepareModelForJsonMergePatch(this.event, false); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of UserCountMetricDefinition from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of UserCountMetricDefinition if the JsonReader was pointing to an instance of it, or null if + * it was pointing to JSON null. + * @throws IOException If an error occurs while reading the UserCountMetricDefinition. + */ + @Generated + public static UserCountMetricDefinition fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + UserCountMetricDefinition deserializedUserCountMetricDefinition = new UserCountMetricDefinition(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("type".equals(fieldName)) { + deserializedUserCountMetricDefinition.type = ExperimentMetricType.fromString(reader.getString()); + } else if ("event".equals(fieldName)) { + deserializedUserCountMetricDefinition.event = ObservedEvent.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedUserCountMetricDefinition; + }); + } +} diff --git a/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/models/UserRateMetricDefinition.java b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/models/UserRateMetricDefinition.java new file mode 100644 index 000000000000..567fad76c3c0 --- /dev/null +++ b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/models/UserRateMetricDefinition.java @@ -0,0 +1,185 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.analytics.onlineexperimentation.models; + +import com.azure.analytics.onlineexperimentation.implementation.JsonMergePatchHelper; +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.HashSet; +import java.util.Set; + +/** + * The definition of a UserRate metric definition. Calculates the percentage of users who encounter a start event and + * subsequently an end event. Users must encounter events in the specified order. + */ +@Fluent +public final class UserRateMetricDefinition extends ExperimentMetricDefinition { + /* + * Discriminator property for ExperimentMetricDefinition. + */ + @Generated + private ExperimentMetricType type = ExperimentMetricType.USER_RATE; + + /* + * The start event to observe as the rate denominator. + */ + @Generated + private ObservedEvent startEvent; + + /* + * The end event to observe, which is a condition for the rate numerator. + */ + @Generated + private ObservedEvent endEvent; + + /** + * Stores updated model property, the value is property name, not serialized name. + */ + @Generated + private final Set updatedProperties = new HashSet<>(); + + /** + * Creates an instance of UserRateMetricDefinition class. + */ + @Generated + public UserRateMetricDefinition() { + } + + /** + * Get the type property: Discriminator property for ExperimentMetricDefinition. + * + * @return the type value. + */ + @Generated + @Override + public ExperimentMetricType getType() { + return this.type; + } + + /** + * Get the startEvent property: The start event to observe as the rate denominator. + * + * @return the startEvent value. + */ + @Generated + public ObservedEvent getStartEvent() { + return this.startEvent; + } + + /** + * Set the startEvent property: The start event to observe as the rate denominator. + *

Required when create the resource.

+ * + * @param startEvent the startEvent value to set. + * @return the UserRateMetricDefinition object itself. + */ + @Generated + public UserRateMetricDefinition setStartEvent(ObservedEvent startEvent) { + this.startEvent = startEvent; + this.updatedProperties.add("startEvent"); + return this; + } + + /** + * Get the endEvent property: The end event to observe, which is a condition for the rate numerator. + * + * @return the endEvent value. + */ + @Generated + public ObservedEvent getEndEvent() { + return this.endEvent; + } + + /** + * Set the endEvent property: The end event to observe, which is a condition for the rate numerator. + *

Required when create the resource.

+ * + * @param endEvent the endEvent value to set. + * @return the UserRateMetricDefinition object itself. + */ + @Generated + public UserRateMetricDefinition setEndEvent(ObservedEvent endEvent) { + this.endEvent = endEvent; + this.updatedProperties.add("endEvent"); + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + if (JsonMergePatchHelper.getExperimentMetricDefinitionAccessor().isJsonMergePatch(this)) { + return toJsonMergePatch(jsonWriter); + } else { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("type", this.type == null ? null : this.type.toString()); + jsonWriter.writeJsonField("startEvent", this.startEvent); + jsonWriter.writeJsonField("endEvent", this.endEvent); + return jsonWriter.writeEndObject(); + } + } + + @Generated + private JsonWriter toJsonMergePatch(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("type", this.type.toString()); + if (updatedProperties.contains("startEvent")) { + if (this.startEvent == null) { + jsonWriter.writeNullField("startEvent"); + } else { + JsonMergePatchHelper.getObservedEventAccessor().prepareModelForJsonMergePatch(this.startEvent, true); + jsonWriter.writeJsonField("startEvent", this.startEvent); + JsonMergePatchHelper.getObservedEventAccessor().prepareModelForJsonMergePatch(this.startEvent, false); + } + } + if (updatedProperties.contains("endEvent")) { + if (this.endEvent == null) { + jsonWriter.writeNullField("endEvent"); + } else { + JsonMergePatchHelper.getObservedEventAccessor().prepareModelForJsonMergePatch(this.endEvent, true); + jsonWriter.writeJsonField("endEvent", this.endEvent); + JsonMergePatchHelper.getObservedEventAccessor().prepareModelForJsonMergePatch(this.endEvent, false); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of UserRateMetricDefinition from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of UserRateMetricDefinition if the JsonReader was pointing to an instance of it, or null if + * it was pointing to JSON null. + * @throws IOException If an error occurs while reading the UserRateMetricDefinition. + */ + @Generated + public static UserRateMetricDefinition fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + UserRateMetricDefinition deserializedUserRateMetricDefinition = new UserRateMetricDefinition(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("type".equals(fieldName)) { + deserializedUserRateMetricDefinition.type = ExperimentMetricType.fromString(reader.getString()); + } else if ("startEvent".equals(fieldName)) { + deserializedUserRateMetricDefinition.startEvent = ObservedEvent.fromJson(reader); + } else if ("endEvent".equals(fieldName)) { + deserializedUserRateMetricDefinition.endEvent = ObservedEvent.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedUserRateMetricDefinition; + }); + } +} diff --git a/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/models/package-info.java b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/models/package-info.java new file mode 100644 index 000000000000..fcdd69e402cd --- /dev/null +++ b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/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 OnlineExperimentation. + * + */ +package com.azure.analytics.onlineexperimentation.models; diff --git a/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/package-info.java b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/package-info.java new file mode 100644 index 000000000000..f5b86226a8d2 --- /dev/null +++ b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/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 OnlineExperimentation. + * + */ +package com.azure.analytics.onlineexperimentation; diff --git a/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/module-info.java b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/module-info.java new file mode 100644 index 000000000000..fe833058bfd0 --- /dev/null +++ b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/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.analytics.onlineexperimentation { + requires transitive com.azure.core; + + exports com.azure.analytics.onlineexperimentation; + exports com.azure.analytics.onlineexperimentation.models; + + opens com.azure.analytics.onlineexperimentation.models to com.azure.core; +} diff --git a/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/resources/META-INF/azure-analytics-onlineexperimentation_apiview_properties.json b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/resources/META-INF/azure-analytics-onlineexperimentation_apiview_properties.json new file mode 100644 index 000000000000..a4550b623d70 --- /dev/null +++ b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/resources/META-INF/azure-analytics-onlineexperimentation_apiview_properties.json @@ -0,0 +1,43 @@ +{ + "flavor": "azure", + "CrossLanguageDefinitionId": { + "com.azure.analytics.onlineexperimentation.OnlineExperimentationAsyncClient": "Azure.Analytics.OnlineExperimentation", + "com.azure.analytics.onlineexperimentation.OnlineExperimentationAsyncClient.createOrUpdateMetric": "Azure.Analytics.OnlineExperimentation.createOrUpdateMetric", + "com.azure.analytics.onlineexperimentation.OnlineExperimentationAsyncClient.createOrUpdateMetricWithResponse": "Azure.Analytics.OnlineExperimentation.createOrUpdateMetric", + "com.azure.analytics.onlineexperimentation.OnlineExperimentationAsyncClient.deleteMetric": "Azure.Analytics.OnlineExperimentation.deleteMetric", + "com.azure.analytics.onlineexperimentation.OnlineExperimentationAsyncClient.deleteMetricWithResponse": "Azure.Analytics.OnlineExperimentation.deleteMetric", + "com.azure.analytics.onlineexperimentation.OnlineExperimentationAsyncClient.getMetric": "Azure.Analytics.OnlineExperimentation.getMetric", + "com.azure.analytics.onlineexperimentation.OnlineExperimentationAsyncClient.getMetricWithResponse": "Azure.Analytics.OnlineExperimentation.getMetric", + "com.azure.analytics.onlineexperimentation.OnlineExperimentationAsyncClient.listMetrics": "Azure.Analytics.OnlineExperimentation.listMetrics", + "com.azure.analytics.onlineexperimentation.OnlineExperimentationAsyncClient.validateMetric": "Azure.Analytics.OnlineExperimentation.validateMetric", + "com.azure.analytics.onlineexperimentation.OnlineExperimentationAsyncClient.validateMetricWithResponse": "Azure.Analytics.OnlineExperimentation.validateMetric", + "com.azure.analytics.onlineexperimentation.OnlineExperimentationClient": "Azure.Analytics.OnlineExperimentation", + "com.azure.analytics.onlineexperimentation.OnlineExperimentationClient.createOrUpdateMetric": "Azure.Analytics.OnlineExperimentation.createOrUpdateMetric", + "com.azure.analytics.onlineexperimentation.OnlineExperimentationClient.createOrUpdateMetricWithResponse": "Azure.Analytics.OnlineExperimentation.createOrUpdateMetric", + "com.azure.analytics.onlineexperimentation.OnlineExperimentationClient.deleteMetric": "Azure.Analytics.OnlineExperimentation.deleteMetric", + "com.azure.analytics.onlineexperimentation.OnlineExperimentationClient.deleteMetricWithResponse": "Azure.Analytics.OnlineExperimentation.deleteMetric", + "com.azure.analytics.onlineexperimentation.OnlineExperimentationClient.getMetric": "Azure.Analytics.OnlineExperimentation.getMetric", + "com.azure.analytics.onlineexperimentation.OnlineExperimentationClient.getMetricWithResponse": "Azure.Analytics.OnlineExperimentation.getMetric", + "com.azure.analytics.onlineexperimentation.OnlineExperimentationClient.listMetrics": "Azure.Analytics.OnlineExperimentation.listMetrics", + "com.azure.analytics.onlineexperimentation.OnlineExperimentationClient.validateMetric": "Azure.Analytics.OnlineExperimentation.validateMetric", + "com.azure.analytics.onlineexperimentation.OnlineExperimentationClient.validateMetricWithResponse": "Azure.Analytics.OnlineExperimentation.validateMetric", + "com.azure.analytics.onlineexperimentation.OnlineExperimentationClientBuilder": "Azure.Analytics.OnlineExperimentation", + "com.azure.analytics.onlineexperimentation.models.AggregatedValue": "Azure.Analytics.OnlineExperimentation.AggregatedValue", + "com.azure.analytics.onlineexperimentation.models.AverageMetricDefinition": "Azure.Analytics.OnlineExperimentation.AverageMetricDefinition", + "com.azure.analytics.onlineexperimentation.models.DesiredDirection": "Azure.Analytics.OnlineExperimentation.DesiredDirection", + "com.azure.analytics.onlineexperimentation.models.DiagnosticCode": "Azure.Analytics.OnlineExperimentation.DiagnosticCode", + "com.azure.analytics.onlineexperimentation.models.DiagnosticDetail": "Azure.Analytics.OnlineExperimentation.DiagnosticDetail", + "com.azure.analytics.onlineexperimentation.models.EventCountMetricDefinition": "Azure.Analytics.OnlineExperimentation.EventCountMetricDefinition", + "com.azure.analytics.onlineexperimentation.models.EventRateMetricDefinition": "Azure.Analytics.OnlineExperimentation.EventRateMetricDefinition", + "com.azure.analytics.onlineexperimentation.models.ExperimentMetric": "Azure.Analytics.OnlineExperimentation.ExperimentMetric", + "com.azure.analytics.onlineexperimentation.models.ExperimentMetricDefinition": "Azure.Analytics.OnlineExperimentation.ExperimentMetricDefinition", + "com.azure.analytics.onlineexperimentation.models.ExperimentMetricType": "Azure.Analytics.OnlineExperimentation.ExperimentMetricType", + "com.azure.analytics.onlineexperimentation.models.ExperimentMetricValidationResult": "Azure.Analytics.OnlineExperimentation.ExperimentMetricValidationResult", + "com.azure.analytics.onlineexperimentation.models.LifecycleStage": "Azure.Analytics.OnlineExperimentation.LifecycleStage", + "com.azure.analytics.onlineexperimentation.models.ObservedEvent": "Azure.Analytics.OnlineExperimentation.ObservedEvent", + "com.azure.analytics.onlineexperimentation.models.PercentileMetricDefinition": "Azure.Analytics.OnlineExperimentation.PercentileMetricDefinition", + "com.azure.analytics.onlineexperimentation.models.SumMetricDefinition": "Azure.Analytics.OnlineExperimentation.SumMetricDefinition", + "com.azure.analytics.onlineexperimentation.models.UserCountMetricDefinition": "Azure.Analytics.OnlineExperimentation.UserCountMetricDefinition", + "com.azure.analytics.onlineexperimentation.models.UserRateMetricDefinition": "Azure.Analytics.OnlineExperimentation.UserRateMetricDefinition" + } +} diff --git a/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/resources/azure-analytics-onlineexperimentation.properties b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/resources/azure-analytics-onlineexperimentation.properties new file mode 100644 index 000000000000..ca812989b4f2 --- /dev/null +++ b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/resources/azure-analytics-onlineexperimentation.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/samples/java/com/azure/analytics/onlineexperimentation/ReadmeSamples.java b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/samples/java/com/azure/analytics/onlineexperimentation/ReadmeSamples.java new file mode 100644 index 000000000000..8e737125c295 --- /dev/null +++ b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/samples/java/com/azure/analytics/onlineexperimentation/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.analytics.onlineexperimentation; + +public final class ReadmeSamples { + public void readmeSamples() { + // BEGIN: com.azure.analytics.onlineexperimentation.readme + // END: com.azure.analytics.onlineexperimentation.readme + } +} diff --git a/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/samples/java/com/azure/analytics/onlineexperimentation/generated/CreateOrUpdateMetricAverage.java b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/samples/java/com/azure/analytics/onlineexperimentation/generated/CreateOrUpdateMetricAverage.java new file mode 100644 index 000000000000..debf61feaaff --- /dev/null +++ b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/samples/java/com/azure/analytics/onlineexperimentation/generated/CreateOrUpdateMetricAverage.java @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.analytics.onlineexperimentation.generated; + +import com.azure.analytics.onlineexperimentation.OnlineExperimentationClient; +import com.azure.analytics.onlineexperimentation.OnlineExperimentationClientBuilder; +import com.azure.analytics.onlineexperimentation.models.AggregatedValue; +import com.azure.analytics.onlineexperimentation.models.AverageMetricDefinition; +import com.azure.analytics.onlineexperimentation.models.DesiredDirection; +import com.azure.analytics.onlineexperimentation.models.ExperimentMetric; +import com.azure.analytics.onlineexperimentation.models.LifecycleStage; +import com.azure.core.http.RequestConditions; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; +import java.time.OffsetDateTime; +import java.util.Arrays; + +public class CreateOrUpdateMetricAverage { + public static void main(String[] args) { + OnlineExperimentationClient onlineExperimentationClient + = new OnlineExperimentationClientBuilder().credential(new DefaultAzureCredentialBuilder().build()) + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT")) + .buildClient(); + // BEGIN:com.azure.analytics.onlineexperimentation.generated.createorupdatemetric.createorupdatemetricaverage + ExperimentMetric response = onlineExperimentationClient.createOrUpdateMetric("avg_purchase_revenue", + new ExperimentMetric().setLifecycle(LifecycleStage.ACTIVE) + .setDisplayName("Average revenue per purchase [USD]") + .setDescription( + "The average revenue per purchase transaction in USD. Refund transactions are excluded from this metric. The total revenue might increase while this metric decreases if the number of purchases increases.") + .setCategories(Arrays.asList("Monetization")) + .setDesiredDirection(DesiredDirection.INCREASE) + .setDefinition(new AverageMetricDefinition().setValue(new AggregatedValue().setEventName("Transaction") + .setFilter("Revenue > 0") + .setEventProperty("Revenue"))), + new RequestConditions().setIfMatch("vxexdn") + .setIfNoneMatch("ijchzdh") + .setIfUnmodifiedSince(OffsetDateTime.parse("2024-08-22T02:02:11Z")) + .setIfModifiedSince(OffsetDateTime.parse("2024-08-22T02:02:11Z"))); + // END:com.azure.analytics.onlineexperimentation.generated.createorupdatemetric.createorupdatemetricaverage + } +} diff --git a/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/samples/java/com/azure/analytics/onlineexperimentation/generated/CreateOrUpdateMetricEventCount.java b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/samples/java/com/azure/analytics/onlineexperimentation/generated/CreateOrUpdateMetricEventCount.java new file mode 100644 index 000000000000..926e0f183542 --- /dev/null +++ b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/samples/java/com/azure/analytics/onlineexperimentation/generated/CreateOrUpdateMetricEventCount.java @@ -0,0 +1,42 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.analytics.onlineexperimentation.generated; + +import com.azure.analytics.onlineexperimentation.OnlineExperimentationClient; +import com.azure.analytics.onlineexperimentation.OnlineExperimentationClientBuilder; +import com.azure.analytics.onlineexperimentation.models.DesiredDirection; +import com.azure.analytics.onlineexperimentation.models.EventCountMetricDefinition; +import com.azure.analytics.onlineexperimentation.models.ExperimentMetric; +import com.azure.analytics.onlineexperimentation.models.LifecycleStage; +import com.azure.analytics.onlineexperimentation.models.ObservedEvent; +import com.azure.core.http.RequestConditions; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; +import java.time.OffsetDateTime; +import java.util.Arrays; + +public class CreateOrUpdateMetricEventCount { + public static void main(String[] args) { + OnlineExperimentationClient onlineExperimentationClient + = new OnlineExperimentationClientBuilder().credential(new DefaultAzureCredentialBuilder().build()) + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT")) + .buildClient(); + // BEGIN:com.azure.analytics.onlineexperimentation.generated.createorupdatemetric.createorupdatemetriceventcount + ExperimentMetric response = onlineExperimentationClient.createOrUpdateMetric("events_purchase_creditcard", + new ExperimentMetric().setLifecycle(LifecycleStage.ACTIVE) + .setDisplayName("Number of purchases (credit card)") + .setDescription( + "The number of purchase transactions made with credit card. Refund transactions are excluded from this metric.") + .setCategories(Arrays.asList("Monetization")) + .setDesiredDirection(DesiredDirection.INCREASE) + .setDefinition(new EventCountMetricDefinition().setEvent(new ObservedEvent().setEventName("Transaction") + .setFilter("Revenue > 0 and ['payment.method'] == 'credit_card'"))), + new RequestConditions().setIfMatch("vxexdn") + .setIfNoneMatch("ijchzdh") + .setIfUnmodifiedSince(OffsetDateTime.parse("2024-08-22T02:02:11Z")) + .setIfModifiedSince(OffsetDateTime.parse("2024-08-22T02:02:11Z"))); + // END:com.azure.analytics.onlineexperimentation.generated.createorupdatemetric.createorupdatemetriceventcount + } +} diff --git a/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/samples/java/com/azure/analytics/onlineexperimentation/generated/CreateOrUpdateMetricEventRate.java b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/samples/java/com/azure/analytics/onlineexperimentation/generated/CreateOrUpdateMetricEventRate.java new file mode 100644 index 000000000000..0dc32406728b --- /dev/null +++ b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/samples/java/com/azure/analytics/onlineexperimentation/generated/CreateOrUpdateMetricEventRate.java @@ -0,0 +1,42 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.analytics.onlineexperimentation.generated; + +import com.azure.analytics.onlineexperimentation.OnlineExperimentationClient; +import com.azure.analytics.onlineexperimentation.OnlineExperimentationClientBuilder; +import com.azure.analytics.onlineexperimentation.models.DesiredDirection; +import com.azure.analytics.onlineexperimentation.models.EventRateMetricDefinition; +import com.azure.analytics.onlineexperimentation.models.ExperimentMetric; +import com.azure.analytics.onlineexperimentation.models.LifecycleStage; +import com.azure.analytics.onlineexperimentation.models.ObservedEvent; +import com.azure.core.http.RequestConditions; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; +import java.time.OffsetDateTime; +import java.util.Arrays; + +public class CreateOrUpdateMetricEventRate { + public static void main(String[] args) { + OnlineExperimentationClient onlineExperimentationClient + = new OnlineExperimentationClientBuilder().credential(new DefaultAzureCredentialBuilder().build()) + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT")) + .buildClient(); + // BEGIN:com.azure.analytics.onlineexperimentation.generated.createorupdatemetric.createorupdatemetriceventrate + ExperimentMetric response = onlineExperimentationClient.createOrUpdateMetric("rate_refund", + new ExperimentMetric().setLifecycle(LifecycleStage.ACTIVE) + .setDisplayName("Refund rate") + .setDescription( + "The percentage of transactions that are refunds. This metric is calculated as the number of refund transactions divided by the total number of transactions.") + .setCategories(Arrays.asList("Monetization")) + .setDesiredDirection(DesiredDirection.NEUTRAL) + .setDefinition(new EventRateMetricDefinition().setEvent(new ObservedEvent().setEventName("Transaction")) + .setRateCondition("Revenue < 0")), + new RequestConditions().setIfMatch("vxexdn") + .setIfNoneMatch("ijchzdh") + .setIfUnmodifiedSince(OffsetDateTime.parse("2024-08-22T02:02:11Z")) + .setIfModifiedSince(OffsetDateTime.parse("2024-08-22T02:02:11Z"))); + // END:com.azure.analytics.onlineexperimentation.generated.createorupdatemetric.createorupdatemetriceventrate + } +} diff --git a/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/samples/java/com/azure/analytics/onlineexperimentation/generated/CreateOrUpdateMetricPercentile.java b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/samples/java/com/azure/analytics/onlineexperimentation/generated/CreateOrUpdateMetricPercentile.java new file mode 100644 index 000000000000..d3dd0b721dd0 --- /dev/null +++ b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/samples/java/com/azure/analytics/onlineexperimentation/generated/CreateOrUpdateMetricPercentile.java @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.analytics.onlineexperimentation.generated; + +import com.azure.analytics.onlineexperimentation.OnlineExperimentationClient; +import com.azure.analytics.onlineexperimentation.OnlineExperimentationClientBuilder; +import com.azure.analytics.onlineexperimentation.models.AggregatedValue; +import com.azure.analytics.onlineexperimentation.models.DesiredDirection; +import com.azure.analytics.onlineexperimentation.models.ExperimentMetric; +import com.azure.analytics.onlineexperimentation.models.LifecycleStage; +import com.azure.analytics.onlineexperimentation.models.PercentileMetricDefinition; +import com.azure.core.http.RequestConditions; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; +import java.time.OffsetDateTime; +import java.util.Arrays; + +public class CreateOrUpdateMetricPercentile { + public static void main(String[] args) { + OnlineExperimentationClient onlineExperimentationClient + = new OnlineExperimentationClientBuilder().credential(new DefaultAzureCredentialBuilder().build()) + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT")) + .buildClient(); + // BEGIN:com.azure.analytics.onlineexperimentation.generated.createorupdatemetric.createorupdatemetricpercentile + ExperimentMetric response = onlineExperimentationClient.createOrUpdateMetric("p95_page_load_time", + new ExperimentMetric().setLifecycle(LifecycleStage.ACTIVE) + .setDisplayName("95th percentile of page load time [ms]") + .setDescription( + "The 95th percentile of the page load time for all pages. Measured in milliseconds. Review page-specific metric results to identify pages that need optimization.") + .setCategories(Arrays.asList("Performance", "Important")) + .setDesiredDirection(DesiredDirection.DECREASE) + .setDefinition(new PercentileMetricDefinition() + .setValue(new AggregatedValue().setEventName("PageLoad").setEventProperty("LoadTime_ms")) + .setPercentile(95.0)), + new RequestConditions().setIfMatch("vxexdn") + .setIfNoneMatch("ijchzdh") + .setIfUnmodifiedSince(OffsetDateTime.parse("2024-08-22T02:02:11Z")) + .setIfModifiedSince(OffsetDateTime.parse("2024-08-22T02:02:11Z"))); + // END:com.azure.analytics.onlineexperimentation.generated.createorupdatemetric.createorupdatemetricpercentile + } +} diff --git a/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/samples/java/com/azure/analytics/onlineexperimentation/generated/CreateOrUpdateMetricSum.java b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/samples/java/com/azure/analytics/onlineexperimentation/generated/CreateOrUpdateMetricSum.java new file mode 100644 index 000000000000..6059554d514c --- /dev/null +++ b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/samples/java/com/azure/analytics/onlineexperimentation/generated/CreateOrUpdateMetricSum.java @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.analytics.onlineexperimentation.generated; + +import com.azure.analytics.onlineexperimentation.OnlineExperimentationClient; +import com.azure.analytics.onlineexperimentation.OnlineExperimentationClientBuilder; +import com.azure.analytics.onlineexperimentation.models.AggregatedValue; +import com.azure.analytics.onlineexperimentation.models.DesiredDirection; +import com.azure.analytics.onlineexperimentation.models.ExperimentMetric; +import com.azure.analytics.onlineexperimentation.models.LifecycleStage; +import com.azure.analytics.onlineexperimentation.models.SumMetricDefinition; +import com.azure.core.http.RequestConditions; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; +import java.time.OffsetDateTime; +import java.util.Arrays; + +public class CreateOrUpdateMetricSum { + public static void main(String[] args) { + OnlineExperimentationClient onlineExperimentationClient + = new OnlineExperimentationClientBuilder().credential(new DefaultAzureCredentialBuilder().build()) + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT")) + .buildClient(); + // BEGIN:com.azure.analytics.onlineexperimentation.generated.createorupdatemetric.createorupdatemetricsum + ExperimentMetric response = onlineExperimentationClient.createOrUpdateMetric("sum_revenue", + new ExperimentMetric().setLifecycle(LifecycleStage.ACTIVE) + .setDisplayName("Total revenue [USD]") + .setDescription("The total revenue in USD. Refund transactions contribute negatively to this metric.") + .setCategories(Arrays.asList("Monetization", "Important")) + .setDesiredDirection(DesiredDirection.INCREASE) + .setDefinition(new SumMetricDefinition() + .setValue(new AggregatedValue().setEventName("Transaction").setEventProperty("Revenue"))), + new RequestConditions().setIfMatch("vxexdn") + .setIfNoneMatch("ijchzdh") + .setIfUnmodifiedSince(OffsetDateTime.parse("2024-08-22T02:02:11Z")) + .setIfModifiedSince(OffsetDateTime.parse("2024-08-22T02:02:11Z"))); + // END:com.azure.analytics.onlineexperimentation.generated.createorupdatemetric.createorupdatemetricsum + } +} diff --git a/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/samples/java/com/azure/analytics/onlineexperimentation/generated/CreateOrUpdateMetricUserCount.java b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/samples/java/com/azure/analytics/onlineexperimentation/generated/CreateOrUpdateMetricUserCount.java new file mode 100644 index 000000000000..269eb2a0caf9 --- /dev/null +++ b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/samples/java/com/azure/analytics/onlineexperimentation/generated/CreateOrUpdateMetricUserCount.java @@ -0,0 +1,42 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.analytics.onlineexperimentation.generated; + +import com.azure.analytics.onlineexperimentation.OnlineExperimentationClient; +import com.azure.analytics.onlineexperimentation.OnlineExperimentationClientBuilder; +import com.azure.analytics.onlineexperimentation.models.DesiredDirection; +import com.azure.analytics.onlineexperimentation.models.ExperimentMetric; +import com.azure.analytics.onlineexperimentation.models.LifecycleStage; +import com.azure.analytics.onlineexperimentation.models.ObservedEvent; +import com.azure.analytics.onlineexperimentation.models.UserCountMetricDefinition; +import com.azure.core.http.RequestConditions; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; +import java.time.OffsetDateTime; +import java.util.Arrays; + +public class CreateOrUpdateMetricUserCount { + public static void main(String[] args) { + OnlineExperimentationClient onlineExperimentationClient + = new OnlineExperimentationClientBuilder().credential(new DefaultAzureCredentialBuilder().build()) + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT")) + .buildClient(); + // BEGIN:com.azure.analytics.onlineexperimentation.generated.createorupdatemetric.createorupdatemetricusercount + ExperimentMetric response = onlineExperimentationClient.createOrUpdateMetric("users_purchase", + new ExperimentMetric().setLifecycle(LifecycleStage.ACTIVE) + .setDisplayName("Users with purchase") + .setDescription( + "The number of users who have made at least one purchase transaction. Refund transactions are excluded from this metric. As the analysis period grows, this metric begins to saturate as users making multiple purchases no longer contribute.") + .setCategories(Arrays.asList("Monetization")) + .setDesiredDirection(DesiredDirection.INCREASE) + .setDefinition(new UserCountMetricDefinition() + .setEvent(new ObservedEvent().setEventName("Transaction").setFilter("Revenue > 0"))), + new RequestConditions().setIfMatch("vxexdn") + .setIfNoneMatch("ijchzdh") + .setIfUnmodifiedSince(OffsetDateTime.parse("2024-08-22T02:02:11Z")) + .setIfModifiedSince(OffsetDateTime.parse("2024-08-22T02:02:11Z"))); + // END:com.azure.analytics.onlineexperimentation.generated.createorupdatemetric.createorupdatemetricusercount + } +} diff --git a/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/samples/java/com/azure/analytics/onlineexperimentation/generated/CreateOrUpdateMetricUserRate.java b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/samples/java/com/azure/analytics/onlineexperimentation/generated/CreateOrUpdateMetricUserRate.java new file mode 100644 index 000000000000..356d8ab20f5e --- /dev/null +++ b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/samples/java/com/azure/analytics/onlineexperimentation/generated/CreateOrUpdateMetricUserRate.java @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.analytics.onlineexperimentation.generated; + +import com.azure.analytics.onlineexperimentation.OnlineExperimentationClient; +import com.azure.analytics.onlineexperimentation.OnlineExperimentationClientBuilder; +import com.azure.analytics.onlineexperimentation.models.DesiredDirection; +import com.azure.analytics.onlineexperimentation.models.ExperimentMetric; +import com.azure.analytics.onlineexperimentation.models.LifecycleStage; +import com.azure.analytics.onlineexperimentation.models.ObservedEvent; +import com.azure.analytics.onlineexperimentation.models.UserRateMetricDefinition; +import com.azure.core.http.RequestConditions; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; +import java.time.OffsetDateTime; +import java.util.Arrays; + +public class CreateOrUpdateMetricUserRate { + public static void main(String[] args) { + OnlineExperimentationClient onlineExperimentationClient + = new OnlineExperimentationClientBuilder().credential(new DefaultAzureCredentialBuilder().build()) + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT")) + .buildClient(); + // BEGIN:com.azure.analytics.onlineexperimentation.generated.createorupdatemetric.createorupdatemetricuserrate + ExperimentMetric response = onlineExperimentationClient.createOrUpdateMetric("rate_subscription_ad", + new ExperimentMetric().setLifecycle(LifecycleStage.ACTIVE) + .setDisplayName("Subscription ad conversion rate") + .setDescription( + "The percentage of users who saw an advertisement for a subscription promotion and then later successfully subscribed. This metric is calculated as the number of users who successfully subscribed after seeing the advert divided by the total number of users who saw the advert. Users who saw multiple adverts or subscribed multiple times are counted only once. Users who saw the advert before the analysis period starts are excluded from this metric.") + .setCategories(Arrays.asList("Monetization")) + .setDesiredDirection(DesiredDirection.INCREASE) + .setDefinition(new UserRateMetricDefinition() + .setStartEvent( + new ObservedEvent().setEventName("AdView").setFilter("Source == 'subscription_promo'")) + .setEndEvent(new ObservedEvent().setEventName("Subscribe").setFilter("Status == 'Success'"))), + new RequestConditions().setIfMatch("vxexdn") + .setIfNoneMatch("ijchzdh") + .setIfUnmodifiedSince(OffsetDateTime.parse("2024-08-22T02:02:11Z")) + .setIfModifiedSince(OffsetDateTime.parse("2024-08-22T02:02:11Z"))); + // END:com.azure.analytics.onlineexperimentation.generated.createorupdatemetric.createorupdatemetricuserrate + } +} diff --git a/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/samples/java/com/azure/analytics/onlineexperimentation/generated/DeleteMetric.java b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/samples/java/com/azure/analytics/onlineexperimentation/generated/DeleteMetric.java new file mode 100644 index 000000000000..da3bc679da8d --- /dev/null +++ b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/samples/java/com/azure/analytics/onlineexperimentation/generated/DeleteMetric.java @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.analytics.onlineexperimentation.generated; + +import com.azure.analytics.onlineexperimentation.OnlineExperimentationClient; +import com.azure.analytics.onlineexperimentation.OnlineExperimentationClientBuilder; +import com.azure.core.http.RequestConditions; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; +import java.time.OffsetDateTime; + +public class DeleteMetric { + public static void main(String[] args) { + OnlineExperimentationClient onlineExperimentationClient + = new OnlineExperimentationClientBuilder().credential(new DefaultAzureCredentialBuilder().build()) + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT")) + .buildClient(); + // BEGIN:com.azure.analytics.onlineexperimentation.generated.deletemetric.deletemetric + onlineExperimentationClient.deleteMetric("avg_purchase_revenue", + new RequestConditions().setIfMatch("vxexdn") + .setIfNoneMatch("ijchzdh") + .setIfUnmodifiedSince(OffsetDateTime.parse("2024-08-22T02:02:11Z")) + .setIfModifiedSince(OffsetDateTime.parse("2024-08-22T02:02:11Z"))); + // END:com.azure.analytics.onlineexperimentation.generated.deletemetric.deletemetric + } +} diff --git a/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/samples/java/com/azure/analytics/onlineexperimentation/generated/GetMetric.java b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/samples/java/com/azure/analytics/onlineexperimentation/generated/GetMetric.java new file mode 100644 index 000000000000..929fc86f4e88 --- /dev/null +++ b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/samples/java/com/azure/analytics/onlineexperimentation/generated/GetMetric.java @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.analytics.onlineexperimentation.generated; + +import com.azure.analytics.onlineexperimentation.OnlineExperimentationClient; +import com.azure.analytics.onlineexperimentation.OnlineExperimentationClientBuilder; +import com.azure.analytics.onlineexperimentation.models.ExperimentMetric; +import com.azure.core.http.RequestConditions; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; +import java.time.OffsetDateTime; + +public class GetMetric { + public static void main(String[] args) { + OnlineExperimentationClient onlineExperimentationClient + = new OnlineExperimentationClientBuilder().credential(new DefaultAzureCredentialBuilder().build()) + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT")) + .buildClient(); + // BEGIN:com.azure.analytics.onlineexperimentation.generated.getmetric.getmetric + ExperimentMetric response = onlineExperimentationClient.getMetric("events_purchase_creditcard", + new RequestConditions().setIfMatch("vxexdn") + .setIfNoneMatch("ijchzdh") + .setIfUnmodifiedSince(OffsetDateTime.parse("2024-08-22T02:02:11Z")) + .setIfModifiedSince(OffsetDateTime.parse("2024-08-22T02:02:11Z"))); + // END:com.azure.analytics.onlineexperimentation.generated.getmetric.getmetric + } +} diff --git a/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/samples/java/com/azure/analytics/onlineexperimentation/generated/ListMetrics.java b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/samples/java/com/azure/analytics/onlineexperimentation/generated/ListMetrics.java new file mode 100644 index 000000000000..18d5184bc603 --- /dev/null +++ b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/samples/java/com/azure/analytics/onlineexperimentation/generated/ListMetrics.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.analytics.onlineexperimentation.generated; + +import com.azure.analytics.onlineexperimentation.OnlineExperimentationClient; +import com.azure.analytics.onlineexperimentation.OnlineExperimentationClientBuilder; +import com.azure.analytics.onlineexperimentation.models.ExperimentMetric; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; + +public class ListMetrics { + public static void main(String[] args) { + OnlineExperimentationClient onlineExperimentationClient + = new OnlineExperimentationClientBuilder().credential(new DefaultAzureCredentialBuilder().build()) + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT")) + .buildClient(); + // BEGIN:com.azure.analytics.onlineexperimentation.generated.listmetrics.listmetrics + PagedIterable response = onlineExperimentationClient.listMetrics(8, 15); + // END:com.azure.analytics.onlineexperimentation.generated.listmetrics.listmetrics + } +} diff --git a/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/samples/java/com/azure/analytics/onlineexperimentation/generated/ValidateMetric.java b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/samples/java/com/azure/analytics/onlineexperimentation/generated/ValidateMetric.java new file mode 100644 index 000000000000..c8179b41fbda --- /dev/null +++ b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/samples/java/com/azure/analytics/onlineexperimentation/generated/ValidateMetric.java @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.analytics.onlineexperimentation.generated; + +import com.azure.analytics.onlineexperimentation.OnlineExperimentationClient; +import com.azure.analytics.onlineexperimentation.OnlineExperimentationClientBuilder; +import com.azure.analytics.onlineexperimentation.models.AggregatedValue; +import com.azure.analytics.onlineexperimentation.models.AverageMetricDefinition; +import com.azure.analytics.onlineexperimentation.models.DesiredDirection; +import com.azure.analytics.onlineexperimentation.models.ExperimentMetric; +import com.azure.analytics.onlineexperimentation.models.ExperimentMetricValidationResult; +import com.azure.analytics.onlineexperimentation.models.LifecycleStage; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; +import java.util.Arrays; + +public class ValidateMetric { + public static void main(String[] args) { + OnlineExperimentationClient onlineExperimentationClient + = new OnlineExperimentationClientBuilder().credential(new DefaultAzureCredentialBuilder().build()) + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT")) + .buildClient(); + // BEGIN:com.azure.analytics.onlineexperimentation.generated.validatemetric.validatemetric + ExperimentMetricValidationResult response = onlineExperimentationClient.validateMetric(new ExperimentMetric() + .setLifecycle(LifecycleStage.ACTIVE) + .setDisplayName("Average revenue per purchase [USD]") + .setDescription( + "The average revenue per purchase transaction in USD. Refund transactions are excluded from this metric. The total revenue might increase while this metric decreases if the number of purchases increases.") + .setCategories(Arrays.asList("Monetization")) + .setDesiredDirection(DesiredDirection.INCREASE) + .setDefinition(new AverageMetricDefinition().setValue( + new AggregatedValue().setEventName("Transaction").setFilter("Revenue >").setEventProperty("Revenue")))); + // END:com.azure.analytics.onlineexperimentation.generated.validatemetric.validatemetric + } +} diff --git a/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/test/java/com/azure/analytics/onlineexperimentation/generated/CreateOrUpdateMetricAverageTests.java b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/test/java/com/azure/analytics/onlineexperimentation/generated/CreateOrUpdateMetricAverageTests.java new file mode 100644 index 000000000000..00bb7f0553f1 --- /dev/null +++ b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/test/java/com/azure/analytics/onlineexperimentation/generated/CreateOrUpdateMetricAverageTests.java @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.analytics.onlineexperimentation.generated; + +import com.azure.analytics.onlineexperimentation.models.AggregatedValue; +import com.azure.analytics.onlineexperimentation.models.AverageMetricDefinition; +import com.azure.analytics.onlineexperimentation.models.DesiredDirection; +import com.azure.analytics.onlineexperimentation.models.ExperimentMetric; +import com.azure.analytics.onlineexperimentation.models.ExperimentMetricDefinition; +import com.azure.analytics.onlineexperimentation.models.ExperimentMetricType; +import com.azure.analytics.onlineexperimentation.models.LifecycleStage; +import com.azure.core.http.RequestConditions; +import java.time.OffsetDateTime; +import java.util.Arrays; +import java.util.List; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +@Disabled +public final class CreateOrUpdateMetricAverageTests extends OnlineExperimentationClientTestBase { + @Test + @Disabled + public void testCreateOrUpdateMetricAverageTests() { + // method invocation + ExperimentMetric response = onlineExperimentationClient.createOrUpdateMetric("avg_purchase_revenue", + new ExperimentMetric().setLifecycle(LifecycleStage.ACTIVE) + .setDisplayName("Average revenue per purchase [USD]") + .setDescription( + "The average revenue per purchase transaction in USD. Refund transactions are excluded from this metric. The total revenue might increase while this metric decreases if the number of purchases increases.") + .setCategories(Arrays.asList("Monetization")) + .setDesiredDirection(DesiredDirection.INCREASE) + .setDefinition(new AverageMetricDefinition().setValue(new AggregatedValue().setEventName("Transaction") + .setFilter("Revenue > 0") + .setEventProperty("Revenue"))), + new RequestConditions().setIfMatch("vxexdn") + .setIfNoneMatch("ijchzdh") + .setIfUnmodifiedSince(OffsetDateTime.parse("2024-08-22T02:02:11Z")) + .setIfModifiedSince(OffsetDateTime.parse("2024-08-22T02:02:11Z"))); + + // response assertion + Assertions.assertNotNull(response); + // verify property "id" + Assertions.assertEquals("avg_purchase_revenue", response.getId()); + // verify property "lifecycle" + Assertions.assertEquals(LifecycleStage.ACTIVE, response.getLifecycle()); + // verify property "displayName" + Assertions.assertEquals("Average revenue per purchase [USD]", response.getDisplayName()); + // verify property "description" + Assertions.assertEquals( + "The average revenue per purchase transaction in USD. Refund transactions are excluded from this metric. The total revenue might increase while this metric decreases if the number of purchases increases.", + response.getDescription()); + // verify property "categories" + List responseCategories = response.getCategories(); + Assertions.assertEquals("Monetization", responseCategories.iterator().next()); + // verify property "desiredDirection" + Assertions.assertEquals(DesiredDirection.INCREASE, response.getDesiredDirection()); + // verify property "definition" + ExperimentMetricDefinition responseDefinition = response.getDefinition(); + Assertions.assertNotNull(responseDefinition); + Assertions.assertEquals(ExperimentMetricType.AVERAGE, responseDefinition.getType()); + // verify property "eTag" + Assertions.assertEquals("ckswkavwgassdlocwuzxz", response.getETag()); + // verify property "lastModifiedAt" + Assertions.assertNotNull(response.getLastModifiedAt()); + } +} diff --git a/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/test/java/com/azure/analytics/onlineexperimentation/generated/CreateOrUpdateMetricEventCountTests.java b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/test/java/com/azure/analytics/onlineexperimentation/generated/CreateOrUpdateMetricEventCountTests.java new file mode 100644 index 000000000000..e7f3ab92d8a7 --- /dev/null +++ b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/test/java/com/azure/analytics/onlineexperimentation/generated/CreateOrUpdateMetricEventCountTests.java @@ -0,0 +1,68 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.analytics.onlineexperimentation.generated; + +import com.azure.analytics.onlineexperimentation.models.DesiredDirection; +import com.azure.analytics.onlineexperimentation.models.EventCountMetricDefinition; +import com.azure.analytics.onlineexperimentation.models.ExperimentMetric; +import com.azure.analytics.onlineexperimentation.models.ExperimentMetricDefinition; +import com.azure.analytics.onlineexperimentation.models.ExperimentMetricType; +import com.azure.analytics.onlineexperimentation.models.LifecycleStage; +import com.azure.analytics.onlineexperimentation.models.ObservedEvent; +import com.azure.core.http.RequestConditions; +import java.time.OffsetDateTime; +import java.util.Arrays; +import java.util.List; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +@Disabled +public final class CreateOrUpdateMetricEventCountTests extends OnlineExperimentationClientTestBase { + @Test + @Disabled + public void testCreateOrUpdateMetricEventCountTests() { + // method invocation + ExperimentMetric response = onlineExperimentationClient.createOrUpdateMetric("events_purchase_creditcard", + new ExperimentMetric().setLifecycle(LifecycleStage.ACTIVE) + .setDisplayName("Number of purchases (credit card)") + .setDescription( + "The number of purchase transactions made with credit card. Refund transactions are excluded from this metric.") + .setCategories(Arrays.asList("Monetization")) + .setDesiredDirection(DesiredDirection.INCREASE) + .setDefinition(new EventCountMetricDefinition().setEvent(new ObservedEvent().setEventName("Transaction") + .setFilter("Revenue > 0 and ['payment.method'] == 'credit_card'"))), + new RequestConditions().setIfMatch("vxexdn") + .setIfNoneMatch("ijchzdh") + .setIfUnmodifiedSince(OffsetDateTime.parse("2024-08-22T02:02:11Z")) + .setIfModifiedSince(OffsetDateTime.parse("2024-08-22T02:02:11Z"))); + + // response assertion + Assertions.assertNotNull(response); + // verify property "id" + Assertions.assertEquals("events_purchase_creditcard", response.getId()); + // verify property "lifecycle" + Assertions.assertEquals(LifecycleStage.ACTIVE, response.getLifecycle()); + // verify property "displayName" + Assertions.assertEquals("Number of purchases (credit card)", response.getDisplayName()); + // verify property "description" + Assertions.assertEquals( + "The number of purchase transactions made with credit card. Refund transactions are excluded from this metric.", + response.getDescription()); + // verify property "categories" + List responseCategories = response.getCategories(); + Assertions.assertEquals("Monetization", responseCategories.iterator().next()); + // verify property "desiredDirection" + Assertions.assertEquals(DesiredDirection.INCREASE, response.getDesiredDirection()); + // verify property "definition" + ExperimentMetricDefinition responseDefinition = response.getDefinition(); + Assertions.assertNotNull(responseDefinition); + Assertions.assertEquals(ExperimentMetricType.EVENT_COUNT, responseDefinition.getType()); + // verify property "eTag" + Assertions.assertEquals("ckswkavwgassdlocwuzxz", response.getETag()); + // verify property "lastModifiedAt" + Assertions.assertNotNull(response.getLastModifiedAt()); + } +} diff --git a/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/test/java/com/azure/analytics/onlineexperimentation/generated/CreateOrUpdateMetricEventRateTests.java b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/test/java/com/azure/analytics/onlineexperimentation/generated/CreateOrUpdateMetricEventRateTests.java new file mode 100644 index 000000000000..fd86944f09fe --- /dev/null +++ b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/test/java/com/azure/analytics/onlineexperimentation/generated/CreateOrUpdateMetricEventRateTests.java @@ -0,0 +1,68 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.analytics.onlineexperimentation.generated; + +import com.azure.analytics.onlineexperimentation.models.DesiredDirection; +import com.azure.analytics.onlineexperimentation.models.EventRateMetricDefinition; +import com.azure.analytics.onlineexperimentation.models.ExperimentMetric; +import com.azure.analytics.onlineexperimentation.models.ExperimentMetricDefinition; +import com.azure.analytics.onlineexperimentation.models.ExperimentMetricType; +import com.azure.analytics.onlineexperimentation.models.LifecycleStage; +import com.azure.analytics.onlineexperimentation.models.ObservedEvent; +import com.azure.core.http.RequestConditions; +import java.time.OffsetDateTime; +import java.util.Arrays; +import java.util.List; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +@Disabled +public final class CreateOrUpdateMetricEventRateTests extends OnlineExperimentationClientTestBase { + @Test + @Disabled + public void testCreateOrUpdateMetricEventRateTests() { + // method invocation + ExperimentMetric response = onlineExperimentationClient.createOrUpdateMetric("rate_refund", + new ExperimentMetric().setLifecycle(LifecycleStage.ACTIVE) + .setDisplayName("Refund rate") + .setDescription( + "The percentage of transactions that are refunds. This metric is calculated as the number of refund transactions divided by the total number of transactions.") + .setCategories(Arrays.asList("Monetization")) + .setDesiredDirection(DesiredDirection.NEUTRAL) + .setDefinition(new EventRateMetricDefinition().setEvent(new ObservedEvent().setEventName("Transaction")) + .setRateCondition("Revenue < 0")), + new RequestConditions().setIfMatch("vxexdn") + .setIfNoneMatch("ijchzdh") + .setIfUnmodifiedSince(OffsetDateTime.parse("2024-08-22T02:02:11Z")) + .setIfModifiedSince(OffsetDateTime.parse("2024-08-22T02:02:11Z"))); + + // response assertion + Assertions.assertNotNull(response); + // verify property "id" + Assertions.assertEquals("rate_refund", response.getId()); + // verify property "lifecycle" + Assertions.assertEquals(LifecycleStage.ACTIVE, response.getLifecycle()); + // verify property "displayName" + Assertions.assertEquals("Refund rate", response.getDisplayName()); + // verify property "description" + Assertions.assertEquals( + "The percentage of transactions that are refunds. This metric is calculated as the number of refund transactions divided by the total number of transactions.", + response.getDescription()); + // verify property "categories" + List responseCategories = response.getCategories(); + Assertions.assertEquals("Monetization", responseCategories.iterator().next()); + // verify property "desiredDirection" + Assertions.assertEquals(DesiredDirection.NEUTRAL, response.getDesiredDirection()); + // verify property "definition" + ExperimentMetricDefinition responseDefinition = response.getDefinition(); + Assertions.assertNotNull(responseDefinition); + Assertions.assertEquals(ExperimentMetricType.EVENT_RATE, responseDefinition.getType()); + // verify property "eTag" + Assertions.assertEquals("ckswkavwgassdlocwuzxz", response.getETag()); + // verify property "lastModifiedAt" + Assertions.assertNotNull(response.getLastModifiedAt()); + } +} diff --git a/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/test/java/com/azure/analytics/onlineexperimentation/generated/CreateOrUpdateMetricPercentileTests.java b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/test/java/com/azure/analytics/onlineexperimentation/generated/CreateOrUpdateMetricPercentileTests.java new file mode 100644 index 000000000000..8249129d751a --- /dev/null +++ b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/test/java/com/azure/analytics/onlineexperimentation/generated/CreateOrUpdateMetricPercentileTests.java @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.analytics.onlineexperimentation.generated; + +import com.azure.analytics.onlineexperimentation.models.AggregatedValue; +import com.azure.analytics.onlineexperimentation.models.DesiredDirection; +import com.azure.analytics.onlineexperimentation.models.ExperimentMetric; +import com.azure.analytics.onlineexperimentation.models.ExperimentMetricDefinition; +import com.azure.analytics.onlineexperimentation.models.ExperimentMetricType; +import com.azure.analytics.onlineexperimentation.models.LifecycleStage; +import com.azure.analytics.onlineexperimentation.models.PercentileMetricDefinition; +import com.azure.core.http.RequestConditions; +import java.time.OffsetDateTime; +import java.util.Arrays; +import java.util.List; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +@Disabled +public final class CreateOrUpdateMetricPercentileTests extends OnlineExperimentationClientTestBase { + @Test + @Disabled + public void testCreateOrUpdateMetricPercentileTests() { + // method invocation + ExperimentMetric response = onlineExperimentationClient.createOrUpdateMetric("p95_page_load_time", + new ExperimentMetric().setLifecycle(LifecycleStage.ACTIVE) + .setDisplayName("95th percentile of page load time [ms]") + .setDescription( + "The 95th percentile of the page load time for all pages. Measured in milliseconds. Review page-specific metric results to identify pages that need optimization.") + .setCategories(Arrays.asList("Performance", "Important")) + .setDesiredDirection(DesiredDirection.DECREASE) + .setDefinition(new PercentileMetricDefinition() + .setValue(new AggregatedValue().setEventName("PageLoad").setEventProperty("LoadTime_ms")) + .setPercentile(95.0)), + new RequestConditions().setIfMatch("vxexdn") + .setIfNoneMatch("ijchzdh") + .setIfUnmodifiedSince(OffsetDateTime.parse("2024-08-22T02:02:11Z")) + .setIfModifiedSince(OffsetDateTime.parse("2024-08-22T02:02:11Z"))); + + // response assertion + Assertions.assertNotNull(response); + // verify property "id" + Assertions.assertEquals("p95_page_load_time", response.getId()); + // verify property "lifecycle" + Assertions.assertEquals(LifecycleStage.ACTIVE, response.getLifecycle()); + // verify property "displayName" + Assertions.assertEquals("95th percentile of page load time [ms]", response.getDisplayName()); + // verify property "description" + Assertions.assertEquals( + "The 95th percentile of the page load time for all pages. Measured in milliseconds. Review page-specific metric results to identify pages that need optimization.", + response.getDescription()); + // verify property "categories" + List responseCategories = response.getCategories(); + Assertions.assertEquals("Performance", responseCategories.iterator().next()); + // verify property "desiredDirection" + Assertions.assertEquals(DesiredDirection.DECREASE, response.getDesiredDirection()); + // verify property "definition" + ExperimentMetricDefinition responseDefinition = response.getDefinition(); + Assertions.assertNotNull(responseDefinition); + Assertions.assertEquals(ExperimentMetricType.PERCENTILE, responseDefinition.getType()); + // verify property "eTag" + Assertions.assertEquals("ckswkavwgassdlocwuzxz", response.getETag()); + // verify property "lastModifiedAt" + Assertions.assertNotNull(response.getLastModifiedAt()); + } +} diff --git a/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/test/java/com/azure/analytics/onlineexperimentation/generated/CreateOrUpdateMetricSumTests.java b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/test/java/com/azure/analytics/onlineexperimentation/generated/CreateOrUpdateMetricSumTests.java new file mode 100644 index 000000000000..f3cb47a1ccc3 --- /dev/null +++ b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/test/java/com/azure/analytics/onlineexperimentation/generated/CreateOrUpdateMetricSumTests.java @@ -0,0 +1,66 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.analytics.onlineexperimentation.generated; + +import com.azure.analytics.onlineexperimentation.models.AggregatedValue; +import com.azure.analytics.onlineexperimentation.models.DesiredDirection; +import com.azure.analytics.onlineexperimentation.models.ExperimentMetric; +import com.azure.analytics.onlineexperimentation.models.ExperimentMetricDefinition; +import com.azure.analytics.onlineexperimentation.models.ExperimentMetricType; +import com.azure.analytics.onlineexperimentation.models.LifecycleStage; +import com.azure.analytics.onlineexperimentation.models.SumMetricDefinition; +import com.azure.core.http.RequestConditions; +import java.time.OffsetDateTime; +import java.util.Arrays; +import java.util.List; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +@Disabled +public final class CreateOrUpdateMetricSumTests extends OnlineExperimentationClientTestBase { + @Test + @Disabled + public void testCreateOrUpdateMetricSumTests() { + // method invocation + ExperimentMetric response = onlineExperimentationClient.createOrUpdateMetric("sum_revenue", + new ExperimentMetric().setLifecycle(LifecycleStage.ACTIVE) + .setDisplayName("Total revenue [USD]") + .setDescription("The total revenue in USD. Refund transactions contribute negatively to this metric.") + .setCategories(Arrays.asList("Monetization", "Important")) + .setDesiredDirection(DesiredDirection.INCREASE) + .setDefinition(new SumMetricDefinition() + .setValue(new AggregatedValue().setEventName("Transaction").setEventProperty("Revenue"))), + new RequestConditions().setIfMatch("vxexdn") + .setIfNoneMatch("ijchzdh") + .setIfUnmodifiedSince(OffsetDateTime.parse("2024-08-22T02:02:11Z")) + .setIfModifiedSince(OffsetDateTime.parse("2024-08-22T02:02:11Z"))); + + // response assertion + Assertions.assertNotNull(response); + // verify property "id" + Assertions.assertEquals("sum_revenue", response.getId()); + // verify property "lifecycle" + Assertions.assertEquals(LifecycleStage.ACTIVE, response.getLifecycle()); + // verify property "displayName" + Assertions.assertEquals("Total revenue [USD]", response.getDisplayName()); + // verify property "description" + Assertions.assertEquals("The total revenue in USD. Refund transactions contribute negatively to this metric.", + response.getDescription()); + // verify property "categories" + List responseCategories = response.getCategories(); + Assertions.assertEquals("Monetization", responseCategories.iterator().next()); + // verify property "desiredDirection" + Assertions.assertEquals(DesiredDirection.INCREASE, response.getDesiredDirection()); + // verify property "definition" + ExperimentMetricDefinition responseDefinition = response.getDefinition(); + Assertions.assertNotNull(responseDefinition); + Assertions.assertEquals(ExperimentMetricType.SUM, responseDefinition.getType()); + // verify property "eTag" + Assertions.assertEquals("ckswkavwgassdlocwuzxz", response.getETag()); + // verify property "lastModifiedAt" + Assertions.assertNotNull(response.getLastModifiedAt()); + } +} diff --git a/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/test/java/com/azure/analytics/onlineexperimentation/generated/CreateOrUpdateMetricUserCountTests.java b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/test/java/com/azure/analytics/onlineexperimentation/generated/CreateOrUpdateMetricUserCountTests.java new file mode 100644 index 000000000000..0c934dea12cb --- /dev/null +++ b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/test/java/com/azure/analytics/onlineexperimentation/generated/CreateOrUpdateMetricUserCountTests.java @@ -0,0 +1,68 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.analytics.onlineexperimentation.generated; + +import com.azure.analytics.onlineexperimentation.models.DesiredDirection; +import com.azure.analytics.onlineexperimentation.models.ExperimentMetric; +import com.azure.analytics.onlineexperimentation.models.ExperimentMetricDefinition; +import com.azure.analytics.onlineexperimentation.models.ExperimentMetricType; +import com.azure.analytics.onlineexperimentation.models.LifecycleStage; +import com.azure.analytics.onlineexperimentation.models.ObservedEvent; +import com.azure.analytics.onlineexperimentation.models.UserCountMetricDefinition; +import com.azure.core.http.RequestConditions; +import java.time.OffsetDateTime; +import java.util.Arrays; +import java.util.List; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +@Disabled +public final class CreateOrUpdateMetricUserCountTests extends OnlineExperimentationClientTestBase { + @Test + @Disabled + public void testCreateOrUpdateMetricUserCountTests() { + // method invocation + ExperimentMetric response = onlineExperimentationClient.createOrUpdateMetric("users_purchase", + new ExperimentMetric().setLifecycle(LifecycleStage.ACTIVE) + .setDisplayName("Users with purchase") + .setDescription( + "The number of users who have made at least one purchase transaction. Refund transactions are excluded from this metric. As the analysis period grows, this metric begins to saturate as users making multiple purchases no longer contribute.") + .setCategories(Arrays.asList("Monetization")) + .setDesiredDirection(DesiredDirection.INCREASE) + .setDefinition(new UserCountMetricDefinition() + .setEvent(new ObservedEvent().setEventName("Transaction").setFilter("Revenue > 0"))), + new RequestConditions().setIfMatch("vxexdn") + .setIfNoneMatch("ijchzdh") + .setIfUnmodifiedSince(OffsetDateTime.parse("2024-08-22T02:02:11Z")) + .setIfModifiedSince(OffsetDateTime.parse("2024-08-22T02:02:11Z"))); + + // response assertion + Assertions.assertNotNull(response); + // verify property "id" + Assertions.assertEquals("users_purchase", response.getId()); + // verify property "lifecycle" + Assertions.assertEquals(LifecycleStage.ACTIVE, response.getLifecycle()); + // verify property "displayName" + Assertions.assertEquals("Users with purchase", response.getDisplayName()); + // verify property "description" + Assertions.assertEquals( + "The number of users who have made at least one purchase transaction. Refund transactions are excluded from this metric. As the analysis period grows, this metric begins to saturate as users making multiple purchases no longer contribute.", + response.getDescription()); + // verify property "categories" + List responseCategories = response.getCategories(); + Assertions.assertEquals("Monetization", responseCategories.iterator().next()); + // verify property "desiredDirection" + Assertions.assertEquals(DesiredDirection.INCREASE, response.getDesiredDirection()); + // verify property "definition" + ExperimentMetricDefinition responseDefinition = response.getDefinition(); + Assertions.assertNotNull(responseDefinition); + Assertions.assertEquals(ExperimentMetricType.USER_COUNT, responseDefinition.getType()); + // verify property "eTag" + Assertions.assertEquals("ckswkavwgassdlocwuzxz", response.getETag()); + // verify property "lastModifiedAt" + Assertions.assertNotNull(response.getLastModifiedAt()); + } +} diff --git a/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/test/java/com/azure/analytics/onlineexperimentation/generated/CreateOrUpdateMetricUserRateTests.java b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/test/java/com/azure/analytics/onlineexperimentation/generated/CreateOrUpdateMetricUserRateTests.java new file mode 100644 index 000000000000..cdba4394cea6 --- /dev/null +++ b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/test/java/com/azure/analytics/onlineexperimentation/generated/CreateOrUpdateMetricUserRateTests.java @@ -0,0 +1,70 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.analytics.onlineexperimentation.generated; + +import com.azure.analytics.onlineexperimentation.models.DesiredDirection; +import com.azure.analytics.onlineexperimentation.models.ExperimentMetric; +import com.azure.analytics.onlineexperimentation.models.ExperimentMetricDefinition; +import com.azure.analytics.onlineexperimentation.models.ExperimentMetricType; +import com.azure.analytics.onlineexperimentation.models.LifecycleStage; +import com.azure.analytics.onlineexperimentation.models.ObservedEvent; +import com.azure.analytics.onlineexperimentation.models.UserRateMetricDefinition; +import com.azure.core.http.RequestConditions; +import java.time.OffsetDateTime; +import java.util.Arrays; +import java.util.List; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +@Disabled +public final class CreateOrUpdateMetricUserRateTests extends OnlineExperimentationClientTestBase { + @Test + @Disabled + public void testCreateOrUpdateMetricUserRateTests() { + // method invocation + ExperimentMetric response = onlineExperimentationClient.createOrUpdateMetric("rate_subscription_ad", + new ExperimentMetric().setLifecycle(LifecycleStage.ACTIVE) + .setDisplayName("Subscription ad conversion rate") + .setDescription( + "The percentage of users who saw an advertisement for a subscription promotion and then later successfully subscribed. This metric is calculated as the number of users who successfully subscribed after seeing the advert divided by the total number of users who saw the advert. Users who saw multiple adverts or subscribed multiple times are counted only once. Users who saw the advert before the analysis period starts are excluded from this metric.") + .setCategories(Arrays.asList("Monetization")) + .setDesiredDirection(DesiredDirection.INCREASE) + .setDefinition(new UserRateMetricDefinition() + .setStartEvent( + new ObservedEvent().setEventName("AdView").setFilter("Source == 'subscription_promo'")) + .setEndEvent(new ObservedEvent().setEventName("Subscribe").setFilter("Status == 'Success'"))), + new RequestConditions().setIfMatch("vxexdn") + .setIfNoneMatch("ijchzdh") + .setIfUnmodifiedSince(OffsetDateTime.parse("2024-08-22T02:02:11Z")) + .setIfModifiedSince(OffsetDateTime.parse("2024-08-22T02:02:11Z"))); + + // response assertion + Assertions.assertNotNull(response); + // verify property "id" + Assertions.assertEquals("rate_subscription_ad", response.getId()); + // verify property "lifecycle" + Assertions.assertEquals(LifecycleStage.ACTIVE, response.getLifecycle()); + // verify property "displayName" + Assertions.assertEquals("Subscription ad conversion rate", response.getDisplayName()); + // verify property "description" + Assertions.assertEquals( + "The percentage of users who saw an advertisement for a subscription promotion and then later successfully subscribed. This metric is calculated as the number of users who successfully subscribed after seeing the advert divided by the total number of users who saw the advert. Users who saw multiple adverts or subscribed multiple times are counted only once. Users who saw the advert before the analysis period starts are excluded from this metric.", + response.getDescription()); + // verify property "categories" + List responseCategories = response.getCategories(); + Assertions.assertEquals("Monetization", responseCategories.iterator().next()); + // verify property "desiredDirection" + Assertions.assertEquals(DesiredDirection.INCREASE, response.getDesiredDirection()); + // verify property "definition" + ExperimentMetricDefinition responseDefinition = response.getDefinition(); + Assertions.assertNotNull(responseDefinition); + Assertions.assertEquals(ExperimentMetricType.USER_RATE, responseDefinition.getType()); + // verify property "eTag" + Assertions.assertEquals("ckswkavwgassdlocwuzxz", response.getETag()); + // verify property "lastModifiedAt" + Assertions.assertNotNull(response.getLastModifiedAt()); + } +} diff --git a/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/test/java/com/azure/analytics/onlineexperimentation/generated/DeleteMetricTests.java b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/test/java/com/azure/analytics/onlineexperimentation/generated/DeleteMetricTests.java new file mode 100644 index 000000000000..10ccc5b3ffdc --- /dev/null +++ b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/test/java/com/azure/analytics/onlineexperimentation/generated/DeleteMetricTests.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.analytics.onlineexperimentation.generated; + +import com.azure.core.http.RequestConditions; +import java.time.OffsetDateTime; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +@Disabled +public final class DeleteMetricTests extends OnlineExperimentationClientTestBase { + @Test + @Disabled + public void testDeleteMetricTests() { + // method invocation + onlineExperimentationClient.deleteMetric("avg_purchase_revenue", + new RequestConditions().setIfMatch("vxexdn") + .setIfNoneMatch("ijchzdh") + .setIfUnmodifiedSince(OffsetDateTime.parse("2024-08-22T02:02:11Z")) + .setIfModifiedSince(OffsetDateTime.parse("2024-08-22T02:02:11Z"))); + } +} diff --git a/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/test/java/com/azure/analytics/onlineexperimentation/generated/GetMetricTests.java b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/test/java/com/azure/analytics/onlineexperimentation/generated/GetMetricTests.java new file mode 100644 index 000000000000..9296d5136cb4 --- /dev/null +++ b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/test/java/com/azure/analytics/onlineexperimentation/generated/GetMetricTests.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.analytics.onlineexperimentation.generated; + +import com.azure.analytics.onlineexperimentation.models.DesiredDirection; +import com.azure.analytics.onlineexperimentation.models.ExperimentMetric; +import com.azure.analytics.onlineexperimentation.models.ExperimentMetricDefinition; +import com.azure.analytics.onlineexperimentation.models.ExperimentMetricType; +import com.azure.analytics.onlineexperimentation.models.LifecycleStage; +import com.azure.core.http.RequestConditions; +import java.time.OffsetDateTime; +import java.util.List; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +@Disabled +public final class GetMetricTests extends OnlineExperimentationClientTestBase { + @Test + @Disabled + public void testGetMetricTests() { + // method invocation + ExperimentMetric response = onlineExperimentationClient.getMetric("events_purchase_creditcard", + new RequestConditions().setIfMatch("vxexdn") + .setIfNoneMatch("ijchzdh") + .setIfUnmodifiedSince(OffsetDateTime.parse("2024-08-22T02:02:11Z")) + .setIfModifiedSince(OffsetDateTime.parse("2024-08-22T02:02:11Z"))); + + // response assertion + Assertions.assertNotNull(response); + // verify property "id" + Assertions.assertEquals("events_purchase_creditcard", response.getId()); + // verify property "lifecycle" + Assertions.assertEquals(LifecycleStage.ACTIVE, response.getLifecycle()); + // verify property "displayName" + Assertions.assertEquals("Number of purchases (credit card)", response.getDisplayName()); + // verify property "description" + Assertions.assertEquals( + "The number of purchase transactions made with credit card. Refund transactions are excluded from this metric.", + response.getDescription()); + // verify property "categories" + List responseCategories = response.getCategories(); + Assertions.assertEquals("Monetization", responseCategories.iterator().next()); + // verify property "desiredDirection" + Assertions.assertEquals(DesiredDirection.INCREASE, response.getDesiredDirection()); + // verify property "definition" + ExperimentMetricDefinition responseDefinition = response.getDefinition(); + Assertions.assertNotNull(responseDefinition); + Assertions.assertEquals(ExperimentMetricType.EVENT_COUNT, responseDefinition.getType()); + // verify property "eTag" + Assertions.assertEquals("ckswkavwgassdlocwuzxz", response.getETag()); + // verify property "lastModifiedAt" + Assertions.assertNotNull(response.getLastModifiedAt()); + } +} diff --git a/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/test/java/com/azure/analytics/onlineexperimentation/generated/ListMetricsTests.java b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/test/java/com/azure/analytics/onlineexperimentation/generated/ListMetricsTests.java new file mode 100644 index 000000000000..1857f6880b3b --- /dev/null +++ b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/test/java/com/azure/analytics/onlineexperimentation/generated/ListMetricsTests.java @@ -0,0 +1,62 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.analytics.onlineexperimentation.generated; + +import com.azure.analytics.onlineexperimentation.models.DesiredDirection; +import com.azure.analytics.onlineexperimentation.models.ExperimentMetric; +import com.azure.analytics.onlineexperimentation.models.ExperimentMetricDefinition; +import com.azure.analytics.onlineexperimentation.models.ExperimentMetricType; +import com.azure.analytics.onlineexperimentation.models.LifecycleStage; +import com.azure.core.http.HttpHeaderName; +import com.azure.core.http.rest.PagedIterable; +import java.util.List; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +@Disabled +public final class ListMetricsTests extends OnlineExperimentationClientTestBase { + @Test + @Disabled + public void testListMetricsTests() { + // method invocation + PagedIterable response = onlineExperimentationClient.listMetrics(8, 15); + + // response assertion + Assertions.assertEquals(200, response.iterableByPage().iterator().next().getStatusCode()); + Assertions.assertEquals("00000000-0000-0000-0000-000000000000", + response.iterableByPage() + .iterator() + .next() + .getHeaders() + .get(HttpHeaderName.fromString("x-ms-client-request-id")) + .getValue()); + ExperimentMetric firstItem = response.iterator().next(); + Assertions.assertNotNull(firstItem); + // verify property "id" + Assertions.assertEquals("events_purchase_creditcard", firstItem.getId()); + // verify property "lifecycle" + Assertions.assertEquals(LifecycleStage.ACTIVE, firstItem.getLifecycle()); + // verify property "displayName" + Assertions.assertEquals("Number of purchases (credit card)", firstItem.getDisplayName()); + // verify property "description" + Assertions.assertEquals( + "The number of purchase transactions made with credit card. Refund transactions are excluded from this metric.", + firstItem.getDescription()); + // verify property "categories" + List firstItemCategories = firstItem.getCategories(); + Assertions.assertEquals("Monetization", firstItemCategories.iterator().next()); + // verify property "desiredDirection" + Assertions.assertEquals(DesiredDirection.INCREASE, firstItem.getDesiredDirection()); + // verify property "definition" + ExperimentMetricDefinition firstItemDefinition = firstItem.getDefinition(); + Assertions.assertNotNull(firstItemDefinition); + Assertions.assertEquals(ExperimentMetricType.EVENT_COUNT, firstItemDefinition.getType()); + // verify property "eTag" + Assertions.assertEquals("ckswkavwgassdlocwuzxz", firstItem.getETag()); + // verify property "lastModifiedAt" + Assertions.assertNotNull(firstItem.getLastModifiedAt()); + } +} diff --git a/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/test/java/com/azure/analytics/onlineexperimentation/generated/OnlineExperimentationClientTestBase.java b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/test/java/com/azure/analytics/onlineexperimentation/generated/OnlineExperimentationClientTestBase.java new file mode 100644 index 000000000000..7ce202e69d70 --- /dev/null +++ b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/test/java/com/azure/analytics/onlineexperimentation/generated/OnlineExperimentationClientTestBase.java @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.analytics.onlineexperimentation.generated; + +// The Java test files under 'generated' package are generated for your reference. +// If you wish to modify these files, please copy them out of the 'generated' package, and modify there. +// See https://aka.ms/azsdk/dpg/java/tests for guide on adding a test. + +import com.azure.analytics.onlineexperimentation.OnlineExperimentationClient; +import com.azure.analytics.onlineexperimentation.OnlineExperimentationClientBuilder; +import com.azure.core.http.policy.HttpLogDetailLevel; +import com.azure.core.http.policy.HttpLogOptions; +import com.azure.core.test.TestMode; +import com.azure.core.test.TestProxyTestBase; +import com.azure.core.test.utils.MockTokenCredential; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; + +class OnlineExperimentationClientTestBase extends TestProxyTestBase { + protected OnlineExperimentationClient onlineExperimentationClient; + + @Override + protected void beforeTest() { + OnlineExperimentationClientBuilder onlineExperimentationClientbuilder = new OnlineExperimentationClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .httpClient(getHttpClientOrUsePlayback(getHttpClients().findFirst().orElse(null))) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + onlineExperimentationClientbuilder.credential(new MockTokenCredential()); + } else if (getTestMode() == TestMode.RECORD) { + onlineExperimentationClientbuilder.addPolicy(interceptorManager.getRecordPolicy()) + .credential(new DefaultAzureCredentialBuilder().build()); + } else if (getTestMode() == TestMode.LIVE) { + onlineExperimentationClientbuilder.credential(new DefaultAzureCredentialBuilder().build()); + } + onlineExperimentationClient = onlineExperimentationClientbuilder.buildClient(); + + } +} diff --git a/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/test/java/com/azure/analytics/onlineexperimentation/generated/ValidateMetricTests.java b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/test/java/com/azure/analytics/onlineexperimentation/generated/ValidateMetricTests.java new file mode 100644 index 000000000000..f364bb28129b --- /dev/null +++ b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/test/java/com/azure/analytics/onlineexperimentation/generated/ValidateMetricTests.java @@ -0,0 +1,49 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.analytics.onlineexperimentation.generated; + +import com.azure.analytics.onlineexperimentation.models.AggregatedValue; +import com.azure.analytics.onlineexperimentation.models.AverageMetricDefinition; +import com.azure.analytics.onlineexperimentation.models.DesiredDirection; +import com.azure.analytics.onlineexperimentation.models.DiagnosticCode; +import com.azure.analytics.onlineexperimentation.models.DiagnosticDetail; +import com.azure.analytics.onlineexperimentation.models.ExperimentMetric; +import com.azure.analytics.onlineexperimentation.models.ExperimentMetricValidationResult; +import com.azure.analytics.onlineexperimentation.models.LifecycleStage; +import java.util.Arrays; +import java.util.List; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +@Disabled +public final class ValidateMetricTests extends OnlineExperimentationClientTestBase { + @Test + @Disabled + public void testValidateMetricTests() { + // method invocation + ExperimentMetricValidationResult response = onlineExperimentationClient.validateMetric(new ExperimentMetric() + .setLifecycle(LifecycleStage.ACTIVE) + .setDisplayName("Average revenue per purchase [USD]") + .setDescription( + "The average revenue per purchase transaction in USD. Refund transactions are excluded from this metric. The total revenue might increase while this metric decreases if the number of purchases increases.") + .setCategories(Arrays.asList("Monetization")) + .setDesiredDirection(DesiredDirection.INCREASE) + .setDefinition(new AverageMetricDefinition().setValue( + new AggregatedValue().setEventName("Transaction").setFilter("Revenue >").setEventProperty("Revenue")))); + + // response assertion + Assertions.assertNotNull(response); + // verify property "isValid" + Assertions.assertEquals(false, response.isValid()); + // verify property "diagnostics" + List responseDiagnostics = response.getDiagnostics(); + DiagnosticDetail responseDiagnosticsFirstItem = responseDiagnostics.iterator().next(); + Assertions.assertNotNull(responseDiagnosticsFirstItem); + Assertions.assertEquals("The filter condition 'Revenue >' is invalid", + responseDiagnosticsFirstItem.getMessage()); + Assertions.assertEquals(DiagnosticCode.INVALID_EVENT_CONDITION, responseDiagnosticsFirstItem.getCode()); + } +} diff --git a/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/tsp-location.yaml b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/tsp-location.yaml new file mode 100644 index 000000000000..260fc1d0af85 --- /dev/null +++ b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/onlineexperimentation/Azure.Analytics.OnlineExperimentation +commit: 4e1f5223f18c456141bfd3fdee2f1fec1c6e503b +repo: Azure/azure-rest-api-specs +additionalDirectories: diff --git a/sdk/onlineexperimentation/ci.yml b/sdk/onlineexperimentation/ci.yml new file mode 100644 index 000000000000..5b3034ee1284 --- /dev/null +++ b/sdk/onlineexperimentation/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/onlineexperimentation/ci.yml + - sdk/onlineexperimentation/azure-analytics-onlineexperimentation/ + exclude: + - sdk/onlineexperimentation/pom.xml + - sdk/onlineexperimentation/azure-analytics-onlineexperimentation/pom.xml + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/onlineexperimentation/ci.yml + - sdk/onlineexperimentation/azure-analytics-onlineexperimentation/ + exclude: + - sdk/onlineexperimentation/pom.xml + - sdk/onlineexperimentation/azure-analytics-onlineexperimentation/pom.xml + +parameters: + - name: release_azureanalyticsonlineexperimentation + displayName: azure-analytics-onlineexperimentation + type: boolean + default: true + +extends: + template: ../../eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: onlineexperimentation + Artifacts: + - name: azure-analytics-onlineexperimentation + groupId: com.azure + safeName: azureanalyticsonlineexperimentation + releaseInBatch: ${{ parameters.release_azureanalyticsonlineexperimentation }} diff --git a/sdk/onlineexperimentation/pom.xml b/sdk/onlineexperimentation/pom.xml new file mode 100644 index 000000000000..f4c909ec2b0e --- /dev/null +++ b/sdk/onlineexperimentation/pom.xml @@ -0,0 +1,15 @@ + + + 4.0.0 + com.azure + azure-onlineexperimentation-service + pom + 1.0.0 + + + azure-analytics-onlineexperimentation + +