diff --git a/eng/versioning/version_client.txt b/eng/versioning/version_client.txt index f6dbf39d0191d..3c55527692b2a 100644 --- a/eng/versioning/version_client.txt +++ b/eng/versioning/version_client.txt @@ -477,6 +477,7 @@ com.azure.resourcemanager:azure-resourcemanager-containerorchestratorruntime;1.0 com.azure.resourcemanager:azure-resourcemanager-terraform;1.0.0-beta.1;1.0.0-beta.2 com.azure.resourcemanager:azure-resourcemanager-connectedcache;1.0.0-beta.1;1.0.0-beta.2 com.azure.resourcemanager:azure-resourcemanager-neonpostgres;1.0.0-beta.1;1.0.0-beta.2 +com.azure.resourcemanager:azure-resourcemanager-monitor-generated;1.0.0-beta.1;1.0.0-beta.1 com.azure.tools:azure-sdk-archetype;1.0.0;1.2.0-beta.1 com.azure.tools:azure-sdk-build-tool;1.0.0;1.1.0-beta.1 io.clientcore:clientcore-parent;1.0.0-beta.1;1.0.0-beta.1 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..524601c81c0c0 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/CHANGELOG.md @@ -0,0 +1,8 @@ +# Release History + +## 1.0.0-beta.1 (2024-12-23) + +- Azure Resource Manager Monitor client library for Java. This package contains Microsoft Azure SDK for Monitor Management SDK. Monitor Management Client. Package tag package-preview-2024-10. For documentation on how to use this package, please see [Azure Management Libraries for Java](https://aka.ms/azsdk/java/mgmt). +### Features Added + +- Initial release for the azure-resourcemanager-monitor-generated Java SDK. 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..a31ace41ddad2 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/README.md @@ -0,0 +1,104 @@ +# 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-preview-2024-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] and [Azure Core Netty HTTP][azure_core_http_netty] packages provide the default implementation. + +### Authentication + +Microsoft Entra ID token authentication relies on the [credential class][azure_identity_credentials] from [Azure Identity][azure_identity] package. + +Azure subscription ID can be configured via `AZURE_SUBSCRIPTION_ID` environment variable. + +Assuming the use of the `DefaultAzureCredential` credential class, the client can be authenticated using the following code: + +```java +AzureProfile profile = new AzureProfile(AzureEnvironment.AZURE); +TokenCredential credential = new DefaultAzureCredentialBuilder() + .authorityHost(profile.getEnvironment().getActiveDirectoryEndpoint()) + .build(); +MonitorManager manager = MonitorManager + .authenticate(credential, profile); +``` + +The sample code assumes global Azure. Please change `AzureEnvironment.AZURE` variable if otherwise. + +See [Authentication][authenticate] for more options. + +## Key concepts + +See [API design][design] for general introduction on design and key concepts on Azure Management Libraries. + +## Examples + +[Code snippets and samples](https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/monitor/azure-resourcemanager-monitor-generated/SAMPLE.md) + + +## Troubleshooting + +## Next steps + +## Contributing + +For details on contributing to this repository, see the [contributing guide][cg]. + +This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit . + +When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repositories using our CLA. + +This project has adopted the [Microsoft Open Source Code of Conduct][coc]. For more information see the [Code of Conduct FAQ][coc_faq] or contact with any additional questions or comments. + + +[survey]: https://microsoft.qualtrics.com/jfe/form/SV_ehN0lIk2FKEBkwd?Q_CHL=DOCS +[docs]: https://azure.github.io/azure-sdk-for-java/ +[jdk]: https://learn.microsoft.com/azure/developer/java/fundamentals/ +[azure_subscription]: https://azure.microsoft.com/free/ +[azure_identity]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/identity/azure-identity +[azure_identity_credentials]: https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/identity/azure-identity#credentials +[azure_core_http_netty]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/core/azure-core-http-netty +[authenticate]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/resourcemanager/docs/AUTH.md +[design]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/resourcemanager/docs/DESIGN.md +[cg]: https://github.com/Azure/azure-sdk-for-java/blob/main/CONTRIBUTING.md +[coc]: https://opensource.microsoft.com/codeofconduct/ +[coc_faq]: https://opensource.microsoft.com/codeofconduct/faq/ + +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-java%2Fsdk%2Fmonitor%2Fazure-resourcemanager-monitor-generated%2FREADME.png) diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/SAMPLE.md b/sdk/monitor/azure-resourcemanager-monitor-generated/SAMPLE.md new file mode 100644 index 0000000000000..7f9ee8c13016a --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/SAMPLE.md @@ -0,0 +1,790 @@ +# Code snippets and samples + + +## ActionGroups + +- [CreateNotificationsAtActionGroupResourceLevel](#actiongroups_createnotificationsatactiongroupresourcelevel) +- [CreateOrUpdate](#actiongroups_createorupdate) +- [Delete](#actiongroups_delete) +- [EnableReceiver](#actiongroups_enablereceiver) +- [GetByResourceGroup](#actiongroups_getbyresourcegroup) +- [GetTestNotificationsAtActionGroupResourceLevel](#actiongroups_gettestnotificationsatactiongroupresourcelevel) +- [List](#actiongroups_list) +- [ListByResourceGroup](#actiongroups_listbyresourcegroup) +- [Update](#actiongroups_update) + +## ScheduledQueryRules + +- [CreateOrUpdate](#scheduledqueryrules_createorupdate) +- [Delete](#scheduledqueryrules_delete) +- [GetByResourceGroup](#scheduledqueryrules_getbyresourcegroup) +- [List](#scheduledqueryrules_list) +- [ListByResourceGroup](#scheduledqueryrules_listbyresourcegroup) +- [Update](#scheduledqueryrules_update) +### ActionGroups_CreateNotificationsAtActionGroupResourceLevel + +```java +import com.azure.resourcemanager.monitor.generated.models.ArmRoleReceiver; +import com.azure.resourcemanager.monitor.generated.models.AutomationRunbookReceiver; +import com.azure.resourcemanager.monitor.generated.models.AzureAppPushReceiver; +import com.azure.resourcemanager.monitor.generated.models.AzureFunctionReceiver; +import com.azure.resourcemanager.monitor.generated.models.EmailReceiver; +import com.azure.resourcemanager.monitor.generated.models.EventHubReceiver; +import com.azure.resourcemanager.monitor.generated.models.ItsmReceiver; +import com.azure.resourcemanager.monitor.generated.models.LogicAppReceiver; +import com.azure.resourcemanager.monitor.generated.models.NotificationRequestBody; +import com.azure.resourcemanager.monitor.generated.models.SmsReceiver; +import com.azure.resourcemanager.monitor.generated.models.VoiceReceiver; +import com.azure.resourcemanager.monitor.generated.models.WebhookReceiver; +import java.util.Arrays; + +/** + * Samples for ActionGroups CreateNotificationsAtActionGroupResourceLevel. + */ +public final class ActionGroupsCreateNotificationsAtActionGroupResourceLevelSamples { + /* + * x-ms-original-file: + * specification/monitor/resource-manager/Microsoft.Insights/preview/2024-10-01-preview/examples/ + * postTestNotificationsAtActionGroupResourceLevel.json + */ + /** + * Sample code: Create notifications at resource group level. + * + * @param manager Entry point to MonitorManager. + */ + public static void + createNotificationsAtResourceGroupLevel(com.azure.resourcemanager.monitor.generated.MonitorManager manager) { + manager.actionGroups() + .createNotificationsAtActionGroupResourceLevel("TestRgName", "TestAgName", new NotificationRequestBody() + .withAlertType("budget") + .withEmailReceivers(Arrays.asList( + new EmailReceiver().withName("John Doe's email") + .withEmailAddress("johndoe@email.com") + .withUseCommonAlertSchema(false), + new EmailReceiver().withName("Jane Smith's email") + .withEmailAddress("janesmith@email.com") + .withUseCommonAlertSchema(true))) + .withSmsReceivers(Arrays.asList( + new SmsReceiver().withName("John Doe's mobile") + .withCountryCode("fakeTokenPlaceholder") + .withPhoneNumber("1234567890"), + new SmsReceiver().withName("Jane Smith's mobile") + .withCountryCode("fakeTokenPlaceholder") + .withPhoneNumber("0987654321"))) + .withWebhookReceivers(Arrays.asList( + new WebhookReceiver().withName("Sample webhook 1") + .withServiceUri("http://www.example.com/webhook1") + .withUseCommonAlertSchema(true), + new WebhookReceiver().withName("Sample webhook 2") + .withServiceUri("http://www.example.com/webhook2") + .withUseCommonAlertSchema(true) + .withUseAadAuth(true) + .withObjectId("d3bb868c-fe44-452c-aa26-769a6538c808") + .withIdentifierUri("http://someidentifier/d7811ba3-7996-4a93-99b6-6b2f3f355f8a") + .withTenantId("68a4459a-ccb8-493c-b9da-dd30457d1b84"))) + .withItsmReceivers(Arrays.asList(new ItsmReceiver().withName("Sample itsm") + .withWorkspaceId("5def922a-3ed4-49c1-b9fd-05ec533819a3|55dfd1f8-7e59-4f89-bf56-4c82f5ace23c") + .withConnectionId("a3b9076c-ce8e-434e-85b4-aff10cb3c8f1") + .withTicketConfiguration( + "{\"PayloadRevision\":0,\"WorkItemType\":\"Incident\",\"UseTemplate\":false,\"WorkItemData\":\"{}\",\"CreateOneWIPerCI\":false}") + .withRegion("westcentralus"))) + .withAzureAppPushReceivers(Arrays.asList( + new AzureAppPushReceiver().withName("Sample azureAppPush").withEmailAddress("johndoe@email.com"))) + .withAutomationRunbookReceivers(Arrays.asList(new AutomationRunbookReceiver().withAutomationAccountId( + "/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/runbookTest/providers/Microsoft.Automation/automationAccounts/runbooktest") + .withRunbookName("Sample runbook") + .withWebhookResourceId( + "/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/runbookTest/providers/Microsoft.Automation/automationAccounts/runbooktest/webhooks/Alert1510184037084") + .withIsGlobalRunbook(false) + .withName("testRunbook") + .withServiceUri("http://test.me") + .withUseCommonAlertSchema(true))) + .withVoiceReceivers(Arrays.asList(new VoiceReceiver().withName("Sample voice") + .withCountryCode("fakeTokenPlaceholder") + .withPhoneNumber("1234567890"))) + .withLogicAppReceivers(Arrays.asList(new LogicAppReceiver().withName("Sample logicApp") + .withResourceId( + "/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/LogicApp/providers/Microsoft.Logic/workflows/testLogicApp") + .withCallbackUrl( + "https://prod-27.northcentralus.logic.azure.com/workflows/68e572e818e5457ba898763b7db90877/triggers/manual/paths/invoke/azns/test?api-version=2016-10-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=Abpsb72UYJxPPvmDo937uzofupO5r_vIeWEx7KVHo7w") + .withUseCommonAlertSchema(false) + .withManagedIdentity("f11979a4-36d1-45d0-9097-a0da3c7e855d"))) + .withAzureFunctionReceivers(Arrays.asList(new AzureFunctionReceiver().withName("Sample azureFunction") + .withFunctionAppResourceId( + "/subscriptions/5def922a-3ed4-49c1-b9fd-05ec533819a3/resourceGroups/aznsTest/providers/Microsoft.Web/sites/testFunctionApp") + .withFunctionName("HttpTriggerCSharp1") + .withHttpTriggerUrl("http://test.me") + .withUseCommonAlertSchema(true) + .withManagedIdentity("f11979a4-36d1-45d0-9097-a0da3c7e855d"))) + .withArmRoleReceivers(Arrays.asList( + new ArmRoleReceiver().withName("ArmRole-Common") + .withRoleId("11111111-1111-1111-1111-111111111111") + .withUseCommonAlertSchema(true), + new ArmRoleReceiver().withName("ArmRole-nonCommon") + .withRoleId("11111111-1111-1111-1111-111111111111") + .withUseCommonAlertSchema(false))) + .withEventHubReceivers(Arrays.asList(new EventHubReceiver().withName("Sample eventHub") + .withEventHubNameSpace("testEventHubNameSpace") + .withEventHubName("testEventHub") + .withTenantId("68a4459a-ccb8-493c-b9da-dd30457d1b84") + .withSubscriptionId("187f412d-1758-44d9-b052-169e2564721d"))), + com.azure.core.util.Context.NONE); + } +} +``` + +### ActionGroups_CreateOrUpdate + +```java +import com.azure.resourcemanager.monitor.generated.models.ArmRoleReceiver; +import com.azure.resourcemanager.monitor.generated.models.AutomationRunbookReceiver; +import com.azure.resourcemanager.monitor.generated.models.AzureAppPushReceiver; +import com.azure.resourcemanager.monitor.generated.models.AzureFunctionReceiver; +import com.azure.resourcemanager.monitor.generated.models.EmailReceiver; +import com.azure.resourcemanager.monitor.generated.models.EventHubReceiver; +import com.azure.resourcemanager.monitor.generated.models.IncidentManagementService; +import com.azure.resourcemanager.monitor.generated.models.IncidentReceiver; +import com.azure.resourcemanager.monitor.generated.models.IncidentServiceConnection; +import com.azure.resourcemanager.monitor.generated.models.ItsmReceiver; +import com.azure.resourcemanager.monitor.generated.models.LogicAppReceiver; +import com.azure.resourcemanager.monitor.generated.models.ManagedServiceIdentity; +import com.azure.resourcemanager.monitor.generated.models.ManagedServiceIdentityType; +import com.azure.resourcemanager.monitor.generated.models.SmsReceiver; +import com.azure.resourcemanager.monitor.generated.models.UserAssignedIdentity; +import com.azure.resourcemanager.monitor.generated.models.VoiceReceiver; +import com.azure.resourcemanager.monitor.generated.models.WebhookReceiver; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; + +/** + * Samples for ActionGroups CreateOrUpdate. + */ +public final class ActionGroupsCreateOrUpdateSamples { + /* + * x-ms-original-file: + * specification/monitor/resource-manager/Microsoft.Insights/preview/2024-10-01-preview/examples/ + * createOrUpdateActionGroup.json + */ + /** + * Sample code: Create or update an action group. + * + * @param manager Entry point to MonitorManager. + */ + public static void createOrUpdateAnActionGroup(com.azure.resourcemanager.monitor.generated.MonitorManager manager) { + manager.actionGroups() + .define("SampleActionGroup") + .withRegion("Global") + .withExistingResourceGroup("Default-NotificationRules") + .withTags(mapOf()) + .withIdentity(new ManagedServiceIdentity().withType(ManagedServiceIdentityType.USER_ASSIGNED) + .withUserAssignedIdentities(mapOf( + "/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/AzSecPackAutoConfigRG/providers/Microsoft.ManagedIdentity/userAssignedIdentities/ThomasTestManagedIdentity_123", + new UserAssignedIdentity(), + "/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/AzSecPackAutoConfigRG/providers/Microsoft.ManagedIdentity/userAssignedIdentities/ThomasTestManagedIdentity_456", + new UserAssignedIdentity()))) + .withGroupShortName("sample") + .withEnabled(true) + .withEmailReceivers(Arrays.asList( + new EmailReceiver().withName("John Doe's email") + .withEmailAddress("johndoe@email.com") + .withUseCommonAlertSchema(false), + new EmailReceiver().withName("Jane Smith's email") + .withEmailAddress("janesmith@email.com") + .withUseCommonAlertSchema(true))) + .withSmsReceivers(Arrays.asList( + new SmsReceiver().withName("John Doe's mobile") + .withCountryCode("fakeTokenPlaceholder") + .withPhoneNumber("1234567890"), + new SmsReceiver().withName("Jane Smith's mobile") + .withCountryCode("fakeTokenPlaceholder") + .withPhoneNumber("0987654321"))) + .withWebhookReceivers(Arrays.asList( + new WebhookReceiver().withName("Sample webhook 1") + .withServiceUri("http://www.example.com/webhook1") + .withUseCommonAlertSchema(true), + new WebhookReceiver().withName("Sample webhook 2") + .withServiceUri("http://www.example.com/webhook2") + .withUseCommonAlertSchema(true) + .withUseAadAuth(true) + .withObjectId("d3bb868c-fe44-452c-aa26-769a6538c808") + .withIdentifierUri("http://someidentifier/d7811ba3-7996-4a93-99b6-6b2f3f355f8a") + .withTenantId("68a4459a-ccb8-493c-b9da-dd30457d1b84") + .withManagedIdentity("30fe7a91-cd31-4edf-96ab-52883b3199cd"))) + .withItsmReceivers(Arrays.asList(new ItsmReceiver().withName("Sample itsm") + .withWorkspaceId("5def922a-3ed4-49c1-b9fd-05ec533819a3|55dfd1f8-7e59-4f89-bf56-4c82f5ace23c") + .withConnectionId("a3b9076c-ce8e-434e-85b4-aff10cb3c8f1") + .withTicketConfiguration( + "{\"PayloadRevision\":0,\"WorkItemType\":\"Incident\",\"UseTemplate\":false,\"WorkItemData\":\"{}\",\"CreateOneWIPerCI\":false}") + .withRegion("westcentralus"))) + .withAzureAppPushReceivers(Arrays.asList( + new AzureAppPushReceiver().withName("Sample azureAppPush").withEmailAddress("johndoe@email.com"))) + .withAutomationRunbookReceivers(Arrays.asList(new AutomationRunbookReceiver().withAutomationAccountId( + "/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/runbookTest/providers/Microsoft.Automation/automationAccounts/runbooktest") + .withRunbookName("Sample runbook") + .withWebhookResourceId( + "/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/runbookTest/providers/Microsoft.Automation/automationAccounts/runbooktest/webhooks/Alert1510184037084") + .withIsGlobalRunbook(false) + .withName("testRunbook") + .withServiceUri("") + .withUseCommonAlertSchema(true) + .withManagedIdentity("30fe7a91-cd31-4edf-96ab-52883b3199cd"))) + .withVoiceReceivers(Arrays.asList(new VoiceReceiver().withName("Sample voice") + .withCountryCode("fakeTokenPlaceholder") + .withPhoneNumber("1234567890"))) + .withLogicAppReceivers(Arrays.asList(new LogicAppReceiver().withName("Sample logicApp") + .withResourceId( + "/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/LogicApp/providers/Microsoft.Logic/workflows/testLogicApp") + .withCallbackUrl( + "https://prod-27.northcentralus.logic.azure.com/workflows/68e572e818e5457ba898763b7db90877/triggers/manual/paths/invoke/azns/test?api-version=2016-10-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=Abpsb72UYJxPPvmDo937uzofupO5r_vIeWEx7KVHo7w") + .withUseCommonAlertSchema(false) + .withManagedIdentity("30fe7a91-cd31-4edf-96ab-52883b3199cd"))) + .withAzureFunctionReceivers(Arrays.asList(new AzureFunctionReceiver().withName("Sample azureFunction") + .withFunctionAppResourceId( + "/subscriptions/5def922a-3ed4-49c1-b9fd-05ec533819a3/resourceGroups/aznsTest/providers/Microsoft.Web/sites/testFunctionApp") + .withFunctionName("HttpTriggerCSharp1") + .withHttpTriggerUrl("http://test.me") + .withUseCommonAlertSchema(true) + .withManagedIdentity("30fe7a91-cd31-4edf-96ab-52883b3199cd"))) + .withArmRoleReceivers(Arrays.asList(new ArmRoleReceiver().withName("Sample armRole") + .withRoleId("8e3af657-a8ff-443c-a75c-2fe8c4bcb635") + .withUseCommonAlertSchema(true))) + .withEventHubReceivers(Arrays.asList(new EventHubReceiver().withName("Sample eventHub") + .withEventHubNameSpace("testEventHubNameSpace") + .withEventHubName("testEventHub") + .withTenantId("68a4459a-ccb8-493c-b9da-dd30457d1b84") + .withSubscriptionId("187f412d-1758-44d9-b052-169e2564721d") + .withManagedIdentity("30fe7a91-cd31-4edf-96ab-52883b3199cd"))) + .withIncidentReceivers(Arrays.asList(new IncidentReceiver().withName("IncidentAction") + .withConnection(new IncidentServiceConnection().withName("IncidentConnection") + .withId("8be638e7-1419-42d4-a059-437a5f4f4e4e")) + .withIncidentManagementService(IncidentManagementService.ICM) + .withMappings(mapOf("icm.automitigationenabled", "true", "icm.correlationid", + "${data.essentials.signalType}://${data.essentials.originAlertId}", "icm.monitorid", + "${data.essentials.alertRule}", "icm.occurringlocation.environment", "PROD", "icm.routingid", + "${data.essentials.monitoringService}://${data.essentials.signalType}", "icm.title", + "${data.essentials.severity}:${data.essentials.monitorCondition} ${data.essentials.monitoringService}:${data.essentials.signalType} ${data.essentials.alertTargetIds}", + "icm.tsgid", "https://microsoft.com")))) + .create(); + } + + // Use "Map.of" if available + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} +``` + +### ActionGroups_Delete + +```java +/** + * Samples for ActionGroups Delete. + */ +public final class ActionGroupsDeleteSamples { + /* + * x-ms-original-file: + * specification/monitor/resource-manager/Microsoft.Insights/preview/2024-10-01-preview/examples/deleteActionGroup. + * json + */ + /** + * Sample code: Delete an action group. + * + * @param manager Entry point to MonitorManager. + */ + public static void deleteAnActionGroup(com.azure.resourcemanager.monitor.generated.MonitorManager manager) { + manager.actionGroups() + .deleteByResourceGroupWithResponse("Default-NotificationRules", "SampleActionGroup", + com.azure.core.util.Context.NONE); + } +} +``` + +### ActionGroups_EnableReceiver + +```java +import com.azure.resourcemanager.monitor.generated.models.EnableRequest; + +/** + * Samples for ActionGroups EnableReceiver. + */ +public final class ActionGroupsEnableReceiverSamples { + /* + * x-ms-original-file: + * specification/monitor/resource-manager/Microsoft.Insights/preview/2024-10-01-preview/examples/enableReceiver.json + */ + /** + * Sample code: Enable the receiver. + * + * @param manager Entry point to MonitorManager. + */ + public static void enableTheReceiver(com.azure.resourcemanager.monitor.generated.MonitorManager manager) { + manager.actionGroups() + .enableReceiverWithResponse("Default-NotificationRules", "SampleActionGroup", + new EnableRequest().withReceiverName("John Doe's mobile"), com.azure.core.util.Context.NONE); + } +} +``` + +### ActionGroups_GetByResourceGroup + +```java +/** + * Samples for ActionGroups GetByResourceGroup. + */ +public final class ActionGroupsGetByResourceGroupSamples { + /* + * x-ms-original-file: + * specification/monitor/resource-manager/Microsoft.Insights/preview/2024-10-01-preview/examples/getActionGroup.json + */ + /** + * Sample code: Get an action group. + * + * @param manager Entry point to MonitorManager. + */ + public static void getAnActionGroup(com.azure.resourcemanager.monitor.generated.MonitorManager manager) { + manager.actionGroups() + .getByResourceGroupWithResponse("Default-NotificationRules", "SampleActionGroup", + com.azure.core.util.Context.NONE); + } +} +``` + +### ActionGroups_GetTestNotificationsAtActionGroupResourceLevel + +```java +/** + * Samples for ActionGroups GetTestNotificationsAtActionGroupResourceLevel. + */ +public final class ActionGroupsGetTestNotificationsAtActionGroupResourceLevelSamples { + /* + * x-ms-original-file: + * specification/monitor/resource-manager/Microsoft.Insights/preview/2024-10-01-preview/examples/ + * getTestNotificationsAtActionGroupResourceLevel.json + */ + /** + * Sample code: Get notification details at resource group level. + * + * @param manager Entry point to MonitorManager. + */ + public static void + getNotificationDetailsAtResourceGroupLevel(com.azure.resourcemanager.monitor.generated.MonitorManager manager) { + manager.actionGroups() + .getTestNotificationsAtActionGroupResourceLevelWithResponse("TestRgName", "TestAgName", "11000222191287", + com.azure.core.util.Context.NONE); + } +} +``` + +### ActionGroups_List + +```java +/** + * Samples for ActionGroups List. + */ +public final class ActionGroupsListSamples { + /* + * x-ms-original-file: + * specification/monitor/resource-manager/Microsoft.Insights/preview/2024-10-01-preview/examples/listActionGroups. + * json + */ + /** + * Sample code: List action groups at subscription level. + * + * @param manager Entry point to MonitorManager. + */ + public static void + listActionGroupsAtSubscriptionLevel(com.azure.resourcemanager.monitor.generated.MonitorManager manager) { + manager.actionGroups().list(com.azure.core.util.Context.NONE); + } +} +``` + +### ActionGroups_ListByResourceGroup + +```java +/** + * Samples for ActionGroups ListByResourceGroup. + */ +public final class ActionGroupsListByResourceGroupSamples { + /* + * x-ms-original-file: + * specification/monitor/resource-manager/Microsoft.Insights/preview/2024-10-01-preview/examples/listActionGroups. + * json + */ + /** + * Sample code: List action groups at resource group level. + * + * @param manager Entry point to MonitorManager. + */ + public static void + listActionGroupsAtResourceGroupLevel(com.azure.resourcemanager.monitor.generated.MonitorManager manager) { + manager.actionGroups().listByResourceGroup("Default-NotificationRules", com.azure.core.util.Context.NONE); + } +} +``` + +### ActionGroups_Update + +```java +import com.azure.resourcemanager.monitor.generated.models.ActionGroupResource; +import com.azure.resourcemanager.monitor.generated.models.ManagedServiceIdentity; +import com.azure.resourcemanager.monitor.generated.models.ManagedServiceIdentityType; +import java.util.HashMap; +import java.util.Map; + +/** + * Samples for ActionGroups Update. + */ +public final class ActionGroupsUpdateSamples { + /* + * x-ms-original-file: + * specification/monitor/resource-manager/Microsoft.Insights/preview/2024-10-01-preview/examples/patchActionGroup. + * json + */ + /** + * Sample code: Patch an action group. + * + * @param manager Entry point to MonitorManager. + */ + public static void patchAnActionGroup(com.azure.resourcemanager.monitor.generated.MonitorManager manager) { + ActionGroupResource resource = manager.actionGroups() + .getByResourceGroupWithResponse("Default-NotificationRules", "SampleActionGroup", + com.azure.core.util.Context.NONE) + .getValue(); + resource.update() + .withTags(mapOf("key1", "fakeTokenPlaceholder", "key2", "fakeTokenPlaceholder")) + .withIdentity(new ManagedServiceIdentity().withType(ManagedServiceIdentityType.SYSTEM_ASSIGNED)) + .withEnabled(false) + .apply(); + } + + // Use "Map.of" if available + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} +``` + +### ScheduledQueryRules_CreateOrUpdate + +```java +import com.azure.resourcemanager.monitor.generated.models.Actions; +import com.azure.resourcemanager.monitor.generated.models.AlertSeverity; +import com.azure.resourcemanager.monitor.generated.models.Condition; +import com.azure.resourcemanager.monitor.generated.models.ConditionFailingPeriods; +import com.azure.resourcemanager.monitor.generated.models.ConditionOperator; +import com.azure.resourcemanager.monitor.generated.models.Dimension; +import com.azure.resourcemanager.monitor.generated.models.DimensionOperator; +import com.azure.resourcemanager.monitor.generated.models.RuleResolveConfiguration; +import com.azure.resourcemanager.monitor.generated.models.ScheduledQueryRuleCriteria; +import com.azure.resourcemanager.monitor.generated.models.TimeAggregation; +import java.time.Duration; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; + +/** + * Samples for ScheduledQueryRules CreateOrUpdate. + */ +public final class ScheduledQueryRulesCreateOrUpdateSamples { + /* + * x-ms-original-file: + * specification/monitor/resource-manager/Microsoft.Insights/preview/2024-01-01-preview/examples/ + * createOrUpdateScheduledQueryRuleSubscription.json + */ + /** + * Sample code: Create or update a scheduled query rule on Subscription. + * + * @param manager Entry point to MonitorManager. + */ + public static void createOrUpdateAScheduledQueryRuleOnSubscription( + com.azure.resourcemanager.monitor.generated.MonitorManager manager) { + manager.scheduledQueryRules() + .define("perf") + .withRegion("eastus") + .withExistingResourceGroup("QueryResourceGroupName") + .withDescription("Performance rule") + .withSeverity(AlertSeverity.FOUR) + .withEnabled(true) + .withScopes(Arrays.asList("/subscriptions/aaf177ed-1330-a9f2-80ea-fd3d7783b147")) + .withEvaluationFrequency(Duration.parse("PT5M")) + .withWindowSize(Duration.parse("PT10M")) + .withTargetResourceTypes(Arrays.asList("Microsoft.Compute/virtualMachines")) + .withCriteria(new ScheduledQueryRuleCriteria() + .withAllOf(Arrays.asList(new Condition().withQuery("Perf | where ObjectName == \"Processor\"") + .withTimeAggregation(TimeAggregation.AVERAGE) + .withMetricMeasureColumn("% Processor Time") + .withResourceIdColumn("resourceId") + .withDimensions(Arrays.asList( + new Dimension().withName("ComputerIp") + .withOperator(DimensionOperator.EXCLUDE) + .withValues(Arrays.asList("192.168.1.1")), + new Dimension().withName("OSType") + .withOperator(DimensionOperator.INCLUDE) + .withValues(Arrays.asList("*")))) + .withOperator(ConditionOperator.GREATER_THAN) + .withThreshold(70.0D) + .withFailingPeriods(new ConditionFailingPeriods().withNumberOfEvaluationPeriods(1L) + .withMinFailingPeriodsToAlert(1L))))) + .withMuteActionsDuration(Duration.parse("PT30M")) + .withActions(new Actions().withActionGroups(Arrays.asList( + "/subscriptions/1cf177ed-1330-4692-80ea-fd3d7783b147/resourcegroups/sqrapi/providers/microsoft.insights/actiongroups/myactiongroup")) + .withCustomProperties(mapOf("key11", "fakeTokenPlaceholder", "key12", "fakeTokenPlaceholder")) + .withActionProperties(mapOf("Icm.Title", "Custom title in ICM", "Icm.TsgId", "https://tsg.url"))) + .withCheckWorkspaceAlertsStorageConfigured(true) + .withSkipQueryValidation(true) + .withResolveConfiguration( + new RuleResolveConfiguration().withAutoResolved(true).withTimeToResolve(Duration.parse("PT10M"))) + .create(); + } + + /* + * x-ms-original-file: + * specification/monitor/resource-manager/Microsoft.Insights/preview/2024-01-01-preview/examples/ + * createOrUpdateScheduledQueryRuleResourceGroup.json + */ + /** + * Sample code: Create or update a scheduled query rule on Resource group(s). + * + * @param manager Entry point to MonitorManager. + */ + public static void createOrUpdateAScheduledQueryRuleOnResourceGroupS( + com.azure.resourcemanager.monitor.generated.MonitorManager manager) { + manager.scheduledQueryRules() + .define("heartbeat") + .withRegion("eastus") + .withExistingResourceGroup("QueryResourceGroupName") + .withDescription("Health check rule") + .withSeverity(AlertSeverity.FOUR) + .withEnabled(true) + .withScopes( + Arrays.asList("/subscriptions/aaf177ed-1330-a9f2-80ea-fd3d7783b147/resourceGroups/scopeResourceGroup1")) + .withEvaluationFrequency(Duration.parse("PT5M")) + .withWindowSize(Duration.parse("PT10M")) + .withTargetResourceTypes(Arrays.asList("Microsoft.Compute/virtualMachines")) + .withCriteria( + new ScheduledQueryRuleCriteria().withAllOf(Arrays.asList(new Condition().withQuery("Heartbeat") + .withTimeAggregation(TimeAggregation.COUNT) + .withDimensions(Arrays.asList()) + .withOperator(ConditionOperator.GREATER_THAN) + .withThreshold(360.0D) + .withFailingPeriods(new ConditionFailingPeriods().withNumberOfEvaluationPeriods(1L) + .withMinFailingPeriodsToAlert(1L))))) + .withMuteActionsDuration(Duration.parse("PT30M")) + .withActions(new Actions().withActionGroups(Arrays.asList( + "/subscriptions/1cf177ed-1330-4692-80ea-fd3d7783b147/resourcegroups/sqrapi/providers/microsoft.insights/actiongroups/myactiongroup")) + .withCustomProperties(mapOf("key11", "fakeTokenPlaceholder", "key12", "fakeTokenPlaceholder")) + .withActionProperties(mapOf("Icm.Title", "Custom title in ICM", "Icm.TsgId", "https://tsg.url"))) + .withCheckWorkspaceAlertsStorageConfigured(true) + .withSkipQueryValidation(true) + .withResolveConfiguration( + new RuleResolveConfiguration().withAutoResolved(true).withTimeToResolve(Duration.parse("PT10M"))) + .create(); + } + + /* + * x-ms-original-file: + * specification/monitor/resource-manager/Microsoft.Insights/preview/2024-01-01-preview/examples/ + * createOrUpdateScheduledQueryRule.json + */ + /** + * Sample code: Create or update a scheduled query rule for Single Resource. + * + * @param manager Entry point to MonitorManager. + */ + public static void createOrUpdateAScheduledQueryRuleForSingleResource( + com.azure.resourcemanager.monitor.generated.MonitorManager manager) { + manager.scheduledQueryRules() + .define("perf") + .withRegion("eastus") + .withExistingResourceGroup("QueryResourceGroupName") + .withDescription("Performance rule") + .withSeverity(AlertSeverity.FOUR) + .withEnabled(true) + .withScopes(Arrays.asList( + "/subscriptions/aaf177ed-1330-a9f2-80ea-fd3d7783b147/resourceGroups/scopeResourceGroup1/providers/Microsoft.Compute/virtualMachines/vm1")) + .withEvaluationFrequency(Duration.parse("PT5M")) + .withWindowSize(Duration.parse("PT10M")) + .withCriteria(new ScheduledQueryRuleCriteria() + .withAllOf(Arrays.asList(new Condition().withQuery("Perf | where ObjectName == \"Processor\"") + .withTimeAggregation(TimeAggregation.AVERAGE) + .withMetricMeasureColumn("% Processor Time") + .withResourceIdColumn("resourceId") + .withDimensions(Arrays.asList( + new Dimension().withName("ComputerIp") + .withOperator(DimensionOperator.EXCLUDE) + .withValues(Arrays.asList("192.168.1.1")), + new Dimension().withName("OSType") + .withOperator(DimensionOperator.INCLUDE) + .withValues(Arrays.asList("*")))) + .withOperator(ConditionOperator.GREATER_THAN) + .withThreshold(70.0D) + .withFailingPeriods(new ConditionFailingPeriods().withNumberOfEvaluationPeriods(1L) + .withMinFailingPeriodsToAlert(1L))))) + .withMuteActionsDuration(Duration.parse("PT30M")) + .withActions(new Actions().withActionGroups(Arrays.asList( + "/subscriptions/1cf177ed-1330-4692-80ea-fd3d7783b147/resourcegroups/sqrapi/providers/microsoft.insights/actiongroups/myactiongroup")) + .withCustomProperties(mapOf("key11", "fakeTokenPlaceholder", "key12", "fakeTokenPlaceholder")) + .withActionProperties(mapOf("Icm.Title", "Custom title in ICM", "Icm.TsgId", "https://tsg.url"))) + .withCheckWorkspaceAlertsStorageConfigured(true) + .withSkipQueryValidation(true) + .withResolveConfiguration( + new RuleResolveConfiguration().withAutoResolved(true).withTimeToResolve(Duration.parse("PT10M"))) + .create(); + } + + // Use "Map.of" if available + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} +``` + +### ScheduledQueryRules_Delete + +```java +/** + * Samples for ScheduledQueryRules Delete. + */ +public final class ScheduledQueryRulesDeleteSamples { + /* + * x-ms-original-file: + * specification/monitor/resource-manager/Microsoft.Insights/preview/2024-01-01-preview/examples/ + * deleteScheduledQueryRule.json + */ + /** + * Sample code: Delete a scheduled query rule. + * + * @param manager Entry point to MonitorManager. + */ + public static void deleteAScheduledQueryRule(com.azure.resourcemanager.monitor.generated.MonitorManager manager) { + manager.scheduledQueryRules() + .deleteByResourceGroupWithResponse("QueryResourceGroupName", "heartbeat", com.azure.core.util.Context.NONE); + } +} +``` + +### ScheduledQueryRules_GetByResourceGroup + +```java +/** + * Samples for ScheduledQueryRules GetByResourceGroup. + */ +public final class ScheduledQueryRulesGetByResourceGroupSamples { + /* + * x-ms-original-file: + * specification/monitor/resource-manager/Microsoft.Insights/preview/2024-01-01-preview/examples/ + * getScheduledQueryRule.json + */ + /** + * Sample code: Get a scheduled query rule for single resource. + * + * @param manager Entry point to MonitorManager. + */ + public static void + getAScheduledQueryRuleForSingleResource(com.azure.resourcemanager.monitor.generated.MonitorManager manager) { + manager.scheduledQueryRules() + .getByResourceGroupWithResponse("QueryResourceGroupName", "perf", com.azure.core.util.Context.NONE); + } +} +``` + +### ScheduledQueryRules_List + +```java +/** + * Samples for ScheduledQueryRules List. + */ +public final class ScheduledQueryRulesListSamples { + /* + * x-ms-original-file: + * specification/monitor/resource-manager/Microsoft.Insights/preview/2024-01-01-preview/examples/ + * listScheduledQueryRulesBySubscription.json + */ + /** + * Sample code: List scheduled query rules by subscription. + * + * @param manager Entry point to MonitorManager. + */ + public static void + listScheduledQueryRulesBySubscription(com.azure.resourcemanager.monitor.generated.MonitorManager manager) { + manager.scheduledQueryRules().list(com.azure.core.util.Context.NONE); + } +} +``` + +### ScheduledQueryRules_ListByResourceGroup + +```java +/** + * Samples for ScheduledQueryRules ListByResourceGroup. + */ +public final class ScheduledQueryRulesListByResourceGroupSamples { + /* + * x-ms-original-file: + * specification/monitor/resource-manager/Microsoft.Insights/preview/2024-01-01-preview/examples/ + * listScheduledQueryRulesByResourceGroup.json + */ + /** + * Sample code: List scheduled query rules by resource group. + * + * @param manager Entry point to MonitorManager. + */ + public static void + listScheduledQueryRulesByResourceGroup(com.azure.resourcemanager.monitor.generated.MonitorManager manager) { + manager.scheduledQueryRules().listByResourceGroup("QueryResourceGroupName", com.azure.core.util.Context.NONE); + } +} +``` + +### ScheduledQueryRules_Update + +```java +import com.azure.resourcemanager.monitor.generated.models.ScheduledQueryRuleResource; + +/** + * Samples for ScheduledQueryRules Update. + */ +public final class ScheduledQueryRulesUpdateSamples { + /* + * x-ms-original-file: + * specification/monitor/resource-manager/Microsoft.Insights/preview/2024-01-01-preview/examples/ + * patchScheduledQueryRule.json + */ + /** + * Sample code: Create or update a scheduled query rule. + * + * @param manager Entry point to MonitorManager. + */ + public static void + createOrUpdateAScheduledQueryRule(com.azure.resourcemanager.monitor.generated.MonitorManager manager) { + ScheduledQueryRuleResource resource = manager.scheduledQueryRules() + .getByResourceGroupWithResponse("QueryResourceGroupName", "heartbeat", com.azure.core.util.Context.NONE) + .getValue(); + resource.update().withEnabled(false).apply(); + } +} +``` + diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/pom.xml b/sdk/monitor/azure-resourcemanager-monitor-generated/pom.xml new file mode 100644 index 0000000000000..262fdaeaaf750 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/pom.xml @@ -0,0 +1,63 @@ + + + 4.0.0 + + com.azure + azure-client-sdk-parent + 1.7.0 + ../../parents/azure-client-sdk-parent + + + com.azure.resourcemanager + azure-resourcemanager-monitor-generated + 1.0.0-beta.1 + jar + + Microsoft Azure SDK for Monitor Management + This package contains Microsoft Azure SDK for Monitor Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. Monitor Management Client. Package tag package-preview-2024-10. + https://github.com/Azure/azure-sdk-for-java + + + + The MIT License (MIT) + http://opensource.org/licenses/MIT + repo + + + + + https://github.com/Azure/azure-sdk-for-java + scm:git:git@github.com:Azure/azure-sdk-for-java.git + scm:git:git@github.com:Azure/azure-sdk-for-java.git + HEAD + + + + microsoft + Microsoft + + + + UTF-8 + 0 + 0 + true + false + + + + com.azure + azure-core + 1.54.1 + + + com.azure + azure-core-management + 1.15.6 + + + 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..4d1d75fd6d240 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/MonitorManager.java @@ -0,0 +1,291 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.monitor.generated; + +import com.azure.core.credential.TokenCredential; +import com.azure.core.http.HttpClient; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpPipelineBuilder; +import com.azure.core.http.HttpPipelinePosition; +import com.azure.core.http.policy.AddDatePolicy; +import com.azure.core.http.policy.AddHeadersFromContextPolicy; +import com.azure.core.http.policy.BearerTokenAuthenticationPolicy; +import com.azure.core.http.policy.HttpLogOptions; +import com.azure.core.http.policy.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpPipelinePolicy; +import com.azure.core.http.policy.HttpPolicyProviders; +import com.azure.core.http.policy.RequestIdPolicy; +import com.azure.core.http.policy.RetryOptions; +import com.azure.core.http.policy.RetryPolicy; +import com.azure.core.http.policy.UserAgentPolicy; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.util.Configuration; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.monitor.generated.fluent.MonitorClient; +import com.azure.resourcemanager.monitor.generated.implementation.ActionGroupsImpl; +import com.azure.resourcemanager.monitor.generated.implementation.MonitorClientBuilder; +import com.azure.resourcemanager.monitor.generated.implementation.ScheduledQueryRulesImpl; +import com.azure.resourcemanager.monitor.generated.models.ActionGroups; +import com.azure.resourcemanager.monitor.generated.models.ScheduledQueryRules; +import java.time.Duration; +import java.time.temporal.ChronoUnit; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; + +/** + * Entry point to MonitorManager. + * Monitor Management Client. + */ +public final class MonitorManager { + private ActionGroups actionGroups; + + private ScheduledQueryRules scheduledQueryRules; + + private final MonitorClient clientObject; + + private MonitorManager(HttpPipeline httpPipeline, AzureProfile profile, Duration defaultPollInterval) { + Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + this.clientObject = new MonitorClientBuilder().pipeline(httpPipeline) + .endpoint(profile.getEnvironment().getResourceManagerEndpoint()) + .subscriptionId(profile.getSubscriptionId()) + .defaultPollInterval(defaultPollInterval) + .buildClient(); + } + + /** + * Creates an instance of Monitor service API entry point. + * + * @param credential the credential to use. + * @param profile the Azure profile for client. + * @return the Monitor service API instance. + */ + public static MonitorManager authenticate(TokenCredential credential, AzureProfile profile) { + Objects.requireNonNull(credential, "'credential' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + return configure().authenticate(credential, profile); + } + + /** + * Creates an instance of Monitor service API entry point. + * + * @param httpPipeline the {@link HttpPipeline} configured with Azure authentication credential. + * @param profile the Azure profile for client. + * @return the Monitor service API instance. + */ + public static MonitorManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) { + Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + return new MonitorManager(httpPipeline, profile, null); + } + + /** + * 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 static final ClientLogger LOGGER = new ClientLogger(Configurable.class); + + private HttpClient httpClient; + private HttpLogOptions httpLogOptions; + private final List policies = new ArrayList<>(); + private final List scopes = new ArrayList<>(); + private RetryPolicy retryPolicy; + private RetryOptions retryOptions; + private Duration defaultPollInterval; + + private Configurable() { + } + + /** + * Sets the http client. + * + * @param httpClient the HTTP client. + * @return the configurable object itself. + */ + public Configurable withHttpClient(HttpClient httpClient) { + this.httpClient = Objects.requireNonNull(httpClient, "'httpClient' cannot be null."); + return this; + } + + /** + * Sets the logging options to the HTTP pipeline. + * + * @param httpLogOptions the HTTP log options. + * @return the configurable object itself. + */ + public Configurable withLogOptions(HttpLogOptions httpLogOptions) { + this.httpLogOptions = Objects.requireNonNull(httpLogOptions, "'httpLogOptions' cannot be null."); + return this; + } + + /** + * Adds the pipeline policy to the HTTP pipeline. + * + * @param policy the HTTP pipeline policy. + * @return the configurable object itself. + */ + public Configurable withPolicy(HttpPipelinePolicy policy) { + this.policies.add(Objects.requireNonNull(policy, "'policy' cannot be null.")); + return this; + } + + /** + * Adds the scope to permission sets. + * + * @param scope the scope. + * @return the configurable object itself. + */ + public Configurable withScope(String scope) { + this.scopes.add(Objects.requireNonNull(scope, "'scope' cannot be null.")); + return this; + } + + /** + * Sets the retry policy to the HTTP pipeline. + * + * @param retryPolicy the HTTP pipeline retry policy. + * @return the configurable object itself. + */ + public Configurable withRetryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = Objects.requireNonNull(retryPolicy, "'retryPolicy' cannot be null."); + return this; + } + + /** + * Sets the retry options for the HTTP pipeline retry policy. + *

+ * This setting has no effect, if retry policy is set via {@link #withRetryPolicy(RetryPolicy)}. + * + * @param retryOptions the retry options for the HTTP pipeline retry policy. + * @return the configurable object itself. + */ + public Configurable withRetryOptions(RetryOptions retryOptions) { + this.retryOptions = Objects.requireNonNull(retryOptions, "'retryOptions' cannot be null."); + return this; + } + + /** + * Sets the default poll interval, used when service does not provide "Retry-After" header. + * + * @param defaultPollInterval the default poll interval. + * @return the configurable object itself. + */ + public Configurable withDefaultPollInterval(Duration defaultPollInterval) { + this.defaultPollInterval + = Objects.requireNonNull(defaultPollInterval, "'defaultPollInterval' cannot be null."); + if (this.defaultPollInterval.isNegative()) { + throw LOGGER + .logExceptionAsError(new IllegalArgumentException("'defaultPollInterval' cannot be negative")); + } + return this; + } + + /** + * Creates an instance of Monitor service API entry point. + * + * @param credential the credential to use. + * @param profile the Azure profile for client. + * @return the Monitor service API instance. + */ + public MonitorManager authenticate(TokenCredential credential, AzureProfile profile) { + Objects.requireNonNull(credential, "'credential' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + + StringBuilder userAgentBuilder = new StringBuilder(); + userAgentBuilder.append("azsdk-java") + .append("-") + .append("com.azure.resourcemanager.monitor.generated") + .append("/") + .append("1.0.0-beta.1"); + if (!Configuration.getGlobalConfiguration().get("AZURE_TELEMETRY_DISABLED", false)) { + userAgentBuilder.append(" (") + .append(Configuration.getGlobalConfiguration().get("java.version")) + .append("; ") + .append(Configuration.getGlobalConfiguration().get("os.name")) + .append("; ") + .append(Configuration.getGlobalConfiguration().get("os.version")) + .append("; auto-generated)"); + } else { + userAgentBuilder.append(" (auto-generated)"); + } + + if (scopes.isEmpty()) { + scopes.add(profile.getEnvironment().getManagementEndpoint() + "/.default"); + } + if (retryPolicy == null) { + if (retryOptions != null) { + retryPolicy = new RetryPolicy(retryOptions); + } else { + retryPolicy = new RetryPolicy("Retry-After", ChronoUnit.SECONDS); + } + } + List policies = new ArrayList<>(); + policies.add(new UserAgentPolicy(userAgentBuilder.toString())); + policies.add(new AddHeadersFromContextPolicy()); + policies.add(new RequestIdPolicy()); + policies.addAll(this.policies.stream() + .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_CALL) + .collect(Collectors.toList())); + HttpPolicyProviders.addBeforeRetryPolicies(policies); + policies.add(retryPolicy); + policies.add(new AddDatePolicy()); + policies.add(new BearerTokenAuthenticationPolicy(credential, scopes.toArray(new String[0]))); + policies.addAll(this.policies.stream() + .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_RETRY) + .collect(Collectors.toList())); + HttpPolicyProviders.addAfterRetryPolicies(policies); + policies.add(new HttpLoggingPolicy(httpLogOptions)); + HttpPipeline httpPipeline = new HttpPipelineBuilder().httpClient(httpClient) + .policies(policies.toArray(new HttpPipelinePolicy[0])) + .build(); + return new MonitorManager(httpPipeline, profile, defaultPollInterval); + } + } + + /** + * Gets the resource collection API of ActionGroups. It manages ActionGroupResource. + * + * @return Resource collection API of ActionGroups. + */ + public ActionGroups actionGroups() { + if (this.actionGroups == null) { + this.actionGroups = new ActionGroupsImpl(clientObject.getActionGroups(), this); + } + return actionGroups; + } + + /** + * Gets the resource collection API of ScheduledQueryRules. It manages ScheduledQueryRuleResource. + * + * @return Resource collection API of ScheduledQueryRules. + */ + public ScheduledQueryRules scheduledQueryRules() { + if (this.scheduledQueryRules == null) { + this.scheduledQueryRules = new ScheduledQueryRulesImpl(clientObject.getScheduledQueryRules(), this); + } + return scheduledQueryRules; + } + + /** + * Gets wrapped service client MonitorClient providing direct access to the underlying auto-generated API + * implementation, based on Azure REST API. + * + * @return Wrapped service client MonitorClient. + */ + public MonitorClient serviceClient() { + return this.clientObject; + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/fluent/ActionGroupsClient.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/fluent/ActionGroupsClient.java new file mode 100644 index 0000000000000..3dbee19a9503b --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/fluent/ActionGroupsClient.java @@ -0,0 +1,316 @@ +// 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.management.polling.PollResult; +import com.azure.core.util.Context; +import com.azure.core.util.polling.SyncPoller; +import com.azure.resourcemanager.monitor.generated.fluent.models.ActionGroupResourceInner; +import com.azure.resourcemanager.monitor.generated.fluent.models.TestNotificationDetailsResponseInner; +import com.azure.resourcemanager.monitor.generated.models.ActionGroupPatchBody; +import com.azure.resourcemanager.monitor.generated.models.EnableRequest; +import com.azure.resourcemanager.monitor.generated.models.NotificationRequestBody; + +/** + * An instance of this class provides access to all the operations defined in ActionGroupsClient. + */ +public interface ActionGroupsClient { + /** + * Create a new action group or update an existing one. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param actionGroupName The name of the action group. + * @param actionGroup The action group 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 action group resource along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response createOrUpdateWithResponse(String resourceGroupName, String actionGroupName, + ActionGroupResourceInner actionGroup, Context context); + + /** + * Create a new action group or update an existing one. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param actionGroupName The name of the action group. + * @param actionGroup The action group 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 action group resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + ActionGroupResourceInner createOrUpdate(String resourceGroupName, String actionGroupName, + ActionGroupResourceInner actionGroup); + + /** + * Get an action group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param actionGroupName The name of the action group. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an action group along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response getByResourceGroupWithResponse(String resourceGroupName, String actionGroupName, + Context context); + + /** + * Get an action group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param actionGroupName The name of the action group. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an action group. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + ActionGroupResourceInner getByResourceGroup(String resourceGroupName, String actionGroupName); + + /** + * Delete an action group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param actionGroupName The name of the action group. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response deleteWithResponse(String resourceGroupName, String actionGroupName, Context context); + + /** + * Delete an action group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param actionGroupName The name of the action group. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + void delete(String resourceGroupName, String actionGroupName); + + /** + * Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param actionGroupName The name of the action group. + * @param actionGroupPatch 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 action group resource along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response updateWithResponse(String resourceGroupName, String actionGroupName, + ActionGroupPatchBody actionGroupPatch, Context context); + + /** + * Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param actionGroupName The name of the action group. + * @param actionGroupPatch 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 action group resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + ActionGroupResourceInner update(String resourceGroupName, String actionGroupName, + ActionGroupPatchBody actionGroupPatch); + + /** + * Send test notifications to a set of provided receivers. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param actionGroupName The name of the action group. + * @param notificationRequest The notification request body which includes the contact details. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of the details of the test notification results. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, TestNotificationDetailsResponseInner> + beginCreateNotificationsAtActionGroupResourceLevel(String resourceGroupName, String actionGroupName, + NotificationRequestBody notificationRequest); + + /** + * Send test notifications to a set of provided receivers. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param actionGroupName The name of the action group. + * @param notificationRequest The notification request body which includes the contact details. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of the details of the test notification results. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, TestNotificationDetailsResponseInner> + beginCreateNotificationsAtActionGroupResourceLevel(String resourceGroupName, String actionGroupName, + NotificationRequestBody notificationRequest, Context context); + + /** + * Send test notifications to a set of provided receivers. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param actionGroupName The name of the action group. + * @param notificationRequest The notification request body which includes the contact details. + * @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 details of the test notification results. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + TestNotificationDetailsResponseInner createNotificationsAtActionGroupResourceLevel(String resourceGroupName, + String actionGroupName, NotificationRequestBody notificationRequest); + + /** + * Send test notifications to a set of provided receivers. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param actionGroupName The name of the action group. + * @param notificationRequest The notification request body which includes the contact details. + * @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 details of the test notification results. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + TestNotificationDetailsResponseInner createNotificationsAtActionGroupResourceLevel(String resourceGroupName, + String actionGroupName, NotificationRequestBody notificationRequest, Context context); + + /** + * Get the test notifications by the notification id. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param actionGroupName The name of the action group. + * @param notificationId The notification 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 test notifications by the notification id along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response getTestNotificationsAtActionGroupResourceLevelWithResponse( + String resourceGroupName, String actionGroupName, String notificationId, Context context); + + /** + * Get the test notifications by the notification id. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param actionGroupName The name of the action group. + * @param notificationId The notification id. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the test notifications by the notification id. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + TestNotificationDetailsResponseInner getTestNotificationsAtActionGroupResourceLevel(String resourceGroupName, + String actionGroupName, String notificationId); + + /** + * Get a list of all action groups 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 action groups in a subscription as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(); + + /** + * Get a list of all action groups 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 action groups in a subscription as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(Context context); + + /** + * Get a list of all action groups 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 action groups in a resource group as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable listByResourceGroup(String resourceGroupName); + + /** + * Get a list of all action groups 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 action groups in a resource group as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable listByResourceGroup(String resourceGroupName, Context context); + + /** + * Enable a receiver in an action group. This changes the receiver's status from Disabled to Enabled. This operation + * is only supported for Email or SMS receivers. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param actionGroupName The name of the action group. + * @param enableRequest The receiver to re-enable. + * @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 com.azure.core.management.exception.ManagementException thrown if the request is rejected by server on + * status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response enableReceiverWithResponse(String resourceGroupName, String actionGroupName, + EnableRequest enableRequest, Context context); + + /** + * Enable a receiver in an action group. This changes the receiver's status from Disabled to Enabled. This operation + * is only supported for Email or SMS receivers. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param actionGroupName The name of the action group. + * @param enableRequest The receiver to re-enable. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server on + * status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + void enableReceiver(String resourceGroupName, String actionGroupName, EnableRequest enableRequest); +} 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..a3dec4c5b143f --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/fluent/MonitorClient.java @@ -0,0 +1,55 @@ +// 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 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 ActionGroupsClient object to access its operations. + * + * @return the ActionGroupsClient object. + */ + ActionGroupsClient getActionGroups(); + + /** + * Gets the ScheduledQueryRulesClient object to access its operations. + * + * @return the ScheduledQueryRulesClient object. + */ + ScheduledQueryRulesClient getScheduledQueryRules(); +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/fluent/ScheduledQueryRulesClient.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/fluent/ScheduledQueryRulesClient.java new file mode 100644 index 0000000000000..92b13004f8348 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/fluent/ScheduledQueryRulesClient.java @@ -0,0 +1,185 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.monitor.generated.fluent; + +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.Response; +import com.azure.core.util.Context; +import com.azure.resourcemanager.monitor.generated.fluent.models.ScheduledQueryRuleResourceInner; +import com.azure.resourcemanager.monitor.generated.models.ScheduledQueryRuleResourcePatch; + +/** + * An instance of this class provides access to all the operations defined in ScheduledQueryRulesClient. + */ +public interface ScheduledQueryRulesClient { + /** + * Retrieve a scheduled query rule definitions in a subscription. + * + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return represents a collection of scheduled query rule resources as paginated response with + * {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(); + + /** + * Retrieve a scheduled query rule definitions in a subscription. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return represents a collection of scheduled query rule resources as paginated response with + * {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(Context context); + + /** + * Retrieve scheduled query rule definitions in a resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return represents a collection of scheduled query rule resources as paginated response with + * {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable listByResourceGroup(String resourceGroupName); + + /** + * Retrieve scheduled query rule definitions in a resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return represents a collection of scheduled query rule resources as paginated response with + * {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable listByResourceGroup(String resourceGroupName, Context context); + + /** + * Retrieve an scheduled query rule definition. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param ruleName The name of the rule. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the scheduled query rule resource along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response getByResourceGroupWithResponse(String resourceGroupName, String ruleName, + Context context); + + /** + * Retrieve an scheduled query rule definition. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param ruleName The name of the rule. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the scheduled query rule resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + ScheduledQueryRuleResourceInner getByResourceGroup(String resourceGroupName, String ruleName); + + /** + * Creates or updates a scheduled query rule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param ruleName The name of the rule. + * @param parameters The parameters of the rule to create or update. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the scheduled query rule resource along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response createOrUpdateWithResponse(String resourceGroupName, String ruleName, + ScheduledQueryRuleResourceInner parameters, Context context); + + /** + * Creates or updates a scheduled query rule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param ruleName The name of the rule. + * @param parameters The parameters of the rule to create or update. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the scheduled query rule resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + ScheduledQueryRuleResourceInner createOrUpdate(String resourceGroupName, String ruleName, + ScheduledQueryRuleResourceInner parameters); + + /** + * Update a scheduled query rule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param ruleName The name of the rule. + * @param parameters The parameters of the rule to update. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the scheduled query rule resource along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response updateWithResponse(String resourceGroupName, String ruleName, + ScheduledQueryRuleResourcePatch parameters, Context context); + + /** + * Update a scheduled query rule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param ruleName The name of the rule. + * @param parameters The parameters of the rule to update. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the scheduled query rule resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + ScheduledQueryRuleResourceInner update(String resourceGroupName, String ruleName, + ScheduledQueryRuleResourcePatch parameters); + + /** + * Deletes a scheduled query rule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param ruleName The name of the rule. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response deleteWithResponse(String resourceGroupName, String ruleName, Context context); + + /** + * Deletes a scheduled query rule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param ruleName The name of the rule. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + void delete(String resourceGroupName, String ruleName); +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/fluent/models/ActionGroup.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/fluent/models/ActionGroup.java new file mode 100644 index 0000000000000..a8a82f9971278 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/fluent/models/ActionGroup.java @@ -0,0 +1,552 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.monitor.generated.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.azure.resourcemanager.monitor.generated.models.ArmRoleReceiver; +import com.azure.resourcemanager.monitor.generated.models.AutomationRunbookReceiver; +import com.azure.resourcemanager.monitor.generated.models.AzureAppPushReceiver; +import com.azure.resourcemanager.monitor.generated.models.AzureFunctionReceiver; +import com.azure.resourcemanager.monitor.generated.models.EmailReceiver; +import com.azure.resourcemanager.monitor.generated.models.EventHubReceiver; +import com.azure.resourcemanager.monitor.generated.models.IncidentReceiver; +import com.azure.resourcemanager.monitor.generated.models.ItsmReceiver; +import com.azure.resourcemanager.monitor.generated.models.LogicAppReceiver; +import com.azure.resourcemanager.monitor.generated.models.SmsReceiver; +import com.azure.resourcemanager.monitor.generated.models.VoiceReceiver; +import com.azure.resourcemanager.monitor.generated.models.WebhookReceiver; +import java.io.IOException; +import java.util.List; + +/** + * An Azure action group. + */ +@Fluent +public final class ActionGroup implements JsonSerializable { + /* + * The short name of the action group. This will be used in SMS messages. + */ + private String groupShortName; + + /* + * Indicates whether this action group is enabled. If an action group is not enabled, then none of its receivers + * will receive communications. + */ + private boolean enabled; + + /* + * The list of email receivers that are part of this action group. + */ + private List emailReceivers; + + /* + * The list of SMS receivers that are part of this action group. + */ + private List smsReceivers; + + /* + * The list of webhook receivers that are part of this action group. + */ + private List webhookReceivers; + + /* + * The list of ITSM receivers that are part of this action group. + */ + private List itsmReceivers; + + /* + * The list of AzureAppPush receivers that are part of this action group. + */ + private List azureAppPushReceivers; + + /* + * The list of AutomationRunbook receivers that are part of this action group. + */ + private List automationRunbookReceivers; + + /* + * The list of voice receivers that are part of this action group. + */ + private List voiceReceivers; + + /* + * The list of logic app receivers that are part of this action group. + */ + private List logicAppReceivers; + + /* + * The list of azure function receivers that are part of this action group. + */ + private List azureFunctionReceivers; + + /* + * The list of ARM role receivers that are part of this action group. Roles are Azure RBAC roles and only built-in + * roles are supported. + */ + private List armRoleReceivers; + + /* + * The list of event hub receivers that are part of this action group. + */ + private List eventHubReceivers; + + /* + * The list of incident receivers that are part of this action group. + */ + private List incidentReceivers; + + /** + * Creates an instance of ActionGroup class. + */ + public ActionGroup() { + } + + /** + * Get the groupShortName property: The short name of the action group. This will be used in SMS messages. + * + * @return the groupShortName value. + */ + public String groupShortName() { + return this.groupShortName; + } + + /** + * Set the groupShortName property: The short name of the action group. This will be used in SMS messages. + * + * @param groupShortName the groupShortName value to set. + * @return the ActionGroup object itself. + */ + public ActionGroup withGroupShortName(String groupShortName) { + this.groupShortName = groupShortName; + return this; + } + + /** + * Get the enabled property: Indicates whether this action group is enabled. If an action group is not enabled, then + * none of its receivers will receive communications. + * + * @return the enabled value. + */ + public boolean enabled() { + return this.enabled; + } + + /** + * Set the enabled property: Indicates whether this action group is enabled. If an action group is not enabled, then + * none of its receivers will receive communications. + * + * @param enabled the enabled value to set. + * @return the ActionGroup object itself. + */ + public ActionGroup withEnabled(boolean enabled) { + this.enabled = enabled; + return this; + } + + /** + * Get the emailReceivers property: The list of email receivers that are part of this action group. + * + * @return the emailReceivers value. + */ + public List emailReceivers() { + return this.emailReceivers; + } + + /** + * Set the emailReceivers property: The list of email receivers that are part of this action group. + * + * @param emailReceivers the emailReceivers value to set. + * @return the ActionGroup object itself. + */ + public ActionGroup withEmailReceivers(List emailReceivers) { + this.emailReceivers = emailReceivers; + return this; + } + + /** + * Get the smsReceivers property: The list of SMS receivers that are part of this action group. + * + * @return the smsReceivers value. + */ + public List smsReceivers() { + return this.smsReceivers; + } + + /** + * Set the smsReceivers property: The list of SMS receivers that are part of this action group. + * + * @param smsReceivers the smsReceivers value to set. + * @return the ActionGroup object itself. + */ + public ActionGroup withSmsReceivers(List smsReceivers) { + this.smsReceivers = smsReceivers; + return this; + } + + /** + * Get the webhookReceivers property: The list of webhook receivers that are part of this action group. + * + * @return the webhookReceivers value. + */ + public List webhookReceivers() { + return this.webhookReceivers; + } + + /** + * Set the webhookReceivers property: The list of webhook receivers that are part of this action group. + * + * @param webhookReceivers the webhookReceivers value to set. + * @return the ActionGroup object itself. + */ + public ActionGroup withWebhookReceivers(List webhookReceivers) { + this.webhookReceivers = webhookReceivers; + return this; + } + + /** + * Get the itsmReceivers property: The list of ITSM receivers that are part of this action group. + * + * @return the itsmReceivers value. + */ + public List itsmReceivers() { + return this.itsmReceivers; + } + + /** + * Set the itsmReceivers property: The list of ITSM receivers that are part of this action group. + * + * @param itsmReceivers the itsmReceivers value to set. + * @return the ActionGroup object itself. + */ + public ActionGroup withItsmReceivers(List itsmReceivers) { + this.itsmReceivers = itsmReceivers; + return this; + } + + /** + * Get the azureAppPushReceivers property: The list of AzureAppPush receivers that are part of this action group. + * + * @return the azureAppPushReceivers value. + */ + public List azureAppPushReceivers() { + return this.azureAppPushReceivers; + } + + /** + * Set the azureAppPushReceivers property: The list of AzureAppPush receivers that are part of this action group. + * + * @param azureAppPushReceivers the azureAppPushReceivers value to set. + * @return the ActionGroup object itself. + */ + public ActionGroup withAzureAppPushReceivers(List azureAppPushReceivers) { + this.azureAppPushReceivers = azureAppPushReceivers; + return this; + } + + /** + * Get the automationRunbookReceivers property: The list of AutomationRunbook receivers that are part of this action + * group. + * + * @return the automationRunbookReceivers value. + */ + public List automationRunbookReceivers() { + return this.automationRunbookReceivers; + } + + /** + * Set the automationRunbookReceivers property: The list of AutomationRunbook receivers that are part of this action + * group. + * + * @param automationRunbookReceivers the automationRunbookReceivers value to set. + * @return the ActionGroup object itself. + */ + public ActionGroup withAutomationRunbookReceivers(List automationRunbookReceivers) { + this.automationRunbookReceivers = automationRunbookReceivers; + return this; + } + + /** + * Get the voiceReceivers property: The list of voice receivers that are part of this action group. + * + * @return the voiceReceivers value. + */ + public List voiceReceivers() { + return this.voiceReceivers; + } + + /** + * Set the voiceReceivers property: The list of voice receivers that are part of this action group. + * + * @param voiceReceivers the voiceReceivers value to set. + * @return the ActionGroup object itself. + */ + public ActionGroup withVoiceReceivers(List voiceReceivers) { + this.voiceReceivers = voiceReceivers; + return this; + } + + /** + * Get the logicAppReceivers property: The list of logic app receivers that are part of this action group. + * + * @return the logicAppReceivers value. + */ + public List logicAppReceivers() { + return this.logicAppReceivers; + } + + /** + * Set the logicAppReceivers property: The list of logic app receivers that are part of this action group. + * + * @param logicAppReceivers the logicAppReceivers value to set. + * @return the ActionGroup object itself. + */ + public ActionGroup withLogicAppReceivers(List logicAppReceivers) { + this.logicAppReceivers = logicAppReceivers; + return this; + } + + /** + * Get the azureFunctionReceivers property: The list of azure function receivers that are part of this action group. + * + * @return the azureFunctionReceivers value. + */ + public List azureFunctionReceivers() { + return this.azureFunctionReceivers; + } + + /** + * Set the azureFunctionReceivers property: The list of azure function receivers that are part of this action group. + * + * @param azureFunctionReceivers the azureFunctionReceivers value to set. + * @return the ActionGroup object itself. + */ + public ActionGroup withAzureFunctionReceivers(List azureFunctionReceivers) { + this.azureFunctionReceivers = azureFunctionReceivers; + return this; + } + + /** + * Get the armRoleReceivers property: The list of ARM role receivers that are part of this action group. Roles are + * Azure RBAC roles and only built-in roles are supported. + * + * @return the armRoleReceivers value. + */ + public List armRoleReceivers() { + return this.armRoleReceivers; + } + + /** + * Set the armRoleReceivers property: The list of ARM role receivers that are part of this action group. Roles are + * Azure RBAC roles and only built-in roles are supported. + * + * @param armRoleReceivers the armRoleReceivers value to set. + * @return the ActionGroup object itself. + */ + public ActionGroup withArmRoleReceivers(List armRoleReceivers) { + this.armRoleReceivers = armRoleReceivers; + return this; + } + + /** + * Get the eventHubReceivers property: The list of event hub receivers that are part of this action group. + * + * @return the eventHubReceivers value. + */ + public List eventHubReceivers() { + return this.eventHubReceivers; + } + + /** + * Set the eventHubReceivers property: The list of event hub receivers that are part of this action group. + * + * @param eventHubReceivers the eventHubReceivers value to set. + * @return the ActionGroup object itself. + */ + public ActionGroup withEventHubReceivers(List eventHubReceivers) { + this.eventHubReceivers = eventHubReceivers; + return this; + } + + /** + * Get the incidentReceivers property: The list of incident receivers that are part of this action group. + * + * @return the incidentReceivers value. + */ + public List incidentReceivers() { + return this.incidentReceivers; + } + + /** + * Set the incidentReceivers property: The list of incident receivers that are part of this action group. + * + * @param incidentReceivers the incidentReceivers value to set. + * @return the ActionGroup object itself. + */ + public ActionGroup withIncidentReceivers(List incidentReceivers) { + this.incidentReceivers = incidentReceivers; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (groupShortName() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property groupShortName in model ActionGroup")); + } + if (emailReceivers() != null) { + emailReceivers().forEach(e -> e.validate()); + } + if (smsReceivers() != null) { + smsReceivers().forEach(e -> e.validate()); + } + if (webhookReceivers() != null) { + webhookReceivers().forEach(e -> e.validate()); + } + if (itsmReceivers() != null) { + itsmReceivers().forEach(e -> e.validate()); + } + if (azureAppPushReceivers() != null) { + azureAppPushReceivers().forEach(e -> e.validate()); + } + if (automationRunbookReceivers() != null) { + automationRunbookReceivers().forEach(e -> e.validate()); + } + if (voiceReceivers() != null) { + voiceReceivers().forEach(e -> e.validate()); + } + if (logicAppReceivers() != null) { + logicAppReceivers().forEach(e -> e.validate()); + } + if (azureFunctionReceivers() != null) { + azureFunctionReceivers().forEach(e -> e.validate()); + } + if (armRoleReceivers() != null) { + armRoleReceivers().forEach(e -> e.validate()); + } + if (eventHubReceivers() != null) { + eventHubReceivers().forEach(e -> e.validate()); + } + if (incidentReceivers() != null) { + incidentReceivers().forEach(e -> e.validate()); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(ActionGroup.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("groupShortName", this.groupShortName); + jsonWriter.writeBooleanField("enabled", this.enabled); + jsonWriter.writeArrayField("emailReceivers", this.emailReceivers, + (writer, element) -> writer.writeJson(element)); + jsonWriter.writeArrayField("smsReceivers", this.smsReceivers, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeArrayField("webhookReceivers", this.webhookReceivers, + (writer, element) -> writer.writeJson(element)); + jsonWriter.writeArrayField("itsmReceivers", this.itsmReceivers, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeArrayField("azureAppPushReceivers", this.azureAppPushReceivers, + (writer, element) -> writer.writeJson(element)); + jsonWriter.writeArrayField("automationRunbookReceivers", this.automationRunbookReceivers, + (writer, element) -> writer.writeJson(element)); + jsonWriter.writeArrayField("voiceReceivers", this.voiceReceivers, + (writer, element) -> writer.writeJson(element)); + jsonWriter.writeArrayField("logicAppReceivers", this.logicAppReceivers, + (writer, element) -> writer.writeJson(element)); + jsonWriter.writeArrayField("azureFunctionReceivers", this.azureFunctionReceivers, + (writer, element) -> writer.writeJson(element)); + jsonWriter.writeArrayField("armRoleReceivers", this.armRoleReceivers, + (writer, element) -> writer.writeJson(element)); + jsonWriter.writeArrayField("eventHubReceivers", this.eventHubReceivers, + (writer, element) -> writer.writeJson(element)); + jsonWriter.writeArrayField("incidentReceivers", this.incidentReceivers, + (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ActionGroup from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ActionGroup if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the ActionGroup. + */ + public static ActionGroup fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ActionGroup deserializedActionGroup = new ActionGroup(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("groupShortName".equals(fieldName)) { + deserializedActionGroup.groupShortName = reader.getString(); + } else if ("enabled".equals(fieldName)) { + deserializedActionGroup.enabled = reader.getBoolean(); + } else if ("emailReceivers".equals(fieldName)) { + List emailReceivers = reader.readArray(reader1 -> EmailReceiver.fromJson(reader1)); + deserializedActionGroup.emailReceivers = emailReceivers; + } else if ("smsReceivers".equals(fieldName)) { + List smsReceivers = reader.readArray(reader1 -> SmsReceiver.fromJson(reader1)); + deserializedActionGroup.smsReceivers = smsReceivers; + } else if ("webhookReceivers".equals(fieldName)) { + List webhookReceivers + = reader.readArray(reader1 -> WebhookReceiver.fromJson(reader1)); + deserializedActionGroup.webhookReceivers = webhookReceivers; + } else if ("itsmReceivers".equals(fieldName)) { + List itsmReceivers = reader.readArray(reader1 -> ItsmReceiver.fromJson(reader1)); + deserializedActionGroup.itsmReceivers = itsmReceivers; + } else if ("azureAppPushReceivers".equals(fieldName)) { + List azureAppPushReceivers + = reader.readArray(reader1 -> AzureAppPushReceiver.fromJson(reader1)); + deserializedActionGroup.azureAppPushReceivers = azureAppPushReceivers; + } else if ("automationRunbookReceivers".equals(fieldName)) { + List automationRunbookReceivers + = reader.readArray(reader1 -> AutomationRunbookReceiver.fromJson(reader1)); + deserializedActionGroup.automationRunbookReceivers = automationRunbookReceivers; + } else if ("voiceReceivers".equals(fieldName)) { + List voiceReceivers = reader.readArray(reader1 -> VoiceReceiver.fromJson(reader1)); + deserializedActionGroup.voiceReceivers = voiceReceivers; + } else if ("logicAppReceivers".equals(fieldName)) { + List logicAppReceivers + = reader.readArray(reader1 -> LogicAppReceiver.fromJson(reader1)); + deserializedActionGroup.logicAppReceivers = logicAppReceivers; + } else if ("azureFunctionReceivers".equals(fieldName)) { + List azureFunctionReceivers + = reader.readArray(reader1 -> AzureFunctionReceiver.fromJson(reader1)); + deserializedActionGroup.azureFunctionReceivers = azureFunctionReceivers; + } else if ("armRoleReceivers".equals(fieldName)) { + List armRoleReceivers + = reader.readArray(reader1 -> ArmRoleReceiver.fromJson(reader1)); + deserializedActionGroup.armRoleReceivers = armRoleReceivers; + } else if ("eventHubReceivers".equals(fieldName)) { + List eventHubReceivers + = reader.readArray(reader1 -> EventHubReceiver.fromJson(reader1)); + deserializedActionGroup.eventHubReceivers = eventHubReceivers; + } else if ("incidentReceivers".equals(fieldName)) { + List incidentReceivers + = reader.readArray(reader1 -> IncidentReceiver.fromJson(reader1)); + deserializedActionGroup.incidentReceivers = incidentReceivers; + } else { + reader.skipChildren(); + } + } + + return deserializedActionGroup; + }); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/fluent/models/ActionGroupPatch.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/fluent/models/ActionGroupPatch.java new file mode 100644 index 0000000000000..08eda4beb1adb --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/fluent/models/ActionGroupPatch.java @@ -0,0 +1,96 @@ +// 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.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * An Azure action group for patch operations. + */ +@Fluent +public final class ActionGroupPatch implements JsonSerializable { + /* + * Indicates whether this action group is enabled. If an action group is not enabled, then none of its actions will + * be activated. + */ + private Boolean enabled; + + /** + * Creates an instance of ActionGroupPatch class. + */ + public ActionGroupPatch() { + } + + /** + * Get the enabled property: Indicates whether this action group is enabled. If an action group 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 action group is enabled. If an action group is not enabled, then + * none of its actions will be activated. + * + * @param enabled the enabled value to set. + * @return the ActionGroupPatch object itself. + */ + public ActionGroupPatch withEnabled(Boolean enabled) { + this.enabled = enabled; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeBooleanField("enabled", this.enabled); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ActionGroupPatch from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ActionGroupPatch if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the ActionGroupPatch. + */ + public static ActionGroupPatch fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ActionGroupPatch deserializedActionGroupPatch = new ActionGroupPatch(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("enabled".equals(fieldName)) { + deserializedActionGroupPatch.enabled = reader.getNullable(JsonReader::getBoolean); + } else { + reader.skipChildren(); + } + } + + return deserializedActionGroupPatch; + }); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/fluent/models/ActionGroupResourceInner.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/fluent/models/ActionGroupResourceInner.java new file mode 100644 index 0000000000000..d0219c87f8fa4 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/fluent/models/ActionGroupResourceInner.java @@ -0,0 +1,537 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.monitor.generated.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.management.Resource; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.azure.resourcemanager.monitor.generated.models.ArmRoleReceiver; +import com.azure.resourcemanager.monitor.generated.models.AutomationRunbookReceiver; +import com.azure.resourcemanager.monitor.generated.models.AzureAppPushReceiver; +import com.azure.resourcemanager.monitor.generated.models.AzureFunctionReceiver; +import com.azure.resourcemanager.monitor.generated.models.EmailReceiver; +import com.azure.resourcemanager.monitor.generated.models.EventHubReceiver; +import com.azure.resourcemanager.monitor.generated.models.IncidentReceiver; +import com.azure.resourcemanager.monitor.generated.models.ItsmReceiver; +import com.azure.resourcemanager.monitor.generated.models.LogicAppReceiver; +import com.azure.resourcemanager.monitor.generated.models.ManagedServiceIdentity; +import com.azure.resourcemanager.monitor.generated.models.SmsReceiver; +import com.azure.resourcemanager.monitor.generated.models.VoiceReceiver; +import com.azure.resourcemanager.monitor.generated.models.WebhookReceiver; +import java.io.IOException; +import java.util.List; +import java.util.Map; + +/** + * An action group resource. + */ +@Fluent +public final class ActionGroupResourceInner extends Resource { + /* + * The action groups properties of the resource. + */ + private ActionGroup innerProperties; + + /* + * Managed service identity (system assigned and/or user assigned identities) + */ + private ManagedServiceIdentity identity; + + /* + * The type of the resource. + */ + private String type; + + /* + * The name of the resource. + */ + private String name; + + /* + * Fully qualified resource Id for the resource. + */ + private String id; + + /** + * Creates an instance of ActionGroupResourceInner class. + */ + public ActionGroupResourceInner() { + } + + /** + * Get the innerProperties property: The action groups properties of the resource. + * + * @return the innerProperties value. + */ + private ActionGroup innerProperties() { + return this.innerProperties; + } + + /** + * Get the identity property: Managed service identity (system assigned and/or user assigned identities). + * + * @return the identity value. + */ + public ManagedServiceIdentity identity() { + return this.identity; + } + + /** + * Set the identity property: Managed service identity (system assigned and/or user assigned identities). + * + * @param identity the identity value to set. + * @return the ActionGroupResourceInner object itself. + */ + public ActionGroupResourceInner withIdentity(ManagedServiceIdentity identity) { + this.identity = identity; + return this; + } + + /** + * Get the type property: The type of the resource. + * + * @return the type value. + */ + @Override + public String type() { + return this.type; + } + + /** + * Get the name property: The name of the resource. + * + * @return the name value. + */ + @Override + public String name() { + return this.name; + } + + /** + * Get the id property: Fully qualified resource Id for the resource. + * + * @return the id value. + */ + @Override + public String id() { + return this.id; + } + + /** + * {@inheritDoc} + */ + @Override + public ActionGroupResourceInner withLocation(String location) { + super.withLocation(location); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public ActionGroupResourceInner withTags(Map tags) { + super.withTags(tags); + return this; + } + + /** + * Get the groupShortName property: The short name of the action group. This will be used in SMS messages. + * + * @return the groupShortName value. + */ + public String groupShortName() { + return this.innerProperties() == null ? null : this.innerProperties().groupShortName(); + } + + /** + * Set the groupShortName property: The short name of the action group. This will be used in SMS messages. + * + * @param groupShortName the groupShortName value to set. + * @return the ActionGroupResourceInner object itself. + */ + public ActionGroupResourceInner withGroupShortName(String groupShortName) { + if (this.innerProperties() == null) { + this.innerProperties = new ActionGroup(); + } + this.innerProperties().withGroupShortName(groupShortName); + return this; + } + + /** + * Get the enabled property: Indicates whether this action group is enabled. If an action group is not enabled, then + * none of its receivers will receive communications. + * + * @return the enabled value. + */ + public Boolean enabled() { + return this.innerProperties() == null ? null : this.innerProperties().enabled(); + } + + /** + * Set the enabled property: Indicates whether this action group is enabled. If an action group is not enabled, then + * none of its receivers will receive communications. + * + * @param enabled the enabled value to set. + * @return the ActionGroupResourceInner object itself. + */ + public ActionGroupResourceInner withEnabled(Boolean enabled) { + if (this.innerProperties() == null) { + this.innerProperties = new ActionGroup(); + } + this.innerProperties().withEnabled(enabled); + return this; + } + + /** + * Get the emailReceivers property: The list of email receivers that are part of this action group. + * + * @return the emailReceivers value. + */ + public List emailReceivers() { + return this.innerProperties() == null ? null : this.innerProperties().emailReceivers(); + } + + /** + * Set the emailReceivers property: The list of email receivers that are part of this action group. + * + * @param emailReceivers the emailReceivers value to set. + * @return the ActionGroupResourceInner object itself. + */ + public ActionGroupResourceInner withEmailReceivers(List emailReceivers) { + if (this.innerProperties() == null) { + this.innerProperties = new ActionGroup(); + } + this.innerProperties().withEmailReceivers(emailReceivers); + return this; + } + + /** + * Get the smsReceivers property: The list of SMS receivers that are part of this action group. + * + * @return the smsReceivers value. + */ + public List smsReceivers() { + return this.innerProperties() == null ? null : this.innerProperties().smsReceivers(); + } + + /** + * Set the smsReceivers property: The list of SMS receivers that are part of this action group. + * + * @param smsReceivers the smsReceivers value to set. + * @return the ActionGroupResourceInner object itself. + */ + public ActionGroupResourceInner withSmsReceivers(List smsReceivers) { + if (this.innerProperties() == null) { + this.innerProperties = new ActionGroup(); + } + this.innerProperties().withSmsReceivers(smsReceivers); + return this; + } + + /** + * Get the webhookReceivers property: The list of webhook receivers that are part of this action group. + * + * @return the webhookReceivers value. + */ + public List webhookReceivers() { + return this.innerProperties() == null ? null : this.innerProperties().webhookReceivers(); + } + + /** + * Set the webhookReceivers property: The list of webhook receivers that are part of this action group. + * + * @param webhookReceivers the webhookReceivers value to set. + * @return the ActionGroupResourceInner object itself. + */ + public ActionGroupResourceInner withWebhookReceivers(List webhookReceivers) { + if (this.innerProperties() == null) { + this.innerProperties = new ActionGroup(); + } + this.innerProperties().withWebhookReceivers(webhookReceivers); + return this; + } + + /** + * Get the itsmReceivers property: The list of ITSM receivers that are part of this action group. + * + * @return the itsmReceivers value. + */ + public List itsmReceivers() { + return this.innerProperties() == null ? null : this.innerProperties().itsmReceivers(); + } + + /** + * Set the itsmReceivers property: The list of ITSM receivers that are part of this action group. + * + * @param itsmReceivers the itsmReceivers value to set. + * @return the ActionGroupResourceInner object itself. + */ + public ActionGroupResourceInner withItsmReceivers(List itsmReceivers) { + if (this.innerProperties() == null) { + this.innerProperties = new ActionGroup(); + } + this.innerProperties().withItsmReceivers(itsmReceivers); + return this; + } + + /** + * Get the azureAppPushReceivers property: The list of AzureAppPush receivers that are part of this action group. + * + * @return the azureAppPushReceivers value. + */ + public List azureAppPushReceivers() { + return this.innerProperties() == null ? null : this.innerProperties().azureAppPushReceivers(); + } + + /** + * Set the azureAppPushReceivers property: The list of AzureAppPush receivers that are part of this action group. + * + * @param azureAppPushReceivers the azureAppPushReceivers value to set. + * @return the ActionGroupResourceInner object itself. + */ + public ActionGroupResourceInner withAzureAppPushReceivers(List azureAppPushReceivers) { + if (this.innerProperties() == null) { + this.innerProperties = new ActionGroup(); + } + this.innerProperties().withAzureAppPushReceivers(azureAppPushReceivers); + return this; + } + + /** + * Get the automationRunbookReceivers property: The list of AutomationRunbook receivers that are part of this action + * group. + * + * @return the automationRunbookReceivers value. + */ + public List automationRunbookReceivers() { + return this.innerProperties() == null ? null : this.innerProperties().automationRunbookReceivers(); + } + + /** + * Set the automationRunbookReceivers property: The list of AutomationRunbook receivers that are part of this action + * group. + * + * @param automationRunbookReceivers the automationRunbookReceivers value to set. + * @return the ActionGroupResourceInner object itself. + */ + public ActionGroupResourceInner + withAutomationRunbookReceivers(List automationRunbookReceivers) { + if (this.innerProperties() == null) { + this.innerProperties = new ActionGroup(); + } + this.innerProperties().withAutomationRunbookReceivers(automationRunbookReceivers); + return this; + } + + /** + * Get the voiceReceivers property: The list of voice receivers that are part of this action group. + * + * @return the voiceReceivers value. + */ + public List voiceReceivers() { + return this.innerProperties() == null ? null : this.innerProperties().voiceReceivers(); + } + + /** + * Set the voiceReceivers property: The list of voice receivers that are part of this action group. + * + * @param voiceReceivers the voiceReceivers value to set. + * @return the ActionGroupResourceInner object itself. + */ + public ActionGroupResourceInner withVoiceReceivers(List voiceReceivers) { + if (this.innerProperties() == null) { + this.innerProperties = new ActionGroup(); + } + this.innerProperties().withVoiceReceivers(voiceReceivers); + return this; + } + + /** + * Get the logicAppReceivers property: The list of logic app receivers that are part of this action group. + * + * @return the logicAppReceivers value. + */ + public List logicAppReceivers() { + return this.innerProperties() == null ? null : this.innerProperties().logicAppReceivers(); + } + + /** + * Set the logicAppReceivers property: The list of logic app receivers that are part of this action group. + * + * @param logicAppReceivers the logicAppReceivers value to set. + * @return the ActionGroupResourceInner object itself. + */ + public ActionGroupResourceInner withLogicAppReceivers(List logicAppReceivers) { + if (this.innerProperties() == null) { + this.innerProperties = new ActionGroup(); + } + this.innerProperties().withLogicAppReceivers(logicAppReceivers); + return this; + } + + /** + * Get the azureFunctionReceivers property: The list of azure function receivers that are part of this action group. + * + * @return the azureFunctionReceivers value. + */ + public List azureFunctionReceivers() { + return this.innerProperties() == null ? null : this.innerProperties().azureFunctionReceivers(); + } + + /** + * Set the azureFunctionReceivers property: The list of azure function receivers that are part of this action group. + * + * @param azureFunctionReceivers the azureFunctionReceivers value to set. + * @return the ActionGroupResourceInner object itself. + */ + public ActionGroupResourceInner withAzureFunctionReceivers(List azureFunctionReceivers) { + if (this.innerProperties() == null) { + this.innerProperties = new ActionGroup(); + } + this.innerProperties().withAzureFunctionReceivers(azureFunctionReceivers); + return this; + } + + /** + * Get the armRoleReceivers property: The list of ARM role receivers that are part of this action group. Roles are + * Azure RBAC roles and only built-in roles are supported. + * + * @return the armRoleReceivers value. + */ + public List armRoleReceivers() { + return this.innerProperties() == null ? null : this.innerProperties().armRoleReceivers(); + } + + /** + * Set the armRoleReceivers property: The list of ARM role receivers that are part of this action group. Roles are + * Azure RBAC roles and only built-in roles are supported. + * + * @param armRoleReceivers the armRoleReceivers value to set. + * @return the ActionGroupResourceInner object itself. + */ + public ActionGroupResourceInner withArmRoleReceivers(List armRoleReceivers) { + if (this.innerProperties() == null) { + this.innerProperties = new ActionGroup(); + } + this.innerProperties().withArmRoleReceivers(armRoleReceivers); + return this; + } + + /** + * Get the eventHubReceivers property: The list of event hub receivers that are part of this action group. + * + * @return the eventHubReceivers value. + */ + public List eventHubReceivers() { + return this.innerProperties() == null ? null : this.innerProperties().eventHubReceivers(); + } + + /** + * Set the eventHubReceivers property: The list of event hub receivers that are part of this action group. + * + * @param eventHubReceivers the eventHubReceivers value to set. + * @return the ActionGroupResourceInner object itself. + */ + public ActionGroupResourceInner withEventHubReceivers(List eventHubReceivers) { + if (this.innerProperties() == null) { + this.innerProperties = new ActionGroup(); + } + this.innerProperties().withEventHubReceivers(eventHubReceivers); + return this; + } + + /** + * Get the incidentReceivers property: The list of incident receivers that are part of this action group. + * + * @return the incidentReceivers value. + */ + public List incidentReceivers() { + return this.innerProperties() == null ? null : this.innerProperties().incidentReceivers(); + } + + /** + * Set the incidentReceivers property: The list of incident receivers that are part of this action group. + * + * @param incidentReceivers the incidentReceivers value to set. + * @return the ActionGroupResourceInner object itself. + */ + public ActionGroupResourceInner withIncidentReceivers(List incidentReceivers) { + if (this.innerProperties() == null) { + this.innerProperties = new ActionGroup(); + } + this.innerProperties().withIncidentReceivers(incidentReceivers); + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (innerProperties() != null) { + innerProperties().validate(); + } + if (identity() != null) { + identity().validate(); + } + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("location", location()); + jsonWriter.writeMapField("tags", tags(), (writer, element) -> writer.writeString(element)); + jsonWriter.writeJsonField("properties", this.innerProperties); + jsonWriter.writeJsonField("identity", this.identity); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ActionGroupResourceInner from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ActionGroupResourceInner if the JsonReader was pointing to an instance of it, or null if + * it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the ActionGroupResourceInner. + */ + public static ActionGroupResourceInner fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ActionGroupResourceInner deserializedActionGroupResourceInner = new ActionGroupResourceInner(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + deserializedActionGroupResourceInner.id = reader.getString(); + } else if ("name".equals(fieldName)) { + deserializedActionGroupResourceInner.name = reader.getString(); + } else if ("type".equals(fieldName)) { + deserializedActionGroupResourceInner.type = reader.getString(); + } else if ("location".equals(fieldName)) { + deserializedActionGroupResourceInner.withLocation(reader.getString()); + } else if ("tags".equals(fieldName)) { + Map tags = reader.readMap(reader1 -> reader1.getString()); + deserializedActionGroupResourceInner.withTags(tags); + } else if ("properties".equals(fieldName)) { + deserializedActionGroupResourceInner.innerProperties = ActionGroup.fromJson(reader); + } else if ("identity".equals(fieldName)) { + deserializedActionGroupResourceInner.identity = ManagedServiceIdentity.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedActionGroupResourceInner; + }); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/fluent/models/ScheduledQueryRuleProperties.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/fluent/models/ScheduledQueryRuleProperties.java new file mode 100644 index 0000000000000..a0610cad19303 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/fluent/models/ScheduledQueryRuleProperties.java @@ -0,0 +1,635 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.monitor.generated.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.CoreUtils; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.azure.resourcemanager.monitor.generated.models.Actions; +import com.azure.resourcemanager.monitor.generated.models.AlertSeverity; +import com.azure.resourcemanager.monitor.generated.models.RuleResolveConfiguration; +import com.azure.resourcemanager.monitor.generated.models.ScheduledQueryRuleCriteria; +import java.io.IOException; +import java.time.Duration; +import java.util.List; + +/** + * scheduled query rule Definition. + */ +@Fluent +public final class ScheduledQueryRuleProperties implements JsonSerializable { + /* + * The api-version used when creating this alert rule + */ + private String createdWithApiVersion; + + /* + * True if alert rule is legacy Log Analytic rule + */ + private Boolean isLegacyLogAnalyticsRule; + + /* + * The description of the scheduled query rule. + */ + private String description; + + /* + * The display name of the alert rule + */ + private String displayName; + + /* + * Severity of the alert. Should be an integer between [0-4]. Value of 0 is severest. Relevant and required only for + * rules of the kind LogAlert. + */ + private AlertSeverity severity; + + /* + * The flag which indicates whether this scheduled query rule is enabled. Value should be true or false + */ + private Boolean enabled; + + /* + * The list of resource id's that this scheduled query rule is scoped to. + */ + private List scopes; + + /* + * How often the scheduled query rule is evaluated represented in ISO 8601 duration format. Relevant and required + * only for rules of the kind LogAlert. + */ + private Duration evaluationFrequency; + + /* + * The period of time (in ISO 8601 duration format) on which the Alert query will be executed (bin size). Relevant + * and required only for rules of the kind LogAlert. + */ + private Duration windowSize; + + /* + * If specified then overrides the query time range (default is WindowSize*NumberOfEvaluationPeriods). Relevant only + * for rules of the kind LogAlert. + */ + private Duration overrideQueryTimeRange; + + /* + * List of resource type of the target resource(s) on which the alert is created/updated. For example if the scope + * is a resource group and targetResourceTypes is Microsoft.Compute/virtualMachines, then a different alert will be + * fired for each virtual machine in the resource group which meet the alert criteria. Relevant only for rules of + * the kind LogAlert + */ + private List targetResourceTypes; + + /* + * The rule criteria that defines the conditions of the scheduled query rule. + */ + private ScheduledQueryRuleCriteria criteria; + + /* + * Mute actions for the chosen period of time (in ISO 8601 duration format) after the alert is fired. Relevant only + * for rules of the kind LogAlert. + */ + private Duration muteActionsDuration; + + /* + * Actions to invoke when the alert fires. + */ + private Actions actions; + + /* + * The flag which indicates whether this scheduled query rule has been configured to be stored in the customer's + * storage. The default is false. + */ + private Boolean isWorkspaceAlertsStorageConfigured; + + /* + * The flag which indicates whether this scheduled query rule should be stored in the customer's storage. The + * default is false. Relevant only for rules of the kind LogAlert. + */ + private Boolean checkWorkspaceAlertsStorageConfigured; + + /* + * The flag which indicates whether the provided query should be validated or not. The default is false. Relevant + * only for rules of the kind LogAlert. + */ + private Boolean skipQueryValidation; + + /* + * The flag that indicates whether the alert should be automatically resolved or not. The default is true. Relevant + * only for rules of the kind LogAlert. + */ + private Boolean autoMitigate; + + /* + * Defines the configuration for resolving fired alerts. Relevant only for rules of the kind LogAlert. + */ + private RuleResolveConfiguration resolveConfiguration; + + /** + * Creates an instance of ScheduledQueryRuleProperties class. + */ + public ScheduledQueryRuleProperties() { + } + + /** + * Get the createdWithApiVersion property: The api-version used when creating this alert rule. + * + * @return the createdWithApiVersion value. + */ + public String createdWithApiVersion() { + return this.createdWithApiVersion; + } + + /** + * Get the isLegacyLogAnalyticsRule property: True if alert rule is legacy Log Analytic rule. + * + * @return the isLegacyLogAnalyticsRule value. + */ + public Boolean isLegacyLogAnalyticsRule() { + return this.isLegacyLogAnalyticsRule; + } + + /** + * Get the description property: The description of the scheduled query rule. + * + * @return the description value. + */ + public String description() { + return this.description; + } + + /** + * Set the description property: The description of the scheduled query rule. + * + * @param description the description value to set. + * @return the ScheduledQueryRuleProperties object itself. + */ + public ScheduledQueryRuleProperties withDescription(String description) { + this.description = description; + return this; + } + + /** + * Get the displayName property: The display name of the alert rule. + * + * @return the displayName value. + */ + public String displayName() { + return this.displayName; + } + + /** + * Set the displayName property: The display name of the alert rule. + * + * @param displayName the displayName value to set. + * @return the ScheduledQueryRuleProperties object itself. + */ + public ScheduledQueryRuleProperties withDisplayName(String displayName) { + this.displayName = displayName; + return this; + } + + /** + * Get the severity property: Severity of the alert. Should be an integer between [0-4]. Value of 0 is severest. + * Relevant and required only for rules of the kind LogAlert. + * + * @return the severity value. + */ + public AlertSeverity severity() { + return this.severity; + } + + /** + * Set the severity property: Severity of the alert. Should be an integer between [0-4]. Value of 0 is severest. + * Relevant and required only for rules of the kind LogAlert. + * + * @param severity the severity value to set. + * @return the ScheduledQueryRuleProperties object itself. + */ + public ScheduledQueryRuleProperties withSeverity(AlertSeverity severity) { + this.severity = severity; + return this; + } + + /** + * Get the enabled property: The flag which indicates whether this scheduled query rule is enabled. Value should be + * true or false. + * + * @return the enabled value. + */ + public Boolean enabled() { + return this.enabled; + } + + /** + * Set the enabled property: The flag which indicates whether this scheduled query rule is enabled. Value should be + * true or false. + * + * @param enabled the enabled value to set. + * @return the ScheduledQueryRuleProperties object itself. + */ + public ScheduledQueryRuleProperties withEnabled(Boolean enabled) { + this.enabled = enabled; + return this; + } + + /** + * Get the scopes property: The list of resource id's that this scheduled query rule is scoped to. + * + * @return the scopes value. + */ + public List scopes() { + return this.scopes; + } + + /** + * Set the scopes property: The list of resource id's that this scheduled query rule is scoped to. + * + * @param scopes the scopes value to set. + * @return the ScheduledQueryRuleProperties object itself. + */ + public ScheduledQueryRuleProperties withScopes(List scopes) { + this.scopes = scopes; + return this; + } + + /** + * Get the evaluationFrequency property: How often the scheduled query rule is evaluated represented in ISO 8601 + * duration format. Relevant and required only for rules of the kind LogAlert. + * + * @return the evaluationFrequency value. + */ + public Duration evaluationFrequency() { + return this.evaluationFrequency; + } + + /** + * Set the evaluationFrequency property: How often the scheduled query rule is evaluated represented in ISO 8601 + * duration format. Relevant and required only for rules of the kind LogAlert. + * + * @param evaluationFrequency the evaluationFrequency value to set. + * @return the ScheduledQueryRuleProperties object itself. + */ + public ScheduledQueryRuleProperties withEvaluationFrequency(Duration evaluationFrequency) { + this.evaluationFrequency = evaluationFrequency; + return this; + } + + /** + * Get the windowSize property: The period of time (in ISO 8601 duration format) on which the Alert query will be + * executed (bin size). Relevant and required only for rules of the kind LogAlert. + * + * @return the windowSize value. + */ + public Duration windowSize() { + return this.windowSize; + } + + /** + * Set the windowSize property: The period of time (in ISO 8601 duration format) on which the Alert query will be + * executed (bin size). Relevant and required only for rules of the kind LogAlert. + * + * @param windowSize the windowSize value to set. + * @return the ScheduledQueryRuleProperties object itself. + */ + public ScheduledQueryRuleProperties withWindowSize(Duration windowSize) { + this.windowSize = windowSize; + return this; + } + + /** + * Get the overrideQueryTimeRange property: If specified then overrides the query time range (default is + * WindowSize*NumberOfEvaluationPeriods). Relevant only for rules of the kind LogAlert. + * + * @return the overrideQueryTimeRange value. + */ + public Duration overrideQueryTimeRange() { + return this.overrideQueryTimeRange; + } + + /** + * Set the overrideQueryTimeRange property: If specified then overrides the query time range (default is + * WindowSize*NumberOfEvaluationPeriods). Relevant only for rules of the kind LogAlert. + * + * @param overrideQueryTimeRange the overrideQueryTimeRange value to set. + * @return the ScheduledQueryRuleProperties object itself. + */ + public ScheduledQueryRuleProperties withOverrideQueryTimeRange(Duration overrideQueryTimeRange) { + this.overrideQueryTimeRange = overrideQueryTimeRange; + return this; + } + + /** + * Get the targetResourceTypes property: List of resource type of the target resource(s) on which the alert is + * created/updated. For example if the scope is a resource group and targetResourceTypes is + * Microsoft.Compute/virtualMachines, then a different alert will be fired for each virtual machine in the resource + * group which meet the alert criteria. Relevant only for rules of the kind LogAlert. + * + * @return the targetResourceTypes value. + */ + public List targetResourceTypes() { + return this.targetResourceTypes; + } + + /** + * Set the targetResourceTypes property: List of resource type of the target resource(s) on which the alert is + * created/updated. For example if the scope is a resource group and targetResourceTypes is + * Microsoft.Compute/virtualMachines, then a different alert will be fired for each virtual machine in the resource + * group which meet the alert criteria. Relevant only for rules of the kind LogAlert. + * + * @param targetResourceTypes the targetResourceTypes value to set. + * @return the ScheduledQueryRuleProperties object itself. + */ + public ScheduledQueryRuleProperties withTargetResourceTypes(List targetResourceTypes) { + this.targetResourceTypes = targetResourceTypes; + return this; + } + + /** + * Get the criteria property: The rule criteria that defines the conditions of the scheduled query rule. + * + * @return the criteria value. + */ + public ScheduledQueryRuleCriteria criteria() { + return this.criteria; + } + + /** + * Set the criteria property: The rule criteria that defines the conditions of the scheduled query rule. + * + * @param criteria the criteria value to set. + * @return the ScheduledQueryRuleProperties object itself. + */ + public ScheduledQueryRuleProperties withCriteria(ScheduledQueryRuleCriteria criteria) { + this.criteria = criteria; + return this; + } + + /** + * Get the muteActionsDuration property: Mute actions for the chosen period of time (in ISO 8601 duration format) + * after the alert is fired. Relevant only for rules of the kind LogAlert. + * + * @return the muteActionsDuration value. + */ + public Duration muteActionsDuration() { + return this.muteActionsDuration; + } + + /** + * Set the muteActionsDuration property: Mute actions for the chosen period of time (in ISO 8601 duration format) + * after the alert is fired. Relevant only for rules of the kind LogAlert. + * + * @param muteActionsDuration the muteActionsDuration value to set. + * @return the ScheduledQueryRuleProperties object itself. + */ + public ScheduledQueryRuleProperties withMuteActionsDuration(Duration muteActionsDuration) { + this.muteActionsDuration = muteActionsDuration; + return this; + } + + /** + * Get the actions property: Actions to invoke when the alert fires. + * + * @return the actions value. + */ + public Actions actions() { + return this.actions; + } + + /** + * Set the actions property: Actions to invoke when the alert fires. + * + * @param actions the actions value to set. + * @return the ScheduledQueryRuleProperties object itself. + */ + public ScheduledQueryRuleProperties withActions(Actions actions) { + this.actions = actions; + return this; + } + + /** + * Get the isWorkspaceAlertsStorageConfigured property: The flag which indicates whether this scheduled query rule + * has been configured to be stored in the customer's storage. The default is false. + * + * @return the isWorkspaceAlertsStorageConfigured value. + */ + public Boolean isWorkspaceAlertsStorageConfigured() { + return this.isWorkspaceAlertsStorageConfigured; + } + + /** + * Get the checkWorkspaceAlertsStorageConfigured property: The flag which indicates whether this scheduled query + * rule should be stored in the customer's storage. The default is false. Relevant only for rules of the kind + * LogAlert. + * + * @return the checkWorkspaceAlertsStorageConfigured value. + */ + public Boolean checkWorkspaceAlertsStorageConfigured() { + return this.checkWorkspaceAlertsStorageConfigured; + } + + /** + * Set the checkWorkspaceAlertsStorageConfigured property: The flag which indicates whether this scheduled query + * rule should be stored in the customer's storage. The default is false. Relevant only for rules of the kind + * LogAlert. + * + * @param checkWorkspaceAlertsStorageConfigured the checkWorkspaceAlertsStorageConfigured value to set. + * @return the ScheduledQueryRuleProperties object itself. + */ + public ScheduledQueryRuleProperties + withCheckWorkspaceAlertsStorageConfigured(Boolean checkWorkspaceAlertsStorageConfigured) { + this.checkWorkspaceAlertsStorageConfigured = checkWorkspaceAlertsStorageConfigured; + return this; + } + + /** + * Get the skipQueryValidation property: The flag which indicates whether the provided query should be validated or + * not. The default is false. Relevant only for rules of the kind LogAlert. + * + * @return the skipQueryValidation value. + */ + public Boolean skipQueryValidation() { + return this.skipQueryValidation; + } + + /** + * Set the skipQueryValidation property: The flag which indicates whether the provided query should be validated or + * not. The default is false. Relevant only for rules of the kind LogAlert. + * + * @param skipQueryValidation the skipQueryValidation value to set. + * @return the ScheduledQueryRuleProperties object itself. + */ + public ScheduledQueryRuleProperties withSkipQueryValidation(Boolean skipQueryValidation) { + this.skipQueryValidation = skipQueryValidation; + return this; + } + + /** + * Get the autoMitigate property: The flag that indicates whether the alert should be automatically resolved or not. + * The default is true. Relevant only for rules of the kind LogAlert. + * + * @return the autoMitigate value. + */ + public Boolean autoMitigate() { + return this.autoMitigate; + } + + /** + * Set the autoMitigate property: The flag that indicates whether the alert should be automatically resolved or not. + * The default is true. Relevant only for rules of the kind LogAlert. + * + * @param autoMitigate the autoMitigate value to set. + * @return the ScheduledQueryRuleProperties object itself. + */ + public ScheduledQueryRuleProperties withAutoMitigate(Boolean autoMitigate) { + this.autoMitigate = autoMitigate; + return this; + } + + /** + * Get the resolveConfiguration property: Defines the configuration for resolving fired alerts. Relevant only for + * rules of the kind LogAlert. + * + * @return the resolveConfiguration value. + */ + public RuleResolveConfiguration resolveConfiguration() { + return this.resolveConfiguration; + } + + /** + * Set the resolveConfiguration property: Defines the configuration for resolving fired alerts. Relevant only for + * rules of the kind LogAlert. + * + * @param resolveConfiguration the resolveConfiguration value to set. + * @return the ScheduledQueryRuleProperties object itself. + */ + public ScheduledQueryRuleProperties withResolveConfiguration(RuleResolveConfiguration resolveConfiguration) { + this.resolveConfiguration = resolveConfiguration; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (criteria() != null) { + criteria().validate(); + } + if (actions() != null) { + actions().validate(); + } + if (resolveConfiguration() != null) { + resolveConfiguration().validate(); + } + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("description", this.description); + jsonWriter.writeStringField("displayName", this.displayName); + jsonWriter.writeNumberField("severity", this.severity == null ? null : this.severity.getValue()); + jsonWriter.writeBooleanField("enabled", this.enabled); + jsonWriter.writeArrayField("scopes", this.scopes, (writer, element) -> writer.writeString(element)); + jsonWriter.writeStringField("evaluationFrequency", + CoreUtils.durationToStringWithDays(this.evaluationFrequency)); + jsonWriter.writeStringField("windowSize", CoreUtils.durationToStringWithDays(this.windowSize)); + jsonWriter.writeStringField("overrideQueryTimeRange", + CoreUtils.durationToStringWithDays(this.overrideQueryTimeRange)); + jsonWriter.writeArrayField("targetResourceTypes", this.targetResourceTypes, + (writer, element) -> writer.writeString(element)); + jsonWriter.writeJsonField("criteria", this.criteria); + jsonWriter.writeStringField("muteActionsDuration", + CoreUtils.durationToStringWithDays(this.muteActionsDuration)); + jsonWriter.writeJsonField("actions", this.actions); + jsonWriter.writeBooleanField("checkWorkspaceAlertsStorageConfigured", + this.checkWorkspaceAlertsStorageConfigured); + jsonWriter.writeBooleanField("skipQueryValidation", this.skipQueryValidation); + jsonWriter.writeBooleanField("autoMitigate", this.autoMitigate); + jsonWriter.writeJsonField("resolveConfiguration", this.resolveConfiguration); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ScheduledQueryRuleProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ScheduledQueryRuleProperties if the JsonReader was pointing to an instance of it, or null + * if it was pointing to JSON null. + * @throws IOException If an error occurs while reading the ScheduledQueryRuleProperties. + */ + public static ScheduledQueryRuleProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ScheduledQueryRuleProperties deserializedScheduledQueryRuleProperties = new ScheduledQueryRuleProperties(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("createdWithApiVersion".equals(fieldName)) { + deserializedScheduledQueryRuleProperties.createdWithApiVersion = reader.getString(); + } else if ("isLegacyLogAnalyticsRule".equals(fieldName)) { + deserializedScheduledQueryRuleProperties.isLegacyLogAnalyticsRule + = reader.getNullable(JsonReader::getBoolean); + } else if ("description".equals(fieldName)) { + deserializedScheduledQueryRuleProperties.description = reader.getString(); + } else if ("displayName".equals(fieldName)) { + deserializedScheduledQueryRuleProperties.displayName = reader.getString(); + } else if ("severity".equals(fieldName)) { + deserializedScheduledQueryRuleProperties.severity = AlertSeverity.fromValue(reader.getLong()); + } else if ("enabled".equals(fieldName)) { + deserializedScheduledQueryRuleProperties.enabled = reader.getNullable(JsonReader::getBoolean); + } else if ("scopes".equals(fieldName)) { + List scopes = reader.readArray(reader1 -> reader1.getString()); + deserializedScheduledQueryRuleProperties.scopes = scopes; + } else if ("evaluationFrequency".equals(fieldName)) { + deserializedScheduledQueryRuleProperties.evaluationFrequency + = reader.getNullable(nonNullReader -> Duration.parse(nonNullReader.getString())); + } else if ("windowSize".equals(fieldName)) { + deserializedScheduledQueryRuleProperties.windowSize + = reader.getNullable(nonNullReader -> Duration.parse(nonNullReader.getString())); + } else if ("overrideQueryTimeRange".equals(fieldName)) { + deserializedScheduledQueryRuleProperties.overrideQueryTimeRange + = reader.getNullable(nonNullReader -> Duration.parse(nonNullReader.getString())); + } else if ("targetResourceTypes".equals(fieldName)) { + List targetResourceTypes = reader.readArray(reader1 -> reader1.getString()); + deserializedScheduledQueryRuleProperties.targetResourceTypes = targetResourceTypes; + } else if ("criteria".equals(fieldName)) { + deserializedScheduledQueryRuleProperties.criteria = ScheduledQueryRuleCriteria.fromJson(reader); + } else if ("muteActionsDuration".equals(fieldName)) { + deserializedScheduledQueryRuleProperties.muteActionsDuration + = reader.getNullable(nonNullReader -> Duration.parse(nonNullReader.getString())); + } else if ("actions".equals(fieldName)) { + deserializedScheduledQueryRuleProperties.actions = Actions.fromJson(reader); + } else if ("isWorkspaceAlertsStorageConfigured".equals(fieldName)) { + deserializedScheduledQueryRuleProperties.isWorkspaceAlertsStorageConfigured + = reader.getNullable(JsonReader::getBoolean); + } else if ("checkWorkspaceAlertsStorageConfigured".equals(fieldName)) { + deserializedScheduledQueryRuleProperties.checkWorkspaceAlertsStorageConfigured + = reader.getNullable(JsonReader::getBoolean); + } else if ("skipQueryValidation".equals(fieldName)) { + deserializedScheduledQueryRuleProperties.skipQueryValidation + = reader.getNullable(JsonReader::getBoolean); + } else if ("autoMitigate".equals(fieldName)) { + deserializedScheduledQueryRuleProperties.autoMitigate = reader.getNullable(JsonReader::getBoolean); + } else if ("resolveConfiguration".equals(fieldName)) { + deserializedScheduledQueryRuleProperties.resolveConfiguration + = RuleResolveConfiguration.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedScheduledQueryRuleProperties; + }); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/fluent/models/ScheduledQueryRuleResourceInner.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/fluent/models/ScheduledQueryRuleResourceInner.java new file mode 100644 index 0000000000000..7f550030070c5 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/fluent/models/ScheduledQueryRuleResourceInner.java @@ -0,0 +1,703 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.monitor.generated.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.management.Resource; +import com.azure.core.management.SystemData; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.azure.resourcemanager.monitor.generated.models.Actions; +import com.azure.resourcemanager.monitor.generated.models.AlertSeverity; +import com.azure.resourcemanager.monitor.generated.models.Identity; +import com.azure.resourcemanager.monitor.generated.models.Kind; +import com.azure.resourcemanager.monitor.generated.models.RuleResolveConfiguration; +import com.azure.resourcemanager.monitor.generated.models.ScheduledQueryRuleCriteria; +import java.io.IOException; +import java.time.Duration; +import java.util.List; +import java.util.Map; + +/** + * The scheduled query rule resource. + */ +@Fluent +public final class ScheduledQueryRuleResourceInner extends Resource { + /* + * The identity of the resource. + */ + private Identity identity; + + /* + * Indicates the type of scheduled query rule. The default is LogAlert. + */ + private Kind kind; + + /* + * The etag field is *not* required. If it is provided in the response body, it must also be provided as a header + * per the normal etag convention. Entity tags are used for comparing two or more entities from the same requested + * resource. HTTP/1.1 uses entity tags in the etag (section 14.19), If-Match (section 14.24), If-None-Match (section + * 14.26), and If-Range (section 14.27) header fields. + */ + private String etag; + + /* + * SystemData of ScheduledQueryRule. + */ + private SystemData systemData; + + /* + * The rule properties of the resource. + */ + private ScheduledQueryRuleProperties innerProperties = new ScheduledQueryRuleProperties(); + + /* + * The type of the resource. + */ + private String type; + + /* + * The name of the resource. + */ + private String name; + + /* + * Fully qualified resource Id for the resource. + */ + private String id; + + /** + * Creates an instance of ScheduledQueryRuleResourceInner class. + */ + public ScheduledQueryRuleResourceInner() { + } + + /** + * Get the identity property: The identity of the resource. + * + * @return the identity value. + */ + public Identity identity() { + return this.identity; + } + + /** + * Set the identity property: The identity of the resource. + * + * @param identity the identity value to set. + * @return the ScheduledQueryRuleResourceInner object itself. + */ + public ScheduledQueryRuleResourceInner withIdentity(Identity identity) { + this.identity = identity; + return this; + } + + /** + * Get the kind property: Indicates the type of scheduled query rule. The default is LogAlert. + * + * @return the kind value. + */ + public Kind kind() { + return this.kind; + } + + /** + * Set the kind property: Indicates the type of scheduled query rule. The default is LogAlert. + * + * @param kind the kind value to set. + * @return the ScheduledQueryRuleResourceInner object itself. + */ + public ScheduledQueryRuleResourceInner withKind(Kind kind) { + this.kind = kind; + return this; + } + + /** + * Get the etag property: The etag field is *not* required. If it is provided in the response body, it must also be + * provided as a header per the normal etag convention. Entity tags are used for comparing two or more entities from + * the same requested resource. HTTP/1.1 uses entity tags in the etag (section 14.19), If-Match (section 14.24), + * If-None-Match (section 14.26), and If-Range (section 14.27) header fields. + * + * @return the etag value. + */ + public String etag() { + return this.etag; + } + + /** + * Get the systemData property: SystemData of ScheduledQueryRule. + * + * @return the systemData value. + */ + public SystemData systemData() { + return this.systemData; + } + + /** + * Get the innerProperties property: The rule properties of the resource. + * + * @return the innerProperties value. + */ + private ScheduledQueryRuleProperties innerProperties() { + return this.innerProperties; + } + + /** + * Get the type property: The type of the resource. + * + * @return the type value. + */ + @Override + public String type() { + return this.type; + } + + /** + * Get the name property: The name of the resource. + * + * @return the name value. + */ + @Override + public String name() { + return this.name; + } + + /** + * Get the id property: Fully qualified resource Id for the resource. + * + * @return the id value. + */ + @Override + public String id() { + return this.id; + } + + /** + * {@inheritDoc} + */ + @Override + public ScheduledQueryRuleResourceInner withLocation(String location) { + super.withLocation(location); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public ScheduledQueryRuleResourceInner withTags(Map tags) { + super.withTags(tags); + return this; + } + + /** + * Get the createdWithApiVersion property: The api-version used when creating this alert rule. + * + * @return the createdWithApiVersion value. + */ + public String createdWithApiVersion() { + return this.innerProperties() == null ? null : this.innerProperties().createdWithApiVersion(); + } + + /** + * Get the isLegacyLogAnalyticsRule property: True if alert rule is legacy Log Analytic rule. + * + * @return the isLegacyLogAnalyticsRule value. + */ + public Boolean isLegacyLogAnalyticsRule() { + return this.innerProperties() == null ? null : this.innerProperties().isLegacyLogAnalyticsRule(); + } + + /** + * Get the description property: The description of the scheduled query rule. + * + * @return the description value. + */ + public String description() { + return this.innerProperties() == null ? null : this.innerProperties().description(); + } + + /** + * Set the description property: The description of the scheduled query rule. + * + * @param description the description value to set. + * @return the ScheduledQueryRuleResourceInner object itself. + */ + public ScheduledQueryRuleResourceInner withDescription(String description) { + if (this.innerProperties() == null) { + this.innerProperties = new ScheduledQueryRuleProperties(); + } + this.innerProperties().withDescription(description); + return this; + } + + /** + * Get the displayName property: The display name of the alert rule. + * + * @return the displayName value. + */ + public String displayName() { + return this.innerProperties() == null ? null : this.innerProperties().displayName(); + } + + /** + * Set the displayName property: The display name of the alert rule. + * + * @param displayName the displayName value to set. + * @return the ScheduledQueryRuleResourceInner object itself. + */ + public ScheduledQueryRuleResourceInner withDisplayName(String displayName) { + if (this.innerProperties() == null) { + this.innerProperties = new ScheduledQueryRuleProperties(); + } + this.innerProperties().withDisplayName(displayName); + return this; + } + + /** + * Get the severity property: Severity of the alert. Should be an integer between [0-4]. Value of 0 is severest. + * Relevant and required only for rules of the kind LogAlert. + * + * @return the severity value. + */ + public AlertSeverity severity() { + return this.innerProperties() == null ? null : this.innerProperties().severity(); + } + + /** + * Set the severity property: Severity of the alert. Should be an integer between [0-4]. Value of 0 is severest. + * Relevant and required only for rules of the kind LogAlert. + * + * @param severity the severity value to set. + * @return the ScheduledQueryRuleResourceInner object itself. + */ + public ScheduledQueryRuleResourceInner withSeverity(AlertSeverity severity) { + if (this.innerProperties() == null) { + this.innerProperties = new ScheduledQueryRuleProperties(); + } + this.innerProperties().withSeverity(severity); + return this; + } + + /** + * Get the enabled property: The flag which indicates whether this scheduled query rule is enabled. Value should be + * true or false. + * + * @return the enabled value. + */ + public Boolean enabled() { + return this.innerProperties() == null ? null : this.innerProperties().enabled(); + } + + /** + * Set the enabled property: The flag which indicates whether this scheduled query rule is enabled. Value should be + * true or false. + * + * @param enabled the enabled value to set. + * @return the ScheduledQueryRuleResourceInner object itself. + */ + public ScheduledQueryRuleResourceInner withEnabled(Boolean enabled) { + if (this.innerProperties() == null) { + this.innerProperties = new ScheduledQueryRuleProperties(); + } + this.innerProperties().withEnabled(enabled); + return this; + } + + /** + * Get the scopes property: The list of resource id's that this scheduled query rule is scoped to. + * + * @return the scopes value. + */ + public List scopes() { + return this.innerProperties() == null ? null : this.innerProperties().scopes(); + } + + /** + * Set the scopes property: The list of resource id's that this scheduled query rule is scoped to. + * + * @param scopes the scopes value to set. + * @return the ScheduledQueryRuleResourceInner object itself. + */ + public ScheduledQueryRuleResourceInner withScopes(List scopes) { + if (this.innerProperties() == null) { + this.innerProperties = new ScheduledQueryRuleProperties(); + } + this.innerProperties().withScopes(scopes); + return this; + } + + /** + * Get the evaluationFrequency property: How often the scheduled query rule is evaluated represented in ISO 8601 + * duration format. Relevant and required only for rules of the kind LogAlert. + * + * @return the evaluationFrequency value. + */ + public Duration evaluationFrequency() { + return this.innerProperties() == null ? null : this.innerProperties().evaluationFrequency(); + } + + /** + * Set the evaluationFrequency property: How often the scheduled query rule is evaluated represented in ISO 8601 + * duration format. Relevant and required only for rules of the kind LogAlert. + * + * @param evaluationFrequency the evaluationFrequency value to set. + * @return the ScheduledQueryRuleResourceInner object itself. + */ + public ScheduledQueryRuleResourceInner withEvaluationFrequency(Duration evaluationFrequency) { + if (this.innerProperties() == null) { + this.innerProperties = new ScheduledQueryRuleProperties(); + } + this.innerProperties().withEvaluationFrequency(evaluationFrequency); + return this; + } + + /** + * Get the windowSize property: The period of time (in ISO 8601 duration format) on which the Alert query will be + * executed (bin size). Relevant and required only for rules of the kind LogAlert. + * + * @return the windowSize value. + */ + public Duration windowSize() { + return this.innerProperties() == null ? null : this.innerProperties().windowSize(); + } + + /** + * Set the windowSize property: The period of time (in ISO 8601 duration format) on which the Alert query will be + * executed (bin size). Relevant and required only for rules of the kind LogAlert. + * + * @param windowSize the windowSize value to set. + * @return the ScheduledQueryRuleResourceInner object itself. + */ + public ScheduledQueryRuleResourceInner withWindowSize(Duration windowSize) { + if (this.innerProperties() == null) { + this.innerProperties = new ScheduledQueryRuleProperties(); + } + this.innerProperties().withWindowSize(windowSize); + return this; + } + + /** + * Get the overrideQueryTimeRange property: If specified then overrides the query time range (default is + * WindowSize*NumberOfEvaluationPeriods). Relevant only for rules of the kind LogAlert. + * + * @return the overrideQueryTimeRange value. + */ + public Duration overrideQueryTimeRange() { + return this.innerProperties() == null ? null : this.innerProperties().overrideQueryTimeRange(); + } + + /** + * Set the overrideQueryTimeRange property: If specified then overrides the query time range (default is + * WindowSize*NumberOfEvaluationPeriods). Relevant only for rules of the kind LogAlert. + * + * @param overrideQueryTimeRange the overrideQueryTimeRange value to set. + * @return the ScheduledQueryRuleResourceInner object itself. + */ + public ScheduledQueryRuleResourceInner withOverrideQueryTimeRange(Duration overrideQueryTimeRange) { + if (this.innerProperties() == null) { + this.innerProperties = new ScheduledQueryRuleProperties(); + } + this.innerProperties().withOverrideQueryTimeRange(overrideQueryTimeRange); + return this; + } + + /** + * Get the targetResourceTypes property: List of resource type of the target resource(s) on which the alert is + * created/updated. For example if the scope is a resource group and targetResourceTypes is + * Microsoft.Compute/virtualMachines, then a different alert will be fired for each virtual machine in the resource + * group which meet the alert criteria. Relevant only for rules of the kind LogAlert. + * + * @return the targetResourceTypes value. + */ + public List targetResourceTypes() { + return this.innerProperties() == null ? null : this.innerProperties().targetResourceTypes(); + } + + /** + * Set the targetResourceTypes property: List of resource type of the target resource(s) on which the alert is + * created/updated. For example if the scope is a resource group and targetResourceTypes is + * Microsoft.Compute/virtualMachines, then a different alert will be fired for each virtual machine in the resource + * group which meet the alert criteria. Relevant only for rules of the kind LogAlert. + * + * @param targetResourceTypes the targetResourceTypes value to set. + * @return the ScheduledQueryRuleResourceInner object itself. + */ + public ScheduledQueryRuleResourceInner withTargetResourceTypes(List targetResourceTypes) { + if (this.innerProperties() == null) { + this.innerProperties = new ScheduledQueryRuleProperties(); + } + this.innerProperties().withTargetResourceTypes(targetResourceTypes); + return this; + } + + /** + * Get the criteria property: The rule criteria that defines the conditions of the scheduled query rule. + * + * @return the criteria value. + */ + public ScheduledQueryRuleCriteria criteria() { + return this.innerProperties() == null ? null : this.innerProperties().criteria(); + } + + /** + * Set the criteria property: The rule criteria that defines the conditions of the scheduled query rule. + * + * @param criteria the criteria value to set. + * @return the ScheduledQueryRuleResourceInner object itself. + */ + public ScheduledQueryRuleResourceInner withCriteria(ScheduledQueryRuleCriteria criteria) { + if (this.innerProperties() == null) { + this.innerProperties = new ScheduledQueryRuleProperties(); + } + this.innerProperties().withCriteria(criteria); + return this; + } + + /** + * Get the muteActionsDuration property: Mute actions for the chosen period of time (in ISO 8601 duration format) + * after the alert is fired. Relevant only for rules of the kind LogAlert. + * + * @return the muteActionsDuration value. + */ + public Duration muteActionsDuration() { + return this.innerProperties() == null ? null : this.innerProperties().muteActionsDuration(); + } + + /** + * Set the muteActionsDuration property: Mute actions for the chosen period of time (in ISO 8601 duration format) + * after the alert is fired. Relevant only for rules of the kind LogAlert. + * + * @param muteActionsDuration the muteActionsDuration value to set. + * @return the ScheduledQueryRuleResourceInner object itself. + */ + public ScheduledQueryRuleResourceInner withMuteActionsDuration(Duration muteActionsDuration) { + if (this.innerProperties() == null) { + this.innerProperties = new ScheduledQueryRuleProperties(); + } + this.innerProperties().withMuteActionsDuration(muteActionsDuration); + return this; + } + + /** + * Get the actions property: Actions to invoke when the alert fires. + * + * @return the actions value. + */ + public Actions actions() { + return this.innerProperties() == null ? null : this.innerProperties().actions(); + } + + /** + * Set the actions property: Actions to invoke when the alert fires. + * + * @param actions the actions value to set. + * @return the ScheduledQueryRuleResourceInner object itself. + */ + public ScheduledQueryRuleResourceInner withActions(Actions actions) { + if (this.innerProperties() == null) { + this.innerProperties = new ScheduledQueryRuleProperties(); + } + this.innerProperties().withActions(actions); + return this; + } + + /** + * Get the isWorkspaceAlertsStorageConfigured property: The flag which indicates whether this scheduled query rule + * has been configured to be stored in the customer's storage. The default is false. + * + * @return the isWorkspaceAlertsStorageConfigured value. + */ + public Boolean isWorkspaceAlertsStorageConfigured() { + return this.innerProperties() == null ? null : this.innerProperties().isWorkspaceAlertsStorageConfigured(); + } + + /** + * Get the checkWorkspaceAlertsStorageConfigured property: The flag which indicates whether this scheduled query + * rule should be stored in the customer's storage. The default is false. Relevant only for rules of the kind + * LogAlert. + * + * @return the checkWorkspaceAlertsStorageConfigured value. + */ + public Boolean checkWorkspaceAlertsStorageConfigured() { + return this.innerProperties() == null ? null : this.innerProperties().checkWorkspaceAlertsStorageConfigured(); + } + + /** + * Set the checkWorkspaceAlertsStorageConfigured property: The flag which indicates whether this scheduled query + * rule should be stored in the customer's storage. The default is false. Relevant only for rules of the kind + * LogAlert. + * + * @param checkWorkspaceAlertsStorageConfigured the checkWorkspaceAlertsStorageConfigured value to set. + * @return the ScheduledQueryRuleResourceInner object itself. + */ + public ScheduledQueryRuleResourceInner + withCheckWorkspaceAlertsStorageConfigured(Boolean checkWorkspaceAlertsStorageConfigured) { + if (this.innerProperties() == null) { + this.innerProperties = new ScheduledQueryRuleProperties(); + } + this.innerProperties().withCheckWorkspaceAlertsStorageConfigured(checkWorkspaceAlertsStorageConfigured); + return this; + } + + /** + * Get the skipQueryValidation property: The flag which indicates whether the provided query should be validated or + * not. The default is false. Relevant only for rules of the kind LogAlert. + * + * @return the skipQueryValidation value. + */ + public Boolean skipQueryValidation() { + return this.innerProperties() == null ? null : this.innerProperties().skipQueryValidation(); + } + + /** + * Set the skipQueryValidation property: The flag which indicates whether the provided query should be validated or + * not. The default is false. Relevant only for rules of the kind LogAlert. + * + * @param skipQueryValidation the skipQueryValidation value to set. + * @return the ScheduledQueryRuleResourceInner object itself. + */ + public ScheduledQueryRuleResourceInner withSkipQueryValidation(Boolean skipQueryValidation) { + if (this.innerProperties() == null) { + this.innerProperties = new ScheduledQueryRuleProperties(); + } + this.innerProperties().withSkipQueryValidation(skipQueryValidation); + return this; + } + + /** + * Get the autoMitigate property: The flag that indicates whether the alert should be automatically resolved or not. + * The default is true. Relevant only for rules of the kind LogAlert. + * + * @return the autoMitigate value. + */ + public Boolean autoMitigate() { + return this.innerProperties() == null ? null : this.innerProperties().autoMitigate(); + } + + /** + * Set the autoMitigate property: The flag that indicates whether the alert should be automatically resolved or not. + * The default is true. Relevant only for rules of the kind LogAlert. + * + * @param autoMitigate the autoMitigate value to set. + * @return the ScheduledQueryRuleResourceInner object itself. + */ + public ScheduledQueryRuleResourceInner withAutoMitigate(Boolean autoMitigate) { + if (this.innerProperties() == null) { + this.innerProperties = new ScheduledQueryRuleProperties(); + } + this.innerProperties().withAutoMitigate(autoMitigate); + return this; + } + + /** + * Get the resolveConfiguration property: Defines the configuration for resolving fired alerts. Relevant only for + * rules of the kind LogAlert. + * + * @return the resolveConfiguration value. + */ + public RuleResolveConfiguration resolveConfiguration() { + return this.innerProperties() == null ? null : this.innerProperties().resolveConfiguration(); + } + + /** + * Set the resolveConfiguration property: Defines the configuration for resolving fired alerts. Relevant only for + * rules of the kind LogAlert. + * + * @param resolveConfiguration the resolveConfiguration value to set. + * @return the ScheduledQueryRuleResourceInner object itself. + */ + public ScheduledQueryRuleResourceInner withResolveConfiguration(RuleResolveConfiguration resolveConfiguration) { + if (this.innerProperties() == null) { + this.innerProperties = new ScheduledQueryRuleProperties(); + } + this.innerProperties().withResolveConfiguration(resolveConfiguration); + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (identity() != null) { + identity().validate(); + } + if (innerProperties() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property innerProperties in model ScheduledQueryRuleResourceInner")); + } else { + innerProperties().validate(); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(ScheduledQueryRuleResourceInner.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("location", location()); + jsonWriter.writeMapField("tags", tags(), (writer, element) -> writer.writeString(element)); + jsonWriter.writeJsonField("properties", this.innerProperties); + jsonWriter.writeJsonField("identity", this.identity); + jsonWriter.writeStringField("kind", this.kind == null ? null : this.kind.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ScheduledQueryRuleResourceInner from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ScheduledQueryRuleResourceInner if the JsonReader was pointing to an instance of it, or + * null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the ScheduledQueryRuleResourceInner. + */ + public static ScheduledQueryRuleResourceInner fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ScheduledQueryRuleResourceInner deserializedScheduledQueryRuleResourceInner + = new ScheduledQueryRuleResourceInner(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + deserializedScheduledQueryRuleResourceInner.id = reader.getString(); + } else if ("name".equals(fieldName)) { + deserializedScheduledQueryRuleResourceInner.name = reader.getString(); + } else if ("type".equals(fieldName)) { + deserializedScheduledQueryRuleResourceInner.type = reader.getString(); + } else if ("location".equals(fieldName)) { + deserializedScheduledQueryRuleResourceInner.withLocation(reader.getString()); + } else if ("tags".equals(fieldName)) { + Map tags = reader.readMap(reader1 -> reader1.getString()); + deserializedScheduledQueryRuleResourceInner.withTags(tags); + } else if ("properties".equals(fieldName)) { + deserializedScheduledQueryRuleResourceInner.innerProperties + = ScheduledQueryRuleProperties.fromJson(reader); + } else if ("identity".equals(fieldName)) { + deserializedScheduledQueryRuleResourceInner.identity = Identity.fromJson(reader); + } else if ("kind".equals(fieldName)) { + deserializedScheduledQueryRuleResourceInner.kind = Kind.fromString(reader.getString()); + } else if ("etag".equals(fieldName)) { + deserializedScheduledQueryRuleResourceInner.etag = reader.getString(); + } else if ("systemData".equals(fieldName)) { + deserializedScheduledQueryRuleResourceInner.systemData = SystemData.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedScheduledQueryRuleResourceInner; + }); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/fluent/models/TestNotificationDetailsResponseInner.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/fluent/models/TestNotificationDetailsResponseInner.java new file mode 100644 index 0000000000000..3f456b5060196 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/fluent/models/TestNotificationDetailsResponseInner.java @@ -0,0 +1,226 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.monitor.generated.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.azure.resourcemanager.monitor.generated.models.ActionDetail; +import com.azure.resourcemanager.monitor.generated.models.Context; +import java.io.IOException; +import java.util.List; + +/** + * The details of the test notification results. + */ +@Fluent +public final class TestNotificationDetailsResponseInner + implements JsonSerializable { + /* + * The context info + */ + private Context context; + + /* + * The overall state + */ + private String state; + + /* + * The completed time + */ + private String completedTime; + + /* + * The created time + */ + private String createdTime; + + /* + * The list of action detail + */ + private List actionDetails; + + /** + * Creates an instance of TestNotificationDetailsResponseInner class. + */ + public TestNotificationDetailsResponseInner() { + } + + /** + * Get the context property: The context info. + * + * @return the context value. + */ + public Context context() { + return this.context; + } + + /** + * Set the context property: The context info. + * + * @param context the context value to set. + * @return the TestNotificationDetailsResponseInner object itself. + */ + public TestNotificationDetailsResponseInner withContext(Context context) { + this.context = context; + return this; + } + + /** + * Get the state property: The overall state. + * + * @return the state value. + */ + public String state() { + return this.state; + } + + /** + * Set the state property: The overall state. + * + * @param state the state value to set. + * @return the TestNotificationDetailsResponseInner object itself. + */ + public TestNotificationDetailsResponseInner withState(String state) { + this.state = state; + return this; + } + + /** + * Get the completedTime property: The completed time. + * + * @return the completedTime value. + */ + public String completedTime() { + return this.completedTime; + } + + /** + * Set the completedTime property: The completed time. + * + * @param completedTime the completedTime value to set. + * @return the TestNotificationDetailsResponseInner object itself. + */ + public TestNotificationDetailsResponseInner withCompletedTime(String completedTime) { + this.completedTime = completedTime; + return this; + } + + /** + * Get the createdTime property: The created time. + * + * @return the createdTime value. + */ + public String createdTime() { + return this.createdTime; + } + + /** + * Set the createdTime property: The created time. + * + * @param createdTime the createdTime value to set. + * @return the TestNotificationDetailsResponseInner object itself. + */ + public TestNotificationDetailsResponseInner withCreatedTime(String createdTime) { + this.createdTime = createdTime; + return this; + } + + /** + * Get the actionDetails property: The list of action detail. + * + * @return the actionDetails value. + */ + public List actionDetails() { + return this.actionDetails; + } + + /** + * Set the actionDetails property: The list of action detail. + * + * @param actionDetails the actionDetails value to set. + * @return the TestNotificationDetailsResponseInner object itself. + */ + public TestNotificationDetailsResponseInner withActionDetails(List actionDetails) { + this.actionDetails = actionDetails; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (context() != null) { + context().validate(); + } + if (state() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property state in model TestNotificationDetailsResponseInner")); + } + if (actionDetails() != null) { + actionDetails().forEach(e -> e.validate()); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(TestNotificationDetailsResponseInner.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("state", this.state); + jsonWriter.writeJsonField("context", this.context); + jsonWriter.writeStringField("completedTime", this.completedTime); + jsonWriter.writeStringField("createdTime", this.createdTime); + jsonWriter.writeArrayField("actionDetails", this.actionDetails, (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of TestNotificationDetailsResponseInner from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of TestNotificationDetailsResponseInner if the JsonReader was pointing to an instance of it, + * or null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the TestNotificationDetailsResponseInner. + */ + public static TestNotificationDetailsResponseInner fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + TestNotificationDetailsResponseInner deserializedTestNotificationDetailsResponseInner + = new TestNotificationDetailsResponseInner(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("state".equals(fieldName)) { + deserializedTestNotificationDetailsResponseInner.state = reader.getString(); + } else if ("context".equals(fieldName)) { + deserializedTestNotificationDetailsResponseInner.context = Context.fromJson(reader); + } else if ("completedTime".equals(fieldName)) { + deserializedTestNotificationDetailsResponseInner.completedTime = reader.getString(); + } else if ("createdTime".equals(fieldName)) { + deserializedTestNotificationDetailsResponseInner.createdTime = reader.getString(); + } else if ("actionDetails".equals(fieldName)) { + List actionDetails = reader.readArray(reader1 -> ActionDetail.fromJson(reader1)); + deserializedTestNotificationDetailsResponseInner.actionDetails = actionDetails; + } else { + reader.skipChildren(); + } + } + + return deserializedTestNotificationDetailsResponseInner; + }); + } +} 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..3d3e111b3e8d8 --- /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,9 @@ +// 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..f76ecdb8d7d15 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/fluent/package-info.java @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +/** + * 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/ActionGroupResourceImpl.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/implementation/ActionGroupResourceImpl.java new file mode 100644 index 0000000000000..f45c581021361 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/implementation/ActionGroupResourceImpl.java @@ -0,0 +1,413 @@ +// 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.Response; +import com.azure.core.management.Region; +import com.azure.core.util.Context; +import com.azure.resourcemanager.monitor.generated.fluent.models.ActionGroupResourceInner; +import com.azure.resourcemanager.monitor.generated.models.ActionGroupPatchBody; +import com.azure.resourcemanager.monitor.generated.models.ActionGroupResource; +import com.azure.resourcemanager.monitor.generated.models.ArmRoleReceiver; +import com.azure.resourcemanager.monitor.generated.models.AutomationRunbookReceiver; +import com.azure.resourcemanager.monitor.generated.models.AzureAppPushReceiver; +import com.azure.resourcemanager.monitor.generated.models.AzureFunctionReceiver; +import com.azure.resourcemanager.monitor.generated.models.EmailReceiver; +import com.azure.resourcemanager.monitor.generated.models.EnableRequest; +import com.azure.resourcemanager.monitor.generated.models.EventHubReceiver; +import com.azure.resourcemanager.monitor.generated.models.IncidentReceiver; +import com.azure.resourcemanager.monitor.generated.models.ItsmReceiver; +import com.azure.resourcemanager.monitor.generated.models.LogicAppReceiver; +import com.azure.resourcemanager.monitor.generated.models.ManagedServiceIdentity; +import com.azure.resourcemanager.monitor.generated.models.NotificationRequestBody; +import com.azure.resourcemanager.monitor.generated.models.SmsReceiver; +import com.azure.resourcemanager.monitor.generated.models.TestNotificationDetailsResponse; +import com.azure.resourcemanager.monitor.generated.models.VoiceReceiver; +import com.azure.resourcemanager.monitor.generated.models.WebhookReceiver; +import java.util.Collections; +import java.util.List; +import java.util.Map; + +public final class ActionGroupResourceImpl + implements ActionGroupResource, ActionGroupResource.Definition, ActionGroupResource.Update { + private ActionGroupResourceInner innerObject; + + private final com.azure.resourcemanager.monitor.generated.MonitorManager serviceManager; + + public String id() { + return this.innerModel().id(); + } + + public String name() { + return this.innerModel().name(); + } + + public String type() { + return this.innerModel().type(); + } + + public String location() { + return this.innerModel().location(); + } + + public Map tags() { + Map inner = this.innerModel().tags(); + if (inner != null) { + return Collections.unmodifiableMap(inner); + } else { + return Collections.emptyMap(); + } + } + + public ManagedServiceIdentity identity() { + return this.innerModel().identity(); + } + + public String groupShortName() { + return this.innerModel().groupShortName(); + } + + public boolean enabled() { + return this.innerModel().enabled(); + } + + public List emailReceivers() { + List inner = this.innerModel().emailReceivers(); + if (inner != null) { + return Collections.unmodifiableList(inner); + } else { + return Collections.emptyList(); + } + } + + public List smsReceivers() { + List inner = this.innerModel().smsReceivers(); + if (inner != null) { + return Collections.unmodifiableList(inner); + } else { + return Collections.emptyList(); + } + } + + public List webhookReceivers() { + List inner = this.innerModel().webhookReceivers(); + if (inner != null) { + return Collections.unmodifiableList(inner); + } else { + return Collections.emptyList(); + } + } + + public List itsmReceivers() { + List inner = this.innerModel().itsmReceivers(); + if (inner != null) { + return Collections.unmodifiableList(inner); + } else { + return Collections.emptyList(); + } + } + + public List azureAppPushReceivers() { + List inner = this.innerModel().azureAppPushReceivers(); + if (inner != null) { + return Collections.unmodifiableList(inner); + } else { + return Collections.emptyList(); + } + } + + public List automationRunbookReceivers() { + List inner = this.innerModel().automationRunbookReceivers(); + if (inner != null) { + return Collections.unmodifiableList(inner); + } else { + return Collections.emptyList(); + } + } + + public List voiceReceivers() { + List inner = this.innerModel().voiceReceivers(); + if (inner != null) { + return Collections.unmodifiableList(inner); + } else { + return Collections.emptyList(); + } + } + + public List logicAppReceivers() { + List inner = this.innerModel().logicAppReceivers(); + if (inner != null) { + return Collections.unmodifiableList(inner); + } else { + return Collections.emptyList(); + } + } + + public List azureFunctionReceivers() { + List inner = this.innerModel().azureFunctionReceivers(); + if (inner != null) { + return Collections.unmodifiableList(inner); + } else { + return Collections.emptyList(); + } + } + + public List armRoleReceivers() { + List inner = this.innerModel().armRoleReceivers(); + if (inner != null) { + return Collections.unmodifiableList(inner); + } else { + return Collections.emptyList(); + } + } + + public List eventHubReceivers() { + List inner = this.innerModel().eventHubReceivers(); + if (inner != null) { + return Collections.unmodifiableList(inner); + } else { + return Collections.emptyList(); + } + } + + public List incidentReceivers() { + List inner = this.innerModel().incidentReceivers(); + if (inner != null) { + return Collections.unmodifiableList(inner); + } else { + return Collections.emptyList(); + } + } + + public Region region() { + return Region.fromName(this.regionName()); + } + + public String regionName() { + return this.location(); + } + + public String resourceGroupName() { + return resourceGroupName; + } + + public ActionGroupResourceInner innerModel() { + return this.innerObject; + } + + private com.azure.resourcemanager.monitor.generated.MonitorManager manager() { + return this.serviceManager; + } + + private String resourceGroupName; + + private String actionGroupName; + + private ActionGroupPatchBody updateActionGroupPatch; + + public ActionGroupResourceImpl withExistingResourceGroup(String resourceGroupName) { + this.resourceGroupName = resourceGroupName; + return this; + } + + public ActionGroupResource create() { + this.innerObject = serviceManager.serviceClient() + .getActionGroups() + .createOrUpdateWithResponse(resourceGroupName, actionGroupName, this.innerModel(), Context.NONE) + .getValue(); + return this; + } + + public ActionGroupResource create(Context context) { + this.innerObject = serviceManager.serviceClient() + .getActionGroups() + .createOrUpdateWithResponse(resourceGroupName, actionGroupName, this.innerModel(), context) + .getValue(); + return this; + } + + ActionGroupResourceImpl(String name, com.azure.resourcemanager.monitor.generated.MonitorManager serviceManager) { + this.innerObject = new ActionGroupResourceInner(); + this.serviceManager = serviceManager; + this.actionGroupName = name; + } + + public ActionGroupResourceImpl update() { + this.updateActionGroupPatch = new ActionGroupPatchBody(); + return this; + } + + public ActionGroupResource apply() { + this.innerObject = serviceManager.serviceClient() + .getActionGroups() + .updateWithResponse(resourceGroupName, actionGroupName, updateActionGroupPatch, Context.NONE) + .getValue(); + return this; + } + + public ActionGroupResource apply(Context context) { + this.innerObject = serviceManager.serviceClient() + .getActionGroups() + .updateWithResponse(resourceGroupName, actionGroupName, updateActionGroupPatch, context) + .getValue(); + return this; + } + + ActionGroupResourceImpl(ActionGroupResourceInner innerObject, + com.azure.resourcemanager.monitor.generated.MonitorManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + this.resourceGroupName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "resourceGroups"); + this.actionGroupName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "actionGroups"); + } + + public ActionGroupResource refresh() { + this.innerObject = serviceManager.serviceClient() + .getActionGroups() + .getByResourceGroupWithResponse(resourceGroupName, actionGroupName, Context.NONE) + .getValue(); + return this; + } + + public ActionGroupResource refresh(Context context) { + this.innerObject = serviceManager.serviceClient() + .getActionGroups() + .getByResourceGroupWithResponse(resourceGroupName, actionGroupName, context) + .getValue(); + return this; + } + + public TestNotificationDetailsResponse + createNotificationsAtActionGroupResourceLevel(NotificationRequestBody notificationRequest) { + return serviceManager.actionGroups() + .createNotificationsAtActionGroupResourceLevel(resourceGroupName, actionGroupName, notificationRequest); + } + + public TestNotificationDetailsResponse + createNotificationsAtActionGroupResourceLevel(NotificationRequestBody notificationRequest, Context context) { + return serviceManager.actionGroups() + .createNotificationsAtActionGroupResourceLevel(resourceGroupName, actionGroupName, notificationRequest, + context); + } + + public Response enableReceiverWithResponse(EnableRequest enableRequest, Context context) { + return serviceManager.actionGroups() + .enableReceiverWithResponse(resourceGroupName, actionGroupName, enableRequest, context); + } + + public void enableReceiver(EnableRequest enableRequest) { + serviceManager.actionGroups().enableReceiver(resourceGroupName, actionGroupName, enableRequest); + } + + public ActionGroupResourceImpl withRegion(Region location) { + this.innerModel().withLocation(location.toString()); + return this; + } + + public ActionGroupResourceImpl withRegion(String location) { + this.innerModel().withLocation(location); + return this; + } + + public ActionGroupResourceImpl withTags(Map tags) { + if (isInCreateMode()) { + this.innerModel().withTags(tags); + return this; + } else { + this.updateActionGroupPatch.withTags(tags); + return this; + } + } + + public ActionGroupResourceImpl withIdentity(ManagedServiceIdentity identity) { + if (isInCreateMode()) { + this.innerModel().withIdentity(identity); + return this; + } else { + this.updateActionGroupPatch.withIdentity(identity); + return this; + } + } + + public ActionGroupResourceImpl withGroupShortName(String groupShortName) { + this.innerModel().withGroupShortName(groupShortName); + return this; + } + + public ActionGroupResourceImpl withEnabled(boolean enabled) { + this.innerModel().withEnabled(enabled); + return this; + } + + public ActionGroupResourceImpl withEmailReceivers(List emailReceivers) { + this.innerModel().withEmailReceivers(emailReceivers); + return this; + } + + public ActionGroupResourceImpl withSmsReceivers(List smsReceivers) { + this.innerModel().withSmsReceivers(smsReceivers); + return this; + } + + public ActionGroupResourceImpl withWebhookReceivers(List webhookReceivers) { + this.innerModel().withWebhookReceivers(webhookReceivers); + return this; + } + + public ActionGroupResourceImpl withItsmReceivers(List itsmReceivers) { + this.innerModel().withItsmReceivers(itsmReceivers); + return this; + } + + public ActionGroupResourceImpl withAzureAppPushReceivers(List azureAppPushReceivers) { + this.innerModel().withAzureAppPushReceivers(azureAppPushReceivers); + return this; + } + + public ActionGroupResourceImpl + withAutomationRunbookReceivers(List automationRunbookReceivers) { + this.innerModel().withAutomationRunbookReceivers(automationRunbookReceivers); + return this; + } + + public ActionGroupResourceImpl withVoiceReceivers(List voiceReceivers) { + this.innerModel().withVoiceReceivers(voiceReceivers); + return this; + } + + public ActionGroupResourceImpl withLogicAppReceivers(List logicAppReceivers) { + this.innerModel().withLogicAppReceivers(logicAppReceivers); + return this; + } + + public ActionGroupResourceImpl withAzureFunctionReceivers(List azureFunctionReceivers) { + this.innerModel().withAzureFunctionReceivers(azureFunctionReceivers); + return this; + } + + public ActionGroupResourceImpl withArmRoleReceivers(List armRoleReceivers) { + this.innerModel().withArmRoleReceivers(armRoleReceivers); + return this; + } + + public ActionGroupResourceImpl withEventHubReceivers(List eventHubReceivers) { + this.innerModel().withEventHubReceivers(eventHubReceivers); + return this; + } + + public ActionGroupResourceImpl withIncidentReceivers(List incidentReceivers) { + this.innerModel().withIncidentReceivers(incidentReceivers); + return this; + } + + public ActionGroupResourceImpl withEnabled(Boolean enabled) { + this.updateActionGroupPatch.withEnabled(enabled); + 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/ActionGroupsClientImpl.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/implementation/ActionGroupsClientImpl.java new file mode 100644 index 0000000000000..ad7fb09ebbbf9 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/implementation/ActionGroupsClientImpl.java @@ -0,0 +1,1471 @@ +// 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.Post; +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.management.polling.PollResult; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import com.azure.core.util.polling.PollerFlux; +import com.azure.core.util.polling.SyncPoller; +import com.azure.resourcemanager.monitor.generated.fluent.ActionGroupsClient; +import com.azure.resourcemanager.monitor.generated.fluent.models.ActionGroupResourceInner; +import com.azure.resourcemanager.monitor.generated.fluent.models.TestNotificationDetailsResponseInner; +import com.azure.resourcemanager.monitor.generated.models.ActionGroupList; +import com.azure.resourcemanager.monitor.generated.models.ActionGroupPatchBody; +import com.azure.resourcemanager.monitor.generated.models.EnableRequest; +import com.azure.resourcemanager.monitor.generated.models.NotificationRequestBody; +import java.nio.ByteBuffer; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in ActionGroupsClient. + */ +public final class ActionGroupsClientImpl implements ActionGroupsClient { + /** + * The proxy service used to perform REST calls. + */ + private final ActionGroupsService service; + + /** + * The service client containing this operation class. + */ + private final MonitorClientImpl client; + + /** + * Initializes an instance of ActionGroupsClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + ActionGroupsClientImpl(MonitorClientImpl client) { + this.service + = RestProxy.create(ActionGroupsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for MonitorClientActionGroups to be used by the proxy service to perform + * REST calls. + */ + @Host("{$host}") + @ServiceInterface(name = "MonitorClientActionG") + public interface ActionGroupsService { + @Headers({ "Content-Type: application/json" }) + @Put("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}") + @ExpectedResponses({ 200, 201 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> createOrUpdate(@HostParam("$host") String endpoint, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("actionGroupName") String actionGroupName, @PathParam("subscriptionId") String subscriptionId, + @QueryParam("api-version") String apiVersion, + @BodyParam("application/json") ActionGroupResourceInner actionGroup, @HeaderParam("Accept") String accept, + Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> getByResourceGroup(@HostParam("$host") String endpoint, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("actionGroupName") String actionGroupName, @PathParam("subscriptionId") String subscriptionId, + @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Delete("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}") + @ExpectedResponses({ 200, 204 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> delete(@HostParam("$host") String endpoint, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("actionGroupName") String actionGroupName, @PathParam("subscriptionId") String subscriptionId, + @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Patch("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> update(@HostParam("$host") String endpoint, + @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("actionGroupName") String actionGroupName, @QueryParam("api-version") String apiVersion, + @BodyParam("application/json") ActionGroupPatchBody actionGroupPatch, @HeaderParam("Accept") String accept, + Context context); + + @Headers({ "Content-Type: application/json" }) + @Post("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/createNotifications") + @ExpectedResponses({ 200, 202 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono>> createNotificationsAtActionGroupResourceLevel( + @HostParam("$host") String endpoint, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("actionGroupName") String actionGroupName, @QueryParam("api-version") String apiVersion, + @BodyParam("application/json") NotificationRequestBody notificationRequest, + @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/notificationStatus/{notificationId}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> getTestNotificationsAtActionGroupResourceLevel( + @HostParam("$host") String endpoint, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("actionGroupName") String actionGroupName, @PathParam("notificationId") String notificationId, + @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/providers/Microsoft.Insights/actionGroups") + @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/actionGroups") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listByResourceGroup(@HostParam("$host") String endpoint, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("subscriptionId") String subscriptionId, @QueryParam("api-version") String apiVersion, + @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Post("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/subscribe") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ManagementException.class, code = { 409 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> enableReceiver(@HostParam("$host") String endpoint, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("actionGroupName") String actionGroupName, @PathParam("subscriptionId") String subscriptionId, + @QueryParam("api-version") String apiVersion, @BodyParam("application/json") EnableRequest enableRequest, + @HeaderParam("Accept") String accept, Context context); + } + + /** + * Create a new action group or update an existing one. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param actionGroupName The name of the action group. + * @param actionGroup The action group 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 action group resource along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> createOrUpdateWithResponseAsync(String resourceGroupName, + String actionGroupName, ActionGroupResourceInner actionGroup) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (actionGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter actionGroupName 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 (actionGroup == null) { + return Mono.error(new IllegalArgumentException("Parameter actionGroup is required and cannot be null.")); + } else { + actionGroup.validate(); + } + final String apiVersion = "2024-10-01-preview"; + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.createOrUpdate(this.client.getEndpoint(), resourceGroupName, + actionGroupName, this.client.getSubscriptionId(), apiVersion, actionGroup, accept, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Create a new action group or update an existing one. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param actionGroupName The name of the action group. + * @param actionGroup The action group 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 action group resource along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> createOrUpdateWithResponseAsync(String resourceGroupName, + String actionGroupName, ActionGroupResourceInner actionGroup, Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (actionGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter actionGroupName 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 (actionGroup == null) { + return Mono.error(new IllegalArgumentException("Parameter actionGroup is required and cannot be null.")); + } else { + actionGroup.validate(); + } + final String apiVersion = "2024-10-01-preview"; + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.createOrUpdate(this.client.getEndpoint(), resourceGroupName, actionGroupName, + this.client.getSubscriptionId(), apiVersion, actionGroup, accept, context); + } + + /** + * Create a new action group or update an existing one. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param actionGroupName The name of the action group. + * @param actionGroup The action group 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 action group resource on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono createOrUpdateAsync(String resourceGroupName, String actionGroupName, + ActionGroupResourceInner actionGroup) { + return createOrUpdateWithResponseAsync(resourceGroupName, actionGroupName, actionGroup) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Create a new action group or update an existing one. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param actionGroupName The name of the action group. + * @param actionGroup The action group 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 action group resource along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response createOrUpdateWithResponse(String resourceGroupName, + String actionGroupName, ActionGroupResourceInner actionGroup, Context context) { + return createOrUpdateWithResponseAsync(resourceGroupName, actionGroupName, actionGroup, context).block(); + } + + /** + * Create a new action group or update an existing one. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param actionGroupName The name of the action group. + * @param actionGroup The action group 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 action group resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ActionGroupResourceInner createOrUpdate(String resourceGroupName, String actionGroupName, + ActionGroupResourceInner actionGroup) { + return createOrUpdateWithResponse(resourceGroupName, actionGroupName, actionGroup, Context.NONE).getValue(); + } + + /** + * Get an action group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param actionGroupName The name of the action group. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an action group along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getByResourceGroupWithResponseAsync(String resourceGroupName, + String actionGroupName) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (actionGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter actionGroupName 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 apiVersion = "2024-10-01-preview"; + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getByResourceGroup(this.client.getEndpoint(), resourceGroupName, + actionGroupName, this.client.getSubscriptionId(), apiVersion, accept, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get an action group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param actionGroupName The name of the action group. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an action group along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getByResourceGroupWithResponseAsync(String resourceGroupName, + String actionGroupName, Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (actionGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter actionGroupName 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 apiVersion = "2024-10-01-preview"; + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.getByResourceGroup(this.client.getEndpoint(), resourceGroupName, actionGroupName, + this.client.getSubscriptionId(), apiVersion, accept, context); + } + + /** + * Get an action group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param actionGroupName The name of the action group. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an action group on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono getByResourceGroupAsync(String resourceGroupName, String actionGroupName) { + return getByResourceGroupWithResponseAsync(resourceGroupName, actionGroupName) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Get an action group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param actionGroupName The name of the action group. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an action group along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getByResourceGroupWithResponse(String resourceGroupName, + String actionGroupName, Context context) { + return getByResourceGroupWithResponseAsync(resourceGroupName, actionGroupName, context).block(); + } + + /** + * Get an action group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param actionGroupName The name of the action group. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an action group. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ActionGroupResourceInner getByResourceGroup(String resourceGroupName, String actionGroupName) { + return getByResourceGroupWithResponse(resourceGroupName, actionGroupName, Context.NONE).getValue(); + } + + /** + * Delete an action group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param actionGroupName The name of the action group. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> deleteWithResponseAsync(String resourceGroupName, String actionGroupName) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (actionGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter actionGroupName 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 apiVersion = "2024-10-01-preview"; + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.delete(this.client.getEndpoint(), resourceGroupName, actionGroupName, + this.client.getSubscriptionId(), apiVersion, accept, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Delete an action group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param actionGroupName The name of the action group. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> deleteWithResponseAsync(String resourceGroupName, String actionGroupName, + Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (actionGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter actionGroupName 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 apiVersion = "2024-10-01-preview"; + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.delete(this.client.getEndpoint(), resourceGroupName, actionGroupName, + this.client.getSubscriptionId(), apiVersion, accept, context); + } + + /** + * Delete an action group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param actionGroupName The name of the action group. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono deleteAsync(String resourceGroupName, String actionGroupName) { + return deleteWithResponseAsync(resourceGroupName, actionGroupName).flatMap(ignored -> Mono.empty()); + } + + /** + * Delete an action group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param actionGroupName The name of the action group. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response deleteWithResponse(String resourceGroupName, String actionGroupName, Context context) { + return deleteWithResponseAsync(resourceGroupName, actionGroupName, context).block(); + } + + /** + * Delete an action group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param actionGroupName The name of the action group. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public void delete(String resourceGroupName, String actionGroupName) { + deleteWithResponse(resourceGroupName, actionGroupName, Context.NONE); + } + + /** + * Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param actionGroupName The name of the action group. + * @param actionGroupPatch 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 action group resource along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> updateWithResponseAsync(String resourceGroupName, + String actionGroupName, ActionGroupPatchBody actionGroupPatch) { + 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 (actionGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter actionGroupName is required and cannot be null.")); + } + if (actionGroupPatch == null) { + return Mono + .error(new IllegalArgumentException("Parameter actionGroupPatch is required and cannot be null.")); + } else { + actionGroupPatch.validate(); + } + final String apiVersion = "2024-10-01-preview"; + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.update(this.client.getEndpoint(), this.client.getSubscriptionId(), + resourceGroupName, actionGroupName, apiVersion, actionGroupPatch, accept, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param actionGroupName The name of the action group. + * @param actionGroupPatch 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 action group resource along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> updateWithResponseAsync(String resourceGroupName, + String actionGroupName, ActionGroupPatchBody actionGroupPatch, 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 (actionGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter actionGroupName is required and cannot be null.")); + } + if (actionGroupPatch == null) { + return Mono + .error(new IllegalArgumentException("Parameter actionGroupPatch is required and cannot be null.")); + } else { + actionGroupPatch.validate(); + } + final String apiVersion = "2024-10-01-preview"; + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.update(this.client.getEndpoint(), this.client.getSubscriptionId(), resourceGroupName, + actionGroupName, apiVersion, actionGroupPatch, accept, context); + } + + /** + * Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param actionGroupName The name of the action group. + * @param actionGroupPatch 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 action group resource on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono updateAsync(String resourceGroupName, String actionGroupName, + ActionGroupPatchBody actionGroupPatch) { + return updateWithResponseAsync(resourceGroupName, actionGroupName, actionGroupPatch) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param actionGroupName The name of the action group. + * @param actionGroupPatch 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 action group resource along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response updateWithResponse(String resourceGroupName, String actionGroupName, + ActionGroupPatchBody actionGroupPatch, Context context) { + return updateWithResponseAsync(resourceGroupName, actionGroupName, actionGroupPatch, context).block(); + } + + /** + * Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param actionGroupName The name of the action group. + * @param actionGroupPatch 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 action group resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ActionGroupResourceInner update(String resourceGroupName, String actionGroupName, + ActionGroupPatchBody actionGroupPatch) { + return updateWithResponse(resourceGroupName, actionGroupName, actionGroupPatch, Context.NONE).getValue(); + } + + /** + * Send test notifications to a set of provided receivers. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param actionGroupName The name of the action group. + * @param notificationRequest The notification request body which includes the contact details. + * @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 details of the test notification results along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> createNotificationsAtActionGroupResourceLevelWithResponseAsync( + String resourceGroupName, String actionGroupName, NotificationRequestBody notificationRequest) { + 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 (actionGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter actionGroupName is required and cannot be null.")); + } + if (notificationRequest == null) { + return Mono + .error(new IllegalArgumentException("Parameter notificationRequest is required and cannot be null.")); + } else { + notificationRequest.validate(); + } + final String apiVersion = "2024-10-01-preview"; + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.createNotificationsAtActionGroupResourceLevel(this.client.getEndpoint(), + this.client.getSubscriptionId(), resourceGroupName, actionGroupName, apiVersion, notificationRequest, + accept, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Send test notifications to a set of provided receivers. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param actionGroupName The name of the action group. + * @param notificationRequest The notification request body which includes the contact details. + * @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 details of the test notification results along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> createNotificationsAtActionGroupResourceLevelWithResponseAsync( + String resourceGroupName, String actionGroupName, NotificationRequestBody notificationRequest, + 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 (actionGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter actionGroupName is required and cannot be null.")); + } + if (notificationRequest == null) { + return Mono + .error(new IllegalArgumentException("Parameter notificationRequest is required and cannot be null.")); + } else { + notificationRequest.validate(); + } + final String apiVersion = "2024-10-01-preview"; + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.createNotificationsAtActionGroupResourceLevel(this.client.getEndpoint(), + this.client.getSubscriptionId(), resourceGroupName, actionGroupName, apiVersion, notificationRequest, + accept, context); + } + + /** + * Send test notifications to a set of provided receivers. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param actionGroupName The name of the action group. + * @param notificationRequest The notification request body which includes the contact details. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link PollerFlux} for polling of the details of the test notification results. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, TestNotificationDetailsResponseInner> + beginCreateNotificationsAtActionGroupResourceLevelAsync(String resourceGroupName, String actionGroupName, + NotificationRequestBody notificationRequest) { + Mono>> mono = createNotificationsAtActionGroupResourceLevelWithResponseAsync( + resourceGroupName, actionGroupName, notificationRequest); + return this.client.getLroResult( + mono, this.client.getHttpPipeline(), TestNotificationDetailsResponseInner.class, + TestNotificationDetailsResponseInner.class, this.client.getContext()); + } + + /** + * Send test notifications to a set of provided receivers. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param actionGroupName The name of the action group. + * @param notificationRequest The notification request body which includes the contact details. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link PollerFlux} for polling of the details of the test notification results. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, TestNotificationDetailsResponseInner> + beginCreateNotificationsAtActionGroupResourceLevelAsync(String resourceGroupName, String actionGroupName, + NotificationRequestBody notificationRequest, Context context) { + context = this.client.mergeContext(context); + Mono>> mono = createNotificationsAtActionGroupResourceLevelWithResponseAsync( + resourceGroupName, actionGroupName, notificationRequest, context); + return this.client.getLroResult( + mono, this.client.getHttpPipeline(), TestNotificationDetailsResponseInner.class, + TestNotificationDetailsResponseInner.class, context); + } + + /** + * Send test notifications to a set of provided receivers. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param actionGroupName The name of the action group. + * @param notificationRequest The notification request body which includes the contact details. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of the details of the test notification results. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, TestNotificationDetailsResponseInner> + beginCreateNotificationsAtActionGroupResourceLevel(String resourceGroupName, String actionGroupName, + NotificationRequestBody notificationRequest) { + return this + .beginCreateNotificationsAtActionGroupResourceLevelAsync(resourceGroupName, actionGroupName, + notificationRequest) + .getSyncPoller(); + } + + /** + * Send test notifications to a set of provided receivers. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param actionGroupName The name of the action group. + * @param notificationRequest The notification request body which includes the contact details. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of the details of the test notification results. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, TestNotificationDetailsResponseInner> + beginCreateNotificationsAtActionGroupResourceLevel(String resourceGroupName, String actionGroupName, + NotificationRequestBody notificationRequest, Context context) { + return this + .beginCreateNotificationsAtActionGroupResourceLevelAsync(resourceGroupName, actionGroupName, + notificationRequest, context) + .getSyncPoller(); + } + + /** + * Send test notifications to a set of provided receivers. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param actionGroupName The name of the action group. + * @param notificationRequest The notification request body which includes the contact details. + * @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 details of the test notification results on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono createNotificationsAtActionGroupResourceLevelAsync( + String resourceGroupName, String actionGroupName, NotificationRequestBody notificationRequest) { + return beginCreateNotificationsAtActionGroupResourceLevelAsync(resourceGroupName, actionGroupName, + notificationRequest).last().flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Send test notifications to a set of provided receivers. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param actionGroupName The name of the action group. + * @param notificationRequest The notification request body which includes the contact details. + * @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 details of the test notification results on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono createNotificationsAtActionGroupResourceLevelAsync( + String resourceGroupName, String actionGroupName, NotificationRequestBody notificationRequest, + Context context) { + return beginCreateNotificationsAtActionGroupResourceLevelAsync(resourceGroupName, actionGroupName, + notificationRequest, context).last().flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Send test notifications to a set of provided receivers. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param actionGroupName The name of the action group. + * @param notificationRequest The notification request body which includes the contact details. + * @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 details of the test notification results. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public TestNotificationDetailsResponseInner createNotificationsAtActionGroupResourceLevel(String resourceGroupName, + String actionGroupName, NotificationRequestBody notificationRequest) { + return createNotificationsAtActionGroupResourceLevelAsync(resourceGroupName, actionGroupName, + notificationRequest).block(); + } + + /** + * Send test notifications to a set of provided receivers. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param actionGroupName The name of the action group. + * @param notificationRequest The notification request body which includes the contact details. + * @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 details of the test notification results. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public TestNotificationDetailsResponseInner createNotificationsAtActionGroupResourceLevel(String resourceGroupName, + String actionGroupName, NotificationRequestBody notificationRequest, Context context) { + return createNotificationsAtActionGroupResourceLevelAsync(resourceGroupName, actionGroupName, + notificationRequest, context).block(); + } + + /** + * Get the test notifications by the notification id. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param actionGroupName The name of the action group. + * @param notificationId The notification id. + * @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 test notifications by the notification id along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> + getTestNotificationsAtActionGroupResourceLevelWithResponseAsync(String resourceGroupName, + String actionGroupName, String notificationId) { + 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 (actionGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter actionGroupName is required and cannot be null.")); + } + if (notificationId == null) { + return Mono.error(new IllegalArgumentException("Parameter notificationId is required and cannot be null.")); + } + final String apiVersion = "2024-10-01-preview"; + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getTestNotificationsAtActionGroupResourceLevel(this.client.getEndpoint(), + this.client.getSubscriptionId(), resourceGroupName, actionGroupName, notificationId, apiVersion, accept, + context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get the test notifications by the notification id. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param actionGroupName The name of the action group. + * @param notificationId The notification id. + * @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 test notifications by the notification id along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> + getTestNotificationsAtActionGroupResourceLevelWithResponseAsync(String resourceGroupName, + String actionGroupName, String notificationId, 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 (actionGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter actionGroupName is required and cannot be null.")); + } + if (notificationId == null) { + return Mono.error(new IllegalArgumentException("Parameter notificationId is required and cannot be null.")); + } + final String apiVersion = "2024-10-01-preview"; + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.getTestNotificationsAtActionGroupResourceLevel(this.client.getEndpoint(), + this.client.getSubscriptionId(), resourceGroupName, actionGroupName, notificationId, apiVersion, accept, + context); + } + + /** + * Get the test notifications by the notification id. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param actionGroupName The name of the action group. + * @param notificationId The notification id. + * @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 test notifications by the notification id on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono getTestNotificationsAtActionGroupResourceLevelAsync( + String resourceGroupName, String actionGroupName, String notificationId) { + return getTestNotificationsAtActionGroupResourceLevelWithResponseAsync(resourceGroupName, actionGroupName, + notificationId).flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Get the test notifications by the notification id. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param actionGroupName The name of the action group. + * @param notificationId The notification id. + * @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 test notifications by the notification id along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getTestNotificationsAtActionGroupResourceLevelWithResponse( + String resourceGroupName, String actionGroupName, String notificationId, Context context) { + return getTestNotificationsAtActionGroupResourceLevelWithResponseAsync(resourceGroupName, actionGroupName, + notificationId, context).block(); + } + + /** + * Get the test notifications by the notification id. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param actionGroupName The name of the action group. + * @param notificationId The notification id. + * @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 test notifications by the notification id. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public TestNotificationDetailsResponseInner getTestNotificationsAtActionGroupResourceLevel(String resourceGroupName, + String actionGroupName, String notificationId) { + return getTestNotificationsAtActionGroupResourceLevelWithResponse(resourceGroupName, actionGroupName, + notificationId, Context.NONE).getValue(); + } + + /** + * Get a list of all action groups 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 action groups in a subscription along with {@link PagedResponse} on successful completion + * of {@link Mono}. + */ + @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 apiVersion = "2024-10-01-preview"; + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.list(this.client.getEndpoint(), this.client.getSubscriptionId(), apiVersion, + accept, context)) + .>map(res -> new PagedResponseBase<>(res.getRequest(), + res.getStatusCode(), res.getHeaders(), res.getValue().value(), null, null)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get a list of all action groups 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 action groups in a subscription along with {@link PagedResponse} on successful completion + * of {@link Mono}. + */ + @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 apiVersion = "2024-10-01-preview"; + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.list(this.client.getEndpoint(), this.client.getSubscriptionId(), apiVersion, accept, context) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + res.getValue().value(), null, null)); + } + + /** + * Get a list of all action groups 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 action groups in a subscription as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync() { + return new PagedFlux<>(() -> listSinglePageAsync()); + } + + /** + * Get a list of all action groups 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 action groups in a subscription as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync(Context context) { + return new PagedFlux<>(() -> listSinglePageAsync(context)); + } + + /** + * Get a list of all action groups 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 action groups in a subscription as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list() { + return new PagedIterable<>(listAsync()); + } + + /** + * Get a list of all action groups 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 action groups in a subscription as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(Context context) { + return new PagedIterable<>(listAsync(context)); + } + + /** + * Get a list of all action groups 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 action groups in a resource group along with {@link PagedResponse} on successful completion + * of {@link Mono}. + */ + @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 (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName 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 apiVersion = "2024-10-01-preview"; + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.listByResourceGroup(this.client.getEndpoint(), resourceGroupName, + this.client.getSubscriptionId(), apiVersion, accept, context)) + .>map(res -> new PagedResponseBase<>(res.getRequest(), + res.getStatusCode(), res.getHeaders(), res.getValue().value(), null, null)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get a list of all action groups 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 action groups in a resource group along with {@link PagedResponse} on successful completion + * of {@link Mono}. + */ + @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 (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName 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 apiVersion = "2024-10-01-preview"; + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .listByResourceGroup(this.client.getEndpoint(), resourceGroupName, this.client.getSubscriptionId(), + apiVersion, accept, context) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + res.getValue().value(), null, null)); + } + + /** + * Get a list of all action groups 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 action groups in a resource group as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listByResourceGroupAsync(String resourceGroupName) { + return new PagedFlux<>(() -> listByResourceGroupSinglePageAsync(resourceGroupName)); + } + + /** + * Get a list of all action groups 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 action groups in a resource group as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listByResourceGroupAsync(String resourceGroupName, Context context) { + return new PagedFlux<>(() -> listByResourceGroupSinglePageAsync(resourceGroupName, context)); + } + + /** + * Get a list of all action groups 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 action groups in a resource group as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listByResourceGroup(String resourceGroupName) { + return new PagedIterable<>(listByResourceGroupAsync(resourceGroupName)); + } + + /** + * Get a list of all action groups 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 action groups in a resource group as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listByResourceGroup(String resourceGroupName, Context context) { + return new PagedIterable<>(listByResourceGroupAsync(resourceGroupName, context)); + } + + /** + * Enable a receiver in an action group. This changes the receiver's status from Disabled to Enabled. This operation + * is only supported for Email or SMS receivers. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param actionGroupName The name of the action group. + * @param enableRequest The receiver to re-enable. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws ManagementException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> enableReceiverWithResponseAsync(String resourceGroupName, String actionGroupName, + EnableRequest enableRequest) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (actionGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter actionGroupName 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 (enableRequest == null) { + return Mono.error(new IllegalArgumentException("Parameter enableRequest is required and cannot be null.")); + } else { + enableRequest.validate(); + } + final String apiVersion = "2024-10-01-preview"; + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.enableReceiver(this.client.getEndpoint(), resourceGroupName, + actionGroupName, this.client.getSubscriptionId(), apiVersion, enableRequest, accept, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Enable a receiver in an action group. This changes the receiver's status from Disabled to Enabled. This operation + * is only supported for Email or SMS receivers. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param actionGroupName The name of the action group. + * @param enableRequest The receiver to re-enable. + * @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 ManagementException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> enableReceiverWithResponseAsync(String resourceGroupName, String actionGroupName, + EnableRequest enableRequest, Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (actionGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter actionGroupName 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 (enableRequest == null) { + return Mono.error(new IllegalArgumentException("Parameter enableRequest is required and cannot be null.")); + } else { + enableRequest.validate(); + } + final String apiVersion = "2024-10-01-preview"; + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.enableReceiver(this.client.getEndpoint(), resourceGroupName, actionGroupName, + this.client.getSubscriptionId(), apiVersion, enableRequest, accept, context); + } + + /** + * Enable a receiver in an action group. This changes the receiver's status from Disabled to Enabled. This operation + * is only supported for Email or SMS receivers. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param actionGroupName The name of the action group. + * @param enableRequest The receiver to re-enable. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws ManagementException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono enableReceiverAsync(String resourceGroupName, String actionGroupName, + EnableRequest enableRequest) { + return enableReceiverWithResponseAsync(resourceGroupName, actionGroupName, enableRequest) + .flatMap(ignored -> Mono.empty()); + } + + /** + * Enable a receiver in an action group. This changes the receiver's status from Disabled to Enabled. This operation + * is only supported for Email or SMS receivers. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param actionGroupName The name of the action group. + * @param enableRequest The receiver to re-enable. + * @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 ManagementException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response enableReceiverWithResponse(String resourceGroupName, String actionGroupName, + EnableRequest enableRequest, Context context) { + return enableReceiverWithResponseAsync(resourceGroupName, actionGroupName, enableRequest, context).block(); + } + + /** + * Enable a receiver in an action group. This changes the receiver's status from Disabled to Enabled. This operation + * is only supported for Email or SMS receivers. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param actionGroupName The name of the action group. + * @param enableRequest The receiver to re-enable. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws ManagementException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public void enableReceiver(String resourceGroupName, String actionGroupName, EnableRequest enableRequest) { + enableReceiverWithResponse(resourceGroupName, actionGroupName, enableRequest, Context.NONE); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/implementation/ActionGroupsImpl.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/implementation/ActionGroupsImpl.java new file mode 100644 index 0000000000000..b6290456c24f5 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/implementation/ActionGroupsImpl.java @@ -0,0 +1,209 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.monitor.generated.implementation; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.SimpleResponse; +import com.azure.core.util.Context; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.monitor.generated.fluent.ActionGroupsClient; +import com.azure.resourcemanager.monitor.generated.fluent.models.ActionGroupResourceInner; +import com.azure.resourcemanager.monitor.generated.fluent.models.TestNotificationDetailsResponseInner; +import com.azure.resourcemanager.monitor.generated.models.ActionGroupResource; +import com.azure.resourcemanager.monitor.generated.models.ActionGroups; +import com.azure.resourcemanager.monitor.generated.models.EnableRequest; +import com.azure.resourcemanager.monitor.generated.models.NotificationRequestBody; +import com.azure.resourcemanager.monitor.generated.models.TestNotificationDetailsResponse; + +public final class ActionGroupsImpl implements ActionGroups { + private static final ClientLogger LOGGER = new ClientLogger(ActionGroupsImpl.class); + + private final ActionGroupsClient innerClient; + + private final com.azure.resourcemanager.monitor.generated.MonitorManager serviceManager; + + public ActionGroupsImpl(ActionGroupsClient innerClient, + com.azure.resourcemanager.monitor.generated.MonitorManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public Response getByResourceGroupWithResponse(String resourceGroupName, + String actionGroupName, Context context) { + Response inner + = this.serviceClient().getByResourceGroupWithResponse(resourceGroupName, actionGroupName, context); + if (inner != null) { + return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(), + new ActionGroupResourceImpl(inner.getValue(), this.manager())); + } else { + return null; + } + } + + public ActionGroupResource getByResourceGroup(String resourceGroupName, String actionGroupName) { + ActionGroupResourceInner inner = this.serviceClient().getByResourceGroup(resourceGroupName, actionGroupName); + if (inner != null) { + return new ActionGroupResourceImpl(inner, this.manager()); + } else { + return null; + } + } + + public Response deleteByResourceGroupWithResponse(String resourceGroupName, String actionGroupName, + Context context) { + return this.serviceClient().deleteWithResponse(resourceGroupName, actionGroupName, context); + } + + public void deleteByResourceGroup(String resourceGroupName, String actionGroupName) { + this.serviceClient().delete(resourceGroupName, actionGroupName); + } + + public TestNotificationDetailsResponse createNotificationsAtActionGroupResourceLevel(String resourceGroupName, + String actionGroupName, NotificationRequestBody notificationRequest) { + TestNotificationDetailsResponseInner inner = this.serviceClient() + .createNotificationsAtActionGroupResourceLevel(resourceGroupName, actionGroupName, notificationRequest); + if (inner != null) { + return new TestNotificationDetailsResponseImpl(inner, this.manager()); + } else { + return null; + } + } + + public TestNotificationDetailsResponse createNotificationsAtActionGroupResourceLevel(String resourceGroupName, + String actionGroupName, NotificationRequestBody notificationRequest, Context context) { + TestNotificationDetailsResponseInner inner = this.serviceClient() + .createNotificationsAtActionGroupResourceLevel(resourceGroupName, actionGroupName, notificationRequest, + context); + if (inner != null) { + return new TestNotificationDetailsResponseImpl(inner, this.manager()); + } else { + return null; + } + } + + public Response getTestNotificationsAtActionGroupResourceLevelWithResponse( + String resourceGroupName, String actionGroupName, String notificationId, Context context) { + Response inner = this.serviceClient() + .getTestNotificationsAtActionGroupResourceLevelWithResponse(resourceGroupName, actionGroupName, + notificationId, context); + if (inner != null) { + return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(), + new TestNotificationDetailsResponseImpl(inner.getValue(), this.manager())); + } else { + return null; + } + } + + public TestNotificationDetailsResponse getTestNotificationsAtActionGroupResourceLevel(String resourceGroupName, + String actionGroupName, String notificationId) { + TestNotificationDetailsResponseInner inner = this.serviceClient() + .getTestNotificationsAtActionGroupResourceLevel(resourceGroupName, actionGroupName, notificationId); + if (inner != null) { + return new TestNotificationDetailsResponseImpl(inner, this.manager()); + } else { + return null; + } + } + + public PagedIterable list() { + PagedIterable inner = this.serviceClient().list(); + return ResourceManagerUtils.mapPage(inner, inner1 -> new ActionGroupResourceImpl(inner1, this.manager())); + } + + public PagedIterable list(Context context) { + PagedIterable inner = this.serviceClient().list(context); + return ResourceManagerUtils.mapPage(inner, inner1 -> new ActionGroupResourceImpl(inner1, this.manager())); + } + + public PagedIterable listByResourceGroup(String resourceGroupName) { + PagedIterable inner = this.serviceClient().listByResourceGroup(resourceGroupName); + return ResourceManagerUtils.mapPage(inner, inner1 -> new ActionGroupResourceImpl(inner1, this.manager())); + } + + public PagedIterable listByResourceGroup(String resourceGroupName, Context context) { + PagedIterable inner + = this.serviceClient().listByResourceGroup(resourceGroupName, context); + return ResourceManagerUtils.mapPage(inner, inner1 -> new ActionGroupResourceImpl(inner1, this.manager())); + } + + public Response enableReceiverWithResponse(String resourceGroupName, String actionGroupName, + EnableRequest enableRequest, Context context) { + return this.serviceClient() + .enableReceiverWithResponse(resourceGroupName, actionGroupName, enableRequest, context); + } + + public void enableReceiver(String resourceGroupName, String actionGroupName, EnableRequest enableRequest) { + this.serviceClient().enableReceiver(resourceGroupName, actionGroupName, enableRequest); + } + + public ActionGroupResource getById(String id) { + String resourceGroupName = ResourceManagerUtils.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 actionGroupName = ResourceManagerUtils.getValueFromIdByName(id, "actionGroups"); + if (actionGroupName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'actionGroups'.", id))); + } + return this.getByResourceGroupWithResponse(resourceGroupName, actionGroupName, Context.NONE).getValue(); + } + + public Response getByIdWithResponse(String id, Context context) { + String resourceGroupName = ResourceManagerUtils.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 actionGroupName = ResourceManagerUtils.getValueFromIdByName(id, "actionGroups"); + if (actionGroupName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'actionGroups'.", id))); + } + return this.getByResourceGroupWithResponse(resourceGroupName, actionGroupName, context); + } + + public void deleteById(String id) { + String resourceGroupName = ResourceManagerUtils.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 actionGroupName = ResourceManagerUtils.getValueFromIdByName(id, "actionGroups"); + if (actionGroupName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'actionGroups'.", id))); + } + this.deleteByResourceGroupWithResponse(resourceGroupName, actionGroupName, Context.NONE); + } + + public Response deleteByIdWithResponse(String id, Context context) { + String resourceGroupName = ResourceManagerUtils.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 actionGroupName = ResourceManagerUtils.getValueFromIdByName(id, "actionGroups"); + if (actionGroupName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'actionGroups'.", id))); + } + return this.deleteByResourceGroupWithResponse(resourceGroupName, actionGroupName, context); + } + + private ActionGroupsClient serviceClient() { + return this.innerClient; + } + + private com.azure.resourcemanager.monitor.generated.MonitorManager manager() { + return this.serviceManager; + } + + public ActionGroupResourceImpl define(String name) { + return new ActionGroupResourceImpl(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..23d060e45e2ef --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/implementation/MonitorClientBuilder.java @@ -0,0 +1,138 @@ +// 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.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 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 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 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() { + String localEndpoint = (endpoint != null) ? endpoint : "https://management.azure.com"; + AzureEnvironment localEnvironment = (environment != null) ? environment : AzureEnvironment.AZURE; + HttpPipeline localPipeline = (pipeline != null) + ? pipeline + : new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(); + Duration localDefaultPollInterval + = (defaultPollInterval != null) ? defaultPollInterval : Duration.ofSeconds(30); + SerializerAdapter localSerializerAdapter = (serializerAdapter != null) + ? serializerAdapter + : SerializerFactory.createDefaultManagementSerializerAdapter(); + MonitorClientImpl client = new MonitorClientImpl(localPipeline, localSerializerAdapter, + localDefaultPollInterval, localEnvironment, this.subscriptionId, localEndpoint); + 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..faa5fc61a3427 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/implementation/MonitorClientImpl.java @@ -0,0 +1,289 @@ +// 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.HttpHeaderName; +import com.azure.core.http.HttpHeaders; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpResponse; +import com.azure.core.http.rest.Response; +import com.azure.core.management.AzureEnvironment; +import com.azure.core.management.exception.ManagementError; +import com.azure.core.management.exception.ManagementException; +import com.azure.core.management.polling.PollResult; +import com.azure.core.management.polling.PollerFactory; +import com.azure.core.util.Context; +import com.azure.core.util.CoreUtils; +import com.azure.core.util.logging.ClientLogger; +import com.azure.core.util.polling.AsyncPollResponse; +import com.azure.core.util.polling.LongRunningOperationStatus; +import com.azure.core.util.polling.PollerFlux; +import com.azure.core.util.serializer.SerializerAdapter; +import com.azure.core.util.serializer.SerializerEncoding; +import com.azure.resourcemanager.monitor.generated.fluent.ActionGroupsClient; +import com.azure.resourcemanager.monitor.generated.fluent.MonitorClient; +import com.azure.resourcemanager.monitor.generated.fluent.ScheduledQueryRulesClient; +import java.io.IOException; +import java.lang.reflect.Type; +import java.nio.ByteBuffer; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.time.Duration; +import 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 { + /** + * 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; + } + + /** + * 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 ActionGroupsClient object to access its operations. + */ + private final ActionGroupsClient actionGroups; + + /** + * Gets the ActionGroupsClient object to access its operations. + * + * @return the ActionGroupsClient object. + */ + public ActionGroupsClient getActionGroups() { + return this.actionGroups; + } + + /** + * The ScheduledQueryRulesClient object to access its operations. + */ + private final ScheduledQueryRulesClient scheduledQueryRules; + + /** + * Gets the ScheduledQueryRulesClient object to access its operations. + * + * @return the ScheduledQueryRulesClient object. + */ + public ScheduledQueryRulesClient getScheduledQueryRules() { + return this.scheduledQueryRules; + } + + /** + * Initializes an instance of MonitorClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param serializerAdapter The serializer to serialize an object into a string. + * @param defaultPollInterval The default poll interval for long-running operation. + * @param environment The Azure environment. + * @param subscriptionId The ID of the target subscription. + * @param endpoint server parameter. + */ + MonitorClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, Duration defaultPollInterval, + AzureEnvironment environment, String subscriptionId, String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.defaultPollInterval = defaultPollInterval; + this.subscriptionId = subscriptionId; + this.endpoint = endpoint; + this.actionGroups = new ActionGroupsClientImpl(this); + this.scheduledQueryRules = new ScheduledQueryRulesClientImpl(this); + } + + /** + * Gets default client context. + * + * @return the default client context. + */ + public Context getContext() { + return Context.NONE; + } + + /** + * Merges default client context with provided context. + * + * @param context the context to be merged with default client context. + * @return the merged context. + */ + public Context mergeContext(Context context) { + return CoreUtils.mergeContexts(this.getContext(), context); + } + + /** + * Gets long running operation result. + * + * @param activationResponse the response of activation operation. + * @param httpPipeline the http pipeline. + * @param pollResultType type of poll result. + * @param finalResultType type of final result. + * @param context the context shared by all requests. + * @param type of poll result. + * @param type of final result. + * @return poller flux for poll result and final result. + */ + public PollerFlux, U> getLroResult(Mono>> activationResponse, + HttpPipeline httpPipeline, Type pollResultType, Type finalResultType, Context context) { + return PollerFactory.create(serializerAdapter, httpPipeline, pollResultType, finalResultType, + defaultPollInterval, activationResponse, context); + } + + /** + * Gets the final result, or an error, based on last async poll response. + * + * @param response the last async poll response. + * @param type of poll result. + * @param type of final result. + * @return the final result, or an error. + */ + public Mono getLroFinalResultOrError(AsyncPollResponse, U> response) { + if (response.getStatus() != LongRunningOperationStatus.SUCCESSFULLY_COMPLETED) { + String errorMessage; + ManagementError managementError = null; + HttpResponse errorResponse = null; + PollResult.Error lroError = response.getValue().getError(); + if (lroError != null) { + errorResponse = new HttpResponseImpl(lroError.getResponseStatusCode(), lroError.getResponseHeaders(), + lroError.getResponseBody()); + + errorMessage = response.getValue().getError().getMessage(); + String errorBody = response.getValue().getError().getResponseBody(); + if (errorBody != null) { + // try to deserialize error body to ManagementError + try { + managementError = this.getSerializerAdapter() + .deserialize(errorBody, ManagementError.class, SerializerEncoding.JSON); + if (managementError.getCode() == null || managementError.getMessage() == null) { + managementError = null; + } + } catch (IOException | RuntimeException ioe) { + LOGGER.logThrowableAsWarning(ioe); + } + } + } else { + // fallback to default error message + errorMessage = "Long running operation failed."; + } + if (managementError == null) { + // fallback to default ManagementError + managementError = new ManagementError(response.getStatus().toString(), errorMessage); + } + return Mono.error(new ManagementException(errorMessage, errorResponse, managementError)); + } else { + return response.getFinalResult(); + } + } + + private static final class HttpResponseImpl extends HttpResponse { + private final int statusCode; + + private final byte[] responseBody; + + private final HttpHeaders httpHeaders; + + HttpResponseImpl(int statusCode, HttpHeaders httpHeaders, String responseBody) { + super(null); + this.statusCode = statusCode; + this.httpHeaders = httpHeaders; + this.responseBody = responseBody == null ? null : responseBody.getBytes(StandardCharsets.UTF_8); + } + + public int getStatusCode() { + return statusCode; + } + + public String getHeaderValue(String s) { + return httpHeaders.getValue(HttpHeaderName.fromString(s)); + } + + public HttpHeaders getHeaders() { + return httpHeaders; + } + + public Flux getBody() { + return Flux.just(ByteBuffer.wrap(responseBody)); + } + + public Mono getBodyAsByteArray() { + return Mono.just(responseBody); + } + + public Mono getBodyAsString() { + return Mono.just(new String(responseBody, StandardCharsets.UTF_8)); + } + + public Mono getBodyAsString(Charset charset) { + return Mono.just(new String(responseBody, charset)); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(MonitorClientImpl.class); +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/implementation/ResourceManagerUtils.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/implementation/ResourceManagerUtils.java new file mode 100644 index 0000000000000..965c1071fca98 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/implementation/ResourceManagerUtils.java @@ -0,0 +1,195 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.monitor.generated.implementation; + +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.util.CoreUtils; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import java.util.function.Function; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import reactor.core.publisher.Flux; + +final class ResourceManagerUtils { + private ResourceManagerUtils() { + } + + static String getValueFromIdByName(String id, String name) { + if (id == null) { + return null; + } + Iterator itr = Arrays.stream(id.split("/")).iterator(); + while (itr.hasNext()) { + String part = itr.next(); + if (part != null && !part.trim().isEmpty()) { + if (part.equalsIgnoreCase(name)) { + if (itr.hasNext()) { + return itr.next(); + } else { + return null; + } + } + } + } + return null; + } + + static String getValueFromIdByParameterName(String id, String pathTemplate, String parameterName) { + if (id == null || pathTemplate == null) { + return null; + } + String parameterNameParentheses = "{" + parameterName + "}"; + List idSegmentsReverted = Arrays.asList(id.split("/")); + List pathSegments = Arrays.asList(pathTemplate.split("/")); + Collections.reverse(idSegmentsReverted); + Iterator idItrReverted = idSegmentsReverted.iterator(); + int pathIndex = pathSegments.size(); + while (idItrReverted.hasNext() && pathIndex > 0) { + String idSegment = idItrReverted.next(); + String pathSegment = pathSegments.get(--pathIndex); + if (!CoreUtils.isNullOrEmpty(idSegment) && !CoreUtils.isNullOrEmpty(pathSegment)) { + if (pathSegment.equalsIgnoreCase(parameterNameParentheses)) { + if (pathIndex == 0 || (pathIndex == 1 && pathSegments.get(0).isEmpty())) { + List segments = new ArrayList<>(); + segments.add(idSegment); + idItrReverted.forEachRemaining(segments::add); + Collections.reverse(segments); + if (!segments.isEmpty() && segments.get(0).isEmpty()) { + segments.remove(0); + } + return String.join("/", segments); + } else { + return idSegment; + } + } + } + } + return null; + } + + static PagedIterable mapPage(PagedIterable pageIterable, Function mapper) { + return new PagedIterableImpl<>(pageIterable, mapper); + } + + private static final class PagedIterableImpl extends PagedIterable { + + private final PagedIterable pagedIterable; + private final Function mapper; + private final Function, PagedResponse> pageMapper; + + private PagedIterableImpl(PagedIterable pagedIterable, Function mapper) { + super(PagedFlux.create(() -> (continuationToken, pageSize) -> Flux + .fromStream(pagedIterable.streamByPage().map(getPageMapper(mapper))))); + this.pagedIterable = pagedIterable; + this.mapper = mapper; + this.pageMapper = getPageMapper(mapper); + } + + private static Function, PagedResponse> getPageMapper(Function mapper) { + return page -> new PagedResponseBase(page.getRequest(), page.getStatusCode(), page.getHeaders(), + page.getElements().stream().map(mapper).collect(Collectors.toList()), page.getContinuationToken(), + null); + } + + @Override + public Stream stream() { + return pagedIterable.stream().map(mapper); + } + + @Override + public Stream> streamByPage() { + return pagedIterable.streamByPage().map(pageMapper); + } + + @Override + public Stream> streamByPage(String continuationToken) { + return pagedIterable.streamByPage(continuationToken).map(pageMapper); + } + + @Override + public Stream> streamByPage(int preferredPageSize) { + return pagedIterable.streamByPage(preferredPageSize).map(pageMapper); + } + + @Override + public Stream> streamByPage(String continuationToken, int preferredPageSize) { + return pagedIterable.streamByPage(continuationToken, preferredPageSize).map(pageMapper); + } + + @Override + public Iterator iterator() { + return new IteratorImpl<>(pagedIterable.iterator(), mapper); + } + + @Override + public Iterable> iterableByPage() { + return new IterableImpl<>(pagedIterable.iterableByPage(), pageMapper); + } + + @Override + public Iterable> iterableByPage(String continuationToken) { + return new IterableImpl<>(pagedIterable.iterableByPage(continuationToken), pageMapper); + } + + @Override + public Iterable> iterableByPage(int preferredPageSize) { + return new IterableImpl<>(pagedIterable.iterableByPage(preferredPageSize), pageMapper); + } + + @Override + public Iterable> iterableByPage(String continuationToken, int preferredPageSize) { + return new IterableImpl<>(pagedIterable.iterableByPage(continuationToken, preferredPageSize), pageMapper); + } + } + + private static final class IteratorImpl implements Iterator { + + private final Iterator iterator; + private final Function mapper; + + private IteratorImpl(Iterator iterator, Function mapper) { + this.iterator = iterator; + this.mapper = mapper; + } + + @Override + public boolean hasNext() { + return iterator.hasNext(); + } + + @Override + public S next() { + return mapper.apply(iterator.next()); + } + + @Override + public void remove() { + iterator.remove(); + } + } + + private static final class IterableImpl implements Iterable { + + private final Iterable iterable; + private final Function mapper; + + private IterableImpl(Iterable iterable, Function mapper) { + this.iterable = iterable; + this.mapper = mapper; + } + + @Override + public Iterator iterator() { + return new IteratorImpl<>(iterable.iterator(), mapper); + } + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/implementation/ScheduledQueryRuleResourceImpl.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/implementation/ScheduledQueryRuleResourceImpl.java new file mode 100644 index 0000000000000..0d41a8fc53eca --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/implementation/ScheduledQueryRuleResourceImpl.java @@ -0,0 +1,455 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.monitor.generated.implementation; + +import com.azure.core.management.Region; +import com.azure.core.management.SystemData; +import com.azure.core.util.Context; +import com.azure.resourcemanager.monitor.generated.fluent.models.ScheduledQueryRuleResourceInner; +import com.azure.resourcemanager.monitor.generated.models.Actions; +import com.azure.resourcemanager.monitor.generated.models.AlertSeverity; +import com.azure.resourcemanager.monitor.generated.models.Identity; +import com.azure.resourcemanager.monitor.generated.models.Kind; +import com.azure.resourcemanager.monitor.generated.models.RuleResolveConfiguration; +import com.azure.resourcemanager.monitor.generated.models.ScheduledQueryRuleCriteria; +import com.azure.resourcemanager.monitor.generated.models.ScheduledQueryRuleResource; +import com.azure.resourcemanager.monitor.generated.models.ScheduledQueryRuleResourcePatch; +import java.time.Duration; +import java.util.Collections; +import java.util.List; +import java.util.Map; + +public final class ScheduledQueryRuleResourceImpl + implements ScheduledQueryRuleResource, ScheduledQueryRuleResource.Definition, ScheduledQueryRuleResource.Update { + private ScheduledQueryRuleResourceInner innerObject; + + private final com.azure.resourcemanager.monitor.generated.MonitorManager serviceManager; + + public String id() { + return this.innerModel().id(); + } + + public String name() { + return this.innerModel().name(); + } + + public String type() { + return this.innerModel().type(); + } + + public String location() { + return this.innerModel().location(); + } + + public Map tags() { + Map inner = this.innerModel().tags(); + if (inner != null) { + return Collections.unmodifiableMap(inner); + } else { + return Collections.emptyMap(); + } + } + + public Identity identity() { + return this.innerModel().identity(); + } + + public Kind kind() { + return this.innerModel().kind(); + } + + public String etag() { + return this.innerModel().etag(); + } + + public SystemData systemData() { + return this.innerModel().systemData(); + } + + public String createdWithApiVersion() { + return this.innerModel().createdWithApiVersion(); + } + + public Boolean isLegacyLogAnalyticsRule() { + return this.innerModel().isLegacyLogAnalyticsRule(); + } + + public String description() { + return this.innerModel().description(); + } + + public String displayName() { + return this.innerModel().displayName(); + } + + public AlertSeverity severity() { + return this.innerModel().severity(); + } + + public Boolean enabled() { + return this.innerModel().enabled(); + } + + public List scopes() { + List inner = this.innerModel().scopes(); + if (inner != null) { + return Collections.unmodifiableList(inner); + } else { + return Collections.emptyList(); + } + } + + public Duration evaluationFrequency() { + return this.innerModel().evaluationFrequency(); + } + + public Duration windowSize() { + return this.innerModel().windowSize(); + } + + public Duration overrideQueryTimeRange() { + return this.innerModel().overrideQueryTimeRange(); + } + + public List targetResourceTypes() { + List inner = this.innerModel().targetResourceTypes(); + if (inner != null) { + return Collections.unmodifiableList(inner); + } else { + return Collections.emptyList(); + } + } + + public ScheduledQueryRuleCriteria criteria() { + return this.innerModel().criteria(); + } + + public Duration muteActionsDuration() { + return this.innerModel().muteActionsDuration(); + } + + public Actions actions() { + return this.innerModel().actions(); + } + + public Boolean isWorkspaceAlertsStorageConfigured() { + return this.innerModel().isWorkspaceAlertsStorageConfigured(); + } + + public Boolean checkWorkspaceAlertsStorageConfigured() { + return this.innerModel().checkWorkspaceAlertsStorageConfigured(); + } + + public Boolean skipQueryValidation() { + return this.innerModel().skipQueryValidation(); + } + + public Boolean autoMitigate() { + return this.innerModel().autoMitigate(); + } + + public RuleResolveConfiguration resolveConfiguration() { + return this.innerModel().resolveConfiguration(); + } + + public Region region() { + return Region.fromName(this.regionName()); + } + + public String regionName() { + return this.location(); + } + + public String resourceGroupName() { + return resourceGroupName; + } + + public ScheduledQueryRuleResourceInner innerModel() { + return this.innerObject; + } + + private com.azure.resourcemanager.monitor.generated.MonitorManager manager() { + return this.serviceManager; + } + + private String resourceGroupName; + + private String ruleName; + + private ScheduledQueryRuleResourcePatch updateParameters; + + public ScheduledQueryRuleResourceImpl withExistingResourceGroup(String resourceGroupName) { + this.resourceGroupName = resourceGroupName; + return this; + } + + public ScheduledQueryRuleResource create() { + this.innerObject = serviceManager.serviceClient() + .getScheduledQueryRules() + .createOrUpdateWithResponse(resourceGroupName, ruleName, this.innerModel(), Context.NONE) + .getValue(); + return this; + } + + public ScheduledQueryRuleResource create(Context context) { + this.innerObject = serviceManager.serviceClient() + .getScheduledQueryRules() + .createOrUpdateWithResponse(resourceGroupName, ruleName, this.innerModel(), context) + .getValue(); + return this; + } + + ScheduledQueryRuleResourceImpl(String name, + com.azure.resourcemanager.monitor.generated.MonitorManager serviceManager) { + this.innerObject = new ScheduledQueryRuleResourceInner(); + this.serviceManager = serviceManager; + this.ruleName = name; + } + + public ScheduledQueryRuleResourceImpl update() { + this.updateParameters = new ScheduledQueryRuleResourcePatch(); + return this; + } + + public ScheduledQueryRuleResource apply() { + this.innerObject = serviceManager.serviceClient() + .getScheduledQueryRules() + .updateWithResponse(resourceGroupName, ruleName, updateParameters, Context.NONE) + .getValue(); + return this; + } + + public ScheduledQueryRuleResource apply(Context context) { + this.innerObject = serviceManager.serviceClient() + .getScheduledQueryRules() + .updateWithResponse(resourceGroupName, ruleName, updateParameters, context) + .getValue(); + return this; + } + + ScheduledQueryRuleResourceImpl(ScheduledQueryRuleResourceInner innerObject, + com.azure.resourcemanager.monitor.generated.MonitorManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + this.resourceGroupName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "resourceGroups"); + this.ruleName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "scheduledQueryRules"); + } + + public ScheduledQueryRuleResource refresh() { + this.innerObject = serviceManager.serviceClient() + .getScheduledQueryRules() + .getByResourceGroupWithResponse(resourceGroupName, ruleName, Context.NONE) + .getValue(); + return this; + } + + public ScheduledQueryRuleResource refresh(Context context) { + this.innerObject = serviceManager.serviceClient() + .getScheduledQueryRules() + .getByResourceGroupWithResponse(resourceGroupName, ruleName, context) + .getValue(); + return this; + } + + public ScheduledQueryRuleResourceImpl withRegion(Region location) { + this.innerModel().withLocation(location.toString()); + return this; + } + + public ScheduledQueryRuleResourceImpl withRegion(String location) { + this.innerModel().withLocation(location); + return this; + } + + public ScheduledQueryRuleResourceImpl withTags(Map tags) { + if (isInCreateMode()) { + this.innerModel().withTags(tags); + return this; + } else { + this.updateParameters.withTags(tags); + return this; + } + } + + public ScheduledQueryRuleResourceImpl withIdentity(Identity identity) { + if (isInCreateMode()) { + this.innerModel().withIdentity(identity); + return this; + } else { + this.updateParameters.withIdentity(identity); + return this; + } + } + + public ScheduledQueryRuleResourceImpl withKind(Kind kind) { + this.innerModel().withKind(kind); + return this; + } + + public ScheduledQueryRuleResourceImpl withDescription(String description) { + if (isInCreateMode()) { + this.innerModel().withDescription(description); + return this; + } else { + this.updateParameters.withDescription(description); + return this; + } + } + + public ScheduledQueryRuleResourceImpl withDisplayName(String displayName) { + if (isInCreateMode()) { + this.innerModel().withDisplayName(displayName); + return this; + } else { + this.updateParameters.withDisplayName(displayName); + return this; + } + } + + public ScheduledQueryRuleResourceImpl withSeverity(AlertSeverity severity) { + if (isInCreateMode()) { + this.innerModel().withSeverity(severity); + return this; + } else { + this.updateParameters.withSeverity(severity); + return this; + } + } + + public ScheduledQueryRuleResourceImpl withEnabled(Boolean enabled) { + if (isInCreateMode()) { + this.innerModel().withEnabled(enabled); + return this; + } else { + this.updateParameters.withEnabled(enabled); + return this; + } + } + + public ScheduledQueryRuleResourceImpl withScopes(List scopes) { + if (isInCreateMode()) { + this.innerModel().withScopes(scopes); + return this; + } else { + this.updateParameters.withScopes(scopes); + return this; + } + } + + public ScheduledQueryRuleResourceImpl withEvaluationFrequency(Duration evaluationFrequency) { + if (isInCreateMode()) { + this.innerModel().withEvaluationFrequency(evaluationFrequency); + return this; + } else { + this.updateParameters.withEvaluationFrequency(evaluationFrequency); + return this; + } + } + + public ScheduledQueryRuleResourceImpl withWindowSize(Duration windowSize) { + if (isInCreateMode()) { + this.innerModel().withWindowSize(windowSize); + return this; + } else { + this.updateParameters.withWindowSize(windowSize); + return this; + } + } + + public ScheduledQueryRuleResourceImpl withOverrideQueryTimeRange(Duration overrideQueryTimeRange) { + if (isInCreateMode()) { + this.innerModel().withOverrideQueryTimeRange(overrideQueryTimeRange); + return this; + } else { + this.updateParameters.withOverrideQueryTimeRange(overrideQueryTimeRange); + return this; + } + } + + public ScheduledQueryRuleResourceImpl withTargetResourceTypes(List targetResourceTypes) { + if (isInCreateMode()) { + this.innerModel().withTargetResourceTypes(targetResourceTypes); + return this; + } else { + this.updateParameters.withTargetResourceTypes(targetResourceTypes); + return this; + } + } + + public ScheduledQueryRuleResourceImpl withCriteria(ScheduledQueryRuleCriteria criteria) { + if (isInCreateMode()) { + this.innerModel().withCriteria(criteria); + return this; + } else { + this.updateParameters.withCriteria(criteria); + return this; + } + } + + public ScheduledQueryRuleResourceImpl withMuteActionsDuration(Duration muteActionsDuration) { + if (isInCreateMode()) { + this.innerModel().withMuteActionsDuration(muteActionsDuration); + return this; + } else { + this.updateParameters.withMuteActionsDuration(muteActionsDuration); + return this; + } + } + + public ScheduledQueryRuleResourceImpl withActions(Actions actions) { + if (isInCreateMode()) { + this.innerModel().withActions(actions); + return this; + } else { + this.updateParameters.withActions(actions); + return this; + } + } + + public ScheduledQueryRuleResourceImpl + withCheckWorkspaceAlertsStorageConfigured(Boolean checkWorkspaceAlertsStorageConfigured) { + if (isInCreateMode()) { + this.innerModel().withCheckWorkspaceAlertsStorageConfigured(checkWorkspaceAlertsStorageConfigured); + return this; + } else { + this.updateParameters.withCheckWorkspaceAlertsStorageConfigured(checkWorkspaceAlertsStorageConfigured); + return this; + } + } + + public ScheduledQueryRuleResourceImpl withSkipQueryValidation(Boolean skipQueryValidation) { + if (isInCreateMode()) { + this.innerModel().withSkipQueryValidation(skipQueryValidation); + return this; + } else { + this.updateParameters.withSkipQueryValidation(skipQueryValidation); + return this; + } + } + + public ScheduledQueryRuleResourceImpl withAutoMitigate(Boolean autoMitigate) { + if (isInCreateMode()) { + this.innerModel().withAutoMitigate(autoMitigate); + return this; + } else { + this.updateParameters.withAutoMitigate(autoMitigate); + return this; + } + } + + public ScheduledQueryRuleResourceImpl withResolveConfiguration(RuleResolveConfiguration resolveConfiguration) { + if (isInCreateMode()) { + this.innerModel().withResolveConfiguration(resolveConfiguration); + return this; + } else { + this.updateParameters.withResolveConfiguration(resolveConfiguration); + return this; + } + } + + private boolean isInCreateMode() { + return this.innerModel().id() == null; + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/implementation/ScheduledQueryRulesClientImpl.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/implementation/ScheduledQueryRulesClientImpl.java new file mode 100644 index 0000000000000..fc942b9b1f9ab --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/implementation/ScheduledQueryRulesClientImpl.java @@ -0,0 +1,1013 @@ +// 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.resourcemanager.monitor.generated.fluent.ScheduledQueryRulesClient; +import com.azure.resourcemanager.monitor.generated.fluent.models.ScheduledQueryRuleResourceInner; +import com.azure.resourcemanager.monitor.generated.models.ScheduledQueryRuleResourceCollection; +import com.azure.resourcemanager.monitor.generated.models.ScheduledQueryRuleResourcePatch; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in ScheduledQueryRulesClient. + */ +public final class ScheduledQueryRulesClientImpl implements ScheduledQueryRulesClient { + /** + * The proxy service used to perform REST calls. + */ + private final ScheduledQueryRulesService service; + + /** + * The service client containing this operation class. + */ + private final MonitorClientImpl client; + + /** + * Initializes an instance of ScheduledQueryRulesClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + ScheduledQueryRulesClientImpl(MonitorClientImpl client) { + this.service = RestProxy.create(ScheduledQueryRulesService.class, client.getHttpPipeline(), + client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for MonitorClientScheduledQueryRules to be used by the proxy service to + * perform REST calls. + */ + @Host("{$host}") + @ServiceInterface(name = "MonitorClientSchedul") + public interface ScheduledQueryRulesService { + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/providers/Microsoft.Insights/scheduledQueryRules") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> list(@HostParam("$host") String endpoint, + @PathParam("subscriptionId") String subscriptionId, @QueryParam("api-version") String apiVersion, + @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listByResourceGroup(@HostParam("$host") String endpoint, + @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, @QueryParam("api-version") String apiVersion, + @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> getByResourceGroup(@HostParam("$host") String endpoint, + @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, @PathParam("ruleName") String ruleName, + @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Put("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}") + @ExpectedResponses({ 200, 201 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> createOrUpdate(@HostParam("$host") String endpoint, + @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, @PathParam("ruleName") String ruleName, + @QueryParam("api-version") String apiVersion, + @BodyParam("application/json") ScheduledQueryRuleResourceInner parameters, + @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Patch("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> update(@HostParam("$host") String endpoint, + @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, @PathParam("ruleName") String ruleName, + @QueryParam("api-version") String apiVersion, + @BodyParam("application/json") ScheduledQueryRuleResourcePatch parameters, + @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Delete("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}") + @ExpectedResponses({ 200, 204 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> delete(@HostParam("$host") String endpoint, + @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, @PathParam("ruleName") String ruleName, + @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listBySubscriptionNext( + @PathParam(value = "nextLink", encoded = true) String nextLink, @HostParam("$host") String endpoint, + @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listByResourceGroupNext( + @PathParam(value = "nextLink", encoded = true) String nextLink, @HostParam("$host") String endpoint, + @HeaderParam("Accept") String accept, Context context); + } + + /** + * Retrieve a scheduled query rule definitions in a subscription. + * + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return represents a collection of scheduled query rule resources along with {@link PagedResponse} on successful + * completion of {@link Mono}. + */ + @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 apiVersion = "2024-01-01-preview"; + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.list(this.client.getEndpoint(), this.client.getSubscriptionId(), apiVersion, + accept, context)) + .>map(res -> new PagedResponseBase<>(res.getRequest(), + res.getStatusCode(), res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Retrieve a scheduled query rule definitions in a subscription. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return represents a collection of scheduled query rule resources along with {@link PagedResponse} on successful + * completion of {@link Mono}. + */ + @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 apiVersion = "2024-01-01-preview"; + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.list(this.client.getEndpoint(), this.client.getSubscriptionId(), apiVersion, accept, context) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + res.getValue().value(), res.getValue().nextLink(), null)); + } + + /** + * Retrieve a scheduled query rule definitions in a subscription. + * + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return represents a collection of scheduled query rule resources as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync() { + return new PagedFlux<>(() -> listSinglePageAsync(), + nextLink -> listBySubscriptionNextSinglePageAsync(nextLink)); + } + + /** + * Retrieve a scheduled query rule definitions in a subscription. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return represents a collection of scheduled query rule resources as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync(Context context) { + return new PagedFlux<>(() -> listSinglePageAsync(context), + nextLink -> listBySubscriptionNextSinglePageAsync(nextLink, context)); + } + + /** + * Retrieve a scheduled query rule definitions in a subscription. + * + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return represents a collection of scheduled query rule resources as paginated response with + * {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list() { + return new PagedIterable<>(listAsync()); + } + + /** + * Retrieve a scheduled query rule definitions in a subscription. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return represents a collection of scheduled query rule resources as paginated response with + * {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(Context context) { + return new PagedIterable<>(listAsync(context)); + } + + /** + * Retrieve scheduled query rule definitions in a resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return represents a collection of scheduled query rule resources along with {@link PagedResponse} on successful + * completion of {@link Mono}. + */ + @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 apiVersion = "2024-01-01-preview"; + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.listByResourceGroup(this.client.getEndpoint(), + this.client.getSubscriptionId(), resourceGroupName, apiVersion, accept, context)) + .>map(res -> new PagedResponseBase<>(res.getRequest(), + res.getStatusCode(), res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Retrieve scheduled query rule definitions in a resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return represents a collection of scheduled query rule resources along with {@link PagedResponse} on successful + * completion of {@link Mono}. + */ + @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 apiVersion = "2024-01-01-preview"; + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .listByResourceGroup(this.client.getEndpoint(), this.client.getSubscriptionId(), resourceGroupName, + apiVersion, accept, context) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + res.getValue().value(), res.getValue().nextLink(), null)); + } + + /** + * Retrieve scheduled query rule definitions in a resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return represents a collection of scheduled query rule resources as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listByResourceGroupAsync(String resourceGroupName) { + return new PagedFlux<>(() -> listByResourceGroupSinglePageAsync(resourceGroupName), + nextLink -> listByResourceGroupNextSinglePageAsync(nextLink)); + } + + /** + * Retrieve scheduled query rule definitions in a resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return represents a collection of scheduled query rule resources as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listByResourceGroupAsync(String resourceGroupName, + Context context) { + return new PagedFlux<>(() -> listByResourceGroupSinglePageAsync(resourceGroupName, context), + nextLink -> listByResourceGroupNextSinglePageAsync(nextLink, context)); + } + + /** + * Retrieve scheduled query rule definitions in a resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return represents a collection of scheduled query rule resources as paginated response with + * {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listByResourceGroup(String resourceGroupName) { + return new PagedIterable<>(listByResourceGroupAsync(resourceGroupName)); + } + + /** + * Retrieve scheduled query rule definitions in a resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return represents a collection of scheduled query rule resources as paginated response with + * {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listByResourceGroup(String resourceGroupName, + Context context) { + return new PagedIterable<>(listByResourceGroupAsync(resourceGroupName, context)); + } + + /** + * Retrieve an scheduled query rule definition. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param ruleName The name of the rule. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the scheduled query rule resource along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> + getByResourceGroupWithResponseAsync(String resourceGroupName, String ruleName) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (ruleName == null) { + return Mono.error(new IllegalArgumentException("Parameter ruleName is required and cannot be null.")); + } + final String apiVersion = "2024-01-01-preview"; + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getByResourceGroup(this.client.getEndpoint(), + this.client.getSubscriptionId(), resourceGroupName, ruleName, apiVersion, accept, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Retrieve an scheduled query rule definition. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param ruleName The name of the rule. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the scheduled query rule resource along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> + getByResourceGroupWithResponseAsync(String resourceGroupName, String ruleName, Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (ruleName == null) { + return Mono.error(new IllegalArgumentException("Parameter ruleName is required and cannot be null.")); + } + final String apiVersion = "2024-01-01-preview"; + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.getByResourceGroup(this.client.getEndpoint(), this.client.getSubscriptionId(), resourceGroupName, + ruleName, apiVersion, accept, context); + } + + /** + * Retrieve an scheduled query rule definition. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param ruleName The name of the rule. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the scheduled query rule resource on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono getByResourceGroupAsync(String resourceGroupName, String ruleName) { + return getByResourceGroupWithResponseAsync(resourceGroupName, ruleName) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Retrieve an scheduled query rule definition. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param ruleName The name of the rule. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the scheduled query rule resource along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getByResourceGroupWithResponse(String resourceGroupName, + String ruleName, Context context) { + return getByResourceGroupWithResponseAsync(resourceGroupName, ruleName, context).block(); + } + + /** + * Retrieve an scheduled query rule definition. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param ruleName The name of the rule. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the scheduled query rule resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ScheduledQueryRuleResourceInner getByResourceGroup(String resourceGroupName, String ruleName) { + return getByResourceGroupWithResponse(resourceGroupName, ruleName, Context.NONE).getValue(); + } + + /** + * Creates or updates a scheduled query rule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param ruleName The name of the rule. + * @param parameters The parameters of the rule to create or update. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the scheduled query rule resource along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> createOrUpdateWithResponseAsync(String resourceGroupName, + String ruleName, ScheduledQueryRuleResourceInner parameters) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (ruleName == null) { + return Mono.error(new IllegalArgumentException("Parameter ruleName is required and cannot be null.")); + } + if (parameters == null) { + return Mono.error(new IllegalArgumentException("Parameter parameters is required and cannot be null.")); + } else { + parameters.validate(); + } + final String apiVersion = "2024-01-01-preview"; + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.createOrUpdate(this.client.getEndpoint(), this.client.getSubscriptionId(), + resourceGroupName, ruleName, apiVersion, parameters, accept, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Creates or updates a scheduled query rule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param ruleName The name of the rule. + * @param parameters The parameters of the rule to create or update. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the scheduled query rule resource along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> createOrUpdateWithResponseAsync(String resourceGroupName, + String ruleName, ScheduledQueryRuleResourceInner parameters, Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (ruleName == null) { + return Mono.error(new IllegalArgumentException("Parameter ruleName is required and cannot be null.")); + } + if (parameters == null) { + return Mono.error(new IllegalArgumentException("Parameter parameters is required and cannot be null.")); + } else { + parameters.validate(); + } + final String apiVersion = "2024-01-01-preview"; + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.createOrUpdate(this.client.getEndpoint(), this.client.getSubscriptionId(), resourceGroupName, + ruleName, apiVersion, parameters, accept, context); + } + + /** + * Creates or updates a scheduled query rule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param ruleName The name of the rule. + * @param parameters The parameters of the rule to create or update. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the scheduled query rule resource on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono createOrUpdateAsync(String resourceGroupName, String ruleName, + ScheduledQueryRuleResourceInner parameters) { + return createOrUpdateWithResponseAsync(resourceGroupName, ruleName, parameters) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Creates or updates a scheduled query rule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param ruleName The name of the rule. + * @param parameters The parameters of the rule to create or update. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the scheduled query rule resource along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response createOrUpdateWithResponse(String resourceGroupName, + String ruleName, ScheduledQueryRuleResourceInner parameters, Context context) { + return createOrUpdateWithResponseAsync(resourceGroupName, ruleName, parameters, context).block(); + } + + /** + * Creates or updates a scheduled query rule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param ruleName The name of the rule. + * @param parameters The parameters of the rule to create or update. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the scheduled query rule resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ScheduledQueryRuleResourceInner createOrUpdate(String resourceGroupName, String ruleName, + ScheduledQueryRuleResourceInner parameters) { + return createOrUpdateWithResponse(resourceGroupName, ruleName, parameters, Context.NONE).getValue(); + } + + /** + * Update a scheduled query rule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param ruleName The name of the rule. + * @param parameters The parameters of the rule to update. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the scheduled query rule resource along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> updateWithResponseAsync(String resourceGroupName, + String ruleName, ScheduledQueryRuleResourcePatch parameters) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (ruleName == null) { + return Mono.error(new IllegalArgumentException("Parameter ruleName is required and cannot be null.")); + } + if (parameters == null) { + return Mono.error(new IllegalArgumentException("Parameter parameters is required and cannot be null.")); + } else { + parameters.validate(); + } + final String apiVersion = "2024-01-01-preview"; + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.update(this.client.getEndpoint(), this.client.getSubscriptionId(), + resourceGroupName, ruleName, apiVersion, parameters, accept, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Update a scheduled query rule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param ruleName The name of the rule. + * @param parameters The parameters of the rule to update. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the scheduled query rule resource along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> updateWithResponseAsync(String resourceGroupName, + String ruleName, ScheduledQueryRuleResourcePatch parameters, Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (ruleName == null) { + return Mono.error(new IllegalArgumentException("Parameter ruleName is required and cannot be null.")); + } + if (parameters == null) { + return Mono.error(new IllegalArgumentException("Parameter parameters is required and cannot be null.")); + } else { + parameters.validate(); + } + final String apiVersion = "2024-01-01-preview"; + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.update(this.client.getEndpoint(), this.client.getSubscriptionId(), resourceGroupName, ruleName, + apiVersion, parameters, accept, context); + } + + /** + * Update a scheduled query rule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param ruleName The name of the rule. + * @param parameters The parameters of the rule to update. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the scheduled query rule resource on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono updateAsync(String resourceGroupName, String ruleName, + ScheduledQueryRuleResourcePatch parameters) { + return updateWithResponseAsync(resourceGroupName, ruleName, parameters) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Update a scheduled query rule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param ruleName The name of the rule. + * @param parameters The parameters of the rule to update. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the scheduled query rule resource along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response updateWithResponse(String resourceGroupName, String ruleName, + ScheduledQueryRuleResourcePatch parameters, Context context) { + return updateWithResponseAsync(resourceGroupName, ruleName, parameters, context).block(); + } + + /** + * Update a scheduled query rule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param ruleName The name of the rule. + * @param parameters The parameters of the rule to update. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the scheduled query rule resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ScheduledQueryRuleResourceInner update(String resourceGroupName, String ruleName, + ScheduledQueryRuleResourcePatch parameters) { + return updateWithResponse(resourceGroupName, ruleName, parameters, Context.NONE).getValue(); + } + + /** + * Deletes a scheduled query rule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param ruleName The name of the rule. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> deleteWithResponseAsync(String resourceGroupName, String ruleName) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (ruleName == null) { + return Mono.error(new IllegalArgumentException("Parameter ruleName is required and cannot be null.")); + } + final String apiVersion = "2024-01-01-preview"; + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.delete(this.client.getEndpoint(), this.client.getSubscriptionId(), + resourceGroupName, ruleName, apiVersion, accept, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Deletes a scheduled query rule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param ruleName The name of the rule. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> deleteWithResponseAsync(String resourceGroupName, String ruleName, Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (ruleName == null) { + return Mono.error(new IllegalArgumentException("Parameter ruleName is required and cannot be null.")); + } + final String apiVersion = "2024-01-01-preview"; + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.delete(this.client.getEndpoint(), this.client.getSubscriptionId(), resourceGroupName, ruleName, + apiVersion, accept, context); + } + + /** + * Deletes a scheduled query rule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param ruleName The name of the rule. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono deleteAsync(String resourceGroupName, String ruleName) { + return deleteWithResponseAsync(resourceGroupName, ruleName).flatMap(ignored -> Mono.empty()); + } + + /** + * Deletes a scheduled query rule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param ruleName The name of the rule. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response deleteWithResponse(String resourceGroupName, String ruleName, Context context) { + return deleteWithResponseAsync(resourceGroupName, ruleName, context).block(); + } + + /** + * Deletes a scheduled query rule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param ruleName The name of the rule. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public void delete(String resourceGroupName, String ruleName) { + deleteWithResponse(resourceGroupName, ruleName, Context.NONE); + } + + /** + * Get the next page of items. + * + * @param nextLink The URL to get the next list of items. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return represents a collection of scheduled query rule resources along with {@link PagedResponse} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> + listBySubscriptionNextSinglePageAsync(String nextLink) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> service.listBySubscriptionNext(nextLink, this.client.getEndpoint(), accept, context)) + .>map(res -> new PagedResponseBase<>(res.getRequest(), + res.getStatusCode(), res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get the next page of items. + * + * @param nextLink The URL to get the next list of items. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return represents a collection of scheduled query rule resources along with {@link PagedResponse} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listBySubscriptionNextSinglePageAsync(String nextLink, + Context context) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.listBySubscriptionNext(nextLink, this.client.getEndpoint(), accept, context) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + res.getValue().value(), res.getValue().nextLink(), null)); + } + + /** + * Get the next page of items. + * + * @param nextLink The URL to get the next list of items. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return represents a collection of scheduled query rule resources along with {@link PagedResponse} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> + listByResourceGroupNextSinglePageAsync(String nextLink) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> service.listByResourceGroupNext(nextLink, this.client.getEndpoint(), accept, context)) + .>map(res -> new PagedResponseBase<>(res.getRequest(), + res.getStatusCode(), res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get the next page of items. + * + * @param nextLink The URL to get the next list of items. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return represents a collection of scheduled query rule resources along with {@link PagedResponse} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByResourceGroupNextSinglePageAsync(String nextLink, + Context context) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.listByResourceGroupNext(nextLink, this.client.getEndpoint(), accept, context) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + res.getValue().value(), res.getValue().nextLink(), null)); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/implementation/ScheduledQueryRulesImpl.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/implementation/ScheduledQueryRulesImpl.java new file mode 100644 index 0000000000000..675175f295f9d --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/implementation/ScheduledQueryRulesImpl.java @@ -0,0 +1,153 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.monitor.generated.implementation; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.SimpleResponse; +import com.azure.core.util.Context; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.monitor.generated.fluent.ScheduledQueryRulesClient; +import com.azure.resourcemanager.monitor.generated.fluent.models.ScheduledQueryRuleResourceInner; +import com.azure.resourcemanager.monitor.generated.models.ScheduledQueryRuleResource; +import com.azure.resourcemanager.monitor.generated.models.ScheduledQueryRules; + +public final class ScheduledQueryRulesImpl implements ScheduledQueryRules { + private static final ClientLogger LOGGER = new ClientLogger(ScheduledQueryRulesImpl.class); + + private final ScheduledQueryRulesClient innerClient; + + private final com.azure.resourcemanager.monitor.generated.MonitorManager serviceManager; + + public ScheduledQueryRulesImpl(ScheduledQueryRulesClient innerClient, + com.azure.resourcemanager.monitor.generated.MonitorManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public PagedIterable list() { + PagedIterable inner = this.serviceClient().list(); + return ResourceManagerUtils.mapPage(inner, + inner1 -> new ScheduledQueryRuleResourceImpl(inner1, this.manager())); + } + + public PagedIterable list(Context context) { + PagedIterable inner = this.serviceClient().list(context); + return ResourceManagerUtils.mapPage(inner, + inner1 -> new ScheduledQueryRuleResourceImpl(inner1, this.manager())); + } + + public PagedIterable listByResourceGroup(String resourceGroupName) { + PagedIterable inner + = this.serviceClient().listByResourceGroup(resourceGroupName); + return ResourceManagerUtils.mapPage(inner, + inner1 -> new ScheduledQueryRuleResourceImpl(inner1, this.manager())); + } + + public PagedIterable listByResourceGroup(String resourceGroupName, Context context) { + PagedIterable inner + = this.serviceClient().listByResourceGroup(resourceGroupName, context); + return ResourceManagerUtils.mapPage(inner, + inner1 -> new ScheduledQueryRuleResourceImpl(inner1, this.manager())); + } + + public Response getByResourceGroupWithResponse(String resourceGroupName, + String ruleName, Context context) { + Response inner + = this.serviceClient().getByResourceGroupWithResponse(resourceGroupName, ruleName, context); + if (inner != null) { + return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(), + new ScheduledQueryRuleResourceImpl(inner.getValue(), this.manager())); + } else { + return null; + } + } + + public ScheduledQueryRuleResource getByResourceGroup(String resourceGroupName, String ruleName) { + ScheduledQueryRuleResourceInner inner = this.serviceClient().getByResourceGroup(resourceGroupName, ruleName); + if (inner != null) { + return new ScheduledQueryRuleResourceImpl(inner, this.manager()); + } else { + return null; + } + } + + public Response deleteByResourceGroupWithResponse(String resourceGroupName, String ruleName, + Context context) { + return this.serviceClient().deleteWithResponse(resourceGroupName, ruleName, context); + } + + public void deleteByResourceGroup(String resourceGroupName, String ruleName) { + this.serviceClient().delete(resourceGroupName, ruleName); + } + + public ScheduledQueryRuleResource getById(String id) { + String resourceGroupName = ResourceManagerUtils.getValueFromIdByName(id, "resourceGroups"); + if (resourceGroupName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id))); + } + String ruleName = ResourceManagerUtils.getValueFromIdByName(id, "scheduledQueryRules"); + if (ruleName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'scheduledQueryRules'.", id))); + } + return this.getByResourceGroupWithResponse(resourceGroupName, ruleName, Context.NONE).getValue(); + } + + public Response getByIdWithResponse(String id, Context context) { + String resourceGroupName = ResourceManagerUtils.getValueFromIdByName(id, "resourceGroups"); + if (resourceGroupName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id))); + } + String ruleName = ResourceManagerUtils.getValueFromIdByName(id, "scheduledQueryRules"); + if (ruleName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'scheduledQueryRules'.", id))); + } + return this.getByResourceGroupWithResponse(resourceGroupName, ruleName, context); + } + + public void deleteById(String id) { + String resourceGroupName = ResourceManagerUtils.getValueFromIdByName(id, "resourceGroups"); + if (resourceGroupName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id))); + } + String ruleName = ResourceManagerUtils.getValueFromIdByName(id, "scheduledQueryRules"); + if (ruleName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'scheduledQueryRules'.", id))); + } + this.deleteByResourceGroupWithResponse(resourceGroupName, ruleName, Context.NONE); + } + + public Response deleteByIdWithResponse(String id, Context context) { + String resourceGroupName = ResourceManagerUtils.getValueFromIdByName(id, "resourceGroups"); + if (resourceGroupName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id))); + } + String ruleName = ResourceManagerUtils.getValueFromIdByName(id, "scheduledQueryRules"); + if (ruleName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'scheduledQueryRules'.", id))); + } + return this.deleteByResourceGroupWithResponse(resourceGroupName, ruleName, context); + } + + private ScheduledQueryRulesClient serviceClient() { + return this.innerClient; + } + + private com.azure.resourcemanager.monitor.generated.MonitorManager manager() { + return this.serviceManager; + } + + public ScheduledQueryRuleResourceImpl define(String name) { + return new ScheduledQueryRuleResourceImpl(name, this.manager()); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/implementation/TestNotificationDetailsResponseImpl.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/implementation/TestNotificationDetailsResponseImpl.java new file mode 100644 index 0000000000000..096cbd7d00739 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/implementation/TestNotificationDetailsResponseImpl.java @@ -0,0 +1,57 @@ +// 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.resourcemanager.monitor.generated.fluent.models.TestNotificationDetailsResponseInner; +import com.azure.resourcemanager.monitor.generated.models.ActionDetail; +import com.azure.resourcemanager.monitor.generated.models.Context; +import com.azure.resourcemanager.monitor.generated.models.TestNotificationDetailsResponse; +import java.util.Collections; +import java.util.List; + +public final class TestNotificationDetailsResponseImpl implements TestNotificationDetailsResponse { + private TestNotificationDetailsResponseInner innerObject; + + private final com.azure.resourcemanager.monitor.generated.MonitorManager serviceManager; + + TestNotificationDetailsResponseImpl(TestNotificationDetailsResponseInner innerObject, + com.azure.resourcemanager.monitor.generated.MonitorManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + } + + public Context context() { + return this.innerModel().context(); + } + + public String state() { + return this.innerModel().state(); + } + + public String completedTime() { + return this.innerModel().completedTime(); + } + + public String createdTime() { + return this.innerModel().createdTime(); + } + + public List actionDetails() { + List inner = this.innerModel().actionDetails(); + if (inner != null) { + return Collections.unmodifiableList(inner); + } else { + return Collections.emptyList(); + } + } + + public TestNotificationDetailsResponseInner innerModel() { + return this.innerObject; + } + + private com.azure.resourcemanager.monitor.generated.MonitorManager manager() { + return this.serviceManager; + } +} 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..e8893597c05e1 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/implementation/package-info.java @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) 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/ActionDetail.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ActionDetail.java new file mode 100644 index 0000000000000..29ddd7ccfa31c --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ActionDetail.java @@ -0,0 +1,233 @@ +// 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.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The action detail. + */ +@Fluent +public final class ActionDetail implements JsonSerializable { + /* + * The mechanism type + */ + private String mechanismType; + + /* + * The name of the action + */ + private String name; + + /* + * The status of the action + */ + private String status; + + /* + * The substatus of the action + */ + private String subState; + + /* + * The send time + */ + private String sendTime; + + /* + * The detail of the friendly error message + */ + private String detail; + + /** + * Creates an instance of ActionDetail class. + */ + public ActionDetail() { + } + + /** + * Get the mechanismType property: The mechanism type. + * + * @return the mechanismType value. + */ + public String mechanismType() { + return this.mechanismType; + } + + /** + * Set the mechanismType property: The mechanism type. + * + * @param mechanismType the mechanismType value to set. + * @return the ActionDetail object itself. + */ + public ActionDetail withMechanismType(String mechanismType) { + this.mechanismType = mechanismType; + return this; + } + + /** + * Get the name property: The name of the action. + * + * @return the name value. + */ + public String name() { + return this.name; + } + + /** + * Set the name property: The name of the action. + * + * @param name the name value to set. + * @return the ActionDetail object itself. + */ + public ActionDetail withName(String name) { + this.name = name; + return this; + } + + /** + * Get the status property: The status of the action. + * + * @return the status value. + */ + public String status() { + return this.status; + } + + /** + * Set the status property: The status of the action. + * + * @param status the status value to set. + * @return the ActionDetail object itself. + */ + public ActionDetail withStatus(String status) { + this.status = status; + return this; + } + + /** + * Get the subState property: The substatus of the action. + * + * @return the subState value. + */ + public String subState() { + return this.subState; + } + + /** + * Set the subState property: The substatus of the action. + * + * @param subState the subState value to set. + * @return the ActionDetail object itself. + */ + public ActionDetail withSubState(String subState) { + this.subState = subState; + return this; + } + + /** + * Get the sendTime property: The send time. + * + * @return the sendTime value. + */ + public String sendTime() { + return this.sendTime; + } + + /** + * Set the sendTime property: The send time. + * + * @param sendTime the sendTime value to set. + * @return the ActionDetail object itself. + */ + public ActionDetail withSendTime(String sendTime) { + this.sendTime = sendTime; + return this; + } + + /** + * Get the detail property: The detail of the friendly error message. + * + * @return the detail value. + */ + public String detail() { + return this.detail; + } + + /** + * Set the detail property: The detail of the friendly error message. + * + * @param detail the detail value to set. + * @return the ActionDetail object itself. + */ + public ActionDetail withDetail(String detail) { + this.detail = detail; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("MechanismType", this.mechanismType); + jsonWriter.writeStringField("Name", this.name); + jsonWriter.writeStringField("Status", this.status); + jsonWriter.writeStringField("SubState", this.subState); + jsonWriter.writeStringField("SendTime", this.sendTime); + jsonWriter.writeStringField("Detail", this.detail); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ActionDetail from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ActionDetail if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the ActionDetail. + */ + public static ActionDetail fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ActionDetail deserializedActionDetail = new ActionDetail(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("MechanismType".equals(fieldName)) { + deserializedActionDetail.mechanismType = reader.getString(); + } else if ("Name".equals(fieldName)) { + deserializedActionDetail.name = reader.getString(); + } else if ("Status".equals(fieldName)) { + deserializedActionDetail.status = reader.getString(); + } else if ("SubState".equals(fieldName)) { + deserializedActionDetail.subState = reader.getString(); + } else if ("SendTime".equals(fieldName)) { + deserializedActionDetail.sendTime = reader.getString(); + } else if ("Detail".equals(fieldName)) { + deserializedActionDetail.detail = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedActionDetail; + }); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ActionGroupList.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ActionGroupList.java new file mode 100644 index 0000000000000..592a1328d9ac3 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ActionGroupList.java @@ -0,0 +1,128 @@ +// 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.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.azure.resourcemanager.monitor.generated.fluent.models.ActionGroupResourceInner; +import java.io.IOException; +import java.util.List; + +/** + * A list of action groups. + */ +@Fluent +public final class ActionGroupList implements JsonSerializable { + /* + * The list of action groups. + */ + private List value; + + /* + * Provides the link to retrieve the next set of elements. + */ + private String nextLink; + + /** + * Creates an instance of ActionGroupList class. + */ + public ActionGroupList() { + } + + /** + * Get the value property: The list of action groups. + * + * @return the value value. + */ + public List value() { + return this.value; + } + + /** + * Set the value property: The list of action groups. + * + * @param value the value value to set. + * @return the ActionGroupList object itself. + */ + public ActionGroupList 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 ActionGroupList object itself. + */ + public ActionGroupList 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()); + } + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("value", this.value, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeStringField("nextLink", this.nextLink); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ActionGroupList from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ActionGroupList if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the ActionGroupList. + */ + public static ActionGroupList fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ActionGroupList deserializedActionGroupList = new ActionGroupList(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("value".equals(fieldName)) { + List value + = reader.readArray(reader1 -> ActionGroupResourceInner.fromJson(reader1)); + deserializedActionGroupList.value = value; + } else if ("nextLink".equals(fieldName)) { + deserializedActionGroupList.nextLink = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedActionGroupList; + }); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ActionGroupPatchBody.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ActionGroupPatchBody.java new file mode 100644 index 0000000000000..89696c1691d34 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ActionGroupPatchBody.java @@ -0,0 +1,172 @@ +// 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.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.azure.resourcemanager.monitor.generated.fluent.models.ActionGroupPatch; +import java.io.IOException; +import java.util.Map; + +/** + * An action group object for the body of patch operations. + */ +@Fluent +public final class ActionGroupPatchBody implements JsonSerializable { + /* + * Resource tags + */ + private Map tags; + + /* + * Managed service identity (system assigned and/or user assigned identities) + */ + private ManagedServiceIdentity identity; + + /* + * The action group settings for an update operation. + */ + private ActionGroupPatch innerProperties; + + /** + * Creates an instance of ActionGroupPatchBody class. + */ + public ActionGroupPatchBody() { + } + + /** + * Get the tags property: Resource tags. + * + * @return the tags value. + */ + public Map tags() { + return this.tags; + } + + /** + * Set the tags property: Resource tags. + * + * @param tags the tags value to set. + * @return the ActionGroupPatchBody object itself. + */ + public ActionGroupPatchBody withTags(Map tags) { + this.tags = tags; + return this; + } + + /** + * Get the identity property: Managed service identity (system assigned and/or user assigned identities). + * + * @return the identity value. + */ + public ManagedServiceIdentity identity() { + return this.identity; + } + + /** + * Set the identity property: Managed service identity (system assigned and/or user assigned identities). + * + * @param identity the identity value to set. + * @return the ActionGroupPatchBody object itself. + */ + public ActionGroupPatchBody withIdentity(ManagedServiceIdentity identity) { + this.identity = identity; + return this; + } + + /** + * Get the innerProperties property: The action group settings for an update operation. + * + * @return the innerProperties value. + */ + private ActionGroupPatch innerProperties() { + return this.innerProperties; + } + + /** + * Get the enabled property: Indicates whether this action group is enabled. If an action group is not enabled, then + * none of its actions will be activated. + * + * @return the enabled value. + */ + public Boolean enabled() { + return this.innerProperties() == null ? null : this.innerProperties().enabled(); + } + + /** + * Set the enabled property: Indicates whether this action group is enabled. If an action group is not enabled, then + * none of its actions will be activated. + * + * @param enabled the enabled value to set. + * @return the ActionGroupPatchBody object itself. + */ + public ActionGroupPatchBody withEnabled(Boolean enabled) { + if (this.innerProperties() == null) { + this.innerProperties = new ActionGroupPatch(); + } + this.innerProperties().withEnabled(enabled); + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (identity() != null) { + identity().validate(); + } + if (innerProperties() != null) { + innerProperties().validate(); + } + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeMapField("tags", this.tags, (writer, element) -> writer.writeString(element)); + jsonWriter.writeJsonField("identity", this.identity); + jsonWriter.writeJsonField("properties", this.innerProperties); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ActionGroupPatchBody from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ActionGroupPatchBody if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IOException If an error occurs while reading the ActionGroupPatchBody. + */ + public static ActionGroupPatchBody fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ActionGroupPatchBody deserializedActionGroupPatchBody = new ActionGroupPatchBody(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("tags".equals(fieldName)) { + Map tags = reader.readMap(reader1 -> reader1.getString()); + deserializedActionGroupPatchBody.tags = tags; + } else if ("identity".equals(fieldName)) { + deserializedActionGroupPatchBody.identity = ManagedServiceIdentity.fromJson(reader); + } else if ("properties".equals(fieldName)) { + deserializedActionGroupPatchBody.innerProperties = ActionGroupPatch.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedActionGroupPatchBody; + }); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ActionGroupResource.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ActionGroupResource.java new file mode 100644 index 0000000000000..f8b0ac0f65c4a --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ActionGroupResource.java @@ -0,0 +1,633 @@ +// 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.Response; +import com.azure.core.management.Region; +import com.azure.core.util.Context; +import com.azure.resourcemanager.monitor.generated.fluent.models.ActionGroupResourceInner; +import java.util.List; +import java.util.Map; + +/** + * An immutable client-side representation of ActionGroupResource. + */ +public interface ActionGroupResource { + /** + * 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 identity property: Managed service identity (system assigned and/or user assigned identities). + * + * @return the identity value. + */ + ManagedServiceIdentity identity(); + + /** + * Gets the groupShortName property: The short name of the action group. This will be used in SMS messages. + * + * @return the groupShortName value. + */ + String groupShortName(); + + /** + * Gets the enabled property: Indicates whether this action group is enabled. If an action group is not enabled, + * then none of its receivers will receive communications. + * + * @return the enabled value. + */ + boolean enabled(); + + /** + * Gets the emailReceivers property: The list of email receivers that are part of this action group. + * + * @return the emailReceivers value. + */ + List emailReceivers(); + + /** + * Gets the smsReceivers property: The list of SMS receivers that are part of this action group. + * + * @return the smsReceivers value. + */ + List smsReceivers(); + + /** + * Gets the webhookReceivers property: The list of webhook receivers that are part of this action group. + * + * @return the webhookReceivers value. + */ + List webhookReceivers(); + + /** + * Gets the itsmReceivers property: The list of ITSM receivers that are part of this action group. + * + * @return the itsmReceivers value. + */ + List itsmReceivers(); + + /** + * Gets the azureAppPushReceivers property: The list of AzureAppPush receivers that are part of this action group. + * + * @return the azureAppPushReceivers value. + */ + List azureAppPushReceivers(); + + /** + * Gets the automationRunbookReceivers property: The list of AutomationRunbook receivers that are part of this + * action group. + * + * @return the automationRunbookReceivers value. + */ + List automationRunbookReceivers(); + + /** + * Gets the voiceReceivers property: The list of voice receivers that are part of this action group. + * + * @return the voiceReceivers value. + */ + List voiceReceivers(); + + /** + * Gets the logicAppReceivers property: The list of logic app receivers that are part of this action group. + * + * @return the logicAppReceivers value. + */ + List logicAppReceivers(); + + /** + * Gets the azureFunctionReceivers property: The list of azure function receivers that are part of this action + * group. + * + * @return the azureFunctionReceivers value. + */ + List azureFunctionReceivers(); + + /** + * Gets the armRoleReceivers property: The list of ARM role receivers that are part of this action group. Roles are + * Azure RBAC roles and only built-in roles are supported. + * + * @return the armRoleReceivers value. + */ + List armRoleReceivers(); + + /** + * Gets the eventHubReceivers property: The list of event hub receivers that are part of this action group. + * + * @return the eventHubReceivers value. + */ + List eventHubReceivers(); + + /** + * Gets the incidentReceivers property: The list of incident receivers that are part of this action group. + * + * @return the incidentReceivers value. + */ + List incidentReceivers(); + + /** + * 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 name of the resource group. + * + * @return the name of the resource group. + */ + String resourceGroupName(); + + /** + * Gets the inner com.azure.resourcemanager.monitor.generated.fluent.models.ActionGroupResourceInner object. + * + * @return the inner object. + */ + ActionGroupResourceInner innerModel(); + + /** + * The entirety of the ActionGroupResource definition. + */ + interface Definition extends DefinitionStages.Blank, DefinitionStages.WithLocation, + DefinitionStages.WithResourceGroup, DefinitionStages.WithCreate { + } + + /** + * The ActionGroupResource definition stages. + */ + interface DefinitionStages { + /** + * The first stage of the ActionGroupResource definition. + */ + interface Blank extends WithLocation { + } + + /** + * The stage of the ActionGroupResource 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 ActionGroupResource 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 ActionGroupResource 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.WithIdentity, DefinitionStages.WithGroupShortName, + DefinitionStages.WithEnabled, DefinitionStages.WithEmailReceivers, DefinitionStages.WithSmsReceivers, + DefinitionStages.WithWebhookReceivers, DefinitionStages.WithItsmReceivers, + DefinitionStages.WithAzureAppPushReceivers, DefinitionStages.WithAutomationRunbookReceivers, + DefinitionStages.WithVoiceReceivers, DefinitionStages.WithLogicAppReceivers, + DefinitionStages.WithAzureFunctionReceivers, DefinitionStages.WithArmRoleReceivers, + DefinitionStages.WithEventHubReceivers, DefinitionStages.WithIncidentReceivers { + /** + * Executes the create request. + * + * @return the created resource. + */ + ActionGroupResource create(); + + /** + * Executes the create request. + * + * @param context The context to associate with this operation. + * @return the created resource. + */ + ActionGroupResource create(Context context); + } + + /** + * The stage of the ActionGroupResource 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 ActionGroupResource definition allowing to specify identity. + */ + interface WithIdentity { + /** + * Specifies the identity property: Managed service identity (system assigned and/or user assigned + * identities). + * + * @param identity Managed service identity (system assigned and/or user assigned identities). + * @return the next definition stage. + */ + WithCreate withIdentity(ManagedServiceIdentity identity); + } + + /** + * The stage of the ActionGroupResource definition allowing to specify groupShortName. + */ + interface WithGroupShortName { + /** + * Specifies the groupShortName property: The short name of the action group. This will be used in SMS + * messages.. + * + * @param groupShortName The short name of the action group. This will be used in SMS messages. + * @return the next definition stage. + */ + WithCreate withGroupShortName(String groupShortName); + } + + /** + * The stage of the ActionGroupResource definition allowing to specify enabled. + */ + interface WithEnabled { + /** + * Specifies the enabled property: Indicates whether this action group is enabled. If an action group is not + * enabled, then none of its receivers will receive communications.. + * + * @param enabled Indicates whether this action group is enabled. If an action group is not enabled, then + * none of its receivers will receive communications. + * @return the next definition stage. + */ + WithCreate withEnabled(boolean enabled); + } + + /** + * The stage of the ActionGroupResource definition allowing to specify emailReceivers. + */ + interface WithEmailReceivers { + /** + * Specifies the emailReceivers property: The list of email receivers that are part of this action group.. + * + * @param emailReceivers The list of email receivers that are part of this action group. + * @return the next definition stage. + */ + WithCreate withEmailReceivers(List emailReceivers); + } + + /** + * The stage of the ActionGroupResource definition allowing to specify smsReceivers. + */ + interface WithSmsReceivers { + /** + * Specifies the smsReceivers property: The list of SMS receivers that are part of this action group.. + * + * @param smsReceivers The list of SMS receivers that are part of this action group. + * @return the next definition stage. + */ + WithCreate withSmsReceivers(List smsReceivers); + } + + /** + * The stage of the ActionGroupResource definition allowing to specify webhookReceivers. + */ + interface WithWebhookReceivers { + /** + * Specifies the webhookReceivers property: The list of webhook receivers that are part of this action + * group.. + * + * @param webhookReceivers The list of webhook receivers that are part of this action group. + * @return the next definition stage. + */ + WithCreate withWebhookReceivers(List webhookReceivers); + } + + /** + * The stage of the ActionGroupResource definition allowing to specify itsmReceivers. + */ + interface WithItsmReceivers { + /** + * Specifies the itsmReceivers property: The list of ITSM receivers that are part of this action group.. + * + * @param itsmReceivers The list of ITSM receivers that are part of this action group. + * @return the next definition stage. + */ + WithCreate withItsmReceivers(List itsmReceivers); + } + + /** + * The stage of the ActionGroupResource definition allowing to specify azureAppPushReceivers. + */ + interface WithAzureAppPushReceivers { + /** + * Specifies the azureAppPushReceivers property: The list of AzureAppPush receivers that are part of this + * action group.. + * + * @param azureAppPushReceivers The list of AzureAppPush receivers that are part of this action group. + * @return the next definition stage. + */ + WithCreate withAzureAppPushReceivers(List azureAppPushReceivers); + } + + /** + * The stage of the ActionGroupResource definition allowing to specify automationRunbookReceivers. + */ + interface WithAutomationRunbookReceivers { + /** + * Specifies the automationRunbookReceivers property: The list of AutomationRunbook receivers that are part + * of this action group.. + * + * @param automationRunbookReceivers The list of AutomationRunbook receivers that are part of this action + * group. + * @return the next definition stage. + */ + WithCreate withAutomationRunbookReceivers(List automationRunbookReceivers); + } + + /** + * The stage of the ActionGroupResource definition allowing to specify voiceReceivers. + */ + interface WithVoiceReceivers { + /** + * Specifies the voiceReceivers property: The list of voice receivers that are part of this action group.. + * + * @param voiceReceivers The list of voice receivers that are part of this action group. + * @return the next definition stage. + */ + WithCreate withVoiceReceivers(List voiceReceivers); + } + + /** + * The stage of the ActionGroupResource definition allowing to specify logicAppReceivers. + */ + interface WithLogicAppReceivers { + /** + * Specifies the logicAppReceivers property: The list of logic app receivers that are part of this action + * group.. + * + * @param logicAppReceivers The list of logic app receivers that are part of this action group. + * @return the next definition stage. + */ + WithCreate withLogicAppReceivers(List logicAppReceivers); + } + + /** + * The stage of the ActionGroupResource definition allowing to specify azureFunctionReceivers. + */ + interface WithAzureFunctionReceivers { + /** + * Specifies the azureFunctionReceivers property: The list of azure function receivers that are part of this + * action group.. + * + * @param azureFunctionReceivers The list of azure function receivers that are part of this action group. + * @return the next definition stage. + */ + WithCreate withAzureFunctionReceivers(List azureFunctionReceivers); + } + + /** + * The stage of the ActionGroupResource definition allowing to specify armRoleReceivers. + */ + interface WithArmRoleReceivers { + /** + * Specifies the armRoleReceivers property: The list of ARM role receivers that are part of this action + * group. Roles are Azure RBAC roles and only built-in roles are supported.. + * + * @param armRoleReceivers The list of ARM role receivers that are part of this action group. Roles are + * Azure RBAC roles and only built-in roles are supported. + * @return the next definition stage. + */ + WithCreate withArmRoleReceivers(List armRoleReceivers); + } + + /** + * The stage of the ActionGroupResource definition allowing to specify eventHubReceivers. + */ + interface WithEventHubReceivers { + /** + * Specifies the eventHubReceivers property: The list of event hub receivers that are part of this action + * group.. + * + * @param eventHubReceivers The list of event hub receivers that are part of this action group. + * @return the next definition stage. + */ + WithCreate withEventHubReceivers(List eventHubReceivers); + } + + /** + * The stage of the ActionGroupResource definition allowing to specify incidentReceivers. + */ + interface WithIncidentReceivers { + /** + * Specifies the incidentReceivers property: The list of incident receivers that are part of this action + * group.. + * + * @param incidentReceivers The list of incident receivers that are part of this action group. + * @return the next definition stage. + */ + WithCreate withIncidentReceivers(List incidentReceivers); + } + } + + /** + * Begins update for the ActionGroupResource resource. + * + * @return the stage of resource update. + */ + ActionGroupResource.Update update(); + + /** + * The template for ActionGroupResource update. + */ + interface Update extends UpdateStages.WithTags, UpdateStages.WithIdentity, UpdateStages.WithEnabled { + /** + * Executes the update request. + * + * @return the updated resource. + */ + ActionGroupResource apply(); + + /** + * Executes the update request. + * + * @param context The context to associate with this operation. + * @return the updated resource. + */ + ActionGroupResource apply(Context context); + } + + /** + * The ActionGroupResource update stages. + */ + interface UpdateStages { + /** + * The stage of the ActionGroupResource update allowing to specify tags. + */ + interface WithTags { + /** + * Specifies the tags property: Resource tags. + * + * @param tags Resource tags. + * @return the next definition stage. + */ + Update withTags(Map tags); + } + + /** + * The stage of the ActionGroupResource update allowing to specify identity. + */ + interface WithIdentity { + /** + * Specifies the identity property: Managed service identity (system assigned and/or user assigned + * identities). + * + * @param identity Managed service identity (system assigned and/or user assigned identities). + * @return the next definition stage. + */ + Update withIdentity(ManagedServiceIdentity identity); + } + + /** + * The stage of the ActionGroupResource update allowing to specify enabled. + */ + interface WithEnabled { + /** + * Specifies the enabled property: Indicates whether this action group is enabled. If an action group is not + * enabled, then none of its actions will be activated.. + * + * @param enabled Indicates whether this action group is enabled. If an action group 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. + */ + ActionGroupResource refresh(); + + /** + * Refreshes the resource to sync with Azure. + * + * @param context The context to associate with this operation. + * @return the refreshed resource. + */ + ActionGroupResource refresh(Context context); + + /** + * Send test notifications to a set of provided receivers. + * + * @param notificationRequest The notification request body which includes the contact details. + * @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 details of the test notification results. + */ + TestNotificationDetailsResponse + createNotificationsAtActionGroupResourceLevel(NotificationRequestBody notificationRequest); + + /** + * Send test notifications to a set of provided receivers. + * + * @param notificationRequest The notification request body which includes the contact details. + * @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 details of the test notification results. + */ + TestNotificationDetailsResponse + createNotificationsAtActionGroupResourceLevel(NotificationRequestBody notificationRequest, Context context); + + /** + * Enable a receiver in an action group. This changes the receiver's status from Disabled to Enabled. This operation + * is only supported for Email or SMS receivers. + * + * @param enableRequest The receiver to re-enable. + * @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 com.azure.core.management.exception.ManagementException thrown if the request is rejected by server on + * status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + Response enableReceiverWithResponse(EnableRequest enableRequest, Context context); + + /** + * Enable a receiver in an action group. This changes the receiver's status from Disabled to Enabled. This operation + * is only supported for Email or SMS receivers. + * + * @param enableRequest The receiver to re-enable. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server on + * status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + void enableReceiver(EnableRequest enableRequest); +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ActionGroups.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ActionGroups.java new file mode 100644 index 0000000000000..cb25a037b8468 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ActionGroups.java @@ -0,0 +1,251 @@ +// 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 ActionGroups. + */ +public interface ActionGroups { + /** + * Get an action group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param actionGroupName The name of the action group. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an action group along with {@link Response}. + */ + Response getByResourceGroupWithResponse(String resourceGroupName, String actionGroupName, + Context context); + + /** + * Get an action group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param actionGroupName The name of the action group. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an action group. + */ + ActionGroupResource getByResourceGroup(String resourceGroupName, String actionGroupName); + + /** + * Delete an action group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param actionGroupName The name of the action group. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + Response deleteByResourceGroupWithResponse(String resourceGroupName, String actionGroupName, Context context); + + /** + * Delete an action group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param actionGroupName The name of the action group. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + void deleteByResourceGroup(String resourceGroupName, String actionGroupName); + + /** + * Send test notifications to a set of provided receivers. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param actionGroupName The name of the action group. + * @param notificationRequest The notification request body which includes the contact details. + * @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 details of the test notification results. + */ + TestNotificationDetailsResponse createNotificationsAtActionGroupResourceLevel(String resourceGroupName, + String actionGroupName, NotificationRequestBody notificationRequest); + + /** + * Send test notifications to a set of provided receivers. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param actionGroupName The name of the action group. + * @param notificationRequest The notification request body which includes the contact details. + * @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 details of the test notification results. + */ + TestNotificationDetailsResponse createNotificationsAtActionGroupResourceLevel(String resourceGroupName, + String actionGroupName, NotificationRequestBody notificationRequest, Context context); + + /** + * Get the test notifications by the notification id. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param actionGroupName The name of the action group. + * @param notificationId The notification 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 test notifications by the notification id along with {@link Response}. + */ + Response getTestNotificationsAtActionGroupResourceLevelWithResponse( + String resourceGroupName, String actionGroupName, String notificationId, Context context); + + /** + * Get the test notifications by the notification id. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param actionGroupName The name of the action group. + * @param notificationId The notification id. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the test notifications by the notification id. + */ + TestNotificationDetailsResponse getTestNotificationsAtActionGroupResourceLevel(String resourceGroupName, + String actionGroupName, String notificationId); + + /** + * Get a list of all action groups 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 action groups in a subscription as paginated response with {@link PagedIterable}. + */ + PagedIterable list(); + + /** + * Get a list of all action groups 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 action groups in a subscription as paginated response with {@link PagedIterable}. + */ + PagedIterable list(Context context); + + /** + * Get a list of all action groups 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 action groups in a resource group as paginated response with {@link PagedIterable}. + */ + PagedIterable listByResourceGroup(String resourceGroupName); + + /** + * Get a list of all action groups 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 action groups in a resource group as paginated response with {@link PagedIterable}. + */ + PagedIterable listByResourceGroup(String resourceGroupName, Context context); + + /** + * Enable a receiver in an action group. This changes the receiver's status from Disabled to Enabled. This operation + * is only supported for Email or SMS receivers. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param actionGroupName The name of the action group. + * @param enableRequest The receiver to re-enable. + * @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 com.azure.core.management.exception.ManagementException thrown if the request is rejected by server on + * status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + Response enableReceiverWithResponse(String resourceGroupName, String actionGroupName, + EnableRequest enableRequest, Context context); + + /** + * Enable a receiver in an action group. This changes the receiver's status from Disabled to Enabled. This operation + * is only supported for Email or SMS receivers. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param actionGroupName The name of the action group. + * @param enableRequest The receiver to re-enable. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server on + * status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + void enableReceiver(String resourceGroupName, String actionGroupName, EnableRequest enableRequest); + + /** + * Get an action group. + * + * @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 action group along with {@link Response}. + */ + ActionGroupResource getById(String id); + + /** + * Get an action group. + * + * @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 action group along with {@link Response}. + */ + Response getByIdWithResponse(String id, Context context); + + /** + * Delete an action group. + * + * @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 action group. + * + * @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 {@link Response}. + */ + Response deleteByIdWithResponse(String id, Context context); + + /** + * Begins definition for a new ActionGroupResource resource. + * + * @param name resource name. + * @return the first stage of the new ActionGroupResource definition. + */ + ActionGroupResource.DefinitionStages.Blank define(String name); +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/Actions.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/Actions.java new file mode 100644 index 0000000000000..48f16cbe56be1 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/Actions.java @@ -0,0 +1,156 @@ +// 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.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; +import java.util.Map; + +/** + * Actions to invoke when the alert fires. + */ +@Fluent +public final class Actions implements JsonSerializable { + /* + * Action Group resource Ids to invoke when the alert fires. + */ + private List actionGroups; + + /* + * The properties of an alert payload. + */ + private Map customProperties; + + /* + * The properties of an action properties. + */ + private Map actionProperties; + + /** + * Creates an instance of Actions class. + */ + public Actions() { + } + + /** + * Get the actionGroups property: Action Group resource Ids to invoke when the alert fires. + * + * @return the actionGroups value. + */ + public List actionGroups() { + return this.actionGroups; + } + + /** + * Set the actionGroups property: Action Group resource Ids to invoke when the alert fires. + * + * @param actionGroups the actionGroups value to set. + * @return the Actions object itself. + */ + public Actions withActionGroups(List actionGroups) { + this.actionGroups = actionGroups; + return this; + } + + /** + * Get the customProperties property: The properties of an alert payload. + * + * @return the customProperties value. + */ + public Map customProperties() { + return this.customProperties; + } + + /** + * Set the customProperties property: The properties of an alert payload. + * + * @param customProperties the customProperties value to set. + * @return the Actions object itself. + */ + public Actions withCustomProperties(Map customProperties) { + this.customProperties = customProperties; + return this; + } + + /** + * Get the actionProperties property: The properties of an action properties. + * + * @return the actionProperties value. + */ + public Map actionProperties() { + return this.actionProperties; + } + + /** + * Set the actionProperties property: The properties of an action properties. + * + * @param actionProperties the actionProperties value to set. + * @return the Actions object itself. + */ + public Actions withActionProperties(Map actionProperties) { + this.actionProperties = actionProperties; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("actionGroups", this.actionGroups, (writer, element) -> writer.writeString(element)); + jsonWriter.writeMapField("customProperties", this.customProperties, + (writer, element) -> writer.writeString(element)); + jsonWriter.writeMapField("actionProperties", this.actionProperties, + (writer, element) -> writer.writeString(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Actions from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Actions if the JsonReader was pointing to an instance of it, or null if it was pointing to + * JSON null. + * @throws IOException If an error occurs while reading the Actions. + */ + public static Actions fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + Actions deserializedActions = new Actions(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("actionGroups".equals(fieldName)) { + List actionGroups = reader.readArray(reader1 -> reader1.getString()); + deserializedActions.actionGroups = actionGroups; + } else if ("customProperties".equals(fieldName)) { + Map customProperties = reader.readMap(reader1 -> reader1.getString()); + deserializedActions.customProperties = customProperties; + } else if ("actionProperties".equals(fieldName)) { + Map actionProperties = reader.readMap(reader1 -> reader1.getString()); + deserializedActions.actionProperties = actionProperties; + } else { + reader.skipChildren(); + } + } + + return deserializedActions; + }); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/AlertSeverity.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/AlertSeverity.java new file mode 100644 index 0000000000000..70674dc398f25 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/AlertSeverity.java @@ -0,0 +1,99 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.monitor.generated.models; + +import com.azure.core.util.ExpandableEnum; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Map; +import java.util.Objects; +import java.util.concurrent.ConcurrentHashMap; +import java.util.function.Function; + +/** + * Severity of the alert. Should be an integer between [0-4]. Value of 0 is severest. Relevant and required only for + * rules of the kind LogAlert. + */ +public final class AlertSeverity implements ExpandableEnum { + private static final Map VALUES = new ConcurrentHashMap<>(); + + private static final Function NEW_INSTANCE = AlertSeverity::new; + + /** + * Static value 0 for AlertSeverity. + */ + public static final AlertSeverity ZERO = fromValue(0L); + + /** + * Static value 1 for AlertSeverity. + */ + public static final AlertSeverity ONE = fromValue(1L); + + /** + * Static value 2 for AlertSeverity. + */ + public static final AlertSeverity TWO = fromValue(2L); + + /** + * Static value 3 for AlertSeverity. + */ + public static final AlertSeverity THREE = fromValue(3L); + + /** + * Static value 4 for AlertSeverity. + */ + public static final AlertSeverity FOUR = fromValue(4L); + + private final Long value; + + private AlertSeverity(Long value) { + this.value = value; + } + + /** + * Creates or finds a AlertSeverity. + * + * @param value a value to look for. + * @return the corresponding AlertSeverity. + */ + public static AlertSeverity fromValue(Long value) { + Objects.requireNonNull(value, "'value' cannot be null."); + return VALUES.computeIfAbsent(value, NEW_INSTANCE); + } + + /** + * Gets known AlertSeverity values. + * + * @return Known AlertSeverity values. + */ + public static Collection values() { + return new ArrayList<>(VALUES.values()); + } + + /** + * Gets the value of the AlertSeverity instance. + * + * @return the value of the AlertSeverity instance. + */ + @Override + public Long getValue() { + return this.value; + } + + @Override + public String toString() { + return Objects.toString(this.value); + } + + @Override + public boolean equals(Object obj) { + return this == obj; + } + + @Override + public int hashCode() { + return Objects.hashCode(this.value); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ArmRoleReceiver.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ArmRoleReceiver.java new file mode 100644 index 0000000000000..57e896f0402e2 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ArmRoleReceiver.java @@ -0,0 +1,163 @@ +// 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.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * An arm role receiver. + */ +@Fluent +public final class ArmRoleReceiver implements JsonSerializable { + /* + * The name of the arm role receiver. Names must be unique across all receivers within an action group. + */ + private String name; + + /* + * The arm role id. + */ + private String roleId; + + /* + * Indicates whether to use common alert schema. + */ + private Boolean useCommonAlertSchema; + + /** + * Creates an instance of ArmRoleReceiver class. + */ + public ArmRoleReceiver() { + } + + /** + * Get the name property: The name of the arm role receiver. Names must be unique across all receivers within an + * action group. + * + * @return the name value. + */ + public String name() { + return this.name; + } + + /** + * Set the name property: The name of the arm role receiver. Names must be unique across all receivers within an + * action group. + * + * @param name the name value to set. + * @return the ArmRoleReceiver object itself. + */ + public ArmRoleReceiver withName(String name) { + this.name = name; + return this; + } + + /** + * Get the roleId property: The arm role id. + * + * @return the roleId value. + */ + public String roleId() { + return this.roleId; + } + + /** + * Set the roleId property: The arm role id. + * + * @param roleId the roleId value to set. + * @return the ArmRoleReceiver object itself. + */ + public ArmRoleReceiver withRoleId(String roleId) { + this.roleId = roleId; + return this; + } + + /** + * Get the useCommonAlertSchema property: Indicates whether to use common alert schema. + * + * @return the useCommonAlertSchema value. + */ + public Boolean useCommonAlertSchema() { + return this.useCommonAlertSchema; + } + + /** + * Set the useCommonAlertSchema property: Indicates whether to use common alert schema. + * + * @param useCommonAlertSchema the useCommonAlertSchema value to set. + * @return the ArmRoleReceiver object itself. + */ + public ArmRoleReceiver withUseCommonAlertSchema(Boolean useCommonAlertSchema) { + this.useCommonAlertSchema = useCommonAlertSchema; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (name() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property name in model ArmRoleReceiver")); + } + if (roleId() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property roleId in model ArmRoleReceiver")); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(ArmRoleReceiver.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + jsonWriter.writeStringField("roleId", this.roleId); + jsonWriter.writeBooleanField("useCommonAlertSchema", this.useCommonAlertSchema); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ArmRoleReceiver from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ArmRoleReceiver if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the ArmRoleReceiver. + */ + public static ArmRoleReceiver fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ArmRoleReceiver deserializedArmRoleReceiver = new ArmRoleReceiver(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + deserializedArmRoleReceiver.name = reader.getString(); + } else if ("roleId".equals(fieldName)) { + deserializedArmRoleReceiver.roleId = reader.getString(); + } else if ("useCommonAlertSchema".equals(fieldName)) { + deserializedArmRoleReceiver.useCommonAlertSchema = reader.getNullable(JsonReader::getBoolean); + } else { + reader.skipChildren(); + } + } + + return deserializedArmRoleReceiver; + }); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/AutomationRunbookReceiver.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/AutomationRunbookReceiver.java new file mode 100644 index 0000000000000..f77ce0ea8f17f --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/AutomationRunbookReceiver.java @@ -0,0 +1,313 @@ +// 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.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The Azure Automation Runbook notification receiver. + */ +@Fluent +public final class AutomationRunbookReceiver implements JsonSerializable { + /* + * The Azure automation account Id which holds this runbook and authenticate to Azure resource. + */ + private String automationAccountId; + + /* + * The name for this runbook. + */ + private String runbookName; + + /* + * The resource id for webhook linked to this runbook. + */ + private String webhookResourceId; + + /* + * Indicates whether this instance is global runbook. + */ + private boolean isGlobalRunbook; + + /* + * Indicates name of the webhook. + */ + private String name; + + /* + * The URI where webhooks should be sent. + */ + private String serviceUri; + + /* + * Indicates whether to use common alert schema. + */ + private Boolean useCommonAlertSchema; + + /* + * The principal id of the managed identity. The value can be "None", "SystemAssigned" + */ + private String managedIdentity; + + /** + * Creates an instance of AutomationRunbookReceiver class. + */ + public AutomationRunbookReceiver() { + } + + /** + * Get the automationAccountId property: The Azure automation account Id which holds this runbook and authenticate + * to Azure resource. + * + * @return the automationAccountId value. + */ + public String automationAccountId() { + return this.automationAccountId; + } + + /** + * Set the automationAccountId property: The Azure automation account Id which holds this runbook and authenticate + * to Azure resource. + * + * @param automationAccountId the automationAccountId value to set. + * @return the AutomationRunbookReceiver object itself. + */ + public AutomationRunbookReceiver withAutomationAccountId(String automationAccountId) { + this.automationAccountId = automationAccountId; + return this; + } + + /** + * Get the runbookName property: The name for this runbook. + * + * @return the runbookName value. + */ + public String runbookName() { + return this.runbookName; + } + + /** + * Set the runbookName property: The name for this runbook. + * + * @param runbookName the runbookName value to set. + * @return the AutomationRunbookReceiver object itself. + */ + public AutomationRunbookReceiver withRunbookName(String runbookName) { + this.runbookName = runbookName; + return this; + } + + /** + * Get the webhookResourceId property: The resource id for webhook linked to this runbook. + * + * @return the webhookResourceId value. + */ + public String webhookResourceId() { + return this.webhookResourceId; + } + + /** + * Set the webhookResourceId property: The resource id for webhook linked to this runbook. + * + * @param webhookResourceId the webhookResourceId value to set. + * @return the AutomationRunbookReceiver object itself. + */ + public AutomationRunbookReceiver withWebhookResourceId(String webhookResourceId) { + this.webhookResourceId = webhookResourceId; + return this; + } + + /** + * Get the isGlobalRunbook property: Indicates whether this instance is global runbook. + * + * @return the isGlobalRunbook value. + */ + public boolean isGlobalRunbook() { + return this.isGlobalRunbook; + } + + /** + * Set the isGlobalRunbook property: Indicates whether this instance is global runbook. + * + * @param isGlobalRunbook the isGlobalRunbook value to set. + * @return the AutomationRunbookReceiver object itself. + */ + public AutomationRunbookReceiver withIsGlobalRunbook(boolean isGlobalRunbook) { + this.isGlobalRunbook = isGlobalRunbook; + return this; + } + + /** + * Get the name property: Indicates name of the webhook. + * + * @return the name value. + */ + public String name() { + return this.name; + } + + /** + * Set the name property: Indicates name of the webhook. + * + * @param name the name value to set. + * @return the AutomationRunbookReceiver object itself. + */ + public AutomationRunbookReceiver withName(String name) { + this.name = name; + return this; + } + + /** + * Get the serviceUri property: The URI where webhooks should be sent. + * + * @return the serviceUri value. + */ + public String serviceUri() { + return this.serviceUri; + } + + /** + * Set the serviceUri property: The URI where webhooks should be sent. + * + * @param serviceUri the serviceUri value to set. + * @return the AutomationRunbookReceiver object itself. + */ + public AutomationRunbookReceiver withServiceUri(String serviceUri) { + this.serviceUri = serviceUri; + return this; + } + + /** + * Get the useCommonAlertSchema property: Indicates whether to use common alert schema. + * + * @return the useCommonAlertSchema value. + */ + public Boolean useCommonAlertSchema() { + return this.useCommonAlertSchema; + } + + /** + * Set the useCommonAlertSchema property: Indicates whether to use common alert schema. + * + * @param useCommonAlertSchema the useCommonAlertSchema value to set. + * @return the AutomationRunbookReceiver object itself. + */ + public AutomationRunbookReceiver withUseCommonAlertSchema(Boolean useCommonAlertSchema) { + this.useCommonAlertSchema = useCommonAlertSchema; + return this; + } + + /** + * Get the managedIdentity property: The principal id of the managed identity. The value can be "None", + * "SystemAssigned". + * + * @return the managedIdentity value. + */ + public String managedIdentity() { + return this.managedIdentity; + } + + /** + * Set the managedIdentity property: The principal id of the managed identity. The value can be "None", + * "SystemAssigned". + * + * @param managedIdentity the managedIdentity value to set. + * @return the AutomationRunbookReceiver object itself. + */ + public AutomationRunbookReceiver withManagedIdentity(String managedIdentity) { + this.managedIdentity = managedIdentity; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (automationAccountId() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property automationAccountId in model AutomationRunbookReceiver")); + } + if (runbookName() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property runbookName in model AutomationRunbookReceiver")); + } + if (webhookResourceId() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property webhookResourceId in model AutomationRunbookReceiver")); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(AutomationRunbookReceiver.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("automationAccountId", this.automationAccountId); + jsonWriter.writeStringField("runbookName", this.runbookName); + jsonWriter.writeStringField("webhookResourceId", this.webhookResourceId); + jsonWriter.writeBooleanField("isGlobalRunbook", this.isGlobalRunbook); + jsonWriter.writeStringField("name", this.name); + jsonWriter.writeStringField("serviceUri", this.serviceUri); + jsonWriter.writeBooleanField("useCommonAlertSchema", this.useCommonAlertSchema); + jsonWriter.writeStringField("managedIdentity", this.managedIdentity); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of AutomationRunbookReceiver from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of AutomationRunbookReceiver if the JsonReader was pointing to an instance of it, or null if + * it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the AutomationRunbookReceiver. + */ + public static AutomationRunbookReceiver fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + AutomationRunbookReceiver deserializedAutomationRunbookReceiver = new AutomationRunbookReceiver(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("automationAccountId".equals(fieldName)) { + deserializedAutomationRunbookReceiver.automationAccountId = reader.getString(); + } else if ("runbookName".equals(fieldName)) { + deserializedAutomationRunbookReceiver.runbookName = reader.getString(); + } else if ("webhookResourceId".equals(fieldName)) { + deserializedAutomationRunbookReceiver.webhookResourceId = reader.getString(); + } else if ("isGlobalRunbook".equals(fieldName)) { + deserializedAutomationRunbookReceiver.isGlobalRunbook = reader.getBoolean(); + } else if ("name".equals(fieldName)) { + deserializedAutomationRunbookReceiver.name = reader.getString(); + } else if ("serviceUri".equals(fieldName)) { + deserializedAutomationRunbookReceiver.serviceUri = reader.getString(); + } else if ("useCommonAlertSchema".equals(fieldName)) { + deserializedAutomationRunbookReceiver.useCommonAlertSchema + = reader.getNullable(JsonReader::getBoolean); + } else if ("managedIdentity".equals(fieldName)) { + deserializedAutomationRunbookReceiver.managedIdentity = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedAutomationRunbookReceiver; + }); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/AzureAppPushReceiver.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/AzureAppPushReceiver.java new file mode 100644 index 0000000000000..29e1d3c7337e7 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/AzureAppPushReceiver.java @@ -0,0 +1,136 @@ +// 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.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The Azure mobile App push notification receiver. + */ +@Fluent +public final class AzureAppPushReceiver implements JsonSerializable { + /* + * The name of the Azure mobile app push receiver. Names must be unique across all receivers within an action group. + */ + private String name; + + /* + * The email address registered for the Azure mobile app. + */ + private String emailAddress; + + /** + * Creates an instance of AzureAppPushReceiver class. + */ + public AzureAppPushReceiver() { + } + + /** + * Get the name property: The name of the Azure mobile app push receiver. Names must be unique across all receivers + * within an action group. + * + * @return the name value. + */ + public String name() { + return this.name; + } + + /** + * Set the name property: The name of the Azure mobile app push receiver. Names must be unique across all receivers + * within an action group. + * + * @param name the name value to set. + * @return the AzureAppPushReceiver object itself. + */ + public AzureAppPushReceiver withName(String name) { + this.name = name; + return this; + } + + /** + * Get the emailAddress property: The email address registered for the Azure mobile app. + * + * @return the emailAddress value. + */ + public String emailAddress() { + return this.emailAddress; + } + + /** + * Set the emailAddress property: The email address registered for the Azure mobile app. + * + * @param emailAddress the emailAddress value to set. + * @return the AzureAppPushReceiver object itself. + */ + public AzureAppPushReceiver withEmailAddress(String emailAddress) { + this.emailAddress = emailAddress; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (name() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property name in model AzureAppPushReceiver")); + } + if (emailAddress() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property emailAddress in model AzureAppPushReceiver")); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(AzureAppPushReceiver.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + jsonWriter.writeStringField("emailAddress", this.emailAddress); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of AzureAppPushReceiver from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of AzureAppPushReceiver if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the AzureAppPushReceiver. + */ + public static AzureAppPushReceiver fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + AzureAppPushReceiver deserializedAzureAppPushReceiver = new AzureAppPushReceiver(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + deserializedAzureAppPushReceiver.name = reader.getString(); + } else if ("emailAddress".equals(fieldName)) { + deserializedAzureAppPushReceiver.emailAddress = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedAzureAppPushReceiver; + }); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/AzureFunctionReceiver.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/AzureFunctionReceiver.java new file mode 100644 index 0000000000000..b616b1dbf7555 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/AzureFunctionReceiver.java @@ -0,0 +1,260 @@ +// 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.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * An azure function receiver. + */ +@Fluent +public final class AzureFunctionReceiver implements JsonSerializable { + /* + * The name of the azure function receiver. Names must be unique across all receivers within an action group. + */ + private String name; + + /* + * The azure resource id of the function app. + */ + private String functionAppResourceId; + + /* + * The function name in the function app. + */ + private String functionName; + + /* + * The http trigger url where http request sent to. + */ + private String httpTriggerUrl; + + /* + * Indicates whether to use common alert schema. + */ + private Boolean useCommonAlertSchema; + + /* + * The principal id of the managed identity. The value can be "None", "SystemAssigned" + */ + private String managedIdentity; + + /** + * Creates an instance of AzureFunctionReceiver class. + */ + public AzureFunctionReceiver() { + } + + /** + * Get the name property: The name of the azure function receiver. Names must be unique across all receivers within + * an action group. + * + * @return the name value. + */ + public String name() { + return this.name; + } + + /** + * Set the name property: The name of the azure function receiver. Names must be unique across all receivers within + * an action group. + * + * @param name the name value to set. + * @return the AzureFunctionReceiver object itself. + */ + public AzureFunctionReceiver withName(String name) { + this.name = name; + return this; + } + + /** + * Get the functionAppResourceId property: The azure resource id of the function app. + * + * @return the functionAppResourceId value. + */ + public String functionAppResourceId() { + return this.functionAppResourceId; + } + + /** + * Set the functionAppResourceId property: The azure resource id of the function app. + * + * @param functionAppResourceId the functionAppResourceId value to set. + * @return the AzureFunctionReceiver object itself. + */ + public AzureFunctionReceiver withFunctionAppResourceId(String functionAppResourceId) { + this.functionAppResourceId = functionAppResourceId; + return this; + } + + /** + * Get the functionName property: The function name in the function app. + * + * @return the functionName value. + */ + public String functionName() { + return this.functionName; + } + + /** + * Set the functionName property: The function name in the function app. + * + * @param functionName the functionName value to set. + * @return the AzureFunctionReceiver object itself. + */ + public AzureFunctionReceiver withFunctionName(String functionName) { + this.functionName = functionName; + return this; + } + + /** + * Get the httpTriggerUrl property: The http trigger url where http request sent to. + * + * @return the httpTriggerUrl value. + */ + public String httpTriggerUrl() { + return this.httpTriggerUrl; + } + + /** + * Set the httpTriggerUrl property: The http trigger url where http request sent to. + * + * @param httpTriggerUrl the httpTriggerUrl value to set. + * @return the AzureFunctionReceiver object itself. + */ + public AzureFunctionReceiver withHttpTriggerUrl(String httpTriggerUrl) { + this.httpTriggerUrl = httpTriggerUrl; + return this; + } + + /** + * Get the useCommonAlertSchema property: Indicates whether to use common alert schema. + * + * @return the useCommonAlertSchema value. + */ + public Boolean useCommonAlertSchema() { + return this.useCommonAlertSchema; + } + + /** + * Set the useCommonAlertSchema property: Indicates whether to use common alert schema. + * + * @param useCommonAlertSchema the useCommonAlertSchema value to set. + * @return the AzureFunctionReceiver object itself. + */ + public AzureFunctionReceiver withUseCommonAlertSchema(Boolean useCommonAlertSchema) { + this.useCommonAlertSchema = useCommonAlertSchema; + return this; + } + + /** + * Get the managedIdentity property: The principal id of the managed identity. The value can be "None", + * "SystemAssigned". + * + * @return the managedIdentity value. + */ + public String managedIdentity() { + return this.managedIdentity; + } + + /** + * Set the managedIdentity property: The principal id of the managed identity. The value can be "None", + * "SystemAssigned". + * + * @param managedIdentity the managedIdentity value to set. + * @return the AzureFunctionReceiver object itself. + */ + public AzureFunctionReceiver withManagedIdentity(String managedIdentity) { + this.managedIdentity = managedIdentity; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (name() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property name in model AzureFunctionReceiver")); + } + if (functionAppResourceId() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property functionAppResourceId in model AzureFunctionReceiver")); + } + if (functionName() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property functionName in model AzureFunctionReceiver")); + } + if (httpTriggerUrl() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property httpTriggerUrl in model AzureFunctionReceiver")); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(AzureFunctionReceiver.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + jsonWriter.writeStringField("functionAppResourceId", this.functionAppResourceId); + jsonWriter.writeStringField("functionName", this.functionName); + jsonWriter.writeStringField("httpTriggerUrl", this.httpTriggerUrl); + jsonWriter.writeBooleanField("useCommonAlertSchema", this.useCommonAlertSchema); + jsonWriter.writeStringField("managedIdentity", this.managedIdentity); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of AzureFunctionReceiver from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of AzureFunctionReceiver if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the AzureFunctionReceiver. + */ + public static AzureFunctionReceiver fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + AzureFunctionReceiver deserializedAzureFunctionReceiver = new AzureFunctionReceiver(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + deserializedAzureFunctionReceiver.name = reader.getString(); + } else if ("functionAppResourceId".equals(fieldName)) { + deserializedAzureFunctionReceiver.functionAppResourceId = reader.getString(); + } else if ("functionName".equals(fieldName)) { + deserializedAzureFunctionReceiver.functionName = reader.getString(); + } else if ("httpTriggerUrl".equals(fieldName)) { + deserializedAzureFunctionReceiver.httpTriggerUrl = reader.getString(); + } else if ("useCommonAlertSchema".equals(fieldName)) { + deserializedAzureFunctionReceiver.useCommonAlertSchema = reader.getNullable(JsonReader::getBoolean); + } else if ("managedIdentity".equals(fieldName)) { + deserializedAzureFunctionReceiver.managedIdentity = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedAzureFunctionReceiver; + }); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/Condition.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/Condition.java new file mode 100644 index 0000000000000..dc89a7932940a --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/Condition.java @@ -0,0 +1,441 @@ +// 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.CoreUtils; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; +import java.util.List; + +/** + * A condition of the scheduled query rule. + */ +@Fluent +public final class Condition implements JsonSerializable { + /* + * Specifies the type of threshold criteria + */ + private CriterionType criterionType; + + /* + * Log query alert + */ + private String query; + + /* + * Aggregation type. Relevant and required only for rules of the kind LogAlert. + */ + private TimeAggregation timeAggregation; + + /* + * The column containing the metric measure number. Relevant only for rules of the kind LogAlert. + */ + private String metricMeasureColumn; + + /* + * The column containing the resource id. The content of the column must be a uri formatted as resource id. Relevant + * only for rules of the kind LogAlert. + */ + private String resourceIdColumn; + + /* + * List of Dimensions conditions + */ + private List dimensions; + + /* + * The criteria operator. Relevant and required only for rules of the kind LogAlert. + */ + private ConditionOperator operator; + + /* + * the criteria threshold value that activates the alert. Relevant and required only for static threshold rules of + * the kind LogAlert. + */ + private Double threshold; + + /* + * The extent of deviation required to trigger an alert. Allowed values are 'Low', 'Medium' and 'High'. This will + * affect how tight the threshold is to the metric series pattern. Relevant and required only for dynamic threshold + * rules of the kind LogAlert. + */ + private String alertSensitivity; + + /* + * Use this option to set the date from which to start learning the metric historical data and calculate the dynamic + * thresholds (in ISO8601 format). Relevant only for dynamic threshold rules of the kind LogAlert. + */ + private OffsetDateTime ignoreDataBefore; + + /* + * The minimum number of violations required within the selected lookback time window required to raise an alert. + * Relevant only for rules of the kind LogAlert. + */ + private ConditionFailingPeriods failingPeriods; + + /* + * The name of the metric to be sent. Relevant and required only for rules of the kind LogToMetric. + */ + private String metricName; + + /** + * Creates an instance of Condition class. + */ + public Condition() { + } + + /** + * Get the criterionType property: Specifies the type of threshold criteria. + * + * @return the criterionType value. + */ + public CriterionType criterionType() { + return this.criterionType; + } + + /** + * Set the criterionType property: Specifies the type of threshold criteria. + * + * @param criterionType the criterionType value to set. + * @return the Condition object itself. + */ + public Condition withCriterionType(CriterionType criterionType) { + this.criterionType = criterionType; + return this; + } + + /** + * Get the query property: Log query alert. + * + * @return the query value. + */ + public String query() { + return this.query; + } + + /** + * Set the query property: Log query alert. + * + * @param query the query value to set. + * @return the Condition object itself. + */ + public Condition withQuery(String query) { + this.query = query; + return this; + } + + /** + * Get the timeAggregation property: Aggregation type. Relevant and required only for rules of the kind LogAlert. + * + * @return the timeAggregation value. + */ + public TimeAggregation timeAggregation() { + return this.timeAggregation; + } + + /** + * Set the timeAggregation property: Aggregation type. Relevant and required only for rules of the kind LogAlert. + * + * @param timeAggregation the timeAggregation value to set. + * @return the Condition object itself. + */ + public Condition withTimeAggregation(TimeAggregation timeAggregation) { + this.timeAggregation = timeAggregation; + return this; + } + + /** + * Get the metricMeasureColumn property: The column containing the metric measure number. Relevant only for rules of + * the kind LogAlert. + * + * @return the metricMeasureColumn value. + */ + public String metricMeasureColumn() { + return this.metricMeasureColumn; + } + + /** + * Set the metricMeasureColumn property: The column containing the metric measure number. Relevant only for rules of + * the kind LogAlert. + * + * @param metricMeasureColumn the metricMeasureColumn value to set. + * @return the Condition object itself. + */ + public Condition withMetricMeasureColumn(String metricMeasureColumn) { + this.metricMeasureColumn = metricMeasureColumn; + return this; + } + + /** + * Get the resourceIdColumn property: The column containing the resource id. The content of the column must be a uri + * formatted as resource id. Relevant only for rules of the kind LogAlert. + * + * @return the resourceIdColumn value. + */ + public String resourceIdColumn() { + return this.resourceIdColumn; + } + + /** + * Set the resourceIdColumn property: The column containing the resource id. The content of the column must be a uri + * formatted as resource id. Relevant only for rules of the kind LogAlert. + * + * @param resourceIdColumn the resourceIdColumn value to set. + * @return the Condition object itself. + */ + public Condition withResourceIdColumn(String resourceIdColumn) { + this.resourceIdColumn = resourceIdColumn; + return this; + } + + /** + * Get the dimensions property: List of Dimensions conditions. + * + * @return the dimensions value. + */ + public List dimensions() { + return this.dimensions; + } + + /** + * Set the dimensions property: List of Dimensions conditions. + * + * @param dimensions the dimensions value to set. + * @return the Condition object itself. + */ + public Condition withDimensions(List dimensions) { + this.dimensions = dimensions; + return this; + } + + /** + * Get the operator property: The criteria operator. Relevant and required only for rules of the kind LogAlert. + * + * @return the operator value. + */ + public ConditionOperator operator() { + return this.operator; + } + + /** + * Set the operator property: The criteria operator. Relevant and required only for rules of the kind LogAlert. + * + * @param operator the operator value to set. + * @return the Condition object itself. + */ + public Condition withOperator(ConditionOperator operator) { + this.operator = operator; + return this; + } + + /** + * Get the threshold property: the criteria threshold value that activates the alert. Relevant and required only for + * static threshold rules of the kind LogAlert. + * + * @return the threshold value. + */ + public Double threshold() { + return this.threshold; + } + + /** + * Set the threshold property: the criteria threshold value that activates the alert. Relevant and required only for + * static threshold rules of the kind LogAlert. + * + * @param threshold the threshold value to set. + * @return the Condition object itself. + */ + public Condition withThreshold(Double threshold) { + this.threshold = threshold; + return this; + } + + /** + * Get the alertSensitivity property: The extent of deviation required to trigger an alert. Allowed values are + * 'Low', 'Medium' and 'High'. This will affect how tight the threshold is to the metric series pattern. Relevant + * and required only for dynamic threshold rules of the kind LogAlert. + * + * @return the alertSensitivity value. + */ + public String alertSensitivity() { + return this.alertSensitivity; + } + + /** + * Set the alertSensitivity property: The extent of deviation required to trigger an alert. Allowed values are + * 'Low', 'Medium' and 'High'. This will affect how tight the threshold is to the metric series pattern. Relevant + * and required only for dynamic threshold rules of the kind LogAlert. + * + * @param alertSensitivity the alertSensitivity value to set. + * @return the Condition object itself. + */ + public Condition withAlertSensitivity(String alertSensitivity) { + this.alertSensitivity = alertSensitivity; + return this; + } + + /** + * Get the ignoreDataBefore property: Use this option to set the date from which to start learning the metric + * historical data and calculate the dynamic thresholds (in ISO8601 format). Relevant only for dynamic threshold + * rules of the kind LogAlert. + * + * @return the ignoreDataBefore value. + */ + public OffsetDateTime ignoreDataBefore() { + return this.ignoreDataBefore; + } + + /** + * Set the ignoreDataBefore property: Use this option to set the date from which to start learning the metric + * historical data and calculate the dynamic thresholds (in ISO8601 format). Relevant only for dynamic threshold + * rules of the kind LogAlert. + * + * @param ignoreDataBefore the ignoreDataBefore value to set. + * @return the Condition object itself. + */ + public Condition withIgnoreDataBefore(OffsetDateTime ignoreDataBefore) { + this.ignoreDataBefore = ignoreDataBefore; + return this; + } + + /** + * Get the failingPeriods property: The minimum number of violations required within the selected lookback time + * window required to raise an alert. Relevant only for rules of the kind LogAlert. + * + * @return the failingPeriods value. + */ + public ConditionFailingPeriods failingPeriods() { + return this.failingPeriods; + } + + /** + * Set the failingPeriods property: The minimum number of violations required within the selected lookback time + * window required to raise an alert. Relevant only for rules of the kind LogAlert. + * + * @param failingPeriods the failingPeriods value to set. + * @return the Condition object itself. + */ + public Condition withFailingPeriods(ConditionFailingPeriods failingPeriods) { + this.failingPeriods = failingPeriods; + return this; + } + + /** + * Get the metricName property: The name of the metric to be sent. Relevant and required only for rules of the kind + * LogToMetric. + * + * @return the metricName value. + */ + public String metricName() { + return this.metricName; + } + + /** + * Set the metricName property: The name of the metric to be sent. Relevant and required only for rules of the kind + * LogToMetric. + * + * @param metricName the metricName value to set. + * @return the Condition object itself. + */ + public Condition withMetricName(String metricName) { + this.metricName = metricName; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (dimensions() != null) { + dimensions().forEach(e -> e.validate()); + } + if (failingPeriods() != null) { + failingPeriods().validate(); + } + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("criterionType", this.criterionType == null ? null : this.criterionType.toString()); + jsonWriter.writeStringField("query", this.query); + jsonWriter.writeStringField("timeAggregation", + this.timeAggregation == null ? null : this.timeAggregation.toString()); + jsonWriter.writeStringField("metricMeasureColumn", this.metricMeasureColumn); + jsonWriter.writeStringField("resourceIdColumn", this.resourceIdColumn); + jsonWriter.writeArrayField("dimensions", this.dimensions, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeStringField("operator", this.operator == null ? null : this.operator.toString()); + jsonWriter.writeNumberField("threshold", this.threshold); + jsonWriter.writeStringField("alertSensitivity", this.alertSensitivity); + jsonWriter.writeStringField("ignoreDataBefore", + this.ignoreDataBefore == null + ? null + : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.ignoreDataBefore)); + jsonWriter.writeJsonField("failingPeriods", this.failingPeriods); + jsonWriter.writeStringField("metricName", this.metricName); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Condition from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Condition if the JsonReader was pointing to an instance of it, or null if it was pointing + * to JSON null. + * @throws IOException If an error occurs while reading the Condition. + */ + public static Condition fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + Condition deserializedCondition = new Condition(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("criterionType".equals(fieldName)) { + deserializedCondition.criterionType = CriterionType.fromString(reader.getString()); + } else if ("query".equals(fieldName)) { + deserializedCondition.query = reader.getString(); + } else if ("timeAggregation".equals(fieldName)) { + deserializedCondition.timeAggregation = TimeAggregation.fromString(reader.getString()); + } else if ("metricMeasureColumn".equals(fieldName)) { + deserializedCondition.metricMeasureColumn = reader.getString(); + } else if ("resourceIdColumn".equals(fieldName)) { + deserializedCondition.resourceIdColumn = reader.getString(); + } else if ("dimensions".equals(fieldName)) { + List dimensions = reader.readArray(reader1 -> Dimension.fromJson(reader1)); + deserializedCondition.dimensions = dimensions; + } else if ("operator".equals(fieldName)) { + deserializedCondition.operator = ConditionOperator.fromString(reader.getString()); + } else if ("threshold".equals(fieldName)) { + deserializedCondition.threshold = reader.getNullable(JsonReader::getDouble); + } else if ("alertSensitivity".equals(fieldName)) { + deserializedCondition.alertSensitivity = reader.getString(); + } else if ("ignoreDataBefore".equals(fieldName)) { + deserializedCondition.ignoreDataBefore = reader + .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString())); + } else if ("failingPeriods".equals(fieldName)) { + deserializedCondition.failingPeriods = ConditionFailingPeriods.fromJson(reader); + } else if ("metricName".equals(fieldName)) { + deserializedCondition.metricName = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedCondition; + }); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ConditionFailingPeriods.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ConditionFailingPeriods.java new file mode 100644 index 0000000000000..c09009fbe6e3c --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ConditionFailingPeriods.java @@ -0,0 +1,132 @@ +// 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.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The minimum number of violations required within the selected lookback time window required to raise an alert. + * Relevant only for rules of the kind LogAlert. + */ +@Fluent +public final class ConditionFailingPeriods implements JsonSerializable { + /* + * The number of aggregated lookback points. The lookback time window is calculated based on the aggregation + * granularity (windowSize) and the selected number of aggregated points. Default value is 1 + */ + private Long numberOfEvaluationPeriods; + + /* + * The number of violations to trigger an alert. Should be smaller or equal to numberOfEvaluationPeriods. Default + * value is 1 + */ + private Long minFailingPeriodsToAlert; + + /** + * Creates an instance of ConditionFailingPeriods class. + */ + public ConditionFailingPeriods() { + } + + /** + * Get the numberOfEvaluationPeriods property: The number of aggregated lookback points. The lookback time window is + * calculated based on the aggregation granularity (windowSize) and the selected number of aggregated points. + * Default value is 1. + * + * @return the numberOfEvaluationPeriods value. + */ + public Long numberOfEvaluationPeriods() { + return this.numberOfEvaluationPeriods; + } + + /** + * Set the numberOfEvaluationPeriods property: The number of aggregated lookback points. The lookback time window is + * calculated based on the aggregation granularity (windowSize) and the selected number of aggregated points. + * Default value is 1. + * + * @param numberOfEvaluationPeriods the numberOfEvaluationPeriods value to set. + * @return the ConditionFailingPeriods object itself. + */ + public ConditionFailingPeriods withNumberOfEvaluationPeriods(Long numberOfEvaluationPeriods) { + this.numberOfEvaluationPeriods = numberOfEvaluationPeriods; + return this; + } + + /** + * Get the minFailingPeriodsToAlert property: The number of violations to trigger an alert. Should be smaller or + * equal to numberOfEvaluationPeriods. Default value is 1. + * + * @return the minFailingPeriodsToAlert value. + */ + public Long minFailingPeriodsToAlert() { + return this.minFailingPeriodsToAlert; + } + + /** + * Set the minFailingPeriodsToAlert property: The number of violations to trigger an alert. Should be smaller or + * equal to numberOfEvaluationPeriods. Default value is 1. + * + * @param minFailingPeriodsToAlert the minFailingPeriodsToAlert value to set. + * @return the ConditionFailingPeriods object itself. + */ + public ConditionFailingPeriods withMinFailingPeriodsToAlert(Long minFailingPeriodsToAlert) { + this.minFailingPeriodsToAlert = minFailingPeriodsToAlert; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeNumberField("numberOfEvaluationPeriods", this.numberOfEvaluationPeriods); + jsonWriter.writeNumberField("minFailingPeriodsToAlert", this.minFailingPeriodsToAlert); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ConditionFailingPeriods from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ConditionFailingPeriods if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IOException If an error occurs while reading the ConditionFailingPeriods. + */ + public static ConditionFailingPeriods fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ConditionFailingPeriods deserializedConditionFailingPeriods = new ConditionFailingPeriods(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("numberOfEvaluationPeriods".equals(fieldName)) { + deserializedConditionFailingPeriods.numberOfEvaluationPeriods + = reader.getNullable(JsonReader::getLong); + } else if ("minFailingPeriodsToAlert".equals(fieldName)) { + deserializedConditionFailingPeriods.minFailingPeriodsToAlert + = reader.getNullable(JsonReader::getLong); + } else { + reader.skipChildren(); + } + } + + return deserializedConditionFailingPeriods; + }); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ConditionOperator.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ConditionOperator.java new file mode 100644 index 0000000000000..0ec02ac2af68a --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ConditionOperator.java @@ -0,0 +1,71 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.monitor.generated.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * The criteria operator. Relevant and required only for rules of the kind LogAlert. + */ +public final class ConditionOperator extends ExpandableStringEnum { + /** + * Static value Equals for ConditionOperator. + */ + public static final ConditionOperator EQUALS = fromString("Equals"); + + /** + * Static value GreaterThan for ConditionOperator. + */ + public static final ConditionOperator GREATER_THAN = fromString("GreaterThan"); + + /** + * Static value GreaterThanOrEqual for ConditionOperator. + */ + public static final ConditionOperator GREATER_THAN_OR_EQUAL = fromString("GreaterThanOrEqual"); + + /** + * Static value LessThan for ConditionOperator. + */ + public static final ConditionOperator LESS_THAN = fromString("LessThan"); + + /** + * Static value LessThanOrEqual for ConditionOperator. + */ + public static final ConditionOperator LESS_THAN_OR_EQUAL = fromString("LessThanOrEqual"); + + /** + * Static value GreaterOrLessThan for ConditionOperator. + */ + public static final ConditionOperator GREATER_OR_LESS_THAN = fromString("GreaterOrLessThan"); + + /** + * Creates a new instance of ConditionOperator value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public ConditionOperator() { + } + + /** + * Creates or finds a ConditionOperator from its string representation. + * + * @param name a name to look for. + * @return the corresponding ConditionOperator. + */ + public static ConditionOperator fromString(String name) { + return fromString(name, ConditionOperator.class); + } + + /** + * Gets known ConditionOperator values. + * + * @return known ConditionOperator values. + */ + public static Collection values() { + return values(ConditionOperator.class); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/Context.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/Context.java new file mode 100644 index 0000000000000..e16ef6d52942e --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/Context.java @@ -0,0 +1,121 @@ +// 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.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The context info. + */ +@Fluent +public final class Context implements JsonSerializable { + /* + * The source of the notification request + */ + private String notificationSource; + + /* + * The context id type + */ + private String contextType; + + /** + * Creates an instance of Context class. + */ + public Context() { + } + + /** + * Get the notificationSource property: The source of the notification request. + * + * @return the notificationSource value. + */ + public String notificationSource() { + return this.notificationSource; + } + + /** + * Set the notificationSource property: The source of the notification request. + * + * @param notificationSource the notificationSource value to set. + * @return the Context object itself. + */ + public Context withNotificationSource(String notificationSource) { + this.notificationSource = notificationSource; + return this; + } + + /** + * Get the contextType property: The context id type. + * + * @return the contextType value. + */ + public String contextType() { + return this.contextType; + } + + /** + * Set the contextType property: The context id type. + * + * @param contextType the contextType value to set. + * @return the Context object itself. + */ + public Context withContextType(String contextType) { + this.contextType = contextType; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("notificationSource", this.notificationSource); + jsonWriter.writeStringField("contextType", this.contextType); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Context from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Context if the JsonReader was pointing to an instance of it, or null if it was pointing to + * JSON null. + * @throws IOException If an error occurs while reading the Context. + */ + public static Context fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + Context deserializedContext = new Context(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("notificationSource".equals(fieldName)) { + deserializedContext.notificationSource = reader.getString(); + } else if ("contextType".equals(fieldName)) { + deserializedContext.contextType = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedContext; + }); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/CriterionType.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/CriterionType.java new file mode 100644 index 0000000000000..7026bfb750b23 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/CriterionType.java @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.monitor.generated.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Specifies the type of threshold criteria. + */ +public final class CriterionType extends ExpandableStringEnum { + /** + * Static value StaticThresholdCriterion for CriterionType. + */ + public static final CriterionType STATIC_THRESHOLD_CRITERION = fromString("StaticThresholdCriterion"); + + /** + * Static value DynamicThresholdCriterion for CriterionType. + */ + public static final CriterionType DYNAMIC_THRESHOLD_CRITERION = fromString("DynamicThresholdCriterion"); + + /** + * Creates a new instance of CriterionType value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public CriterionType() { + } + + /** + * Creates or finds a CriterionType from its string representation. + * + * @param name a name to look for. + * @return the corresponding CriterionType. + */ + public static CriterionType fromString(String name) { + return fromString(name, CriterionType.class); + } + + /** + * Gets known CriterionType values. + * + * @return known CriterionType values. + */ + public static Collection values() { + return values(CriterionType.class); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/Dimension.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/Dimension.java new file mode 100644 index 0000000000000..2ed90a988109f --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/Dimension.java @@ -0,0 +1,167 @@ +// 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.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * Dimension splitting and filtering definition. + */ +@Fluent +public final class Dimension implements JsonSerializable { + /* + * Name of the dimension + */ + private String name; + + /* + * Operator for dimension values + */ + private DimensionOperator operator; + + /* + * List of dimension values + */ + private List values; + + /** + * Creates an instance of Dimension class. + */ + public Dimension() { + } + + /** + * Get the name property: Name of the dimension. + * + * @return the name value. + */ + public String name() { + return this.name; + } + + /** + * Set the name property: Name of the dimension. + * + * @param name the name value to set. + * @return the Dimension object itself. + */ + public Dimension withName(String name) { + this.name = name; + return this; + } + + /** + * Get the operator property: Operator for dimension values. + * + * @return the operator value. + */ + public DimensionOperator operator() { + return this.operator; + } + + /** + * Set the operator property: Operator for dimension values. + * + * @param operator the operator value to set. + * @return the Dimension object itself. + */ + public Dimension withOperator(DimensionOperator operator) { + this.operator = operator; + return this; + } + + /** + * Get the values property: List of dimension values. + * + * @return the values value. + */ + public List values() { + return this.values; + } + + /** + * Set the values property: List of dimension values. + * + * @param values the values value to set. + * @return the Dimension object itself. + */ + public Dimension withValues(List values) { + this.values = values; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (name() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property name in model Dimension")); + } + if (operator() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property operator in model Dimension")); + } + if (values() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property values in model Dimension")); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(Dimension.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + jsonWriter.writeStringField("operator", this.operator == null ? null : this.operator.toString()); + jsonWriter.writeArrayField("values", this.values, (writer, element) -> writer.writeString(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Dimension from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Dimension if the JsonReader was pointing to an instance of it, or null if it was pointing + * to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the Dimension. + */ + public static Dimension fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + Dimension deserializedDimension = new Dimension(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + deserializedDimension.name = reader.getString(); + } else if ("operator".equals(fieldName)) { + deserializedDimension.operator = DimensionOperator.fromString(reader.getString()); + } else if ("values".equals(fieldName)) { + List values = reader.readArray(reader1 -> reader1.getString()); + deserializedDimension.values = values; + } else { + reader.skipChildren(); + } + } + + return deserializedDimension; + }); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/DimensionOperator.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/DimensionOperator.java new file mode 100644 index 0000000000000..29fd64d058f76 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/DimensionOperator.java @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.monitor.generated.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Operator for dimension values. + */ +public final class DimensionOperator extends ExpandableStringEnum { + /** + * Static value Include for DimensionOperator. + */ + public static final DimensionOperator INCLUDE = fromString("Include"); + + /** + * Static value Exclude for DimensionOperator. + */ + public static final DimensionOperator EXCLUDE = fromString("Exclude"); + + /** + * Creates a new instance of DimensionOperator value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public DimensionOperator() { + } + + /** + * Creates or finds a DimensionOperator from its string representation. + * + * @param name a name to look for. + * @return the corresponding DimensionOperator. + */ + public static DimensionOperator fromString(String name) { + return fromString(name, DimensionOperator.class); + } + + /** + * Gets known DimensionOperator values. + * + * @return known DimensionOperator values. + */ + public static Collection values() { + return values(DimensionOperator.class); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/EmailReceiver.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/EmailReceiver.java new file mode 100644 index 0000000000000..42458f3709465 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/EmailReceiver.java @@ -0,0 +1,179 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.monitor.generated.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * An email receiver. + */ +@Fluent +public final class EmailReceiver implements JsonSerializable { + /* + * The name of the email receiver. Names must be unique across all receivers within an action group. + */ + private String name; + + /* + * The email address of this receiver. + */ + private String emailAddress; + + /* + * Indicates whether to use common alert schema. + */ + private Boolean useCommonAlertSchema; + + /* + * The receiver status of the e-mail. + */ + private ReceiverStatus status; + + /** + * Creates an instance of EmailReceiver class. + */ + public EmailReceiver() { + } + + /** + * Get the name property: The name of the email receiver. Names must be unique across all receivers within an action + * group. + * + * @return the name value. + */ + public String name() { + return this.name; + } + + /** + * Set the name property: The name of the email receiver. Names must be unique across all receivers within an action + * group. + * + * @param name the name value to set. + * @return the EmailReceiver object itself. + */ + public EmailReceiver withName(String name) { + this.name = name; + return this; + } + + /** + * Get the emailAddress property: The email address of this receiver. + * + * @return the emailAddress value. + */ + public String emailAddress() { + return this.emailAddress; + } + + /** + * Set the emailAddress property: The email address of this receiver. + * + * @param emailAddress the emailAddress value to set. + * @return the EmailReceiver object itself. + */ + public EmailReceiver withEmailAddress(String emailAddress) { + this.emailAddress = emailAddress; + return this; + } + + /** + * Get the useCommonAlertSchema property: Indicates whether to use common alert schema. + * + * @return the useCommonAlertSchema value. + */ + public Boolean useCommonAlertSchema() { + return this.useCommonAlertSchema; + } + + /** + * Set the useCommonAlertSchema property: Indicates whether to use common alert schema. + * + * @param useCommonAlertSchema the useCommonAlertSchema value to set. + * @return the EmailReceiver object itself. + */ + public EmailReceiver withUseCommonAlertSchema(Boolean useCommonAlertSchema) { + this.useCommonAlertSchema = useCommonAlertSchema; + return this; + } + + /** + * Get the status property: The receiver status of the e-mail. + * + * @return the status value. + */ + public ReceiverStatus status() { + return this.status; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (name() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property name in model EmailReceiver")); + } + if (emailAddress() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property emailAddress in model EmailReceiver")); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(EmailReceiver.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + jsonWriter.writeStringField("emailAddress", this.emailAddress); + jsonWriter.writeBooleanField("useCommonAlertSchema", this.useCommonAlertSchema); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of EmailReceiver from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of EmailReceiver if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the EmailReceiver. + */ + public static EmailReceiver fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + EmailReceiver deserializedEmailReceiver = new EmailReceiver(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + deserializedEmailReceiver.name = reader.getString(); + } else if ("emailAddress".equals(fieldName)) { + deserializedEmailReceiver.emailAddress = reader.getString(); + } else if ("useCommonAlertSchema".equals(fieldName)) { + deserializedEmailReceiver.useCommonAlertSchema = reader.getNullable(JsonReader::getBoolean); + } else if ("status".equals(fieldName)) { + deserializedEmailReceiver.status = ReceiverStatus.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + + return deserializedEmailReceiver; + }); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/EnableRequest.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/EnableRequest.java new file mode 100644 index 0000000000000..418dffa9aef28 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/EnableRequest.java @@ -0,0 +1,101 @@ +// 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.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Describes a receiver that should be resubscribed. + */ +@Fluent +public final class EnableRequest implements JsonSerializable { + /* + * The name of the receiver to resubscribe. + */ + private String receiverName; + + /** + * Creates an instance of EnableRequest class. + */ + public EnableRequest() { + } + + /** + * Get the receiverName property: The name of the receiver to resubscribe. + * + * @return the receiverName value. + */ + public String receiverName() { + return this.receiverName; + } + + /** + * Set the receiverName property: The name of the receiver to resubscribe. + * + * @param receiverName the receiverName value to set. + * @return the EnableRequest object itself. + */ + public EnableRequest withReceiverName(String receiverName) { + this.receiverName = receiverName; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (receiverName() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property receiverName in model EnableRequest")); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(EnableRequest.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("receiverName", this.receiverName); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of EnableRequest from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of EnableRequest if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the EnableRequest. + */ + public static EnableRequest fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + EnableRequest deserializedEnableRequest = new EnableRequest(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("receiverName".equals(fieldName)) { + deserializedEnableRequest.receiverName = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedEnableRequest; + }); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/EventHubReceiver.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/EventHubReceiver.java new file mode 100644 index 0000000000000..a4dfc9c21b8a2 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/EventHubReceiver.java @@ -0,0 +1,287 @@ +// 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.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * An Event hub receiver. + */ +@Fluent +public final class EventHubReceiver implements JsonSerializable { + /* + * The name of the Event hub receiver. Names must be unique across all receivers within an action group. + */ + private String name; + + /* + * The Event Hub namespace + */ + private String eventHubNameSpace; + + /* + * The name of the specific Event Hub queue + */ + private String eventHubName; + + /* + * Indicates whether to use common alert schema. + */ + private Boolean useCommonAlertSchema; + + /* + * The tenant Id for the subscription containing this event hub + */ + private String tenantId; + + /* + * The Id for the subscription containing this event hub + */ + private String subscriptionId; + + /* + * The principal id of the managed identity. The value can be "None", "SystemAssigned" + */ + private String managedIdentity; + + /** + * Creates an instance of EventHubReceiver class. + */ + public EventHubReceiver() { + } + + /** + * Get the name property: The name of the Event hub receiver. Names must be unique across all receivers within an + * action group. + * + * @return the name value. + */ + public String name() { + return this.name; + } + + /** + * Set the name property: The name of the Event hub receiver. Names must be unique across all receivers within an + * action group. + * + * @param name the name value to set. + * @return the EventHubReceiver object itself. + */ + public EventHubReceiver withName(String name) { + this.name = name; + return this; + } + + /** + * Get the eventHubNameSpace property: The Event Hub namespace. + * + * @return the eventHubNameSpace value. + */ + public String eventHubNameSpace() { + return this.eventHubNameSpace; + } + + /** + * Set the eventHubNameSpace property: The Event Hub namespace. + * + * @param eventHubNameSpace the eventHubNameSpace value to set. + * @return the EventHubReceiver object itself. + */ + public EventHubReceiver withEventHubNameSpace(String eventHubNameSpace) { + this.eventHubNameSpace = eventHubNameSpace; + return this; + } + + /** + * Get the eventHubName property: The name of the specific Event Hub queue. + * + * @return the eventHubName value. + */ + public String eventHubName() { + return this.eventHubName; + } + + /** + * Set the eventHubName property: The name of the specific Event Hub queue. + * + * @param eventHubName the eventHubName value to set. + * @return the EventHubReceiver object itself. + */ + public EventHubReceiver withEventHubName(String eventHubName) { + this.eventHubName = eventHubName; + return this; + } + + /** + * Get the useCommonAlertSchema property: Indicates whether to use common alert schema. + * + * @return the useCommonAlertSchema value. + */ + public Boolean useCommonAlertSchema() { + return this.useCommonAlertSchema; + } + + /** + * Set the useCommonAlertSchema property: Indicates whether to use common alert schema. + * + * @param useCommonAlertSchema the useCommonAlertSchema value to set. + * @return the EventHubReceiver object itself. + */ + public EventHubReceiver withUseCommonAlertSchema(Boolean useCommonAlertSchema) { + this.useCommonAlertSchema = useCommonAlertSchema; + return this; + } + + /** + * Get the tenantId property: The tenant Id for the subscription containing this event hub. + * + * @return the tenantId value. + */ + public String tenantId() { + return this.tenantId; + } + + /** + * Set the tenantId property: The tenant Id for the subscription containing this event hub. + * + * @param tenantId the tenantId value to set. + * @return the EventHubReceiver object itself. + */ + public EventHubReceiver withTenantId(String tenantId) { + this.tenantId = tenantId; + return this; + } + + /** + * Get the subscriptionId property: The Id for the subscription containing this event hub. + * + * @return the subscriptionId value. + */ + public String subscriptionId() { + return this.subscriptionId; + } + + /** + * Set the subscriptionId property: The Id for the subscription containing this event hub. + * + * @param subscriptionId the subscriptionId value to set. + * @return the EventHubReceiver object itself. + */ + public EventHubReceiver withSubscriptionId(String subscriptionId) { + this.subscriptionId = subscriptionId; + return this; + } + + /** + * Get the managedIdentity property: The principal id of the managed identity. The value can be "None", + * "SystemAssigned". + * + * @return the managedIdentity value. + */ + public String managedIdentity() { + return this.managedIdentity; + } + + /** + * Set the managedIdentity property: The principal id of the managed identity. The value can be "None", + * "SystemAssigned". + * + * @param managedIdentity the managedIdentity value to set. + * @return the EventHubReceiver object itself. + */ + public EventHubReceiver withManagedIdentity(String managedIdentity) { + this.managedIdentity = managedIdentity; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (name() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property name in model EventHubReceiver")); + } + if (eventHubNameSpace() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property eventHubNameSpace in model EventHubReceiver")); + } + if (eventHubName() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property eventHubName in model EventHubReceiver")); + } + if (subscriptionId() == null) { + throw LOGGER.atError() + .log( + new IllegalArgumentException("Missing required property subscriptionId in model EventHubReceiver")); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(EventHubReceiver.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + jsonWriter.writeStringField("eventHubNameSpace", this.eventHubNameSpace); + jsonWriter.writeStringField("eventHubName", this.eventHubName); + jsonWriter.writeStringField("subscriptionId", this.subscriptionId); + jsonWriter.writeBooleanField("useCommonAlertSchema", this.useCommonAlertSchema); + jsonWriter.writeStringField("tenantId", this.tenantId); + jsonWriter.writeStringField("managedIdentity", this.managedIdentity); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of EventHubReceiver from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of EventHubReceiver if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the EventHubReceiver. + */ + public static EventHubReceiver fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + EventHubReceiver deserializedEventHubReceiver = new EventHubReceiver(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + deserializedEventHubReceiver.name = reader.getString(); + } else if ("eventHubNameSpace".equals(fieldName)) { + deserializedEventHubReceiver.eventHubNameSpace = reader.getString(); + } else if ("eventHubName".equals(fieldName)) { + deserializedEventHubReceiver.eventHubName = reader.getString(); + } else if ("subscriptionId".equals(fieldName)) { + deserializedEventHubReceiver.subscriptionId = reader.getString(); + } else if ("useCommonAlertSchema".equals(fieldName)) { + deserializedEventHubReceiver.useCommonAlertSchema = reader.getNullable(JsonReader::getBoolean); + } else if ("tenantId".equals(fieldName)) { + deserializedEventHubReceiver.tenantId = reader.getString(); + } else if ("managedIdentity".equals(fieldName)) { + deserializedEventHubReceiver.managedIdentity = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedEventHubReceiver; + }); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/Identity.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/Identity.java new file mode 100644 index 0000000000000..abd4ebbd3a145 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/Identity.java @@ -0,0 +1,179 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.monitor.generated.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.Map; + +/** + * Identity for the resource. + */ +@Fluent +public final class Identity implements JsonSerializable { + /* + * The principal ID of resource identity. + */ + private String principalId; + + /* + * The tenant ID of resource. + */ + private String tenantId; + + /* + * Type of managed service identity. + */ + private IdentityType type; + + /* + * The list of user identities associated with the resource. The user identity dictionary key references will be ARM + * resource ids in the form: + * '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/ + * userAssignedIdentities/{identityName}'. + */ + private Map userAssignedIdentities; + + /** + * Creates an instance of Identity class. + */ + public Identity() { + } + + /** + * Get the principalId property: The principal ID of resource identity. + * + * @return the principalId value. + */ + public String principalId() { + return this.principalId; + } + + /** + * Get the tenantId property: The tenant ID of resource. + * + * @return the tenantId value. + */ + public String tenantId() { + return this.tenantId; + } + + /** + * Get the type property: Type of managed service identity. + * + * @return the type value. + */ + public IdentityType type() { + return this.type; + } + + /** + * Set the type property: Type of managed service identity. + * + * @param type the type value to set. + * @return the Identity object itself. + */ + public Identity withType(IdentityType type) { + this.type = type; + return this; + } + + /** + * Get the userAssignedIdentities property: The list of user identities associated with the resource. The user + * identity dictionary key references will be ARM resource ids in the form: + * '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. + * + * @return the userAssignedIdentities value. + */ + public Map userAssignedIdentities() { + return this.userAssignedIdentities; + } + + /** + * Set the userAssignedIdentities property: The list of user identities associated with the resource. The user + * identity dictionary key references will be ARM resource ids in the form: + * '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. + * + * @param userAssignedIdentities the userAssignedIdentities value to set. + * @return the Identity object itself. + */ + public Identity withUserAssignedIdentities(Map userAssignedIdentities) { + this.userAssignedIdentities = userAssignedIdentities; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (type() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property type in model Identity")); + } + if (userAssignedIdentities() != null) { + userAssignedIdentities().values().forEach(e -> { + if (e != null) { + e.validate(); + } + }); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(Identity.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("type", this.type == null ? null : this.type.toString()); + jsonWriter.writeMapField("userAssignedIdentities", this.userAssignedIdentities, + (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Identity from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Identity if the JsonReader was pointing to an instance of it, or null if it was pointing + * to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the Identity. + */ + public static Identity fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + Identity deserializedIdentity = new Identity(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("type".equals(fieldName)) { + deserializedIdentity.type = IdentityType.fromString(reader.getString()); + } else if ("principalId".equals(fieldName)) { + deserializedIdentity.principalId = reader.getString(); + } else if ("tenantId".equals(fieldName)) { + deserializedIdentity.tenantId = reader.getString(); + } else if ("userAssignedIdentities".equals(fieldName)) { + Map userAssignedIdentities + = reader.readMap(reader1 -> UserIdentityProperties.fromJson(reader1)); + deserializedIdentity.userAssignedIdentities = userAssignedIdentities; + } else { + reader.skipChildren(); + } + } + + return deserializedIdentity; + }); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/IdentityType.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/IdentityType.java new file mode 100644 index 0000000000000..7be02f221d274 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/IdentityType.java @@ -0,0 +1,61 @@ +// 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; + +/** + * Type of managed service identity. + */ +public enum IdentityType { + /** + * Enum value SystemAssigned. + */ + SYSTEM_ASSIGNED("SystemAssigned"), + + /** + * Enum value UserAssigned. + */ + USER_ASSIGNED("UserAssigned"), + + /** + * Enum value None. + */ + NONE("None"); + + /** + * The actual serialized value for a IdentityType instance. + */ + private final String value; + + IdentityType(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a IdentityType instance. + * + * @param value the serialized value to parse. + * @return the parsed IdentityType object, or null if unable to parse. + */ + public static IdentityType fromString(String value) { + if (value == null) { + return null; + } + IdentityType[] items = IdentityType.values(); + for (IdentityType item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return this.value; + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/IncidentManagementService.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/IncidentManagementService.java new file mode 100644 index 0000000000000..36e50d6fe9c64 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/IncidentManagementService.java @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.monitor.generated.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * The incident management service type. + */ +public final class IncidentManagementService extends ExpandableStringEnum { + /** + * Static value Icm for IncidentManagementService. + */ + public static final IncidentManagementService ICM = fromString("Icm"); + + /** + * Creates a new instance of IncidentManagementService value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public IncidentManagementService() { + } + + /** + * Creates or finds a IncidentManagementService from its string representation. + * + * @param name a name to look for. + * @return the corresponding IncidentManagementService. + */ + public static IncidentManagementService fromString(String name) { + return fromString(name, IncidentManagementService.class); + } + + /** + * Gets known IncidentManagementService values. + * + * @return known IncidentManagementService values. + */ + public static Collection values() { + return values(IncidentManagementService.class); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/IncidentReceiver.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/IncidentReceiver.java new file mode 100644 index 0000000000000..4ca1b93509892 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/IncidentReceiver.java @@ -0,0 +1,206 @@ +// 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.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.Map; + +/** + * An Incident receiver. + */ +@Fluent +public final class IncidentReceiver implements JsonSerializable { + /* + * The name of the Incident receiver. Names must be unique across all receivers within an action group. + */ + private String name; + + /* + * The incident service connection + */ + private IncidentServiceConnection connection; + + /* + * The incident management service type + */ + private IncidentManagementService incidentManagementService; + + /* + * Field mappings for the incident service + */ + private Map mappings; + + /** + * Creates an instance of IncidentReceiver class. + */ + public IncidentReceiver() { + } + + /** + * Get the name property: The name of the Incident receiver. Names must be unique across all receivers within an + * action group. + * + * @return the name value. + */ + public String name() { + return this.name; + } + + /** + * Set the name property: The name of the Incident receiver. Names must be unique across all receivers within an + * action group. + * + * @param name the name value to set. + * @return the IncidentReceiver object itself. + */ + public IncidentReceiver withName(String name) { + this.name = name; + return this; + } + + /** + * Get the connection property: The incident service connection. + * + * @return the connection value. + */ + public IncidentServiceConnection connection() { + return this.connection; + } + + /** + * Set the connection property: The incident service connection. + * + * @param connection the connection value to set. + * @return the IncidentReceiver object itself. + */ + public IncidentReceiver withConnection(IncidentServiceConnection connection) { + this.connection = connection; + return this; + } + + /** + * Get the incidentManagementService property: The incident management service type. + * + * @return the incidentManagementService value. + */ + public IncidentManagementService incidentManagementService() { + return this.incidentManagementService; + } + + /** + * Set the incidentManagementService property: The incident management service type. + * + * @param incidentManagementService the incidentManagementService value to set. + * @return the IncidentReceiver object itself. + */ + public IncidentReceiver withIncidentManagementService(IncidentManagementService incidentManagementService) { + this.incidentManagementService = incidentManagementService; + return this; + } + + /** + * Get the mappings property: Field mappings for the incident service. + * + * @return the mappings value. + */ + public Map mappings() { + return this.mappings; + } + + /** + * Set the mappings property: Field mappings for the incident service. + * + * @param mappings the mappings value to set. + * @return the IncidentReceiver object itself. + */ + public IncidentReceiver withMappings(Map mappings) { + this.mappings = mappings; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (name() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property name in model IncidentReceiver")); + } + if (connection() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property connection in model IncidentReceiver")); + } else { + connection().validate(); + } + if (incidentManagementService() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property incidentManagementService in model IncidentReceiver")); + } + if (mappings() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property mappings in model IncidentReceiver")); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(IncidentReceiver.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + jsonWriter.writeJsonField("connection", this.connection); + jsonWriter.writeStringField("incidentManagementService", + this.incidentManagementService == null ? null : this.incidentManagementService.toString()); + jsonWriter.writeMapField("mappings", this.mappings, (writer, element) -> writer.writeString(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of IncidentReceiver from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of IncidentReceiver if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the IncidentReceiver. + */ + public static IncidentReceiver fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + IncidentReceiver deserializedIncidentReceiver = new IncidentReceiver(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + deserializedIncidentReceiver.name = reader.getString(); + } else if ("connection".equals(fieldName)) { + deserializedIncidentReceiver.connection = IncidentServiceConnection.fromJson(reader); + } else if ("incidentManagementService".equals(fieldName)) { + deserializedIncidentReceiver.incidentManagementService + = IncidentManagementService.fromString(reader.getString()); + } else if ("mappings".equals(fieldName)) { + Map mappings = reader.readMap(reader1 -> reader1.getString()); + deserializedIncidentReceiver.mappings = mappings; + } else { + reader.skipChildren(); + } + } + + return deserializedIncidentReceiver; + }); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/IncidentServiceConnection.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/IncidentServiceConnection.java new file mode 100644 index 0000000000000..8d10e1cdb6985 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/IncidentServiceConnection.java @@ -0,0 +1,133 @@ +// 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.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The connection info for Incident Receiver. + */ +@Fluent +public final class IncidentServiceConnection implements JsonSerializable { + /* + * The name of the connection. + */ + private String name; + + /* + * GUID value representing the connection ID for the incident management service. + */ + private String id; + + /** + * Creates an instance of IncidentServiceConnection class. + */ + public IncidentServiceConnection() { + } + + /** + * Get the name property: The name of the connection. + * + * @return the name value. + */ + public String name() { + return this.name; + } + + /** + * Set the name property: The name of the connection. + * + * @param name the name value to set. + * @return the IncidentServiceConnection object itself. + */ + public IncidentServiceConnection withName(String name) { + this.name = name; + return this; + } + + /** + * Get the id property: GUID value representing the connection ID for the incident management service. + * + * @return the id value. + */ + public String id() { + return this.id; + } + + /** + * Set the id property: GUID value representing the connection ID for the incident management service. + * + * @param id the id value to set. + * @return the IncidentServiceConnection object itself. + */ + public IncidentServiceConnection withId(String id) { + this.id = id; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (name() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property name in model IncidentServiceConnection")); + } + if (id() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property id in model IncidentServiceConnection")); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(IncidentServiceConnection.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + jsonWriter.writeStringField("id", this.id); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of IncidentServiceConnection from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of IncidentServiceConnection if the JsonReader was pointing to an instance of it, or null if + * it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the IncidentServiceConnection. + */ + public static IncidentServiceConnection fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + IncidentServiceConnection deserializedIncidentServiceConnection = new IncidentServiceConnection(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + deserializedIncidentServiceConnection.name = reader.getString(); + } else if ("id".equals(fieldName)) { + deserializedIncidentServiceConnection.id = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedIncidentServiceConnection; + }); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ItsmReceiver.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ItsmReceiver.java new file mode 100644 index 0000000000000..4f548f2cfdf78 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ItsmReceiver.java @@ -0,0 +1,241 @@ +// 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.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * An Itsm receiver. + */ +@Fluent +public final class ItsmReceiver implements JsonSerializable { + /* + * The name of the Itsm receiver. Names must be unique across all receivers within an action group. + */ + private String name; + + /* + * OMS LA instance identifier. + */ + private String workspaceId; + + /* + * Unique identification of ITSM connection among multiple defined in above workspace. + */ + private String connectionId; + + /* + * JSON blob for the configurations of the ITSM action. CreateMultipleWorkItems option will be part of this blob as + * well. + */ + private String ticketConfiguration; + + /* + * Region in which workspace resides. Supported + * values:'centralindia','japaneast','southeastasia','australiasoutheast','uksouth','westcentralus','canadacentral', + * 'eastus','westeurope' + */ + private String region; + + /** + * Creates an instance of ItsmReceiver class. + */ + public ItsmReceiver() { + } + + /** + * Get the name property: The name of the Itsm receiver. Names must be unique across all receivers within an action + * group. + * + * @return the name value. + */ + public String name() { + return this.name; + } + + /** + * Set the name property: The name of the Itsm receiver. Names must be unique across all receivers within an action + * group. + * + * @param name the name value to set. + * @return the ItsmReceiver object itself. + */ + public ItsmReceiver withName(String name) { + this.name = name; + return this; + } + + /** + * Get the workspaceId property: OMS LA instance identifier. + * + * @return the workspaceId value. + */ + public String workspaceId() { + return this.workspaceId; + } + + /** + * Set the workspaceId property: OMS LA instance identifier. + * + * @param workspaceId the workspaceId value to set. + * @return the ItsmReceiver object itself. + */ + public ItsmReceiver withWorkspaceId(String workspaceId) { + this.workspaceId = workspaceId; + return this; + } + + /** + * Get the connectionId property: Unique identification of ITSM connection among multiple defined in above + * workspace. + * + * @return the connectionId value. + */ + public String connectionId() { + return this.connectionId; + } + + /** + * Set the connectionId property: Unique identification of ITSM connection among multiple defined in above + * workspace. + * + * @param connectionId the connectionId value to set. + * @return the ItsmReceiver object itself. + */ + public ItsmReceiver withConnectionId(String connectionId) { + this.connectionId = connectionId; + return this; + } + + /** + * Get the ticketConfiguration property: JSON blob for the configurations of the ITSM action. + * CreateMultipleWorkItems option will be part of this blob as well. + * + * @return the ticketConfiguration value. + */ + public String ticketConfiguration() { + return this.ticketConfiguration; + } + + /** + * Set the ticketConfiguration property: JSON blob for the configurations of the ITSM action. + * CreateMultipleWorkItems option will be part of this blob as well. + * + * @param ticketConfiguration the ticketConfiguration value to set. + * @return the ItsmReceiver object itself. + */ + public ItsmReceiver withTicketConfiguration(String ticketConfiguration) { + this.ticketConfiguration = ticketConfiguration; + return this; + } + + /** + * Get the region property: Region in which workspace resides. Supported + * values:'centralindia','japaneast','southeastasia','australiasoutheast','uksouth','westcentralus','canadacentral','eastus','westeurope'. + * + * @return the region value. + */ + public String region() { + return this.region; + } + + /** + * Set the region property: Region in which workspace resides. Supported + * values:'centralindia','japaneast','southeastasia','australiasoutheast','uksouth','westcentralus','canadacentral','eastus','westeurope'. + * + * @param region the region value to set. + * @return the ItsmReceiver object itself. + */ + public ItsmReceiver withRegion(String region) { + this.region = region; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (name() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property name in model ItsmReceiver")); + } + if (workspaceId() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property workspaceId in model ItsmReceiver")); + } + if (connectionId() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property connectionId in model ItsmReceiver")); + } + if (ticketConfiguration() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property ticketConfiguration in model ItsmReceiver")); + } + if (region() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property region in model ItsmReceiver")); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(ItsmReceiver.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + jsonWriter.writeStringField("workspaceId", this.workspaceId); + jsonWriter.writeStringField("connectionId", this.connectionId); + jsonWriter.writeStringField("ticketConfiguration", this.ticketConfiguration); + jsonWriter.writeStringField("region", this.region); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ItsmReceiver from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ItsmReceiver if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the ItsmReceiver. + */ + public static ItsmReceiver fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ItsmReceiver deserializedItsmReceiver = new ItsmReceiver(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + deserializedItsmReceiver.name = reader.getString(); + } else if ("workspaceId".equals(fieldName)) { + deserializedItsmReceiver.workspaceId = reader.getString(); + } else if ("connectionId".equals(fieldName)) { + deserializedItsmReceiver.connectionId = reader.getString(); + } else if ("ticketConfiguration".equals(fieldName)) { + deserializedItsmReceiver.ticketConfiguration = reader.getString(); + } else if ("region".equals(fieldName)) { + deserializedItsmReceiver.region = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedItsmReceiver; + }); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/Kind.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/Kind.java new file mode 100644 index 0000000000000..2b46fafd1fb0f --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/Kind.java @@ -0,0 +1,56 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.monitor.generated.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Indicates the type of scheduled query rule. The default is LogAlert. + */ +public final class Kind extends ExpandableStringEnum { + /** + * Static value LogAlert for Kind. + */ + public static final Kind LOG_ALERT = fromString("LogAlert"); + + /** + * Static value EventLogAlert for Kind. + */ + public static final Kind EVENT_LOG_ALERT = fromString("EventLogAlert"); + + /** + * Static value LogToMetric for Kind. + */ + public static final Kind LOG_TO_METRIC = fromString("LogToMetric"); + + /** + * Creates a new instance of Kind value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public Kind() { + } + + /** + * Creates or finds a Kind from its string representation. + * + * @param name a name to look for. + * @return the corresponding Kind. + */ + public static Kind fromString(String name) { + return fromString(name, Kind.class); + } + + /** + * Gets known Kind values. + * + * @return known Kind values. + */ + public static Collection values() { + return values(Kind.class); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/LogicAppReceiver.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/LogicAppReceiver.java new file mode 100644 index 0000000000000..33d9143edf42c --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/LogicAppReceiver.java @@ -0,0 +1,225 @@ +// 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.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * A logic app receiver. + */ +@Fluent +public final class LogicAppReceiver implements JsonSerializable { + /* + * The name of the logic app receiver. Names must be unique across all receivers within an action group. + */ + private String name; + + /* + * The azure resource id of the logic app receiver. + */ + private String resourceId; + + /* + * The callback url where http request sent to. + */ + private String callbackUrl; + + /* + * Indicates whether to use common alert schema. + */ + private Boolean useCommonAlertSchema; + + /* + * The principal id of the managed identity. The value can be "None", "SystemAssigned" + */ + private String managedIdentity; + + /** + * Creates an instance of LogicAppReceiver class. + */ + public LogicAppReceiver() { + } + + /** + * Get the name property: The name of the logic app receiver. Names must be unique across all receivers within an + * action group. + * + * @return the name value. + */ + public String name() { + return this.name; + } + + /** + * Set the name property: The name of the logic app receiver. Names must be unique across all receivers within an + * action group. + * + * @param name the name value to set. + * @return the LogicAppReceiver object itself. + */ + public LogicAppReceiver withName(String name) { + this.name = name; + return this; + } + + /** + * Get the resourceId property: The azure resource id of the logic app receiver. + * + * @return the resourceId value. + */ + public String resourceId() { + return this.resourceId; + } + + /** + * Set the resourceId property: The azure resource id of the logic app receiver. + * + * @param resourceId the resourceId value to set. + * @return the LogicAppReceiver object itself. + */ + public LogicAppReceiver withResourceId(String resourceId) { + this.resourceId = resourceId; + return this; + } + + /** + * Get the callbackUrl property: The callback url where http request sent to. + * + * @return the callbackUrl value. + */ + public String callbackUrl() { + return this.callbackUrl; + } + + /** + * Set the callbackUrl property: The callback url where http request sent to. + * + * @param callbackUrl the callbackUrl value to set. + * @return the LogicAppReceiver object itself. + */ + public LogicAppReceiver withCallbackUrl(String callbackUrl) { + this.callbackUrl = callbackUrl; + return this; + } + + /** + * Get the useCommonAlertSchema property: Indicates whether to use common alert schema. + * + * @return the useCommonAlertSchema value. + */ + public Boolean useCommonAlertSchema() { + return this.useCommonAlertSchema; + } + + /** + * Set the useCommonAlertSchema property: Indicates whether to use common alert schema. + * + * @param useCommonAlertSchema the useCommonAlertSchema value to set. + * @return the LogicAppReceiver object itself. + */ + public LogicAppReceiver withUseCommonAlertSchema(Boolean useCommonAlertSchema) { + this.useCommonAlertSchema = useCommonAlertSchema; + return this; + } + + /** + * Get the managedIdentity property: The principal id of the managed identity. The value can be "None", + * "SystemAssigned". + * + * @return the managedIdentity value. + */ + public String managedIdentity() { + return this.managedIdentity; + } + + /** + * Set the managedIdentity property: The principal id of the managed identity. The value can be "None", + * "SystemAssigned". + * + * @param managedIdentity the managedIdentity value to set. + * @return the LogicAppReceiver object itself. + */ + public LogicAppReceiver withManagedIdentity(String managedIdentity) { + this.managedIdentity = managedIdentity; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (name() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property name in model LogicAppReceiver")); + } + if (resourceId() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property resourceId in model LogicAppReceiver")); + } + if (callbackUrl() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property callbackUrl in model LogicAppReceiver")); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(LogicAppReceiver.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + jsonWriter.writeStringField("resourceId", this.resourceId); + jsonWriter.writeStringField("callbackUrl", this.callbackUrl); + jsonWriter.writeBooleanField("useCommonAlertSchema", this.useCommonAlertSchema); + jsonWriter.writeStringField("managedIdentity", this.managedIdentity); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of LogicAppReceiver from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of LogicAppReceiver if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the LogicAppReceiver. + */ + public static LogicAppReceiver fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + LogicAppReceiver deserializedLogicAppReceiver = new LogicAppReceiver(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + deserializedLogicAppReceiver.name = reader.getString(); + } else if ("resourceId".equals(fieldName)) { + deserializedLogicAppReceiver.resourceId = reader.getString(); + } else if ("callbackUrl".equals(fieldName)) { + deserializedLogicAppReceiver.callbackUrl = reader.getString(); + } else if ("useCommonAlertSchema".equals(fieldName)) { + deserializedLogicAppReceiver.useCommonAlertSchema = reader.getNullable(JsonReader::getBoolean); + } else if ("managedIdentity".equals(fieldName)) { + deserializedLogicAppReceiver.managedIdentity = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedLogicAppReceiver; + }); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ManagedServiceIdentity.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ManagedServiceIdentity.java new file mode 100644 index 0000000000000..f47e9e7d45bfd --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ManagedServiceIdentity.java @@ -0,0 +1,190 @@ +// 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.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.Map; +import java.util.UUID; + +/** + * Managed service identity (system assigned and/or user assigned identities). + */ +@Fluent +public final class ManagedServiceIdentity implements JsonSerializable { + /* + * The service principal ID of the system assigned identity. This property will only be provided for a system + * assigned identity. + */ + private UUID principalId; + + /* + * The tenant ID of the system assigned identity. This property will only be provided for a system assigned + * identity. + */ + private UUID tenantId; + + /* + * Type of managed service identity (where both SystemAssigned and UserAssigned types are allowed). + */ + private ManagedServiceIdentityType type; + + /* + * The set of user assigned identities associated with the resource. The userAssignedIdentities dictionary keys will + * be ARM resource ids in the form: + * '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/ + * userAssignedIdentities/{identityName}. The dictionary values can be empty objects ({}) in requests. + */ + private Map userAssignedIdentities; + + /** + * Creates an instance of ManagedServiceIdentity class. + */ + public ManagedServiceIdentity() { + } + + /** + * Get the principalId property: The service principal ID of the system assigned identity. This property will only + * be provided for a system assigned identity. + * + * @return the principalId value. + */ + public UUID principalId() { + return this.principalId; + } + + /** + * Get the tenantId property: The tenant ID of the system assigned identity. This property will only be provided for + * a system assigned identity. + * + * @return the tenantId value. + */ + public UUID tenantId() { + return this.tenantId; + } + + /** + * Get the type property: Type of managed service identity (where both SystemAssigned and UserAssigned types are + * allowed). + * + * @return the type value. + */ + public ManagedServiceIdentityType type() { + return this.type; + } + + /** + * Set the type property: Type of managed service identity (where both SystemAssigned and UserAssigned types are + * allowed). + * + * @param type the type value to set. + * @return the ManagedServiceIdentity object itself. + */ + public ManagedServiceIdentity withType(ManagedServiceIdentityType type) { + this.type = type; + return this; + } + + /** + * Get the userAssignedIdentities property: The set of user assigned identities associated with the resource. The + * userAssignedIdentities dictionary keys will be ARM resource ids in the form: + * '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. + * The dictionary values can be empty objects ({}) in requests. + * + * @return the userAssignedIdentities value. + */ + public Map userAssignedIdentities() { + return this.userAssignedIdentities; + } + + /** + * Set the userAssignedIdentities property: The set of user assigned identities associated with the resource. The + * userAssignedIdentities dictionary keys will be ARM resource ids in the form: + * '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. + * The dictionary values can be empty objects ({}) in requests. + * + * @param userAssignedIdentities the userAssignedIdentities value to set. + * @return the ManagedServiceIdentity object itself. + */ + public ManagedServiceIdentity withUserAssignedIdentities(Map userAssignedIdentities) { + this.userAssignedIdentities = userAssignedIdentities; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (type() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property type in model ManagedServiceIdentity")); + } + if (userAssignedIdentities() != null) { + userAssignedIdentities().values().forEach(e -> { + if (e != null) { + e.validate(); + } + }); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(ManagedServiceIdentity.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("type", this.type == null ? null : this.type.toString()); + jsonWriter.writeMapField("userAssignedIdentities", this.userAssignedIdentities, + (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ManagedServiceIdentity from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ManagedServiceIdentity if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the ManagedServiceIdentity. + */ + public static ManagedServiceIdentity fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ManagedServiceIdentity deserializedManagedServiceIdentity = new ManagedServiceIdentity(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("type".equals(fieldName)) { + deserializedManagedServiceIdentity.type = ManagedServiceIdentityType.fromString(reader.getString()); + } else if ("principalId".equals(fieldName)) { + deserializedManagedServiceIdentity.principalId + = reader.getNullable(nonNullReader -> UUID.fromString(nonNullReader.getString())); + } else if ("tenantId".equals(fieldName)) { + deserializedManagedServiceIdentity.tenantId + = reader.getNullable(nonNullReader -> UUID.fromString(nonNullReader.getString())); + } else if ("userAssignedIdentities".equals(fieldName)) { + Map userAssignedIdentities + = reader.readMap(reader1 -> UserAssignedIdentity.fromJson(reader1)); + deserializedManagedServiceIdentity.userAssignedIdentities = userAssignedIdentities; + } else { + reader.skipChildren(); + } + } + + return deserializedManagedServiceIdentity; + }); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ManagedServiceIdentityType.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ManagedServiceIdentityType.java new file mode 100644 index 0000000000000..9e5db12cce883 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ManagedServiceIdentityType.java @@ -0,0 +1,62 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.monitor.generated.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Type of managed service identity (where both SystemAssigned and UserAssigned types are allowed). + */ +public final class ManagedServiceIdentityType extends ExpandableStringEnum { + /** + * Static value None for ManagedServiceIdentityType. + */ + public static final ManagedServiceIdentityType NONE = fromString("None"); + + /** + * Static value SystemAssigned for ManagedServiceIdentityType. + */ + public static final ManagedServiceIdentityType SYSTEM_ASSIGNED = fromString("SystemAssigned"); + + /** + * Static value UserAssigned for ManagedServiceIdentityType. + */ + public static final ManagedServiceIdentityType USER_ASSIGNED = fromString("UserAssigned"); + + /** + * Static value SystemAssigned,UserAssigned for ManagedServiceIdentityType. + */ + public static final ManagedServiceIdentityType SYSTEM_ASSIGNED_USER_ASSIGNED + = fromString("SystemAssigned,UserAssigned"); + + /** + * Creates a new instance of ManagedServiceIdentityType value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public ManagedServiceIdentityType() { + } + + /** + * Creates or finds a ManagedServiceIdentityType from its string representation. + * + * @param name a name to look for. + * @return the corresponding ManagedServiceIdentityType. + */ + public static ManagedServiceIdentityType fromString(String name) { + return fromString(name, ManagedServiceIdentityType.class); + } + + /** + * Gets known ManagedServiceIdentityType values. + * + * @return known ManagedServiceIdentityType values. + */ + public static Collection values() { + return values(ManagedServiceIdentityType.class); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/NotificationRequestBody.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/NotificationRequestBody.java new file mode 100644 index 0000000000000..b42594d2c14f2 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/NotificationRequestBody.java @@ -0,0 +1,519 @@ +// 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.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * The request body which contain contact detail metadata. + */ +@Fluent +public final class NotificationRequestBody implements JsonSerializable { + /* + * The value of the supported alert type. Supported alert type values are: servicehealth, metricstaticthreshold, + * metricsdynamicthreshold, logalertv2, smartalert, webtestalert, logalertv1numresult, logalertv1metricmeasurement, + * resourcehealth, activitylog, actualcostbudget, forecastedbudget + */ + private String alertType; + + /* + * The list of email receivers that are part of this action group. + */ + private List emailReceivers; + + /* + * The list of SMS receivers that are part of this action group. + */ + private List smsReceivers; + + /* + * The list of webhook receivers that are part of this action group. + */ + private List webhookReceivers; + + /* + * The list of ITSM receivers that are part of this action group. + */ + private List itsmReceivers; + + /* + * The list of AzureAppPush receivers that are part of this action group. + */ + private List azureAppPushReceivers; + + /* + * The list of AutomationRunbook receivers that are part of this action group. + */ + private List automationRunbookReceivers; + + /* + * The list of voice receivers that are part of this action group. + */ + private List voiceReceivers; + + /* + * The list of logic app receivers that are part of this action group. + */ + private List logicAppReceivers; + + /* + * The list of azure function receivers that are part of this action group. + */ + private List azureFunctionReceivers; + + /* + * The list of ARM role receivers that are part of this action group. Roles are Azure RBAC roles and only built-in + * roles are supported. + */ + private List armRoleReceivers; + + /* + * The list of event hub receivers that are part of this action group. + */ + private List eventHubReceivers; + + /* + * The list of incident receivers that are part of this action group. + */ + private List incidentReceivers; + + /** + * Creates an instance of NotificationRequestBody class. + */ + public NotificationRequestBody() { + } + + /** + * Get the alertType property: The value of the supported alert type. Supported alert type values are: + * servicehealth, metricstaticthreshold, metricsdynamicthreshold, logalertv2, smartalert, webtestalert, + * logalertv1numresult, logalertv1metricmeasurement, resourcehealth, activitylog, actualcostbudget, + * forecastedbudget. + * + * @return the alertType value. + */ + public String alertType() { + return this.alertType; + } + + /** + * Set the alertType property: The value of the supported alert type. Supported alert type values are: + * servicehealth, metricstaticthreshold, metricsdynamicthreshold, logalertv2, smartalert, webtestalert, + * logalertv1numresult, logalertv1metricmeasurement, resourcehealth, activitylog, actualcostbudget, + * forecastedbudget. + * + * @param alertType the alertType value to set. + * @return the NotificationRequestBody object itself. + */ + public NotificationRequestBody withAlertType(String alertType) { + this.alertType = alertType; + return this; + } + + /** + * Get the emailReceivers property: The list of email receivers that are part of this action group. + * + * @return the emailReceivers value. + */ + public List emailReceivers() { + return this.emailReceivers; + } + + /** + * Set the emailReceivers property: The list of email receivers that are part of this action group. + * + * @param emailReceivers the emailReceivers value to set. + * @return the NotificationRequestBody object itself. + */ + public NotificationRequestBody withEmailReceivers(List emailReceivers) { + this.emailReceivers = emailReceivers; + return this; + } + + /** + * Get the smsReceivers property: The list of SMS receivers that are part of this action group. + * + * @return the smsReceivers value. + */ + public List smsReceivers() { + return this.smsReceivers; + } + + /** + * Set the smsReceivers property: The list of SMS receivers that are part of this action group. + * + * @param smsReceivers the smsReceivers value to set. + * @return the NotificationRequestBody object itself. + */ + public NotificationRequestBody withSmsReceivers(List smsReceivers) { + this.smsReceivers = smsReceivers; + return this; + } + + /** + * Get the webhookReceivers property: The list of webhook receivers that are part of this action group. + * + * @return the webhookReceivers value. + */ + public List webhookReceivers() { + return this.webhookReceivers; + } + + /** + * Set the webhookReceivers property: The list of webhook receivers that are part of this action group. + * + * @param webhookReceivers the webhookReceivers value to set. + * @return the NotificationRequestBody object itself. + */ + public NotificationRequestBody withWebhookReceivers(List webhookReceivers) { + this.webhookReceivers = webhookReceivers; + return this; + } + + /** + * Get the itsmReceivers property: The list of ITSM receivers that are part of this action group. + * + * @return the itsmReceivers value. + */ + public List itsmReceivers() { + return this.itsmReceivers; + } + + /** + * Set the itsmReceivers property: The list of ITSM receivers that are part of this action group. + * + * @param itsmReceivers the itsmReceivers value to set. + * @return the NotificationRequestBody object itself. + */ + public NotificationRequestBody withItsmReceivers(List itsmReceivers) { + this.itsmReceivers = itsmReceivers; + return this; + } + + /** + * Get the azureAppPushReceivers property: The list of AzureAppPush receivers that are part of this action group. + * + * @return the azureAppPushReceivers value. + */ + public List azureAppPushReceivers() { + return this.azureAppPushReceivers; + } + + /** + * Set the azureAppPushReceivers property: The list of AzureAppPush receivers that are part of this action group. + * + * @param azureAppPushReceivers the azureAppPushReceivers value to set. + * @return the NotificationRequestBody object itself. + */ + public NotificationRequestBody withAzureAppPushReceivers(List azureAppPushReceivers) { + this.azureAppPushReceivers = azureAppPushReceivers; + return this; + } + + /** + * Get the automationRunbookReceivers property: The list of AutomationRunbook receivers that are part of this action + * group. + * + * @return the automationRunbookReceivers value. + */ + public List automationRunbookReceivers() { + return this.automationRunbookReceivers; + } + + /** + * Set the automationRunbookReceivers property: The list of AutomationRunbook receivers that are part of this action + * group. + * + * @param automationRunbookReceivers the automationRunbookReceivers value to set. + * @return the NotificationRequestBody object itself. + */ + public NotificationRequestBody + withAutomationRunbookReceivers(List automationRunbookReceivers) { + this.automationRunbookReceivers = automationRunbookReceivers; + return this; + } + + /** + * Get the voiceReceivers property: The list of voice receivers that are part of this action group. + * + * @return the voiceReceivers value. + */ + public List voiceReceivers() { + return this.voiceReceivers; + } + + /** + * Set the voiceReceivers property: The list of voice receivers that are part of this action group. + * + * @param voiceReceivers the voiceReceivers value to set. + * @return the NotificationRequestBody object itself. + */ + public NotificationRequestBody withVoiceReceivers(List voiceReceivers) { + this.voiceReceivers = voiceReceivers; + return this; + } + + /** + * Get the logicAppReceivers property: The list of logic app receivers that are part of this action group. + * + * @return the logicAppReceivers value. + */ + public List logicAppReceivers() { + return this.logicAppReceivers; + } + + /** + * Set the logicAppReceivers property: The list of logic app receivers that are part of this action group. + * + * @param logicAppReceivers the logicAppReceivers value to set. + * @return the NotificationRequestBody object itself. + */ + public NotificationRequestBody withLogicAppReceivers(List logicAppReceivers) { + this.logicAppReceivers = logicAppReceivers; + return this; + } + + /** + * Get the azureFunctionReceivers property: The list of azure function receivers that are part of this action group. + * + * @return the azureFunctionReceivers value. + */ + public List azureFunctionReceivers() { + return this.azureFunctionReceivers; + } + + /** + * Set the azureFunctionReceivers property: The list of azure function receivers that are part of this action group. + * + * @param azureFunctionReceivers the azureFunctionReceivers value to set. + * @return the NotificationRequestBody object itself. + */ + public NotificationRequestBody withAzureFunctionReceivers(List azureFunctionReceivers) { + this.azureFunctionReceivers = azureFunctionReceivers; + return this; + } + + /** + * Get the armRoleReceivers property: The list of ARM role receivers that are part of this action group. Roles are + * Azure RBAC roles and only built-in roles are supported. + * + * @return the armRoleReceivers value. + */ + public List armRoleReceivers() { + return this.armRoleReceivers; + } + + /** + * Set the armRoleReceivers property: The list of ARM role receivers that are part of this action group. Roles are + * Azure RBAC roles and only built-in roles are supported. + * + * @param armRoleReceivers the armRoleReceivers value to set. + * @return the NotificationRequestBody object itself. + */ + public NotificationRequestBody withArmRoleReceivers(List armRoleReceivers) { + this.armRoleReceivers = armRoleReceivers; + return this; + } + + /** + * Get the eventHubReceivers property: The list of event hub receivers that are part of this action group. + * + * @return the eventHubReceivers value. + */ + public List eventHubReceivers() { + return this.eventHubReceivers; + } + + /** + * Set the eventHubReceivers property: The list of event hub receivers that are part of this action group. + * + * @param eventHubReceivers the eventHubReceivers value to set. + * @return the NotificationRequestBody object itself. + */ + public NotificationRequestBody withEventHubReceivers(List eventHubReceivers) { + this.eventHubReceivers = eventHubReceivers; + return this; + } + + /** + * Get the incidentReceivers property: The list of incident receivers that are part of this action group. + * + * @return the incidentReceivers value. + */ + public List incidentReceivers() { + return this.incidentReceivers; + } + + /** + * Set the incidentReceivers property: The list of incident receivers that are part of this action group. + * + * @param incidentReceivers the incidentReceivers value to set. + * @return the NotificationRequestBody object itself. + */ + public NotificationRequestBody withIncidentReceivers(List incidentReceivers) { + this.incidentReceivers = incidentReceivers; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (alertType() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property alertType in model NotificationRequestBody")); + } + if (emailReceivers() != null) { + emailReceivers().forEach(e -> e.validate()); + } + if (smsReceivers() != null) { + smsReceivers().forEach(e -> e.validate()); + } + if (webhookReceivers() != null) { + webhookReceivers().forEach(e -> e.validate()); + } + if (itsmReceivers() != null) { + itsmReceivers().forEach(e -> e.validate()); + } + if (azureAppPushReceivers() != null) { + azureAppPushReceivers().forEach(e -> e.validate()); + } + if (automationRunbookReceivers() != null) { + automationRunbookReceivers().forEach(e -> e.validate()); + } + if (voiceReceivers() != null) { + voiceReceivers().forEach(e -> e.validate()); + } + if (logicAppReceivers() != null) { + logicAppReceivers().forEach(e -> e.validate()); + } + if (azureFunctionReceivers() != null) { + azureFunctionReceivers().forEach(e -> e.validate()); + } + if (armRoleReceivers() != null) { + armRoleReceivers().forEach(e -> e.validate()); + } + if (eventHubReceivers() != null) { + eventHubReceivers().forEach(e -> e.validate()); + } + if (incidentReceivers() != null) { + incidentReceivers().forEach(e -> e.validate()); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(NotificationRequestBody.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("alertType", this.alertType); + jsonWriter.writeArrayField("emailReceivers", this.emailReceivers, + (writer, element) -> writer.writeJson(element)); + jsonWriter.writeArrayField("smsReceivers", this.smsReceivers, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeArrayField("webhookReceivers", this.webhookReceivers, + (writer, element) -> writer.writeJson(element)); + jsonWriter.writeArrayField("itsmReceivers", this.itsmReceivers, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeArrayField("azureAppPushReceivers", this.azureAppPushReceivers, + (writer, element) -> writer.writeJson(element)); + jsonWriter.writeArrayField("automationRunbookReceivers", this.automationRunbookReceivers, + (writer, element) -> writer.writeJson(element)); + jsonWriter.writeArrayField("voiceReceivers", this.voiceReceivers, + (writer, element) -> writer.writeJson(element)); + jsonWriter.writeArrayField("logicAppReceivers", this.logicAppReceivers, + (writer, element) -> writer.writeJson(element)); + jsonWriter.writeArrayField("azureFunctionReceivers", this.azureFunctionReceivers, + (writer, element) -> writer.writeJson(element)); + jsonWriter.writeArrayField("armRoleReceivers", this.armRoleReceivers, + (writer, element) -> writer.writeJson(element)); + jsonWriter.writeArrayField("eventHubReceivers", this.eventHubReceivers, + (writer, element) -> writer.writeJson(element)); + jsonWriter.writeArrayField("incidentReceivers", this.incidentReceivers, + (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of NotificationRequestBody from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of NotificationRequestBody if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the NotificationRequestBody. + */ + public static NotificationRequestBody fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + NotificationRequestBody deserializedNotificationRequestBody = new NotificationRequestBody(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("alertType".equals(fieldName)) { + deserializedNotificationRequestBody.alertType = reader.getString(); + } else if ("emailReceivers".equals(fieldName)) { + List emailReceivers = reader.readArray(reader1 -> EmailReceiver.fromJson(reader1)); + deserializedNotificationRequestBody.emailReceivers = emailReceivers; + } else if ("smsReceivers".equals(fieldName)) { + List smsReceivers = reader.readArray(reader1 -> SmsReceiver.fromJson(reader1)); + deserializedNotificationRequestBody.smsReceivers = smsReceivers; + } else if ("webhookReceivers".equals(fieldName)) { + List webhookReceivers + = reader.readArray(reader1 -> WebhookReceiver.fromJson(reader1)); + deserializedNotificationRequestBody.webhookReceivers = webhookReceivers; + } else if ("itsmReceivers".equals(fieldName)) { + List itsmReceivers = reader.readArray(reader1 -> ItsmReceiver.fromJson(reader1)); + deserializedNotificationRequestBody.itsmReceivers = itsmReceivers; + } else if ("azureAppPushReceivers".equals(fieldName)) { + List azureAppPushReceivers + = reader.readArray(reader1 -> AzureAppPushReceiver.fromJson(reader1)); + deserializedNotificationRequestBody.azureAppPushReceivers = azureAppPushReceivers; + } else if ("automationRunbookReceivers".equals(fieldName)) { + List automationRunbookReceivers + = reader.readArray(reader1 -> AutomationRunbookReceiver.fromJson(reader1)); + deserializedNotificationRequestBody.automationRunbookReceivers = automationRunbookReceivers; + } else if ("voiceReceivers".equals(fieldName)) { + List voiceReceivers = reader.readArray(reader1 -> VoiceReceiver.fromJson(reader1)); + deserializedNotificationRequestBody.voiceReceivers = voiceReceivers; + } else if ("logicAppReceivers".equals(fieldName)) { + List logicAppReceivers + = reader.readArray(reader1 -> LogicAppReceiver.fromJson(reader1)); + deserializedNotificationRequestBody.logicAppReceivers = logicAppReceivers; + } else if ("azureFunctionReceivers".equals(fieldName)) { + List azureFunctionReceivers + = reader.readArray(reader1 -> AzureFunctionReceiver.fromJson(reader1)); + deserializedNotificationRequestBody.azureFunctionReceivers = azureFunctionReceivers; + } else if ("armRoleReceivers".equals(fieldName)) { + List armRoleReceivers + = reader.readArray(reader1 -> ArmRoleReceiver.fromJson(reader1)); + deserializedNotificationRequestBody.armRoleReceivers = armRoleReceivers; + } else if ("eventHubReceivers".equals(fieldName)) { + List eventHubReceivers + = reader.readArray(reader1 -> EventHubReceiver.fromJson(reader1)); + deserializedNotificationRequestBody.eventHubReceivers = eventHubReceivers; + } else if ("incidentReceivers".equals(fieldName)) { + List incidentReceivers + = reader.readArray(reader1 -> IncidentReceiver.fromJson(reader1)); + deserializedNotificationRequestBody.incidentReceivers = incidentReceivers; + } else { + reader.skipChildren(); + } + } + + return deserializedNotificationRequestBody; + }); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ReceiverStatus.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ReceiverStatus.java new file mode 100644 index 0000000000000..3fae16a7e7c57 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ReceiverStatus.java @@ -0,0 +1,61 @@ +// 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; + +/** + * Indicates the status of the receiver. Receivers that are not Enabled will not receive any communications. + */ +public enum ReceiverStatus { + /** + * Enum value NotSpecified. + */ + NOT_SPECIFIED("NotSpecified"), + + /** + * Enum value Enabled. + */ + ENABLED("Enabled"), + + /** + * Enum value Disabled. + */ + DISABLED("Disabled"); + + /** + * The actual serialized value for a ReceiverStatus instance. + */ + private final String value; + + ReceiverStatus(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a ReceiverStatus instance. + * + * @param value the serialized value to parse. + * @return the parsed ReceiverStatus object, or null if unable to parse. + */ + public static ReceiverStatus fromString(String value) { + if (value == null) { + return null; + } + ReceiverStatus[] items = ReceiverStatus.values(); + for (ReceiverStatus item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return this.value; + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/RuleResolveConfiguration.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/RuleResolveConfiguration.java new file mode 100644 index 0000000000000..e7ef1a06b2298 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/RuleResolveConfiguration.java @@ -0,0 +1,127 @@ +// 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.CoreUtils; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.time.Duration; + +/** + * TBD. Relevant only for rules of the kind LogAlert. + */ +@Fluent +public final class RuleResolveConfiguration implements JsonSerializable { + /* + * The flag that indicates whether or not to auto resolve a fired alert. + */ + private Boolean autoResolved; + + /* + * The duration a rule must evaluate as healthy before the fired alert is automatically resolved represented in ISO + * 8601 duration format. + */ + private Duration timeToResolve; + + /** + * Creates an instance of RuleResolveConfiguration class. + */ + public RuleResolveConfiguration() { + } + + /** + * Get the autoResolved property: The flag that indicates whether or not to auto resolve a fired alert. + * + * @return the autoResolved value. + */ + public Boolean autoResolved() { + return this.autoResolved; + } + + /** + * Set the autoResolved property: The flag that indicates whether or not to auto resolve a fired alert. + * + * @param autoResolved the autoResolved value to set. + * @return the RuleResolveConfiguration object itself. + */ + public RuleResolveConfiguration withAutoResolved(Boolean autoResolved) { + this.autoResolved = autoResolved; + return this; + } + + /** + * Get the timeToResolve property: The duration a rule must evaluate as healthy before the fired alert is + * automatically resolved represented in ISO 8601 duration format. + * + * @return the timeToResolve value. + */ + public Duration timeToResolve() { + return this.timeToResolve; + } + + /** + * Set the timeToResolve property: The duration a rule must evaluate as healthy before the fired alert is + * automatically resolved represented in ISO 8601 duration format. + * + * @param timeToResolve the timeToResolve value to set. + * @return the RuleResolveConfiguration object itself. + */ + public RuleResolveConfiguration withTimeToResolve(Duration timeToResolve) { + this.timeToResolve = timeToResolve; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeBooleanField("autoResolved", this.autoResolved); + jsonWriter.writeStringField("timeToResolve", CoreUtils.durationToStringWithDays(this.timeToResolve)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of RuleResolveConfiguration from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of RuleResolveConfiguration if the JsonReader was pointing to an instance of it, or null if + * it was pointing to JSON null. + * @throws IOException If an error occurs while reading the RuleResolveConfiguration. + */ + public static RuleResolveConfiguration fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + RuleResolveConfiguration deserializedRuleResolveConfiguration = new RuleResolveConfiguration(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("autoResolved".equals(fieldName)) { + deserializedRuleResolveConfiguration.autoResolved = reader.getNullable(JsonReader::getBoolean); + } else if ("timeToResolve".equals(fieldName)) { + deserializedRuleResolveConfiguration.timeToResolve + = reader.getNullable(nonNullReader -> Duration.parse(nonNullReader.getString())); + } else { + reader.skipChildren(); + } + } + + return deserializedRuleResolveConfiguration; + }); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ScheduledQueryRuleCriteria.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ScheduledQueryRuleCriteria.java new file mode 100644 index 0000000000000..dd547c55ad0b9 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ScheduledQueryRuleCriteria.java @@ -0,0 +1,98 @@ +// 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.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * The rule criteria that defines the conditions of the scheduled query rule. + */ +@Fluent +public final class ScheduledQueryRuleCriteria implements JsonSerializable { + /* + * A list of conditions to evaluate against the specified scopes + */ + private List allOf; + + /** + * Creates an instance of ScheduledQueryRuleCriteria class. + */ + public ScheduledQueryRuleCriteria() { + } + + /** + * Get the allOf property: A list of conditions to evaluate against the specified scopes. + * + * @return the allOf value. + */ + public List allOf() { + return this.allOf; + } + + /** + * Set the allOf property: A list of conditions to evaluate against the specified scopes. + * + * @param allOf the allOf value to set. + * @return the ScheduledQueryRuleCriteria object itself. + */ + public ScheduledQueryRuleCriteria withAllOf(List allOf) { + this.allOf = allOf; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (allOf() != null) { + allOf().forEach(e -> e.validate()); + } + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("allOf", this.allOf, (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ScheduledQueryRuleCriteria from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ScheduledQueryRuleCriteria if the JsonReader was pointing to an instance of it, or null if + * it was pointing to JSON null. + * @throws IOException If an error occurs while reading the ScheduledQueryRuleCriteria. + */ + public static ScheduledQueryRuleCriteria fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ScheduledQueryRuleCriteria deserializedScheduledQueryRuleCriteria = new ScheduledQueryRuleCriteria(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("allOf".equals(fieldName)) { + List allOf = reader.readArray(reader1 -> Condition.fromJson(reader1)); + deserializedScheduledQueryRuleCriteria.allOf = allOf; + } else { + reader.skipChildren(); + } + } + + return deserializedScheduledQueryRuleCriteria; + }); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ScheduledQueryRuleResource.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ScheduledQueryRuleResource.java new file mode 100644 index 0000000000000..b6b6b8d5d5737 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ScheduledQueryRuleResource.java @@ -0,0 +1,932 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.monitor.generated.models; + +import com.azure.core.management.Region; +import com.azure.core.management.SystemData; +import com.azure.core.util.Context; +import com.azure.resourcemanager.monitor.generated.fluent.models.ScheduledQueryRuleResourceInner; +import java.time.Duration; +import java.util.List; +import java.util.Map; + +/** + * An immutable client-side representation of ScheduledQueryRuleResource. + */ +public interface ScheduledQueryRuleResource { + /** + * Gets the id property: Fully qualified resource Id for the resource. + * + * @return the id value. + */ + String id(); + + /** + * Gets the name property: The name of the resource. + * + * @return the name value. + */ + String name(); + + /** + * Gets the type property: The type of the resource. + * + * @return the type value. + */ + String type(); + + /** + * Gets the location property: The geo-location where the resource lives. + * + * @return the location value. + */ + String location(); + + /** + * Gets the tags property: Resource tags. + * + * @return the tags value. + */ + Map tags(); + + /** + * Gets the identity property: The identity of the resource. + * + * @return the identity value. + */ + Identity identity(); + + /** + * Gets the kind property: Indicates the type of scheduled query rule. The default is LogAlert. + * + * @return the kind value. + */ + Kind kind(); + + /** + * Gets the etag property: The etag field is *not* required. If it is provided in the response body, it must also be + * provided as a header per the normal etag convention. Entity tags are used for comparing two or more entities from + * the same requested resource. HTTP/1.1 uses entity tags in the etag (section 14.19), If-Match (section 14.24), + * If-None-Match (section 14.26), and If-Range (section 14.27) header fields. + * + * @return the etag value. + */ + String etag(); + + /** + * Gets the systemData property: SystemData of ScheduledQueryRule. + * + * @return the systemData value. + */ + SystemData systemData(); + + /** + * Gets the createdWithApiVersion property: The api-version used when creating this alert rule. + * + * @return the createdWithApiVersion value. + */ + String createdWithApiVersion(); + + /** + * Gets the isLegacyLogAnalyticsRule property: True if alert rule is legacy Log Analytic rule. + * + * @return the isLegacyLogAnalyticsRule value. + */ + Boolean isLegacyLogAnalyticsRule(); + + /** + * Gets the description property: The description of the scheduled query rule. + * + * @return the description value. + */ + String description(); + + /** + * Gets the displayName property: The display name of the alert rule. + * + * @return the displayName value. + */ + String displayName(); + + /** + * Gets the severity property: Severity of the alert. Should be an integer between [0-4]. Value of 0 is severest. + * Relevant and required only for rules of the kind LogAlert. + * + * @return the severity value. + */ + AlertSeverity severity(); + + /** + * Gets the enabled property: The flag which indicates whether this scheduled query rule is enabled. Value should be + * true or false. + * + * @return the enabled value. + */ + Boolean enabled(); + + /** + * Gets the scopes property: The list of resource id's that this scheduled query rule is scoped to. + * + * @return the scopes value. + */ + List scopes(); + + /** + * Gets the evaluationFrequency property: How often the scheduled query rule is evaluated represented in ISO 8601 + * duration format. Relevant and required only for rules of the kind LogAlert. + * + * @return the evaluationFrequency value. + */ + Duration evaluationFrequency(); + + /** + * Gets the windowSize property: The period of time (in ISO 8601 duration format) on which the Alert query will be + * executed (bin size). Relevant and required only for rules of the kind LogAlert. + * + * @return the windowSize value. + */ + Duration windowSize(); + + /** + * Gets the overrideQueryTimeRange property: If specified then overrides the query time range (default is + * WindowSize*NumberOfEvaluationPeriods). Relevant only for rules of the kind LogAlert. + * + * @return the overrideQueryTimeRange value. + */ + Duration overrideQueryTimeRange(); + + /** + * Gets the targetResourceTypes property: List of resource type of the target resource(s) on which the alert is + * created/updated. For example if the scope is a resource group and targetResourceTypes is + * Microsoft.Compute/virtualMachines, then a different alert will be fired for each virtual machine in the resource + * group which meet the alert criteria. Relevant only for rules of the kind LogAlert. + * + * @return the targetResourceTypes value. + */ + List targetResourceTypes(); + + /** + * Gets the criteria property: The rule criteria that defines the conditions of the scheduled query rule. + * + * @return the criteria value. + */ + ScheduledQueryRuleCriteria criteria(); + + /** + * Gets the muteActionsDuration property: Mute actions for the chosen period of time (in ISO 8601 duration format) + * after the alert is fired. Relevant only for rules of the kind LogAlert. + * + * @return the muteActionsDuration value. + */ + Duration muteActionsDuration(); + + /** + * Gets the actions property: Actions to invoke when the alert fires. + * + * @return the actions value. + */ + Actions actions(); + + /** + * Gets the isWorkspaceAlertsStorageConfigured property: The flag which indicates whether this scheduled query rule + * has been configured to be stored in the customer's storage. The default is false. + * + * @return the isWorkspaceAlertsStorageConfigured value. + */ + Boolean isWorkspaceAlertsStorageConfigured(); + + /** + * Gets the checkWorkspaceAlertsStorageConfigured property: The flag which indicates whether this scheduled query + * rule should be stored in the customer's storage. The default is false. Relevant only for rules of the kind + * LogAlert. + * + * @return the checkWorkspaceAlertsStorageConfigured value. + */ + Boolean checkWorkspaceAlertsStorageConfigured(); + + /** + * Gets the skipQueryValidation property: The flag which indicates whether the provided query should be validated or + * not. The default is false. Relevant only for rules of the kind LogAlert. + * + * @return the skipQueryValidation value. + */ + Boolean skipQueryValidation(); + + /** + * Gets the autoMitigate property: The flag that indicates whether the alert should be automatically resolved or + * not. The default is true. Relevant only for rules of the kind LogAlert. + * + * @return the autoMitigate value. + */ + Boolean autoMitigate(); + + /** + * Gets the resolveConfiguration property: Defines the configuration for resolving fired alerts. Relevant only for + * rules of the kind LogAlert. + * + * @return the resolveConfiguration value. + */ + RuleResolveConfiguration resolveConfiguration(); + + /** + * 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 name of the resource group. + * + * @return the name of the resource group. + */ + String resourceGroupName(); + + /** + * Gets the inner com.azure.resourcemanager.monitor.generated.fluent.models.ScheduledQueryRuleResourceInner object. + * + * @return the inner object. + */ + ScheduledQueryRuleResourceInner innerModel(); + + /** + * The entirety of the ScheduledQueryRuleResource definition. + */ + interface Definition extends DefinitionStages.Blank, DefinitionStages.WithLocation, + DefinitionStages.WithResourceGroup, DefinitionStages.WithCreate { + } + + /** + * The ScheduledQueryRuleResource definition stages. + */ + interface DefinitionStages { + /** + * The first stage of the ScheduledQueryRuleResource definition. + */ + interface Blank extends WithLocation { + } + + /** + * The stage of the ScheduledQueryRuleResource definition allowing to specify location. + */ + interface WithLocation { + /** + * Specifies the region for the resource. + * + * @param location The geo-location where the resource lives. + * @return the next definition stage. + */ + WithResourceGroup withRegion(Region location); + + /** + * Specifies the region for the resource. + * + * @param location The geo-location where the resource lives. + * @return the next definition stage. + */ + WithResourceGroup withRegion(String location); + } + + /** + * The stage of the ScheduledQueryRuleResource definition allowing to specify parent resource. + */ + interface WithResourceGroup { + /** + * Specifies resourceGroupName. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @return the next definition stage. + */ + WithCreate withExistingResourceGroup(String resourceGroupName); + } + + /** + * The stage of the ScheduledQueryRuleResource definition which contains all the minimum required properties for + * the resource to be created, but also allows for any other optional properties to be specified. + */ + interface WithCreate extends DefinitionStages.WithTags, DefinitionStages.WithIdentity, + DefinitionStages.WithKind, DefinitionStages.WithDescription, DefinitionStages.WithDisplayName, + DefinitionStages.WithSeverity, DefinitionStages.WithEnabled, DefinitionStages.WithScopes, + DefinitionStages.WithEvaluationFrequency, DefinitionStages.WithWindowSize, + DefinitionStages.WithOverrideQueryTimeRange, DefinitionStages.WithTargetResourceTypes, + DefinitionStages.WithCriteria, DefinitionStages.WithMuteActionsDuration, DefinitionStages.WithActions, + DefinitionStages.WithCheckWorkspaceAlertsStorageConfigured, DefinitionStages.WithSkipQueryValidation, + DefinitionStages.WithAutoMitigate, DefinitionStages.WithResolveConfiguration { + /** + * Executes the create request. + * + * @return the created resource. + */ + ScheduledQueryRuleResource create(); + + /** + * Executes the create request. + * + * @param context The context to associate with this operation. + * @return the created resource. + */ + ScheduledQueryRuleResource create(Context context); + } + + /** + * The stage of the ScheduledQueryRuleResource definition allowing to specify tags. + */ + interface WithTags { + /** + * Specifies the tags property: Resource tags.. + * + * @param tags Resource tags. + * @return the next definition stage. + */ + WithCreate withTags(Map tags); + } + + /** + * The stage of the ScheduledQueryRuleResource definition allowing to specify identity. + */ + interface WithIdentity { + /** + * Specifies the identity property: The identity of the resource.. + * + * @param identity The identity of the resource. + * @return the next definition stage. + */ + WithCreate withIdentity(Identity identity); + } + + /** + * The stage of the ScheduledQueryRuleResource definition allowing to specify kind. + */ + interface WithKind { + /** + * Specifies the kind property: Indicates the type of scheduled query rule. The default is LogAlert.. + * + * @param kind Indicates the type of scheduled query rule. The default is LogAlert. + * @return the next definition stage. + */ + WithCreate withKind(Kind kind); + } + + /** + * The stage of the ScheduledQueryRuleResource definition allowing to specify description. + */ + interface WithDescription { + /** + * Specifies the description property: The description of the scheduled query rule.. + * + * @param description The description of the scheduled query rule. + * @return the next definition stage. + */ + WithCreate withDescription(String description); + } + + /** + * The stage of the ScheduledQueryRuleResource definition allowing to specify displayName. + */ + interface WithDisplayName { + /** + * Specifies the displayName property: The display name of the alert rule. + * + * @param displayName The display name of the alert rule. + * @return the next definition stage. + */ + WithCreate withDisplayName(String displayName); + } + + /** + * The stage of the ScheduledQueryRuleResource definition allowing to specify severity. + */ + interface WithSeverity { + /** + * Specifies the severity property: Severity of the alert. Should be an integer between [0-4]. Value of 0 is + * severest. Relevant and required only for rules of the kind LogAlert.. + * + * @param severity Severity of the alert. Should be an integer between [0-4]. Value of 0 is severest. + * Relevant and required only for rules of the kind LogAlert. + * @return the next definition stage. + */ + WithCreate withSeverity(AlertSeverity severity); + } + + /** + * The stage of the ScheduledQueryRuleResource definition allowing to specify enabled. + */ + interface WithEnabled { + /** + * Specifies the enabled property: The flag which indicates whether this scheduled query rule is enabled. + * Value should be true or false. + * + * @param enabled The flag which indicates whether this scheduled query rule is enabled. Value should be + * true or false. + * @return the next definition stage. + */ + WithCreate withEnabled(Boolean enabled); + } + + /** + * The stage of the ScheduledQueryRuleResource definition allowing to specify scopes. + */ + interface WithScopes { + /** + * Specifies the scopes property: The list of resource id's that this scheduled query rule is scoped to.. + * + * @param scopes The list of resource id's that this scheduled query rule is scoped to. + * @return the next definition stage. + */ + WithCreate withScopes(List scopes); + } + + /** + * The stage of the ScheduledQueryRuleResource definition allowing to specify evaluationFrequency. + */ + interface WithEvaluationFrequency { + /** + * Specifies the evaluationFrequency property: How often the scheduled query rule is evaluated represented + * in ISO 8601 duration format. Relevant and required only for rules of the kind LogAlert.. + * + * @param evaluationFrequency How often the scheduled query rule is evaluated represented in ISO 8601 + * duration format. Relevant and required only for rules of the kind LogAlert. + * @return the next definition stage. + */ + WithCreate withEvaluationFrequency(Duration evaluationFrequency); + } + + /** + * The stage of the ScheduledQueryRuleResource definition allowing to specify windowSize. + */ + interface WithWindowSize { + /** + * Specifies the windowSize property: The period of time (in ISO 8601 duration format) on which the Alert + * query will be executed (bin size). Relevant and required only for rules of the kind LogAlert.. + * + * @param windowSize The period of time (in ISO 8601 duration format) on which the Alert query will be + * executed (bin size). Relevant and required only for rules of the kind LogAlert. + * @return the next definition stage. + */ + WithCreate withWindowSize(Duration windowSize); + } + + /** + * The stage of the ScheduledQueryRuleResource definition allowing to specify overrideQueryTimeRange. + */ + interface WithOverrideQueryTimeRange { + /** + * Specifies the overrideQueryTimeRange property: If specified then overrides the query time range (default + * is WindowSize*NumberOfEvaluationPeriods). Relevant only for rules of the kind LogAlert.. + * + * @param overrideQueryTimeRange If specified then overrides the query time range (default is + * WindowSize*NumberOfEvaluationPeriods). Relevant only for rules of the kind LogAlert. + * @return the next definition stage. + */ + WithCreate withOverrideQueryTimeRange(Duration overrideQueryTimeRange); + } + + /** + * The stage of the ScheduledQueryRuleResource definition allowing to specify targetResourceTypes. + */ + interface WithTargetResourceTypes { + /** + * Specifies the targetResourceTypes property: List of resource type of the target resource(s) on which the + * alert is created/updated. For example if the scope is a resource group and targetResourceTypes is + * Microsoft.Compute/virtualMachines, then a different alert will be fired for each virtual machine in the + * resource group which meet the alert criteria. Relevant only for rules of the kind LogAlert. + * + * @param targetResourceTypes List of resource type of the target resource(s) on which the alert is + * created/updated. For example if the scope is a resource group and targetResourceTypes is + * Microsoft.Compute/virtualMachines, then a different alert will be fired for each virtual machine in the + * resource group which meet the alert criteria. Relevant only for rules of the kind LogAlert. + * @return the next definition stage. + */ + WithCreate withTargetResourceTypes(List targetResourceTypes); + } + + /** + * The stage of the ScheduledQueryRuleResource definition allowing to specify criteria. + */ + interface WithCriteria { + /** + * Specifies the criteria property: The rule criteria that defines the conditions of the scheduled query + * rule.. + * + * @param criteria The rule criteria that defines the conditions of the scheduled query rule. + * @return the next definition stage. + */ + WithCreate withCriteria(ScheduledQueryRuleCriteria criteria); + } + + /** + * The stage of the ScheduledQueryRuleResource definition allowing to specify muteActionsDuration. + */ + interface WithMuteActionsDuration { + /** + * Specifies the muteActionsDuration property: Mute actions for the chosen period of time (in ISO 8601 + * duration format) after the alert is fired. Relevant only for rules of the kind LogAlert.. + * + * @param muteActionsDuration Mute actions for the chosen period of time (in ISO 8601 duration format) after + * the alert is fired. Relevant only for rules of the kind LogAlert. + * @return the next definition stage. + */ + WithCreate withMuteActionsDuration(Duration muteActionsDuration); + } + + /** + * The stage of the ScheduledQueryRuleResource definition allowing to specify actions. + */ + interface WithActions { + /** + * Specifies the actions property: Actions to invoke when the alert fires.. + * + * @param actions Actions to invoke when the alert fires. + * @return the next definition stage. + */ + WithCreate withActions(Actions actions); + } + + /** + * The stage of the ScheduledQueryRuleResource definition allowing to specify + * checkWorkspaceAlertsStorageConfigured. + */ + interface WithCheckWorkspaceAlertsStorageConfigured { + /** + * Specifies the checkWorkspaceAlertsStorageConfigured property: The flag which indicates whether this + * scheduled query rule should be stored in the customer's storage. The default is false. Relevant only for + * rules of the kind LogAlert.. + * + * @param checkWorkspaceAlertsStorageConfigured The flag which indicates whether this scheduled query rule + * should be stored in the customer's storage. The default is false. Relevant only for rules of the kind + * LogAlert. + * @return the next definition stage. + */ + WithCreate withCheckWorkspaceAlertsStorageConfigured(Boolean checkWorkspaceAlertsStorageConfigured); + } + + /** + * The stage of the ScheduledQueryRuleResource definition allowing to specify skipQueryValidation. + */ + interface WithSkipQueryValidation { + /** + * Specifies the skipQueryValidation property: The flag which indicates whether the provided query should be + * validated or not. The default is false. Relevant only for rules of the kind LogAlert.. + * + * @param skipQueryValidation The flag which indicates whether the provided query should be validated or + * not. The default is false. Relevant only for rules of the kind LogAlert. + * @return the next definition stage. + */ + WithCreate withSkipQueryValidation(Boolean skipQueryValidation); + } + + /** + * The stage of the ScheduledQueryRuleResource definition allowing to specify autoMitigate. + */ + interface WithAutoMitigate { + /** + * Specifies the autoMitigate property: The flag that indicates whether the alert should be automatically + * resolved or not. The default is true. Relevant only for rules of the kind LogAlert.. + * + * @param autoMitigate The flag that indicates whether the alert should be automatically resolved or not. + * The default is true. Relevant only for rules of the kind LogAlert. + * @return the next definition stage. + */ + WithCreate withAutoMitigate(Boolean autoMitigate); + } + + /** + * The stage of the ScheduledQueryRuleResource definition allowing to specify resolveConfiguration. + */ + interface WithResolveConfiguration { + /** + * Specifies the resolveConfiguration property: Defines the configuration for resolving fired alerts. + * Relevant only for rules of the kind LogAlert.. + * + * @param resolveConfiguration Defines the configuration for resolving fired alerts. Relevant only for rules + * of the kind LogAlert. + * @return the next definition stage. + */ + WithCreate withResolveConfiguration(RuleResolveConfiguration resolveConfiguration); + } + } + + /** + * Begins update for the ScheduledQueryRuleResource resource. + * + * @return the stage of resource update. + */ + ScheduledQueryRuleResource.Update update(); + + /** + * The template for ScheduledQueryRuleResource update. + */ + interface Update extends UpdateStages.WithTags, UpdateStages.WithIdentity, UpdateStages.WithDescription, + UpdateStages.WithDisplayName, UpdateStages.WithSeverity, UpdateStages.WithEnabled, UpdateStages.WithScopes, + UpdateStages.WithEvaluationFrequency, UpdateStages.WithWindowSize, UpdateStages.WithOverrideQueryTimeRange, + UpdateStages.WithTargetResourceTypes, UpdateStages.WithCriteria, UpdateStages.WithMuteActionsDuration, + UpdateStages.WithActions, UpdateStages.WithCheckWorkspaceAlertsStorageConfigured, + UpdateStages.WithSkipQueryValidation, UpdateStages.WithAutoMitigate, UpdateStages.WithResolveConfiguration { + /** + * Executes the update request. + * + * @return the updated resource. + */ + ScheduledQueryRuleResource apply(); + + /** + * Executes the update request. + * + * @param context The context to associate with this operation. + * @return the updated resource. + */ + ScheduledQueryRuleResource apply(Context context); + } + + /** + * The ScheduledQueryRuleResource update stages. + */ + interface UpdateStages { + /** + * The stage of the ScheduledQueryRuleResource update allowing to specify tags. + */ + interface WithTags { + /** + * Specifies the tags property: Resource tags. + * + * @param tags Resource tags. + * @return the next definition stage. + */ + Update withTags(Map tags); + } + + /** + * The stage of the ScheduledQueryRuleResource update allowing to specify identity. + */ + interface WithIdentity { + /** + * Specifies the identity property: The identity of the resource.. + * + * @param identity The identity of the resource. + * @return the next definition stage. + */ + Update withIdentity(Identity identity); + } + + /** + * The stage of the ScheduledQueryRuleResource update allowing to specify description. + */ + interface WithDescription { + /** + * Specifies the description property: The description of the scheduled query rule.. + * + * @param description The description of the scheduled query rule. + * @return the next definition stage. + */ + Update withDescription(String description); + } + + /** + * The stage of the ScheduledQueryRuleResource update allowing to specify displayName. + */ + interface WithDisplayName { + /** + * Specifies the displayName property: The display name of the alert rule. + * + * @param displayName The display name of the alert rule. + * @return the next definition stage. + */ + Update withDisplayName(String displayName); + } + + /** + * The stage of the ScheduledQueryRuleResource update allowing to specify severity. + */ + interface WithSeverity { + /** + * Specifies the severity property: Severity of the alert. Should be an integer between [0-4]. Value of 0 is + * severest. Relevant and required only for rules of the kind LogAlert.. + * + * @param severity Severity of the alert. Should be an integer between [0-4]. Value of 0 is severest. + * Relevant and required only for rules of the kind LogAlert. + * @return the next definition stage. + */ + Update withSeverity(AlertSeverity severity); + } + + /** + * The stage of the ScheduledQueryRuleResource update allowing to specify enabled. + */ + interface WithEnabled { + /** + * Specifies the enabled property: The flag which indicates whether this scheduled query rule is enabled. + * Value should be true or false. + * + * @param enabled The flag which indicates whether this scheduled query rule is enabled. Value should be + * true or false. + * @return the next definition stage. + */ + Update withEnabled(Boolean enabled); + } + + /** + * The stage of the ScheduledQueryRuleResource update allowing to specify scopes. + */ + interface WithScopes { + /** + * Specifies the scopes property: The list of resource id's that this scheduled query rule is scoped to.. + * + * @param scopes The list of resource id's that this scheduled query rule is scoped to. + * @return the next definition stage. + */ + Update withScopes(List scopes); + } + + /** + * The stage of the ScheduledQueryRuleResource update allowing to specify evaluationFrequency. + */ + interface WithEvaluationFrequency { + /** + * Specifies the evaluationFrequency property: How often the scheduled query rule is evaluated represented + * in ISO 8601 duration format. Relevant and required only for rules of the kind LogAlert.. + * + * @param evaluationFrequency How often the scheduled query rule is evaluated represented in ISO 8601 + * duration format. Relevant and required only for rules of the kind LogAlert. + * @return the next definition stage. + */ + Update withEvaluationFrequency(Duration evaluationFrequency); + } + + /** + * The stage of the ScheduledQueryRuleResource update allowing to specify windowSize. + */ + interface WithWindowSize { + /** + * Specifies the windowSize property: The period of time (in ISO 8601 duration format) on which the Alert + * query will be executed (bin size). Relevant and required only for rules of the kind LogAlert.. + * + * @param windowSize The period of time (in ISO 8601 duration format) on which the Alert query will be + * executed (bin size). Relevant and required only for rules of the kind LogAlert. + * @return the next definition stage. + */ + Update withWindowSize(Duration windowSize); + } + + /** + * The stage of the ScheduledQueryRuleResource update allowing to specify overrideQueryTimeRange. + */ + interface WithOverrideQueryTimeRange { + /** + * Specifies the overrideQueryTimeRange property: If specified then overrides the query time range (default + * is WindowSize*NumberOfEvaluationPeriods). Relevant only for rules of the kind LogAlert.. + * + * @param overrideQueryTimeRange If specified then overrides the query time range (default is + * WindowSize*NumberOfEvaluationPeriods). Relevant only for rules of the kind LogAlert. + * @return the next definition stage. + */ + Update withOverrideQueryTimeRange(Duration overrideQueryTimeRange); + } + + /** + * The stage of the ScheduledQueryRuleResource update allowing to specify targetResourceTypes. + */ + interface WithTargetResourceTypes { + /** + * Specifies the targetResourceTypes property: List of resource type of the target resource(s) on which the + * alert is created/updated. For example if the scope is a resource group and targetResourceTypes is + * Microsoft.Compute/virtualMachines, then a different alert will be fired for each virtual machine in the + * resource group which meet the alert criteria. Relevant only for rules of the kind LogAlert. + * + * @param targetResourceTypes List of resource type of the target resource(s) on which the alert is + * created/updated. For example if the scope is a resource group and targetResourceTypes is + * Microsoft.Compute/virtualMachines, then a different alert will be fired for each virtual machine in the + * resource group which meet the alert criteria. Relevant only for rules of the kind LogAlert. + * @return the next definition stage. + */ + Update withTargetResourceTypes(List targetResourceTypes); + } + + /** + * The stage of the ScheduledQueryRuleResource update allowing to specify criteria. + */ + interface WithCriteria { + /** + * Specifies the criteria property: The rule criteria that defines the conditions of the scheduled query + * rule.. + * + * @param criteria The rule criteria that defines the conditions of the scheduled query rule. + * @return the next definition stage. + */ + Update withCriteria(ScheduledQueryRuleCriteria criteria); + } + + /** + * The stage of the ScheduledQueryRuleResource update allowing to specify muteActionsDuration. + */ + interface WithMuteActionsDuration { + /** + * Specifies the muteActionsDuration property: Mute actions for the chosen period of time (in ISO 8601 + * duration format) after the alert is fired. Relevant only for rules of the kind LogAlert.. + * + * @param muteActionsDuration Mute actions for the chosen period of time (in ISO 8601 duration format) after + * the alert is fired. Relevant only for rules of the kind LogAlert. + * @return the next definition stage. + */ + Update withMuteActionsDuration(Duration muteActionsDuration); + } + + /** + * The stage of the ScheduledQueryRuleResource update allowing to specify actions. + */ + interface WithActions { + /** + * Specifies the actions property: Actions to invoke when the alert fires.. + * + * @param actions Actions to invoke when the alert fires. + * @return the next definition stage. + */ + Update withActions(Actions actions); + } + + /** + * The stage of the ScheduledQueryRuleResource update allowing to specify checkWorkspaceAlertsStorageConfigured. + */ + interface WithCheckWorkspaceAlertsStorageConfigured { + /** + * Specifies the checkWorkspaceAlertsStorageConfigured property: The flag which indicates whether this + * scheduled query rule should be stored in the customer's storage. The default is false. Relevant only for + * rules of the kind LogAlert.. + * + * @param checkWorkspaceAlertsStorageConfigured The flag which indicates whether this scheduled query rule + * should be stored in the customer's storage. The default is false. Relevant only for rules of the kind + * LogAlert. + * @return the next definition stage. + */ + Update withCheckWorkspaceAlertsStorageConfigured(Boolean checkWorkspaceAlertsStorageConfigured); + } + + /** + * The stage of the ScheduledQueryRuleResource update allowing to specify skipQueryValidation. + */ + interface WithSkipQueryValidation { + /** + * Specifies the skipQueryValidation property: The flag which indicates whether the provided query should be + * validated or not. The default is false. Relevant only for rules of the kind LogAlert.. + * + * @param skipQueryValidation The flag which indicates whether the provided query should be validated or + * not. The default is false. Relevant only for rules of the kind LogAlert. + * @return the next definition stage. + */ + Update withSkipQueryValidation(Boolean skipQueryValidation); + } + + /** + * The stage of the ScheduledQueryRuleResource update allowing to specify autoMitigate. + */ + interface WithAutoMitigate { + /** + * Specifies the autoMitigate property: The flag that indicates whether the alert should be automatically + * resolved or not. The default is true. Relevant only for rules of the kind LogAlert.. + * + * @param autoMitigate The flag that indicates whether the alert should be automatically resolved or not. + * The default is true. Relevant only for rules of the kind LogAlert. + * @return the next definition stage. + */ + Update withAutoMitigate(Boolean autoMitigate); + } + + /** + * The stage of the ScheduledQueryRuleResource update allowing to specify resolveConfiguration. + */ + interface WithResolveConfiguration { + /** + * Specifies the resolveConfiguration property: Defines the configuration for resolving fired alerts. + * Relevant only for rules of the kind LogAlert.. + * + * @param resolveConfiguration Defines the configuration for resolving fired alerts. Relevant only for rules + * of the kind LogAlert. + * @return the next definition stage. + */ + Update withResolveConfiguration(RuleResolveConfiguration resolveConfiguration); + } + } + + /** + * Refreshes the resource to sync with Azure. + * + * @return the refreshed resource. + */ + ScheduledQueryRuleResource refresh(); + + /** + * Refreshes the resource to sync with Azure. + * + * @param context The context to associate with this operation. + * @return the refreshed resource. + */ + ScheduledQueryRuleResource refresh(Context context); +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ScheduledQueryRuleResourceCollection.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ScheduledQueryRuleResourceCollection.java new file mode 100644 index 0000000000000..c781267384996 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ScheduledQueryRuleResourceCollection.java @@ -0,0 +1,118 @@ +// 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.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.azure.resourcemanager.monitor.generated.fluent.models.ScheduledQueryRuleResourceInner; +import java.io.IOException; +import java.util.List; + +/** + * Represents a collection of scheduled query rule resources. + */ +@Fluent +public final class ScheduledQueryRuleResourceCollection + implements JsonSerializable { + /* + * The values for the scheduled query rule resources. + */ + private List value; + + /* + * Provides the link to retrieve the next set of elements. + */ + private String nextLink; + + /** + * Creates an instance of ScheduledQueryRuleResourceCollection class. + */ + public ScheduledQueryRuleResourceCollection() { + } + + /** + * Get the value property: The values for the scheduled query rule resources. + * + * @return the value value. + */ + public List value() { + return this.value; + } + + /** + * Set the value property: The values for the scheduled query rule resources. + * + * @param value the value value to set. + * @return the ScheduledQueryRuleResourceCollection object itself. + */ + public ScheduledQueryRuleResourceCollection withValue(List value) { + this.value = value; + return this; + } + + /** + * Get the nextLink property: Provides the link to retrieve the next set of elements. + * + * @return the nextLink value. + */ + public String nextLink() { + return this.nextLink; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (value() != null) { + value().forEach(e -> e.validate()); + } + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("value", this.value, (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ScheduledQueryRuleResourceCollection from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ScheduledQueryRuleResourceCollection if the JsonReader was pointing to an instance of it, + * or null if it was pointing to JSON null. + * @throws IOException If an error occurs while reading the ScheduledQueryRuleResourceCollection. + */ + public static ScheduledQueryRuleResourceCollection fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ScheduledQueryRuleResourceCollection deserializedScheduledQueryRuleResourceCollection + = new ScheduledQueryRuleResourceCollection(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("value".equals(fieldName)) { + List value + = reader.readArray(reader1 -> ScheduledQueryRuleResourceInner.fromJson(reader1)); + deserializedScheduledQueryRuleResourceCollection.value = value; + } else if ("nextLink".equals(fieldName)) { + deserializedScheduledQueryRuleResourceCollection.nextLink = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedScheduledQueryRuleResourceCollection; + }); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ScheduledQueryRuleResourcePatch.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ScheduledQueryRuleResourcePatch.java new file mode 100644 index 0000000000000..0faa1d71204a4 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ScheduledQueryRuleResourcePatch.java @@ -0,0 +1,576 @@ +// 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.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.azure.resourcemanager.monitor.generated.fluent.models.ScheduledQueryRuleProperties; +import java.io.IOException; +import java.time.Duration; +import java.util.List; +import java.util.Map; + +/** + * The scheduled query rule resource for patch operations. + */ +@Fluent +public final class ScheduledQueryRuleResourcePatch implements JsonSerializable { + /* + * The identity of the resource. + */ + private Identity identity; + + /* + * Resource tags + */ + private Map tags; + + /* + * The scheduled query rule properties of the resource. + */ + private ScheduledQueryRuleProperties innerProperties; + + /** + * Creates an instance of ScheduledQueryRuleResourcePatch class. + */ + public ScheduledQueryRuleResourcePatch() { + } + + /** + * Get the identity property: The identity of the resource. + * + * @return the identity value. + */ + public Identity identity() { + return this.identity; + } + + /** + * Set the identity property: The identity of the resource. + * + * @param identity the identity value to set. + * @return the ScheduledQueryRuleResourcePatch object itself. + */ + public ScheduledQueryRuleResourcePatch withIdentity(Identity identity) { + this.identity = identity; + return this; + } + + /** + * Get the tags property: Resource tags. + * + * @return the tags value. + */ + public Map tags() { + return this.tags; + } + + /** + * Set the tags property: Resource tags. + * + * @param tags the tags value to set. + * @return the ScheduledQueryRuleResourcePatch object itself. + */ + public ScheduledQueryRuleResourcePatch withTags(Map tags) { + this.tags = tags; + return this; + } + + /** + * Get the innerProperties property: The scheduled query rule properties of the resource. + * + * @return the innerProperties value. + */ + private ScheduledQueryRuleProperties innerProperties() { + return this.innerProperties; + } + + /** + * Get the createdWithApiVersion property: The api-version used when creating this alert rule. + * + * @return the createdWithApiVersion value. + */ + public String createdWithApiVersion() { + return this.innerProperties() == null ? null : this.innerProperties().createdWithApiVersion(); + } + + /** + * Get the isLegacyLogAnalyticsRule property: True if alert rule is legacy Log Analytic rule. + * + * @return the isLegacyLogAnalyticsRule value. + */ + public Boolean isLegacyLogAnalyticsRule() { + return this.innerProperties() == null ? null : this.innerProperties().isLegacyLogAnalyticsRule(); + } + + /** + * Get the description property: The description of the scheduled query rule. + * + * @return the description value. + */ + public String description() { + return this.innerProperties() == null ? null : this.innerProperties().description(); + } + + /** + * Set the description property: The description of the scheduled query rule. + * + * @param description the description value to set. + * @return the ScheduledQueryRuleResourcePatch object itself. + */ + public ScheduledQueryRuleResourcePatch withDescription(String description) { + if (this.innerProperties() == null) { + this.innerProperties = new ScheduledQueryRuleProperties(); + } + this.innerProperties().withDescription(description); + return this; + } + + /** + * Get the displayName property: The display name of the alert rule. + * + * @return the displayName value. + */ + public String displayName() { + return this.innerProperties() == null ? null : this.innerProperties().displayName(); + } + + /** + * Set the displayName property: The display name of the alert rule. + * + * @param displayName the displayName value to set. + * @return the ScheduledQueryRuleResourcePatch object itself. + */ + public ScheduledQueryRuleResourcePatch withDisplayName(String displayName) { + if (this.innerProperties() == null) { + this.innerProperties = new ScheduledQueryRuleProperties(); + } + this.innerProperties().withDisplayName(displayName); + return this; + } + + /** + * Get the severity property: Severity of the alert. Should be an integer between [0-4]. Value of 0 is severest. + * Relevant and required only for rules of the kind LogAlert. + * + * @return the severity value. + */ + public AlertSeverity severity() { + return this.innerProperties() == null ? null : this.innerProperties().severity(); + } + + /** + * Set the severity property: Severity of the alert. Should be an integer between [0-4]. Value of 0 is severest. + * Relevant and required only for rules of the kind LogAlert. + * + * @param severity the severity value to set. + * @return the ScheduledQueryRuleResourcePatch object itself. + */ + public ScheduledQueryRuleResourcePatch withSeverity(AlertSeverity severity) { + if (this.innerProperties() == null) { + this.innerProperties = new ScheduledQueryRuleProperties(); + } + this.innerProperties().withSeverity(severity); + return this; + } + + /** + * Get the enabled property: The flag which indicates whether this scheduled query rule is enabled. Value should be + * true or false. + * + * @return the enabled value. + */ + public Boolean enabled() { + return this.innerProperties() == null ? null : this.innerProperties().enabled(); + } + + /** + * Set the enabled property: The flag which indicates whether this scheduled query rule is enabled. Value should be + * true or false. + * + * @param enabled the enabled value to set. + * @return the ScheduledQueryRuleResourcePatch object itself. + */ + public ScheduledQueryRuleResourcePatch withEnabled(Boolean enabled) { + if (this.innerProperties() == null) { + this.innerProperties = new ScheduledQueryRuleProperties(); + } + this.innerProperties().withEnabled(enabled); + return this; + } + + /** + * Get the scopes property: The list of resource id's that this scheduled query rule is scoped to. + * + * @return the scopes value. + */ + public List scopes() { + return this.innerProperties() == null ? null : this.innerProperties().scopes(); + } + + /** + * Set the scopes property: The list of resource id's that this scheduled query rule is scoped to. + * + * @param scopes the scopes value to set. + * @return the ScheduledQueryRuleResourcePatch object itself. + */ + public ScheduledQueryRuleResourcePatch withScopes(List scopes) { + if (this.innerProperties() == null) { + this.innerProperties = new ScheduledQueryRuleProperties(); + } + this.innerProperties().withScopes(scopes); + return this; + } + + /** + * Get the evaluationFrequency property: How often the scheduled query rule is evaluated represented in ISO 8601 + * duration format. Relevant and required only for rules of the kind LogAlert. + * + * @return the evaluationFrequency value. + */ + public Duration evaluationFrequency() { + return this.innerProperties() == null ? null : this.innerProperties().evaluationFrequency(); + } + + /** + * Set the evaluationFrequency property: How often the scheduled query rule is evaluated represented in ISO 8601 + * duration format. Relevant and required only for rules of the kind LogAlert. + * + * @param evaluationFrequency the evaluationFrequency value to set. + * @return the ScheduledQueryRuleResourcePatch object itself. + */ + public ScheduledQueryRuleResourcePatch withEvaluationFrequency(Duration evaluationFrequency) { + if (this.innerProperties() == null) { + this.innerProperties = new ScheduledQueryRuleProperties(); + } + this.innerProperties().withEvaluationFrequency(evaluationFrequency); + return this; + } + + /** + * Get the windowSize property: The period of time (in ISO 8601 duration format) on which the Alert query will be + * executed (bin size). Relevant and required only for rules of the kind LogAlert. + * + * @return the windowSize value. + */ + public Duration windowSize() { + return this.innerProperties() == null ? null : this.innerProperties().windowSize(); + } + + /** + * Set the windowSize property: The period of time (in ISO 8601 duration format) on which the Alert query will be + * executed (bin size). Relevant and required only for rules of the kind LogAlert. + * + * @param windowSize the windowSize value to set. + * @return the ScheduledQueryRuleResourcePatch object itself. + */ + public ScheduledQueryRuleResourcePatch withWindowSize(Duration windowSize) { + if (this.innerProperties() == null) { + this.innerProperties = new ScheduledQueryRuleProperties(); + } + this.innerProperties().withWindowSize(windowSize); + return this; + } + + /** + * Get the overrideQueryTimeRange property: If specified then overrides the query time range (default is + * WindowSize*NumberOfEvaluationPeriods). Relevant only for rules of the kind LogAlert. + * + * @return the overrideQueryTimeRange value. + */ + public Duration overrideQueryTimeRange() { + return this.innerProperties() == null ? null : this.innerProperties().overrideQueryTimeRange(); + } + + /** + * Set the overrideQueryTimeRange property: If specified then overrides the query time range (default is + * WindowSize*NumberOfEvaluationPeriods). Relevant only for rules of the kind LogAlert. + * + * @param overrideQueryTimeRange the overrideQueryTimeRange value to set. + * @return the ScheduledQueryRuleResourcePatch object itself. + */ + public ScheduledQueryRuleResourcePatch withOverrideQueryTimeRange(Duration overrideQueryTimeRange) { + if (this.innerProperties() == null) { + this.innerProperties = new ScheduledQueryRuleProperties(); + } + this.innerProperties().withOverrideQueryTimeRange(overrideQueryTimeRange); + return this; + } + + /** + * Get the targetResourceTypes property: List of resource type of the target resource(s) on which the alert is + * created/updated. For example if the scope is a resource group and targetResourceTypes is + * Microsoft.Compute/virtualMachines, then a different alert will be fired for each virtual machine in the resource + * group which meet the alert criteria. Relevant only for rules of the kind LogAlert. + * + * @return the targetResourceTypes value. + */ + public List targetResourceTypes() { + return this.innerProperties() == null ? null : this.innerProperties().targetResourceTypes(); + } + + /** + * Set the targetResourceTypes property: List of resource type of the target resource(s) on which the alert is + * created/updated. For example if the scope is a resource group and targetResourceTypes is + * Microsoft.Compute/virtualMachines, then a different alert will be fired for each virtual machine in the resource + * group which meet the alert criteria. Relevant only for rules of the kind LogAlert. + * + * @param targetResourceTypes the targetResourceTypes value to set. + * @return the ScheduledQueryRuleResourcePatch object itself. + */ + public ScheduledQueryRuleResourcePatch withTargetResourceTypes(List targetResourceTypes) { + if (this.innerProperties() == null) { + this.innerProperties = new ScheduledQueryRuleProperties(); + } + this.innerProperties().withTargetResourceTypes(targetResourceTypes); + return this; + } + + /** + * Get the criteria property: The rule criteria that defines the conditions of the scheduled query rule. + * + * @return the criteria value. + */ + public ScheduledQueryRuleCriteria criteria() { + return this.innerProperties() == null ? null : this.innerProperties().criteria(); + } + + /** + * Set the criteria property: The rule criteria that defines the conditions of the scheduled query rule. + * + * @param criteria the criteria value to set. + * @return the ScheduledQueryRuleResourcePatch object itself. + */ + public ScheduledQueryRuleResourcePatch withCriteria(ScheduledQueryRuleCriteria criteria) { + if (this.innerProperties() == null) { + this.innerProperties = new ScheduledQueryRuleProperties(); + } + this.innerProperties().withCriteria(criteria); + return this; + } + + /** + * Get the muteActionsDuration property: Mute actions for the chosen period of time (in ISO 8601 duration format) + * after the alert is fired. Relevant only for rules of the kind LogAlert. + * + * @return the muteActionsDuration value. + */ + public Duration muteActionsDuration() { + return this.innerProperties() == null ? null : this.innerProperties().muteActionsDuration(); + } + + /** + * Set the muteActionsDuration property: Mute actions for the chosen period of time (in ISO 8601 duration format) + * after the alert is fired. Relevant only for rules of the kind LogAlert. + * + * @param muteActionsDuration the muteActionsDuration value to set. + * @return the ScheduledQueryRuleResourcePatch object itself. + */ + public ScheduledQueryRuleResourcePatch withMuteActionsDuration(Duration muteActionsDuration) { + if (this.innerProperties() == null) { + this.innerProperties = new ScheduledQueryRuleProperties(); + } + this.innerProperties().withMuteActionsDuration(muteActionsDuration); + return this; + } + + /** + * Get the actions property: Actions to invoke when the alert fires. + * + * @return the actions value. + */ + public Actions actions() { + return this.innerProperties() == null ? null : this.innerProperties().actions(); + } + + /** + * Set the actions property: Actions to invoke when the alert fires. + * + * @param actions the actions value to set. + * @return the ScheduledQueryRuleResourcePatch object itself. + */ + public ScheduledQueryRuleResourcePatch withActions(Actions actions) { + if (this.innerProperties() == null) { + this.innerProperties = new ScheduledQueryRuleProperties(); + } + this.innerProperties().withActions(actions); + return this; + } + + /** + * Get the isWorkspaceAlertsStorageConfigured property: The flag which indicates whether this scheduled query rule + * has been configured to be stored in the customer's storage. The default is false. + * + * @return the isWorkspaceAlertsStorageConfigured value. + */ + public Boolean isWorkspaceAlertsStorageConfigured() { + return this.innerProperties() == null ? null : this.innerProperties().isWorkspaceAlertsStorageConfigured(); + } + + /** + * Get the checkWorkspaceAlertsStorageConfigured property: The flag which indicates whether this scheduled query + * rule should be stored in the customer's storage. The default is false. Relevant only for rules of the kind + * LogAlert. + * + * @return the checkWorkspaceAlertsStorageConfigured value. + */ + public Boolean checkWorkspaceAlertsStorageConfigured() { + return this.innerProperties() == null ? null : this.innerProperties().checkWorkspaceAlertsStorageConfigured(); + } + + /** + * Set the checkWorkspaceAlertsStorageConfigured property: The flag which indicates whether this scheduled query + * rule should be stored in the customer's storage. The default is false. Relevant only for rules of the kind + * LogAlert. + * + * @param checkWorkspaceAlertsStorageConfigured the checkWorkspaceAlertsStorageConfigured value to set. + * @return the ScheduledQueryRuleResourcePatch object itself. + */ + public ScheduledQueryRuleResourcePatch + withCheckWorkspaceAlertsStorageConfigured(Boolean checkWorkspaceAlertsStorageConfigured) { + if (this.innerProperties() == null) { + this.innerProperties = new ScheduledQueryRuleProperties(); + } + this.innerProperties().withCheckWorkspaceAlertsStorageConfigured(checkWorkspaceAlertsStorageConfigured); + return this; + } + + /** + * Get the skipQueryValidation property: The flag which indicates whether the provided query should be validated or + * not. The default is false. Relevant only for rules of the kind LogAlert. + * + * @return the skipQueryValidation value. + */ + public Boolean skipQueryValidation() { + return this.innerProperties() == null ? null : this.innerProperties().skipQueryValidation(); + } + + /** + * Set the skipQueryValidation property: The flag which indicates whether the provided query should be validated or + * not. The default is false. Relevant only for rules of the kind LogAlert. + * + * @param skipQueryValidation the skipQueryValidation value to set. + * @return the ScheduledQueryRuleResourcePatch object itself. + */ + public ScheduledQueryRuleResourcePatch withSkipQueryValidation(Boolean skipQueryValidation) { + if (this.innerProperties() == null) { + this.innerProperties = new ScheduledQueryRuleProperties(); + } + this.innerProperties().withSkipQueryValidation(skipQueryValidation); + return this; + } + + /** + * Get the autoMitigate property: The flag that indicates whether the alert should be automatically resolved or not. + * The default is true. Relevant only for rules of the kind LogAlert. + * + * @return the autoMitigate value. + */ + public Boolean autoMitigate() { + return this.innerProperties() == null ? null : this.innerProperties().autoMitigate(); + } + + /** + * Set the autoMitigate property: The flag that indicates whether the alert should be automatically resolved or not. + * The default is true. Relevant only for rules of the kind LogAlert. + * + * @param autoMitigate the autoMitigate value to set. + * @return the ScheduledQueryRuleResourcePatch object itself. + */ + public ScheduledQueryRuleResourcePatch withAutoMitigate(Boolean autoMitigate) { + if (this.innerProperties() == null) { + this.innerProperties = new ScheduledQueryRuleProperties(); + } + this.innerProperties().withAutoMitigate(autoMitigate); + return this; + } + + /** + * Get the resolveConfiguration property: Defines the configuration for resolving fired alerts. Relevant only for + * rules of the kind LogAlert. + * + * @return the resolveConfiguration value. + */ + public RuleResolveConfiguration resolveConfiguration() { + return this.innerProperties() == null ? null : this.innerProperties().resolveConfiguration(); + } + + /** + * Set the resolveConfiguration property: Defines the configuration for resolving fired alerts. Relevant only for + * rules of the kind LogAlert. + * + * @param resolveConfiguration the resolveConfiguration value to set. + * @return the ScheduledQueryRuleResourcePatch object itself. + */ + public ScheduledQueryRuleResourcePatch withResolveConfiguration(RuleResolveConfiguration resolveConfiguration) { + if (this.innerProperties() == null) { + this.innerProperties = new ScheduledQueryRuleProperties(); + } + this.innerProperties().withResolveConfiguration(resolveConfiguration); + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (identity() != null) { + identity().validate(); + } + if (innerProperties() != null) { + innerProperties().validate(); + } + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("identity", this.identity); + jsonWriter.writeMapField("tags", this.tags, (writer, element) -> writer.writeString(element)); + jsonWriter.writeJsonField("properties", this.innerProperties); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ScheduledQueryRuleResourcePatch from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ScheduledQueryRuleResourcePatch if the JsonReader was pointing to an instance of it, or + * null if it was pointing to JSON null. + * @throws IOException If an error occurs while reading the ScheduledQueryRuleResourcePatch. + */ + public static ScheduledQueryRuleResourcePatch fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ScheduledQueryRuleResourcePatch deserializedScheduledQueryRuleResourcePatch + = new ScheduledQueryRuleResourcePatch(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("identity".equals(fieldName)) { + deserializedScheduledQueryRuleResourcePatch.identity = Identity.fromJson(reader); + } else if ("tags".equals(fieldName)) { + Map tags = reader.readMap(reader1 -> reader1.getString()); + deserializedScheduledQueryRuleResourcePatch.tags = tags; + } else if ("properties".equals(fieldName)) { + deserializedScheduledQueryRuleResourcePatch.innerProperties + = ScheduledQueryRuleProperties.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedScheduledQueryRuleResourcePatch; + }); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ScheduledQueryRules.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ScheduledQueryRules.java new file mode 100644 index 0000000000000..4f497fdb39932 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/ScheduledQueryRules.java @@ -0,0 +1,164 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.monitor.generated.models; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.Response; +import com.azure.core.util.Context; + +/** + * Resource collection API of ScheduledQueryRules. + */ +public interface ScheduledQueryRules { + /** + * Retrieve a scheduled query rule definitions in a subscription. + * + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return represents a collection of scheduled query rule resources as paginated response with + * {@link PagedIterable}. + */ + PagedIterable list(); + + /** + * Retrieve a scheduled query rule definitions in a subscription. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return represents a collection of scheduled query rule resources as paginated response with + * {@link PagedIterable}. + */ + PagedIterable list(Context context); + + /** + * Retrieve scheduled query rule definitions in a resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return represents a collection of scheduled query rule resources as paginated response with + * {@link PagedIterable}. + */ + PagedIterable listByResourceGroup(String resourceGroupName); + + /** + * Retrieve scheduled query rule definitions in a resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return represents a collection of scheduled query rule resources as paginated response with + * {@link PagedIterable}. + */ + PagedIterable listByResourceGroup(String resourceGroupName, Context context); + + /** + * Retrieve an scheduled query rule definition. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param ruleName The name of the rule. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the scheduled query rule resource along with {@link Response}. + */ + Response getByResourceGroupWithResponse(String resourceGroupName, String ruleName, + Context context); + + /** + * Retrieve an scheduled query rule definition. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param ruleName The name of the rule. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the scheduled query rule resource. + */ + ScheduledQueryRuleResource getByResourceGroup(String resourceGroupName, String ruleName); + + /** + * Deletes a scheduled query rule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param ruleName The name of the rule. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + Response deleteByResourceGroupWithResponse(String resourceGroupName, String ruleName, Context context); + + /** + * Deletes a scheduled query rule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param ruleName The name of the rule. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + void deleteByResourceGroup(String resourceGroupName, String ruleName); + + /** + * Retrieve an scheduled query rule definition. + * + * @param id the resource ID. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the scheduled query rule resource along with {@link Response}. + */ + ScheduledQueryRuleResource getById(String id); + + /** + * Retrieve an scheduled query rule definition. + * + * @param id the resource ID. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the scheduled query rule resource along with {@link Response}. + */ + Response getByIdWithResponse(String id, Context context); + + /** + * Deletes a scheduled query rule. + * + * @param id the resource ID. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + void deleteById(String id); + + /** + * Deletes a scheduled query rule. + * + * @param id the resource ID. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + Response deleteByIdWithResponse(String id, Context context); + + /** + * Begins definition for a new ScheduledQueryRuleResource resource. + * + * @param name resource name. + * @return the first stage of the new ScheduledQueryRuleResource definition. + */ + ScheduledQueryRuleResource.DefinitionStages.Blank define(String name); +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/SmsReceiver.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/SmsReceiver.java new file mode 100644 index 0000000000000..cc70d0441b3b4 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/SmsReceiver.java @@ -0,0 +1,183 @@ +// 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.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * An SMS receiver. + */ +@Fluent +public final class SmsReceiver implements JsonSerializable { + /* + * The name of the SMS receiver. Names must be unique across all receivers within an action group. + */ + private String name; + + /* + * The country code of the SMS receiver. + */ + private String countryCode; + + /* + * The phone number of the SMS receiver. + */ + private String phoneNumber; + + /* + * The status of the receiver. + */ + private ReceiverStatus status; + + /** + * Creates an instance of SmsReceiver class. + */ + public SmsReceiver() { + } + + /** + * Get the name property: The name of the SMS receiver. Names must be unique across all receivers within an action + * group. + * + * @return the name value. + */ + public String name() { + return this.name; + } + + /** + * Set the name property: The name of the SMS receiver. Names must be unique across all receivers within an action + * group. + * + * @param name the name value to set. + * @return the SmsReceiver object itself. + */ + public SmsReceiver withName(String name) { + this.name = name; + return this; + } + + /** + * Get the countryCode property: The country code of the SMS receiver. + * + * @return the countryCode value. + */ + public String countryCode() { + return this.countryCode; + } + + /** + * Set the countryCode property: The country code of the SMS receiver. + * + * @param countryCode the countryCode value to set. + * @return the SmsReceiver object itself. + */ + public SmsReceiver withCountryCode(String countryCode) { + this.countryCode = countryCode; + return this; + } + + /** + * Get the phoneNumber property: The phone number of the SMS receiver. + * + * @return the phoneNumber value. + */ + public String phoneNumber() { + return this.phoneNumber; + } + + /** + * Set the phoneNumber property: The phone number of the SMS receiver. + * + * @param phoneNumber the phoneNumber value to set. + * @return the SmsReceiver object itself. + */ + public SmsReceiver withPhoneNumber(String phoneNumber) { + this.phoneNumber = phoneNumber; + return this; + } + + /** + * Get the status property: The status of the receiver. + * + * @return the status value. + */ + public ReceiverStatus status() { + return this.status; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (name() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property name in model SmsReceiver")); + } + if (countryCode() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property countryCode in model SmsReceiver")); + } + if (phoneNumber() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property phoneNumber in model SmsReceiver")); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(SmsReceiver.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + jsonWriter.writeStringField("countryCode", this.countryCode); + jsonWriter.writeStringField("phoneNumber", this.phoneNumber); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SmsReceiver from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SmsReceiver if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the SmsReceiver. + */ + public static SmsReceiver fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + SmsReceiver deserializedSmsReceiver = new SmsReceiver(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + deserializedSmsReceiver.name = reader.getString(); + } else if ("countryCode".equals(fieldName)) { + deserializedSmsReceiver.countryCode = reader.getString(); + } else if ("phoneNumber".equals(fieldName)) { + deserializedSmsReceiver.phoneNumber = reader.getString(); + } else if ("status".equals(fieldName)) { + deserializedSmsReceiver.status = ReceiverStatus.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + + return deserializedSmsReceiver; + }); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/TestNotificationDetailsResponse.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/TestNotificationDetailsResponse.java new file mode 100644 index 0000000000000..b3b2726346b4e --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/TestNotificationDetailsResponse.java @@ -0,0 +1,56 @@ +// 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.resourcemanager.monitor.generated.fluent.models.TestNotificationDetailsResponseInner; +import java.util.List; + +/** + * An immutable client-side representation of TestNotificationDetailsResponse. + */ +public interface TestNotificationDetailsResponse { + /** + * Gets the context property: The context info. + * + * @return the context value. + */ + Context context(); + + /** + * Gets the state property: The overall state. + * + * @return the state value. + */ + String state(); + + /** + * Gets the completedTime property: The completed time. + * + * @return the completedTime value. + */ + String completedTime(); + + /** + * Gets the createdTime property: The created time. + * + * @return the createdTime value. + */ + String createdTime(); + + /** + * Gets the actionDetails property: The list of action detail. + * + * @return the actionDetails value. + */ + List actionDetails(); + + /** + * Gets the inner com.azure.resourcemanager.monitor.generated.fluent.models.TestNotificationDetailsResponseInner + * object. + * + * @return the inner object. + */ + TestNotificationDetailsResponseInner innerModel(); +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/TimeAggregation.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/TimeAggregation.java new file mode 100644 index 0000000000000..e2384dd8ac7f4 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/TimeAggregation.java @@ -0,0 +1,66 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.monitor.generated.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Aggregation type. Relevant and required only for rules of the kind LogAlert. + */ +public final class TimeAggregation extends ExpandableStringEnum { + /** + * Static value Count for TimeAggregation. + */ + public static final TimeAggregation COUNT = fromString("Count"); + + /** + * Static value Average for TimeAggregation. + */ + public static final TimeAggregation AVERAGE = fromString("Average"); + + /** + * Static value Minimum for TimeAggregation. + */ + public static final TimeAggregation MINIMUM = fromString("Minimum"); + + /** + * Static value Maximum for TimeAggregation. + */ + public static final TimeAggregation MAXIMUM = fromString("Maximum"); + + /** + * Static value Total for TimeAggregation. + */ + public static final TimeAggregation TOTAL = fromString("Total"); + + /** + * Creates a new instance of TimeAggregation value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public TimeAggregation() { + } + + /** + * Creates or finds a TimeAggregation from its string representation. + * + * @param name a name to look for. + * @return the corresponding TimeAggregation. + */ + public static TimeAggregation fromString(String name) { + return fromString(name, TimeAggregation.class); + } + + /** + * Gets known TimeAggregation values. + * + * @return known TimeAggregation values. + */ + public static Collection values() { + return values(TimeAggregation.class); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/UserAssignedIdentity.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/UserAssignedIdentity.java new file mode 100644 index 0000000000000..4ec62c372cd01 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/UserAssignedIdentity.java @@ -0,0 +1,100 @@ +// 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.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.UUID; + +/** + * User assigned identity properties. + */ +@Immutable +public final class UserAssignedIdentity implements JsonSerializable { + /* + * The principal ID of the assigned identity. + */ + private UUID principalId; + + /* + * The client ID of the assigned identity. + */ + private UUID clientId; + + /** + * Creates an instance of UserAssignedIdentity class. + */ + public UserAssignedIdentity() { + } + + /** + * Get the principalId property: The principal ID of the assigned identity. + * + * @return the principalId value. + */ + public UUID principalId() { + return this.principalId; + } + + /** + * Get the clientId property: The client ID of the assigned identity. + * + * @return the clientId value. + */ + public UUID clientId() { + return this.clientId; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of UserAssignedIdentity from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of UserAssignedIdentity if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IOException If an error occurs while reading the UserAssignedIdentity. + */ + public static UserAssignedIdentity fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + UserAssignedIdentity deserializedUserAssignedIdentity = new UserAssignedIdentity(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("principalId".equals(fieldName)) { + deserializedUserAssignedIdentity.principalId + = reader.getNullable(nonNullReader -> UUID.fromString(nonNullReader.getString())); + } else if ("clientId".equals(fieldName)) { + deserializedUserAssignedIdentity.clientId + = reader.getNullable(nonNullReader -> UUID.fromString(nonNullReader.getString())); + } else { + reader.skipChildren(); + } + } + + return deserializedUserAssignedIdentity; + }); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/UserIdentityProperties.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/UserIdentityProperties.java new file mode 100644 index 0000000000000..e430b2c9ce457 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/UserIdentityProperties.java @@ -0,0 +1,97 @@ +// 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.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * User assigned identity properties. + */ +@Immutable +public final class UserIdentityProperties implements JsonSerializable { + /* + * The principal id of user assigned identity. + */ + private String principalId; + + /* + * The client id of user assigned identity. + */ + private String clientId; + + /** + * Creates an instance of UserIdentityProperties class. + */ + public UserIdentityProperties() { + } + + /** + * Get the principalId property: The principal id of user assigned identity. + * + * @return the principalId value. + */ + public String principalId() { + return this.principalId; + } + + /** + * Get the clientId property: The client id of user assigned identity. + * + * @return the clientId value. + */ + public String clientId() { + return this.clientId; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of UserIdentityProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of UserIdentityProperties if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IOException If an error occurs while reading the UserIdentityProperties. + */ + public static UserIdentityProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + UserIdentityProperties deserializedUserIdentityProperties = new UserIdentityProperties(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("principalId".equals(fieldName)) { + deserializedUserIdentityProperties.principalId = reader.getString(); + } else if ("clientId".equals(fieldName)) { + deserializedUserIdentityProperties.clientId = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedUserIdentityProperties; + }); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/VoiceReceiver.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/VoiceReceiver.java new file mode 100644 index 0000000000000..2ebe7b7a12538 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/VoiceReceiver.java @@ -0,0 +1,167 @@ +// 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.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * A voice receiver. + */ +@Fluent +public final class VoiceReceiver implements JsonSerializable { + /* + * The name of the voice receiver. Names must be unique across all receivers within an action group. + */ + private String name; + + /* + * The country code of the voice receiver. + */ + private String countryCode; + + /* + * The phone number of the voice receiver. + */ + private String phoneNumber; + + /** + * Creates an instance of VoiceReceiver class. + */ + public VoiceReceiver() { + } + + /** + * Get the name property: The name of the voice receiver. Names must be unique across all receivers within an action + * group. + * + * @return the name value. + */ + public String name() { + return this.name; + } + + /** + * Set the name property: The name of the voice receiver. Names must be unique across all receivers within an action + * group. + * + * @param name the name value to set. + * @return the VoiceReceiver object itself. + */ + public VoiceReceiver withName(String name) { + this.name = name; + return this; + } + + /** + * Get the countryCode property: The country code of the voice receiver. + * + * @return the countryCode value. + */ + public String countryCode() { + return this.countryCode; + } + + /** + * Set the countryCode property: The country code of the voice receiver. + * + * @param countryCode the countryCode value to set. + * @return the VoiceReceiver object itself. + */ + public VoiceReceiver withCountryCode(String countryCode) { + this.countryCode = countryCode; + return this; + } + + /** + * Get the phoneNumber property: The phone number of the voice receiver. + * + * @return the phoneNumber value. + */ + public String phoneNumber() { + return this.phoneNumber; + } + + /** + * Set the phoneNumber property: The phone number of the voice receiver. + * + * @param phoneNumber the phoneNumber value to set. + * @return the VoiceReceiver object itself. + */ + public VoiceReceiver withPhoneNumber(String phoneNumber) { + this.phoneNumber = phoneNumber; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (name() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property name in model VoiceReceiver")); + } + if (countryCode() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property countryCode in model VoiceReceiver")); + } + if (phoneNumber() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property phoneNumber in model VoiceReceiver")); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(VoiceReceiver.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + jsonWriter.writeStringField("countryCode", this.countryCode); + jsonWriter.writeStringField("phoneNumber", this.phoneNumber); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of VoiceReceiver from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of VoiceReceiver if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the VoiceReceiver. + */ + public static VoiceReceiver fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + VoiceReceiver deserializedVoiceReceiver = new VoiceReceiver(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + deserializedVoiceReceiver.name = reader.getString(); + } else if ("countryCode".equals(fieldName)) { + deserializedVoiceReceiver.countryCode = reader.getString(); + } else if ("phoneNumber".equals(fieldName)) { + deserializedVoiceReceiver.phoneNumber = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedVoiceReceiver; + }); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/WebhookReceiver.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/WebhookReceiver.java new file mode 100644 index 0000000000000..50b24c09f4f2c --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/WebhookReceiver.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.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * A webhook receiver. + */ +@Fluent +public final class WebhookReceiver implements JsonSerializable { + /* + * The name of the webhook receiver. Names must be unique across all receivers within an action group. + */ + private String name; + + /* + * The URI where webhooks should be sent. + */ + private String serviceUri; + + /* + * Indicates whether to use common alert schema. + */ + private Boolean useCommonAlertSchema; + + /* + * Indicates whether or not use AAD authentication. + */ + private Boolean useAadAuth; + + /* + * Indicates the webhook app object Id for aad auth. + */ + private String objectId; + + /* + * Indicates the identifier uri for aad auth. + */ + private String identifierUri; + + /* + * Indicates the tenant id for aad auth. + */ + private String tenantId; + + /* + * The principal id of the managed identity. The value can be "None", "SystemAssigned" + */ + private String managedIdentity; + + /** + * Creates an instance of WebhookReceiver class. + */ + public WebhookReceiver() { + } + + /** + * Get the name property: The name of the webhook receiver. Names must be unique across all receivers within an + * action group. + * + * @return the name value. + */ + public String name() { + return this.name; + } + + /** + * Set the name property: The name of the webhook receiver. Names must be unique across all receivers within an + * action group. + * + * @param name the name value to set. + * @return the WebhookReceiver object itself. + */ + public WebhookReceiver withName(String name) { + this.name = name; + return this; + } + + /** + * Get the serviceUri property: The URI where webhooks should be sent. + * + * @return the serviceUri value. + */ + public String serviceUri() { + return this.serviceUri; + } + + /** + * Set the serviceUri property: The URI where webhooks should be sent. + * + * @param serviceUri the serviceUri value to set. + * @return the WebhookReceiver object itself. + */ + public WebhookReceiver withServiceUri(String serviceUri) { + this.serviceUri = serviceUri; + return this; + } + + /** + * Get the useCommonAlertSchema property: Indicates whether to use common alert schema. + * + * @return the useCommonAlertSchema value. + */ + public Boolean useCommonAlertSchema() { + return this.useCommonAlertSchema; + } + + /** + * Set the useCommonAlertSchema property: Indicates whether to use common alert schema. + * + * @param useCommonAlertSchema the useCommonAlertSchema value to set. + * @return the WebhookReceiver object itself. + */ + public WebhookReceiver withUseCommonAlertSchema(Boolean useCommonAlertSchema) { + this.useCommonAlertSchema = useCommonAlertSchema; + return this; + } + + /** + * Get the useAadAuth property: Indicates whether or not use AAD authentication. + * + * @return the useAadAuth value. + */ + public Boolean useAadAuth() { + return this.useAadAuth; + } + + /** + * Set the useAadAuth property: Indicates whether or not use AAD authentication. + * + * @param useAadAuth the useAadAuth value to set. + * @return the WebhookReceiver object itself. + */ + public WebhookReceiver withUseAadAuth(Boolean useAadAuth) { + this.useAadAuth = useAadAuth; + return this; + } + + /** + * Get the objectId property: Indicates the webhook app object Id for aad auth. + * + * @return the objectId value. + */ + public String objectId() { + return this.objectId; + } + + /** + * Set the objectId property: Indicates the webhook app object Id for aad auth. + * + * @param objectId the objectId value to set. + * @return the WebhookReceiver object itself. + */ + public WebhookReceiver withObjectId(String objectId) { + this.objectId = objectId; + return this; + } + + /** + * Get the identifierUri property: Indicates the identifier uri for aad auth. + * + * @return the identifierUri value. + */ + public String identifierUri() { + return this.identifierUri; + } + + /** + * Set the identifierUri property: Indicates the identifier uri for aad auth. + * + * @param identifierUri the identifierUri value to set. + * @return the WebhookReceiver object itself. + */ + public WebhookReceiver withIdentifierUri(String identifierUri) { + this.identifierUri = identifierUri; + return this; + } + + /** + * Get the tenantId property: Indicates the tenant id for aad auth. + * + * @return the tenantId value. + */ + public String tenantId() { + return this.tenantId; + } + + /** + * Set the tenantId property: Indicates the tenant id for aad auth. + * + * @param tenantId the tenantId value to set. + * @return the WebhookReceiver object itself. + */ + public WebhookReceiver withTenantId(String tenantId) { + this.tenantId = tenantId; + return this; + } + + /** + * Get the managedIdentity property: The principal id of the managed identity. The value can be "None", + * "SystemAssigned". + * + * @return the managedIdentity value. + */ + public String managedIdentity() { + return this.managedIdentity; + } + + /** + * Set the managedIdentity property: The principal id of the managed identity. The value can be "None", + * "SystemAssigned". + * + * @param managedIdentity the managedIdentity value to set. + * @return the WebhookReceiver object itself. + */ + public WebhookReceiver withManagedIdentity(String managedIdentity) { + this.managedIdentity = managedIdentity; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (name() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property name in model WebhookReceiver")); + } + if (serviceUri() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property serviceUri in model WebhookReceiver")); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(WebhookReceiver.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + jsonWriter.writeStringField("serviceUri", this.serviceUri); + jsonWriter.writeBooleanField("useCommonAlertSchema", this.useCommonAlertSchema); + jsonWriter.writeBooleanField("useAadAuth", this.useAadAuth); + jsonWriter.writeStringField("objectId", this.objectId); + jsonWriter.writeStringField("identifierUri", this.identifierUri); + jsonWriter.writeStringField("tenantId", this.tenantId); + jsonWriter.writeStringField("managedIdentity", this.managedIdentity); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of WebhookReceiver from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of WebhookReceiver if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the WebhookReceiver. + */ + public static WebhookReceiver fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + WebhookReceiver deserializedWebhookReceiver = new WebhookReceiver(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + deserializedWebhookReceiver.name = reader.getString(); + } else if ("serviceUri".equals(fieldName)) { + deserializedWebhookReceiver.serviceUri = reader.getString(); + } else if ("useCommonAlertSchema".equals(fieldName)) { + deserializedWebhookReceiver.useCommonAlertSchema = reader.getNullable(JsonReader::getBoolean); + } else if ("useAadAuth".equals(fieldName)) { + deserializedWebhookReceiver.useAadAuth = reader.getNullable(JsonReader::getBoolean); + } else if ("objectId".equals(fieldName)) { + deserializedWebhookReceiver.objectId = reader.getString(); + } else if ("identifierUri".equals(fieldName)) { + deserializedWebhookReceiver.identifierUri = reader.getString(); + } else if ("tenantId".equals(fieldName)) { + deserializedWebhookReceiver.tenantId = reader.getString(); + } else if ("managedIdentity".equals(fieldName)) { + deserializedWebhookReceiver.managedIdentity = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedWebhookReceiver; + }); + } +} 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..a85a49375628e --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/models/package-info.java @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) 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..960c45082be31 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/com/azure/resourcemanager/monitor/generated/package-info.java @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +/** + * 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..bfe971b9d1cfd --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/java/module-info.java @@ -0,0 +1,15 @@ +// 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; + opens com.azure.resourcemanager.monitor.generated.models to com.azure.core; +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-monitor-generated/proxy-config.json b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-monitor-generated/proxy-config.json new file mode 100644 index 0000000000000..9f8504ebe03da --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-monitor-generated/proxy-config.json @@ -0,0 +1 @@ +[["com.azure.resourcemanager.monitor.generated.implementation.ActionGroupsClientImpl$ActionGroupsService"],["com.azure.resourcemanager.monitor.generated.implementation.ScheduledQueryRulesClientImpl$ScheduledQueryRulesService"]] \ No newline at end of file diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-monitor-generated/reflect-config.json b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-monitor-generated/reflect-config.json new file mode 100644 index 0000000000000..0637a088a01e8 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-monitor-generated/reflect-config.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/samples/java/com/azure/resourcemanager/monitor/generated/generated/ActionGroupsCreateNotificationsAtActionGroupResourceLevelSamples.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/samples/java/com/azure/resourcemanager/monitor/generated/generated/ActionGroupsCreateNotificationsAtActionGroupResourceLevelSamples.java new file mode 100644 index 0000000000000..ef1bbb254dcd8 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/samples/java/com/azure/resourcemanager/monitor/generated/generated/ActionGroupsCreateNotificationsAtActionGroupResourceLevelSamples.java @@ -0,0 +1,113 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.monitor.generated.generated; + +import com.azure.resourcemanager.monitor.generated.models.ArmRoleReceiver; +import com.azure.resourcemanager.monitor.generated.models.AutomationRunbookReceiver; +import com.azure.resourcemanager.monitor.generated.models.AzureAppPushReceiver; +import com.azure.resourcemanager.monitor.generated.models.AzureFunctionReceiver; +import com.azure.resourcemanager.monitor.generated.models.EmailReceiver; +import com.azure.resourcemanager.monitor.generated.models.EventHubReceiver; +import com.azure.resourcemanager.monitor.generated.models.ItsmReceiver; +import com.azure.resourcemanager.monitor.generated.models.LogicAppReceiver; +import com.azure.resourcemanager.monitor.generated.models.NotificationRequestBody; +import com.azure.resourcemanager.monitor.generated.models.SmsReceiver; +import com.azure.resourcemanager.monitor.generated.models.VoiceReceiver; +import com.azure.resourcemanager.monitor.generated.models.WebhookReceiver; +import java.util.Arrays; + +/** + * Samples for ActionGroups CreateNotificationsAtActionGroupResourceLevel. + */ +public final class ActionGroupsCreateNotificationsAtActionGroupResourceLevelSamples { + /* + * x-ms-original-file: + * specification/monitor/resource-manager/Microsoft.Insights/preview/2024-10-01-preview/examples/ + * postTestNotificationsAtActionGroupResourceLevel.json + */ + /** + * Sample code: Create notifications at resource group level. + * + * @param manager Entry point to MonitorManager. + */ + public static void + createNotificationsAtResourceGroupLevel(com.azure.resourcemanager.monitor.generated.MonitorManager manager) { + manager.actionGroups() + .createNotificationsAtActionGroupResourceLevel("TestRgName", "TestAgName", new NotificationRequestBody() + .withAlertType("budget") + .withEmailReceivers(Arrays.asList( + new EmailReceiver().withName("John Doe's email") + .withEmailAddress("johndoe@email.com") + .withUseCommonAlertSchema(false), + new EmailReceiver().withName("Jane Smith's email") + .withEmailAddress("janesmith@email.com") + .withUseCommonAlertSchema(true))) + .withSmsReceivers(Arrays.asList( + new SmsReceiver().withName("John Doe's mobile") + .withCountryCode("fakeTokenPlaceholder") + .withPhoneNumber("1234567890"), + new SmsReceiver().withName("Jane Smith's mobile") + .withCountryCode("fakeTokenPlaceholder") + .withPhoneNumber("0987654321"))) + .withWebhookReceivers(Arrays.asList( + new WebhookReceiver().withName("Sample webhook 1") + .withServiceUri("http://www.example.com/webhook1") + .withUseCommonAlertSchema(true), + new WebhookReceiver().withName("Sample webhook 2") + .withServiceUri("http://www.example.com/webhook2") + .withUseCommonAlertSchema(true) + .withUseAadAuth(true) + .withObjectId("d3bb868c-fe44-452c-aa26-769a6538c808") + .withIdentifierUri("http://someidentifier/d7811ba3-7996-4a93-99b6-6b2f3f355f8a") + .withTenantId("68a4459a-ccb8-493c-b9da-dd30457d1b84"))) + .withItsmReceivers(Arrays.asList(new ItsmReceiver().withName("Sample itsm") + .withWorkspaceId("5def922a-3ed4-49c1-b9fd-05ec533819a3|55dfd1f8-7e59-4f89-bf56-4c82f5ace23c") + .withConnectionId("a3b9076c-ce8e-434e-85b4-aff10cb3c8f1") + .withTicketConfiguration( + "{\"PayloadRevision\":0,\"WorkItemType\":\"Incident\",\"UseTemplate\":false,\"WorkItemData\":\"{}\",\"CreateOneWIPerCI\":false}") + .withRegion("westcentralus"))) + .withAzureAppPushReceivers(Arrays.asList( + new AzureAppPushReceiver().withName("Sample azureAppPush").withEmailAddress("johndoe@email.com"))) + .withAutomationRunbookReceivers(Arrays.asList(new AutomationRunbookReceiver().withAutomationAccountId( + "/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/runbookTest/providers/Microsoft.Automation/automationAccounts/runbooktest") + .withRunbookName("Sample runbook") + .withWebhookResourceId( + "/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/runbookTest/providers/Microsoft.Automation/automationAccounts/runbooktest/webhooks/Alert1510184037084") + .withIsGlobalRunbook(false) + .withName("testRunbook") + .withServiceUri("http://test.me") + .withUseCommonAlertSchema(true))) + .withVoiceReceivers(Arrays.asList(new VoiceReceiver().withName("Sample voice") + .withCountryCode("fakeTokenPlaceholder") + .withPhoneNumber("1234567890"))) + .withLogicAppReceivers(Arrays.asList(new LogicAppReceiver().withName("Sample logicApp") + .withResourceId( + "/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/LogicApp/providers/Microsoft.Logic/workflows/testLogicApp") + .withCallbackUrl( + "https://prod-27.northcentralus.logic.azure.com/workflows/68e572e818e5457ba898763b7db90877/triggers/manual/paths/invoke/azns/test?api-version=2016-10-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=Abpsb72UYJxPPvmDo937uzofupO5r_vIeWEx7KVHo7w") + .withUseCommonAlertSchema(false) + .withManagedIdentity("f11979a4-36d1-45d0-9097-a0da3c7e855d"))) + .withAzureFunctionReceivers(Arrays.asList(new AzureFunctionReceiver().withName("Sample azureFunction") + .withFunctionAppResourceId( + "/subscriptions/5def922a-3ed4-49c1-b9fd-05ec533819a3/resourceGroups/aznsTest/providers/Microsoft.Web/sites/testFunctionApp") + .withFunctionName("HttpTriggerCSharp1") + .withHttpTriggerUrl("http://test.me") + .withUseCommonAlertSchema(true) + .withManagedIdentity("f11979a4-36d1-45d0-9097-a0da3c7e855d"))) + .withArmRoleReceivers(Arrays.asList( + new ArmRoleReceiver().withName("ArmRole-Common") + .withRoleId("11111111-1111-1111-1111-111111111111") + .withUseCommonAlertSchema(true), + new ArmRoleReceiver().withName("ArmRole-nonCommon") + .withRoleId("11111111-1111-1111-1111-111111111111") + .withUseCommonAlertSchema(false))) + .withEventHubReceivers(Arrays.asList(new EventHubReceiver().withName("Sample eventHub") + .withEventHubNameSpace("testEventHubNameSpace") + .withEventHubName("testEventHub") + .withTenantId("68a4459a-ccb8-493c-b9da-dd30457d1b84") + .withSubscriptionId("187f412d-1758-44d9-b052-169e2564721d"))), + com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/samples/java/com/azure/resourcemanager/monitor/generated/generated/ActionGroupsCreateOrUpdateSamples.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/samples/java/com/azure/resourcemanager/monitor/generated/generated/ActionGroupsCreateOrUpdateSamples.java new file mode 100644 index 0000000000000..363068b9b75fe --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/samples/java/com/azure/resourcemanager/monitor/generated/generated/ActionGroupsCreateOrUpdateSamples.java @@ -0,0 +1,150 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.monitor.generated.generated; + +import com.azure.resourcemanager.monitor.generated.models.ArmRoleReceiver; +import com.azure.resourcemanager.monitor.generated.models.AutomationRunbookReceiver; +import com.azure.resourcemanager.monitor.generated.models.AzureAppPushReceiver; +import com.azure.resourcemanager.monitor.generated.models.AzureFunctionReceiver; +import com.azure.resourcemanager.monitor.generated.models.EmailReceiver; +import com.azure.resourcemanager.monitor.generated.models.EventHubReceiver; +import com.azure.resourcemanager.monitor.generated.models.IncidentManagementService; +import com.azure.resourcemanager.monitor.generated.models.IncidentReceiver; +import com.azure.resourcemanager.monitor.generated.models.IncidentServiceConnection; +import com.azure.resourcemanager.monitor.generated.models.ItsmReceiver; +import com.azure.resourcemanager.monitor.generated.models.LogicAppReceiver; +import com.azure.resourcemanager.monitor.generated.models.ManagedServiceIdentity; +import com.azure.resourcemanager.monitor.generated.models.ManagedServiceIdentityType; +import com.azure.resourcemanager.monitor.generated.models.SmsReceiver; +import com.azure.resourcemanager.monitor.generated.models.UserAssignedIdentity; +import com.azure.resourcemanager.monitor.generated.models.VoiceReceiver; +import com.azure.resourcemanager.monitor.generated.models.WebhookReceiver; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; + +/** + * Samples for ActionGroups CreateOrUpdate. + */ +public final class ActionGroupsCreateOrUpdateSamples { + /* + * x-ms-original-file: + * specification/monitor/resource-manager/Microsoft.Insights/preview/2024-10-01-preview/examples/ + * createOrUpdateActionGroup.json + */ + /** + * Sample code: Create or update an action group. + * + * @param manager Entry point to MonitorManager. + */ + public static void createOrUpdateAnActionGroup(com.azure.resourcemanager.monitor.generated.MonitorManager manager) { + manager.actionGroups() + .define("SampleActionGroup") + .withRegion("Global") + .withExistingResourceGroup("Default-NotificationRules") + .withTags(mapOf()) + .withIdentity(new ManagedServiceIdentity().withType(ManagedServiceIdentityType.USER_ASSIGNED) + .withUserAssignedIdentities(mapOf( + "/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/AzSecPackAutoConfigRG/providers/Microsoft.ManagedIdentity/userAssignedIdentities/ThomasTestManagedIdentity_123", + new UserAssignedIdentity(), + "/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/AzSecPackAutoConfigRG/providers/Microsoft.ManagedIdentity/userAssignedIdentities/ThomasTestManagedIdentity_456", + new UserAssignedIdentity()))) + .withGroupShortName("sample") + .withEnabled(true) + .withEmailReceivers(Arrays.asList( + new EmailReceiver().withName("John Doe's email") + .withEmailAddress("johndoe@email.com") + .withUseCommonAlertSchema(false), + new EmailReceiver().withName("Jane Smith's email") + .withEmailAddress("janesmith@email.com") + .withUseCommonAlertSchema(true))) + .withSmsReceivers(Arrays.asList( + new SmsReceiver().withName("John Doe's mobile") + .withCountryCode("fakeTokenPlaceholder") + .withPhoneNumber("1234567890"), + new SmsReceiver().withName("Jane Smith's mobile") + .withCountryCode("fakeTokenPlaceholder") + .withPhoneNumber("0987654321"))) + .withWebhookReceivers(Arrays.asList( + new WebhookReceiver().withName("Sample webhook 1") + .withServiceUri("http://www.example.com/webhook1") + .withUseCommonAlertSchema(true), + new WebhookReceiver().withName("Sample webhook 2") + .withServiceUri("http://www.example.com/webhook2") + .withUseCommonAlertSchema(true) + .withUseAadAuth(true) + .withObjectId("d3bb868c-fe44-452c-aa26-769a6538c808") + .withIdentifierUri("http://someidentifier/d7811ba3-7996-4a93-99b6-6b2f3f355f8a") + .withTenantId("68a4459a-ccb8-493c-b9da-dd30457d1b84") + .withManagedIdentity("30fe7a91-cd31-4edf-96ab-52883b3199cd"))) + .withItsmReceivers(Arrays.asList(new ItsmReceiver().withName("Sample itsm") + .withWorkspaceId("5def922a-3ed4-49c1-b9fd-05ec533819a3|55dfd1f8-7e59-4f89-bf56-4c82f5ace23c") + .withConnectionId("a3b9076c-ce8e-434e-85b4-aff10cb3c8f1") + .withTicketConfiguration( + "{\"PayloadRevision\":0,\"WorkItemType\":\"Incident\",\"UseTemplate\":false,\"WorkItemData\":\"{}\",\"CreateOneWIPerCI\":false}") + .withRegion("westcentralus"))) + .withAzureAppPushReceivers(Arrays.asList( + new AzureAppPushReceiver().withName("Sample azureAppPush").withEmailAddress("johndoe@email.com"))) + .withAutomationRunbookReceivers(Arrays.asList(new AutomationRunbookReceiver().withAutomationAccountId( + "/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/runbookTest/providers/Microsoft.Automation/automationAccounts/runbooktest") + .withRunbookName("Sample runbook") + .withWebhookResourceId( + "/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/runbookTest/providers/Microsoft.Automation/automationAccounts/runbooktest/webhooks/Alert1510184037084") + .withIsGlobalRunbook(false) + .withName("testRunbook") + .withServiceUri("") + .withUseCommonAlertSchema(true) + .withManagedIdentity("30fe7a91-cd31-4edf-96ab-52883b3199cd"))) + .withVoiceReceivers(Arrays.asList(new VoiceReceiver().withName("Sample voice") + .withCountryCode("fakeTokenPlaceholder") + .withPhoneNumber("1234567890"))) + .withLogicAppReceivers(Arrays.asList(new LogicAppReceiver().withName("Sample logicApp") + .withResourceId( + "/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/LogicApp/providers/Microsoft.Logic/workflows/testLogicApp") + .withCallbackUrl( + "https://prod-27.northcentralus.logic.azure.com/workflows/68e572e818e5457ba898763b7db90877/triggers/manual/paths/invoke/azns/test?api-version=2016-10-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=Abpsb72UYJxPPvmDo937uzofupO5r_vIeWEx7KVHo7w") + .withUseCommonAlertSchema(false) + .withManagedIdentity("30fe7a91-cd31-4edf-96ab-52883b3199cd"))) + .withAzureFunctionReceivers(Arrays.asList(new AzureFunctionReceiver().withName("Sample azureFunction") + .withFunctionAppResourceId( + "/subscriptions/5def922a-3ed4-49c1-b9fd-05ec533819a3/resourceGroups/aznsTest/providers/Microsoft.Web/sites/testFunctionApp") + .withFunctionName("HttpTriggerCSharp1") + .withHttpTriggerUrl("http://test.me") + .withUseCommonAlertSchema(true) + .withManagedIdentity("30fe7a91-cd31-4edf-96ab-52883b3199cd"))) + .withArmRoleReceivers(Arrays.asList(new ArmRoleReceiver().withName("Sample armRole") + .withRoleId("8e3af657-a8ff-443c-a75c-2fe8c4bcb635") + .withUseCommonAlertSchema(true))) + .withEventHubReceivers(Arrays.asList(new EventHubReceiver().withName("Sample eventHub") + .withEventHubNameSpace("testEventHubNameSpace") + .withEventHubName("testEventHub") + .withTenantId("68a4459a-ccb8-493c-b9da-dd30457d1b84") + .withSubscriptionId("187f412d-1758-44d9-b052-169e2564721d") + .withManagedIdentity("30fe7a91-cd31-4edf-96ab-52883b3199cd"))) + .withIncidentReceivers(Arrays.asList(new IncidentReceiver().withName("IncidentAction") + .withConnection(new IncidentServiceConnection().withName("IncidentConnection") + .withId("8be638e7-1419-42d4-a059-437a5f4f4e4e")) + .withIncidentManagementService(IncidentManagementService.ICM) + .withMappings(mapOf("icm.automitigationenabled", "true", "icm.correlationid", + "${data.essentials.signalType}://${data.essentials.originAlertId}", "icm.monitorid", + "${data.essentials.alertRule}", "icm.occurringlocation.environment", "PROD", "icm.routingid", + "${data.essentials.monitoringService}://${data.essentials.signalType}", "icm.title", + "${data.essentials.severity}:${data.essentials.monitorCondition} ${data.essentials.monitoringService}:${data.essentials.signalType} ${data.essentials.alertTargetIds}", + "icm.tsgid", "https://microsoft.com")))) + .create(); + } + + // Use "Map.of" if available + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/samples/java/com/azure/resourcemanager/monitor/generated/generated/ActionGroupsDeleteSamples.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/samples/java/com/azure/resourcemanager/monitor/generated/generated/ActionGroupsDeleteSamples.java new file mode 100644 index 0000000000000..02374e76c9378 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/samples/java/com/azure/resourcemanager/monitor/generated/generated/ActionGroupsDeleteSamples.java @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.monitor.generated.generated; + +/** + * Samples for ActionGroups Delete. + */ +public final class ActionGroupsDeleteSamples { + /* + * x-ms-original-file: + * specification/monitor/resource-manager/Microsoft.Insights/preview/2024-10-01-preview/examples/deleteActionGroup. + * json + */ + /** + * Sample code: Delete an action group. + * + * @param manager Entry point to MonitorManager. + */ + public static void deleteAnActionGroup(com.azure.resourcemanager.monitor.generated.MonitorManager manager) { + manager.actionGroups() + .deleteByResourceGroupWithResponse("Default-NotificationRules", "SampleActionGroup", + com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/samples/java/com/azure/resourcemanager/monitor/generated/generated/ActionGroupsEnableReceiverSamples.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/samples/java/com/azure/resourcemanager/monitor/generated/generated/ActionGroupsEnableReceiverSamples.java new file mode 100644 index 0000000000000..fd5a60f446946 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/samples/java/com/azure/resourcemanager/monitor/generated/generated/ActionGroupsEnableReceiverSamples.java @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.monitor.generated.generated; + +import com.azure.resourcemanager.monitor.generated.models.EnableRequest; + +/** + * Samples for ActionGroups EnableReceiver. + */ +public final class ActionGroupsEnableReceiverSamples { + /* + * x-ms-original-file: + * specification/monitor/resource-manager/Microsoft.Insights/preview/2024-10-01-preview/examples/enableReceiver.json + */ + /** + * Sample code: Enable the receiver. + * + * @param manager Entry point to MonitorManager. + */ + public static void enableTheReceiver(com.azure.resourcemanager.monitor.generated.MonitorManager manager) { + manager.actionGroups() + .enableReceiverWithResponse("Default-NotificationRules", "SampleActionGroup", + new EnableRequest().withReceiverName("John Doe's mobile"), com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/samples/java/com/azure/resourcemanager/monitor/generated/generated/ActionGroupsGetByResourceGroupSamples.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/samples/java/com/azure/resourcemanager/monitor/generated/generated/ActionGroupsGetByResourceGroupSamples.java new file mode 100644 index 0000000000000..75be319836f45 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/samples/java/com/azure/resourcemanager/monitor/generated/generated/ActionGroupsGetByResourceGroupSamples.java @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.monitor.generated.generated; + +/** + * Samples for ActionGroups GetByResourceGroup. + */ +public final class ActionGroupsGetByResourceGroupSamples { + /* + * x-ms-original-file: + * specification/monitor/resource-manager/Microsoft.Insights/preview/2024-10-01-preview/examples/getActionGroup.json + */ + /** + * Sample code: Get an action group. + * + * @param manager Entry point to MonitorManager. + */ + public static void getAnActionGroup(com.azure.resourcemanager.monitor.generated.MonitorManager manager) { + manager.actionGroups() + .getByResourceGroupWithResponse("Default-NotificationRules", "SampleActionGroup", + com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/samples/java/com/azure/resourcemanager/monitor/generated/generated/ActionGroupsGetTestNotificationsAtActionGroupResourceLevelSamples.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/samples/java/com/azure/resourcemanager/monitor/generated/generated/ActionGroupsGetTestNotificationsAtActionGroupResourceLevelSamples.java new file mode 100644 index 0000000000000..8a959296e6b7f --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/samples/java/com/azure/resourcemanager/monitor/generated/generated/ActionGroupsGetTestNotificationsAtActionGroupResourceLevelSamples.java @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.monitor.generated.generated; + +/** + * Samples for ActionGroups GetTestNotificationsAtActionGroupResourceLevel. + */ +public final class ActionGroupsGetTestNotificationsAtActionGroupResourceLevelSamples { + /* + * x-ms-original-file: + * specification/monitor/resource-manager/Microsoft.Insights/preview/2024-10-01-preview/examples/ + * getTestNotificationsAtActionGroupResourceLevel.json + */ + /** + * Sample code: Get notification details at resource group level. + * + * @param manager Entry point to MonitorManager. + */ + public static void + getNotificationDetailsAtResourceGroupLevel(com.azure.resourcemanager.monitor.generated.MonitorManager manager) { + manager.actionGroups() + .getTestNotificationsAtActionGroupResourceLevelWithResponse("TestRgName", "TestAgName", "11000222191287", + com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/samples/java/com/azure/resourcemanager/monitor/generated/generated/ActionGroupsListByResourceGroupSamples.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/samples/java/com/azure/resourcemanager/monitor/generated/generated/ActionGroupsListByResourceGroupSamples.java new file mode 100644 index 0000000000000..938539d3dfbda --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/samples/java/com/azure/resourcemanager/monitor/generated/generated/ActionGroupsListByResourceGroupSamples.java @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.monitor.generated.generated; + +/** + * Samples for ActionGroups ListByResourceGroup. + */ +public final class ActionGroupsListByResourceGroupSamples { + /* + * x-ms-original-file: + * specification/monitor/resource-manager/Microsoft.Insights/preview/2024-10-01-preview/examples/listActionGroups. + * json + */ + /** + * Sample code: List action groups at resource group level. + * + * @param manager Entry point to MonitorManager. + */ + public static void + listActionGroupsAtResourceGroupLevel(com.azure.resourcemanager.monitor.generated.MonitorManager manager) { + manager.actionGroups().listByResourceGroup("Default-NotificationRules", com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/samples/java/com/azure/resourcemanager/monitor/generated/generated/ActionGroupsListSamples.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/samples/java/com/azure/resourcemanager/monitor/generated/generated/ActionGroupsListSamples.java new file mode 100644 index 0000000000000..3ec3611a44fb8 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/samples/java/com/azure/resourcemanager/monitor/generated/generated/ActionGroupsListSamples.java @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.monitor.generated.generated; + +/** + * Samples for ActionGroups List. + */ +public final class ActionGroupsListSamples { + /* + * x-ms-original-file: + * specification/monitor/resource-manager/Microsoft.Insights/preview/2024-10-01-preview/examples/listActionGroups. + * json + */ + /** + * Sample code: List action groups at subscription level. + * + * @param manager Entry point to MonitorManager. + */ + public static void + listActionGroupsAtSubscriptionLevel(com.azure.resourcemanager.monitor.generated.MonitorManager manager) { + manager.actionGroups().list(com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/samples/java/com/azure/resourcemanager/monitor/generated/generated/ActionGroupsUpdateSamples.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/samples/java/com/azure/resourcemanager/monitor/generated/generated/ActionGroupsUpdateSamples.java new file mode 100644 index 0000000000000..f3bcd62888c0a --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/samples/java/com/azure/resourcemanager/monitor/generated/generated/ActionGroupsUpdateSamples.java @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.monitor.generated.generated; + +import com.azure.resourcemanager.monitor.generated.models.ActionGroupResource; +import com.azure.resourcemanager.monitor.generated.models.ManagedServiceIdentity; +import com.azure.resourcemanager.monitor.generated.models.ManagedServiceIdentityType; +import java.util.HashMap; +import java.util.Map; + +/** + * Samples for ActionGroups Update. + */ +public final class ActionGroupsUpdateSamples { + /* + * x-ms-original-file: + * specification/monitor/resource-manager/Microsoft.Insights/preview/2024-10-01-preview/examples/patchActionGroup. + * json + */ + /** + * Sample code: Patch an action group. + * + * @param manager Entry point to MonitorManager. + */ + public static void patchAnActionGroup(com.azure.resourcemanager.monitor.generated.MonitorManager manager) { + ActionGroupResource resource = manager.actionGroups() + .getByResourceGroupWithResponse("Default-NotificationRules", "SampleActionGroup", + com.azure.core.util.Context.NONE) + .getValue(); + resource.update() + .withTags(mapOf("key1", "fakeTokenPlaceholder", "key2", "fakeTokenPlaceholder")) + .withIdentity(new ManagedServiceIdentity().withType(ManagedServiceIdentityType.SYSTEM_ASSIGNED)) + .withEnabled(false) + .apply(); + } + + // Use "Map.of" if available + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/samples/java/com/azure/resourcemanager/monitor/generated/generated/ScheduledQueryRulesCreateOrUpdateSamples.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/samples/java/com/azure/resourcemanager/monitor/generated/generated/ScheduledQueryRulesCreateOrUpdateSamples.java new file mode 100644 index 0000000000000..2bcc6f7067d43 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/samples/java/com/azure/resourcemanager/monitor/generated/generated/ScheduledQueryRulesCreateOrUpdateSamples.java @@ -0,0 +1,183 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.monitor.generated.generated; + +import com.azure.resourcemanager.monitor.generated.models.Actions; +import com.azure.resourcemanager.monitor.generated.models.AlertSeverity; +import com.azure.resourcemanager.monitor.generated.models.Condition; +import com.azure.resourcemanager.monitor.generated.models.ConditionFailingPeriods; +import com.azure.resourcemanager.monitor.generated.models.ConditionOperator; +import com.azure.resourcemanager.monitor.generated.models.Dimension; +import com.azure.resourcemanager.monitor.generated.models.DimensionOperator; +import com.azure.resourcemanager.monitor.generated.models.RuleResolveConfiguration; +import com.azure.resourcemanager.monitor.generated.models.ScheduledQueryRuleCriteria; +import com.azure.resourcemanager.monitor.generated.models.TimeAggregation; +import java.time.Duration; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; + +/** + * Samples for ScheduledQueryRules CreateOrUpdate. + */ +public final class ScheduledQueryRulesCreateOrUpdateSamples { + /* + * x-ms-original-file: + * specification/monitor/resource-manager/Microsoft.Insights/preview/2024-01-01-preview/examples/ + * createOrUpdateScheduledQueryRuleSubscription.json + */ + /** + * Sample code: Create or update a scheduled query rule on Subscription. + * + * @param manager Entry point to MonitorManager. + */ + public static void createOrUpdateAScheduledQueryRuleOnSubscription( + com.azure.resourcemanager.monitor.generated.MonitorManager manager) { + manager.scheduledQueryRules() + .define("perf") + .withRegion("eastus") + .withExistingResourceGroup("QueryResourceGroupName") + .withDescription("Performance rule") + .withSeverity(AlertSeverity.FOUR) + .withEnabled(true) + .withScopes(Arrays.asList("/subscriptions/aaf177ed-1330-a9f2-80ea-fd3d7783b147")) + .withEvaluationFrequency(Duration.parse("PT5M")) + .withWindowSize(Duration.parse("PT10M")) + .withTargetResourceTypes(Arrays.asList("Microsoft.Compute/virtualMachines")) + .withCriteria(new ScheduledQueryRuleCriteria() + .withAllOf(Arrays.asList(new Condition().withQuery("Perf | where ObjectName == \"Processor\"") + .withTimeAggregation(TimeAggregation.AVERAGE) + .withMetricMeasureColumn("% Processor Time") + .withResourceIdColumn("resourceId") + .withDimensions(Arrays.asList( + new Dimension().withName("ComputerIp") + .withOperator(DimensionOperator.EXCLUDE) + .withValues(Arrays.asList("192.168.1.1")), + new Dimension().withName("OSType") + .withOperator(DimensionOperator.INCLUDE) + .withValues(Arrays.asList("*")))) + .withOperator(ConditionOperator.GREATER_THAN) + .withThreshold(70.0D) + .withFailingPeriods(new ConditionFailingPeriods().withNumberOfEvaluationPeriods(1L) + .withMinFailingPeriodsToAlert(1L))))) + .withMuteActionsDuration(Duration.parse("PT30M")) + .withActions(new Actions().withActionGroups(Arrays.asList( + "/subscriptions/1cf177ed-1330-4692-80ea-fd3d7783b147/resourcegroups/sqrapi/providers/microsoft.insights/actiongroups/myactiongroup")) + .withCustomProperties(mapOf("key11", "fakeTokenPlaceholder", "key12", "fakeTokenPlaceholder")) + .withActionProperties(mapOf("Icm.Title", "Custom title in ICM", "Icm.TsgId", "https://tsg.url"))) + .withCheckWorkspaceAlertsStorageConfigured(true) + .withSkipQueryValidation(true) + .withResolveConfiguration( + new RuleResolveConfiguration().withAutoResolved(true).withTimeToResolve(Duration.parse("PT10M"))) + .create(); + } + + /* + * x-ms-original-file: + * specification/monitor/resource-manager/Microsoft.Insights/preview/2024-01-01-preview/examples/ + * createOrUpdateScheduledQueryRuleResourceGroup.json + */ + /** + * Sample code: Create or update a scheduled query rule on Resource group(s). + * + * @param manager Entry point to MonitorManager. + */ + public static void createOrUpdateAScheduledQueryRuleOnResourceGroupS( + com.azure.resourcemanager.monitor.generated.MonitorManager manager) { + manager.scheduledQueryRules() + .define("heartbeat") + .withRegion("eastus") + .withExistingResourceGroup("QueryResourceGroupName") + .withDescription("Health check rule") + .withSeverity(AlertSeverity.FOUR) + .withEnabled(true) + .withScopes( + Arrays.asList("/subscriptions/aaf177ed-1330-a9f2-80ea-fd3d7783b147/resourceGroups/scopeResourceGroup1")) + .withEvaluationFrequency(Duration.parse("PT5M")) + .withWindowSize(Duration.parse("PT10M")) + .withTargetResourceTypes(Arrays.asList("Microsoft.Compute/virtualMachines")) + .withCriteria( + new ScheduledQueryRuleCriteria().withAllOf(Arrays.asList(new Condition().withQuery("Heartbeat") + .withTimeAggregation(TimeAggregation.COUNT) + .withDimensions(Arrays.asList()) + .withOperator(ConditionOperator.GREATER_THAN) + .withThreshold(360.0D) + .withFailingPeriods(new ConditionFailingPeriods().withNumberOfEvaluationPeriods(1L) + .withMinFailingPeriodsToAlert(1L))))) + .withMuteActionsDuration(Duration.parse("PT30M")) + .withActions(new Actions().withActionGroups(Arrays.asList( + "/subscriptions/1cf177ed-1330-4692-80ea-fd3d7783b147/resourcegroups/sqrapi/providers/microsoft.insights/actiongroups/myactiongroup")) + .withCustomProperties(mapOf("key11", "fakeTokenPlaceholder", "key12", "fakeTokenPlaceholder")) + .withActionProperties(mapOf("Icm.Title", "Custom title in ICM", "Icm.TsgId", "https://tsg.url"))) + .withCheckWorkspaceAlertsStorageConfigured(true) + .withSkipQueryValidation(true) + .withResolveConfiguration( + new RuleResolveConfiguration().withAutoResolved(true).withTimeToResolve(Duration.parse("PT10M"))) + .create(); + } + + /* + * x-ms-original-file: + * specification/monitor/resource-manager/Microsoft.Insights/preview/2024-01-01-preview/examples/ + * createOrUpdateScheduledQueryRule.json + */ + /** + * Sample code: Create or update a scheduled query rule for Single Resource. + * + * @param manager Entry point to MonitorManager. + */ + public static void createOrUpdateAScheduledQueryRuleForSingleResource( + com.azure.resourcemanager.monitor.generated.MonitorManager manager) { + manager.scheduledQueryRules() + .define("perf") + .withRegion("eastus") + .withExistingResourceGroup("QueryResourceGroupName") + .withDescription("Performance rule") + .withSeverity(AlertSeverity.FOUR) + .withEnabled(true) + .withScopes(Arrays.asList( + "/subscriptions/aaf177ed-1330-a9f2-80ea-fd3d7783b147/resourceGroups/scopeResourceGroup1/providers/Microsoft.Compute/virtualMachines/vm1")) + .withEvaluationFrequency(Duration.parse("PT5M")) + .withWindowSize(Duration.parse("PT10M")) + .withCriteria(new ScheduledQueryRuleCriteria() + .withAllOf(Arrays.asList(new Condition().withQuery("Perf | where ObjectName == \"Processor\"") + .withTimeAggregation(TimeAggregation.AVERAGE) + .withMetricMeasureColumn("% Processor Time") + .withResourceIdColumn("resourceId") + .withDimensions(Arrays.asList( + new Dimension().withName("ComputerIp") + .withOperator(DimensionOperator.EXCLUDE) + .withValues(Arrays.asList("192.168.1.1")), + new Dimension().withName("OSType") + .withOperator(DimensionOperator.INCLUDE) + .withValues(Arrays.asList("*")))) + .withOperator(ConditionOperator.GREATER_THAN) + .withThreshold(70.0D) + .withFailingPeriods(new ConditionFailingPeriods().withNumberOfEvaluationPeriods(1L) + .withMinFailingPeriodsToAlert(1L))))) + .withMuteActionsDuration(Duration.parse("PT30M")) + .withActions(new Actions().withActionGroups(Arrays.asList( + "/subscriptions/1cf177ed-1330-4692-80ea-fd3d7783b147/resourcegroups/sqrapi/providers/microsoft.insights/actiongroups/myactiongroup")) + .withCustomProperties(mapOf("key11", "fakeTokenPlaceholder", "key12", "fakeTokenPlaceholder")) + .withActionProperties(mapOf("Icm.Title", "Custom title in ICM", "Icm.TsgId", "https://tsg.url"))) + .withCheckWorkspaceAlertsStorageConfigured(true) + .withSkipQueryValidation(true) + .withResolveConfiguration( + new RuleResolveConfiguration().withAutoResolved(true).withTimeToResolve(Duration.parse("PT10M"))) + .create(); + } + + // Use "Map.of" if available + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/samples/java/com/azure/resourcemanager/monitor/generated/generated/ScheduledQueryRulesDeleteSamples.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/samples/java/com/azure/resourcemanager/monitor/generated/generated/ScheduledQueryRulesDeleteSamples.java new file mode 100644 index 0000000000000..564bb5428fe07 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/samples/java/com/azure/resourcemanager/monitor/generated/generated/ScheduledQueryRulesDeleteSamples.java @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.monitor.generated.generated; + +/** + * Samples for ScheduledQueryRules Delete. + */ +public final class ScheduledQueryRulesDeleteSamples { + /* + * x-ms-original-file: + * specification/monitor/resource-manager/Microsoft.Insights/preview/2024-01-01-preview/examples/ + * deleteScheduledQueryRule.json + */ + /** + * Sample code: Delete a scheduled query rule. + * + * @param manager Entry point to MonitorManager. + */ + public static void deleteAScheduledQueryRule(com.azure.resourcemanager.monitor.generated.MonitorManager manager) { + manager.scheduledQueryRules() + .deleteByResourceGroupWithResponse("QueryResourceGroupName", "heartbeat", com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/samples/java/com/azure/resourcemanager/monitor/generated/generated/ScheduledQueryRulesGetByResourceGroupSamples.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/samples/java/com/azure/resourcemanager/monitor/generated/generated/ScheduledQueryRulesGetByResourceGroupSamples.java new file mode 100644 index 0000000000000..d658047082ddb --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/samples/java/com/azure/resourcemanager/monitor/generated/generated/ScheduledQueryRulesGetByResourceGroupSamples.java @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.monitor.generated.generated; + +/** + * Samples for ScheduledQueryRules GetByResourceGroup. + */ +public final class ScheduledQueryRulesGetByResourceGroupSamples { + /* + * x-ms-original-file: + * specification/monitor/resource-manager/Microsoft.Insights/preview/2024-01-01-preview/examples/ + * getScheduledQueryRule.json + */ + /** + * Sample code: Get a scheduled query rule for single resource. + * + * @param manager Entry point to MonitorManager. + */ + public static void + getAScheduledQueryRuleForSingleResource(com.azure.resourcemanager.monitor.generated.MonitorManager manager) { + manager.scheduledQueryRules() + .getByResourceGroupWithResponse("QueryResourceGroupName", "perf", com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/samples/java/com/azure/resourcemanager/monitor/generated/generated/ScheduledQueryRulesListByResourceGroupSamples.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/samples/java/com/azure/resourcemanager/monitor/generated/generated/ScheduledQueryRulesListByResourceGroupSamples.java new file mode 100644 index 0000000000000..e34baedeadaa2 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/samples/java/com/azure/resourcemanager/monitor/generated/generated/ScheduledQueryRulesListByResourceGroupSamples.java @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.monitor.generated.generated; + +/** + * Samples for ScheduledQueryRules ListByResourceGroup. + */ +public final class ScheduledQueryRulesListByResourceGroupSamples { + /* + * x-ms-original-file: + * specification/monitor/resource-manager/Microsoft.Insights/preview/2024-01-01-preview/examples/ + * listScheduledQueryRulesByResourceGroup.json + */ + /** + * Sample code: List scheduled query rules by resource group. + * + * @param manager Entry point to MonitorManager. + */ + public static void + listScheduledQueryRulesByResourceGroup(com.azure.resourcemanager.monitor.generated.MonitorManager manager) { + manager.scheduledQueryRules().listByResourceGroup("QueryResourceGroupName", com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/samples/java/com/azure/resourcemanager/monitor/generated/generated/ScheduledQueryRulesListSamples.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/samples/java/com/azure/resourcemanager/monitor/generated/generated/ScheduledQueryRulesListSamples.java new file mode 100644 index 0000000000000..0909451402978 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/samples/java/com/azure/resourcemanager/monitor/generated/generated/ScheduledQueryRulesListSamples.java @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.monitor.generated.generated; + +/** + * Samples for ScheduledQueryRules List. + */ +public final class ScheduledQueryRulesListSamples { + /* + * x-ms-original-file: + * specification/monitor/resource-manager/Microsoft.Insights/preview/2024-01-01-preview/examples/ + * listScheduledQueryRulesBySubscription.json + */ + /** + * Sample code: List scheduled query rules by subscription. + * + * @param manager Entry point to MonitorManager. + */ + public static void + listScheduledQueryRulesBySubscription(com.azure.resourcemanager.monitor.generated.MonitorManager manager) { + manager.scheduledQueryRules().list(com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-generated/src/samples/java/com/azure/resourcemanager/monitor/generated/generated/ScheduledQueryRulesUpdateSamples.java b/sdk/monitor/azure-resourcemanager-monitor-generated/src/samples/java/com/azure/resourcemanager/monitor/generated/generated/ScheduledQueryRulesUpdateSamples.java new file mode 100644 index 0000000000000..6d2419779955e --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-generated/src/samples/java/com/azure/resourcemanager/monitor/generated/generated/ScheduledQueryRulesUpdateSamples.java @@ -0,0 +1,30 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.monitor.generated.generated; + +import com.azure.resourcemanager.monitor.generated.models.ScheduledQueryRuleResource; + +/** + * Samples for ScheduledQueryRules Update. + */ +public final class ScheduledQueryRulesUpdateSamples { + /* + * x-ms-original-file: + * specification/monitor/resource-manager/Microsoft.Insights/preview/2024-01-01-preview/examples/ + * patchScheduledQueryRule.json + */ + /** + * Sample code: Create or update a scheduled query rule. + * + * @param manager Entry point to MonitorManager. + */ + public static void + createOrUpdateAScheduledQueryRule(com.azure.resourcemanager.monitor.generated.MonitorManager manager) { + ScheduledQueryRuleResource resource = manager.scheduledQueryRules() + .getByResourceGroupWithResponse("QueryResourceGroupName", "heartbeat", com.azure.core.util.Context.NONE) + .getValue(); + resource.update().withEnabled(false).apply(); + } +} diff --git a/sdk/monitor/ci.yml b/sdk/monitor/ci.yml index 07d14861fa42d..86f4a3414dfa4 100644 --- a/sdk/monitor/ci.yml +++ b/sdk/monitor/ci.yml @@ -36,26 +36,30 @@ pr: - sdk/monitor/azure-monitor-query-perf/pom.xml parameters: -- name: release_dependsonlivetests - displayName: 'Release depends on live tests' - type: boolean - default: true -- name: release_azuremonitoringestion - displayName: 'azure-monitor-ingestion' - type: boolean - default: true -- name: release_azuremonitoropentelemetryexporter - displayName: 'azure-monitor-opentelemetry-exporter' - type: boolean - default: true -- name: release_azuremonitoropentelemetryautoconfigure - displayName: 'azure-monitor-opentelemetry-autoconfigure' - type: boolean - default: true -- name: release_azuremonitorquery - displayName: 'azure-monitor-query' - type: boolean - default: true + - name: release_dependsonlivetests + displayName: Release depends on live tests + type: boolean + default: true + - name: release_azuremonitoringestion + displayName: azure-monitor-ingestion + type: boolean + default: true + - name: release_azuremonitoropentelemetryexporter + displayName: azure-monitor-opentelemetry-exporter + type: boolean + default: true + - name: release_azuremonitoropentelemetryautoconfigure + displayName: azure-monitor-opentelemetry-autoconfigure + type: boolean + default: true + - name: release_azuremonitorquery + displayName: azure-monitor-query + type: boolean + default: true + - name: release_azureresourcemanagermonitorgenerated + displayName: azure-resourcemanager-monitor-generated + type: boolean + default: false extends: template: ../../eng/pipelines/templates/stages/archetype-sdk-client.yml @@ -78,11 +82,14 @@ extends: groupId: com.azure safeName: azuremonitorquery releaseInBatch: ${{ parameters.release_azuremonitorquery }} + - name: azure-resourcemanager-monitor-generated + groupId: com.azure.resourcemanager + safeName: azureresourcemanagermonitorgenerated + releaseInBatch: ${{ parameters.release_azureresourcemanagermonitorgenerated }} AdditionalModules: - name: azure-monitor-query-perf groupId: com.azure - name: azure-monitor-ingestion-perf groupId: com.azure - # required by the above perf library - name: perf-test-core groupId: com.azure diff --git a/sdk/monitor/pom.xml b/sdk/monitor/pom.xml index 32e28ff3197ac..fab679c7e1dba 100644 --- a/sdk/monitor/pom.xml +++ b/sdk/monitor/pom.xml @@ -10,11 +10,12 @@ 1.0.0 - azure-monitor-ingestion - azure-monitor-ingestion-perf - azure-monitor-opentelemetry-exporter - azure-monitor-opentelemetry-autoconfigure - azure-monitor-query - azure-monitor-query-perf + azure-monitor-ingestion + azure-monitor-ingestion-perf + azure-monitor-opentelemetry-autoconfigure + azure-monitor-opentelemetry-exporter + azure-monitor-query + azure-monitor-query-perf + azure-resourcemanager-monitor-generated