diff --git a/sdk/cognitiveservices/azure-cognitiveservices-AnomalyDetector/CHANGELOG.md b/sdk/cognitiveservices/azure-cognitiveservices-AnomalyDetector/CHANGELOG.md new file mode 100644 index 000000000000..5350cdc0924f --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-AnomalyDetector/CHANGELOG.md @@ -0,0 +1,13 @@ +# Release History + +## 1.0.0-beta.1 (Unreleased) + +- Azure AnomalyDetectorClient client library for Java. This package contains Microsoft Azure AnomalyDetectorClient client library. + +### Features Added + +### Breaking Changes + +### Bugs Fixed + +### Other Changes diff --git a/sdk/cognitiveservices/azure-cognitiveservices-AnomalyDetector/README.md b/sdk/cognitiveservices/azure-cognitiveservices-AnomalyDetector/README.md new file mode 100644 index 000000000000..4d4fd6a2839c --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-AnomalyDetector/README.md @@ -0,0 +1,63 @@ +# Azure AnomalyDetectorClient client library for Java + +Azure AnomalyDetectorClient client library for Java. + +This package contains Microsoft Azure AnomalyDetectorClient 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-cognitiveservices-AnomalyDetector;current}) +```xml + + com.azure + azure-cognitiveservices-AnomalyDetector + 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.cognitiveservices.anomalydetector.readme +``` + +## Troubleshooting + +## Next steps + +## Contributing + +For details on contributing to this repository, see the [contributing guide](https://github.com/Azure/azure-sdk-for-java/blob/main/CONTRIBUTING.md). + +1. Fork it +1. Create your feature branch (`git checkout -b my-new-feature`) +1. Commit your changes (`git commit -am 'Add some feature'`) +1. Push to the branch (`git push origin my-new-feature`) +1. Create new Pull Request + + +[product_documentation]: https://azure.microsoft.com/services/ +[docs]: https://azure.github.io/azure-sdk-for-java/ +[jdk]: https://docs.microsoft.com/java/azure/jdk/ +[azure_subscription]: https://azure.microsoft.com/free/ +[azure_identity]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/identity/azure-identity diff --git a/sdk/cognitiveservices/azure-cognitiveservices-AnomalyDetector/pom.xml b/sdk/cognitiveservices/azure-cognitiveservices-AnomalyDetector/pom.xml new file mode 100644 index 000000000000..bf24e6654fa8 --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-AnomalyDetector/pom.xml @@ -0,0 +1,73 @@ + + 4.0.0 + + com.azure + azure-client-sdk-parent + 1.7.0 + ../../parents/azure-client-sdk-parent + + + com.azure + azure-cognitiveservices-AnomalyDetector + 1.0.0-beta.1 + jar + + Microsoft Azure SDK for AnomalyDetectorClient Management + This package contains Microsoft Azure AnomalyDetectorClient client library. + https://github.com/Azure/azure-sdk-for-java + + + + The MIT License (MIT) + http://opensource.org/licenses/MIT + repo + + + + + https://github.com/Azure/azure-sdk-for-java + scm:git:git@github.com:Azure/azure-sdk-for-java.git + scm:git:git@github.com:Azure/azure-sdk-for-java.git + HEAD + + + + microsoft + Microsoft + + + + UTF-8 + true + + + + com.azure + azure-core + 1.24.1 + + + com.azure + azure-core-http-netty + 1.11.6 + + + org.junit.jupiter + junit-jupiter-engine + 5.8.2 + test + + + com.azure + azure-core-test + 1.7.7 + test + + + com.azure + azure-identity + 1.4.3 + test + + + diff --git a/sdk/cognitiveservices/azure-cognitiveservices-AnomalyDetector/src/main/java/com/azure/cognitiveservices/anomalydetector/AnomalyDetectorAsyncClient.java b/sdk/cognitiveservices/azure-cognitiveservices-AnomalyDetector/src/main/java/com/azure/cognitiveservices/anomalydetector/AnomalyDetectorAsyncClient.java new file mode 100644 index 000000000000..37173789ef5b --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-AnomalyDetector/src/main/java/com/azure/cognitiveservices/anomalydetector/AnomalyDetectorAsyncClient.java @@ -0,0 +1,199 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.cognitiveservices.anomalydetector; + +import com.azure.cognitiveservices.anomalydetector.implementation.AnomalyDetectorClientImpl; +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.HttpResponseException; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; +import reactor.core.publisher.Mono; + +/** Initializes a new instance of the asynchronous AnomalyDetectorClient type. */ +@ServiceClient(builder = AnomalyDetectorClientBuilder.class, isAsync = true) +public final class AnomalyDetectorAsyncClient { + @Generated private final AnomalyDetectorClientImpl serviceClient; + + /** + * Initializes an instance of AnomalyDetectorClient client. + * + * @param serviceClient the service client implementation. + */ + @Generated + AnomalyDetectorAsyncClient(AnomalyDetectorClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * This operation generates a model with an entire series, each point is detected with the same model. With this + * method, points before and after a certain point are used to determine whether it is an anomaly. The entire + * detection can give user an overall status of the time series. + * + *

Request Body Schema + * + *

{@code
+     * {
+     *     series: [
+     *         {
+     *             timestamp: String
+     *             value: float
+     *         }
+     *     ]
+     *     granularity: String(yearly/monthly/weekly/daily/hourly/minutely/secondly/microsecond/none)
+     *     customInterval: Integer
+     *     period: Integer
+     *     maxAnomalyRatio: Float
+     *     sensitivity: Integer
+     *     imputeMode: String(auto/previous/linear/fixed/zero/notFill)
+     *     imputeFixedValue: Float
+     * }
+     * }
+ * + *

Response Body Schema + * + *

