From b807f7e665c1143ef29811f0f4902dac14e945ba Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Fri, 26 Feb 2021 00:09:36 +0000 Subject: [PATCH] CodeGen from PR 12736 in Azure/azure-rest-api-specs Merge e6bcbb8805791b6cafb9810fafd0c791dec355e6 into 19234797aebaac189ab89ba27ffb56695e0fea35 --- eng/versioning/version_client.txt | 1 + .../CHANGELOG.md | 5 + .../README.md | 99 ++ .../pom.xml | 67 + .../monitor/generated/MonitorManager.java | 214 +++ .../fluent/ActivityLogAlertsClient.java | 187 +++ .../generated/fluent/MonitorClient.java | 53 + .../models/ActivityLogAlertResourceInner.java | 193 +++ .../generated/fluent/models/package-info.java | 6 + .../generated/fluent/package-info.java | 6 + .../ActivityLogAlertResourceImpl.java | 234 +++ .../ActivityLogAlertsClientImpl.java | 1287 +++++++++++++++++ .../implementation/ActivityLogAlertsImpl.java | 181 +++ .../implementation/MonitorClientBuilder.java | 146 ++ .../implementation/MonitorClientImpl.java | 293 ++++ .../generated/implementation/Utils.java | 196 +++ .../implementation/package-info.java | 6 + .../monitor/generated/models/ActionGroup.java | 85 ++ .../monitor/generated/models/ActionList.java | 54 + .../models/ActivityLogAlertResource.java | 305 ++++ .../generated/models/ActivityLogAlerts.java | 158 ++ .../models/AlertRuleAllOfCondition.java | 58 + .../models/AlertRuleAnyOfOrLeafCondition.java | 87 ++ .../models/AlertRuleLeafCondition.java | 123 ++ .../generated/models/AlertRuleList.java | 81 ++ .../models/AlertRulePatchObject.java | 83 ++ .../generated/models/AzureResource.java | 39 + .../generated/models/package-info.java | 6 + .../monitor/generated/package-info.java | 6 + .../src/main/java/module-info.java | 19 + sdk/monitor/ci.yml | 3 + sdk/monitor/pom.xml | 1 + 32 files changed, 4282 insertions(+) create mode 100644 sdk/monitor/azure-resourcemanager-monitor-generated/CHANGELOG.md create mode 100644 sdk/monitor/azure-resourcemanager-monitor-generated/README.md create mode 100644 sdk/monitor/azure-resourcemanager-monitor-generated/pom.xml create mode 100644 sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/MonitorManager.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/fluent/ActivityLogAlertsClient.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/fluent/MonitorClient.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/fluent/models/ActivityLogAlertResourceInner.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/fluent/models/package-info.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/fluent/package-info.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/implementation/ActivityLogAlertResourceImpl.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/implementation/ActivityLogAlertsClientImpl.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/implementation/ActivityLogAlertsImpl.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/implementation/MonitorClientBuilder.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/implementation/MonitorClientImpl.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/implementation/Utils.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/implementation/package-info.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ActionGroup.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ActionList.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ActivityLogAlertResource.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ActivityLogAlerts.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/AlertRuleAllOfCondition.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/AlertRuleAnyOfOrLeafCondition.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/AlertRuleLeafCondition.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/AlertRuleList.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/AlertRulePatchObject.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/AzureResource.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/package-info.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/package-info.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/module-info.java diff --git a/eng/versioning/version_client.txt b/eng/versioning/version_client.txt index a4f5ca22cbe74..57cb93fca18cc 100644 --- a/eng/versioning/version_client.txt +++ b/eng/versioning/version_client.txt @@ -206,6 +206,7 @@ com.azure.resourcemanager:azure-resourcemanager-digitaltwins;1.0.0-beta.1;1.0.0- com.azure.resourcemanager:azure-resourcemanager-netapp;1.0.0-beta.1;1.0.0-beta.2 com.azure.resourcemanager:azure-resourcemanager-storagecache;1.0.0-beta.1;1.0.0-beta.2 com.azure.resourcemanager:azure-resourcemanager-redisenterprise;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 # Unreleased dependencies: Copy the entry from above, prepend "unreleased_" and remove the current # version. Unreleased dependencies are only valid for dependency versions. 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..a19efe63c99c9 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/CHANGELOG.md @@ -0,0 +1,5 @@ +# Release History + +## 1.0.0-beta.1 (2021-02-26) + +- Azure Resource Manager Monitor client library for Java. This package contains Microsoft Azure SDK for Monitor Management SDK. Monitor Management Client. Package tag package-2020-10. 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..b309ebca320a0 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/README.md @@ -0,0 +1,99 @@ +# 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-2020-10. 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 + +## Troubleshooting + +## Next steps + +## Contributing + +For details on contributing to this repository, see the [contributing guide](https://github.com/Azure/azure-sdk-for-java/blob/master/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/master/sdk/identity/azure-identity +[azure_core_http_netty]: https://github.com/Azure/azure-sdk-for-java/blob/master/sdk/core/azure-core-http-netty +[authenticate]: https://github.com/Azure/azure-sdk-for-java/blob/master/sdk/resourcemanager/docs/AUTH.md +[design]: https://github.com/Azure/azure-sdk-for-java/blob/master/sdk/resourcemanager/docs/DESIGN.md 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..61af90c6ae50b --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/pom.xml @@ -0,0 +1,67 @@ + + 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. Monitor Management Client. Package tag package-2020-10. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt + https://github.com/Azure/azure-sdk-for-java + + + + The MIT License (MIT) + http://opensource.org/licenses/MIT + repo + + + + + https://github.com/Azure/azure-sdk-for-java + scm:git:git@github.com:Azure/azure-sdk-for-java.git + scm:git:git@github.com:Azure/azure-sdk-for-java.git + HEAD + + + + microsoft + Microsoft + + + + UTF-8 + + + + + com.azure + azure-core + 1.13.0 + + + com.azure + azure-core-management + 1.1.1 + + + + + + org.jacoco + jacoco-maven-plugin + 0.8.5 + + true + + + + + 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..93426dd44b75a --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/MonitorManager.java @@ -0,0 +1,214 @@ +// 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.policy.AddDatePolicy; +import com.azure.core.http.policy.BearerTokenAuthenticationPolicy; +import com.azure.core.http.policy.HttpLogOptions; +import com.azure.core.http.policy.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpPipelinePolicy; +import com.azure.core.http.policy.HttpPolicyProviders; +import com.azure.core.http.policy.RequestIdPolicy; +import com.azure.core.http.policy.RetryPolicy; +import com.azure.core.http.policy.UserAgentPolicy; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.util.Configuration; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.monitor.generated.fluent.MonitorClient; +import com.azure.resourcemanager.monitor.generated.implementation.ActivityLogAlertsImpl; +import com.azure.resourcemanager.monitor.generated.implementation.MonitorClientBuilder; +import com.azure.resourcemanager.monitor.generated.models.ActivityLogAlerts; +import java.time.Duration; +import java.time.temporal.ChronoUnit; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** Entry point to MonitorManager. Monitor Management Client. */ +public final class MonitorManager { + private ActivityLogAlerts activityLogAlerts; + + 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 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; + } + + /** + * 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 (retryPolicy == null) { + retryPolicy = new RetryPolicy("Retry-After", ChronoUnit.SECONDS); + } + List policies = new ArrayList<>(); + policies.add(new UserAgentPolicy(userAgentBuilder.toString())); + policies.add(new RequestIdPolicy()); + HttpPolicyProviders.addBeforeRetryPolicies(policies); + policies.add(retryPolicy); + policies.add(new AddDatePolicy()); + policies + .add( + new BearerTokenAuthenticationPolicy( + credential, profile.getEnvironment().getManagementEndpoint() + "/.default")); + 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 ActivityLogAlerts. */ + public ActivityLogAlerts activityLogAlerts() { + if (this.activityLogAlerts == null) { + this.activityLogAlerts = new ActivityLogAlertsImpl(clientObject.getActivityLogAlerts(), this); + } + return activityLogAlerts; + } + + /** + * @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/ActivityLogAlertsClient.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/fluent/ActivityLogAlertsClient.java new file mode 100644 index 0000000000000..cf228e11fe075 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/fluent/ActivityLogAlertsClient.java @@ -0,0 +1,187 @@ +// 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.ActivityLogAlertResourceInner; +import com.azure.resourcemanager.monitor.generated.models.AlertRulePatchObject; + +/** An instance of this class provides access to all the operations defined in ActivityLogAlertsClient. */ +public interface ActivityLogAlertsClient { + /** + * Create a new Activity Log Alert rule or update an existing one. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param activityLogAlertName The name of the Activity Log Alert rule. + * @param activityLogAlertRule The Activity Log Alert rule to create or use for the 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 an Activity Log Alert rule resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + ActivityLogAlertResourceInner createOrUpdate( + String resourceGroupName, String activityLogAlertName, ActivityLogAlertResourceInner activityLogAlertRule); + + /** + * Create a new Activity Log Alert rule or update an existing one. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param activityLogAlertName The name of the Activity Log Alert rule. + * @param activityLogAlertRule The Activity Log Alert rule to create or use for the 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 an Activity Log Alert rule resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response createOrUpdateWithResponse( + String resourceGroupName, + String activityLogAlertName, + ActivityLogAlertResourceInner activityLogAlertRule, + Context context); + + /** + * Get an Activity Log Alert rule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param activityLogAlertName The name of the Activity Log Alert 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 an Activity Log Alert rule. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + ActivityLogAlertResourceInner getByResourceGroup(String resourceGroupName, String activityLogAlertName); + + /** + * Get an Activity Log Alert rule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param activityLogAlertName The name of the Activity Log Alert 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 an Activity Log Alert rule. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response getByResourceGroupWithResponse( + String resourceGroupName, String activityLogAlertName, Context context); + + /** + * Delete an Activity Log Alert rule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param activityLogAlertName The name of the Activity Log Alert 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 activityLogAlertName); + + /** + * Delete an Activity Log Alert rule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param activityLogAlertName The name of the Activity Log Alert 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 activityLogAlertName, Context context); + + /** + * Updates 'tags' and 'enabled' fields in an existing Alert rule. This method is used to update the Alert rule tags, + * and to enable or disable the Alert rule. To update other fields use CreateOrUpdate operation. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param activityLogAlertName The name of the Activity Log Alert rule. + * @param activityLogAlertRulePatch Parameters supplied to the operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an Activity Log Alert rule resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + ActivityLogAlertResourceInner update( + String resourceGroupName, String activityLogAlertName, AlertRulePatchObject activityLogAlertRulePatch); + + /** + * Updates 'tags' and 'enabled' fields in an existing Alert rule. This method is used to update the Alert rule tags, + * and to enable or disable the Alert rule. To update other fields use CreateOrUpdate operation. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param activityLogAlertName The name of the Activity Log Alert rule. + * @param activityLogAlertRulePatch Parameters supplied to the operation. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an Activity Log Alert rule resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response updateWithResponse( + String resourceGroupName, + String activityLogAlertName, + AlertRulePatchObject activityLogAlertRulePatch, + Context context); + + /** + * Get a list of all Activity Log Alert rules 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 a list of all Activity Log Alert rules in a subscription. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(); + + /** + * Get a list of all Activity Log Alert rules 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 a list of all Activity Log Alert rules in a subscription. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(Context context); + + /** + * Get a list of all Activity Log Alert rules 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 a list of all Activity Log Alert rules in a resource group. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable listByResourceGroup(String resourceGroupName); + + /** + * Get a list of all Activity Log Alert rules 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 a list of all Activity Log Alert rules in a resource group. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable listByResourceGroup(String resourceGroupName, Context context); +} 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..95d67bade0b9c --- /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 ActivityLogAlertsClient object to access its operations. + * + * @return the ActivityLogAlertsClient object. + */ + ActivityLogAlertsClient getActivityLogAlerts(); +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/fluent/models/ActivityLogAlertResourceInner.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/fluent/models/ActivityLogAlertResourceInner.java new file mode 100644 index 0000000000000..81a21da9acfea --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/fluent/models/ActivityLogAlertResourceInner.java @@ -0,0 +1,193 @@ +// 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.annotation.JsonFlatten; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.monitor.generated.models.ActionList; +import com.azure.resourcemanager.monitor.generated.models.AlertRuleAllOfCondition; +import com.azure.resourcemanager.monitor.generated.models.AzureResource; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; +import java.util.Map; + +/** An Activity Log Alert rule resource. */ +@JsonFlatten +@Fluent +public class ActivityLogAlertResourceInner extends AzureResource { + @JsonIgnore private final ClientLogger logger = new ClientLogger(ActivityLogAlertResourceInner.class); + + /* + * A list of resource IDs that will be used as prefixes. The alert will + * only apply to Activity Log events with resource IDs that fall under one + * of these prefixes. This list must include at least one item. + */ + @JsonProperty(value = "properties.scopes") + private List scopes; + + /* + * The condition that will cause this alert to activate. + */ + @JsonProperty(value = "properties.condition") + private AlertRuleAllOfCondition condition; + + /* + * The actions that will activate when the condition is met. + */ + @JsonProperty(value = "properties.actions") + private ActionList actions; + + /* + * Indicates whether this Activity Log Alert rule is enabled. If an + * Activity Log Alert rule is not enabled, then none of its actions will be + * activated. + */ + @JsonProperty(value = "properties.enabled") + private Boolean enabled; + + /* + * A description of this Activity Log Alert rule. + */ + @JsonProperty(value = "properties.description") + private String description; + + /** + * Get the scopes property: A list of resource IDs that will be used as prefixes. The alert will only apply to + * Activity Log events with resource IDs that fall under one of these prefixes. This list must include at least one + * item. + * + * @return the scopes value. + */ + public List scopes() { + return this.scopes; + } + + /** + * Set the scopes property: A list of resource IDs that will be used as prefixes. The alert will only apply to + * Activity Log events with resource IDs that fall under one of these prefixes. This list must include at least one + * item. + * + * @param scopes the scopes value to set. + * @return the ActivityLogAlertResourceInner object itself. + */ + public ActivityLogAlertResourceInner withScopes(List scopes) { + this.scopes = scopes; + return this; + } + + /** + * Get the condition property: The condition that will cause this alert to activate. + * + * @return the condition value. + */ + public AlertRuleAllOfCondition condition() { + return this.condition; + } + + /** + * Set the condition property: The condition that will cause this alert to activate. + * + * @param condition the condition value to set. + * @return the ActivityLogAlertResourceInner object itself. + */ + public ActivityLogAlertResourceInner withCondition(AlertRuleAllOfCondition condition) { + this.condition = condition; + return this; + } + + /** + * Get the actions property: The actions that will activate when the condition is met. + * + * @return the actions value. + */ + public ActionList actions() { + return this.actions; + } + + /** + * Set the actions property: The actions that will activate when the condition is met. + * + * @param actions the actions value to set. + * @return the ActivityLogAlertResourceInner object itself. + */ + public ActivityLogAlertResourceInner withActions(ActionList actions) { + this.actions = actions; + return this; + } + + /** + * Get the enabled property: Indicates whether this Activity Log Alert rule is enabled. If an Activity Log Alert + * rule is not enabled, then none of its actions will be activated. + * + * @return the enabled value. + */ + public Boolean enabled() { + return this.enabled; + } + + /** + * Set the enabled property: Indicates whether this Activity Log Alert rule is enabled. If an Activity Log Alert + * rule is not enabled, then none of its actions will be activated. + * + * @param enabled the enabled value to set. + * @return the ActivityLogAlertResourceInner object itself. + */ + public ActivityLogAlertResourceInner withEnabled(Boolean enabled) { + this.enabled = enabled; + return this; + } + + /** + * Get the description property: A description of this Activity Log Alert rule. + * + * @return the description value. + */ + public String description() { + return this.description; + } + + /** + * Set the description property: A description of this Activity Log Alert rule. + * + * @param description the description value to set. + * @return the ActivityLogAlertResourceInner object itself. + */ + public ActivityLogAlertResourceInner withDescription(String description) { + this.description = description; + return this; + } + + /** {@inheritDoc} */ + @Override + public ActivityLogAlertResourceInner withLocation(String location) { + super.withLocation(location); + return this; + } + + /** {@inheritDoc} */ + @Override + public ActivityLogAlertResourceInner withTags(Map tags) { + super.withTags(tags); + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + @Override + public void validate() { + super.validate(); + if (condition() != null) { + condition().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/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/ActivityLogAlertResourceImpl.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/implementation/ActivityLogAlertResourceImpl.java new file mode 100644 index 0000000000000..f061618900a99 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/implementation/ActivityLogAlertResourceImpl.java @@ -0,0 +1,234 @@ +// 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.util.Context; +import com.azure.resourcemanager.monitor.generated.MonitorManager; +import com.azure.resourcemanager.monitor.generated.fluent.models.ActivityLogAlertResourceInner; +import com.azure.resourcemanager.monitor.generated.models.ActionList; +import com.azure.resourcemanager.monitor.generated.models.ActivityLogAlertResource; +import com.azure.resourcemanager.monitor.generated.models.AlertRuleAllOfCondition; +import com.azure.resourcemanager.monitor.generated.models.AlertRulePatchObject; +import java.util.Collections; +import java.util.List; +import java.util.Map; + +public final class ActivityLogAlertResourceImpl + implements ActivityLogAlertResource, ActivityLogAlertResource.Definition, ActivityLogAlertResource.Update { + private ActivityLogAlertResourceInner innerObject; + + private final 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 List scopes() { + List inner = this.innerModel().scopes(); + if (inner != null) { + return Collections.unmodifiableList(inner); + } else { + return Collections.emptyList(); + } + } + + public AlertRuleAllOfCondition condition() { + return this.innerModel().condition(); + } + + public ActionList actions() { + return this.innerModel().actions(); + } + + public Boolean enabled() { + return this.innerModel().enabled(); + } + + public String description() { + return this.innerModel().description(); + } + + public Region region() { + return Region.fromName(this.regionName()); + } + + public String regionName() { + return this.location(); + } + + public ActivityLogAlertResourceInner innerModel() { + return this.innerObject; + } + + private MonitorManager manager() { + return this.serviceManager; + } + + private String resourceGroupName; + + private String activityLogAlertName; + + private AlertRulePatchObject updateActivityLogAlertRulePatch; + + public ActivityLogAlertResourceImpl withExistingResourceGroup(String resourceGroupName) { + this.resourceGroupName = resourceGroupName; + return this; + } + + public ActivityLogAlertResource create() { + this.innerObject = + serviceManager + .serviceClient() + .getActivityLogAlerts() + .createOrUpdateWithResponse(resourceGroupName, activityLogAlertName, this.innerModel(), Context.NONE) + .getValue(); + return this; + } + + public ActivityLogAlertResource create(Context context) { + this.innerObject = + serviceManager + .serviceClient() + .getActivityLogAlerts() + .createOrUpdateWithResponse(resourceGroupName, activityLogAlertName, this.innerModel(), context) + .getValue(); + return this; + } + + ActivityLogAlertResourceImpl(String name, MonitorManager serviceManager) { + this.innerObject = new ActivityLogAlertResourceInner(); + this.serviceManager = serviceManager; + this.activityLogAlertName = name; + } + + public ActivityLogAlertResourceImpl update() { + this.updateActivityLogAlertRulePatch = new AlertRulePatchObject(); + return this; + } + + public ActivityLogAlertResource apply() { + this.innerObject = + serviceManager + .serviceClient() + .getActivityLogAlerts() + .updateWithResponse( + resourceGroupName, activityLogAlertName, updateActivityLogAlertRulePatch, Context.NONE) + .getValue(); + return this; + } + + public ActivityLogAlertResource apply(Context context) { + this.innerObject = + serviceManager + .serviceClient() + .getActivityLogAlerts() + .updateWithResponse(resourceGroupName, activityLogAlertName, updateActivityLogAlertRulePatch, context) + .getValue(); + return this; + } + + ActivityLogAlertResourceImpl(ActivityLogAlertResourceInner innerObject, MonitorManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + this.resourceGroupName = Utils.getValueFromIdByName(innerObject.id(), "resourceGroups"); + this.activityLogAlertName = Utils.getValueFromIdByName(innerObject.id(), "activityLogAlerts"); + } + + public ActivityLogAlertResource refresh() { + this.innerObject = + serviceManager + .serviceClient() + .getActivityLogAlerts() + .getByResourceGroupWithResponse(resourceGroupName, activityLogAlertName, Context.NONE) + .getValue(); + return this; + } + + public ActivityLogAlertResource refresh(Context context) { + this.innerObject = + serviceManager + .serviceClient() + .getActivityLogAlerts() + .getByResourceGroupWithResponse(resourceGroupName, activityLogAlertName, context) + .getValue(); + return this; + } + + public ActivityLogAlertResourceImpl withRegion(Region location) { + this.innerModel().withLocation(location.toString()); + return this; + } + + public ActivityLogAlertResourceImpl withRegion(String location) { + this.innerModel().withLocation(location); + return this; + } + + public ActivityLogAlertResourceImpl withTags(Map tags) { + if (isInCreateMode()) { + this.innerModel().withTags(tags); + return this; + } else { + this.updateActivityLogAlertRulePatch.withTags(tags); + return this; + } + } + + public ActivityLogAlertResourceImpl withScopes(List scopes) { + this.innerModel().withScopes(scopes); + return this; + } + + public ActivityLogAlertResourceImpl withCondition(AlertRuleAllOfCondition condition) { + this.innerModel().withCondition(condition); + return this; + } + + public ActivityLogAlertResourceImpl withActions(ActionList actions) { + this.innerModel().withActions(actions); + return this; + } + + public ActivityLogAlertResourceImpl withEnabled(Boolean enabled) { + if (isInCreateMode()) { + this.innerModel().withEnabled(enabled); + return this; + } else { + this.updateActivityLogAlertRulePatch.withEnabled(enabled); + return this; + } + } + + public ActivityLogAlertResourceImpl withDescription(String description) { + this.innerModel().withDescription(description); + 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/ActivityLogAlertsClientImpl.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/implementation/ActivityLogAlertsClientImpl.java new file mode 100644 index 0000000000000..048163997b39c --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/implementation/ActivityLogAlertsClientImpl.java @@ -0,0 +1,1287 @@ +// 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.ActivityLogAlertsClient; +import com.azure.resourcemanager.monitor.generated.fluent.models.ActivityLogAlertResourceInner; +import com.azure.resourcemanager.monitor.generated.models.AlertRuleList; +import com.azure.resourcemanager.monitor.generated.models.AlertRulePatchObject; +import reactor.core.publisher.Mono; + +/** An instance of this class provides access to all the operations defined in ActivityLogAlertsClient. */ +public final class ActivityLogAlertsClientImpl implements ActivityLogAlertsClient { + private final ClientLogger logger = new ClientLogger(ActivityLogAlertsClientImpl.class); + + /** The proxy service used to perform REST calls. */ + private final ActivityLogAlertsService service; + + /** The service client containing this operation class. */ + private final MonitorClientImpl client; + + /** + * Initializes an instance of ActivityLogAlertsClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + ActivityLogAlertsClientImpl(MonitorClientImpl client) { + this.service = + RestProxy.create(ActivityLogAlertsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for MonitorClientActivityLogAlerts to be used by the proxy service to + * perform REST calls. + */ + @Host("{$host}") + @ServiceInterface(name = "MonitorClientActivit") + private interface ActivityLogAlertsService { + @Headers({"Content-Type: application/json"}) + @Put( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights" + + "/activityLogAlerts/{activityLogAlertName}") + @ExpectedResponses({200, 201}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> createOrUpdate( + @HostParam("$host") String endpoint, + @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("activityLogAlertName") String activityLogAlertName, + @QueryParam("api-version") String apiVersion, + @BodyParam("application/json") ActivityLogAlertResourceInner activityLogAlertRule, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Content-Type: application/json"}) + @Get( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights" + + "/activityLogAlerts/{activityLogAlertName}") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> getByResourceGroup( + @HostParam("$host") String endpoint, + @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("activityLogAlertName") String activityLogAlertName, + @QueryParam("api-version") String apiVersion, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Content-Type: application/json"}) + @Delete( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights" + + "/activityLogAlerts/{activityLogAlertName}") + @ExpectedResponses({200, 204}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> delete( + @HostParam("$host") String endpoint, + @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("activityLogAlertName") String activityLogAlertName, + @QueryParam("api-version") String apiVersion, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Content-Type: application/json"}) + @Patch( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights" + + "/activityLogAlerts/{activityLogAlertName}") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> update( + @HostParam("$host") String endpoint, + @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("activityLogAlertName") String activityLogAlertName, + @QueryParam("api-version") String apiVersion, + @BodyParam("application/json") AlertRulePatchObject activityLogAlertRulePatch, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Content-Type: application/json"}) + @Get("/subscriptions/{subscriptionId}/providers/Microsoft.Insights/activityLogAlerts") + @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" + + "/activityLogAlerts") + @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("{nextLink}") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listBySubscriptionIdNext( + @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); + } + + /** + * Create a new Activity Log Alert rule or update an existing one. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param activityLogAlertName The name of the Activity Log Alert rule. + * @param activityLogAlertRule The Activity Log Alert rule to create or use for the 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 an Activity Log Alert rule resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> createOrUpdateWithResponseAsync( + String resourceGroupName, String activityLogAlertName, ActivityLogAlertResourceInner activityLogAlertRule) { + 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 (activityLogAlertName == null) { + return Mono + .error(new IllegalArgumentException("Parameter activityLogAlertName is required and cannot be null.")); + } + if (activityLogAlertRule == null) { + return Mono + .error(new IllegalArgumentException("Parameter activityLogAlertRule is required and cannot be null.")); + } else { + activityLogAlertRule.validate(); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> + service + .createOrUpdate( + this.client.getEndpoint(), + this.client.getSubscriptionId(), + resourceGroupName, + activityLogAlertName, + this.client.getApiVersion(), + activityLogAlertRule, + accept, + context)) + .subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()))); + } + + /** + * Create a new Activity Log Alert rule or update an existing one. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param activityLogAlertName The name of the Activity Log Alert rule. + * @param activityLogAlertRule The Activity Log Alert rule to create or use for the 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 an Activity Log Alert rule resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> createOrUpdateWithResponseAsync( + String resourceGroupName, + String activityLogAlertName, + ActivityLogAlertResourceInner activityLogAlertRule, + 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 (activityLogAlertName == null) { + return Mono + .error(new IllegalArgumentException("Parameter activityLogAlertName is required and cannot be null.")); + } + if (activityLogAlertRule == null) { + return Mono + .error(new IllegalArgumentException("Parameter activityLogAlertRule is required and cannot be null.")); + } else { + activityLogAlertRule.validate(); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .createOrUpdate( + this.client.getEndpoint(), + this.client.getSubscriptionId(), + resourceGroupName, + activityLogAlertName, + this.client.getApiVersion(), + activityLogAlertRule, + accept, + context); + } + + /** + * Create a new Activity Log Alert rule or update an existing one. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param activityLogAlertName The name of the Activity Log Alert rule. + * @param activityLogAlertRule The Activity Log Alert rule to create or use for the 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 an Activity Log Alert rule resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono createOrUpdateAsync( + String resourceGroupName, String activityLogAlertName, ActivityLogAlertResourceInner activityLogAlertRule) { + return createOrUpdateWithResponseAsync(resourceGroupName, activityLogAlertName, activityLogAlertRule) + .flatMap( + (Response res) -> { + if (res.getValue() != null) { + return Mono.just(res.getValue()); + } else { + return Mono.empty(); + } + }); + } + + /** + * Create a new Activity Log Alert rule or update an existing one. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param activityLogAlertName The name of the Activity Log Alert rule. + * @param activityLogAlertRule The Activity Log Alert rule to create or use for the 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 an Activity Log Alert rule resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ActivityLogAlertResourceInner createOrUpdate( + String resourceGroupName, String activityLogAlertName, ActivityLogAlertResourceInner activityLogAlertRule) { + return createOrUpdateAsync(resourceGroupName, activityLogAlertName, activityLogAlertRule).block(); + } + + /** + * Create a new Activity Log Alert rule or update an existing one. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param activityLogAlertName The name of the Activity Log Alert rule. + * @param activityLogAlertRule The Activity Log Alert rule to create or use for the 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 an Activity Log Alert rule resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response createOrUpdateWithResponse( + String resourceGroupName, + String activityLogAlertName, + ActivityLogAlertResourceInner activityLogAlertRule, + Context context) { + return createOrUpdateWithResponseAsync(resourceGroupName, activityLogAlertName, activityLogAlertRule, context) + .block(); + } + + /** + * Get an Activity Log Alert rule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param activityLogAlertName The name of the Activity Log Alert 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 an Activity Log Alert rule. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getByResourceGroupWithResponseAsync( + String resourceGroupName, String activityLogAlertName) { + 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 (activityLogAlertName == null) { + return Mono + .error(new IllegalArgumentException("Parameter activityLogAlertName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> + service + .getByResourceGroup( + this.client.getEndpoint(), + this.client.getSubscriptionId(), + resourceGroupName, + activityLogAlertName, + this.client.getApiVersion(), + accept, + context)) + .subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()))); + } + + /** + * Get an Activity Log Alert rule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param activityLogAlertName The name of the Activity Log Alert 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 an Activity Log Alert rule. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getByResourceGroupWithResponseAsync( + String resourceGroupName, String activityLogAlertName, 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 (activityLogAlertName == null) { + return Mono + .error(new IllegalArgumentException("Parameter activityLogAlertName 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, + activityLogAlertName, + this.client.getApiVersion(), + accept, + context); + } + + /** + * Get an Activity Log Alert rule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param activityLogAlertName The name of the Activity Log Alert 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 an Activity Log Alert rule. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono getByResourceGroupAsync( + String resourceGroupName, String activityLogAlertName) { + return getByResourceGroupWithResponseAsync(resourceGroupName, activityLogAlertName) + .flatMap( + (Response res) -> { + if (res.getValue() != null) { + return Mono.just(res.getValue()); + } else { + return Mono.empty(); + } + }); + } + + /** + * Get an Activity Log Alert rule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param activityLogAlertName The name of the Activity Log Alert 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 an Activity Log Alert rule. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ActivityLogAlertResourceInner getByResourceGroup(String resourceGroupName, String activityLogAlertName) { + return getByResourceGroupAsync(resourceGroupName, activityLogAlertName).block(); + } + + /** + * Get an Activity Log Alert rule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param activityLogAlertName The name of the Activity Log Alert 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 an Activity Log Alert rule. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getByResourceGroupWithResponse( + String resourceGroupName, String activityLogAlertName, Context context) { + return getByResourceGroupWithResponseAsync(resourceGroupName, activityLogAlertName, context).block(); + } + + /** + * Delete an Activity Log Alert rule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param activityLogAlertName The name of the Activity Log Alert 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 activityLogAlertName) { + 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 (activityLogAlertName == null) { + return Mono + .error(new IllegalArgumentException("Parameter activityLogAlertName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> + service + .delete( + this.client.getEndpoint(), + this.client.getSubscriptionId(), + resourceGroupName, + activityLogAlertName, + this.client.getApiVersion(), + accept, + context)) + .subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()))); + } + + /** + * Delete an Activity Log Alert rule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param activityLogAlertName The name of the Activity Log Alert 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 activityLogAlertName, 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 (activityLogAlertName == null) { + return Mono + .error(new IllegalArgumentException("Parameter activityLogAlertName 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, + activityLogAlertName, + this.client.getApiVersion(), + accept, + context); + } + + /** + * Delete an Activity Log Alert rule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param activityLogAlertName The name of the Activity Log Alert 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 activityLogAlertName) { + return deleteWithResponseAsync(resourceGroupName, activityLogAlertName) + .flatMap((Response res) -> Mono.empty()); + } + + /** + * Delete an Activity Log Alert rule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param activityLogAlertName The name of the Activity Log Alert 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 activityLogAlertName) { + deleteAsync(resourceGroupName, activityLogAlertName).block(); + } + + /** + * Delete an Activity Log Alert rule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param activityLogAlertName The name of the Activity Log Alert 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 activityLogAlertName, Context context) { + return deleteWithResponseAsync(resourceGroupName, activityLogAlertName, context).block(); + } + + /** + * Updates 'tags' and 'enabled' fields in an existing Alert rule. This method is used to update the Alert rule tags, + * and to enable or disable the Alert rule. To update other fields use CreateOrUpdate operation. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param activityLogAlertName The name of the Activity Log Alert rule. + * @param activityLogAlertRulePatch Parameters supplied to the operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an Activity Log Alert rule resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> updateWithResponseAsync( + String resourceGroupName, String activityLogAlertName, AlertRulePatchObject activityLogAlertRulePatch) { + 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 (activityLogAlertName == null) { + return Mono + .error(new IllegalArgumentException("Parameter activityLogAlertName is required and cannot be null.")); + } + if (activityLogAlertRulePatch == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter activityLogAlertRulePatch is required and cannot be null.")); + } else { + activityLogAlertRulePatch.validate(); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> + service + .update( + this.client.getEndpoint(), + this.client.getSubscriptionId(), + resourceGroupName, + activityLogAlertName, + this.client.getApiVersion(), + activityLogAlertRulePatch, + accept, + context)) + .subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()))); + } + + /** + * Updates 'tags' and 'enabled' fields in an existing Alert rule. This method is used to update the Alert rule tags, + * and to enable or disable the Alert rule. To update other fields use CreateOrUpdate operation. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param activityLogAlertName The name of the Activity Log Alert rule. + * @param activityLogAlertRulePatch Parameters supplied to the operation. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an Activity Log Alert rule resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> updateWithResponseAsync( + String resourceGroupName, + String activityLogAlertName, + AlertRulePatchObject activityLogAlertRulePatch, + 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 (activityLogAlertName == null) { + return Mono + .error(new IllegalArgumentException("Parameter activityLogAlertName is required and cannot be null.")); + } + if (activityLogAlertRulePatch == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter activityLogAlertRulePatch is required and cannot be null.")); + } else { + activityLogAlertRulePatch.validate(); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .update( + this.client.getEndpoint(), + this.client.getSubscriptionId(), + resourceGroupName, + activityLogAlertName, + this.client.getApiVersion(), + activityLogAlertRulePatch, + accept, + context); + } + + /** + * Updates 'tags' and 'enabled' fields in an existing Alert rule. This method is used to update the Alert rule tags, + * and to enable or disable the Alert rule. To update other fields use CreateOrUpdate operation. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param activityLogAlertName The name of the Activity Log Alert rule. + * @param activityLogAlertRulePatch Parameters supplied to the operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an Activity Log Alert rule resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono updateAsync( + String resourceGroupName, String activityLogAlertName, AlertRulePatchObject activityLogAlertRulePatch) { + return updateWithResponseAsync(resourceGroupName, activityLogAlertName, activityLogAlertRulePatch) + .flatMap( + (Response res) -> { + if (res.getValue() != null) { + return Mono.just(res.getValue()); + } else { + return Mono.empty(); + } + }); + } + + /** + * Updates 'tags' and 'enabled' fields in an existing Alert rule. This method is used to update the Alert rule tags, + * and to enable or disable the Alert rule. To update other fields use CreateOrUpdate operation. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param activityLogAlertName The name of the Activity Log Alert rule. + * @param activityLogAlertRulePatch Parameters supplied to the operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an Activity Log Alert rule resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ActivityLogAlertResourceInner update( + String resourceGroupName, String activityLogAlertName, AlertRulePatchObject activityLogAlertRulePatch) { + return updateAsync(resourceGroupName, activityLogAlertName, activityLogAlertRulePatch).block(); + } + + /** + * Updates 'tags' and 'enabled' fields in an existing Alert rule. This method is used to update the Alert rule tags, + * and to enable or disable the Alert rule. To update other fields use CreateOrUpdate operation. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param activityLogAlertName The name of the Activity Log Alert rule. + * @param activityLogAlertRulePatch Parameters supplied to the operation. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an Activity Log Alert rule resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response updateWithResponse( + String resourceGroupName, + String activityLogAlertName, + AlertRulePatchObject activityLogAlertRulePatch, + Context context) { + return updateWithResponseAsync(resourceGroupName, activityLogAlertName, activityLogAlertRulePatch, context) + .block(); + } + + /** + * Get a list of all Activity Log Alert rules 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 a list of all Activity Log Alert rules in a subscription. + */ + @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)) + .subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()))); + } + + /** + * Get a list of all Activity Log Alert rules 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 a list of all Activity Log Alert rules in a subscription. + */ + @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)); + } + + /** + * Get a list of all Activity Log Alert rules 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 a list of all Activity Log Alert rules in a subscription. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync() { + return new PagedFlux<>( + () -> listSinglePageAsync(), nextLink -> listBySubscriptionIdNextSinglePageAsync(nextLink)); + } + + /** + * Get a list of all Activity Log Alert rules 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 a list of all Activity Log Alert rules in a subscription. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync(Context context) { + return new PagedFlux<>( + () -> listSinglePageAsync(context), nextLink -> listBySubscriptionIdNextSinglePageAsync(nextLink, context)); + } + + /** + * Get a list of all Activity Log Alert rules 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 a list of all Activity Log Alert rules in a subscription. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list() { + return new PagedIterable<>(listAsync()); + } + + /** + * Get a list of all Activity Log Alert rules 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 a list of all Activity Log Alert rules in a subscription. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(Context context) { + return new PagedIterable<>(listAsync(context)); + } + + /** + * Get a list of all Activity Log Alert rules 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 a list of all Activity Log Alert rules in a resource group. + */ + @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)) + .subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()))); + } + + /** + * Get a list of all Activity Log Alert rules 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 a list of all Activity Log Alert rules in a resource group. + */ + @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)); + } + + /** + * Get a list of all Activity Log Alert rules 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 a list of all Activity Log Alert rules in a resource group. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listByResourceGroupAsync(String resourceGroupName) { + return new PagedFlux<>( + () -> listByResourceGroupSinglePageAsync(resourceGroupName), + nextLink -> listByResourceGroupNextSinglePageAsync(nextLink)); + } + + /** + * Get a list of all Activity Log Alert rules 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 a list of all Activity Log Alert rules in a resource group. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listByResourceGroupAsync( + String resourceGroupName, Context context) { + return new PagedFlux<>( + () -> listByResourceGroupSinglePageAsync(resourceGroupName, context), + nextLink -> listByResourceGroupNextSinglePageAsync(nextLink, context)); + } + + /** + * Get a list of all Activity Log Alert rules 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 a list of all Activity Log Alert rules in a resource group. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listByResourceGroup(String resourceGroupName) { + return new PagedIterable<>(listByResourceGroupAsync(resourceGroupName)); + } + + /** + * Get a list of all Activity Log Alert rules 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 a list of all Activity Log Alert rules in a resource group. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listByResourceGroup(String resourceGroupName, Context context) { + return new PagedIterable<>(listByResourceGroupAsync(resourceGroupName, context)); + } + + /** + * 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 a list of Activity Log Alert rules. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listBySubscriptionIdNextSinglePageAsync( + 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.listBySubscriptionIdNext(nextLink, this.client.getEndpoint(), accept, context)) + .>map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().value(), + res.getValue().nextLink(), + null)) + .subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()))); + } + + /** + * 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 a list of Activity Log Alert rules. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listBySubscriptionIdNextSinglePageAsync( + 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 + .listBySubscriptionIdNext(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 a list of Activity Log Alert rules. + */ + @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)) + .subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()))); + } + + /** + * 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 a list of Activity Log Alert rules. + */ + @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/ActivityLogAlertsImpl.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/implementation/ActivityLogAlertsImpl.java new file mode 100644 index 0000000000000..11e1775c98a04 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/implementation/ActivityLogAlertsImpl.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.MonitorManager; +import com.azure.resourcemanager.monitor.generated.fluent.ActivityLogAlertsClient; +import com.azure.resourcemanager.monitor.generated.fluent.models.ActivityLogAlertResourceInner; +import com.azure.resourcemanager.monitor.generated.models.ActivityLogAlertResource; +import com.azure.resourcemanager.monitor.generated.models.ActivityLogAlerts; +import com.fasterxml.jackson.annotation.JsonIgnore; + +public final class ActivityLogAlertsImpl implements ActivityLogAlerts { + @JsonIgnore private final ClientLogger logger = new ClientLogger(ActivityLogAlertsImpl.class); + + private final ActivityLogAlertsClient innerClient; + + private final MonitorManager serviceManager; + + public ActivityLogAlertsImpl(ActivityLogAlertsClient innerClient, MonitorManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public ActivityLogAlertResource getByResourceGroup(String resourceGroupName, String activityLogAlertName) { + ActivityLogAlertResourceInner inner = + this.serviceClient().getByResourceGroup(resourceGroupName, activityLogAlertName); + if (inner != null) { + return new ActivityLogAlertResourceImpl(inner, this.manager()); + } else { + return null; + } + } + + public Response getByResourceGroupWithResponse( + String resourceGroupName, String activityLogAlertName, Context context) { + Response inner = + this.serviceClient().getByResourceGroupWithResponse(resourceGroupName, activityLogAlertName, context); + if (inner != null) { + return new SimpleResponse<>( + inner.getRequest(), + inner.getStatusCode(), + inner.getHeaders(), + new ActivityLogAlertResourceImpl(inner.getValue(), this.manager())); + } else { + return null; + } + } + + public void deleteByResourceGroup(String resourceGroupName, String activityLogAlertName) { + this.serviceClient().delete(resourceGroupName, activityLogAlertName); + } + + public Response deleteWithResponse(String resourceGroupName, String activityLogAlertName, Context context) { + return this.serviceClient().deleteWithResponse(resourceGroupName, activityLogAlertName, context); + } + + public PagedIterable list() { + PagedIterable inner = this.serviceClient().list(); + return Utils.mapPage(inner, inner1 -> new ActivityLogAlertResourceImpl(inner1, this.manager())); + } + + public PagedIterable list(Context context) { + PagedIterable inner = this.serviceClient().list(context); + return Utils.mapPage(inner, inner1 -> new ActivityLogAlertResourceImpl(inner1, this.manager())); + } + + public PagedIterable listByResourceGroup(String resourceGroupName) { + PagedIterable inner = + this.serviceClient().listByResourceGroup(resourceGroupName); + return Utils.mapPage(inner, inner1 -> new ActivityLogAlertResourceImpl(inner1, this.manager())); + } + + public PagedIterable listByResourceGroup(String resourceGroupName, Context context) { + PagedIterable inner = + this.serviceClient().listByResourceGroup(resourceGroupName, context); + return Utils.mapPage(inner, inner1 -> new ActivityLogAlertResourceImpl(inner1, this.manager())); + } + + public ActivityLogAlertResource 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 activityLogAlertName = Utils.getValueFromIdByName(id, "activityLogAlerts"); + if (activityLogAlertName == null) { + throw logger + .logExceptionAsError( + new IllegalArgumentException( + String + .format( + "The resource ID '%s' is not valid. Missing path segment 'activityLogAlerts'.", id))); + } + return this.getByResourceGroupWithResponse(resourceGroupName, activityLogAlertName, 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 activityLogAlertName = Utils.getValueFromIdByName(id, "activityLogAlerts"); + if (activityLogAlertName == null) { + throw logger + .logExceptionAsError( + new IllegalArgumentException( + String + .format( + "The resource ID '%s' is not valid. Missing path segment 'activityLogAlerts'.", id))); + } + return this.getByResourceGroupWithResponse(resourceGroupName, activityLogAlertName, 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 activityLogAlertName = Utils.getValueFromIdByName(id, "activityLogAlerts"); + if (activityLogAlertName == null) { + throw logger + .logExceptionAsError( + new IllegalArgumentException( + String + .format( + "The resource ID '%s' is not valid. Missing path segment 'activityLogAlerts'.", id))); + } + this.deleteWithResponse(resourceGroupName, activityLogAlertName, Context.NONE).getValue(); + } + + 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 activityLogAlertName = Utils.getValueFromIdByName(id, "activityLogAlerts"); + if (activityLogAlertName == null) { + throw logger + .logExceptionAsError( + new IllegalArgumentException( + String + .format( + "The resource ID '%s' is not valid. Missing path segment 'activityLogAlerts'.", id))); + } + return this.deleteWithResponse(resourceGroupName, activityLogAlertName, context); + } + + private ActivityLogAlertsClient serviceClient() { + return this.innerClient; + } + + private MonitorManager manager() { + return this.serviceManager; + } + + public ActivityLogAlertResourceImpl define(String name) { + return new ActivityLogAlertResourceImpl(name, this.manager()); + } +} 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..729fb712a536c --- /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.ActivityLogAlertsClient; +import com.azure.resourcemanager.monitor.generated.fluent.MonitorClient; +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 ActivityLogAlertsClient object to access its operations. */ + private final ActivityLogAlertsClient activityLogAlerts; + + /** + * Gets the ActivityLogAlertsClient object to access its operations. + * + * @return the ActivityLogAlertsClient object. + */ + public ActivityLogAlertsClient getActivityLogAlerts() { + return this.activityLogAlerts; + } + + /** + * 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 = "2020-10-01"; + this.activityLogAlerts = new ActivityLogAlertsClientImpl(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/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..0b2334183b2c7 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/implementation/Utils.java @@ -0,0 +1,196 @@ +// 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.Mono; + +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 pageIterable; + private final Function mapper; + private final Function, PagedResponse> pageMapper; + + private PagedIterableImpl(PagedIterable pageIterable, Function mapper) { + super(new PagedFlux(Mono::empty)); + this.pageIterable = pageIterable; + this.mapper = mapper; + this.pageMapper = + 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 pageIterable.stream().map(mapper); + } + + @Override + public Stream> streamByPage() { + return pageIterable.streamByPage().map(pageMapper); + } + + @Override + public Stream> streamByPage(String continuationToken) { + return pageIterable.streamByPage(continuationToken).map(pageMapper); + } + + @Override + public Stream> streamByPage(int preferredPageSize) { + return pageIterable.streamByPage(preferredPageSize).map(pageMapper); + } + + @Override + public Stream> streamByPage(String continuationToken, int preferredPageSize) { + return pageIterable.streamByPage(continuationToken, preferredPageSize).map(pageMapper); + } + + @Override + public Iterator iterator() { + return new IteratorImpl(pageIterable.iterator(), mapper); + } + + @Override + public Iterable> iterableByPage() { + return new IterableImpl, PagedResponse>(pageIterable.iterableByPage(), pageMapper); + } + + @Override + public Iterable> iterableByPage(String continuationToken) { + return new IterableImpl, PagedResponse>( + pageIterable.iterableByPage(continuationToken), pageMapper); + } + + @Override + public Iterable> iterableByPage(int preferredPageSize) { + return new IterableImpl, PagedResponse>( + pageIterable.iterableByPage(preferredPageSize), pageMapper); + } + + @Override + public Iterable> iterableByPage(String continuationToken, int preferredPageSize) { + return new IterableImpl, PagedResponse>( + pageIterable.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/ActionGroup.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ActionGroup.java new file mode 100644 index 0000000000000..039634544a36f --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ActionGroup.java @@ -0,0 +1,85 @@ +// 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.Map; + +/** A pointer to an Azure Action Group. */ +@Fluent +public final class ActionGroup { + @JsonIgnore private final ClientLogger logger = new ClientLogger(ActionGroup.class); + + /* + * The resource ID of the Action Group. This cannot be null or empty. + */ + @JsonProperty(value = "actionGroupId", required = true) + private String actionGroupId; + + /* + * the dictionary of custom properties to include with the post operation. + * These data are appended to the webhook payload. + */ + @JsonProperty(value = "webhookProperties") + private Map webhookProperties; + + /** + * Get the actionGroupId property: The resource ID of the Action Group. This cannot be null or empty. + * + * @return the actionGroupId value. + */ + public String actionGroupId() { + return this.actionGroupId; + } + + /** + * Set the actionGroupId property: The resource ID of the Action Group. This cannot be null or empty. + * + * @param actionGroupId the actionGroupId value to set. + * @return the ActionGroup object itself. + */ + public ActionGroup withActionGroupId(String actionGroupId) { + this.actionGroupId = actionGroupId; + return this; + } + + /** + * Get the webhookProperties property: the dictionary of custom properties to include with the post operation. These + * data are appended to the webhook payload. + * + * @return the webhookProperties value. + */ + public Map webhookProperties() { + return this.webhookProperties; + } + + /** + * Set the webhookProperties property: the dictionary of custom properties to include with the post operation. These + * data are appended to the webhook payload. + * + * @param webhookProperties the webhookProperties value to set. + * @return the ActionGroup object itself. + */ + public ActionGroup withWebhookProperties(Map webhookProperties) { + this.webhookProperties = webhookProperties; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (actionGroupId() == null) { + throw logger + .logExceptionAsError( + new IllegalArgumentException("Missing required property actionGroupId in model ActionGroup")); + } + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ActionList.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ActionList.java new file mode 100644 index 0000000000000..d3bbbe96d8864 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ActionList.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; + +/** A list of Activity Log Alert rule actions. */ +@Fluent +public final class ActionList { + @JsonIgnore private final ClientLogger logger = new ClientLogger(ActionList.class); + + /* + * The list of the Action Groups. + */ + @JsonProperty(value = "actionGroups") + private List actionGroups; + + /** + * Get the actionGroups property: The list of the Action Groups. + * + * @return the actionGroups value. + */ + public List actionGroups() { + return this.actionGroups; + } + + /** + * Set the actionGroups property: The list of the Action Groups. + * + * @param actionGroups the actionGroups value to set. + * @return the ActionList object itself. + */ + public ActionList withActionGroups(List actionGroups) { + this.actionGroups = actionGroups; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (actionGroups() != null) { + actionGroups().forEach(e -> e.validate()); + } + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ActivityLogAlertResource.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ActivityLogAlertResource.java new file mode 100644 index 0000000000000..491d16fe68100 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ActivityLogAlertResource.java @@ -0,0 +1,305 @@ +// 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.util.Context; +import com.azure.resourcemanager.monitor.generated.fluent.models.ActivityLogAlertResourceInner; +import java.util.List; +import java.util.Map; + +/** An immutable client-side representation of ActivityLogAlertResource. */ +public interface ActivityLogAlertResource { + /** + * 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 scopes property: A list of resource IDs that will be used as prefixes. The alert will only apply to + * Activity Log events with resource IDs that fall under one of these prefixes. This list must include at least one + * item. + * + * @return the scopes value. + */ + List scopes(); + + /** + * Gets the condition property: The condition that will cause this alert to activate. + * + * @return the condition value. + */ + AlertRuleAllOfCondition condition(); + + /** + * Gets the actions property: The actions that will activate when the condition is met. + * + * @return the actions value. + */ + ActionList actions(); + + /** + * Gets the enabled property: Indicates whether this Activity Log Alert rule is enabled. If an Activity Log Alert + * rule is not enabled, then none of its actions will be activated. + * + * @return the enabled value. + */ + Boolean enabled(); + + /** + * Gets the description property: A description of this Activity Log Alert rule. + * + * @return the description value. + */ + String description(); + + /** + * 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.ActivityLogAlertResourceInner object. + * + * @return the inner object. + */ + ActivityLogAlertResourceInner innerModel(); + + /** The entirety of the ActivityLogAlertResource definition. */ + interface Definition + extends DefinitionStages.Blank, + DefinitionStages.WithLocation, + DefinitionStages.WithResourceGroup, + DefinitionStages.WithCreate { + } + /** The ActivityLogAlertResource definition stages. */ + interface DefinitionStages { + /** The first stage of the ActivityLogAlertResource definition. */ + interface Blank extends WithLocation { + } + /** The stage of the ActivityLogAlertResource 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 ActivityLogAlertResource 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 ActivityLogAlertResource 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.WithScopes, + DefinitionStages.WithCondition, + DefinitionStages.WithActions, + DefinitionStages.WithEnabled, + DefinitionStages.WithDescription { + /** + * Executes the create request. + * + * @return the created resource. + */ + ActivityLogAlertResource create(); + + /** + * Executes the create request. + * + * @param context The context to associate with this operation. + * @return the created resource. + */ + ActivityLogAlertResource create(Context context); + } + /** The stage of the ActivityLogAlertResource 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 ActivityLogAlertResource definition allowing to specify scopes. */ + interface WithScopes { + /** + * Specifies the scopes property: A list of resource IDs that will be used as prefixes. The alert will only + * apply to Activity Log events with resource IDs that fall under one of these prefixes. This list must + * include at least one item.. + * + * @param scopes A list of resource IDs that will be used as prefixes. The alert will only apply to Activity + * Log events with resource IDs that fall under one of these prefixes. This list must include at least + * one item. + * @return the next definition stage. + */ + WithCreate withScopes(List scopes); + } + /** The stage of the ActivityLogAlertResource definition allowing to specify condition. */ + interface WithCondition { + /** + * Specifies the condition property: The condition that will cause this alert to activate.. + * + * @param condition The condition that will cause this alert to activate. + * @return the next definition stage. + */ + WithCreate withCondition(AlertRuleAllOfCondition condition); + } + /** The stage of the ActivityLogAlertResource definition allowing to specify actions. */ + interface WithActions { + /** + * Specifies the actions property: The actions that will activate when the condition is met.. + * + * @param actions The actions that will activate when the condition is met. + * @return the next definition stage. + */ + WithCreate withActions(ActionList actions); + } + /** The stage of the ActivityLogAlertResource definition allowing to specify enabled. */ + interface WithEnabled { + /** + * Specifies the enabled property: Indicates whether this Activity Log Alert rule is enabled. If an Activity + * Log Alert rule is not enabled, then none of its actions will be activated.. + * + * @param enabled Indicates whether this Activity Log Alert rule is enabled. If an Activity Log Alert rule + * is not enabled, then none of its actions will be activated. + * @return the next definition stage. + */ + WithCreate withEnabled(Boolean enabled); + } + /** The stage of the ActivityLogAlertResource definition allowing to specify description. */ + interface WithDescription { + /** + * Specifies the description property: A description of this Activity Log Alert rule.. + * + * @param description A description of this Activity Log Alert rule. + * @return the next definition stage. + */ + WithCreate withDescription(String description); + } + } + /** + * Begins update for the ActivityLogAlertResource resource. + * + * @return the stage of resource update. + */ + ActivityLogAlertResource.Update update(); + + /** The template for ActivityLogAlertResource update. */ + interface Update extends UpdateStages.WithTags, UpdateStages.WithEnabled { + /** + * Executes the update request. + * + * @return the updated resource. + */ + ActivityLogAlertResource apply(); + + /** + * Executes the update request. + * + * @param context The context to associate with this operation. + * @return the updated resource. + */ + ActivityLogAlertResource apply(Context context); + } + /** The ActivityLogAlertResource update stages. */ + interface UpdateStages { + /** The stage of the ActivityLogAlertResource update allowing to specify tags. */ + interface WithTags { + /** + * Specifies the tags property: The resource tags. + * + * @param tags The resource tags. + * @return the next definition stage. + */ + Update withTags(Map tags); + } + /** The stage of the ActivityLogAlertResource update allowing to specify enabled. */ + interface WithEnabled { + /** + * Specifies the enabled property: Indicates whether this Activity Log Alert rule is enabled. If an Activity + * Log Alert rule is not enabled, then none of its actions will be activated.. + * + * @param enabled Indicates whether this Activity Log Alert rule is enabled. If an Activity Log Alert rule + * is not enabled, then none of its actions will be activated. + * @return the next definition stage. + */ + Update withEnabled(Boolean enabled); + } + } + /** + * Refreshes the resource to sync with Azure. + * + * @return the refreshed resource. + */ + ActivityLogAlertResource refresh(); + + /** + * Refreshes the resource to sync with Azure. + * + * @param context The context to associate with this operation. + * @return the refreshed resource. + */ + ActivityLogAlertResource refresh(Context context); +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ActivityLogAlerts.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ActivityLogAlerts.java new file mode 100644 index 0000000000000..a96b0fb081046 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ActivityLogAlerts.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 ActivityLogAlerts. */ +public interface ActivityLogAlerts { + /** + * Get an Activity Log Alert rule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param activityLogAlertName The name of the Activity Log Alert 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 an Activity Log Alert rule. + */ + ActivityLogAlertResource getByResourceGroup(String resourceGroupName, String activityLogAlertName); + + /** + * Get an Activity Log Alert rule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param activityLogAlertName The name of the Activity Log Alert 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 an Activity Log Alert rule. + */ + Response getByResourceGroupWithResponse( + String resourceGroupName, String activityLogAlertName, Context context); + + /** + * Delete an Activity Log Alert rule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param activityLogAlertName The name of the Activity Log Alert 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 activityLogAlertName); + + /** + * Delete an Activity Log Alert rule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param activityLogAlertName The name of the Activity Log Alert 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 activityLogAlertName, Context context); + + /** + * Get a list of all Activity Log Alert rules 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 a list of all Activity Log Alert rules in a subscription. + */ + PagedIterable list(); + + /** + * Get a list of all Activity Log Alert rules 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 a list of all Activity Log Alert rules in a subscription. + */ + PagedIterable list(Context context); + + /** + * Get a list of all Activity Log Alert rules 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 a list of all Activity Log Alert rules in a resource group. + */ + PagedIterable listByResourceGroup(String resourceGroupName); + + /** + * Get a list of all Activity Log Alert rules 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 a list of all Activity Log Alert rules in a resource group. + */ + PagedIterable listByResourceGroup(String resourceGroupName, Context context); + + /** + * Get an Activity Log Alert 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. + * @return an Activity Log Alert rule. + */ + ActivityLogAlertResource getById(String id); + + /** + * Get an Activity Log Alert 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 an Activity Log Alert rule. + */ + Response getByIdWithResponse(String id, Context context); + + /** + * Delete an Activity Log Alert 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); + + /** + * Delete an Activity Log Alert 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 ActivityLogAlertResource resource. + * + * @param name resource name. + * @return the first stage of the new ActivityLogAlertResource definition. + */ + ActivityLogAlertResource.DefinitionStages.Blank define(String name); +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/AlertRuleAllOfCondition.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/AlertRuleAllOfCondition.java new file mode 100644 index 0000000000000..97facf7b5688b --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/AlertRuleAllOfCondition.java @@ -0,0 +1,58 @@ +// 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; + +/** An Activity Log Alert rule condition that is met when all its member conditions are met. */ +@Fluent +public final class AlertRuleAllOfCondition { + @JsonIgnore private final ClientLogger logger = new ClientLogger(AlertRuleAllOfCondition.class); + + /* + * The list of Activity Log Alert rule conditions. + */ + @JsonProperty(value = "allOf", required = true) + private List allOf; + + /** + * Get the allOf property: The list of Activity Log Alert rule conditions. + * + * @return the allOf value. + */ + public List allOf() { + return this.allOf; + } + + /** + * Set the allOf property: The list of Activity Log Alert rule conditions. + * + * @param allOf the allOf value to set. + * @return the AlertRuleAllOfCondition object itself. + */ + public AlertRuleAllOfCondition 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) { + throw logger + .logExceptionAsError( + new IllegalArgumentException("Missing required property allOf in model AlertRuleAllOfCondition")); + } else { + allOf().forEach(e -> e.validate()); + } + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/AlertRuleAnyOfOrLeafCondition.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/AlertRuleAnyOfOrLeafCondition.java new file mode 100644 index 0000000000000..7e59d1349852e --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/AlertRuleAnyOfOrLeafCondition.java @@ -0,0 +1,87 @@ +// 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; + +/** + * An Activity Log Alert rule condition that is met when all its member conditions are met. Each condition can be of one + * of the following types: __Important__: Each type has its unique subset of properties. Properties from different types + * CANNOT exist in one condition. * __Leaf Condition -__ must contain 'field' and either 'equals' or 'containsAny'. + * _Please note, 'anyOf' should __not__ be set in a Leaf Condition._ * __AnyOf Condition -__ must contain __only__ + * 'anyOf' (which is an array of Leaf Conditions). _Please note, 'field', 'equals' and 'containsAny' should __not__ be + * set in an AnyOf Condition._. + */ +@Fluent +public final class AlertRuleAnyOfOrLeafCondition extends AlertRuleLeafCondition { + @JsonIgnore private final ClientLogger logger = new ClientLogger(AlertRuleAnyOfOrLeafCondition.class); + + /* + * An Activity Log Alert rule condition that is met when at least one of + * its member leaf conditions are met. + */ + @JsonProperty(value = "anyOf") + private List anyOf; + + /** + * Get the anyOf property: An Activity Log Alert rule condition that is met when at least one of its member leaf + * conditions are met. + * + * @return the anyOf value. + */ + public List anyOf() { + return this.anyOf; + } + + /** + * Set the anyOf property: An Activity Log Alert rule condition that is met when at least one of its member leaf + * conditions are met. + * + * @param anyOf the anyOf value to set. + * @return the AlertRuleAnyOfOrLeafCondition object itself. + */ + public AlertRuleAnyOfOrLeafCondition withAnyOf(List anyOf) { + this.anyOf = anyOf; + return this; + } + + /** {@inheritDoc} */ + @Override + public AlertRuleAnyOfOrLeafCondition withField(String field) { + super.withField(field); + return this; + } + + /** {@inheritDoc} */ + @Override + public AlertRuleAnyOfOrLeafCondition withEquals(String equals) { + super.withEquals(equals); + return this; + } + + /** {@inheritDoc} */ + @Override + public AlertRuleAnyOfOrLeafCondition withContainsAny(List containsAny) { + super.withContainsAny(containsAny); + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + @Override + public void validate() { + super.validate(); + if (anyOf() != null) { + anyOf().forEach(e -> e.validate()); + } + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/AlertRuleLeafCondition.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/AlertRuleLeafCondition.java new file mode 100644 index 0000000000000..4e023829a4b72 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/AlertRuleLeafCondition.java @@ -0,0 +1,123 @@ +// 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; + +/** + * An Activity Log Alert rule condition that is met by comparing the field and value of an Activity Log event. This + * condition must contain 'field' and either 'equals' or 'containsAny'. + */ +@Fluent +public class AlertRuleLeafCondition { + @JsonIgnore private final ClientLogger logger = new ClientLogger(AlertRuleLeafCondition.class); + + /* + * The name of the Activity Log event's field that this condition will + * examine. + * The possible values for this field are (case-insensitive): 'resourceId', + * 'category', 'caller', 'level', 'operationName', 'resourceGroup', + * 'resourceProvider', 'status', 'subStatus', 'resourceType', or anything + * beginning with 'properties'. + */ + @JsonProperty(value = "field") + private String field; + + /* + * The value of the event's field will be compared to this value + * (case-insensitive) to determine if the condition is met. + */ + @JsonProperty(value = "equals") + private String equals; + + /* + * The value of the event's field will be compared to the values in this + * array (case-insensitive) to determine if the condition is met. + */ + @JsonProperty(value = "containsAny") + private List containsAny; + + /** + * Get the field property: The name of the Activity Log event's field that this condition will examine. The possible + * values for this field are (case-insensitive): 'resourceId', 'category', 'caller', 'level', 'operationName', + * 'resourceGroup', 'resourceProvider', 'status', 'subStatus', 'resourceType', or anything beginning with + * 'properties'. + * + * @return the field value. + */ + public String field() { + return this.field; + } + + /** + * Set the field property: The name of the Activity Log event's field that this condition will examine. The possible + * values for this field are (case-insensitive): 'resourceId', 'category', 'caller', 'level', 'operationName', + * 'resourceGroup', 'resourceProvider', 'status', 'subStatus', 'resourceType', or anything beginning with + * 'properties'. + * + * @param field the field value to set. + * @return the AlertRuleLeafCondition object itself. + */ + public AlertRuleLeafCondition withField(String field) { + this.field = field; + return this; + } + + /** + * Get the equals property: The value of the event's field will be compared to this value (case-insensitive) to + * determine if the condition is met. + * + * @return the equals value. + */ + public String equals() { + return this.equals; + } + + /** + * Set the equals property: The value of the event's field will be compared to this value (case-insensitive) to + * determine if the condition is met. + * + * @param equals the equals value to set. + * @return the AlertRuleLeafCondition object itself. + */ + public AlertRuleLeafCondition withEquals(String equals) { + this.equals = equals; + return this; + } + + /** + * Get the containsAny property: The value of the event's field will be compared to the values in this array + * (case-insensitive) to determine if the condition is met. + * + * @return the containsAny value. + */ + public List containsAny() { + return this.containsAny; + } + + /** + * Set the containsAny property: The value of the event's field will be compared to the values in this array + * (case-insensitive) to determine if the condition is met. + * + * @param containsAny the containsAny value to set. + * @return the AlertRuleLeafCondition object itself. + */ + public AlertRuleLeafCondition withContainsAny(List containsAny) { + this.containsAny = containsAny; + 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/AlertRuleList.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/AlertRuleList.java new file mode 100644 index 0000000000000..db824743a249a --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/AlertRuleList.java @@ -0,0 +1,81 @@ +// 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.ActivityLogAlertResourceInner; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +/** A list of Activity Log Alert rules. */ +@Fluent +public final class AlertRuleList { + @JsonIgnore private final ClientLogger logger = new ClientLogger(AlertRuleList.class); + + /* + * The list of Activity Log Alert rules. + */ + @JsonProperty(value = "value") + private List value; + + /* + * Provides the link to retrieve the next set of elements. + */ + @JsonProperty(value = "nextLink") + private String nextLink; + + /** + * Get the value property: The list of Activity Log Alert rules. + * + * @return the value value. + */ + public List value() { + return this.value; + } + + /** + * Set the value property: The list of Activity Log Alert rules. + * + * @param value the value value to set. + * @return the AlertRuleList object itself. + */ + public AlertRuleList 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; + } + + /** + * Set the nextLink property: Provides the link to retrieve the next set of elements. + * + * @param nextLink the nextLink value to set. + * @return the AlertRuleList object itself. + */ + public AlertRuleList withNextLink(String nextLink) { + this.nextLink = nextLink; + return this; + } + + /** + * 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/AlertRulePatchObject.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/AlertRulePatchObject.java new file mode 100644 index 0000000000000..2701c3d271060 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/AlertRulePatchObject.java @@ -0,0 +1,83 @@ +// 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.annotation.JsonFlatten; +import com.azure.core.util.logging.ClientLogger; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.Map; + +/** An Activity Log Alert rule object for the body of patch operations. */ +@JsonFlatten +@Fluent +public class AlertRulePatchObject { + @JsonIgnore private final ClientLogger logger = new ClientLogger(AlertRulePatchObject.class); + + /* + * The resource tags + */ + @JsonProperty(value = "tags") + private Map tags; + + /* + * Indicates whether this Activity Log Alert rule is enabled. If an + * Activity Log Alert rule is not enabled, then none of its actions will be + * activated. + */ + @JsonProperty(value = "properties.enabled") + private Boolean enabled; + + /** + * Get the tags property: The resource tags. + * + * @return the tags value. + */ + public Map tags() { + return this.tags; + } + + /** + * Set the tags property: The resource tags. + * + * @param tags the tags value to set. + * @return the AlertRulePatchObject object itself. + */ + public AlertRulePatchObject withTags(Map tags) { + this.tags = tags; + return this; + } + + /** + * Get the enabled property: Indicates whether this Activity Log Alert rule is enabled. If an Activity Log Alert + * rule is not enabled, then none of its actions will be activated. + * + * @return the enabled value. + */ + public Boolean enabled() { + return this.enabled; + } + + /** + * Set the enabled property: Indicates whether this Activity Log Alert rule is enabled. If an Activity Log Alert + * rule is not enabled, then none of its actions will be activated. + * + * @param enabled the enabled value to set. + * @return the AlertRulePatchObject object itself. + */ + public AlertRulePatchObject withEnabled(Boolean enabled) { + this.enabled = enabled; + 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/AzureResource.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/AzureResource.java new file mode 100644 index 0000000000000..a20024137552e --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/AzureResource.java @@ -0,0 +1,39 @@ +// 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.Immutable; +import com.azure.core.management.Resource; +import com.azure.core.util.logging.ClientLogger; +import com.fasterxml.jackson.annotation.JsonIgnore; +import java.util.Map; + +/** An Azure resource object. */ +@Immutable +public class AzureResource extends Resource { + @JsonIgnore private final ClientLogger logger = new ClientLogger(AzureResource.class); + + /** {@inheritDoc} */ + @Override + public AzureResource withLocation(String location) { + super.withLocation(location); + return this; + } + + /** {@inheritDoc} */ + @Override + public AzureResource withTags(Map tags) { + super.withTags(tags); + 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/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/ci.yml b/sdk/monitor/ci.yml index f0a481f70d8e3..3bb83413f2f4f 100644 --- a/sdk/monitor/ci.yml +++ b/sdk/monitor/ci.yml @@ -53,3 +53,6 @@ extends: - name: azure-monitor-opentelemetry-exporter groupId: com.azure safeName: azuremonitoropentelemetryexporter + - name: azure-resourcemanager-monitor-generated + groupId: com.azure.resourcemanager + safeName: azureresourcemanagermonitorgenerated diff --git a/sdk/monitor/pom.xml b/sdk/monitor/pom.xml index 030600ef5d252..68e8c4be56c5f 100644 --- a/sdk/monitor/pom.xml +++ b/sdk/monitor/pom.xml @@ -53,6 +53,7 @@ azure-monitor-opentelemetry-exporter + azure-resourcemanager-monitor-generated