diff --git a/eng/versioning/version_client.txt b/eng/versioning/version_client.txt index 1fa30caaabd9..feb9d5ed2c6a 100644 --- a/eng/versioning/version_client.txt +++ b/eng/versioning/version_client.txt @@ -527,6 +527,7 @@ com.azure.resourcemanager:azure-resourcemanager-appnetwork;1.0.0-beta.1;1.0.0-be com.azure.resourcemanager:azure-resourcemanager-servicegroups;1.0.0-beta.2;1.0.0-beta.3 com.azure.resourcemanager:azure-resourcemanager-horizondb;1.0.0-beta.1;1.0.0-beta.1 com.azure.resourcemanager:azure-resourcemanager-relationships;1.0.0-beta.1;1.0.0-beta.2 +com.azure.resourcemanager:azure-resourcemanager-monitor-slis;1.0.0-beta.1;1.0.0-beta.1 com.azure.tools:azure-sdk-archetype;1.0.0;1.2.0-beta.1 com.azure.tools:azure-sdk-build-tool;1.0.0;1.1.0-beta.1 com.azure.v2:azure-client-sdk-parent;2.0.0-beta.2;2.0.0-beta.2 diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/CHANGELOG.md b/sdk/monitor/azure-resourcemanager-monitor-slis/CHANGELOG.md new file mode 100644 index 000000000000..38b732e10d23 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/CHANGELOG.md @@ -0,0 +1,14 @@ +# Release History + +## 1.0.0-beta.1 (2026-04-22) + +### Features Added + +- Initial preview release of `azure-resourcemanager-monitor-slis` for managing + Service Level Indicator (SLI) resources under the `Microsoft.Monitor` namespace. +- Support for SLI resource CRUD operations: create or update, get, delete, and list. +- SLI evaluation with Availability and Latency categories, supporting both + window-based and request-based evaluation types with configurable signal sources, + aggregation, and SLO baselines. +- Integration with Azure Monitor Workspace (AMW) accounts for metric emission, + with managed identity and alert support. diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/README.md b/sdk/monitor/azure-resourcemanager-monitor-slis/README.md new file mode 100644 index 000000000000..84f448afb1e8 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/README.md @@ -0,0 +1,102 @@ +# Azure Resource Manager Slis client library for Java + +Azure Resource Manager Slis client library for Java. + +This package contains Microsoft Azure SDK for Slis Management SDK. Package api-version 2025-03-01-preview. For documentation on how to use this package, please see [Azure Management Libraries for Java](https://aka.ms/azsdk/java/mgmt). + +## We'd love to hear your feedback + +We're always working on improving our products and the way we communicate with our users. So we'd love to learn what's working and how we can do better. + +If you haven't already, please take a few minutes to [complete this short survey][survey] we have put together. + +Thank you in advance for your collaboration. We really appreciate your time! + +## Documentation + +Various documentation is available to help you get started + +- [API reference documentation][docs] + +## 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.resourcemanager:azure-resourcemanager-monitor-slis;current}) +```xml + + com.azure.resourcemanager + azure-resourcemanager-monitor-slis + 1.0.0-beta.1 + +``` +[//]: # ({x-version-update-end}) + +### Include the recommended packages + +Azure Management Libraries require a `TokenCredential` implementation for authentication and an `HttpClient` implementation for HTTP client. + +[Azure Identity][azure_identity] and [Azure Core Netty HTTP][azure_core_http_netty] packages provide the default implementation. + +### Authentication + +Microsoft Entra ID token authentication relies on the [credential class][azure_identity_credentials] from [Azure Identity][azure_identity] package. + +Azure subscription ID can be configured via `AZURE_SUBSCRIPTION_ID` environment variable. + +Assuming the use of the `DefaultAzureCredential` credential class, the client can be authenticated using the following code: + +```java +AzureProfile profile = new AzureProfile(AzureCloud.AZURE_PUBLIC_CLOUD); +TokenCredential credential = new DefaultAzureCredentialBuilder() + .authorityHost(profile.getEnvironment().getActiveDirectoryEndpoint()) + .build(); +SlisManager manager = SlisManager + .authenticate(credential, profile); +``` + +The sample code assumes global Azure. Please change the `AzureCloud.AZURE_PUBLIC_CLOUD` variable if otherwise. + +See [Authentication][authenticate] for more options. + +## Key concepts + +See [API design][design] for general introduction on design and key concepts on Azure Management Libraries. + +## Examples + +[Code snippets and samples](https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/monitor/azure-resourcemanager-monitor-slis/SAMPLE.md) + + +## Troubleshooting + +## Next steps + +## Contributing + +For details on contributing to this repository, see the [contributing guide][cg]. + +This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit . + +When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repositories using our CLA. + +This project has adopted the [Microsoft Open Source Code of Conduct][coc]. For more information see the [Code of Conduct FAQ][coc_faq] or contact with any additional questions or comments. + + +[survey]: https://microsoft.qualtrics.com/jfe/form/SV_ehN0lIk2FKEBkwd?Q_CHL=DOCS +[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 +[azure_identity_credentials]: https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/identity/azure-identity#credentials +[azure_core_http_netty]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/core/azure-core-http-netty +[authenticate]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/resourcemanager/docs/AUTH.md +[design]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/resourcemanager/docs/DESIGN.md +[cg]: https://github.com/Azure/azure-sdk-for-java/blob/main/CONTRIBUTING.md +[coc]: https://opensource.microsoft.com/codeofconduct/ +[coc_faq]: https://opensource.microsoft.com/codeofconduct/faq/ diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/SAMPLE.md b/sdk/monitor/azure-resourcemanager-monitor-slis/SAMPLE.md new file mode 100644 index 000000000000..d7d077f280cb --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/SAMPLE.md @@ -0,0 +1,160 @@ +# Code snippets and samples + + +## Slis + +- [CreateOrUpdate](#slis_createorupdate) +- [Delete](#slis_delete) +- [Get](#slis_get) +- [ListByParent](#slis_listbyparent) +### Slis_CreateOrUpdate + +```java +import com.azure.resourcemanager.monitor.slis.fluent.models.SliInner; +import com.azure.resourcemanager.monitor.slis.models.AmwAccount; +import com.azure.resourcemanager.monitor.slis.models.Baseline; +import com.azure.resourcemanager.monitor.slis.models.BaselineProperties; +import com.azure.resourcemanager.monitor.slis.models.Category; +import com.azure.resourcemanager.monitor.slis.models.Condition; +import com.azure.resourcemanager.monitor.slis.models.ConditionOperator; +import com.azure.resourcemanager.monitor.slis.models.EvaluationCalculationType; +import com.azure.resourcemanager.monitor.slis.models.EvaluationType; +import com.azure.resourcemanager.monitor.slis.models.Signal; +import com.azure.resourcemanager.monitor.slis.models.SignalSource; +import com.azure.resourcemanager.monitor.slis.models.SliProperties; +import com.azure.resourcemanager.monitor.slis.models.SliResource; +import com.azure.resourcemanager.monitor.slis.models.SpatialAggregation; +import com.azure.resourcemanager.monitor.slis.models.SpatialAggregationType; +import com.azure.resourcemanager.monitor.slis.models.TemporalAggregation; +import com.azure.resourcemanager.monitor.slis.models.TemporalAggregationType; +import com.azure.resourcemanager.monitor.slis.models.WindowUptimeCriteria; +import com.azure.resourcemanager.monitor.slis.models.WindowUptimeCriteriaComparator; +import java.util.Arrays; + +/** + * Samples for Slis CreateOrUpdate. + */ +public final class SlisCreateOrUpdateSamples { + /* + * x-ms-original-file: 2025-03-01-preview/Slis_CreateOrUpdate.json + */ + /** + * Sample code: CreateSli. + * + * @param manager Entry point to SlisManager. + */ + public static void createSli(com.azure.resourcemanager.monitor.slis.SlisManager manager) { + manager.slis() + .createOrUpdateWithResponse("testSG", "testSli", new SliInner().withProperties(new SliResource() + .withDescription("Measures the performance characteristics of the GetContosoUsers() API. ") + .withCategory(Category.LATENCY) + .withEvaluationType(EvaluationType.WINDOW_BASED) + .withDestinationAmwAccounts(Arrays.asList(new AmwAccount() + .withResourceId( + "/subscriptions//resourcegroups//providers/microsoft.monitor/accounts/") + .withIdentity( + "/subscriptions//resourcegroups//providers/Microsoft.ManagedIdentity/userAssignedIdentities/"))) + .withBaselineProperties(new BaselineProperties().withBaseline(new Baseline().withValue(99.0) + .withEvaluationPeriodDays(30) + .withEvaluationCalculationType(EvaluationCalculationType.CALENDAR_DAYS))) + .withEnableAlert(true) + .withSliProperties(new SliProperties().withSignals(new Signal().withSignalSources(Arrays.asList( + new SignalSource().withSignalSourceId("A") + .withSourceAmwAccountManagedIdentity( + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myIdentity") + .withSourceAmwAccountResourceId( + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/microsoft.monitor/accounts/myAccount") + .withMetricNamespace("ContosoMetricsWest") + .withMetricName("Stamp1Latency") + .withFilters(Arrays.asList(new Condition().withDimensionName("ApiName") + .withOperator(ConditionOperator.EQUAL) + .withValue("GetContosoUsers"))) + .withSpatialAggregation(new SpatialAggregation().withType(SpatialAggregationType.AVERAGE) + .withDimensions(Arrays.asList("Region", "ResponseCode"))) + .withTemporalAggregation(new TemporalAggregation().withType(TemporalAggregationType.AVERAGE) + .withWindowSizeMinutes(5)), + new SignalSource().withSignalSourceId("B") + .withSourceAmwAccountManagedIdentity( + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myIdentity") + .withSourceAmwAccountResourceId( + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/microsoft.monitor/accounts/myAccount") + .withMetricNamespace("ContosoMetricsEast") + .withMetricName("Stamp2Latency") + .withFilters(Arrays.asList(new Condition().withDimensionName("ApiName") + .withOperator(ConditionOperator.EQUAL) + .withValue("GetContosoUsers"))) + .withSpatialAggregation(new SpatialAggregation().withType(SpatialAggregationType.AVERAGE) + .withDimensions(Arrays.asList("Region", "ResponseCode"))) + .withTemporalAggregation(new TemporalAggregation().withType(TemporalAggregationType.AVERAGE) + .withWindowSizeMinutes(5)))) + .withSignalFormula("(A + B) /2")) + .withWindowUptimeCriteria(new WindowUptimeCriteria().withTarget(95.0) + .withComparator(WindowUptimeCriteriaComparator.GREATER_THAN_OR_EQUAL)))), + com.azure.core.util.Context.NONE); + } +} +``` + +### Slis_Delete + +```java +/** + * Samples for Slis Delete. + */ +public final class SlisDeleteSamples { + /* + * x-ms-original-file: 2025-03-01-preview/Slis_Delete.json + */ + /** + * Sample code: DeleteSli. + * + * @param manager Entry point to SlisManager. + */ + public static void deleteSli(com.azure.resourcemanager.monitor.slis.SlisManager manager) { + manager.slis().deleteByResourceGroupWithResponse("testSG", "testSli", com.azure.core.util.Context.NONE); + } +} +``` + +### Slis_Get + +```java +/** + * Samples for Slis Get. + */ +public final class SlisGetSamples { + /* + * x-ms-original-file: 2025-03-01-preview/Slis_Get.json + */ + /** + * Sample code: GetSli. + * + * @param manager Entry point to SlisManager. + */ + public static void getSli(com.azure.resourcemanager.monitor.slis.SlisManager manager) { + manager.slis().getWithResponse("testSG", "testSli", com.azure.core.util.Context.NONE); + } +} +``` + +### Slis_ListByParent + +```java +/** + * Samples for Slis ListByParent. + */ +public final class SlisListByParentSamples { + /* + * x-ms-original-file: 2025-03-01-preview/Slis_ListByParent.json + */ + /** + * Sample code: SlisListByParent. + * + * @param manager Entry point to SlisManager. + */ + public static void slisListByParent(com.azure.resourcemanager.monitor.slis.SlisManager manager) { + manager.slis().listByParent("testSG", com.azure.core.util.Context.NONE); + } +} +``` + diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/pom.xml b/sdk/monitor/azure-resourcemanager-monitor-slis/pom.xml new file mode 100644 index 000000000000..3642f391e2b0 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/pom.xml @@ -0,0 +1,74 @@ + + + 4.0.0 + + com.azure + azure-client-sdk-parent + 1.7.0 + ../../parents/azure-client-sdk-parent + + + com.azure.resourcemanager + azure-resourcemanager-monitor-slis + 1.0.0-beta.1 + jar + + Microsoft Azure SDK for Slis Management + This package contains Microsoft Azure SDK for Slis Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. Package api-version 2025-03-01-preview. + 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 + 0 + 0 + true + + + + com.azure + azure-core + 1.57.1 + + + com.azure + azure-core-management + 1.19.3 + + + com.azure + azure-core-test + 1.27.0-beta.14 + test + + + com.azure + azure-identity + 1.18.2 + test + + + diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/SlisManager.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/SlisManager.java new file mode 100644 index 000000000000..6a8c014d906a --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/SlisManager.java @@ -0,0 +1,280 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis; + +import com.azure.core.credential.TokenCredential; +import com.azure.core.http.HttpClient; +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.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.management.profile.AzureProfile; +import com.azure.core.util.Configuration; +import com.azure.core.util.CoreUtils; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.monitor.slis.fluent.SlisManagementClient; +import com.azure.resourcemanager.monitor.slis.implementation.SlisImpl; +import com.azure.resourcemanager.monitor.slis.implementation.SlisManagementClientBuilder; +import com.azure.resourcemanager.monitor.slis.models.Slis; +import java.time.Duration; +import java.time.temporal.ChronoUnit; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.stream.Collectors; + +/** + * Entry point to SlisManager. + */ +public final class SlisManager { + private Slis slis; + + private final SlisManagementClient clientObject; + + private SlisManager(HttpPipeline httpPipeline, AzureProfile profile, Duration defaultPollInterval) { + Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + this.clientObject = new SlisManagementClientBuilder().pipeline(httpPipeline) + .endpoint(profile.getEnvironment().getResourceManagerEndpoint()) + .defaultPollInterval(defaultPollInterval) + .buildClient(); + } + + /** + * Creates an instance of Slis service API entry point. + * + * @param credential the credential to use. + * @param profile the Azure profile for client. + * @return the Slis service API instance. + */ + public static SlisManager authenticate(TokenCredential credential, AzureProfile profile) { + Objects.requireNonNull(credential, "'credential' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + return configure().authenticate(credential, profile); + } + + /** + * Creates an instance of Slis service API entry point. + * + * @param httpPipeline the {@link HttpPipeline} configured with Azure authentication credential. + * @param profile the Azure profile for client. + * @return the Slis service API instance. + */ + public static SlisManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) { + Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + return new SlisManager(httpPipeline, profile, null); + } + + /** + * Gets a Configurable instance that can be used to create SlisManager with optional configuration. + * + * @return the Configurable instance allowing configurations. + */ + public static Configurable configure() { + return new SlisManager.Configurable(); + } + + /** + * The Configurable allowing configurations to be set. + */ + public static final class Configurable { + private static final ClientLogger LOGGER = new ClientLogger(Configurable.class); + private static final String SDK_VERSION = "version"; + private static final Map PROPERTIES + = CoreUtils.getProperties("azure-resourcemanager-monitor-slis.properties"); + + private HttpClient httpClient; + private HttpLogOptions httpLogOptions; + private final List policies = new ArrayList<>(); + private final List scopes = new ArrayList<>(); + private RetryPolicy retryPolicy; + private RetryOptions retryOptions; + private Duration defaultPollInterval; + + private Configurable() { + } + + /** + * Sets the http client. + * + * @param httpClient the HTTP client. + * @return the configurable object itself. + */ + public Configurable withHttpClient(HttpClient httpClient) { + this.httpClient = Objects.requireNonNull(httpClient, "'httpClient' cannot be null."); + return this; + } + + /** + * Sets the logging options to the HTTP pipeline. + * + * @param httpLogOptions the HTTP log options. + * @return the configurable object itself. + */ + public Configurable withLogOptions(HttpLogOptions httpLogOptions) { + this.httpLogOptions = Objects.requireNonNull(httpLogOptions, "'httpLogOptions' cannot be null."); + return this; + } + + /** + * Adds the pipeline policy to the HTTP pipeline. + * + * @param policy the HTTP pipeline policy. + * @return the configurable object itself. + */ + public Configurable withPolicy(HttpPipelinePolicy policy) { + this.policies.add(Objects.requireNonNull(policy, "'policy' cannot be null.")); + return this; + } + + /** + * Adds the scope to permission sets. + * + * @param scope the scope. + * @return the configurable object itself. + */ + public Configurable withScope(String scope) { + this.scopes.add(Objects.requireNonNull(scope, "'scope' cannot be null.")); + return this; + } + + /** + * Sets the retry policy to the HTTP pipeline. + * + * @param retryPolicy the HTTP pipeline retry policy. + * @return the configurable object itself. + */ + public Configurable withRetryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = Objects.requireNonNull(retryPolicy, "'retryPolicy' cannot be null."); + return this; + } + + /** + * Sets the retry options for the HTTP pipeline retry policy. + *

+ * This setting has no effect, if retry policy is set via {@link #withRetryPolicy(RetryPolicy)}. + * + * @param retryOptions the retry options for the HTTP pipeline retry policy. + * @return the configurable object itself. + */ + public Configurable withRetryOptions(RetryOptions retryOptions) { + this.retryOptions = Objects.requireNonNull(retryOptions, "'retryOptions' cannot be null."); + return this; + } + + /** + * Sets the default poll interval, used when service does not provide "Retry-After" header. + * + * @param defaultPollInterval the default poll interval. + * @return the configurable object itself. + */ + public Configurable withDefaultPollInterval(Duration defaultPollInterval) { + this.defaultPollInterval + = Objects.requireNonNull(defaultPollInterval, "'defaultPollInterval' cannot be null."); + if (this.defaultPollInterval.isNegative()) { + throw LOGGER + .logExceptionAsError(new IllegalArgumentException("'defaultPollInterval' cannot be negative")); + } + return this; + } + + /** + * Creates an instance of Slis service API entry point. + * + * @param credential the credential to use. + * @param profile the Azure profile for client. + * @return the Slis service API instance. + */ + public SlisManager authenticate(TokenCredential credential, AzureProfile profile) { + Objects.requireNonNull(credential, "'credential' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + + String clientVersion = PROPERTIES.getOrDefault(SDK_VERSION, "UnknownVersion"); + + StringBuilder userAgentBuilder = new StringBuilder(); + userAgentBuilder.append("azsdk-java") + .append("-") + .append("com.azure.resourcemanager.monitor.slis") + .append("/") + .append(clientVersion); + if (!Configuration.getGlobalConfiguration().get("AZURE_TELEMETRY_DISABLED", false)) { + userAgentBuilder.append(" (") + .append(Configuration.getGlobalConfiguration().get("java.version")) + .append("; ") + .append(Configuration.getGlobalConfiguration().get("os.name")) + .append("; ") + .append(Configuration.getGlobalConfiguration().get("os.version")) + .append("; auto-generated)"); + } else { + userAgentBuilder.append(" (auto-generated)"); + } + + if (scopes.isEmpty()) { + scopes.add(profile.getEnvironment().getManagementEndpoint() + "/.default"); + } + if (retryPolicy == null) { + if (retryOptions != null) { + retryPolicy = new RetryPolicy(retryOptions); + } else { + retryPolicy = new RetryPolicy("Retry-After", ChronoUnit.SECONDS); + } + } + List policies = new ArrayList<>(); + policies.add(new UserAgentPolicy(userAgentBuilder.toString())); + policies.add(new AddHeadersFromContextPolicy()); + policies.add(new RequestIdPolicy()); + policies.addAll(this.policies.stream() + .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_CALL) + .collect(Collectors.toList())); + HttpPolicyProviders.addBeforeRetryPolicies(policies); + policies.add(retryPolicy); + policies.add(new AddDatePolicy()); + policies.add(new BearerTokenAuthenticationPolicy(credential, scopes.toArray(new String[0]))); + policies.addAll(this.policies.stream() + .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_RETRY) + .collect(Collectors.toList())); + HttpPolicyProviders.addAfterRetryPolicies(policies); + policies.add(new HttpLoggingPolicy(httpLogOptions)); + HttpPipeline httpPipeline = new HttpPipelineBuilder().httpClient(httpClient) + .policies(policies.toArray(new HttpPipelinePolicy[0])) + .build(); + return new SlisManager(httpPipeline, profile, defaultPollInterval); + } + } + + /** + * Gets the resource collection API of Slis. + * + * @return Resource collection API of Slis. + */ + public Slis slis() { + if (this.slis == null) { + this.slis = new SlisImpl(clientObject.getSlis(), this); + } + return slis; + } + + /** + * Gets wrapped service client SlisManagementClient providing direct access to the underlying auto-generated API + * implementation, based on Azure REST API. + * + * @return Wrapped service client SlisManagementClient. + */ + public SlisManagementClient serviceClient() { + return this.clientObject; + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/fluent/SlisClient.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/fluent/SlisClient.java new file mode 100644 index 000000000000..9a7e921bc200 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/fluent/SlisClient.java @@ -0,0 +1,125 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.fluent; + +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.Response; +import com.azure.core.util.Context; +import com.azure.resourcemanager.monitor.slis.fluent.models.SliInner; + +/** + * An instance of this class provides access to all the operations defined in SlisClient. + */ +public interface SlisClient { + /** + * Gets an SLI resource. + * + * @param serviceGroupName The name of the service group. + * @param sliName Name of the SLI that is given by the user. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an SLI resource along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response getWithResponse(String serviceGroupName, String sliName, Context context); + + /** + * Gets an SLI resource. + * + * @param serviceGroupName The name of the service group. + * @param sliName Name of the SLI that is given by the user. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an SLI resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + SliInner get(String serviceGroupName, String sliName); + + /** + * Creates or updates an SLI resource. + * + * @param serviceGroupName The name of the service group. + * @param sliName Name of the SLI that is given by the user. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return represents an SLI resource within the ProviderHub along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response createOrUpdateWithResponse(String serviceGroupName, String sliName, SliInner resource, + Context context); + + /** + * Creates or updates an SLI resource. + * + * @param serviceGroupName The name of the service group. + * @param sliName Name of the SLI that is given by the user. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return represents an SLI resource within the ProviderHub. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + SliInner createOrUpdate(String serviceGroupName, String sliName, SliInner resource); + + /** + * Deletes an SLI resource. + * + * @param serviceGroupName The name of the service group. + * @param sliName Name of the SLI that is given by the user. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response deleteWithResponse(String serviceGroupName, String sliName, Context context); + + /** + * Deletes an SLI resource. + * + * @param serviceGroupName The name of the service group. + * @param sliName Name of the SLI that is given by the user. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + void delete(String serviceGroupName, String sliName); + + /** + * Lists all SLI resources under a parent resource. + * + * @param serviceGroupName The name of the service group. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Sli list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable listByParent(String serviceGroupName); + + /** + * Lists all SLI resources under a parent resource. + * + * @param serviceGroupName The name of the service group. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Sli list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable listByParent(String serviceGroupName, Context context); +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/fluent/SlisManagementClient.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/fluent/SlisManagementClient.java new file mode 100644 index 000000000000..75feaeb2b8da --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/fluent/SlisManagementClient.java @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.fluent; + +import com.azure.core.http.HttpPipeline; +import java.time.Duration; + +/** + * The interface for SlisManagementClient class. + */ +public interface SlisManagementClient { + /** + * Gets Service host. + * + * @return the endpoint value. + */ + String getEndpoint(); + + /** + * Gets Version parameter. + * + * @return the apiVersion value. + */ + String getApiVersion(); + + /** + * Gets The HTTP pipeline to send requests through. + * + * @return the httpPipeline value. + */ + HttpPipeline getHttpPipeline(); + + /** + * Gets The default poll interval for long-running operation. + * + * @return the defaultPollInterval value. + */ + Duration getDefaultPollInterval(); + + /** + * Gets the SlisClient object to access its operations. + * + * @return the SlisClient object. + */ + SlisClient getSlis(); +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/fluent/models/SliInner.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/fluent/models/SliInner.java new file mode 100644 index 000000000000..b224d1be1016 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/fluent/models/SliInner.java @@ -0,0 +1,184 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.management.ProxyResource; +import com.azure.core.management.SystemData; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.azure.resourcemanager.monitor.slis.models.ManagedServiceIdentity; +import com.azure.resourcemanager.monitor.slis.models.SliResource; +import java.io.IOException; + +/** + * Represents an SLI resource within the ProviderHub. + */ +@Fluent +public final class SliInner extends ProxyResource { + /* + * The resource-specific properties for this resource. + */ + private SliResource properties; + + /* + * The managed service identities assigned to this resource. + */ + private ManagedServiceIdentity identity; + + /* + * Azure Resource Manager metadata containing createdBy and modifiedBy information. + */ + private SystemData systemData; + + /* + * The type of the resource. + */ + private String type; + + /* + * The name of the resource. + */ + private String name; + + /* + * Fully qualified resource Id for the resource. + */ + private String id; + + /** + * Creates an instance of SliInner class. + */ + public SliInner() { + } + + /** + * Get the properties property: The resource-specific properties for this resource. + * + * @return the properties value. + */ + public SliResource properties() { + return this.properties; + } + + /** + * Set the properties property: The resource-specific properties for this resource. + * + * @param properties the properties value to set. + * @return the SliInner object itself. + */ + public SliInner withProperties(SliResource properties) { + this.properties = properties; + return this; + } + + /** + * Get the identity property: The managed service identities assigned to this resource. + * + * @return the identity value. + */ + public ManagedServiceIdentity identity() { + return this.identity; + } + + /** + * Set the identity property: The managed service identities assigned to this resource. + * + * @param identity the identity value to set. + * @return the SliInner object itself. + */ + public SliInner withIdentity(ManagedServiceIdentity identity) { + this.identity = identity; + return this; + } + + /** + * Get the systemData property: Azure Resource Manager metadata containing createdBy and modifiedBy information. + * + * @return the systemData value. + */ + public SystemData systemData() { + return this.systemData; + } + + /** + * Get the type property: The type of the resource. + * + * @return the type value. + */ + @Override + public String type() { + return this.type; + } + + /** + * Get the name property: The name of the resource. + * + * @return the name value. + */ + @Override + public String name() { + return this.name; + } + + /** + * Get the id property: Fully qualified resource Id for the resource. + * + * @return the id value. + */ + @Override + public String id() { + return this.id; + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("properties", this.properties); + jsonWriter.writeJsonField("identity", this.identity); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SliInner from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SliInner 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 SliInner. + */ + public static SliInner fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + SliInner deserializedSliInner = new SliInner(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + deserializedSliInner.id = reader.getString(); + } else if ("name".equals(fieldName)) { + deserializedSliInner.name = reader.getString(); + } else if ("type".equals(fieldName)) { + deserializedSliInner.type = reader.getString(); + } else if ("properties".equals(fieldName)) { + deserializedSliInner.properties = SliResource.fromJson(reader); + } else if ("identity".equals(fieldName)) { + deserializedSliInner.identity = ManagedServiceIdentity.fromJson(reader); + } else if ("systemData".equals(fieldName)) { + deserializedSliInner.systemData = SystemData.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedSliInner; + }); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/fluent/models/package-info.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/fluent/models/package-info.java new file mode 100644 index 000000000000..abc7fcd7c1f8 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/fluent/models/package-info.java @@ -0,0 +1,8 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the inner data models for SlisManagementClient. + */ +package com.azure.resourcemanager.monitor.slis.fluent.models; diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/fluent/package-info.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/fluent/package-info.java new file mode 100644 index 000000000000..1987114f0822 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/fluent/package-info.java @@ -0,0 +1,8 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the service clients for SlisManagementClient. + */ +package com.azure.resourcemanager.monitor.slis.fluent; diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/implementation/ResourceManagerUtils.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/implementation/ResourceManagerUtils.java new file mode 100644 index 000000000000..e83fad7c0eb1 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/implementation/ResourceManagerUtils.java @@ -0,0 +1,195 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.implementation; + +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.util.CoreUtils; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import java.util.function.Function; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import reactor.core.publisher.Flux; + +final class ResourceManagerUtils { + private ResourceManagerUtils() { + } + + static String getValueFromIdByName(String id, String name) { + if (id == null) { + return null; + } + Iterator itr = Arrays.stream(id.split("/")).iterator(); + while (itr.hasNext()) { + String part = itr.next(); + if (part != null && !part.trim().isEmpty()) { + if (part.equalsIgnoreCase(name)) { + if (itr.hasNext()) { + return itr.next(); + } else { + return null; + } + } + } + } + return null; + } + + static String getValueFromIdByParameterName(String id, String pathTemplate, String parameterName) { + if (id == null || pathTemplate == null) { + return null; + } + String parameterNameParentheses = "{" + parameterName + "}"; + List idSegmentsReverted = Arrays.asList(id.split("/")); + List pathSegments = Arrays.asList(pathTemplate.split("/")); + Collections.reverse(idSegmentsReverted); + Iterator idItrReverted = idSegmentsReverted.iterator(); + int pathIndex = pathSegments.size(); + while (idItrReverted.hasNext() && pathIndex > 0) { + String idSegment = idItrReverted.next(); + String pathSegment = pathSegments.get(--pathIndex); + if (!CoreUtils.isNullOrEmpty(idSegment) && !CoreUtils.isNullOrEmpty(pathSegment)) { + if (pathSegment.equalsIgnoreCase(parameterNameParentheses)) { + if (pathIndex == 0 || (pathIndex == 1 && pathSegments.get(0).isEmpty())) { + List segments = new ArrayList<>(); + segments.add(idSegment); + idItrReverted.forEachRemaining(segments::add); + Collections.reverse(segments); + if (!segments.isEmpty() && segments.get(0).isEmpty()) { + segments.remove(0); + } + return String.join("/", segments); + } else { + return idSegment; + } + } + } + } + return null; + } + + static PagedIterable mapPage(PagedIterable pageIterable, Function mapper) { + return new PagedIterableImpl<>(pageIterable, mapper); + } + + private static final class PagedIterableImpl extends PagedIterable { + + private final PagedIterable pagedIterable; + private final Function mapper; + private final Function, PagedResponse> pageMapper; + + private PagedIterableImpl(PagedIterable pagedIterable, Function mapper) { + super(PagedFlux.create(() -> (continuationToken, pageSize) -> Flux + .fromStream(pagedIterable.streamByPage().map(getPageMapper(mapper))))); + this.pagedIterable = pagedIterable; + this.mapper = mapper; + this.pageMapper = getPageMapper(mapper); + } + + private static Function, PagedResponse> getPageMapper(Function mapper) { + return page -> new PagedResponseBase(page.getRequest(), page.getStatusCode(), page.getHeaders(), + page.getElements().stream().map(mapper).collect(Collectors.toList()), page.getContinuationToken(), + null); + } + + @Override + public Stream stream() { + return pagedIterable.stream().map(mapper); + } + + @Override + public Stream> streamByPage() { + return pagedIterable.streamByPage().map(pageMapper); + } + + @Override + public Stream> streamByPage(String continuationToken) { + return pagedIterable.streamByPage(continuationToken).map(pageMapper); + } + + @Override + public Stream> streamByPage(int preferredPageSize) { + return pagedIterable.streamByPage(preferredPageSize).map(pageMapper); + } + + @Override + public Stream> streamByPage(String continuationToken, int preferredPageSize) { + return pagedIterable.streamByPage(continuationToken, preferredPageSize).map(pageMapper); + } + + @Override + public Iterator iterator() { + return new IteratorImpl<>(pagedIterable.iterator(), mapper); + } + + @Override + public Iterable> iterableByPage() { + return new IterableImpl<>(pagedIterable.iterableByPage(), pageMapper); + } + + @Override + public Iterable> iterableByPage(String continuationToken) { + return new IterableImpl<>(pagedIterable.iterableByPage(continuationToken), pageMapper); + } + + @Override + public Iterable> iterableByPage(int preferredPageSize) { + return new IterableImpl<>(pagedIterable.iterableByPage(preferredPageSize), pageMapper); + } + + @Override + public Iterable> iterableByPage(String continuationToken, int preferredPageSize) { + return new IterableImpl<>(pagedIterable.iterableByPage(continuationToken, preferredPageSize), pageMapper); + } + } + + private static final class IteratorImpl implements Iterator { + + private final Iterator iterator; + private final Function mapper; + + private IteratorImpl(Iterator iterator, Function mapper) { + this.iterator = iterator; + this.mapper = mapper; + } + + @Override + public boolean hasNext() { + return iterator.hasNext(); + } + + @Override + public S next() { + return mapper.apply(iterator.next()); + } + + @Override + public void remove() { + iterator.remove(); + } + } + + private static final class IterableImpl implements Iterable { + + private final Iterable iterable; + private final Function mapper; + + private IterableImpl(Iterable iterable, Function mapper) { + this.iterable = iterable; + this.mapper = mapper; + } + + @Override + public Iterator iterator() { + return new IteratorImpl<>(iterable.iterator(), mapper); + } + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/implementation/SliImpl.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/implementation/SliImpl.java new file mode 100644 index 000000000000..4d5c97db8d35 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/implementation/SliImpl.java @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.implementation; + +import com.azure.core.management.SystemData; +import com.azure.resourcemanager.monitor.slis.fluent.models.SliInner; +import com.azure.resourcemanager.monitor.slis.models.ManagedServiceIdentity; +import com.azure.resourcemanager.monitor.slis.models.Sli; +import com.azure.resourcemanager.monitor.slis.models.SliResource; + +public final class SliImpl implements Sli { + private SliInner innerObject; + + private final com.azure.resourcemanager.monitor.slis.SlisManager serviceManager; + + SliImpl(SliInner innerObject, com.azure.resourcemanager.monitor.slis.SlisManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + } + + public String id() { + return this.innerModel().id(); + } + + public String name() { + return this.innerModel().name(); + } + + public String type() { + return this.innerModel().type(); + } + + public SliResource properties() { + return this.innerModel().properties(); + } + + public ManagedServiceIdentity identity() { + return this.innerModel().identity(); + } + + public SystemData systemData() { + return this.innerModel().systemData(); + } + + public SliInner innerModel() { + return this.innerObject; + } + + private com.azure.resourcemanager.monitor.slis.SlisManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/implementation/SlisClientImpl.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/implementation/SlisClientImpl.java new file mode 100644 index 000000000000..235c53cb06a4 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/implementation/SlisClientImpl.java @@ -0,0 +1,514 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.implementation; + +import com.azure.core.annotation.BodyParam; +import com.azure.core.annotation.Delete; +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Headers; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.PathParam; +import com.azure.core.annotation.Put; +import com.azure.core.annotation.QueryParam; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.management.exception.ManagementException; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import com.azure.resourcemanager.monitor.slis.fluent.SlisClient; +import com.azure.resourcemanager.monitor.slis.fluent.models.SliInner; +import com.azure.resourcemanager.monitor.slis.implementation.models.SliListResult; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in SlisClient. + */ +public final class SlisClientImpl implements SlisClient { + /** + * The proxy service used to perform REST calls. + */ + private final SlisService service; + + /** + * The service client containing this operation class. + */ + private final SlisManagementClientImpl client; + + /** + * Initializes an instance of SlisClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + SlisClientImpl(SlisManagementClientImpl client) { + this.service = RestProxy.create(SlisService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for SlisManagementClientSlis to be used by the proxy service to perform + * REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "SlisManagementClientSlis") + public interface SlisService { + @Headers({ "Content-Type: application/json" }) + @Get("/providers/Microsoft.Management/serviceGroups/{serviceGroupName}/providers/Microsoft.Monitor/slis/{sliName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> get(@HostParam("endpoint") String endpoint, + @PathParam("serviceGroupName") String serviceGroupName, @QueryParam("api-version") String apiVersion, + @PathParam("sliName") String sliName, @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("/providers/Microsoft.Management/serviceGroups/{serviceGroupName}/providers/Microsoft.Monitor/slis/{sliName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Response getSync(@HostParam("endpoint") String endpoint, + @PathParam("serviceGroupName") String serviceGroupName, @QueryParam("api-version") String apiVersion, + @PathParam("sliName") String sliName, @HeaderParam("Accept") String accept, Context context); + + @Put("/providers/Microsoft.Management/serviceGroups/{serviceGroupName}/providers/Microsoft.Monitor/slis/{sliName}") + @ExpectedResponses({ 200, 201 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> createOrUpdate(@HostParam("endpoint") String endpoint, + @PathParam("serviceGroupName") String serviceGroupName, @QueryParam("api-version") String apiVersion, + @PathParam("sliName") String sliName, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") SliInner resource, Context context); + + @Put("/providers/Microsoft.Management/serviceGroups/{serviceGroupName}/providers/Microsoft.Monitor/slis/{sliName}") + @ExpectedResponses({ 200, 201 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Response createOrUpdateSync(@HostParam("endpoint") String endpoint, + @PathParam("serviceGroupName") String serviceGroupName, @QueryParam("api-version") String apiVersion, + @PathParam("sliName") String sliName, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") SliInner resource, Context context); + + @Headers({ "Accept: application/json;q=0.9", "Content-Type: application/json" }) + @Delete("/providers/Microsoft.Management/serviceGroups/{serviceGroupName}/providers/Microsoft.Monitor/slis/{sliName}") + @ExpectedResponses({ 200, 204 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> delete(@HostParam("endpoint") String endpoint, + @PathParam("serviceGroupName") String serviceGroupName, @QueryParam("api-version") String apiVersion, + @PathParam("sliName") String sliName, Context context); + + @Headers({ "Accept: application/json;q=0.9", "Content-Type: application/json" }) + @Delete("/providers/Microsoft.Management/serviceGroups/{serviceGroupName}/providers/Microsoft.Monitor/slis/{sliName}") + @ExpectedResponses({ 200, 204 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Response deleteSync(@HostParam("endpoint") String endpoint, + @PathParam("serviceGroupName") String serviceGroupName, @QueryParam("api-version") String apiVersion, + @PathParam("sliName") String sliName, Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("/providers/Microsoft.Management/serviceGroups/{serviceGroupName}/providers/Microsoft.Monitor/slis") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listByParent(@HostParam("endpoint") String endpoint, + @PathParam("serviceGroupName") String serviceGroupName, @QueryParam("api-version") String apiVersion, + @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("/providers/Microsoft.Management/serviceGroups/{serviceGroupName}/providers/Microsoft.Monitor/slis") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Response listByParentSync(@HostParam("endpoint") String endpoint, + @PathParam("serviceGroupName") String serviceGroupName, @QueryParam("api-version") String apiVersion, + @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listByParentNext(@PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Response listByParentNextSync(@PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, Context context); + } + + /** + * Gets an SLI resource. + * + * @param serviceGroupName The name of the service group. + * @param sliName Name of the SLI that is given by the user. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an SLI resource along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getWithResponseAsync(String serviceGroupName, String sliName) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.get(this.client.getEndpoint(), serviceGroupName, + this.client.getApiVersion(), sliName, accept, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Gets an SLI resource. + * + * @param serviceGroupName The name of the service group. + * @param sliName Name of the SLI that is given by the user. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an SLI resource on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono getAsync(String serviceGroupName, String sliName) { + return getWithResponseAsync(serviceGroupName, sliName).flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Gets an SLI resource. + * + * @param serviceGroupName The name of the service group. + * @param sliName Name of the SLI that is given by the user. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an SLI resource along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(String serviceGroupName, String sliName, Context context) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), serviceGroupName, this.client.getApiVersion(), sliName, + accept, context); + } + + /** + * Gets an SLI resource. + * + * @param serviceGroupName The name of the service group. + * @param sliName Name of the SLI that is given by the user. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an SLI resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public SliInner get(String serviceGroupName, String sliName) { + return getWithResponse(serviceGroupName, sliName, Context.NONE).getValue(); + } + + /** + * Creates or updates an SLI resource. + * + * @param serviceGroupName The name of the service group. + * @param sliName Name of the SLI that is given by the user. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return represents an SLI resource within the ProviderHub along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> createOrUpdateWithResponseAsync(String serviceGroupName, String sliName, + SliInner resource) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.createOrUpdate(this.client.getEndpoint(), serviceGroupName, + this.client.getApiVersion(), sliName, contentType, accept, resource, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Creates or updates an SLI resource. + * + * @param serviceGroupName The name of the service group. + * @param sliName Name of the SLI that is given by the user. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return represents an SLI resource within the ProviderHub on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono createOrUpdateAsync(String serviceGroupName, String sliName, SliInner resource) { + return createOrUpdateWithResponseAsync(serviceGroupName, sliName, resource) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Creates or updates an SLI resource. + * + * @param serviceGroupName The name of the service group. + * @param sliName Name of the SLI that is given by the user. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return represents an SLI resource within the ProviderHub along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response createOrUpdateWithResponse(String serviceGroupName, String sliName, SliInner resource, + Context context) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.createOrUpdateSync(this.client.getEndpoint(), serviceGroupName, this.client.getApiVersion(), + sliName, contentType, accept, resource, context); + } + + /** + * Creates or updates an SLI resource. + * + * @param serviceGroupName The name of the service group. + * @param sliName Name of the SLI that is given by the user. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return represents an SLI resource within the ProviderHub. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public SliInner createOrUpdate(String serviceGroupName, String sliName, SliInner resource) { + return createOrUpdateWithResponse(serviceGroupName, sliName, resource, Context.NONE).getValue(); + } + + /** + * Deletes an SLI resource. + * + * @param serviceGroupName The name of the service group. + * @param sliName Name of the SLI that is given by the user. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> deleteWithResponseAsync(String serviceGroupName, String sliName) { + return FluxUtil + .withContext(context -> service.delete(this.client.getEndpoint(), serviceGroupName, + this.client.getApiVersion(), sliName, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Deletes an SLI resource. + * + * @param serviceGroupName The name of the service group. + * @param sliName Name of the SLI that is given by the user. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono deleteAsync(String serviceGroupName, String sliName) { + return deleteWithResponseAsync(serviceGroupName, sliName).flatMap(ignored -> Mono.empty()); + } + + /** + * Deletes an SLI resource. + * + * @param serviceGroupName The name of the service group. + * @param sliName Name of the SLI that is given by the user. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response deleteWithResponse(String serviceGroupName, String sliName, Context context) { + return service.deleteSync(this.client.getEndpoint(), serviceGroupName, this.client.getApiVersion(), sliName, + context); + } + + /** + * Deletes an SLI resource. + * + * @param serviceGroupName The name of the service group. + * @param sliName Name of the SLI that is given by the user. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public void delete(String serviceGroupName, String sliName) { + deleteWithResponse(serviceGroupName, sliName, Context.NONE); + } + + /** + * Lists all SLI resources under a parent resource. + * + * @param serviceGroupName The name of the service group. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Sli list operation along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByParentSinglePageAsync(String serviceGroupName) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.listByParent(this.client.getEndpoint(), serviceGroupName, + this.client.getApiVersion(), accept, context)) + .>map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), + res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Lists all SLI resources under a parent resource. + * + * @param serviceGroupName The name of the service group. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Sli list operation as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listByParentAsync(String serviceGroupName) { + return new PagedFlux<>(() -> listByParentSinglePageAsync(serviceGroupName), + nextLink -> listByParentNextSinglePageAsync(nextLink)); + } + + /** + * Lists all SLI resources under a parent resource. + * + * @param serviceGroupName The name of the service group. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Sli list operation along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listByParentSinglePage(String serviceGroupName) { + final String accept = "application/json"; + Response res = service.listByParentSync(this.client.getEndpoint(), serviceGroupName, + this.client.getApiVersion(), accept, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue().value(), + res.getValue().nextLink(), null); + } + + /** + * Lists all SLI resources under a parent resource. + * + * @param serviceGroupName The name of the service group. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Sli list operation along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listByParentSinglePage(String serviceGroupName, Context context) { + final String accept = "application/json"; + Response res = service.listByParentSync(this.client.getEndpoint(), serviceGroupName, + this.client.getApiVersion(), accept, context); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue().value(), + res.getValue().nextLink(), null); + } + + /** + * Lists all SLI resources under a parent resource. + * + * @param serviceGroupName The name of the service group. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Sli list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listByParent(String serviceGroupName) { + return new PagedIterable<>(() -> listByParentSinglePage(serviceGroupName), + nextLink -> listByParentNextSinglePage(nextLink)); + } + + /** + * Lists all SLI resources under a parent resource. + * + * @param serviceGroupName The name of the service group. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Sli list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listByParent(String serviceGroupName, Context context) { + return new PagedIterable<>(() -> listByParentSinglePage(serviceGroupName, context), + nextLink -> listByParentNextSinglePage(nextLink, context)); + } + + /** + * Get the next page of items. + * + * @param nextLink The URL to get the next list of items. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Sli list operation along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByParentNextSinglePageAsync(String nextLink) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.listByParentNext(nextLink, this.client.getEndpoint(), accept, context)) + .>map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), + res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get the next page of items. + * + * @param nextLink The URL to get the next list of items. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Sli list operation along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listByParentNextSinglePage(String nextLink) { + final String accept = "application/json"; + Response res + = service.listByParentNextSync(nextLink, this.client.getEndpoint(), accept, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue().value(), + res.getValue().nextLink(), null); + } + + /** + * Get the next page of items. + * + * @param nextLink The URL to get the next list of items. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Sli list operation along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listByParentNextSinglePage(String nextLink, Context context) { + final String accept = "application/json"; + Response res + = service.listByParentNextSync(nextLink, this.client.getEndpoint(), accept, context); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue().value(), + res.getValue().nextLink(), null); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/implementation/SlisImpl.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/implementation/SlisImpl.java new file mode 100644 index 000000000000..8558674be7c7 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/implementation/SlisImpl.java @@ -0,0 +1,86 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.implementation; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.SimpleResponse; +import com.azure.core.util.Context; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.monitor.slis.fluent.SlisClient; +import com.azure.resourcemanager.monitor.slis.fluent.models.SliInner; +import com.azure.resourcemanager.monitor.slis.models.Sli; +import com.azure.resourcemanager.monitor.slis.models.Slis; + +public final class SlisImpl implements Slis { + private static final ClientLogger LOGGER = new ClientLogger(SlisImpl.class); + + private final SlisClient innerClient; + + private final com.azure.resourcemanager.monitor.slis.SlisManager serviceManager; + + public SlisImpl(SlisClient innerClient, com.azure.resourcemanager.monitor.slis.SlisManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public Response getWithResponse(String serviceGroupName, String sliName, Context context) { + Response inner = this.serviceClient().getWithResponse(serviceGroupName, sliName, context); + return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(), + new SliImpl(inner.getValue(), this.manager())); + } + + public Sli get(String serviceGroupName, String sliName) { + SliInner inner = this.serviceClient().get(serviceGroupName, sliName); + if (inner != null) { + return new SliImpl(inner, this.manager()); + } else { + return null; + } + } + + public Response createOrUpdateWithResponse(String serviceGroupName, String sliName, SliInner resource, + Context context) { + Response inner + = this.serviceClient().createOrUpdateWithResponse(serviceGroupName, sliName, resource, context); + return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(), + new SliImpl(inner.getValue(), this.manager())); + } + + public Sli createOrUpdate(String serviceGroupName, String sliName, SliInner resource) { + SliInner inner = this.serviceClient().createOrUpdate(serviceGroupName, sliName, resource); + if (inner != null) { + return new SliImpl(inner, this.manager()); + } else { + return null; + } + } + + public Response deleteByResourceGroupWithResponse(String serviceGroupName, String sliName, Context context) { + return this.serviceClient().deleteWithResponse(serviceGroupName, sliName, context); + } + + public void deleteByResourceGroup(String serviceGroupName, String sliName) { + this.serviceClient().delete(serviceGroupName, sliName); + } + + public PagedIterable listByParent(String serviceGroupName) { + PagedIterable inner = this.serviceClient().listByParent(serviceGroupName); + return ResourceManagerUtils.mapPage(inner, inner1 -> new SliImpl(inner1, this.manager())); + } + + public PagedIterable listByParent(String serviceGroupName, Context context) { + PagedIterable inner = this.serviceClient().listByParent(serviceGroupName, context); + return ResourceManagerUtils.mapPage(inner, inner1 -> new SliImpl(inner1, this.manager())); + } + + private SlisClient serviceClient() { + return this.innerClient; + } + + private com.azure.resourcemanager.monitor.slis.SlisManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/implementation/SlisManagementClientBuilder.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/implementation/SlisManagementClientBuilder.java new file mode 100644 index 000000000000..4ad38756ad63 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/implementation/SlisManagementClientBuilder.java @@ -0,0 +1,122 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.implementation; + +import com.azure.core.annotation.ServiceClientBuilder; +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.management.AzureEnvironment; +import com.azure.core.management.serializer.SerializerFactory; +import com.azure.core.util.serializer.SerializerAdapter; +import java.time.Duration; + +/** + * A builder for creating a new instance of the SlisManagementClientImpl type. + */ +@ServiceClientBuilder(serviceClients = { SlisManagementClientImpl.class }) +public final class SlisManagementClientBuilder { + /* + * Service host + */ + private String endpoint; + + /** + * Sets Service host. + * + * @param endpoint the endpoint value. + * @return the SlisManagementClientBuilder. + */ + public SlisManagementClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * The environment to connect to + */ + private AzureEnvironment environment; + + /** + * Sets The environment to connect to. + * + * @param environment the environment value. + * @return the SlisManagementClientBuilder. + */ + public SlisManagementClientBuilder environment(AzureEnvironment environment) { + this.environment = environment; + return this; + } + + /* + * The HTTP pipeline to send requests through + */ + private HttpPipeline pipeline; + + /** + * Sets The HTTP pipeline to send requests through. + * + * @param pipeline the pipeline value. + * @return the SlisManagementClientBuilder. + */ + public SlisManagementClientBuilder pipeline(HttpPipeline pipeline) { + this.pipeline = pipeline; + return this; + } + + /* + * The default poll interval for long-running operation + */ + private Duration defaultPollInterval; + + /** + * Sets The default poll interval for long-running operation. + * + * @param defaultPollInterval the defaultPollInterval value. + * @return the SlisManagementClientBuilder. + */ + public SlisManagementClientBuilder defaultPollInterval(Duration defaultPollInterval) { + this.defaultPollInterval = defaultPollInterval; + return this; + } + + /* + * The serializer to serialize an object into a string + */ + private SerializerAdapter serializerAdapter; + + /** + * Sets The serializer to serialize an object into a string. + * + * @param serializerAdapter the serializerAdapter value. + * @return the SlisManagementClientBuilder. + */ + public SlisManagementClientBuilder serializerAdapter(SerializerAdapter serializerAdapter) { + this.serializerAdapter = serializerAdapter; + return this; + } + + /** + * Builds an instance of SlisManagementClientImpl with the provided parameters. + * + * @return an instance of SlisManagementClientImpl. + */ + public SlisManagementClientImpl buildClient() { + String localEndpoint = (endpoint != null) ? endpoint : "https://management.azure.com"; + AzureEnvironment localEnvironment = (environment != null) ? environment : AzureEnvironment.AZURE; + HttpPipeline localPipeline = (pipeline != null) + ? pipeline + : new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(); + Duration localDefaultPollInterval + = (defaultPollInterval != null) ? defaultPollInterval : Duration.ofSeconds(30); + SerializerAdapter localSerializerAdapter = (serializerAdapter != null) + ? serializerAdapter + : SerializerFactory.createDefaultManagementSerializerAdapter(); + SlisManagementClientImpl client = new SlisManagementClientImpl(localPipeline, localSerializerAdapter, + localDefaultPollInterval, localEnvironment, localEndpoint); + return client; + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/implementation/SlisManagementClientImpl.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/implementation/SlisManagementClientImpl.java new file mode 100644 index 000000000000..0b34032a4413 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/implementation/SlisManagementClientImpl.java @@ -0,0 +1,292 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.implementation; + +import com.azure.core.annotation.ServiceClient; +import com.azure.core.http.HttpHeaderName; +import com.azure.core.http.HttpHeaders; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpResponse; +import com.azure.core.http.rest.Response; +import com.azure.core.management.AzureEnvironment; +import com.azure.core.management.exception.ManagementError; +import com.azure.core.management.exception.ManagementException; +import com.azure.core.management.polling.PollResult; +import com.azure.core.management.polling.PollerFactory; +import com.azure.core.management.polling.SyncPollerFactory; +import com.azure.core.util.BinaryData; +import com.azure.core.util.Context; +import com.azure.core.util.CoreUtils; +import com.azure.core.util.logging.ClientLogger; +import com.azure.core.util.polling.AsyncPollResponse; +import com.azure.core.util.polling.LongRunningOperationStatus; +import com.azure.core.util.polling.PollerFlux; +import com.azure.core.util.polling.SyncPoller; +import com.azure.core.util.serializer.SerializerAdapter; +import com.azure.core.util.serializer.SerializerEncoding; +import com.azure.resourcemanager.monitor.slis.fluent.SlisClient; +import com.azure.resourcemanager.monitor.slis.fluent.SlisManagementClient; +import java.io.IOException; +import java.lang.reflect.Type; +import java.nio.ByteBuffer; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.time.Duration; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the SlisManagementClientImpl type. + */ +@ServiceClient(builder = SlisManagementClientBuilder.class) +public final class SlisManagementClientImpl implements SlisManagementClient { + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * Version parameter. + */ + private final String apiVersion; + + /** + * Gets Version parameter. + * + * @return the apiVersion value. + */ + public String getApiVersion() { + return this.apiVersion; + } + + /** + * 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. + */ + SerializerAdapter getSerializerAdapter() { + return this.serializerAdapter; + } + + /** + * The default poll interval for long-running operation. + */ + private final Duration defaultPollInterval; + + /** + * Gets The default poll interval for long-running operation. + * + * @return the defaultPollInterval value. + */ + public Duration getDefaultPollInterval() { + return this.defaultPollInterval; + } + + /** + * The SlisClient object to access its operations. + */ + private final SlisClient slis; + + /** + * Gets the SlisClient object to access its operations. + * + * @return the SlisClient object. + */ + public SlisClient getSlis() { + return this.slis; + } + + /** + * Initializes an instance of SlisManagementClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param serializerAdapter The serializer to serialize an object into a string. + * @param defaultPollInterval The default poll interval for long-running operation. + * @param environment The Azure environment. + * @param endpoint Service host. + */ + SlisManagementClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, + Duration defaultPollInterval, AzureEnvironment environment, String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.defaultPollInterval = defaultPollInterval; + this.endpoint = endpoint; + this.apiVersion = "2025-03-01-preview"; + this.slis = new SlisClientImpl(this); + } + + /** + * Gets default client context. + * + * @return the default client context. + */ + public Context getContext() { + return Context.NONE; + } + + /** + * Merges default client context with provided context. + * + * @param context the context to be merged with default client context. + * @return the merged context. + */ + public Context mergeContext(Context context) { + return CoreUtils.mergeContexts(this.getContext(), context); + } + + /** + * Gets long running operation result. + * + * @param activationResponse the response of activation operation. + * @param httpPipeline the http pipeline. + * @param pollResultType type of poll result. + * @param finalResultType type of final result. + * @param context the context shared by all requests. + * @param type of poll result. + * @param type of final result. + * @return poller flux for poll result and final result. + */ + public PollerFlux, U> getLroResult(Mono>> activationResponse, + HttpPipeline httpPipeline, Type pollResultType, Type finalResultType, Context context) { + return PollerFactory.create(serializerAdapter, httpPipeline, pollResultType, finalResultType, + defaultPollInterval, activationResponse, context); + } + + /** + * Gets long running operation result. + * + * @param activationResponse the response of activation operation. + * @param pollResultType type of poll result. + * @param finalResultType type of final result. + * @param context the context shared by all requests. + * @param type of poll result. + * @param type of final result. + * @return SyncPoller for poll result and final result. + */ + public SyncPoller, U> getLroResult(Response activationResponse, + Type pollResultType, Type finalResultType, Context context) { + return SyncPollerFactory.create(serializerAdapter, httpPipeline, pollResultType, finalResultType, + defaultPollInterval, () -> activationResponse, context); + } + + /** + * Gets the final result, or an error, based on last async poll response. + * + * @param response the last async poll response. + * @param type of poll result. + * @param type of final result. + * @return the final result, or an error. + */ + public Mono getLroFinalResultOrError(AsyncPollResponse, U> response) { + if (response.getStatus() != LongRunningOperationStatus.SUCCESSFULLY_COMPLETED) { + String errorMessage; + ManagementError managementError = null; + HttpResponse errorResponse = null; + PollResult.Error lroError = response.getValue().getError(); + if (lroError != null) { + errorResponse = new HttpResponseImpl(lroError.getResponseStatusCode(), lroError.getResponseHeaders(), + lroError.getResponseBody()); + + errorMessage = response.getValue().getError().getMessage(); + String errorBody = response.getValue().getError().getResponseBody(); + if (errorBody != null) { + // try to deserialize error body to ManagementError + try { + managementError = this.getSerializerAdapter() + .deserialize(errorBody, ManagementError.class, SerializerEncoding.JSON); + if (managementError.getCode() == null || managementError.getMessage() == null) { + managementError = null; + } + } catch (IOException | RuntimeException ioe) { + LOGGER.logThrowableAsWarning(ioe); + } + } + } else { + // fallback to default error message + errorMessage = "Long running operation failed."; + } + if (managementError == null) { + // fallback to default ManagementError + managementError = new ManagementError(response.getStatus().toString(), errorMessage); + } + return Mono.error(new ManagementException(errorMessage, errorResponse, managementError)); + } else { + return response.getFinalResult(); + } + } + + private static final class HttpResponseImpl extends HttpResponse { + private final int statusCode; + + private final byte[] responseBody; + + private final HttpHeaders httpHeaders; + + HttpResponseImpl(int statusCode, HttpHeaders httpHeaders, String responseBody) { + super(null); + this.statusCode = statusCode; + this.httpHeaders = httpHeaders; + this.responseBody = responseBody == null ? null : responseBody.getBytes(StandardCharsets.UTF_8); + } + + public int getStatusCode() { + return statusCode; + } + + public String getHeaderValue(String s) { + return httpHeaders.getValue(HttpHeaderName.fromString(s)); + } + + public HttpHeaders getHeaders() { + return httpHeaders; + } + + public Flux getBody() { + return Flux.just(ByteBuffer.wrap(responseBody)); + } + + public Mono getBodyAsByteArray() { + return Mono.just(responseBody); + } + + public Mono getBodyAsString() { + return Mono.just(new String(responseBody, StandardCharsets.UTF_8)); + } + + public Mono getBodyAsString(Charset charset) { + return Mono.just(new String(responseBody, charset)); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(SlisManagementClientImpl.class); +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/implementation/models/SliListResult.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/implementation/models/SliListResult.java new file mode 100644 index 000000000000..a7dca504d6b4 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/implementation/models/SliListResult.java @@ -0,0 +1,95 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.implementation.models; + +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 com.azure.resourcemanager.monitor.slis.fluent.models.SliInner; +import java.io.IOException; +import java.util.List; + +/** + * The response of a Sli list operation. + */ +@Immutable +public final class SliListResult implements JsonSerializable { + /* + * The Sli items on this page + */ + private List value; + + /* + * The link to the next page of items + */ + private String nextLink; + + /** + * Creates an instance of SliListResult class. + */ + private SliListResult() { + } + + /** + * Get the value property: The Sli items on this page. + * + * @return the value value. + */ + public List value() { + return this.value; + } + + /** + * Get the nextLink property: The link to the next page of items. + * + * @return the nextLink value. + */ + public String nextLink() { + return this.nextLink; + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("value", this.value, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeStringField("nextLink", this.nextLink); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SliListResult from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SliListResult 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 SliListResult. + */ + public static SliListResult fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + SliListResult deserializedSliListResult = new SliListResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("value".equals(fieldName)) { + List value = reader.readArray(reader1 -> SliInner.fromJson(reader1)); + deserializedSliListResult.value = value; + } else if ("nextLink".equals(fieldName)) { + deserializedSliListResult.nextLink = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedSliListResult; + }); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/implementation/package-info.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/implementation/package-info.java new file mode 100644 index 000000000000..f74fcd62cf0e --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/implementation/package-info.java @@ -0,0 +1,8 @@ +// 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 SlisManagementClient. + */ +package com.azure.resourcemanager.monitor.slis.implementation; diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/AmwAccount.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/AmwAccount.java new file mode 100644 index 000000000000..20fb9f501b80 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/AmwAccount.java @@ -0,0 +1,114 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.models; + +import com.azure.core.annotation.Fluent; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Represents an Azure Monitor Workspace (AMW) account used for emitting metrics. + */ +@Fluent +public final class AmwAccount implements JsonSerializable { + /* + * The ARM resource ID of the account where metrics are emitted. + */ + private String resourceId; + + /* + * The ARM resource ID of the managed identity with access to the source account. + */ + private String identity; + + /** + * Creates an instance of AmwAccount class. + */ + public AmwAccount() { + } + + /** + * Get the resourceId property: The ARM resource ID of the account where metrics are emitted. + * + * @return the resourceId value. + */ + public String resourceId() { + return this.resourceId; + } + + /** + * Set the resourceId property: The ARM resource ID of the account where metrics are emitted. + * + * @param resourceId the resourceId value to set. + * @return the AmwAccount object itself. + */ + public AmwAccount withResourceId(String resourceId) { + this.resourceId = resourceId; + return this; + } + + /** + * Get the identity property: The ARM resource ID of the managed identity with access to the source account. + * + * @return the identity value. + */ + public String identity() { + return this.identity; + } + + /** + * Set the identity property: The ARM resource ID of the managed identity with access to the source account. + * + * @param identity the identity value to set. + * @return the AmwAccount object itself. + */ + public AmwAccount withIdentity(String identity) { + this.identity = identity; + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("resourceId", this.resourceId); + jsonWriter.writeStringField("identity", this.identity); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of AmwAccount from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of AmwAccount 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 AmwAccount. + */ + public static AmwAccount fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + AmwAccount deserializedAmwAccount = new AmwAccount(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("resourceId".equals(fieldName)) { + deserializedAmwAccount.resourceId = reader.getString(); + } else if ("identity".equals(fieldName)) { + deserializedAmwAccount.identity = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedAmwAccount; + }); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/Baseline.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/Baseline.java new file mode 100644 index 000000000000..8d2e16113178 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/Baseline.java @@ -0,0 +1,146 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.models; + +import com.azure.core.annotation.Fluent; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Defines the target parameters for a Slo baseline. + */ +@Fluent +public final class Baseline implements JsonSerializable { + /* + * The user-defined or Azure-defined target value used for comparison against the SLI value. + */ + private double value; + + /* + * The time frame (in days) used for SLI evaluation. + */ + private int evaluationPeriodDays; + + /* + * Specifies how evaluation is calculated, either based on calendar days or a rolling window. + */ + private EvaluationCalculationType evaluationCalculationType; + + /** + * Creates an instance of Baseline class. + */ + public Baseline() { + } + + /** + * Get the value property: The user-defined or Azure-defined target value used for comparison against the SLI value. + * + * @return the value value. + */ + public double value() { + return this.value; + } + + /** + * Set the value property: The user-defined or Azure-defined target value used for comparison against the SLI value. + * + * @param value the value value to set. + * @return the Baseline object itself. + */ + public Baseline withValue(double value) { + this.value = value; + return this; + } + + /** + * Get the evaluationPeriodDays property: The time frame (in days) used for SLI evaluation. + * + * @return the evaluationPeriodDays value. + */ + public int evaluationPeriodDays() { + return this.evaluationPeriodDays; + } + + /** + * Set the evaluationPeriodDays property: The time frame (in days) used for SLI evaluation. + * + * @param evaluationPeriodDays the evaluationPeriodDays value to set. + * @return the Baseline object itself. + */ + public Baseline withEvaluationPeriodDays(int evaluationPeriodDays) { + this.evaluationPeriodDays = evaluationPeriodDays; + return this; + } + + /** + * Get the evaluationCalculationType property: Specifies how evaluation is calculated, either based on calendar days + * or a rolling window. + * + * @return the evaluationCalculationType value. + */ + public EvaluationCalculationType evaluationCalculationType() { + return this.evaluationCalculationType; + } + + /** + * Set the evaluationCalculationType property: Specifies how evaluation is calculated, either based on calendar days + * or a rolling window. + * + * @param evaluationCalculationType the evaluationCalculationType value to set. + * @return the Baseline object itself. + */ + public Baseline withEvaluationCalculationType(EvaluationCalculationType evaluationCalculationType) { + this.evaluationCalculationType = evaluationCalculationType; + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeDoubleField("value", this.value); + jsonWriter.writeIntField("evaluationPeriodDays", this.evaluationPeriodDays); + jsonWriter.writeStringField("evaluationCalculationType", + this.evaluationCalculationType == null ? null : this.evaluationCalculationType.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Baseline from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Baseline 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 Baseline. + */ + public static Baseline fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + Baseline deserializedBaseline = new Baseline(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("value".equals(fieldName)) { + deserializedBaseline.value = reader.getDouble(); + } else if ("evaluationPeriodDays".equals(fieldName)) { + deserializedBaseline.evaluationPeriodDays = reader.getInt(); + } else if ("evaluationCalculationType".equals(fieldName)) { + deserializedBaseline.evaluationCalculationType + = EvaluationCalculationType.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + + return deserializedBaseline; + }); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/BaselineProperties.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/BaselineProperties.java new file mode 100644 index 000000000000..993db29463b6 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/BaselineProperties.java @@ -0,0 +1,88 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.models; + +import com.azure.core.annotation.Fluent; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Defines the properties of a baseline. + */ +@Fluent +public final class BaselineProperties implements JsonSerializable { + /* + * Defines the baseline target, which is compared against the SLI value to determine compliance. + */ + private Baseline baseline; + + /** + * Creates an instance of BaselineProperties class. + */ + public BaselineProperties() { + } + + /** + * Get the baseline property: Defines the baseline target, which is compared against the SLI value to determine + * compliance. + * + * @return the baseline value. + */ + public Baseline baseline() { + return this.baseline; + } + + /** + * Set the baseline property: Defines the baseline target, which is compared against the SLI value to determine + * compliance. + * + * @param baseline the baseline value to set. + * @return the BaselineProperties object itself. + */ + public BaselineProperties withBaseline(Baseline baseline) { + this.baseline = baseline; + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("baseline", this.baseline); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of BaselineProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of BaselineProperties 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 BaselineProperties. + */ + public static BaselineProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + BaselineProperties deserializedBaselineProperties = new BaselineProperties(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("baseline".equals(fieldName)) { + deserializedBaselineProperties.baseline = Baseline.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedBaselineProperties; + }); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/Category.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/Category.java new file mode 100644 index 000000000000..fa58e55f3e1d --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/Category.java @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Defines the category of an SLI. + */ +public final class Category extends ExpandableStringEnum { + /** + * Indicates availability-related metrics. + */ + public static final Category AVAILABILITY = fromString("Availability"); + + /** + * Indicates latency-related metrics. + */ + public static final Category LATENCY = fromString("Latency"); + + /** + * Creates a new instance of Category value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public Category() { + } + + /** + * Creates or finds a Category from its string representation. + * + * @param name a name to look for. + * @return the corresponding Category. + */ + public static Category fromString(String name) { + return fromString(name, Category.class); + } + + /** + * Gets known Category values. + * + * @return known Category values. + */ + public static Collection values() { + return values(Category.class); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/Condition.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/Condition.java new file mode 100644 index 000000000000..8232abe3bd6e --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/Condition.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.resourcemanager.monitor.slis.models; + +import com.azure.core.annotation.Fluent; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Represents a filtering condition. + */ +@Fluent +public final class Condition implements JsonSerializable { + /* + * Dimension name used in filtering. + */ + private String dimensionName; + + /* + * Scalar function applied for filtering. + */ + private ScalarFunction scalarFunction; + + /* + * Defines the sampling type. + */ + private SamplingType samplingType; + + /* + * Operator used in the filtering condition. + */ + private ConditionOperator operator; + + /* + * Value used in filtering. + */ + private String value; + + /** + * Creates an instance of Condition class. + */ + public Condition() { + } + + /** + * Get the dimensionName property: Dimension name used in filtering. + * + * @return the dimensionName value. + */ + public String dimensionName() { + return this.dimensionName; + } + + /** + * Set the dimensionName property: Dimension name used in filtering. + * + * @param dimensionName the dimensionName value to set. + * @return the Condition object itself. + */ + public Condition withDimensionName(String dimensionName) { + this.dimensionName = dimensionName; + return this; + } + + /** + * Get the scalarFunction property: Scalar function applied for filtering. + * + * @return the scalarFunction value. + */ + public ScalarFunction scalarFunction() { + return this.scalarFunction; + } + + /** + * Set the scalarFunction property: Scalar function applied for filtering. + * + * @param scalarFunction the scalarFunction value to set. + * @return the Condition object itself. + */ + public Condition withScalarFunction(ScalarFunction scalarFunction) { + this.scalarFunction = scalarFunction; + return this; + } + + /** + * Get the samplingType property: Defines the sampling type. + * + * @return the samplingType value. + */ + public SamplingType samplingType() { + return this.samplingType; + } + + /** + * Set the samplingType property: Defines the sampling type. + * + * @param samplingType the samplingType value to set. + * @return the Condition object itself. + */ + public Condition withSamplingType(SamplingType samplingType) { + this.samplingType = samplingType; + return this; + } + + /** + * Get the operator property: Operator used in the filtering condition. + * + * @return the operator value. + */ + public ConditionOperator operator() { + return this.operator; + } + + /** + * Set the operator property: Operator used in the filtering condition. + * + * @param operator the operator value to set. + * @return the Condition object itself. + */ + public Condition withOperator(ConditionOperator operator) { + this.operator = operator; + return this; + } + + /** + * Get the value property: Value used in filtering. + * + * @return the value value. + */ + public String value() { + return this.value; + } + + /** + * Set the value property: Value used in filtering. + * + * @param value the value value to set. + * @return the Condition object itself. + */ + public Condition withValue(String value) { + this.value = value; + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("operator", this.operator == null ? null : this.operator.toString()); + jsonWriter.writeStringField("value", this.value); + jsonWriter.writeStringField("dimensionName", this.dimensionName); + jsonWriter.writeStringField("scalarFunction", + this.scalarFunction == null ? null : this.scalarFunction.toString()); + jsonWriter.writeStringField("samplingType", this.samplingType == null ? null : this.samplingType.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Condition from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Condition 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 Condition. + */ + public static Condition fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + Condition deserializedCondition = new Condition(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("operator".equals(fieldName)) { + deserializedCondition.operator = ConditionOperator.fromString(reader.getString()); + } else if ("value".equals(fieldName)) { + deserializedCondition.value = reader.getString(); + } else if ("dimensionName".equals(fieldName)) { + deserializedCondition.dimensionName = reader.getString(); + } else if ("scalarFunction".equals(fieldName)) { + deserializedCondition.scalarFunction = ScalarFunction.fromString(reader.getString()); + } else if ("samplingType".equals(fieldName)) { + deserializedCondition.samplingType = SamplingType.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + + return deserializedCondition; + }); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/ConditionOperator.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/ConditionOperator.java new file mode 100644 index 000000000000..dc12609a7648 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/ConditionOperator.java @@ -0,0 +1,101 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Defines operators used in filter conditions. + */ +public final class ConditionOperator extends ExpandableStringEnum { + /** + * Equal to. + */ + public static final ConditionOperator EQUAL = fromString("=="); + + /** + * Not equal to. + */ + public static final ConditionOperator NOT_EQUAL = fromString("!="); + + /** + * Less than. + */ + public static final ConditionOperator LESS_THAN = fromString("<"); + + /** + * Less than or equal to. + */ + public static final ConditionOperator LESS_THAN_OR_EQUAL = fromString("<="); + + /** + * Greater than. + */ + public static final ConditionOperator GREATER_THAN = fromString(">"); + + /** + * Greater than or equal to. + */ + public static final ConditionOperator GREATER_THAN_OR_EQUAL = fromString(">="); + + /** + * In operator. + */ + public static final ConditionOperator IN = fromString("@in"); + + /** + * Not in. + */ + public static final ConditionOperator NOT_IN = fromString("!in"); + + /** + * Starts with. + */ + public static final ConditionOperator STARTS_WITH = fromString("startswith"); + + /** + * Does not start with. + */ + public static final ConditionOperator NOT_STARTS_WITH = fromString("!startswith"); + + /** + * Contains the value. + */ + public static final ConditionOperator CONTAINS = fromString("contains"); + + /** + * Does not contain the value. + */ + public static final ConditionOperator NOT_CONTAINS = fromString("!contains"); + + /** + * Creates a new instance of ConditionOperator value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public ConditionOperator() { + } + + /** + * Creates or finds a ConditionOperator from its string representation. + * + * @param name a name to look for. + * @return the corresponding ConditionOperator. + */ + public static ConditionOperator fromString(String name) { + return fromString(name, ConditionOperator.class); + } + + /** + * Gets known ConditionOperator values. + * + * @return known ConditionOperator values. + */ + public static Collection values() { + return values(ConditionOperator.class); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/EvaluationCalculationType.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/EvaluationCalculationType.java new file mode 100644 index 000000000000..4af8c53228b3 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/EvaluationCalculationType.java @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Specifies the method for evaluation calculation. + */ +public final class EvaluationCalculationType extends ExpandableStringEnum { + /** + * Calculates evaluation based on a fixed calendar period. + */ + public static final EvaluationCalculationType CALENDAR_DAYS = fromString("CalendarDays"); + + /** + * Calculates evaluation using a rolling time window. + */ + public static final EvaluationCalculationType ROLLING_DAYS = fromString("RollingDays"); + + /** + * Creates a new instance of EvaluationCalculationType value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public EvaluationCalculationType() { + } + + /** + * Creates or finds a EvaluationCalculationType from its string representation. + * + * @param name a name to look for. + * @return the corresponding EvaluationCalculationType. + */ + public static EvaluationCalculationType fromString(String name) { + return fromString(name, EvaluationCalculationType.class); + } + + /** + * Gets known EvaluationCalculationType values. + * + * @return known EvaluationCalculationType values. + */ + public static Collection values() { + return values(EvaluationCalculationType.class); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/EvaluationType.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/EvaluationType.java new file mode 100644 index 000000000000..0f26f7693bba --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/EvaluationType.java @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Specifies how the SLI is evaluated. + */ +public final class EvaluationType extends ExpandableStringEnum { + /** + * Evaluates SLI based on time windows. + */ + public static final EvaluationType WINDOW_BASED = fromString("WindowBased"); + + /** + * Evaluates SLI based on request counts. + */ + public static final EvaluationType REQUEST_BASED = fromString("RequestBased"); + + /** + * Creates a new instance of EvaluationType value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public EvaluationType() { + } + + /** + * Creates or finds a EvaluationType from its string representation. + * + * @param name a name to look for. + * @return the corresponding EvaluationType. + */ + public static EvaluationType fromString(String name) { + return fromString(name, EvaluationType.class); + } + + /** + * Gets known EvaluationType values. + * + * @return known EvaluationType values. + */ + public static Collection values() { + return values(EvaluationType.class); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/ExecutionState.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/ExecutionState.java new file mode 100644 index 000000000000..3b858c2eaa3a --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/ExecutionState.java @@ -0,0 +1,92 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.models; + +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; + +/** + * Represents the current execution state of an SLI. + */ +@Immutable +public final class ExecutionState implements JsonSerializable { + /* + * The execution state value. + */ + private String state; + + /* + * A descriptive message related to the execution state. + */ + private String message; + + /** + * Creates an instance of ExecutionState class. + */ + private ExecutionState() { + } + + /** + * Get the state property: The execution state value. + * + * @return the state value. + */ + public String state() { + return this.state; + } + + /** + * Get the message property: A descriptive message related to the execution state. + * + * @return the message value. + */ + public String message() { + return this.message; + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("state", this.state); + jsonWriter.writeStringField("message", this.message); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ExecutionState from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ExecutionState 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 ExecutionState. + */ + public static ExecutionState fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ExecutionState deserializedExecutionState = new ExecutionState(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("state".equals(fieldName)) { + deserializedExecutionState.state = reader.getString(); + } else if ("message".equals(fieldName)) { + deserializedExecutionState.message = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedExecutionState; + }); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/ManagedServiceIdentity.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/ManagedServiceIdentity.java new file mode 100644 index 000000000000..878aa458e9e8 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/ManagedServiceIdentity.java @@ -0,0 +1,154 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.models; + +import com.azure.core.annotation.Fluent; +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.Map; + +/** + * Managed service identity (system assigned and/or user assigned identities). + */ +@Fluent +public final class ManagedServiceIdentity implements JsonSerializable { + /* + * The service principal ID of the system assigned identity. This property will only be provided for a system + * assigned identity. + */ + private String principalId; + + /* + * The tenant ID of the system assigned identity. This property will only be provided for a system assigned + * identity. + */ + private String tenantId; + + /* + * The type of managed identity assigned to this resource. + */ + private ManagedServiceIdentityType type; + + /* + * The identities assigned to this resource by the user. + */ + private Map userAssignedIdentities; + + /** + * Creates an instance of ManagedServiceIdentity class. + */ + public ManagedServiceIdentity() { + } + + /** + * Get the principalId property: The service principal ID of the system assigned identity. This property will only + * be provided for a system assigned identity. + * + * @return the principalId value. + */ + public String principalId() { + return this.principalId; + } + + /** + * Get the tenantId property: The tenant ID of the system assigned identity. This property will only be provided for + * a system assigned identity. + * + * @return the tenantId value. + */ + public String tenantId() { + return this.tenantId; + } + + /** + * Get the type property: The type of managed identity assigned to this resource. + * + * @return the type value. + */ + public ManagedServiceIdentityType type() { + return this.type; + } + + /** + * Set the type property: The type of managed identity assigned to this resource. + * + * @param type the type value to set. + * @return the ManagedServiceIdentity object itself. + */ + public ManagedServiceIdentity withType(ManagedServiceIdentityType type) { + this.type = type; + return this; + } + + /** + * Get the userAssignedIdentities property: The identities assigned to this resource by the user. + * + * @return the userAssignedIdentities value. + */ + public Map userAssignedIdentities() { + return this.userAssignedIdentities; + } + + /** + * Set the userAssignedIdentities property: The identities assigned to this resource by the user. + * + * @param userAssignedIdentities the userAssignedIdentities value to set. + * @return the ManagedServiceIdentity object itself. + */ + public ManagedServiceIdentity withUserAssignedIdentities(Map userAssignedIdentities) { + this.userAssignedIdentities = userAssignedIdentities; + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("type", this.type == null ? null : this.type.toString()); + jsonWriter.writeMapField("userAssignedIdentities", this.userAssignedIdentities, + (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ManagedServiceIdentity from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ManagedServiceIdentity 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 ManagedServiceIdentity. + */ + public static ManagedServiceIdentity fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ManagedServiceIdentity deserializedManagedServiceIdentity = new ManagedServiceIdentity(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("type".equals(fieldName)) { + deserializedManagedServiceIdentity.type = ManagedServiceIdentityType.fromString(reader.getString()); + } else if ("principalId".equals(fieldName)) { + deserializedManagedServiceIdentity.principalId = reader.getString(); + } else if ("tenantId".equals(fieldName)) { + deserializedManagedServiceIdentity.tenantId = reader.getString(); + } else if ("userAssignedIdentities".equals(fieldName)) { + Map userAssignedIdentities + = reader.readMap(reader1 -> UserAssignedIdentity.fromJson(reader1)); + deserializedManagedServiceIdentity.userAssignedIdentities = userAssignedIdentities; + } else { + reader.skipChildren(); + } + } + + return deserializedManagedServiceIdentity; + }); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/ManagedServiceIdentityType.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/ManagedServiceIdentityType.java new file mode 100644 index 000000000000..cb067549e237 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/ManagedServiceIdentityType.java @@ -0,0 +1,62 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Type of managed service identity (where both SystemAssigned and UserAssigned types are allowed). + */ +public final class ManagedServiceIdentityType extends ExpandableStringEnum { + /** + * No managed identity. + */ + public static final ManagedServiceIdentityType NONE = fromString("None"); + + /** + * System assigned managed identity. + */ + public static final ManagedServiceIdentityType SYSTEM_ASSIGNED = fromString("SystemAssigned"); + + /** + * User assigned managed identity. + */ + public static final ManagedServiceIdentityType USER_ASSIGNED = fromString("UserAssigned"); + + /** + * System and user assigned managed identity. + */ + public static final ManagedServiceIdentityType SYSTEM_ASSIGNED_USER_ASSIGNED + = fromString("SystemAssigned,UserAssigned"); + + /** + * Creates a new instance of ManagedServiceIdentityType value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public ManagedServiceIdentityType() { + } + + /** + * Creates or finds a ManagedServiceIdentityType from its string representation. + * + * @param name a name to look for. + * @return the corresponding ManagedServiceIdentityType. + */ + public static ManagedServiceIdentityType fromString(String name) { + return fromString(name, ManagedServiceIdentityType.class); + } + + /** + * Gets known ManagedServiceIdentityType values. + * + * @return known ManagedServiceIdentityType values. + */ + public static Collection values() { + return values(ManagedServiceIdentityType.class); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/Metric.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/Metric.java new file mode 100644 index 000000000000..4be57462a7d6 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/Metric.java @@ -0,0 +1,92 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.models; + +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; + +/** + * Defines a metric in the destination AMW account. + */ +@Immutable +public final class Metric implements JsonSerializable { + /* + * The namespace of the metric. + */ + private String metricNamespace; + + /* + * The name of the metric. + */ + private String metricName; + + /** + * Creates an instance of Metric class. + */ + private Metric() { + } + + /** + * Get the metricNamespace property: The namespace of the metric. + * + * @return the metricNamespace value. + */ + public String metricNamespace() { + return this.metricNamespace; + } + + /** + * Get the metricName property: The name of the metric. + * + * @return the metricName value. + */ + public String metricName() { + return this.metricName; + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("metricNamespace", this.metricNamespace); + jsonWriter.writeStringField("metricName", this.metricName); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Metric from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Metric 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 Metric. + */ + public static Metric fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + Metric deserializedMetric = new Metric(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("metricNamespace".equals(fieldName)) { + deserializedMetric.metricNamespace = reader.getString(); + } else if ("metricName".equals(fieldName)) { + deserializedMetric.metricName = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedMetric; + }); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/ProvisioningState.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/ProvisioningState.java new file mode 100644 index 000000000000..369642bc877c --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/ProvisioningState.java @@ -0,0 +1,56 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Represents the provisioning state of the SLI resource. + */ +public final class ProvisioningState extends ExpandableStringEnum { + /** + * Resource has been created. + */ + public static final ProvisioningState SUCCEEDED = fromString("Succeeded"); + + /** + * Resource creation failed. + */ + public static final ProvisioningState FAILED = fromString("Failed"); + + /** + * Resource creation was canceled. + */ + public static final ProvisioningState CANCELED = fromString("Canceled"); + + /** + * Creates a new instance of ProvisioningState value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public ProvisioningState() { + } + + /** + * Creates or finds a ProvisioningState from its string representation. + * + * @param name a name to look for. + * @return the corresponding ProvisioningState. + */ + public static ProvisioningState fromString(String name) { + return fromString(name, ProvisioningState.class); + } + + /** + * Gets known ProvisioningState values. + * + * @return known ProvisioningState values. + */ + public static Collection values() { + return values(ProvisioningState.class); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/SamplingType.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/SamplingType.java new file mode 100644 index 000000000000..eae669b0ff0e --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/SamplingType.java @@ -0,0 +1,61 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Defines the available sampling types. + */ +public final class SamplingType extends ExpandableStringEnum { + /** + * Maximum value. + */ + public static final SamplingType MAX = fromString("max"); + + /** + * Minimum value. + */ + public static final SamplingType MIN = fromString("min"); + + /** + * Average value. + */ + public static final SamplingType AVG = fromString("avg"); + + /** + * Summation. + */ + public static final SamplingType SUM = fromString("sum"); + + /** + * Creates a new instance of SamplingType value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public SamplingType() { + } + + /** + * Creates or finds a SamplingType from its string representation. + * + * @param name a name to look for. + * @return the corresponding SamplingType. + */ + public static SamplingType fromString(String name) { + return fromString(name, SamplingType.class); + } + + /** + * Gets known SamplingType values. + * + * @return known SamplingType values. + */ + public static Collection values() { + return values(SamplingType.class); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/ScalarFunction.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/ScalarFunction.java new file mode 100644 index 000000000000..61d0bbc2ff75 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/ScalarFunction.java @@ -0,0 +1,61 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Defines scalar functions used in filtering. + */ +public final class ScalarFunction extends ExpandableStringEnum { + /** + * Maximum value. + */ + public static final ScalarFunction MAX = fromString("max"); + + /** + * Minimum value. + */ + public static final ScalarFunction MIN = fromString("min"); + + /** + * Average value. + */ + public static final ScalarFunction AVG = fromString("avg"); + + /** + * Summation. + */ + public static final ScalarFunction SUM = fromString("sum"); + + /** + * Creates a new instance of ScalarFunction value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public ScalarFunction() { + } + + /** + * Creates or finds a ScalarFunction from its string representation. + * + * @param name a name to look for. + * @return the corresponding ScalarFunction. + */ + public static ScalarFunction fromString(String name) { + return fromString(name, ScalarFunction.class); + } + + /** + * Gets known ScalarFunction values. + * + * @return known ScalarFunction values. + */ + public static Collection values() { + return values(ScalarFunction.class); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/Signal.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/Signal.java new file mode 100644 index 000000000000..f371fcb324fa --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/Signal.java @@ -0,0 +1,116 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.models; + +import com.azure.core.annotation.Fluent; +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 a signal model used in SLI calculations. + */ +@Fluent +public final class Signal implements JsonSerializable { + /* + * Sources of metrics used for SLIs. + */ + private List signalSources; + + /* + * Mathematical formula used to combine multiple metrics. + */ + private String signalFormula; + + /** + * Creates an instance of Signal class. + */ + public Signal() { + } + + /** + * Get the signalSources property: Sources of metrics used for SLIs. + * + * @return the signalSources value. + */ + public List signalSources() { + return this.signalSources; + } + + /** + * Set the signalSources property: Sources of metrics used for SLIs. + * + * @param signalSources the signalSources value to set. + * @return the Signal object itself. + */ + public Signal withSignalSources(List signalSources) { + this.signalSources = signalSources; + return this; + } + + /** + * Get the signalFormula property: Mathematical formula used to combine multiple metrics. + * + * @return the signalFormula value. + */ + public String signalFormula() { + return this.signalFormula; + } + + /** + * Set the signalFormula property: Mathematical formula used to combine multiple metrics. + * + * @param signalFormula the signalFormula value to set. + * @return the Signal object itself. + */ + public Signal withSignalFormula(String signalFormula) { + this.signalFormula = signalFormula; + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("signalSources", this.signalSources, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeStringField("signalFormula", this.signalFormula); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Signal from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Signal 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 Signal. + */ + public static Signal fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + Signal deserializedSignal = new Signal(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("signalSources".equals(fieldName)) { + List signalSources = reader.readArray(reader1 -> SignalSource.fromJson(reader1)); + deserializedSignal.signalSources = signalSources; + } else if ("signalFormula".equals(fieldName)) { + deserializedSignal.signalFormula = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedSignal; + }); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/SignalSource.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/SignalSource.java new file mode 100644 index 000000000000..32c3501c3efa --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/SignalSource.java @@ -0,0 +1,286 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.models; + +import com.azure.core.annotation.Fluent; +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 a signal source used in SLIs. + */ +@Fluent +public final class SignalSource implements JsonSerializable { + /* + * Unique identifier for the signal source. + */ + private String signalSourceId; + + /* + * Managed identity for authenticating the signal source. + */ + private String sourceAmwAccountManagedIdentity; + + /* + * Resource ID of the source AMW account. + */ + private String sourceAmwAccountResourceId; + + /* + * Namespace of the metric. + */ + private String metricNamespace; + + /* + * Name of the metric. + */ + private String metricName; + + /* + * Filters applied to modify signal values. + */ + private List filters; + + /* + * Defines how measurements are aggregated across multiple time series. + */ + private SpatialAggregation spatialAggregation; + + /* + * Defines how measurements are aggregated over a specific time window within the same time series. + */ + private TemporalAggregation temporalAggregation; + + /** + * Creates an instance of SignalSource class. + */ + public SignalSource() { + } + + /** + * Get the signalSourceId property: Unique identifier for the signal source. + * + * @return the signalSourceId value. + */ + public String signalSourceId() { + return this.signalSourceId; + } + + /** + * Set the signalSourceId property: Unique identifier for the signal source. + * + * @param signalSourceId the signalSourceId value to set. + * @return the SignalSource object itself. + */ + public SignalSource withSignalSourceId(String signalSourceId) { + this.signalSourceId = signalSourceId; + return this; + } + + /** + * Get the sourceAmwAccountManagedIdentity property: Managed identity for authenticating the signal source. + * + * @return the sourceAmwAccountManagedIdentity value. + */ + public String sourceAmwAccountManagedIdentity() { + return this.sourceAmwAccountManagedIdentity; + } + + /** + * Set the sourceAmwAccountManagedIdentity property: Managed identity for authenticating the signal source. + * + * @param sourceAmwAccountManagedIdentity the sourceAmwAccountManagedIdentity value to set. + * @return the SignalSource object itself. + */ + public SignalSource withSourceAmwAccountManagedIdentity(String sourceAmwAccountManagedIdentity) { + this.sourceAmwAccountManagedIdentity = sourceAmwAccountManagedIdentity; + return this; + } + + /** + * Get the sourceAmwAccountResourceId property: Resource ID of the source AMW account. + * + * @return the sourceAmwAccountResourceId value. + */ + public String sourceAmwAccountResourceId() { + return this.sourceAmwAccountResourceId; + } + + /** + * Set the sourceAmwAccountResourceId property: Resource ID of the source AMW account. + * + * @param sourceAmwAccountResourceId the sourceAmwAccountResourceId value to set. + * @return the SignalSource object itself. + */ + public SignalSource withSourceAmwAccountResourceId(String sourceAmwAccountResourceId) { + this.sourceAmwAccountResourceId = sourceAmwAccountResourceId; + return this; + } + + /** + * Get the metricNamespace property: Namespace of the metric. + * + * @return the metricNamespace value. + */ + public String metricNamespace() { + return this.metricNamespace; + } + + /** + * Set the metricNamespace property: Namespace of the metric. + * + * @param metricNamespace the metricNamespace value to set. + * @return the SignalSource object itself. + */ + public SignalSource withMetricNamespace(String metricNamespace) { + this.metricNamespace = metricNamespace; + return this; + } + + /** + * Get the metricName property: Name of the metric. + * + * @return the metricName value. + */ + public String metricName() { + return this.metricName; + } + + /** + * Set the metricName property: Name of the metric. + * + * @param metricName the metricName value to set. + * @return the SignalSource object itself. + */ + public SignalSource withMetricName(String metricName) { + this.metricName = metricName; + return this; + } + + /** + * Get the filters property: Filters applied to modify signal values. + * + * @return the filters value. + */ + public List filters() { + return this.filters; + } + + /** + * Set the filters property: Filters applied to modify signal values. + * + * @param filters the filters value to set. + * @return the SignalSource object itself. + */ + public SignalSource withFilters(List filters) { + this.filters = filters; + return this; + } + + /** + * Get the spatialAggregation property: Defines how measurements are aggregated across multiple time series. + * + * @return the spatialAggregation value. + */ + public SpatialAggregation spatialAggregation() { + return this.spatialAggregation; + } + + /** + * Set the spatialAggregation property: Defines how measurements are aggregated across multiple time series. + * + * @param spatialAggregation the spatialAggregation value to set. + * @return the SignalSource object itself. + */ + public SignalSource withSpatialAggregation(SpatialAggregation spatialAggregation) { + this.spatialAggregation = spatialAggregation; + return this; + } + + /** + * Get the temporalAggregation property: Defines how measurements are aggregated over a specific time window within + * the same time series. + * + * @return the temporalAggregation value. + */ + public TemporalAggregation temporalAggregation() { + return this.temporalAggregation; + } + + /** + * Set the temporalAggregation property: Defines how measurements are aggregated over a specific time window within + * the same time series. + * + * @param temporalAggregation the temporalAggregation value to set. + * @return the SignalSource object itself. + */ + public SignalSource withTemporalAggregation(TemporalAggregation temporalAggregation) { + this.temporalAggregation = temporalAggregation; + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("signalSourceId", this.signalSourceId); + jsonWriter.writeStringField("sourceAmwAccountManagedIdentity", this.sourceAmwAccountManagedIdentity); + jsonWriter.writeStringField("sourceAmwAccountResourceId", this.sourceAmwAccountResourceId); + jsonWriter.writeStringField("metricNamespace", this.metricNamespace); + jsonWriter.writeStringField("metricName", this.metricName); + jsonWriter.writeArrayField("filters", this.filters, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeJsonField("spatialAggregation", this.spatialAggregation); + jsonWriter.writeJsonField("temporalAggregation", this.temporalAggregation); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SignalSource from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SignalSource 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 SignalSource. + */ + public static SignalSource fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + SignalSource deserializedSignalSource = new SignalSource(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("signalSourceId".equals(fieldName)) { + deserializedSignalSource.signalSourceId = reader.getString(); + } else if ("sourceAmwAccountManagedIdentity".equals(fieldName)) { + deserializedSignalSource.sourceAmwAccountManagedIdentity = reader.getString(); + } else if ("sourceAmwAccountResourceId".equals(fieldName)) { + deserializedSignalSource.sourceAmwAccountResourceId = reader.getString(); + } else if ("metricNamespace".equals(fieldName)) { + deserializedSignalSource.metricNamespace = reader.getString(); + } else if ("metricName".equals(fieldName)) { + deserializedSignalSource.metricName = reader.getString(); + } else if ("filters".equals(fieldName)) { + List filters = reader.readArray(reader1 -> Condition.fromJson(reader1)); + deserializedSignalSource.filters = filters; + } else if ("spatialAggregation".equals(fieldName)) { + deserializedSignalSource.spatialAggregation = SpatialAggregation.fromJson(reader); + } else if ("temporalAggregation".equals(fieldName)) { + deserializedSignalSource.temporalAggregation = TemporalAggregation.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedSignalSource; + }); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/Sli.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/Sli.java new file mode 100644 index 000000000000..a287bb06cdf8 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/Sli.java @@ -0,0 +1,62 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.models; + +import com.azure.core.management.SystemData; +import com.azure.resourcemanager.monitor.slis.fluent.models.SliInner; + +/** + * An immutable client-side representation of Sli. + */ +public interface Sli { + /** + * Gets the id property: Fully qualified resource Id for the resource. + * + * @return the id value. + */ + String id(); + + /** + * Gets the name property: The name of the resource. + * + * @return the name value. + */ + String name(); + + /** + * Gets the type property: The type of the resource. + * + * @return the type value. + */ + String type(); + + /** + * Gets the properties property: The resource-specific properties for this resource. + * + * @return the properties value. + */ + SliResource properties(); + + /** + * Gets the identity property: The managed service identities assigned to this resource. + * + * @return the identity value. + */ + ManagedServiceIdentity identity(); + + /** + * Gets the systemData property: Azure Resource Manager metadata containing createdBy and modifiedBy information. + * + * @return the systemData value. + */ + SystemData systemData(); + + /** + * Gets the inner com.azure.resourcemanager.monitor.slis.fluent.models.SliInner object. + * + * @return the inner object. + */ + SliInner innerModel(); +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/SliProperties.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/SliProperties.java new file mode 100644 index 000000000000..b106b5612385 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/SliProperties.java @@ -0,0 +1,169 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.models; + +import com.azure.core.annotation.Fluent; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Defines the properties of an SLI. + */ +@Fluent +public final class SliProperties implements JsonSerializable { + /* + * Represents good signals used in request-based SLI calculations. + */ + private Signal goodSignals; + + /* + * Represents total signals used in request-based SLI calculations. + */ + private Signal totalSignals; + + /* + * Signals used for window-based SLI calculations. + */ + private Signal signals; + + /* + * Defines the uptime criteria for window-based SLIs. + */ + private WindowUptimeCriteria windowUptimeCriteria; + + /** + * Creates an instance of SliProperties class. + */ + public SliProperties() { + } + + /** + * Get the goodSignals property: Represents good signals used in request-based SLI calculations. + * + * @return the goodSignals value. + */ + public Signal goodSignals() { + return this.goodSignals; + } + + /** + * Set the goodSignals property: Represents good signals used in request-based SLI calculations. + * + * @param goodSignals the goodSignals value to set. + * @return the SliProperties object itself. + */ + public SliProperties withGoodSignals(Signal goodSignals) { + this.goodSignals = goodSignals; + return this; + } + + /** + * Get the totalSignals property: Represents total signals used in request-based SLI calculations. + * + * @return the totalSignals value. + */ + public Signal totalSignals() { + return this.totalSignals; + } + + /** + * Set the totalSignals property: Represents total signals used in request-based SLI calculations. + * + * @param totalSignals the totalSignals value to set. + * @return the SliProperties object itself. + */ + public SliProperties withTotalSignals(Signal totalSignals) { + this.totalSignals = totalSignals; + return this; + } + + /** + * Get the signals property: Signals used for window-based SLI calculations. + * + * @return the signals value. + */ + public Signal signals() { + return this.signals; + } + + /** + * Set the signals property: Signals used for window-based SLI calculations. + * + * @param signals the signals value to set. + * @return the SliProperties object itself. + */ + public SliProperties withSignals(Signal signals) { + this.signals = signals; + return this; + } + + /** + * Get the windowUptimeCriteria property: Defines the uptime criteria for window-based SLIs. + * + * @return the windowUptimeCriteria value. + */ + public WindowUptimeCriteria windowUptimeCriteria() { + return this.windowUptimeCriteria; + } + + /** + * Set the windowUptimeCriteria property: Defines the uptime criteria for window-based SLIs. + * + * @param windowUptimeCriteria the windowUptimeCriteria value to set. + * @return the SliProperties object itself. + */ + public SliProperties withWindowUptimeCriteria(WindowUptimeCriteria windowUptimeCriteria) { + this.windowUptimeCriteria = windowUptimeCriteria; + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("goodSignals", this.goodSignals); + jsonWriter.writeJsonField("totalSignals", this.totalSignals); + jsonWriter.writeJsonField("signals", this.signals); + jsonWriter.writeJsonField("windowUptimeCriteria", this.windowUptimeCriteria); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SliProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SliProperties 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 SliProperties. + */ + public static SliProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + SliProperties deserializedSliProperties = new SliProperties(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("goodSignals".equals(fieldName)) { + deserializedSliProperties.goodSignals = Signal.fromJson(reader); + } else if ("totalSignals".equals(fieldName)) { + deserializedSliProperties.totalSignals = Signal.fromJson(reader); + } else if ("signals".equals(fieldName)) { + deserializedSliProperties.signals = Signal.fromJson(reader); + } else if ("windowUptimeCriteria".equals(fieldName)) { + deserializedSliProperties.windowUptimeCriteria = WindowUptimeCriteria.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedSliProperties; + }); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/SliResource.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/SliResource.java new file mode 100644 index 000000000000..20e813f69a4a --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/SliResource.java @@ -0,0 +1,348 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.CoreUtils; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.time.OffsetDateTime; +import java.util.List; + +/** + * Defines the root level properties of an SLI resource. + */ +@Fluent +public final class SliResource implements JsonSerializable { + /* + * Indicates the provisioning status of the last operation. + */ + private ProvisioningState provisioningState; + + /* + * A user-provided description of the SLI, with a maximum length of 1000 characters. + */ + private String description; + + /* + * Specifies the category of the SLI, used to classify signals such as Availability and Latency. + */ + private Category category; + + /* + * Determines how the SLI is evaluated—either based on request counts or time windows. + */ + private EvaluationType evaluationType; + + /* + * Indicates the current execution status of the SLI resource in ARM responses. + */ + private ExecutionState executionState; + + /* + * Destination AMW accounts. + */ + private List destinationAmwAccounts; + + /* + * The destination Azure Monitor Workspace (AMW) accounts where the SLI emits metrics. + */ + private List destinationMetrics; + + /* + * Defines the SLO baseline associated with the SLI. + */ + private BaselineProperties baselineProperties; + + /* + * The streaming rule Id associated with the Sli resource. + */ + private String streamingRuleId; + + /* + * The streaming rule last updated timestamp associated with the Sli resource. + */ + private OffsetDateTime streamingRuleLastUpdatedTimestamp; + + /* + * A flag to determine whether alert is enabled. + */ + private boolean enableAlert; + + /* + * Defines the SLI properties associated with the SLI. + */ + private SliProperties sliProperties; + + /** + * Creates an instance of SliResource class. + */ + public SliResource() { + } + + /** + * Get the provisioningState property: Indicates the provisioning status of the last operation. + * + * @return the provisioningState value. + */ + public ProvisioningState provisioningState() { + return this.provisioningState; + } + + /** + * Get the description property: A user-provided description of the SLI, with a maximum length of 1000 characters. + * + * @return the description value. + */ + public String description() { + return this.description; + } + + /** + * Set the description property: A user-provided description of the SLI, with a maximum length of 1000 characters. + * + * @param description the description value to set. + * @return the SliResource object itself. + */ + public SliResource withDescription(String description) { + this.description = description; + return this; + } + + /** + * Get the category property: Specifies the category of the SLI, used to classify signals such as Availability and + * Latency. + * + * @return the category value. + */ + public Category category() { + return this.category; + } + + /** + * Set the category property: Specifies the category of the SLI, used to classify signals such as Availability and + * Latency. + * + * @param category the category value to set. + * @return the SliResource object itself. + */ + public SliResource withCategory(Category category) { + this.category = category; + return this; + } + + /** + * Get the evaluationType property: Determines how the SLI is evaluated—either based on request counts or time + * windows. + * + * @return the evaluationType value. + */ + public EvaluationType evaluationType() { + return this.evaluationType; + } + + /** + * Set the evaluationType property: Determines how the SLI is evaluated—either based on request counts or time + * windows. + * + * @param evaluationType the evaluationType value to set. + * @return the SliResource object itself. + */ + public SliResource withEvaluationType(EvaluationType evaluationType) { + this.evaluationType = evaluationType; + return this; + } + + /** + * Get the executionState property: Indicates the current execution status of the SLI resource in ARM responses. + * + * @return the executionState value. + */ + public ExecutionState executionState() { + return this.executionState; + } + + /** + * Get the destinationAmwAccounts property: Destination AMW accounts. + * + * @return the destinationAmwAccounts value. + */ + public List destinationAmwAccounts() { + return this.destinationAmwAccounts; + } + + /** + * Set the destinationAmwAccounts property: Destination AMW accounts. + * + * @param destinationAmwAccounts the destinationAmwAccounts value to set. + * @return the SliResource object itself. + */ + public SliResource withDestinationAmwAccounts(List destinationAmwAccounts) { + this.destinationAmwAccounts = destinationAmwAccounts; + return this; + } + + /** + * Get the destinationMetrics property: The destination Azure Monitor Workspace (AMW) accounts where the SLI emits + * metrics. + * + * @return the destinationMetrics value. + */ + public List destinationMetrics() { + return this.destinationMetrics; + } + + /** + * Get the baselineProperties property: Defines the SLO baseline associated with the SLI. + * + * @return the baselineProperties value. + */ + public BaselineProperties baselineProperties() { + return this.baselineProperties; + } + + /** + * Set the baselineProperties property: Defines the SLO baseline associated with the SLI. + * + * @param baselineProperties the baselineProperties value to set. + * @return the SliResource object itself. + */ + public SliResource withBaselineProperties(BaselineProperties baselineProperties) { + this.baselineProperties = baselineProperties; + return this; + } + + /** + * Get the streamingRuleId property: The streaming rule Id associated with the Sli resource. + * + * @return the streamingRuleId value. + */ + public String streamingRuleId() { + return this.streamingRuleId; + } + + /** + * Get the streamingRuleLastUpdatedTimestamp property: The streaming rule last updated timestamp associated with the + * Sli resource. + * + * @return the streamingRuleLastUpdatedTimestamp value. + */ + public OffsetDateTime streamingRuleLastUpdatedTimestamp() { + return this.streamingRuleLastUpdatedTimestamp; + } + + /** + * Get the enableAlert property: A flag to determine whether alert is enabled. + * + * @return the enableAlert value. + */ + public boolean enableAlert() { + return this.enableAlert; + } + + /** + * Set the enableAlert property: A flag to determine whether alert is enabled. + * + * @param enableAlert the enableAlert value to set. + * @return the SliResource object itself. + */ + public SliResource withEnableAlert(boolean enableAlert) { + this.enableAlert = enableAlert; + return this; + } + + /** + * Get the sliProperties property: Defines the SLI properties associated with the SLI. + * + * @return the sliProperties value. + */ + public SliProperties sliProperties() { + return this.sliProperties; + } + + /** + * Set the sliProperties property: Defines the SLI properties associated with the SLI. + * + * @param sliProperties the sliProperties value to set. + * @return the SliResource object itself. + */ + public SliResource withSliProperties(SliProperties sliProperties) { + this.sliProperties = sliProperties; + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("description", this.description); + jsonWriter.writeStringField("category", this.category == null ? null : this.category.toString()); + jsonWriter.writeStringField("evaluationType", + this.evaluationType == null ? null : this.evaluationType.toString()); + jsonWriter.writeArrayField("destinationAmwAccounts", this.destinationAmwAccounts, + (writer, element) -> writer.writeJson(element)); + jsonWriter.writeJsonField("baselineProperties", this.baselineProperties); + jsonWriter.writeBooleanField("enableAlert", this.enableAlert); + jsonWriter.writeJsonField("sliProperties", this.sliProperties); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SliResource from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SliResource 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 SliResource. + */ + public static SliResource fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + SliResource deserializedSliResource = new SliResource(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("description".equals(fieldName)) { + deserializedSliResource.description = reader.getString(); + } else if ("category".equals(fieldName)) { + deserializedSliResource.category = Category.fromString(reader.getString()); + } else if ("evaluationType".equals(fieldName)) { + deserializedSliResource.evaluationType = EvaluationType.fromString(reader.getString()); + } else if ("destinationAmwAccounts".equals(fieldName)) { + List destinationAmwAccounts = reader.readArray(reader1 -> AmwAccount.fromJson(reader1)); + deserializedSliResource.destinationAmwAccounts = destinationAmwAccounts; + } else if ("baselineProperties".equals(fieldName)) { + deserializedSliResource.baselineProperties = BaselineProperties.fromJson(reader); + } else if ("enableAlert".equals(fieldName)) { + deserializedSliResource.enableAlert = reader.getBoolean(); + } else if ("sliProperties".equals(fieldName)) { + deserializedSliResource.sliProperties = SliProperties.fromJson(reader); + } else if ("provisioningState".equals(fieldName)) { + deserializedSliResource.provisioningState = ProvisioningState.fromString(reader.getString()); + } else if ("executionState".equals(fieldName)) { + deserializedSliResource.executionState = ExecutionState.fromJson(reader); + } else if ("destinationMetrics".equals(fieldName)) { + List destinationMetrics = reader.readArray(reader1 -> Metric.fromJson(reader1)); + deserializedSliResource.destinationMetrics = destinationMetrics; + } else if ("streamingRuleId".equals(fieldName)) { + deserializedSliResource.streamingRuleId = reader.getString(); + } else if ("streamingRuleLastUpdatedTimestamp".equals(fieldName)) { + deserializedSliResource.streamingRuleLastUpdatedTimestamp = reader + .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString())); + } else { + reader.skipChildren(); + } + } + + return deserializedSliResource; + }); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/Slis.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/Slis.java new file mode 100644 index 000000000000..2545e93f784e --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/Slis.java @@ -0,0 +1,115 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.models; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.Response; +import com.azure.core.util.Context; +import com.azure.resourcemanager.monitor.slis.fluent.models.SliInner; + +/** + * Resource collection API of Slis. + */ +public interface Slis { + /** + * Gets an SLI resource. + * + * @param serviceGroupName The name of the service group. + * @param sliName Name of the SLI that is given by the user. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an SLI resource along with {@link Response}. + */ + Response getWithResponse(String serviceGroupName, String sliName, Context context); + + /** + * Gets an SLI resource. + * + * @param serviceGroupName The name of the service group. + * @param sliName Name of the SLI that is given by the user. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an SLI resource. + */ + Sli get(String serviceGroupName, String sliName); + + /** + * Creates or updates an SLI resource. + * + * @param serviceGroupName The name of the service group. + * @param sliName Name of the SLI that is given by the user. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return represents an SLI resource within the ProviderHub along with {@link Response}. + */ + Response createOrUpdateWithResponse(String serviceGroupName, String sliName, SliInner resource, + Context context); + + /** + * Creates or updates an SLI resource. + * + * @param serviceGroupName The name of the service group. + * @param sliName Name of the SLI that is given by the user. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return represents an SLI resource within the ProviderHub. + */ + Sli createOrUpdate(String serviceGroupName, String sliName, SliInner resource); + + /** + * Deletes an SLI resource. + * + * @param serviceGroupName The name of the service group. + * @param sliName Name of the SLI that is given by the user. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + Response deleteByResourceGroupWithResponse(String serviceGroupName, String sliName, Context context); + + /** + * Deletes an SLI resource. + * + * @param serviceGroupName The name of the service group. + * @param sliName Name of the SLI that is given by the user. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + void deleteByResourceGroup(String serviceGroupName, String sliName); + + /** + * Lists all SLI resources under a parent resource. + * + * @param serviceGroupName The name of the service group. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Sli list operation as paginated response with {@link PagedIterable}. + */ + PagedIterable listByParent(String serviceGroupName); + + /** + * Lists all SLI resources under a parent resource. + * + * @param serviceGroupName The name of the service group. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Sli list operation as paginated response with {@link PagedIterable}. + */ + PagedIterable listByParent(String serviceGroupName, Context context); +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/SpatialAggregation.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/SpatialAggregation.java new file mode 100644 index 000000000000..58a5593f48ea --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/SpatialAggregation.java @@ -0,0 +1,116 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.models; + +import com.azure.core.annotation.Fluent; +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 spatial aggregation model. + */ +@Fluent +public final class SpatialAggregation implements JsonSerializable { + /* + * Type of spatial aggregation. + */ + private SpatialAggregationType type; + + /* + * Dimensions considered for spatial aggregation. + */ + private List dimensions; + + /** + * Creates an instance of SpatialAggregation class. + */ + public SpatialAggregation() { + } + + /** + * Get the type property: Type of spatial aggregation. + * + * @return the type value. + */ + public SpatialAggregationType type() { + return this.type; + } + + /** + * Set the type property: Type of spatial aggregation. + * + * @param type the type value to set. + * @return the SpatialAggregation object itself. + */ + public SpatialAggregation withType(SpatialAggregationType type) { + this.type = type; + return this; + } + + /** + * Get the dimensions property: Dimensions considered for spatial aggregation. + * + * @return the dimensions value. + */ + public List dimensions() { + return this.dimensions; + } + + /** + * Set the dimensions property: Dimensions considered for spatial aggregation. + * + * @param dimensions the dimensions value to set. + * @return the SpatialAggregation object itself. + */ + public SpatialAggregation withDimensions(List dimensions) { + this.dimensions = dimensions; + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("type", this.type == null ? null : this.type.toString()); + jsonWriter.writeArrayField("dimensions", this.dimensions, (writer, element) -> writer.writeString(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SpatialAggregation from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SpatialAggregation 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 SpatialAggregation. + */ + public static SpatialAggregation fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + SpatialAggregation deserializedSpatialAggregation = new SpatialAggregation(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("type".equals(fieldName)) { + deserializedSpatialAggregation.type = SpatialAggregationType.fromString(reader.getString()); + } else if ("dimensions".equals(fieldName)) { + List dimensions = reader.readArray(reader1 -> reader1.getString()); + deserializedSpatialAggregation.dimensions = dimensions; + } else { + reader.skipChildren(); + } + } + + return deserializedSpatialAggregation; + }); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/SpatialAggregationType.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/SpatialAggregationType.java new file mode 100644 index 000000000000..afcf1b64afff --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/SpatialAggregationType.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.resourcemanager.monitor.slis.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Defines the available spatial aggregation types for aggregating measurements across multiple time series. + */ +public final class SpatialAggregationType extends ExpandableStringEnum { + /** + * Average value. + */ + public static final SpatialAggregationType AVERAGE = fromString("Average"); + + /** + * Minimum value. + */ + public static final SpatialAggregationType MIN = fromString("Min"); + + /** + * Maximum value. + */ + public static final SpatialAggregationType MAX = fromString("Max"); + + /** + * Summation. + */ + public static final SpatialAggregationType SUM = fromString("Sum"); + + /** + * Count of occurrences. + */ + public static final SpatialAggregationType COUNT = fromString("Count"); + + /** + * Creates a new instance of SpatialAggregationType value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public SpatialAggregationType() { + } + + /** + * Creates or finds a SpatialAggregationType from its string representation. + * + * @param name a name to look for. + * @return the corresponding SpatialAggregationType. + */ + public static SpatialAggregationType fromString(String name) { + return fromString(name, SpatialAggregationType.class); + } + + /** + * Gets known SpatialAggregationType values. + * + * @return known SpatialAggregationType values. + */ + public static Collection values() { + return values(SpatialAggregationType.class); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/TemporalAggregation.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/TemporalAggregation.java new file mode 100644 index 000000000000..cc0c4f4d01a9 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/TemporalAggregation.java @@ -0,0 +1,114 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.models; + +import com.azure.core.annotation.Fluent; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Represents temporal aggregation settings. + */ +@Fluent +public final class TemporalAggregation implements JsonSerializable { + /* + * Type of temporal aggregation. + */ + private TemporalAggregationType type; + + /* + * Time window size for aggregation, in minutes. + */ + private Integer windowSizeMinutes; + + /** + * Creates an instance of TemporalAggregation class. + */ + public TemporalAggregation() { + } + + /** + * Get the type property: Type of temporal aggregation. + * + * @return the type value. + */ + public TemporalAggregationType type() { + return this.type; + } + + /** + * Set the type property: Type of temporal aggregation. + * + * @param type the type value to set. + * @return the TemporalAggregation object itself. + */ + public TemporalAggregation withType(TemporalAggregationType type) { + this.type = type; + return this; + } + + /** + * Get the windowSizeMinutes property: Time window size for aggregation, in minutes. + * + * @return the windowSizeMinutes value. + */ + public Integer windowSizeMinutes() { + return this.windowSizeMinutes; + } + + /** + * Set the windowSizeMinutes property: Time window size for aggregation, in minutes. + * + * @param windowSizeMinutes the windowSizeMinutes value to set. + * @return the TemporalAggregation object itself. + */ + public TemporalAggregation withWindowSizeMinutes(Integer windowSizeMinutes) { + this.windowSizeMinutes = windowSizeMinutes; + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("type", this.type == null ? null : this.type.toString()); + jsonWriter.writeNumberField("windowSizeMinutes", this.windowSizeMinutes); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of TemporalAggregation from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of TemporalAggregation 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 TemporalAggregation. + */ + public static TemporalAggregation fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + TemporalAggregation deserializedTemporalAggregation = new TemporalAggregation(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("type".equals(fieldName)) { + deserializedTemporalAggregation.type = TemporalAggregationType.fromString(reader.getString()); + } else if ("windowSizeMinutes".equals(fieldName)) { + deserializedTemporalAggregation.windowSizeMinutes = reader.getNullable(JsonReader::getInt); + } else { + reader.skipChildren(); + } + } + + return deserializedTemporalAggregation; + }); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/TemporalAggregationType.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/TemporalAggregationType.java new file mode 100644 index 000000000000..277388ad7af8 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/TemporalAggregationType.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.resourcemanager.monitor.slis.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Defines the available temporal aggregation types for aggregating measurements over a specific time window within the + * same time series. + */ +public final class TemporalAggregationType extends ExpandableStringEnum { + /** + * Average value. + */ + public static final TemporalAggregationType AVERAGE = fromString("Average"); + + /** + * Minimum value. + */ + public static final TemporalAggregationType MIN = fromString("Min"); + + /** + * Maximum value. + */ + public static final TemporalAggregationType MAX = fromString("Max"); + + /** + * Summation. + */ + public static final TemporalAggregationType SUM = fromString("Sum"); + + /** + * Rate over time. + */ + public static final TemporalAggregationType RATE = fromString("Rate"); + + /** + * Instance rate. + */ + public static final TemporalAggregationType IRATE = fromString("IRate"); + + /** + * Delta over time. + */ + public static final TemporalAggregationType DELTA = fromString("Delta"); + + /** + * Instance delta. + */ + public static final TemporalAggregationType IDELTA = fromString("IDelta"); + + /** + * Increase over time. + */ + public static final TemporalAggregationType INCREASE = fromString("Increase"); + + /** + * Creates a new instance of TemporalAggregationType value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public TemporalAggregationType() { + } + + /** + * Creates or finds a TemporalAggregationType from its string representation. + * + * @param name a name to look for. + * @return the corresponding TemporalAggregationType. + */ + public static TemporalAggregationType fromString(String name) { + return fromString(name, TemporalAggregationType.class); + } + + /** + * Gets known TemporalAggregationType values. + * + * @return known TemporalAggregationType values. + */ + public static Collection values() { + return values(TemporalAggregationType.class); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/UserAssignedIdentity.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/UserAssignedIdentity.java new file mode 100644 index 000000000000..a31bf744731f --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/UserAssignedIdentity.java @@ -0,0 +1,89 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.models; + +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; + +/** + * User assigned identity properties. + */ +@Immutable +public final class UserAssignedIdentity implements JsonSerializable { + /* + * The principal ID of the assigned identity. + */ + private String principalId; + + /* + * The client ID of the assigned identity. + */ + private String clientId; + + /** + * Creates an instance of UserAssignedIdentity class. + */ + public UserAssignedIdentity() { + } + + /** + * Get the principalId property: The principal ID of the assigned identity. + * + * @return the principalId value. + */ + public String principalId() { + return this.principalId; + } + + /** + * Get the clientId property: The client ID of the assigned identity. + * + * @return the clientId value. + */ + public String clientId() { + return this.clientId; + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of UserAssignedIdentity from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of UserAssignedIdentity 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 UserAssignedIdentity. + */ + public static UserAssignedIdentity fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + UserAssignedIdentity deserializedUserAssignedIdentity = new UserAssignedIdentity(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("principalId".equals(fieldName)) { + deserializedUserAssignedIdentity.principalId = reader.getString(); + } else if ("clientId".equals(fieldName)) { + deserializedUserAssignedIdentity.clientId = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedUserAssignedIdentity; + }); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/WindowUptimeCriteria.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/WindowUptimeCriteria.java new file mode 100644 index 000000000000..950bc19dca62 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/WindowUptimeCriteria.java @@ -0,0 +1,115 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.models; + +import com.azure.core.annotation.Fluent; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Represents criteria for determining uptime in window-based SLIs. + */ +@Fluent +public final class WindowUptimeCriteria implements JsonSerializable { + /* + * Threshold value used to determine uptime. + */ + private double target; + + /* + * Comparison operator used for uptime evaluation. + */ + private WindowUptimeCriteriaComparator comparator; + + /** + * Creates an instance of WindowUptimeCriteria class. + */ + public WindowUptimeCriteria() { + } + + /** + * Get the target property: Threshold value used to determine uptime. + * + * @return the target value. + */ + public double target() { + return this.target; + } + + /** + * Set the target property: Threshold value used to determine uptime. + * + * @param target the target value to set. + * @return the WindowUptimeCriteria object itself. + */ + public WindowUptimeCriteria withTarget(double target) { + this.target = target; + return this; + } + + /** + * Get the comparator property: Comparison operator used for uptime evaluation. + * + * @return the comparator value. + */ + public WindowUptimeCriteriaComparator comparator() { + return this.comparator; + } + + /** + * Set the comparator property: Comparison operator used for uptime evaluation. + * + * @param comparator the comparator value to set. + * @return the WindowUptimeCriteria object itself. + */ + public WindowUptimeCriteria withComparator(WindowUptimeCriteriaComparator comparator) { + this.comparator = comparator; + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeDoubleField("target", this.target); + jsonWriter.writeStringField("comparator", this.comparator == null ? null : this.comparator.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of WindowUptimeCriteria from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of WindowUptimeCriteria 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 WindowUptimeCriteria. + */ + public static WindowUptimeCriteria fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + WindowUptimeCriteria deserializedWindowUptimeCriteria = new WindowUptimeCriteria(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("target".equals(fieldName)) { + deserializedWindowUptimeCriteria.target = reader.getDouble(); + } else if ("comparator".equals(fieldName)) { + deserializedWindowUptimeCriteria.comparator + = WindowUptimeCriteriaComparator.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + + return deserializedWindowUptimeCriteria; + }); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/WindowUptimeCriteriaComparator.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/WindowUptimeCriteriaComparator.java new file mode 100644 index 000000000000..0e13d5709c17 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/WindowUptimeCriteriaComparator.java @@ -0,0 +1,61 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Defines comparison operators for window uptime criteria. + */ +public final class WindowUptimeCriteriaComparator extends ExpandableStringEnum { + /** + * Less than the target value. + */ + public static final WindowUptimeCriteriaComparator LESS_THAN = fromString("<"); + + /** + * Greater than the target value. + */ + public static final WindowUptimeCriteriaComparator GREATER_THAN = fromString(">"); + + /** + * Less than or equal to the target value. + */ + public static final WindowUptimeCriteriaComparator LESS_THAN_OR_EQUAL = fromString("<="); + + /** + * Greater than or equal to the target value. + */ + public static final WindowUptimeCriteriaComparator GREATER_THAN_OR_EQUAL = fromString(">="); + + /** + * Creates a new instance of WindowUptimeCriteriaComparator value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public WindowUptimeCriteriaComparator() { + } + + /** + * Creates or finds a WindowUptimeCriteriaComparator from its string representation. + * + * @param name a name to look for. + * @return the corresponding WindowUptimeCriteriaComparator. + */ + public static WindowUptimeCriteriaComparator fromString(String name) { + return fromString(name, WindowUptimeCriteriaComparator.class); + } + + /** + * Gets known WindowUptimeCriteriaComparator values. + * + * @return known WindowUptimeCriteriaComparator values. + */ + public static Collection values() { + return values(WindowUptimeCriteriaComparator.class); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/package-info.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/package-info.java new file mode 100644 index 000000000000..fbea1bd2e68a --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/package-info.java @@ -0,0 +1,8 @@ +// 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 SlisManagementClient. + */ +package com.azure.resourcemanager.monitor.slis.models; diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/package-info.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/package-info.java new file mode 100644 index 000000000000..cbdaf8b2354e --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/package-info.java @@ -0,0 +1,8 @@ +// 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 SlisManagementClient. + */ +package com.azure.resourcemanager.monitor.slis; diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/module-info.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/module-info.java new file mode 100644 index 000000000000..ea4862ecbc58 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/module-info.java @@ -0,0 +1,16 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +module com.azure.resourcemanager.monitor.slis { + requires transitive com.azure.core.management; + + exports com.azure.resourcemanager.monitor.slis; + exports com.azure.resourcemanager.monitor.slis.fluent; + exports com.azure.resourcemanager.monitor.slis.fluent.models; + exports com.azure.resourcemanager.monitor.slis.models; + + opens com.azure.resourcemanager.monitor.slis.fluent.models to com.azure.core; + opens com.azure.resourcemanager.monitor.slis.models to com.azure.core; + opens com.azure.resourcemanager.monitor.slis.implementation.models to com.azure.core; +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/resources/META-INF/azure-resourcemanager-monitor-slis_metadata.json b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/resources/META-INF/azure-resourcemanager-monitor-slis_metadata.json new file mode 100644 index 000000000000..5e94dcb485a5 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/resources/META-INF/azure-resourcemanager-monitor-slis_metadata.json @@ -0,0 +1 @@ +{"flavor":"azure","apiVersions":{"Microsoft.Monitor":"2025-03-01-preview"},"crossLanguageDefinitions":{"com.azure.resourcemanager.monitor.slis.fluent.SlisClient":"Microsoft.Monitor.Slis","com.azure.resourcemanager.monitor.slis.fluent.SlisClient.createOrUpdate":"Microsoft.Monitor.Slis.createOrUpdate","com.azure.resourcemanager.monitor.slis.fluent.SlisClient.createOrUpdateWithResponse":"Microsoft.Monitor.Slis.createOrUpdate","com.azure.resourcemanager.monitor.slis.fluent.SlisClient.delete":"Microsoft.Monitor.Slis.delete","com.azure.resourcemanager.monitor.slis.fluent.SlisClient.deleteWithResponse":"Microsoft.Monitor.Slis.delete","com.azure.resourcemanager.monitor.slis.fluent.SlisClient.get":"Microsoft.Monitor.Slis.get","com.azure.resourcemanager.monitor.slis.fluent.SlisClient.getWithResponse":"Microsoft.Monitor.Slis.get","com.azure.resourcemanager.monitor.slis.fluent.SlisClient.listByParent":"Microsoft.Monitor.Slis.listByParent","com.azure.resourcemanager.monitor.slis.fluent.SlisManagementClient":"Microsoft.Monitor","com.azure.resourcemanager.monitor.slis.fluent.models.SliInner":"Microsoft.Monitor.Sli","com.azure.resourcemanager.monitor.slis.implementation.SlisManagementClientBuilder":"Microsoft.Monitor","com.azure.resourcemanager.monitor.slis.implementation.models.SliListResult":"Azure.ResourceManager.ResourceListResult","com.azure.resourcemanager.monitor.slis.models.AmwAccount":"Microsoft.Monitor.AmwAccount","com.azure.resourcemanager.monitor.slis.models.Baseline":"Microsoft.Monitor.Baseline","com.azure.resourcemanager.monitor.slis.models.BaselineProperties":"Microsoft.Monitor.BaselineProperties","com.azure.resourcemanager.monitor.slis.models.Category":"Microsoft.Monitor.Category","com.azure.resourcemanager.monitor.slis.models.Condition":"Microsoft.Monitor.Condition","com.azure.resourcemanager.monitor.slis.models.ConditionOperator":"Microsoft.Monitor.ConditionOperator","com.azure.resourcemanager.monitor.slis.models.EvaluationCalculationType":"Microsoft.Monitor.EvaluationCalculationType","com.azure.resourcemanager.monitor.slis.models.EvaluationType":"Microsoft.Monitor.EvaluationType","com.azure.resourcemanager.monitor.slis.models.ExecutionState":"Microsoft.Monitor.ExecutionState","com.azure.resourcemanager.monitor.slis.models.ManagedServiceIdentity":"Azure.ResourceManager.CommonTypes.ManagedServiceIdentity","com.azure.resourcemanager.monitor.slis.models.ManagedServiceIdentityType":"Azure.ResourceManager.CommonTypes.ManagedServiceIdentityType","com.azure.resourcemanager.monitor.slis.models.Metric":"Microsoft.Monitor.Metric","com.azure.resourcemanager.monitor.slis.models.ProvisioningState":"Microsoft.Monitor.ProvisioningState","com.azure.resourcemanager.monitor.slis.models.SamplingType":"Microsoft.Monitor.SamplingType","com.azure.resourcemanager.monitor.slis.models.ScalarFunction":"Microsoft.Monitor.ScalarFunction","com.azure.resourcemanager.monitor.slis.models.Signal":"Microsoft.Monitor.Signal","com.azure.resourcemanager.monitor.slis.models.SignalSource":"Microsoft.Monitor.SignalSource","com.azure.resourcemanager.monitor.slis.models.SliProperties":"Microsoft.Monitor.SliProperties","com.azure.resourcemanager.monitor.slis.models.SliResource":"Microsoft.Monitor.SliResource","com.azure.resourcemanager.monitor.slis.models.SpatialAggregation":"Microsoft.Monitor.SpatialAggregation","com.azure.resourcemanager.monitor.slis.models.SpatialAggregationType":"Microsoft.Monitor.SpatialAggregationType","com.azure.resourcemanager.monitor.slis.models.TemporalAggregation":"Microsoft.Monitor.TemporalAggregation","com.azure.resourcemanager.monitor.slis.models.TemporalAggregationType":"Microsoft.Monitor.TemporalAggregationType","com.azure.resourcemanager.monitor.slis.models.UserAssignedIdentity":"Azure.ResourceManager.CommonTypes.UserAssignedIdentity","com.azure.resourcemanager.monitor.slis.models.WindowUptimeCriteria":"Microsoft.Monitor.WindowUptimeCriteria","com.azure.resourcemanager.monitor.slis.models.WindowUptimeCriteriaComparator":"Microsoft.Monitor.WindowUptimeCriteriaComparator"},"generatedFiles":["src/main/java/com/azure/resourcemanager/monitor/slis/SlisManager.java","src/main/java/com/azure/resourcemanager/monitor/slis/fluent/SlisClient.java","src/main/java/com/azure/resourcemanager/monitor/slis/fluent/SlisManagementClient.java","src/main/java/com/azure/resourcemanager/monitor/slis/fluent/models/SliInner.java","src/main/java/com/azure/resourcemanager/monitor/slis/fluent/models/package-info.java","src/main/java/com/azure/resourcemanager/monitor/slis/fluent/package-info.java","src/main/java/com/azure/resourcemanager/monitor/slis/implementation/ResourceManagerUtils.java","src/main/java/com/azure/resourcemanager/monitor/slis/implementation/SliImpl.java","src/main/java/com/azure/resourcemanager/monitor/slis/implementation/SlisClientImpl.java","src/main/java/com/azure/resourcemanager/monitor/slis/implementation/SlisImpl.java","src/main/java/com/azure/resourcemanager/monitor/slis/implementation/SlisManagementClientBuilder.java","src/main/java/com/azure/resourcemanager/monitor/slis/implementation/SlisManagementClientImpl.java","src/main/java/com/azure/resourcemanager/monitor/slis/implementation/models/SliListResult.java","src/main/java/com/azure/resourcemanager/monitor/slis/implementation/package-info.java","src/main/java/com/azure/resourcemanager/monitor/slis/models/AmwAccount.java","src/main/java/com/azure/resourcemanager/monitor/slis/models/Baseline.java","src/main/java/com/azure/resourcemanager/monitor/slis/models/BaselineProperties.java","src/main/java/com/azure/resourcemanager/monitor/slis/models/Category.java","src/main/java/com/azure/resourcemanager/monitor/slis/models/Condition.java","src/main/java/com/azure/resourcemanager/monitor/slis/models/ConditionOperator.java","src/main/java/com/azure/resourcemanager/monitor/slis/models/EvaluationCalculationType.java","src/main/java/com/azure/resourcemanager/monitor/slis/models/EvaluationType.java","src/main/java/com/azure/resourcemanager/monitor/slis/models/ExecutionState.java","src/main/java/com/azure/resourcemanager/monitor/slis/models/ManagedServiceIdentity.java","src/main/java/com/azure/resourcemanager/monitor/slis/models/ManagedServiceIdentityType.java","src/main/java/com/azure/resourcemanager/monitor/slis/models/Metric.java","src/main/java/com/azure/resourcemanager/monitor/slis/models/ProvisioningState.java","src/main/java/com/azure/resourcemanager/monitor/slis/models/SamplingType.java","src/main/java/com/azure/resourcemanager/monitor/slis/models/ScalarFunction.java","src/main/java/com/azure/resourcemanager/monitor/slis/models/Signal.java","src/main/java/com/azure/resourcemanager/monitor/slis/models/SignalSource.java","src/main/java/com/azure/resourcemanager/monitor/slis/models/Sli.java","src/main/java/com/azure/resourcemanager/monitor/slis/models/SliProperties.java","src/main/java/com/azure/resourcemanager/monitor/slis/models/SliResource.java","src/main/java/com/azure/resourcemanager/monitor/slis/models/Slis.java","src/main/java/com/azure/resourcemanager/monitor/slis/models/SpatialAggregation.java","src/main/java/com/azure/resourcemanager/monitor/slis/models/SpatialAggregationType.java","src/main/java/com/azure/resourcemanager/monitor/slis/models/TemporalAggregation.java","src/main/java/com/azure/resourcemanager/monitor/slis/models/TemporalAggregationType.java","src/main/java/com/azure/resourcemanager/monitor/slis/models/UserAssignedIdentity.java","src/main/java/com/azure/resourcemanager/monitor/slis/models/WindowUptimeCriteria.java","src/main/java/com/azure/resourcemanager/monitor/slis/models/WindowUptimeCriteriaComparator.java","src/main/java/com/azure/resourcemanager/monitor/slis/models/package-info.java","src/main/java/com/azure/resourcemanager/monitor/slis/package-info.java","src/main/java/module-info.java"]} \ No newline at end of file diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-monitor-slis/proxy-config.json b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-monitor-slis/proxy-config.json new file mode 100644 index 000000000000..d7da7e9b3915 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-monitor-slis/proxy-config.json @@ -0,0 +1 @@ +[["com.azure.resourcemanager.monitor.slis.implementation.SlisClientImpl$SlisService"]] \ No newline at end of file diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-monitor-slis/reflect-config.json b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-monitor-slis/reflect-config.json new file mode 100644 index 000000000000..0637a088a01e --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-monitor-slis/reflect-config.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/resources/azure-resourcemanager-monitor-slis.properties b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/resources/azure-resourcemanager-monitor-slis.properties new file mode 100644 index 000000000000..defbd48204e4 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/resources/azure-resourcemanager-monitor-slis.properties @@ -0,0 +1 @@ +version=${project.version} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/samples/java/com/azure/resourcemanager/monitor/slis/generated/SlisCreateOrUpdateSamples.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/samples/java/com/azure/resourcemanager/monitor/slis/generated/SlisCreateOrUpdateSamples.java new file mode 100644 index 000000000000..db27ed508ffc --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/samples/java/com/azure/resourcemanager/monitor/slis/generated/SlisCreateOrUpdateSamples.java @@ -0,0 +1,89 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.generated; + +import com.azure.resourcemanager.monitor.slis.fluent.models.SliInner; +import com.azure.resourcemanager.monitor.slis.models.AmwAccount; +import com.azure.resourcemanager.monitor.slis.models.Baseline; +import com.azure.resourcemanager.monitor.slis.models.BaselineProperties; +import com.azure.resourcemanager.monitor.slis.models.Category; +import com.azure.resourcemanager.monitor.slis.models.Condition; +import com.azure.resourcemanager.monitor.slis.models.ConditionOperator; +import com.azure.resourcemanager.monitor.slis.models.EvaluationCalculationType; +import com.azure.resourcemanager.monitor.slis.models.EvaluationType; +import com.azure.resourcemanager.monitor.slis.models.Signal; +import com.azure.resourcemanager.monitor.slis.models.SignalSource; +import com.azure.resourcemanager.monitor.slis.models.SliProperties; +import com.azure.resourcemanager.monitor.slis.models.SliResource; +import com.azure.resourcemanager.monitor.slis.models.SpatialAggregation; +import com.azure.resourcemanager.monitor.slis.models.SpatialAggregationType; +import com.azure.resourcemanager.monitor.slis.models.TemporalAggregation; +import com.azure.resourcemanager.monitor.slis.models.TemporalAggregationType; +import com.azure.resourcemanager.monitor.slis.models.WindowUptimeCriteria; +import com.azure.resourcemanager.monitor.slis.models.WindowUptimeCriteriaComparator; +import java.util.Arrays; + +/** + * Samples for Slis CreateOrUpdate. + */ +public final class SlisCreateOrUpdateSamples { + /* + * x-ms-original-file: 2025-03-01-preview/Slis_CreateOrUpdate.json + */ + /** + * Sample code: CreateSli. + * + * @param manager Entry point to SlisManager. + */ + public static void createSli(com.azure.resourcemanager.monitor.slis.SlisManager manager) { + manager.slis() + .createOrUpdateWithResponse("testSG", "testSli", new SliInner().withProperties(new SliResource() + .withDescription("Measures the performance characteristics of the GetContosoUsers() API. ") + .withCategory(Category.LATENCY) + .withEvaluationType(EvaluationType.WINDOW_BASED) + .withDestinationAmwAccounts(Arrays.asList(new AmwAccount() + .withResourceId( + "/subscriptions//resourcegroups//providers/microsoft.monitor/accounts/") + .withIdentity( + "/subscriptions//resourcegroups//providers/Microsoft.ManagedIdentity/userAssignedIdentities/"))) + .withBaselineProperties(new BaselineProperties().withBaseline(new Baseline().withValue(99.0) + .withEvaluationPeriodDays(30) + .withEvaluationCalculationType(EvaluationCalculationType.CALENDAR_DAYS))) + .withEnableAlert(true) + .withSliProperties(new SliProperties().withSignals(new Signal().withSignalSources(Arrays.asList( + new SignalSource().withSignalSourceId("A") + .withSourceAmwAccountManagedIdentity( + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myIdentity") + .withSourceAmwAccountResourceId( + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/microsoft.monitor/accounts/myAccount") + .withMetricNamespace("ContosoMetricsWest") + .withMetricName("Stamp1Latency") + .withFilters(Arrays.asList(new Condition().withDimensionName("ApiName") + .withOperator(ConditionOperator.EQUAL) + .withValue("GetContosoUsers"))) + .withSpatialAggregation(new SpatialAggregation().withType(SpatialAggregationType.AVERAGE) + .withDimensions(Arrays.asList("Region", "ResponseCode"))) + .withTemporalAggregation(new TemporalAggregation().withType(TemporalAggregationType.AVERAGE) + .withWindowSizeMinutes(5)), + new SignalSource().withSignalSourceId("B") + .withSourceAmwAccountManagedIdentity( + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myIdentity") + .withSourceAmwAccountResourceId( + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/microsoft.monitor/accounts/myAccount") + .withMetricNamespace("ContosoMetricsEast") + .withMetricName("Stamp2Latency") + .withFilters(Arrays.asList(new Condition().withDimensionName("ApiName") + .withOperator(ConditionOperator.EQUAL) + .withValue("GetContosoUsers"))) + .withSpatialAggregation(new SpatialAggregation().withType(SpatialAggregationType.AVERAGE) + .withDimensions(Arrays.asList("Region", "ResponseCode"))) + .withTemporalAggregation(new TemporalAggregation().withType(TemporalAggregationType.AVERAGE) + .withWindowSizeMinutes(5)))) + .withSignalFormula("(A + B) /2")) + .withWindowUptimeCriteria(new WindowUptimeCriteria().withTarget(95.0) + .withComparator(WindowUptimeCriteriaComparator.GREATER_THAN_OR_EQUAL)))), + com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/samples/java/com/azure/resourcemanager/monitor/slis/generated/SlisDeleteSamples.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/samples/java/com/azure/resourcemanager/monitor/slis/generated/SlisDeleteSamples.java new file mode 100644 index 000000000000..211731845048 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/samples/java/com/azure/resourcemanager/monitor/slis/generated/SlisDeleteSamples.java @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.generated; + +/** + * Samples for Slis Delete. + */ +public final class SlisDeleteSamples { + /* + * x-ms-original-file: 2025-03-01-preview/Slis_Delete.json + */ + /** + * Sample code: DeleteSli. + * + * @param manager Entry point to SlisManager. + */ + public static void deleteSli(com.azure.resourcemanager.monitor.slis.SlisManager manager) { + manager.slis().deleteByResourceGroupWithResponse("testSG", "testSli", com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/samples/java/com/azure/resourcemanager/monitor/slis/generated/SlisGetSamples.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/samples/java/com/azure/resourcemanager/monitor/slis/generated/SlisGetSamples.java new file mode 100644 index 000000000000..828f4169edcc --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/samples/java/com/azure/resourcemanager/monitor/slis/generated/SlisGetSamples.java @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.generated; + +/** + * Samples for Slis Get. + */ +public final class SlisGetSamples { + /* + * x-ms-original-file: 2025-03-01-preview/Slis_Get.json + */ + /** + * Sample code: GetSli. + * + * @param manager Entry point to SlisManager. + */ + public static void getSli(com.azure.resourcemanager.monitor.slis.SlisManager manager) { + manager.slis().getWithResponse("testSG", "testSli", com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/samples/java/com/azure/resourcemanager/monitor/slis/generated/SlisListByParentSamples.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/samples/java/com/azure/resourcemanager/monitor/slis/generated/SlisListByParentSamples.java new file mode 100644 index 000000000000..bdb6397371cf --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/samples/java/com/azure/resourcemanager/monitor/slis/generated/SlisListByParentSamples.java @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.generated; + +/** + * Samples for Slis ListByParent. + */ +public final class SlisListByParentSamples { + /* + * x-ms-original-file: 2025-03-01-preview/Slis_ListByParent.json + */ + /** + * Sample code: SlisListByParent. + * + * @param manager Entry point to SlisManager. + */ + public static void slisListByParent(com.azure.resourcemanager.monitor.slis.SlisManager manager) { + manager.slis().listByParent("testSG", com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/AmwAccountTests.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/AmwAccountTests.java new file mode 100644 index 000000000000..383c615b1a13 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/AmwAccountTests.java @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.monitor.slis.models.AmwAccount; +import org.junit.jupiter.api.Assertions; + +public final class AmwAccountTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + AmwAccount model + = BinaryData.fromString("{\"resourceId\":\"mcy\",\"identity\":\"pwlbjnpg\"}").toObject(AmwAccount.class); + Assertions.assertEquals("mcy", model.resourceId()); + Assertions.assertEquals("pwlbjnpg", model.identity()); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + AmwAccount model = new AmwAccount().withResourceId("mcy").withIdentity("pwlbjnpg"); + model = BinaryData.fromObject(model).toObject(AmwAccount.class); + Assertions.assertEquals("mcy", model.resourceId()); + Assertions.assertEquals("pwlbjnpg", model.identity()); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/BaselinePropertiesTests.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/BaselinePropertiesTests.java new file mode 100644 index 000000000000..29f242b13839 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/BaselinePropertiesTests.java @@ -0,0 +1,34 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.monitor.slis.models.Baseline; +import com.azure.resourcemanager.monitor.slis.models.BaselineProperties; +import com.azure.resourcemanager.monitor.slis.models.EvaluationCalculationType; +import org.junit.jupiter.api.Assertions; + +public final class BaselinePropertiesTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + BaselineProperties model = BinaryData.fromString( + "{\"baseline\":{\"value\":42.583161707778174,\"evaluationPeriodDays\":317621756,\"evaluationCalculationType\":\"CalendarDays\"}}") + .toObject(BaselineProperties.class); + Assertions.assertEquals(42.583161707778174, model.baseline().value()); + Assertions.assertEquals(317621756, model.baseline().evaluationPeriodDays()); + Assertions.assertEquals(EvaluationCalculationType.CALENDAR_DAYS, model.baseline().evaluationCalculationType()); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + BaselineProperties model = new BaselineProperties().withBaseline(new Baseline().withValue(42.583161707778174) + .withEvaluationPeriodDays(317621756) + .withEvaluationCalculationType(EvaluationCalculationType.CALENDAR_DAYS)); + model = BinaryData.fromObject(model).toObject(BaselineProperties.class); + Assertions.assertEquals(42.583161707778174, model.baseline().value()); + Assertions.assertEquals(317621756, model.baseline().evaluationPeriodDays()); + Assertions.assertEquals(EvaluationCalculationType.CALENDAR_DAYS, model.baseline().evaluationCalculationType()); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/BaselineTests.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/BaselineTests.java new file mode 100644 index 000000000000..9a23cd179fa9 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/BaselineTests.java @@ -0,0 +1,33 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.monitor.slis.models.Baseline; +import com.azure.resourcemanager.monitor.slis.models.EvaluationCalculationType; +import org.junit.jupiter.api.Assertions; + +public final class BaselineTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + Baseline model = BinaryData.fromString( + "{\"value\":13.988969723738675,\"evaluationPeriodDays\":1696341054,\"evaluationCalculationType\":\"RollingDays\"}") + .toObject(Baseline.class); + Assertions.assertEquals(13.988969723738675, model.value()); + Assertions.assertEquals(1696341054, model.evaluationPeriodDays()); + Assertions.assertEquals(EvaluationCalculationType.ROLLING_DAYS, model.evaluationCalculationType()); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + Baseline model = new Baseline().withValue(13.988969723738675) + .withEvaluationPeriodDays(1696341054) + .withEvaluationCalculationType(EvaluationCalculationType.ROLLING_DAYS); + model = BinaryData.fromObject(model).toObject(Baseline.class); + Assertions.assertEquals(13.988969723738675, model.value()); + Assertions.assertEquals(1696341054, model.evaluationPeriodDays()); + Assertions.assertEquals(EvaluationCalculationType.ROLLING_DAYS, model.evaluationCalculationType()); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/ConditionTests.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/ConditionTests.java new file mode 100644 index 000000000000..57a17e5ab01c --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/ConditionTests.java @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.monitor.slis.models.Condition; +import com.azure.resourcemanager.monitor.slis.models.ConditionOperator; +import com.azure.resourcemanager.monitor.slis.models.SamplingType; +import com.azure.resourcemanager.monitor.slis.models.ScalarFunction; +import org.junit.jupiter.api.Assertions; + +public final class ConditionTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + Condition model = BinaryData.fromString( + "{\"dimensionName\":\"fssxqukkfplg\",\"scalarFunction\":\"sum\",\"samplingType\":\"sum\",\"operator\":\"!startswith\",\"value\":\"jzkdeslpvlopwi\"}") + .toObject(Condition.class); + Assertions.assertEquals("fssxqukkfplg", model.dimensionName()); + Assertions.assertEquals(ScalarFunction.SUM, model.scalarFunction()); + Assertions.assertEquals(SamplingType.SUM, model.samplingType()); + Assertions.assertEquals(ConditionOperator.NOT_STARTS_WITH, model.operator()); + Assertions.assertEquals("jzkdeslpvlopwi", model.value()); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + Condition model = new Condition().withDimensionName("fssxqukkfplg") + .withScalarFunction(ScalarFunction.SUM) + .withSamplingType(SamplingType.SUM) + .withOperator(ConditionOperator.NOT_STARTS_WITH) + .withValue("jzkdeslpvlopwi"); + model = BinaryData.fromObject(model).toObject(Condition.class); + Assertions.assertEquals("fssxqukkfplg", model.dimensionName()); + Assertions.assertEquals(ScalarFunction.SUM, model.scalarFunction()); + Assertions.assertEquals(SamplingType.SUM, model.samplingType()); + Assertions.assertEquals(ConditionOperator.NOT_STARTS_WITH, model.operator()); + Assertions.assertEquals("jzkdeslpvlopwi", model.value()); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/ExecutionStateTests.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/ExecutionStateTests.java new file mode 100644 index 000000000000..0745d247f989 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/ExecutionStateTests.java @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.monitor.slis.models.ExecutionState; +import org.junit.jupiter.api.Assertions; + +public final class ExecutionStateTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + ExecutionState model + = BinaryData.fromString("{\"state\":\"v\",\"message\":\"dgwdslfhot\"}").toObject(ExecutionState.class); + Assertions.assertEquals("v", model.state()); + Assertions.assertEquals("dgwdslfhot", model.message()); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/ManagedServiceIdentityTests.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/ManagedServiceIdentityTests.java new file mode 100644 index 000000000000..d3c956994582 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/ManagedServiceIdentityTests.java @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.monitor.slis.models.ManagedServiceIdentity; +import com.azure.resourcemanager.monitor.slis.models.ManagedServiceIdentityType; +import com.azure.resourcemanager.monitor.slis.models.UserAssignedIdentity; +import java.util.HashMap; +import java.util.Map; +import org.junit.jupiter.api.Assertions; + +public final class ManagedServiceIdentityTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + ManagedServiceIdentity model = BinaryData.fromString( + "{\"principalId\":\"m\",\"tenantId\":\"qupedeojnab\",\"type\":\"UserAssigned\",\"userAssignedIdentities\":{\"krdqmh\":{\"principalId\":\"txp\",\"clientId\":\"ebtfhvpesap\"},\"scwsv\":{\"principalId\":\"dhtldwkyz\",\"clientId\":\"utknc\"},\"kvceoveilovnotyf\":{\"principalId\":\"otogtwrupqs\",\"clientId\":\"nmic\"}}}") + .toObject(ManagedServiceIdentity.class); + Assertions.assertEquals(ManagedServiceIdentityType.USER_ASSIGNED, model.type()); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + ManagedServiceIdentity model = new ManagedServiceIdentity().withType(ManagedServiceIdentityType.USER_ASSIGNED) + .withUserAssignedIdentities(mapOf("krdqmh", new UserAssignedIdentity(), "scwsv", new UserAssignedIdentity(), + "kvceoveilovnotyf", new UserAssignedIdentity())); + model = BinaryData.fromObject(model).toObject(ManagedServiceIdentity.class); + Assertions.assertEquals(ManagedServiceIdentityType.USER_ASSIGNED, model.type()); + } + + // Use "Map.of" if available + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/MetricTests.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/MetricTests.java new file mode 100644 index 000000000000..4ceee66c431a --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/MetricTests.java @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.monitor.slis.models.Metric; +import org.junit.jupiter.api.Assertions; + +public final class MetricTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + Metric model = BinaryData.fromString("{\"metricNamespace\":\"cftadeh\",\"metricName\":\"nltyfsoppusuesnz\"}") + .toObject(Metric.class); + Assertions.assertEquals("cftadeh", model.metricNamespace()); + Assertions.assertEquals("nltyfsoppusuesnz", model.metricName()); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/SignalSourceTests.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/SignalSourceTests.java new file mode 100644 index 000000000000..ba53ada72045 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/SignalSourceTests.java @@ -0,0 +1,74 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.monitor.slis.models.Condition; +import com.azure.resourcemanager.monitor.slis.models.ConditionOperator; +import com.azure.resourcemanager.monitor.slis.models.SamplingType; +import com.azure.resourcemanager.monitor.slis.models.ScalarFunction; +import com.azure.resourcemanager.monitor.slis.models.SignalSource; +import com.azure.resourcemanager.monitor.slis.models.SpatialAggregation; +import com.azure.resourcemanager.monitor.slis.models.SpatialAggregationType; +import com.azure.resourcemanager.monitor.slis.models.TemporalAggregation; +import com.azure.resourcemanager.monitor.slis.models.TemporalAggregationType; +import java.util.Arrays; +import org.junit.jupiter.api.Assertions; + +public final class SignalSourceTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + SignalSource model = BinaryData.fromString( + "{\"signalSourceId\":\"bxu\",\"sourceAmwAccountManagedIdentity\":\"wbhqwal\",\"sourceAmwAccountResourceId\":\"uzyoxaep\",\"metricNamespace\":\"kzjancuxrhdwbav\",\"metricName\":\"bniwdj\",\"filters\":[{\"dimensionName\":\"tsdbpgn\",\"scalarFunction\":\"max\",\"samplingType\":\"avg\",\"operator\":\"!in\",\"value\":\"zxbzpfzabglc\"}],\"spatialAggregation\":{\"type\":\"Average\",\"dimensions\":[\"wtctyqi\",\"lbbovplw\",\"bhvgy\",\"gu\"]},\"temporalAggregation\":{\"type\":\"Delta\",\"windowSizeMinutes\":1732351990}}") + .toObject(SignalSource.class); + Assertions.assertEquals("bxu", model.signalSourceId()); + Assertions.assertEquals("wbhqwal", model.sourceAmwAccountManagedIdentity()); + Assertions.assertEquals("uzyoxaep", model.sourceAmwAccountResourceId()); + Assertions.assertEquals("kzjancuxrhdwbav", model.metricNamespace()); + Assertions.assertEquals("bniwdj", model.metricName()); + Assertions.assertEquals("tsdbpgn", model.filters().get(0).dimensionName()); + Assertions.assertEquals(ScalarFunction.MAX, model.filters().get(0).scalarFunction()); + Assertions.assertEquals(SamplingType.AVG, model.filters().get(0).samplingType()); + Assertions.assertEquals(ConditionOperator.NOT_IN, model.filters().get(0).operator()); + Assertions.assertEquals("zxbzpfzabglc", model.filters().get(0).value()); + Assertions.assertEquals(SpatialAggregationType.AVERAGE, model.spatialAggregation().type()); + Assertions.assertEquals("wtctyqi", model.spatialAggregation().dimensions().get(0)); + Assertions.assertEquals(TemporalAggregationType.DELTA, model.temporalAggregation().type()); + Assertions.assertEquals(1732351990, model.temporalAggregation().windowSizeMinutes()); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + SignalSource model = new SignalSource().withSignalSourceId("bxu") + .withSourceAmwAccountManagedIdentity("wbhqwal") + .withSourceAmwAccountResourceId("uzyoxaep") + .withMetricNamespace("kzjancuxrhdwbav") + .withMetricName("bniwdj") + .withFilters(Arrays.asList(new Condition().withDimensionName("tsdbpgn") + .withScalarFunction(ScalarFunction.MAX) + .withSamplingType(SamplingType.AVG) + .withOperator(ConditionOperator.NOT_IN) + .withValue("zxbzpfzabglc"))) + .withSpatialAggregation(new SpatialAggregation().withType(SpatialAggregationType.AVERAGE) + .withDimensions(Arrays.asList("wtctyqi", "lbbovplw", "bhvgy", "gu"))) + .withTemporalAggregation( + new TemporalAggregation().withType(TemporalAggregationType.DELTA).withWindowSizeMinutes(1732351990)); + model = BinaryData.fromObject(model).toObject(SignalSource.class); + Assertions.assertEquals("bxu", model.signalSourceId()); + Assertions.assertEquals("wbhqwal", model.sourceAmwAccountManagedIdentity()); + Assertions.assertEquals("uzyoxaep", model.sourceAmwAccountResourceId()); + Assertions.assertEquals("kzjancuxrhdwbav", model.metricNamespace()); + Assertions.assertEquals("bniwdj", model.metricName()); + Assertions.assertEquals("tsdbpgn", model.filters().get(0).dimensionName()); + Assertions.assertEquals(ScalarFunction.MAX, model.filters().get(0).scalarFunction()); + Assertions.assertEquals(SamplingType.AVG, model.filters().get(0).samplingType()); + Assertions.assertEquals(ConditionOperator.NOT_IN, model.filters().get(0).operator()); + Assertions.assertEquals("zxbzpfzabglc", model.filters().get(0).value()); + Assertions.assertEquals(SpatialAggregationType.AVERAGE, model.spatialAggregation().type()); + Assertions.assertEquals("wtctyqi", model.spatialAggregation().dimensions().get(0)); + Assertions.assertEquals(TemporalAggregationType.DELTA, model.temporalAggregation().type()); + Assertions.assertEquals(1732351990, model.temporalAggregation().windowSizeMinutes()); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/SignalTests.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/SignalTests.java new file mode 100644 index 000000000000..4f768ffca48a --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/SignalTests.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.resourcemanager.monitor.slis.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.monitor.slis.models.Condition; +import com.azure.resourcemanager.monitor.slis.models.ConditionOperator; +import com.azure.resourcemanager.monitor.slis.models.SamplingType; +import com.azure.resourcemanager.monitor.slis.models.ScalarFunction; +import com.azure.resourcemanager.monitor.slis.models.Signal; +import com.azure.resourcemanager.monitor.slis.models.SignalSource; +import com.azure.resourcemanager.monitor.slis.models.SpatialAggregation; +import com.azure.resourcemanager.monitor.slis.models.SpatialAggregationType; +import com.azure.resourcemanager.monitor.slis.models.TemporalAggregation; +import com.azure.resourcemanager.monitor.slis.models.TemporalAggregationType; +import java.util.Arrays; +import org.junit.jupiter.api.Assertions; + +public final class SignalTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + Signal model = BinaryData.fromString( + "{\"signalSources\":[{\"signalSourceId\":\"jhtxfvgxbfsmxne\",\"sourceAmwAccountManagedIdentity\":\"mpvecxgodebfqk\",\"sourceAmwAccountResourceId\":\"rbmpukgri\",\"metricNamespace\":\"flz\",\"metricName\":\"fbxzpuzycisp\",\"filters\":[{\"dimensionName\":\"ahmgkbrp\",\"scalarFunction\":\"min\",\"samplingType\":\"avg\",\"operator\":\"startswith\",\"value\":\"nuqqkpikadrgvt\"},{\"dimensionName\":\"gnbuy\",\"scalarFunction\":\"avg\",\"samplingType\":\"max\",\"operator\":\"contains\",\"value\":\"mebf\"},{\"dimensionName\":\"arbu\",\"scalarFunction\":\"sum\",\"samplingType\":\"min\",\"operator\":\"!contains\",\"value\":\"azzmhjrunmpxt\"}],\"spatialAggregation\":{\"type\":\"Sum\",\"dimensions\":[\"hrbnlankxmyskpbh\"]},\"temporalAggregation\":{\"type\":\"Sum\",\"windowSizeMinutes\":1326044907}},{\"signalSourceId\":\"kcxywnyt\",\"sourceAmwAccountManagedIdentity\":\"rsyn\",\"sourceAmwAccountResourceId\":\"qidybyx\",\"metricNamespace\":\"zfcl\",\"metricName\":\"aaxdbabphlwrq\",\"filters\":[{\"dimensionName\":\"tsthsucocm\",\"scalarFunction\":\"sum\",\"samplingType\":\"max\",\"operator\":\"!=\",\"value\":\"t\"}],\"spatialAggregation\":{\"type\":\"Count\",\"dimensions\":[\"wrqpue\"]},\"temporalAggregation\":{\"type\":\"Max\",\"windowSizeMinutes\":1618897040}}],\"signalFormula\":\"ywbiexzfeyueax\"}") + .toObject(Signal.class); + Assertions.assertEquals("jhtxfvgxbfsmxne", model.signalSources().get(0).signalSourceId()); + Assertions.assertEquals("mpvecxgodebfqk", model.signalSources().get(0).sourceAmwAccountManagedIdentity()); + Assertions.assertEquals("rbmpukgri", model.signalSources().get(0).sourceAmwAccountResourceId()); + Assertions.assertEquals("flz", model.signalSources().get(0).metricNamespace()); + Assertions.assertEquals("fbxzpuzycisp", model.signalSources().get(0).metricName()); + Assertions.assertEquals("ahmgkbrp", model.signalSources().get(0).filters().get(0).dimensionName()); + Assertions.assertEquals(ScalarFunction.MIN, model.signalSources().get(0).filters().get(0).scalarFunction()); + Assertions.assertEquals(SamplingType.AVG, model.signalSources().get(0).filters().get(0).samplingType()); + Assertions.assertEquals(ConditionOperator.STARTS_WITH, + model.signalSources().get(0).filters().get(0).operator()); + Assertions.assertEquals("nuqqkpikadrgvt", model.signalSources().get(0).filters().get(0).value()); + Assertions.assertEquals(SpatialAggregationType.SUM, model.signalSources().get(0).spatialAggregation().type()); + Assertions.assertEquals("hrbnlankxmyskpbh", + model.signalSources().get(0).spatialAggregation().dimensions().get(0)); + Assertions.assertEquals(TemporalAggregationType.SUM, model.signalSources().get(0).temporalAggregation().type()); + Assertions.assertEquals(1326044907, model.signalSources().get(0).temporalAggregation().windowSizeMinutes()); + Assertions.assertEquals("ywbiexzfeyueax", model.signalFormula()); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + Signal model = new Signal().withSignalSources(Arrays.asList( + new SignalSource().withSignalSourceId("jhtxfvgxbfsmxne") + .withSourceAmwAccountManagedIdentity("mpvecxgodebfqk") + .withSourceAmwAccountResourceId("rbmpukgri") + .withMetricNamespace("flz") + .withMetricName("fbxzpuzycisp") + .withFilters(Arrays.asList( + new Condition().withDimensionName("ahmgkbrp") + .withScalarFunction(ScalarFunction.MIN) + .withSamplingType(SamplingType.AVG) + .withOperator(ConditionOperator.STARTS_WITH) + .withValue("nuqqkpikadrgvt"), + new Condition().withDimensionName("gnbuy") + .withScalarFunction(ScalarFunction.AVG) + .withSamplingType(SamplingType.MAX) + .withOperator(ConditionOperator.CONTAINS) + .withValue("mebf"), + new Condition().withDimensionName("arbu") + .withScalarFunction(ScalarFunction.SUM) + .withSamplingType(SamplingType.MIN) + .withOperator(ConditionOperator.NOT_CONTAINS) + .withValue("azzmhjrunmpxt"))) + .withSpatialAggregation(new SpatialAggregation().withType(SpatialAggregationType.SUM) + .withDimensions(Arrays.asList("hrbnlankxmyskpbh"))) + .withTemporalAggregation( + new TemporalAggregation().withType(TemporalAggregationType.SUM).withWindowSizeMinutes(1326044907)), + new SignalSource().withSignalSourceId("kcxywnyt") + .withSourceAmwAccountManagedIdentity("rsyn") + .withSourceAmwAccountResourceId("qidybyx") + .withMetricNamespace("zfcl") + .withMetricName("aaxdbabphlwrq") + .withFilters(Arrays.asList(new Condition().withDimensionName("tsthsucocm") + .withScalarFunction(ScalarFunction.SUM) + .withSamplingType(SamplingType.MAX) + .withOperator(ConditionOperator.NOT_EQUAL) + .withValue("t"))) + .withSpatialAggregation(new SpatialAggregation().withType(SpatialAggregationType.COUNT) + .withDimensions(Arrays.asList("wrqpue"))) + .withTemporalAggregation( + new TemporalAggregation().withType(TemporalAggregationType.MAX).withWindowSizeMinutes(1618897040)))) + .withSignalFormula("ywbiexzfeyueax"); + model = BinaryData.fromObject(model).toObject(Signal.class); + Assertions.assertEquals("jhtxfvgxbfsmxne", model.signalSources().get(0).signalSourceId()); + Assertions.assertEquals("mpvecxgodebfqk", model.signalSources().get(0).sourceAmwAccountManagedIdentity()); + Assertions.assertEquals("rbmpukgri", model.signalSources().get(0).sourceAmwAccountResourceId()); + Assertions.assertEquals("flz", model.signalSources().get(0).metricNamespace()); + Assertions.assertEquals("fbxzpuzycisp", model.signalSources().get(0).metricName()); + Assertions.assertEquals("ahmgkbrp", model.signalSources().get(0).filters().get(0).dimensionName()); + Assertions.assertEquals(ScalarFunction.MIN, model.signalSources().get(0).filters().get(0).scalarFunction()); + Assertions.assertEquals(SamplingType.AVG, model.signalSources().get(0).filters().get(0).samplingType()); + Assertions.assertEquals(ConditionOperator.STARTS_WITH, + model.signalSources().get(0).filters().get(0).operator()); + Assertions.assertEquals("nuqqkpikadrgvt", model.signalSources().get(0).filters().get(0).value()); + Assertions.assertEquals(SpatialAggregationType.SUM, model.signalSources().get(0).spatialAggregation().type()); + Assertions.assertEquals("hrbnlankxmyskpbh", + model.signalSources().get(0).spatialAggregation().dimensions().get(0)); + Assertions.assertEquals(TemporalAggregationType.SUM, model.signalSources().get(0).temporalAggregation().type()); + Assertions.assertEquals(1326044907, model.signalSources().get(0).temporalAggregation().windowSizeMinutes()); + Assertions.assertEquals("ywbiexzfeyueax", model.signalFormula()); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/SliInnerTests.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/SliInnerTests.java new file mode 100644 index 000000000000..77e756bd3111 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/SliInnerTests.java @@ -0,0 +1,390 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.monitor.slis.fluent.models.SliInner; +import com.azure.resourcemanager.monitor.slis.models.AmwAccount; +import com.azure.resourcemanager.monitor.slis.models.Baseline; +import com.azure.resourcemanager.monitor.slis.models.BaselineProperties; +import com.azure.resourcemanager.monitor.slis.models.Category; +import com.azure.resourcemanager.monitor.slis.models.Condition; +import com.azure.resourcemanager.monitor.slis.models.ConditionOperator; +import com.azure.resourcemanager.monitor.slis.models.EvaluationCalculationType; +import com.azure.resourcemanager.monitor.slis.models.EvaluationType; +import com.azure.resourcemanager.monitor.slis.models.ManagedServiceIdentity; +import com.azure.resourcemanager.monitor.slis.models.ManagedServiceIdentityType; +import com.azure.resourcemanager.monitor.slis.models.Signal; +import com.azure.resourcemanager.monitor.slis.models.SignalSource; +import com.azure.resourcemanager.monitor.slis.models.SliProperties; +import com.azure.resourcemanager.monitor.slis.models.SliResource; +import com.azure.resourcemanager.monitor.slis.models.SpatialAggregation; +import com.azure.resourcemanager.monitor.slis.models.SpatialAggregationType; +import com.azure.resourcemanager.monitor.slis.models.TemporalAggregation; +import com.azure.resourcemanager.monitor.slis.models.TemporalAggregationType; +import com.azure.resourcemanager.monitor.slis.models.UserAssignedIdentity; +import com.azure.resourcemanager.monitor.slis.models.WindowUptimeCriteria; +import com.azure.resourcemanager.monitor.slis.models.WindowUptimeCriteriaComparator; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import org.junit.jupiter.api.Assertions; + +public final class SliInnerTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + SliInner model = BinaryData.fromString( + "{\"properties\":{\"provisioningState\":\"Succeeded\",\"description\":\"quvgjxpybczme\",\"category\":\"Availability\",\"evaluationType\":\"RequestBased\",\"executionState\":{\"state\":\"opb\",\"message\":\"h\"},\"destinationAmwAccounts\":[{\"resourceId\":\"pidgsybbejhphoyc\",\"identity\":\"sx\"}],\"destinationMetrics\":[{\"metricNamespace\":\"hdxbmtqio\",\"metricName\":\"jzehtb\"},{\"metricNamespace\":\"ufpo\",\"metricName\":\"noi\"}],\"baselineProperties\":{\"baseline\":{\"value\":28.301840077728546,\"evaluationPeriodDays\":4771592,\"evaluationCalculationType\":\"CalendarDays\"}},\"streamingRuleId\":\"ybqsoqijg\",\"streamingRuleLastUpdatedTimestamp\":\"2021-10-01T09:23:29Z\",\"enableAlert\":true,\"sliProperties\":{\"goodSignals\":{\"signalSources\":[{\"signalSourceId\":\"zlobcufpd\",\"sourceAmwAccountManagedIdentity\":\"nrbtcqqjnq\",\"sourceAmwAccountResourceId\":\"lhqgnufooojy\",\"metricNamespace\":\"ifsqesaagdfmg\",\"metricName\":\"zlhjxrifkwmrvkt\",\"filters\":[{\"operator\":\"<\",\"value\":\"nt\"},{\"operator\":\"==\",\"value\":\"ipa\"},{\"operator\":\"startswith\",\"value\":\"ajpsquc\"}],\"spatialAggregation\":{\"type\":\"Max\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Rate\"}},{\"signalSourceId\":\"yf\",\"sourceAmwAccountManagedIdentity\":\"kfo\",\"sourceAmwAccountResourceId\":\"knygjofjddeq\",\"metricNamespace\":\"rd\",\"metricName\":\"upewnwreitjzy\",\"filters\":[{\"operator\":\"!contains\",\"value\":\"sarhmofc\"},{\"operator\":\">\",\"value\":\"smy\"}],\"spatialAggregation\":{\"type\":\"Count\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Average\"}},{\"signalSourceId\":\"dtmlxhekuksjt\",\"sourceAmwAccountManagedIdentity\":\"ukcdmparcryuanzw\",\"sourceAmwAccountResourceId\":\"xzdxtayrlhmwh\",\"metricNamespace\":\"pmrqobm\",\"metricName\":\"u\",\"filters\":[{\"operator\":\"startswith\",\"value\":\"ryrtihfxtijbpzv\"},{\"operator\":\">\",\"value\":\"wzsymglzufcy\"},{\"operator\":\"!startswith\",\"value\":\"ohdbihanufh\"},{\"operator\":\"!contains\",\"value\":\"bj\"}],\"spatialAggregation\":{\"type\":\"Count\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Min\"}},{\"signalSourceId\":\"git\",\"sourceAmwAccountManagedIdentity\":\"xqhabi\",\"sourceAmwAccountResourceId\":\"pikxwczbyscnpqxu\",\"metricNamespace\":\"ivyqniwbybrkxvd\",\"metricName\":\"mjgr\",\"filters\":[{\"operator\":\"!in\",\"value\":\"vukxgau\"},{\"operator\":\"!in\",\"value\":\"cs\"}],\"spatialAggregation\":{\"type\":\"Min\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Max\"}}],\"signalFormula\":\"jcny\"},\"totalSignals\":{\"signalSources\":[{\"signalSourceId\":\"kryhtnapczwlokj\",\"sourceAmwAccountManagedIdentity\":\"emkkvnipjox\",\"sourceAmwAccountResourceId\":\"jnchgej\",\"metricNamespace\":\"podmailzydehojwy\",\"metricName\":\"huxinpmqnj\",\"filters\":[{\"operator\":\"@in\",\"value\":\"ixjsprozvcputeg\"},{\"operator\":\"!=\",\"value\":\"wmfdatscmdvpjhul\"},{\"operator\":\"<\",\"value\":\"uvm\"}],\"spatialAggregation\":{\"type\":\"Sum\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Average\"}},{\"signalSourceId\":\"zkrwfn\",\"sourceAmwAccountManagedIdentity\":\"iodjp\",\"sourceAmwAccountResourceId\":\"lwejdpv\",\"metricNamespace\":\"ryo\",\"metricName\":\"psoacctazakljl\",\"filters\":[{\"operator\":\"!=\",\"value\":\"cr\"},{\"operator\":\"==\",\"value\":\"fdfdosygexpa\"},{\"operator\":\"startswith\",\"value\":\"akhmsbzjhcrz\"},{\"operator\":\">\",\"value\":\"dphlxaolt\"}],\"spatialAggregation\":{\"type\":\"Max\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Sum\"}}],\"signalFormula\":\"rgqjbpfzfsinzg\"},\"signals\":{\"signalSources\":[{\"signalSourceId\":\"jrwzox\",\"sourceAmwAccountManagedIdentity\":\"j\",\"sourceAmwAccountResourceId\":\"felluwfzitonpe\",\"metricNamespace\":\"fpjkjlxofp\",\"metricName\":\"vhpfxxypininmay\",\"filters\":[{\"operator\":\">\",\"value\":\"bbkpodep\"},{\"operator\":\">\",\"value\":\"ginuvamih\"},{\"operator\":\"contains\",\"value\":\"gnarxzxtheo\"}],\"spatialAggregation\":{\"type\":\"Count\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Sum\"}},{\"signalSourceId\":\"ivyevcciqihnhun\",\"sourceAmwAccountManagedIdentity\":\"bwjzr\",\"sourceAmwAccountResourceId\":\"fygxgispemvtzfk\",\"metricNamespace\":\"fublj\",\"metricName\":\"fxqeof\",\"filters\":[{\"operator\":\">\",\"value\":\"qjhqjbas\"},{\"operator\":\"!in\",\"value\":\"smjqulngsntnbyb\"},{\"operator\":\"contains\",\"value\":\"gc\"},{\"operator\":\"contains\",\"value\":\"wclxxwrl\"}],\"spatialAggregation\":{\"type\":\"Average\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Rate\"}},{\"signalSourceId\":\"uskcqvkocrcj\",\"sourceAmwAccountManagedIdentity\":\"kwt\",\"sourceAmwAccountResourceId\":\"hxbnjbiksqrg\",\"metricNamespace\":\"ssainqpjwnzll\",\"metricName\":\"fmppe\",\"filters\":[{\"operator\":\"!in\",\"value\":\"mgxsab\"},{\"operator\":\"<\",\"value\":\"qduujitcjczdz\"},{\"operator\":\"@in\",\"value\":\"ndhkrw\"},{\"operator\":\"<=\",\"value\":\"appd\"}],\"spatialAggregation\":{\"type\":\"Average\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Average\"}},{\"signalSourceId\":\"kvwrwjfeu\",\"sourceAmwAccountManagedIdentity\":\"nhutjeltmrldhugj\",\"sourceAmwAccountResourceId\":\"zdatqxhocdg\",\"metricNamespace\":\"ablgphuticndvk\",\"metricName\":\"ozwyiftyhxhuro\",\"filters\":[{\"operator\":\"!startswith\",\"value\":\"yxolniwp\"},{\"operator\":\"==\",\"value\":\"ukjfkgiawxklr\"},{\"operator\":\"@in\",\"value\":\"lwckbasyypnddhs\"}],\"spatialAggregation\":{\"type\":\"Max\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Delta\"}}],\"signalFormula\":\"acphejkoty\"},\"windowUptimeCriteria\":{\"target\":17.641552819912953,\"comparator\":\"<=\"}}},\"identity\":{\"principalId\":\"ndlik\",\"tenantId\":\"qkgfgibma\",\"type\":\"SystemAssigned\",\"userAssignedIdentities\":{\"kzsmodm\":{\"principalId\":\"qsrxybzqqed\",\"clientId\":\"tbciqfouflmm\"},\"umkdosvqwhbmd\":{\"principalId\":\"ougpbkwt\",\"clientId\":\"tduqktapspwgcuer\"},\"q\":{\"principalId\":\"bjf\",\"clientId\":\"gmbmbexppbh\"},\"igjyjg\":{\"principalId\":\"ol\",\"clientId\":\"fpsalgbqu\"}}},\"id\":\"aoyfhrtxilnerkuj\",\"name\":\"s\",\"type\":\"l\"}") + .toObject(SliInner.class); + Assertions.assertEquals("quvgjxpybczme", model.properties().description()); + Assertions.assertEquals(Category.AVAILABILITY, model.properties().category()); + Assertions.assertEquals(EvaluationType.REQUEST_BASED, model.properties().evaluationType()); + Assertions.assertEquals("pidgsybbejhphoyc", model.properties().destinationAmwAccounts().get(0).resourceId()); + Assertions.assertEquals("sx", model.properties().destinationAmwAccounts().get(0).identity()); + Assertions.assertEquals(28.301840077728546, model.properties().baselineProperties().baseline().value()); + Assertions.assertEquals(4771592, model.properties().baselineProperties().baseline().evaluationPeriodDays()); + Assertions.assertEquals(EvaluationCalculationType.CALENDAR_DAYS, + model.properties().baselineProperties().baseline().evaluationCalculationType()); + Assertions.assertTrue(model.properties().enableAlert()); + Assertions.assertEquals("zlobcufpd", + model.properties().sliProperties().goodSignals().signalSources().get(0).signalSourceId()); + Assertions.assertEquals("nrbtcqqjnq", + model.properties().sliProperties().goodSignals().signalSources().get(0).sourceAmwAccountManagedIdentity()); + Assertions.assertEquals("lhqgnufooojy", + model.properties().sliProperties().goodSignals().signalSources().get(0).sourceAmwAccountResourceId()); + Assertions.assertEquals("ifsqesaagdfmg", + model.properties().sliProperties().goodSignals().signalSources().get(0).metricNamespace()); + Assertions.assertEquals("zlhjxrifkwmrvkt", + model.properties().sliProperties().goodSignals().signalSources().get(0).metricName()); + Assertions.assertEquals(ConditionOperator.LESS_THAN, + model.properties().sliProperties().goodSignals().signalSources().get(0).filters().get(0).operator()); + Assertions.assertEquals("nt", + model.properties().sliProperties().goodSignals().signalSources().get(0).filters().get(0).value()); + Assertions.assertEquals(SpatialAggregationType.MAX, + model.properties().sliProperties().goodSignals().signalSources().get(0).spatialAggregation().type()); + Assertions.assertEquals(TemporalAggregationType.RATE, + model.properties().sliProperties().goodSignals().signalSources().get(0).temporalAggregation().type()); + Assertions.assertEquals("jcny", model.properties().sliProperties().goodSignals().signalFormula()); + Assertions.assertEquals("kryhtnapczwlokj", + model.properties().sliProperties().totalSignals().signalSources().get(0).signalSourceId()); + Assertions.assertEquals("emkkvnipjox", + model.properties().sliProperties().totalSignals().signalSources().get(0).sourceAmwAccountManagedIdentity()); + Assertions.assertEquals("jnchgej", + model.properties().sliProperties().totalSignals().signalSources().get(0).sourceAmwAccountResourceId()); + Assertions.assertEquals("podmailzydehojwy", + model.properties().sliProperties().totalSignals().signalSources().get(0).metricNamespace()); + Assertions.assertEquals("huxinpmqnj", + model.properties().sliProperties().totalSignals().signalSources().get(0).metricName()); + Assertions.assertEquals(ConditionOperator.IN, + model.properties().sliProperties().totalSignals().signalSources().get(0).filters().get(0).operator()); + Assertions.assertEquals("ixjsprozvcputeg", + model.properties().sliProperties().totalSignals().signalSources().get(0).filters().get(0).value()); + Assertions.assertEquals(SpatialAggregationType.SUM, + model.properties().sliProperties().totalSignals().signalSources().get(0).spatialAggregation().type()); + Assertions.assertEquals(TemporalAggregationType.AVERAGE, + model.properties().sliProperties().totalSignals().signalSources().get(0).temporalAggregation().type()); + Assertions.assertEquals("rgqjbpfzfsinzg", model.properties().sliProperties().totalSignals().signalFormula()); + Assertions.assertEquals("jrwzox", + model.properties().sliProperties().signals().signalSources().get(0).signalSourceId()); + Assertions.assertEquals("j", + model.properties().sliProperties().signals().signalSources().get(0).sourceAmwAccountManagedIdentity()); + Assertions.assertEquals("felluwfzitonpe", + model.properties().sliProperties().signals().signalSources().get(0).sourceAmwAccountResourceId()); + Assertions.assertEquals("fpjkjlxofp", + model.properties().sliProperties().signals().signalSources().get(0).metricNamespace()); + Assertions.assertEquals("vhpfxxypininmay", + model.properties().sliProperties().signals().signalSources().get(0).metricName()); + Assertions.assertEquals(ConditionOperator.GREATER_THAN, + model.properties().sliProperties().signals().signalSources().get(0).filters().get(0).operator()); + Assertions.assertEquals("bbkpodep", + model.properties().sliProperties().signals().signalSources().get(0).filters().get(0).value()); + Assertions.assertEquals(SpatialAggregationType.COUNT, + model.properties().sliProperties().signals().signalSources().get(0).spatialAggregation().type()); + Assertions.assertEquals(TemporalAggregationType.SUM, + model.properties().sliProperties().signals().signalSources().get(0).temporalAggregation().type()); + Assertions.assertEquals("acphejkoty", model.properties().sliProperties().signals().signalFormula()); + Assertions.assertEquals(17.641552819912953, model.properties().sliProperties().windowUptimeCriteria().target()); + Assertions.assertEquals(WindowUptimeCriteriaComparator.LESS_THAN_OR_EQUAL, + model.properties().sliProperties().windowUptimeCriteria().comparator()); + Assertions.assertEquals(ManagedServiceIdentityType.SYSTEM_ASSIGNED, model.identity().type()); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + SliInner model + = new SliInner() + .withProperties(new SliResource().withDescription("quvgjxpybczme") + .withCategory(Category.AVAILABILITY) + .withEvaluationType(EvaluationType.REQUEST_BASED) + .withDestinationAmwAccounts( + Arrays.asList(new AmwAccount().withResourceId("pidgsybbejhphoyc").withIdentity("sx"))) + .withBaselineProperties( + new BaselineProperties().withBaseline(new Baseline().withValue(28.301840077728546) + .withEvaluationPeriodDays(4771592) + .withEvaluationCalculationType(EvaluationCalculationType.CALENDAR_DAYS))) + .withEnableAlert(true) + .withSliProperties(new SliProperties() + .withGoodSignals(new Signal() + .withSignalSources(Arrays.asList( + new SignalSource().withSignalSourceId("zlobcufpd") + .withSourceAmwAccountManagedIdentity("nrbtcqqjnq") + .withSourceAmwAccountResourceId("lhqgnufooojy") + .withMetricNamespace("ifsqesaagdfmg") + .withMetricName("zlhjxrifkwmrvkt") + .withFilters(Arrays.asList( + new Condition().withOperator(ConditionOperator.LESS_THAN).withValue("nt"), + new Condition().withOperator(ConditionOperator.EQUAL).withValue("ipa"), + new Condition() + .withOperator(ConditionOperator.STARTS_WITH) + .withValue("ajpsquc"))) + .withSpatialAggregation( + new SpatialAggregation().withType(SpatialAggregationType.MAX) + .withDimensions(Arrays.asList())) + .withTemporalAggregation( + new TemporalAggregation().withType(TemporalAggregationType.RATE)), + new SignalSource().withSignalSourceId("yf") + .withSourceAmwAccountManagedIdentity("kfo") + .withSourceAmwAccountResourceId("knygjofjddeq") + .withMetricNamespace("rd") + .withMetricName("upewnwreitjzy") + .withFilters(Arrays.asList( + new Condition() + .withOperator(ConditionOperator.NOT_CONTAINS) + .withValue("sarhmofc"), + new Condition().withOperator(ConditionOperator.GREATER_THAN).withValue("smy"))) + .withSpatialAggregation( + new SpatialAggregation().withType(SpatialAggregationType.COUNT) + .withDimensions(Arrays.asList())) + .withTemporalAggregation( + new TemporalAggregation().withType(TemporalAggregationType.AVERAGE)), + new SignalSource().withSignalSourceId("dtmlxhekuksjt") + .withSourceAmwAccountManagedIdentity("ukcdmparcryuanzw") + .withSourceAmwAccountResourceId("xzdxtayrlhmwh") + .withMetricNamespace("pmrqobm") + .withMetricName("u") + .withFilters(Arrays.asList( + new Condition().withOperator(ConditionOperator.STARTS_WITH) + .withValue("ryrtihfxtijbpzv"), + new Condition().withOperator(ConditionOperator.GREATER_THAN) + .withValue("wzsymglzufcy"), + new Condition().withOperator(ConditionOperator.NOT_STARTS_WITH) + .withValue("ohdbihanufh"), + new Condition().withOperator(ConditionOperator.NOT_CONTAINS).withValue("bj"))) + .withSpatialAggregation( + new SpatialAggregation().withType(SpatialAggregationType.COUNT) + .withDimensions(Arrays.asList())) + .withTemporalAggregation( + new TemporalAggregation().withType(TemporalAggregationType.MIN)), + new SignalSource().withSignalSourceId("git") + .withSourceAmwAccountManagedIdentity("xqhabi") + .withSourceAmwAccountResourceId("pikxwczbyscnpqxu") + .withMetricNamespace("ivyqniwbybrkxvd") + .withMetricName("mjgr") + .withFilters(Arrays.asList( + new Condition().withOperator(ConditionOperator.NOT_IN).withValue("vukxgau"), + new Condition().withOperator(ConditionOperator.NOT_IN).withValue("cs"))) + .withSpatialAggregation( + new SpatialAggregation().withType(SpatialAggregationType.MIN) + .withDimensions(Arrays.asList())) + .withTemporalAggregation( + new TemporalAggregation().withType(TemporalAggregationType.MAX)))) + .withSignalFormula("jcny")) + .withTotalSignals(new Signal() + .withSignalSources(Arrays.asList( + new SignalSource().withSignalSourceId("kryhtnapczwlokj") + .withSourceAmwAccountManagedIdentity("emkkvnipjox") + .withSourceAmwAccountResourceId("jnchgej") + .withMetricNamespace("podmailzydehojwy") + .withMetricName("huxinpmqnj") + .withFilters(Arrays.asList( + new Condition().withOperator(ConditionOperator.IN).withValue("ixjsprozvcputeg"), + new Condition() + .withOperator(ConditionOperator.NOT_EQUAL) + .withValue("wmfdatscmdvpjhul"), + new Condition().withOperator(ConditionOperator.LESS_THAN).withValue("uvm"))) + .withSpatialAggregation(new SpatialAggregation() + .withType(SpatialAggregationType.SUM) + .withDimensions(Arrays.asList())) + .withTemporalAggregation( + new TemporalAggregation().withType(TemporalAggregationType.AVERAGE)), + new SignalSource().withSignalSourceId("zkrwfn") + .withSourceAmwAccountManagedIdentity("iodjp") + .withSourceAmwAccountResourceId("lwejdpv") + .withMetricNamespace("ryo") + .withMetricName("psoacctazakljl") + .withFilters(Arrays.asList( + new Condition().withOperator(ConditionOperator.NOT_EQUAL).withValue("cr"), + new Condition().withOperator(ConditionOperator.EQUAL).withValue("fdfdosygexpa"), + new Condition().withOperator(ConditionOperator.STARTS_WITH) + .withValue("akhmsbzjhcrz"), + new Condition().withOperator(ConditionOperator.GREATER_THAN) + .withValue("dphlxaolt"))) + .withSpatialAggregation( + new SpatialAggregation().withType(SpatialAggregationType.MAX) + .withDimensions(Arrays.asList())) + .withTemporalAggregation( + new TemporalAggregation().withType(TemporalAggregationType.SUM)))) + .withSignalFormula("rgqjbpfzfsinzg")) + .withSignals(new Signal() + .withSignalSources(Arrays.asList(new SignalSource().withSignalSourceId("jrwzox") + .withSourceAmwAccountManagedIdentity("j") + .withSourceAmwAccountResourceId("felluwfzitonpe") + .withMetricNamespace("fpjkjlxofp") + .withMetricName("vhpfxxypininmay") + .withFilters(Arrays.asList( + new Condition().withOperator(ConditionOperator.GREATER_THAN).withValue("bbkpodep"), + new Condition().withOperator(ConditionOperator.GREATER_THAN).withValue("ginuvamih"), + new Condition().withOperator(ConditionOperator.CONTAINS).withValue("gnarxzxtheo"))) + .withSpatialAggregation(new SpatialAggregation() + .withType(SpatialAggregationType.COUNT) + .withDimensions(Arrays.asList())) + .withTemporalAggregation( + new TemporalAggregation().withType(TemporalAggregationType.SUM)), + new SignalSource().withSignalSourceId("ivyevcciqihnhun") + .withSourceAmwAccountManagedIdentity("bwjzr") + .withSourceAmwAccountResourceId("fygxgispemvtzfk") + .withMetricNamespace("fublj") + .withMetricName("fxqeof") + .withFilters(Arrays.asList(new Condition() + .withOperator(ConditionOperator.GREATER_THAN) + .withValue("qjhqjbas"), + new Condition().withOperator(ConditionOperator.NOT_IN) + .withValue("smjqulngsntnbyb"), + new Condition().withOperator(ConditionOperator.CONTAINS).withValue("gc"), + new Condition().withOperator(ConditionOperator.CONTAINS).withValue("wclxxwrl"))) + .withSpatialAggregation( + new SpatialAggregation().withType(SpatialAggregationType.AVERAGE) + .withDimensions(Arrays.asList())) + .withTemporalAggregation( + new TemporalAggregation().withType(TemporalAggregationType.RATE)), + new SignalSource().withSignalSourceId("uskcqvkocrcj") + .withSourceAmwAccountManagedIdentity("kwt") + .withSourceAmwAccountResourceId("hxbnjbiksqrg") + .withMetricNamespace("ssainqpjwnzll") + .withMetricName("fmppe") + .withFilters(Arrays.asList( + new Condition().withOperator(ConditionOperator.NOT_IN).withValue("mgxsab"), + new Condition().withOperator(ConditionOperator.LESS_THAN) + .withValue("qduujitcjczdz"), + new Condition().withOperator(ConditionOperator.IN).withValue("ndhkrw"), + new Condition() + .withOperator(ConditionOperator.LESS_THAN_OR_EQUAL) + .withValue("appd"))) + .withSpatialAggregation( + new SpatialAggregation().withType(SpatialAggregationType.AVERAGE) + .withDimensions(Arrays.asList())) + .withTemporalAggregation( + new TemporalAggregation().withType(TemporalAggregationType.AVERAGE)), + new SignalSource().withSignalSourceId("kvwrwjfeu") + .withSourceAmwAccountManagedIdentity("nhutjeltmrldhugj") + .withSourceAmwAccountResourceId("zdatqxhocdg") + .withMetricNamespace("ablgphuticndvk") + .withMetricName("ozwyiftyhxhuro") + .withFilters(Arrays.asList(new Condition() + .withOperator(ConditionOperator.NOT_STARTS_WITH) + .withValue("yxolniwp"), + new Condition() + .withOperator(ConditionOperator.EQUAL) + .withValue("ukjfkgiawxklr"), + new Condition().withOperator(ConditionOperator.IN) + .withValue("lwckbasyypnddhs"))) + .withSpatialAggregation( + new SpatialAggregation().withType(SpatialAggregationType.MAX) + .withDimensions(Arrays.asList())) + .withTemporalAggregation( + new TemporalAggregation().withType(TemporalAggregationType.DELTA)))) + .withSignalFormula("acphejkoty")) + .withWindowUptimeCriteria(new WindowUptimeCriteria().withTarget(17.641552819912953) + .withComparator(WindowUptimeCriteriaComparator.LESS_THAN_OR_EQUAL)))) + .withIdentity(new ManagedServiceIdentity().withType(ManagedServiceIdentityType.SYSTEM_ASSIGNED) + .withUserAssignedIdentities( + mapOf("kzsmodm", new UserAssignedIdentity(), "umkdosvqwhbmd", new UserAssignedIdentity(), "q", + new UserAssignedIdentity(), "igjyjg", new UserAssignedIdentity()))); + model = BinaryData.fromObject(model).toObject(SliInner.class); + Assertions.assertEquals("quvgjxpybczme", model.properties().description()); + Assertions.assertEquals(Category.AVAILABILITY, model.properties().category()); + Assertions.assertEquals(EvaluationType.REQUEST_BASED, model.properties().evaluationType()); + Assertions.assertEquals("pidgsybbejhphoyc", model.properties().destinationAmwAccounts().get(0).resourceId()); + Assertions.assertEquals("sx", model.properties().destinationAmwAccounts().get(0).identity()); + Assertions.assertEquals(28.301840077728546, model.properties().baselineProperties().baseline().value()); + Assertions.assertEquals(4771592, model.properties().baselineProperties().baseline().evaluationPeriodDays()); + Assertions.assertEquals(EvaluationCalculationType.CALENDAR_DAYS, + model.properties().baselineProperties().baseline().evaluationCalculationType()); + Assertions.assertTrue(model.properties().enableAlert()); + Assertions.assertEquals("zlobcufpd", + model.properties().sliProperties().goodSignals().signalSources().get(0).signalSourceId()); + Assertions.assertEquals("nrbtcqqjnq", + model.properties().sliProperties().goodSignals().signalSources().get(0).sourceAmwAccountManagedIdentity()); + Assertions.assertEquals("lhqgnufooojy", + model.properties().sliProperties().goodSignals().signalSources().get(0).sourceAmwAccountResourceId()); + Assertions.assertEquals("ifsqesaagdfmg", + model.properties().sliProperties().goodSignals().signalSources().get(0).metricNamespace()); + Assertions.assertEquals("zlhjxrifkwmrvkt", + model.properties().sliProperties().goodSignals().signalSources().get(0).metricName()); + Assertions.assertEquals(ConditionOperator.LESS_THAN, + model.properties().sliProperties().goodSignals().signalSources().get(0).filters().get(0).operator()); + Assertions.assertEquals("nt", + model.properties().sliProperties().goodSignals().signalSources().get(0).filters().get(0).value()); + Assertions.assertEquals(SpatialAggregationType.MAX, + model.properties().sliProperties().goodSignals().signalSources().get(0).spatialAggregation().type()); + Assertions.assertEquals(TemporalAggregationType.RATE, + model.properties().sliProperties().goodSignals().signalSources().get(0).temporalAggregation().type()); + Assertions.assertEquals("jcny", model.properties().sliProperties().goodSignals().signalFormula()); + Assertions.assertEquals("kryhtnapczwlokj", + model.properties().sliProperties().totalSignals().signalSources().get(0).signalSourceId()); + Assertions.assertEquals("emkkvnipjox", + model.properties().sliProperties().totalSignals().signalSources().get(0).sourceAmwAccountManagedIdentity()); + Assertions.assertEquals("jnchgej", + model.properties().sliProperties().totalSignals().signalSources().get(0).sourceAmwAccountResourceId()); + Assertions.assertEquals("podmailzydehojwy", + model.properties().sliProperties().totalSignals().signalSources().get(0).metricNamespace()); + Assertions.assertEquals("huxinpmqnj", + model.properties().sliProperties().totalSignals().signalSources().get(0).metricName()); + Assertions.assertEquals(ConditionOperator.IN, + model.properties().sliProperties().totalSignals().signalSources().get(0).filters().get(0).operator()); + Assertions.assertEquals("ixjsprozvcputeg", + model.properties().sliProperties().totalSignals().signalSources().get(0).filters().get(0).value()); + Assertions.assertEquals(SpatialAggregationType.SUM, + model.properties().sliProperties().totalSignals().signalSources().get(0).spatialAggregation().type()); + Assertions.assertEquals(TemporalAggregationType.AVERAGE, + model.properties().sliProperties().totalSignals().signalSources().get(0).temporalAggregation().type()); + Assertions.assertEquals("rgqjbpfzfsinzg", model.properties().sliProperties().totalSignals().signalFormula()); + Assertions.assertEquals("jrwzox", + model.properties().sliProperties().signals().signalSources().get(0).signalSourceId()); + Assertions.assertEquals("j", + model.properties().sliProperties().signals().signalSources().get(0).sourceAmwAccountManagedIdentity()); + Assertions.assertEquals("felluwfzitonpe", + model.properties().sliProperties().signals().signalSources().get(0).sourceAmwAccountResourceId()); + Assertions.assertEquals("fpjkjlxofp", + model.properties().sliProperties().signals().signalSources().get(0).metricNamespace()); + Assertions.assertEquals("vhpfxxypininmay", + model.properties().sliProperties().signals().signalSources().get(0).metricName()); + Assertions.assertEquals(ConditionOperator.GREATER_THAN, + model.properties().sliProperties().signals().signalSources().get(0).filters().get(0).operator()); + Assertions.assertEquals("bbkpodep", + model.properties().sliProperties().signals().signalSources().get(0).filters().get(0).value()); + Assertions.assertEquals(SpatialAggregationType.COUNT, + model.properties().sliProperties().signals().signalSources().get(0).spatialAggregation().type()); + Assertions.assertEquals(TemporalAggregationType.SUM, + model.properties().sliProperties().signals().signalSources().get(0).temporalAggregation().type()); + Assertions.assertEquals("acphejkoty", model.properties().sliProperties().signals().signalFormula()); + Assertions.assertEquals(17.641552819912953, model.properties().sliProperties().windowUptimeCriteria().target()); + Assertions.assertEquals(WindowUptimeCriteriaComparator.LESS_THAN_OR_EQUAL, + model.properties().sliProperties().windowUptimeCriteria().comparator()); + Assertions.assertEquals(ManagedServiceIdentityType.SYSTEM_ASSIGNED, model.identity().type()); + } + + // Use "Map.of" if available + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/SliListResultTests.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/SliListResultTests.java new file mode 100644 index 000000000000..a01ad30e0e61 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/SliListResultTests.java @@ -0,0 +1,182 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.monitor.slis.implementation.models.SliListResult; +import com.azure.resourcemanager.monitor.slis.models.Category; +import com.azure.resourcemanager.monitor.slis.models.EvaluationCalculationType; +import com.azure.resourcemanager.monitor.slis.models.EvaluationType; +import com.azure.resourcemanager.monitor.slis.models.ManagedServiceIdentityType; +import com.azure.resourcemanager.monitor.slis.models.SpatialAggregationType; +import com.azure.resourcemanager.monitor.slis.models.TemporalAggregationType; +import com.azure.resourcemanager.monitor.slis.models.WindowUptimeCriteriaComparator; +import org.junit.jupiter.api.Assertions; + +public final class SliListResultTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + SliListResult model = BinaryData.fromString( + "{\"value\":[{\"properties\":{\"provisioningState\":\"Failed\",\"description\":\"rmclfplphoxu\",\"category\":\"Availability\",\"evaluationType\":\"WindowBased\",\"executionState\":{\"state\":\"abgy\",\"message\":\"sbj\"},\"destinationAmwAccounts\":[{\"resourceId\":\"zq\",\"identity\":\"gxywpmue\"},{\"resourceId\":\"fjz\",\"identity\":\"fqkquj\"},{\"resourceId\":\"dsuyonobgla\",\"identity\":\"cq\"},{\"resourceId\":\"tcc\",\"identity\":\"g\"}],\"destinationMetrics\":[{\"metricNamespace\":\"xy\",\"metricName\":\"lmoyrx\"}],\"baselineProperties\":{\"baseline\":{\"value\":91.75911917706165,\"evaluationPeriodDays\":76468143,\"evaluationCalculationType\":\"CalendarDays\"}},\"streamingRuleId\":\"pz\",\"streamingRuleLastUpdatedTimestamp\":\"2021-05-21T05:23:51Z\",\"enableAlert\":false,\"sliProperties\":{\"goodSignals\":{\"signalSources\":[{\"signalSourceId\":\"hl\",\"sourceAmwAccountManagedIdentity\":\"qj\",\"sourceAmwAccountResourceId\":\"hckfrlhrx\",\"metricNamespace\":\"bkyvp\",\"metricName\":\"ca\",\"filters\":[],\"spatialAggregation\":{\"type\":\"Min\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Sum\"}},{\"signalSourceId\":\"bpzkafkuwbc\",\"sourceAmwAccountManagedIdentity\":\"nwbmeh\",\"sourceAmwAccountResourceId\":\"seyvj\",\"metricNamespace\":\"srtslhspkdeem\",\"metricName\":\"ofmxagkvtmelmqkr\",\"filters\":[],\"spatialAggregation\":{\"type\":\"Min\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Delta\"}}],\"signalFormula\":\"vljua\"},\"totalSignals\":{\"signalSources\":[{\"signalSourceId\":\"uhcdhm\",\"sourceAmwAccountManagedIdentity\":\"ualaexqpvfadmw\",\"sourceAmwAccountResourceId\":\"rcrgvx\",\"metricNamespace\":\"vgomz\",\"metricName\":\"fmisg\",\"filters\":[],\"spatialAggregation\":{\"type\":\"Min\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Increase\"}},{\"signalSourceId\":\"b\",\"sourceAmwAccountManagedIdentity\":\"e\",\"sourceAmwAccountResourceId\":\"dawkzbali\",\"metricNamespace\":\"urqhaka\",\"metricName\":\"hashsfwxosow\",\"filters\":[],\"spatialAggregation\":{\"type\":\"Min\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Max\"}},{\"signalSourceId\":\"ugicjooxdjebw\",\"sourceAmwAccountManagedIdentity\":\"ucww\",\"sourceAmwAccountResourceId\":\"vo\",\"metricNamespace\":\"bvmeuecivy\",\"metricName\":\"zceuojgjrw\",\"filters\":[],\"spatialAggregation\":{\"type\":\"Min\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Min\"}}],\"signalFormula\":\"iotwmcdytdxwit\"},\"signals\":{\"signalSources\":[{\"signalSourceId\":\"jawgqwg\",\"sourceAmwAccountManagedIdentity\":\"hniskxfbkpyc\",\"sourceAmwAccountResourceId\":\"klwndnhjdauwhv\",\"metricNamespace\":\"l\",\"metricName\":\"zbtd\",\"filters\":[],\"spatialAggregation\":{\"type\":\"Max\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Max\"}}],\"signalFormula\":\"jznb\"},\"windowUptimeCriteria\":{\"target\":6.623657803570204,\"comparator\":\">\"}}},\"identity\":{\"principalId\":\"rzqlveu\",\"tenantId\":\"upjm\",\"type\":\"SystemAssigned,UserAssigned\",\"userAssignedIdentities\":{\"xzvlvqhjkbegib\":{\"principalId\":\"bbcswsrtjri\",\"clientId\":\"rbpbewtghfgblcg\"},\"tzjuzgwyzmhtxo\":{\"principalId\":\"mxiebw\",\"clientId\":\"loayqcgw\"},\"rwmdyvxqtay\":{\"principalId\":\"mtsavjcbpwxqp\",\"clientId\":\"knftguvriuh\"}}},\"id\":\"ww\",\"name\":\"oyq\",\"type\":\"exrmcqibycnojvk\"},{\"properties\":{\"provisioningState\":\"Succeeded\",\"description\":\"qsgzvahapj\",\"category\":\"Latency\",\"evaluationType\":\"WindowBased\",\"executionState\":{\"state\":\"vgqzcjrvxd\",\"message\":\"lmwlxkvugfhzo\"},\"destinationAmwAccounts\":[{\"resourceId\":\"wjvzunluthnn\",\"identity\":\"rnxipei\"},{\"resourceId\":\"pjzu\",\"identity\":\"e\"},{\"resourceId\":\"xdult\",\"identity\":\"kzbbtd\"},{\"resourceId\":\"umveekgpwozuhkf\",\"identity\":\"bsjyofdx\"}],\"destinationMetrics\":[{\"metricNamespace\":\"sd\",\"metricName\":\"touwaboekqv\"}],\"baselineProperties\":{\"baseline\":{\"value\":52.428353050864814,\"evaluationPeriodDays\":109250802,\"evaluationCalculationType\":\"CalendarDays\"}},\"streamingRuleId\":\"vbxwyjsflhh\",\"streamingRuleLastUpdatedTimestamp\":\"2020-12-20T13:53:44Z\",\"enableAlert\":true,\"sliProperties\":{\"goodSignals\":{\"signalSources\":[{\"signalSourceId\":\"ixisxyawjoy\",\"sourceAmwAccountManagedIdentity\":\"qcslyjpkiid\",\"sourceAmwAccountResourceId\":\"yexz\",\"metricNamespace\":\"eli\",\"metricName\":\"hnrztfol\",\"filters\":[],\"spatialAggregation\":{\"type\":\"Max\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"IDelta\"}},{\"signalSourceId\":\"xknalaulppg\",\"sourceAmwAccountManagedIdentity\":\"dtpnapnyiropuhp\",\"sourceAmwAccountResourceId\":\"gvpgy\",\"metricNamespace\":\"gqgitxmedjvcsl\",\"metricName\":\"n\",\"filters\":[],\"spatialAggregation\":{\"type\":\"Average\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"IDelta\"}},{\"signalSourceId\":\"ncw\",\"sourceAmwAccountManagedIdentity\":\"zhxgktrmgucn\",\"sourceAmwAccountResourceId\":\"pkteo\",\"metricNamespace\":\"llwptfdy\",\"metricName\":\"pfqbuaceopzf\",\"filters\":[],\"spatialAggregation\":{\"type\":\"Count\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Delta\"}},{\"signalSourceId\":\"huaoppp\",\"sourceAmwAccountManagedIdentity\":\"qeqxo\",\"sourceAmwAccountResourceId\":\"z\",\"metricNamespace\":\"ahzxctobgbk\",\"metricName\":\"moizpos\",\"filters\":[],\"spatialAggregation\":{\"type\":\"Max\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Max\"}}],\"signalFormula\":\"rcfbunrm\"},\"totalSignals\":{\"signalSources\":[{\"signalSourceId\":\"hhkxbp\",\"sourceAmwAccountManagedIdentity\":\"jy\",\"sourceAmwAccountResourceId\":\"jhxxjyn\",\"metricNamespace\":\"u\",\"metricName\":\"ivkrtsw\",\"filters\":[],\"spatialAggregation\":{\"type\":\"Min\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Max\"}},{\"signalSourceId\":\"zvszj\",\"sourceAmwAccountManagedIdentity\":\"auvjfdxxivet\",\"sourceAmwAccountResourceId\":\"t\",\"metricNamespace\":\"qaqtdoqmcbxvwvxy\",\"metricName\":\"lqbhsf\",\"filters\":[],\"spatialAggregation\":{\"type\":\"Max\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Max\"}}],\"signalFormula\":\"lyt\"},\"signals\":{\"signalSources\":[{\"signalSourceId\":\"mpew\",\"sourceAmwAccountManagedIdentity\":\"wfbkrvrns\",\"sourceAmwAccountResourceId\":\"shqjohxcrsbf\",\"metricNamespace\":\"vasrruvwb\",\"metricName\":\"sqfsubcgjbirxb\",\"filters\":[],\"spatialAggregation\":{\"type\":\"Average\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"IDelta\"}},{\"signalSourceId\":\"srfbjfdtwss\",\"sourceAmwAccountManagedIdentity\":\"t\",\"sourceAmwAccountResourceId\":\"tpvjzbexilzznfqq\",\"metricNamespace\":\"vwpm\",\"metricName\":\"taruoujmkcj\",\"filters\":[],\"spatialAggregation\":{\"type\":\"Min\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Increase\"}},{\"signalSourceId\":\"ytjrybnwjewgdr\",\"sourceAmwAccountManagedIdentity\":\"ervnaenqpehi\",\"sourceAmwAccountResourceId\":\"doy\",\"metricNamespace\":\"mifthnzdnd\",\"metricName\":\"l\",\"filters\":[],\"spatialAggregation\":{\"type\":\"Average\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"IRate\"}}],\"signalFormula\":\"yq\"},\"windowUptimeCriteria\":{\"target\":36.90142308535591,\"comparator\":\"<=\"}}},\"identity\":{\"principalId\":\"avhqlkth\",\"tenantId\":\"aqolbgycduiertg\",\"type\":\"None\",\"userAssignedIdentities\":{\"lzpswiydm\":{\"principalId\":\"aolps\",\"clientId\":\"qlfmmdnbb\"},\"dbzm\":{\"principalId\":\"yhz\",\"clientId\":\"ss\"}}},\"id\":\"dfznudaodv\",\"name\":\"zbn\",\"type\":\"blylpstdbh\"},{\"properties\":{\"provisioningState\":\"Canceled\",\"description\":\"zdzucerscdntnevf\",\"category\":\"Availability\",\"evaluationType\":\"RequestBased\",\"executionState\":{\"state\":\"ygtdsslswt\",\"message\":\"eriofzpyqs\"},\"destinationAmwAccounts\":[{\"resourceId\":\"wab\",\"identity\":\"ets\"},{\"resourceId\":\"hszhedplvwiwu\",\"identity\":\"mwmbes\"},{\"resourceId\":\"dnkwwtppjflcxog\",\"identity\":\"okonzmnsikvmkqz\"},{\"resourceId\":\"qqkdltfzxmhhvhgu\",\"identity\":\"eodkwobda\"}],\"destinationMetrics\":[{\"metricNamespace\":\"ibqdxbxwakbogqx\",\"metricName\":\"dlkzgxhuri\"},{\"metricNamespace\":\"lbpodxunk\",\"metricName\":\"ebxmubyynt\"},{\"metricNamespace\":\"lrb\",\"metricName\":\"tkoievseotgq\"}],\"baselineProperties\":{\"baseline\":{\"value\":4.886296094520515,\"evaluationPeriodDays\":407342571,\"evaluationCalculationType\":\"RollingDays\"}},\"streamingRuleId\":\"wlauwzizxbmpg\",\"streamingRuleLastUpdatedTimestamp\":\"2021-07-24T09:20:41Z\",\"enableAlert\":true,\"sliProperties\":{\"goodSignals\":{\"signalSources\":[{\"signalSourceId\":\"muvp\",\"sourceAmwAccountManagedIdentity\":\"ttdumorppxebmnzb\",\"sourceAmwAccountResourceId\":\"bhjpglkfgohdne\",\"metricNamespace\":\"el\",\"metricName\":\"phsdyhto\",\"filters\":[],\"spatialAggregation\":{\"type\":\"Count\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Increase\"}},{\"signalSourceId\":\"kd\",\"sourceAmwAccountManagedIdentity\":\"wwquuvxzxclvithh\",\"sourceAmwAccountResourceId\":\"zonosgg\",\"metricNamespace\":\"hcohfwdsjnk\",\"metricName\":\"ljuti\",\"filters\":[],\"spatialAggregation\":{\"type\":\"Min\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Rate\"}},{\"signalSourceId\":\"acffgdkzzewkfvhq\",\"sourceAmwAccountManagedIdentity\":\"railvpnppfuf\",\"sourceAmwAccountResourceId\":\"rwdmhdlxyjrxsa\",\"metricNamespace\":\"afcnih\",\"metricName\":\"wqapnedgfbcvk\",\"filters\":[],\"spatialAggregation\":{\"type\":\"Count\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Rate\"}},{\"signalSourceId\":\"vpk\",\"sourceAmwAccountManagedIdentity\":\"qdcvdrhvoo\",\"sourceAmwAccountResourceId\":\"sotbob\",\"metricNamespace\":\"dopcjwvnh\",\"metricName\":\"ld\",\"filters\":[],\"spatialAggregation\":{\"type\":\"Average\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Sum\"}}],\"signalFormula\":\"xcxrsl\"},\"totalSignals\":{\"signalSources\":[{\"signalSourceId\":\"twuoegrpkhjwni\",\"sourceAmwAccountManagedIdentity\":\"qsluicp\",\"sourceAmwAccountResourceId\":\"ggkzzlvmbmpa\",\"metricNamespace\":\"modfvuefywsbpfvm\",\"metricName\":\"yhrfouyftaakcpw\",\"filters\":[],\"spatialAggregation\":{\"type\":\"Min\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Rate\"}}],\"signalFormula\":\"vqtmnub\"},\"signals\":{\"signalSources\":[{\"signalSourceId\":\"pzk\",\"sourceAmwAccountManagedIdentity\":\"mond\",\"sourceAmwAccountResourceId\":\"mquxvypo\",\"metricNamespace\":\"gkopkwhojvpajqgx\",\"metricName\":\"smocmbq\",\"filters\":[],\"spatialAggregation\":{\"type\":\"Average\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Average\"}},{\"signalSourceId\":\"mkcxozapvh\",\"sourceAmwAccountManagedIdentity\":\"lxprglyatddckcbc\",\"sourceAmwAccountResourceId\":\"ejrjxgciqibrho\",\"metricNamespace\":\"xsdqrhzoymibmrqy\",\"metricName\":\"bahwfl\",\"filters\":[],\"spatialAggregation\":{\"type\":\"Max\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Delta\"}},{\"signalSourceId\":\"dtmhrkwofyyvoqa\",\"sourceAmwAccountManagedIdentity\":\"piexpbtgiw\",\"sourceAmwAccountResourceId\":\"wo\",\"metricNamespace\":\"nwashrtd\",\"metricName\":\"kcnqxwbpo\",\"filters\":[],\"spatialAggregation\":{\"type\":\"Average\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Average\"}}],\"signalFormula\":\"pi\"},\"windowUptimeCriteria\":{\"target\":37.028919775226754,\"comparator\":\">\"}}},\"identity\":{\"principalId\":\"pqiiobyuqe\",\"tenantId\":\"qlpqwcciuq\",\"type\":\"UserAssigned\",\"userAssignedIdentities\":{\"mhykojoxafnndl\":{\"principalId\":\"t\",\"clientId\":\"vfbtkuwh\"},\"ovljxywsu\":{\"principalId\":\"chkoymkcdyh\",\"clientId\":\"kkpwdreqnovvq\"}}},\"id\":\"yrs\",\"name\":\"dsytgadgvr\",\"type\":\"ea\"}],\"nextLink\":\"e\"}") + .toObject(SliListResult.class); + Assertions.assertEquals("rmclfplphoxu", model.value().get(0).properties().description()); + Assertions.assertEquals(Category.AVAILABILITY, model.value().get(0).properties().category()); + Assertions.assertEquals(EvaluationType.WINDOW_BASED, model.value().get(0).properties().evaluationType()); + Assertions.assertEquals("zq", model.value().get(0).properties().destinationAmwAccounts().get(0).resourceId()); + Assertions.assertEquals("gxywpmue", + model.value().get(0).properties().destinationAmwAccounts().get(0).identity()); + Assertions.assertEquals(91.75911917706165, + model.value().get(0).properties().baselineProperties().baseline().value()); + Assertions.assertEquals(76468143, + model.value().get(0).properties().baselineProperties().baseline().evaluationPeriodDays()); + Assertions.assertEquals(EvaluationCalculationType.CALENDAR_DAYS, + model.value().get(0).properties().baselineProperties().baseline().evaluationCalculationType()); + Assertions.assertFalse(model.value().get(0).properties().enableAlert()); + Assertions.assertEquals("hl", + model.value().get(0).properties().sliProperties().goodSignals().signalSources().get(0).signalSourceId()); + Assertions.assertEquals("qj", + model.value() + .get(0) + .properties() + .sliProperties() + .goodSignals() + .signalSources() + .get(0) + .sourceAmwAccountManagedIdentity()); + Assertions.assertEquals("hckfrlhrx", + model.value() + .get(0) + .properties() + .sliProperties() + .goodSignals() + .signalSources() + .get(0) + .sourceAmwAccountResourceId()); + Assertions.assertEquals("bkyvp", + model.value().get(0).properties().sliProperties().goodSignals().signalSources().get(0).metricNamespace()); + Assertions.assertEquals("ca", + model.value().get(0).properties().sliProperties().goodSignals().signalSources().get(0).metricName()); + Assertions.assertEquals(SpatialAggregationType.MIN, + model.value() + .get(0) + .properties() + .sliProperties() + .goodSignals() + .signalSources() + .get(0) + .spatialAggregation() + .type()); + Assertions.assertEquals(TemporalAggregationType.SUM, + model.value() + .get(0) + .properties() + .sliProperties() + .goodSignals() + .signalSources() + .get(0) + .temporalAggregation() + .type()); + Assertions.assertEquals("vljua", + model.value().get(0).properties().sliProperties().goodSignals().signalFormula()); + Assertions.assertEquals("uhcdhm", + model.value().get(0).properties().sliProperties().totalSignals().signalSources().get(0).signalSourceId()); + Assertions.assertEquals("ualaexqpvfadmw", + model.value() + .get(0) + .properties() + .sliProperties() + .totalSignals() + .signalSources() + .get(0) + .sourceAmwAccountManagedIdentity()); + Assertions.assertEquals("rcrgvx", + model.value() + .get(0) + .properties() + .sliProperties() + .totalSignals() + .signalSources() + .get(0) + .sourceAmwAccountResourceId()); + Assertions.assertEquals("vgomz", + model.value().get(0).properties().sliProperties().totalSignals().signalSources().get(0).metricNamespace()); + Assertions.assertEquals("fmisg", + model.value().get(0).properties().sliProperties().totalSignals().signalSources().get(0).metricName()); + Assertions.assertEquals(SpatialAggregationType.MIN, + model.value() + .get(0) + .properties() + .sliProperties() + .totalSignals() + .signalSources() + .get(0) + .spatialAggregation() + .type()); + Assertions.assertEquals(TemporalAggregationType.INCREASE, + model.value() + .get(0) + .properties() + .sliProperties() + .totalSignals() + .signalSources() + .get(0) + .temporalAggregation() + .type()); + Assertions.assertEquals("iotwmcdytdxwit", + model.value().get(0).properties().sliProperties().totalSignals().signalFormula()); + Assertions.assertEquals("jawgqwg", + model.value().get(0).properties().sliProperties().signals().signalSources().get(0).signalSourceId()); + Assertions.assertEquals("hniskxfbkpyc", + model.value() + .get(0) + .properties() + .sliProperties() + .signals() + .signalSources() + .get(0) + .sourceAmwAccountManagedIdentity()); + Assertions.assertEquals("klwndnhjdauwhv", + model.value() + .get(0) + .properties() + .sliProperties() + .signals() + .signalSources() + .get(0) + .sourceAmwAccountResourceId()); + Assertions.assertEquals("l", + model.value().get(0).properties().sliProperties().signals().signalSources().get(0).metricNamespace()); + Assertions.assertEquals("zbtd", + model.value().get(0).properties().sliProperties().signals().signalSources().get(0).metricName()); + Assertions.assertEquals(SpatialAggregationType.MAX, + model.value() + .get(0) + .properties() + .sliProperties() + .signals() + .signalSources() + .get(0) + .spatialAggregation() + .type()); + Assertions.assertEquals(TemporalAggregationType.MAX, + model.value() + .get(0) + .properties() + .sliProperties() + .signals() + .signalSources() + .get(0) + .temporalAggregation() + .type()); + Assertions.assertEquals("jznb", model.value().get(0).properties().sliProperties().signals().signalFormula()); + Assertions.assertEquals(6.623657803570204, + model.value().get(0).properties().sliProperties().windowUptimeCriteria().target()); + Assertions.assertEquals(WindowUptimeCriteriaComparator.GREATER_THAN, + model.value().get(0).properties().sliProperties().windowUptimeCriteria().comparator()); + Assertions.assertEquals(ManagedServiceIdentityType.SYSTEM_ASSIGNED_USER_ASSIGNED, + model.value().get(0).identity().type()); + Assertions.assertEquals("e", model.nextLink()); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/SliPropertiesTests.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/SliPropertiesTests.java new file mode 100644 index 000000000000..b421dd41e8b3 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/SliPropertiesTests.java @@ -0,0 +1,319 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.monitor.slis.models.Condition; +import com.azure.resourcemanager.monitor.slis.models.ConditionOperator; +import com.azure.resourcemanager.monitor.slis.models.SamplingType; +import com.azure.resourcemanager.monitor.slis.models.ScalarFunction; +import com.azure.resourcemanager.monitor.slis.models.Signal; +import com.azure.resourcemanager.monitor.slis.models.SignalSource; +import com.azure.resourcemanager.monitor.slis.models.SliProperties; +import com.azure.resourcemanager.monitor.slis.models.SpatialAggregation; +import com.azure.resourcemanager.monitor.slis.models.SpatialAggregationType; +import com.azure.resourcemanager.monitor.slis.models.TemporalAggregation; +import com.azure.resourcemanager.monitor.slis.models.TemporalAggregationType; +import com.azure.resourcemanager.monitor.slis.models.WindowUptimeCriteria; +import com.azure.resourcemanager.monitor.slis.models.WindowUptimeCriteriaComparator; +import java.util.Arrays; +import org.junit.jupiter.api.Assertions; + +public final class SliPropertiesTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + SliProperties model = BinaryData.fromString( + "{\"goodSignals\":{\"signalSources\":[{\"signalSourceId\":\"dmoh\",\"sourceAmwAccountManagedIdentity\":\"tbqvudw\",\"sourceAmwAccountResourceId\":\"dndnvow\",\"metricNamespace\":\"ujjugwdkcglh\",\"metricName\":\"lazjdyggdtjixhbk\",\"filters\":[{\"dimensionName\":\"qweykhmenev\",\"scalarFunction\":\"min\",\"samplingType\":\"avg\",\"operator\":\"!contains\",\"value\":\"hybcibv\"},{\"dimensionName\":\"dcsi\",\"scalarFunction\":\"sum\",\"samplingType\":\"min\",\"operator\":\"startswith\",\"value\":\"mdectehfiqscjey\"},{\"dimensionName\":\"hezrkgq\",\"scalarFunction\":\"sum\",\"samplingType\":\"min\",\"operator\":\">\",\"value\":\"o\"},{\"dimensionName\":\"mkqsleyyv\",\"scalarFunction\":\"sum\",\"samplingType\":\"max\",\"operator\":\"<=\",\"value\":\"cattpngjcrcczsq\"}],\"spatialAggregation\":{\"type\":\"Min\",\"dimensions\":[\"vmdajvnysou\",\"q\",\"canoaeupf\",\"yhltrpmopjmcm\"]},\"temporalAggregation\":{\"type\":\"IDelta\",\"windowSizeMinutes\":860799201}},{\"signalSourceId\":\"kthfui\",\"sourceAmwAccountManagedIdentity\":\"aodsfcpkv\",\"sourceAmwAccountResourceId\":\"odpuozmyzydag\",\"metricNamespace\":\"uaxbezyiuokkt\",\"metricName\":\"hrdxwzywqsmbs\",\"filters\":[{\"dimensionName\":\"xim\",\"scalarFunction\":\"max\",\"samplingType\":\"max\",\"operator\":\"startswith\",\"value\":\"sfksy\"},{\"dimensionName\":\"dystkiiuxhqyud\",\"scalarFunction\":\"sum\",\"samplingType\":\"max\",\"operator\":\"==\",\"value\":\"b\"},{\"dimensionName\":\"czvyifq\",\"scalarFunction\":\"min\",\"samplingType\":\"avg\",\"operator\":\"!startswith\",\"value\":\"sllr\"}],\"spatialAggregation\":{\"type\":\"Min\",\"dimensions\":[\"d\",\"watkpnpulexxb\",\"zwtruwiqzbqjvsov\"]},\"temporalAggregation\":{\"type\":\"IDelta\",\"windowSizeMinutes\":1785940860}},{\"signalSourceId\":\"acspkwl\",\"sourceAmwAccountManagedIdentity\":\"zdobpxjmflbvvnch\",\"sourceAmwAccountResourceId\":\"kcciwwzjuqkhr\",\"metricNamespace\":\"ajiwkuo\",\"metricName\":\"oskg\",\"filters\":[{\"dimensionName\":\"uuimjmvxieduug\",\"scalarFunction\":\"max\",\"samplingType\":\"sum\",\"operator\":\"!=\",\"value\":\"f\"},{\"dimensionName\":\"aos\",\"scalarFunction\":\"max\",\"samplingType\":\"avg\",\"operator\":\"<\",\"value\":\"npc\"}],\"spatialAggregation\":{\"type\":\"Min\",\"dimensions\":[\"cohslkev\",\"eggzfb\",\"hfmvfaxkffe\"]},\"temporalAggregation\":{\"type\":\"Average\",\"windowSizeMinutes\":378191098}}],\"signalFormula\":\"lvmezyvshxmzsbbz\"},\"totalSignals\":{\"signalSources\":[{\"signalSourceId\":\"igrxwburvjxxjn\",\"sourceAmwAccountManagedIdentity\":\"pydptko\",\"sourceAmwAccountResourceId\":\"nkoukn\",\"metricNamespace\":\"udwtiukbl\",\"metricName\":\"ngkpocipazy\",\"filters\":[{\"dimensionName\":\"gukgjnpiucgygevq\",\"scalarFunction\":\"sum\",\"samplingType\":\"max\",\"operator\":\"!=\",\"value\":\"rbpizc\"}],\"spatialAggregation\":{\"type\":\"Average\",\"dimensions\":[\"j\",\"dpydn\",\"yhxdeoejzicwi\",\"sjttgzfbish\"]},\"temporalAggregation\":{\"type\":\"IRate\",\"windowSizeMinutes\":1326905161}}],\"signalFormula\":\"ajdeyeamdphaga\"},\"signals\":{\"signalSources\":[{\"signalSourceId\":\"uxwgipwho\",\"sourceAmwAccountManagedIdentity\":\"ow\",\"sourceAmwAccountResourceId\":\"gshwankixz\",\"metricNamespace\":\"injep\",\"metricName\":\"ttmrywnuzoqf\",\"filters\":[{\"dimensionName\":\"qzrnkcqvyxlwhz\",\"scalarFunction\":\"avg\",\"samplingType\":\"sum\",\"operator\":\"startswith\",\"value\":\"oqqnwvlryav\"},{\"dimensionName\":\"heun\",\"scalarFunction\":\"sum\",\"samplingType\":\"min\",\"operator\":\"==\",\"value\":\"xzko\"}],\"spatialAggregation\":{\"type\":\"Min\",\"dimensions\":[\"uko\",\"lyaxuc\",\"nuqszfkbey\",\"ewrmjmwvvjektc\"]},\"temporalAggregation\":{\"type\":\"Min\",\"windowSizeMinutes\":1562497596}},{\"signalSourceId\":\"hwlrsf\",\"sourceAmwAccountManagedIdentity\":\"rzpwvlqdqgbiq\",\"sourceAmwAccountResourceId\":\"lihkaetcktvfc\",\"metricNamespace\":\"vf\",\"metricName\":\"nkymuctqhjfbebrj\",\"filters\":[{\"dimensionName\":\"rfuwutt\",\"scalarFunction\":\"sum\",\"samplingType\":\"sum\",\"operator\":\"!in\",\"value\":\"birphxepcyva\"}],\"spatialAggregation\":{\"type\":\"Average\",\"dimensions\":[\"ljkyqxjvuuj\",\"gidokgjljyoxgvcl\"]},\"temporalAggregation\":{\"type\":\"Sum\",\"windowSizeMinutes\":794855452}}],\"signalFormula\":\"ncghkje\"},\"windowUptimeCriteria\":{\"target\":56.497059361324276,\"comparator\":\"<=\"}}") + .toObject(SliProperties.class); + Assertions.assertEquals("dmoh", model.goodSignals().signalSources().get(0).signalSourceId()); + Assertions.assertEquals("tbqvudw", + model.goodSignals().signalSources().get(0).sourceAmwAccountManagedIdentity()); + Assertions.assertEquals("dndnvow", model.goodSignals().signalSources().get(0).sourceAmwAccountResourceId()); + Assertions.assertEquals("ujjugwdkcglh", model.goodSignals().signalSources().get(0).metricNamespace()); + Assertions.assertEquals("lazjdyggdtjixhbk", model.goodSignals().signalSources().get(0).metricName()); + Assertions.assertEquals("qweykhmenev", + model.goodSignals().signalSources().get(0).filters().get(0).dimensionName()); + Assertions.assertEquals(ScalarFunction.MIN, + model.goodSignals().signalSources().get(0).filters().get(0).scalarFunction()); + Assertions.assertEquals(SamplingType.AVG, + model.goodSignals().signalSources().get(0).filters().get(0).samplingType()); + Assertions.assertEquals(ConditionOperator.NOT_CONTAINS, + model.goodSignals().signalSources().get(0).filters().get(0).operator()); + Assertions.assertEquals("hybcibv", model.goodSignals().signalSources().get(0).filters().get(0).value()); + Assertions.assertEquals(SpatialAggregationType.MIN, + model.goodSignals().signalSources().get(0).spatialAggregation().type()); + Assertions.assertEquals("vmdajvnysou", + model.goodSignals().signalSources().get(0).spatialAggregation().dimensions().get(0)); + Assertions.assertEquals(TemporalAggregationType.IDELTA, + model.goodSignals().signalSources().get(0).temporalAggregation().type()); + Assertions.assertEquals(860799201, + model.goodSignals().signalSources().get(0).temporalAggregation().windowSizeMinutes()); + Assertions.assertEquals("lvmezyvshxmzsbbz", model.goodSignals().signalFormula()); + Assertions.assertEquals("igrxwburvjxxjn", model.totalSignals().signalSources().get(0).signalSourceId()); + Assertions.assertEquals("pydptko", + model.totalSignals().signalSources().get(0).sourceAmwAccountManagedIdentity()); + Assertions.assertEquals("nkoukn", model.totalSignals().signalSources().get(0).sourceAmwAccountResourceId()); + Assertions.assertEquals("udwtiukbl", model.totalSignals().signalSources().get(0).metricNamespace()); + Assertions.assertEquals("ngkpocipazy", model.totalSignals().signalSources().get(0).metricName()); + Assertions.assertEquals("gukgjnpiucgygevq", + model.totalSignals().signalSources().get(0).filters().get(0).dimensionName()); + Assertions.assertEquals(ScalarFunction.SUM, + model.totalSignals().signalSources().get(0).filters().get(0).scalarFunction()); + Assertions.assertEquals(SamplingType.MAX, + model.totalSignals().signalSources().get(0).filters().get(0).samplingType()); + Assertions.assertEquals(ConditionOperator.NOT_EQUAL, + model.totalSignals().signalSources().get(0).filters().get(0).operator()); + Assertions.assertEquals("rbpizc", model.totalSignals().signalSources().get(0).filters().get(0).value()); + Assertions.assertEquals(SpatialAggregationType.AVERAGE, + model.totalSignals().signalSources().get(0).spatialAggregation().type()); + Assertions.assertEquals("j", + model.totalSignals().signalSources().get(0).spatialAggregation().dimensions().get(0)); + Assertions.assertEquals(TemporalAggregationType.IRATE, + model.totalSignals().signalSources().get(0).temporalAggregation().type()); + Assertions.assertEquals(1326905161, + model.totalSignals().signalSources().get(0).temporalAggregation().windowSizeMinutes()); + Assertions.assertEquals("ajdeyeamdphaga", model.totalSignals().signalFormula()); + Assertions.assertEquals("uxwgipwho", model.signals().signalSources().get(0).signalSourceId()); + Assertions.assertEquals("ow", model.signals().signalSources().get(0).sourceAmwAccountManagedIdentity()); + Assertions.assertEquals("gshwankixz", model.signals().signalSources().get(0).sourceAmwAccountResourceId()); + Assertions.assertEquals("injep", model.signals().signalSources().get(0).metricNamespace()); + Assertions.assertEquals("ttmrywnuzoqf", model.signals().signalSources().get(0).metricName()); + Assertions.assertEquals("qzrnkcqvyxlwhz", + model.signals().signalSources().get(0).filters().get(0).dimensionName()); + Assertions.assertEquals(ScalarFunction.AVG, + model.signals().signalSources().get(0).filters().get(0).scalarFunction()); + Assertions.assertEquals(SamplingType.SUM, + model.signals().signalSources().get(0).filters().get(0).samplingType()); + Assertions.assertEquals(ConditionOperator.STARTS_WITH, + model.signals().signalSources().get(0).filters().get(0).operator()); + Assertions.assertEquals("oqqnwvlryav", model.signals().signalSources().get(0).filters().get(0).value()); + Assertions.assertEquals(SpatialAggregationType.MIN, + model.signals().signalSources().get(0).spatialAggregation().type()); + Assertions.assertEquals("uko", model.signals().signalSources().get(0).spatialAggregation().dimensions().get(0)); + Assertions.assertEquals(TemporalAggregationType.MIN, + model.signals().signalSources().get(0).temporalAggregation().type()); + Assertions.assertEquals(1562497596, + model.signals().signalSources().get(0).temporalAggregation().windowSizeMinutes()); + Assertions.assertEquals("ncghkje", model.signals().signalFormula()); + Assertions.assertEquals(56.497059361324276, model.windowUptimeCriteria().target()); + Assertions.assertEquals(WindowUptimeCriteriaComparator.LESS_THAN_OR_EQUAL, + model.windowUptimeCriteria().comparator()); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + SliProperties model + = new SliProperties() + .withGoodSignals(new Signal() + .withSignalSources(Arrays.asList( + new SignalSource().withSignalSourceId("dmoh") + .withSourceAmwAccountManagedIdentity("tbqvudw") + .withSourceAmwAccountResourceId("dndnvow") + .withMetricNamespace("ujjugwdkcglh") + .withMetricName("lazjdyggdtjixhbk") + .withFilters(Arrays.asList( + new Condition().withDimensionName("qweykhmenev") + .withScalarFunction(ScalarFunction.MIN) + .withSamplingType(SamplingType.AVG) + .withOperator(ConditionOperator.NOT_CONTAINS) + .withValue("hybcibv"), + new Condition().withDimensionName("dcsi") + .withScalarFunction(ScalarFunction.SUM) + .withSamplingType(SamplingType.MIN) + .withOperator(ConditionOperator.STARTS_WITH) + .withValue("mdectehfiqscjey"), + new Condition().withDimensionName("hezrkgq") + .withScalarFunction(ScalarFunction.SUM) + .withSamplingType(SamplingType.MIN) + .withOperator(ConditionOperator.GREATER_THAN) + .withValue("o"), + new Condition().withDimensionName("mkqsleyyv") + .withScalarFunction(ScalarFunction.SUM) + .withSamplingType(SamplingType.MAX) + .withOperator(ConditionOperator.LESS_THAN_OR_EQUAL) + .withValue("cattpngjcrcczsq"))) + .withSpatialAggregation(new SpatialAggregation().withType(SpatialAggregationType.MIN) + .withDimensions(Arrays.asList("vmdajvnysou", "q", "canoaeupf", "yhltrpmopjmcm"))) + .withTemporalAggregation(new TemporalAggregation().withType( + TemporalAggregationType.IDELTA) + .withWindowSizeMinutes(860799201)), + new SignalSource().withSignalSourceId("kthfui") + .withSourceAmwAccountManagedIdentity("aodsfcpkv") + .withSourceAmwAccountResourceId("odpuozmyzydag") + .withMetricNamespace("uaxbezyiuokkt") + .withMetricName("hrdxwzywqsmbs") + .withFilters(Arrays.asList( + new Condition().withDimensionName("xim") + .withScalarFunction(ScalarFunction.MAX) + .withSamplingType(SamplingType.MAX) + .withOperator(ConditionOperator.STARTS_WITH) + .withValue("sfksy"), + new Condition().withDimensionName("dystkiiuxhqyud") + .withScalarFunction(ScalarFunction.SUM) + .withSamplingType(SamplingType.MAX) + .withOperator(ConditionOperator.EQUAL) + .withValue("b"), + new Condition().withDimensionName("czvyifq") + .withScalarFunction(ScalarFunction.MIN) + .withSamplingType(SamplingType.AVG) + .withOperator(ConditionOperator.NOT_STARTS_WITH) + .withValue("sllr"))) + .withSpatialAggregation(new SpatialAggregation().withType(SpatialAggregationType.MIN) + .withDimensions(Arrays.asList("d", "watkpnpulexxb", "zwtruwiqzbqjvsov"))) + .withTemporalAggregation( + new TemporalAggregation().withType(TemporalAggregationType.IDELTA) + .withWindowSizeMinutes(1785940860)), + new SignalSource().withSignalSourceId("acspkwl") + .withSourceAmwAccountManagedIdentity("zdobpxjmflbvvnch") + .withSourceAmwAccountResourceId("kcciwwzjuqkhr") + .withMetricNamespace("ajiwkuo") + .withMetricName("oskg") + .withFilters(Arrays.asList( + new Condition().withDimensionName("uuimjmvxieduug") + .withScalarFunction(ScalarFunction.MAX) + .withSamplingType(SamplingType.SUM) + .withOperator(ConditionOperator.NOT_EQUAL) + .withValue("f"), + new Condition().withDimensionName("aos") + .withScalarFunction(ScalarFunction.MAX) + .withSamplingType(SamplingType.AVG) + .withOperator(ConditionOperator.LESS_THAN) + .withValue("npc"))) + .withSpatialAggregation(new SpatialAggregation().withType(SpatialAggregationType.MIN) + .withDimensions(Arrays.asList("cohslkev", "eggzfb", "hfmvfaxkffe"))) + .withTemporalAggregation(new TemporalAggregation().withType(TemporalAggregationType.AVERAGE) + .withWindowSizeMinutes(378191098)))) + .withSignalFormula("lvmezyvshxmzsbbz")) + .withTotalSignals( + new Signal() + .withSignalSources(Arrays.asList(new SignalSource().withSignalSourceId("igrxwburvjxxjn") + .withSourceAmwAccountManagedIdentity("pydptko") + .withSourceAmwAccountResourceId("nkoukn") + .withMetricNamespace("udwtiukbl") + .withMetricName("ngkpocipazy") + .withFilters(Arrays.asList(new Condition().withDimensionName("gukgjnpiucgygevq") + .withScalarFunction(ScalarFunction.SUM) + .withSamplingType(SamplingType.MAX) + .withOperator(ConditionOperator.NOT_EQUAL) + .withValue("rbpizc"))) + .withSpatialAggregation(new SpatialAggregation().withType(SpatialAggregationType.AVERAGE) + .withDimensions(Arrays.asList("j", "dpydn", "yhxdeoejzicwi", "sjttgzfbish"))) + .withTemporalAggregation(new TemporalAggregation().withType(TemporalAggregationType.IRATE) + .withWindowSizeMinutes(1326905161)))) + .withSignalFormula("ajdeyeamdphaga")) + .withSignals(new Signal().withSignalSources(Arrays.asList( + new SignalSource().withSignalSourceId("uxwgipwho") + .withSourceAmwAccountManagedIdentity("ow") + .withSourceAmwAccountResourceId("gshwankixz") + .withMetricNamespace("injep") + .withMetricName("ttmrywnuzoqf") + .withFilters(Arrays.asList( + new Condition().withDimensionName("qzrnkcqvyxlwhz") + .withScalarFunction(ScalarFunction.AVG) + .withSamplingType(SamplingType.SUM) + .withOperator(ConditionOperator.STARTS_WITH) + .withValue("oqqnwvlryav"), + new Condition().withDimensionName("heun") + .withScalarFunction(ScalarFunction.SUM) + .withSamplingType(SamplingType.MIN) + .withOperator(ConditionOperator.EQUAL) + .withValue("xzko"))) + .withSpatialAggregation(new SpatialAggregation().withType(SpatialAggregationType.MIN) + .withDimensions(Arrays.asList("uko", "lyaxuc", "nuqszfkbey", "ewrmjmwvvjektc"))) + .withTemporalAggregation(new TemporalAggregation().withType(TemporalAggregationType.MIN) + .withWindowSizeMinutes(1562497596)), + new SignalSource().withSignalSourceId("hwlrsf") + .withSourceAmwAccountManagedIdentity("rzpwvlqdqgbiq") + .withSourceAmwAccountResourceId("lihkaetcktvfc") + .withMetricNamespace("vf") + .withMetricName("nkymuctqhjfbebrj") + .withFilters(Arrays.asList(new Condition().withDimensionName("rfuwutt") + .withScalarFunction(ScalarFunction.SUM) + .withSamplingType(SamplingType.SUM) + .withOperator(ConditionOperator.NOT_IN) + .withValue("birphxepcyva"))) + .withSpatialAggregation(new SpatialAggregation().withType(SpatialAggregationType.AVERAGE) + .withDimensions(Arrays.asList("ljkyqxjvuuj", "gidokgjljyoxgvcl"))) + .withTemporalAggregation(new TemporalAggregation().withType(TemporalAggregationType.SUM) + .withWindowSizeMinutes(794855452)))) + .withSignalFormula("ncghkje")) + .withWindowUptimeCriteria(new WindowUptimeCriteria().withTarget(56.497059361324276) + .withComparator(WindowUptimeCriteriaComparator.LESS_THAN_OR_EQUAL)); + model = BinaryData.fromObject(model).toObject(SliProperties.class); + Assertions.assertEquals("dmoh", model.goodSignals().signalSources().get(0).signalSourceId()); + Assertions.assertEquals("tbqvudw", + model.goodSignals().signalSources().get(0).sourceAmwAccountManagedIdentity()); + Assertions.assertEquals("dndnvow", model.goodSignals().signalSources().get(0).sourceAmwAccountResourceId()); + Assertions.assertEquals("ujjugwdkcglh", model.goodSignals().signalSources().get(0).metricNamespace()); + Assertions.assertEquals("lazjdyggdtjixhbk", model.goodSignals().signalSources().get(0).metricName()); + Assertions.assertEquals("qweykhmenev", + model.goodSignals().signalSources().get(0).filters().get(0).dimensionName()); + Assertions.assertEquals(ScalarFunction.MIN, + model.goodSignals().signalSources().get(0).filters().get(0).scalarFunction()); + Assertions.assertEquals(SamplingType.AVG, + model.goodSignals().signalSources().get(0).filters().get(0).samplingType()); + Assertions.assertEquals(ConditionOperator.NOT_CONTAINS, + model.goodSignals().signalSources().get(0).filters().get(0).operator()); + Assertions.assertEquals("hybcibv", model.goodSignals().signalSources().get(0).filters().get(0).value()); + Assertions.assertEquals(SpatialAggregationType.MIN, + model.goodSignals().signalSources().get(0).spatialAggregation().type()); + Assertions.assertEquals("vmdajvnysou", + model.goodSignals().signalSources().get(0).spatialAggregation().dimensions().get(0)); + Assertions.assertEquals(TemporalAggregationType.IDELTA, + model.goodSignals().signalSources().get(0).temporalAggregation().type()); + Assertions.assertEquals(860799201, + model.goodSignals().signalSources().get(0).temporalAggregation().windowSizeMinutes()); + Assertions.assertEquals("lvmezyvshxmzsbbz", model.goodSignals().signalFormula()); + Assertions.assertEquals("igrxwburvjxxjn", model.totalSignals().signalSources().get(0).signalSourceId()); + Assertions.assertEquals("pydptko", + model.totalSignals().signalSources().get(0).sourceAmwAccountManagedIdentity()); + Assertions.assertEquals("nkoukn", model.totalSignals().signalSources().get(0).sourceAmwAccountResourceId()); + Assertions.assertEquals("udwtiukbl", model.totalSignals().signalSources().get(0).metricNamespace()); + Assertions.assertEquals("ngkpocipazy", model.totalSignals().signalSources().get(0).metricName()); + Assertions.assertEquals("gukgjnpiucgygevq", + model.totalSignals().signalSources().get(0).filters().get(0).dimensionName()); + Assertions.assertEquals(ScalarFunction.SUM, + model.totalSignals().signalSources().get(0).filters().get(0).scalarFunction()); + Assertions.assertEquals(SamplingType.MAX, + model.totalSignals().signalSources().get(0).filters().get(0).samplingType()); + Assertions.assertEquals(ConditionOperator.NOT_EQUAL, + model.totalSignals().signalSources().get(0).filters().get(0).operator()); + Assertions.assertEquals("rbpizc", model.totalSignals().signalSources().get(0).filters().get(0).value()); + Assertions.assertEquals(SpatialAggregationType.AVERAGE, + model.totalSignals().signalSources().get(0).spatialAggregation().type()); + Assertions.assertEquals("j", + model.totalSignals().signalSources().get(0).spatialAggregation().dimensions().get(0)); + Assertions.assertEquals(TemporalAggregationType.IRATE, + model.totalSignals().signalSources().get(0).temporalAggregation().type()); + Assertions.assertEquals(1326905161, + model.totalSignals().signalSources().get(0).temporalAggregation().windowSizeMinutes()); + Assertions.assertEquals("ajdeyeamdphaga", model.totalSignals().signalFormula()); + Assertions.assertEquals("uxwgipwho", model.signals().signalSources().get(0).signalSourceId()); + Assertions.assertEquals("ow", model.signals().signalSources().get(0).sourceAmwAccountManagedIdentity()); + Assertions.assertEquals("gshwankixz", model.signals().signalSources().get(0).sourceAmwAccountResourceId()); + Assertions.assertEquals("injep", model.signals().signalSources().get(0).metricNamespace()); + Assertions.assertEquals("ttmrywnuzoqf", model.signals().signalSources().get(0).metricName()); + Assertions.assertEquals("qzrnkcqvyxlwhz", + model.signals().signalSources().get(0).filters().get(0).dimensionName()); + Assertions.assertEquals(ScalarFunction.AVG, + model.signals().signalSources().get(0).filters().get(0).scalarFunction()); + Assertions.assertEquals(SamplingType.SUM, + model.signals().signalSources().get(0).filters().get(0).samplingType()); + Assertions.assertEquals(ConditionOperator.STARTS_WITH, + model.signals().signalSources().get(0).filters().get(0).operator()); + Assertions.assertEquals("oqqnwvlryav", model.signals().signalSources().get(0).filters().get(0).value()); + Assertions.assertEquals(SpatialAggregationType.MIN, + model.signals().signalSources().get(0).spatialAggregation().type()); + Assertions.assertEquals("uko", model.signals().signalSources().get(0).spatialAggregation().dimensions().get(0)); + Assertions.assertEquals(TemporalAggregationType.MIN, + model.signals().signalSources().get(0).temporalAggregation().type()); + Assertions.assertEquals(1562497596, + model.signals().signalSources().get(0).temporalAggregation().windowSizeMinutes()); + Assertions.assertEquals("ncghkje", model.signals().signalFormula()); + Assertions.assertEquals(56.497059361324276, model.windowUptimeCriteria().target()); + Assertions.assertEquals(WindowUptimeCriteriaComparator.LESS_THAN_OR_EQUAL, + model.windowUptimeCriteria().comparator()); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/SliResourceTests.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/SliResourceTests.java new file mode 100644 index 000000000000..5fe836485370 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/SliResourceTests.java @@ -0,0 +1,289 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.monitor.slis.models.AmwAccount; +import com.azure.resourcemanager.monitor.slis.models.Baseline; +import com.azure.resourcemanager.monitor.slis.models.BaselineProperties; +import com.azure.resourcemanager.monitor.slis.models.Category; +import com.azure.resourcemanager.monitor.slis.models.Condition; +import com.azure.resourcemanager.monitor.slis.models.ConditionOperator; +import com.azure.resourcemanager.monitor.slis.models.EvaluationCalculationType; +import com.azure.resourcemanager.monitor.slis.models.EvaluationType; +import com.azure.resourcemanager.monitor.slis.models.Signal; +import com.azure.resourcemanager.monitor.slis.models.SignalSource; +import com.azure.resourcemanager.monitor.slis.models.SliProperties; +import com.azure.resourcemanager.monitor.slis.models.SliResource; +import com.azure.resourcemanager.monitor.slis.models.SpatialAggregation; +import com.azure.resourcemanager.monitor.slis.models.SpatialAggregationType; +import com.azure.resourcemanager.monitor.slis.models.TemporalAggregation; +import com.azure.resourcemanager.monitor.slis.models.TemporalAggregationType; +import com.azure.resourcemanager.monitor.slis.models.WindowUptimeCriteria; +import com.azure.resourcemanager.monitor.slis.models.WindowUptimeCriteriaComparator; +import java.util.Arrays; +import org.junit.jupiter.api.Assertions; + +public final class SliResourceTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + SliResource model = BinaryData.fromString( + "{\"provisioningState\":\"Failed\",\"description\":\"vfqawrlyxwjkcpr\",\"category\":\"Latency\",\"evaluationType\":\"WindowBased\",\"executionState\":{\"state\":\"xgjvtbv\",\"message\":\"sszdnru\"},\"destinationAmwAccounts\":[{\"resourceId\":\"guhmuouqfpr\",\"identity\":\"zw\"},{\"resourceId\":\"nguitnwuizgazxu\",\"identity\":\"izuckyfihrfidfvz\"}],\"destinationMetrics\":[{\"metricNamespace\":\"uht\",\"metricName\":\"mwisdkfthwxmnt\"},{\"metricNamespace\":\"i\",\"metricName\":\"aop\"},{\"metricNamespace\":\"km\",\"metricName\":\"jcmmxdcufufsrp\"},{\"metricNamespace\":\"mzidnsezcxtb\",\"metricName\":\"sgfyccsnew\"}],\"baselineProperties\":{\"baseline\":{\"value\":54.537750032723274,\"evaluationPeriodDays\":44464100,\"evaluationCalculationType\":\"RollingDays\"}},\"streamingRuleId\":\"iachbo\",\"streamingRuleLastUpdatedTimestamp\":\"2021-05-15T06:55:08Z\",\"enableAlert\":false,\"sliProperties\":{\"goodSignals\":{\"signalSources\":[{\"signalSourceId\":\"osfqpteehzzv\",\"sourceAmwAccountManagedIdentity\":\"pyqr\",\"sourceAmwAccountResourceId\":\"mzinpvswjdk\",\"metricNamespace\":\"rsoodqxhcrmnoh\",\"metricName\":\"t\",\"filters\":[{\"operator\":\"==\",\"value\":\"h\"}],\"spatialAggregation\":{\"type\":\"Count\",\"dimensions\":[\"ifiyipjxsqwpgrj\",\"znorcj\",\"vsnb\",\"xqabnmocpcysh\"]},\"temporalAggregation\":{\"type\":\"IRate\",\"windowSizeMinutes\":2023442123}}],\"signalFormula\":\"fblj\"},\"totalSignals\":{\"signalSources\":[{\"signalSourceId\":\"btoqcjmkljavbqid\",\"sourceAmwAccountManagedIdentity\":\"qajzyulpkudjkr\",\"sourceAmwAccountResourceId\":\"khbzhfepgzg\",\"metricNamespace\":\"e\",\"metricName\":\"zloc\",\"filters\":[{\"operator\":\"startswith\",\"value\":\"paierh\"},{\"operator\":\"<=\",\"value\":\"csglum\"}],\"spatialAggregation\":{\"type\":\"Average\",\"dimensions\":[\"tjaodxobnb\",\"xkqpxo\",\"ajionpimexgstxg\",\"po\"]},\"temporalAggregation\":{\"type\":\"Rate\",\"windowSizeMinutes\":1107396913}},{\"signalSourceId\":\"ajrmvdjwzrlovmc\",\"sourceAmwAccountManagedIdentity\":\"whijcoejctbza\",\"sourceAmwAccountResourceId\":\"s\",\"metricNamespace\":\"sycbkbfk\",\"metricName\":\"ukdkexxppofmxa\",\"filters\":[{\"operator\":\"==\",\"value\":\"jpgd\"}],\"spatialAggregation\":{\"type\":\"Max\",\"dimensions\":[\"c\",\"j\",\"hvpmoue\",\"hd\"]},\"temporalAggregation\":{\"type\":\"Increase\",\"windowSizeMinutes\":738311617}},{\"signalSourceId\":\"qeojnxqbzvddntw\",\"sourceAmwAccountManagedIdentity\":\"deicbtwnpzao\",\"sourceAmwAccountResourceId\":\"vuhrhcffcyddgl\",\"metricNamespace\":\"jthjqkwpyei\",\"metricName\":\"xmqci\",\"filters\":[{\"operator\":\">\",\"value\":\"hkh\"}],\"spatialAggregation\":{\"type\":\"Sum\",\"dimensions\":[\"igdtopbob\",\"og\",\"m\",\"w\"]},\"temporalAggregation\":{\"type\":\"Increase\",\"windowSizeMinutes\":248377661}}],\"signalFormula\":\"uhrzayvvt\"},\"signals\":{\"signalSources\":[{\"signalSourceId\":\"dfgiot\",\"sourceAmwAccountManagedIdentity\":\"ftutqxlngxlefgu\",\"sourceAmwAccountResourceId\":\"nxkrx\",\"metricNamespace\":\"qmi\",\"metricName\":\"tthzrvqd\",\"filters\":[{\"operator\":\"startswith\",\"value\":\"hjybigehoqfbo\"},{\"operator\":\"<\",\"value\":\"kanyktzlcuiywg\"}],\"spatialAggregation\":{\"type\":\"Count\",\"dimensions\":[\"gndrvynh\",\"gpphrcgyn\",\"ocpecfvmmco\",\"fsxlzevgbmqjqa\"]},\"temporalAggregation\":{\"type\":\"Increase\",\"windowSizeMinutes\":138991761}},{\"signalSourceId\":\"mivkwlzuvcc\",\"sourceAmwAccountManagedIdentity\":\"wnfnbacf\",\"sourceAmwAccountResourceId\":\"onlebxetqgtzxdpn\",\"metricNamespace\":\"bqqwxrj\",\"metricName\":\"eallnwsubisnj\",\"filters\":[{\"operator\":\"contains\",\"value\":\"mngnzscxaqw\"},{\"operator\":\"startswith\",\"value\":\"chcbonqvpkvlrxnj\"},{\"operator\":\"<\",\"value\":\"seiphe\"},{\"operator\":\"@in\",\"value\":\"lokeyy\"}],\"spatialAggregation\":{\"type\":\"Min\",\"dimensions\":[\"jbdlwtgrhpdjpju\"]},\"temporalAggregation\":{\"type\":\"Increase\",\"windowSizeMinutes\":1012728769}}],\"signalFormula\":\"azjpqyegualhbxxh\"},\"windowUptimeCriteria\":{\"target\":38.92750235772227,\"comparator\":\">=\"}}}") + .toObject(SliResource.class); + Assertions.assertEquals("vfqawrlyxwjkcpr", model.description()); + Assertions.assertEquals(Category.LATENCY, model.category()); + Assertions.assertEquals(EvaluationType.WINDOW_BASED, model.evaluationType()); + Assertions.assertEquals("guhmuouqfpr", model.destinationAmwAccounts().get(0).resourceId()); + Assertions.assertEquals("zw", model.destinationAmwAccounts().get(0).identity()); + Assertions.assertEquals(54.537750032723274, model.baselineProperties().baseline().value()); + Assertions.assertEquals(44464100, model.baselineProperties().baseline().evaluationPeriodDays()); + Assertions.assertEquals(EvaluationCalculationType.ROLLING_DAYS, + model.baselineProperties().baseline().evaluationCalculationType()); + Assertions.assertFalse(model.enableAlert()); + Assertions.assertEquals("osfqpteehzzv", + model.sliProperties().goodSignals().signalSources().get(0).signalSourceId()); + Assertions.assertEquals("pyqr", + model.sliProperties().goodSignals().signalSources().get(0).sourceAmwAccountManagedIdentity()); + Assertions.assertEquals("mzinpvswjdk", + model.sliProperties().goodSignals().signalSources().get(0).sourceAmwAccountResourceId()); + Assertions.assertEquals("rsoodqxhcrmnoh", + model.sliProperties().goodSignals().signalSources().get(0).metricNamespace()); + Assertions.assertEquals("t", model.sliProperties().goodSignals().signalSources().get(0).metricName()); + Assertions.assertEquals(ConditionOperator.EQUAL, + model.sliProperties().goodSignals().signalSources().get(0).filters().get(0).operator()); + Assertions.assertEquals("h", + model.sliProperties().goodSignals().signalSources().get(0).filters().get(0).value()); + Assertions.assertEquals(SpatialAggregationType.COUNT, + model.sliProperties().goodSignals().signalSources().get(0).spatialAggregation().type()); + Assertions.assertEquals("ifiyipjxsqwpgrj", + model.sliProperties().goodSignals().signalSources().get(0).spatialAggregation().dimensions().get(0)); + Assertions.assertEquals(TemporalAggregationType.IRATE, + model.sliProperties().goodSignals().signalSources().get(0).temporalAggregation().type()); + Assertions.assertEquals(2023442123, + model.sliProperties().goodSignals().signalSources().get(0).temporalAggregation().windowSizeMinutes()); + Assertions.assertEquals("fblj", model.sliProperties().goodSignals().signalFormula()); + Assertions.assertEquals("btoqcjmkljavbqid", + model.sliProperties().totalSignals().signalSources().get(0).signalSourceId()); + Assertions.assertEquals("qajzyulpkudjkr", + model.sliProperties().totalSignals().signalSources().get(0).sourceAmwAccountManagedIdentity()); + Assertions.assertEquals("khbzhfepgzg", + model.sliProperties().totalSignals().signalSources().get(0).sourceAmwAccountResourceId()); + Assertions.assertEquals("e", model.sliProperties().totalSignals().signalSources().get(0).metricNamespace()); + Assertions.assertEquals("zloc", model.sliProperties().totalSignals().signalSources().get(0).metricName()); + Assertions.assertEquals(ConditionOperator.STARTS_WITH, + model.sliProperties().totalSignals().signalSources().get(0).filters().get(0).operator()); + Assertions.assertEquals("paierh", + model.sliProperties().totalSignals().signalSources().get(0).filters().get(0).value()); + Assertions.assertEquals(SpatialAggregationType.AVERAGE, + model.sliProperties().totalSignals().signalSources().get(0).spatialAggregation().type()); + Assertions.assertEquals("tjaodxobnb", + model.sliProperties().totalSignals().signalSources().get(0).spatialAggregation().dimensions().get(0)); + Assertions.assertEquals(TemporalAggregationType.RATE, + model.sliProperties().totalSignals().signalSources().get(0).temporalAggregation().type()); + Assertions.assertEquals(1107396913, + model.sliProperties().totalSignals().signalSources().get(0).temporalAggregation().windowSizeMinutes()); + Assertions.assertEquals("uhrzayvvt", model.sliProperties().totalSignals().signalFormula()); + Assertions.assertEquals("dfgiot", model.sliProperties().signals().signalSources().get(0).signalSourceId()); + Assertions.assertEquals("ftutqxlngxlefgu", + model.sliProperties().signals().signalSources().get(0).sourceAmwAccountManagedIdentity()); + Assertions.assertEquals("nxkrx", + model.sliProperties().signals().signalSources().get(0).sourceAmwAccountResourceId()); + Assertions.assertEquals("qmi", model.sliProperties().signals().signalSources().get(0).metricNamespace()); + Assertions.assertEquals("tthzrvqd", model.sliProperties().signals().signalSources().get(0).metricName()); + Assertions.assertEquals(ConditionOperator.STARTS_WITH, + model.sliProperties().signals().signalSources().get(0).filters().get(0).operator()); + Assertions.assertEquals("hjybigehoqfbo", + model.sliProperties().signals().signalSources().get(0).filters().get(0).value()); + Assertions.assertEquals(SpatialAggregationType.COUNT, + model.sliProperties().signals().signalSources().get(0).spatialAggregation().type()); + Assertions.assertEquals("gndrvynh", + model.sliProperties().signals().signalSources().get(0).spatialAggregation().dimensions().get(0)); + Assertions.assertEquals(TemporalAggregationType.INCREASE, + model.sliProperties().signals().signalSources().get(0).temporalAggregation().type()); + Assertions.assertEquals(138991761, + model.sliProperties().signals().signalSources().get(0).temporalAggregation().windowSizeMinutes()); + Assertions.assertEquals("azjpqyegualhbxxh", model.sliProperties().signals().signalFormula()); + Assertions.assertEquals(38.92750235772227, model.sliProperties().windowUptimeCriteria().target()); + Assertions.assertEquals(WindowUptimeCriteriaComparator.GREATER_THAN_OR_EQUAL, + model.sliProperties().windowUptimeCriteria().comparator()); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + SliResource model = new SliResource().withDescription("vfqawrlyxwjkcpr") + .withCategory(Category.LATENCY) + .withEvaluationType(EvaluationType.WINDOW_BASED) + .withDestinationAmwAccounts(Arrays.asList(new AmwAccount().withResourceId("guhmuouqfpr").withIdentity("zw"), + new AmwAccount().withResourceId("nguitnwuizgazxu").withIdentity("izuckyfihrfidfvz"))) + .withBaselineProperties(new BaselineProperties().withBaseline(new Baseline().withValue(54.537750032723274) + .withEvaluationPeriodDays(44464100) + .withEvaluationCalculationType(EvaluationCalculationType.ROLLING_DAYS))) + .withEnableAlert(false) + .withSliProperties(new SliProperties() + .withGoodSignals(new Signal().withSignalSources(Arrays.asList(new SignalSource() + .withSignalSourceId("osfqpteehzzv") + .withSourceAmwAccountManagedIdentity("pyqr") + .withSourceAmwAccountResourceId("mzinpvswjdk") + .withMetricNamespace("rsoodqxhcrmnoh") + .withMetricName("t") + .withFilters(Arrays.asList(new Condition().withOperator(ConditionOperator.EQUAL).withValue("h"))) + .withSpatialAggregation(new SpatialAggregation().withType(SpatialAggregationType.COUNT) + .withDimensions(Arrays.asList("ifiyipjxsqwpgrj", "znorcj", "vsnb", "xqabnmocpcysh"))) + .withTemporalAggregation(new TemporalAggregation().withType(TemporalAggregationType.IRATE) + .withWindowSizeMinutes(2023442123)))) + .withSignalFormula("fblj")) + .withTotalSignals( + new Signal() + .withSignalSources(Arrays.asList( + new SignalSource().withSignalSourceId("btoqcjmkljavbqid") + .withSourceAmwAccountManagedIdentity("qajzyulpkudjkr") + .withSourceAmwAccountResourceId("khbzhfepgzg") + .withMetricNamespace("e") + .withMetricName("zloc") + .withFilters(Arrays.asList( + new Condition().withOperator(ConditionOperator.STARTS_WITH).withValue("paierh"), + new Condition().withOperator(ConditionOperator.LESS_THAN_OR_EQUAL) + .withValue("csglum"))) + .withSpatialAggregation( + new SpatialAggregation().withType(SpatialAggregationType.AVERAGE) + .withDimensions(Arrays.asList("tjaodxobnb", "xkqpxo", "ajionpimexgstxg", "po"))) + .withTemporalAggregation(new TemporalAggregation() + .withType(TemporalAggregationType.RATE) + .withWindowSizeMinutes(1107396913)), + new SignalSource().withSignalSourceId("ajrmvdjwzrlovmc") + .withSourceAmwAccountManagedIdentity("whijcoejctbza") + .withSourceAmwAccountResourceId("s") + .withMetricNamespace("sycbkbfk") + .withMetricName("ukdkexxppofmxa") + .withFilters(Arrays + .asList(new Condition().withOperator(ConditionOperator.EQUAL).withValue("jpgd"))) + .withSpatialAggregation(new SpatialAggregation().withType(SpatialAggregationType.MAX) + .withDimensions(Arrays.asList("c", "j", "hvpmoue", "hd"))) + .withTemporalAggregation(new TemporalAggregation() + .withType(TemporalAggregationType.INCREASE) + .withWindowSizeMinutes(738311617)), + new SignalSource() + .withSignalSourceId("qeojnxqbzvddntw") + .withSourceAmwAccountManagedIdentity("deicbtwnpzao") + .withSourceAmwAccountResourceId("vuhrhcffcyddgl") + .withMetricNamespace("jthjqkwpyei") + .withMetricName("xmqci") + .withFilters(Arrays.asList( + new Condition().withOperator(ConditionOperator.GREATER_THAN).withValue("hkh"))) + .withSpatialAggregation(new SpatialAggregation().withType(SpatialAggregationType.SUM) + .withDimensions(Arrays.asList("igdtopbob", "og", "m", "w"))) + .withTemporalAggregation(new TemporalAggregation() + .withType(TemporalAggregationType.INCREASE) + .withWindowSizeMinutes(248377661)))) + .withSignalFormula("uhrzayvvt")) + .withSignals(new Signal().withSignalSources(Arrays.asList( + new SignalSource().withSignalSourceId("dfgiot") + .withSourceAmwAccountManagedIdentity("ftutqxlngxlefgu") + .withSourceAmwAccountResourceId("nxkrx") + .withMetricNamespace("qmi") + .withMetricName("tthzrvqd") + .withFilters(Arrays.asList( + new Condition().withOperator(ConditionOperator.STARTS_WITH).withValue("hjybigehoqfbo"), + new Condition().withOperator(ConditionOperator.LESS_THAN).withValue("kanyktzlcuiywg"))) + .withSpatialAggregation(new SpatialAggregation().withType(SpatialAggregationType.COUNT) + .withDimensions(Arrays.asList("gndrvynh", "gpphrcgyn", "ocpecfvmmco", "fsxlzevgbmqjqa"))) + .withTemporalAggregation(new TemporalAggregation().withType(TemporalAggregationType.INCREASE) + .withWindowSizeMinutes(138991761)), + new SignalSource().withSignalSourceId("mivkwlzuvcc") + .withSourceAmwAccountManagedIdentity("wnfnbacf") + .withSourceAmwAccountResourceId("onlebxetqgtzxdpn") + .withMetricNamespace("bqqwxrj") + .withMetricName("eallnwsubisnj") + .withFilters(Arrays.asList( + new Condition().withOperator(ConditionOperator.CONTAINS).withValue("mngnzscxaqw"), + new Condition().withOperator(ConditionOperator.STARTS_WITH).withValue("chcbonqvpkvlrxnj"), + new Condition().withOperator(ConditionOperator.LESS_THAN).withValue("seiphe"), + new Condition().withOperator(ConditionOperator.IN).withValue("lokeyy"))) + .withSpatialAggregation(new SpatialAggregation().withType(SpatialAggregationType.MIN) + .withDimensions(Arrays.asList("jbdlwtgrhpdjpju"))) + .withTemporalAggregation(new TemporalAggregation().withType(TemporalAggregationType.INCREASE) + .withWindowSizeMinutes(1012728769)))) + .withSignalFormula("azjpqyegualhbxxh")) + .withWindowUptimeCriteria(new WindowUptimeCriteria().withTarget(38.92750235772227) + .withComparator(WindowUptimeCriteriaComparator.GREATER_THAN_OR_EQUAL))); + model = BinaryData.fromObject(model).toObject(SliResource.class); + Assertions.assertEquals("vfqawrlyxwjkcpr", model.description()); + Assertions.assertEquals(Category.LATENCY, model.category()); + Assertions.assertEquals(EvaluationType.WINDOW_BASED, model.evaluationType()); + Assertions.assertEquals("guhmuouqfpr", model.destinationAmwAccounts().get(0).resourceId()); + Assertions.assertEquals("zw", model.destinationAmwAccounts().get(0).identity()); + Assertions.assertEquals(54.537750032723274, model.baselineProperties().baseline().value()); + Assertions.assertEquals(44464100, model.baselineProperties().baseline().evaluationPeriodDays()); + Assertions.assertEquals(EvaluationCalculationType.ROLLING_DAYS, + model.baselineProperties().baseline().evaluationCalculationType()); + Assertions.assertFalse(model.enableAlert()); + Assertions.assertEquals("osfqpteehzzv", + model.sliProperties().goodSignals().signalSources().get(0).signalSourceId()); + Assertions.assertEquals("pyqr", + model.sliProperties().goodSignals().signalSources().get(0).sourceAmwAccountManagedIdentity()); + Assertions.assertEquals("mzinpvswjdk", + model.sliProperties().goodSignals().signalSources().get(0).sourceAmwAccountResourceId()); + Assertions.assertEquals("rsoodqxhcrmnoh", + model.sliProperties().goodSignals().signalSources().get(0).metricNamespace()); + Assertions.assertEquals("t", model.sliProperties().goodSignals().signalSources().get(0).metricName()); + Assertions.assertEquals(ConditionOperator.EQUAL, + model.sliProperties().goodSignals().signalSources().get(0).filters().get(0).operator()); + Assertions.assertEquals("h", + model.sliProperties().goodSignals().signalSources().get(0).filters().get(0).value()); + Assertions.assertEquals(SpatialAggregationType.COUNT, + model.sliProperties().goodSignals().signalSources().get(0).spatialAggregation().type()); + Assertions.assertEquals("ifiyipjxsqwpgrj", + model.sliProperties().goodSignals().signalSources().get(0).spatialAggregation().dimensions().get(0)); + Assertions.assertEquals(TemporalAggregationType.IRATE, + model.sliProperties().goodSignals().signalSources().get(0).temporalAggregation().type()); + Assertions.assertEquals(2023442123, + model.sliProperties().goodSignals().signalSources().get(0).temporalAggregation().windowSizeMinutes()); + Assertions.assertEquals("fblj", model.sliProperties().goodSignals().signalFormula()); + Assertions.assertEquals("btoqcjmkljavbqid", + model.sliProperties().totalSignals().signalSources().get(0).signalSourceId()); + Assertions.assertEquals("qajzyulpkudjkr", + model.sliProperties().totalSignals().signalSources().get(0).sourceAmwAccountManagedIdentity()); + Assertions.assertEquals("khbzhfepgzg", + model.sliProperties().totalSignals().signalSources().get(0).sourceAmwAccountResourceId()); + Assertions.assertEquals("e", model.sliProperties().totalSignals().signalSources().get(0).metricNamespace()); + Assertions.assertEquals("zloc", model.sliProperties().totalSignals().signalSources().get(0).metricName()); + Assertions.assertEquals(ConditionOperator.STARTS_WITH, + model.sliProperties().totalSignals().signalSources().get(0).filters().get(0).operator()); + Assertions.assertEquals("paierh", + model.sliProperties().totalSignals().signalSources().get(0).filters().get(0).value()); + Assertions.assertEquals(SpatialAggregationType.AVERAGE, + model.sliProperties().totalSignals().signalSources().get(0).spatialAggregation().type()); + Assertions.assertEquals("tjaodxobnb", + model.sliProperties().totalSignals().signalSources().get(0).spatialAggregation().dimensions().get(0)); + Assertions.assertEquals(TemporalAggregationType.RATE, + model.sliProperties().totalSignals().signalSources().get(0).temporalAggregation().type()); + Assertions.assertEquals(1107396913, + model.sliProperties().totalSignals().signalSources().get(0).temporalAggregation().windowSizeMinutes()); + Assertions.assertEquals("uhrzayvvt", model.sliProperties().totalSignals().signalFormula()); + Assertions.assertEquals("dfgiot", model.sliProperties().signals().signalSources().get(0).signalSourceId()); + Assertions.assertEquals("ftutqxlngxlefgu", + model.sliProperties().signals().signalSources().get(0).sourceAmwAccountManagedIdentity()); + Assertions.assertEquals("nxkrx", + model.sliProperties().signals().signalSources().get(0).sourceAmwAccountResourceId()); + Assertions.assertEquals("qmi", model.sliProperties().signals().signalSources().get(0).metricNamespace()); + Assertions.assertEquals("tthzrvqd", model.sliProperties().signals().signalSources().get(0).metricName()); + Assertions.assertEquals(ConditionOperator.STARTS_WITH, + model.sliProperties().signals().signalSources().get(0).filters().get(0).operator()); + Assertions.assertEquals("hjybigehoqfbo", + model.sliProperties().signals().signalSources().get(0).filters().get(0).value()); + Assertions.assertEquals(SpatialAggregationType.COUNT, + model.sliProperties().signals().signalSources().get(0).spatialAggregation().type()); + Assertions.assertEquals("gndrvynh", + model.sliProperties().signals().signalSources().get(0).spatialAggregation().dimensions().get(0)); + Assertions.assertEquals(TemporalAggregationType.INCREASE, + model.sliProperties().signals().signalSources().get(0).temporalAggregation().type()); + Assertions.assertEquals(138991761, + model.sliProperties().signals().signalSources().get(0).temporalAggregation().windowSizeMinutes()); + Assertions.assertEquals("azjpqyegualhbxxh", model.sliProperties().signals().signalFormula()); + Assertions.assertEquals(38.92750235772227, model.sliProperties().windowUptimeCriteria().target()); + Assertions.assertEquals(WindowUptimeCriteriaComparator.GREATER_THAN_OR_EQUAL, + model.sliProperties().windowUptimeCriteria().comparator()); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/SlisCreateOrUpdateWithResponseMockTests.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/SlisCreateOrUpdateWithResponseMockTests.java new file mode 100644 index 000000000000..f4b04d21f34d --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/SlisCreateOrUpdateWithResponseMockTests.java @@ -0,0 +1,260 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.generated; + +import com.azure.core.credential.AccessToken; +import com.azure.core.http.HttpClient; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.models.AzureCloud; +import com.azure.core.test.http.MockHttpResponse; +import com.azure.resourcemanager.monitor.slis.SlisManager; +import com.azure.resourcemanager.monitor.slis.fluent.models.SliInner; +import com.azure.resourcemanager.monitor.slis.models.AmwAccount; +import com.azure.resourcemanager.monitor.slis.models.Baseline; +import com.azure.resourcemanager.monitor.slis.models.BaselineProperties; +import com.azure.resourcemanager.monitor.slis.models.Category; +import com.azure.resourcemanager.monitor.slis.models.EvaluationCalculationType; +import com.azure.resourcemanager.monitor.slis.models.EvaluationType; +import com.azure.resourcemanager.monitor.slis.models.ManagedServiceIdentity; +import com.azure.resourcemanager.monitor.slis.models.ManagedServiceIdentityType; +import com.azure.resourcemanager.monitor.slis.models.Signal; +import com.azure.resourcemanager.monitor.slis.models.SignalSource; +import com.azure.resourcemanager.monitor.slis.models.Sli; +import com.azure.resourcemanager.monitor.slis.models.SliProperties; +import com.azure.resourcemanager.monitor.slis.models.SliResource; +import com.azure.resourcemanager.monitor.slis.models.SpatialAggregation; +import com.azure.resourcemanager.monitor.slis.models.SpatialAggregationType; +import com.azure.resourcemanager.monitor.slis.models.TemporalAggregation; +import com.azure.resourcemanager.monitor.slis.models.TemporalAggregationType; +import com.azure.resourcemanager.monitor.slis.models.UserAssignedIdentity; +import com.azure.resourcemanager.monitor.slis.models.WindowUptimeCriteria; +import com.azure.resourcemanager.monitor.slis.models.WindowUptimeCriteriaComparator; +import java.nio.charset.StandardCharsets; +import java.time.OffsetDateTime; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import reactor.core.publisher.Mono; + +public final class SlisCreateOrUpdateWithResponseMockTests { + @Test + public void testCreateOrUpdateWithResponse() throws Exception { + String responseStr + = "{\"properties\":{\"provisioningState\":\"Failed\",\"description\":\"lhalnswh\",\"category\":\"Availability\",\"evaluationType\":\"WindowBased\",\"executionState\":{\"state\":\"hka\",\"message\":\"witqscywuggwoluh\"},\"destinationAmwAccounts\":[{\"resourceId\":\"bwemhairs\",\"identity\":\"rgzdwmsweyp\"},{\"resourceId\":\"w\",\"identity\":\"xggicccnxqhuexmk\"}],\"destinationMetrics\":[{\"metricNamespace\":\"stvlzywemhzrnc\",\"metricName\":\"dtclusiypb\"},{\"metricNamespace\":\"fgytguslfeadcyg\",\"metricName\":\"ukyhejhzis\"},{\"metricNamespace\":\"gfpelolppvksrpqv\",\"metricName\":\"jzraehtwdwrf\"}],\"baselineProperties\":{\"baseline\":{\"value\":33.494544229054966,\"evaluationPeriodDays\":767551661,\"evaluationCalculationType\":\"RollingDays\"}},\"streamingRuleId\":\"rcdlbhshfwpr\",\"streamingRuleLastUpdatedTimestamp\":\"2021-11-29T07:17:38Z\",\"enableAlert\":true,\"sliProperties\":{\"goodSignals\":{\"signalSources\":[{\"signalSourceId\":\"ty\",\"sourceAmwAccountManagedIdentity\":\"hevxcced\",\"sourceAmwAccountResourceId\":\"pnmdyodnwzxltjcv\",\"metricNamespace\":\"hlt\",\"metricName\":\"ugcxnavvwxq\",\"filters\":[],\"spatialAggregation\":{\"type\":\"Min\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Min\"}},{\"signalSourceId\":\"qunyowxwlmdjr\",\"sourceAmwAccountManagedIdentity\":\"vfgbvfvpdboda\",\"sourceAmwAccountResourceId\":\"izsjqlhkrr\",\"metricNamespace\":\"bdeibqipqk\",\"metricName\":\"hvxndzwmkrefajpj\",\"filters\":[],\"spatialAggregation\":{\"type\":\"Count\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Rate\"}}],\"signalFormula\":\"kqnyh\"},\"totalSignals\":{\"signalSources\":[{\"signalSourceId\":\"j\",\"sourceAmwAccountManagedIdentity\":\"jivfxzsjabib\",\"sourceAmwAccountResourceId\":\"ystawfsdjpvkvp\",\"metricNamespace\":\"jxbkzbzkdvn\",\"metricName\":\"jabudurgkakmo\",\"filters\":[],\"spatialAggregation\":{\"type\":\"Max\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Average\"}}],\"signalFormula\":\"jjklff\"},\"signals\":{\"signalSources\":[{\"signalSourceId\":\"uwqlgzrfzeey\",\"sourceAmwAccountManagedIdentity\":\"bizikayuhq\",\"sourceAmwAccountResourceId\":\"bjbsybb\",\"metricNamespace\":\"wrv\",\"metricName\":\"ldgmfpgvmpip\",\"filters\":[],\"spatialAggregation\":{\"type\":\"Max\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Delta\"}}],\"signalFormula\":\"thaqfxssmwu\"},\"windowUptimeCriteria\":{\"target\":31.752490870226723,\"comparator\":\">\"}}},\"identity\":{\"principalId\":\"zpdrhneu\",\"tenantId\":\"wqkdwytisibi\",\"type\":\"SystemAssigned\",\"userAssignedIdentities\":{\"anlfzxiavrmbz\":{\"principalId\":\"kpzi\",\"clientId\":\"j\"},\"nwoiind\":{\"principalId\":\"okixrjqcir\",\"clientId\":\"pfrlazsz\"}}},\"id\":\"wp\",\"name\":\"ylwbtlhflsjcdhsz\",\"type\":\"jvfbgofelja\"}"; + + HttpClient httpClient + = response -> Mono.just(new MockHttpResponse(response, 200, responseStr.getBytes(StandardCharsets.UTF_8))); + SlisManager manager = SlisManager.configure() + .withHttpClient(httpClient) + .authenticate(tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), + new AzureProfile("", "", AzureCloud.AZURE_PUBLIC_CLOUD)); + + Sli response + = manager.slis() + .createOrUpdateWithResponse("atdooaojkniod", "oo", new SliInner() + .withProperties(new SliResource().withDescription("ujhemmsbvdkcrodt") + .withCategory(Category.LATENCY) + .withEvaluationType(EvaluationType.REQUEST_BASED) + .withDestinationAmwAccounts(Arrays.asList( + new AmwAccount().withResourceId("cjvefkdlfo").withIdentity("kggkfpa"), + new AmwAccount().withResourceId("ao").withIdentity("pulpqblylsyxk"))) + .withBaselineProperties(new BaselineProperties().withBaseline(new Baseline() + .withValue(13.059784474144799) + .withEvaluationPeriodDays(993241324) + .withEvaluationCalculationType(EvaluationCalculationType.ROLLING_DAYS))) + .withEnableAlert(false) + .withSliProperties(new SliProperties().withGoodSignals(new Signal() + .withSignalSources(Arrays.asList(new SignalSource().withSignalSourceId("v") + .withSourceAmwAccountManagedIdentity("jjxd") + .withSourceAmwAccountResourceId("rbuukzclewyhmlwp") + .withMetricNamespace("ztzp") + .withMetricName("fn") + .withFilters(Arrays.asList()) + .withSpatialAggregation(new SpatialAggregation() + .withType(SpatialAggregationType.COUNT) + .withDimensions(Arrays.asList())) + .withTemporalAggregation(new TemporalAggregation().withType( + TemporalAggregationType.MAX)), + new SignalSource().withSignalSourceId("wyfzqwhxxbuyqa") + .withSourceAmwAccountManagedIdentity("zfeqztppri") + .withSourceAmwAccountResourceId("lxorjaltolmncws") + .withMetricNamespace("bqwcsdbnwdcf") + .withMetricName("ucqdpfuvglsb") + .withFilters(Arrays.asList()) + .withSpatialAggregation( + new SpatialAggregation() + .withType(SpatialAggregationType.COUNT) + .withDimensions(Arrays.asList())) + .withTemporalAggregation( + new TemporalAggregation().withType(TemporalAggregationType.SUM)), + new SignalSource().withSignalSourceId("anvx") + .withSourceAmwAccountManagedIdentity("vtvudutncormr") + .withSourceAmwAccountResourceId("xqtvcofu") + .withMetricNamespace("f") + .withMetricName("vkg") + .withFilters(Arrays.asList()) + .withSpatialAggregation( + new SpatialAggregation().withType(SpatialAggregationType.COUNT) + .withDimensions(Arrays.asList())) + .withTemporalAggregation( + new TemporalAggregation().withType(TemporalAggregationType.RATE)), + new SignalSource() + .withSignalSourceId("gdknnqv") + .withSourceAmwAccountManagedIdentity("aznqntoru") + .withSourceAmwAccountResourceId("sgsahmkycgr") + .withMetricNamespace("uwjuetaeburuvdmo") + .withMetricName("s") + .withFilters(Arrays.asList()) + .withSpatialAggregation( + new SpatialAggregation().withType(SpatialAggregationType.AVERAGE) + .withDimensions(Arrays.asList())) + .withTemporalAggregation( + new TemporalAggregation().withType(TemporalAggregationType.IRATE)))) + .withSignalFormula("xwabmqoe")) + .withTotalSignals(new Signal() + .withSignalSources(Arrays.asList( + new SignalSource().withSignalSourceId("frvtpuqu") + .withSourceAmwAccountManagedIdentity("mqlgk") + .withSourceAmwAccountResourceId("btndo") + .withMetricNamespace("ongbjcnt") + .withMetricName("jitcjedftwwaez") + .withFilters(Arrays.asList()) + .withSpatialAggregation( + new SpatialAggregation().withType(SpatialAggregationType.SUM) + .withDimensions(Arrays.asList())) + .withTemporalAggregation( + new TemporalAggregation().withType(TemporalAggregationType.SUM)), + new SignalSource().withSignalSourceId("v") + .withSourceAmwAccountManagedIdentity("c") + .withSourceAmwAccountResourceId("zfoqouicybxar") + .withMetricNamespace("gszufoxciqopid") + .withMetricName("amcio") + .withFilters(Arrays.asList()) + .withSpatialAggregation( + new SpatialAggregation().withType(SpatialAggregationType.MAX) + .withDimensions(Arrays.asList())) + .withTemporalAggregation( + new TemporalAggregation().withType(TemporalAggregationType.MIN)))) + .withSignalFormula("haz")) + .withSignals(new Signal() + .withSignalSources(Arrays.asList( + new SignalSource().withSignalSourceId("nz") + .withSourceAmwAccountManagedIdentity("onlwntoeg") + .withSourceAmwAccountResourceId("kdwbwhkszz") + .withMetricNamespace("mrv") + .withMetricName("xztvbtqgsfraoyzk") + .withFilters(Arrays.asList()) + .withSpatialAggregation( + new SpatialAggregation().withType(SpatialAggregationType.AVERAGE) + .withDimensions(Arrays.asList())) + .withTemporalAggregation( + new TemporalAggregation().withType(TemporalAggregationType.AVERAGE)), + new SignalSource().withSignalSourceId("tlmngu") + .withSourceAmwAccountManagedIdentity("aw") + .withSourceAmwAccountResourceId("aldsy") + .withMetricNamespace("uximerqfobw") + .withMetricName("znkbykutwpfhpagm") + .withFilters(Arrays.asList()) + .withSpatialAggregation( + new SpatialAggregation().withType(SpatialAggregationType.MAX) + .withDimensions(Arrays.asList())) + .withTemporalAggregation( + new TemporalAggregation().withType(TemporalAggregationType.RATE)))) + .withSignalFormula("kdsnfdsdoakgtdl")) + .withWindowUptimeCriteria(new WindowUptimeCriteria().withTarget(85.74386556222765) + .withComparator(WindowUptimeCriteriaComparator.GREATER_THAN)))) + .withIdentity(new ManagedServiceIdentity().withType(ManagedServiceIdentityType.SYSTEM_ASSIGNED) + .withUserAssignedIdentities( + mapOf("enuuzkopbm", new UserAssignedIdentity(), "mlmz", new UserAssignedIdentity()))), + com.azure.core.util.Context.NONE) + .getValue(); + + Assertions.assertEquals("lhalnswh", response.properties().description()); + Assertions.assertEquals(Category.AVAILABILITY, response.properties().category()); + Assertions.assertEquals(EvaluationType.WINDOW_BASED, response.properties().evaluationType()); + Assertions.assertEquals("bwemhairs", response.properties().destinationAmwAccounts().get(0).resourceId()); + Assertions.assertEquals("rgzdwmsweyp", response.properties().destinationAmwAccounts().get(0).identity()); + Assertions.assertEquals(33.494544229054966, response.properties().baselineProperties().baseline().value()); + Assertions.assertEquals(767551661, + response.properties().baselineProperties().baseline().evaluationPeriodDays()); + Assertions.assertEquals(EvaluationCalculationType.ROLLING_DAYS, + response.properties().baselineProperties().baseline().evaluationCalculationType()); + Assertions.assertTrue(response.properties().enableAlert()); + Assertions.assertEquals("ty", + response.properties().sliProperties().goodSignals().signalSources().get(0).signalSourceId()); + Assertions.assertEquals("hevxcced", + response.properties() + .sliProperties() + .goodSignals() + .signalSources() + .get(0) + .sourceAmwAccountManagedIdentity()); + Assertions.assertEquals("pnmdyodnwzxltjcv", + response.properties().sliProperties().goodSignals().signalSources().get(0).sourceAmwAccountResourceId()); + Assertions.assertEquals("hlt", + response.properties().sliProperties().goodSignals().signalSources().get(0).metricNamespace()); + Assertions.assertEquals("ugcxnavvwxq", + response.properties().sliProperties().goodSignals().signalSources().get(0).metricName()); + Assertions.assertEquals(SpatialAggregationType.MIN, + response.properties().sliProperties().goodSignals().signalSources().get(0).spatialAggregation().type()); + Assertions.assertEquals(TemporalAggregationType.MIN, + response.properties().sliProperties().goodSignals().signalSources().get(0).temporalAggregation().type()); + Assertions.assertEquals("kqnyh", response.properties().sliProperties().goodSignals().signalFormula()); + Assertions.assertEquals("j", + response.properties().sliProperties().totalSignals().signalSources().get(0).signalSourceId()); + Assertions.assertEquals("jivfxzsjabib", + response.properties() + .sliProperties() + .totalSignals() + .signalSources() + .get(0) + .sourceAmwAccountManagedIdentity()); + Assertions.assertEquals("ystawfsdjpvkvp", + response.properties().sliProperties().totalSignals().signalSources().get(0).sourceAmwAccountResourceId()); + Assertions.assertEquals("jxbkzbzkdvn", + response.properties().sliProperties().totalSignals().signalSources().get(0).metricNamespace()); + Assertions.assertEquals("jabudurgkakmo", + response.properties().sliProperties().totalSignals().signalSources().get(0).metricName()); + Assertions.assertEquals(SpatialAggregationType.MAX, + response.properties().sliProperties().totalSignals().signalSources().get(0).spatialAggregation().type()); + Assertions.assertEquals(TemporalAggregationType.AVERAGE, + response.properties().sliProperties().totalSignals().signalSources().get(0).temporalAggregation().type()); + Assertions.assertEquals("jjklff", response.properties().sliProperties().totalSignals().signalFormula()); + Assertions.assertEquals("uwqlgzrfzeey", + response.properties().sliProperties().signals().signalSources().get(0).signalSourceId()); + Assertions.assertEquals("bizikayuhq", + response.properties().sliProperties().signals().signalSources().get(0).sourceAmwAccountManagedIdentity()); + Assertions.assertEquals("bjbsybb", + response.properties().sliProperties().signals().signalSources().get(0).sourceAmwAccountResourceId()); + Assertions.assertEquals("wrv", + response.properties().sliProperties().signals().signalSources().get(0).metricNamespace()); + Assertions.assertEquals("ldgmfpgvmpip", + response.properties().sliProperties().signals().signalSources().get(0).metricName()); + Assertions.assertEquals(SpatialAggregationType.MAX, + response.properties().sliProperties().signals().signalSources().get(0).spatialAggregation().type()); + Assertions.assertEquals(TemporalAggregationType.DELTA, + response.properties().sliProperties().signals().signalSources().get(0).temporalAggregation().type()); + Assertions.assertEquals("thaqfxssmwu", response.properties().sliProperties().signals().signalFormula()); + Assertions.assertEquals(31.752490870226723, + response.properties().sliProperties().windowUptimeCriteria().target()); + Assertions.assertEquals(WindowUptimeCriteriaComparator.GREATER_THAN, + response.properties().sliProperties().windowUptimeCriteria().comparator()); + Assertions.assertEquals(ManagedServiceIdentityType.SYSTEM_ASSIGNED, response.identity().type()); + } + + // Use "Map.of" if available + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/SlisDeleteByResourceGroupWithResponseMockTests.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/SlisDeleteByResourceGroupWithResponseMockTests.java new file mode 100644 index 000000000000..ff20a50132fd --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/SlisDeleteByResourceGroupWithResponseMockTests.java @@ -0,0 +1,33 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.generated; + +import com.azure.core.credential.AccessToken; +import com.azure.core.http.HttpClient; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.models.AzureCloud; +import com.azure.core.test.http.MockHttpResponse; +import com.azure.resourcemanager.monitor.slis.SlisManager; +import java.nio.charset.StandardCharsets; +import java.time.OffsetDateTime; +import org.junit.jupiter.api.Test; +import reactor.core.publisher.Mono; + +public final class SlisDeleteByResourceGroupWithResponseMockTests { + @Test + public void testDeleteWithResponse() throws Exception { + String responseStr = "{}"; + + HttpClient httpClient + = response -> Mono.just(new MockHttpResponse(response, 200, responseStr.getBytes(StandardCharsets.UTF_8))); + SlisManager manager = SlisManager.configure() + .withHttpClient(httpClient) + .authenticate(tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), + new AzureProfile("", "", AzureCloud.AZURE_PUBLIC_CLOUD)); + + manager.slis().deleteByResourceGroupWithResponse("rqmq", "ldvriiiojnalghfk", com.azure.core.util.Context.NONE); + + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/SlisGetWithResponseMockTests.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/SlisGetWithResponseMockTests.java new file mode 100644 index 000000000000..4c7abc77286f --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/SlisGetWithResponseMockTests.java @@ -0,0 +1,115 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.generated; + +import com.azure.core.credential.AccessToken; +import com.azure.core.http.HttpClient; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.models.AzureCloud; +import com.azure.core.test.http.MockHttpResponse; +import com.azure.resourcemanager.monitor.slis.SlisManager; +import com.azure.resourcemanager.monitor.slis.models.Category; +import com.azure.resourcemanager.monitor.slis.models.EvaluationCalculationType; +import com.azure.resourcemanager.monitor.slis.models.EvaluationType; +import com.azure.resourcemanager.monitor.slis.models.ManagedServiceIdentityType; +import com.azure.resourcemanager.monitor.slis.models.Sli; +import com.azure.resourcemanager.monitor.slis.models.SpatialAggregationType; +import com.azure.resourcemanager.monitor.slis.models.TemporalAggregationType; +import com.azure.resourcemanager.monitor.slis.models.WindowUptimeCriteriaComparator; +import java.nio.charset.StandardCharsets; +import java.time.OffsetDateTime; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import reactor.core.publisher.Mono; + +public final class SlisGetWithResponseMockTests { + @Test + public void testGetWithResponse() throws Exception { + String responseStr + = "{\"properties\":{\"provisioningState\":\"Failed\",\"description\":\"fpubjibwwi\",\"category\":\"Latency\",\"evaluationType\":\"RequestBased\",\"executionState\":{\"state\":\"qkvpuvksgplsakn\",\"message\":\"fsynljphuop\"},\"destinationAmwAccounts\":[{\"resourceId\":\"dlqiyntorzih\",\"identity\":\"eosjswsr\"},{\"resourceId\":\"slyzrpzbchckqq\",\"identity\":\"qioxi\"},{\"resourceId\":\"suiizynkedyat\",\"identity\":\"wyhqmibzyhwits\"}],\"destinationMetrics\":[{\"metricNamespace\":\"yynpcdpumnzgmwz\",\"metricName\":\"mabiknsorgjhxb\"}],\"baselineProperties\":{\"baseline\":{\"value\":50.25586250539239,\"evaluationPeriodDays\":1166597262,\"evaluationCalculationType\":\"RollingDays\"}},\"streamingRuleId\":\"rlkdmtncvokotl\",\"streamingRuleLastUpdatedTimestamp\":\"2021-09-05T12:27:29Z\",\"enableAlert\":false,\"sliProperties\":{\"goodSignals\":{\"signalSources\":[{\"signalSourceId\":\"syocogjltdtbnnha\",\"sourceAmwAccountManagedIdentity\":\"oocrkvcikhnv\",\"sourceAmwAccountResourceId\":\"amqgxqquezikyw\",\"metricNamespace\":\"gxk\",\"metricName\":\"lla\",\"filters\":[],\"spatialAggregation\":{\"type\":\"Max\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Min\"}},{\"signalSourceId\":\"lwuip\",\"sourceAmwAccountManagedIdentity\":\"ccjzkzivgvv\",\"sourceAmwAccountResourceId\":\"nayrhyrnxxmueedn\",\"metricNamespace\":\"rdvstkwqqtch\",\"metricName\":\"alm\",\"filters\":[],\"spatialAggregation\":{\"type\":\"Sum\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"IRate\"}}],\"signalFormula\":\"d\"},\"totalSignals\":{\"signalSources\":[{\"signalSourceId\":\"gdv\",\"sourceAmwAccountManagedIdentity\":\"vgpiohgwxrt\",\"sourceAmwAccountResourceId\":\"udxepxgyqagv\",\"metricNamespace\":\"vmnpkukghimdblx\",\"metricName\":\"wi\",\"filters\":[],\"spatialAggregation\":{\"type\":\"Average\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Sum\"}},{\"signalSourceId\":\"jhfjxwm\",\"sourceAmwAccountManagedIdentity\":\"zk\",\"sourceAmwAccountResourceId\":\"foqreyfkzik\",\"metricNamespace\":\"jawneaiv\",\"metricName\":\"wczelpci\",\"filters\":[],\"spatialAggregation\":{\"type\":\"Count\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Increase\"}}],\"signalFormula\":\"sfeaenwabfat\"},\"signals\":{\"signalSources\":[{\"signalSourceId\":\"dxbjhwuaanozj\",\"sourceAmwAccountManagedIdentity\":\"sphyoulpjrvxa\",\"sourceAmwAccountResourceId\":\"l\",\"metricNamespace\":\"vimjwos\",\"metricName\":\"tx\",\"filters\":[],\"spatialAggregation\":{\"type\":\"Sum\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Average\"}},{\"signalSourceId\":\"skfc\",\"sourceAmwAccountManagedIdentity\":\"tq\",\"sourceAmwAccountResourceId\":\"miekkezzikhlyfjh\",\"metricNamespace\":\"gqggebdunygae\",\"metricName\":\"idb\",\"filters\":[],\"spatialAggregation\":{\"type\":\"Count\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Rate\"}},{\"signalSourceId\":\"t\",\"sourceAmwAccountManagedIdentity\":\"xllrxcyjm\",\"sourceAmwAccountResourceId\":\"a\",\"metricNamespace\":\"su\",\"metricName\":\"arm\",\"filters\":[],\"spatialAggregation\":{\"type\":\"Count\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Rate\"}},{\"signalSourceId\":\"mjsjqb\",\"sourceAmwAccountManagedIdentity\":\"hhyxxrw\",\"sourceAmwAccountResourceId\":\"yc\",\"metricNamespace\":\"duhpk\",\"metricName\":\"kgymareqnajxqug\",\"filters\":[],\"spatialAggregation\":{\"type\":\"Max\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Delta\"}}],\"signalFormula\":\"ycubeddgs\"},\"windowUptimeCriteria\":{\"target\":74.75268861048747,\"comparator\":\">=\"}}},\"identity\":{\"principalId\":\"qal\",\"tenantId\":\"mnjijpxacqqudf\",\"type\":\"UserAssigned\",\"userAssignedIdentities\":{\"evfdnwnwm\":{\"principalId\":\"aaabjyvayff\",\"clientId\":\"rzrtuzqogsex\"},\"thzvaytdwkqbrqu\":{\"principalId\":\"zsyyceuzso\",\"clientId\":\"judpfrxt\"},\"oaxoruzfgsqu\":{\"principalId\":\"axhexiilivp\",\"clientId\":\"iirqtd\"}}},\"id\":\"xrxxlep\",\"name\":\"ramxjezwlwnw\",\"type\":\"uqlcvydy\"}"; + + HttpClient httpClient + = response -> Mono.just(new MockHttpResponse(response, 200, responseStr.getBytes(StandardCharsets.UTF_8))); + SlisManager manager = SlisManager.configure() + .withHttpClient(httpClient) + .authenticate(tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), + new AzureProfile("", "", AzureCloud.AZURE_PUBLIC_CLOUD)); + + Sli response + = manager.slis().getWithResponse("nzar", "wlquuijfqkace", com.azure.core.util.Context.NONE).getValue(); + + Assertions.assertEquals("fpubjibwwi", response.properties().description()); + Assertions.assertEquals(Category.LATENCY, response.properties().category()); + Assertions.assertEquals(EvaluationType.REQUEST_BASED, response.properties().evaluationType()); + Assertions.assertEquals("dlqiyntorzih", response.properties().destinationAmwAccounts().get(0).resourceId()); + Assertions.assertEquals("eosjswsr", response.properties().destinationAmwAccounts().get(0).identity()); + Assertions.assertEquals(50.25586250539239, response.properties().baselineProperties().baseline().value()); + Assertions.assertEquals(1166597262, + response.properties().baselineProperties().baseline().evaluationPeriodDays()); + Assertions.assertEquals(EvaluationCalculationType.ROLLING_DAYS, + response.properties().baselineProperties().baseline().evaluationCalculationType()); + Assertions.assertFalse(response.properties().enableAlert()); + Assertions.assertEquals("syocogjltdtbnnha", + response.properties().sliProperties().goodSignals().signalSources().get(0).signalSourceId()); + Assertions.assertEquals("oocrkvcikhnv", + response.properties() + .sliProperties() + .goodSignals() + .signalSources() + .get(0) + .sourceAmwAccountManagedIdentity()); + Assertions.assertEquals("amqgxqquezikyw", + response.properties().sliProperties().goodSignals().signalSources().get(0).sourceAmwAccountResourceId()); + Assertions.assertEquals("gxk", + response.properties().sliProperties().goodSignals().signalSources().get(0).metricNamespace()); + Assertions.assertEquals("lla", + response.properties().sliProperties().goodSignals().signalSources().get(0).metricName()); + Assertions.assertEquals(SpatialAggregationType.MAX, + response.properties().sliProperties().goodSignals().signalSources().get(0).spatialAggregation().type()); + Assertions.assertEquals(TemporalAggregationType.MIN, + response.properties().sliProperties().goodSignals().signalSources().get(0).temporalAggregation().type()); + Assertions.assertEquals("d", response.properties().sliProperties().goodSignals().signalFormula()); + Assertions.assertEquals("gdv", + response.properties().sliProperties().totalSignals().signalSources().get(0).signalSourceId()); + Assertions.assertEquals("vgpiohgwxrt", + response.properties() + .sliProperties() + .totalSignals() + .signalSources() + .get(0) + .sourceAmwAccountManagedIdentity()); + Assertions.assertEquals("udxepxgyqagv", + response.properties().sliProperties().totalSignals().signalSources().get(0).sourceAmwAccountResourceId()); + Assertions.assertEquals("vmnpkukghimdblx", + response.properties().sliProperties().totalSignals().signalSources().get(0).metricNamespace()); + Assertions.assertEquals("wi", + response.properties().sliProperties().totalSignals().signalSources().get(0).metricName()); + Assertions.assertEquals(SpatialAggregationType.AVERAGE, + response.properties().sliProperties().totalSignals().signalSources().get(0).spatialAggregation().type()); + Assertions.assertEquals(TemporalAggregationType.SUM, + response.properties().sliProperties().totalSignals().signalSources().get(0).temporalAggregation().type()); + Assertions.assertEquals("sfeaenwabfat", response.properties().sliProperties().totalSignals().signalFormula()); + Assertions.assertEquals("dxbjhwuaanozj", + response.properties().sliProperties().signals().signalSources().get(0).signalSourceId()); + Assertions.assertEquals("sphyoulpjrvxa", + response.properties().sliProperties().signals().signalSources().get(0).sourceAmwAccountManagedIdentity()); + Assertions.assertEquals("l", + response.properties().sliProperties().signals().signalSources().get(0).sourceAmwAccountResourceId()); + Assertions.assertEquals("vimjwos", + response.properties().sliProperties().signals().signalSources().get(0).metricNamespace()); + Assertions.assertEquals("tx", + response.properties().sliProperties().signals().signalSources().get(0).metricName()); + Assertions.assertEquals(SpatialAggregationType.SUM, + response.properties().sliProperties().signals().signalSources().get(0).spatialAggregation().type()); + Assertions.assertEquals(TemporalAggregationType.AVERAGE, + response.properties().sliProperties().signals().signalSources().get(0).temporalAggregation().type()); + Assertions.assertEquals("ycubeddgs", response.properties().sliProperties().signals().signalFormula()); + Assertions.assertEquals(74.75268861048747, + response.properties().sliProperties().windowUptimeCriteria().target()); + Assertions.assertEquals(WindowUptimeCriteriaComparator.GREATER_THAN_OR_EQUAL, + response.properties().sliProperties().windowUptimeCriteria().comparator()); + Assertions.assertEquals(ManagedServiceIdentityType.USER_ASSIGNED, response.identity().type()); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/SlisListByParentMockTests.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/SlisListByParentMockTests.java new file mode 100644 index 000000000000..96e01a0cdcf3 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/SlisListByParentMockTests.java @@ -0,0 +1,230 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.generated; + +import com.azure.core.credential.AccessToken; +import com.azure.core.http.HttpClient; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.models.AzureCloud; +import com.azure.core.test.http.MockHttpResponse; +import com.azure.resourcemanager.monitor.slis.SlisManager; +import com.azure.resourcemanager.monitor.slis.models.Category; +import com.azure.resourcemanager.monitor.slis.models.EvaluationCalculationType; +import com.azure.resourcemanager.monitor.slis.models.EvaluationType; +import com.azure.resourcemanager.monitor.slis.models.ManagedServiceIdentityType; +import com.azure.resourcemanager.monitor.slis.models.Sli; +import com.azure.resourcemanager.monitor.slis.models.SpatialAggregationType; +import com.azure.resourcemanager.monitor.slis.models.TemporalAggregationType; +import com.azure.resourcemanager.monitor.slis.models.WindowUptimeCriteriaComparator; +import java.nio.charset.StandardCharsets; +import java.time.OffsetDateTime; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import reactor.core.publisher.Mono; + +public final class SlisListByParentMockTests { + @Test + public void testListByParent() throws Exception { + String responseStr + = "{\"value\":[{\"properties\":{\"provisioningState\":\"Canceled\",\"description\":\"ahhxvrh\",\"category\":\"Availability\",\"evaluationType\":\"RequestBased\",\"executionState\":{\"state\":\"pjgwwspug\",\"message\":\"tqs\"},\"destinationAmwAccounts\":[{\"resourceId\":\"qxujxukndxd\",\"identity\":\"grjguufzd\"},{\"resourceId\":\"syqtfi\",\"identity\":\"whbotzingamv\"},{\"resourceId\":\"phoszqz\",\"identity\":\"dphqamv\"},{\"resourceId\":\"kfwynw\",\"identity\":\"vtbvkayh\"}],\"destinationMetrics\":[{\"metricNamespace\":\"vyqia\",\"metricName\":\"kzwpcnpw\"}],\"baselineProperties\":{\"baseline\":{\"value\":55.10261161552592,\"evaluationPeriodDays\":48409211,\"evaluationCalculationType\":\"RollingDays\"}},\"streamingRuleId\":\"gvvs\",\"streamingRuleLastUpdatedTimestamp\":\"2021-10-01T18:08:28Z\",\"enableAlert\":false,\"sliProperties\":{\"goodSignals\":{\"signalSources\":[{\"signalSourceId\":\"uq\",\"sourceAmwAccountManagedIdentity\":\"hwyg\",\"sourceAmwAccountResourceId\":\"lvdnkfx\",\"metricNamespace\":\"semdwzrmu\",\"metricName\":\"apfcqdpsq\",\"filters\":[],\"spatialAggregation\":{\"type\":\"Sum\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"IRate\"}}],\"signalFormula\":\"psvuoymgc\"},\"totalSignals\":{\"signalSources\":[{\"signalSourceId\":\"vezrypqlmfeo\",\"sourceAmwAccountManagedIdentity\":\"erqwkyhkobopg\",\"sourceAmwAccountResourceId\":\"edkowepbqpcrfk\",\"metricNamespace\":\"wccsnjvcdwxlpqek\",\"metricName\":\"tn\",\"filters\":[],\"spatialAggregation\":{\"type\":\"Count\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Min\"}}],\"signalFormula\":\"jsyingwfqatm\"},\"signals\":{\"signalSources\":[{\"signalSourceId\":\"tmdvypgikdgs\",\"sourceAmwAccountManagedIdentity\":\"ywkbirryuzhlhkjo\",\"sourceAmwAccountResourceId\":\"rvqqaatj\",\"metricNamespace\":\"nrvgoupmfiibfgg\",\"metricName\":\"ioolvrwxkvtkkgll\",\"filters\":[],\"spatialAggregation\":{\"type\":\"Min\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Min\"}},{\"signalSourceId\":\"ygvjayvblmh\",\"sourceAmwAccountManagedIdentity\":\"k\",\"sourceAmwAccountResourceId\":\"uhbxvvy\",\"metricNamespace\":\"gsopbyrqufegxu\",\"metricName\":\"wz\",\"filters\":[],\"spatialAggregation\":{\"type\":\"Min\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"IRate\"}}],\"signalFormula\":\"hlmctlpdngitvgb\"},\"windowUptimeCriteria\":{\"target\":79.06151231394061,\"comparator\":\"<\"}}},\"identity\":{\"principalId\":\"myijejvegr\",\"tenantId\":\"pna\",\"type\":\"SystemAssigned,UserAssigned\",\"userAssignedIdentities\":{\"nhyjsv\":{\"principalId\":\"cbdreaxhcexd\",\"clientId\":\"vqahqkghtpwi\"},\"jqppyostronzmy\":{\"principalId\":\"cxzbfvoowvr\",\"clientId\":\"t\"},\"afxtsgum\":{\"principalId\":\"fipns\",\"clientId\":\"mcwaekrrjr\"},\"felfktg\":{\"principalId\":\"glikkxwslolb\",\"clientId\":\"vuzlm\"}}},\"id\":\"crpw\",\"name\":\"xeznoi\",\"type\":\"brnjwmw\"}]}"; + + HttpClient httpClient + = response -> Mono.just(new MockHttpResponse(response, 200, responseStr.getBytes(StandardCharsets.UTF_8))); + SlisManager manager = SlisManager.configure() + .withHttpClient(httpClient) + .authenticate(tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), + new AzureProfile("", "", AzureCloud.AZURE_PUBLIC_CLOUD)); + + PagedIterable response = manager.slis().listByParent("tvsexsowuel", com.azure.core.util.Context.NONE); + + Assertions.assertEquals("ahhxvrh", response.iterator().next().properties().description()); + Assertions.assertEquals(Category.AVAILABILITY, response.iterator().next().properties().category()); + Assertions.assertEquals(EvaluationType.REQUEST_BASED, response.iterator().next().properties().evaluationType()); + Assertions.assertEquals("qxujxukndxd", + response.iterator().next().properties().destinationAmwAccounts().get(0).resourceId()); + Assertions.assertEquals("grjguufzd", + response.iterator().next().properties().destinationAmwAccounts().get(0).identity()); + Assertions.assertEquals(55.10261161552592, + response.iterator().next().properties().baselineProperties().baseline().value()); + Assertions.assertEquals(48409211, + response.iterator().next().properties().baselineProperties().baseline().evaluationPeriodDays()); + Assertions.assertEquals(EvaluationCalculationType.ROLLING_DAYS, + response.iterator().next().properties().baselineProperties().baseline().evaluationCalculationType()); + Assertions.assertFalse(response.iterator().next().properties().enableAlert()); + Assertions.assertEquals("uq", + response.iterator() + .next() + .properties() + .sliProperties() + .goodSignals() + .signalSources() + .get(0) + .signalSourceId()); + Assertions.assertEquals("hwyg", + response.iterator() + .next() + .properties() + .sliProperties() + .goodSignals() + .signalSources() + .get(0) + .sourceAmwAccountManagedIdentity()); + Assertions.assertEquals("lvdnkfx", + response.iterator() + .next() + .properties() + .sliProperties() + .goodSignals() + .signalSources() + .get(0) + .sourceAmwAccountResourceId()); + Assertions.assertEquals("semdwzrmu", + response.iterator() + .next() + .properties() + .sliProperties() + .goodSignals() + .signalSources() + .get(0) + .metricNamespace()); + Assertions.assertEquals("apfcqdpsq", + response.iterator().next().properties().sliProperties().goodSignals().signalSources().get(0).metricName()); + Assertions.assertEquals(SpatialAggregationType.SUM, + response.iterator() + .next() + .properties() + .sliProperties() + .goodSignals() + .signalSources() + .get(0) + .spatialAggregation() + .type()); + Assertions.assertEquals(TemporalAggregationType.IRATE, + response.iterator() + .next() + .properties() + .sliProperties() + .goodSignals() + .signalSources() + .get(0) + .temporalAggregation() + .type()); + Assertions.assertEquals("psvuoymgc", + response.iterator().next().properties().sliProperties().goodSignals().signalFormula()); + Assertions.assertEquals("vezrypqlmfeo", + response.iterator() + .next() + .properties() + .sliProperties() + .totalSignals() + .signalSources() + .get(0) + .signalSourceId()); + Assertions.assertEquals("erqwkyhkobopg", + response.iterator() + .next() + .properties() + .sliProperties() + .totalSignals() + .signalSources() + .get(0) + .sourceAmwAccountManagedIdentity()); + Assertions.assertEquals("edkowepbqpcrfk", + response.iterator() + .next() + .properties() + .sliProperties() + .totalSignals() + .signalSources() + .get(0) + .sourceAmwAccountResourceId()); + Assertions.assertEquals("wccsnjvcdwxlpqek", + response.iterator() + .next() + .properties() + .sliProperties() + .totalSignals() + .signalSources() + .get(0) + .metricNamespace()); + Assertions.assertEquals("tn", + response.iterator().next().properties().sliProperties().totalSignals().signalSources().get(0).metricName()); + Assertions.assertEquals(SpatialAggregationType.COUNT, + response.iterator() + .next() + .properties() + .sliProperties() + .totalSignals() + .signalSources() + .get(0) + .spatialAggregation() + .type()); + Assertions.assertEquals(TemporalAggregationType.MIN, + response.iterator() + .next() + .properties() + .sliProperties() + .totalSignals() + .signalSources() + .get(0) + .temporalAggregation() + .type()); + Assertions.assertEquals("jsyingwfqatm", + response.iterator().next().properties().sliProperties().totalSignals().signalFormula()); + Assertions.assertEquals("tmdvypgikdgs", + response.iterator().next().properties().sliProperties().signals().signalSources().get(0).signalSourceId()); + Assertions.assertEquals("ywkbirryuzhlhkjo", + response.iterator() + .next() + .properties() + .sliProperties() + .signals() + .signalSources() + .get(0) + .sourceAmwAccountManagedIdentity()); + Assertions.assertEquals("rvqqaatj", + response.iterator() + .next() + .properties() + .sliProperties() + .signals() + .signalSources() + .get(0) + .sourceAmwAccountResourceId()); + Assertions.assertEquals("nrvgoupmfiibfgg", + response.iterator().next().properties().sliProperties().signals().signalSources().get(0).metricNamespace()); + Assertions.assertEquals("ioolvrwxkvtkkgll", + response.iterator().next().properties().sliProperties().signals().signalSources().get(0).metricName()); + Assertions.assertEquals(SpatialAggregationType.MIN, + response.iterator() + .next() + .properties() + .sliProperties() + .signals() + .signalSources() + .get(0) + .spatialAggregation() + .type()); + Assertions.assertEquals(TemporalAggregationType.MIN, + response.iterator() + .next() + .properties() + .sliProperties() + .signals() + .signalSources() + .get(0) + .temporalAggregation() + .type()); + Assertions.assertEquals("hlmctlpdngitvgb", + response.iterator().next().properties().sliProperties().signals().signalFormula()); + Assertions.assertEquals(79.06151231394061, + response.iterator().next().properties().sliProperties().windowUptimeCriteria().target()); + Assertions.assertEquals(WindowUptimeCriteriaComparator.LESS_THAN, + response.iterator().next().properties().sliProperties().windowUptimeCriteria().comparator()); + Assertions.assertEquals(ManagedServiceIdentityType.SYSTEM_ASSIGNED_USER_ASSIGNED, + response.iterator().next().identity().type()); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/SpatialAggregationTests.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/SpatialAggregationTests.java new file mode 100644 index 000000000000..41d40d16ac55 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/SpatialAggregationTests.java @@ -0,0 +1,30 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.monitor.slis.models.SpatialAggregation; +import com.azure.resourcemanager.monitor.slis.models.SpatialAggregationType; +import java.util.Arrays; +import org.junit.jupiter.api.Assertions; + +public final class SpatialAggregationTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + SpatialAggregation model = BinaryData.fromString("{\"type\":\"Max\",\"dimensions\":[\"hxpkd\",\"zb\"]}") + .toObject(SpatialAggregation.class); + Assertions.assertEquals(SpatialAggregationType.MAX, model.type()); + Assertions.assertEquals("hxpkd", model.dimensions().get(0)); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + SpatialAggregation model = new SpatialAggregation().withType(SpatialAggregationType.MAX) + .withDimensions(Arrays.asList("hxpkd", "zb")); + model = BinaryData.fromObject(model).toObject(SpatialAggregation.class); + Assertions.assertEquals(SpatialAggregationType.MAX, model.type()); + Assertions.assertEquals("hxpkd", model.dimensions().get(0)); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/TemporalAggregationTests.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/TemporalAggregationTests.java new file mode 100644 index 000000000000..b1c57fc3bc6b --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/TemporalAggregationTests.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.resourcemanager.monitor.slis.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.monitor.slis.models.TemporalAggregation; +import com.azure.resourcemanager.monitor.slis.models.TemporalAggregationType; +import org.junit.jupiter.api.Assertions; + +public final class TemporalAggregationTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + TemporalAggregation model = BinaryData.fromString("{\"type\":\"Max\",\"windowSizeMinutes\":718463085}") + .toObject(TemporalAggregation.class); + Assertions.assertEquals(TemporalAggregationType.MAX, model.type()); + Assertions.assertEquals(718463085, model.windowSizeMinutes()); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + TemporalAggregation model + = new TemporalAggregation().withType(TemporalAggregationType.MAX).withWindowSizeMinutes(718463085); + model = BinaryData.fromObject(model).toObject(TemporalAggregation.class); + Assertions.assertEquals(TemporalAggregationType.MAX, model.type()); + Assertions.assertEquals(718463085, model.windowSizeMinutes()); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/UserAssignedIdentityTests.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/UserAssignedIdentityTests.java new file mode 100644 index 000000000000..e188a23a4a4a --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/UserAssignedIdentityTests.java @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.monitor.slis.models.UserAssignedIdentity; + +public final class UserAssignedIdentityTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + UserAssignedIdentity model + = BinaryData.fromString("{\"principalId\":\"cnjbkcnxdhbt\",\"clientId\":\"phywpnvj\"}") + .toObject(UserAssignedIdentity.class); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + UserAssignedIdentity model = new UserAssignedIdentity(); + model = BinaryData.fromObject(model).toObject(UserAssignedIdentity.class); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/WindowUptimeCriteriaTests.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/WindowUptimeCriteriaTests.java new file mode 100644 index 000000000000..f8e8fd3a8cf5 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/WindowUptimeCriteriaTests.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.resourcemanager.monitor.slis.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.monitor.slis.models.WindowUptimeCriteria; +import com.azure.resourcemanager.monitor.slis.models.WindowUptimeCriteriaComparator; +import org.junit.jupiter.api.Assertions; + +public final class WindowUptimeCriteriaTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + WindowUptimeCriteria model = BinaryData.fromString("{\"target\":69.3418872608996,\"comparator\":\"<\"}") + .toObject(WindowUptimeCriteria.class); + Assertions.assertEquals(69.3418872608996, model.target()); + Assertions.assertEquals(WindowUptimeCriteriaComparator.LESS_THAN, model.comparator()); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + WindowUptimeCriteria model = new WindowUptimeCriteria().withTarget(69.3418872608996) + .withComparator(WindowUptimeCriteriaComparator.LESS_THAN); + model = BinaryData.fromObject(model).toObject(WindowUptimeCriteria.class); + Assertions.assertEquals(69.3418872608996, model.target()); + Assertions.assertEquals(WindowUptimeCriteriaComparator.LESS_THAN, model.comparator()); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/tsp-location.yaml b/sdk/monitor/azure-resourcemanager-monitor-slis/tsp-location.yaml new file mode 100644 index 000000000000..b22197448f69 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/monitoringservice/resource-manager/Microsoft.Monitor/Slis +commit: d32a3f6cc49c6dd6604161f8c7cee7c95a84c578 +repo: Azure/azure-rest-api-specs +additionalDirectories: diff --git a/sdk/monitor/ci.yml b/sdk/monitor/ci.yml index 40b8d119c616..92f152a46816 100644 --- a/sdk/monitor/ci.yml +++ b/sdk/monitor/ci.yml @@ -42,38 +42,42 @@ pr: - sdk/monitor/azure-resourcemanager-monitor/pom.xml parameters: -- name: release_dependsonlivetests - displayName: 'Release depends on live tests' - type: boolean - default: true -- name: release_azuremonitoringestion - displayName: 'azure-monitor-ingestion' - type: boolean - default: true -- name: release_azuremonitoropentelemetryexporter - displayName: 'azure-monitor-opentelemetry-exporter' - type: boolean - default: true -- name: release_azuremonitoropentelemetryautoconfigure - displayName: 'azure-monitor-opentelemetry-autoconfigure' - type: boolean - default: true -- name: release_azuremonitorquery - displayName: 'azure-monitor-query' - type: boolean - default: true -- name: release_azuremonitorquerylogs - displayName: 'azure-monitor-query-logs' - type: boolean - default: true -- name: release_azuremonitorquerymetrics - displayName: 'azure-monitor-query-metrics' - type: boolean - default: true -- name: release_azureresourcemanagermonitor - displayName: 'azure-resourcemanager-monitor' - type: boolean - default: false + - name: release_dependsonlivetests + displayName: Release depends on live tests + type: boolean + default: true + - name: release_azuremonitoringestion + displayName: azure-monitor-ingestion + type: boolean + default: true + - name: release_azuremonitoropentelemetryexporter + displayName: azure-monitor-opentelemetry-exporter + type: boolean + default: true + - name: release_azuremonitoropentelemetryautoconfigure + displayName: azure-monitor-opentelemetry-autoconfigure + type: boolean + default: true + - name: release_azuremonitorquery + displayName: azure-monitor-query + type: boolean + default: true + - name: release_azuremonitorquerylogs + displayName: azure-monitor-query-logs + type: boolean + default: true + - name: release_azuremonitorquerymetrics + displayName: azure-monitor-query-metrics + type: boolean + default: true + - name: release_azureresourcemanagermonitor + displayName: azure-resourcemanager-monitor + type: boolean + default: false + - name: release_azureresourcemanagermonitorslis + displayName: azure-resourcemanager-monitor-slis + type: boolean + default: false extends: template: ../../eng/pipelines/templates/stages/archetype-sdk-client.yml @@ -108,11 +112,14 @@ extends: groupId: com.azure.resourcemanager safeName: azureresourcemanagermonitor releaseInBatch: ${{ parameters.release_azureresourcemanagermonitor }} + - name: azure-resourcemanager-monitor-slis + groupId: com.azure.resourcemanager + safeName: azureresourcemanagermonitorslis + releaseInBatch: ${{ parameters.release_azureresourcemanagermonitorslis }} AdditionalModules: - name: azure-monitor-query-perf groupId: com.azure - name: azure-monitor-ingestion-perf groupId: com.azure - # required by the above perf library - name: perf-test-core groupId: com.azure diff --git a/sdk/monitor/pom.xml b/sdk/monitor/pom.xml index cdaa5e7aa1ee..21c722066070 100644 --- a/sdk/monitor/pom.xml +++ b/sdk/monitor/pom.xml @@ -10,14 +10,15 @@ 1.0.0 - azure-monitor-ingestion - azure-monitor-ingestion-perf - azure-monitor-opentelemetry-exporter - azure-monitor-opentelemetry-autoconfigure - azure-monitor-query - azure-monitor-query-logs - azure-monitor-query-metrics - azure-monitor-query-perf - azure-resourcemanager-monitor + azure-monitor-ingestion + azure-monitor-ingestion-perf + azure-monitor-opentelemetry-autoconfigure + azure-monitor-opentelemetry-exporter + azure-monitor-query + azure-monitor-query-logs + azure-monitor-query-metrics + azure-monitor-query-perf + azure-resourcemanager-monitor + azure-resourcemanager-monitor-slis