{@code
+     * {
+     *     period: int
+     *     expectedValues: [
+     *         float
+     *     ]
+     *     upperMargins: [
+     *         float
+     *     ]
+     *     lowerMargins: [
+     *         float
+     *     ]
+     *     isAnomaly: [
+     *         boolean
+     *     ]
+     *     isNegativeAnomaly: [
+     *         boolean
+     *     ]
+     *     isPositiveAnomaly: [
+     *         boolean
+     *     ]
+     *     severity: [
+     *         float
+     *     ]
+     * }
+     * }
+ * + * @param body Time series points and period if needed. Advanced model parameters can also be set in the request. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @return the response of entire anomaly detection along with {@link Response} on successful completion of {@link + * Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> detectEntireSeriesWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.detectEntireSeriesWithResponseAsync(body, requestOptions); + } + + /** + * This operation generates a model using points before the latest one. With this method, only historical points are + * used to determine whether the target point is an anomaly. The latest point detecting operation matches the + * scenario of real-time monitoring of business metrics. + * + *

Request Body Schema + * + *

{@code
+     * {
+     *     series: [
+     *         {
+     *             timestamp: String
+     *             value: float
+     *         }
+     *     ]
+     *     granularity: String(yearly/monthly/weekly/daily/hourly/minutely/secondly/microsecond/none)
+     *     customInterval: Integer
+     *     period: Integer
+     *     maxAnomalyRatio: Float
+     *     sensitivity: Integer
+     *     imputeMode: String(auto/previous/linear/fixed/zero/notFill)
+     *     imputeFixedValue: Float
+     * }
+     * }
+ * + *

Response Body Schema + * + *

{@code
+     * {
+     *     period: int
+     *     suggestedWindow: int
+     *     expectedValue: float
+     *     upperMargin: float
+     *     lowerMargin: float
+     *     isAnomaly: boolean
+     *     isNegativeAnomaly: boolean
+     *     isPositiveAnomaly: boolean
+     *     severity: Float
+     * }
+     * }
+ * + * @param body Time series points and period if needed. Advanced model parameters can also be set in the request. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @return the response of last anomaly detection along with {@link Response} on successful completion of {@link + * Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> detectLastPointWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.detectLastPointWithResponseAsync(body, requestOptions); + } + + /** + * Evaluate change point score of every series point. + * + *

Request Body Schema + * + *

{@code
+     * {
+     *     series: [
+     *         {
+     *             timestamp: String
+     *             value: float
+     *         }
+     *     ]
+     *     granularity: String(yearly/monthly/weekly/daily/hourly/minutely/secondly/microsecond/none)
+     *     customInterval: Integer
+     *     period: Integer
+     *     stableTrendWindow: Integer
+     *     threshold: Float
+     * }
+     * }
+ * + *

Response Body Schema + * + *

{@code
+     * {
+     *     period: Integer
+     *     isChangePoint: [
+     *         boolean
+     *     ]
+     *     confidenceScores: [
+     *         float
+     *     ]
+     * }
+     * }
+ * + * @param body Time series points and granularity is needed. Advanced model parameters can also be set in the + * request if needed. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @return the response of change point detection along with {@link Response} on successful completion of {@link + * Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> detectChangePointWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.detectChangePointWithResponseAsync(body, requestOptions); + } +} diff --git a/sdk/cognitiveservices/azure-cognitiveservices-AnomalyDetector/src/main/java/com/azure/cognitiveservices/anomalydetector/AnomalyDetectorClient.java b/sdk/cognitiveservices/azure-cognitiveservices-AnomalyDetector/src/main/java/com/azure/cognitiveservices/anomalydetector/AnomalyDetectorClient.java new file mode 100644 index 000000000000..a1b73172c2b7 --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-AnomalyDetector/src/main/java/com/azure/cognitiveservices/anomalydetector/AnomalyDetectorClient.java @@ -0,0 +1,195 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.cognitiveservices.anomalydetector; + +import com.azure.cognitiveservices.anomalydetector.implementation.AnomalyDetectorClientImpl; +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.HttpResponseException; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; + +/** Initializes a new instance of the synchronous AnomalyDetectorClient type. */ +@ServiceClient(builder = AnomalyDetectorClientBuilder.class) +public final class AnomalyDetectorClient { + @Generated private final AnomalyDetectorClientImpl serviceClient; + + /** + * Initializes an instance of AnomalyDetectorClient client. + * + * @param serviceClient the service client implementation. + */ + @Generated + AnomalyDetectorClient(AnomalyDetectorClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * This operation generates a model with an entire series, each point is detected with the same model. With this + * method, points before and after a certain point are used to determine whether it is an anomaly. The entire + * detection can give user an overall status of the time series. + * + *

Request Body Schema + * + *

{@code
+     * {
+     *     series: [
+     *         {
+     *             timestamp: String
+     *             value: float
+     *         }
+     *     ]
+     *     granularity: String(yearly/monthly/weekly/daily/hourly/minutely/secondly/microsecond/none)
+     *     customInterval: Integer
+     *     period: Integer
+     *     maxAnomalyRatio: Float
+     *     sensitivity: Integer
+     *     imputeMode: String(auto/previous/linear/fixed/zero/notFill)
+     *     imputeFixedValue: Float
+     * }
+     * }
+ * + *

Response Body Schema + * + *

{@code
+     * {
+     *     period: int
+     *     expectedValues: [
+     *         float
+     *     ]
+     *     upperMargins: [
+     *         float
+     *     ]
+     *     lowerMargins: [
+     *         float
+     *     ]
+     *     isAnomaly: [
+     *         boolean
+     *     ]
+     *     isNegativeAnomaly: [
+     *         boolean
+     *     ]
+     *     isPositiveAnomaly: [
+     *         boolean
+     *     ]
+     *     severity: [
+     *         float
+     *     ]
+     * }
+     * }
+ * + * @param body Time series points and period if needed. Advanced model parameters can also be set in the request. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @return the response of entire anomaly detection along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response detectEntireSeriesWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.detectEntireSeriesWithResponse(body, requestOptions); + } + + /** + * This operation generates a model using points before the latest one. With this method, only historical points are + * used to determine whether the target point is an anomaly. The latest point detecting operation matches the + * scenario of real-time monitoring of business metrics. + * + *

Request Body Schema + * + *

{@code
+     * {
+     *     series: [
+     *         {
+     *             timestamp: String
+     *             value: float
+     *         }
+     *     ]
+     *     granularity: String(yearly/monthly/weekly/daily/hourly/minutely/secondly/microsecond/none)
+     *     customInterval: Integer
+     *     period: Integer
+     *     maxAnomalyRatio: Float
+     *     sensitivity: Integer
+     *     imputeMode: String(auto/previous/linear/fixed/zero/notFill)
+     *     imputeFixedValue: Float
+     * }
+     * }
+ * + *

Response Body Schema + * + *

{@code
+     * {
+     *     period: int
+     *     suggestedWindow: int
+     *     expectedValue: float
+     *     upperMargin: float
+     *     lowerMargin: float
+     *     isAnomaly: boolean
+     *     isNegativeAnomaly: boolean
+     *     isPositiveAnomaly: boolean
+     *     severity: Float
+     * }
+     * }
+ * + * @param body Time series points and period if needed. Advanced model parameters can also be set in the request. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @return the response of last anomaly detection along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response detectLastPointWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.detectLastPointWithResponse(body, requestOptions); + } + + /** + * Evaluate change point score of every series point. + * + *

Request Body Schema + * + *

{@code
+     * {
+     *     series: [
+     *         {
+     *             timestamp: String
+     *             value: float
+     *         }
+     *     ]
+     *     granularity: String(yearly/monthly/weekly/daily/hourly/minutely/secondly/microsecond/none)
+     *     customInterval: Integer
+     *     period: Integer
+     *     stableTrendWindow: Integer
+     *     threshold: Float
+     * }
+     * }
+ * + *

Response Body Schema + * + *

{@code
+     * {
+     *     period: Integer
+     *     isChangePoint: [
+     *         boolean
+     *     ]
+     *     confidenceScores: [
+     *         float
+     *     ]
+     * }
+     * }
+ * + * @param body Time series points and granularity is needed. Advanced model parameters can also be set in the + * request if needed. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @return the response of change point detection along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response detectChangePointWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.detectChangePointWithResponse(body, requestOptions); + } +} diff --git a/sdk/cognitiveservices/azure-cognitiveservices-AnomalyDetector/src/main/java/com/azure/cognitiveservices/anomalydetector/AnomalyDetectorClientBuilder.java b/sdk/cognitiveservices/azure-cognitiveservices-AnomalyDetector/src/main/java/com/azure/cognitiveservices/anomalydetector/AnomalyDetectorClientBuilder.java new file mode 100644 index 000000000000..96f7222baac0 --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-AnomalyDetector/src/main/java/com/azure/cognitiveservices/anomalydetector/AnomalyDetectorClientBuilder.java @@ -0,0 +1,311 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.cognitiveservices.anomalydetector; + +import com.azure.cognitiveservices.anomalydetector.implementation.AnomalyDetectorClientImpl; +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.ServiceClientBuilder; +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.AddHeadersPolicy; +import com.azure.core.http.policy.BearerTokenAuthenticationPolicy; +import com.azure.core.http.policy.CookiePolicy; +import com.azure.core.http.policy.HttpLogOptions; +import com.azure.core.http.policy.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpPipelinePolicy; +import com.azure.core.http.policy.HttpPolicyProviders; +import com.azure.core.http.policy.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.serializer.JacksonAdapter; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** A builder for creating a new instance of the AnomalyDetectorClient type. */ +@ServiceClientBuilder(serviceClients = {AnomalyDetectorClient.class, AnomalyDetectorAsyncClient.class}) +public final class AnomalyDetectorClientBuilder { + @Generated private static final String SDK_NAME = "name"; + + @Generated private static final String SDK_VERSION = "version"; + + @Generated static final String[] DEFAULT_SCOPES = new String[] {"https://cognitiveservices.azure.com/.default"}; + + @Generated + private final Map properties = + CoreUtils.getProperties("azure-cognitiveservices-AnomalyDetector.properties"); + + /** Create an instance of the AnomalyDetectorClientBuilder. */ + @Generated + public AnomalyDetectorClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * Supported Cognitive Services endpoints (protocol and hostname, for + * example: https://westus2.api.cognitive.microsoft.com). + */ + @Generated private String endpoint; + + /** + * Sets Supported Cognitive Services endpoints (protocol and hostname, for example: + * https://westus2.api.cognitive.microsoft.com). + * + * @param endpoint the endpoint value. + * @return the AnomalyDetectorClientBuilder. + */ + @Generated + public AnomalyDetectorClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * Service version + */ + @Generated private AnomalyDetectorServiceVersion serviceVersion; + + /** + * Sets Service version. + * + * @param serviceVersion the serviceVersion value. + * @return the AnomalyDetectorClientBuilder. + */ + @Generated + public AnomalyDetectorClientBuilder serviceVersion(AnomalyDetectorServiceVersion serviceVersion) { + this.serviceVersion = serviceVersion; + return this; + } + + /* + * The HTTP pipeline to send requests through + */ + @Generated private HttpPipeline pipeline; + + /** + * Sets The HTTP pipeline to send requests through. + * + * @param pipeline the pipeline value. + * @return the AnomalyDetectorClientBuilder. + */ + @Generated + public AnomalyDetectorClientBuilder pipeline(HttpPipeline pipeline) { + this.pipeline = pipeline; + return this; + } + + /* + * The HTTP client used to send the request. + */ + @Generated private HttpClient httpClient; + + /** + * Sets The HTTP client used to send the request. + * + * @param httpClient the httpClient value. + * @return the AnomalyDetectorClientBuilder. + */ + @Generated + public AnomalyDetectorClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The configuration store that is used during construction of the service + * client. + */ + @Generated private Configuration configuration; + + /** + * Sets The configuration store that is used during construction of the service client. + * + * @param configuration the configuration value. + * @return the AnomalyDetectorClientBuilder. + */ + @Generated + public AnomalyDetectorClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The TokenCredential used for authentication. + */ + @Generated private TokenCredential tokenCredential; + + /** + * Sets The TokenCredential used for authentication. + * + * @param tokenCredential the tokenCredential value. + * @return the AnomalyDetectorClientBuilder. + */ + @Generated + public AnomalyDetectorClientBuilder credential(TokenCredential tokenCredential) { + this.tokenCredential = tokenCredential; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated private HttpLogOptions httpLogOptions; + + /** + * Sets The logging configuration for HTTP requests and responses. + * + * @param httpLogOptions the httpLogOptions value. + * @return the AnomalyDetectorClientBuilder. + */ + @Generated + public AnomalyDetectorClientBuilder httpLogOptions(HttpLogOptions httpLogOptions) { + this.httpLogOptions = httpLogOptions; + 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 AnomalyDetectorClientBuilder. + */ + @Generated + public AnomalyDetectorClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /* + * The list of Http pipeline policies to add. + */ + @Generated private final List pipelinePolicies; + + /* + * The client options such as application ID and custom headers to set on a + * request. + */ + @Generated private ClientOptions clientOptions; + + /** + * Sets The client options such as application ID and custom headers to set on a request. + * + * @param clientOptions the clientOptions value. + * @return the AnomalyDetectorClientBuilder. + */ + @Generated + public AnomalyDetectorClientBuilder clientOptions(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + return this; + } + + /** + * Adds a custom Http pipeline policy. + * + * @param customPolicy The custom Http pipeline policy to add. + * @return the AnomalyDetectorClientBuilder. + */ + @Generated + public AnomalyDetectorClientBuilder addPolicy(HttpPipelinePolicy customPolicy) { + pipelinePolicies.add(customPolicy); + return this; + } + + /** + * Builds an instance of AnomalyDetectorClientImpl with the provided parameters. + * + * @return an instance of AnomalyDetectorClientImpl. + */ + @Generated + private AnomalyDetectorClientImpl buildInnerClient() { + if (serviceVersion == null) { + this.serviceVersion = AnomalyDetectorServiceVersion.getLatest(); + } + if (pipeline == null) { + this.pipeline = createHttpPipeline(); + } + AnomalyDetectorClientImpl client = + new AnomalyDetectorClientImpl( + pipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); + return client; + } + + @Generated + private HttpPipeline createHttpPipeline() { + Configuration buildConfiguration = + (configuration == null) ? Configuration.getGlobalConfiguration() : configuration; + if (httpLogOptions == null) { + httpLogOptions = new HttpLogOptions(); + } + if (clientOptions == null) { + clientOptions = new ClientOptions(); + } + List policies = new ArrayList<>(); + String clientName = properties.getOrDefault(SDK_NAME, "UnknownName"); + String clientVersion = properties.getOrDefault(SDK_VERSION, "UnknownVersion"); + String applicationId = CoreUtils.getApplicationId(clientOptions, httpLogOptions); + policies.add(new UserAgentPolicy(applicationId, clientName, clientVersion, buildConfiguration)); + HttpHeaders headers = new HttpHeaders(); + clientOptions.getHeaders().forEach(header -> headers.set(header.getName(), header.getValue())); + if (headers.getSize() > 0) { + policies.add(new AddHeadersPolicy(headers)); + } + policies.addAll( + this.pipelinePolicies.stream() + .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_CALL) + .collect(Collectors.toList())); + HttpPolicyProviders.addBeforeRetryPolicies(policies); + policies.add(retryPolicy == null ? new RetryPolicy() : retryPolicy); + policies.add(new CookiePolicy()); + if (tokenCredential != null) { + policies.add(new BearerTokenAuthenticationPolicy(tokenCredential, DEFAULT_SCOPES)); + } + policies.addAll( + this.pipelinePolicies.stream() + .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_RETRY) + .collect(Collectors.toList())); + HttpPolicyProviders.addAfterRetryPolicies(policies); + policies.add(new HttpLoggingPolicy(httpLogOptions)); + HttpPipeline httpPipeline = + new HttpPipelineBuilder() + .policies(policies.toArray(new HttpPipelinePolicy[0])) + .httpClient(httpClient) + .clientOptions(clientOptions) + .build(); + return httpPipeline; + } + + /** + * Builds an instance of AnomalyDetectorAsyncClient async client. + * + * @return an instance of AnomalyDetectorAsyncClient. + */ + @Generated + public AnomalyDetectorAsyncClient buildAsyncClient() { + return new AnomalyDetectorAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of AnomalyDetectorClient sync client. + * + * @return an instance of AnomalyDetectorClient. + */ + @Generated + public AnomalyDetectorClient buildClient() { + return new AnomalyDetectorClient(buildInnerClient()); + } +} diff --git a/sdk/cognitiveservices/azure-cognitiveservices-AnomalyDetector/src/main/java/com/azure/cognitiveservices/anomalydetector/AnomalyDetectorServiceVersion.java b/sdk/cognitiveservices/azure-cognitiveservices-AnomalyDetector/src/main/java/com/azure/cognitiveservices/anomalydetector/AnomalyDetectorServiceVersion.java new file mode 100644 index 000000000000..d4c1336f0511 --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-AnomalyDetector/src/main/java/com/azure/cognitiveservices/anomalydetector/AnomalyDetectorServiceVersion.java @@ -0,0 +1,33 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.cognitiveservices.anomalydetector; + +import com.azure.core.util.ServiceVersion; + +/** Service version of AnomalyDetectorClient. */ +public enum AnomalyDetectorServiceVersion implements ServiceVersion { + /** Enum value 1.1-preview.1. */ + V1_1_PREVIEW_1("1.1-preview.1"); + + private final String version; + + AnomalyDetectorServiceVersion(String version) { + this.version = version; + } + + @Override + public String getVersion() { + return this.version; + } + + /** + * Gets the latest service version supported by this client library. + * + * @return The latest {@link AnomalyDetectorServiceVersion}. + */ + public static AnomalyDetectorServiceVersion getLatest() { + return V1_1_PREVIEW_1; + } +} diff --git a/sdk/cognitiveservices/azure-cognitiveservices-AnomalyDetector/src/main/java/com/azure/cognitiveservices/anomalydetector/implementation/AnomalyDetectorClientImpl.java b/sdk/cognitiveservices/azure-cognitiveservices-AnomalyDetector/src/main/java/com/azure/cognitiveservices/anomalydetector/implementation/AnomalyDetectorClientImpl.java new file mode 100644 index 000000000000..79be331c85ba --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-AnomalyDetector/src/main/java/com/azure/cognitiveservices/anomalydetector/implementation/AnomalyDetectorClientImpl.java @@ -0,0 +1,696 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.cognitiveservices.anomalydetector.implementation; + +import com.azure.cognitiveservices.anomalydetector.AnomalyDetectorServiceVersion; +import com.azure.core.annotation.BodyParam; +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Post; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpPipelineBuilder; +import com.azure.core.http.policy.CookiePolicy; +import com.azure.core.http.policy.RetryPolicy; +import com.azure.core.http.policy.UserAgentPolicy; +import com.azure.core.http.rest.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.serializer.JacksonAdapter; +import com.azure.core.util.serializer.SerializerAdapter; +import reactor.core.publisher.Mono; + +/** Initializes a new instance of the AnomalyDetectorClient type. */ +public final class AnomalyDetectorClientImpl { + /** The proxy service used to perform REST calls. */ + private final AnomalyDetectorClientService service; + + /** + * Supported Cognitive Services endpoints (protocol and hostname, for example: + * https://westus2.api.cognitive.microsoft.com). + */ + private final String endpoint; + + /** + * Gets Supported Cognitive Services endpoints (protocol and hostname, for example: + * https://westus2.api.cognitive.microsoft.com). + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** Service version. */ + private final AnomalyDetectorServiceVersion serviceVersion; + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public AnomalyDetectorServiceVersion 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 AnomalyDetectorClient client. + * + * @param endpoint Supported Cognitive Services endpoints (protocol and hostname, for example: + * https://westus2.api.cognitive.microsoft.com). + * @param serviceVersion Service version. + */ + public AnomalyDetectorClientImpl(String endpoint, AnomalyDetectorServiceVersion serviceVersion) { + this( + new HttpPipelineBuilder() + .policies(new UserAgentPolicy(), new RetryPolicy(), new CookiePolicy()) + .build(), + JacksonAdapter.createDefaultSerializerAdapter(), + endpoint, + serviceVersion); + } + + /** + * Initializes an instance of AnomalyDetectorClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Supported Cognitive Services endpoints (protocol and hostname, for example: + * https://westus2.api.cognitive.microsoft.com). + * @param serviceVersion Service version. + */ + public AnomalyDetectorClientImpl( + HttpPipeline httpPipeline, String endpoint, AnomalyDetectorServiceVersion serviceVersion) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); + } + + /** + * Initializes an instance of AnomalyDetectorClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param serializerAdapter The serializer to serialize an object into a string. + * @param endpoint Supported Cognitive Services endpoints (protocol and hostname, for example: + * https://westus2.api.cognitive.microsoft.com). + * @param serviceVersion Service version. + */ + public AnomalyDetectorClientImpl( + HttpPipeline httpPipeline, + SerializerAdapter serializerAdapter, + String endpoint, + AnomalyDetectorServiceVersion serviceVersion) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.serviceVersion = serviceVersion; + this.service = + RestProxy.create(AnomalyDetectorClientService.class, this.httpPipeline, this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for AnomalyDetectorClient to be used by the proxy service to perform REST + * calls. + */ + @Host("{Endpoint}/anomalydetector/{ApiVersion}") + @ServiceInterface(name = "AnomalyDetectorClien") + private interface AnomalyDetectorClientService { + @Post("/timeseries/entire/detect") + @ExpectedResponses({200}) + Mono> detectEntireSeries( + @HostParam("Endpoint") String endpoint, + @HostParam("ApiVersion") String apiVersion, + @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, + Context context); + + @Post("/timeseries/last/detect") + @ExpectedResponses({200}) + Mono> detectLastPoint( + @HostParam("Endpoint") String endpoint, + @HostParam("ApiVersion") String apiVersion, + @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, + Context context); + + @Post("/timeseries/changepoint/detect") + @ExpectedResponses({200}) + Mono> detectChangePoint( + @HostParam("Endpoint") String endpoint, + @HostParam("ApiVersion") String apiVersion, + @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, + Context context); + } + + /** + * This operation generates a model with an entire series, each point is detected with the same model. With this + * method, points before and after a certain point are used to determine whether it is an anomaly. The entire + * detection can give user an overall status of the time series. + * + *

Request Body Schema + * + *

{@code
+     * {
+     *     series: [
+     *         {
+     *             timestamp: String
+     *             value: float
+     *         }
+     *     ]
+     *     granularity: String(yearly/monthly/weekly/daily/hourly/minutely/secondly/microsecond/none)
+     *     customInterval: Integer
+     *     period: Integer
+     *     maxAnomalyRatio: Float
+     *     sensitivity: Integer
+     *     imputeMode: String(auto/previous/linear/fixed/zero/notFill)
+     *     imputeFixedValue: Float
+     * }
+     * }
+ * + *

Response Body Schema + * + *

{@code
+     * {
+     *     period: int
+     *     expectedValues: [
+     *         float
+     *     ]
+     *     upperMargins: [
+     *         float
+     *     ]
+     *     lowerMargins: [
+     *         float
+     *     ]
+     *     isAnomaly: [
+     *         boolean
+     *     ]
+     *     isNegativeAnomaly: [
+     *         boolean
+     *     ]
+     *     isPositiveAnomaly: [
+     *         boolean
+     *     ]
+     *     severity: [
+     *         float
+     *     ]
+     * }
+     * }
+ * + * @param body Time series points and period if needed. Advanced model parameters can also be set in the request. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @return the response of entire anomaly detection along with {@link Response} on successful completion of {@link + * Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> detectEntireSeriesWithResponseAsync( + BinaryData body, RequestOptions requestOptions) { + return FluxUtil.withContext( + context -> + service.detectEntireSeries( + this.getEndpoint(), + this.getServiceVersion().getVersion(), + body, + requestOptions, + context)); + } + + /** + * This operation generates a model with an entire series, each point is detected with the same model. With this + * method, points before and after a certain point are used to determine whether it is an anomaly. The entire + * detection can give user an overall status of the time series. + * + *

Request Body Schema + * + *

{@code
+     * {
+     *     series: [
+     *         {
+     *             timestamp: String
+     *             value: float
+     *         }
+     *     ]
+     *     granularity: String(yearly/monthly/weekly/daily/hourly/minutely/secondly/microsecond/none)
+     *     customInterval: Integer
+     *     period: Integer
+     *     maxAnomalyRatio: Float
+     *     sensitivity: Integer
+     *     imputeMode: String(auto/previous/linear/fixed/zero/notFill)
+     *     imputeFixedValue: Float
+     * }
+     * }
+ * + *

Response Body Schema + * + *

{@code
+     * {
+     *     period: int
+     *     expectedValues: [
+     *         float
+     *     ]
+     *     upperMargins: [
+     *         float
+     *     ]
+     *     lowerMargins: [
+     *         float
+     *     ]
+     *     isAnomaly: [
+     *         boolean
+     *     ]
+     *     isNegativeAnomaly: [
+     *         boolean
+     *     ]
+     *     isPositiveAnomaly: [
+     *         boolean
+     *     ]
+     *     severity: [
+     *         float
+     *     ]
+     * }
+     * }
+ * + * @param body Time series points and period if needed. Advanced model parameters can also be set in the request. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @param context The context to associate with this operation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @return the response of entire anomaly detection along with {@link Response} on successful completion of {@link + * Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> detectEntireSeriesWithResponseAsync( + BinaryData body, RequestOptions requestOptions, Context context) { + return service.detectEntireSeries( + this.getEndpoint(), this.getServiceVersion().getVersion(), body, requestOptions, context); + } + + /** + * This operation generates a model with an entire series, each point is detected with the same model. With this + * method, points before and after a certain point are used to determine whether it is an anomaly. The entire + * detection can give user an overall status of the time series. + * + *

Request Body Schema + * + *

{@code
+     * {
+     *     series: [
+     *         {
+     *             timestamp: String
+     *             value: float
+     *         }
+     *     ]
+     *     granularity: String(yearly/monthly/weekly/daily/hourly/minutely/secondly/microsecond/none)
+     *     customInterval: Integer
+     *     period: Integer
+     *     maxAnomalyRatio: Float
+     *     sensitivity: Integer
+     *     imputeMode: String(auto/previous/linear/fixed/zero/notFill)
+     *     imputeFixedValue: Float
+     * }
+     * }
+ * + *

Response Body Schema + * + *

{@code
+     * {
+     *     period: int
+     *     expectedValues: [
+     *         float
+     *     ]
+     *     upperMargins: [
+     *         float
+     *     ]
+     *     lowerMargins: [
+     *         float
+     *     ]
+     *     isAnomaly: [
+     *         boolean
+     *     ]
+     *     isNegativeAnomaly: [
+     *         boolean
+     *     ]
+     *     isPositiveAnomaly: [
+     *         boolean
+     *     ]
+     *     severity: [
+     *         float
+     *     ]
+     * }
+     * }
+ * + * @param body Time series points and period if needed. Advanced model parameters can also be set in the request. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @return the response of entire anomaly detection along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response detectEntireSeriesWithResponse(BinaryData body, RequestOptions requestOptions) { + return detectEntireSeriesWithResponseAsync(body, requestOptions).block(); + } + + /** + * This operation generates a model using points before the latest one. With this method, only historical points are + * used to determine whether the target point is an anomaly. The latest point detecting operation matches the + * scenario of real-time monitoring of business metrics. + * + *

Request Body Schema + * + *

{@code
+     * {
+     *     series: [
+     *         {
+     *             timestamp: String
+     *             value: float
+     *         }
+     *     ]
+     *     granularity: String(yearly/monthly/weekly/daily/hourly/minutely/secondly/microsecond/none)
+     *     customInterval: Integer
+     *     period: Integer
+     *     maxAnomalyRatio: Float
+     *     sensitivity: Integer
+     *     imputeMode: String(auto/previous/linear/fixed/zero/notFill)
+     *     imputeFixedValue: Float
+     * }
+     * }
+ * + *

Response Body Schema + * + *

{@code
+     * {
+     *     period: int
+     *     suggestedWindow: int
+     *     expectedValue: float
+     *     upperMargin: float
+     *     lowerMargin: float
+     *     isAnomaly: boolean
+     *     isNegativeAnomaly: boolean
+     *     isPositiveAnomaly: boolean
+     *     severity: Float
+     * }
+     * }
+ * + * @param body Time series points and period if needed. Advanced model parameters can also be set in the request. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @return the response of last anomaly detection along with {@link Response} on successful completion of {@link + * Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> detectLastPointWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + return FluxUtil.withContext( + context -> + service.detectLastPoint( + this.getEndpoint(), + this.getServiceVersion().getVersion(), + body, + requestOptions, + context)); + } + + /** + * This operation generates a model using points before the latest one. With this method, only historical points are + * used to determine whether the target point is an anomaly. The latest point detecting operation matches the + * scenario of real-time monitoring of business metrics. + * + *

Request Body Schema + * + *

{@code
+     * {
+     *     series: [
+     *         {
+     *             timestamp: String
+     *             value: float
+     *         }
+     *     ]
+     *     granularity: String(yearly/monthly/weekly/daily/hourly/minutely/secondly/microsecond/none)
+     *     customInterval: Integer
+     *     period: Integer
+     *     maxAnomalyRatio: Float
+     *     sensitivity: Integer
+     *     imputeMode: String(auto/previous/linear/fixed/zero/notFill)
+     *     imputeFixedValue: Float
+     * }
+     * }
+ * + *

Response Body Schema + * + *

{@code
+     * {
+     *     period: int
+     *     suggestedWindow: int
+     *     expectedValue: float
+     *     upperMargin: float
+     *     lowerMargin: float
+     *     isAnomaly: boolean
+     *     isNegativeAnomaly: boolean
+     *     isPositiveAnomaly: boolean
+     *     severity: Float
+     * }
+     * }
+ * + * @param body Time series points and period if needed. Advanced model parameters can also be set in the request. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @param context The context to associate with this operation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @return the response of last anomaly detection along with {@link Response} on successful completion of {@link + * Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> detectLastPointWithResponseAsync( + BinaryData body, RequestOptions requestOptions, Context context) { + return service.detectLastPoint( + this.getEndpoint(), this.getServiceVersion().getVersion(), body, requestOptions, context); + } + + /** + * This operation generates a model using points before the latest one. With this method, only historical points are + * used to determine whether the target point is an anomaly. The latest point detecting operation matches the + * scenario of real-time monitoring of business metrics. + * + *

Request Body Schema + * + *

{@code
+     * {
+     *     series: [
+     *         {
+     *             timestamp: String
+     *             value: float
+     *         }
+     *     ]
+     *     granularity: String(yearly/monthly/weekly/daily/hourly/minutely/secondly/microsecond/none)
+     *     customInterval: Integer
+     *     period: Integer
+     *     maxAnomalyRatio: Float
+     *     sensitivity: Integer
+     *     imputeMode: String(auto/previous/linear/fixed/zero/notFill)
+     *     imputeFixedValue: Float
+     * }
+     * }
+ * + *

Response Body Schema + * + *

{@code
+     * {
+     *     period: int
+     *     suggestedWindow: int
+     *     expectedValue: float
+     *     upperMargin: float
+     *     lowerMargin: float
+     *     isAnomaly: boolean
+     *     isNegativeAnomaly: boolean
+     *     isPositiveAnomaly: boolean
+     *     severity: Float
+     * }
+     * }
+ * + * @param body Time series points and period if needed. Advanced model parameters can also be set in the request. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @return the response of last anomaly detection along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response detectLastPointWithResponse(BinaryData body, RequestOptions requestOptions) { + return detectLastPointWithResponseAsync(body, requestOptions).block(); + } + + /** + * Evaluate change point score of every series point. + * + *

Request Body Schema + * + *

{@code
+     * {
+     *     series: [
+     *         {
+     *             timestamp: String
+     *             value: float
+     *         }
+     *     ]
+     *     granularity: String(yearly/monthly/weekly/daily/hourly/minutely/secondly/microsecond/none)
+     *     customInterval: Integer
+     *     period: Integer
+     *     stableTrendWindow: Integer
+     *     threshold: Float
+     * }
+     * }
+ * + *

Response Body Schema + * + *

{@code
+     * {
+     *     period: Integer
+     *     isChangePoint: [
+     *         boolean
+     *     ]
+     *     confidenceScores: [
+     *         float
+     *     ]
+     * }
+     * }
+ * + * @param body Time series points and granularity is needed. Advanced model parameters can also be set in the + * request if needed. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @return the response of change point detection along with {@link Response} on successful completion of {@link + * Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> detectChangePointWithResponseAsync( + BinaryData body, RequestOptions requestOptions) { + return FluxUtil.withContext( + context -> + service.detectChangePoint( + this.getEndpoint(), + this.getServiceVersion().getVersion(), + body, + requestOptions, + context)); + } + + /** + * Evaluate change point score of every series point. + * + *

Request Body Schema + * + *

{@code
+     * {
+     *     series: [
+     *         {
+     *             timestamp: String
+     *             value: float
+     *         }
+     *     ]
+     *     granularity: String(yearly/monthly/weekly/daily/hourly/minutely/secondly/microsecond/none)
+     *     customInterval: Integer
+     *     period: Integer
+     *     stableTrendWindow: Integer
+     *     threshold: Float
+     * }
+     * }
+ * + *

Response Body Schema + * + *

{@code
+     * {
+     *     period: Integer
+     *     isChangePoint: [
+     *         boolean
+     *     ]
+     *     confidenceScores: [
+     *         float
+     *     ]
+     * }
+     * }
+ * + * @param body Time series points and granularity is needed. Advanced model parameters can also be set in the + * request if needed. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @param context The context to associate with this operation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @return the response of change point detection along with {@link Response} on successful completion of {@link + * Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> detectChangePointWithResponseAsync( + BinaryData body, RequestOptions requestOptions, Context context) { + return service.detectChangePoint( + this.getEndpoint(), this.getServiceVersion().getVersion(), body, requestOptions, context); + } + + /** + * Evaluate change point score of every series point. + * + *

Request Body Schema + * + *

{@code
+     * {
+     *     series: [
+     *         {
+     *             timestamp: String
+     *             value: float
+     *         }
+     *     ]
+     *     granularity: String(yearly/monthly/weekly/daily/hourly/minutely/secondly/microsecond/none)
+     *     customInterval: Integer
+     *     period: Integer
+     *     stableTrendWindow: Integer
+     *     threshold: Float
+     * }
+     * }
+ * + *

Response Body Schema + * + *

{@code
+     * {
+     *     period: Integer
+     *     isChangePoint: [
+     *         boolean
+     *     ]
+     *     confidenceScores: [
+     *         float
+     *     ]
+     * }
+     * }
+ * + * @param body Time series points and granularity is needed. Advanced model parameters can also be set in the + * request if needed. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @return the response of change point detection along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response detectChangePointWithResponse(BinaryData body, RequestOptions requestOptions) { + return detectChangePointWithResponseAsync(body, requestOptions).block(); + } +} diff --git a/sdk/cognitiveservices/azure-cognitiveservices-AnomalyDetector/src/main/java/com/azure/cognitiveservices/anomalydetector/package-info.java b/sdk/cognitiveservices/azure-cognitiveservices-AnomalyDetector/src/main/java/com/azure/cognitiveservices/anomalydetector/package-info.java new file mode 100644 index 000000000000..60577bb0f851 --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-AnomalyDetector/src/main/java/com/azure/cognitiveservices/anomalydetector/package-info.java @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +/** + * Package containing the classes for AnomalyDetectorClient. The Anomaly Detector API detects anomalies automatically in + * time series data. It supports two kinds of mode, one is for stateless using, another is for stateful using. In + * stateless mode, there are three functionalities. Entire Detect is for detecting the whole series with model trained + * by the time series, Last Detect is detecting last point with model trained by points before. ChangePoint Detect is + * for detecting trend changes in time series. In stateful mode, user can store time series, the stored time series will + * be used for detection anomalies. Under this mode, user can still use the above three functionalities by only giving a + * time range without preparing time series in client side. Besides the above three functionalities, stateful model also + * provide group based detection and labeling service. By leveraging labeling service user can provide labels for each + * detection result, these labels will be used for retuning or regenerating detection models. Inconsistency detection is + * a kind of group based detection, this detection will find inconsistency ones in a set of time series. By using + * anomaly detector service, business customers can discover incidents and establish a logic flow for root cause + * analysis. + */ +package com.azure.cognitiveservices.anomalydetector; diff --git a/sdk/cognitiveservices/azure-cognitiveservices-AnomalyDetector/src/main/java/module-info.java b/sdk/cognitiveservices/azure-cognitiveservices-AnomalyDetector/src/main/java/module-info.java new file mode 100644 index 000000000000..3b68b4754f2a --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-AnomalyDetector/src/main/java/module-info.java @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +module com.azure.cognitiveservices.anomalydetector { + requires transitive com.azure.core; + + exports com.azure.cognitiveservices.anomalydetector; +} diff --git a/sdk/cognitiveservices/azure-cognitiveservices-AnomalyDetector/src/main/resources/azure-cognitiveservices-AnomalyDetector.properties b/sdk/cognitiveservices/azure-cognitiveservices-AnomalyDetector/src/main/resources/azure-cognitiveservices-AnomalyDetector.properties new file mode 100644 index 000000000000..ca812989b4f2 --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-AnomalyDetector/src/main/resources/azure-cognitiveservices-AnomalyDetector.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/sdk/cognitiveservices/azure-cognitiveservices-AnomalyDetector/src/samples/java/com/azure/cognitiveservices/anomalydetector/ReadmeSamples.java b/sdk/cognitiveservices/azure-cognitiveservices-AnomalyDetector/src/samples/java/com/azure/cognitiveservices/anomalydetector/ReadmeSamples.java new file mode 100644 index 000000000000..f79f44b5ec53 --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-AnomalyDetector/src/samples/java/com/azure/cognitiveservices/anomalydetector/ReadmeSamples.java @@ -0,0 +1,12 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.cognitiveservices.anomalydetector; + +public final class ReadmeSamples { + public void readmeSamples() { + // BEGIN: com.azure.cognitiveservices.anomalydetector.readme + // END: com.azure.cognitiveservices.anomalydetector.readme + } +} diff --git a/sdk/cognitiveservices/azure-cognitiveservices-AnomalyDetector/src/test/java/com/azure/cognitiveservices/anomalydetector/ClientTests.java b/sdk/cognitiveservices/azure-cognitiveservices-AnomalyDetector/src/test/java/com/azure/cognitiveservices/anomalydetector/ClientTests.java new file mode 100644 index 000000000000..e15158df1582 --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-AnomalyDetector/src/test/java/com/azure/cognitiveservices/anomalydetector/ClientTests.java @@ -0,0 +1,47 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.cognitiveservices.anomalydetector; + +import com.azure.core.credential.AccessToken; +import com.azure.core.http.HttpClient; +import com.azure.core.http.policy.HttpLogDetailLevel; +import com.azure.core.http.policy.HttpLogOptions; +import com.azure.core.test.TestBase; +import com.azure.core.test.TestMode; +import com.azure.core.test.annotation.DoNotRecord; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; +import java.time.OffsetDateTime; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import reactor.core.publisher.Mono; + +public final class ClientTests extends TestBase { + private AnomalyDetectorClientBuilder builder; + + @BeforeEach + public void setup() { + builder = + new AnomalyDetectorClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BODY_AND_HEADERS)); + if (getTestMode() == TestMode.PLAYBACK) { + builder.httpClient(interceptorManager.getPlaybackClient()) + .credential(request -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX))); + } else if (getTestMode() == TestMode.RECORD) { + builder.addPolicy(interceptorManager.getRecordPolicy()) + .credential(new DefaultAzureCredentialBuilder().build()); + } else if (getTestMode() == TestMode.LIVE) { + builder.credential(new DefaultAzureCredentialBuilder().build()); + } + } + + @Test + @DoNotRecord(skipInPlayback = true) + public void testClient() { + // use the builder to create client + } +} diff --git a/sdk/cognitiveservices/azure-cognitiveservices-AnomalyDetector/swagger/README_SPEC.md b/sdk/cognitiveservices/azure-cognitiveservices-AnomalyDetector/swagger/README_SPEC.md new file mode 100644 index 000000000000..ee66bd3dc31f --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-AnomalyDetector/swagger/README_SPEC.md @@ -0,0 +1,26 @@ +## Generate autorest code + +```yaml +input-file: + - /home/vsts/work/1/s/azure-rest-api-specs/specification/cognitiveservices/data-plane/AnomalyDetector/preview/v1.1-preview.1/AnomalyDetector.json +java: true +output-folder: ../ +partial-update: true +regenerate-pom: false +generate-sync-async-clients: true +generate-client-as-impl: true +generate-client-interfaces: false +add-context-parameter: true +artifact-id: azure-cognitiveservices-AnomalyDetector +low-level-client: true +sync-methods: all +generate-samples: true +license-header: MICROSOFT_MIT_SMALL +namespace: com.azure.cognitiveservices.AnomalyDetector +context-client-method-parameter: true +azure-arm: false +credential-types: tokencredential +credential-scopes: https://cognitiveservices.azure.com/.default +service-versions: + - '1.1-preview.1' +```