diff --git a/eng/versioning/version_client.txt b/eng/versioning/version_client.txt index 81fae11f6e0e..1daacec134a1 100644 --- a/eng/versioning/version_client.txt +++ b/eng/versioning/version_client.txt @@ -258,6 +258,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-applicationinsights-livemetrics;1.0.0-beta.1;1.0.0-beta.1 com.azure.resourcemanager:azure-resourcemanager;2.50.0;2.51.0-beta.1 com.azure.resourcemanager:azure-resourcemanager-appplatform;2.50.0;2.51.0-beta.1 com.azure.resourcemanager:azure-resourcemanager-appservice;2.50.0;2.51.0-beta.1 diff --git a/sdk/applicationinsights/azure-applicationinsights-livemetrics/CHANGELOG.md b/sdk/applicationinsights/azure-applicationinsights-livemetrics/CHANGELOG.md new file mode 100644 index 000000000000..fad7b5a8bfc5 --- /dev/null +++ b/sdk/applicationinsights/azure-applicationinsights-livemetrics/CHANGELOG.md @@ -0,0 +1,16 @@ +# Release History + +## 1.0.0-beta.1 (Unreleased) + +- Azure LiveMetrics client library for Java. This package contains Microsoft Azure LiveMetrics client library. + +### Features Added + +### Breaking Changes + +### Bugs Fixed + +### Other Changes +### Features Added + +- Initial release for the azure-applicationinsights-livemetrics Java SDK. diff --git a/sdk/applicationinsights/azure-applicationinsights-livemetrics/README.md b/sdk/applicationinsights/azure-applicationinsights-livemetrics/README.md new file mode 100644 index 000000000000..9914532771fc --- /dev/null +++ b/sdk/applicationinsights/azure-applicationinsights-livemetrics/README.md @@ -0,0 +1,78 @@ +# Azure LiveMetrics client library for Java + +Azure LiveMetrics client library for Java. + +This package contains Microsoft Azure LiveMetrics 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-applicationinsights-livemetrics;current}) +```xml + + com.azure + azure-applicationinsights-livemetrics + 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.applicationinsights.livemetrics.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/applicationinsights/azure-applicationinsights-livemetrics/assets.json b/sdk/applicationinsights/azure-applicationinsights-livemetrics/assets.json new file mode 100644 index 000000000000..8b43d5119eeb --- /dev/null +++ b/sdk/applicationinsights/azure-applicationinsights-livemetrics/assets.json @@ -0,0 +1 @@ +{"AssetsRepo":"Azure/azure-sdk-assets","AssetsRepoPrefixPath":"java","TagPrefix":"java/applicationinsights/azure-applicationinsights-livemetrics","Tag":""} \ No newline at end of file diff --git a/sdk/applicationinsights/azure-applicationinsights-livemetrics/pom.xml b/sdk/applicationinsights/azure-applicationinsights-livemetrics/pom.xml new file mode 100644 index 000000000000..3c08a2d4d301 --- /dev/null +++ b/sdk/applicationinsights/azure-applicationinsights-livemetrics/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-applicationinsights-livemetrics + 1.0.0-beta.1 + jar + + Microsoft Azure SDK for LiveMetrics + This package contains Microsoft Azure LiveMetrics 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.16.0 + test + + + diff --git a/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/LiveMetricsAsyncClient.java b/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/LiveMetricsAsyncClient.java new file mode 100644 index 000000000000..adb366f52a38 --- /dev/null +++ b/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/LiveMetricsAsyncClient.java @@ -0,0 +1,468 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.applicationinsights.livemetrics; + +import com.azure.applicationinsights.livemetrics.implementation.LiveMetricsClientImpl; +import com.azure.applicationinsights.livemetrics.models.CollectionConfigurationInfo; +import com.azure.applicationinsights.livemetrics.models.MonitoringDataPoint; +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.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; +import com.azure.core.util.FluxUtil; +import java.util.List; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous LiveMetricsClient type. + */ +@ServiceClient(builder = LiveMetricsClientBuilder.class, isAsync = true) +public final class LiveMetricsAsyncClient { + @Generated + private final LiveMetricsClientImpl serviceClient; + + /** + * Initializes an instance of LiveMetricsAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + LiveMetricsAsyncClient(LiveMetricsClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Determine whether there is any subscription to the metrics and documents. + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
Content-TypeStringNoThe content type. Allowed values: + * "application/json".
x-ms-qps-transmission-timeLongNoTimestamp when the client transmits the + * metrics and documents to Live Metrics. A 8-byte long type of ticks.
x-ms-qps-machine-nameStringNoComputer name where Application Insights SDK + * lives. Live Metrics uses machine name with instance name as a backup.
x-ms-qps-instance-nameStringNoService instance name where Application Insights + * SDK lives. Live Metrics uses machine name with instance name as a backup.
x-ms-qps-stream-idStringNoIdentifies an Application Insights SDK as trusted + * agent to report metrics and documents.
x-ms-qps-role-nameStringNoCloud role name of the service.
x-ms-qps-invariant-versionStringNoVersion/generation of the data contract + * (MonitoringDataPoint) between the client and Live Metrics.
x-ms-qps-configuration-etagStringNoAn encoded string that indicates whether + * the collection configuration is changed.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     Version: String (Required)
+     *     InvariantVersion: int (Required)
+     *     Instance: String (Required)
+     *     RoleName: String (Required)
+     *     MachineName: String (Required)
+     *     StreamId: String (Required)
+     *     Timestamp: OffsetDateTime (Optional)
+     *     TransmissionTime: OffsetDateTime (Optional)
+     *     IsWebApp: boolean (Required)
+     *     PerformanceCollectionSupported: boolean (Required)
+     *     Metrics (Optional): [
+     *          (Optional){
+     *             Name: String (Required)
+     *             Value: double (Required)
+     *             Weight: int (Required)
+     *         }
+     *     ]
+     *     Documents (Optional): [
+     *          (Optional){
+     *             DocumentType: String(Request/RemoteDependency/Exception/Event/Trace/Unknown) (Required)
+     *             DocumentStreamIds (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             Properties (Optional): [
+     *                  (Optional){
+     *                     key: String (Required)
+     *                     value: String (Required)
+     *                 }
+     *             ]
+     *         }
+     *     ]
+     *     TopCpuProcesses (Optional): [
+     *          (Optional){
+     *             ProcessName: String (Required)
+     *             CpuPercentage: int (Required)
+     *         }
+     *     ]
+     *     CollectionConfigurationErrors (Optional): [
+     *          (Optional){
+     *             CollectionConfigurationErrorType: String(Unknown/PerformanceCounterParsing/PerformanceCounterUnexpected/PerformanceCounterDuplicateIds/DocumentStreamDuplicateIds/DocumentStreamFailureToCreate/DocumentStreamFailureToCreateFilterUnexpected/MetricDuplicateIds/MetricTelemetryTypeUnsupported/MetricFailureToCreate/MetricFailureToCreateFilterUnexpected/FilterFailureToCreateUnexpected/CollectionConfigurationFailureToCreateUnexpected) (Required)
+     *             Message: String (Required)
+     *             FullException: String (Required)
+     *             Data (Required): [
+     *                 (recursive schema, see above)
+     *             ]
+     *         }
+     *     ]
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     ETag: String (Required)
+     *     Metrics (Required): [
+     *          (Required){
+     *             Id: String (Required)
+     *             TelemetryType: String (Required)
+     *             FilterGroups (Required): [
+     *                  (Required){
+     *                     Filters (Required): [
+     *                          (Required){
+     *                             FieldName: String (Required)
+     *                             Predicate: String(Equal/NotEqual/LessThan/GreaterThan/LessThanOrEqual/GreaterThanOrEqual/Contains/DoesNotContain) (Required)
+     *                             Comparand: String (Required)
+     *                         }
+     *                     ]
+     *                 }
+     *             ]
+     *             Projection: String (Required)
+     *             Aggregation: String(Avg/Sum/Min/Max) (Required)
+     *             BackEndAggregation: String(Avg/Sum/Min/Max) (Required)
+     *         }
+     *     ]
+     *     DocumentStreams (Required): [
+     *          (Required){
+     *             Id: String (Required)
+     *             DocumentFilterGroups (Required): [
+     *                  (Required){
+     *                     TelemetryType: String(Request/Dependency/Exception/Event/Metric/PerformanceCounter/Trace) (Required)
+     *                     Filters (Required): (recursive schema, see Filters above)
+     *                 }
+     *             ]
+     *         }
+     *     ]
+     *     QuotaInfo (Optional): {
+     *         InitialQuota: Double (Optional)
+     *         MaxQuota: double (Required)
+     *         QuotaAccrualRatePerSec: double (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param ikey The instrumentation key of the target Application Insights component for which the client checks + * whether there's any subscription to it. + * @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 represents the collection configuration - a customizable description of performance counters, metrics, + * and full telemetry documents to be collected by the client SDK along with {@link Response} on successful + * completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> isSubscribedWithResponse(String ikey, RequestOptions requestOptions) { + return this.serviceClient.isSubscribedWithResponseAsync(ikey, requestOptions); + } + + /** + * Publish live metrics to the Live Metrics service when there is an active subscription to the metrics. + *

Header Parameters

+ * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
Content-TypeStringNoThe content type. Allowed values: + * "application/json".
x-ms-qps-configuration-etagStringNoAn encoded string that indicates whether + * the collection configuration is changed.
x-ms-qps-transmission-timeLongNoTimestamp when the client transmits the + * metrics and documents to Live Metrics. A 8-byte long type of ticks.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
+     * {@code
+     * [
+     *      (Optional){
+     *         Version: String (Required)
+     *         InvariantVersion: int (Required)
+     *         Instance: String (Required)
+     *         RoleName: String (Required)
+     *         MachineName: String (Required)
+     *         StreamId: String (Required)
+     *         Timestamp: OffsetDateTime (Optional)
+     *         TransmissionTime: OffsetDateTime (Optional)
+     *         IsWebApp: boolean (Required)
+     *         PerformanceCollectionSupported: boolean (Required)
+     *         Metrics (Optional): [
+     *              (Optional){
+     *                 Name: String (Required)
+     *                 Value: double (Required)
+     *                 Weight: int (Required)
+     *             }
+     *         ]
+     *         Documents (Optional): [
+     *              (Optional){
+     *                 DocumentType: String(Request/RemoteDependency/Exception/Event/Trace/Unknown) (Required)
+     *                 DocumentStreamIds (Optional): [
+     *                     String (Optional)
+     *                 ]
+     *                 Properties (Optional): [
+     *                      (Optional){
+     *                         key: String (Required)
+     *                         value: String (Required)
+     *                     }
+     *                 ]
+     *             }
+     *         ]
+     *         TopCpuProcesses (Optional): [
+     *              (Optional){
+     *                 ProcessName: String (Required)
+     *                 CpuPercentage: int (Required)
+     *             }
+     *         ]
+     *         CollectionConfigurationErrors (Optional): [
+     *              (Optional){
+     *                 CollectionConfigurationErrorType: String(Unknown/PerformanceCounterParsing/PerformanceCounterUnexpected/PerformanceCounterDuplicateIds/DocumentStreamDuplicateIds/DocumentStreamFailureToCreate/DocumentStreamFailureToCreateFilterUnexpected/MetricDuplicateIds/MetricTelemetryTypeUnsupported/MetricFailureToCreate/MetricFailureToCreateFilterUnexpected/FilterFailureToCreateUnexpected/CollectionConfigurationFailureToCreateUnexpected) (Required)
+     *                 Message: String (Required)
+     *                 FullException: String (Required)
+     *                 Data (Required): [
+     *                     (recursive schema, see above)
+     *                 ]
+     *             }
+     *         ]
+     *     }
+     * ]
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     ETag: String (Required)
+     *     Metrics (Required): [
+     *          (Required){
+     *             Id: String (Required)
+     *             TelemetryType: String (Required)
+     *             FilterGroups (Required): [
+     *                  (Required){
+     *                     Filters (Required): [
+     *                          (Required){
+     *                             FieldName: String (Required)
+     *                             Predicate: String(Equal/NotEqual/LessThan/GreaterThan/LessThanOrEqual/GreaterThanOrEqual/Contains/DoesNotContain) (Required)
+     *                             Comparand: String (Required)
+     *                         }
+     *                     ]
+     *                 }
+     *             ]
+     *             Projection: String (Required)
+     *             Aggregation: String(Avg/Sum/Min/Max) (Required)
+     *             BackEndAggregation: String(Avg/Sum/Min/Max) (Required)
+     *         }
+     *     ]
+     *     DocumentStreams (Required): [
+     *          (Required){
+     *             Id: String (Required)
+     *             DocumentFilterGroups (Required): [
+     *                  (Required){
+     *                     TelemetryType: String(Request/Dependency/Exception/Event/Metric/PerformanceCounter/Trace) (Required)
+     *                     Filters (Required): (recursive schema, see Filters above)
+     *                 }
+     *             ]
+     *         }
+     *     ]
+     *     QuotaInfo (Optional): {
+     *         InitialQuota: Double (Optional)
+     *         MaxQuota: double (Required)
+     *         QuotaAccrualRatePerSec: double (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param ikey The instrumentation key of the target Application Insights component for which the client checks + * whether there's any subscription to it. + * @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 represents the collection configuration - a customizable description of performance counters, metrics, + * and full telemetry documents to be collected by the client SDK along with {@link Response} on successful + * completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> publishWithResponse(String ikey, RequestOptions requestOptions) { + return this.serviceClient.publishWithResponseAsync(ikey, requestOptions); + } + + /** + * Determine whether there is any subscription to the metrics and documents. + * + * @param ikey The instrumentation key of the target Application Insights component for which the client checks + * whether there's any subscription to it. + * @param transmissionTime Timestamp when the client transmits the metrics and documents to Live Metrics. A 8-byte + * long type of ticks. + * @param machineName Computer name where Application Insights SDK lives. Live Metrics uses machine name with + * instance name as a backup. + * @param instanceName Service instance name where Application Insights SDK lives. Live Metrics uses machine name + * with instance name as a backup. + * @param streamId Identifies an Application Insights SDK as trusted agent to report metrics and documents. + * @param roleName Cloud role name of the service. + * @param invariantVersion Version/generation of the data contract (MonitoringDataPoint) between the client and Live + * Metrics. + * @param configurationEtag An encoded string that indicates whether the collection configuration is changed. + * @param monitoringDataPoint Data contract between Application Insights client SDK and Live Metrics. + * /QuickPulseService.svc/ping uses this as a backup source of machine name, instance name and invariant version. + * @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 represents the collection configuration - a customizable description of performance counters, metrics, + * and full telemetry documents to be collected by the client SDK on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono isSubscribed(String ikey, Long transmissionTime, String machineName, + String instanceName, String streamId, String roleName, String invariantVersion, String configurationEtag, + MonitoringDataPoint monitoringDataPoint) { + // Generated convenience method for isSubscribedWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (transmissionTime != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-qps-transmission-time"), + String.valueOf(transmissionTime)); + } + if (machineName != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-qps-machine-name"), machineName); + } + if (instanceName != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-qps-instance-name"), instanceName); + } + if (streamId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-qps-stream-id"), streamId); + } + if (roleName != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-qps-role-name"), roleName); + } + if (invariantVersion != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-qps-invariant-version"), invariantVersion); + } + if (configurationEtag != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-qps-configuration-etag"), configurationEtag); + } + if (monitoringDataPoint != null) { + requestOptions.setBody(BinaryData.fromObject(monitoringDataPoint)); + } + return isSubscribedWithResponse(ikey, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(CollectionConfigurationInfo.class)); + } + + /** + * Determine whether there is any subscription to the metrics and documents. + * + * @param ikey The instrumentation key of the target Application Insights component for which the client checks + * whether there's any subscription to it. + * @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 represents the collection configuration - a customizable description of performance counters, metrics, + * and full telemetry documents to be collected by the client SDK on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono isSubscribed(String ikey) { + // Generated convenience method for isSubscribedWithResponse + RequestOptions requestOptions = new RequestOptions(); + return isSubscribedWithResponse(ikey, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(CollectionConfigurationInfo.class)); + } + + /** + * Publish live metrics to the Live Metrics service when there is an active subscription to the metrics. + * + * @param ikey The instrumentation key of the target Application Insights component for which the client checks + * whether there's any subscription to it. + * @param configurationEtag An encoded string that indicates whether the collection configuration is changed. + * @param transmissionTime Timestamp when the client transmits the metrics and documents to Live Metrics. A 8-byte + * long type of ticks. + * @param monitoringDataPoints Data contract between the client and Live Metrics. /QuickPulseService.svc/ping uses + * this as a backup source of machine name, instance name and invariant version. + * @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 represents the collection configuration - a customizable description of performance counters, metrics, + * and full telemetry documents to be collected by the client SDK on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono publish(String ikey, String configurationEtag, Long transmissionTime, + List monitoringDataPoints) { + // Generated convenience method for publishWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (configurationEtag != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-qps-configuration-etag"), configurationEtag); + } + if (transmissionTime != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-qps-transmission-time"), + String.valueOf(transmissionTime)); + } + if (monitoringDataPoints != null) { + requestOptions.setBody(BinaryData.fromObject(monitoringDataPoints)); + } + return publishWithResponse(ikey, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(CollectionConfigurationInfo.class)); + } + + /** + * Publish live metrics to the Live Metrics service when there is an active subscription to the metrics. + * + * @param ikey The instrumentation key of the target Application Insights component for which the client checks + * whether there's any subscription to it. + * @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 represents the collection configuration - a customizable description of performance counters, metrics, + * and full telemetry documents to be collected by the client SDK on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono publish(String ikey) { + // Generated convenience method for publishWithResponse + RequestOptions requestOptions = new RequestOptions(); + return publishWithResponse(ikey, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(CollectionConfigurationInfo.class)); + } +} diff --git a/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/LiveMetricsClient.java b/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/LiveMetricsClient.java new file mode 100644 index 000000000000..dc8dec194900 --- /dev/null +++ b/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/LiveMetricsClient.java @@ -0,0 +1,460 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.applicationinsights.livemetrics; + +import com.azure.applicationinsights.livemetrics.implementation.LiveMetricsClientImpl; +import com.azure.applicationinsights.livemetrics.models.CollectionConfigurationInfo; +import com.azure.applicationinsights.livemetrics.models.MonitoringDataPoint; +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.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; +import java.util.List; + +/** + * Initializes a new instance of the synchronous LiveMetricsClient type. + */ +@ServiceClient(builder = LiveMetricsClientBuilder.class) +public final class LiveMetricsClient { + @Generated + private final LiveMetricsClientImpl serviceClient; + + /** + * Initializes an instance of LiveMetricsClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + LiveMetricsClient(LiveMetricsClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Determine whether there is any subscription to the metrics and documents. + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
Content-TypeStringNoThe content type. Allowed values: + * "application/json".
x-ms-qps-transmission-timeLongNoTimestamp when the client transmits the + * metrics and documents to Live Metrics. A 8-byte long type of ticks.
x-ms-qps-machine-nameStringNoComputer name where Application Insights SDK + * lives. Live Metrics uses machine name with instance name as a backup.
x-ms-qps-instance-nameStringNoService instance name where Application Insights + * SDK lives. Live Metrics uses machine name with instance name as a backup.
x-ms-qps-stream-idStringNoIdentifies an Application Insights SDK as trusted + * agent to report metrics and documents.
x-ms-qps-role-nameStringNoCloud role name of the service.
x-ms-qps-invariant-versionStringNoVersion/generation of the data contract + * (MonitoringDataPoint) between the client and Live Metrics.
x-ms-qps-configuration-etagStringNoAn encoded string that indicates whether + * the collection configuration is changed.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     Version: String (Required)
+     *     InvariantVersion: int (Required)
+     *     Instance: String (Required)
+     *     RoleName: String (Required)
+     *     MachineName: String (Required)
+     *     StreamId: String (Required)
+     *     Timestamp: OffsetDateTime (Optional)
+     *     TransmissionTime: OffsetDateTime (Optional)
+     *     IsWebApp: boolean (Required)
+     *     PerformanceCollectionSupported: boolean (Required)
+     *     Metrics (Optional): [
+     *          (Optional){
+     *             Name: String (Required)
+     *             Value: double (Required)
+     *             Weight: int (Required)
+     *         }
+     *     ]
+     *     Documents (Optional): [
+     *          (Optional){
+     *             DocumentType: String(Request/RemoteDependency/Exception/Event/Trace/Unknown) (Required)
+     *             DocumentStreamIds (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             Properties (Optional): [
+     *                  (Optional){
+     *                     key: String (Required)
+     *                     value: String (Required)
+     *                 }
+     *             ]
+     *         }
+     *     ]
+     *     TopCpuProcesses (Optional): [
+     *          (Optional){
+     *             ProcessName: String (Required)
+     *             CpuPercentage: int (Required)
+     *         }
+     *     ]
+     *     CollectionConfigurationErrors (Optional): [
+     *          (Optional){
+     *             CollectionConfigurationErrorType: String(Unknown/PerformanceCounterParsing/PerformanceCounterUnexpected/PerformanceCounterDuplicateIds/DocumentStreamDuplicateIds/DocumentStreamFailureToCreate/DocumentStreamFailureToCreateFilterUnexpected/MetricDuplicateIds/MetricTelemetryTypeUnsupported/MetricFailureToCreate/MetricFailureToCreateFilterUnexpected/FilterFailureToCreateUnexpected/CollectionConfigurationFailureToCreateUnexpected) (Required)
+     *             Message: String (Required)
+     *             FullException: String (Required)
+     *             Data (Required): [
+     *                 (recursive schema, see above)
+     *             ]
+     *         }
+     *     ]
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     ETag: String (Required)
+     *     Metrics (Required): [
+     *          (Required){
+     *             Id: String (Required)
+     *             TelemetryType: String (Required)
+     *             FilterGroups (Required): [
+     *                  (Required){
+     *                     Filters (Required): [
+     *                          (Required){
+     *                             FieldName: String (Required)
+     *                             Predicate: String(Equal/NotEqual/LessThan/GreaterThan/LessThanOrEqual/GreaterThanOrEqual/Contains/DoesNotContain) (Required)
+     *                             Comparand: String (Required)
+     *                         }
+     *                     ]
+     *                 }
+     *             ]
+     *             Projection: String (Required)
+     *             Aggregation: String(Avg/Sum/Min/Max) (Required)
+     *             BackEndAggregation: String(Avg/Sum/Min/Max) (Required)
+     *         }
+     *     ]
+     *     DocumentStreams (Required): [
+     *          (Required){
+     *             Id: String (Required)
+     *             DocumentFilterGroups (Required): [
+     *                  (Required){
+     *                     TelemetryType: String(Request/Dependency/Exception/Event/Metric/PerformanceCounter/Trace) (Required)
+     *                     Filters (Required): (recursive schema, see Filters above)
+     *                 }
+     *             ]
+     *         }
+     *     ]
+     *     QuotaInfo (Optional): {
+     *         InitialQuota: Double (Optional)
+     *         MaxQuota: double (Required)
+     *         QuotaAccrualRatePerSec: double (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param ikey The instrumentation key of the target Application Insights component for which the client checks + * whether there's any subscription to it. + * @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 represents the collection configuration - a customizable description of performance counters, metrics, + * and full telemetry documents to be collected by the client SDK along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response isSubscribedWithResponse(String ikey, RequestOptions requestOptions) { + return this.serviceClient.isSubscribedWithResponse(ikey, requestOptions); + } + + /** + * Publish live metrics to the Live Metrics service when there is an active subscription to the metrics. + *

Header Parameters

+ * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
Content-TypeStringNoThe content type. Allowed values: + * "application/json".
x-ms-qps-configuration-etagStringNoAn encoded string that indicates whether + * the collection configuration is changed.
x-ms-qps-transmission-timeLongNoTimestamp when the client transmits the + * metrics and documents to Live Metrics. A 8-byte long type of ticks.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
+     * {@code
+     * [
+     *      (Optional){
+     *         Version: String (Required)
+     *         InvariantVersion: int (Required)
+     *         Instance: String (Required)
+     *         RoleName: String (Required)
+     *         MachineName: String (Required)
+     *         StreamId: String (Required)
+     *         Timestamp: OffsetDateTime (Optional)
+     *         TransmissionTime: OffsetDateTime (Optional)
+     *         IsWebApp: boolean (Required)
+     *         PerformanceCollectionSupported: boolean (Required)
+     *         Metrics (Optional): [
+     *              (Optional){
+     *                 Name: String (Required)
+     *                 Value: double (Required)
+     *                 Weight: int (Required)
+     *             }
+     *         ]
+     *         Documents (Optional): [
+     *              (Optional){
+     *                 DocumentType: String(Request/RemoteDependency/Exception/Event/Trace/Unknown) (Required)
+     *                 DocumentStreamIds (Optional): [
+     *                     String (Optional)
+     *                 ]
+     *                 Properties (Optional): [
+     *                      (Optional){
+     *                         key: String (Required)
+     *                         value: String (Required)
+     *                     }
+     *                 ]
+     *             }
+     *         ]
+     *         TopCpuProcesses (Optional): [
+     *              (Optional){
+     *                 ProcessName: String (Required)
+     *                 CpuPercentage: int (Required)
+     *             }
+     *         ]
+     *         CollectionConfigurationErrors (Optional): [
+     *              (Optional){
+     *                 CollectionConfigurationErrorType: String(Unknown/PerformanceCounterParsing/PerformanceCounterUnexpected/PerformanceCounterDuplicateIds/DocumentStreamDuplicateIds/DocumentStreamFailureToCreate/DocumentStreamFailureToCreateFilterUnexpected/MetricDuplicateIds/MetricTelemetryTypeUnsupported/MetricFailureToCreate/MetricFailureToCreateFilterUnexpected/FilterFailureToCreateUnexpected/CollectionConfigurationFailureToCreateUnexpected) (Required)
+     *                 Message: String (Required)
+     *                 FullException: String (Required)
+     *                 Data (Required): [
+     *                     (recursive schema, see above)
+     *                 ]
+     *             }
+     *         ]
+     *     }
+     * ]
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     ETag: String (Required)
+     *     Metrics (Required): [
+     *          (Required){
+     *             Id: String (Required)
+     *             TelemetryType: String (Required)
+     *             FilterGroups (Required): [
+     *                  (Required){
+     *                     Filters (Required): [
+     *                          (Required){
+     *                             FieldName: String (Required)
+     *                             Predicate: String(Equal/NotEqual/LessThan/GreaterThan/LessThanOrEqual/GreaterThanOrEqual/Contains/DoesNotContain) (Required)
+     *                             Comparand: String (Required)
+     *                         }
+     *                     ]
+     *                 }
+     *             ]
+     *             Projection: String (Required)
+     *             Aggregation: String(Avg/Sum/Min/Max) (Required)
+     *             BackEndAggregation: String(Avg/Sum/Min/Max) (Required)
+     *         }
+     *     ]
+     *     DocumentStreams (Required): [
+     *          (Required){
+     *             Id: String (Required)
+     *             DocumentFilterGroups (Required): [
+     *                  (Required){
+     *                     TelemetryType: String(Request/Dependency/Exception/Event/Metric/PerformanceCounter/Trace) (Required)
+     *                     Filters (Required): (recursive schema, see Filters above)
+     *                 }
+     *             ]
+     *         }
+     *     ]
+     *     QuotaInfo (Optional): {
+     *         InitialQuota: Double (Optional)
+     *         MaxQuota: double (Required)
+     *         QuotaAccrualRatePerSec: double (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param ikey The instrumentation key of the target Application Insights component for which the client checks + * whether there's any subscription to it. + * @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 represents the collection configuration - a customizable description of performance counters, metrics, + * and full telemetry documents to be collected by the client SDK along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response publishWithResponse(String ikey, RequestOptions requestOptions) { + return this.serviceClient.publishWithResponse(ikey, requestOptions); + } + + /** + * Determine whether there is any subscription to the metrics and documents. + * + * @param ikey The instrumentation key of the target Application Insights component for which the client checks + * whether there's any subscription to it. + * @param transmissionTime Timestamp when the client transmits the metrics and documents to Live Metrics. A 8-byte + * long type of ticks. + * @param machineName Computer name where Application Insights SDK lives. Live Metrics uses machine name with + * instance name as a backup. + * @param instanceName Service instance name where Application Insights SDK lives. Live Metrics uses machine name + * with instance name as a backup. + * @param streamId Identifies an Application Insights SDK as trusted agent to report metrics and documents. + * @param roleName Cloud role name of the service. + * @param invariantVersion Version/generation of the data contract (MonitoringDataPoint) between the client and Live + * Metrics. + * @param configurationEtag An encoded string that indicates whether the collection configuration is changed. + * @param monitoringDataPoint Data contract between Application Insights client SDK and Live Metrics. + * /QuickPulseService.svc/ping uses this as a backup source of machine name, instance name and invariant version. + * @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 represents the collection configuration - a customizable description of performance counters, metrics, + * and full telemetry documents to be collected by the client SDK. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public CollectionConfigurationInfo isSubscribed(String ikey, Long transmissionTime, String machineName, + String instanceName, String streamId, String roleName, String invariantVersion, String configurationEtag, + MonitoringDataPoint monitoringDataPoint) { + // Generated convenience method for isSubscribedWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (transmissionTime != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-qps-transmission-time"), + String.valueOf(transmissionTime)); + } + if (machineName != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-qps-machine-name"), machineName); + } + if (instanceName != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-qps-instance-name"), instanceName); + } + if (streamId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-qps-stream-id"), streamId); + } + if (roleName != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-qps-role-name"), roleName); + } + if (invariantVersion != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-qps-invariant-version"), invariantVersion); + } + if (configurationEtag != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-qps-configuration-etag"), configurationEtag); + } + if (monitoringDataPoint != null) { + requestOptions.setBody(BinaryData.fromObject(monitoringDataPoint)); + } + return isSubscribedWithResponse(ikey, requestOptions).getValue().toObject(CollectionConfigurationInfo.class); + } + + /** + * Determine whether there is any subscription to the metrics and documents. + * + * @param ikey The instrumentation key of the target Application Insights component for which the client checks + * whether there's any subscription to it. + * @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 represents the collection configuration - a customizable description of performance counters, metrics, + * and full telemetry documents to be collected by the client SDK. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public CollectionConfigurationInfo isSubscribed(String ikey) { + // Generated convenience method for isSubscribedWithResponse + RequestOptions requestOptions = new RequestOptions(); + return isSubscribedWithResponse(ikey, requestOptions).getValue().toObject(CollectionConfigurationInfo.class); + } + + /** + * Publish live metrics to the Live Metrics service when there is an active subscription to the metrics. + * + * @param ikey The instrumentation key of the target Application Insights component for which the client checks + * whether there's any subscription to it. + * @param configurationEtag An encoded string that indicates whether the collection configuration is changed. + * @param transmissionTime Timestamp when the client transmits the metrics and documents to Live Metrics. A 8-byte + * long type of ticks. + * @param monitoringDataPoints Data contract between the client and Live Metrics. /QuickPulseService.svc/ping uses + * this as a backup source of machine name, instance name and invariant version. + * @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 represents the collection configuration - a customizable description of performance counters, metrics, + * and full telemetry documents to be collected by the client SDK. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public CollectionConfigurationInfo publish(String ikey, String configurationEtag, Long transmissionTime, + List monitoringDataPoints) { + // Generated convenience method for publishWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (configurationEtag != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-qps-configuration-etag"), configurationEtag); + } + if (transmissionTime != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-qps-transmission-time"), + String.valueOf(transmissionTime)); + } + if (monitoringDataPoints != null) { + requestOptions.setBody(BinaryData.fromObject(monitoringDataPoints)); + } + return publishWithResponse(ikey, requestOptions).getValue().toObject(CollectionConfigurationInfo.class); + } + + /** + * Publish live metrics to the Live Metrics service when there is an active subscription to the metrics. + * + * @param ikey The instrumentation key of the target Application Insights component for which the client checks + * whether there's any subscription to it. + * @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 represents the collection configuration - a customizable description of performance counters, metrics, + * and full telemetry documents to be collected by the client SDK. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public CollectionConfigurationInfo publish(String ikey) { + // Generated convenience method for publishWithResponse + RequestOptions requestOptions = new RequestOptions(); + return publishWithResponse(ikey, requestOptions).getValue().toObject(CollectionConfigurationInfo.class); + } +} diff --git a/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/LiveMetricsClientBuilder.java b/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/LiveMetricsClientBuilder.java new file mode 100644 index 000000000000..f46d458a64b0 --- /dev/null +++ b/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/LiveMetricsClientBuilder.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.applicationinsights.livemetrics; + +import com.azure.applicationinsights.livemetrics.implementation.LiveMetricsClientImpl; +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 LiveMetricsClient type. + */ +@ServiceClientBuilder(serviceClients = { LiveMetricsClient.class, LiveMetricsAsyncClient.class }) +public final class LiveMetricsClientBuilder + 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://monitor.azure.com/.default" }; + + @Generated + private static final Map PROPERTIES + = CoreUtils.getProperties("azure-applicationinsights-livemetrics.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the LiveMetricsClientBuilder. + */ + @Generated + public LiveMetricsClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public LiveMetricsClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public LiveMetricsClientBuilder 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 logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public LiveMetricsClientBuilder 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 LiveMetricsClientBuilder 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 LiveMetricsClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public LiveMetricsClientBuilder 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 LiveMetricsClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The TokenCredential used for authentication. + */ + @Generated + private TokenCredential tokenCredential; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public LiveMetricsClientBuilder credential(TokenCredential tokenCredential) { + this.tokenCredential = tokenCredential; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public LiveMetricsClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * Service version + */ + @Generated + private LiveMetricsServiceVersion serviceVersion; + + /** + * Sets Service version. + * + * @param serviceVersion the serviceVersion value. + * @return the LiveMetricsClientBuilder. + */ + @Generated + public LiveMetricsClientBuilder serviceVersion(LiveMetricsServiceVersion 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 LiveMetricsClientBuilder. + */ + @Generated + public LiveMetricsClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of LiveMetricsClientImpl with the provided parameters. + * + * @return an instance of LiveMetricsClientImpl. + */ + @Generated + private LiveMetricsClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "https://global.livediagnostics.monitor.azure.com"; + LiveMetricsServiceVersion localServiceVersion + = (serviceVersion != null) ? serviceVersion : LiveMetricsServiceVersion.getLatest(); + LiveMetricsClientImpl client = new LiveMetricsClientImpl(localPipeline, + JacksonAdapter.createDefaultSerializerAdapter(), localEndpoint, 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. + } + + @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 LiveMetricsAsyncClient class. + * + * @return an instance of LiveMetricsAsyncClient. + */ + @Generated + public LiveMetricsAsyncClient buildAsyncClient() { + return new LiveMetricsAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of LiveMetricsClient class. + * + * @return an instance of LiveMetricsClient. + */ + @Generated + public LiveMetricsClient buildClient() { + return new LiveMetricsClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(LiveMetricsClientBuilder.class); +} diff --git a/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/LiveMetricsServiceVersion.java b/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/LiveMetricsServiceVersion.java new file mode 100644 index 000000000000..583554c110e8 --- /dev/null +++ b/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/LiveMetricsServiceVersion.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.applicationinsights.livemetrics; + +import com.azure.core.util.ServiceVersion; + +/** + * Service version of LiveMetricsClient. + */ +public enum LiveMetricsServiceVersion implements ServiceVersion { + /** + * Enum value 2024-04-01-preview. + */ + V2024_04_01_PREVIEW("2024-04-01-preview"); + + private final String version; + + LiveMetricsServiceVersion(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 LiveMetricsServiceVersion}. + */ + public static LiveMetricsServiceVersion getLatest() { + return V2024_04_01_PREVIEW; + } +} diff --git a/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/implementation/LiveMetricsClientImpl.java b/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/implementation/LiveMetricsClientImpl.java new file mode 100644 index 000000000000..a89668629b09 --- /dev/null +++ b/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/implementation/LiveMetricsClientImpl.java @@ -0,0 +1,768 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.applicationinsights.livemetrics.implementation; + +import com.azure.applicationinsights.livemetrics.LiveMetricsServiceVersion; +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +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.HttpHeaderName; +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.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 LiveMetricsClient type. + */ +public final class LiveMetricsClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final LiveMetricsClientService service; + + /** + * The endpoint of the Live Metrics service. + */ + private final String endpoint; + + /** + * Gets The endpoint of the Live Metrics service. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * Service version. + */ + private final LiveMetricsServiceVersion serviceVersion; + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public LiveMetricsServiceVersion 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 LiveMetricsClient client. + * + * @param endpoint The endpoint of the Live Metrics service. + * @param serviceVersion Service version. + */ + public LiveMetricsClientImpl(String endpoint, LiveMetricsServiceVersion serviceVersion) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); + } + + /** + * Initializes an instance of LiveMetricsClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint The endpoint of the Live Metrics service. + * @param serviceVersion Service version. + */ + public LiveMetricsClientImpl(HttpPipeline httpPipeline, String endpoint, LiveMetricsServiceVersion serviceVersion) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); + } + + /** + * Initializes an instance of LiveMetricsClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param serializerAdapter The serializer to serialize an object into a string. + * @param endpoint The endpoint of the Live Metrics service. + * @param serviceVersion Service version. + */ + public LiveMetricsClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint, + LiveMetricsServiceVersion serviceVersion) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.serviceVersion = serviceVersion; + this.service = RestProxy.create(LiveMetricsClientService.class, this.httpPipeline, this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for LiveMetricsClient to be used by the proxy service to perform REST + * calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "LiveMetricsClient") + public interface LiveMetricsClientService { + @Post("/QuickPulseService.svc/ping") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> isSubscribed(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @QueryParam("ikey") String ikey, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Post("/QuickPulseService.svc/ping") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response isSubscribedSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @QueryParam("ikey") String ikey, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Post("/QuickPulseService.svc/post") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> publish(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @QueryParam("ikey") String ikey, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Post("/QuickPulseService.svc/post") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response publishSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @QueryParam("ikey") String ikey, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + } + + /** + * Determine whether there is any subscription to the metrics and documents. + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
Content-TypeStringNoThe content type. Allowed values: + * "application/json".
x-ms-qps-transmission-timeLongNoTimestamp when the client transmits the + * metrics and documents to Live Metrics. A 8-byte long type of ticks.
x-ms-qps-machine-nameStringNoComputer name where Application Insights SDK + * lives. Live Metrics uses machine name with instance name as a backup.
x-ms-qps-instance-nameStringNoService instance name where Application Insights + * SDK lives. Live Metrics uses machine name with instance name as a backup.
x-ms-qps-stream-idStringNoIdentifies an Application Insights SDK as trusted + * agent to report metrics and documents.
x-ms-qps-role-nameStringNoCloud role name of the service.
x-ms-qps-invariant-versionStringNoVersion/generation of the data contract + * (MonitoringDataPoint) between the client and Live Metrics.
x-ms-qps-configuration-etagStringNoAn encoded string that indicates whether + * the collection configuration is changed.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     Version: String (Required)
+     *     InvariantVersion: int (Required)
+     *     Instance: String (Required)
+     *     RoleName: String (Required)
+     *     MachineName: String (Required)
+     *     StreamId: String (Required)
+     *     Timestamp: OffsetDateTime (Optional)
+     *     TransmissionTime: OffsetDateTime (Optional)
+     *     IsWebApp: boolean (Required)
+     *     PerformanceCollectionSupported: boolean (Required)
+     *     Metrics (Optional): [
+     *          (Optional){
+     *             Name: String (Required)
+     *             Value: double (Required)
+     *             Weight: int (Required)
+     *         }
+     *     ]
+     *     Documents (Optional): [
+     *          (Optional){
+     *             DocumentType: String(Request/RemoteDependency/Exception/Event/Trace/Unknown) (Required)
+     *             DocumentStreamIds (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             Properties (Optional): [
+     *                  (Optional){
+     *                     key: String (Required)
+     *                     value: String (Required)
+     *                 }
+     *             ]
+     *         }
+     *     ]
+     *     TopCpuProcesses (Optional): [
+     *          (Optional){
+     *             ProcessName: String (Required)
+     *             CpuPercentage: int (Required)
+     *         }
+     *     ]
+     *     CollectionConfigurationErrors (Optional): [
+     *          (Optional){
+     *             CollectionConfigurationErrorType: String(Unknown/PerformanceCounterParsing/PerformanceCounterUnexpected/PerformanceCounterDuplicateIds/DocumentStreamDuplicateIds/DocumentStreamFailureToCreate/DocumentStreamFailureToCreateFilterUnexpected/MetricDuplicateIds/MetricTelemetryTypeUnsupported/MetricFailureToCreate/MetricFailureToCreateFilterUnexpected/FilterFailureToCreateUnexpected/CollectionConfigurationFailureToCreateUnexpected) (Required)
+     *             Message: String (Required)
+     *             FullException: String (Required)
+     *             Data (Required): [
+     *                 (recursive schema, see above)
+     *             ]
+     *         }
+     *     ]
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     ETag: String (Required)
+     *     Metrics (Required): [
+     *          (Required){
+     *             Id: String (Required)
+     *             TelemetryType: String (Required)
+     *             FilterGroups (Required): [
+     *                  (Required){
+     *                     Filters (Required): [
+     *                          (Required){
+     *                             FieldName: String (Required)
+     *                             Predicate: String(Equal/NotEqual/LessThan/GreaterThan/LessThanOrEqual/GreaterThanOrEqual/Contains/DoesNotContain) (Required)
+     *                             Comparand: String (Required)
+     *                         }
+     *                     ]
+     *                 }
+     *             ]
+     *             Projection: String (Required)
+     *             Aggregation: String(Avg/Sum/Min/Max) (Required)
+     *             BackEndAggregation: String(Avg/Sum/Min/Max) (Required)
+     *         }
+     *     ]
+     *     DocumentStreams (Required): [
+     *          (Required){
+     *             Id: String (Required)
+     *             DocumentFilterGroups (Required): [
+     *                  (Required){
+     *                     TelemetryType: String(Request/Dependency/Exception/Event/Metric/PerformanceCounter/Trace) (Required)
+     *                     Filters (Required): (recursive schema, see Filters above)
+     *                 }
+     *             ]
+     *         }
+     *     ]
+     *     QuotaInfo (Optional): {
+     *         InitialQuota: Double (Optional)
+     *         MaxQuota: double (Required)
+     *         QuotaAccrualRatePerSec: double (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param ikey The instrumentation key of the target Application Insights component for which the client checks + * whether there's any subscription to it. + * @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 represents the collection configuration - a customizable description of performance counters, metrics, + * and full telemetry documents to be collected by the client SDK along with {@link Response} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> isSubscribedWithResponseAsync(String ikey, RequestOptions requestOptions) { + final String accept = "application/json"; + RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions; + requestOptionsLocal.addRequestCallback(requestLocal -> { + if (requestLocal.getBody() != null && requestLocal.getHeaders().get(HttpHeaderName.CONTENT_TYPE) == null) { + requestLocal.getHeaders().set(HttpHeaderName.CONTENT_TYPE, "application/json"); + } + }); + return FluxUtil.withContext(context -> service.isSubscribed(this.getEndpoint(), + this.getServiceVersion().getVersion(), ikey, accept, requestOptionsLocal, context)); + } + + /** + * Determine whether there is any subscription to the metrics and documents. + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
Content-TypeStringNoThe content type. Allowed values: + * "application/json".
x-ms-qps-transmission-timeLongNoTimestamp when the client transmits the + * metrics and documents to Live Metrics. A 8-byte long type of ticks.
x-ms-qps-machine-nameStringNoComputer name where Application Insights SDK + * lives. Live Metrics uses machine name with instance name as a backup.
x-ms-qps-instance-nameStringNoService instance name where Application Insights + * SDK lives. Live Metrics uses machine name with instance name as a backup.
x-ms-qps-stream-idStringNoIdentifies an Application Insights SDK as trusted + * agent to report metrics and documents.
x-ms-qps-role-nameStringNoCloud role name of the service.
x-ms-qps-invariant-versionStringNoVersion/generation of the data contract + * (MonitoringDataPoint) between the client and Live Metrics.
x-ms-qps-configuration-etagStringNoAn encoded string that indicates whether + * the collection configuration is changed.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     Version: String (Required)
+     *     InvariantVersion: int (Required)
+     *     Instance: String (Required)
+     *     RoleName: String (Required)
+     *     MachineName: String (Required)
+     *     StreamId: String (Required)
+     *     Timestamp: OffsetDateTime (Optional)
+     *     TransmissionTime: OffsetDateTime (Optional)
+     *     IsWebApp: boolean (Required)
+     *     PerformanceCollectionSupported: boolean (Required)
+     *     Metrics (Optional): [
+     *          (Optional){
+     *             Name: String (Required)
+     *             Value: double (Required)
+     *             Weight: int (Required)
+     *         }
+     *     ]
+     *     Documents (Optional): [
+     *          (Optional){
+     *             DocumentType: String(Request/RemoteDependency/Exception/Event/Trace/Unknown) (Required)
+     *             DocumentStreamIds (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             Properties (Optional): [
+     *                  (Optional){
+     *                     key: String (Required)
+     *                     value: String (Required)
+     *                 }
+     *             ]
+     *         }
+     *     ]
+     *     TopCpuProcesses (Optional): [
+     *          (Optional){
+     *             ProcessName: String (Required)
+     *             CpuPercentage: int (Required)
+     *         }
+     *     ]
+     *     CollectionConfigurationErrors (Optional): [
+     *          (Optional){
+     *             CollectionConfigurationErrorType: String(Unknown/PerformanceCounterParsing/PerformanceCounterUnexpected/PerformanceCounterDuplicateIds/DocumentStreamDuplicateIds/DocumentStreamFailureToCreate/DocumentStreamFailureToCreateFilterUnexpected/MetricDuplicateIds/MetricTelemetryTypeUnsupported/MetricFailureToCreate/MetricFailureToCreateFilterUnexpected/FilterFailureToCreateUnexpected/CollectionConfigurationFailureToCreateUnexpected) (Required)
+     *             Message: String (Required)
+     *             FullException: String (Required)
+     *             Data (Required): [
+     *                 (recursive schema, see above)
+     *             ]
+     *         }
+     *     ]
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     ETag: String (Required)
+     *     Metrics (Required): [
+     *          (Required){
+     *             Id: String (Required)
+     *             TelemetryType: String (Required)
+     *             FilterGroups (Required): [
+     *                  (Required){
+     *                     Filters (Required): [
+     *                          (Required){
+     *                             FieldName: String (Required)
+     *                             Predicate: String(Equal/NotEqual/LessThan/GreaterThan/LessThanOrEqual/GreaterThanOrEqual/Contains/DoesNotContain) (Required)
+     *                             Comparand: String (Required)
+     *                         }
+     *                     ]
+     *                 }
+     *             ]
+     *             Projection: String (Required)
+     *             Aggregation: String(Avg/Sum/Min/Max) (Required)
+     *             BackEndAggregation: String(Avg/Sum/Min/Max) (Required)
+     *         }
+     *     ]
+     *     DocumentStreams (Required): [
+     *          (Required){
+     *             Id: String (Required)
+     *             DocumentFilterGroups (Required): [
+     *                  (Required){
+     *                     TelemetryType: String(Request/Dependency/Exception/Event/Metric/PerformanceCounter/Trace) (Required)
+     *                     Filters (Required): (recursive schema, see Filters above)
+     *                 }
+     *             ]
+     *         }
+     *     ]
+     *     QuotaInfo (Optional): {
+     *         InitialQuota: Double (Optional)
+     *         MaxQuota: double (Required)
+     *         QuotaAccrualRatePerSec: double (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param ikey The instrumentation key of the target Application Insights component for which the client checks + * whether there's any subscription to it. + * @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 represents the collection configuration - a customizable description of performance counters, metrics, + * and full telemetry documents to be collected by the client SDK along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response isSubscribedWithResponse(String ikey, RequestOptions requestOptions) { + final String accept = "application/json"; + RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions; + requestOptionsLocal.addRequestCallback(requestLocal -> { + if (requestLocal.getBody() != null && requestLocal.getHeaders().get(HttpHeaderName.CONTENT_TYPE) == null) { + requestLocal.getHeaders().set(HttpHeaderName.CONTENT_TYPE, "application/json"); + } + }); + return service.isSubscribedSync(this.getEndpoint(), this.getServiceVersion().getVersion(), ikey, accept, + requestOptionsLocal, Context.NONE); + } + + /** + * Publish live metrics to the Live Metrics service when there is an active subscription to the metrics. + *

Header Parameters

+ * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
Content-TypeStringNoThe content type. Allowed values: + * "application/json".
x-ms-qps-configuration-etagStringNoAn encoded string that indicates whether + * the collection configuration is changed.
x-ms-qps-transmission-timeLongNoTimestamp when the client transmits the + * metrics and documents to Live Metrics. A 8-byte long type of ticks.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
+     * {@code
+     * [
+     *      (Optional){
+     *         Version: String (Required)
+     *         InvariantVersion: int (Required)
+     *         Instance: String (Required)
+     *         RoleName: String (Required)
+     *         MachineName: String (Required)
+     *         StreamId: String (Required)
+     *         Timestamp: OffsetDateTime (Optional)
+     *         TransmissionTime: OffsetDateTime (Optional)
+     *         IsWebApp: boolean (Required)
+     *         PerformanceCollectionSupported: boolean (Required)
+     *         Metrics (Optional): [
+     *              (Optional){
+     *                 Name: String (Required)
+     *                 Value: double (Required)
+     *                 Weight: int (Required)
+     *             }
+     *         ]
+     *         Documents (Optional): [
+     *              (Optional){
+     *                 DocumentType: String(Request/RemoteDependency/Exception/Event/Trace/Unknown) (Required)
+     *                 DocumentStreamIds (Optional): [
+     *                     String (Optional)
+     *                 ]
+     *                 Properties (Optional): [
+     *                      (Optional){
+     *                         key: String (Required)
+     *                         value: String (Required)
+     *                     }
+     *                 ]
+     *             }
+     *         ]
+     *         TopCpuProcesses (Optional): [
+     *              (Optional){
+     *                 ProcessName: String (Required)
+     *                 CpuPercentage: int (Required)
+     *             }
+     *         ]
+     *         CollectionConfigurationErrors (Optional): [
+     *              (Optional){
+     *                 CollectionConfigurationErrorType: String(Unknown/PerformanceCounterParsing/PerformanceCounterUnexpected/PerformanceCounterDuplicateIds/DocumentStreamDuplicateIds/DocumentStreamFailureToCreate/DocumentStreamFailureToCreateFilterUnexpected/MetricDuplicateIds/MetricTelemetryTypeUnsupported/MetricFailureToCreate/MetricFailureToCreateFilterUnexpected/FilterFailureToCreateUnexpected/CollectionConfigurationFailureToCreateUnexpected) (Required)
+     *                 Message: String (Required)
+     *                 FullException: String (Required)
+     *                 Data (Required): [
+     *                     (recursive schema, see above)
+     *                 ]
+     *             }
+     *         ]
+     *     }
+     * ]
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     ETag: String (Required)
+     *     Metrics (Required): [
+     *          (Required){
+     *             Id: String (Required)
+     *             TelemetryType: String (Required)
+     *             FilterGroups (Required): [
+     *                  (Required){
+     *                     Filters (Required): [
+     *                          (Required){
+     *                             FieldName: String (Required)
+     *                             Predicate: String(Equal/NotEqual/LessThan/GreaterThan/LessThanOrEqual/GreaterThanOrEqual/Contains/DoesNotContain) (Required)
+     *                             Comparand: String (Required)
+     *                         }
+     *                     ]
+     *                 }
+     *             ]
+     *             Projection: String (Required)
+     *             Aggregation: String(Avg/Sum/Min/Max) (Required)
+     *             BackEndAggregation: String(Avg/Sum/Min/Max) (Required)
+     *         }
+     *     ]
+     *     DocumentStreams (Required): [
+     *          (Required){
+     *             Id: String (Required)
+     *             DocumentFilterGroups (Required): [
+     *                  (Required){
+     *                     TelemetryType: String(Request/Dependency/Exception/Event/Metric/PerformanceCounter/Trace) (Required)
+     *                     Filters (Required): (recursive schema, see Filters above)
+     *                 }
+     *             ]
+     *         }
+     *     ]
+     *     QuotaInfo (Optional): {
+     *         InitialQuota: Double (Optional)
+     *         MaxQuota: double (Required)
+     *         QuotaAccrualRatePerSec: double (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param ikey The instrumentation key of the target Application Insights component for which the client checks + * whether there's any subscription to it. + * @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 represents the collection configuration - a customizable description of performance counters, metrics, + * and full telemetry documents to be collected by the client SDK along with {@link Response} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> publishWithResponseAsync(String ikey, RequestOptions requestOptions) { + final String accept = "application/json"; + RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions; + requestOptionsLocal.addRequestCallback(requestLocal -> { + if (requestLocal.getBody() != null && requestLocal.getHeaders().get(HttpHeaderName.CONTENT_TYPE) == null) { + requestLocal.getHeaders().set(HttpHeaderName.CONTENT_TYPE, "application/json"); + } + }); + return FluxUtil.withContext(context -> service.publish(this.getEndpoint(), + this.getServiceVersion().getVersion(), ikey, accept, requestOptionsLocal, context)); + } + + /** + * Publish live metrics to the Live Metrics service when there is an active subscription to the metrics. + *

Header Parameters

+ * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
Content-TypeStringNoThe content type. Allowed values: + * "application/json".
x-ms-qps-configuration-etagStringNoAn encoded string that indicates whether + * the collection configuration is changed.
x-ms-qps-transmission-timeLongNoTimestamp when the client transmits the + * metrics and documents to Live Metrics. A 8-byte long type of ticks.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
+     * {@code
+     * [
+     *      (Optional){
+     *         Version: String (Required)
+     *         InvariantVersion: int (Required)
+     *         Instance: String (Required)
+     *         RoleName: String (Required)
+     *         MachineName: String (Required)
+     *         StreamId: String (Required)
+     *         Timestamp: OffsetDateTime (Optional)
+     *         TransmissionTime: OffsetDateTime (Optional)
+     *         IsWebApp: boolean (Required)
+     *         PerformanceCollectionSupported: boolean (Required)
+     *         Metrics (Optional): [
+     *              (Optional){
+     *                 Name: String (Required)
+     *                 Value: double (Required)
+     *                 Weight: int (Required)
+     *             }
+     *         ]
+     *         Documents (Optional): [
+     *              (Optional){
+     *                 DocumentType: String(Request/RemoteDependency/Exception/Event/Trace/Unknown) (Required)
+     *                 DocumentStreamIds (Optional): [
+     *                     String (Optional)
+     *                 ]
+     *                 Properties (Optional): [
+     *                      (Optional){
+     *                         key: String (Required)
+     *                         value: String (Required)
+     *                     }
+     *                 ]
+     *             }
+     *         ]
+     *         TopCpuProcesses (Optional): [
+     *              (Optional){
+     *                 ProcessName: String (Required)
+     *                 CpuPercentage: int (Required)
+     *             }
+     *         ]
+     *         CollectionConfigurationErrors (Optional): [
+     *              (Optional){
+     *                 CollectionConfigurationErrorType: String(Unknown/PerformanceCounterParsing/PerformanceCounterUnexpected/PerformanceCounterDuplicateIds/DocumentStreamDuplicateIds/DocumentStreamFailureToCreate/DocumentStreamFailureToCreateFilterUnexpected/MetricDuplicateIds/MetricTelemetryTypeUnsupported/MetricFailureToCreate/MetricFailureToCreateFilterUnexpected/FilterFailureToCreateUnexpected/CollectionConfigurationFailureToCreateUnexpected) (Required)
+     *                 Message: String (Required)
+     *                 FullException: String (Required)
+     *                 Data (Required): [
+     *                     (recursive schema, see above)
+     *                 ]
+     *             }
+     *         ]
+     *     }
+     * ]
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     ETag: String (Required)
+     *     Metrics (Required): [
+     *          (Required){
+     *             Id: String (Required)
+     *             TelemetryType: String (Required)
+     *             FilterGroups (Required): [
+     *                  (Required){
+     *                     Filters (Required): [
+     *                          (Required){
+     *                             FieldName: String (Required)
+     *                             Predicate: String(Equal/NotEqual/LessThan/GreaterThan/LessThanOrEqual/GreaterThanOrEqual/Contains/DoesNotContain) (Required)
+     *                             Comparand: String (Required)
+     *                         }
+     *                     ]
+     *                 }
+     *             ]
+     *             Projection: String (Required)
+     *             Aggregation: String(Avg/Sum/Min/Max) (Required)
+     *             BackEndAggregation: String(Avg/Sum/Min/Max) (Required)
+     *         }
+     *     ]
+     *     DocumentStreams (Required): [
+     *          (Required){
+     *             Id: String (Required)
+     *             DocumentFilterGroups (Required): [
+     *                  (Required){
+     *                     TelemetryType: String(Request/Dependency/Exception/Event/Metric/PerformanceCounter/Trace) (Required)
+     *                     Filters (Required): (recursive schema, see Filters above)
+     *                 }
+     *             ]
+     *         }
+     *     ]
+     *     QuotaInfo (Optional): {
+     *         InitialQuota: Double (Optional)
+     *         MaxQuota: double (Required)
+     *         QuotaAccrualRatePerSec: double (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param ikey The instrumentation key of the target Application Insights component for which the client checks + * whether there's any subscription to it. + * @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 represents the collection configuration - a customizable description of performance counters, metrics, + * and full telemetry documents to be collected by the client SDK along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response publishWithResponse(String ikey, RequestOptions requestOptions) { + final String accept = "application/json"; + RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions; + requestOptionsLocal.addRequestCallback(requestLocal -> { + if (requestLocal.getBody() != null && requestLocal.getHeaders().get(HttpHeaderName.CONTENT_TYPE) == null) { + requestLocal.getHeaders().set(HttpHeaderName.CONTENT_TYPE, "application/json"); + } + }); + return service.publishSync(this.getEndpoint(), this.getServiceVersion().getVersion(), ikey, accept, + requestOptionsLocal, Context.NONE); + } +} diff --git a/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/implementation/package-info.java b/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/implementation/package-info.java new file mode 100644 index 000000000000..35e2400fb27a --- /dev/null +++ b/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/implementation/package-info.java @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the implementations for LiveMetrics. + * Live Metrics REST APIs. + */ +package com.azure.applicationinsights.livemetrics.implementation; diff --git a/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/models/AggregationType.java b/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/models/AggregationType.java new file mode 100644 index 000000000000..749216a70674 --- /dev/null +++ b/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/models/AggregationType.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.applicationinsights.livemetrics.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Aggregation type. + */ +public final class AggregationType extends ExpandableStringEnum { + /** + * Average. + */ + @Generated + public static final AggregationType AVG = fromString("Avg"); + + /** + * Sum. + */ + @Generated + public static final AggregationType SUM = fromString("Sum"); + + /** + * Minimum. + */ + @Generated + public static final AggregationType MIN = fromString("Min"); + + /** + * Maximum. + */ + @Generated + public static final AggregationType MAX = fromString("Max"); + + /** + * Creates a new instance of AggregationType value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public AggregationType() { + } + + /** + * Creates or finds a AggregationType from its string representation. + * + * @param name a name to look for. + * @return the corresponding AggregationType. + */ + @Generated + public static AggregationType fromString(String name) { + return fromString(name, AggregationType.class); + } + + /** + * Gets known AggregationType values. + * + * @return known AggregationType values. + */ + @Generated + public static Collection values() { + return values(AggregationType.class); + } +} diff --git a/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/models/CollectionConfigurationError.java b/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/models/CollectionConfigurationError.java new file mode 100644 index 000000000000..e8b5ea07da01 --- /dev/null +++ b/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/models/CollectionConfigurationError.java @@ -0,0 +1,152 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.applicationinsights.livemetrics.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; + +/** + * Represents an error while SDK parses and applies an instance of CollectionConfigurationInfo. + */ +@Immutable +public final class CollectionConfigurationError implements JsonSerializable { + /* + * Error type. + */ + @Generated + private final CollectionConfigurationErrorType collectionConfigurationErrorType; + + /* + * Error message. + */ + @Generated + private final String message; + + /* + * Exception that led to the creation of the configuration error. + */ + @Generated + private final String fullException; + + /* + * Custom properties to add more information to the error. + */ + @Generated + private final List data; + + /** + * Creates an instance of CollectionConfigurationError class. + * + * @param collectionConfigurationErrorType the collectionConfigurationErrorType value to set. + * @param message the message value to set. + * @param fullException the fullException value to set. + * @param data the data value to set. + */ + @Generated + public CollectionConfigurationError(CollectionConfigurationErrorType collectionConfigurationErrorType, + String message, String fullException, List data) { + this.collectionConfigurationErrorType = collectionConfigurationErrorType; + this.message = message; + this.fullException = fullException; + this.data = data; + } + + /** + * Get the collectionConfigurationErrorType property: Error type. + * + * @return the collectionConfigurationErrorType value. + */ + @Generated + public CollectionConfigurationErrorType getCollectionConfigurationErrorType() { + return this.collectionConfigurationErrorType; + } + + /** + * Get the message property: Error message. + * + * @return the message value. + */ + @Generated + public String getMessage() { + return this.message; + } + + /** + * Get the fullException property: Exception that led to the creation of the configuration error. + * + * @return the fullException value. + */ + @Generated + public String getFullException() { + return this.fullException; + } + + /** + * Get the data property: Custom properties to add more information to the error. + * + * @return the data value. + */ + @Generated + public List getData() { + return this.data; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("CollectionConfigurationErrorType", + this.collectionConfigurationErrorType == null ? null : this.collectionConfigurationErrorType.toString()); + jsonWriter.writeStringField("Message", this.message); + jsonWriter.writeStringField("FullException", this.fullException); + jsonWriter.writeArrayField("Data", this.data, (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of CollectionConfigurationError from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of CollectionConfigurationError 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 CollectionConfigurationError. + */ + @Generated + public static CollectionConfigurationError fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + CollectionConfigurationErrorType collectionConfigurationErrorType = null; + String message = null; + String fullException = null; + List data = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("CollectionConfigurationErrorType".equals(fieldName)) { + collectionConfigurationErrorType = CollectionConfigurationErrorType.fromString(reader.getString()); + } else if ("Message".equals(fieldName)) { + message = reader.getString(); + } else if ("FullException".equals(fieldName)) { + fullException = reader.getString(); + } else if ("Data".equals(fieldName)) { + data = reader.readArray(reader1 -> KeyValuePairStringString.fromJson(reader1)); + } else { + reader.skipChildren(); + } + } + return new CollectionConfigurationError(collectionConfigurationErrorType, message, fullException, data); + }); + } +} diff --git a/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/models/CollectionConfigurationErrorType.java b/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/models/CollectionConfigurationErrorType.java new file mode 100644 index 000000000000..b7d9450e449f --- /dev/null +++ b/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/models/CollectionConfigurationErrorType.java @@ -0,0 +1,133 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.applicationinsights.livemetrics.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Collection configuration error type reported by the client SDK. + */ +public final class CollectionConfigurationErrorType extends ExpandableStringEnum { + /** + * Unknown error type. + */ + @Generated + public static final CollectionConfigurationErrorType UNKNOWN = fromString("Unknown"); + + /** + * Performance counter parsing error. + */ + @Generated + public static final CollectionConfigurationErrorType PERFORMANCE_COUNTER_PARSING + = fromString("PerformanceCounterParsing"); + + /** + * Performance counter unexpected error. + */ + @Generated + public static final CollectionConfigurationErrorType PERFORMANCE_COUNTER_UNEXPECTED + = fromString("PerformanceCounterUnexpected"); + + /** + * Performance counter duplicate ids. + */ + @Generated + public static final CollectionConfigurationErrorType PERFORMANCE_COUNTER_DUPLICATE_IDS + = fromString("PerformanceCounterDuplicateIds"); + + /** + * Document stream duplication ids. + */ + @Generated + public static final CollectionConfigurationErrorType DOCUMENT_STREAM_DUPLICATE_IDS + = fromString("DocumentStreamDuplicateIds"); + + /** + * Document stream failed to create. + */ + @Generated + public static final CollectionConfigurationErrorType DOCUMENT_STREAM_FAILURE_TO_CREATE + = fromString("DocumentStreamFailureToCreate"); + + /** + * Document stream failed to create filter unexpectedly. + */ + @Generated + public static final CollectionConfigurationErrorType DOCUMENT_STREAM_FAILURE_TO_CREATE_FILTER_UNEXPECTED + = fromString("DocumentStreamFailureToCreateFilterUnexpected"); + + /** + * Metric duplicate ids. + */ + @Generated + public static final CollectionConfigurationErrorType METRIC_DUPLICATE_IDS = fromString("MetricDuplicateIds"); + + /** + * Metric telemetry type unsupported. + */ + @Generated + public static final CollectionConfigurationErrorType METRIC_TELEMETRY_TYPE_UNSUPPORTED + = fromString("MetricTelemetryTypeUnsupported"); + + /** + * Metric failed to create. + */ + @Generated + public static final CollectionConfigurationErrorType METRIC_FAILURE_TO_CREATE = fromString("MetricFailureToCreate"); + + /** + * Metric failed to create filter unexpectedly. + */ + @Generated + public static final CollectionConfigurationErrorType METRIC_FAILURE_TO_CREATE_FILTER_UNEXPECTED + = fromString("MetricFailureToCreateFilterUnexpected"); + + /** + * Filter failed to create unexpectedly. + */ + @Generated + public static final CollectionConfigurationErrorType FILTER_FAILURE_TO_CREATE_UNEXPECTED + = fromString("FilterFailureToCreateUnexpected"); + + /** + * Collection configuration failed to create unexpectedly. + */ + @Generated + public static final CollectionConfigurationErrorType COLLECTION_CONFIGURATION_FAILURE_TO_CREATE_UNEXPECTED + = fromString("CollectionConfigurationFailureToCreateUnexpected"); + + /** + * Creates a new instance of CollectionConfigurationErrorType value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public CollectionConfigurationErrorType() { + } + + /** + * Creates or finds a CollectionConfigurationErrorType from its string representation. + * + * @param name a name to look for. + * @return the corresponding CollectionConfigurationErrorType. + */ + @Generated + public static CollectionConfigurationErrorType fromString(String name) { + return fromString(name, CollectionConfigurationErrorType.class); + } + + /** + * Gets known CollectionConfigurationErrorType values. + * + * @return known CollectionConfigurationErrorType values. + */ + @Generated + public static Collection values() { + return values(CollectionConfigurationErrorType.class); + } +} diff --git a/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/models/CollectionConfigurationInfo.java b/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/models/CollectionConfigurationInfo.java new file mode 100644 index 000000000000..bc640d41ab37 --- /dev/null +++ b/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/models/CollectionConfigurationInfo.java @@ -0,0 +1,155 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.applicationinsights.livemetrics.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; + +/** + * Represents the collection configuration - a customizable description of performance counters, metrics, and full + * telemetry documents to be collected by the client SDK. + */ +@Immutable +public final class CollectionConfigurationInfo implements JsonSerializable { + /* + * An encoded string that indicates whether the collection configuration is changed. + */ + @Generated + private final String eTag; + + /* + * An array of metric configuration info. + */ + @Generated + private final List metrics; + + /* + * An array of document stream configuration info. + */ + @Generated + private final List documentStreams; + + /* + * Controls document quotas to be sent to Live Metrics. + */ + @Generated + private QuotaConfigurationInfo quotaInfo; + + /** + * Creates an instance of CollectionConfigurationInfo class. + * + * @param eTag the eTag value to set. + * @param metrics the metrics value to set. + * @param documentStreams the documentStreams value to set. + */ + @Generated + private CollectionConfigurationInfo(String eTag, List metrics, + List documentStreams) { + this.eTag = eTag; + this.metrics = metrics; + this.documentStreams = documentStreams; + } + + /** + * Get the eTag property: An encoded string that indicates whether the collection configuration is changed. + * + * @return the eTag value. + */ + @Generated + public String getETag() { + return this.eTag; + } + + /** + * Get the metrics property: An array of metric configuration info. + * + * @return the metrics value. + */ + @Generated + public List getMetrics() { + return this.metrics; + } + + /** + * Get the documentStreams property: An array of document stream configuration info. + * + * @return the documentStreams value. + */ + @Generated + public List getDocumentStreams() { + return this.documentStreams; + } + + /** + * Get the quotaInfo property: Controls document quotas to be sent to Live Metrics. + * + * @return the quotaInfo value. + */ + @Generated + public QuotaConfigurationInfo getQuotaInfo() { + return this.quotaInfo; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("ETag", this.eTag); + jsonWriter.writeArrayField("Metrics", this.metrics, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeArrayField("DocumentStreams", this.documentStreams, + (writer, element) -> writer.writeJson(element)); + jsonWriter.writeJsonField("QuotaInfo", this.quotaInfo); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of CollectionConfigurationInfo from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of CollectionConfigurationInfo 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 CollectionConfigurationInfo. + */ + @Generated + public static CollectionConfigurationInfo fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String eTag = null; + List metrics = null; + List documentStreams = null; + QuotaConfigurationInfo quotaInfo = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("ETag".equals(fieldName)) { + eTag = reader.getString(); + } else if ("Metrics".equals(fieldName)) { + metrics = reader.readArray(reader1 -> DerivedMetricInfo.fromJson(reader1)); + } else if ("DocumentStreams".equals(fieldName)) { + documentStreams = reader.readArray(reader1 -> DocumentStreamInfo.fromJson(reader1)); + } else if ("QuotaInfo".equals(fieldName)) { + quotaInfo = QuotaConfigurationInfo.fromJson(reader); + } else { + reader.skipChildren(); + } + } + CollectionConfigurationInfo deserializedCollectionConfigurationInfo + = new CollectionConfigurationInfo(eTag, metrics, documentStreams); + deserializedCollectionConfigurationInfo.quotaInfo = quotaInfo; + + return deserializedCollectionConfigurationInfo; + }); + } +} diff --git a/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/models/DerivedMetricInfo.java b/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/models/DerivedMetricInfo.java new file mode 100644 index 000000000000..80ffe34341a7 --- /dev/null +++ b/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/models/DerivedMetricInfo.java @@ -0,0 +1,199 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.applicationinsights.livemetrics.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; + +/** + * A metric configuration set by UX to scope the metrics it's interested in. + */ +@Immutable +public final class DerivedMetricInfo implements JsonSerializable { + /* + * metric configuration identifier. + */ + @Generated + private final String id; + + /* + * Telemetry type. + */ + @Generated + private final String telemetryType; + + /* + * A collection of filters to scope metrics that UX needs. + */ + @Generated + private final List filterGroups; + + /* + * Telemetry's metric dimension whose value is to be aggregated. Example values: Duration, Count(),... + */ + @Generated + private final String projection; + + /* + * Aggregation type. This is the aggregation done from everything within a single server. + */ + @Generated + private final AggregationType aggregation; + + /* + * Aggregation type. This Aggregation is done across the values for all the servers taken together. + */ + @Generated + private final AggregationType backEndAggregation; + + /** + * Creates an instance of DerivedMetricInfo class. + * + * @param id the id value to set. + * @param telemetryType the telemetryType value to set. + * @param filterGroups the filterGroups value to set. + * @param projection the projection value to set. + * @param aggregation the aggregation value to set. + * @param backEndAggregation the backEndAggregation value to set. + */ + @Generated + private DerivedMetricInfo(String id, String telemetryType, List filterGroups, + String projection, AggregationType aggregation, AggregationType backEndAggregation) { + this.id = id; + this.telemetryType = telemetryType; + this.filterGroups = filterGroups; + this.projection = projection; + this.aggregation = aggregation; + this.backEndAggregation = backEndAggregation; + } + + /** + * Get the id property: metric configuration identifier. + * + * @return the id value. + */ + @Generated + public String getId() { + return this.id; + } + + /** + * Get the telemetryType property: Telemetry type. + * + * @return the telemetryType value. + */ + @Generated + public String getTelemetryType() { + return this.telemetryType; + } + + /** + * Get the filterGroups property: A collection of filters to scope metrics that UX needs. + * + * @return the filterGroups value. + */ + @Generated + public List getFilterGroups() { + return this.filterGroups; + } + + /** + * Get the projection property: Telemetry's metric dimension whose value is to be aggregated. Example values: + * Duration, Count(),... + * + * @return the projection value. + */ + @Generated + public String getProjection() { + return this.projection; + } + + /** + * Get the aggregation property: Aggregation type. This is the aggregation done from everything within a single + * server. + * + * @return the aggregation value. + */ + @Generated + public AggregationType getAggregation() { + return this.aggregation; + } + + /** + * Get the backEndAggregation property: Aggregation type. This Aggregation is done across the values for all the + * servers taken together. + * + * @return the backEndAggregation value. + */ + @Generated + public AggregationType getBackEndAggregation() { + return this.backEndAggregation; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("Id", this.id); + jsonWriter.writeStringField("TelemetryType", this.telemetryType); + jsonWriter.writeArrayField("FilterGroups", this.filterGroups, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeStringField("Projection", this.projection); + jsonWriter.writeStringField("Aggregation", this.aggregation == null ? null : this.aggregation.toString()); + jsonWriter.writeStringField("BackEndAggregation", + this.backEndAggregation == null ? null : this.backEndAggregation.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of DerivedMetricInfo from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of DerivedMetricInfo 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 DerivedMetricInfo. + */ + @Generated + public static DerivedMetricInfo fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String id = null; + String telemetryType = null; + List filterGroups = null; + String projection = null; + AggregationType aggregation = null; + AggregationType backEndAggregation = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("Id".equals(fieldName)) { + id = reader.getString(); + } else if ("TelemetryType".equals(fieldName)) { + telemetryType = reader.getString(); + } else if ("FilterGroups".equals(fieldName)) { + filterGroups = reader.readArray(reader1 -> FilterConjunctionGroupInfo.fromJson(reader1)); + } else if ("Projection".equals(fieldName)) { + projection = reader.getString(); + } else if ("Aggregation".equals(fieldName)) { + aggregation = AggregationType.fromString(reader.getString()); + } else if ("BackEndAggregation".equals(fieldName)) { + backEndAggregation = AggregationType.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + return new DerivedMetricInfo(id, telemetryType, filterGroups, projection, aggregation, backEndAggregation); + }); + } +} diff --git a/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/models/DocumentFilterConjunctionGroupInfo.java b/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/models/DocumentFilterConjunctionGroupInfo.java new file mode 100644 index 000000000000..6220463b09a8 --- /dev/null +++ b/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/models/DocumentFilterConjunctionGroupInfo.java @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.applicationinsights.livemetrics.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; + +/** + * A collection of filters for a specific telemetry type. + */ +@Immutable +public final class DocumentFilterConjunctionGroupInfo implements JsonSerializable { + /* + * Telemetry type. + */ + @Generated + private final TelemetryType telemetryType; + + /* + * An array of filter groups. + */ + @Generated + private final FilterConjunctionGroupInfo filters; + + /** + * Creates an instance of DocumentFilterConjunctionGroupInfo class. + * + * @param telemetryType the telemetryType value to set. + * @param filters the filters value to set. + */ + @Generated + private DocumentFilterConjunctionGroupInfo(TelemetryType telemetryType, FilterConjunctionGroupInfo filters) { + this.telemetryType = telemetryType; + this.filters = filters; + } + + /** + * Get the telemetryType property: Telemetry type. + * + * @return the telemetryType value. + */ + @Generated + public TelemetryType getTelemetryType() { + return this.telemetryType; + } + + /** + * Get the filters property: An array of filter groups. + * + * @return the filters value. + */ + @Generated + public FilterConjunctionGroupInfo getFilters() { + return this.filters; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("TelemetryType", this.telemetryType == null ? null : this.telemetryType.toString()); + jsonWriter.writeJsonField("Filters", this.filters); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of DocumentFilterConjunctionGroupInfo from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of DocumentFilterConjunctionGroupInfo 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 DocumentFilterConjunctionGroupInfo. + */ + @Generated + public static DocumentFilterConjunctionGroupInfo fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + TelemetryType telemetryType = null; + FilterConjunctionGroupInfo filters = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("TelemetryType".equals(fieldName)) { + telemetryType = TelemetryType.fromString(reader.getString()); + } else if ("Filters".equals(fieldName)) { + filters = FilterConjunctionGroupInfo.fromJson(reader); + } else { + reader.skipChildren(); + } + } + return new DocumentFilterConjunctionGroupInfo(telemetryType, filters); + }); + } +} diff --git a/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/models/DocumentIngress.java b/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/models/DocumentIngress.java new file mode 100644 index 000000000000..e1fa186fa30a --- /dev/null +++ b/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/models/DocumentIngress.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.applicationinsights.livemetrics.models; + +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.List; + +/** + * Base class of the specific document types. + */ +@Fluent +public class DocumentIngress implements JsonSerializable { + /* + * Telemetry type. Types not defined in enum will get replaced with a 'Unknown' type. + */ + @Generated + private DocumentType documentType = DocumentType.fromString("DocumentIngress"); + + /* + * An array of document streaming ids. Each id identifies a flow of documents customized by UX customers. + */ + @Generated + private List documentStreamIds; + + /* + * Collection of custom properties. + */ + @Generated + private List properties; + + /** + * Creates an instance of DocumentIngress class. + */ + @Generated + public DocumentIngress() { + } + + /** + * Get the documentType property: Telemetry type. Types not defined in enum will get replaced with a 'Unknown' type. + * + * @return the documentType value. + */ + @Generated + public DocumentType getDocumentType() { + return this.documentType; + } + + /** + * Get the documentStreamIds property: An array of document streaming ids. Each id identifies a flow of documents + * customized by UX customers. + * + * @return the documentStreamIds value. + */ + @Generated + public List getDocumentStreamIds() { + return this.documentStreamIds; + } + + /** + * Set the documentStreamIds property: An array of document streaming ids. Each id identifies a flow of documents + * customized by UX customers. + * + * @param documentStreamIds the documentStreamIds value to set. + * @return the DocumentIngress object itself. + */ + @Generated + public DocumentIngress setDocumentStreamIds(List documentStreamIds) { + this.documentStreamIds = documentStreamIds; + return this; + } + + /** + * Get the properties property: Collection of custom properties. + * + * @return the properties value. + */ + @Generated + public List getProperties() { + return this.properties; + } + + /** + * Set the properties property: Collection of custom properties. + * + * @param properties the properties value to set. + * @return the DocumentIngress object itself. + */ + @Generated + public DocumentIngress setProperties(List properties) { + this.properties = properties; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("DocumentType", this.documentType == null ? null : this.documentType.toString()); + jsonWriter.writeArrayField("DocumentStreamIds", this.documentStreamIds, + (writer, element) -> writer.writeString(element)); + jsonWriter.writeArrayField("Properties", this.properties, (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of DocumentIngress from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of DocumentIngress 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 DocumentIngress. + */ + @Generated + public static DocumentIngress 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 ("DocumentType".equals(fieldName)) { + discriminatorValue = readerToUse.getString(); + break; + } else { + readerToUse.skipChildren(); + } + } + // Use the discriminator value to determine which subtype should be deserialized. + if ("Request".equals(discriminatorValue)) { + return Request.fromJson(readerToUse.reset()); + } else if ("RemoteDependency".equals(discriminatorValue)) { + return RemoteDependency.fromJson(readerToUse.reset()); + } else if ("Exception".equals(discriminatorValue)) { + return Exception.fromJson(readerToUse.reset()); + } else if ("Event".equals(discriminatorValue)) { + return Event.fromJson(readerToUse.reset()); + } else if ("Trace".equals(discriminatorValue)) { + return Trace.fromJson(readerToUse.reset()); + } else { + return fromJsonKnownDiscriminator(readerToUse.reset()); + } + } + }); + } + + @Generated + static DocumentIngress fromJsonKnownDiscriminator(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + DocumentIngress deserializedDocumentIngress = new DocumentIngress(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("DocumentType".equals(fieldName)) { + deserializedDocumentIngress.documentType = DocumentType.fromString(reader.getString()); + } else if ("DocumentStreamIds".equals(fieldName)) { + List documentStreamIds = reader.readArray(reader1 -> reader1.getString()); + deserializedDocumentIngress.documentStreamIds = documentStreamIds; + } else if ("Properties".equals(fieldName)) { + List properties + = reader.readArray(reader1 -> KeyValuePairStringString.fromJson(reader1)); + deserializedDocumentIngress.properties = properties; + } else { + reader.skipChildren(); + } + } + + return deserializedDocumentIngress; + }); + } +} diff --git a/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/models/DocumentStreamInfo.java b/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/models/DocumentStreamInfo.java new file mode 100644 index 000000000000..11e2e57466dd --- /dev/null +++ b/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/models/DocumentStreamInfo.java @@ -0,0 +1,108 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.applicationinsights.livemetrics.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; + +/** + * Configurations/filters set by UX to scope the document/telemetry it's interested in. + */ +@Immutable +public final class DocumentStreamInfo implements JsonSerializable { + /* + * Identifier of the document stream initiated by a UX. + */ + @Generated + private final String id; + + /* + * Gets or sets an OR-connected collection of filter groups. + */ + @Generated + private final List documentFilterGroups; + + /** + * Creates an instance of DocumentStreamInfo class. + * + * @param id the id value to set. + * @param documentFilterGroups the documentFilterGroups value to set. + */ + @Generated + private DocumentStreamInfo(String id, List documentFilterGroups) { + this.id = id; + this.documentFilterGroups = documentFilterGroups; + } + + /** + * Get the id property: Identifier of the document stream initiated by a UX. + * + * @return the id value. + */ + @Generated + public String getId() { + return this.id; + } + + /** + * Get the documentFilterGroups property: Gets or sets an OR-connected collection of filter groups. + * + * @return the documentFilterGroups value. + */ + @Generated + public List getDocumentFilterGroups() { + return this.documentFilterGroups; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("Id", this.id); + jsonWriter.writeArrayField("DocumentFilterGroups", this.documentFilterGroups, + (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of DocumentStreamInfo from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of DocumentStreamInfo 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 DocumentStreamInfo. + */ + @Generated + public static DocumentStreamInfo fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String id = null; + List documentFilterGroups = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("Id".equals(fieldName)) { + id = reader.getString(); + } else if ("DocumentFilterGroups".equals(fieldName)) { + documentFilterGroups + = reader.readArray(reader1 -> DocumentFilterConjunctionGroupInfo.fromJson(reader1)); + } else { + reader.skipChildren(); + } + } + return new DocumentStreamInfo(id, documentFilterGroups); + }); + } +} diff --git a/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/models/DocumentType.java b/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/models/DocumentType.java new file mode 100644 index 000000000000..99c3ddd7248d --- /dev/null +++ b/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/models/DocumentType.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.applicationinsights.livemetrics.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Document type. + */ +public final class DocumentType extends ExpandableStringEnum { + /** + * Represents a request telemetry type. + */ + @Generated + public static final DocumentType REQUEST = fromString("Request"); + + /** + * Represents a remote dependency telemetry type. + */ + @Generated + public static final DocumentType REMOTE_DEPENDENCY = fromString("RemoteDependency"); + + /** + * Represents an exception telemetry type. + */ + @Generated + public static final DocumentType EXCEPTION = fromString("Exception"); + + /** + * Represents an event telemetry type. + */ + @Generated + public static final DocumentType EVENT = fromString("Event"); + + /** + * Represents a trace telemetry type. + */ + @Generated + public static final DocumentType TRACE = fromString("Trace"); + + /** + * Represents an unknown telemetry type. + */ + @Generated + public static final DocumentType UNKNOWN = fromString("Unknown"); + + /** + * Creates a new instance of DocumentType value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public DocumentType() { + } + + /** + * Creates or finds a DocumentType from its string representation. + * + * @param name a name to look for. + * @return the corresponding DocumentType. + */ + @Generated + public static DocumentType fromString(String name) { + return fromString(name, DocumentType.class); + } + + /** + * Gets known DocumentType values. + * + * @return known DocumentType values. + */ + @Generated + public static Collection values() { + return values(DocumentType.class); + } +} diff --git a/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/models/Event.java b/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/models/Event.java new file mode 100644 index 000000000000..fcf56c734477 --- /dev/null +++ b/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/models/Event.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.applicationinsights.livemetrics.models; + +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.List; + +/** + * Event document type. + */ +@Fluent +public final class Event extends DocumentIngress { + /* + * Telemetry type. Types not defined in enum will get replaced with a 'Unknown' type. + */ + @Generated + private DocumentType documentType = DocumentType.EVENT; + + /* + * Event name. + */ + @Generated + private String name; + + /** + * Creates an instance of Event class. + */ + @Generated + public Event() { + } + + /** + * Get the documentType property: Telemetry type. Types not defined in enum will get replaced with a 'Unknown' type. + * + * @return the documentType value. + */ + @Generated + @Override + public DocumentType getDocumentType() { + return this.documentType; + } + + /** + * Get the name property: Event name. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * Set the name property: Event name. + * + * @param name the name value to set. + * @return the Event object itself. + */ + @Generated + public Event setName(String name) { + this.name = name; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public Event setDocumentStreamIds(List documentStreamIds) { + super.setDocumentStreamIds(documentStreamIds); + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public Event setProperties(List properties) { + super.setProperties(properties); + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("DocumentStreamIds", getDocumentStreamIds(), + (writer, element) -> writer.writeString(element)); + jsonWriter.writeArrayField("Properties", getProperties(), (writer, element) -> writer.writeJson(element)); + jsonWriter.writeStringField("DocumentType", this.documentType == null ? null : this.documentType.toString()); + jsonWriter.writeStringField("Name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Event from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Event 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 Event. + */ + @Generated + public static Event fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + Event deserializedEvent = new Event(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("DocumentStreamIds".equals(fieldName)) { + List documentStreamIds = reader.readArray(reader1 -> reader1.getString()); + deserializedEvent.setDocumentStreamIds(documentStreamIds); + } else if ("Properties".equals(fieldName)) { + List properties + = reader.readArray(reader1 -> KeyValuePairStringString.fromJson(reader1)); + deserializedEvent.setProperties(properties); + } else if ("DocumentType".equals(fieldName)) { + deserializedEvent.documentType = DocumentType.fromString(reader.getString()); + } else if ("Name".equals(fieldName)) { + deserializedEvent.name = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedEvent; + }); + } +} diff --git a/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/models/Exception.java b/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/models/Exception.java new file mode 100644 index 000000000000..86237e752098 --- /dev/null +++ b/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/models/Exception.java @@ -0,0 +1,173 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.applicationinsights.livemetrics.models; + +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.List; + +/** + * Exception document type. + */ +@Fluent +public final class Exception extends DocumentIngress { + /* + * Telemetry type. Types not defined in enum will get replaced with a 'Unknown' type. + */ + @Generated + private DocumentType documentType = DocumentType.EXCEPTION; + + /* + * Exception type name. + */ + @Generated + private String exceptionType; + + /* + * Exception message. + */ + @Generated + private String exceptionMessage; + + /** + * Creates an instance of Exception class. + */ + @Generated + public Exception() { + } + + /** + * Get the documentType property: Telemetry type. Types not defined in enum will get replaced with a 'Unknown' type. + * + * @return the documentType value. + */ + @Generated + @Override + public DocumentType getDocumentType() { + return this.documentType; + } + + /** + * Get the exceptionType property: Exception type name. + * + * @return the exceptionType value. + */ + @Generated + public String getExceptionType() { + return this.exceptionType; + } + + /** + * Set the exceptionType property: Exception type name. + * + * @param exceptionType the exceptionType value to set. + * @return the Exception object itself. + */ + @Generated + public Exception setExceptionType(String exceptionType) { + this.exceptionType = exceptionType; + return this; + } + + /** + * Get the exceptionMessage property: Exception message. + * + * @return the exceptionMessage value. + */ + @Generated + public String getExceptionMessage() { + return this.exceptionMessage; + } + + /** + * Set the exceptionMessage property: Exception message. + * + * @param exceptionMessage the exceptionMessage value to set. + * @return the Exception object itself. + */ + @Generated + public Exception setExceptionMessage(String exceptionMessage) { + this.exceptionMessage = exceptionMessage; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public Exception setDocumentStreamIds(List documentStreamIds) { + super.setDocumentStreamIds(documentStreamIds); + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public Exception setProperties(List properties) { + super.setProperties(properties); + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("DocumentStreamIds", getDocumentStreamIds(), + (writer, element) -> writer.writeString(element)); + jsonWriter.writeArrayField("Properties", getProperties(), (writer, element) -> writer.writeJson(element)); + jsonWriter.writeStringField("DocumentType", this.documentType == null ? null : this.documentType.toString()); + jsonWriter.writeStringField("ExceptionType", this.exceptionType); + jsonWriter.writeStringField("ExceptionMessage", this.exceptionMessage); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Exception from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Exception 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 Exception. + */ + @Generated + public static Exception fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + Exception deserializedException = new Exception(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("DocumentStreamIds".equals(fieldName)) { + List documentStreamIds = reader.readArray(reader1 -> reader1.getString()); + deserializedException.setDocumentStreamIds(documentStreamIds); + } else if ("Properties".equals(fieldName)) { + List properties + = reader.readArray(reader1 -> KeyValuePairStringString.fromJson(reader1)); + deserializedException.setProperties(properties); + } else if ("DocumentType".equals(fieldName)) { + deserializedException.documentType = DocumentType.fromString(reader.getString()); + } else if ("ExceptionType".equals(fieldName)) { + deserializedException.exceptionType = reader.getString(); + } else if ("ExceptionMessage".equals(fieldName)) { + deserializedException.exceptionMessage = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedException; + }); + } +} diff --git a/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/models/FilterConjunctionGroupInfo.java b/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/models/FilterConjunctionGroupInfo.java new file mode 100644 index 000000000000..18384c0d6e99 --- /dev/null +++ b/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/models/FilterConjunctionGroupInfo.java @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.applicationinsights.livemetrics.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; + +/** + * An AND-connected group of FilterInfo objects. + */ +@Immutable +public final class FilterConjunctionGroupInfo implements JsonSerializable { + /* + * An array of filters. + */ + @Generated + private final List filters; + + /** + * Creates an instance of FilterConjunctionGroupInfo class. + * + * @param filters the filters value to set. + */ + @Generated + private FilterConjunctionGroupInfo(List filters) { + this.filters = filters; + } + + /** + * Get the filters property: An array of filters. + * + * @return the filters value. + */ + @Generated + public List getFilters() { + return this.filters; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("Filters", this.filters, (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of FilterConjunctionGroupInfo from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of FilterConjunctionGroupInfo 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 FilterConjunctionGroupInfo. + */ + @Generated + public static FilterConjunctionGroupInfo fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + List filters = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("Filters".equals(fieldName)) { + filters = reader.readArray(reader1 -> FilterInfo.fromJson(reader1)); + } else { + reader.skipChildren(); + } + } + return new FilterConjunctionGroupInfo(filters); + }); + } +} diff --git a/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/models/FilterInfo.java b/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/models/FilterInfo.java new file mode 100644 index 000000000000..07e64c9c2cbb --- /dev/null +++ b/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/models/FilterInfo.java @@ -0,0 +1,127 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.applicationinsights.livemetrics.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; + +/** + * A filter set on UX. + */ +@Immutable +public final class FilterInfo implements JsonSerializable { + /* + * dimension name of the filter + */ + @Generated + private final String fieldName; + + /* + * Operator of the filter + */ + @Generated + private final PredicateType predicate; + + /* + * Comparand of the filter + */ + @Generated + private final String comparand; + + /** + * Creates an instance of FilterInfo class. + * + * @param fieldName the fieldName value to set. + * @param predicate the predicate value to set. + * @param comparand the comparand value to set. + */ + @Generated + private FilterInfo(String fieldName, PredicateType predicate, String comparand) { + this.fieldName = fieldName; + this.predicate = predicate; + this.comparand = comparand; + } + + /** + * Get the fieldName property: dimension name of the filter. + * + * @return the fieldName value. + */ + @Generated + public String getFieldName() { + return this.fieldName; + } + + /** + * Get the predicate property: Operator of the filter. + * + * @return the predicate value. + */ + @Generated + public PredicateType getPredicate() { + return this.predicate; + } + + /** + * Get the comparand property: Comparand of the filter. + * + * @return the comparand value. + */ + @Generated + public String getComparand() { + return this.comparand; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("FieldName", this.fieldName); + jsonWriter.writeStringField("Predicate", this.predicate == null ? null : this.predicate.toString()); + jsonWriter.writeStringField("Comparand", this.comparand); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of FilterInfo from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of FilterInfo 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 FilterInfo. + */ + @Generated + public static FilterInfo fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String fieldName = null; + PredicateType predicate = null; + String comparand = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String jsonFieldName = reader.getFieldName(); + reader.nextToken(); + + if ("FieldName".equals(jsonFieldName)) { + fieldName = reader.getString(); + } else if ("Predicate".equals(jsonFieldName)) { + predicate = PredicateType.fromString(reader.getString()); + } else if ("Comparand".equals(jsonFieldName)) { + comparand = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new FilterInfo(fieldName, predicate, comparand); + }); + } +} diff --git a/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/models/KeyValuePairStringString.java b/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/models/KeyValuePairStringString.java new file mode 100644 index 000000000000..0464b3cb1488 --- /dev/null +++ b/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/models/KeyValuePairStringString.java @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.applicationinsights.livemetrics.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; + +/** + * Key-value pair of string and string. + */ +@Immutable +public final class KeyValuePairStringString implements JsonSerializable { + /* + * Key of the key-value pair. + */ + @Generated + private final String key; + + /* + * Value of the key-value pair. + */ + @Generated + private final String value; + + /** + * Creates an instance of KeyValuePairStringString class. + * + * @param key the key value to set. + * @param value the value value to set. + */ + @Generated + public KeyValuePairStringString(String key, String value) { + this.key = key; + this.value = value; + } + + /** + * Get the key property: Key of the key-value pair. + * + * @return the key value. + */ + @Generated + public String getKey() { + return this.key; + } + + /** + * Get the value property: Value of the key-value pair. + * + * @return the value value. + */ + @Generated + public String getValue() { + return this.value; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("key", this.key); + jsonWriter.writeStringField("value", this.value); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of KeyValuePairStringString from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of KeyValuePairStringString 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 KeyValuePairStringString. + */ + @Generated + public static KeyValuePairStringString fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String key = null; + String value = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("key".equals(fieldName)) { + key = reader.getString(); + } else if ("value".equals(fieldName)) { + value = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new KeyValuePairStringString(key, value); + }); + } +} diff --git a/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/models/MetricPoint.java b/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/models/MetricPoint.java new file mode 100644 index 000000000000..edb20bd3704a --- /dev/null +++ b/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/models/MetricPoint.java @@ -0,0 +1,127 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.applicationinsights.livemetrics.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; + +/** + * Metric data point. + */ +@Immutable +public final class MetricPoint implements JsonSerializable { + /* + * Metric name. + */ + @Generated + private final String name; + + /* + * Metric value. + */ + @Generated + private final double value; + + /* + * Metric weight. + */ + @Generated + private final int weight; + + /** + * Creates an instance of MetricPoint class. + * + * @param name the name value to set. + * @param value the value value to set. + * @param weight the weight value to set. + */ + @Generated + public MetricPoint(String name, double value, int weight) { + this.name = name; + this.value = value; + this.weight = weight; + } + + /** + * Get the name property: Metric name. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * Get the value property: Metric value. + * + * @return the value value. + */ + @Generated + public double getValue() { + return this.value; + } + + /** + * Get the weight property: Metric weight. + * + * @return the weight value. + */ + @Generated + public int getWeight() { + return this.weight; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("Name", this.name); + jsonWriter.writeDoubleField("Value", this.value); + jsonWriter.writeIntField("Weight", this.weight); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of MetricPoint from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of MetricPoint 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 MetricPoint. + */ + @Generated + public static MetricPoint fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + double value = 0.0; + int weight = 0; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("Name".equals(fieldName)) { + name = reader.getString(); + } else if ("Value".equals(fieldName)) { + value = reader.getDouble(); + } else if ("Weight".equals(fieldName)) { + weight = reader.getInt(); + } else { + reader.skipChildren(); + } + } + return new MetricPoint(name, value, weight); + }); + } +} diff --git a/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/models/MonitoringDataPoint.java b/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/models/MonitoringDataPoint.java new file mode 100644 index 000000000000..78e686e1932d --- /dev/null +++ b/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/models/MonitoringDataPoint.java @@ -0,0 +1,459 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.applicationinsights.livemetrics.models; + +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.time.format.DateTimeFormatter; +import java.util.List; + +/** + * Monitoring data point coming from the client, which includes metrics, documents and other metadata info. + */ +@Fluent +public final class MonitoringDataPoint implements JsonSerializable { + /* + * Application Insights SDK version. + */ + @Generated + private final String version; + + /* + * Version/generation of the data contract (MonitoringDataPoint) between SDK and Live Metrics. + */ + @Generated + private final int invariantVersion; + + /* + * Service instance name where Application Insights SDK lives. + */ + @Generated + private final String instance; + + /* + * Service role name. + */ + @Generated + private final String roleName; + + /* + * Computer name where Application Insights SDK lives. + */ + @Generated + private final String machineName; + + /* + * Identifies an Application Insights SDK as a trusted agent to report metrics and documents. + */ + @Generated + private final String streamId; + + /* + * Data point generation timestamp. + */ + @Generated + private OffsetDateTime timestamp; + + /* + * Timestamp when the client transmits the metrics and documents to Live Metrics. + */ + @Generated + private OffsetDateTime transmissionTime; + + /* + * True if the current application is an Azure Web App. + */ + @Generated + private final boolean isWebApp; + + /* + * True if performance counters collection is supported. + */ + @Generated + private final boolean performanceCollectionSupported; + + /* + * An array of metric data points. + */ + @Generated + private List metrics; + + /* + * An array of documents of a specific type {Request}, {RemoteDependency}, {Exception}, {Event}, or {Trace} + */ + @Generated + private List documents; + + /* + * An array of top cpu consumption data point. + */ + @Generated + private List topCpuProcesses; + + /* + * An array of error while SDK parses and applies the {CollectionConfigurationInfo} provided by Live Metrics. + */ + @Generated + private List collectionConfigurationErrors; + + /** + * Creates an instance of MonitoringDataPoint class. + * + * @param version the version value to set. + * @param invariantVersion the invariantVersion value to set. + * @param instance the instance value to set. + * @param roleName the roleName value to set. + * @param machineName the machineName value to set. + * @param streamId the streamId value to set. + * @param isWebApp the isWebApp value to set. + * @param performanceCollectionSupported the performanceCollectionSupported value to set. + */ + @Generated + public MonitoringDataPoint(String version, int invariantVersion, String instance, String roleName, + String machineName, String streamId, boolean isWebApp, boolean performanceCollectionSupported) { + this.version = version; + this.invariantVersion = invariantVersion; + this.instance = instance; + this.roleName = roleName; + this.machineName = machineName; + this.streamId = streamId; + this.isWebApp = isWebApp; + this.performanceCollectionSupported = performanceCollectionSupported; + } + + /** + * Get the version property: Application Insights SDK version. + * + * @return the version value. + */ + @Generated + public String getVersion() { + return this.version; + } + + /** + * Get the invariantVersion property: Version/generation of the data contract (MonitoringDataPoint) between SDK and + * Live Metrics. + * + * @return the invariantVersion value. + */ + @Generated + public int getInvariantVersion() { + return this.invariantVersion; + } + + /** + * Get the instance property: Service instance name where Application Insights SDK lives. + * + * @return the instance value. + */ + @Generated + public String getInstance() { + return this.instance; + } + + /** + * Get the roleName property: Service role name. + * + * @return the roleName value. + */ + @Generated + public String getRoleName() { + return this.roleName; + } + + /** + * Get the machineName property: Computer name where Application Insights SDK lives. + * + * @return the machineName value. + */ + @Generated + public String getMachineName() { + return this.machineName; + } + + /** + * Get the streamId property: Identifies an Application Insights SDK as a trusted agent to report metrics and + * documents. + * + * @return the streamId value. + */ + @Generated + public String getStreamId() { + return this.streamId; + } + + /** + * Get the timestamp property: Data point generation timestamp. + * + * @return the timestamp value. + */ + @Generated + public OffsetDateTime getTimestamp() { + return this.timestamp; + } + + /** + * Set the timestamp property: Data point generation timestamp. + * + * @param timestamp the timestamp value to set. + * @return the MonitoringDataPoint object itself. + */ + @Generated + public MonitoringDataPoint setTimestamp(OffsetDateTime timestamp) { + this.timestamp = timestamp; + return this; + } + + /** + * Get the transmissionTime property: Timestamp when the client transmits the metrics and documents to Live Metrics. + * + * @return the transmissionTime value. + */ + @Generated + public OffsetDateTime getTransmissionTime() { + return this.transmissionTime; + } + + /** + * Set the transmissionTime property: Timestamp when the client transmits the metrics and documents to Live Metrics. + * + * @param transmissionTime the transmissionTime value to set. + * @return the MonitoringDataPoint object itself. + */ + @Generated + public MonitoringDataPoint setTransmissionTime(OffsetDateTime transmissionTime) { + this.transmissionTime = transmissionTime; + return this; + } + + /** + * Get the isWebApp property: True if the current application is an Azure Web App. + * + * @return the isWebApp value. + */ + @Generated + public boolean isWebApp() { + return this.isWebApp; + } + + /** + * Get the performanceCollectionSupported property: True if performance counters collection is supported. + * + * @return the performanceCollectionSupported value. + */ + @Generated + public boolean isPerformanceCollectionSupported() { + return this.performanceCollectionSupported; + } + + /** + * Get the metrics property: An array of metric data points. + * + * @return the metrics value. + */ + @Generated + public List getMetrics() { + return this.metrics; + } + + /** + * Set the metrics property: An array of metric data points. + * + * @param metrics the metrics value to set. + * @return the MonitoringDataPoint object itself. + */ + @Generated + public MonitoringDataPoint setMetrics(List metrics) { + this.metrics = metrics; + return this; + } + + /** + * Get the documents property: An array of documents of a specific type {Request}, {RemoteDependency}, {Exception}, + * {Event}, or {Trace}. + * + * @return the documents value. + */ + @Generated + public List getDocuments() { + return this.documents; + } + + /** + * Set the documents property: An array of documents of a specific type {Request}, {RemoteDependency}, {Exception}, + * {Event}, or {Trace}. + * + * @param documents the documents value to set. + * @return the MonitoringDataPoint object itself. + */ + @Generated + public MonitoringDataPoint setDocuments(List documents) { + this.documents = documents; + return this; + } + + /** + * Get the topCpuProcesses property: An array of top cpu consumption data point. + * + * @return the topCpuProcesses value. + */ + @Generated + public List getTopCpuProcesses() { + return this.topCpuProcesses; + } + + /** + * Set the topCpuProcesses property: An array of top cpu consumption data point. + * + * @param topCpuProcesses the topCpuProcesses value to set. + * @return the MonitoringDataPoint object itself. + */ + @Generated + public MonitoringDataPoint setTopCpuProcesses(List topCpuProcesses) { + this.topCpuProcesses = topCpuProcesses; + return this; + } + + /** + * Get the collectionConfigurationErrors property: An array of error while SDK parses and applies the + * {CollectionConfigurationInfo} provided by Live Metrics. + * + * @return the collectionConfigurationErrors value. + */ + @Generated + public List getCollectionConfigurationErrors() { + return this.collectionConfigurationErrors; + } + + /** + * Set the collectionConfigurationErrors property: An array of error while SDK parses and applies the + * {CollectionConfigurationInfo} provided by Live Metrics. + * + * @param collectionConfigurationErrors the collectionConfigurationErrors value to set. + * @return the MonitoringDataPoint object itself. + */ + @Generated + public MonitoringDataPoint + setCollectionConfigurationErrors(List collectionConfigurationErrors) { + this.collectionConfigurationErrors = collectionConfigurationErrors; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("Version", this.version); + jsonWriter.writeIntField("InvariantVersion", this.invariantVersion); + jsonWriter.writeStringField("Instance", this.instance); + jsonWriter.writeStringField("RoleName", this.roleName); + jsonWriter.writeStringField("MachineName", this.machineName); + jsonWriter.writeStringField("StreamId", this.streamId); + jsonWriter.writeBooleanField("IsWebApp", this.isWebApp); + jsonWriter.writeBooleanField("PerformanceCollectionSupported", this.performanceCollectionSupported); + jsonWriter.writeStringField("Timestamp", + this.timestamp == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.timestamp)); + jsonWriter.writeStringField("TransmissionTime", + this.transmissionTime == null + ? null + : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.transmissionTime)); + jsonWriter.writeArrayField("Metrics", this.metrics, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeArrayField("Documents", this.documents, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeArrayField("TopCpuProcesses", this.topCpuProcesses, + (writer, element) -> writer.writeJson(element)); + jsonWriter.writeArrayField("CollectionConfigurationErrors", this.collectionConfigurationErrors, + (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of MonitoringDataPoint from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of MonitoringDataPoint 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 MonitoringDataPoint. + */ + @Generated + public static MonitoringDataPoint fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String version = null; + int invariantVersion = 0; + String instance = null; + String roleName = null; + String machineName = null; + String streamId = null; + boolean isWebApp = false; + boolean performanceCollectionSupported = false; + OffsetDateTime timestamp = null; + OffsetDateTime transmissionTime = null; + List metrics = null; + List documents = null; + List topCpuProcesses = null; + List collectionConfigurationErrors = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("Version".equals(fieldName)) { + version = reader.getString(); + } else if ("InvariantVersion".equals(fieldName)) { + invariantVersion = reader.getInt(); + } else if ("Instance".equals(fieldName)) { + instance = reader.getString(); + } else if ("RoleName".equals(fieldName)) { + roleName = reader.getString(); + } else if ("MachineName".equals(fieldName)) { + machineName = reader.getString(); + } else if ("StreamId".equals(fieldName)) { + streamId = reader.getString(); + } else if ("IsWebApp".equals(fieldName)) { + isWebApp = reader.getBoolean(); + } else if ("PerformanceCollectionSupported".equals(fieldName)) { + performanceCollectionSupported = reader.getBoolean(); + } else if ("Timestamp".equals(fieldName)) { + timestamp = reader + .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString())); + } else if ("TransmissionTime".equals(fieldName)) { + transmissionTime = reader + .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString())); + } else if ("Metrics".equals(fieldName)) { + metrics = reader.readArray(reader1 -> MetricPoint.fromJson(reader1)); + } else if ("Documents".equals(fieldName)) { + documents = reader.readArray(reader1 -> DocumentIngress.fromJson(reader1)); + } else if ("TopCpuProcesses".equals(fieldName)) { + topCpuProcesses = reader.readArray(reader1 -> ProcessCpuData.fromJson(reader1)); + } else if ("CollectionConfigurationErrors".equals(fieldName)) { + collectionConfigurationErrors + = reader.readArray(reader1 -> CollectionConfigurationError.fromJson(reader1)); + } else { + reader.skipChildren(); + } + } + MonitoringDataPoint deserializedMonitoringDataPoint = new MonitoringDataPoint(version, invariantVersion, + instance, roleName, machineName, streamId, isWebApp, performanceCollectionSupported); + deserializedMonitoringDataPoint.timestamp = timestamp; + deserializedMonitoringDataPoint.transmissionTime = transmissionTime; + deserializedMonitoringDataPoint.metrics = metrics; + deserializedMonitoringDataPoint.documents = documents; + deserializedMonitoringDataPoint.topCpuProcesses = topCpuProcesses; + deserializedMonitoringDataPoint.collectionConfigurationErrors = collectionConfigurationErrors; + + return deserializedMonitoringDataPoint; + }); + } +} diff --git a/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/models/PredicateType.java b/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/models/PredicateType.java new file mode 100644 index 000000000000..df5c1f36b1d1 --- /dev/null +++ b/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/models/PredicateType.java @@ -0,0 +1,93 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.applicationinsights.livemetrics.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Enum representing the different types of predicates. + */ +public final class PredicateType extends ExpandableStringEnum { + /** + * Represents an equality predicate. + */ + @Generated + public static final PredicateType EQUAL = fromString("Equal"); + + /** + * Represents a not-equal predicate. + */ + @Generated + public static final PredicateType NOT_EQUAL = fromString("NotEqual"); + + /** + * Represents a less-than predicate. + */ + @Generated + public static final PredicateType LESS_THAN = fromString("LessThan"); + + /** + * Represents a greater-than predicate. + */ + @Generated + public static final PredicateType GREATER_THAN = fromString("GreaterThan"); + + /** + * Represents a less-than-or-equal predicate. + */ + @Generated + public static final PredicateType LESS_THAN_OR_EQUAL = fromString("LessThanOrEqual"); + + /** + * Represents a greater-than-or-equal predicate. + */ + @Generated + public static final PredicateType GREATER_THAN_OR_EQUAL = fromString("GreaterThanOrEqual"); + + /** + * Represents a contains predicate. + */ + @Generated + public static final PredicateType CONTAINS = fromString("Contains"); + + /** + * Represents a does-not-contain predicate. + */ + @Generated + public static final PredicateType DOES_NOT_CONTAIN = fromString("DoesNotContain"); + + /** + * Creates a new instance of PredicateType value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public PredicateType() { + } + + /** + * Creates or finds a PredicateType from its string representation. + * + * @param name a name to look for. + * @return the corresponding PredicateType. + */ + @Generated + public static PredicateType fromString(String name) { + return fromString(name, PredicateType.class); + } + + /** + * Gets known PredicateType values. + * + * @return known PredicateType values. + */ + @Generated + public static Collection values() { + return values(PredicateType.class); + } +} diff --git a/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/models/ProcessCpuData.java b/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/models/ProcessCpuData.java new file mode 100644 index 000000000000..61a542a0f87f --- /dev/null +++ b/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/models/ProcessCpuData.java @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.applicationinsights.livemetrics.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; + +/** + * CPU consumption datapoint. + */ +@Immutable +public final class ProcessCpuData implements JsonSerializable { + /* + * Process name. + */ + @Generated + private final String processName; + + /* + * CPU consumption percentage. + */ + @Generated + private final int cpuPercentage; + + /** + * Creates an instance of ProcessCpuData class. + * + * @param processName the processName value to set. + * @param cpuPercentage the cpuPercentage value to set. + */ + @Generated + public ProcessCpuData(String processName, int cpuPercentage) { + this.processName = processName; + this.cpuPercentage = cpuPercentage; + } + + /** + * Get the processName property: Process name. + * + * @return the processName value. + */ + @Generated + public String getProcessName() { + return this.processName; + } + + /** + * Get the cpuPercentage property: CPU consumption percentage. + * + * @return the cpuPercentage value. + */ + @Generated + public int getCpuPercentage() { + return this.cpuPercentage; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("ProcessName", this.processName); + jsonWriter.writeIntField("CpuPercentage", this.cpuPercentage); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ProcessCpuData from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ProcessCpuData 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 ProcessCpuData. + */ + @Generated + public static ProcessCpuData fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String processName = null; + int cpuPercentage = 0; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("ProcessName".equals(fieldName)) { + processName = reader.getString(); + } else if ("CpuPercentage".equals(fieldName)) { + cpuPercentage = reader.getInt(); + } else { + reader.skipChildren(); + } + } + return new ProcessCpuData(processName, cpuPercentage); + }); + } +} diff --git a/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/models/QuotaConfigurationInfo.java b/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/models/QuotaConfigurationInfo.java new file mode 100644 index 000000000000..721ab6b5e046 --- /dev/null +++ b/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/models/QuotaConfigurationInfo.java @@ -0,0 +1,129 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.applicationinsights.livemetrics.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; + +/** + * Controls document quotas to be sent to Live Metrics. + */ +@Immutable +public final class QuotaConfigurationInfo implements JsonSerializable { + /* + * Initial quota + */ + @Generated + private Double initialQuota; + + /* + * Max quota + */ + @Generated + private final double maxQuota; + + /* + * Quota accrual rate per second + */ + @Generated + private final double quotaAccrualRatePerSec; + + /** + * Creates an instance of QuotaConfigurationInfo class. + * + * @param maxQuota the maxQuota value to set. + * @param quotaAccrualRatePerSec the quotaAccrualRatePerSec value to set. + */ + @Generated + private QuotaConfigurationInfo(double maxQuota, double quotaAccrualRatePerSec) { + this.maxQuota = maxQuota; + this.quotaAccrualRatePerSec = quotaAccrualRatePerSec; + } + + /** + * Get the initialQuota property: Initial quota. + * + * @return the initialQuota value. + */ + @Generated + public Double getInitialQuota() { + return this.initialQuota; + } + + /** + * Get the maxQuota property: Max quota. + * + * @return the maxQuota value. + */ + @Generated + public double getMaxQuota() { + return this.maxQuota; + } + + /** + * Get the quotaAccrualRatePerSec property: Quota accrual rate per second. + * + * @return the quotaAccrualRatePerSec value. + */ + @Generated + public double getQuotaAccrualRatePerSec() { + return this.quotaAccrualRatePerSec; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeDoubleField("MaxQuota", this.maxQuota); + jsonWriter.writeDoubleField("QuotaAccrualRatePerSec", this.quotaAccrualRatePerSec); + jsonWriter.writeNumberField("InitialQuota", this.initialQuota); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of QuotaConfigurationInfo from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of QuotaConfigurationInfo 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 QuotaConfigurationInfo. + */ + @Generated + public static QuotaConfigurationInfo fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + double maxQuota = 0.0; + double quotaAccrualRatePerSec = 0.0; + Double initialQuota = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("MaxQuota".equals(fieldName)) { + maxQuota = reader.getDouble(); + } else if ("QuotaAccrualRatePerSec".equals(fieldName)) { + quotaAccrualRatePerSec = reader.getDouble(); + } else if ("InitialQuota".equals(fieldName)) { + initialQuota = reader.getNullable(JsonReader::getDouble); + } else { + reader.skipChildren(); + } + } + QuotaConfigurationInfo deserializedQuotaConfigurationInfo + = new QuotaConfigurationInfo(maxQuota, quotaAccrualRatePerSec); + deserializedQuotaConfigurationInfo.initialQuota = initialQuota; + + return deserializedQuotaConfigurationInfo; + }); + } +} diff --git a/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/models/RemoteDependency.java b/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/models/RemoteDependency.java new file mode 100644 index 000000000000..de56d88dbdb2 --- /dev/null +++ b/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/models/RemoteDependency.java @@ -0,0 +1,237 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.applicationinsights.livemetrics.models; + +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.List; + +/** + * RemoteDependency document type. + */ +@Fluent +public final class RemoteDependency extends DocumentIngress { + /* + * Telemetry type. Types not defined in enum will get replaced with a 'Unknown' type. + */ + @Generated + private DocumentType documentType = DocumentType.REMOTE_DEPENDENCY; + + /* + * Name of the command initiated with this dependency call, e.g., GET /username. + */ + @Generated + private String name; + + /* + * URL of the dependency call to the target, with all query string parameters. + */ + @Generated + private String commandName; + + /* + * Result code of a dependency call. Examples are SQL error code and HTTP status code. + */ + @Generated + private String resultCode; + + /* + * Request duration in ISO 8601 duration format, i.e., P[n]Y[n]M[n]DT[n]H[n]M[n]S or P[n]W. + */ + @Generated + private String duration; + + /** + * Creates an instance of RemoteDependency class. + */ + @Generated + public RemoteDependency() { + } + + /** + * Get the documentType property: Telemetry type. Types not defined in enum will get replaced with a 'Unknown' type. + * + * @return the documentType value. + */ + @Generated + @Override + public DocumentType getDocumentType() { + return this.documentType; + } + + /** + * Get the name property: Name of the command initiated with this dependency call, e.g., GET /username. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * Set the name property: Name of the command initiated with this dependency call, e.g., GET /username. + * + * @param name the name value to set. + * @return the RemoteDependency object itself. + */ + @Generated + public RemoteDependency setName(String name) { + this.name = name; + return this; + } + + /** + * Get the commandName property: URL of the dependency call to the target, with all query string parameters. + * + * @return the commandName value. + */ + @Generated + public String getCommandName() { + return this.commandName; + } + + /** + * Set the commandName property: URL of the dependency call to the target, with all query string parameters. + * + * @param commandName the commandName value to set. + * @return the RemoteDependency object itself. + */ + @Generated + public RemoteDependency setCommandName(String commandName) { + this.commandName = commandName; + return this; + } + + /** + * Get the resultCode property: Result code of a dependency call. Examples are SQL error code and HTTP status code. + * + * @return the resultCode value. + */ + @Generated + public String getResultCode() { + return this.resultCode; + } + + /** + * Set the resultCode property: Result code of a dependency call. Examples are SQL error code and HTTP status code. + * + * @param resultCode the resultCode value to set. + * @return the RemoteDependency object itself. + */ + @Generated + public RemoteDependency setResultCode(String resultCode) { + this.resultCode = resultCode; + return this; + } + + /** + * Get the duration property: Request duration in ISO 8601 duration format, i.e., P[n]Y[n]M[n]DT[n]H[n]M[n]S or + * P[n]W. + * + * @return the duration value. + */ + @Generated + public String getDuration() { + return this.duration; + } + + /** + * Set the duration property: Request duration in ISO 8601 duration format, i.e., P[n]Y[n]M[n]DT[n]H[n]M[n]S or + * P[n]W. + * + * @param duration the duration value to set. + * @return the RemoteDependency object itself. + */ + @Generated + public RemoteDependency setDuration(String duration) { + this.duration = duration; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public RemoteDependency setDocumentStreamIds(List documentStreamIds) { + super.setDocumentStreamIds(documentStreamIds); + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public RemoteDependency setProperties(List properties) { + super.setProperties(properties); + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("DocumentStreamIds", getDocumentStreamIds(), + (writer, element) -> writer.writeString(element)); + jsonWriter.writeArrayField("Properties", getProperties(), (writer, element) -> writer.writeJson(element)); + jsonWriter.writeStringField("DocumentType", this.documentType == null ? null : this.documentType.toString()); + jsonWriter.writeStringField("Name", this.name); + jsonWriter.writeStringField("CommandName", this.commandName); + jsonWriter.writeStringField("ResultCode", this.resultCode); + jsonWriter.writeStringField("Duration", this.duration); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of RemoteDependency from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of RemoteDependency 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 RemoteDependency. + */ + @Generated + public static RemoteDependency fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + RemoteDependency deserializedRemoteDependency = new RemoteDependency(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("DocumentStreamIds".equals(fieldName)) { + List documentStreamIds = reader.readArray(reader1 -> reader1.getString()); + deserializedRemoteDependency.setDocumentStreamIds(documentStreamIds); + } else if ("Properties".equals(fieldName)) { + List properties + = reader.readArray(reader1 -> KeyValuePairStringString.fromJson(reader1)); + deserializedRemoteDependency.setProperties(properties); + } else if ("DocumentType".equals(fieldName)) { + deserializedRemoteDependency.documentType = DocumentType.fromString(reader.getString()); + } else if ("Name".equals(fieldName)) { + deserializedRemoteDependency.name = reader.getString(); + } else if ("CommandName".equals(fieldName)) { + deserializedRemoteDependency.commandName = reader.getString(); + } else if ("ResultCode".equals(fieldName)) { + deserializedRemoteDependency.resultCode = reader.getString(); + } else if ("Duration".equals(fieldName)) { + deserializedRemoteDependency.duration = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedRemoteDependency; + }); + } +} diff --git a/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/models/Request.java b/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/models/Request.java new file mode 100644 index 000000000000..f1a62f8c6ef6 --- /dev/null +++ b/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/models/Request.java @@ -0,0 +1,239 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.applicationinsights.livemetrics.models; + +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.List; + +/** + * Request document type. + */ +@Fluent +public final class Request extends DocumentIngress { + /* + * Telemetry type. Types not defined in enum will get replaced with a 'Unknown' type. + */ + @Generated + private DocumentType documentType = DocumentType.REQUEST; + + /* + * Name of the request, e.g., 'GET /values/{id}'. + */ + @Generated + private String name; + + /* + * Request URL with all query string parameters. + */ + @Generated + private String url; + + /* + * Result of a request execution. For http requests, it could be some HTTP status code. + */ + @Generated + private String responseCode; + + /* + * Request duration in ISO 8601 duration format, i.e., P[n]Y[n]M[n]DT[n]H[n]M[n]S or P[n]W. + */ + @Generated + private String duration; + + /** + * Creates an instance of Request class. + */ + @Generated + public Request() { + } + + /** + * Get the documentType property: Telemetry type. Types not defined in enum will get replaced with a 'Unknown' type. + * + * @return the documentType value. + */ + @Generated + @Override + public DocumentType getDocumentType() { + return this.documentType; + } + + /** + * Get the name property: Name of the request, e.g., 'GET /values/{id}'. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * Set the name property: Name of the request, e.g., 'GET /values/{id}'. + * + * @param name the name value to set. + * @return the Request object itself. + */ + @Generated + public Request setName(String name) { + this.name = name; + return this; + } + + /** + * Get the url property: Request URL with all query string parameters. + * + * @return the url value. + */ + @Generated + public String getUrl() { + return this.url; + } + + /** + * Set the url property: Request URL with all query string parameters. + * + * @param url the url value to set. + * @return the Request object itself. + */ + @Generated + public Request setUrl(String url) { + this.url = url; + return this; + } + + /** + * Get the responseCode property: Result of a request execution. For http requests, it could be some HTTP status + * code. + * + * @return the responseCode value. + */ + @Generated + public String getResponseCode() { + return this.responseCode; + } + + /** + * Set the responseCode property: Result of a request execution. For http requests, it could be some HTTP status + * code. + * + * @param responseCode the responseCode value to set. + * @return the Request object itself. + */ + @Generated + public Request setResponseCode(String responseCode) { + this.responseCode = responseCode; + return this; + } + + /** + * Get the duration property: Request duration in ISO 8601 duration format, i.e., P[n]Y[n]M[n]DT[n]H[n]M[n]S or + * P[n]W. + * + * @return the duration value. + */ + @Generated + public String getDuration() { + return this.duration; + } + + /** + * Set the duration property: Request duration in ISO 8601 duration format, i.e., P[n]Y[n]M[n]DT[n]H[n]M[n]S or + * P[n]W. + * + * @param duration the duration value to set. + * @return the Request object itself. + */ + @Generated + public Request setDuration(String duration) { + this.duration = duration; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public Request setDocumentStreamIds(List documentStreamIds) { + super.setDocumentStreamIds(documentStreamIds); + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public Request setProperties(List properties) { + super.setProperties(properties); + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("DocumentStreamIds", getDocumentStreamIds(), + (writer, element) -> writer.writeString(element)); + jsonWriter.writeArrayField("Properties", getProperties(), (writer, element) -> writer.writeJson(element)); + jsonWriter.writeStringField("DocumentType", this.documentType == null ? null : this.documentType.toString()); + jsonWriter.writeStringField("Name", this.name); + jsonWriter.writeStringField("Url", this.url); + jsonWriter.writeStringField("ResponseCode", this.responseCode); + jsonWriter.writeStringField("Duration", this.duration); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Request from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Request 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 Request. + */ + @Generated + public static Request fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + Request deserializedRequest = new Request(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("DocumentStreamIds".equals(fieldName)) { + List documentStreamIds = reader.readArray(reader1 -> reader1.getString()); + deserializedRequest.setDocumentStreamIds(documentStreamIds); + } else if ("Properties".equals(fieldName)) { + List properties + = reader.readArray(reader1 -> KeyValuePairStringString.fromJson(reader1)); + deserializedRequest.setProperties(properties); + } else if ("DocumentType".equals(fieldName)) { + deserializedRequest.documentType = DocumentType.fromString(reader.getString()); + } else if ("Name".equals(fieldName)) { + deserializedRequest.name = reader.getString(); + } else if ("Url".equals(fieldName)) { + deserializedRequest.url = reader.getString(); + } else if ("ResponseCode".equals(fieldName)) { + deserializedRequest.responseCode = reader.getString(); + } else if ("Duration".equals(fieldName)) { + deserializedRequest.duration = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedRequest; + }); + } +} diff --git a/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/models/TelemetryType.java b/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/models/TelemetryType.java new file mode 100644 index 000000000000..f8774e645d22 --- /dev/null +++ b/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/models/TelemetryType.java @@ -0,0 +1,87 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.applicationinsights.livemetrics.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Telemetry type. + */ +public final class TelemetryType extends ExpandableStringEnum { + /** + * Represents a request telemetry type. + */ + @Generated + public static final TelemetryType REQUEST = fromString("Request"); + + /** + * Represents a dependency telemetry type. + */ + @Generated + public static final TelemetryType DEPENDENCY = fromString("Dependency"); + + /** + * Represents an exception telemetry type. + */ + @Generated + public static final TelemetryType EXCEPTION = fromString("Exception"); + + /** + * Represents an event telemetry type. + */ + @Generated + public static final TelemetryType EVENT = fromString("Event"); + + /** + * Represents a metric telemetry type. + */ + @Generated + public static final TelemetryType METRIC = fromString("Metric"); + + /** + * Represents a performance counter telemetry type. + */ + @Generated + public static final TelemetryType PERFORMANCE_COUNTER = fromString("PerformanceCounter"); + + /** + * Represents a trace telemetry type. + */ + @Generated + public static final TelemetryType TRACE = fromString("Trace"); + + /** + * Creates a new instance of TelemetryType value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public TelemetryType() { + } + + /** + * Creates or finds a TelemetryType from its string representation. + * + * @param name a name to look for. + * @return the corresponding TelemetryType. + */ + @Generated + public static TelemetryType fromString(String name) { + return fromString(name, TelemetryType.class); + } + + /** + * Gets known TelemetryType values. + * + * @return known TelemetryType values. + */ + @Generated + public static Collection values() { + return values(TelemetryType.class); + } +} diff --git a/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/models/Trace.java b/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/models/Trace.java new file mode 100644 index 000000000000..6f317309f115 --- /dev/null +++ b/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/models/Trace.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.applicationinsights.livemetrics.models; + +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.List; + +/** + * Trace document type. + */ +@Fluent +public final class Trace extends DocumentIngress { + /* + * Telemetry type. Types not defined in enum will get replaced with a 'Unknown' type. + */ + @Generated + private DocumentType documentType = DocumentType.TRACE; + + /* + * Trace message. + */ + @Generated + private String message; + + /** + * Creates an instance of Trace class. + */ + @Generated + public Trace() { + } + + /** + * Get the documentType property: Telemetry type. Types not defined in enum will get replaced with a 'Unknown' type. + * + * @return the documentType value. + */ + @Generated + @Override + public DocumentType getDocumentType() { + return this.documentType; + } + + /** + * Get the message property: Trace message. + * + * @return the message value. + */ + @Generated + public String getMessage() { + return this.message; + } + + /** + * Set the message property: Trace message. + * + * @param message the message value to set. + * @return the Trace object itself. + */ + @Generated + public Trace setMessage(String message) { + this.message = message; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public Trace setDocumentStreamIds(List documentStreamIds) { + super.setDocumentStreamIds(documentStreamIds); + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public Trace setProperties(List properties) { + super.setProperties(properties); + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("DocumentStreamIds", getDocumentStreamIds(), + (writer, element) -> writer.writeString(element)); + jsonWriter.writeArrayField("Properties", getProperties(), (writer, element) -> writer.writeJson(element)); + jsonWriter.writeStringField("DocumentType", this.documentType == null ? null : this.documentType.toString()); + jsonWriter.writeStringField("Message", this.message); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Trace from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Trace 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 Trace. + */ + @Generated + public static Trace fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + Trace deserializedTrace = new Trace(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("DocumentStreamIds".equals(fieldName)) { + List documentStreamIds = reader.readArray(reader1 -> reader1.getString()); + deserializedTrace.setDocumentStreamIds(documentStreamIds); + } else if ("Properties".equals(fieldName)) { + List properties + = reader.readArray(reader1 -> KeyValuePairStringString.fromJson(reader1)); + deserializedTrace.setProperties(properties); + } else if ("DocumentType".equals(fieldName)) { + deserializedTrace.documentType = DocumentType.fromString(reader.getString()); + } else if ("Message".equals(fieldName)) { + deserializedTrace.message = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedTrace; + }); + } +} diff --git a/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/models/package-info.java b/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/models/package-info.java new file mode 100644 index 000000000000..ea214723eac5 --- /dev/null +++ b/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/models/package-info.java @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the data models for LiveMetrics. + * Live Metrics REST APIs. + */ +package com.azure.applicationinsights.livemetrics.models; diff --git a/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/package-info.java b/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/package-info.java new file mode 100644 index 000000000000..c5a9e6c93364 --- /dev/null +++ b/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/com/azure/applicationinsights/livemetrics/package-info.java @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the classes for LiveMetrics. + * Live Metrics REST APIs. + */ +package com.azure.applicationinsights.livemetrics; diff --git a/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/module-info.java b/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/java/module-info.java new file mode 100644 index 000000000000..a32ee004fe81 --- /dev/null +++ b/sdk/applicationinsights/azure-applicationinsights-livemetrics/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.applicationinsights.livemetrics { + requires transitive com.azure.core; + + exports com.azure.applicationinsights.livemetrics; + exports com.azure.applicationinsights.livemetrics.models; + + opens com.azure.applicationinsights.livemetrics.models to com.azure.core; +} diff --git a/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/resources/META-INF/azure-applicationinsights-livemetrics_apiview_properties.json b/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/resources/META-INF/azure-applicationinsights-livemetrics_apiview_properties.json new file mode 100644 index 000000000000..9b85ec4fc443 --- /dev/null +++ b/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/resources/META-INF/azure-applicationinsights-livemetrics_apiview_properties.json @@ -0,0 +1,39 @@ +{ + "flavor": "azure", + "CrossLanguageDefinitionId": { + "com.azure.applicationinsights.livemetrics.LiveMetricsAsyncClient": "Azure.Monitor.LiveMetrics", + "com.azure.applicationinsights.livemetrics.LiveMetricsAsyncClient.isSubscribed": "Azure.Monitor.LiveMetrics.isSubscribed", + "com.azure.applicationinsights.livemetrics.LiveMetricsAsyncClient.isSubscribedWithResponse": "Azure.Monitor.LiveMetrics.isSubscribed", + "com.azure.applicationinsights.livemetrics.LiveMetricsAsyncClient.publish": "Azure.Monitor.LiveMetrics.publish", + "com.azure.applicationinsights.livemetrics.LiveMetricsAsyncClient.publishWithResponse": "Azure.Monitor.LiveMetrics.publish", + "com.azure.applicationinsights.livemetrics.LiveMetricsClient": "Azure.Monitor.LiveMetrics", + "com.azure.applicationinsights.livemetrics.LiveMetricsClient.isSubscribed": "Azure.Monitor.LiveMetrics.isSubscribed", + "com.azure.applicationinsights.livemetrics.LiveMetricsClient.isSubscribedWithResponse": "Azure.Monitor.LiveMetrics.isSubscribed", + "com.azure.applicationinsights.livemetrics.LiveMetricsClient.publish": "Azure.Monitor.LiveMetrics.publish", + "com.azure.applicationinsights.livemetrics.LiveMetricsClient.publishWithResponse": "Azure.Monitor.LiveMetrics.publish", + "com.azure.applicationinsights.livemetrics.LiveMetricsClientBuilder": "Azure.Monitor.LiveMetrics", + "com.azure.applicationinsights.livemetrics.models.AggregationType": "Azure.Monitor.LiveMetrics.AggregationType", + "com.azure.applicationinsights.livemetrics.models.CollectionConfigurationError": "Azure.Monitor.LiveMetrics.CollectionConfigurationError", + "com.azure.applicationinsights.livemetrics.models.CollectionConfigurationErrorType": "Azure.Monitor.LiveMetrics.CollectionConfigurationErrorType", + "com.azure.applicationinsights.livemetrics.models.CollectionConfigurationInfo": "Azure.Monitor.LiveMetrics.CollectionConfigurationInfo", + "com.azure.applicationinsights.livemetrics.models.DerivedMetricInfo": "Azure.Monitor.LiveMetrics.DerivedMetricInfo", + "com.azure.applicationinsights.livemetrics.models.DocumentFilterConjunctionGroupInfo": "Azure.Monitor.LiveMetrics.DocumentFilterConjunctionGroupInfo", + "com.azure.applicationinsights.livemetrics.models.DocumentIngress": "Azure.Monitor.LiveMetrics.DocumentIngress", + "com.azure.applicationinsights.livemetrics.models.DocumentStreamInfo": "Azure.Monitor.LiveMetrics.DocumentStreamInfo", + "com.azure.applicationinsights.livemetrics.models.DocumentType": "Azure.Monitor.LiveMetrics.DocumentType", + "com.azure.applicationinsights.livemetrics.models.Event": "Azure.Monitor.LiveMetrics.Event", + "com.azure.applicationinsights.livemetrics.models.Exception": "Azure.Monitor.LiveMetrics.Exception", + "com.azure.applicationinsights.livemetrics.models.FilterConjunctionGroupInfo": "Azure.Monitor.LiveMetrics.FilterConjunctionGroupInfo", + "com.azure.applicationinsights.livemetrics.models.FilterInfo": "Azure.Monitor.LiveMetrics.FilterInfo", + "com.azure.applicationinsights.livemetrics.models.KeyValuePairStringString": "Azure.Monitor.LiveMetrics.KeyValuePairStringString", + "com.azure.applicationinsights.livemetrics.models.MetricPoint": "Azure.Monitor.LiveMetrics.MetricPoint", + "com.azure.applicationinsights.livemetrics.models.MonitoringDataPoint": "Azure.Monitor.LiveMetrics.MonitoringDataPoint", + "com.azure.applicationinsights.livemetrics.models.PredicateType": "Azure.Monitor.LiveMetrics.PredicateType", + "com.azure.applicationinsights.livemetrics.models.ProcessCpuData": "Azure.Monitor.LiveMetrics.ProcessCpuData", + "com.azure.applicationinsights.livemetrics.models.QuotaConfigurationInfo": "Azure.Monitor.LiveMetrics.QuotaConfigurationInfo", + "com.azure.applicationinsights.livemetrics.models.RemoteDependency": "Azure.Monitor.LiveMetrics.RemoteDependency", + "com.azure.applicationinsights.livemetrics.models.Request": "Azure.Monitor.LiveMetrics.Request", + "com.azure.applicationinsights.livemetrics.models.TelemetryType": "Azure.Monitor.LiveMetrics.TelemetryType", + "com.azure.applicationinsights.livemetrics.models.Trace": "Azure.Monitor.LiveMetrics.Trace" + } +} diff --git a/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/resources/azure-applicationinsights-livemetrics.properties b/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/resources/azure-applicationinsights-livemetrics.properties new file mode 100644 index 000000000000..ca812989b4f2 --- /dev/null +++ b/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/main/resources/azure-applicationinsights-livemetrics.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/samples/java/com/azure/applicationinsights/livemetrics/ReadmeSamples.java b/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/samples/java/com/azure/applicationinsights/livemetrics/ReadmeSamples.java new file mode 100644 index 000000000000..ee731debbef4 --- /dev/null +++ b/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/samples/java/com/azure/applicationinsights/livemetrics/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.applicationinsights.livemetrics; + +public final class ReadmeSamples { + public void readmeSamples() { + // BEGIN: com.azure.applicationinsights.livemetrics.readme + // END: com.azure.applicationinsights.livemetrics.readme + } +} diff --git a/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/samples/java/com/azure/applicationinsights/livemetrics/generated/LiveMetricsClientChecksIfItsDataIsSubscribedTo.java b/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/samples/java/com/azure/applicationinsights/livemetrics/generated/LiveMetricsClientChecksIfItsDataIsSubscribedTo.java new file mode 100644 index 000000000000..2f6365fd68ab --- /dev/null +++ b/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/samples/java/com/azure/applicationinsights/livemetrics/generated/LiveMetricsClientChecksIfItsDataIsSubscribedTo.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.applicationinsights.livemetrics.generated; + +import com.azure.applicationinsights.livemetrics.LiveMetricsClient; +import com.azure.applicationinsights.livemetrics.LiveMetricsClientBuilder; +import com.azure.applicationinsights.livemetrics.models.CollectionConfigurationInfo; +import com.azure.applicationinsights.livemetrics.models.MonitoringDataPoint; +import com.azure.identity.DefaultAzureCredentialBuilder; +import java.time.OffsetDateTime; + +public class LiveMetricsClientChecksIfItsDataIsSubscribedTo { + public static void main(String[] args) { + LiveMetricsClient liveMetricsClient + = new LiveMetricsClientBuilder().credential(new DefaultAzureCredentialBuilder().build()) + .endpoint("https://global.livediagnostics.monitor.azure.com") + .buildClient(); + // BEGIN:com.azure.applicationinsights.livemetrics.generated.issubscribed.livemetricsclientchecksifitsdataissubscribedto + CollectionConfigurationInfo response = liveMetricsClient.isSubscribed("4473b98e-c70d-4220-b57c-2984c2a0e5cd", + 638422471817023700L, "SERVER-PC-NAME", "server-pc-name", "41112328328b4edb9aa777aa6d675186", + "server-role-name", "5", "1::bu8uyb2wr89ycvvn0iznpa4a9ufqax76::2::", + new MonitoringDataPoint("2.21.0-429", 5, "server-pc-name", "", "SERVER-PC-NAME", + "41112328328b4edb9aa777aa6d675186", false, true) + .setTimestamp(OffsetDateTime.parse("2024-02-01T21:36:32.5717105Z"))); + // END:com.azure.applicationinsights.livemetrics.generated.issubscribed.livemetricsclientchecksifitsdataissubscribedto + } +} diff --git a/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/samples/java/com/azure/applicationinsights/livemetrics/generated/LiveMetricsClientPublishesLiveMetrics.java b/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/samples/java/com/azure/applicationinsights/livemetrics/generated/LiveMetricsClientPublishesLiveMetrics.java new file mode 100644 index 000000000000..c45b39cc7bff --- /dev/null +++ b/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/samples/java/com/azure/applicationinsights/livemetrics/generated/LiveMetricsClientPublishesLiveMetrics.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.applicationinsights.livemetrics.generated; + +import com.azure.applicationinsights.livemetrics.LiveMetricsClient; +import com.azure.applicationinsights.livemetrics.LiveMetricsClientBuilder; +import com.azure.applicationinsights.livemetrics.models.CollectionConfigurationInfo; +import com.azure.applicationinsights.livemetrics.models.Exception; +import com.azure.applicationinsights.livemetrics.models.KeyValuePairStringString; +import com.azure.applicationinsights.livemetrics.models.MetricPoint; +import com.azure.applicationinsights.livemetrics.models.MonitoringDataPoint; +import com.azure.applicationinsights.livemetrics.models.Request; +import com.azure.identity.DefaultAzureCredentialBuilder; +import java.time.OffsetDateTime; +import java.util.Arrays; + +public class LiveMetricsClientPublishesLiveMetrics { + public static void main(String[] args) { + LiveMetricsClient liveMetricsClient + = new LiveMetricsClientBuilder().credential(new DefaultAzureCredentialBuilder().build()) + .endpoint("https://global.livediagnostics.monitor.azure.com") + .buildClient(); + // BEGIN:com.azure.applicationinsights.livemetrics.generated.publish.livemetricsclientpublisheslivemetrics + CollectionConfigurationInfo response + = liveMetricsClient + .publish("4473b98e-c70d-4220-b57c-2984c2a0e5cd", "1::bu8uyb2wr89ycvvn0iznpa4a9ufqax76::2::", + 638422471817023700L, + Arrays.asList(new MonitoringDataPoint("2.1.0.42", 5, "server-pc-name", "", "SERVER-PC-NAME", + "41112328328b4edb9aa777aa6d675186", false, true) + .setTimestamp(OffsetDateTime.parse("2024-02-01T21:36:30.5717105Z")) + .setMetrics(Arrays.asList(new MetricPoint("\\ApplicationInsights\\Requests/Sec", 0.9989, 1), + new MetricPoint("\\ApplicationInsights\\Request Duration", 2.266, 1), + new MetricPoint("\\ApplicationInsights\\Requests Failed/Sec", 0.0, 1), + new MetricPoint("\\ApplicationInsights\\Requests Succeeded/Sec", 0.9989, 1), + new MetricPoint("\\ApplicationInsights\\Dependency Calls/Sec", 0.0, 1), new MetricPoint( + "\\ApplicationInsights\\Dependency Call Duration", 0.0, 0), + new MetricPoint("\\ApplicationInsights\\Dependency Calls Failed/Sec", 0.0, 1), + new MetricPoint("\\ApplicationInsights\\Dependency Calls Succeeded/Sec", 0.0, 1), + new MetricPoint("\\ApplicationInsights\\Exceptions/Sec", 0.0, 1), new MetricPoint( + "\\ASP.NET Applications(__Total__)\\Requests In Application Queue", 0.0, 1), + new MetricPoint("\\Memory\\Committed Bytes", 1.9902644224E10, 1), + new MetricPoint("\\Processor(_Total)\\% Processor Time", 54.738, 1))) + .setDocuments( + Arrays + .asList( + new Exception() + .setProperties(Arrays.asList( + new KeyValuePairStringString("fakeTokenPlaceholder", "UserPropValue2"), + new KeyValuePairStringString("fakeTokenPlaceholder", + "true"), + new KeyValuePairStringString("fakeTokenPlaceholder", "UserPropValue1"))) + .setExceptionType("System.ArgumentNullException") + .setExceptionMessage( + "Value cannot be null.\r\nParameter name: This exception has properties"), + new Request() + .setProperties(Arrays + .asList(new KeyValuePairStringString("fakeTokenPlaceholder", "true"))) + .setName("GET Home/blablabla") + .setUrl("http://40.78.109.134/Home/blablabla") + .setResponseCode("fakeTokenPlaceholder") + .setDuration("PT0.0010105S"))))); + // END:com.azure.applicationinsights.livemetrics.generated.publish.livemetricsclientpublisheslivemetrics + } +} diff --git a/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/test/java/com/azure/applicationinsights/livemetrics/generated/LiveMetricsClientChecksIfItsDataIsSubscribedToTests.java b/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/test/java/com/azure/applicationinsights/livemetrics/generated/LiveMetricsClientChecksIfItsDataIsSubscribedToTests.java new file mode 100644 index 000000000000..a104ed3d0683 --- /dev/null +++ b/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/test/java/com/azure/applicationinsights/livemetrics/generated/LiveMetricsClientChecksIfItsDataIsSubscribedToTests.java @@ -0,0 +1,99 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.applicationinsights.livemetrics.generated; + +import com.azure.applicationinsights.livemetrics.models.AggregationType; +import com.azure.applicationinsights.livemetrics.models.CollectionConfigurationInfo; +import com.azure.applicationinsights.livemetrics.models.DerivedMetricInfo; +import com.azure.applicationinsights.livemetrics.models.DocumentFilterConjunctionGroupInfo; +import com.azure.applicationinsights.livemetrics.models.DocumentStreamInfo; +import com.azure.applicationinsights.livemetrics.models.FilterConjunctionGroupInfo; +import com.azure.applicationinsights.livemetrics.models.FilterInfo; +import com.azure.applicationinsights.livemetrics.models.MonitoringDataPoint; +import com.azure.applicationinsights.livemetrics.models.PredicateType; +import com.azure.applicationinsights.livemetrics.models.QuotaConfigurationInfo; +import com.azure.applicationinsights.livemetrics.models.TelemetryType; +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 LiveMetricsClientChecksIfItsDataIsSubscribedToTests extends LiveMetricsClientTestBase { + @Test + @Disabled + public void testLiveMetricsClientChecksIfItsDataIsSubscribedToTests() { + // method invocation + CollectionConfigurationInfo response = liveMetricsClient.isSubscribed("4473b98e-c70d-4220-b57c-2984c2a0e5cd", + 638422471817023700L, "SERVER-PC-NAME", "server-pc-name", "41112328328b4edb9aa777aa6d675186", + "server-role-name", "5", "1::bu8uyb2wr89ycvvn0iznpa4a9ufqax76::2::", + new MonitoringDataPoint("2.21.0-429", 5, "server-pc-name", "", "SERVER-PC-NAME", + "41112328328b4edb9aa777aa6d675186", false, true) + .setTimestamp(OffsetDateTime.parse("2024-02-01T21:36:32.5717105Z"))); + + // response assertion + Assertions.assertNotNull(response); + // verify property "eTag" + Assertions.assertEquals("1::bu8uyb2wr89ycvvn0iznpa4a9ufqax76::2::", response.getETag()); + // verify property "metrics" + List responseMetrics = response.getMetrics(); + DerivedMetricInfo responseMetricsFirstItem = responseMetrics.iterator().next(); + Assertions.assertNotNull(responseMetricsFirstItem); + Assertions.assertEquals("141.8a7513a4", responseMetricsFirstItem.getId()); + Assertions.assertEquals("Request", responseMetricsFirstItem.getTelemetryType()); + List responseMetricsFirstItemFilterGroups + = responseMetricsFirstItem.getFilterGroups(); + FilterConjunctionGroupInfo responseMetricsFirstItemFilterGroupsFirstItem + = responseMetricsFirstItemFilterGroups.iterator().next(); + Assertions.assertNotNull(responseMetricsFirstItemFilterGroupsFirstItem); + List responseMetricsFirstItemFilterGroupsFirstItemFilters + = responseMetricsFirstItemFilterGroupsFirstItem.getFilters(); + FilterInfo responseMetricsFirstItemFilterGroupsFirstItemFiltersFirstItem + = responseMetricsFirstItemFilterGroupsFirstItemFilters.iterator().next(); + Assertions.assertNotNull(responseMetricsFirstItemFilterGroupsFirstItemFiltersFirstItem); + Assertions.assertEquals("Duration", + responseMetricsFirstItemFilterGroupsFirstItemFiltersFirstItem.getFieldName()); + Assertions.assertEquals(PredicateType.GREATER_THAN, + responseMetricsFirstItemFilterGroupsFirstItemFiltersFirstItem.getPredicate()); + Assertions.assertEquals("0.0:0:10", + responseMetricsFirstItemFilterGroupsFirstItemFiltersFirstItem.getComparand()); + Assertions.assertEquals("Duration", responseMetricsFirstItem.getProjection()); + Assertions.assertEquals(AggregationType.AVG, responseMetricsFirstItem.getAggregation()); + Assertions.assertEquals(AggregationType.AVG, responseMetricsFirstItem.getBackEndAggregation()); + // verify property "documentStreams" + List responseDocumentStreams = response.getDocumentStreams(); + DocumentStreamInfo responseDocumentStreamsFirstItem = responseDocumentStreams.iterator().next(); + Assertions.assertNotNull(responseDocumentStreamsFirstItem); + Assertions.assertEquals("200.ecb0e7dd", responseDocumentStreamsFirstItem.getId()); + List responseDocumentStreamsFirstItemDocumentFilterGroups + = responseDocumentStreamsFirstItem.getDocumentFilterGroups(); + DocumentFilterConjunctionGroupInfo responseDocumentStreamsFirstItemDocumentFilterGroupsFirstItem + = responseDocumentStreamsFirstItemDocumentFilterGroups.iterator().next(); + Assertions.assertNotNull(responseDocumentStreamsFirstItemDocumentFilterGroupsFirstItem); + Assertions.assertEquals(TelemetryType.REQUEST, + responseDocumentStreamsFirstItemDocumentFilterGroupsFirstItem.getTelemetryType()); + FilterConjunctionGroupInfo responseDocumentStreamsFirstItemDocumentFilterGroupsFirstItemFilters + = responseDocumentStreamsFirstItemDocumentFilterGroupsFirstItem.getFilters(); + Assertions.assertNotNull(responseDocumentStreamsFirstItemDocumentFilterGroupsFirstItemFilters); + List responseDocumentStreamsFirstItemDocumentFilterGroupsFirstItemFiltersFilters + = responseDocumentStreamsFirstItemDocumentFilterGroupsFirstItemFilters.getFilters(); + FilterInfo responseDocumentStreamsFirstItemDocumentFilterGroupsFirstItemFiltersFiltersFirstItem + = responseDocumentStreamsFirstItemDocumentFilterGroupsFirstItemFiltersFilters.iterator().next(); + Assertions.assertNotNull(responseDocumentStreamsFirstItemDocumentFilterGroupsFirstItemFiltersFiltersFirstItem); + Assertions.assertEquals("Success", + responseDocumentStreamsFirstItemDocumentFilterGroupsFirstItemFiltersFiltersFirstItem.getFieldName()); + Assertions.assertEquals(PredicateType.EQUAL, + responseDocumentStreamsFirstItemDocumentFilterGroupsFirstItemFiltersFiltersFirstItem.getPredicate()); + Assertions.assertEquals("False", + responseDocumentStreamsFirstItemDocumentFilterGroupsFirstItemFiltersFiltersFirstItem.getComparand()); + // verify property "quotaInfo" + QuotaConfigurationInfo responseQuotaInfo = response.getQuotaInfo(); + Assertions.assertNotNull(responseQuotaInfo); + Assertions.assertEquals(200.0D, responseQuotaInfo.getInitialQuota()); + Assertions.assertEquals(200.0, responseQuotaInfo.getMaxQuota()); + Assertions.assertEquals(200.0, responseQuotaInfo.getQuotaAccrualRatePerSec()); + } +} diff --git a/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/test/java/com/azure/applicationinsights/livemetrics/generated/LiveMetricsClientPublishesLiveMetricsTests.java b/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/test/java/com/azure/applicationinsights/livemetrics/generated/LiveMetricsClientPublishesLiveMetricsTests.java new file mode 100644 index 000000000000..3eabb6e10d2a --- /dev/null +++ b/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/test/java/com/azure/applicationinsights/livemetrics/generated/LiveMetricsClientPublishesLiveMetricsTests.java @@ -0,0 +1,106 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.applicationinsights.livemetrics.generated; + +import com.azure.applicationinsights.livemetrics.models.CollectionConfigurationInfo; +import com.azure.applicationinsights.livemetrics.models.DerivedMetricInfo; +import com.azure.applicationinsights.livemetrics.models.DocumentFilterConjunctionGroupInfo; +import com.azure.applicationinsights.livemetrics.models.DocumentStreamInfo; +import com.azure.applicationinsights.livemetrics.models.Exception; +import com.azure.applicationinsights.livemetrics.models.FilterConjunctionGroupInfo; +import com.azure.applicationinsights.livemetrics.models.FilterInfo; +import com.azure.applicationinsights.livemetrics.models.KeyValuePairStringString; +import com.azure.applicationinsights.livemetrics.models.MetricPoint; +import com.azure.applicationinsights.livemetrics.models.MonitoringDataPoint; +import com.azure.applicationinsights.livemetrics.models.PredicateType; +import com.azure.applicationinsights.livemetrics.models.Request; +import com.azure.applicationinsights.livemetrics.models.TelemetryType; +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 LiveMetricsClientPublishesLiveMetricsTests extends LiveMetricsClientTestBase { + @Test + @Disabled + public void testLiveMetricsClientPublishesLiveMetricsTests() { + // method invocation + CollectionConfigurationInfo response + = liveMetricsClient + .publish("4473b98e-c70d-4220-b57c-2984c2a0e5cd", "1::bu8uyb2wr89ycvvn0iznpa4a9ufqax76::2::", + 638422471817023700L, + Arrays.asList(new MonitoringDataPoint("2.1.0.42", 5, "server-pc-name", "", "SERVER-PC-NAME", + "41112328328b4edb9aa777aa6d675186", false, true) + .setTimestamp(OffsetDateTime.parse("2024-02-01T21:36:30.5717105Z")) + .setMetrics(Arrays.asList(new MetricPoint("\\ApplicationInsights\\Requests/Sec", 0.9989, 1), + new MetricPoint("\\ApplicationInsights\\Request Duration", 2.266, 1), + new MetricPoint("\\ApplicationInsights\\Requests Failed/Sec", 0.0, 1), + new MetricPoint("\\ApplicationInsights\\Requests Succeeded/Sec", 0.9989, 1), + new MetricPoint("\\ApplicationInsights\\Dependency Calls/Sec", 0.0, 1), new MetricPoint( + "\\ApplicationInsights\\Dependency Call Duration", 0.0, 0), + new MetricPoint("\\ApplicationInsights\\Dependency Calls Failed/Sec", 0.0, 1), + new MetricPoint("\\ApplicationInsights\\Dependency Calls Succeeded/Sec", 0.0, 1), + new MetricPoint("\\ApplicationInsights\\Exceptions/Sec", 0.0, 1), new MetricPoint( + "\\ASP.NET Applications(__Total__)\\Requests In Application Queue", 0.0, 1), + new MetricPoint("\\Memory\\Committed Bytes", 1.9902644224E10, 1), + new MetricPoint("\\Processor(_Total)\\% Processor Time", 54.738, 1))) + .setDocuments( + Arrays + .asList( + new Exception() + .setProperties(Arrays.asList( + new KeyValuePairStringString("fakeTokenPlaceholder", "UserPropValue2"), + new KeyValuePairStringString("fakeTokenPlaceholder", + "true"), + new KeyValuePairStringString("fakeTokenPlaceholder", "UserPropValue1"))) + .setExceptionType("System.ArgumentNullException") + .setExceptionMessage( + "Value cannot be null.\r\nParameter name: This exception has properties"), + new Request() + .setProperties(Arrays + .asList(new KeyValuePairStringString("fakeTokenPlaceholder", "true"))) + .setName("GET Home/blablabla") + .setUrl("http://40.78.109.134/Home/blablabla") + .setResponseCode("fakeTokenPlaceholder") + .setDuration("PT0.0010105S"))))); + + // response assertion + Assertions.assertNotNull(response); + // verify property "eTag" + Assertions.assertEquals("1::bu8uyb2wr89ycvvn0iznpa4a9ufqax76::2::", response.getETag()); + // verify property "metrics" + List responseMetrics = response.getMetrics(); + Assertions.assertEquals(0, responseMetrics.size()); + // verify property "documentStreams" + List responseDocumentStreams = response.getDocumentStreams(); + DocumentStreamInfo responseDocumentStreamsFirstItem = responseDocumentStreams.iterator().next(); + Assertions.assertNotNull(responseDocumentStreamsFirstItem); + Assertions.assertEquals("all-types-default", responseDocumentStreamsFirstItem.getId()); + List responseDocumentStreamsFirstItemDocumentFilterGroups + = responseDocumentStreamsFirstItem.getDocumentFilterGroups(); + DocumentFilterConjunctionGroupInfo responseDocumentStreamsFirstItemDocumentFilterGroupsFirstItem + = responseDocumentStreamsFirstItemDocumentFilterGroups.iterator().next(); + Assertions.assertNotNull(responseDocumentStreamsFirstItemDocumentFilterGroupsFirstItem); + Assertions.assertEquals(TelemetryType.REQUEST, + responseDocumentStreamsFirstItemDocumentFilterGroupsFirstItem.getTelemetryType()); + FilterConjunctionGroupInfo responseDocumentStreamsFirstItemDocumentFilterGroupsFirstItemFilters + = responseDocumentStreamsFirstItemDocumentFilterGroupsFirstItem.getFilters(); + Assertions.assertNotNull(responseDocumentStreamsFirstItemDocumentFilterGroupsFirstItemFilters); + List responseDocumentStreamsFirstItemDocumentFilterGroupsFirstItemFiltersFilters + = responseDocumentStreamsFirstItemDocumentFilterGroupsFirstItemFilters.getFilters(); + FilterInfo responseDocumentStreamsFirstItemDocumentFilterGroupsFirstItemFiltersFiltersFirstItem + = responseDocumentStreamsFirstItemDocumentFilterGroupsFirstItemFiltersFilters.iterator().next(); + Assertions.assertNotNull(responseDocumentStreamsFirstItemDocumentFilterGroupsFirstItemFiltersFiltersFirstItem); + Assertions.assertEquals("Success", + responseDocumentStreamsFirstItemDocumentFilterGroupsFirstItemFiltersFiltersFirstItem.getFieldName()); + Assertions.assertEquals(PredicateType.EQUAL, + responseDocumentStreamsFirstItemDocumentFilterGroupsFirstItemFiltersFiltersFirstItem.getPredicate()); + Assertions.assertEquals("false", + responseDocumentStreamsFirstItemDocumentFilterGroupsFirstItemFiltersFiltersFirstItem.getComparand()); + } +} diff --git a/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/test/java/com/azure/applicationinsights/livemetrics/generated/LiveMetricsClientTestBase.java b/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/test/java/com/azure/applicationinsights/livemetrics/generated/LiveMetricsClientTestBase.java new file mode 100644 index 000000000000..f9ff32e9edb2 --- /dev/null +++ b/sdk/applicationinsights/azure-applicationinsights-livemetrics/src/test/java/com/azure/applicationinsights/livemetrics/generated/LiveMetricsClientTestBase.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.applicationinsights.livemetrics.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.applicationinsights.livemetrics.LiveMetricsClient; +import com.azure.applicationinsights.livemetrics.LiveMetricsClientBuilder; +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 LiveMetricsClientTestBase extends TestProxyTestBase { + protected LiveMetricsClient liveMetricsClient; + + @Override + protected void beforeTest() { + LiveMetricsClientBuilder liveMetricsClientbuilder = new LiveMetricsClientBuilder() + .endpoint(Configuration.getGlobalConfiguration() + .get("ENDPOINT", "https://global.livediagnostics.monitor.azure.com")) + .httpClient(getHttpClientOrUsePlayback(getHttpClients().findFirst().orElse(null))) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + liveMetricsClientbuilder.credential(new MockTokenCredential()); + } else if (getTestMode() == TestMode.RECORD) { + liveMetricsClientbuilder.addPolicy(interceptorManager.getRecordPolicy()) + .credential(new DefaultAzureCredentialBuilder().build()); + } else if (getTestMode() == TestMode.LIVE) { + liveMetricsClientbuilder.credential(new DefaultAzureCredentialBuilder().build()); + } + liveMetricsClient = liveMetricsClientbuilder.buildClient(); + + } +} diff --git a/sdk/applicationinsights/azure-applicationinsights-livemetrics/tsp-location.yaml b/sdk/applicationinsights/azure-applicationinsights-livemetrics/tsp-location.yaml new file mode 100644 index 000000000000..bc3d18bda7b7 --- /dev/null +++ b/sdk/applicationinsights/azure-applicationinsights-livemetrics/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/applicationinsights/ApplicationInsights.LiveMetrics +commit: c537a4e6cc3ed95c030b2c10671d1f0585ddcc08 +repo: Azure/azure-rest-api-specs +additionalDirectories: diff --git a/sdk/applicationinsights/ci.yml b/sdk/applicationinsights/ci.yml index 45f10c6069b1..06e4d45769cf 100644 --- a/sdk/applicationinsights/ci.yml +++ b/sdk/applicationinsights/ci.yml @@ -37,3 +37,6 @@ extends: - name: azure-resourcemanager-applicationinsights groupId: com.azure.resourcemanager safeName: azureresourcemanagerapplicationinsights + - name: azure-applicationinsights-livemetrics + groupId: com.azure + safeName: azureapplicationinsightslivemetrics diff --git a/sdk/applicationinsights/pom.xml b/sdk/applicationinsights/pom.xml index 9c2c91714ffd..59f2dc2b9c33 100644 --- a/sdk/applicationinsights/pom.xml +++ b/sdk/applicationinsights/pom.xml @@ -10,6 +10,7 @@ 1.0.0 - azure-resourcemanager-applicationinsights + azure-applicationinsights-livemetrics + azure-resourcemanager-applicationinsights