diff --git a/eng/versioning/version_client.txt b/eng/versioning/version_client.txt index 2d56a925105a7..16f424c136499 100644 --- a/eng/versioning/version_client.txt +++ b/eng/versioning/version_client.txt @@ -323,6 +323,7 @@ com.azure.resourcemanager:azure-resourcemanager-logz;1.0.0-beta.1;1.0.0-beta.2 com.azure.resourcemanager:azure-resourcemanager-storagepool;1.0.0-beta.1;1.0.0-beta.2 com.azure.resourcemanager:azure-resourcemanager-dataprotection;1.0.0-beta.1;1.0.0-beta.2 com.azure.resourcemanager:azure-resourcemanager-desktopvirtualization;1.0.0-beta.1;1.0.0-beta.2 +com.azure.resourcemanager:azure-resourcemanager-monitor-generated;1.0.0-beta.1;1.0.0-beta.1 com.azure.tools:azure-sdk-archetype;1.0.0;1.0.0 # Unreleased dependencies: Copy the entry from above, prepend "unreleased_" and remove the current diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/CHANGELOG.md b/sdk/monitor/azure-resourcemanager-monitor-generated/CHANGELOG.md new file mode 100644 index 0000000000000..fe1b9f50125e6 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/CHANGELOG.md @@ -0,0 +1,5 @@ +# Release History + +## 1.0.0-beta.1 (2021-12-02) + +- Azure Resource Manager Monitor client library for Java. This package contains Microsoft Azure SDK for Monitor Management SDK. Monitor Management Client. Package tag package-2021-08. For documentation on how to use this package, please see [Azure Management Libraries for Java](https://aka.ms/azsdk/java/mgmt). diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/README.md b/sdk/monitor/azure-resourcemanager-monitor-generated/README.md new file mode 100644 index 0000000000000..c978632fca58a --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/README.md @@ -0,0 +1,102 @@ +# Azure Resource Manager Monitor client library for Java + +Azure Resource Manager Monitor client library for Java. + +This package contains Microsoft Azure SDK for Monitor Management SDK. Monitor Management Client. Package tag package-2021-08. 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-generated;current}) +```xml + + com.azure.resourcemanager + azure-resourcemanager-monitor-generated + 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] package and [Azure Core Netty HTTP][azure_core_http_netty] package provide the default implementation. + +### Authentication + +By default, Azure Active Directory token authentication depends on correct configure of following environment variables. + +- `AZURE_CLIENT_ID` for Azure client ID. +- `AZURE_TENANT_ID` for Azure tenant ID. +- `AZURE_CLIENT_SECRET` or `AZURE_CLIENT_CERTIFICATE_PATH` for client secret or client certificate. + +In addition, Azure subscription ID can be configured via environment variable `AZURE_SUBSCRIPTION_ID`. + +With above configuration, `azure` client can be authenticated by following code: + +```java +AzureProfile profile = new AzureProfile(AzureEnvironment.AZURE); +TokenCredential credential = new DefaultAzureCredentialBuilder() + .authorityHost(profile.getEnvironment().getActiveDirectoryEndpoint()) + .build(); +MonitorManager manager = MonitorManager + .authenticate(credential, profile); +``` + +The sample code assumes global Azure. Please change `AzureEnvironment.AZURE` 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-generated/SAMPLE.md) + + +## Troubleshooting + +## Next steps + +## Contributing + +For details on contributing to this repository, see the [contributing guide](https://github.com/Azure/azure-sdk-for-java/blob/main/CONTRIBUTING.md). + +1. Fork it +1. Create your feature branch (`git checkout -b my-new-feature`) +1. Commit your changes (`git commit -am 'Add some feature'`) +1. Push to the branch (`git push origin my-new-feature`) +1. Create new Pull Request + + +[survey]: https://microsoft.qualtrics.com/jfe/form/SV_ehN0lIk2FKEBkwd?Q_CHL=DOCS +[docs]: https://azure.github.io/azure-sdk-for-java/ +[jdk]: https://docs.microsoft.com/java/azure/jdk/ +[azure_subscription]: https://azure.microsoft.com/free/ +[azure_identity]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/identity/azure-identity +[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 diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/SAMPLE.md b/sdk/monitor/azure-resourcemanager-monitor-generated/SAMPLE.md new file mode 100644 index 0000000000000..588c77c0a6b96 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/SAMPLE.md @@ -0,0 +1,338 @@ +# Code snippets and samples + + +## ScheduledQueryRules + +- [CreateOrUpdate](#scheduledqueryrules_createorupdate) +- [Delete](#scheduledqueryrules_delete) +- [GetByResourceGroup](#scheduledqueryrules_getbyresourcegroup) +- [List](#scheduledqueryrules_list) +- [ListByResourceGroup](#scheduledqueryrules_listbyresourcegroup) +- [Update](#scheduledqueryrules_update) +### ScheduledQueryRules_CreateOrUpdate + +```java +import com.azure.resourcemanager.monitor.generated.models.Actions; +import com.azure.resourcemanager.monitor.generated.models.AlertSeverity; +import com.azure.resourcemanager.monitor.generated.models.Condition; +import com.azure.resourcemanager.monitor.generated.models.ConditionFailingPeriods; +import com.azure.resourcemanager.monitor.generated.models.ConditionOperator; +import com.azure.resourcemanager.monitor.generated.models.Dimension; +import com.azure.resourcemanager.monitor.generated.models.DimensionOperator; +import com.azure.resourcemanager.monitor.generated.models.ScheduledQueryRuleCriteria; +import com.azure.resourcemanager.monitor.generated.models.TimeAggregation; +import java.time.Duration; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; + +/** Samples for ScheduledQueryRules CreateOrUpdate. */ +public final class ScheduledQueryRulesCreateOrUpdateSamples { + /* + * x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2021-08-01/examples/createOrUpdateScheduledQueryRuleSubscription.json + */ + /** + * Sample code: Create or update a scheduled query rule on Subscription. + * + * @param manager Entry point to MonitorManager. + */ + public static void createOrUpdateAScheduledQueryRuleOnSubscription( + com.azure.resourcemanager.monitor.generated.MonitorManager manager) { + manager + .scheduledQueryRules() + .define("perf") + .withRegion("eastus") + .withExistingResourceGroup("QueryResourceGroupName") + .withDescription("Performance rule") + .withSeverity(AlertSeverity.FOUR) + .withEnabled(true) + .withScopes(Arrays.asList("/subscriptions/aaf177ed-1330-a9f2-80ea-fd3d7783b147")) + .withEvaluationFrequency(Duration.parse("PT5M")) + .withWindowSize(Duration.parse("PT10M")) + .withTargetResourceTypes(Arrays.asList("Microsoft.Compute/virtualMachines")) + .withCriteria( + new ScheduledQueryRuleCriteria() + .withAllOf( + Arrays + .asList( + new Condition() + .withQuery("Perf | where ObjectName == \"Processor\"") + .withTimeAggregation(TimeAggregation.AVERAGE) + .withMetricMeasureColumn("% Processor Time") + .withResourceIdColumn("resourceId") + .withDimensions( + Arrays + .asList( + new Dimension() + .withName("ComputerIp") + .withOperator(DimensionOperator.EXCLUDE) + .withValues(Arrays.asList("192.168.1.1")), + new Dimension() + .withName("OSType") + .withOperator(DimensionOperator.INCLUDE) + .withValues(Arrays.asList("*")))) + .withOperator(ConditionOperator.GREATER_THAN) + .withThreshold(70.0) + .withFailingPeriods( + new ConditionFailingPeriods() + .withNumberOfEvaluationPeriods(1L) + .withMinFailingPeriodsToAlert(1L))))) + .withMuteActionsDuration(Duration.parse("PT30M")) + .withActions( + new Actions() + .withActionGroups( + Arrays + .asList( + "/subscriptions/1cf177ed-1330-4692-80ea-fd3d7783b147/resourcegroups/sqrapi/providers/microsoft.insights/actiongroups/myactiongroup")) + .withCustomProperties(mapOf("key11", "value11", "key12", "value12"))) + .withCheckWorkspaceAlertsStorageConfigured(true) + .withSkipQueryValidation(true) + .withAutoMitigate(true) + .create(); + } + + /* + * x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2021-08-01/examples/createOrUpdateScheduledQueryRuleResourceGroup.json + */ + /** + * Sample code: Create or update a scheduled query rule on Resource group(s). + * + * @param manager Entry point to MonitorManager. + */ + public static void createOrUpdateAScheduledQueryRuleOnResourceGroupS( + com.azure.resourcemanager.monitor.generated.MonitorManager manager) { + manager + .scheduledQueryRules() + .define("heartbeat") + .withRegion("eastus") + .withExistingResourceGroup("QueryResourceGroupName") + .withDescription("Health check rule") + .withSeverity(AlertSeverity.FOUR) + .withEnabled(true) + .withScopes( + Arrays.asList("/subscriptions/aaf177ed-1330-a9f2-80ea-fd3d7783b147/resourceGroups/scopeResourceGroup1")) + .withEvaluationFrequency(Duration.parse("PT5M")) + .withWindowSize(Duration.parse("PT10M")) + .withTargetResourceTypes(Arrays.asList("Microsoft.Compute/virtualMachines")) + .withCriteria( + new ScheduledQueryRuleCriteria() + .withAllOf( + Arrays + .asList( + new Condition() + .withQuery("Heartbeat") + .withTimeAggregation(TimeAggregation.COUNT) + .withDimensions(Arrays.asList()) + .withOperator(ConditionOperator.GREATER_THAN) + .withThreshold(360.0) + .withFailingPeriods( + new ConditionFailingPeriods() + .withNumberOfEvaluationPeriods(1L) + .withMinFailingPeriodsToAlert(1L))))) + .withMuteActionsDuration(Duration.parse("PT30M")) + .withActions( + new Actions() + .withActionGroups( + Arrays + .asList( + "/subscriptions/1cf177ed-1330-4692-80ea-fd3d7783b147/resourcegroups/sqrapi/providers/microsoft.insights/actiongroups/myactiongroup")) + .withCustomProperties(mapOf("key11", "value11", "key12", "value12"))) + .withCheckWorkspaceAlertsStorageConfigured(true) + .withSkipQueryValidation(true) + .withAutoMitigate(true) + .create(); + } + + /* + * x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2021-08-01/examples/createOrUpdateScheduledQueryRule.json + */ + /** + * Sample code: Create or update a scheduled query rule for Single Resource. + * + * @param manager Entry point to MonitorManager. + */ + public static void createOrUpdateAScheduledQueryRuleForSingleResource( + com.azure.resourcemanager.monitor.generated.MonitorManager manager) { + manager + .scheduledQueryRules() + .define("perf") + .withRegion("eastus") + .withExistingResourceGroup("QueryResourceGroupName") + .withDescription("Performance rule") + .withSeverity(AlertSeverity.FOUR) + .withEnabled(true) + .withScopes( + Arrays + .asList( + "/subscriptions/aaf177ed-1330-a9f2-80ea-fd3d7783b147/resourceGroups/scopeResourceGroup1/providers/Microsoft.Compute/virtualMachines/vm1")) + .withEvaluationFrequency(Duration.parse("PT5M")) + .withWindowSize(Duration.parse("PT10M")) + .withCriteria( + new ScheduledQueryRuleCriteria() + .withAllOf( + Arrays + .asList( + new Condition() + .withQuery("Perf | where ObjectName == \"Processor\"") + .withTimeAggregation(TimeAggregation.AVERAGE) + .withMetricMeasureColumn("% Processor Time") + .withResourceIdColumn("resourceId") + .withDimensions( + Arrays + .asList( + new Dimension() + .withName("ComputerIp") + .withOperator(DimensionOperator.EXCLUDE) + .withValues(Arrays.asList("192.168.1.1")), + new Dimension() + .withName("OSType") + .withOperator(DimensionOperator.INCLUDE) + .withValues(Arrays.asList("*")))) + .withOperator(ConditionOperator.GREATER_THAN) + .withThreshold(70.0) + .withFailingPeriods( + new ConditionFailingPeriods() + .withNumberOfEvaluationPeriods(1L) + .withMinFailingPeriodsToAlert(1L))))) + .withMuteActionsDuration(Duration.parse("PT30M")) + .withActions( + new Actions() + .withActionGroups( + Arrays + .asList( + "/subscriptions/1cf177ed-1330-4692-80ea-fd3d7783b147/resourcegroups/sqrapi/providers/microsoft.insights/actiongroups/myactiongroup")) + .withCustomProperties(mapOf("key11", "value11", "key12", "value12"))) + .withCheckWorkspaceAlertsStorageConfigured(true) + .withSkipQueryValidation(true) + .withAutoMitigate(true) + .create(); + } + + @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; + } +} +``` + +### ScheduledQueryRules_Delete + +```java +import com.azure.core.util.Context; + +/** Samples for ScheduledQueryRules Delete. */ +public final class ScheduledQueryRulesDeleteSamples { + /* + * x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2021-08-01/examples/deleteScheduledQueryRule.json + */ + /** + * Sample code: Delete a scheduled query rule. + * + * @param manager Entry point to MonitorManager. + */ + public static void deleteAScheduledQueryRule(com.azure.resourcemanager.monitor.generated.MonitorManager manager) { + manager.scheduledQueryRules().deleteWithResponse("QueryResourceGroupName", "heartbeat", Context.NONE); + } +} +``` + +### ScheduledQueryRules_GetByResourceGroup + +```java +import com.azure.core.util.Context; + +/** Samples for ScheduledQueryRules GetByResourceGroup. */ +public final class ScheduledQueryRulesGetByResourceGroupSamples { + /* + * x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2021-08-01/examples/getScheduledQueryRule.json + */ + /** + * Sample code: Get a scheduled query rule for single resource. + * + * @param manager Entry point to MonitorManager. + */ + public static void getAScheduledQueryRuleForSingleResource( + com.azure.resourcemanager.monitor.generated.MonitorManager manager) { + manager.scheduledQueryRules().getByResourceGroupWithResponse("QueryResourceGroupName", "perf", Context.NONE); + } +} +``` + +### ScheduledQueryRules_List + +```java +import com.azure.core.util.Context; + +/** Samples for ScheduledQueryRules List. */ +public final class ScheduledQueryRulesListSamples { + /* + * x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2021-08-01/examples/listScheduledQueryRulesBySubscription.json + */ + /** + * Sample code: List scheduled query rules by subscription. + * + * @param manager Entry point to MonitorManager. + */ + public static void listScheduledQueryRulesBySubscription( + com.azure.resourcemanager.monitor.generated.MonitorManager manager) { + manager.scheduledQueryRules().list(Context.NONE); + } +} +``` + +### ScheduledQueryRules_ListByResourceGroup + +```java +import com.azure.core.util.Context; + +/** Samples for ScheduledQueryRules ListByResourceGroup. */ +public final class ScheduledQueryRulesListByResourceGroupSamples { + /* + * x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2021-08-01/examples/listScheduledQueryRulesByResourceGroup.json + */ + /** + * Sample code: List scheduled query rules by resource group. + * + * @param manager Entry point to MonitorManager. + */ + public static void listScheduledQueryRulesByResourceGroup( + com.azure.resourcemanager.monitor.generated.MonitorManager manager) { + manager.scheduledQueryRules().listByResourceGroup("QueryResourceGroupName", Context.NONE); + } +} +``` + +### ScheduledQueryRules_Update + +```java +import com.azure.core.util.Context; +import com.azure.resourcemanager.monitor.generated.models.ScheduledQueryRuleResource; + +/** Samples for ScheduledQueryRules Update. */ +public final class ScheduledQueryRulesUpdateSamples { + /* + * x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2021-08-01/examples/patchScheduledQueryRule.json + */ + /** + * Sample code: Create or update a scheduled query rule. + * + * @param manager Entry point to MonitorManager. + */ + public static void createOrUpdateAScheduledQueryRule( + com.azure.resourcemanager.monitor.generated.MonitorManager manager) { + ScheduledQueryRuleResource resource = + manager + .scheduledQueryRules() + .getByResourceGroupWithResponse("QueryResourceGroupName", "heartbeat", Context.NONE) + .getValue(); + resource.update().withEnabled(false).apply(); + } +} +``` + diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/pom.xml b/sdk/monitor/azure-resourcemanager-monitor-generated/pom.xml new file mode 100644 index 0000000000000..4a820515f4ca6 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/pom.xml @@ -0,0 +1,81 @@ + + 4.0.0 + + com.azure + azure-client-sdk-parent + 1.7.0 + ../../parents/azure-client-sdk-parent + + + com.azure.resourcemanager + azure-resourcemanager-monitor-generated + 1.0.0-beta.1 + jar + + Microsoft Azure SDK for Monitor Management + This package contains Microsoft Azure SDK for Monitor Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. Monitor Management Client. Package tag package-2021-08. + https://github.com/Azure/azure-sdk-for-java + + + + The MIT License (MIT) + http://opensource.org/licenses/MIT + repo + + + + + https://github.com/Azure/azure-sdk-for-java + scm:git:git@github.com:Azure/azure-sdk-for-java.git + scm:git:git@github.com:Azure/azure-sdk-for-java.git + HEAD + + + + microsoft + Microsoft + + + + UTF-8 + true + false + + + + + + com.azure + azure-core + 1.23.0 + + + com.azure + azure-core-management + 1.4.3 + + + + + + org.revapi + revapi-maven-plugin + 0.11.2 + + + + + java.method.addedToInterface + + + true + .* + com\.azure\.resourcemanager(\.[^.]+)+\.fluent(\.[^.]+)* + + + + + + + + diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/MonitorManager.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/MonitorManager.java new file mode 100644 index 0000000000000..a83a2ee67efb5 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/MonitorManager.java @@ -0,0 +1,242 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.monitor.generated; + +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.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.RetryPolicy; +import com.azure.core.http.policy.UserAgentPolicy; +import com.azure.core.management.http.policy.ArmChallengeAuthenticationPolicy; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.util.Configuration; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.monitor.generated.fluent.MonitorClient; +import com.azure.resourcemanager.monitor.generated.implementation.MonitorClientBuilder; +import com.azure.resourcemanager.monitor.generated.implementation.ScheduledQueryRulesImpl; +import com.azure.resourcemanager.monitor.generated.models.ScheduledQueryRules; +import java.time.Duration; +import java.time.temporal.ChronoUnit; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; + +/** Entry point to MonitorManager. Monitor Management Client. */ +public final class MonitorManager { + private ScheduledQueryRules scheduledQueryRules; + + private final MonitorClient clientObject; + + private MonitorManager(HttpPipeline httpPipeline, AzureProfile profile, Duration defaultPollInterval) { + Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + this.clientObject = + new MonitorClientBuilder() + .pipeline(httpPipeline) + .endpoint(profile.getEnvironment().getResourceManagerEndpoint()) + .subscriptionId(profile.getSubscriptionId()) + .defaultPollInterval(defaultPollInterval) + .buildClient(); + } + + /** + * Creates an instance of Monitor service API entry point. + * + * @param credential the credential to use. + * @param profile the Azure profile for client. + * @return the Monitor service API instance. + */ + public static MonitorManager authenticate(TokenCredential credential, AzureProfile profile) { + Objects.requireNonNull(credential, "'credential' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + return configure().authenticate(credential, profile); + } + + /** + * Gets a Configurable instance that can be used to create MonitorManager with optional configuration. + * + * @return the Configurable instance allowing configurations. + */ + public static Configurable configure() { + return new MonitorManager.Configurable(); + } + + /** The Configurable allowing configurations to be set. */ + public static final class Configurable { + private final ClientLogger logger = new ClientLogger(Configurable.class); + + private HttpClient httpClient; + private HttpLogOptions httpLogOptions; + private final List policies = new ArrayList<>(); + private final List scopes = new ArrayList<>(); + private RetryPolicy retryPolicy; + 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 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, "'retryPolicy' cannot be null."); + if (this.defaultPollInterval.isNegative()) { + throw logger.logExceptionAsError(new IllegalArgumentException("'httpPipeline' cannot be negative")); + } + return this; + } + + /** + * Creates an instance of Monitor service API entry point. + * + * @param credential the credential to use. + * @param profile the Azure profile for client. + * @return the Monitor service API instance. + */ + public MonitorManager authenticate(TokenCredential credential, AzureProfile profile) { + Objects.requireNonNull(credential, "'credential' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + + StringBuilder userAgentBuilder = new StringBuilder(); + userAgentBuilder + .append("azsdk-java") + .append("-") + .append("com.azure.resourcemanager.monitor.generated") + .append("/") + .append("1.0.0-beta.1"); + 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) { + retryPolicy = new RetryPolicy("Retry-After", ChronoUnit.SECONDS); + } + List policies = new ArrayList<>(); + policies.add(new UserAgentPolicy(userAgentBuilder.toString())); + 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 ArmChallengeAuthenticationPolicy(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 MonitorManager(httpPipeline, profile, defaultPollInterval); + } + } + + /** @return Resource collection API of ScheduledQueryRules. */ + public ScheduledQueryRules scheduledQueryRules() { + if (this.scheduledQueryRules == null) { + this.scheduledQueryRules = new ScheduledQueryRulesImpl(clientObject.getScheduledQueryRules(), this); + } + return scheduledQueryRules; + } + + /** + * @return Wrapped service client MonitorClient providing direct access to the underlying auto-generated API + * implementation, based on Azure REST API. + */ + public MonitorClient serviceClient() { + return this.clientObject; + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/fluent/MonitorClient.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/fluent/MonitorClient.java new file mode 100644 index 0000000000000..797eb83758610 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/fluent/MonitorClient.java @@ -0,0 +1,53 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.monitor.generated.fluent; + +import com.azure.core.http.HttpPipeline; +import java.time.Duration; + +/** The interface for MonitorClient class. */ +public interface MonitorClient { + /** + * Gets The ID of the target subscription. + * + * @return the subscriptionId value. + */ + String getSubscriptionId(); + + /** + * Gets server parameter. + * + * @return the endpoint value. + */ + String getEndpoint(); + + /** + * Gets Api Version. + * + * @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 ScheduledQueryRulesClient object to access its operations. + * + * @return the ScheduledQueryRulesClient object. + */ + ScheduledQueryRulesClient getScheduledQueryRules(); +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/fluent/ScheduledQueryRulesClient.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/fluent/ScheduledQueryRulesClient.java new file mode 100644 index 0000000000000..9246d0419d0e6 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/fluent/ScheduledQueryRulesClient.java @@ -0,0 +1,179 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.monitor.generated.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.generated.fluent.models.ScheduledQueryRuleResourceInner; +import com.azure.resourcemanager.monitor.generated.models.ScheduledQueryRuleResourcePatch; + +/** An instance of this class provides access to all the operations defined in ScheduledQueryRulesClient. */ +public interface ScheduledQueryRulesClient { + /** + * Retrieve a scheduled query rule definitions in a subscription. + * + * @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 a collection of scheduled query rule resources. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(); + + /** + * Retrieve a scheduled query rule definitions in a subscription. + * + * @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 a collection of scheduled query rule resources. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(Context context); + + /** + * Retrieve scheduled query rule definitions in a resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @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 a collection of scheduled query rule resources. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable listByResourceGroup(String resourceGroupName); + + /** + * Retrieve scheduled query rule definitions in a resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @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 a collection of scheduled query rule resources. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable listByResourceGroup(String resourceGroupName, Context context); + + /** + * Retrieve an scheduled query rule definition. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param ruleName The name of the rule. + * @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 scheduled query rule resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + ScheduledQueryRuleResourceInner getByResourceGroup(String resourceGroupName, String ruleName); + + /** + * Retrieve an scheduled query rule definition. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param ruleName The name of the rule. + * @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 scheduled query rule resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response getByResourceGroupWithResponse( + String resourceGroupName, String ruleName, Context context); + + /** + * Creates or updates a scheduled query rule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param ruleName The name of the rule. + * @param parameters The parameters of the rule to create or update. + * @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 scheduled query rule resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + ScheduledQueryRuleResourceInner createOrUpdate( + String resourceGroupName, String ruleName, ScheduledQueryRuleResourceInner parameters); + + /** + * Creates or updates a scheduled query rule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param ruleName The name of the rule. + * @param parameters The parameters of the rule to create or update. + * @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 scheduled query rule resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response createOrUpdateWithResponse( + String resourceGroupName, String ruleName, ScheduledQueryRuleResourceInner parameters, Context context); + + /** + * Update a scheduled query rule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param ruleName The name of the rule. + * @param parameters The parameters of the rule to update. + * @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 scheduled query rule resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + ScheduledQueryRuleResourceInner update( + String resourceGroupName, String ruleName, ScheduledQueryRuleResourcePatch parameters); + + /** + * Update a scheduled query rule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param ruleName The name of the rule. + * @param parameters The parameters of the rule to update. + * @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 scheduled query rule resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response updateWithResponse( + String resourceGroupName, String ruleName, ScheduledQueryRuleResourcePatch parameters, Context context); + + /** + * Deletes a scheduled query rule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param ruleName The name of the rule. + * @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 resourceGroupName, String ruleName); + + /** + * Deletes a scheduled query rule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param ruleName The name of the rule. + * @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. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response deleteWithResponse(String resourceGroupName, String ruleName, Context context); +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/fluent/models/ScheduledQueryRuleProperties.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/fluent/models/ScheduledQueryRuleProperties.java new file mode 100644 index 0000000000000..b4c79b8b67b41 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/fluent/models/ScheduledQueryRuleProperties.java @@ -0,0 +1,520 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.monitor.generated.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.monitor.generated.models.Actions; +import com.azure.resourcemanager.monitor.generated.models.AlertSeverity; +import com.azure.resourcemanager.monitor.generated.models.ScheduledQueryRuleCriteria; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.time.Duration; +import java.util.List; + +/** scheduled query rule Definition. */ +@Fluent +public final class ScheduledQueryRuleProperties { + @JsonIgnore private final ClientLogger logger = new ClientLogger(ScheduledQueryRuleProperties.class); + + /* + * The api-version used when creating this alert rule + */ + @JsonProperty(value = "createdWithApiVersion", access = JsonProperty.Access.WRITE_ONLY) + private String createdWithApiVersion; + + /* + * True if alert rule is legacy Log Analytic rule + */ + @JsonProperty(value = "isLegacyLogAnalyticsRule", access = JsonProperty.Access.WRITE_ONLY) + private Boolean isLegacyLogAnalyticsRule; + + /* + * The description of the scheduled query rule. + */ + @JsonProperty(value = "description") + private String description; + + /* + * The display name of the alert rule + */ + @JsonProperty(value = "displayName") + private String displayName; + + /* + * Severity of the alert. Should be an integer between [0-4]. Value of 0 is + * severest. Relevant and required only for rules of the kind LogAlert. + */ + @JsonProperty(value = "severity") + private AlertSeverity severity; + + /* + * The flag which indicates whether this scheduled query rule is enabled. + * Value should be true or false + */ + @JsonProperty(value = "enabled") + private Boolean enabled; + + /* + * The list of resource id's that this scheduled query rule is scoped to. + */ + @JsonProperty(value = "scopes") + private List scopes; + + /* + * How often the scheduled query rule is evaluated represented in ISO 8601 + * duration format. Relevant and required only for rules of the kind + * LogAlert. + */ + @JsonProperty(value = "evaluationFrequency") + private Duration evaluationFrequency; + + /* + * The period of time (in ISO 8601 duration format) on which the Alert + * query will be executed (bin size). Relevant and required only for rules + * of the kind LogAlert. + */ + @JsonProperty(value = "windowSize") + private Duration windowSize; + + /* + * If specified then overrides the query time range (default is + * WindowSize*NumberOfEvaluationPeriods). Relevant only for rules of the + * kind LogAlert. + */ + @JsonProperty(value = "overrideQueryTimeRange") + private Duration overrideQueryTimeRange; + + /* + * List of resource type of the target resource(s) on which the alert is + * created/updated. For example if the scope is a resource group and + * targetResourceTypes is Microsoft.Compute/virtualMachines, then a + * different alert will be fired for each virtual machine in the resource + * group which meet the alert criteria. Relevant only for rules of the kind + * LogAlert + */ + @JsonProperty(value = "targetResourceTypes") + private List targetResourceTypes; + + /* + * The rule criteria that defines the conditions of the scheduled query + * rule. + */ + @JsonProperty(value = "criteria") + private ScheduledQueryRuleCriteria criteria; + + /* + * Mute actions for the chosen period of time (in ISO 8601 duration format) + * after the alert is fired. Relevant only for rules of the kind LogAlert. + */ + @JsonProperty(value = "muteActionsDuration") + private Duration muteActionsDuration; + + /* + * Actions to invoke when the alert fires. + */ + @JsonProperty(value = "actions") + private Actions actions; + + /* + * The flag which indicates whether this scheduled query rule has been + * configured to be stored in the customer's storage. The default is false. + */ + @JsonProperty(value = "isWorkspaceAlertsStorageConfigured", access = JsonProperty.Access.WRITE_ONLY) + private Boolean isWorkspaceAlertsStorageConfigured; + + /* + * The flag which indicates whether this scheduled query rule should be + * stored in the customer's storage. The default is false. Relevant only + * for rules of the kind LogAlert. + */ + @JsonProperty(value = "checkWorkspaceAlertsStorageConfigured") + private Boolean checkWorkspaceAlertsStorageConfigured; + + /* + * The flag which indicates whether the provided query should be validated + * or not. The default is false. Relevant only for rules of the kind + * LogAlert. + */ + @JsonProperty(value = "skipQueryValidation") + private Boolean skipQueryValidation; + + /* + * The flag that indicates whether the alert should be automatically + * resolved or not. The default is true. Relevant only for rules of the + * kind LogAlert. + */ + @JsonProperty(value = "autoMitigate") + private Boolean autoMitigate; + + /** + * Get the createdWithApiVersion property: The api-version used when creating this alert rule. + * + * @return the createdWithApiVersion value. + */ + public String createdWithApiVersion() { + return this.createdWithApiVersion; + } + + /** + * Get the isLegacyLogAnalyticsRule property: True if alert rule is legacy Log Analytic rule. + * + * @return the isLegacyLogAnalyticsRule value. + */ + public Boolean isLegacyLogAnalyticsRule() { + return this.isLegacyLogAnalyticsRule; + } + + /** + * Get the description property: The description of the scheduled query rule. + * + * @return the description value. + */ + public String description() { + return this.description; + } + + /** + * Set the description property: The description of the scheduled query rule. + * + * @param description the description value to set. + * @return the ScheduledQueryRuleProperties object itself. + */ + public ScheduledQueryRuleProperties withDescription(String description) { + this.description = description; + return this; + } + + /** + * Get the displayName property: The display name of the alert rule. + * + * @return the displayName value. + */ + public String displayName() { + return this.displayName; + } + + /** + * Set the displayName property: The display name of the alert rule. + * + * @param displayName the displayName value to set. + * @return the ScheduledQueryRuleProperties object itself. + */ + public ScheduledQueryRuleProperties withDisplayName(String displayName) { + this.displayName = displayName; + return this; + } + + /** + * Get the severity property: Severity of the alert. Should be an integer between [0-4]. Value of 0 is severest. + * Relevant and required only for rules of the kind LogAlert. + * + * @return the severity value. + */ + public AlertSeverity severity() { + return this.severity; + } + + /** + * Set the severity property: Severity of the alert. Should be an integer between [0-4]. Value of 0 is severest. + * Relevant and required only for rules of the kind LogAlert. + * + * @param severity the severity value to set. + * @return the ScheduledQueryRuleProperties object itself. + */ + public ScheduledQueryRuleProperties withSeverity(AlertSeverity severity) { + this.severity = severity; + return this; + } + + /** + * Get the enabled property: The flag which indicates whether this scheduled query rule is enabled. Value should be + * true or false. + * + * @return the enabled value. + */ + public Boolean enabled() { + return this.enabled; + } + + /** + * Set the enabled property: The flag which indicates whether this scheduled query rule is enabled. Value should be + * true or false. + * + * @param enabled the enabled value to set. + * @return the ScheduledQueryRuleProperties object itself. + */ + public ScheduledQueryRuleProperties withEnabled(Boolean enabled) { + this.enabled = enabled; + return this; + } + + /** + * Get the scopes property: The list of resource id's that this scheduled query rule is scoped to. + * + * @return the scopes value. + */ + public List scopes() { + return this.scopes; + } + + /** + * Set the scopes property: The list of resource id's that this scheduled query rule is scoped to. + * + * @param scopes the scopes value to set. + * @return the ScheduledQueryRuleProperties object itself. + */ + public ScheduledQueryRuleProperties withScopes(List scopes) { + this.scopes = scopes; + return this; + } + + /** + * Get the evaluationFrequency property: How often the scheduled query rule is evaluated represented in ISO 8601 + * duration format. Relevant and required only for rules of the kind LogAlert. + * + * @return the evaluationFrequency value. + */ + public Duration evaluationFrequency() { + return this.evaluationFrequency; + } + + /** + * Set the evaluationFrequency property: How often the scheduled query rule is evaluated represented in ISO 8601 + * duration format. Relevant and required only for rules of the kind LogAlert. + * + * @param evaluationFrequency the evaluationFrequency value to set. + * @return the ScheduledQueryRuleProperties object itself. + */ + public ScheduledQueryRuleProperties withEvaluationFrequency(Duration evaluationFrequency) { + this.evaluationFrequency = evaluationFrequency; + return this; + } + + /** + * Get the windowSize property: The period of time (in ISO 8601 duration format) on which the Alert query will be + * executed (bin size). Relevant and required only for rules of the kind LogAlert. + * + * @return the windowSize value. + */ + public Duration windowSize() { + return this.windowSize; + } + + /** + * Set the windowSize property: The period of time (in ISO 8601 duration format) on which the Alert query will be + * executed (bin size). Relevant and required only for rules of the kind LogAlert. + * + * @param windowSize the windowSize value to set. + * @return the ScheduledQueryRuleProperties object itself. + */ + public ScheduledQueryRuleProperties withWindowSize(Duration windowSize) { + this.windowSize = windowSize; + return this; + } + + /** + * Get the overrideQueryTimeRange property: If specified then overrides the query time range (default is + * WindowSize*NumberOfEvaluationPeriods). Relevant only for rules of the kind LogAlert. + * + * @return the overrideQueryTimeRange value. + */ + public Duration overrideQueryTimeRange() { + return this.overrideQueryTimeRange; + } + + /** + * Set the overrideQueryTimeRange property: If specified then overrides the query time range (default is + * WindowSize*NumberOfEvaluationPeriods). Relevant only for rules of the kind LogAlert. + * + * @param overrideQueryTimeRange the overrideQueryTimeRange value to set. + * @return the ScheduledQueryRuleProperties object itself. + */ + public ScheduledQueryRuleProperties withOverrideQueryTimeRange(Duration overrideQueryTimeRange) { + this.overrideQueryTimeRange = overrideQueryTimeRange; + return this; + } + + /** + * Get the targetResourceTypes property: List of resource type of the target resource(s) on which the alert is + * created/updated. For example if the scope is a resource group and targetResourceTypes is + * Microsoft.Compute/virtualMachines, then a different alert will be fired for each virtual machine in the resource + * group which meet the alert criteria. Relevant only for rules of the kind LogAlert. + * + * @return the targetResourceTypes value. + */ + public List targetResourceTypes() { + return this.targetResourceTypes; + } + + /** + * Set the targetResourceTypes property: List of resource type of the target resource(s) on which the alert is + * created/updated. For example if the scope is a resource group and targetResourceTypes is + * Microsoft.Compute/virtualMachines, then a different alert will be fired for each virtual machine in the resource + * group which meet the alert criteria. Relevant only for rules of the kind LogAlert. + * + * @param targetResourceTypes the targetResourceTypes value to set. + * @return the ScheduledQueryRuleProperties object itself. + */ + public ScheduledQueryRuleProperties withTargetResourceTypes(List targetResourceTypes) { + this.targetResourceTypes = targetResourceTypes; + return this; + } + + /** + * Get the criteria property: The rule criteria that defines the conditions of the scheduled query rule. + * + * @return the criteria value. + */ + public ScheduledQueryRuleCriteria criteria() { + return this.criteria; + } + + /** + * Set the criteria property: The rule criteria that defines the conditions of the scheduled query rule. + * + * @param criteria the criteria value to set. + * @return the ScheduledQueryRuleProperties object itself. + */ + public ScheduledQueryRuleProperties withCriteria(ScheduledQueryRuleCriteria criteria) { + this.criteria = criteria; + return this; + } + + /** + * Get the muteActionsDuration property: Mute actions for the chosen period of time (in ISO 8601 duration format) + * after the alert is fired. Relevant only for rules of the kind LogAlert. + * + * @return the muteActionsDuration value. + */ + public Duration muteActionsDuration() { + return this.muteActionsDuration; + } + + /** + * Set the muteActionsDuration property: Mute actions for the chosen period of time (in ISO 8601 duration format) + * after the alert is fired. Relevant only for rules of the kind LogAlert. + * + * @param muteActionsDuration the muteActionsDuration value to set. + * @return the ScheduledQueryRuleProperties object itself. + */ + public ScheduledQueryRuleProperties withMuteActionsDuration(Duration muteActionsDuration) { + this.muteActionsDuration = muteActionsDuration; + return this; + } + + /** + * Get the actions property: Actions to invoke when the alert fires. + * + * @return the actions value. + */ + public Actions actions() { + return this.actions; + } + + /** + * Set the actions property: Actions to invoke when the alert fires. + * + * @param actions the actions value to set. + * @return the ScheduledQueryRuleProperties object itself. + */ + public ScheduledQueryRuleProperties withActions(Actions actions) { + this.actions = actions; + return this; + } + + /** + * Get the isWorkspaceAlertsStorageConfigured property: The flag which indicates whether this scheduled query rule + * has been configured to be stored in the customer's storage. The default is false. + * + * @return the isWorkspaceAlertsStorageConfigured value. + */ + public Boolean isWorkspaceAlertsStorageConfigured() { + return this.isWorkspaceAlertsStorageConfigured; + } + + /** + * Get the checkWorkspaceAlertsStorageConfigured property: The flag which indicates whether this scheduled query + * rule should be stored in the customer's storage. The default is false. Relevant only for rules of the kind + * LogAlert. + * + * @return the checkWorkspaceAlertsStorageConfigured value. + */ + public Boolean checkWorkspaceAlertsStorageConfigured() { + return this.checkWorkspaceAlertsStorageConfigured; + } + + /** + * Set the checkWorkspaceAlertsStorageConfigured property: The flag which indicates whether this scheduled query + * rule should be stored in the customer's storage. The default is false. Relevant only for rules of the kind + * LogAlert. + * + * @param checkWorkspaceAlertsStorageConfigured the checkWorkspaceAlertsStorageConfigured value to set. + * @return the ScheduledQueryRuleProperties object itself. + */ + public ScheduledQueryRuleProperties withCheckWorkspaceAlertsStorageConfigured( + Boolean checkWorkspaceAlertsStorageConfigured) { + this.checkWorkspaceAlertsStorageConfigured = checkWorkspaceAlertsStorageConfigured; + return this; + } + + /** + * Get the skipQueryValidation property: The flag which indicates whether the provided query should be validated or + * not. The default is false. Relevant only for rules of the kind LogAlert. + * + * @return the skipQueryValidation value. + */ + public Boolean skipQueryValidation() { + return this.skipQueryValidation; + } + + /** + * Set the skipQueryValidation property: The flag which indicates whether the provided query should be validated or + * not. The default is false. Relevant only for rules of the kind LogAlert. + * + * @param skipQueryValidation the skipQueryValidation value to set. + * @return the ScheduledQueryRuleProperties object itself. + */ + public ScheduledQueryRuleProperties withSkipQueryValidation(Boolean skipQueryValidation) { + this.skipQueryValidation = skipQueryValidation; + return this; + } + + /** + * Get the autoMitigate property: The flag that indicates whether the alert should be automatically resolved or not. + * The default is true. Relevant only for rules of the kind LogAlert. + * + * @return the autoMitigate value. + */ + public Boolean autoMitigate() { + return this.autoMitigate; + } + + /** + * Set the autoMitigate property: The flag that indicates whether the alert should be automatically resolved or not. + * The default is true. Relevant only for rules of the kind LogAlert. + * + * @param autoMitigate the autoMitigate value to set. + * @return the ScheduledQueryRuleProperties object itself. + */ + public ScheduledQueryRuleProperties withAutoMitigate(Boolean autoMitigate) { + this.autoMitigate = autoMitigate; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (criteria() != null) { + criteria().validate(); + } + if (actions() != null) { + actions().validate(); + } + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/fluent/models/ScheduledQueryRuleResourceInner.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/fluent/models/ScheduledQueryRuleResourceInner.java new file mode 100644 index 0000000000000..6dc5558d54173 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/fluent/models/ScheduledQueryRuleResourceInner.java @@ -0,0 +1,534 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.monitor.generated.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.management.Resource; +import com.azure.core.management.SystemData; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.monitor.generated.models.Actions; +import com.azure.resourcemanager.monitor.generated.models.AlertSeverity; +import com.azure.resourcemanager.monitor.generated.models.Kind; +import com.azure.resourcemanager.monitor.generated.models.ScheduledQueryRuleCriteria; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.time.Duration; +import java.util.List; +import java.util.Map; + +/** The scheduled query rule resource. */ +@Fluent +public final class ScheduledQueryRuleResourceInner extends Resource { + @JsonIgnore private final ClientLogger logger = new ClientLogger(ScheduledQueryRuleResourceInner.class); + + /* + * Indicates the type of scheduled query rule. The default is LogAlert. + */ + @JsonProperty(value = "kind") + private Kind kind; + + /* + * The etag field is *not* required. If it is provided in the response + * body, it must also be provided as a header per the normal etag + * convention. Entity tags are used for comparing two or more entities + * from the same requested resource. HTTP/1.1 uses entity tags in the etag + * (section 14.19), If-Match (section 14.24), If-None-Match (section + * 14.26), and If-Range (section 14.27) header fields. + */ + @JsonProperty(value = "etag", access = JsonProperty.Access.WRITE_ONLY) + private String etag; + + /* + * SystemData of ScheduledQueryRule. + */ + @JsonProperty(value = "systemData", access = JsonProperty.Access.WRITE_ONLY) + private SystemData systemData; + + /* + * The rule properties of the resource. + */ + @JsonProperty(value = "properties", required = true) + private ScheduledQueryRuleProperties innerProperties = new ScheduledQueryRuleProperties(); + + /** + * Get the kind property: Indicates the type of scheduled query rule. The default is LogAlert. + * + * @return the kind value. + */ + public Kind kind() { + return this.kind; + } + + /** + * Set the kind property: Indicates the type of scheduled query rule. The default is LogAlert. + * + * @param kind the kind value to set. + * @return the ScheduledQueryRuleResourceInner object itself. + */ + public ScheduledQueryRuleResourceInner withKind(Kind kind) { + this.kind = kind; + return this; + } + + /** + * Get the etag property: The etag field is *not* required. If it is provided in the response body, it must also be + * provided as a header per the normal etag convention. Entity tags are used for comparing two or more entities from + * the same requested resource. HTTP/1.1 uses entity tags in the etag (section 14.19), If-Match (section 14.24), + * If-None-Match (section 14.26), and If-Range (section 14.27) header fields. + * + * @return the etag value. + */ + public String etag() { + return this.etag; + } + + /** + * Get the systemData property: SystemData of ScheduledQueryRule. + * + * @return the systemData value. + */ + public SystemData systemData() { + return this.systemData; + } + + /** + * Get the innerProperties property: The rule properties of the resource. + * + * @return the innerProperties value. + */ + private ScheduledQueryRuleProperties innerProperties() { + return this.innerProperties; + } + + /** {@inheritDoc} */ + @Override + public ScheduledQueryRuleResourceInner withLocation(String location) { + super.withLocation(location); + return this; + } + + /** {@inheritDoc} */ + @Override + public ScheduledQueryRuleResourceInner withTags(Map tags) { + super.withTags(tags); + return this; + } + + /** + * Get the createdWithApiVersion property: The api-version used when creating this alert rule. + * + * @return the createdWithApiVersion value. + */ + public String createdWithApiVersion() { + return this.innerProperties() == null ? null : this.innerProperties().createdWithApiVersion(); + } + + /** + * Get the isLegacyLogAnalyticsRule property: True if alert rule is legacy Log Analytic rule. + * + * @return the isLegacyLogAnalyticsRule value. + */ + public Boolean isLegacyLogAnalyticsRule() { + return this.innerProperties() == null ? null : this.innerProperties().isLegacyLogAnalyticsRule(); + } + + /** + * Get the description property: The description of the scheduled query rule. + * + * @return the description value. + */ + public String description() { + return this.innerProperties() == null ? null : this.innerProperties().description(); + } + + /** + * Set the description property: The description of the scheduled query rule. + * + * @param description the description value to set. + * @return the ScheduledQueryRuleResourceInner object itself. + */ + public ScheduledQueryRuleResourceInner withDescription(String description) { + if (this.innerProperties() == null) { + this.innerProperties = new ScheduledQueryRuleProperties(); + } + this.innerProperties().withDescription(description); + return this; + } + + /** + * Get the displayName property: The display name of the alert rule. + * + * @return the displayName value. + */ + public String displayName() { + return this.innerProperties() == null ? null : this.innerProperties().displayName(); + } + + /** + * Set the displayName property: The display name of the alert rule. + * + * @param displayName the displayName value to set. + * @return the ScheduledQueryRuleResourceInner object itself. + */ + public ScheduledQueryRuleResourceInner withDisplayName(String displayName) { + if (this.innerProperties() == null) { + this.innerProperties = new ScheduledQueryRuleProperties(); + } + this.innerProperties().withDisplayName(displayName); + return this; + } + + /** + * Get the severity property: Severity of the alert. Should be an integer between [0-4]. Value of 0 is severest. + * Relevant and required only for rules of the kind LogAlert. + * + * @return the severity value. + */ + public AlertSeverity severity() { + return this.innerProperties() == null ? null : this.innerProperties().severity(); + } + + /** + * Set the severity property: Severity of the alert. Should be an integer between [0-4]. Value of 0 is severest. + * Relevant and required only for rules of the kind LogAlert. + * + * @param severity the severity value to set. + * @return the ScheduledQueryRuleResourceInner object itself. + */ + public ScheduledQueryRuleResourceInner withSeverity(AlertSeverity severity) { + if (this.innerProperties() == null) { + this.innerProperties = new ScheduledQueryRuleProperties(); + } + this.innerProperties().withSeverity(severity); + return this; + } + + /** + * Get the enabled property: The flag which indicates whether this scheduled query rule is enabled. Value should be + * true or false. + * + * @return the enabled value. + */ + public Boolean enabled() { + return this.innerProperties() == null ? null : this.innerProperties().enabled(); + } + + /** + * Set the enabled property: The flag which indicates whether this scheduled query rule is enabled. Value should be + * true or false. + * + * @param enabled the enabled value to set. + * @return the ScheduledQueryRuleResourceInner object itself. + */ + public ScheduledQueryRuleResourceInner withEnabled(Boolean enabled) { + if (this.innerProperties() == null) { + this.innerProperties = new ScheduledQueryRuleProperties(); + } + this.innerProperties().withEnabled(enabled); + return this; + } + + /** + * Get the scopes property: The list of resource id's that this scheduled query rule is scoped to. + * + * @return the scopes value. + */ + public List scopes() { + return this.innerProperties() == null ? null : this.innerProperties().scopes(); + } + + /** + * Set the scopes property: The list of resource id's that this scheduled query rule is scoped to. + * + * @param scopes the scopes value to set. + * @return the ScheduledQueryRuleResourceInner object itself. + */ + public ScheduledQueryRuleResourceInner withScopes(List scopes) { + if (this.innerProperties() == null) { + this.innerProperties = new ScheduledQueryRuleProperties(); + } + this.innerProperties().withScopes(scopes); + return this; + } + + /** + * Get the evaluationFrequency property: How often the scheduled query rule is evaluated represented in ISO 8601 + * duration format. Relevant and required only for rules of the kind LogAlert. + * + * @return the evaluationFrequency value. + */ + public Duration evaluationFrequency() { + return this.innerProperties() == null ? null : this.innerProperties().evaluationFrequency(); + } + + /** + * Set the evaluationFrequency property: How often the scheduled query rule is evaluated represented in ISO 8601 + * duration format. Relevant and required only for rules of the kind LogAlert. + * + * @param evaluationFrequency the evaluationFrequency value to set. + * @return the ScheduledQueryRuleResourceInner object itself. + */ + public ScheduledQueryRuleResourceInner withEvaluationFrequency(Duration evaluationFrequency) { + if (this.innerProperties() == null) { + this.innerProperties = new ScheduledQueryRuleProperties(); + } + this.innerProperties().withEvaluationFrequency(evaluationFrequency); + return this; + } + + /** + * Get the windowSize property: The period of time (in ISO 8601 duration format) on which the Alert query will be + * executed (bin size). Relevant and required only for rules of the kind LogAlert. + * + * @return the windowSize value. + */ + public Duration windowSize() { + return this.innerProperties() == null ? null : this.innerProperties().windowSize(); + } + + /** + * Set the windowSize property: The period of time (in ISO 8601 duration format) on which the Alert query will be + * executed (bin size). Relevant and required only for rules of the kind LogAlert. + * + * @param windowSize the windowSize value to set. + * @return the ScheduledQueryRuleResourceInner object itself. + */ + public ScheduledQueryRuleResourceInner withWindowSize(Duration windowSize) { + if (this.innerProperties() == null) { + this.innerProperties = new ScheduledQueryRuleProperties(); + } + this.innerProperties().withWindowSize(windowSize); + return this; + } + + /** + * Get the overrideQueryTimeRange property: If specified then overrides the query time range (default is + * WindowSize*NumberOfEvaluationPeriods). Relevant only for rules of the kind LogAlert. + * + * @return the overrideQueryTimeRange value. + */ + public Duration overrideQueryTimeRange() { + return this.innerProperties() == null ? null : this.innerProperties().overrideQueryTimeRange(); + } + + /** + * Set the overrideQueryTimeRange property: If specified then overrides the query time range (default is + * WindowSize*NumberOfEvaluationPeriods). Relevant only for rules of the kind LogAlert. + * + * @param overrideQueryTimeRange the overrideQueryTimeRange value to set. + * @return the ScheduledQueryRuleResourceInner object itself. + */ + public ScheduledQueryRuleResourceInner withOverrideQueryTimeRange(Duration overrideQueryTimeRange) { + if (this.innerProperties() == null) { + this.innerProperties = new ScheduledQueryRuleProperties(); + } + this.innerProperties().withOverrideQueryTimeRange(overrideQueryTimeRange); + return this; + } + + /** + * Get the targetResourceTypes property: List of resource type of the target resource(s) on which the alert is + * created/updated. For example if the scope is a resource group and targetResourceTypes is + * Microsoft.Compute/virtualMachines, then a different alert will be fired for each virtual machine in the resource + * group which meet the alert criteria. Relevant only for rules of the kind LogAlert. + * + * @return the targetResourceTypes value. + */ + public List targetResourceTypes() { + return this.innerProperties() == null ? null : this.innerProperties().targetResourceTypes(); + } + + /** + * Set the targetResourceTypes property: List of resource type of the target resource(s) on which the alert is + * created/updated. For example if the scope is a resource group and targetResourceTypes is + * Microsoft.Compute/virtualMachines, then a different alert will be fired for each virtual machine in the resource + * group which meet the alert criteria. Relevant only for rules of the kind LogAlert. + * + * @param targetResourceTypes the targetResourceTypes value to set. + * @return the ScheduledQueryRuleResourceInner object itself. + */ + public ScheduledQueryRuleResourceInner withTargetResourceTypes(List targetResourceTypes) { + if (this.innerProperties() == null) { + this.innerProperties = new ScheduledQueryRuleProperties(); + } + this.innerProperties().withTargetResourceTypes(targetResourceTypes); + return this; + } + + /** + * Get the criteria property: The rule criteria that defines the conditions of the scheduled query rule. + * + * @return the criteria value. + */ + public ScheduledQueryRuleCriteria criteria() { + return this.innerProperties() == null ? null : this.innerProperties().criteria(); + } + + /** + * Set the criteria property: The rule criteria that defines the conditions of the scheduled query rule. + * + * @param criteria the criteria value to set. + * @return the ScheduledQueryRuleResourceInner object itself. + */ + public ScheduledQueryRuleResourceInner withCriteria(ScheduledQueryRuleCriteria criteria) { + if (this.innerProperties() == null) { + this.innerProperties = new ScheduledQueryRuleProperties(); + } + this.innerProperties().withCriteria(criteria); + return this; + } + + /** + * Get the muteActionsDuration property: Mute actions for the chosen period of time (in ISO 8601 duration format) + * after the alert is fired. Relevant only for rules of the kind LogAlert. + * + * @return the muteActionsDuration value. + */ + public Duration muteActionsDuration() { + return this.innerProperties() == null ? null : this.innerProperties().muteActionsDuration(); + } + + /** + * Set the muteActionsDuration property: Mute actions for the chosen period of time (in ISO 8601 duration format) + * after the alert is fired. Relevant only for rules of the kind LogAlert. + * + * @param muteActionsDuration the muteActionsDuration value to set. + * @return the ScheduledQueryRuleResourceInner object itself. + */ + public ScheduledQueryRuleResourceInner withMuteActionsDuration(Duration muteActionsDuration) { + if (this.innerProperties() == null) { + this.innerProperties = new ScheduledQueryRuleProperties(); + } + this.innerProperties().withMuteActionsDuration(muteActionsDuration); + return this; + } + + /** + * Get the actions property: Actions to invoke when the alert fires. + * + * @return the actions value. + */ + public Actions actions() { + return this.innerProperties() == null ? null : this.innerProperties().actions(); + } + + /** + * Set the actions property: Actions to invoke when the alert fires. + * + * @param actions the actions value to set. + * @return the ScheduledQueryRuleResourceInner object itself. + */ + public ScheduledQueryRuleResourceInner withActions(Actions actions) { + if (this.innerProperties() == null) { + this.innerProperties = new ScheduledQueryRuleProperties(); + } + this.innerProperties().withActions(actions); + return this; + } + + /** + * Get the isWorkspaceAlertsStorageConfigured property: The flag which indicates whether this scheduled query rule + * has been configured to be stored in the customer's storage. The default is false. + * + * @return the isWorkspaceAlertsStorageConfigured value. + */ + public Boolean isWorkspaceAlertsStorageConfigured() { + return this.innerProperties() == null ? null : this.innerProperties().isWorkspaceAlertsStorageConfigured(); + } + + /** + * Get the checkWorkspaceAlertsStorageConfigured property: The flag which indicates whether this scheduled query + * rule should be stored in the customer's storage. The default is false. Relevant only for rules of the kind + * LogAlert. + * + * @return the checkWorkspaceAlertsStorageConfigured value. + */ + public Boolean checkWorkspaceAlertsStorageConfigured() { + return this.innerProperties() == null ? null : this.innerProperties().checkWorkspaceAlertsStorageConfigured(); + } + + /** + * Set the checkWorkspaceAlertsStorageConfigured property: The flag which indicates whether this scheduled query + * rule should be stored in the customer's storage. The default is false. Relevant only for rules of the kind + * LogAlert. + * + * @param checkWorkspaceAlertsStorageConfigured the checkWorkspaceAlertsStorageConfigured value to set. + * @return the ScheduledQueryRuleResourceInner object itself. + */ + public ScheduledQueryRuleResourceInner withCheckWorkspaceAlertsStorageConfigured( + Boolean checkWorkspaceAlertsStorageConfigured) { + if (this.innerProperties() == null) { + this.innerProperties = new ScheduledQueryRuleProperties(); + } + this.innerProperties().withCheckWorkspaceAlertsStorageConfigured(checkWorkspaceAlertsStorageConfigured); + return this; + } + + /** + * Get the skipQueryValidation property: The flag which indicates whether the provided query should be validated or + * not. The default is false. Relevant only for rules of the kind LogAlert. + * + * @return the skipQueryValidation value. + */ + public Boolean skipQueryValidation() { + return this.innerProperties() == null ? null : this.innerProperties().skipQueryValidation(); + } + + /** + * Set the skipQueryValidation property: The flag which indicates whether the provided query should be validated or + * not. The default is false. Relevant only for rules of the kind LogAlert. + * + * @param skipQueryValidation the skipQueryValidation value to set. + * @return the ScheduledQueryRuleResourceInner object itself. + */ + public ScheduledQueryRuleResourceInner withSkipQueryValidation(Boolean skipQueryValidation) { + if (this.innerProperties() == null) { + this.innerProperties = new ScheduledQueryRuleProperties(); + } + this.innerProperties().withSkipQueryValidation(skipQueryValidation); + return this; + } + + /** + * Get the autoMitigate property: The flag that indicates whether the alert should be automatically resolved or not. + * The default is true. Relevant only for rules of the kind LogAlert. + * + * @return the autoMitigate value. + */ + public Boolean autoMitigate() { + return this.innerProperties() == null ? null : this.innerProperties().autoMitigate(); + } + + /** + * Set the autoMitigate property: The flag that indicates whether the alert should be automatically resolved or not. + * The default is true. Relevant only for rules of the kind LogAlert. + * + * @param autoMitigate the autoMitigate value to set. + * @return the ScheduledQueryRuleResourceInner object itself. + */ + public ScheduledQueryRuleResourceInner withAutoMitigate(Boolean autoMitigate) { + if (this.innerProperties() == null) { + this.innerProperties = new ScheduledQueryRuleProperties(); + } + this.innerProperties().withAutoMitigate(autoMitigate); + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (innerProperties() == null) { + throw logger + .logExceptionAsError( + new IllegalArgumentException( + "Missing required property innerProperties in model ScheduledQueryRuleResourceInner")); + } else { + innerProperties().validate(); + } + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/fluent/models/package-info.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/fluent/models/package-info.java new file mode 100644 index 0000000000000..f47cfdde9d782 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/fluent/models/package-info.java @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +/** Package containing the inner data models for MonitorClient. Monitor Management Client. */ +package com.azure.resourcemanager.monitor.generated.fluent.models; diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/fluent/package-info.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/fluent/package-info.java new file mode 100644 index 0000000000000..42ea0995be6e7 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/fluent/package-info.java @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +/** Package containing the service clients for MonitorClient. Monitor Management Client. */ +package com.azure.resourcemanager.monitor.generated.fluent; diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/implementation/MonitorClientBuilder.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/implementation/MonitorClientBuilder.java new file mode 100644 index 0000000000000..95114498d4dd0 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/implementation/MonitorClientBuilder.java @@ -0,0 +1,146 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.monitor.generated.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.CookiePolicy; +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 MonitorClientImpl type. */ +@ServiceClientBuilder(serviceClients = {MonitorClientImpl.class}) +public final class MonitorClientBuilder { + /* + * The ID of the target subscription. + */ + private String subscriptionId; + + /** + * Sets The ID of the target subscription. + * + * @param subscriptionId the subscriptionId value. + * @return the MonitorClientBuilder. + */ + public MonitorClientBuilder subscriptionId(String subscriptionId) { + this.subscriptionId = subscriptionId; + return this; + } + + /* + * server parameter + */ + private String endpoint; + + /** + * Sets server parameter. + * + * @param endpoint the endpoint value. + * @return the MonitorClientBuilder. + */ + public MonitorClientBuilder 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 MonitorClientBuilder. + */ + public MonitorClientBuilder environment(AzureEnvironment environment) { + this.environment = environment; + 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 MonitorClientBuilder. + */ + public MonitorClientBuilder defaultPollInterval(Duration defaultPollInterval) { + this.defaultPollInterval = defaultPollInterval; + 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 MonitorClientBuilder. + */ + public MonitorClientBuilder pipeline(HttpPipeline pipeline) { + this.pipeline = pipeline; + 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 MonitorClientBuilder. + */ + public MonitorClientBuilder serializerAdapter(SerializerAdapter serializerAdapter) { + this.serializerAdapter = serializerAdapter; + return this; + } + + /** + * Builds an instance of MonitorClientImpl with the provided parameters. + * + * @return an instance of MonitorClientImpl. + */ + public MonitorClientImpl buildClient() { + if (endpoint == null) { + this.endpoint = "https://management.azure.com"; + } + if (environment == null) { + this.environment = AzureEnvironment.AZURE; + } + if (defaultPollInterval == null) { + this.defaultPollInterval = Duration.ofSeconds(30); + } + if (pipeline == null) { + this.pipeline = + new HttpPipelineBuilder() + .policies(new UserAgentPolicy(), new RetryPolicy(), new CookiePolicy()) + .build(); + } + if (serializerAdapter == null) { + this.serializerAdapter = SerializerFactory.createDefaultManagementSerializerAdapter(); + } + MonitorClientImpl client = + new MonitorClientImpl( + pipeline, serializerAdapter, defaultPollInterval, environment, subscriptionId, endpoint); + return client; + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/implementation/MonitorClientImpl.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/implementation/MonitorClientImpl.java new file mode 100644 index 0000000000000..7d49105e220e1 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/implementation/MonitorClientImpl.java @@ -0,0 +1,293 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.monitor.generated.implementation; + +import com.azure.core.annotation.ServiceClient; +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.util.Context; +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.serializer.SerializerAdapter; +import com.azure.core.util.serializer.SerializerEncoding; +import com.azure.resourcemanager.monitor.generated.fluent.MonitorClient; +import com.azure.resourcemanager.monitor.generated.fluent.ScheduledQueryRulesClient; +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 java.util.Map; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +/** Initializes a new instance of the MonitorClientImpl type. */ +@ServiceClient(builder = MonitorClientBuilder.class) +public final class MonitorClientImpl implements MonitorClient { + private final ClientLogger logger = new ClientLogger(MonitorClientImpl.class); + + /** The ID of the target subscription. */ + private final String subscriptionId; + + /** + * Gets The ID of the target subscription. + * + * @return the subscriptionId value. + */ + public String getSubscriptionId() { + return this.subscriptionId; + } + + /** server parameter. */ + private final String endpoint; + + /** + * Gets server parameter. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** Api Version. */ + private final String apiVersion; + + /** + * Gets Api Version. + * + * @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 ScheduledQueryRulesClient object to access its operations. */ + private final ScheduledQueryRulesClient scheduledQueryRules; + + /** + * Gets the ScheduledQueryRulesClient object to access its operations. + * + * @return the ScheduledQueryRulesClient object. + */ + public ScheduledQueryRulesClient getScheduledQueryRules() { + return this.scheduledQueryRules; + } + + /** + * Initializes an instance of MonitorClient 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 subscriptionId The ID of the target subscription. + * @param endpoint server parameter. + */ + MonitorClientImpl( + HttpPipeline httpPipeline, + SerializerAdapter serializerAdapter, + Duration defaultPollInterval, + AzureEnvironment environment, + String subscriptionId, + String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.defaultPollInterval = defaultPollInterval; + this.subscriptionId = subscriptionId; + this.endpoint = endpoint; + this.apiVersion = "2021-08-01"; + this.scheduledQueryRules = new ScheduledQueryRulesClientImpl(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) { + for (Map.Entry entry : this.getContext().getValues().entrySet()) { + context = context.addData(entry.getKey(), entry.getValue()); + } + return 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 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(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)); + } + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/implementation/ScheduledQueryRuleResourceImpl.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/implementation/ScheduledQueryRuleResourceImpl.java new file mode 100644 index 0000000000000..c3a2b4897dfa3 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/implementation/ScheduledQueryRuleResourceImpl.java @@ -0,0 +1,434 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.monitor.generated.implementation; + +import com.azure.core.management.Region; +import com.azure.core.management.SystemData; +import com.azure.core.util.Context; +import com.azure.resourcemanager.monitor.generated.fluent.models.ScheduledQueryRuleResourceInner; +import com.azure.resourcemanager.monitor.generated.models.Actions; +import com.azure.resourcemanager.monitor.generated.models.AlertSeverity; +import com.azure.resourcemanager.monitor.generated.models.Kind; +import com.azure.resourcemanager.monitor.generated.models.ScheduledQueryRuleCriteria; +import com.azure.resourcemanager.monitor.generated.models.ScheduledQueryRuleResource; +import com.azure.resourcemanager.monitor.generated.models.ScheduledQueryRuleResourcePatch; +import java.time.Duration; +import java.util.Collections; +import java.util.List; +import java.util.Map; + +public final class ScheduledQueryRuleResourceImpl + implements ScheduledQueryRuleResource, ScheduledQueryRuleResource.Definition, ScheduledQueryRuleResource.Update { + private ScheduledQueryRuleResourceInner innerObject; + + private final com.azure.resourcemanager.monitor.generated.MonitorManager serviceManager; + + public String id() { + return this.innerModel().id(); + } + + public String name() { + return this.innerModel().name(); + } + + public String type() { + return this.innerModel().type(); + } + + public String location() { + return this.innerModel().location(); + } + + public Map tags() { + Map inner = this.innerModel().tags(); + if (inner != null) { + return Collections.unmodifiableMap(inner); + } else { + return Collections.emptyMap(); + } + } + + public Kind kind() { + return this.innerModel().kind(); + } + + public String etag() { + return this.innerModel().etag(); + } + + public SystemData systemData() { + return this.innerModel().systemData(); + } + + public String createdWithApiVersion() { + return this.innerModel().createdWithApiVersion(); + } + + public Boolean isLegacyLogAnalyticsRule() { + return this.innerModel().isLegacyLogAnalyticsRule(); + } + + public String description() { + return this.innerModel().description(); + } + + public String displayName() { + return this.innerModel().displayName(); + } + + public AlertSeverity severity() { + return this.innerModel().severity(); + } + + public Boolean enabled() { + return this.innerModel().enabled(); + } + + public List scopes() { + List inner = this.innerModel().scopes(); + if (inner != null) { + return Collections.unmodifiableList(inner); + } else { + return Collections.emptyList(); + } + } + + public Duration evaluationFrequency() { + return this.innerModel().evaluationFrequency(); + } + + public Duration windowSize() { + return this.innerModel().windowSize(); + } + + public Duration overrideQueryTimeRange() { + return this.innerModel().overrideQueryTimeRange(); + } + + public List targetResourceTypes() { + List inner = this.innerModel().targetResourceTypes(); + if (inner != null) { + return Collections.unmodifiableList(inner); + } else { + return Collections.emptyList(); + } + } + + public ScheduledQueryRuleCriteria criteria() { + return this.innerModel().criteria(); + } + + public Duration muteActionsDuration() { + return this.innerModel().muteActionsDuration(); + } + + public Actions actions() { + return this.innerModel().actions(); + } + + public Boolean isWorkspaceAlertsStorageConfigured() { + return this.innerModel().isWorkspaceAlertsStorageConfigured(); + } + + public Boolean checkWorkspaceAlertsStorageConfigured() { + return this.innerModel().checkWorkspaceAlertsStorageConfigured(); + } + + public Boolean skipQueryValidation() { + return this.innerModel().skipQueryValidation(); + } + + public Boolean autoMitigate() { + return this.innerModel().autoMitigate(); + } + + public Region region() { + return Region.fromName(this.regionName()); + } + + public String regionName() { + return this.location(); + } + + public ScheduledQueryRuleResourceInner innerModel() { + return this.innerObject; + } + + private com.azure.resourcemanager.monitor.generated.MonitorManager manager() { + return this.serviceManager; + } + + private String resourceGroupName; + + private String ruleName; + + private ScheduledQueryRuleResourcePatch updateParameters; + + public ScheduledQueryRuleResourceImpl withExistingResourceGroup(String resourceGroupName) { + this.resourceGroupName = resourceGroupName; + return this; + } + + public ScheduledQueryRuleResource create() { + this.innerObject = + serviceManager + .serviceClient() + .getScheduledQueryRules() + .createOrUpdateWithResponse(resourceGroupName, ruleName, this.innerModel(), Context.NONE) + .getValue(); + return this; + } + + public ScheduledQueryRuleResource create(Context context) { + this.innerObject = + serviceManager + .serviceClient() + .getScheduledQueryRules() + .createOrUpdateWithResponse(resourceGroupName, ruleName, this.innerModel(), context) + .getValue(); + return this; + } + + ScheduledQueryRuleResourceImpl( + String name, com.azure.resourcemanager.monitor.generated.MonitorManager serviceManager) { + this.innerObject = new ScheduledQueryRuleResourceInner(); + this.serviceManager = serviceManager; + this.ruleName = name; + } + + public ScheduledQueryRuleResourceImpl update() { + this.updateParameters = new ScheduledQueryRuleResourcePatch(); + return this; + } + + public ScheduledQueryRuleResource apply() { + this.innerObject = + serviceManager + .serviceClient() + .getScheduledQueryRules() + .updateWithResponse(resourceGroupName, ruleName, updateParameters, Context.NONE) + .getValue(); + return this; + } + + public ScheduledQueryRuleResource apply(Context context) { + this.innerObject = + serviceManager + .serviceClient() + .getScheduledQueryRules() + .updateWithResponse(resourceGroupName, ruleName, updateParameters, context) + .getValue(); + return this; + } + + ScheduledQueryRuleResourceImpl( + ScheduledQueryRuleResourceInner innerObject, + com.azure.resourcemanager.monitor.generated.MonitorManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + this.resourceGroupName = Utils.getValueFromIdByName(innerObject.id(), "resourceGroups"); + this.ruleName = Utils.getValueFromIdByName(innerObject.id(), "scheduledQueryRules"); + } + + public ScheduledQueryRuleResource refresh() { + this.innerObject = + serviceManager + .serviceClient() + .getScheduledQueryRules() + .getByResourceGroupWithResponse(resourceGroupName, ruleName, Context.NONE) + .getValue(); + return this; + } + + public ScheduledQueryRuleResource refresh(Context context) { + this.innerObject = + serviceManager + .serviceClient() + .getScheduledQueryRules() + .getByResourceGroupWithResponse(resourceGroupName, ruleName, context) + .getValue(); + return this; + } + + public ScheduledQueryRuleResourceImpl withRegion(Region location) { + this.innerModel().withLocation(location.toString()); + return this; + } + + public ScheduledQueryRuleResourceImpl withRegion(String location) { + this.innerModel().withLocation(location); + return this; + } + + public ScheduledQueryRuleResourceImpl withTags(Map tags) { + if (isInCreateMode()) { + this.innerModel().withTags(tags); + return this; + } else { + this.updateParameters.withTags(tags); + return this; + } + } + + public ScheduledQueryRuleResourceImpl withKind(Kind kind) { + this.innerModel().withKind(kind); + return this; + } + + public ScheduledQueryRuleResourceImpl withDescription(String description) { + if (isInCreateMode()) { + this.innerModel().withDescription(description); + return this; + } else { + this.updateParameters.withDescription(description); + return this; + } + } + + public ScheduledQueryRuleResourceImpl withDisplayName(String displayName) { + if (isInCreateMode()) { + this.innerModel().withDisplayName(displayName); + return this; + } else { + this.updateParameters.withDisplayName(displayName); + return this; + } + } + + public ScheduledQueryRuleResourceImpl withSeverity(AlertSeverity severity) { + if (isInCreateMode()) { + this.innerModel().withSeverity(severity); + return this; + } else { + this.updateParameters.withSeverity(severity); + return this; + } + } + + public ScheduledQueryRuleResourceImpl withEnabled(Boolean enabled) { + if (isInCreateMode()) { + this.innerModel().withEnabled(enabled); + return this; + } else { + this.updateParameters.withEnabled(enabled); + return this; + } + } + + public ScheduledQueryRuleResourceImpl withScopes(List scopes) { + if (isInCreateMode()) { + this.innerModel().withScopes(scopes); + return this; + } else { + this.updateParameters.withScopes(scopes); + return this; + } + } + + public ScheduledQueryRuleResourceImpl withEvaluationFrequency(Duration evaluationFrequency) { + if (isInCreateMode()) { + this.innerModel().withEvaluationFrequency(evaluationFrequency); + return this; + } else { + this.updateParameters.withEvaluationFrequency(evaluationFrequency); + return this; + } + } + + public ScheduledQueryRuleResourceImpl withWindowSize(Duration windowSize) { + if (isInCreateMode()) { + this.innerModel().withWindowSize(windowSize); + return this; + } else { + this.updateParameters.withWindowSize(windowSize); + return this; + } + } + + public ScheduledQueryRuleResourceImpl withOverrideQueryTimeRange(Duration overrideQueryTimeRange) { + if (isInCreateMode()) { + this.innerModel().withOverrideQueryTimeRange(overrideQueryTimeRange); + return this; + } else { + this.updateParameters.withOverrideQueryTimeRange(overrideQueryTimeRange); + return this; + } + } + + public ScheduledQueryRuleResourceImpl withTargetResourceTypes(List targetResourceTypes) { + if (isInCreateMode()) { + this.innerModel().withTargetResourceTypes(targetResourceTypes); + return this; + } else { + this.updateParameters.withTargetResourceTypes(targetResourceTypes); + return this; + } + } + + public ScheduledQueryRuleResourceImpl withCriteria(ScheduledQueryRuleCriteria criteria) { + if (isInCreateMode()) { + this.innerModel().withCriteria(criteria); + return this; + } else { + this.updateParameters.withCriteria(criteria); + return this; + } + } + + public ScheduledQueryRuleResourceImpl withMuteActionsDuration(Duration muteActionsDuration) { + if (isInCreateMode()) { + this.innerModel().withMuteActionsDuration(muteActionsDuration); + return this; + } else { + this.updateParameters.withMuteActionsDuration(muteActionsDuration); + return this; + } + } + + public ScheduledQueryRuleResourceImpl withActions(Actions actions) { + if (isInCreateMode()) { + this.innerModel().withActions(actions); + return this; + } else { + this.updateParameters.withActions(actions); + return this; + } + } + + public ScheduledQueryRuleResourceImpl withCheckWorkspaceAlertsStorageConfigured( + Boolean checkWorkspaceAlertsStorageConfigured) { + if (isInCreateMode()) { + this.innerModel().withCheckWorkspaceAlertsStorageConfigured(checkWorkspaceAlertsStorageConfigured); + return this; + } else { + this.updateParameters.withCheckWorkspaceAlertsStorageConfigured(checkWorkspaceAlertsStorageConfigured); + return this; + } + } + + public ScheduledQueryRuleResourceImpl withSkipQueryValidation(Boolean skipQueryValidation) { + if (isInCreateMode()) { + this.innerModel().withSkipQueryValidation(skipQueryValidation); + return this; + } else { + this.updateParameters.withSkipQueryValidation(skipQueryValidation); + return this; + } + } + + public ScheduledQueryRuleResourceImpl withAutoMitigate(Boolean autoMitigate) { + if (isInCreateMode()) { + this.innerModel().withAutoMitigate(autoMitigate); + return this; + } else { + this.updateParameters.withAutoMitigate(autoMitigate); + return this; + } + } + + private boolean isInCreateMode() { + return this.innerModel().id() == null; + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/implementation/ScheduledQueryRulesClientImpl.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/implementation/ScheduledQueryRulesClientImpl.java new file mode 100644 index 0000000000000..4c9fa5d155e7a --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/implementation/ScheduledQueryRulesClientImpl.java @@ -0,0 +1,1251 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.monitor.generated.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.Patch; +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.core.util.logging.ClientLogger; +import com.azure.resourcemanager.monitor.generated.fluent.ScheduledQueryRulesClient; +import com.azure.resourcemanager.monitor.generated.fluent.models.ScheduledQueryRuleResourceInner; +import com.azure.resourcemanager.monitor.generated.models.ScheduledQueryRuleResourceCollection; +import com.azure.resourcemanager.monitor.generated.models.ScheduledQueryRuleResourcePatch; +import reactor.core.publisher.Mono; + +/** An instance of this class provides access to all the operations defined in ScheduledQueryRulesClient. */ +public final class ScheduledQueryRulesClientImpl implements ScheduledQueryRulesClient { + private final ClientLogger logger = new ClientLogger(ScheduledQueryRulesClientImpl.class); + + /** The proxy service used to perform REST calls. */ + private final ScheduledQueryRulesService service; + + /** The service client containing this operation class. */ + private final MonitorClientImpl client; + + /** + * Initializes an instance of ScheduledQueryRulesClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + ScheduledQueryRulesClientImpl(MonitorClientImpl client) { + this.service = + RestProxy.create(ScheduledQueryRulesService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for MonitorClientScheduledQueryRules to be used by the proxy service to + * perform REST calls. + */ + @Host("{$host}") + @ServiceInterface(name = "MonitorClientSchedul") + private interface ScheduledQueryRulesService { + @Headers({"Content-Type: application/json"}) + @Get("/subscriptions/{subscriptionId}/providers/Microsoft.Insights/scheduledQueryRules") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> list( + @HostParam("$host") String endpoint, + @PathParam("subscriptionId") String subscriptionId, + @QueryParam("api-version") String apiVersion, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Content-Type: application/json"}) + @Get( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights" + + "/scheduledQueryRules") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listByResourceGroup( + @HostParam("$host") String endpoint, + @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @QueryParam("api-version") String apiVersion, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Content-Type: application/json"}) + @Get( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights" + + "/scheduledQueryRules/{ruleName}") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> getByResourceGroup( + @HostParam("$host") String endpoint, + @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("ruleName") String ruleName, + @QueryParam("api-version") String apiVersion, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Content-Type: application/json"}) + @Put( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights" + + "/scheduledQueryRules/{ruleName}") + @ExpectedResponses({200, 201}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> createOrUpdate( + @HostParam("$host") String endpoint, + @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("ruleName") String ruleName, + @QueryParam("api-version") String apiVersion, + @BodyParam("application/json") ScheduledQueryRuleResourceInner parameters, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Content-Type: application/json"}) + @Patch( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights" + + "/scheduledQueryRules/{ruleName}") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> update( + @HostParam("$host") String endpoint, + @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("ruleName") String ruleName, + @QueryParam("api-version") String apiVersion, + @BodyParam("application/json") ScheduledQueryRuleResourcePatch parameters, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Content-Type: application/json"}) + @Delete( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights" + + "/scheduledQueryRules/{ruleName}") + @ExpectedResponses({200, 204}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> delete( + @HostParam("$host") String endpoint, + @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("ruleName") String ruleName, + @QueryParam("api-version") String apiVersion, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Content-Type: application/json"}) + @Get("{nextLink}") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listBySubscriptionNext( + @PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("$host") String endpoint, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Content-Type: application/json"}) + @Get("{nextLink}") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listByResourceGroupNext( + @PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("$host") String endpoint, + @HeaderParam("Accept") String accept, + Context context); + } + + /** + * Retrieve a scheduled query rule definitions in a subscription. + * + * @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 a collection of scheduled query rule resources. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listSinglePageAsync() { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> + service + .list( + this.client.getEndpoint(), + this.client.getSubscriptionId(), + 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())); + } + + /** + * Retrieve a scheduled query rule definitions in a subscription. + * + * @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 a collection of scheduled query rule resources. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listSinglePageAsync(Context context) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .list( + this.client.getEndpoint(), + this.client.getSubscriptionId(), + this.client.getApiVersion(), + accept, + context) + .map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().value(), + res.getValue().nextLink(), + null)); + } + + /** + * Retrieve a scheduled query rule definitions in a subscription. + * + * @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 a collection of scheduled query rule resources. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync() { + return new PagedFlux<>( + () -> listSinglePageAsync(), nextLink -> listBySubscriptionNextSinglePageAsync(nextLink)); + } + + /** + * Retrieve a scheduled query rule definitions in a subscription. + * + * @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 a collection of scheduled query rule resources. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync(Context context) { + return new PagedFlux<>( + () -> listSinglePageAsync(context), nextLink -> listBySubscriptionNextSinglePageAsync(nextLink, context)); + } + + /** + * Retrieve a scheduled query rule definitions in a subscription. + * + * @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 a collection of scheduled query rule resources. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list() { + return new PagedIterable<>(listAsync()); + } + + /** + * Retrieve a scheduled query rule definitions in a subscription. + * + * @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 a collection of scheduled query rule resources. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(Context context) { + return new PagedIterable<>(listAsync(context)); + } + + /** + * Retrieve scheduled query rule definitions in a resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @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 a collection of scheduled query rule resources. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByResourceGroupSinglePageAsync( + String resourceGroupName) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> + service + .listByResourceGroup( + this.client.getEndpoint(), + this.client.getSubscriptionId(), + resourceGroupName, + 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())); + } + + /** + * Retrieve scheduled query rule definitions in a resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @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 a collection of scheduled query rule resources. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByResourceGroupSinglePageAsync( + String resourceGroupName, Context context) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .listByResourceGroup( + this.client.getEndpoint(), + this.client.getSubscriptionId(), + resourceGroupName, + this.client.getApiVersion(), + accept, + context) + .map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().value(), + res.getValue().nextLink(), + null)); + } + + /** + * Retrieve scheduled query rule definitions in a resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @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 a collection of scheduled query rule resources. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listByResourceGroupAsync(String resourceGroupName) { + return new PagedFlux<>( + () -> listByResourceGroupSinglePageAsync(resourceGroupName), + nextLink -> listByResourceGroupNextSinglePageAsync(nextLink)); + } + + /** + * Retrieve scheduled query rule definitions in a resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @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 a collection of scheduled query rule resources. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listByResourceGroupAsync( + String resourceGroupName, Context context) { + return new PagedFlux<>( + () -> listByResourceGroupSinglePageAsync(resourceGroupName, context), + nextLink -> listByResourceGroupNextSinglePageAsync(nextLink, context)); + } + + /** + * Retrieve scheduled query rule definitions in a resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @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 a collection of scheduled query rule resources. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listByResourceGroup(String resourceGroupName) { + return new PagedIterable<>(listByResourceGroupAsync(resourceGroupName)); + } + + /** + * Retrieve scheduled query rule definitions in a resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @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 a collection of scheduled query rule resources. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listByResourceGroup( + String resourceGroupName, Context context) { + return new PagedIterable<>(listByResourceGroupAsync(resourceGroupName, context)); + } + + /** + * Retrieve an scheduled query rule definition. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param ruleName The name of the rule. + * @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 scheduled query rule resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getByResourceGroupWithResponseAsync( + String resourceGroupName, String ruleName) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (ruleName == null) { + return Mono.error(new IllegalArgumentException("Parameter ruleName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> + service + .getByResourceGroup( + this.client.getEndpoint(), + this.client.getSubscriptionId(), + resourceGroupName, + ruleName, + this.client.getApiVersion(), + accept, + context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Retrieve an scheduled query rule definition. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param ruleName The name of the rule. + * @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 scheduled query rule resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getByResourceGroupWithResponseAsync( + String resourceGroupName, String ruleName, Context context) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (ruleName == null) { + return Mono.error(new IllegalArgumentException("Parameter ruleName is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .getByResourceGroup( + this.client.getEndpoint(), + this.client.getSubscriptionId(), + resourceGroupName, + ruleName, + this.client.getApiVersion(), + accept, + context); + } + + /** + * Retrieve an scheduled query rule definition. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param ruleName The name of the rule. + * @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 scheduled query rule resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono getByResourceGroupAsync(String resourceGroupName, String ruleName) { + return getByResourceGroupWithResponseAsync(resourceGroupName, ruleName) + .flatMap( + (Response res) -> { + if (res.getValue() != null) { + return Mono.just(res.getValue()); + } else { + return Mono.empty(); + } + }); + } + + /** + * Retrieve an scheduled query rule definition. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param ruleName The name of the rule. + * @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 scheduled query rule resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ScheduledQueryRuleResourceInner getByResourceGroup(String resourceGroupName, String ruleName) { + return getByResourceGroupAsync(resourceGroupName, ruleName).block(); + } + + /** + * Retrieve an scheduled query rule definition. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param ruleName The name of the rule. + * @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 scheduled query rule resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getByResourceGroupWithResponse( + String resourceGroupName, String ruleName, Context context) { + return getByResourceGroupWithResponseAsync(resourceGroupName, ruleName, context).block(); + } + + /** + * Creates or updates a scheduled query rule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param ruleName The name of the rule. + * @param parameters The parameters of the rule to create or update. + * @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 scheduled query rule resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> createOrUpdateWithResponseAsync( + String resourceGroupName, String ruleName, ScheduledQueryRuleResourceInner parameters) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (ruleName == null) { + return Mono.error(new IllegalArgumentException("Parameter ruleName is required and cannot be null.")); + } + if (parameters == null) { + return Mono.error(new IllegalArgumentException("Parameter parameters is required and cannot be null.")); + } else { + parameters.validate(); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> + service + .createOrUpdate( + this.client.getEndpoint(), + this.client.getSubscriptionId(), + resourceGroupName, + ruleName, + this.client.getApiVersion(), + parameters, + accept, + context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Creates or updates a scheduled query rule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param ruleName The name of the rule. + * @param parameters The parameters of the rule to create or update. + * @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 scheduled query rule resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> createOrUpdateWithResponseAsync( + String resourceGroupName, String ruleName, ScheduledQueryRuleResourceInner parameters, Context context) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (ruleName == null) { + return Mono.error(new IllegalArgumentException("Parameter ruleName is required and cannot be null.")); + } + if (parameters == null) { + return Mono.error(new IllegalArgumentException("Parameter parameters is required and cannot be null.")); + } else { + parameters.validate(); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .createOrUpdate( + this.client.getEndpoint(), + this.client.getSubscriptionId(), + resourceGroupName, + ruleName, + this.client.getApiVersion(), + parameters, + accept, + context); + } + + /** + * Creates or updates a scheduled query rule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param ruleName The name of the rule. + * @param parameters The parameters of the rule to create or update. + * @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 scheduled query rule resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono createOrUpdateAsync( + String resourceGroupName, String ruleName, ScheduledQueryRuleResourceInner parameters) { + return createOrUpdateWithResponseAsync(resourceGroupName, ruleName, parameters) + .flatMap( + (Response res) -> { + if (res.getValue() != null) { + return Mono.just(res.getValue()); + } else { + return Mono.empty(); + } + }); + } + + /** + * Creates or updates a scheduled query rule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param ruleName The name of the rule. + * @param parameters The parameters of the rule to create or update. + * @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 scheduled query rule resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ScheduledQueryRuleResourceInner createOrUpdate( + String resourceGroupName, String ruleName, ScheduledQueryRuleResourceInner parameters) { + return createOrUpdateAsync(resourceGroupName, ruleName, parameters).block(); + } + + /** + * Creates or updates a scheduled query rule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param ruleName The name of the rule. + * @param parameters The parameters of the rule to create or update. + * @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 scheduled query rule resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response createOrUpdateWithResponse( + String resourceGroupName, String ruleName, ScheduledQueryRuleResourceInner parameters, Context context) { + return createOrUpdateWithResponseAsync(resourceGroupName, ruleName, parameters, context).block(); + } + + /** + * Update a scheduled query rule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param ruleName The name of the rule. + * @param parameters The parameters of the rule to update. + * @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 scheduled query rule resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> updateWithResponseAsync( + String resourceGroupName, String ruleName, ScheduledQueryRuleResourcePatch parameters) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (ruleName == null) { + return Mono.error(new IllegalArgumentException("Parameter ruleName is required and cannot be null.")); + } + if (parameters == null) { + return Mono.error(new IllegalArgumentException("Parameter parameters is required and cannot be null.")); + } else { + parameters.validate(); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> + service + .update( + this.client.getEndpoint(), + this.client.getSubscriptionId(), + resourceGroupName, + ruleName, + this.client.getApiVersion(), + parameters, + accept, + context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Update a scheduled query rule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param ruleName The name of the rule. + * @param parameters The parameters of the rule to update. + * @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 scheduled query rule resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> updateWithResponseAsync( + String resourceGroupName, String ruleName, ScheduledQueryRuleResourcePatch parameters, Context context) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (ruleName == null) { + return Mono.error(new IllegalArgumentException("Parameter ruleName is required and cannot be null.")); + } + if (parameters == null) { + return Mono.error(new IllegalArgumentException("Parameter parameters is required and cannot be null.")); + } else { + parameters.validate(); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .update( + this.client.getEndpoint(), + this.client.getSubscriptionId(), + resourceGroupName, + ruleName, + this.client.getApiVersion(), + parameters, + accept, + context); + } + + /** + * Update a scheduled query rule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param ruleName The name of the rule. + * @param parameters The parameters of the rule to update. + * @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 scheduled query rule resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono updateAsync( + String resourceGroupName, String ruleName, ScheduledQueryRuleResourcePatch parameters) { + return updateWithResponseAsync(resourceGroupName, ruleName, parameters) + .flatMap( + (Response res) -> { + if (res.getValue() != null) { + return Mono.just(res.getValue()); + } else { + return Mono.empty(); + } + }); + } + + /** + * Update a scheduled query rule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param ruleName The name of the rule. + * @param parameters The parameters of the rule to update. + * @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 scheduled query rule resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ScheduledQueryRuleResourceInner update( + String resourceGroupName, String ruleName, ScheduledQueryRuleResourcePatch parameters) { + return updateAsync(resourceGroupName, ruleName, parameters).block(); + } + + /** + * Update a scheduled query rule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param ruleName The name of the rule. + * @param parameters The parameters of the rule to update. + * @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 scheduled query rule resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response updateWithResponse( + String resourceGroupName, String ruleName, ScheduledQueryRuleResourcePatch parameters, Context context) { + return updateWithResponseAsync(resourceGroupName, ruleName, parameters, context).block(); + } + + /** + * Deletes a scheduled query rule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param ruleName The name of the rule. + * @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 completion. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> deleteWithResponseAsync(String resourceGroupName, String ruleName) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (ruleName == null) { + return Mono.error(new IllegalArgumentException("Parameter ruleName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> + service + .delete( + this.client.getEndpoint(), + this.client.getSubscriptionId(), + resourceGroupName, + ruleName, + this.client.getApiVersion(), + accept, + context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Deletes a scheduled query rule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param ruleName The name of the rule. + * @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 completion. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> deleteWithResponseAsync(String resourceGroupName, String ruleName, Context context) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (ruleName == null) { + return Mono.error(new IllegalArgumentException("Parameter ruleName is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .delete( + this.client.getEndpoint(), + this.client.getSubscriptionId(), + resourceGroupName, + ruleName, + this.client.getApiVersion(), + accept, + context); + } + + /** + * Deletes a scheduled query rule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param ruleName The name of the rule. + * @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 completion. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono deleteAsync(String resourceGroupName, String ruleName) { + return deleteWithResponseAsync(resourceGroupName, ruleName).flatMap((Response res) -> Mono.empty()); + } + + /** + * Deletes a scheduled query rule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param ruleName The name of the rule. + * @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 resourceGroupName, String ruleName) { + deleteAsync(resourceGroupName, ruleName).block(); + } + + /** + * Deletes a scheduled query rule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param ruleName The name of the rule. + * @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. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response deleteWithResponse(String resourceGroupName, String ruleName, Context context) { + return deleteWithResponseAsync(resourceGroupName, ruleName, context).block(); + } + + /** + * Get the next page of items. + * + * @param nextLink The nextLink parameter. + * @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 a collection of scheduled query rule resources. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listBySubscriptionNextSinglePageAsync( + String nextLink) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> service.listBySubscriptionNext(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 nextLink parameter. + * @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 a collection of scheduled query rule resources. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listBySubscriptionNextSinglePageAsync( + String nextLink, Context context) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .listBySubscriptionNext(nextLink, this.client.getEndpoint(), accept, context) + .map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().value(), + res.getValue().nextLink(), + null)); + } + + /** + * Get the next page of items. + * + * @param nextLink The nextLink parameter. + * @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 a collection of scheduled query rule resources. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByResourceGroupNextSinglePageAsync( + String nextLink) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> service.listByResourceGroupNext(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 nextLink parameter. + * @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 a collection of scheduled query rule resources. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByResourceGroupNextSinglePageAsync( + String nextLink, Context context) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .listByResourceGroupNext(nextLink, this.client.getEndpoint(), accept, context) + .map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().value(), + res.getValue().nextLink(), + null)); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/implementation/ScheduledQueryRulesImpl.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/implementation/ScheduledQueryRulesImpl.java new file mode 100644 index 0000000000000..459a4ce96bef7 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/implementation/ScheduledQueryRulesImpl.java @@ -0,0 +1,181 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.monitor.generated.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.generated.fluent.ScheduledQueryRulesClient; +import com.azure.resourcemanager.monitor.generated.fluent.models.ScheduledQueryRuleResourceInner; +import com.azure.resourcemanager.monitor.generated.models.ScheduledQueryRuleResource; +import com.azure.resourcemanager.monitor.generated.models.ScheduledQueryRules; +import com.fasterxml.jackson.annotation.JsonIgnore; + +public final class ScheduledQueryRulesImpl implements ScheduledQueryRules { + @JsonIgnore private final ClientLogger logger = new ClientLogger(ScheduledQueryRulesImpl.class); + + private final ScheduledQueryRulesClient innerClient; + + private final com.azure.resourcemanager.monitor.generated.MonitorManager serviceManager; + + public ScheduledQueryRulesImpl( + ScheduledQueryRulesClient innerClient, + com.azure.resourcemanager.monitor.generated.MonitorManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public PagedIterable list() { + PagedIterable inner = this.serviceClient().list(); + return Utils.mapPage(inner, inner1 -> new ScheduledQueryRuleResourceImpl(inner1, this.manager())); + } + + public PagedIterable list(Context context) { + PagedIterable inner = this.serviceClient().list(context); + return Utils.mapPage(inner, inner1 -> new ScheduledQueryRuleResourceImpl(inner1, this.manager())); + } + + public PagedIterable listByResourceGroup(String resourceGroupName) { + PagedIterable inner = + this.serviceClient().listByResourceGroup(resourceGroupName); + return Utils.mapPage(inner, inner1 -> new ScheduledQueryRuleResourceImpl(inner1, this.manager())); + } + + public PagedIterable listByResourceGroup(String resourceGroupName, Context context) { + PagedIterable inner = + this.serviceClient().listByResourceGroup(resourceGroupName, context); + return Utils.mapPage(inner, inner1 -> new ScheduledQueryRuleResourceImpl(inner1, this.manager())); + } + + public ScheduledQueryRuleResource getByResourceGroup(String resourceGroupName, String ruleName) { + ScheduledQueryRuleResourceInner inner = this.serviceClient().getByResourceGroup(resourceGroupName, ruleName); + if (inner != null) { + return new ScheduledQueryRuleResourceImpl(inner, this.manager()); + } else { + return null; + } + } + + public Response getByResourceGroupWithResponse( + String resourceGroupName, String ruleName, Context context) { + Response inner = + this.serviceClient().getByResourceGroupWithResponse(resourceGroupName, ruleName, context); + if (inner != null) { + return new SimpleResponse<>( + inner.getRequest(), + inner.getStatusCode(), + inner.getHeaders(), + new ScheduledQueryRuleResourceImpl(inner.getValue(), this.manager())); + } else { + return null; + } + } + + public void deleteByResourceGroup(String resourceGroupName, String ruleName) { + this.serviceClient().delete(resourceGroupName, ruleName); + } + + public Response deleteWithResponse(String resourceGroupName, String ruleName, Context context) { + return this.serviceClient().deleteWithResponse(resourceGroupName, ruleName, context); + } + + public ScheduledQueryRuleResource getById(String id) { + String resourceGroupName = Utils.getValueFromIdByName(id, "resourceGroups"); + if (resourceGroupName == null) { + throw logger + .logExceptionAsError( + new IllegalArgumentException( + String + .format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id))); + } + String ruleName = Utils.getValueFromIdByName(id, "scheduledQueryRules"); + if (ruleName == null) { + throw logger + .logExceptionAsError( + new IllegalArgumentException( + String + .format( + "The resource ID '%s' is not valid. Missing path segment 'scheduledQueryRules'.", id))); + } + return this.getByResourceGroupWithResponse(resourceGroupName, ruleName, Context.NONE).getValue(); + } + + public Response getByIdWithResponse(String id, Context context) { + String resourceGroupName = Utils.getValueFromIdByName(id, "resourceGroups"); + if (resourceGroupName == null) { + throw logger + .logExceptionAsError( + new IllegalArgumentException( + String + .format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id))); + } + String ruleName = Utils.getValueFromIdByName(id, "scheduledQueryRules"); + if (ruleName == null) { + throw logger + .logExceptionAsError( + new IllegalArgumentException( + String + .format( + "The resource ID '%s' is not valid. Missing path segment 'scheduledQueryRules'.", id))); + } + return this.getByResourceGroupWithResponse(resourceGroupName, ruleName, context); + } + + public void deleteById(String id) { + String resourceGroupName = Utils.getValueFromIdByName(id, "resourceGroups"); + if (resourceGroupName == null) { + throw logger + .logExceptionAsError( + new IllegalArgumentException( + String + .format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id))); + } + String ruleName = Utils.getValueFromIdByName(id, "scheduledQueryRules"); + if (ruleName == null) { + throw logger + .logExceptionAsError( + new IllegalArgumentException( + String + .format( + "The resource ID '%s' is not valid. Missing path segment 'scheduledQueryRules'.", id))); + } + this.deleteWithResponse(resourceGroupName, ruleName, Context.NONE); + } + + public Response deleteByIdWithResponse(String id, Context context) { + String resourceGroupName = Utils.getValueFromIdByName(id, "resourceGroups"); + if (resourceGroupName == null) { + throw logger + .logExceptionAsError( + new IllegalArgumentException( + String + .format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id))); + } + String ruleName = Utils.getValueFromIdByName(id, "scheduledQueryRules"); + if (ruleName == null) { + throw logger + .logExceptionAsError( + new IllegalArgumentException( + String + .format( + "The resource ID '%s' is not valid. Missing path segment 'scheduledQueryRules'.", id))); + } + return this.deleteWithResponse(resourceGroupName, ruleName, context); + } + + private ScheduledQueryRulesClient serviceClient() { + return this.innerClient; + } + + private com.azure.resourcemanager.monitor.generated.MonitorManager manager() { + return this.serviceManager; + } + + public ScheduledQueryRuleResourceImpl define(String name) { + return new ScheduledQueryRuleResourceImpl(name, this.manager()); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/implementation/Utils.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/implementation/Utils.java new file mode 100644 index 0000000000000..eaf4e69bfabea --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/implementation/Utils.java @@ -0,0 +1,204 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.monitor.generated.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 Utils { + 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.size() > 0 && 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, PagedResponse>(pagedIterable.iterableByPage(), pageMapper); + } + + @Override + public Iterable> iterableByPage(String continuationToken) { + return new IterableImpl, PagedResponse>( + pagedIterable.iterableByPage(continuationToken), pageMapper); + } + + @Override + public Iterable> iterableByPage(int preferredPageSize) { + return new IterableImpl, PagedResponse>( + pagedIterable.iterableByPage(preferredPageSize), pageMapper); + } + + @Override + public Iterable> iterableByPage(String continuationToken, int preferredPageSize) { + return new IterableImpl, PagedResponse>( + 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-generated/src/main/java/com/azure/resourcemanager/monitor/generated/implementation/package-info.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/implementation/package-info.java new file mode 100644 index 0000000000000..64f7e8232bbdd --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/implementation/package-info.java @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +/** Package containing the implementations for MonitorClient. Monitor Management Client. */ +package com.azure.resourcemanager.monitor.generated.implementation; diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/Actions.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/Actions.java new file mode 100644 index 0000000000000..2bc239a7a7247 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/Actions.java @@ -0,0 +1,80 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.monitor.generated.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; +import java.util.Map; + +/** Actions to invoke when the alert fires. */ +@Fluent +public final class Actions { + @JsonIgnore private final ClientLogger logger = new ClientLogger(Actions.class); + + /* + * Action Group resource Ids to invoke when the alert fires. + */ + @JsonProperty(value = "actionGroups") + private List actionGroups; + + /* + * The properties of an alert payload. + */ + @JsonProperty(value = "customProperties") + @JsonInclude(value = JsonInclude.Include.NON_NULL, content = JsonInclude.Include.ALWAYS) + private Map customProperties; + + /** + * Get the actionGroups property: Action Group resource Ids to invoke when the alert fires. + * + * @return the actionGroups value. + */ + public List actionGroups() { + return this.actionGroups; + } + + /** + * Set the actionGroups property: Action Group resource Ids to invoke when the alert fires. + * + * @param actionGroups the actionGroups value to set. + * @return the Actions object itself. + */ + public Actions withActionGroups(List actionGroups) { + this.actionGroups = actionGroups; + return this; + } + + /** + * Get the customProperties property: The properties of an alert payload. + * + * @return the customProperties value. + */ + public Map customProperties() { + return this.customProperties; + } + + /** + * Set the customProperties property: The properties of an alert payload. + * + * @param customProperties the customProperties value to set. + * @return the Actions object itself. + */ + public Actions withCustomProperties(Map customProperties) { + this.customProperties = customProperties; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/AlertSeverity.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/AlertSeverity.java new file mode 100644 index 0000000000000..60521eb9bfc33 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/AlertSeverity.java @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.monitor.generated.models; + +import com.azure.core.util.ExpandableStringEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import java.util.Collection; + +/** Defines values for AlertSeverity. */ +public final class AlertSeverity extends ExpandableStringEnum { + /** Static value 0 for AlertSeverity. */ + public static final AlertSeverity ZERO = fromFloat(0f); + + /** Static value 1 for AlertSeverity. */ + public static final AlertSeverity ONE = fromFloat(1f); + + /** Static value 2 for AlertSeverity. */ + public static final AlertSeverity TWO = fromFloat(2f); + + /** Static value 3 for AlertSeverity. */ + public static final AlertSeverity THREE = fromFloat(3f); + + /** Static value 4 for AlertSeverity. */ + public static final AlertSeverity FOUR = fromFloat(4f); + + /** + * Creates or finds a AlertSeverity from its string representation. + * + * @param name a name to look for. + * @return the corresponding AlertSeverity. + */ + @JsonCreator + public static AlertSeverity fromFloat(float name) { + return fromString(String.valueOf(name), AlertSeverity.class); + } + + /** @return known AlertSeverity values. */ + public static Collection values() { + return values(AlertSeverity.class); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/Condition.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/Condition.java new file mode 100644 index 0000000000000..375c7d0717b0f --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/Condition.java @@ -0,0 +1,284 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.monitor.generated.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +/** A condition of the scheduled query rule. */ +@Fluent +public final class Condition { + @JsonIgnore private final ClientLogger logger = new ClientLogger(Condition.class); + + /* + * Log query alert + */ + @JsonProperty(value = "query") + private String query; + + /* + * Aggregation type. Relevant and required only for rules of the kind + * LogAlert. + */ + @JsonProperty(value = "timeAggregation") + private TimeAggregation timeAggregation; + + /* + * The column containing the metric measure number. Relevant only for rules + * of the kind LogAlert. + */ + @JsonProperty(value = "metricMeasureColumn") + private String metricMeasureColumn; + + /* + * The column containing the resource id. The content of the column must be + * a uri formatted as resource id. Relevant only for rules of the kind + * LogAlert. + */ + @JsonProperty(value = "resourceIdColumn") + private String resourceIdColumn; + + /* + * List of Dimensions conditions + */ + @JsonProperty(value = "dimensions") + private List dimensions; + + /* + * The criteria operator. Relevant and required only for rules of the kind + * LogAlert. + */ + @JsonProperty(value = "operator") + private ConditionOperator operator; + + /* + * the criteria threshold value that activates the alert. Relevant and + * required only for rules of the kind LogAlert. + */ + @JsonProperty(value = "threshold") + private Double threshold; + + /* + * The minimum number of violations required within the selected lookback + * time window required to raise an alert. Relevant only for rules of the + * kind LogAlert. + */ + @JsonProperty(value = "failingPeriods") + private ConditionFailingPeriods failingPeriods; + + /* + * The name of the metric to be sent. Relevant and required only for rules + * of the kind LogToMetric. + */ + @JsonProperty(value = "metricName") + private String metricName; + + /** + * Get the query property: Log query alert. + * + * @return the query value. + */ + public String query() { + return this.query; + } + + /** + * Set the query property: Log query alert. + * + * @param query the query value to set. + * @return the Condition object itself. + */ + public Condition withQuery(String query) { + this.query = query; + return this; + } + + /** + * Get the timeAggregation property: Aggregation type. Relevant and required only for rules of the kind LogAlert. + * + * @return the timeAggregation value. + */ + public TimeAggregation timeAggregation() { + return this.timeAggregation; + } + + /** + * Set the timeAggregation property: Aggregation type. Relevant and required only for rules of the kind LogAlert. + * + * @param timeAggregation the timeAggregation value to set. + * @return the Condition object itself. + */ + public Condition withTimeAggregation(TimeAggregation timeAggregation) { + this.timeAggregation = timeAggregation; + return this; + } + + /** + * Get the metricMeasureColumn property: The column containing the metric measure number. Relevant only for rules of + * the kind LogAlert. + * + * @return the metricMeasureColumn value. + */ + public String metricMeasureColumn() { + return this.metricMeasureColumn; + } + + /** + * Set the metricMeasureColumn property: The column containing the metric measure number. Relevant only for rules of + * the kind LogAlert. + * + * @param metricMeasureColumn the metricMeasureColumn value to set. + * @return the Condition object itself. + */ + public Condition withMetricMeasureColumn(String metricMeasureColumn) { + this.metricMeasureColumn = metricMeasureColumn; + return this; + } + + /** + * Get the resourceIdColumn property: The column containing the resource id. The content of the column must be a uri + * formatted as resource id. Relevant only for rules of the kind LogAlert. + * + * @return the resourceIdColumn value. + */ + public String resourceIdColumn() { + return this.resourceIdColumn; + } + + /** + * Set the resourceIdColumn property: The column containing the resource id. The content of the column must be a uri + * formatted as resource id. Relevant only for rules of the kind LogAlert. + * + * @param resourceIdColumn the resourceIdColumn value to set. + * @return the Condition object itself. + */ + public Condition withResourceIdColumn(String resourceIdColumn) { + this.resourceIdColumn = resourceIdColumn; + return this; + } + + /** + * Get the dimensions property: List of Dimensions conditions. + * + * @return the dimensions value. + */ + public List dimensions() { + return this.dimensions; + } + + /** + * Set the dimensions property: List of Dimensions conditions. + * + * @param dimensions the dimensions value to set. + * @return the Condition object itself. + */ + public Condition withDimensions(List dimensions) { + this.dimensions = dimensions; + return this; + } + + /** + * Get the operator property: The criteria operator. Relevant and required only for rules of the kind LogAlert. + * + * @return the operator value. + */ + public ConditionOperator operator() { + return this.operator; + } + + /** + * Set the operator property: The criteria operator. Relevant and required only for rules of the kind LogAlert. + * + * @param operator the operator value to set. + * @return the Condition object itself. + */ + public Condition withOperator(ConditionOperator operator) { + this.operator = operator; + return this; + } + + /** + * Get the threshold property: the criteria threshold value that activates the alert. Relevant and required only for + * rules of the kind LogAlert. + * + * @return the threshold value. + */ + public Double threshold() { + return this.threshold; + } + + /** + * Set the threshold property: the criteria threshold value that activates the alert. Relevant and required only for + * rules of the kind LogAlert. + * + * @param threshold the threshold value to set. + * @return the Condition object itself. + */ + public Condition withThreshold(Double threshold) { + this.threshold = threshold; + return this; + } + + /** + * Get the failingPeriods property: The minimum number of violations required within the selected lookback time + * window required to raise an alert. Relevant only for rules of the kind LogAlert. + * + * @return the failingPeriods value. + */ + public ConditionFailingPeriods failingPeriods() { + return this.failingPeriods; + } + + /** + * Set the failingPeriods property: The minimum number of violations required within the selected lookback time + * window required to raise an alert. Relevant only for rules of the kind LogAlert. + * + * @param failingPeriods the failingPeriods value to set. + * @return the Condition object itself. + */ + public Condition withFailingPeriods(ConditionFailingPeriods failingPeriods) { + this.failingPeriods = failingPeriods; + return this; + } + + /** + * Get the metricName property: The name of the metric to be sent. Relevant and required only for rules of the kind + * LogToMetric. + * + * @return the metricName value. + */ + public String metricName() { + return this.metricName; + } + + /** + * Set the metricName property: The name of the metric to be sent. Relevant and required only for rules of the kind + * LogToMetric. + * + * @param metricName the metricName value to set. + * @return the Condition object itself. + */ + public Condition withMetricName(String metricName) { + this.metricName = metricName; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (dimensions() != null) { + dimensions().forEach(e -> e.validate()); + } + if (failingPeriods() != null) { + failingPeriods().validate(); + } + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ConditionFailingPeriods.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ConditionFailingPeriods.java new file mode 100644 index 0000000000000..67b8b5457a275 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ConditionFailingPeriods.java @@ -0,0 +1,88 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.monitor.generated.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The minimum number of violations required within the selected lookback time window required to raise an alert. + * Relevant only for rules of the kind LogAlert. + */ +@Fluent +public final class ConditionFailingPeriods { + @JsonIgnore private final ClientLogger logger = new ClientLogger(ConditionFailingPeriods.class); + + /* + * The number of aggregated lookback points. The lookback time window is + * calculated based on the aggregation granularity (windowSize) and the + * selected number of aggregated points. Default value is 1 + */ + @JsonProperty(value = "numberOfEvaluationPeriods") + private Long numberOfEvaluationPeriods; + + /* + * The number of violations to trigger an alert. Should be smaller or equal + * to numberOfEvaluationPeriods. Default value is 1 + */ + @JsonProperty(value = "minFailingPeriodsToAlert") + private Long minFailingPeriodsToAlert; + + /** + * Get the numberOfEvaluationPeriods property: The number of aggregated lookback points. The lookback time window is + * calculated based on the aggregation granularity (windowSize) and the selected number of aggregated points. + * Default value is 1. + * + * @return the numberOfEvaluationPeriods value. + */ + public Long numberOfEvaluationPeriods() { + return this.numberOfEvaluationPeriods; + } + + /** + * Set the numberOfEvaluationPeriods property: The number of aggregated lookback points. The lookback time window is + * calculated based on the aggregation granularity (windowSize) and the selected number of aggregated points. + * Default value is 1. + * + * @param numberOfEvaluationPeriods the numberOfEvaluationPeriods value to set. + * @return the ConditionFailingPeriods object itself. + */ + public ConditionFailingPeriods withNumberOfEvaluationPeriods(Long numberOfEvaluationPeriods) { + this.numberOfEvaluationPeriods = numberOfEvaluationPeriods; + return this; + } + + /** + * Get the minFailingPeriodsToAlert property: The number of violations to trigger an alert. Should be smaller or + * equal to numberOfEvaluationPeriods. Default value is 1. + * + * @return the minFailingPeriodsToAlert value. + */ + public Long minFailingPeriodsToAlert() { + return this.minFailingPeriodsToAlert; + } + + /** + * Set the minFailingPeriodsToAlert property: The number of violations to trigger an alert. Should be smaller or + * equal to numberOfEvaluationPeriods. Default value is 1. + * + * @param minFailingPeriodsToAlert the minFailingPeriodsToAlert value to set. + * @return the ConditionFailingPeriods object itself. + */ + public ConditionFailingPeriods withMinFailingPeriodsToAlert(Long minFailingPeriodsToAlert) { + this.minFailingPeriodsToAlert = minFailingPeriodsToAlert; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ConditionOperator.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ConditionOperator.java new file mode 100644 index 0000000000000..0f3c90d5c3a6b --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ConditionOperator.java @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.monitor.generated.models; + +import com.azure.core.util.ExpandableStringEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import java.util.Collection; + +/** Defines values for ConditionOperator. */ +public final class ConditionOperator extends ExpandableStringEnum { + /** Static value Equals for ConditionOperator. */ + public static final ConditionOperator EQUALS = fromString("Equals"); + + /** Static value GreaterThan for ConditionOperator. */ + public static final ConditionOperator GREATER_THAN = fromString("GreaterThan"); + + /** Static value GreaterThanOrEqual for ConditionOperator. */ + public static final ConditionOperator GREATER_THAN_OR_EQUAL = fromString("GreaterThanOrEqual"); + + /** Static value LessThan for ConditionOperator. */ + public static final ConditionOperator LESS_THAN = fromString("LessThan"); + + /** Static value LessThanOrEqual for ConditionOperator. */ + public static final ConditionOperator LESS_THAN_OR_EQUAL = fromString("LessThanOrEqual"); + + /** + * Creates or finds a ConditionOperator from its string representation. + * + * @param name a name to look for. + * @return the corresponding ConditionOperator. + */ + @JsonCreator + public static ConditionOperator fromString(String name) { + return fromString(name, ConditionOperator.class); + } + + /** @return known ConditionOperator values. */ + public static Collection values() { + return values(ConditionOperator.class); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/Dimension.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/Dimension.java new file mode 100644 index 0000000000000..def497c7c4b89 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/Dimension.java @@ -0,0 +1,117 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.monitor.generated.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +/** Dimension splitting and filtering definition. */ +@Fluent +public final class Dimension { + @JsonIgnore private final ClientLogger logger = new ClientLogger(Dimension.class); + + /* + * Name of the dimension + */ + @JsonProperty(value = "name", required = true) + private String name; + + /* + * Operator for dimension values + */ + @JsonProperty(value = "operator", required = true) + private DimensionOperator operator; + + /* + * List of dimension values + */ + @JsonProperty(value = "values", required = true) + private List values; + + /** + * Get the name property: Name of the dimension. + * + * @return the name value. + */ + public String name() { + return this.name; + } + + /** + * Set the name property: Name of the dimension. + * + * @param name the name value to set. + * @return the Dimension object itself. + */ + public Dimension withName(String name) { + this.name = name; + return this; + } + + /** + * Get the operator property: Operator for dimension values. + * + * @return the operator value. + */ + public DimensionOperator operator() { + return this.operator; + } + + /** + * Set the operator property: Operator for dimension values. + * + * @param operator the operator value to set. + * @return the Dimension object itself. + */ + public Dimension withOperator(DimensionOperator operator) { + this.operator = operator; + return this; + } + + /** + * Get the values property: List of dimension values. + * + * @return the values value. + */ + public List values() { + return this.values; + } + + /** + * Set the values property: List of dimension values. + * + * @param values the values value to set. + * @return the Dimension object itself. + */ + public Dimension withValues(List values) { + this.values = values; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (name() == null) { + throw logger + .logExceptionAsError(new IllegalArgumentException("Missing required property name in model Dimension")); + } + if (operator() == null) { + throw logger + .logExceptionAsError( + new IllegalArgumentException("Missing required property operator in model Dimension")); + } + if (values() == null) { + throw logger + .logExceptionAsError( + new IllegalArgumentException("Missing required property values in model Dimension")); + } + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/DimensionOperator.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/DimensionOperator.java new file mode 100644 index 0000000000000..96fb853acb8c9 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/DimensionOperator.java @@ -0,0 +1,34 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.monitor.generated.models; + +import com.azure.core.util.ExpandableStringEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import java.util.Collection; + +/** Defines values for DimensionOperator. */ +public final class DimensionOperator extends ExpandableStringEnum { + /** Static value Include for DimensionOperator. */ + public static final DimensionOperator INCLUDE = fromString("Include"); + + /** Static value Exclude for DimensionOperator. */ + public static final DimensionOperator EXCLUDE = fromString("Exclude"); + + /** + * Creates or finds a DimensionOperator from its string representation. + * + * @param name a name to look for. + * @return the corresponding DimensionOperator. + */ + @JsonCreator + public static DimensionOperator fromString(String name) { + return fromString(name, DimensionOperator.class); + } + + /** @return known DimensionOperator values. */ + public static Collection values() { + return values(DimensionOperator.class); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/Kind.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/Kind.java new file mode 100644 index 0000000000000..a6549adac7ff2 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/Kind.java @@ -0,0 +1,34 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.monitor.generated.models; + +import com.azure.core.util.ExpandableStringEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import java.util.Collection; + +/** Defines values for Kind. */ +public final class Kind extends ExpandableStringEnum { + /** Static value LogAlert for Kind. */ + public static final Kind LOG_ALERT = fromString("LogAlert"); + + /** Static value LogToMetric for Kind. */ + public static final Kind LOG_TO_METRIC = fromString("LogToMetric"); + + /** + * Creates or finds a Kind from its string representation. + * + * @param name a name to look for. + * @return the corresponding Kind. + */ + @JsonCreator + public static Kind fromString(String name) { + return fromString(name, Kind.class); + } + + /** @return known Kind values. */ + public static Collection values() { + return values(Kind.class); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ScheduledQueryRuleCriteria.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ScheduledQueryRuleCriteria.java new file mode 100644 index 0000000000000..394c848973e52 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ScheduledQueryRuleCriteria.java @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.monitor.generated.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +/** The rule criteria that defines the conditions of the scheduled query rule. */ +@Fluent +public final class ScheduledQueryRuleCriteria { + @JsonIgnore private final ClientLogger logger = new ClientLogger(ScheduledQueryRuleCriteria.class); + + /* + * A list of conditions to evaluate against the specified scopes + */ + @JsonProperty(value = "allOf") + private List allOf; + + /** + * Get the allOf property: A list of conditions to evaluate against the specified scopes. + * + * @return the allOf value. + */ + public List allOf() { + return this.allOf; + } + + /** + * Set the allOf property: A list of conditions to evaluate against the specified scopes. + * + * @param allOf the allOf value to set. + * @return the ScheduledQueryRuleCriteria object itself. + */ + public ScheduledQueryRuleCriteria withAllOf(List allOf) { + this.allOf = allOf; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (allOf() != null) { + allOf().forEach(e -> e.validate()); + } + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ScheduledQueryRuleResource.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ScheduledQueryRuleResource.java new file mode 100644 index 0000000000000..40d8d0b853417 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ScheduledQueryRuleResource.java @@ -0,0 +1,761 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.monitor.generated.models; + +import com.azure.core.management.Region; +import com.azure.core.management.SystemData; +import com.azure.core.util.Context; +import com.azure.resourcemanager.monitor.generated.fluent.models.ScheduledQueryRuleResourceInner; +import java.time.Duration; +import java.util.List; +import java.util.Map; + +/** An immutable client-side representation of ScheduledQueryRuleResource. */ +public interface ScheduledQueryRuleResource { + /** + * 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 location property: The geo-location where the resource lives. + * + * @return the location value. + */ + String location(); + + /** + * Gets the tags property: Resource tags. + * + * @return the tags value. + */ + Map tags(); + + /** + * Gets the kind property: Indicates the type of scheduled query rule. The default is LogAlert. + * + * @return the kind value. + */ + Kind kind(); + + /** + * Gets the etag property: The etag field is *not* required. If it is provided in the response body, it must also be + * provided as a header per the normal etag convention. Entity tags are used for comparing two or more entities from + * the same requested resource. HTTP/1.1 uses entity tags in the etag (section 14.19), If-Match (section 14.24), + * If-None-Match (section 14.26), and If-Range (section 14.27) header fields. + * + * @return the etag value. + */ + String etag(); + + /** + * Gets the systemData property: SystemData of ScheduledQueryRule. + * + * @return the systemData value. + */ + SystemData systemData(); + + /** + * Gets the createdWithApiVersion property: The api-version used when creating this alert rule. + * + * @return the createdWithApiVersion value. + */ + String createdWithApiVersion(); + + /** + * Gets the isLegacyLogAnalyticsRule property: True if alert rule is legacy Log Analytic rule. + * + * @return the isLegacyLogAnalyticsRule value. + */ + Boolean isLegacyLogAnalyticsRule(); + + /** + * Gets the description property: The description of the scheduled query rule. + * + * @return the description value. + */ + String description(); + + /** + * Gets the displayName property: The display name of the alert rule. + * + * @return the displayName value. + */ + String displayName(); + + /** + * Gets the severity property: Severity of the alert. Should be an integer between [0-4]. Value of 0 is severest. + * Relevant and required only for rules of the kind LogAlert. + * + * @return the severity value. + */ + AlertSeverity severity(); + + /** + * Gets the enabled property: The flag which indicates whether this scheduled query rule is enabled. Value should be + * true or false. + * + * @return the enabled value. + */ + Boolean enabled(); + + /** + * Gets the scopes property: The list of resource id's that this scheduled query rule is scoped to. + * + * @return the scopes value. + */ + List scopes(); + + /** + * Gets the evaluationFrequency property: How often the scheduled query rule is evaluated represented in ISO 8601 + * duration format. Relevant and required only for rules of the kind LogAlert. + * + * @return the evaluationFrequency value. + */ + Duration evaluationFrequency(); + + /** + * Gets the windowSize property: The period of time (in ISO 8601 duration format) on which the Alert query will be + * executed (bin size). Relevant and required only for rules of the kind LogAlert. + * + * @return the windowSize value. + */ + Duration windowSize(); + + /** + * Gets the overrideQueryTimeRange property: If specified then overrides the query time range (default is + * WindowSize*NumberOfEvaluationPeriods). Relevant only for rules of the kind LogAlert. + * + * @return the overrideQueryTimeRange value. + */ + Duration overrideQueryTimeRange(); + + /** + * Gets the targetResourceTypes property: List of resource type of the target resource(s) on which the alert is + * created/updated. For example if the scope is a resource group and targetResourceTypes is + * Microsoft.Compute/virtualMachines, then a different alert will be fired for each virtual machine in the resource + * group which meet the alert criteria. Relevant only for rules of the kind LogAlert. + * + * @return the targetResourceTypes value. + */ + List targetResourceTypes(); + + /** + * Gets the criteria property: The rule criteria that defines the conditions of the scheduled query rule. + * + * @return the criteria value. + */ + ScheduledQueryRuleCriteria criteria(); + + /** + * Gets the muteActionsDuration property: Mute actions for the chosen period of time (in ISO 8601 duration format) + * after the alert is fired. Relevant only for rules of the kind LogAlert. + * + * @return the muteActionsDuration value. + */ + Duration muteActionsDuration(); + + /** + * Gets the actions property: Actions to invoke when the alert fires. + * + * @return the actions value. + */ + Actions actions(); + + /** + * Gets the isWorkspaceAlertsStorageConfigured property: The flag which indicates whether this scheduled query rule + * has been configured to be stored in the customer's storage. The default is false. + * + * @return the isWorkspaceAlertsStorageConfigured value. + */ + Boolean isWorkspaceAlertsStorageConfigured(); + + /** + * Gets the checkWorkspaceAlertsStorageConfigured property: The flag which indicates whether this scheduled query + * rule should be stored in the customer's storage. The default is false. Relevant only for rules of the kind + * LogAlert. + * + * @return the checkWorkspaceAlertsStorageConfigured value. + */ + Boolean checkWorkspaceAlertsStorageConfigured(); + + /** + * Gets the skipQueryValidation property: The flag which indicates whether the provided query should be validated or + * not. The default is false. Relevant only for rules of the kind LogAlert. + * + * @return the skipQueryValidation value. + */ + Boolean skipQueryValidation(); + + /** + * Gets the autoMitigate property: The flag that indicates whether the alert should be automatically resolved or + * not. The default is true. Relevant only for rules of the kind LogAlert. + * + * @return the autoMitigate value. + */ + Boolean autoMitigate(); + + /** + * Gets the region of the resource. + * + * @return the region of the resource. + */ + Region region(); + + /** + * Gets the name of the resource region. + * + * @return the name of the resource region. + */ + String regionName(); + + /** + * Gets the inner com.azure.resourcemanager.monitor.generated.fluent.models.ScheduledQueryRuleResourceInner object. + * + * @return the inner object. + */ + ScheduledQueryRuleResourceInner innerModel(); + + /** The entirety of the ScheduledQueryRuleResource definition. */ + interface Definition + extends DefinitionStages.Blank, + DefinitionStages.WithLocation, + DefinitionStages.WithResourceGroup, + DefinitionStages.WithCreate { + } + /** The ScheduledQueryRuleResource definition stages. */ + interface DefinitionStages { + /** The first stage of the ScheduledQueryRuleResource definition. */ + interface Blank extends WithLocation { + } + /** The stage of the ScheduledQueryRuleResource definition allowing to specify location. */ + interface WithLocation { + /** + * Specifies the region for the resource. + * + * @param location The geo-location where the resource lives. + * @return the next definition stage. + */ + WithResourceGroup withRegion(Region location); + + /** + * Specifies the region for the resource. + * + * @param location The geo-location where the resource lives. + * @return the next definition stage. + */ + WithResourceGroup withRegion(String location); + } + /** The stage of the ScheduledQueryRuleResource definition allowing to specify parent resource. */ + interface WithResourceGroup { + /** + * Specifies resourceGroupName. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @return the next definition stage. + */ + WithCreate withExistingResourceGroup(String resourceGroupName); + } + /** + * The stage of the ScheduledQueryRuleResource definition which contains all the minimum required properties for + * the resource to be created, but also allows for any other optional properties to be specified. + */ + interface WithCreate + extends DefinitionStages.WithTags, + DefinitionStages.WithKind, + DefinitionStages.WithDescription, + DefinitionStages.WithDisplayName, + DefinitionStages.WithSeverity, + DefinitionStages.WithEnabled, + DefinitionStages.WithScopes, + DefinitionStages.WithEvaluationFrequency, + DefinitionStages.WithWindowSize, + DefinitionStages.WithOverrideQueryTimeRange, + DefinitionStages.WithTargetResourceTypes, + DefinitionStages.WithCriteria, + DefinitionStages.WithMuteActionsDuration, + DefinitionStages.WithActions, + DefinitionStages.WithCheckWorkspaceAlertsStorageConfigured, + DefinitionStages.WithSkipQueryValidation, + DefinitionStages.WithAutoMitigate { + /** + * Executes the create request. + * + * @return the created resource. + */ + ScheduledQueryRuleResource create(); + + /** + * Executes the create request. + * + * @param context The context to associate with this operation. + * @return the created resource. + */ + ScheduledQueryRuleResource create(Context context); + } + /** The stage of the ScheduledQueryRuleResource definition allowing to specify tags. */ + interface WithTags { + /** + * Specifies the tags property: Resource tags.. + * + * @param tags Resource tags. + * @return the next definition stage. + */ + WithCreate withTags(Map tags); + } + /** The stage of the ScheduledQueryRuleResource definition allowing to specify kind. */ + interface WithKind { + /** + * Specifies the kind property: Indicates the type of scheduled query rule. The default is LogAlert.. + * + * @param kind Indicates the type of scheduled query rule. The default is LogAlert. + * @return the next definition stage. + */ + WithCreate withKind(Kind kind); + } + /** The stage of the ScheduledQueryRuleResource definition allowing to specify description. */ + interface WithDescription { + /** + * Specifies the description property: The description of the scheduled query rule.. + * + * @param description The description of the scheduled query rule. + * @return the next definition stage. + */ + WithCreate withDescription(String description); + } + /** The stage of the ScheduledQueryRuleResource definition allowing to specify displayName. */ + interface WithDisplayName { + /** + * Specifies the displayName property: The display name of the alert rule. + * + * @param displayName The display name of the alert rule. + * @return the next definition stage. + */ + WithCreate withDisplayName(String displayName); + } + /** The stage of the ScheduledQueryRuleResource definition allowing to specify severity. */ + interface WithSeverity { + /** + * Specifies the severity property: Severity of the alert. Should be an integer between [0-4]. Value of 0 is + * severest. Relevant and required only for rules of the kind LogAlert.. + * + * @param severity Severity of the alert. Should be an integer between [0-4]. Value of 0 is severest. + * Relevant and required only for rules of the kind LogAlert. + * @return the next definition stage. + */ + WithCreate withSeverity(AlertSeverity severity); + } + /** The stage of the ScheduledQueryRuleResource definition allowing to specify enabled. */ + interface WithEnabled { + /** + * Specifies the enabled property: The flag which indicates whether this scheduled query rule is enabled. + * Value should be true or false. + * + * @param enabled The flag which indicates whether this scheduled query rule is enabled. Value should be + * true or false. + * @return the next definition stage. + */ + WithCreate withEnabled(Boolean enabled); + } + /** The stage of the ScheduledQueryRuleResource definition allowing to specify scopes. */ + interface WithScopes { + /** + * Specifies the scopes property: The list of resource id's that this scheduled query rule is scoped to.. + * + * @param scopes The list of resource id's that this scheduled query rule is scoped to. + * @return the next definition stage. + */ + WithCreate withScopes(List scopes); + } + /** The stage of the ScheduledQueryRuleResource definition allowing to specify evaluationFrequency. */ + interface WithEvaluationFrequency { + /** + * Specifies the evaluationFrequency property: How often the scheduled query rule is evaluated represented + * in ISO 8601 duration format. Relevant and required only for rules of the kind LogAlert.. + * + * @param evaluationFrequency How often the scheduled query rule is evaluated represented in ISO 8601 + * duration format. Relevant and required only for rules of the kind LogAlert. + * @return the next definition stage. + */ + WithCreate withEvaluationFrequency(Duration evaluationFrequency); + } + /** The stage of the ScheduledQueryRuleResource definition allowing to specify windowSize. */ + interface WithWindowSize { + /** + * Specifies the windowSize property: The period of time (in ISO 8601 duration format) on which the Alert + * query will be executed (bin size). Relevant and required only for rules of the kind LogAlert.. + * + * @param windowSize The period of time (in ISO 8601 duration format) on which the Alert query will be + * executed (bin size). Relevant and required only for rules of the kind LogAlert. + * @return the next definition stage. + */ + WithCreate withWindowSize(Duration windowSize); + } + /** The stage of the ScheduledQueryRuleResource definition allowing to specify overrideQueryTimeRange. */ + interface WithOverrideQueryTimeRange { + /** + * Specifies the overrideQueryTimeRange property: If specified then overrides the query time range (default + * is WindowSize*NumberOfEvaluationPeriods). Relevant only for rules of the kind LogAlert.. + * + * @param overrideQueryTimeRange If specified then overrides the query time range (default is + * WindowSize*NumberOfEvaluationPeriods). Relevant only for rules of the kind LogAlert. + * @return the next definition stage. + */ + WithCreate withOverrideQueryTimeRange(Duration overrideQueryTimeRange); + } + /** The stage of the ScheduledQueryRuleResource definition allowing to specify targetResourceTypes. */ + interface WithTargetResourceTypes { + /** + * Specifies the targetResourceTypes property: List of resource type of the target resource(s) on which the + * alert is created/updated. For example if the scope is a resource group and targetResourceTypes is + * Microsoft.Compute/virtualMachines, then a different alert will be fired for each virtual machine in the + * resource group which meet the alert criteria. Relevant only for rules of the kind LogAlert. + * + * @param targetResourceTypes List of resource type of the target resource(s) on which the alert is + * created/updated. For example if the scope is a resource group and targetResourceTypes is + * Microsoft.Compute/virtualMachines, then a different alert will be fired for each virtual machine in + * the resource group which meet the alert criteria. Relevant only for rules of the kind LogAlert. + * @return the next definition stage. + */ + WithCreate withTargetResourceTypes(List targetResourceTypes); + } + /** The stage of the ScheduledQueryRuleResource definition allowing to specify criteria. */ + interface WithCriteria { + /** + * Specifies the criteria property: The rule criteria that defines the conditions of the scheduled query + * rule.. + * + * @param criteria The rule criteria that defines the conditions of the scheduled query rule. + * @return the next definition stage. + */ + WithCreate withCriteria(ScheduledQueryRuleCriteria criteria); + } + /** The stage of the ScheduledQueryRuleResource definition allowing to specify muteActionsDuration. */ + interface WithMuteActionsDuration { + /** + * Specifies the muteActionsDuration property: Mute actions for the chosen period of time (in ISO 8601 + * duration format) after the alert is fired. Relevant only for rules of the kind LogAlert.. + * + * @param muteActionsDuration Mute actions for the chosen period of time (in ISO 8601 duration format) after + * the alert is fired. Relevant only for rules of the kind LogAlert. + * @return the next definition stage. + */ + WithCreate withMuteActionsDuration(Duration muteActionsDuration); + } + /** The stage of the ScheduledQueryRuleResource definition allowing to specify actions. */ + interface WithActions { + /** + * Specifies the actions property: Actions to invoke when the alert fires.. + * + * @param actions Actions to invoke when the alert fires. + * @return the next definition stage. + */ + WithCreate withActions(Actions actions); + } + /** + * The stage of the ScheduledQueryRuleResource definition allowing to specify + * checkWorkspaceAlertsStorageConfigured. + */ + interface WithCheckWorkspaceAlertsStorageConfigured { + /** + * Specifies the checkWorkspaceAlertsStorageConfigured property: The flag which indicates whether this + * scheduled query rule should be stored in the customer's storage. The default is false. Relevant only for + * rules of the kind LogAlert.. + * + * @param checkWorkspaceAlertsStorageConfigured The flag which indicates whether this scheduled query rule + * should be stored in the customer's storage. The default is false. Relevant only for rules of the kind + * LogAlert. + * @return the next definition stage. + */ + WithCreate withCheckWorkspaceAlertsStorageConfigured(Boolean checkWorkspaceAlertsStorageConfigured); + } + /** The stage of the ScheduledQueryRuleResource definition allowing to specify skipQueryValidation. */ + interface WithSkipQueryValidation { + /** + * Specifies the skipQueryValidation property: The flag which indicates whether the provided query should be + * validated or not. The default is false. Relevant only for rules of the kind LogAlert.. + * + * @param skipQueryValidation The flag which indicates whether the provided query should be validated or + * not. The default is false. Relevant only for rules of the kind LogAlert. + * @return the next definition stage. + */ + WithCreate withSkipQueryValidation(Boolean skipQueryValidation); + } + /** The stage of the ScheduledQueryRuleResource definition allowing to specify autoMitigate. */ + interface WithAutoMitigate { + /** + * Specifies the autoMitigate property: The flag that indicates whether the alert should be automatically + * resolved or not. The default is true. Relevant only for rules of the kind LogAlert.. + * + * @param autoMitigate The flag that indicates whether the alert should be automatically resolved or not. + * The default is true. Relevant only for rules of the kind LogAlert. + * @return the next definition stage. + */ + WithCreate withAutoMitigate(Boolean autoMitigate); + } + } + /** + * Begins update for the ScheduledQueryRuleResource resource. + * + * @return the stage of resource update. + */ + ScheduledQueryRuleResource.Update update(); + + /** The template for ScheduledQueryRuleResource update. */ + interface Update + extends UpdateStages.WithTags, + UpdateStages.WithDescription, + UpdateStages.WithDisplayName, + UpdateStages.WithSeverity, + UpdateStages.WithEnabled, + UpdateStages.WithScopes, + UpdateStages.WithEvaluationFrequency, + UpdateStages.WithWindowSize, + UpdateStages.WithOverrideQueryTimeRange, + UpdateStages.WithTargetResourceTypes, + UpdateStages.WithCriteria, + UpdateStages.WithMuteActionsDuration, + UpdateStages.WithActions, + UpdateStages.WithCheckWorkspaceAlertsStorageConfigured, + UpdateStages.WithSkipQueryValidation, + UpdateStages.WithAutoMitigate { + /** + * Executes the update request. + * + * @return the updated resource. + */ + ScheduledQueryRuleResource apply(); + + /** + * Executes the update request. + * + * @param context The context to associate with this operation. + * @return the updated resource. + */ + ScheduledQueryRuleResource apply(Context context); + } + /** The ScheduledQueryRuleResource update stages. */ + interface UpdateStages { + /** The stage of the ScheduledQueryRuleResource update allowing to specify tags. */ + interface WithTags { + /** + * Specifies the tags property: Resource tags. + * + * @param tags Resource tags. + * @return the next definition stage. + */ + Update withTags(Map tags); + } + /** The stage of the ScheduledQueryRuleResource update allowing to specify description. */ + interface WithDescription { + /** + * Specifies the description property: The description of the scheduled query rule.. + * + * @param description The description of the scheduled query rule. + * @return the next definition stage. + */ + Update withDescription(String description); + } + /** The stage of the ScheduledQueryRuleResource update allowing to specify displayName. */ + interface WithDisplayName { + /** + * Specifies the displayName property: The display name of the alert rule. + * + * @param displayName The display name of the alert rule. + * @return the next definition stage. + */ + Update withDisplayName(String displayName); + } + /** The stage of the ScheduledQueryRuleResource update allowing to specify severity. */ + interface WithSeverity { + /** + * Specifies the severity property: Severity of the alert. Should be an integer between [0-4]. Value of 0 is + * severest. Relevant and required only for rules of the kind LogAlert.. + * + * @param severity Severity of the alert. Should be an integer between [0-4]. Value of 0 is severest. + * Relevant and required only for rules of the kind LogAlert. + * @return the next definition stage. + */ + Update withSeverity(AlertSeverity severity); + } + /** The stage of the ScheduledQueryRuleResource update allowing to specify enabled. */ + interface WithEnabled { + /** + * Specifies the enabled property: The flag which indicates whether this scheduled query rule is enabled. + * Value should be true or false. + * + * @param enabled The flag which indicates whether this scheduled query rule is enabled. Value should be + * true or false. + * @return the next definition stage. + */ + Update withEnabled(Boolean enabled); + } + /** The stage of the ScheduledQueryRuleResource update allowing to specify scopes. */ + interface WithScopes { + /** + * Specifies the scopes property: The list of resource id's that this scheduled query rule is scoped to.. + * + * @param scopes The list of resource id's that this scheduled query rule is scoped to. + * @return the next definition stage. + */ + Update withScopes(List scopes); + } + /** The stage of the ScheduledQueryRuleResource update allowing to specify evaluationFrequency. */ + interface WithEvaluationFrequency { + /** + * Specifies the evaluationFrequency property: How often the scheduled query rule is evaluated represented + * in ISO 8601 duration format. Relevant and required only for rules of the kind LogAlert.. + * + * @param evaluationFrequency How often the scheduled query rule is evaluated represented in ISO 8601 + * duration format. Relevant and required only for rules of the kind LogAlert. + * @return the next definition stage. + */ + Update withEvaluationFrequency(Duration evaluationFrequency); + } + /** The stage of the ScheduledQueryRuleResource update allowing to specify windowSize. */ + interface WithWindowSize { + /** + * Specifies the windowSize property: The period of time (in ISO 8601 duration format) on which the Alert + * query will be executed (bin size). Relevant and required only for rules of the kind LogAlert.. + * + * @param windowSize The period of time (in ISO 8601 duration format) on which the Alert query will be + * executed (bin size). Relevant and required only for rules of the kind LogAlert. + * @return the next definition stage. + */ + Update withWindowSize(Duration windowSize); + } + /** The stage of the ScheduledQueryRuleResource update allowing to specify overrideQueryTimeRange. */ + interface WithOverrideQueryTimeRange { + /** + * Specifies the overrideQueryTimeRange property: If specified then overrides the query time range (default + * is WindowSize*NumberOfEvaluationPeriods). Relevant only for rules of the kind LogAlert.. + * + * @param overrideQueryTimeRange If specified then overrides the query time range (default is + * WindowSize*NumberOfEvaluationPeriods). Relevant only for rules of the kind LogAlert. + * @return the next definition stage. + */ + Update withOverrideQueryTimeRange(Duration overrideQueryTimeRange); + } + /** The stage of the ScheduledQueryRuleResource update allowing to specify targetResourceTypes. */ + interface WithTargetResourceTypes { + /** + * Specifies the targetResourceTypes property: List of resource type of the target resource(s) on which the + * alert is created/updated. For example if the scope is a resource group and targetResourceTypes is + * Microsoft.Compute/virtualMachines, then a different alert will be fired for each virtual machine in the + * resource group which meet the alert criteria. Relevant only for rules of the kind LogAlert. + * + * @param targetResourceTypes List of resource type of the target resource(s) on which the alert is + * created/updated. For example if the scope is a resource group and targetResourceTypes is + * Microsoft.Compute/virtualMachines, then a different alert will be fired for each virtual machine in + * the resource group which meet the alert criteria. Relevant only for rules of the kind LogAlert. + * @return the next definition stage. + */ + Update withTargetResourceTypes(List targetResourceTypes); + } + /** The stage of the ScheduledQueryRuleResource update allowing to specify criteria. */ + interface WithCriteria { + /** + * Specifies the criteria property: The rule criteria that defines the conditions of the scheduled query + * rule.. + * + * @param criteria The rule criteria that defines the conditions of the scheduled query rule. + * @return the next definition stage. + */ + Update withCriteria(ScheduledQueryRuleCriteria criteria); + } + /** The stage of the ScheduledQueryRuleResource update allowing to specify muteActionsDuration. */ + interface WithMuteActionsDuration { + /** + * Specifies the muteActionsDuration property: Mute actions for the chosen period of time (in ISO 8601 + * duration format) after the alert is fired. Relevant only for rules of the kind LogAlert.. + * + * @param muteActionsDuration Mute actions for the chosen period of time (in ISO 8601 duration format) after + * the alert is fired. Relevant only for rules of the kind LogAlert. + * @return the next definition stage. + */ + Update withMuteActionsDuration(Duration muteActionsDuration); + } + /** The stage of the ScheduledQueryRuleResource update allowing to specify actions. */ + interface WithActions { + /** + * Specifies the actions property: Actions to invoke when the alert fires.. + * + * @param actions Actions to invoke when the alert fires. + * @return the next definition stage. + */ + Update withActions(Actions actions); + } + /** + * The stage of the ScheduledQueryRuleResource update allowing to specify checkWorkspaceAlertsStorageConfigured. + */ + interface WithCheckWorkspaceAlertsStorageConfigured { + /** + * Specifies the checkWorkspaceAlertsStorageConfigured property: The flag which indicates whether this + * scheduled query rule should be stored in the customer's storage. The default is false. Relevant only for + * rules of the kind LogAlert.. + * + * @param checkWorkspaceAlertsStorageConfigured The flag which indicates whether this scheduled query rule + * should be stored in the customer's storage. The default is false. Relevant only for rules of the kind + * LogAlert. + * @return the next definition stage. + */ + Update withCheckWorkspaceAlertsStorageConfigured(Boolean checkWorkspaceAlertsStorageConfigured); + } + /** The stage of the ScheduledQueryRuleResource update allowing to specify skipQueryValidation. */ + interface WithSkipQueryValidation { + /** + * Specifies the skipQueryValidation property: The flag which indicates whether the provided query should be + * validated or not. The default is false. Relevant only for rules of the kind LogAlert.. + * + * @param skipQueryValidation The flag which indicates whether the provided query should be validated or + * not. The default is false. Relevant only for rules of the kind LogAlert. + * @return the next definition stage. + */ + Update withSkipQueryValidation(Boolean skipQueryValidation); + } + /** The stage of the ScheduledQueryRuleResource update allowing to specify autoMitigate. */ + interface WithAutoMitigate { + /** + * Specifies the autoMitigate property: The flag that indicates whether the alert should be automatically + * resolved or not. The default is true. Relevant only for rules of the kind LogAlert.. + * + * @param autoMitigate The flag that indicates whether the alert should be automatically resolved or not. + * The default is true. Relevant only for rules of the kind LogAlert. + * @return the next definition stage. + */ + Update withAutoMitigate(Boolean autoMitigate); + } + } + /** + * Refreshes the resource to sync with Azure. + * + * @return the refreshed resource. + */ + ScheduledQueryRuleResource refresh(); + + /** + * Refreshes the resource to sync with Azure. + * + * @param context The context to associate with this operation. + * @return the refreshed resource. + */ + ScheduledQueryRuleResource refresh(Context context); +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ScheduledQueryRuleResourceCollection.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ScheduledQueryRuleResourceCollection.java new file mode 100644 index 0000000000000..8c0bb6af8a225 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ScheduledQueryRuleResourceCollection.java @@ -0,0 +1,70 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.monitor.generated.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.monitor.generated.fluent.models.ScheduledQueryRuleResourceInner; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +/** Represents a collection of scheduled query rule resources. */ +@Fluent +public final class ScheduledQueryRuleResourceCollection { + @JsonIgnore private final ClientLogger logger = new ClientLogger(ScheduledQueryRuleResourceCollection.class); + + /* + * The values for the scheduled query rule resources. + */ + @JsonProperty(value = "value") + private List value; + + /* + * Provides the link to retrieve the next set of elements. + */ + @JsonProperty(value = "nextLink", access = JsonProperty.Access.WRITE_ONLY) + private String nextLink; + + /** + * Get the value property: The values for the scheduled query rule resources. + * + * @return the value value. + */ + public List value() { + return this.value; + } + + /** + * Set the value property: The values for the scheduled query rule resources. + * + * @param value the value value to set. + * @return the ScheduledQueryRuleResourceCollection object itself. + */ + public ScheduledQueryRuleResourceCollection withValue(List value) { + this.value = value; + return this; + } + + /** + * Get the nextLink property: Provides the link to retrieve the next set of elements. + * + * @return the nextLink value. + */ + public String nextLink() { + return this.nextLink; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (value() != null) { + value().forEach(e -> e.validate()); + } + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ScheduledQueryRuleResourcePatch.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ScheduledQueryRuleResourcePatch.java new file mode 100644 index 0000000000000..5d18e64f7f779 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ScheduledQueryRuleResourcePatch.java @@ -0,0 +1,474 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.monitor.generated.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.monitor.generated.fluent.models.ScheduledQueryRuleProperties; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.time.Duration; +import java.util.List; +import java.util.Map; + +/** The scheduled query rule resource for patch operations. */ +@Fluent +public final class ScheduledQueryRuleResourcePatch { + @JsonIgnore private final ClientLogger logger = new ClientLogger(ScheduledQueryRuleResourcePatch.class); + + /* + * Resource tags + */ + @JsonProperty(value = "tags") + @JsonInclude(value = JsonInclude.Include.NON_NULL, content = JsonInclude.Include.ALWAYS) + private Map tags; + + /* + * The scheduled query rule properties of the resource. + */ + @JsonProperty(value = "properties") + private ScheduledQueryRuleProperties innerProperties; + + /** + * Get the tags property: Resource tags. + * + * @return the tags value. + */ + public Map tags() { + return this.tags; + } + + /** + * Set the tags property: Resource tags. + * + * @param tags the tags value to set. + * @return the ScheduledQueryRuleResourcePatch object itself. + */ + public ScheduledQueryRuleResourcePatch withTags(Map tags) { + this.tags = tags; + return this; + } + + /** + * Get the innerProperties property: The scheduled query rule properties of the resource. + * + * @return the innerProperties value. + */ + private ScheduledQueryRuleProperties innerProperties() { + return this.innerProperties; + } + + /** + * Get the createdWithApiVersion property: The api-version used when creating this alert rule. + * + * @return the createdWithApiVersion value. + */ + public String createdWithApiVersion() { + return this.innerProperties() == null ? null : this.innerProperties().createdWithApiVersion(); + } + + /** + * Get the isLegacyLogAnalyticsRule property: True if alert rule is legacy Log Analytic rule. + * + * @return the isLegacyLogAnalyticsRule value. + */ + public Boolean isLegacyLogAnalyticsRule() { + return this.innerProperties() == null ? null : this.innerProperties().isLegacyLogAnalyticsRule(); + } + + /** + * Get the description property: The description of the scheduled query rule. + * + * @return the description value. + */ + public String description() { + return this.innerProperties() == null ? null : this.innerProperties().description(); + } + + /** + * Set the description property: The description of the scheduled query rule. + * + * @param description the description value to set. + * @return the ScheduledQueryRuleResourcePatch object itself. + */ + public ScheduledQueryRuleResourcePatch withDescription(String description) { + if (this.innerProperties() == null) { + this.innerProperties = new ScheduledQueryRuleProperties(); + } + this.innerProperties().withDescription(description); + return this; + } + + /** + * Get the displayName property: The display name of the alert rule. + * + * @return the displayName value. + */ + public String displayName() { + return this.innerProperties() == null ? null : this.innerProperties().displayName(); + } + + /** + * Set the displayName property: The display name of the alert rule. + * + * @param displayName the displayName value to set. + * @return the ScheduledQueryRuleResourcePatch object itself. + */ + public ScheduledQueryRuleResourcePatch withDisplayName(String displayName) { + if (this.innerProperties() == null) { + this.innerProperties = new ScheduledQueryRuleProperties(); + } + this.innerProperties().withDisplayName(displayName); + return this; + } + + /** + * Get the severity property: Severity of the alert. Should be an integer between [0-4]. Value of 0 is severest. + * Relevant and required only for rules of the kind LogAlert. + * + * @return the severity value. + */ + public AlertSeverity severity() { + return this.innerProperties() == null ? null : this.innerProperties().severity(); + } + + /** + * Set the severity property: Severity of the alert. Should be an integer between [0-4]. Value of 0 is severest. + * Relevant and required only for rules of the kind LogAlert. + * + * @param severity the severity value to set. + * @return the ScheduledQueryRuleResourcePatch object itself. + */ + public ScheduledQueryRuleResourcePatch withSeverity(AlertSeverity severity) { + if (this.innerProperties() == null) { + this.innerProperties = new ScheduledQueryRuleProperties(); + } + this.innerProperties().withSeverity(severity); + return this; + } + + /** + * Get the enabled property: The flag which indicates whether this scheduled query rule is enabled. Value should be + * true or false. + * + * @return the enabled value. + */ + public Boolean enabled() { + return this.innerProperties() == null ? null : this.innerProperties().enabled(); + } + + /** + * Set the enabled property: The flag which indicates whether this scheduled query rule is enabled. Value should be + * true or false. + * + * @param enabled the enabled value to set. + * @return the ScheduledQueryRuleResourcePatch object itself. + */ + public ScheduledQueryRuleResourcePatch withEnabled(Boolean enabled) { + if (this.innerProperties() == null) { + this.innerProperties = new ScheduledQueryRuleProperties(); + } + this.innerProperties().withEnabled(enabled); + return this; + } + + /** + * Get the scopes property: The list of resource id's that this scheduled query rule is scoped to. + * + * @return the scopes value. + */ + public List scopes() { + return this.innerProperties() == null ? null : this.innerProperties().scopes(); + } + + /** + * Set the scopes property: The list of resource id's that this scheduled query rule is scoped to. + * + * @param scopes the scopes value to set. + * @return the ScheduledQueryRuleResourcePatch object itself. + */ + public ScheduledQueryRuleResourcePatch withScopes(List scopes) { + if (this.innerProperties() == null) { + this.innerProperties = new ScheduledQueryRuleProperties(); + } + this.innerProperties().withScopes(scopes); + return this; + } + + /** + * Get the evaluationFrequency property: How often the scheduled query rule is evaluated represented in ISO 8601 + * duration format. Relevant and required only for rules of the kind LogAlert. + * + * @return the evaluationFrequency value. + */ + public Duration evaluationFrequency() { + return this.innerProperties() == null ? null : this.innerProperties().evaluationFrequency(); + } + + /** + * Set the evaluationFrequency property: How often the scheduled query rule is evaluated represented in ISO 8601 + * duration format. Relevant and required only for rules of the kind LogAlert. + * + * @param evaluationFrequency the evaluationFrequency value to set. + * @return the ScheduledQueryRuleResourcePatch object itself. + */ + public ScheduledQueryRuleResourcePatch withEvaluationFrequency(Duration evaluationFrequency) { + if (this.innerProperties() == null) { + this.innerProperties = new ScheduledQueryRuleProperties(); + } + this.innerProperties().withEvaluationFrequency(evaluationFrequency); + return this; + } + + /** + * Get the windowSize property: The period of time (in ISO 8601 duration format) on which the Alert query will be + * executed (bin size). Relevant and required only for rules of the kind LogAlert. + * + * @return the windowSize value. + */ + public Duration windowSize() { + return this.innerProperties() == null ? null : this.innerProperties().windowSize(); + } + + /** + * Set the windowSize property: The period of time (in ISO 8601 duration format) on which the Alert query will be + * executed (bin size). Relevant and required only for rules of the kind LogAlert. + * + * @param windowSize the windowSize value to set. + * @return the ScheduledQueryRuleResourcePatch object itself. + */ + public ScheduledQueryRuleResourcePatch withWindowSize(Duration windowSize) { + if (this.innerProperties() == null) { + this.innerProperties = new ScheduledQueryRuleProperties(); + } + this.innerProperties().withWindowSize(windowSize); + return this; + } + + /** + * Get the overrideQueryTimeRange property: If specified then overrides the query time range (default is + * WindowSize*NumberOfEvaluationPeriods). Relevant only for rules of the kind LogAlert. + * + * @return the overrideQueryTimeRange value. + */ + public Duration overrideQueryTimeRange() { + return this.innerProperties() == null ? null : this.innerProperties().overrideQueryTimeRange(); + } + + /** + * Set the overrideQueryTimeRange property: If specified then overrides the query time range (default is + * WindowSize*NumberOfEvaluationPeriods). Relevant only for rules of the kind LogAlert. + * + * @param overrideQueryTimeRange the overrideQueryTimeRange value to set. + * @return the ScheduledQueryRuleResourcePatch object itself. + */ + public ScheduledQueryRuleResourcePatch withOverrideQueryTimeRange(Duration overrideQueryTimeRange) { + if (this.innerProperties() == null) { + this.innerProperties = new ScheduledQueryRuleProperties(); + } + this.innerProperties().withOverrideQueryTimeRange(overrideQueryTimeRange); + return this; + } + + /** + * Get the targetResourceTypes property: List of resource type of the target resource(s) on which the alert is + * created/updated. For example if the scope is a resource group and targetResourceTypes is + * Microsoft.Compute/virtualMachines, then a different alert will be fired for each virtual machine in the resource + * group which meet the alert criteria. Relevant only for rules of the kind LogAlert. + * + * @return the targetResourceTypes value. + */ + public List targetResourceTypes() { + return this.innerProperties() == null ? null : this.innerProperties().targetResourceTypes(); + } + + /** + * Set the targetResourceTypes property: List of resource type of the target resource(s) on which the alert is + * created/updated. For example if the scope is a resource group and targetResourceTypes is + * Microsoft.Compute/virtualMachines, then a different alert will be fired for each virtual machine in the resource + * group which meet the alert criteria. Relevant only for rules of the kind LogAlert. + * + * @param targetResourceTypes the targetResourceTypes value to set. + * @return the ScheduledQueryRuleResourcePatch object itself. + */ + public ScheduledQueryRuleResourcePatch withTargetResourceTypes(List targetResourceTypes) { + if (this.innerProperties() == null) { + this.innerProperties = new ScheduledQueryRuleProperties(); + } + this.innerProperties().withTargetResourceTypes(targetResourceTypes); + return this; + } + + /** + * Get the criteria property: The rule criteria that defines the conditions of the scheduled query rule. + * + * @return the criteria value. + */ + public ScheduledQueryRuleCriteria criteria() { + return this.innerProperties() == null ? null : this.innerProperties().criteria(); + } + + /** + * Set the criteria property: The rule criteria that defines the conditions of the scheduled query rule. + * + * @param criteria the criteria value to set. + * @return the ScheduledQueryRuleResourcePatch object itself. + */ + public ScheduledQueryRuleResourcePatch withCriteria(ScheduledQueryRuleCriteria criteria) { + if (this.innerProperties() == null) { + this.innerProperties = new ScheduledQueryRuleProperties(); + } + this.innerProperties().withCriteria(criteria); + return this; + } + + /** + * Get the muteActionsDuration property: Mute actions for the chosen period of time (in ISO 8601 duration format) + * after the alert is fired. Relevant only for rules of the kind LogAlert. + * + * @return the muteActionsDuration value. + */ + public Duration muteActionsDuration() { + return this.innerProperties() == null ? null : this.innerProperties().muteActionsDuration(); + } + + /** + * Set the muteActionsDuration property: Mute actions for the chosen period of time (in ISO 8601 duration format) + * after the alert is fired. Relevant only for rules of the kind LogAlert. + * + * @param muteActionsDuration the muteActionsDuration value to set. + * @return the ScheduledQueryRuleResourcePatch object itself. + */ + public ScheduledQueryRuleResourcePatch withMuteActionsDuration(Duration muteActionsDuration) { + if (this.innerProperties() == null) { + this.innerProperties = new ScheduledQueryRuleProperties(); + } + this.innerProperties().withMuteActionsDuration(muteActionsDuration); + return this; + } + + /** + * Get the actions property: Actions to invoke when the alert fires. + * + * @return the actions value. + */ + public Actions actions() { + return this.innerProperties() == null ? null : this.innerProperties().actions(); + } + + /** + * Set the actions property: Actions to invoke when the alert fires. + * + * @param actions the actions value to set. + * @return the ScheduledQueryRuleResourcePatch object itself. + */ + public ScheduledQueryRuleResourcePatch withActions(Actions actions) { + if (this.innerProperties() == null) { + this.innerProperties = new ScheduledQueryRuleProperties(); + } + this.innerProperties().withActions(actions); + return this; + } + + /** + * Get the isWorkspaceAlertsStorageConfigured property: The flag which indicates whether this scheduled query rule + * has been configured to be stored in the customer's storage. The default is false. + * + * @return the isWorkspaceAlertsStorageConfigured value. + */ + public Boolean isWorkspaceAlertsStorageConfigured() { + return this.innerProperties() == null ? null : this.innerProperties().isWorkspaceAlertsStorageConfigured(); + } + + /** + * Get the checkWorkspaceAlertsStorageConfigured property: The flag which indicates whether this scheduled query + * rule should be stored in the customer's storage. The default is false. Relevant only for rules of the kind + * LogAlert. + * + * @return the checkWorkspaceAlertsStorageConfigured value. + */ + public Boolean checkWorkspaceAlertsStorageConfigured() { + return this.innerProperties() == null ? null : this.innerProperties().checkWorkspaceAlertsStorageConfigured(); + } + + /** + * Set the checkWorkspaceAlertsStorageConfigured property: The flag which indicates whether this scheduled query + * rule should be stored in the customer's storage. The default is false. Relevant only for rules of the kind + * LogAlert. + * + * @param checkWorkspaceAlertsStorageConfigured the checkWorkspaceAlertsStorageConfigured value to set. + * @return the ScheduledQueryRuleResourcePatch object itself. + */ + public ScheduledQueryRuleResourcePatch withCheckWorkspaceAlertsStorageConfigured( + Boolean checkWorkspaceAlertsStorageConfigured) { + if (this.innerProperties() == null) { + this.innerProperties = new ScheduledQueryRuleProperties(); + } + this.innerProperties().withCheckWorkspaceAlertsStorageConfigured(checkWorkspaceAlertsStorageConfigured); + return this; + } + + /** + * Get the skipQueryValidation property: The flag which indicates whether the provided query should be validated or + * not. The default is false. Relevant only for rules of the kind LogAlert. + * + * @return the skipQueryValidation value. + */ + public Boolean skipQueryValidation() { + return this.innerProperties() == null ? null : this.innerProperties().skipQueryValidation(); + } + + /** + * Set the skipQueryValidation property: The flag which indicates whether the provided query should be validated or + * not. The default is false. Relevant only for rules of the kind LogAlert. + * + * @param skipQueryValidation the skipQueryValidation value to set. + * @return the ScheduledQueryRuleResourcePatch object itself. + */ + public ScheduledQueryRuleResourcePatch withSkipQueryValidation(Boolean skipQueryValidation) { + if (this.innerProperties() == null) { + this.innerProperties = new ScheduledQueryRuleProperties(); + } + this.innerProperties().withSkipQueryValidation(skipQueryValidation); + return this; + } + + /** + * Get the autoMitigate property: The flag that indicates whether the alert should be automatically resolved or not. + * The default is true. Relevant only for rules of the kind LogAlert. + * + * @return the autoMitigate value. + */ + public Boolean autoMitigate() { + return this.innerProperties() == null ? null : this.innerProperties().autoMitigate(); + } + + /** + * Set the autoMitigate property: The flag that indicates whether the alert should be automatically resolved or not. + * The default is true. Relevant only for rules of the kind LogAlert. + * + * @param autoMitigate the autoMitigate value to set. + * @return the ScheduledQueryRuleResourcePatch object itself. + */ + public ScheduledQueryRuleResourcePatch withAutoMitigate(Boolean autoMitigate) { + if (this.innerProperties() == null) { + this.innerProperties = new ScheduledQueryRuleProperties(); + } + this.innerProperties().withAutoMitigate(autoMitigate); + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (innerProperties() != null) { + innerProperties().validate(); + } + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ScheduledQueryRules.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ScheduledQueryRules.java new file mode 100644 index 0000000000000..81cca61917dae --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ScheduledQueryRules.java @@ -0,0 +1,158 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.monitor.generated.models; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.Response; +import com.azure.core.util.Context; + +/** Resource collection API of ScheduledQueryRules. */ +public interface ScheduledQueryRules { + /** + * Retrieve a scheduled query rule definitions in a subscription. + * + * @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 a collection of scheduled query rule resources. + */ + PagedIterable list(); + + /** + * Retrieve a scheduled query rule definitions in a subscription. + * + * @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 a collection of scheduled query rule resources. + */ + PagedIterable list(Context context); + + /** + * Retrieve scheduled query rule definitions in a resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @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 a collection of scheduled query rule resources. + */ + PagedIterable listByResourceGroup(String resourceGroupName); + + /** + * Retrieve scheduled query rule definitions in a resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @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 a collection of scheduled query rule resources. + */ + PagedIterable listByResourceGroup(String resourceGroupName, Context context); + + /** + * Retrieve an scheduled query rule definition. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param ruleName The name of the rule. + * @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 scheduled query rule resource. + */ + ScheduledQueryRuleResource getByResourceGroup(String resourceGroupName, String ruleName); + + /** + * Retrieve an scheduled query rule definition. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param ruleName The name of the rule. + * @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 scheduled query rule resource. + */ + Response getByResourceGroupWithResponse( + String resourceGroupName, String ruleName, Context context); + + /** + * Deletes a scheduled query rule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param ruleName The name of the rule. + * @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 resourceGroupName, String ruleName); + + /** + * Deletes a scheduled query rule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param ruleName The name of the rule. + * @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. + */ + Response deleteWithResponse(String resourceGroupName, String ruleName, Context context); + + /** + * Retrieve an scheduled query rule definition. + * + * @param id the resource ID. + * @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 scheduled query rule resource. + */ + ScheduledQueryRuleResource getById(String id); + + /** + * Retrieve an scheduled query rule definition. + * + * @param id the resource ID. + * @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 scheduled query rule resource. + */ + Response getByIdWithResponse(String id, Context context); + + /** + * Deletes a scheduled query rule. + * + * @param id the resource ID. + * @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 deleteById(String id); + + /** + * Deletes a scheduled query rule. + * + * @param id the resource ID. + * @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. + */ + Response deleteByIdWithResponse(String id, Context context); + + /** + * Begins definition for a new ScheduledQueryRuleResource resource. + * + * @param name resource name. + * @return the first stage of the new ScheduledQueryRuleResource definition. + */ + ScheduledQueryRuleResource.DefinitionStages.Blank define(String name); +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/TimeAggregation.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/TimeAggregation.java new file mode 100644 index 0000000000000..463aebce20a78 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/TimeAggregation.java @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.monitor.generated.models; + +import com.azure.core.util.ExpandableStringEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import java.util.Collection; + +/** Defines values for TimeAggregation. */ +public final class TimeAggregation extends ExpandableStringEnum { + /** Static value Count for TimeAggregation. */ + public static final TimeAggregation COUNT = fromString("Count"); + + /** Static value Average for TimeAggregation. */ + public static final TimeAggregation AVERAGE = fromString("Average"); + + /** Static value Minimum for TimeAggregation. */ + public static final TimeAggregation MINIMUM = fromString("Minimum"); + + /** Static value Maximum for TimeAggregation. */ + public static final TimeAggregation MAXIMUM = fromString("Maximum"); + + /** Static value Total for TimeAggregation. */ + public static final TimeAggregation TOTAL = fromString("Total"); + + /** + * Creates or finds a TimeAggregation from its string representation. + * + * @param name a name to look for. + * @return the corresponding TimeAggregation. + */ + @JsonCreator + public static TimeAggregation fromString(String name) { + return fromString(name, TimeAggregation.class); + } + + /** @return known TimeAggregation values. */ + public static Collection values() { + return values(TimeAggregation.class); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/package-info.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/package-info.java new file mode 100644 index 0000000000000..68a5871166842 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/package-info.java @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +/** Package containing the data models for MonitorClient. Monitor Management Client. */ +package com.azure.resourcemanager.monitor.generated.models; diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/package-info.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/package-info.java new file mode 100644 index 0000000000000..a2864a4af8b17 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/package-info.java @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +/** Package containing the classes for MonitorClient. Monitor Management Client. */ +package com.azure.resourcemanager.monitor.generated; diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/module-info.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/module-info.java new file mode 100644 index 0000000000000..881ba4bcd0ba6 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/module-info.java @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +module com.azure.resourcemanager.monitor.generated { + requires transitive com.azure.core.management; + + exports com.azure.resourcemanager.monitor.generated; + exports com.azure.resourcemanager.monitor.generated.fluent; + exports com.azure.resourcemanager.monitor.generated.fluent.models; + exports com.azure.resourcemanager.monitor.generated.models; + + opens com.azure.resourcemanager.monitor.generated.fluent.models to + com.azure.core, + com.fasterxml.jackson.databind; + opens com.azure.resourcemanager.monitor.generated.models to + com.azure.core, + com.fasterxml.jackson.databind; +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/samples/java/com/azure/resourcemanager/monitor/generated/generated/ScheduledQueryRulesCreateOrUpdateSamples.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/samples/java/com/azure/resourcemanager/monitor/generated/generated/ScheduledQueryRulesCreateOrUpdateSamples.java new file mode 100644 index 0000000000000..e819d3b4481bf --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/samples/java/com/azure/resourcemanager/monitor/generated/generated/ScheduledQueryRulesCreateOrUpdateSamples.java @@ -0,0 +1,213 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.monitor.generated.generated; + +import com.azure.resourcemanager.monitor.generated.models.Actions; +import com.azure.resourcemanager.monitor.generated.models.AlertSeverity; +import com.azure.resourcemanager.monitor.generated.models.Condition; +import com.azure.resourcemanager.monitor.generated.models.ConditionFailingPeriods; +import com.azure.resourcemanager.monitor.generated.models.ConditionOperator; +import com.azure.resourcemanager.monitor.generated.models.Dimension; +import com.azure.resourcemanager.monitor.generated.models.DimensionOperator; +import com.azure.resourcemanager.monitor.generated.models.ScheduledQueryRuleCriteria; +import com.azure.resourcemanager.monitor.generated.models.TimeAggregation; +import java.time.Duration; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; + +/** Samples for ScheduledQueryRules CreateOrUpdate. */ +public final class ScheduledQueryRulesCreateOrUpdateSamples { + /* + * x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2021-08-01/examples/createOrUpdateScheduledQueryRuleSubscription.json + */ + /** + * Sample code: Create or update a scheduled query rule on Subscription. + * + * @param manager Entry point to MonitorManager. + */ + public static void createOrUpdateAScheduledQueryRuleOnSubscription( + com.azure.resourcemanager.monitor.generated.MonitorManager manager) { + manager + .scheduledQueryRules() + .define("perf") + .withRegion("eastus") + .withExistingResourceGroup("QueryResourceGroupName") + .withDescription("Performance rule") + .withSeverity(AlertSeverity.FOUR) + .withEnabled(true) + .withScopes(Arrays.asList("/subscriptions/aaf177ed-1330-a9f2-80ea-fd3d7783b147")) + .withEvaluationFrequency(Duration.parse("PT5M")) + .withWindowSize(Duration.parse("PT10M")) + .withTargetResourceTypes(Arrays.asList("Microsoft.Compute/virtualMachines")) + .withCriteria( + new ScheduledQueryRuleCriteria() + .withAllOf( + Arrays + .asList( + new Condition() + .withQuery("Perf | where ObjectName == \"Processor\"") + .withTimeAggregation(TimeAggregation.AVERAGE) + .withMetricMeasureColumn("% Processor Time") + .withResourceIdColumn("resourceId") + .withDimensions( + Arrays + .asList( + new Dimension() + .withName("ComputerIp") + .withOperator(DimensionOperator.EXCLUDE) + .withValues(Arrays.asList("192.168.1.1")), + new Dimension() + .withName("OSType") + .withOperator(DimensionOperator.INCLUDE) + .withValues(Arrays.asList("*")))) + .withOperator(ConditionOperator.GREATER_THAN) + .withThreshold(70.0) + .withFailingPeriods( + new ConditionFailingPeriods() + .withNumberOfEvaluationPeriods(1L) + .withMinFailingPeriodsToAlert(1L))))) + .withMuteActionsDuration(Duration.parse("PT30M")) + .withActions( + new Actions() + .withActionGroups( + Arrays + .asList( + "/subscriptions/1cf177ed-1330-4692-80ea-fd3d7783b147/resourcegroups/sqrapi/providers/microsoft.insights/actiongroups/myactiongroup")) + .withCustomProperties(mapOf("key11", "value11", "key12", "value12"))) + .withCheckWorkspaceAlertsStorageConfigured(true) + .withSkipQueryValidation(true) + .withAutoMitigate(true) + .create(); + } + + /* + * x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2021-08-01/examples/createOrUpdateScheduledQueryRuleResourceGroup.json + */ + /** + * Sample code: Create or update a scheduled query rule on Resource group(s). + * + * @param manager Entry point to MonitorManager. + */ + public static void createOrUpdateAScheduledQueryRuleOnResourceGroupS( + com.azure.resourcemanager.monitor.generated.MonitorManager manager) { + manager + .scheduledQueryRules() + .define("heartbeat") + .withRegion("eastus") + .withExistingResourceGroup("QueryResourceGroupName") + .withDescription("Health check rule") + .withSeverity(AlertSeverity.FOUR) + .withEnabled(true) + .withScopes( + Arrays.asList("/subscriptions/aaf177ed-1330-a9f2-80ea-fd3d7783b147/resourceGroups/scopeResourceGroup1")) + .withEvaluationFrequency(Duration.parse("PT5M")) + .withWindowSize(Duration.parse("PT10M")) + .withTargetResourceTypes(Arrays.asList("Microsoft.Compute/virtualMachines")) + .withCriteria( + new ScheduledQueryRuleCriteria() + .withAllOf( + Arrays + .asList( + new Condition() + .withQuery("Heartbeat") + .withTimeAggregation(TimeAggregation.COUNT) + .withDimensions(Arrays.asList()) + .withOperator(ConditionOperator.GREATER_THAN) + .withThreshold(360.0) + .withFailingPeriods( + new ConditionFailingPeriods() + .withNumberOfEvaluationPeriods(1L) + .withMinFailingPeriodsToAlert(1L))))) + .withMuteActionsDuration(Duration.parse("PT30M")) + .withActions( + new Actions() + .withActionGroups( + Arrays + .asList( + "/subscriptions/1cf177ed-1330-4692-80ea-fd3d7783b147/resourcegroups/sqrapi/providers/microsoft.insights/actiongroups/myactiongroup")) + .withCustomProperties(mapOf("key11", "value11", "key12", "value12"))) + .withCheckWorkspaceAlertsStorageConfigured(true) + .withSkipQueryValidation(true) + .withAutoMitigate(true) + .create(); + } + + /* + * x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2021-08-01/examples/createOrUpdateScheduledQueryRule.json + */ + /** + * Sample code: Create or update a scheduled query rule for Single Resource. + * + * @param manager Entry point to MonitorManager. + */ + public static void createOrUpdateAScheduledQueryRuleForSingleResource( + com.azure.resourcemanager.monitor.generated.MonitorManager manager) { + manager + .scheduledQueryRules() + .define("perf") + .withRegion("eastus") + .withExistingResourceGroup("QueryResourceGroupName") + .withDescription("Performance rule") + .withSeverity(AlertSeverity.FOUR) + .withEnabled(true) + .withScopes( + Arrays + .asList( + "/subscriptions/aaf177ed-1330-a9f2-80ea-fd3d7783b147/resourceGroups/scopeResourceGroup1/providers/Microsoft.Compute/virtualMachines/vm1")) + .withEvaluationFrequency(Duration.parse("PT5M")) + .withWindowSize(Duration.parse("PT10M")) + .withCriteria( + new ScheduledQueryRuleCriteria() + .withAllOf( + Arrays + .asList( + new Condition() + .withQuery("Perf | where ObjectName == \"Processor\"") + .withTimeAggregation(TimeAggregation.AVERAGE) + .withMetricMeasureColumn("% Processor Time") + .withResourceIdColumn("resourceId") + .withDimensions( + Arrays + .asList( + new Dimension() + .withName("ComputerIp") + .withOperator(DimensionOperator.EXCLUDE) + .withValues(Arrays.asList("192.168.1.1")), + new Dimension() + .withName("OSType") + .withOperator(DimensionOperator.INCLUDE) + .withValues(Arrays.asList("*")))) + .withOperator(ConditionOperator.GREATER_THAN) + .withThreshold(70.0) + .withFailingPeriods( + new ConditionFailingPeriods() + .withNumberOfEvaluationPeriods(1L) + .withMinFailingPeriodsToAlert(1L))))) + .withMuteActionsDuration(Duration.parse("PT30M")) + .withActions( + new Actions() + .withActionGroups( + Arrays + .asList( + "/subscriptions/1cf177ed-1330-4692-80ea-fd3d7783b147/resourcegroups/sqrapi/providers/microsoft.insights/actiongroups/myactiongroup")) + .withCustomProperties(mapOf("key11", "value11", "key12", "value12"))) + .withCheckWorkspaceAlertsStorageConfigured(true) + .withSkipQueryValidation(true) + .withAutoMitigate(true) + .create(); + } + + @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-generated/src/samples/java/com/azure/resourcemanager/monitor/generated/generated/ScheduledQueryRulesDeleteSamples.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/samples/java/com/azure/resourcemanager/monitor/generated/generated/ScheduledQueryRulesDeleteSamples.java new file mode 100644 index 0000000000000..06c9ea5184dca --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/samples/java/com/azure/resourcemanager/monitor/generated/generated/ScheduledQueryRulesDeleteSamples.java @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.monitor.generated.generated; + +import com.azure.core.util.Context; + +/** Samples for ScheduledQueryRules Delete. */ +public final class ScheduledQueryRulesDeleteSamples { + /* + * x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2021-08-01/examples/deleteScheduledQueryRule.json + */ + /** + * Sample code: Delete a scheduled query rule. + * + * @param manager Entry point to MonitorManager. + */ + public static void deleteAScheduledQueryRule(com.azure.resourcemanager.monitor.generated.MonitorManager manager) { + manager.scheduledQueryRules().deleteWithResponse("QueryResourceGroupName", "heartbeat", Context.NONE); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/samples/java/com/azure/resourcemanager/monitor/generated/generated/ScheduledQueryRulesGetByResourceGroupSamples.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/samples/java/com/azure/resourcemanager/monitor/generated/generated/ScheduledQueryRulesGetByResourceGroupSamples.java new file mode 100644 index 0000000000000..40ed04431678c --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/samples/java/com/azure/resourcemanager/monitor/generated/generated/ScheduledQueryRulesGetByResourceGroupSamples.java @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.monitor.generated.generated; + +import com.azure.core.util.Context; + +/** Samples for ScheduledQueryRules GetByResourceGroup. */ +public final class ScheduledQueryRulesGetByResourceGroupSamples { + /* + * x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2021-08-01/examples/getScheduledQueryRule.json + */ + /** + * Sample code: Get a scheduled query rule for single resource. + * + * @param manager Entry point to MonitorManager. + */ + public static void getAScheduledQueryRuleForSingleResource( + com.azure.resourcemanager.monitor.generated.MonitorManager manager) { + manager.scheduledQueryRules().getByResourceGroupWithResponse("QueryResourceGroupName", "perf", Context.NONE); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/samples/java/com/azure/resourcemanager/monitor/generated/generated/ScheduledQueryRulesListByResourceGroupSamples.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/samples/java/com/azure/resourcemanager/monitor/generated/generated/ScheduledQueryRulesListByResourceGroupSamples.java new file mode 100644 index 0000000000000..de750c02fd837 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/samples/java/com/azure/resourcemanager/monitor/generated/generated/ScheduledQueryRulesListByResourceGroupSamples.java @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.monitor.generated.generated; + +import com.azure.core.util.Context; + +/** Samples for ScheduledQueryRules ListByResourceGroup. */ +public final class ScheduledQueryRulesListByResourceGroupSamples { + /* + * x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2021-08-01/examples/listScheduledQueryRulesByResourceGroup.json + */ + /** + * Sample code: List scheduled query rules by resource group. + * + * @param manager Entry point to MonitorManager. + */ + public static void listScheduledQueryRulesByResourceGroup( + com.azure.resourcemanager.monitor.generated.MonitorManager manager) { + manager.scheduledQueryRules().listByResourceGroup("QueryResourceGroupName", Context.NONE); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/samples/java/com/azure/resourcemanager/monitor/generated/generated/ScheduledQueryRulesListSamples.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/samples/java/com/azure/resourcemanager/monitor/generated/generated/ScheduledQueryRulesListSamples.java new file mode 100644 index 0000000000000..c5ed50ac12446 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/samples/java/com/azure/resourcemanager/monitor/generated/generated/ScheduledQueryRulesListSamples.java @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.monitor.generated.generated; + +import com.azure.core.util.Context; + +/** Samples for ScheduledQueryRules List. */ +public final class ScheduledQueryRulesListSamples { + /* + * x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2021-08-01/examples/listScheduledQueryRulesBySubscription.json + */ + /** + * Sample code: List scheduled query rules by subscription. + * + * @param manager Entry point to MonitorManager. + */ + public static void listScheduledQueryRulesBySubscription( + com.azure.resourcemanager.monitor.generated.MonitorManager manager) { + manager.scheduledQueryRules().list(Context.NONE); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/samples/java/com/azure/resourcemanager/monitor/generated/generated/ScheduledQueryRulesUpdateSamples.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/samples/java/com/azure/resourcemanager/monitor/generated/generated/ScheduledQueryRulesUpdateSamples.java new file mode 100644 index 0000000000000..f1685fa06af98 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/samples/java/com/azure/resourcemanager/monitor/generated/generated/ScheduledQueryRulesUpdateSamples.java @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.monitor.generated.generated; + +import com.azure.core.util.Context; +import com.azure.resourcemanager.monitor.generated.models.ScheduledQueryRuleResource; + +/** Samples for ScheduledQueryRules Update. */ +public final class ScheduledQueryRulesUpdateSamples { + /* + * x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2021-08-01/examples/patchScheduledQueryRule.json + */ + /** + * Sample code: Create or update a scheduled query rule. + * + * @param manager Entry point to MonitorManager. + */ + public static void createOrUpdateAScheduledQueryRule( + com.azure.resourcemanager.monitor.generated.MonitorManager manager) { + ScheduledQueryRuleResource resource = + manager + .scheduledQueryRules() + .getByResourceGroupWithResponse("QueryResourceGroupName", "heartbeat", Context.NONE) + .getValue(); + resource.update().withEnabled(false).apply(); + } +} diff --git a/sdk/monitor/ci.yml b/sdk/monitor/ci.yml index fef254d14fd65..d665c461dd509 100644 --- a/sdk/monitor/ci.yml +++ b/sdk/monitor/ci.yml @@ -44,3 +44,6 @@ extends: - name: azure-monitor-query groupId: com.azure safeName: azuremonitorquery + - name: azure-resourcemanager-monitor-generated + groupId: com.azure.resourcemanager + safeName: azureresourcemanagermonitorgenerated diff --git a/sdk/monitor/pom.xml b/sdk/monitor/pom.xml index 6c41f46298bb4..c3918da373c89 100644 --- a/sdk/monitor/pom.xml +++ b/sdk/monitor/pom.xml @@ -61,6 +61,7 @@ azure-monitor-opentelemetry-exporter azure-monitor-query azure-monitor-query-perf + azure-resourcemanager-monitor-generated