From ce1986c302a76df3c02174188187620d818f8e46 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Mon, 29 Jul 2024 17:35:38 +0000 Subject: [PATCH] CodeGen from PR 29971 in Azure/azure-rest-api-specs Merge 68f6b9f065525a603400122311c09b21f09b586b into a651ba25cda4eec698a3a4e35f867ecc2681d126 --- eng/versioning/version_client.txt | 1 + pom.xml | 1 + .../CHANGELOG.md | 8 + .../README.md | 104 + .../SAMPLE.md | 669 +++++++ .../pom.xml | 67 + .../DatabasewatcherManager.java | 339 ++++ .../fluent/AlertRuleResourcesClient.java | 137 ++ .../fluent/MicrosoftDatabaseWatcher.java | 83 + .../fluent/OperationsClient.java | 40 + .../SharedPrivateLinkResourcesClient.java | 208 ++ .../databasewatcher/fluent/TargetsClient.java | 135 ++ .../fluent/WatchersClient.java | 377 ++++ .../fluent/models/AlertRuleResourceInner.java | 281 +++ .../models/AlertRuleResourceProperties.java | 255 +++ .../fluent/models/OperationInner.java | 172 ++ .../SharedPrivateLinkResourceInner.java | 271 +++ .../SharedPrivateLinkResourceProperties.java | 237 +++ .../fluent/models/TargetInner.java | 166 ++ .../fluent/models/WatcherInner.java | 281 +++ .../fluent/models/WatcherProperties.java | 162 ++ .../models/WatcherUpdateProperties.java | 127 ++ .../fluent/models/package-info.java | 9 + .../databasewatcher/fluent/package-info.java | 9 + .../implementation/AlertRuleResourceImpl.java | 181 ++ .../AlertRuleResourcesClientImpl.java | 730 +++++++ .../AlertRuleResourcesImpl.java | 159 ++ .../MicrosoftDatabaseWatcherBuilder.java | 138 ++ .../MicrosoftDatabaseWatcherImpl.java | 352 ++++ .../implementation/OperationImpl.java | 51 + .../implementation/OperationsClientImpl.java | 235 +++ .../implementation/OperationsImpl.java | 45 + .../implementation/ResourceManagerUtils.java | 195 ++ .../SharedPrivateLinkResourceImpl.java | 142 ++ .../SharedPrivateLinkResourcesClientImpl.java | 948 +++++++++ .../SharedPrivateLinkResourcesImpl.java | 167 ++ .../implementation/TargetImpl.java | 133 ++ .../implementation/TargetsClientImpl.java | 714 +++++++ .../implementation/TargetsImpl.java | 157 ++ .../implementation/WatcherImpl.java | 238 +++ .../implementation/WatchersClientImpl.java | 1699 +++++++++++++++++ .../implementation/WatchersImpl.java | 182 ++ .../implementation/package-info.java | 9 + .../databasewatcher/models/ActionType.java | 46 + .../models/AlertRuleCreationProperties.java | 51 + .../models/AlertRuleResource.java | 334 ++++ .../models/AlertRuleResourceListResult.java | 136 ++ .../models/AlertRuleResources.java | 147 ++ .../DatabaseWatcherProvisioningState.java | 56 + .../databasewatcher/models/Datastore.java | 287 +++ .../models/DatastoreUpdate.java | 262 +++ .../models/KustoOfferingType.java | 56 + .../models/ManagedServiceIdentity.java | 190 ++ .../models/ManagedServiceIdentityType.java | 62 + .../databasewatcher/models/Operation.java | 58 + .../models/OperationDisplay.java | 136 ++ .../models/OperationListResult.java | 104 + .../databasewatcher/models/Operations.java | 35 + .../databasewatcher/models/Origin.java | 57 + .../models/ResourceProvisioningState.java | 56 + .../models/SharedPrivateLinkResource.java | 220 +++ .../SharedPrivateLinkResourceListResult.java | 138 ++ .../SharedPrivateLinkResourceStatus.java | 61 + .../models/SharedPrivateLinkResources.java | 147 ++ .../SqlDbElasticPoolTargetProperties.java | 243 +++ .../SqlDbSingleDatabaseTargetProperties.java | 208 ++ .../models/SqlMiTargetProperties.java | 236 +++ .../models/SqlVmTargetProperties.java | 237 +++ .../databasewatcher/models/Target.java | 189 ++ .../models/TargetAuthenticationType.java | 51 + .../models/TargetListResult.java | 134 ++ .../models/TargetProperties.java | 250 +++ .../databasewatcher/models/Targets.java | 145 ++ .../models/UserAssignedIdentity.java | 100 + .../databasewatcher/models/VaultSecret.java | 156 ++ .../databasewatcher/models/Watcher.java | 392 ++++ .../models/WatcherListResult.java | 134 ++ .../databasewatcher/models/WatcherStatus.java | 66 + .../databasewatcher/models/WatcherUpdate.java | 195 ++ .../databasewatcher/models/Watchers.java | 207 ++ .../databasewatcher/models/package-info.java | 9 + .../databasewatcher/package-info.java | 9 + .../src/main/java/module-info.java | 13 + .../proxy-config.json | 1 + .../reflect-config.json | 1 + ...ertRuleResourcesCreateOrUpdateSamples.java | 37 + .../AlertRuleResourcesDeleteSamples.java | 26 + .../AlertRuleResourcesGetSamples.java | 26 + ...AlertRuleResourcesListByParentSamples.java | 25 + .../generated/OperationsListSamples.java | 40 + ...aredPrivateLinkResourcesCreateSamples.java | 33 + ...aredPrivateLinkResourcesDeleteSamples.java | 26 + .../SharedPrivateLinkResourcesGetSamples.java | 27 + ...vateLinkResourcesListByWatcherSamples.java | 26 + .../TargetsCreateOrUpdateSamples.java | 36 + .../generated/TargetsDeleteSamples.java | 27 + .../generated/TargetsGetSamples.java | 27 + .../TargetsListByWatcherSamples.java | 25 + .../WatchersCreateOrUpdateSamples.java | 60 + .../generated/WatchersDeleteSamples.java | 25 + .../WatchersGetByResourceGroupSamples.java | 25 + .../WatchersListByResourceGroupSamples.java | 25 + .../generated/WatchersListSamples.java | 25 + .../generated/WatchersStartSamples.java | 25 + .../generated/WatchersStopSamples.java | 25 + .../generated/WatchersUpdateSamples.java | 61 + sdk/databasewatcher/ci.yml | 46 + sdk/databasewatcher/pom.xml | 15 + .../pom.xml | 2 +- 109 files changed, 16943 insertions(+), 1 deletion(-) create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/CHANGELOG.md create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/README.md create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/SAMPLE.md create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/pom.xml create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/DatabasewatcherManager.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/fluent/AlertRuleResourcesClient.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/fluent/MicrosoftDatabaseWatcher.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/fluent/OperationsClient.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/fluent/SharedPrivateLinkResourcesClient.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/fluent/TargetsClient.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/fluent/WatchersClient.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/fluent/models/AlertRuleResourceInner.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/fluent/models/AlertRuleResourceProperties.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/fluent/models/OperationInner.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/fluent/models/SharedPrivateLinkResourceInner.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/fluent/models/SharedPrivateLinkResourceProperties.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/fluent/models/TargetInner.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/fluent/models/WatcherInner.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/fluent/models/WatcherProperties.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/fluent/models/WatcherUpdateProperties.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/fluent/models/package-info.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/fluent/package-info.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/implementation/AlertRuleResourceImpl.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/implementation/AlertRuleResourcesClientImpl.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/implementation/AlertRuleResourcesImpl.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/implementation/MicrosoftDatabaseWatcherBuilder.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/implementation/MicrosoftDatabaseWatcherImpl.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/implementation/OperationImpl.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/implementation/OperationsClientImpl.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/implementation/OperationsImpl.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/implementation/ResourceManagerUtils.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/implementation/SharedPrivateLinkResourceImpl.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/implementation/SharedPrivateLinkResourcesClientImpl.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/implementation/SharedPrivateLinkResourcesImpl.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/implementation/TargetImpl.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/implementation/TargetsClientImpl.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/implementation/TargetsImpl.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/implementation/WatcherImpl.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/implementation/WatchersClientImpl.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/implementation/WatchersImpl.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/implementation/package-info.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/ActionType.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/AlertRuleCreationProperties.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/AlertRuleResource.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/AlertRuleResourceListResult.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/AlertRuleResources.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/DatabaseWatcherProvisioningState.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/Datastore.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/DatastoreUpdate.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/KustoOfferingType.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/ManagedServiceIdentity.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/ManagedServiceIdentityType.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/Operation.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/OperationDisplay.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/OperationListResult.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/Operations.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/Origin.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/ResourceProvisioningState.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/SharedPrivateLinkResource.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/SharedPrivateLinkResourceListResult.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/SharedPrivateLinkResourceStatus.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/SharedPrivateLinkResources.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/SqlDbElasticPoolTargetProperties.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/SqlDbSingleDatabaseTargetProperties.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/SqlMiTargetProperties.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/SqlVmTargetProperties.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/Target.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/TargetAuthenticationType.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/TargetListResult.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/TargetProperties.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/Targets.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/UserAssignedIdentity.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/VaultSecret.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/Watcher.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/WatcherListResult.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/WatcherStatus.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/WatcherUpdate.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/Watchers.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/package-info.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/package-info.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/module-info.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-databasewatcher/proxy-config.json create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-databasewatcher/reflect-config.json create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/AlertRuleResourcesCreateOrUpdateSamples.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/AlertRuleResourcesDeleteSamples.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/AlertRuleResourcesGetSamples.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/AlertRuleResourcesListByParentSamples.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/OperationsListSamples.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/SharedPrivateLinkResourcesCreateSamples.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/SharedPrivateLinkResourcesDeleteSamples.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/SharedPrivateLinkResourcesGetSamples.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/SharedPrivateLinkResourcesListByWatcherSamples.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/TargetsCreateOrUpdateSamples.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/TargetsDeleteSamples.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/TargetsGetSamples.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/TargetsListByWatcherSamples.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/WatchersCreateOrUpdateSamples.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/WatchersDeleteSamples.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/WatchersGetByResourceGroupSamples.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/WatchersListByResourceGroupSamples.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/WatchersListSamples.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/WatchersStartSamples.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/WatchersStopSamples.java create mode 100644 sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/WatchersUpdateSamples.java create mode 100644 sdk/databasewatcher/ci.yml create mode 100644 sdk/databasewatcher/pom.xml diff --git a/eng/versioning/version_client.txt b/eng/versioning/version_client.txt index 47471925fdd86..489321dccdd71 100644 --- a/eng/versioning/version_client.txt +++ b/eng/versioning/version_client.txt @@ -466,6 +466,7 @@ com.azure.resourcemanager:azure-resourcemanager-oracledatabase;1.0.0;1.1.0-beta. com.azure.resourcemanager:azure-resourcemanager-informaticadatamanagement;1.0.0;1.1.0-beta.1 com.azure.resourcemanager:azure-resourcemanager-mongocluster;1.0.0-beta.1;1.0.0-beta.2 com.azure.resourcemanager:azure-resourcemanager-computefleet;1.0.0-beta.2;1.0.0-beta.3 +com.azure.resourcemanager:azure-resourcemanager-databasewatcher;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/pom.xml b/pom.xml index bab1932942a3a..6c5d1f0c2bc08 100644 --- a/pom.xml +++ b/pom.xml @@ -58,6 +58,7 @@ sdk/costmanagement sdk/customerinsights sdk/dashboard + sdk/databasewatcher sdk/databox sdk/databoxedge sdk/databricks diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/CHANGELOG.md b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/CHANGELOG.md new file mode 100644 index 0000000000000..e15baa4cc4565 --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/CHANGELOG.md @@ -0,0 +1,8 @@ +# Release History + +## 1.0.0-beta.1 (2024-07-29) + +- Azure Resource Manager databasewatcher client library for Java. This package contains Microsoft Azure SDK for databasewatcher Management SDK. Package tag package-2024-07-19-preview. 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-databasewatcher Java SDK. diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/README.md b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/README.md new file mode 100644 index 0000000000000..ef5a9f4c7d644 --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/README.md @@ -0,0 +1,104 @@ +# Azure Resource Manager databasewatcher client library for Java + +Azure Resource Manager databasewatcher client library for Java. + +This package contains Microsoft Azure SDK for databasewatcher Management SDK. Package tag package-2024-07-19-preview. For documentation on how to use this package, please see [Azure Management Libraries for Java](https://aka.ms/azsdk/java/mgmt). + +## We'd love to hear your feedback + +We're always working on improving our products and the way we communicate with our users. So we'd love to learn what's working and how we can do better. + +If you haven't already, please take a few minutes to [complete this short survey][survey] we have put together. + +Thank you in advance for your collaboration. We really appreciate your time! + +## Documentation + +Various documentation is available to help you get started + +- [API reference documentation][docs] + +## Getting started + +### Prerequisites + +- [Java Development Kit (JDK)][jdk] with version 8 or above +- [Azure Subscription][azure_subscription] + +### Adding the package to your product + +[//]: # ({x-version-update-start;com.azure.resourcemanager:azure-resourcemanager-databasewatcher;current}) +```xml + + com.azure.resourcemanager + azure-resourcemanager-databasewatcher + 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(); +DatabasewatcherManager manager = DatabasewatcherManager + .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/databasewatcher/azure-resourcemanager-databasewatcher/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%2Fdatabasewatcher%2Fazure-resourcemanager-databasewatcher%2FREADME.png) diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/SAMPLE.md b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/SAMPLE.md new file mode 100644 index 0000000000000..ae0b2440a2517 --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/SAMPLE.md @@ -0,0 +1,669 @@ +# Code snippets and samples + + +## AlertRuleResources + +- [CreateOrUpdate](#alertruleresources_createorupdate) +- [Delete](#alertruleresources_delete) +- [Get](#alertruleresources_get) +- [ListByParent](#alertruleresources_listbyparent) + +## Operations + +- [List](#operations_list) + +## SharedPrivateLinkResources + +- [Create](#sharedprivatelinkresources_create) +- [Delete](#sharedprivatelinkresources_delete) +- [Get](#sharedprivatelinkresources_get) +- [ListByWatcher](#sharedprivatelinkresources_listbywatcher) + +## Targets + +- [CreateOrUpdate](#targets_createorupdate) +- [Delete](#targets_delete) +- [Get](#targets_get) +- [ListByWatcher](#targets_listbywatcher) + +## Watchers + +- [CreateOrUpdate](#watchers_createorupdate) +- [Delete](#watchers_delete) +- [GetByResourceGroup](#watchers_getbyresourcegroup) +- [List](#watchers_list) +- [ListByResourceGroup](#watchers_listbyresourcegroup) +- [Start](#watchers_start) +- [Stop](#watchers_stop) +- [Update](#watchers_update) +### AlertRuleResources_CreateOrUpdate + +```java +import com.azure.resourcemanager.databasewatcher.models.AlertRuleCreationProperties; +import java.time.OffsetDateTime; + +/** + * Samples for AlertRuleResources CreateOrUpdate. + */ +public final class AlertRuleResourcesCreateOrUpdateSamples { + /* + * x-ms-original-file: + * specification/databasewatcher/resource-manager/Microsoft.DatabaseWatcher/preview/2024-07-19-preview/examples/ + * AlertRuleResources_CreateOrUpdate_MaximumSet_Gen.json + */ + /** + * Sample code: AlertRuleResources_CreateOrUpdate - generated by [MaximumSet] rule. + * + * @param manager Entry point to DatabasewatcherManager. + */ + public static void alertRuleResourcesCreateOrUpdateGeneratedByMaximumSetRule( + com.azure.resourcemanager.databasewatcher.DatabasewatcherManager manager) { + manager.alertRuleResources() + .define("testAlert") + .withExistingWatcher("rgWatcher", "testWatcher") + .withAlertRuleResourceId( + "/subscriptions/469DD77C-C8DB-47B7-B9E1-72D29F8C878Be/resourceGroups/rgWatcher/providers/microsoft.insights/scheduledqueryrules/alerts-demo") + .withCreatedWithProperties(AlertRuleCreationProperties.CREATED_WITH_ACTION_GROUP) + .withCreationTime(OffsetDateTime.parse("2024-07-25T15:38:47.798Z")) + .withAlertRuleTemplateId("someTemplateId") + .withAlertRuleTemplateVersion("1.0") + .create(); + } +} +``` + +### AlertRuleResources_Delete + +```java +/** + * Samples for AlertRuleResources Delete. + */ +public final class AlertRuleResourcesDeleteSamples { + /* + * x-ms-original-file: + * specification/databasewatcher/resource-manager/Microsoft.DatabaseWatcher/preview/2024-07-19-preview/examples/ + * AlertRuleResources_Delete_MaximumSet_Gen.json + */ + /** + * Sample code: AlertRuleResources_Delete - generated by [MaximumSet] rule. + * + * @param manager Entry point to DatabasewatcherManager. + */ + public static void alertRuleResourcesDeleteGeneratedByMaximumSetRule( + com.azure.resourcemanager.databasewatcher.DatabasewatcherManager manager) { + manager.alertRuleResources() + .deleteWithResponse("rgWatcher", "testWatcher", "testAlert", com.azure.core.util.Context.NONE); + } +} +``` + +### AlertRuleResources_Get + +```java +/** + * Samples for AlertRuleResources Get. + */ +public final class AlertRuleResourcesGetSamples { + /* + * x-ms-original-file: + * specification/databasewatcher/resource-manager/Microsoft.DatabaseWatcher/preview/2024-07-19-preview/examples/ + * AlertRuleResources_Get_MaximumSet_Gen.json + */ + /** + * Sample code: AlertRuleResources_Get - generated by [MaximumSet] rule. + * + * @param manager Entry point to DatabasewatcherManager. + */ + public static void alertRuleResourcesGetGeneratedByMaximumSetRule( + com.azure.resourcemanager.databasewatcher.DatabasewatcherManager manager) { + manager.alertRuleResources() + .getWithResponse("rgWatcher", "testWatcher", "testAlert", com.azure.core.util.Context.NONE); + } +} +``` + +### AlertRuleResources_ListByParent + +```java +/** + * Samples for AlertRuleResources ListByParent. + */ +public final class AlertRuleResourcesListByParentSamples { + /* + * x-ms-original-file: + * specification/databasewatcher/resource-manager/Microsoft.DatabaseWatcher/preview/2024-07-19-preview/examples/ + * AlertRuleResources_ListByParent_MaximumSet_Gen.json + */ + /** + * Sample code: AlertRuleResources_ListByParent. + * + * @param manager Entry point to DatabasewatcherManager. + */ + public static void + alertRuleResourcesListByParent(com.azure.resourcemanager.databasewatcher.DatabasewatcherManager manager) { + manager.alertRuleResources().listByParent("rgWatcher", "testWatcher", com.azure.core.util.Context.NONE); + } +} +``` + +### Operations_List + +```java +/** + * Samples for Operations List. + */ +public final class OperationsListSamples { + /* + * x-ms-original-file: + * specification/databasewatcher/resource-manager/Microsoft.DatabaseWatcher/preview/2024-07-19-preview/examples/ + * Operations_List_MaximumSet_Gen.json + */ + /** + * Sample code: Operations_List - generated by [MaximumSet] rule. + * + * @param manager Entry point to DatabasewatcherManager. + */ + public static void operationsListGeneratedByMaximumSetRule( + com.azure.resourcemanager.databasewatcher.DatabasewatcherManager manager) { + manager.operations().list(com.azure.core.util.Context.NONE); + } + + /* + * x-ms-original-file: + * specification/databasewatcher/resource-manager/Microsoft.DatabaseWatcher/preview/2024-07-19-preview/examples/ + * Operations_List_MinimumSet_Gen.json + */ + /** + * Sample code: Operations_List - generated by [MinimumSet] rule. + * + * @param manager Entry point to DatabasewatcherManager. + */ + public static void operationsListGeneratedByMinimumSetRule( + com.azure.resourcemanager.databasewatcher.DatabasewatcherManager manager) { + manager.operations().list(com.azure.core.util.Context.NONE); + } +} +``` + +### SharedPrivateLinkResources_Create + +```java +/** + * Samples for SharedPrivateLinkResources Create. + */ +public final class SharedPrivateLinkResourcesCreateSamples { + /* + * x-ms-original-file: + * specification/databasewatcher/resource-manager/Microsoft.DatabaseWatcher/preview/2024-07-19-preview/examples/ + * SharedPrivateLinkResources_Create_MaximumSet_Gen.json + */ + /** + * Sample code: SharedPrivateLinkResources_Create - generated by [MaximumSet] rule. + * + * @param manager Entry point to DatabasewatcherManager. + */ + public static void sharedPrivateLinkResourcesCreateGeneratedByMaximumSetRule( + com.azure.resourcemanager.databasewatcher.DatabasewatcherManager manager) { + manager.sharedPrivateLinkResources() + .define("monitoringh22eed") + .withExistingWatcher("apiTest-ddat4p", "databasemo3ej9ih") + .withPrivateLinkResourceId( + "/subscriptions/6f53185c-ea09-4fc3-9075-318dec805303/resourceGroups/apiTest-ddat4p/providers/Microsoft.KeyVault/vaults/kvmo3ej9ih") + .withGroupId("vault") + .withRequestMessage("request message") + .withDnsZone("ec3ae9d410ba") + .create(); + } +} +``` + +### SharedPrivateLinkResources_Delete + +```java +/** + * Samples for SharedPrivateLinkResources Delete. + */ +public final class SharedPrivateLinkResourcesDeleteSamples { + /* + * x-ms-original-file: + * specification/databasewatcher/resource-manager/Microsoft.DatabaseWatcher/preview/2024-07-19-preview/examples/ + * SharedPrivateLinkResources_Delete_MaximumSet_Gen.json + */ + /** + * Sample code: SharedPrivateLinkResources_Delete - generated by [MaximumSet] rule. + * + * @param manager Entry point to DatabasewatcherManager. + */ + public static void sharedPrivateLinkResourcesDeleteGeneratedByMaximumSetRule( + com.azure.resourcemanager.databasewatcher.DatabasewatcherManager manager) { + manager.sharedPrivateLinkResources() + .delete("apiTest-ddat4p", "databasemo3ej9ih", "monitoringh22eed", com.azure.core.util.Context.NONE); + } +} +``` + +### SharedPrivateLinkResources_Get + +```java +/** + * Samples for SharedPrivateLinkResources Get. + */ +public final class SharedPrivateLinkResourcesGetSamples { + /* + * x-ms-original-file: + * specification/databasewatcher/resource-manager/Microsoft.DatabaseWatcher/preview/2024-07-19-preview/examples/ + * SharedPrivateLinkResources_Get_MaximumSet_Gen.json + */ + /** + * Sample code: SharedPrivateLinkResources_Get - generated by [MaximumSet] rule. + * + * @param manager Entry point to DatabasewatcherManager. + */ + public static void sharedPrivateLinkResourcesGetGeneratedByMaximumSetRule( + com.azure.resourcemanager.databasewatcher.DatabasewatcherManager manager) { + manager.sharedPrivateLinkResources() + .getWithResponse("apiTest-ddat4p", "databasemo3ej9ih", "monitoringh22eed", + com.azure.core.util.Context.NONE); + } +} +``` + +### SharedPrivateLinkResources_ListByWatcher + +```java +/** + * Samples for SharedPrivateLinkResources ListByWatcher. + */ +public final class SharedPrivateLinkResourcesListByWatcherSamples { + /* + * x-ms-original-file: + * specification/databasewatcher/resource-manager/Microsoft.DatabaseWatcher/preview/2024-07-19-preview/examples/ + * SharedPrivateLinkResources_ListByWatcher_MaximumSet_Gen.json + */ + /** + * Sample code: SharedPrivateLinkResources_ListByWatcher - generated by [MaximumSet] rule. + * + * @param manager Entry point to DatabasewatcherManager. + */ + public static void sharedPrivateLinkResourcesListByWatcherGeneratedByMaximumSetRule( + com.azure.resourcemanager.databasewatcher.DatabasewatcherManager manager) { + manager.sharedPrivateLinkResources() + .listByWatcher("apiTest-ddat4p", "databasemo3ej9ih", com.azure.core.util.Context.NONE); + } +} +``` + +### Targets_CreateOrUpdate + +```java +import com.azure.resourcemanager.databasewatcher.models.SqlDbSingleDatabaseTargetProperties; +import com.azure.resourcemanager.databasewatcher.models.TargetAuthenticationType; + +/** + * Samples for Targets CreateOrUpdate. + */ +public final class TargetsCreateOrUpdateSamples { + /* + * x-ms-original-file: + * specification/databasewatcher/resource-manager/Microsoft.DatabaseWatcher/preview/2024-07-19-preview/examples/ + * Targets_CreateOrUpdate_MaximumSet_Gen.json + */ + /** + * Sample code: Targets_CreateOrUpdate - generated by [MaximumSet] rule. + * + * @param manager Entry point to DatabasewatcherManager. + */ + public static void targetsCreateOrUpdateGeneratedByMaximumSetRule( + com.azure.resourcemanager.databasewatcher.DatabasewatcherManager manager) { + manager.targets() + .define("monitoringh22eed") + .withExistingWatcher("apiTest-ddat4p", "databasemo3ej9ih") + .withProperties(new SqlDbSingleDatabaseTargetProperties() + .withTargetAuthenticationType(TargetAuthenticationType.AAD) + .withConnectionServerName("sqlServero1ihe2") + .withSqlDbResourceId( + "/subscriptions/6f53185c-ea09-4fc3-9075-318dec805303/resourceGroups/apiTest-ddat4p/providers/Microsoft.Sql/servers/m1/databases/m2")) + .create(); + } +} +``` + +### Targets_Delete + +```java +/** + * Samples for Targets Delete. + */ +public final class TargetsDeleteSamples { + /* + * x-ms-original-file: + * specification/databasewatcher/resource-manager/Microsoft.DatabaseWatcher/preview/2024-07-19-preview/examples/ + * Targets_Delete_MaximumSet_Gen.json + */ + /** + * Sample code: Targets_Delete - generated by [MaximumSet] rule. + * + * @param manager Entry point to DatabasewatcherManager. + */ + public static void targetsDeleteGeneratedByMaximumSetRule( + com.azure.resourcemanager.databasewatcher.DatabasewatcherManager manager) { + manager.targets() + .deleteWithResponse("apiTest-ddat4p", "databasemo3ej9ih", "monitoringh22eed", + com.azure.core.util.Context.NONE); + } +} +``` + +### Targets_Get + +```java +/** + * Samples for Targets Get. + */ +public final class TargetsGetSamples { + /* + * x-ms-original-file: + * specification/databasewatcher/resource-manager/Microsoft.DatabaseWatcher/preview/2024-07-19-preview/examples/ + * Targets_Get_MaximumSet_Gen.json + */ + /** + * Sample code: Targets_Get - generated by [MaximumSet] rule. + * + * @param manager Entry point to DatabasewatcherManager. + */ + public static void + targetsGetGeneratedByMaximumSetRule(com.azure.resourcemanager.databasewatcher.DatabasewatcherManager manager) { + manager.targets() + .getWithResponse("apiTest-ddat4p", "databasemo3ej9ih", "monitoringh22eed", + com.azure.core.util.Context.NONE); + } +} +``` + +### Targets_ListByWatcher + +```java +/** + * Samples for Targets ListByWatcher. + */ +public final class TargetsListByWatcherSamples { + /* + * x-ms-original-file: + * specification/databasewatcher/resource-manager/Microsoft.DatabaseWatcher/preview/2024-07-19-preview/examples/ + * Targets_ListByWatcher_MaximumSet_Gen.json + */ + /** + * Sample code: Targets_ListByWatcher - generated by [MaximumSet] rule. + * + * @param manager Entry point to DatabasewatcherManager. + */ + public static void targetsListByWatcherGeneratedByMaximumSetRule( + com.azure.resourcemanager.databasewatcher.DatabasewatcherManager manager) { + manager.targets().listByWatcher("apiTest-ddat4p", "databasemo3ej9ih", com.azure.core.util.Context.NONE); + } +} +``` + +### Watchers_CreateOrUpdate + +```java +import com.azure.resourcemanager.databasewatcher.models.Datastore; +import com.azure.resourcemanager.databasewatcher.models.KustoOfferingType; +import com.azure.resourcemanager.databasewatcher.models.ManagedServiceIdentity; +import com.azure.resourcemanager.databasewatcher.models.ManagedServiceIdentityType; +import java.util.HashMap; +import java.util.Map; + +/** + * Samples for Watchers CreateOrUpdate. + */ +public final class WatchersCreateOrUpdateSamples { + /* + * x-ms-original-file: + * specification/databasewatcher/resource-manager/Microsoft.DatabaseWatcher/preview/2024-07-19-preview/examples/ + * Watchers_CreateOrUpdate_MaximumSet_Gen.json + */ + /** + * Sample code: Watchers_CreateOrUpdate - generated by [MaximumSet] rule. + * + * @param manager Entry point to DatabasewatcherManager. + */ + public static void watchersCreateOrUpdateGeneratedByMaximumSetRule( + com.azure.resourcemanager.databasewatcher.DatabasewatcherManager manager) { + manager.watchers() + .define("testWatcher") + .withRegion("eastus2euap") + .withExistingResourceGroup("rgWatcher") + .withTags(mapOf()) + .withIdentity(new ManagedServiceIdentity().withType(ManagedServiceIdentityType.SYSTEM_ASSIGNED)) + .withDatastore(new Datastore().withAdxClusterResourceId( + "/subscriptions/6f53185c-ea09-4fc3-9075-318dec805303/resourceGroups/apiTest/providers/Microsoft.Kusto/clusters/apiTestKusto") + .withKustoClusterDisplayName("kustoUri-adx") + .withKustoClusterUri("https://kustouri-adx.eastus.kusto.windows.net") + .withKustoDataIngestionUri("https://ingest-kustouri-adx.eastus.kusto.windows.net") + .withKustoDatabaseName("kustoDatabaseName1") + .withKustoManagementUrl("https://portal.azure.com/") + .withKustoOfferingType(KustoOfferingType.ADX)) + .withDefaultAlertRuleIdentityResourceId( + "/subscriptions/469DD77C-C8DB-47B7-B9E1-72D29F8C878B/resourceGroups/rgWatcher/providers/Microsoft.ManagedIdentity/userAssignedIdentities/3pmtest") + .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; + } +} +``` + +### Watchers_Delete + +```java +/** + * Samples for Watchers Delete. + */ +public final class WatchersDeleteSamples { + /* + * x-ms-original-file: + * specification/databasewatcher/resource-manager/Microsoft.DatabaseWatcher/preview/2024-07-19-preview/examples/ + * Watchers_Delete_MaximumSet_Gen.json + */ + /** + * Sample code: Watchers_Delete - generated by [MaximumSet] rule - generated by [MaximumSet] rule. + * + * @param manager Entry point to DatabasewatcherManager. + */ + public static void watchersDeleteGeneratedByMaximumSetRuleGeneratedByMaximumSetRule( + com.azure.resourcemanager.databasewatcher.DatabasewatcherManager manager) { + manager.watchers().delete("rgWatcher", "testWatcher", com.azure.core.util.Context.NONE); + } +} +``` + +### Watchers_GetByResourceGroup + +```java +/** + * Samples for Watchers GetByResourceGroup. + */ +public final class WatchersGetByResourceGroupSamples { + /* + * x-ms-original-file: + * specification/databasewatcher/resource-manager/Microsoft.DatabaseWatcher/preview/2024-07-19-preview/examples/ + * Watchers_Get_MaximumSet_Gen.json + */ + /** + * Sample code: Watchers_Get - generated by [MaximumSet] rule. + * + * @param manager Entry point to DatabasewatcherManager. + */ + public static void + watchersGetGeneratedByMaximumSetRule(com.azure.resourcemanager.databasewatcher.DatabasewatcherManager manager) { + manager.watchers().getByResourceGroupWithResponse("rgWatcher", "myWatcher", com.azure.core.util.Context.NONE); + } +} +``` + +### Watchers_List + +```java +/** + * Samples for Watchers List. + */ +public final class WatchersListSamples { + /* + * x-ms-original-file: + * specification/databasewatcher/resource-manager/Microsoft.DatabaseWatcher/preview/2024-07-19-preview/examples/ + * Watchers_ListBySubscription_MaximumSet_Gen.json + */ + /** + * Sample code: Watchers_ListBySubscription - generated by [MaximumSet] rule - generated by [MaximumSet] rule. + * + * @param manager Entry point to DatabasewatcherManager. + */ + public static void watchersListBySubscriptionGeneratedByMaximumSetRuleGeneratedByMaximumSetRule( + com.azure.resourcemanager.databasewatcher.DatabasewatcherManager manager) { + manager.watchers().list(com.azure.core.util.Context.NONE); + } +} +``` + +### Watchers_ListByResourceGroup + +```java +/** + * Samples for Watchers ListByResourceGroup. + */ +public final class WatchersListByResourceGroupSamples { + /* + * x-ms-original-file: + * specification/databasewatcher/resource-manager/Microsoft.DatabaseWatcher/preview/2024-07-19-preview/examples/ + * Watchers_ListByResourceGroup_MaximumSet_Gen.json + */ + /** + * Sample code: Watchers_ListByResourceGroup - generated by [MaximumSet] rule - generated by [MaximumSet] rule. + * + * @param manager Entry point to DatabasewatcherManager. + */ + public static void watchersListByResourceGroupGeneratedByMaximumSetRuleGeneratedByMaximumSetRule( + com.azure.resourcemanager.databasewatcher.DatabasewatcherManager manager) { + manager.watchers().listByResourceGroup("rgWatcher", com.azure.core.util.Context.NONE); + } +} +``` + +### Watchers_Start + +```java +/** + * Samples for Watchers Start. + */ +public final class WatchersStartSamples { + /* + * x-ms-original-file: + * specification/databasewatcher/resource-manager/Microsoft.DatabaseWatcher/preview/2024-07-19-preview/examples/ + * Watchers_Start_MaximumSet_Gen.json + */ + /** + * Sample code: Watchers_Start - generated by [MaximumSet] rule - generated by [MaximumSet] rule. + * + * @param manager Entry point to DatabasewatcherManager. + */ + public static void watchersStartGeneratedByMaximumSetRuleGeneratedByMaximumSetRule( + com.azure.resourcemanager.databasewatcher.DatabasewatcherManager manager) { + manager.watchers().start("rgWatcher", "testWatcher", com.azure.core.util.Context.NONE); + } +} +``` + +### Watchers_Stop + +```java +/** + * Samples for Watchers Stop. + */ +public final class WatchersStopSamples { + /* + * x-ms-original-file: + * specification/databasewatcher/resource-manager/Microsoft.DatabaseWatcher/preview/2024-07-19-preview/examples/ + * Watchers_Stop_MaximumSet_Gen.json + */ + /** + * Sample code: Watchers_Stop - generated by [MaximumSet] rule - generated by [MaximumSet] rule. + * + * @param manager Entry point to DatabasewatcherManager. + */ + public static void watchersStopGeneratedByMaximumSetRuleGeneratedByMaximumSetRule( + com.azure.resourcemanager.databasewatcher.DatabasewatcherManager manager) { + manager.watchers().stop("rgWatcher", "myWatcher", com.azure.core.util.Context.NONE); + } +} +``` + +### Watchers_Update + +```java +import com.azure.resourcemanager.databasewatcher.models.DatastoreUpdate; +import com.azure.resourcemanager.databasewatcher.models.KustoOfferingType; +import com.azure.resourcemanager.databasewatcher.models.ManagedServiceIdentity; +import com.azure.resourcemanager.databasewatcher.models.ManagedServiceIdentityType; +import com.azure.resourcemanager.databasewatcher.models.Watcher; +import java.util.HashMap; +import java.util.Map; + +/** + * Samples for Watchers Update. + */ +public final class WatchersUpdateSamples { + /* + * x-ms-original-file: + * specification/databasewatcher/resource-manager/Microsoft.DatabaseWatcher/preview/2024-07-19-preview/examples/ + * Watchers_Update_MaximumSet_Gen.json + */ + /** + * Sample code: Watchers_Update - generated by [MaximumSet] rule - generated by [MaximumSet] rule. + * + * @param manager Entry point to DatabasewatcherManager. + */ + public static void watchersUpdateGeneratedByMaximumSetRuleGeneratedByMaximumSetRule( + com.azure.resourcemanager.databasewatcher.DatabasewatcherManager manager) { + Watcher resource = manager.watchers() + .getByResourceGroupWithResponse("rgWatcher", "testWatcher", com.azure.core.util.Context.NONE) + .getValue(); + resource.update() + .withTags(mapOf()) + .withIdentity(new ManagedServiceIdentity().withType(ManagedServiceIdentityType.SYSTEM_ASSIGNED)) + .withDatastore(new DatastoreUpdate().withAdxClusterResourceId( + "/subscriptions/6f53185c-ea09-4fc3-9075-318dec805303/resourceGroups/apiTest/providers/Microsoft.Kusto/clusters/apiTestKusto") + .withKustoClusterDisplayName("kustoUri-adx") + .withKustoClusterUri("https://kustouri-adx.eastus.kusto.windows.net") + .withKustoDataIngestionUri("https://ingest-kustouri-adx.eastus.kusto.windows.net") + .withKustoDatabaseName("kustoDatabaseName1") + .withKustoManagementUrl("https://portal.azure.com/") + .withKustoOfferingType(KustoOfferingType.ADX)) + .withDefaultAlertRuleIdentityResourceId( + "/subscriptions/469DD77C-C8DB-47B7-B9E1-72D29F8C878B/resourceGroups/rgWatcher/providers/Microsoft.ManagedIdentity/userAssignedIdentities/newtest") + .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/databasewatcher/azure-resourcemanager-databasewatcher/pom.xml b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/pom.xml new file mode 100644 index 0000000000000..d8f654212a759 --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/pom.xml @@ -0,0 +1,67 @@ + + + 4.0.0 + + com.azure + azure-client-sdk-parent + 1.7.0 + ../../parents/azure-client-sdk-parent + + + com.azure.resourcemanager + azure-resourcemanager-databasewatcher + 1.0.0-beta.1 + jar + + Microsoft Azure SDK for databasewatcher Management + This package contains Microsoft Azure SDK for databasewatcher Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. Package tag package-2024-07-19-preview. + https://github.com/Azure/azure-sdk-for-java + + + + The MIT License (MIT) + http://opensource.org/licenses/MIT + repo + + + + + https://github.com/Azure/azure-sdk-for-java + scm:git:git@github.com:Azure/azure-sdk-for-java.git + scm:git:git@github.com:Azure/azure-sdk-for-java.git + HEAD + + + + microsoft + Microsoft + + + + UTF-8 + 0 + 0 + true + + + + com.azure + azure-json + 1.1.0 + + + com.azure + azure-core + 1.50.0 + + + com.azure + azure-core-management + 1.15.1 + + + diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/DatabasewatcherManager.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/DatabasewatcherManager.java new file mode 100644 index 0000000000000..a5f5957db87e7 --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/DatabasewatcherManager.java @@ -0,0 +1,339 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.databasewatcher; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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.http.policy.ArmChallengeAuthenticationPolicy; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.util.Configuration; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.databasewatcher.fluent.MicrosoftDatabaseWatcher; +import com.azure.resourcemanager.databasewatcher.implementation.AlertRuleResourcesImpl; +import com.azure.resourcemanager.databasewatcher.implementation.MicrosoftDatabaseWatcherBuilder; +import com.azure.resourcemanager.databasewatcher.implementation.OperationsImpl; +import com.azure.resourcemanager.databasewatcher.implementation.SharedPrivateLinkResourcesImpl; +import com.azure.resourcemanager.databasewatcher.implementation.TargetsImpl; +import com.azure.resourcemanager.databasewatcher.implementation.WatchersImpl; +import com.azure.resourcemanager.databasewatcher.models.AlertRuleResources; +import com.azure.resourcemanager.databasewatcher.models.Operations; +import com.azure.resourcemanager.databasewatcher.models.SharedPrivateLinkResources; +import com.azure.resourcemanager.databasewatcher.models.Targets; +import com.azure.resourcemanager.databasewatcher.models.Watchers; +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 DatabasewatcherManager. + */ +public final class DatabasewatcherManager { + private Operations operations; + + private Watchers watchers; + + private AlertRuleResources alertRuleResources; + + private SharedPrivateLinkResources sharedPrivateLinkResources; + + private Targets targets; + + private final MicrosoftDatabaseWatcher clientObject; + + private DatabasewatcherManager(HttpPipeline httpPipeline, AzureProfile profile, Duration defaultPollInterval) { + Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + this.clientObject = new MicrosoftDatabaseWatcherBuilder().pipeline(httpPipeline) + .endpoint(profile.getEnvironment().getResourceManagerEndpoint()) + .subscriptionId(profile.getSubscriptionId()) + .defaultPollInterval(defaultPollInterval) + .buildClient(); + } + + /** + * Creates an instance of databasewatcher service API entry point. + * + * @param credential the credential to use. + * @param profile the Azure profile for client. + * @return the databasewatcher service API instance. + */ + public static DatabasewatcherManager 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 databasewatcher service API entry point. + * + * @param httpPipeline the {@link HttpPipeline} configured with Azure authentication credential. + * @param profile the Azure profile for client. + * @return the databasewatcher service API instance. + */ + public static DatabasewatcherManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) { + Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + return new DatabasewatcherManager(httpPipeline, profile, null); + } + + /** + * Gets a Configurable instance that can be used to create DatabasewatcherManager with optional configuration. + * + * @return the Configurable instance allowing configurations. + */ + public static Configurable configure() { + return new DatabasewatcherManager.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 databasewatcher service API entry point. + * + * @param credential the credential to use. + * @param profile the Azure profile for client. + * @return the databasewatcher service API instance. + */ + public DatabasewatcherManager 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.databasewatcher") + .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 ArmChallengeAuthenticationPolicy(credential, scopes.toArray(new String[0]))); + policies.addAll(this.policies.stream() + .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_RETRY) + .collect(Collectors.toList())); + HttpPolicyProviders.addAfterRetryPolicies(policies); + policies.add(new HttpLoggingPolicy(httpLogOptions)); + HttpPipeline httpPipeline = new HttpPipelineBuilder().httpClient(httpClient) + .policies(policies.toArray(new HttpPipelinePolicy[0])) + .build(); + return new DatabasewatcherManager(httpPipeline, profile, defaultPollInterval); + } + } + + /** + * Gets the resource collection API of Operations. + * + * @return Resource collection API of Operations. + */ + public Operations operations() { + if (this.operations == null) { + this.operations = new OperationsImpl(clientObject.getOperations(), this); + } + return operations; + } + + /** + * Gets the resource collection API of Watchers. It manages Watcher. + * + * @return Resource collection API of Watchers. + */ + public Watchers watchers() { + if (this.watchers == null) { + this.watchers = new WatchersImpl(clientObject.getWatchers(), this); + } + return watchers; + } + + /** + * Gets the resource collection API of AlertRuleResources. It manages AlertRuleResource. + * + * @return Resource collection API of AlertRuleResources. + */ + public AlertRuleResources alertRuleResources() { + if (this.alertRuleResources == null) { + this.alertRuleResources = new AlertRuleResourcesImpl(clientObject.getAlertRuleResources(), this); + } + return alertRuleResources; + } + + /** + * Gets the resource collection API of SharedPrivateLinkResources. It manages SharedPrivateLinkResource. + * + * @return Resource collection API of SharedPrivateLinkResources. + */ + public SharedPrivateLinkResources sharedPrivateLinkResources() { + if (this.sharedPrivateLinkResources == null) { + this.sharedPrivateLinkResources + = new SharedPrivateLinkResourcesImpl(clientObject.getSharedPrivateLinkResources(), this); + } + return sharedPrivateLinkResources; + } + + /** + * Gets the resource collection API of Targets. It manages Target. + * + * @return Resource collection API of Targets. + */ + public Targets targets() { + if (this.targets == null) { + this.targets = new TargetsImpl(clientObject.getTargets(), this); + } + return targets; + } + + /** + * Gets wrapped service client MicrosoftDatabaseWatcher providing direct access to the underlying auto-generated API + * implementation, based on Azure REST API. + * + * @return Wrapped service client MicrosoftDatabaseWatcher. + */ + public MicrosoftDatabaseWatcher serviceClient() { + return this.clientObject; + } +} diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/fluent/AlertRuleResourcesClient.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/fluent/AlertRuleResourcesClient.java new file mode 100644 index 0000000000000..f2e9d46d0bf0d --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/fluent/AlertRuleResourcesClient.java @@ -0,0 +1,137 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.databasewatcher.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.databasewatcher.fluent.models.AlertRuleResourceInner; + +/** + * An instance of this class provides access to all the operations defined in AlertRuleResourcesClient. + */ +public interface AlertRuleResourcesClient { + /** + * List AlertRuleResource resources by Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a AlertRuleResource list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable listByParent(String resourceGroupName, String watcherName); + + /** + * List AlertRuleResource resources by Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a AlertRuleResource list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable listByParent(String resourceGroupName, String watcherName, Context context); + + /** + * Get a AlertRuleResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param alertRuleResourceName The alert rule proxy resource name. + * @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 AlertRuleResource along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response getWithResponse(String resourceGroupName, String watcherName, + String alertRuleResourceName, Context context); + + /** + * Get a AlertRuleResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param alertRuleResourceName The alert rule proxy resource name. + * @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 AlertRuleResource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + AlertRuleResourceInner get(String resourceGroupName, String watcherName, String alertRuleResourceName); + + /** + * Create a AlertRuleResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param alertRuleResourceName The alert rule proxy resource name. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete proxy resource types can be created by aliasing this type using a specific property type along + * with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response createOrUpdateWithResponse(String resourceGroupName, String watcherName, + String alertRuleResourceName, AlertRuleResourceInner resource, Context context); + + /** + * Create a AlertRuleResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param alertRuleResourceName The alert rule proxy resource name. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete proxy resource types can be created by aliasing this type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + AlertRuleResourceInner createOrUpdate(String resourceGroupName, String watcherName, String alertRuleResourceName, + AlertRuleResourceInner resource); + + /** + * Delete a AlertRuleResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param alertRuleResourceName The alert rule proxy resource name. + * @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 watcherName, String alertRuleResourceName, + Context context); + + /** + * Delete a AlertRuleResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param alertRuleResourceName The alert rule proxy resource name. + * @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 watcherName, String alertRuleResourceName); +} diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/fluent/MicrosoftDatabaseWatcher.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/fluent/MicrosoftDatabaseWatcher.java new file mode 100644 index 0000000000000..847fc422d77e8 --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/fluent/MicrosoftDatabaseWatcher.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.databasewatcher.fluent; + +import com.azure.core.http.HttpPipeline; +import java.time.Duration; + +/** + * The interface for MicrosoftDatabaseWatcher class. + */ +public interface MicrosoftDatabaseWatcher { + /** + * Gets The ID of the target subscription. The value must be an UUID. + * + * @return the subscriptionId value. + */ + String getSubscriptionId(); + + /** + * Gets server parameter. + * + * @return the endpoint value. + */ + String getEndpoint(); + + /** + * Gets Api Version. + * + * @return the apiVersion value. + */ + String getApiVersion(); + + /** + * Gets The HTTP pipeline to send requests through. + * + * @return the httpPipeline value. + */ + HttpPipeline getHttpPipeline(); + + /** + * Gets The default poll interval for long-running operation. + * + * @return the defaultPollInterval value. + */ + Duration getDefaultPollInterval(); + + /** + * Gets the OperationsClient object to access its operations. + * + * @return the OperationsClient object. + */ + OperationsClient getOperations(); + + /** + * Gets the WatchersClient object to access its operations. + * + * @return the WatchersClient object. + */ + WatchersClient getWatchers(); + + /** + * Gets the AlertRuleResourcesClient object to access its operations. + * + * @return the AlertRuleResourcesClient object. + */ + AlertRuleResourcesClient getAlertRuleResources(); + + /** + * Gets the SharedPrivateLinkResourcesClient object to access its operations. + * + * @return the SharedPrivateLinkResourcesClient object. + */ + SharedPrivateLinkResourcesClient getSharedPrivateLinkResources(); + + /** + * Gets the TargetsClient object to access its operations. + * + * @return the TargetsClient object. + */ + TargetsClient getTargets(); +} diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/fluent/OperationsClient.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/fluent/OperationsClient.java new file mode 100644 index 0000000000000..c8909ad09c618 --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/fluent/OperationsClient.java @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.databasewatcher.fluent; + +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.util.Context; +import com.azure.resourcemanager.databasewatcher.fluent.models.OperationInner; + +/** + * An instance of this class provides access to all the operations defined in OperationsClient. + */ +public interface OperationsClient { + /** + * List the operations for the provider. + * + * @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 REST API operations supported by an Azure Resource Provider as paginated response with + * {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(); + + /** + * List the operations for the provider. + * + * @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 REST API operations supported by an Azure Resource Provider as paginated response with + * {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(Context context); +} diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/fluent/SharedPrivateLinkResourcesClient.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/fluent/SharedPrivateLinkResourcesClient.java new file mode 100644 index 0000000000000..4671888c1e9f3 --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/fluent/SharedPrivateLinkResourcesClient.java @@ -0,0 +1,208 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.databasewatcher.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.databasewatcher.fluent.models.SharedPrivateLinkResourceInner; + +/** + * An instance of this class provides access to all the operations defined in SharedPrivateLinkResourcesClient. + */ +public interface SharedPrivateLinkResourcesClient { + /** + * List SharedPrivateLinkResource resources by Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a SharedPrivateLinkResource list operation as paginated response with + * {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable listByWatcher(String resourceGroupName, String watcherName); + + /** + * List SharedPrivateLinkResource resources by Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a SharedPrivateLinkResource list operation as paginated response with + * {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable listByWatcher(String resourceGroupName, String watcherName, + Context context); + + /** + * Get a SharedPrivateLinkResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param sharedPrivateLinkResourceName The Shared Private Link resource name. + * @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 SharedPrivateLinkResource along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response getWithResponse(String resourceGroupName, String watcherName, + String sharedPrivateLinkResourceName, Context context); + + /** + * Get a SharedPrivateLinkResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param sharedPrivateLinkResourceName The Shared Private Link resource name. + * @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 SharedPrivateLinkResource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + SharedPrivateLinkResourceInner get(String resourceGroupName, String watcherName, + String sharedPrivateLinkResourceName); + + /** + * Create a SharedPrivateLinkResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param sharedPrivateLinkResourceName The Shared Private Link resource name. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of concrete proxy resource types can be created by aliasing this type + * using a specific property type. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, SharedPrivateLinkResourceInner> beginCreate( + String resourceGroupName, String watcherName, String sharedPrivateLinkResourceName, + SharedPrivateLinkResourceInner resource); + + /** + * Create a SharedPrivateLinkResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param sharedPrivateLinkResourceName The Shared Private Link resource name. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of concrete proxy resource types can be created by aliasing this type + * using a specific property type. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, SharedPrivateLinkResourceInner> beginCreate( + String resourceGroupName, String watcherName, String sharedPrivateLinkResourceName, + SharedPrivateLinkResourceInner resource, Context context); + + /** + * Create a SharedPrivateLinkResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param sharedPrivateLinkResourceName The Shared Private Link resource name. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete proxy resource types can be created by aliasing this type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + SharedPrivateLinkResourceInner create(String resourceGroupName, String watcherName, + String sharedPrivateLinkResourceName, SharedPrivateLinkResourceInner resource); + + /** + * Create a SharedPrivateLinkResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param sharedPrivateLinkResourceName The Shared Private Link resource name. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete proxy resource types can be created by aliasing this type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + SharedPrivateLinkResourceInner create(String resourceGroupName, String watcherName, + String sharedPrivateLinkResourceName, SharedPrivateLinkResourceInner resource, Context context); + + /** + * Delete a SharedPrivateLinkResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param sharedPrivateLinkResourceName The Shared Private Link resource name. + * @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 long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, Void> beginDelete(String resourceGroupName, String watcherName, + String sharedPrivateLinkResourceName); + + /** + * Delete a SharedPrivateLinkResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param sharedPrivateLinkResourceName The Shared Private Link resource name. + * @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 long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, Void> beginDelete(String resourceGroupName, String watcherName, + String sharedPrivateLinkResourceName, Context context); + + /** + * Delete a SharedPrivateLinkResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param sharedPrivateLinkResourceName The Shared Private Link resource name. + * @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 watcherName, String sharedPrivateLinkResourceName); + + /** + * Delete a SharedPrivateLinkResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param sharedPrivateLinkResourceName The Shared Private Link resource name. + * @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. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + void delete(String resourceGroupName, String watcherName, String sharedPrivateLinkResourceName, Context context); +} diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/fluent/TargetsClient.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/fluent/TargetsClient.java new file mode 100644 index 0000000000000..400aa3025561a --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/fluent/TargetsClient.java @@ -0,0 +1,135 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.databasewatcher.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.databasewatcher.fluent.models.TargetInner; + +/** + * An instance of this class provides access to all the operations defined in TargetsClient. + */ +public interface TargetsClient { + /** + * List Target resources by Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Target list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable listByWatcher(String resourceGroupName, String watcherName); + + /** + * List Target resources by Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Target list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable listByWatcher(String resourceGroupName, String watcherName, Context context); + + /** + * Get a Target. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param targetName The target resource name. + * @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 Target along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response getWithResponse(String resourceGroupName, String watcherName, String targetName, + Context context); + + /** + * Get a Target. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param targetName The target resource name. + * @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 Target. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + TargetInner get(String resourceGroupName, String watcherName, String targetName); + + /** + * Create a Target. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param targetName The target resource name. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete proxy resource types can be created by aliasing this type using a specific property type along + * with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response createOrUpdateWithResponse(String resourceGroupName, String watcherName, String targetName, + TargetInner resource, Context context); + + /** + * Create a Target. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param targetName The target resource name. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete proxy resource types can be created by aliasing this type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + TargetInner createOrUpdate(String resourceGroupName, String watcherName, String targetName, TargetInner resource); + + /** + * Delete a Target. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param targetName The target resource name. + * @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 watcherName, String targetName, Context context); + + /** + * Delete a Target. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param targetName The target resource name. + * @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 watcherName, String targetName); +} diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/fluent/WatchersClient.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/fluent/WatchersClient.java new file mode 100644 index 0000000000000..c03211614d0e7 --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/fluent/WatchersClient.java @@ -0,0 +1,377 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.databasewatcher.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.databasewatcher.fluent.models.WatcherInner; +import com.azure.resourcemanager.databasewatcher.models.WatcherUpdate; + +/** + * An instance of this class provides access to all the operations defined in WatchersClient. + */ +public interface WatchersClient { + /** + * List Watcher resources by subscription ID. + * + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Watcher list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(); + + /** + * List Watcher resources by subscription ID. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Watcher list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(Context context); + + /** + * List Watcher resources by 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 the response of a Watcher list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable listByResourceGroup(String resourceGroupName); + + /** + * List Watcher resources by 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 the response of a Watcher list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable listByResourceGroup(String resourceGroupName, Context context); + + /** + * Get a Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @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 Watcher along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response getByResourceGroupWithResponse(String resourceGroupName, String watcherName, + Context context); + + /** + * Get a Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @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 Watcher. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + WatcherInner getByResourceGroup(String resourceGroupName, String watcherName); + + /** + * Create a Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of the DatabaseWatcherProviderHub resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, WatcherInner> beginCreateOrUpdate(String resourceGroupName, String watcherName, + WatcherInner resource); + + /** + * Create a Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of the DatabaseWatcherProviderHub resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, WatcherInner> beginCreateOrUpdate(String resourceGroupName, String watcherName, + WatcherInner resource, Context context); + + /** + * Create a Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the DatabaseWatcherProviderHub resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + WatcherInner createOrUpdate(String resourceGroupName, String watcherName, WatcherInner resource); + + /** + * Create a Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the DatabaseWatcherProviderHub resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + WatcherInner createOrUpdate(String resourceGroupName, String watcherName, WatcherInner resource, Context context); + + /** + * Update a Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param properties The resource properties to be updated. + * @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 DatabaseWatcherProviderHub resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, WatcherInner> beginUpdate(String resourceGroupName, String watcherName, + WatcherUpdate properties); + + /** + * Update a Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param properties The resource properties to be updated. + * @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 DatabaseWatcherProviderHub resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, WatcherInner> beginUpdate(String resourceGroupName, String watcherName, + WatcherUpdate properties, Context context); + + /** + * Update a Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param properties The resource properties to be updated. + * @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 DatabaseWatcherProviderHub resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + WatcherInner update(String resourceGroupName, String watcherName, WatcherUpdate properties); + + /** + * Update a Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param properties The resource properties to be updated. + * @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 DatabaseWatcherProviderHub resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + WatcherInner update(String resourceGroupName, String watcherName, WatcherUpdate properties, Context context); + + /** + * Delete a Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @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 long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, Void> beginDelete(String resourceGroupName, String watcherName); + + /** + * Delete a Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @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 long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, Void> beginDelete(String resourceGroupName, String watcherName, Context context); + + /** + * Delete a Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @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 watcherName); + + /** + * Delete a Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @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. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + void delete(String resourceGroupName, String watcherName, Context context); + + /** + * The action to start monitoring all targets configured for a database watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @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 DatabaseWatcherProviderHub resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, WatcherInner> beginStart(String resourceGroupName, String watcherName); + + /** + * The action to start monitoring all targets configured for a database watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @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 DatabaseWatcherProviderHub resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, WatcherInner> beginStart(String resourceGroupName, String watcherName, + Context context); + + /** + * The action to start monitoring all targets configured for a database watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @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 DatabaseWatcherProviderHub resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + WatcherInner start(String resourceGroupName, String watcherName); + + /** + * The action to start monitoring all targets configured for a database watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @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 DatabaseWatcherProviderHub resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + WatcherInner start(String resourceGroupName, String watcherName, Context context); + + /** + * The action to stop monitoring all targets configured for a database watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @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 DatabaseWatcherProviderHub resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, WatcherInner> beginStop(String resourceGroupName, String watcherName); + + /** + * The action to stop monitoring all targets configured for a database watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @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 DatabaseWatcherProviderHub resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, WatcherInner> beginStop(String resourceGroupName, String watcherName, + Context context); + + /** + * The action to stop monitoring all targets configured for a database watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @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 DatabaseWatcherProviderHub resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + WatcherInner stop(String resourceGroupName, String watcherName); + + /** + * The action to stop monitoring all targets configured for a database watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @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 DatabaseWatcherProviderHub resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + WatcherInner stop(String resourceGroupName, String watcherName, Context context); +} diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/fluent/models/AlertRuleResourceInner.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/fluent/models/AlertRuleResourceInner.java new file mode 100644 index 0000000000000..0ba06a670a9ad --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/fluent/models/AlertRuleResourceInner.java @@ -0,0 +1,281 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.databasewatcher.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.management.ProxyResource; +import com.azure.core.management.SystemData; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.azure.resourcemanager.databasewatcher.models.AlertRuleCreationProperties; +import com.azure.resourcemanager.databasewatcher.models.ResourceProvisioningState; +import java.io.IOException; +import java.time.OffsetDateTime; + +/** + * Concrete proxy resource types can be created by aliasing this type using a specific property type. + */ +@Fluent +public final class AlertRuleResourceInner extends ProxyResource { + /* + * The resource-specific properties for this resource. + */ + private AlertRuleResourceProperties innerProperties; + + /* + * Azure Resource Manager metadata containing createdBy and modifiedBy information. + */ + private SystemData systemData; + + /* + * Fully qualified resource Id for the resource. + */ + private String id; + + /* + * The name of the resource. + */ + private String name; + + /* + * The type of the resource. + */ + private String type; + + /** + * Creates an instance of AlertRuleResourceInner class. + */ + public AlertRuleResourceInner() { + } + + /** + * Get the innerProperties property: The resource-specific properties for this resource. + * + * @return the innerProperties value. + */ + private AlertRuleResourceProperties innerProperties() { + return this.innerProperties; + } + + /** + * Get the systemData property: Azure Resource Manager metadata containing createdBy and modifiedBy information. + * + * @return the systemData value. + */ + public SystemData systemData() { + return this.systemData; + } + + /** + * Get the id property: Fully qualified resource Id for the resource. + * + * @return the id value. + */ + @Override + public String id() { + return this.id; + } + + /** + * Get the name property: The name of the resource. + * + * @return the name value. + */ + @Override + public String name() { + return this.name; + } + + /** + * Get the type property: The type of the resource. + * + * @return the type value. + */ + @Override + public String type() { + return this.type; + } + + /** + * Get the alertRuleResourceId property: The resource ID of the alert rule resource. + * + * @return the alertRuleResourceId value. + */ + public String alertRuleResourceId() { + return this.innerProperties() == null ? null : this.innerProperties().alertRuleResourceId(); + } + + /** + * Set the alertRuleResourceId property: The resource ID of the alert rule resource. + * + * @param alertRuleResourceId the alertRuleResourceId value to set. + * @return the AlertRuleResourceInner object itself. + */ + public AlertRuleResourceInner withAlertRuleResourceId(String alertRuleResourceId) { + if (this.innerProperties() == null) { + this.innerProperties = new AlertRuleResourceProperties(); + } + this.innerProperties().withAlertRuleResourceId(alertRuleResourceId); + return this; + } + + /** + * Get the createdWithProperties property: The properties with which the alert rule resource was created. + * + * @return the createdWithProperties value. + */ + public AlertRuleCreationProperties createdWithProperties() { + return this.innerProperties() == null ? null : this.innerProperties().createdWithProperties(); + } + + /** + * Set the createdWithProperties property: The properties with which the alert rule resource was created. + * + * @param createdWithProperties the createdWithProperties value to set. + * @return the AlertRuleResourceInner object itself. + */ + public AlertRuleResourceInner withCreatedWithProperties(AlertRuleCreationProperties createdWithProperties) { + if (this.innerProperties() == null) { + this.innerProperties = new AlertRuleResourceProperties(); + } + this.innerProperties().withCreatedWithProperties(createdWithProperties); + return this; + } + + /** + * Get the creationTime property: The creation time of the alert rule resource. + * + * @return the creationTime value. + */ + public OffsetDateTime creationTime() { + return this.innerProperties() == null ? null : this.innerProperties().creationTime(); + } + + /** + * Set the creationTime property: The creation time of the alert rule resource. + * + * @param creationTime the creationTime value to set. + * @return the AlertRuleResourceInner object itself. + */ + public AlertRuleResourceInner withCreationTime(OffsetDateTime creationTime) { + if (this.innerProperties() == null) { + this.innerProperties = new AlertRuleResourceProperties(); + } + this.innerProperties().withCreationTime(creationTime); + return this; + } + + /** + * Get the provisioningState property: The provisioning state of the alert rule resource. + * + * @return the provisioningState value. + */ + public ResourceProvisioningState provisioningState() { + return this.innerProperties() == null ? null : this.innerProperties().provisioningState(); + } + + /** + * Get the alertRuleTemplateId property: The template ID associated with alert rule resource. + * + * @return the alertRuleTemplateId value. + */ + public String alertRuleTemplateId() { + return this.innerProperties() == null ? null : this.innerProperties().alertRuleTemplateId(); + } + + /** + * Set the alertRuleTemplateId property: The template ID associated with alert rule resource. + * + * @param alertRuleTemplateId the alertRuleTemplateId value to set. + * @return the AlertRuleResourceInner object itself. + */ + public AlertRuleResourceInner withAlertRuleTemplateId(String alertRuleTemplateId) { + if (this.innerProperties() == null) { + this.innerProperties = new AlertRuleResourceProperties(); + } + this.innerProperties().withAlertRuleTemplateId(alertRuleTemplateId); + return this; + } + + /** + * Get the alertRuleTemplateVersion property: The alert rule template version. + * + * @return the alertRuleTemplateVersion value. + */ + public String alertRuleTemplateVersion() { + return this.innerProperties() == null ? null : this.innerProperties().alertRuleTemplateVersion(); + } + + /** + * Set the alertRuleTemplateVersion property: The alert rule template version. + * + * @param alertRuleTemplateVersion the alertRuleTemplateVersion value to set. + * @return the AlertRuleResourceInner object itself. + */ + public AlertRuleResourceInner withAlertRuleTemplateVersion(String alertRuleTemplateVersion) { + if (this.innerProperties() == null) { + this.innerProperties = new AlertRuleResourceProperties(); + } + this.innerProperties().withAlertRuleTemplateVersion(alertRuleTemplateVersion); + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (innerProperties() != null) { + innerProperties().validate(); + } + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("properties", this.innerProperties); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of AlertRuleResourceInner from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of AlertRuleResourceInner 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 AlertRuleResourceInner. + */ + public static AlertRuleResourceInner fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + AlertRuleResourceInner deserializedAlertRuleResourceInner = new AlertRuleResourceInner(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + deserializedAlertRuleResourceInner.id = reader.getString(); + } else if ("name".equals(fieldName)) { + deserializedAlertRuleResourceInner.name = reader.getString(); + } else if ("type".equals(fieldName)) { + deserializedAlertRuleResourceInner.type = reader.getString(); + } else if ("properties".equals(fieldName)) { + deserializedAlertRuleResourceInner.innerProperties = AlertRuleResourceProperties.fromJson(reader); + } else if ("systemData".equals(fieldName)) { + deserializedAlertRuleResourceInner.systemData = SystemData.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedAlertRuleResourceInner; + }); + } +} diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/fluent/models/AlertRuleResourceProperties.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/fluent/models/AlertRuleResourceProperties.java new file mode 100644 index 0000000000000..e1a9f5ee8f997 --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/fluent/models/AlertRuleResourceProperties.java @@ -0,0 +1,255 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.databasewatcher.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.CoreUtils; +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.databasewatcher.models.AlertRuleCreationProperties; +import com.azure.resourcemanager.databasewatcher.models.ResourceProvisioningState; +import java.io.IOException; +import java.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; + +/** + * The generic properties of the alert rule proxy resource. + */ +@Fluent +public final class AlertRuleResourceProperties implements JsonSerializable { + /* + * The resource ID of the alert rule resource. + */ + private String alertRuleResourceId; + + /* + * The properties with which the alert rule resource was created. + */ + private AlertRuleCreationProperties createdWithProperties; + + /* + * The creation time of the alert rule resource. + */ + private OffsetDateTime creationTime; + + /* + * The provisioning state of the alert rule resource. + */ + private ResourceProvisioningState provisioningState; + + /* + * The template ID associated with alert rule resource. + */ + private String alertRuleTemplateId; + + /* + * The alert rule template version. + */ + private String alertRuleTemplateVersion; + + /** + * Creates an instance of AlertRuleResourceProperties class. + */ + public AlertRuleResourceProperties() { + } + + /** + * Get the alertRuleResourceId property: The resource ID of the alert rule resource. + * + * @return the alertRuleResourceId value. + */ + public String alertRuleResourceId() { + return this.alertRuleResourceId; + } + + /** + * Set the alertRuleResourceId property: The resource ID of the alert rule resource. + * + * @param alertRuleResourceId the alertRuleResourceId value to set. + * @return the AlertRuleResourceProperties object itself. + */ + public AlertRuleResourceProperties withAlertRuleResourceId(String alertRuleResourceId) { + this.alertRuleResourceId = alertRuleResourceId; + return this; + } + + /** + * Get the createdWithProperties property: The properties with which the alert rule resource was created. + * + * @return the createdWithProperties value. + */ + public AlertRuleCreationProperties createdWithProperties() { + return this.createdWithProperties; + } + + /** + * Set the createdWithProperties property: The properties with which the alert rule resource was created. + * + * @param createdWithProperties the createdWithProperties value to set. + * @return the AlertRuleResourceProperties object itself. + */ + public AlertRuleResourceProperties withCreatedWithProperties(AlertRuleCreationProperties createdWithProperties) { + this.createdWithProperties = createdWithProperties; + return this; + } + + /** + * Get the creationTime property: The creation time of the alert rule resource. + * + * @return the creationTime value. + */ + public OffsetDateTime creationTime() { + return this.creationTime; + } + + /** + * Set the creationTime property: The creation time of the alert rule resource. + * + * @param creationTime the creationTime value to set. + * @return the AlertRuleResourceProperties object itself. + */ + public AlertRuleResourceProperties withCreationTime(OffsetDateTime creationTime) { + this.creationTime = creationTime; + return this; + } + + /** + * Get the provisioningState property: The provisioning state of the alert rule resource. + * + * @return the provisioningState value. + */ + public ResourceProvisioningState provisioningState() { + return this.provisioningState; + } + + /** + * Get the alertRuleTemplateId property: The template ID associated with alert rule resource. + * + * @return the alertRuleTemplateId value. + */ + public String alertRuleTemplateId() { + return this.alertRuleTemplateId; + } + + /** + * Set the alertRuleTemplateId property: The template ID associated with alert rule resource. + * + * @param alertRuleTemplateId the alertRuleTemplateId value to set. + * @return the AlertRuleResourceProperties object itself. + */ + public AlertRuleResourceProperties withAlertRuleTemplateId(String alertRuleTemplateId) { + this.alertRuleTemplateId = alertRuleTemplateId; + return this; + } + + /** + * Get the alertRuleTemplateVersion property: The alert rule template version. + * + * @return the alertRuleTemplateVersion value. + */ + public String alertRuleTemplateVersion() { + return this.alertRuleTemplateVersion; + } + + /** + * Set the alertRuleTemplateVersion property: The alert rule template version. + * + * @param alertRuleTemplateVersion the alertRuleTemplateVersion value to set. + * @return the AlertRuleResourceProperties object itself. + */ + public AlertRuleResourceProperties withAlertRuleTemplateVersion(String alertRuleTemplateVersion) { + this.alertRuleTemplateVersion = alertRuleTemplateVersion; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (alertRuleResourceId() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property alertRuleResourceId in model AlertRuleResourceProperties")); + } + if (creationTime() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property creationTime in model AlertRuleResourceProperties")); + } + if (alertRuleTemplateId() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property alertRuleTemplateId in model AlertRuleResourceProperties")); + } + if (alertRuleTemplateVersion() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property alertRuleTemplateVersion in model AlertRuleResourceProperties")); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(AlertRuleResourceProperties.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("alertRuleResourceId", this.alertRuleResourceId); + jsonWriter.writeStringField("creationTime", + this.creationTime == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.creationTime)); + jsonWriter.writeStringField("alertRuleTemplateId", this.alertRuleTemplateId); + jsonWriter.writeStringField("alertRuleTemplateVersion", this.alertRuleTemplateVersion); + jsonWriter.writeStringField("createdWithProperties", + this.createdWithProperties == null ? null : this.createdWithProperties.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of AlertRuleResourceProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of AlertRuleResourceProperties 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 AlertRuleResourceProperties. + */ + public static AlertRuleResourceProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + AlertRuleResourceProperties deserializedAlertRuleResourceProperties = new AlertRuleResourceProperties(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("alertRuleResourceId".equals(fieldName)) { + deserializedAlertRuleResourceProperties.alertRuleResourceId = reader.getString(); + } else if ("creationTime".equals(fieldName)) { + deserializedAlertRuleResourceProperties.creationTime = reader + .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString())); + } else if ("alertRuleTemplateId".equals(fieldName)) { + deserializedAlertRuleResourceProperties.alertRuleTemplateId = reader.getString(); + } else if ("alertRuleTemplateVersion".equals(fieldName)) { + deserializedAlertRuleResourceProperties.alertRuleTemplateVersion = reader.getString(); + } else if ("createdWithProperties".equals(fieldName)) { + deserializedAlertRuleResourceProperties.createdWithProperties + = AlertRuleCreationProperties.fromString(reader.getString()); + } else if ("provisioningState".equals(fieldName)) { + deserializedAlertRuleResourceProperties.provisioningState + = ResourceProvisioningState.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + + return deserializedAlertRuleResourceProperties; + }); + } +} diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/fluent/models/OperationInner.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/fluent/models/OperationInner.java new file mode 100644 index 0000000000000..3e1e13badde98 --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/fluent/models/OperationInner.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.databasewatcher.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 com.azure.resourcemanager.databasewatcher.models.ActionType; +import com.azure.resourcemanager.databasewatcher.models.OperationDisplay; +import com.azure.resourcemanager.databasewatcher.models.Origin; +import java.io.IOException; + +/** + * REST API Operation + * + * Details of a REST API operation, returned from the Resource Provider Operations API. + */ +@Fluent +public final class OperationInner implements JsonSerializable { + /* + * The name of the operation, as per Resource-Based Access Control (RBAC). Examples: + * "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action" + */ + private String name; + + /* + * Whether the operation applies to data-plane. This is "true" for data-plane operations and "false" for + * ARM/control-plane operations. + */ + private Boolean isDataAction; + + /* + * Localized display information for this particular operation. + */ + private OperationDisplay display; + + /* + * The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default + * value is "user,system" + */ + private Origin origin; + + /* + * Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + */ + private ActionType actionType; + + /** + * Creates an instance of OperationInner class. + */ + public OperationInner() { + } + + /** + * Get the name property: The name of the operation, as per Resource-Based Access Control (RBAC). Examples: + * "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action". + * + * @return the name value. + */ + public String name() { + return this.name; + } + + /** + * Get the isDataAction property: Whether the operation applies to data-plane. This is "true" for data-plane + * operations and "false" for ARM/control-plane operations. + * + * @return the isDataAction value. + */ + public Boolean isDataAction() { + return this.isDataAction; + } + + /** + * Get the display property: Localized display information for this particular operation. + * + * @return the display value. + */ + public OperationDisplay display() { + return this.display; + } + + /** + * Set the display property: Localized display information for this particular operation. + * + * @param display the display value to set. + * @return the OperationInner object itself. + */ + public OperationInner withDisplay(OperationDisplay display) { + this.display = display; + return this; + } + + /** + * Get the origin property: The intended executor of the operation; as in Resource Based Access Control (RBAC) and + * audit logs UX. Default value is "user,system". + * + * @return the origin value. + */ + public Origin origin() { + return this.origin; + } + + /** + * Get the actionType property: Enum. Indicates the action type. "Internal" refers to actions that are for internal + * only APIs. + * + * @return the actionType value. + */ + public ActionType actionType() { + return this.actionType; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (display() != null) { + display().validate(); + } + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("display", this.display); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of OperationInner from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of OperationInner 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 OperationInner. + */ + public static OperationInner fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + OperationInner deserializedOperationInner = new OperationInner(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + deserializedOperationInner.name = reader.getString(); + } else if ("isDataAction".equals(fieldName)) { + deserializedOperationInner.isDataAction = reader.getNullable(JsonReader::getBoolean); + } else if ("display".equals(fieldName)) { + deserializedOperationInner.display = OperationDisplay.fromJson(reader); + } else if ("origin".equals(fieldName)) { + deserializedOperationInner.origin = Origin.fromString(reader.getString()); + } else if ("actionType".equals(fieldName)) { + deserializedOperationInner.actionType = ActionType.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + + return deserializedOperationInner; + }); + } +} diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/fluent/models/SharedPrivateLinkResourceInner.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/fluent/models/SharedPrivateLinkResourceInner.java new file mode 100644 index 0000000000000..be36950daa404 --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/fluent/models/SharedPrivateLinkResourceInner.java @@ -0,0 +1,271 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.databasewatcher.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.management.ProxyResource; +import com.azure.core.management.SystemData; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.azure.resourcemanager.databasewatcher.models.ResourceProvisioningState; +import com.azure.resourcemanager.databasewatcher.models.SharedPrivateLinkResourceStatus; +import java.io.IOException; + +/** + * Concrete proxy resource types can be created by aliasing this type using a specific property type. + */ +@Fluent +public final class SharedPrivateLinkResourceInner extends ProxyResource { + /* + * The resource-specific properties for this resource. + */ + private SharedPrivateLinkResourceProperties innerProperties; + + /* + * Azure Resource Manager metadata containing createdBy and modifiedBy information. + */ + private SystemData systemData; + + /* + * Fully qualified resource Id for the resource. + */ + private String id; + + /* + * The name of the resource. + */ + private String name; + + /* + * The type of the resource. + */ + private String type; + + /** + * Creates an instance of SharedPrivateLinkResourceInner class. + */ + public SharedPrivateLinkResourceInner() { + } + + /** + * Get the innerProperties property: The resource-specific properties for this resource. + * + * @return the innerProperties value. + */ + private SharedPrivateLinkResourceProperties innerProperties() { + return this.innerProperties; + } + + /** + * Get the systemData property: Azure Resource Manager metadata containing createdBy and modifiedBy information. + * + * @return the systemData value. + */ + public SystemData systemData() { + return this.systemData; + } + + /** + * Get the id property: Fully qualified resource Id for the resource. + * + * @return the id value. + */ + @Override + public String id() { + return this.id; + } + + /** + * Get the name property: The name of the resource. + * + * @return the name value. + */ + @Override + public String name() { + return this.name; + } + + /** + * Get the type property: The type of the resource. + * + * @return the type value. + */ + @Override + public String type() { + return this.type; + } + + /** + * Get the privateLinkResourceId property: The resource id of the resource the shared private link resource is for. + * + * @return the privateLinkResourceId value. + */ + public String privateLinkResourceId() { + return this.innerProperties() == null ? null : this.innerProperties().privateLinkResourceId(); + } + + /** + * Set the privateLinkResourceId property: The resource id of the resource the shared private link resource is for. + * + * @param privateLinkResourceId the privateLinkResourceId value to set. + * @return the SharedPrivateLinkResourceInner object itself. + */ + public SharedPrivateLinkResourceInner withPrivateLinkResourceId(String privateLinkResourceId) { + if (this.innerProperties() == null) { + this.innerProperties = new SharedPrivateLinkResourceProperties(); + } + this.innerProperties().withPrivateLinkResourceId(privateLinkResourceId); + return this; + } + + /** + * Get the groupId property: The group id from the provider of resource the shared private link resource is for. + * + * @return the groupId value. + */ + public String groupId() { + return this.innerProperties() == null ? null : this.innerProperties().groupId(); + } + + /** + * Set the groupId property: The group id from the provider of resource the shared private link resource is for. + * + * @param groupId the groupId value to set. + * @return the SharedPrivateLinkResourceInner object itself. + */ + public SharedPrivateLinkResourceInner withGroupId(String groupId) { + if (this.innerProperties() == null) { + this.innerProperties = new SharedPrivateLinkResourceProperties(); + } + this.innerProperties().withGroupId(groupId); + return this; + } + + /** + * Get the requestMessage property: The request message for requesting approval of the shared private link resource. + * + * @return the requestMessage value. + */ + public String requestMessage() { + return this.innerProperties() == null ? null : this.innerProperties().requestMessage(); + } + + /** + * Set the requestMessage property: The request message for requesting approval of the shared private link resource. + * + * @param requestMessage the requestMessage value to set. + * @return the SharedPrivateLinkResourceInner object itself. + */ + public SharedPrivateLinkResourceInner withRequestMessage(String requestMessage) { + if (this.innerProperties() == null) { + this.innerProperties = new SharedPrivateLinkResourceProperties(); + } + this.innerProperties().withRequestMessage(requestMessage); + return this; + } + + /** + * Get the dnsZone property: The DNS zone to be included in the DNS name of the shared private link. Value is + * service-specific. + * + * @return the dnsZone value. + */ + public String dnsZone() { + return this.innerProperties() == null ? null : this.innerProperties().dnsZone(); + } + + /** + * Set the dnsZone property: The DNS zone to be included in the DNS name of the shared private link. Value is + * service-specific. + * + * @param dnsZone the dnsZone value to set. + * @return the SharedPrivateLinkResourceInner object itself. + */ + public SharedPrivateLinkResourceInner withDnsZone(String dnsZone) { + if (this.innerProperties() == null) { + this.innerProperties = new SharedPrivateLinkResourceProperties(); + } + this.innerProperties().withDnsZone(dnsZone); + return this; + } + + /** + * Get the status property: Status of the shared private link resource. Can be Pending, Approved, Rejected or + * Disconnected. + * + * @return the status value. + */ + public SharedPrivateLinkResourceStatus status() { + return this.innerProperties() == null ? null : this.innerProperties().status(); + } + + /** + * Get the provisioningState property: The provisioning state of the resource. + * + * @return the provisioningState value. + */ + public ResourceProvisioningState provisioningState() { + return this.innerProperties() == null ? null : this.innerProperties().provisioningState(); + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (innerProperties() != null) { + innerProperties().validate(); + } + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("properties", this.innerProperties); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SharedPrivateLinkResourceInner from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SharedPrivateLinkResourceInner 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 SharedPrivateLinkResourceInner. + */ + public static SharedPrivateLinkResourceInner fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + SharedPrivateLinkResourceInner deserializedSharedPrivateLinkResourceInner + = new SharedPrivateLinkResourceInner(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + deserializedSharedPrivateLinkResourceInner.id = reader.getString(); + } else if ("name".equals(fieldName)) { + deserializedSharedPrivateLinkResourceInner.name = reader.getString(); + } else if ("type".equals(fieldName)) { + deserializedSharedPrivateLinkResourceInner.type = reader.getString(); + } else if ("properties".equals(fieldName)) { + deserializedSharedPrivateLinkResourceInner.innerProperties + = SharedPrivateLinkResourceProperties.fromJson(reader); + } else if ("systemData".equals(fieldName)) { + deserializedSharedPrivateLinkResourceInner.systemData = SystemData.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedSharedPrivateLinkResourceInner; + }); + } +} diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/fluent/models/SharedPrivateLinkResourceProperties.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/fluent/models/SharedPrivateLinkResourceProperties.java new file mode 100644 index 0000000000000..88c9efc24f7d4 --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/fluent/models/SharedPrivateLinkResourceProperties.java @@ -0,0 +1,237 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.databasewatcher.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.databasewatcher.models.ResourceProvisioningState; +import com.azure.resourcemanager.databasewatcher.models.SharedPrivateLinkResourceStatus; +import java.io.IOException; + +/** + * The generic properties of a Shared Private Link resource. + */ +@Fluent +public final class SharedPrivateLinkResourceProperties + implements JsonSerializable { + /* + * The resource id of the resource the shared private link resource is for. + */ + private String privateLinkResourceId; + + /* + * The group id from the provider of resource the shared private link resource is for. + */ + private String groupId; + + /* + * The request message for requesting approval of the shared private link resource. + */ + private String requestMessage; + + /* + * The DNS zone to be included in the DNS name of the shared private link. Value is service-specific. + */ + private String dnsZone; + + /* + * Status of the shared private link resource. Can be Pending, Approved, Rejected or Disconnected. + */ + private SharedPrivateLinkResourceStatus status; + + /* + * The provisioning state of the resource. + */ + private ResourceProvisioningState provisioningState; + + /** + * Creates an instance of SharedPrivateLinkResourceProperties class. + */ + public SharedPrivateLinkResourceProperties() { + } + + /** + * Get the privateLinkResourceId property: The resource id of the resource the shared private link resource is for. + * + * @return the privateLinkResourceId value. + */ + public String privateLinkResourceId() { + return this.privateLinkResourceId; + } + + /** + * Set the privateLinkResourceId property: The resource id of the resource the shared private link resource is for. + * + * @param privateLinkResourceId the privateLinkResourceId value to set. + * @return the SharedPrivateLinkResourceProperties object itself. + */ + public SharedPrivateLinkResourceProperties withPrivateLinkResourceId(String privateLinkResourceId) { + this.privateLinkResourceId = privateLinkResourceId; + return this; + } + + /** + * Get the groupId property: The group id from the provider of resource the shared private link resource is for. + * + * @return the groupId value. + */ + public String groupId() { + return this.groupId; + } + + /** + * Set the groupId property: The group id from the provider of resource the shared private link resource is for. + * + * @param groupId the groupId value to set. + * @return the SharedPrivateLinkResourceProperties object itself. + */ + public SharedPrivateLinkResourceProperties withGroupId(String groupId) { + this.groupId = groupId; + return this; + } + + /** + * Get the requestMessage property: The request message for requesting approval of the shared private link resource. + * + * @return the requestMessage value. + */ + public String requestMessage() { + return this.requestMessage; + } + + /** + * Set the requestMessage property: The request message for requesting approval of the shared private link resource. + * + * @param requestMessage the requestMessage value to set. + * @return the SharedPrivateLinkResourceProperties object itself. + */ + public SharedPrivateLinkResourceProperties withRequestMessage(String requestMessage) { + this.requestMessage = requestMessage; + return this; + } + + /** + * Get the dnsZone property: The DNS zone to be included in the DNS name of the shared private link. Value is + * service-specific. + * + * @return the dnsZone value. + */ + public String dnsZone() { + return this.dnsZone; + } + + /** + * Set the dnsZone property: The DNS zone to be included in the DNS name of the shared private link. Value is + * service-specific. + * + * @param dnsZone the dnsZone value to set. + * @return the SharedPrivateLinkResourceProperties object itself. + */ + public SharedPrivateLinkResourceProperties withDnsZone(String dnsZone) { + this.dnsZone = dnsZone; + return this; + } + + /** + * Get the status property: Status of the shared private link resource. Can be Pending, Approved, Rejected or + * Disconnected. + * + * @return the status value. + */ + public SharedPrivateLinkResourceStatus status() { + return this.status; + } + + /** + * Get the provisioningState property: The provisioning state of the resource. + * + * @return the provisioningState value. + */ + public ResourceProvisioningState provisioningState() { + return this.provisioningState; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (privateLinkResourceId() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property privateLinkResourceId in model SharedPrivateLinkResourceProperties")); + } + if (groupId() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property groupId in model SharedPrivateLinkResourceProperties")); + } + if (requestMessage() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property requestMessage in model SharedPrivateLinkResourceProperties")); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(SharedPrivateLinkResourceProperties.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("privateLinkResourceId", this.privateLinkResourceId); + jsonWriter.writeStringField("groupId", this.groupId); + jsonWriter.writeStringField("requestMessage", this.requestMessage); + jsonWriter.writeStringField("dnsZone", this.dnsZone); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SharedPrivateLinkResourceProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SharedPrivateLinkResourceProperties 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 SharedPrivateLinkResourceProperties. + */ + public static SharedPrivateLinkResourceProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + SharedPrivateLinkResourceProperties deserializedSharedPrivateLinkResourceProperties + = new SharedPrivateLinkResourceProperties(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("privateLinkResourceId".equals(fieldName)) { + deserializedSharedPrivateLinkResourceProperties.privateLinkResourceId = reader.getString(); + } else if ("groupId".equals(fieldName)) { + deserializedSharedPrivateLinkResourceProperties.groupId = reader.getString(); + } else if ("requestMessage".equals(fieldName)) { + deserializedSharedPrivateLinkResourceProperties.requestMessage = reader.getString(); + } else if ("dnsZone".equals(fieldName)) { + deserializedSharedPrivateLinkResourceProperties.dnsZone = reader.getString(); + } else if ("status".equals(fieldName)) { + deserializedSharedPrivateLinkResourceProperties.status + = SharedPrivateLinkResourceStatus.fromString(reader.getString()); + } else if ("provisioningState".equals(fieldName)) { + deserializedSharedPrivateLinkResourceProperties.provisioningState + = ResourceProvisioningState.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + + return deserializedSharedPrivateLinkResourceProperties; + }); + } +} diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/fluent/models/TargetInner.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/fluent/models/TargetInner.java new file mode 100644 index 0000000000000..3236916de115c --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/fluent/models/TargetInner.java @@ -0,0 +1,166 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.databasewatcher.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.management.ProxyResource; +import com.azure.core.management.SystemData; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.azure.resourcemanager.databasewatcher.models.TargetProperties; +import java.io.IOException; + +/** + * Concrete proxy resource types can be created by aliasing this type using a specific property type. + */ +@Fluent +public final class TargetInner extends ProxyResource { + /* + * The resource-specific properties for this resource. + */ + private TargetProperties properties; + + /* + * Azure Resource Manager metadata containing createdBy and modifiedBy information. + */ + private SystemData systemData; + + /* + * Fully qualified resource Id for the resource. + */ + private String id; + + /* + * The name of the resource. + */ + private String name; + + /* + * The type of the resource. + */ + private String type; + + /** + * Creates an instance of TargetInner class. + */ + public TargetInner() { + } + + /** + * Get the properties property: The resource-specific properties for this resource. + * + * @return the properties value. + */ + public TargetProperties properties() { + return this.properties; + } + + /** + * Set the properties property: The resource-specific properties for this resource. + * + * @param properties the properties value to set. + * @return the TargetInner object itself. + */ + public TargetInner withProperties(TargetProperties properties) { + this.properties = properties; + return this; + } + + /** + * Get the systemData property: Azure Resource Manager metadata containing createdBy and modifiedBy information. + * + * @return the systemData value. + */ + public SystemData systemData() { + return this.systemData; + } + + /** + * Get the id property: Fully qualified resource Id for the resource. + * + * @return the id value. + */ + @Override + public String id() { + return this.id; + } + + /** + * Get the name property: The name of the resource. + * + * @return the name value. + */ + @Override + public String name() { + return this.name; + } + + /** + * Get the type property: The type of the resource. + * + * @return the type value. + */ + @Override + public String type() { + return this.type; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (properties() != null) { + properties().validate(); + } + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("properties", this.properties); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of TargetInner from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of TargetInner 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 TargetInner. + */ + public static TargetInner fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + TargetInner deserializedTargetInner = new TargetInner(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + deserializedTargetInner.id = reader.getString(); + } else if ("name".equals(fieldName)) { + deserializedTargetInner.name = reader.getString(); + } else if ("type".equals(fieldName)) { + deserializedTargetInner.type = reader.getString(); + } else if ("properties".equals(fieldName)) { + deserializedTargetInner.properties = TargetProperties.fromJson(reader); + } else if ("systemData".equals(fieldName)) { + deserializedTargetInner.systemData = SystemData.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedTargetInner; + }); + } +} diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/fluent/models/WatcherInner.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/fluent/models/WatcherInner.java new file mode 100644 index 0000000000000..753079188ce2a --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/fluent/models/WatcherInner.java @@ -0,0 +1,281 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.databasewatcher.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.management.Resource; +import com.azure.core.management.SystemData; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.azure.resourcemanager.databasewatcher.models.DatabaseWatcherProvisioningState; +import com.azure.resourcemanager.databasewatcher.models.Datastore; +import com.azure.resourcemanager.databasewatcher.models.ManagedServiceIdentity; +import com.azure.resourcemanager.databasewatcher.models.WatcherStatus; +import java.io.IOException; +import java.util.Map; + +/** + * The DatabaseWatcherProviderHub resource. + */ +@Fluent +public final class WatcherInner extends Resource { + /* + * The resource-specific properties for this resource. + */ + private WatcherProperties innerProperties; + + /* + * The managed service identities assigned to this resource. + */ + private ManagedServiceIdentity identity; + + /* + * Azure Resource Manager metadata containing createdBy and modifiedBy information. + */ + private SystemData systemData; + + /* + * Fully qualified resource Id for the resource. + */ + private String id; + + /* + * The name of the resource. + */ + private String name; + + /* + * The type of the resource. + */ + private String type; + + /** + * Creates an instance of WatcherInner class. + */ + public WatcherInner() { + } + + /** + * Get the innerProperties property: The resource-specific properties for this resource. + * + * @return the innerProperties value. + */ + private WatcherProperties innerProperties() { + return this.innerProperties; + } + + /** + * Get the identity property: The managed service identities assigned to this resource. + * + * @return the identity value. + */ + public ManagedServiceIdentity identity() { + return this.identity; + } + + /** + * Set the identity property: The managed service identities assigned to this resource. + * + * @param identity the identity value to set. + * @return the WatcherInner object itself. + */ + public WatcherInner withIdentity(ManagedServiceIdentity identity) { + this.identity = identity; + return this; + } + + /** + * Get the systemData property: Azure Resource Manager metadata containing createdBy and modifiedBy information. + * + * @return the systemData value. + */ + public SystemData systemData() { + return this.systemData; + } + + /** + * Get the id property: Fully qualified resource Id for the resource. + * + * @return the id value. + */ + @Override + public String id() { + return this.id; + } + + /** + * Get the name property: The name of the resource. + * + * @return the name value. + */ + @Override + public String name() { + return this.name; + } + + /** + * Get the type property: The type of the resource. + * + * @return the type value. + */ + @Override + public String type() { + return this.type; + } + + /** + * {@inheritDoc} + */ + @Override + public WatcherInner withLocation(String location) { + super.withLocation(location); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public WatcherInner withTags(Map tags) { + super.withTags(tags); + return this; + } + + /** + * Get the datastore property: The data store for collected monitoring data. + * + * @return the datastore value. + */ + public Datastore datastore() { + return this.innerProperties() == null ? null : this.innerProperties().datastore(); + } + + /** + * Set the datastore property: The data store for collected monitoring data. + * + * @param datastore the datastore value to set. + * @return the WatcherInner object itself. + */ + public WatcherInner withDatastore(Datastore datastore) { + if (this.innerProperties() == null) { + this.innerProperties = new WatcherProperties(); + } + this.innerProperties().withDatastore(datastore); + return this; + } + + /** + * Get the status property: The monitoring collection status of the watcher. + * + * @return the status value. + */ + public WatcherStatus status() { + return this.innerProperties() == null ? null : this.innerProperties().status(); + } + + /** + * Get the provisioningState property: The provisioning state of the resource watcher. + * + * @return the provisioningState value. + */ + public DatabaseWatcherProvisioningState provisioningState() { + return this.innerProperties() == null ? null : this.innerProperties().provisioningState(); + } + + /** + * Get the defaultAlertRuleIdentityResourceId property: The resource ID of a user-assigned managed identity that + * will be assigned to a new alert rule. + * + * @return the defaultAlertRuleIdentityResourceId value. + */ + public String defaultAlertRuleIdentityResourceId() { + return this.innerProperties() == null ? null : this.innerProperties().defaultAlertRuleIdentityResourceId(); + } + + /** + * Set the defaultAlertRuleIdentityResourceId property: The resource ID of a user-assigned managed identity that + * will be assigned to a new alert rule. + * + * @param defaultAlertRuleIdentityResourceId the defaultAlertRuleIdentityResourceId value to set. + * @return the WatcherInner object itself. + */ + public WatcherInner withDefaultAlertRuleIdentityResourceId(String defaultAlertRuleIdentityResourceId) { + if (this.innerProperties() == null) { + this.innerProperties = new WatcherProperties(); + } + this.innerProperties().withDefaultAlertRuleIdentityResourceId(defaultAlertRuleIdentityResourceId); + 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 WatcherInner from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of WatcherInner 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 WatcherInner. + */ + public static WatcherInner fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + WatcherInner deserializedWatcherInner = new WatcherInner(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + deserializedWatcherInner.id = reader.getString(); + } else if ("name".equals(fieldName)) { + deserializedWatcherInner.name = reader.getString(); + } else if ("type".equals(fieldName)) { + deserializedWatcherInner.type = reader.getString(); + } else if ("location".equals(fieldName)) { + deserializedWatcherInner.withLocation(reader.getString()); + } else if ("tags".equals(fieldName)) { + Map tags = reader.readMap(reader1 -> reader1.getString()); + deserializedWatcherInner.withTags(tags); + } else if ("properties".equals(fieldName)) { + deserializedWatcherInner.innerProperties = WatcherProperties.fromJson(reader); + } else if ("identity".equals(fieldName)) { + deserializedWatcherInner.identity = ManagedServiceIdentity.fromJson(reader); + } else if ("systemData".equals(fieldName)) { + deserializedWatcherInner.systemData = SystemData.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedWatcherInner; + }); + } +} diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/fluent/models/WatcherProperties.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/fluent/models/WatcherProperties.java new file mode 100644 index 0000000000000..a4a0f823a92ab --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/fluent/models/WatcherProperties.java @@ -0,0 +1,162 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.databasewatcher.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 com.azure.resourcemanager.databasewatcher.models.DatabaseWatcherProvisioningState; +import com.azure.resourcemanager.databasewatcher.models.Datastore; +import com.azure.resourcemanager.databasewatcher.models.WatcherStatus; +import java.io.IOException; + +/** + * The RP specific properties of the resource. + */ +@Fluent +public final class WatcherProperties implements JsonSerializable { + /* + * The data store for collected monitoring data. + */ + private Datastore datastore; + + /* + * The monitoring collection status of the watcher. + */ + private WatcherStatus status; + + /* + * The provisioning state of the resource watcher. + */ + private DatabaseWatcherProvisioningState provisioningState; + + /* + * The resource ID of a user-assigned managed identity that will be assigned to a new alert rule. + */ + private String defaultAlertRuleIdentityResourceId; + + /** + * Creates an instance of WatcherProperties class. + */ + public WatcherProperties() { + } + + /** + * Get the datastore property: The data store for collected monitoring data. + * + * @return the datastore value. + */ + public Datastore datastore() { + return this.datastore; + } + + /** + * Set the datastore property: The data store for collected monitoring data. + * + * @param datastore the datastore value to set. + * @return the WatcherProperties object itself. + */ + public WatcherProperties withDatastore(Datastore datastore) { + this.datastore = datastore; + return this; + } + + /** + * Get the status property: The monitoring collection status of the watcher. + * + * @return the status value. + */ + public WatcherStatus status() { + return this.status; + } + + /** + * Get the provisioningState property: The provisioning state of the resource watcher. + * + * @return the provisioningState value. + */ + public DatabaseWatcherProvisioningState provisioningState() { + return this.provisioningState; + } + + /** + * Get the defaultAlertRuleIdentityResourceId property: The resource ID of a user-assigned managed identity that + * will be assigned to a new alert rule. + * + * @return the defaultAlertRuleIdentityResourceId value. + */ + public String defaultAlertRuleIdentityResourceId() { + return this.defaultAlertRuleIdentityResourceId; + } + + /** + * Set the defaultAlertRuleIdentityResourceId property: The resource ID of a user-assigned managed identity that + * will be assigned to a new alert rule. + * + * @param defaultAlertRuleIdentityResourceId the defaultAlertRuleIdentityResourceId value to set. + * @return the WatcherProperties object itself. + */ + public WatcherProperties withDefaultAlertRuleIdentityResourceId(String defaultAlertRuleIdentityResourceId) { + this.defaultAlertRuleIdentityResourceId = defaultAlertRuleIdentityResourceId; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (datastore() != null) { + datastore().validate(); + } + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("datastore", this.datastore); + jsonWriter.writeStringField("defaultAlertRuleIdentityResourceId", this.defaultAlertRuleIdentityResourceId); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of WatcherProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of WatcherProperties 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 WatcherProperties. + */ + public static WatcherProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + WatcherProperties deserializedWatcherProperties = new WatcherProperties(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("datastore".equals(fieldName)) { + deserializedWatcherProperties.datastore = Datastore.fromJson(reader); + } else if ("status".equals(fieldName)) { + deserializedWatcherProperties.status = WatcherStatus.fromString(reader.getString()); + } else if ("provisioningState".equals(fieldName)) { + deserializedWatcherProperties.provisioningState + = DatabaseWatcherProvisioningState.fromString(reader.getString()); + } else if ("defaultAlertRuleIdentityResourceId".equals(fieldName)) { + deserializedWatcherProperties.defaultAlertRuleIdentityResourceId = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedWatcherProperties; + }); + } +} diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/fluent/models/WatcherUpdateProperties.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/fluent/models/WatcherUpdateProperties.java new file mode 100644 index 0000000000000..5029b8abfd979 --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/fluent/models/WatcherUpdateProperties.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.databasewatcher.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 com.azure.resourcemanager.databasewatcher.models.DatastoreUpdate; +import java.io.IOException; + +/** + * The updatable properties of the Watcher. + */ +@Fluent +public final class WatcherUpdateProperties implements JsonSerializable { + /* + * The data store for collected monitoring data. + */ + private DatastoreUpdate datastore; + + /* + * The resource ID of a user-assigned managed identity that will be assigned to a new alert rule. + */ + private String defaultAlertRuleIdentityResourceId; + + /** + * Creates an instance of WatcherUpdateProperties class. + */ + public WatcherUpdateProperties() { + } + + /** + * Get the datastore property: The data store for collected monitoring data. + * + * @return the datastore value. + */ + public DatastoreUpdate datastore() { + return this.datastore; + } + + /** + * Set the datastore property: The data store for collected monitoring data. + * + * @param datastore the datastore value to set. + * @return the WatcherUpdateProperties object itself. + */ + public WatcherUpdateProperties withDatastore(DatastoreUpdate datastore) { + this.datastore = datastore; + return this; + } + + /** + * Get the defaultAlertRuleIdentityResourceId property: The resource ID of a user-assigned managed identity that + * will be assigned to a new alert rule. + * + * @return the defaultAlertRuleIdentityResourceId value. + */ + public String defaultAlertRuleIdentityResourceId() { + return this.defaultAlertRuleIdentityResourceId; + } + + /** + * Set the defaultAlertRuleIdentityResourceId property: The resource ID of a user-assigned managed identity that + * will be assigned to a new alert rule. + * + * @param defaultAlertRuleIdentityResourceId the defaultAlertRuleIdentityResourceId value to set. + * @return the WatcherUpdateProperties object itself. + */ + public WatcherUpdateProperties withDefaultAlertRuleIdentityResourceId(String defaultAlertRuleIdentityResourceId) { + this.defaultAlertRuleIdentityResourceId = defaultAlertRuleIdentityResourceId; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (datastore() != null) { + datastore().validate(); + } + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("datastore", this.datastore); + jsonWriter.writeStringField("defaultAlertRuleIdentityResourceId", this.defaultAlertRuleIdentityResourceId); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of WatcherUpdateProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of WatcherUpdateProperties 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 WatcherUpdateProperties. + */ + public static WatcherUpdateProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + WatcherUpdateProperties deserializedWatcherUpdateProperties = new WatcherUpdateProperties(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("datastore".equals(fieldName)) { + deserializedWatcherUpdateProperties.datastore = DatastoreUpdate.fromJson(reader); + } else if ("defaultAlertRuleIdentityResourceId".equals(fieldName)) { + deserializedWatcherUpdateProperties.defaultAlertRuleIdentityResourceId = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedWatcherUpdateProperties; + }); + } +} diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/fluent/models/package-info.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/fluent/models/package-info.java new file mode 100644 index 0000000000000..2299054e31bc0 --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/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 MicrosoftDatabaseWatcher. + * null. + */ +package com.azure.resourcemanager.databasewatcher.fluent.models; diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/fluent/package-info.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/fluent/package-info.java new file mode 100644 index 0000000000000..51403b30b0a74 --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/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 MicrosoftDatabaseWatcher. + * null. + */ +package com.azure.resourcemanager.databasewatcher.fluent; diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/implementation/AlertRuleResourceImpl.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/implementation/AlertRuleResourceImpl.java new file mode 100644 index 0000000000000..86711ade15dcd --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/implementation/AlertRuleResourceImpl.java @@ -0,0 +1,181 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.databasewatcher.implementation; + +import com.azure.core.management.SystemData; +import com.azure.core.util.Context; +import com.azure.resourcemanager.databasewatcher.fluent.models.AlertRuleResourceInner; +import com.azure.resourcemanager.databasewatcher.models.AlertRuleCreationProperties; +import com.azure.resourcemanager.databasewatcher.models.AlertRuleResource; +import com.azure.resourcemanager.databasewatcher.models.ResourceProvisioningState; +import java.time.OffsetDateTime; + +public final class AlertRuleResourceImpl + implements AlertRuleResource, AlertRuleResource.Definition, AlertRuleResource.Update { + private AlertRuleResourceInner innerObject; + + private final com.azure.resourcemanager.databasewatcher.DatabasewatcherManager serviceManager; + + public String id() { + return this.innerModel().id(); + } + + public String name() { + return this.innerModel().name(); + } + + public String type() { + return this.innerModel().type(); + } + + public SystemData systemData() { + return this.innerModel().systemData(); + } + + public String alertRuleResourceId() { + return this.innerModel().alertRuleResourceId(); + } + + public AlertRuleCreationProperties createdWithProperties() { + return this.innerModel().createdWithProperties(); + } + + public OffsetDateTime creationTime() { + return this.innerModel().creationTime(); + } + + public ResourceProvisioningState provisioningState() { + return this.innerModel().provisioningState(); + } + + public String alertRuleTemplateId() { + return this.innerModel().alertRuleTemplateId(); + } + + public String alertRuleTemplateVersion() { + return this.innerModel().alertRuleTemplateVersion(); + } + + public String resourceGroupName() { + return resourceGroupName; + } + + public AlertRuleResourceInner innerModel() { + return this.innerObject; + } + + private com.azure.resourcemanager.databasewatcher.DatabasewatcherManager manager() { + return this.serviceManager; + } + + private String resourceGroupName; + + private String watcherName; + + private String alertRuleResourceName; + + public AlertRuleResourceImpl withExistingWatcher(String resourceGroupName, String watcherName) { + this.resourceGroupName = resourceGroupName; + this.watcherName = watcherName; + return this; + } + + public AlertRuleResource create() { + this.innerObject = serviceManager.serviceClient() + .getAlertRuleResources() + .createOrUpdateWithResponse(resourceGroupName, watcherName, alertRuleResourceName, this.innerModel(), + Context.NONE) + .getValue(); + return this; + } + + public AlertRuleResource create(Context context) { + this.innerObject = serviceManager.serviceClient() + .getAlertRuleResources() + .createOrUpdateWithResponse(resourceGroupName, watcherName, alertRuleResourceName, this.innerModel(), + context) + .getValue(); + return this; + } + + AlertRuleResourceImpl(String name, + com.azure.resourcemanager.databasewatcher.DatabasewatcherManager serviceManager) { + this.innerObject = new AlertRuleResourceInner(); + this.serviceManager = serviceManager; + this.alertRuleResourceName = name; + } + + public AlertRuleResourceImpl update() { + return this; + } + + public AlertRuleResource apply() { + this.innerObject = serviceManager.serviceClient() + .getAlertRuleResources() + .createOrUpdateWithResponse(resourceGroupName, watcherName, alertRuleResourceName, this.innerModel(), + Context.NONE) + .getValue(); + return this; + } + + public AlertRuleResource apply(Context context) { + this.innerObject = serviceManager.serviceClient() + .getAlertRuleResources() + .createOrUpdateWithResponse(resourceGroupName, watcherName, alertRuleResourceName, this.innerModel(), + context) + .getValue(); + return this; + } + + AlertRuleResourceImpl(AlertRuleResourceInner innerObject, + com.azure.resourcemanager.databasewatcher.DatabasewatcherManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + this.resourceGroupName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "resourceGroups"); + this.watcherName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "watchers"); + this.alertRuleResourceName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "alertRuleResources"); + } + + public AlertRuleResource refresh() { + this.innerObject = serviceManager.serviceClient() + .getAlertRuleResources() + .getWithResponse(resourceGroupName, watcherName, alertRuleResourceName, Context.NONE) + .getValue(); + return this; + } + + public AlertRuleResource refresh(Context context) { + this.innerObject = serviceManager.serviceClient() + .getAlertRuleResources() + .getWithResponse(resourceGroupName, watcherName, alertRuleResourceName, context) + .getValue(); + return this; + } + + public AlertRuleResourceImpl withAlertRuleResourceId(String alertRuleResourceId) { + this.innerModel().withAlertRuleResourceId(alertRuleResourceId); + return this; + } + + public AlertRuleResourceImpl withCreatedWithProperties(AlertRuleCreationProperties createdWithProperties) { + this.innerModel().withCreatedWithProperties(createdWithProperties); + return this; + } + + public AlertRuleResourceImpl withCreationTime(OffsetDateTime creationTime) { + this.innerModel().withCreationTime(creationTime); + return this; + } + + public AlertRuleResourceImpl withAlertRuleTemplateId(String alertRuleTemplateId) { + this.innerModel().withAlertRuleTemplateId(alertRuleTemplateId); + return this; + } + + public AlertRuleResourceImpl withAlertRuleTemplateVersion(String alertRuleTemplateVersion) { + this.innerModel().withAlertRuleTemplateVersion(alertRuleTemplateVersion); + return this; + } +} diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/implementation/AlertRuleResourcesClientImpl.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/implementation/AlertRuleResourcesClientImpl.java new file mode 100644 index 0000000000000..10f634d9ec4eb --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/implementation/AlertRuleResourcesClientImpl.java @@ -0,0 +1,730 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.databasewatcher.implementation; + +import com.azure.core.annotation.BodyParam; +import com.azure.core.annotation.Delete; +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Headers; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.PathParam; +import com.azure.core.annotation.Put; +import com.azure.core.annotation.QueryParam; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.management.exception.ManagementException; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import com.azure.resourcemanager.databasewatcher.fluent.AlertRuleResourcesClient; +import com.azure.resourcemanager.databasewatcher.fluent.models.AlertRuleResourceInner; +import com.azure.resourcemanager.databasewatcher.models.AlertRuleResourceListResult; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in AlertRuleResourcesClient. + */ +public final class AlertRuleResourcesClientImpl implements AlertRuleResourcesClient { + /** + * The proxy service used to perform REST calls. + */ + private final AlertRuleResourcesService service; + + /** + * The service client containing this operation class. + */ + private final MicrosoftDatabaseWatcherImpl client; + + /** + * Initializes an instance of AlertRuleResourcesClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + AlertRuleResourcesClientImpl(MicrosoftDatabaseWatcherImpl client) { + this.service = RestProxy.create(AlertRuleResourcesService.class, client.getHttpPipeline(), + client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for MicrosoftDatabaseWatcherAlertRuleResources to be used by the proxy + * service to perform REST calls. + */ + @Host("{$host}") + @ServiceInterface(name = "MicrosoftDatabaseWat") + public interface AlertRuleResourcesService { + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/alertRuleResources") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listByParent(@HostParam("$host") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, @PathParam("watcherName") String watcherName, + @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/alertRuleResources/{alertRuleResourceName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> get(@HostParam("$host") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, @PathParam("watcherName") String watcherName, + @PathParam("alertRuleResourceName") String alertRuleResourceName, @HeaderParam("Accept") String accept, + Context context); + + @Headers({ "Content-Type: application/json" }) + @Put("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/alertRuleResources/{alertRuleResourceName}") + @ExpectedResponses({ 200, 201 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> createOrUpdate(@HostParam("$host") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, @PathParam("watcherName") String watcherName, + @PathParam("alertRuleResourceName") String alertRuleResourceName, + @BodyParam("application/json") AlertRuleResourceInner resource, @HeaderParam("Accept") String accept, + Context context); + + @Headers({ "Content-Type: application/json" }) + @Delete("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/alertRuleResources/{alertRuleResourceName}") + @ExpectedResponses({ 200, 204 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> delete(@HostParam("$host") String endpoint, @QueryParam("api-version") String apiVersion, + @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, @PathParam("watcherName") String watcherName, + @PathParam("alertRuleResourceName") String alertRuleResourceName, @HeaderParam("Accept") String accept, + Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listByParentNext( + @PathParam(value = "nextLink", encoded = true) String nextLink, @HostParam("$host") String endpoint, + @HeaderParam("Accept") String accept, Context context); + } + + /** + * List AlertRuleResource resources by Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a AlertRuleResource list operation along with {@link PagedResponse} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByParentSinglePageAsync(String resourceGroupName, + String watcherName) { + 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 (watcherName == null) { + return Mono.error(new IllegalArgumentException("Parameter watcherName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.listByParent(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, watcherName, 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())); + } + + /** + * List AlertRuleResource resources by Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a AlertRuleResource list operation along with {@link PagedResponse} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByParentSinglePageAsync(String resourceGroupName, + String watcherName, 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 (watcherName == null) { + return Mono.error(new IllegalArgumentException("Parameter watcherName is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .listByParent(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), + resourceGroupName, watcherName, accept, context) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + res.getValue().value(), res.getValue().nextLink(), null)); + } + + /** + * List AlertRuleResource resources by Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a AlertRuleResource list operation as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listByParentAsync(String resourceGroupName, String watcherName) { + return new PagedFlux<>(() -> listByParentSinglePageAsync(resourceGroupName, watcherName), + nextLink -> listByParentNextSinglePageAsync(nextLink)); + } + + /** + * List AlertRuleResource resources by Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a AlertRuleResource list operation as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listByParentAsync(String resourceGroupName, String watcherName, + Context context) { + return new PagedFlux<>(() -> listByParentSinglePageAsync(resourceGroupName, watcherName, context), + nextLink -> listByParentNextSinglePageAsync(nextLink, context)); + } + + /** + * List AlertRuleResource resources by Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a AlertRuleResource list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listByParent(String resourceGroupName, String watcherName) { + return new PagedIterable<>(listByParentAsync(resourceGroupName, watcherName)); + } + + /** + * List AlertRuleResource resources by Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a AlertRuleResource list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listByParent(String resourceGroupName, String watcherName, + Context context) { + return new PagedIterable<>(listByParentAsync(resourceGroupName, watcherName, context)); + } + + /** + * Get a AlertRuleResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param alertRuleResourceName The alert rule proxy resource name. + * @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 AlertRuleResource along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getWithResponseAsync(String resourceGroupName, String watcherName, + String alertRuleResourceName) { + 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 (watcherName == null) { + return Mono.error(new IllegalArgumentException("Parameter watcherName is required and cannot be null.")); + } + if (alertRuleResourceName == null) { + return Mono + .error(new IllegalArgumentException("Parameter alertRuleResourceName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, watcherName, alertRuleResourceName, accept, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get a AlertRuleResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param alertRuleResourceName The alert rule proxy resource name. + * @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 AlertRuleResource along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getWithResponseAsync(String resourceGroupName, String watcherName, + String alertRuleResourceName, 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 (watcherName == null) { + return Mono.error(new IllegalArgumentException("Parameter watcherName is required and cannot be null.")); + } + if (alertRuleResourceName == null) { + return Mono + .error(new IllegalArgumentException("Parameter alertRuleResourceName is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.get(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), + resourceGroupName, watcherName, alertRuleResourceName, accept, context); + } + + /** + * Get a AlertRuleResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param alertRuleResourceName The alert rule proxy resource name. + * @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 AlertRuleResource on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono getAsync(String resourceGroupName, String watcherName, + String alertRuleResourceName) { + return getWithResponseAsync(resourceGroupName, watcherName, alertRuleResourceName) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Get a AlertRuleResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param alertRuleResourceName The alert rule proxy resource name. + * @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 AlertRuleResource along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(String resourceGroupName, String watcherName, + String alertRuleResourceName, Context context) { + return getWithResponseAsync(resourceGroupName, watcherName, alertRuleResourceName, context).block(); + } + + /** + * Get a AlertRuleResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param alertRuleResourceName The alert rule proxy resource name. + * @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 AlertRuleResource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public AlertRuleResourceInner get(String resourceGroupName, String watcherName, String alertRuleResourceName) { + return getWithResponse(resourceGroupName, watcherName, alertRuleResourceName, Context.NONE).getValue(); + } + + /** + * Create a AlertRuleResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param alertRuleResourceName The alert rule proxy resource name. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete proxy resource types can be created by aliasing this type using a specific property type along + * with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> createOrUpdateWithResponseAsync(String resourceGroupName, + String watcherName, String alertRuleResourceName, AlertRuleResourceInner resource) { + 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 (watcherName == null) { + return Mono.error(new IllegalArgumentException("Parameter watcherName is required and cannot be null.")); + } + if (alertRuleResourceName == null) { + return Mono + .error(new IllegalArgumentException("Parameter alertRuleResourceName is required and cannot be null.")); + } + if (resource == null) { + return Mono.error(new IllegalArgumentException("Parameter resource is required and cannot be null.")); + } else { + resource.validate(); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.createOrUpdate(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, watcherName, alertRuleResourceName, resource, + accept, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Create a AlertRuleResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param alertRuleResourceName The alert rule proxy resource name. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete proxy resource types can be created by aliasing this type using a specific property type along + * with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> createOrUpdateWithResponseAsync(String resourceGroupName, + String watcherName, String alertRuleResourceName, AlertRuleResourceInner resource, 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 (watcherName == null) { + return Mono.error(new IllegalArgumentException("Parameter watcherName is required and cannot be null.")); + } + if (alertRuleResourceName == null) { + return Mono + .error(new IllegalArgumentException("Parameter alertRuleResourceName is required and cannot be null.")); + } + if (resource == null) { + return Mono.error(new IllegalArgumentException("Parameter resource is required and cannot be null.")); + } else { + resource.validate(); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.createOrUpdate(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, watcherName, alertRuleResourceName, resource, accept, + context); + } + + /** + * Create a AlertRuleResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param alertRuleResourceName The alert rule proxy resource name. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete proxy resource types can be created by aliasing this type using a specific property type on + * successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono createOrUpdateAsync(String resourceGroupName, String watcherName, + String alertRuleResourceName, AlertRuleResourceInner resource) { + return createOrUpdateWithResponseAsync(resourceGroupName, watcherName, alertRuleResourceName, resource) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Create a AlertRuleResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param alertRuleResourceName The alert rule proxy resource name. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete proxy resource types can be created by aliasing this type using a specific property type along + * with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response createOrUpdateWithResponse(String resourceGroupName, String watcherName, + String alertRuleResourceName, AlertRuleResourceInner resource, Context context) { + return createOrUpdateWithResponseAsync(resourceGroupName, watcherName, alertRuleResourceName, resource, context) + .block(); + } + + /** + * Create a AlertRuleResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param alertRuleResourceName The alert rule proxy resource name. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete proxy resource types can be created by aliasing this type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public AlertRuleResourceInner createOrUpdate(String resourceGroupName, String watcherName, + String alertRuleResourceName, AlertRuleResourceInner resource) { + return createOrUpdateWithResponse(resourceGroupName, watcherName, alertRuleResourceName, resource, Context.NONE) + .getValue(); + } + + /** + * Delete a AlertRuleResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param alertRuleResourceName The alert rule proxy resource name. + * @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 watcherName, + String alertRuleResourceName) { + 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 (watcherName == null) { + return Mono.error(new IllegalArgumentException("Parameter watcherName is required and cannot be null.")); + } + if (alertRuleResourceName == null) { + return Mono + .error(new IllegalArgumentException("Parameter alertRuleResourceName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.delete(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, watcherName, alertRuleResourceName, accept, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Delete a AlertRuleResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param alertRuleResourceName The alert rule proxy resource name. + * @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 watcherName, + String alertRuleResourceName, 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 (watcherName == null) { + return Mono.error(new IllegalArgumentException("Parameter watcherName is required and cannot be null.")); + } + if (alertRuleResourceName == null) { + return Mono + .error(new IllegalArgumentException("Parameter alertRuleResourceName is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.delete(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), + resourceGroupName, watcherName, alertRuleResourceName, accept, context); + } + + /** + * Delete a AlertRuleResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param alertRuleResourceName The alert rule proxy resource name. + * @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 watcherName, String alertRuleResourceName) { + return deleteWithResponseAsync(resourceGroupName, watcherName, alertRuleResourceName) + .flatMap(ignored -> Mono.empty()); + } + + /** + * Delete a AlertRuleResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param alertRuleResourceName The alert rule proxy resource name. + * @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 watcherName, String alertRuleResourceName, + Context context) { + return deleteWithResponseAsync(resourceGroupName, watcherName, alertRuleResourceName, context).block(); + } + + /** + * Delete a AlertRuleResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param alertRuleResourceName The alert rule proxy resource name. + * @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 watcherName, String alertRuleResourceName) { + deleteWithResponse(resourceGroupName, watcherName, alertRuleResourceName, 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 the response of a AlertRuleResource list operation along with {@link PagedResponse} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByParentNextSinglePageAsync(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.listByParentNext(nextLink, this.client.getEndpoint(), accept, context)) + .>map(res -> new PagedResponseBase<>(res.getRequest(), + res.getStatusCode(), res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get the next page of items. + * + * @param nextLink The URL to get the next list of items. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a AlertRuleResource list operation along with {@link PagedResponse} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByParentNextSinglePageAsync(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.listByParentNext(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/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/implementation/AlertRuleResourcesImpl.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/implementation/AlertRuleResourcesImpl.java new file mode 100644 index 0000000000000..e4c3702e340d4 --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/implementation/AlertRuleResourcesImpl.java @@ -0,0 +1,159 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.databasewatcher.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.databasewatcher.fluent.AlertRuleResourcesClient; +import com.azure.resourcemanager.databasewatcher.fluent.models.AlertRuleResourceInner; +import com.azure.resourcemanager.databasewatcher.models.AlertRuleResource; +import com.azure.resourcemanager.databasewatcher.models.AlertRuleResources; + +public final class AlertRuleResourcesImpl implements AlertRuleResources { + private static final ClientLogger LOGGER = new ClientLogger(AlertRuleResourcesImpl.class); + + private final AlertRuleResourcesClient innerClient; + + private final com.azure.resourcemanager.databasewatcher.DatabasewatcherManager serviceManager; + + public AlertRuleResourcesImpl(AlertRuleResourcesClient innerClient, + com.azure.resourcemanager.databasewatcher.DatabasewatcherManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public PagedIterable listByParent(String resourceGroupName, String watcherName) { + PagedIterable inner = this.serviceClient().listByParent(resourceGroupName, watcherName); + return ResourceManagerUtils.mapPage(inner, inner1 -> new AlertRuleResourceImpl(inner1, this.manager())); + } + + public PagedIterable listByParent(String resourceGroupName, String watcherName, + Context context) { + PagedIterable inner + = this.serviceClient().listByParent(resourceGroupName, watcherName, context); + return ResourceManagerUtils.mapPage(inner, inner1 -> new AlertRuleResourceImpl(inner1, this.manager())); + } + + public Response getWithResponse(String resourceGroupName, String watcherName, + String alertRuleResourceName, Context context) { + Response inner + = this.serviceClient().getWithResponse(resourceGroupName, watcherName, alertRuleResourceName, context); + if (inner != null) { + return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(), + new AlertRuleResourceImpl(inner.getValue(), this.manager())); + } else { + return null; + } + } + + public AlertRuleResource get(String resourceGroupName, String watcherName, String alertRuleResourceName) { + AlertRuleResourceInner inner = this.serviceClient().get(resourceGroupName, watcherName, alertRuleResourceName); + if (inner != null) { + return new AlertRuleResourceImpl(inner, this.manager()); + } else { + return null; + } + } + + public Response deleteWithResponse(String resourceGroupName, String watcherName, String alertRuleResourceName, + Context context) { + return this.serviceClient().deleteWithResponse(resourceGroupName, watcherName, alertRuleResourceName, context); + } + + public void delete(String resourceGroupName, String watcherName, String alertRuleResourceName) { + this.serviceClient().delete(resourceGroupName, watcherName, alertRuleResourceName); + } + + public AlertRuleResource 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 watcherName = ResourceManagerUtils.getValueFromIdByName(id, "watchers"); + if (watcherName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'watchers'.", id))); + } + String alertRuleResourceName = ResourceManagerUtils.getValueFromIdByName(id, "alertRuleResources"); + if (alertRuleResourceName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'alertRuleResources'.", id))); + } + return this.getWithResponse(resourceGroupName, watcherName, alertRuleResourceName, 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 watcherName = ResourceManagerUtils.getValueFromIdByName(id, "watchers"); + if (watcherName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'watchers'.", id))); + } + String alertRuleResourceName = ResourceManagerUtils.getValueFromIdByName(id, "alertRuleResources"); + if (alertRuleResourceName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'alertRuleResources'.", id))); + } + return this.getWithResponse(resourceGroupName, watcherName, alertRuleResourceName, 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 watcherName = ResourceManagerUtils.getValueFromIdByName(id, "watchers"); + if (watcherName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'watchers'.", id))); + } + String alertRuleResourceName = ResourceManagerUtils.getValueFromIdByName(id, "alertRuleResources"); + if (alertRuleResourceName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'alertRuleResources'.", id))); + } + this.deleteWithResponse(resourceGroupName, watcherName, alertRuleResourceName, 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 watcherName = ResourceManagerUtils.getValueFromIdByName(id, "watchers"); + if (watcherName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'watchers'.", id))); + } + String alertRuleResourceName = ResourceManagerUtils.getValueFromIdByName(id, "alertRuleResources"); + if (alertRuleResourceName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'alertRuleResources'.", id))); + } + return this.deleteWithResponse(resourceGroupName, watcherName, alertRuleResourceName, context); + } + + private AlertRuleResourcesClient serviceClient() { + return this.innerClient; + } + + private com.azure.resourcemanager.databasewatcher.DatabasewatcherManager manager() { + return this.serviceManager; + } + + public AlertRuleResourceImpl define(String name) { + return new AlertRuleResourceImpl(name, this.manager()); + } +} diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/implementation/MicrosoftDatabaseWatcherBuilder.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/implementation/MicrosoftDatabaseWatcherBuilder.java new file mode 100644 index 0000000000000..90b14538b82a5 --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/implementation/MicrosoftDatabaseWatcherBuilder.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.databasewatcher.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 MicrosoftDatabaseWatcherImpl type. + */ +@ServiceClientBuilder(serviceClients = { MicrosoftDatabaseWatcherImpl.class }) +public final class MicrosoftDatabaseWatcherBuilder { + /* + * The ID of the target subscription. The value must be an UUID. + */ + private String subscriptionId; + + /** + * Sets The ID of the target subscription. The value must be an UUID. + * + * @param subscriptionId the subscriptionId value. + * @return the MicrosoftDatabaseWatcherBuilder. + */ + public MicrosoftDatabaseWatcherBuilder subscriptionId(String subscriptionId) { + this.subscriptionId = subscriptionId; + return this; + } + + /* + * server parameter + */ + private String endpoint; + + /** + * Sets server parameter. + * + * @param endpoint the endpoint value. + * @return the MicrosoftDatabaseWatcherBuilder. + */ + public MicrosoftDatabaseWatcherBuilder 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 MicrosoftDatabaseWatcherBuilder. + */ + public MicrosoftDatabaseWatcherBuilder 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 MicrosoftDatabaseWatcherBuilder. + */ + public MicrosoftDatabaseWatcherBuilder 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 MicrosoftDatabaseWatcherBuilder. + */ + public MicrosoftDatabaseWatcherBuilder 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 MicrosoftDatabaseWatcherBuilder. + */ + public MicrosoftDatabaseWatcherBuilder serializerAdapter(SerializerAdapter serializerAdapter) { + this.serializerAdapter = serializerAdapter; + return this; + } + + /** + * Builds an instance of MicrosoftDatabaseWatcherImpl with the provided parameters. + * + * @return an instance of MicrosoftDatabaseWatcherImpl. + */ + public MicrosoftDatabaseWatcherImpl 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(); + MicrosoftDatabaseWatcherImpl client = new MicrosoftDatabaseWatcherImpl(localPipeline, localSerializerAdapter, + localDefaultPollInterval, localEnvironment, this.subscriptionId, localEndpoint); + return client; + } +} diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/implementation/MicrosoftDatabaseWatcherImpl.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/implementation/MicrosoftDatabaseWatcherImpl.java new file mode 100644 index 0000000000000..528bc5241c7e8 --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/implementation/MicrosoftDatabaseWatcherImpl.java @@ -0,0 +1,352 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.databasewatcher.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.PollerFactory; +import com.azure.core.management.polling.PollResult; +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.databasewatcher.fluent.AlertRuleResourcesClient; +import com.azure.resourcemanager.databasewatcher.fluent.MicrosoftDatabaseWatcher; +import com.azure.resourcemanager.databasewatcher.fluent.OperationsClient; +import com.azure.resourcemanager.databasewatcher.fluent.SharedPrivateLinkResourcesClient; +import com.azure.resourcemanager.databasewatcher.fluent.TargetsClient; +import com.azure.resourcemanager.databasewatcher.fluent.WatchersClient; +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 MicrosoftDatabaseWatcherImpl type. + */ +@ServiceClient(builder = MicrosoftDatabaseWatcherBuilder.class) +public final class MicrosoftDatabaseWatcherImpl implements MicrosoftDatabaseWatcher { + /** + * The ID of the target subscription. The value must be an UUID. + */ + private final String subscriptionId; + + /** + * Gets The ID of the target subscription. The value must be an UUID. + * + * @return the subscriptionId value. + */ + public String getSubscriptionId() { + return this.subscriptionId; + } + + /** + * server parameter. + */ + private final String endpoint; + + /** + * Gets server parameter. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * Api Version. + */ + private final String apiVersion; + + /** + * Gets Api Version. + * + * @return the apiVersion value. + */ + public String getApiVersion() { + return this.apiVersion; + } + + /** + * The HTTP pipeline to send requests through. + */ + private final HttpPipeline httpPipeline; + + /** + * Gets The HTTP pipeline to send requests through. + * + * @return the httpPipeline value. + */ + public HttpPipeline getHttpPipeline() { + return this.httpPipeline; + } + + /** + * The serializer to serialize an object into a string. + */ + private final SerializerAdapter serializerAdapter; + + /** + * Gets The serializer to serialize an object into a string. + * + * @return the serializerAdapter value. + */ + SerializerAdapter getSerializerAdapter() { + return this.serializerAdapter; + } + + /** + * The default poll interval for long-running operation. + */ + private final Duration defaultPollInterval; + + /** + * Gets The default poll interval for long-running operation. + * + * @return the defaultPollInterval value. + */ + public Duration getDefaultPollInterval() { + return this.defaultPollInterval; + } + + /** + * The OperationsClient object to access its operations. + */ + private final OperationsClient operations; + + /** + * Gets the OperationsClient object to access its operations. + * + * @return the OperationsClient object. + */ + public OperationsClient getOperations() { + return this.operations; + } + + /** + * The WatchersClient object to access its operations. + */ + private final WatchersClient watchers; + + /** + * Gets the WatchersClient object to access its operations. + * + * @return the WatchersClient object. + */ + public WatchersClient getWatchers() { + return this.watchers; + } + + /** + * The AlertRuleResourcesClient object to access its operations. + */ + private final AlertRuleResourcesClient alertRuleResources; + + /** + * Gets the AlertRuleResourcesClient object to access its operations. + * + * @return the AlertRuleResourcesClient object. + */ + public AlertRuleResourcesClient getAlertRuleResources() { + return this.alertRuleResources; + } + + /** + * The SharedPrivateLinkResourcesClient object to access its operations. + */ + private final SharedPrivateLinkResourcesClient sharedPrivateLinkResources; + + /** + * Gets the SharedPrivateLinkResourcesClient object to access its operations. + * + * @return the SharedPrivateLinkResourcesClient object. + */ + public SharedPrivateLinkResourcesClient getSharedPrivateLinkResources() { + return this.sharedPrivateLinkResources; + } + + /** + * The TargetsClient object to access its operations. + */ + private final TargetsClient targets; + + /** + * Gets the TargetsClient object to access its operations. + * + * @return the TargetsClient object. + */ + public TargetsClient getTargets() { + return this.targets; + } + + /** + * Initializes an instance of MicrosoftDatabaseWatcher 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. The value must be an UUID. + * @param endpoint server parameter. + */ + MicrosoftDatabaseWatcherImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, + Duration defaultPollInterval, AzureEnvironment environment, String subscriptionId, String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.defaultPollInterval = defaultPollInterval; + this.subscriptionId = subscriptionId; + this.endpoint = endpoint; + this.apiVersion = "2024-07-19-preview"; + this.operations = new OperationsClientImpl(this); + this.watchers = new WatchersClientImpl(this); + this.alertRuleResources = new AlertRuleResourcesClientImpl(this); + this.sharedPrivateLinkResources = new SharedPrivateLinkResourcesClientImpl(this); + this.targets = new TargetsClientImpl(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(MicrosoftDatabaseWatcherImpl.class); +} diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/implementation/OperationImpl.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/implementation/OperationImpl.java new file mode 100644 index 0000000000000..c37d8fae05dd5 --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/implementation/OperationImpl.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.databasewatcher.implementation; + +import com.azure.resourcemanager.databasewatcher.fluent.models.OperationInner; +import com.azure.resourcemanager.databasewatcher.models.ActionType; +import com.azure.resourcemanager.databasewatcher.models.Operation; +import com.azure.resourcemanager.databasewatcher.models.OperationDisplay; +import com.azure.resourcemanager.databasewatcher.models.Origin; + +public final class OperationImpl implements Operation { + private OperationInner innerObject; + + private final com.azure.resourcemanager.databasewatcher.DatabasewatcherManager serviceManager; + + OperationImpl(OperationInner innerObject, + com.azure.resourcemanager.databasewatcher.DatabasewatcherManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + } + + public String name() { + return this.innerModel().name(); + } + + public Boolean isDataAction() { + return this.innerModel().isDataAction(); + } + + public OperationDisplay display() { + return this.innerModel().display(); + } + + public Origin origin() { + return this.innerModel().origin(); + } + + public ActionType actionType() { + return this.innerModel().actionType(); + } + + public OperationInner innerModel() { + return this.innerObject; + } + + private com.azure.resourcemanager.databasewatcher.DatabasewatcherManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/implementation/OperationsClientImpl.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/implementation/OperationsClientImpl.java new file mode 100644 index 0000000000000..0775d3c6f01e6 --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/implementation/OperationsClientImpl.java @@ -0,0 +1,235 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.databasewatcher.implementation; + +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Headers; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.PathParam; +import com.azure.core.annotation.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.databasewatcher.fluent.OperationsClient; +import com.azure.resourcemanager.databasewatcher.fluent.models.OperationInner; +import com.azure.resourcemanager.databasewatcher.models.OperationListResult; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in OperationsClient. + */ +public final class OperationsClientImpl implements OperationsClient { + /** + * The proxy service used to perform REST calls. + */ + private final OperationsService service; + + /** + * The service client containing this operation class. + */ + private final MicrosoftDatabaseWatcherImpl client; + + /** + * Initializes an instance of OperationsClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + OperationsClientImpl(MicrosoftDatabaseWatcherImpl client) { + this.service + = RestProxy.create(OperationsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for MicrosoftDatabaseWatcherOperations to be used by the proxy service to + * perform REST calls. + */ + @Host("{$host}") + @ServiceInterface(name = "MicrosoftDatabaseWat") + public interface OperationsService { + @Headers({ "Content-Type: application/json" }) + @Get("/providers/Microsoft.DatabaseWatcher/operations") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> list(@HostParam("$host") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listNext(@PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("$host") String endpoint, @HeaderParam("Accept") String accept, Context context); + } + + /** + * List the operations for the provider. + * + * @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 REST API operations supported by an Azure Resource Provider 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.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> service.list(this.client.getEndpoint(), this.client.getApiVersion(), accept, context)) + .>map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), + res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * List the operations for the provider. + * + * @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 REST API operations supported by an Azure Resource Provider 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.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.list(this.client.getEndpoint(), this.client.getApiVersion(), accept, context) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + res.getValue().value(), res.getValue().nextLink(), null)); + } + + /** + * List the operations for the provider. + * + * @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 REST API operations supported by an Azure Resource Provider as paginated response with + * {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync() { + return new PagedFlux<>(() -> listSinglePageAsync(), nextLink -> listNextSinglePageAsync(nextLink)); + } + + /** + * List the operations for the provider. + * + * @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 REST API operations supported by an Azure Resource Provider as paginated response with + * {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync(Context context) { + return new PagedFlux<>(() -> listSinglePageAsync(context), + nextLink -> listNextSinglePageAsync(nextLink, context)); + } + + /** + * List the operations for the provider. + * + * @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 REST API operations supported by an Azure Resource Provider as paginated response with + * {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list() { + return new PagedIterable<>(listAsync()); + } + + /** + * List the operations for the provider. + * + * @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 REST API operations supported by an Azure Resource Provider as paginated response with + * {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(Context context) { + return new PagedIterable<>(listAsync(context)); + } + + /** + * Get the next page of items. + * + * @param nextLink The URL to get the next list of items. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider along with {@link PagedResponse} on + * successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listNextSinglePageAsync(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.listNext(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 a list of REST API operations supported by an Azure Resource Provider along with {@link PagedResponse} on + * successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listNextSinglePageAsync(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.listNext(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/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/implementation/OperationsImpl.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/implementation/OperationsImpl.java new file mode 100644 index 0000000000000..0cb9f973b551e --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/implementation/OperationsImpl.java @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.databasewatcher.implementation; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.util.Context; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.databasewatcher.fluent.OperationsClient; +import com.azure.resourcemanager.databasewatcher.fluent.models.OperationInner; +import com.azure.resourcemanager.databasewatcher.models.Operation; +import com.azure.resourcemanager.databasewatcher.models.Operations; + +public final class OperationsImpl implements Operations { + private static final ClientLogger LOGGER = new ClientLogger(OperationsImpl.class); + + private final OperationsClient innerClient; + + private final com.azure.resourcemanager.databasewatcher.DatabasewatcherManager serviceManager; + + public OperationsImpl(OperationsClient innerClient, + com.azure.resourcemanager.databasewatcher.DatabasewatcherManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public PagedIterable list() { + PagedIterable inner = this.serviceClient().list(); + return ResourceManagerUtils.mapPage(inner, inner1 -> new OperationImpl(inner1, this.manager())); + } + + public PagedIterable list(Context context) { + PagedIterable inner = this.serviceClient().list(context); + return ResourceManagerUtils.mapPage(inner, inner1 -> new OperationImpl(inner1, this.manager())); + } + + private OperationsClient serviceClient() { + return this.innerClient; + } + + private com.azure.resourcemanager.databasewatcher.DatabasewatcherManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/implementation/ResourceManagerUtils.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/implementation/ResourceManagerUtils.java new file mode 100644 index 0000000000000..eae59eb18091a --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/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.databasewatcher.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/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/implementation/SharedPrivateLinkResourceImpl.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/implementation/SharedPrivateLinkResourceImpl.java new file mode 100644 index 0000000000000..01c927ffcae23 --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/implementation/SharedPrivateLinkResourceImpl.java @@ -0,0 +1,142 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.databasewatcher.implementation; + +import com.azure.core.management.SystemData; +import com.azure.core.util.Context; +import com.azure.resourcemanager.databasewatcher.fluent.models.SharedPrivateLinkResourceInner; +import com.azure.resourcemanager.databasewatcher.models.ResourceProvisioningState; +import com.azure.resourcemanager.databasewatcher.models.SharedPrivateLinkResource; +import com.azure.resourcemanager.databasewatcher.models.SharedPrivateLinkResourceStatus; + +public final class SharedPrivateLinkResourceImpl + implements SharedPrivateLinkResource, SharedPrivateLinkResource.Definition { + private SharedPrivateLinkResourceInner innerObject; + + private final com.azure.resourcemanager.databasewatcher.DatabasewatcherManager serviceManager; + + SharedPrivateLinkResourceImpl(SharedPrivateLinkResourceInner innerObject, + com.azure.resourcemanager.databasewatcher.DatabasewatcherManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + } + + public String id() { + return this.innerModel().id(); + } + + public String name() { + return this.innerModel().name(); + } + + public String type() { + return this.innerModel().type(); + } + + public SystemData systemData() { + return this.innerModel().systemData(); + } + + public String privateLinkResourceId() { + return this.innerModel().privateLinkResourceId(); + } + + public String groupId() { + return this.innerModel().groupId(); + } + + public String requestMessage() { + return this.innerModel().requestMessage(); + } + + public String dnsZone() { + return this.innerModel().dnsZone(); + } + + public SharedPrivateLinkResourceStatus status() { + return this.innerModel().status(); + } + + public ResourceProvisioningState provisioningState() { + return this.innerModel().provisioningState(); + } + + public SharedPrivateLinkResourceInner innerModel() { + return this.innerObject; + } + + private com.azure.resourcemanager.databasewatcher.DatabasewatcherManager manager() { + return this.serviceManager; + } + + private String resourceGroupName; + + private String watcherName; + + private String sharedPrivateLinkResourceName; + + public SharedPrivateLinkResourceImpl withExistingWatcher(String resourceGroupName, String watcherName) { + this.resourceGroupName = resourceGroupName; + this.watcherName = watcherName; + return this; + } + + public SharedPrivateLinkResource create() { + this.innerObject = serviceManager.serviceClient() + .getSharedPrivateLinkResources() + .create(resourceGroupName, watcherName, sharedPrivateLinkResourceName, this.innerModel(), Context.NONE); + return this; + } + + public SharedPrivateLinkResource create(Context context) { + this.innerObject = serviceManager.serviceClient() + .getSharedPrivateLinkResources() + .create(resourceGroupName, watcherName, sharedPrivateLinkResourceName, this.innerModel(), context); + return this; + } + + SharedPrivateLinkResourceImpl(String name, + com.azure.resourcemanager.databasewatcher.DatabasewatcherManager serviceManager) { + this.innerObject = new SharedPrivateLinkResourceInner(); + this.serviceManager = serviceManager; + this.sharedPrivateLinkResourceName = name; + } + + public SharedPrivateLinkResource refresh() { + this.innerObject = serviceManager.serviceClient() + .getSharedPrivateLinkResources() + .getWithResponse(resourceGroupName, watcherName, sharedPrivateLinkResourceName, Context.NONE) + .getValue(); + return this; + } + + public SharedPrivateLinkResource refresh(Context context) { + this.innerObject = serviceManager.serviceClient() + .getSharedPrivateLinkResources() + .getWithResponse(resourceGroupName, watcherName, sharedPrivateLinkResourceName, context) + .getValue(); + return this; + } + + public SharedPrivateLinkResourceImpl withPrivateLinkResourceId(String privateLinkResourceId) { + this.innerModel().withPrivateLinkResourceId(privateLinkResourceId); + return this; + } + + public SharedPrivateLinkResourceImpl withGroupId(String groupId) { + this.innerModel().withGroupId(groupId); + return this; + } + + public SharedPrivateLinkResourceImpl withRequestMessage(String requestMessage) { + this.innerModel().withRequestMessage(requestMessage); + return this; + } + + public SharedPrivateLinkResourceImpl withDnsZone(String dnsZone) { + this.innerModel().withDnsZone(dnsZone); + return this; + } +} diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/implementation/SharedPrivateLinkResourcesClientImpl.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/implementation/SharedPrivateLinkResourcesClientImpl.java new file mode 100644 index 0000000000000..7e6308b4ad806 --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/implementation/SharedPrivateLinkResourcesClientImpl.java @@ -0,0 +1,948 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.databasewatcher.implementation; + +import com.azure.core.annotation.BodyParam; +import com.azure.core.annotation.Delete; +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Headers; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.PathParam; +import com.azure.core.annotation.Put; +import com.azure.core.annotation.QueryParam; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.management.exception.ManagementException; +import com.azure.core.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.databasewatcher.fluent.SharedPrivateLinkResourcesClient; +import com.azure.resourcemanager.databasewatcher.fluent.models.SharedPrivateLinkResourceInner; +import com.azure.resourcemanager.databasewatcher.models.SharedPrivateLinkResourceListResult; +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 SharedPrivateLinkResourcesClient. + */ +public final class SharedPrivateLinkResourcesClientImpl implements SharedPrivateLinkResourcesClient { + /** + * The proxy service used to perform REST calls. + */ + private final SharedPrivateLinkResourcesService service; + + /** + * The service client containing this operation class. + */ + private final MicrosoftDatabaseWatcherImpl client; + + /** + * Initializes an instance of SharedPrivateLinkResourcesClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + SharedPrivateLinkResourcesClientImpl(MicrosoftDatabaseWatcherImpl client) { + this.service = RestProxy.create(SharedPrivateLinkResourcesService.class, client.getHttpPipeline(), + client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for MicrosoftDatabaseWatcherSharedPrivateLinkResources to be used by the + * proxy service to perform REST calls. + */ + @Host("{$host}") + @ServiceInterface(name = "MicrosoftDatabaseWat") + public interface SharedPrivateLinkResourcesService { + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/sharedPrivateLinkResources") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listByWatcher(@HostParam("$host") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, @PathParam("watcherName") String watcherName, + @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> get(@HostParam("$host") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, @PathParam("watcherName") String watcherName, + @PathParam("sharedPrivateLinkResourceName") String sharedPrivateLinkResourceName, + @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Put("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}") + @ExpectedResponses({ 200, 201 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono>> create(@HostParam("$host") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, @PathParam("watcherName") String watcherName, + @PathParam("sharedPrivateLinkResourceName") String sharedPrivateLinkResourceName, + @BodyParam("application/json") SharedPrivateLinkResourceInner resource, + @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Delete("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}") + @ExpectedResponses({ 202, 204 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono>> delete(@HostParam("$host") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, @PathParam("watcherName") String watcherName, + @PathParam("sharedPrivateLinkResourceName") String sharedPrivateLinkResourceName, + @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listByWatcherNext( + @PathParam(value = "nextLink", encoded = true) String nextLink, @HostParam("$host") String endpoint, + @HeaderParam("Accept") String accept, Context context); + } + + /** + * List SharedPrivateLinkResource resources by Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a SharedPrivateLinkResource list operation along with {@link PagedResponse} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByWatcherSinglePageAsync(String resourceGroupName, + String watcherName) { + 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 (watcherName == null) { + return Mono.error(new IllegalArgumentException("Parameter watcherName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.listByWatcher(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, watcherName, 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())); + } + + /** + * List SharedPrivateLinkResource resources by Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a SharedPrivateLinkResource list operation along with {@link PagedResponse} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByWatcherSinglePageAsync(String resourceGroupName, + String watcherName, 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 (watcherName == null) { + return Mono.error(new IllegalArgumentException("Parameter watcherName is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .listByWatcher(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), + resourceGroupName, watcherName, accept, context) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + res.getValue().value(), res.getValue().nextLink(), null)); + } + + /** + * List SharedPrivateLinkResource resources by Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a SharedPrivateLinkResource list operation as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listByWatcherAsync(String resourceGroupName, String watcherName) { + return new PagedFlux<>(() -> listByWatcherSinglePageAsync(resourceGroupName, watcherName), + nextLink -> listByWatcherNextSinglePageAsync(nextLink)); + } + + /** + * List SharedPrivateLinkResource resources by Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a SharedPrivateLinkResource list operation as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listByWatcherAsync(String resourceGroupName, String watcherName, + Context context) { + return new PagedFlux<>(() -> listByWatcherSinglePageAsync(resourceGroupName, watcherName, context), + nextLink -> listByWatcherNextSinglePageAsync(nextLink, context)); + } + + /** + * List SharedPrivateLinkResource resources by Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a SharedPrivateLinkResource list operation as paginated response with + * {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listByWatcher(String resourceGroupName, String watcherName) { + return new PagedIterable<>(listByWatcherAsync(resourceGroupName, watcherName)); + } + + /** + * List SharedPrivateLinkResource resources by Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a SharedPrivateLinkResource list operation as paginated response with + * {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listByWatcher(String resourceGroupName, String watcherName, + Context context) { + return new PagedIterable<>(listByWatcherAsync(resourceGroupName, watcherName, context)); + } + + /** + * Get a SharedPrivateLinkResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param sharedPrivateLinkResourceName The Shared Private Link resource name. + * @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 SharedPrivateLinkResource along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getWithResponseAsync(String resourceGroupName, + String watcherName, String sharedPrivateLinkResourceName) { + 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 (watcherName == null) { + return Mono.error(new IllegalArgumentException("Parameter watcherName is required and cannot be null.")); + } + if (sharedPrivateLinkResourceName == null) { + return Mono.error(new IllegalArgumentException( + "Parameter sharedPrivateLinkResourceName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.get(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, watcherName, sharedPrivateLinkResourceName, accept, + context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get a SharedPrivateLinkResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param sharedPrivateLinkResourceName The Shared Private Link resource name. + * @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 SharedPrivateLinkResource along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getWithResponseAsync(String resourceGroupName, + String watcherName, String sharedPrivateLinkResourceName, 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 (watcherName == null) { + return Mono.error(new IllegalArgumentException("Parameter watcherName is required and cannot be null.")); + } + if (sharedPrivateLinkResourceName == null) { + return Mono.error(new IllegalArgumentException( + "Parameter sharedPrivateLinkResourceName is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.get(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), + resourceGroupName, watcherName, sharedPrivateLinkResourceName, accept, context); + } + + /** + * Get a SharedPrivateLinkResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param sharedPrivateLinkResourceName The Shared Private Link resource name. + * @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 SharedPrivateLinkResource on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono getAsync(String resourceGroupName, String watcherName, + String sharedPrivateLinkResourceName) { + return getWithResponseAsync(resourceGroupName, watcherName, sharedPrivateLinkResourceName) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Get a SharedPrivateLinkResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param sharedPrivateLinkResourceName The Shared Private Link resource name. + * @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 SharedPrivateLinkResource along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(String resourceGroupName, String watcherName, + String sharedPrivateLinkResourceName, Context context) { + return getWithResponseAsync(resourceGroupName, watcherName, sharedPrivateLinkResourceName, context).block(); + } + + /** + * Get a SharedPrivateLinkResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param sharedPrivateLinkResourceName The Shared Private Link resource name. + * @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 SharedPrivateLinkResource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public SharedPrivateLinkResourceInner get(String resourceGroupName, String watcherName, + String sharedPrivateLinkResourceName) { + return getWithResponse(resourceGroupName, watcherName, sharedPrivateLinkResourceName, Context.NONE).getValue(); + } + + /** + * Create a SharedPrivateLinkResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param sharedPrivateLinkResourceName The Shared Private Link resource name. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete proxy resource types can be created by aliasing this type using a specific property type along + * with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> createWithResponseAsync(String resourceGroupName, String watcherName, + String sharedPrivateLinkResourceName, SharedPrivateLinkResourceInner resource) { + 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 (watcherName == null) { + return Mono.error(new IllegalArgumentException("Parameter watcherName is required and cannot be null.")); + } + if (sharedPrivateLinkResourceName == null) { + return Mono.error(new IllegalArgumentException( + "Parameter sharedPrivateLinkResourceName is required and cannot be null.")); + } + if (resource == null) { + return Mono.error(new IllegalArgumentException("Parameter resource is required and cannot be null.")); + } else { + resource.validate(); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.create(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, watcherName, sharedPrivateLinkResourceName, + resource, accept, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Create a SharedPrivateLinkResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param sharedPrivateLinkResourceName The Shared Private Link resource name. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete proxy resource types can be created by aliasing this type using a specific property type along + * with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> createWithResponseAsync(String resourceGroupName, String watcherName, + String sharedPrivateLinkResourceName, SharedPrivateLinkResourceInner resource, 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 (watcherName == null) { + return Mono.error(new IllegalArgumentException("Parameter watcherName is required and cannot be null.")); + } + if (sharedPrivateLinkResourceName == null) { + return Mono.error(new IllegalArgumentException( + "Parameter sharedPrivateLinkResourceName is required and cannot be null.")); + } + if (resource == null) { + return Mono.error(new IllegalArgumentException("Parameter resource is required and cannot be null.")); + } else { + resource.validate(); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.create(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), + resourceGroupName, watcherName, sharedPrivateLinkResourceName, resource, accept, context); + } + + /** + * Create a SharedPrivateLinkResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param sharedPrivateLinkResourceName The Shared Private Link resource name. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link PollerFlux} for polling of concrete proxy resource types can be created by aliasing this type + * using a specific property type. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, SharedPrivateLinkResourceInner> beginCreateAsync( + String resourceGroupName, String watcherName, String sharedPrivateLinkResourceName, + SharedPrivateLinkResourceInner resource) { + Mono>> mono + = createWithResponseAsync(resourceGroupName, watcherName, sharedPrivateLinkResourceName, resource); + return this.client.getLroResult(mono, + this.client.getHttpPipeline(), SharedPrivateLinkResourceInner.class, SharedPrivateLinkResourceInner.class, + this.client.getContext()); + } + + /** + * Create a SharedPrivateLinkResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param sharedPrivateLinkResourceName The Shared Private Link resource name. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link PollerFlux} for polling of concrete proxy resource types can be created by aliasing this type + * using a specific property type. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, SharedPrivateLinkResourceInner> beginCreateAsync( + String resourceGroupName, String watcherName, String sharedPrivateLinkResourceName, + SharedPrivateLinkResourceInner resource, Context context) { + context = this.client.mergeContext(context); + Mono>> mono + = createWithResponseAsync(resourceGroupName, watcherName, sharedPrivateLinkResourceName, resource, context); + return this.client.getLroResult(mono, + this.client.getHttpPipeline(), SharedPrivateLinkResourceInner.class, SharedPrivateLinkResourceInner.class, + context); + } + + /** + * Create a SharedPrivateLinkResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param sharedPrivateLinkResourceName The Shared Private Link resource name. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of concrete proxy resource types can be created by aliasing this type + * using a specific property type. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, SharedPrivateLinkResourceInner> beginCreate( + String resourceGroupName, String watcherName, String sharedPrivateLinkResourceName, + SharedPrivateLinkResourceInner resource) { + return this.beginCreateAsync(resourceGroupName, watcherName, sharedPrivateLinkResourceName, resource) + .getSyncPoller(); + } + + /** + * Create a SharedPrivateLinkResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param sharedPrivateLinkResourceName The Shared Private Link resource name. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of concrete proxy resource types can be created by aliasing this type + * using a specific property type. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, SharedPrivateLinkResourceInner> beginCreate( + String resourceGroupName, String watcherName, String sharedPrivateLinkResourceName, + SharedPrivateLinkResourceInner resource, Context context) { + return this.beginCreateAsync(resourceGroupName, watcherName, sharedPrivateLinkResourceName, resource, context) + .getSyncPoller(); + } + + /** + * Create a SharedPrivateLinkResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param sharedPrivateLinkResourceName The Shared Private Link resource name. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete proxy resource types can be created by aliasing this type using a specific property type on + * successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono createAsync(String resourceGroupName, String watcherName, + String sharedPrivateLinkResourceName, SharedPrivateLinkResourceInner resource) { + return beginCreateAsync(resourceGroupName, watcherName, sharedPrivateLinkResourceName, resource).last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Create a SharedPrivateLinkResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param sharedPrivateLinkResourceName The Shared Private Link resource name. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete proxy resource types can be created by aliasing this type using a specific property type on + * successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono createAsync(String resourceGroupName, String watcherName, + String sharedPrivateLinkResourceName, SharedPrivateLinkResourceInner resource, Context context) { + return beginCreateAsync(resourceGroupName, watcherName, sharedPrivateLinkResourceName, resource, context).last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Create a SharedPrivateLinkResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param sharedPrivateLinkResourceName The Shared Private Link resource name. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete proxy resource types can be created by aliasing this type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public SharedPrivateLinkResourceInner create(String resourceGroupName, String watcherName, + String sharedPrivateLinkResourceName, SharedPrivateLinkResourceInner resource) { + return createAsync(resourceGroupName, watcherName, sharedPrivateLinkResourceName, resource).block(); + } + + /** + * Create a SharedPrivateLinkResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param sharedPrivateLinkResourceName The Shared Private Link resource name. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete proxy resource types can be created by aliasing this type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public SharedPrivateLinkResourceInner create(String resourceGroupName, String watcherName, + String sharedPrivateLinkResourceName, SharedPrivateLinkResourceInner resource, Context context) { + return createAsync(resourceGroupName, watcherName, sharedPrivateLinkResourceName, resource, context).block(); + } + + /** + * Delete a SharedPrivateLinkResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param sharedPrivateLinkResourceName The Shared Private Link resource name. + * @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 watcherName, + String sharedPrivateLinkResourceName) { + 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 (watcherName == null) { + return Mono.error(new IllegalArgumentException("Parameter watcherName is required and cannot be null.")); + } + if (sharedPrivateLinkResourceName == null) { + return Mono.error(new IllegalArgumentException( + "Parameter sharedPrivateLinkResourceName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.delete(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, watcherName, sharedPrivateLinkResourceName, accept, + context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Delete a SharedPrivateLinkResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param sharedPrivateLinkResourceName The Shared Private Link resource name. + * @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 watcherName, + String sharedPrivateLinkResourceName, 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 (watcherName == null) { + return Mono.error(new IllegalArgumentException("Parameter watcherName is required and cannot be null.")); + } + if (sharedPrivateLinkResourceName == null) { + return Mono.error(new IllegalArgumentException( + "Parameter sharedPrivateLinkResourceName is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.delete(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), + resourceGroupName, watcherName, sharedPrivateLinkResourceName, accept, context); + } + + /** + * Delete a SharedPrivateLinkResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param sharedPrivateLinkResourceName The Shared Private Link resource name. + * @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 long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, Void> beginDeleteAsync(String resourceGroupName, String watcherName, + String sharedPrivateLinkResourceName) { + Mono>> mono + = deleteWithResponseAsync(resourceGroupName, watcherName, sharedPrivateLinkResourceName); + return this.client.getLroResult(mono, this.client.getHttpPipeline(), Void.class, Void.class, + this.client.getContext()); + } + + /** + * Delete a SharedPrivateLinkResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param sharedPrivateLinkResourceName The Shared Private Link resource name. + * @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 long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, Void> beginDeleteAsync(String resourceGroupName, String watcherName, + String sharedPrivateLinkResourceName, Context context) { + context = this.client.mergeContext(context); + Mono>> mono + = deleteWithResponseAsync(resourceGroupName, watcherName, sharedPrivateLinkResourceName, context); + return this.client.getLroResult(mono, this.client.getHttpPipeline(), Void.class, Void.class, + context); + } + + /** + * Delete a SharedPrivateLinkResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param sharedPrivateLinkResourceName The Shared Private Link resource name. + * @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 long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, Void> beginDelete(String resourceGroupName, String watcherName, + String sharedPrivateLinkResourceName) { + return this.beginDeleteAsync(resourceGroupName, watcherName, sharedPrivateLinkResourceName).getSyncPoller(); + } + + /** + * Delete a SharedPrivateLinkResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param sharedPrivateLinkResourceName The Shared Private Link resource name. + * @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 long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, Void> beginDelete(String resourceGroupName, String watcherName, + String sharedPrivateLinkResourceName, Context context) { + return this.beginDeleteAsync(resourceGroupName, watcherName, sharedPrivateLinkResourceName, context) + .getSyncPoller(); + } + + /** + * Delete a SharedPrivateLinkResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param sharedPrivateLinkResourceName The Shared Private Link resource name. + * @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 watcherName, String sharedPrivateLinkResourceName) { + return beginDeleteAsync(resourceGroupName, watcherName, sharedPrivateLinkResourceName).last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Delete a SharedPrivateLinkResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param sharedPrivateLinkResourceName The Shared Private Link resource name. + * @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 {@link Mono} that completes when a successful response is received. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono deleteAsync(String resourceGroupName, String watcherName, String sharedPrivateLinkResourceName, + Context context) { + return beginDeleteAsync(resourceGroupName, watcherName, sharedPrivateLinkResourceName, context).last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Delete a SharedPrivateLinkResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param sharedPrivateLinkResourceName The Shared Private Link resource name. + * @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 watcherName, String sharedPrivateLinkResourceName) { + deleteAsync(resourceGroupName, watcherName, sharedPrivateLinkResourceName).block(); + } + + /** + * Delete a SharedPrivateLinkResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param sharedPrivateLinkResourceName The Shared Private Link resource name. + * @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. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public void delete(String resourceGroupName, String watcherName, String sharedPrivateLinkResourceName, + Context context) { + deleteAsync(resourceGroupName, watcherName, sharedPrivateLinkResourceName, context).block(); + } + + /** + * Get the next page of items. + * + * @param nextLink The URL to get the next list of items. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a SharedPrivateLinkResource list operation along with {@link PagedResponse} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByWatcherNextSinglePageAsync(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.listByWatcherNext(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 the response of a SharedPrivateLinkResource list operation along with {@link PagedResponse} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByWatcherNextSinglePageAsync(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.listByWatcherNext(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/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/implementation/SharedPrivateLinkResourcesImpl.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/implementation/SharedPrivateLinkResourcesImpl.java new file mode 100644 index 0000000000000..97d0b6d35dd10 --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/implementation/SharedPrivateLinkResourcesImpl.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.databasewatcher.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.databasewatcher.fluent.SharedPrivateLinkResourcesClient; +import com.azure.resourcemanager.databasewatcher.fluent.models.SharedPrivateLinkResourceInner; +import com.azure.resourcemanager.databasewatcher.models.SharedPrivateLinkResource; +import com.azure.resourcemanager.databasewatcher.models.SharedPrivateLinkResources; + +public final class SharedPrivateLinkResourcesImpl implements SharedPrivateLinkResources { + private static final ClientLogger LOGGER = new ClientLogger(SharedPrivateLinkResourcesImpl.class); + + private final SharedPrivateLinkResourcesClient innerClient; + + private final com.azure.resourcemanager.databasewatcher.DatabasewatcherManager serviceManager; + + public SharedPrivateLinkResourcesImpl(SharedPrivateLinkResourcesClient innerClient, + com.azure.resourcemanager.databasewatcher.DatabasewatcherManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public PagedIterable listByWatcher(String resourceGroupName, String watcherName) { + PagedIterable inner + = this.serviceClient().listByWatcher(resourceGroupName, watcherName); + return ResourceManagerUtils.mapPage(inner, inner1 -> new SharedPrivateLinkResourceImpl(inner1, this.manager())); + } + + public PagedIterable listByWatcher(String resourceGroupName, String watcherName, + Context context) { + PagedIterable inner + = this.serviceClient().listByWatcher(resourceGroupName, watcherName, context); + return ResourceManagerUtils.mapPage(inner, inner1 -> new SharedPrivateLinkResourceImpl(inner1, this.manager())); + } + + public Response getWithResponse(String resourceGroupName, String watcherName, + String sharedPrivateLinkResourceName, Context context) { + Response inner = this.serviceClient() + .getWithResponse(resourceGroupName, watcherName, sharedPrivateLinkResourceName, context); + if (inner != null) { + return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(), + new SharedPrivateLinkResourceImpl(inner.getValue(), this.manager())); + } else { + return null; + } + } + + public SharedPrivateLinkResource get(String resourceGroupName, String watcherName, + String sharedPrivateLinkResourceName) { + SharedPrivateLinkResourceInner inner + = this.serviceClient().get(resourceGroupName, watcherName, sharedPrivateLinkResourceName); + if (inner != null) { + return new SharedPrivateLinkResourceImpl(inner, this.manager()); + } else { + return null; + } + } + + public void delete(String resourceGroupName, String watcherName, String sharedPrivateLinkResourceName) { + this.serviceClient().delete(resourceGroupName, watcherName, sharedPrivateLinkResourceName); + } + + public void delete(String resourceGroupName, String watcherName, String sharedPrivateLinkResourceName, + Context context) { + this.serviceClient().delete(resourceGroupName, watcherName, sharedPrivateLinkResourceName, context); + } + + public SharedPrivateLinkResource 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 watcherName = ResourceManagerUtils.getValueFromIdByName(id, "watchers"); + if (watcherName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'watchers'.", id))); + } + String sharedPrivateLinkResourceName + = ResourceManagerUtils.getValueFromIdByName(id, "sharedPrivateLinkResources"); + if (sharedPrivateLinkResourceName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException(String + .format("The resource ID '%s' is not valid. Missing path segment 'sharedPrivateLinkResources'.", id))); + } + return this.getWithResponse(resourceGroupName, watcherName, sharedPrivateLinkResourceName, 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 watcherName = ResourceManagerUtils.getValueFromIdByName(id, "watchers"); + if (watcherName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'watchers'.", id))); + } + String sharedPrivateLinkResourceName + = ResourceManagerUtils.getValueFromIdByName(id, "sharedPrivateLinkResources"); + if (sharedPrivateLinkResourceName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException(String + .format("The resource ID '%s' is not valid. Missing path segment 'sharedPrivateLinkResources'.", id))); + } + return this.getWithResponse(resourceGroupName, watcherName, sharedPrivateLinkResourceName, 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 watcherName = ResourceManagerUtils.getValueFromIdByName(id, "watchers"); + if (watcherName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'watchers'.", id))); + } + String sharedPrivateLinkResourceName + = ResourceManagerUtils.getValueFromIdByName(id, "sharedPrivateLinkResources"); + if (sharedPrivateLinkResourceName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException(String + .format("The resource ID '%s' is not valid. Missing path segment 'sharedPrivateLinkResources'.", id))); + } + this.delete(resourceGroupName, watcherName, sharedPrivateLinkResourceName, Context.NONE); + } + + public void 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 watcherName = ResourceManagerUtils.getValueFromIdByName(id, "watchers"); + if (watcherName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'watchers'.", id))); + } + String sharedPrivateLinkResourceName + = ResourceManagerUtils.getValueFromIdByName(id, "sharedPrivateLinkResources"); + if (sharedPrivateLinkResourceName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException(String + .format("The resource ID '%s' is not valid. Missing path segment 'sharedPrivateLinkResources'.", id))); + } + this.delete(resourceGroupName, watcherName, sharedPrivateLinkResourceName, context); + } + + private SharedPrivateLinkResourcesClient serviceClient() { + return this.innerClient; + } + + private com.azure.resourcemanager.databasewatcher.DatabasewatcherManager manager() { + return this.serviceManager; + } + + public SharedPrivateLinkResourceImpl define(String name) { + return new SharedPrivateLinkResourceImpl(name, this.manager()); + } +} diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/implementation/TargetImpl.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/implementation/TargetImpl.java new file mode 100644 index 0000000000000..b98a854c0141b --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/implementation/TargetImpl.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.databasewatcher.implementation; + +import com.azure.core.management.SystemData; +import com.azure.core.util.Context; +import com.azure.resourcemanager.databasewatcher.fluent.models.TargetInner; +import com.azure.resourcemanager.databasewatcher.models.Target; +import com.azure.resourcemanager.databasewatcher.models.TargetProperties; + +public final class TargetImpl implements Target, Target.Definition, Target.Update { + private TargetInner innerObject; + + private final com.azure.resourcemanager.databasewatcher.DatabasewatcherManager serviceManager; + + public String id() { + return this.innerModel().id(); + } + + public String name() { + return this.innerModel().name(); + } + + public String type() { + return this.innerModel().type(); + } + + public TargetProperties properties() { + return this.innerModel().properties(); + } + + public SystemData systemData() { + return this.innerModel().systemData(); + } + + public String resourceGroupName() { + return resourceGroupName; + } + + public TargetInner innerModel() { + return this.innerObject; + } + + private com.azure.resourcemanager.databasewatcher.DatabasewatcherManager manager() { + return this.serviceManager; + } + + private String resourceGroupName; + + private String watcherName; + + private String targetName; + + public TargetImpl withExistingWatcher(String resourceGroupName, String watcherName) { + this.resourceGroupName = resourceGroupName; + this.watcherName = watcherName; + return this; + } + + public Target create() { + this.innerObject = serviceManager.serviceClient() + .getTargets() + .createOrUpdateWithResponse(resourceGroupName, watcherName, targetName, this.innerModel(), Context.NONE) + .getValue(); + return this; + } + + public Target create(Context context) { + this.innerObject = serviceManager.serviceClient() + .getTargets() + .createOrUpdateWithResponse(resourceGroupName, watcherName, targetName, this.innerModel(), context) + .getValue(); + return this; + } + + TargetImpl(String name, com.azure.resourcemanager.databasewatcher.DatabasewatcherManager serviceManager) { + this.innerObject = new TargetInner(); + this.serviceManager = serviceManager; + this.targetName = name; + } + + public TargetImpl update() { + return this; + } + + public Target apply() { + this.innerObject = serviceManager.serviceClient() + .getTargets() + .createOrUpdateWithResponse(resourceGroupName, watcherName, targetName, this.innerModel(), Context.NONE) + .getValue(); + return this; + } + + public Target apply(Context context) { + this.innerObject = serviceManager.serviceClient() + .getTargets() + .createOrUpdateWithResponse(resourceGroupName, watcherName, targetName, this.innerModel(), context) + .getValue(); + return this; + } + + TargetImpl(TargetInner innerObject, + com.azure.resourcemanager.databasewatcher.DatabasewatcherManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + this.resourceGroupName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "resourceGroups"); + this.watcherName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "watchers"); + this.targetName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "targets"); + } + + public Target refresh() { + this.innerObject = serviceManager.serviceClient() + .getTargets() + .getWithResponse(resourceGroupName, watcherName, targetName, Context.NONE) + .getValue(); + return this; + } + + public Target refresh(Context context) { + this.innerObject = serviceManager.serviceClient() + .getTargets() + .getWithResponse(resourceGroupName, watcherName, targetName, context) + .getValue(); + return this; + } + + public TargetImpl withProperties(TargetProperties properties) { + this.innerModel().withProperties(properties); + return this; + } +} diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/implementation/TargetsClientImpl.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/implementation/TargetsClientImpl.java new file mode 100644 index 0000000000000..81a3657762014 --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/implementation/TargetsClientImpl.java @@ -0,0 +1,714 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.databasewatcher.implementation; + +import com.azure.core.annotation.BodyParam; +import com.azure.core.annotation.Delete; +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Headers; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.PathParam; +import com.azure.core.annotation.Put; +import com.azure.core.annotation.QueryParam; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.management.exception.ManagementException; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import com.azure.resourcemanager.databasewatcher.fluent.TargetsClient; +import com.azure.resourcemanager.databasewatcher.fluent.models.TargetInner; +import com.azure.resourcemanager.databasewatcher.models.TargetListResult; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in TargetsClient. + */ +public final class TargetsClientImpl implements TargetsClient { + /** + * The proxy service used to perform REST calls. + */ + private final TargetsService service; + + /** + * The service client containing this operation class. + */ + private final MicrosoftDatabaseWatcherImpl client; + + /** + * Initializes an instance of TargetsClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + TargetsClientImpl(MicrosoftDatabaseWatcherImpl client) { + this.service = RestProxy.create(TargetsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for MicrosoftDatabaseWatcherTargets to be used by the proxy service to + * perform REST calls. + */ + @Host("{$host}") + @ServiceInterface(name = "MicrosoftDatabaseWat") + public interface TargetsService { + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/targets") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listByWatcher(@HostParam("$host") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, @PathParam("watcherName") String watcherName, + @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/targets/{targetName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> get(@HostParam("$host") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, @PathParam("watcherName") String watcherName, + @PathParam("targetName") String targetName, @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Put("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/targets/{targetName}") + @ExpectedResponses({ 200, 201 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> createOrUpdate(@HostParam("$host") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, @PathParam("watcherName") String watcherName, + @PathParam("targetName") String targetName, @BodyParam("application/json") TargetInner resource, + @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Delete("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/targets/{targetName}") + @ExpectedResponses({ 200, 204 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> delete(@HostParam("$host") String endpoint, @QueryParam("api-version") String apiVersion, + @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, @PathParam("watcherName") String watcherName, + @PathParam("targetName") String targetName, @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listByWatcherNext( + @PathParam(value = "nextLink", encoded = true) String nextLink, @HostParam("$host") String endpoint, + @HeaderParam("Accept") String accept, Context context); + } + + /** + * List Target resources by Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Target list operation along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByWatcherSinglePageAsync(String resourceGroupName, + String watcherName) { + 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 (watcherName == null) { + return Mono.error(new IllegalArgumentException("Parameter watcherName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.listByWatcher(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, watcherName, 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())); + } + + /** + * List Target resources by Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Target list operation along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByWatcherSinglePageAsync(String resourceGroupName, String watcherName, + 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 (watcherName == null) { + return Mono.error(new IllegalArgumentException("Parameter watcherName is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .listByWatcher(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), + resourceGroupName, watcherName, accept, context) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + res.getValue().value(), res.getValue().nextLink(), null)); + } + + /** + * List Target resources by Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Target list operation as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listByWatcherAsync(String resourceGroupName, String watcherName) { + return new PagedFlux<>(() -> listByWatcherSinglePageAsync(resourceGroupName, watcherName), + nextLink -> listByWatcherNextSinglePageAsync(nextLink)); + } + + /** + * List Target resources by Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Target list operation as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listByWatcherAsync(String resourceGroupName, String watcherName, Context context) { + return new PagedFlux<>(() -> listByWatcherSinglePageAsync(resourceGroupName, watcherName, context), + nextLink -> listByWatcherNextSinglePageAsync(nextLink, context)); + } + + /** + * List Target resources by Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Target list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listByWatcher(String resourceGroupName, String watcherName) { + return new PagedIterable<>(listByWatcherAsync(resourceGroupName, watcherName)); + } + + /** + * List Target resources by Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Target list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listByWatcher(String resourceGroupName, String watcherName, Context context) { + return new PagedIterable<>(listByWatcherAsync(resourceGroupName, watcherName, context)); + } + + /** + * Get a Target. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param targetName The target resource name. + * @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 Target along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getWithResponseAsync(String resourceGroupName, String watcherName, + String targetName) { + 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 (watcherName == null) { + return Mono.error(new IllegalArgumentException("Parameter watcherName is required and cannot be null.")); + } + if (targetName == null) { + return Mono.error(new IllegalArgumentException("Parameter targetName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.get(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, watcherName, targetName, accept, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get a Target. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param targetName The target resource name. + * @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 Target along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getWithResponseAsync(String resourceGroupName, String watcherName, + String targetName, 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 (watcherName == null) { + return Mono.error(new IllegalArgumentException("Parameter watcherName is required and cannot be null.")); + } + if (targetName == null) { + return Mono.error(new IllegalArgumentException("Parameter targetName is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.get(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), + resourceGroupName, watcherName, targetName, accept, context); + } + + /** + * Get a Target. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param targetName The target resource name. + * @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 Target on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono getAsync(String resourceGroupName, String watcherName, String targetName) { + return getWithResponseAsync(resourceGroupName, watcherName, targetName) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Get a Target. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param targetName The target resource name. + * @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 Target along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(String resourceGroupName, String watcherName, String targetName, + Context context) { + return getWithResponseAsync(resourceGroupName, watcherName, targetName, context).block(); + } + + /** + * Get a Target. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param targetName The target resource name. + * @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 Target. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public TargetInner get(String resourceGroupName, String watcherName, String targetName) { + return getWithResponse(resourceGroupName, watcherName, targetName, Context.NONE).getValue(); + } + + /** + * Create a Target. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param targetName The target resource name. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete proxy resource types can be created by aliasing this type using a specific property type along + * with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> createOrUpdateWithResponseAsync(String resourceGroupName, String watcherName, + String targetName, TargetInner resource) { + 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 (watcherName == null) { + return Mono.error(new IllegalArgumentException("Parameter watcherName is required and cannot be null.")); + } + if (targetName == null) { + return Mono.error(new IllegalArgumentException("Parameter targetName is required and cannot be null.")); + } + if (resource == null) { + return Mono.error(new IllegalArgumentException("Parameter resource is required and cannot be null.")); + } else { + resource.validate(); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.createOrUpdate(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, watcherName, targetName, resource, accept, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Create a Target. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param targetName The target resource name. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete proxy resource types can be created by aliasing this type using a specific property type along + * with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> createOrUpdateWithResponseAsync(String resourceGroupName, String watcherName, + String targetName, TargetInner resource, 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 (watcherName == null) { + return Mono.error(new IllegalArgumentException("Parameter watcherName is required and cannot be null.")); + } + if (targetName == null) { + return Mono.error(new IllegalArgumentException("Parameter targetName is required and cannot be null.")); + } + if (resource == null) { + return Mono.error(new IllegalArgumentException("Parameter resource is required and cannot be null.")); + } else { + resource.validate(); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.createOrUpdate(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, watcherName, targetName, resource, accept, context); + } + + /** + * Create a Target. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param targetName The target resource name. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete proxy resource types can be created by aliasing this type using a specific property type on + * successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono createOrUpdateAsync(String resourceGroupName, String watcherName, String targetName, + TargetInner resource) { + return createOrUpdateWithResponseAsync(resourceGroupName, watcherName, targetName, resource) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Create a Target. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param targetName The target resource name. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete proxy resource types can be created by aliasing this type using a specific property type along + * with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response createOrUpdateWithResponse(String resourceGroupName, String watcherName, + String targetName, TargetInner resource, Context context) { + return createOrUpdateWithResponseAsync(resourceGroupName, watcherName, targetName, resource, context).block(); + } + + /** + * Create a Target. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param targetName The target resource name. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete proxy resource types can be created by aliasing this type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public TargetInner createOrUpdate(String resourceGroupName, String watcherName, String targetName, + TargetInner resource) { + return createOrUpdateWithResponse(resourceGroupName, watcherName, targetName, resource, Context.NONE) + .getValue(); + } + + /** + * Delete a Target. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param targetName The target resource name. + * @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 watcherName, + String targetName) { + 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 (watcherName == null) { + return Mono.error(new IllegalArgumentException("Parameter watcherName is required and cannot be null.")); + } + if (targetName == null) { + return Mono.error(new IllegalArgumentException("Parameter targetName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.delete(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, watcherName, targetName, accept, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Delete a Target. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param targetName The target resource name. + * @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 watcherName, + String targetName, 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 (watcherName == null) { + return Mono.error(new IllegalArgumentException("Parameter watcherName is required and cannot be null.")); + } + if (targetName == null) { + return Mono.error(new IllegalArgumentException("Parameter targetName is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.delete(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), + resourceGroupName, watcherName, targetName, accept, context); + } + + /** + * Delete a Target. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param targetName The target resource name. + * @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 watcherName, String targetName) { + return deleteWithResponseAsync(resourceGroupName, watcherName, targetName).flatMap(ignored -> Mono.empty()); + } + + /** + * Delete a Target. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param targetName The target resource name. + * @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 watcherName, String targetName, + Context context) { + return deleteWithResponseAsync(resourceGroupName, watcherName, targetName, context).block(); + } + + /** + * Delete a Target. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param targetName The target resource name. + * @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 watcherName, String targetName) { + deleteWithResponse(resourceGroupName, watcherName, targetName, 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 the response of a Target list operation along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByWatcherNextSinglePageAsync(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.listByWatcherNext(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 the response of a Target list operation along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByWatcherNextSinglePageAsync(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.listByWatcherNext(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/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/implementation/TargetsImpl.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/implementation/TargetsImpl.java new file mode 100644 index 0000000000000..25162b494f411 --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/implementation/TargetsImpl.java @@ -0,0 +1,157 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.databasewatcher.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.databasewatcher.fluent.TargetsClient; +import com.azure.resourcemanager.databasewatcher.fluent.models.TargetInner; +import com.azure.resourcemanager.databasewatcher.models.Target; +import com.azure.resourcemanager.databasewatcher.models.Targets; + +public final class TargetsImpl implements Targets { + private static final ClientLogger LOGGER = new ClientLogger(TargetsImpl.class); + + private final TargetsClient innerClient; + + private final com.azure.resourcemanager.databasewatcher.DatabasewatcherManager serviceManager; + + public TargetsImpl(TargetsClient innerClient, + com.azure.resourcemanager.databasewatcher.DatabasewatcherManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public PagedIterable listByWatcher(String resourceGroupName, String watcherName) { + PagedIterable inner = this.serviceClient().listByWatcher(resourceGroupName, watcherName); + return ResourceManagerUtils.mapPage(inner, inner1 -> new TargetImpl(inner1, this.manager())); + } + + public PagedIterable listByWatcher(String resourceGroupName, String watcherName, Context context) { + PagedIterable inner = this.serviceClient().listByWatcher(resourceGroupName, watcherName, context); + return ResourceManagerUtils.mapPage(inner, inner1 -> new TargetImpl(inner1, this.manager())); + } + + public Response getWithResponse(String resourceGroupName, String watcherName, String targetName, + Context context) { + Response inner + = this.serviceClient().getWithResponse(resourceGroupName, watcherName, targetName, context); + if (inner != null) { + return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(), + new TargetImpl(inner.getValue(), this.manager())); + } else { + return null; + } + } + + public Target get(String resourceGroupName, String watcherName, String targetName) { + TargetInner inner = this.serviceClient().get(resourceGroupName, watcherName, targetName); + if (inner != null) { + return new TargetImpl(inner, this.manager()); + } else { + return null; + } + } + + public Response deleteWithResponse(String resourceGroupName, String watcherName, String targetName, + Context context) { + return this.serviceClient().deleteWithResponse(resourceGroupName, watcherName, targetName, context); + } + + public void delete(String resourceGroupName, String watcherName, String targetName) { + this.serviceClient().delete(resourceGroupName, watcherName, targetName); + } + + public Target 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 watcherName = ResourceManagerUtils.getValueFromIdByName(id, "watchers"); + if (watcherName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'watchers'.", id))); + } + String targetName = ResourceManagerUtils.getValueFromIdByName(id, "targets"); + if (targetName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'targets'.", id))); + } + return this.getWithResponse(resourceGroupName, watcherName, targetName, 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 watcherName = ResourceManagerUtils.getValueFromIdByName(id, "watchers"); + if (watcherName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'watchers'.", id))); + } + String targetName = ResourceManagerUtils.getValueFromIdByName(id, "targets"); + if (targetName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'targets'.", id))); + } + return this.getWithResponse(resourceGroupName, watcherName, targetName, 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 watcherName = ResourceManagerUtils.getValueFromIdByName(id, "watchers"); + if (watcherName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'watchers'.", id))); + } + String targetName = ResourceManagerUtils.getValueFromIdByName(id, "targets"); + if (targetName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'targets'.", id))); + } + this.deleteWithResponse(resourceGroupName, watcherName, targetName, 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 watcherName = ResourceManagerUtils.getValueFromIdByName(id, "watchers"); + if (watcherName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'watchers'.", id))); + } + String targetName = ResourceManagerUtils.getValueFromIdByName(id, "targets"); + if (targetName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'targets'.", id))); + } + return this.deleteWithResponse(resourceGroupName, watcherName, targetName, context); + } + + private TargetsClient serviceClient() { + return this.innerClient; + } + + private com.azure.resourcemanager.databasewatcher.DatabasewatcherManager manager() { + return this.serviceManager; + } + + public TargetImpl define(String name) { + return new TargetImpl(name, this.manager()); + } +} diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/implementation/WatcherImpl.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/implementation/WatcherImpl.java new file mode 100644 index 0000000000000..b0e90ed3fb42d --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/implementation/WatcherImpl.java @@ -0,0 +1,238 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.databasewatcher.implementation; + +import com.azure.core.management.Region; +import com.azure.core.management.SystemData; +import com.azure.core.util.Context; +import com.azure.resourcemanager.databasewatcher.fluent.models.WatcherInner; +import com.azure.resourcemanager.databasewatcher.models.DatabaseWatcherProvisioningState; +import com.azure.resourcemanager.databasewatcher.models.Datastore; +import com.azure.resourcemanager.databasewatcher.models.DatastoreUpdate; +import com.azure.resourcemanager.databasewatcher.models.ManagedServiceIdentity; +import com.azure.resourcemanager.databasewatcher.models.Watcher; +import com.azure.resourcemanager.databasewatcher.models.WatcherStatus; +import com.azure.resourcemanager.databasewatcher.models.WatcherUpdate; +import java.util.Collections; +import java.util.Map; + +public final class WatcherImpl implements Watcher, Watcher.Definition, Watcher.Update { + private WatcherInner innerObject; + + private final com.azure.resourcemanager.databasewatcher.DatabasewatcherManager 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 SystemData systemData() { + return this.innerModel().systemData(); + } + + public Datastore datastore() { + return this.innerModel().datastore(); + } + + public WatcherStatus status() { + return this.innerModel().status(); + } + + public DatabaseWatcherProvisioningState provisioningState() { + return this.innerModel().provisioningState(); + } + + public String defaultAlertRuleIdentityResourceId() { + return this.innerModel().defaultAlertRuleIdentityResourceId(); + } + + public Region region() { + return Region.fromName(this.regionName()); + } + + public String regionName() { + return this.location(); + } + + public String resourceGroupName() { + return resourceGroupName; + } + + public WatcherInner innerModel() { + return this.innerObject; + } + + private com.azure.resourcemanager.databasewatcher.DatabasewatcherManager manager() { + return this.serviceManager; + } + + private String resourceGroupName; + + private String watcherName; + + private WatcherUpdate updateProperties; + + public WatcherImpl withExistingResourceGroup(String resourceGroupName) { + this.resourceGroupName = resourceGroupName; + return this; + } + + public Watcher create() { + this.innerObject = serviceManager.serviceClient() + .getWatchers() + .createOrUpdate(resourceGroupName, watcherName, this.innerModel(), Context.NONE); + return this; + } + + public Watcher create(Context context) { + this.innerObject = serviceManager.serviceClient() + .getWatchers() + .createOrUpdate(resourceGroupName, watcherName, this.innerModel(), context); + return this; + } + + WatcherImpl(String name, com.azure.resourcemanager.databasewatcher.DatabasewatcherManager serviceManager) { + this.innerObject = new WatcherInner(); + this.serviceManager = serviceManager; + this.watcherName = name; + } + + public WatcherImpl update() { + this.updateProperties = new WatcherUpdate(); + return this; + } + + public Watcher apply() { + this.innerObject = serviceManager.serviceClient() + .getWatchers() + .update(resourceGroupName, watcherName, updateProperties, Context.NONE); + return this; + } + + public Watcher apply(Context context) { + this.innerObject = serviceManager.serviceClient() + .getWatchers() + .update(resourceGroupName, watcherName, updateProperties, context); + return this; + } + + WatcherImpl(WatcherInner innerObject, + com.azure.resourcemanager.databasewatcher.DatabasewatcherManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + this.resourceGroupName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "resourceGroups"); + this.watcherName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "watchers"); + } + + public Watcher refresh() { + this.innerObject = serviceManager.serviceClient() + .getWatchers() + .getByResourceGroupWithResponse(resourceGroupName, watcherName, Context.NONE) + .getValue(); + return this; + } + + public Watcher refresh(Context context) { + this.innerObject = serviceManager.serviceClient() + .getWatchers() + .getByResourceGroupWithResponse(resourceGroupName, watcherName, context) + .getValue(); + return this; + } + + public Watcher start() { + return serviceManager.watchers().start(resourceGroupName, watcherName); + } + + public Watcher start(Context context) { + return serviceManager.watchers().start(resourceGroupName, watcherName, context); + } + + public Watcher stop() { + return serviceManager.watchers().stop(resourceGroupName, watcherName); + } + + public Watcher stop(Context context) { + return serviceManager.watchers().stop(resourceGroupName, watcherName, context); + } + + public WatcherImpl withRegion(Region location) { + this.innerModel().withLocation(location.toString()); + return this; + } + + public WatcherImpl withRegion(String location) { + this.innerModel().withLocation(location); + return this; + } + + public WatcherImpl withTags(Map tags) { + if (isInCreateMode()) { + this.innerModel().withTags(tags); + return this; + } else { + this.updateProperties.withTags(tags); + return this; + } + } + + public WatcherImpl withIdentity(ManagedServiceIdentity identity) { + if (isInCreateMode()) { + this.innerModel().withIdentity(identity); + return this; + } else { + this.updateProperties.withIdentity(identity); + return this; + } + } + + public WatcherImpl withDatastore(Datastore datastore) { + this.innerModel().withDatastore(datastore); + return this; + } + + public WatcherImpl withDefaultAlertRuleIdentityResourceId(String defaultAlertRuleIdentityResourceId) { + if (isInCreateMode()) { + this.innerModel().withDefaultAlertRuleIdentityResourceId(defaultAlertRuleIdentityResourceId); + return this; + } else { + this.updateProperties.withDefaultAlertRuleIdentityResourceId(defaultAlertRuleIdentityResourceId); + return this; + } + } + + public WatcherImpl withDatastore(DatastoreUpdate datastore) { + this.updateProperties.withDatastore(datastore); + return this; + } + + private boolean isInCreateMode() { + return this.innerModel().id() == null; + } +} diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/implementation/WatchersClientImpl.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/implementation/WatchersClientImpl.java new file mode 100644 index 0000000000000..cd41be736f50b --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/implementation/WatchersClientImpl.java @@ -0,0 +1,1699 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.databasewatcher.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.databasewatcher.fluent.WatchersClient; +import com.azure.resourcemanager.databasewatcher.fluent.models.WatcherInner; +import com.azure.resourcemanager.databasewatcher.models.WatcherListResult; +import com.azure.resourcemanager.databasewatcher.models.WatcherUpdate; +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 WatchersClient. + */ +public final class WatchersClientImpl implements WatchersClient { + /** + * The proxy service used to perform REST calls. + */ + private final WatchersService service; + + /** + * The service client containing this operation class. + */ + private final MicrosoftDatabaseWatcherImpl client; + + /** + * Initializes an instance of WatchersClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + WatchersClientImpl(MicrosoftDatabaseWatcherImpl client) { + this.service = RestProxy.create(WatchersService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for MicrosoftDatabaseWatcherWatchers to be used by the proxy service to + * perform REST calls. + */ + @Host("{$host}") + @ServiceInterface(name = "MicrosoftDatabaseWat") + public interface WatchersService { + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/providers/Microsoft.DatabaseWatcher/watchers") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> list(@HostParam("$host") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listByResourceGroup(@HostParam("$host") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, @HeaderParam("Accept") String accept, + Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> getByResourceGroup(@HostParam("$host") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, @PathParam("watcherName") String watcherName, + @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Put("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}") + @ExpectedResponses({ 200, 201 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono>> createOrUpdate(@HostParam("$host") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, @PathParam("watcherName") String watcherName, + @BodyParam("application/json") WatcherInner resource, @HeaderParam("Accept") String accept, + Context context); + + @Headers({ "Content-Type: application/json" }) + @Patch("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}") + @ExpectedResponses({ 200, 202 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono>> update(@HostParam("$host") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, @PathParam("watcherName") String watcherName, + @BodyParam("application/json") WatcherUpdate properties, @HeaderParam("Accept") String accept, + Context context); + + @Headers({ "Content-Type: application/json" }) + @Delete("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}") + @ExpectedResponses({ 202, 204 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono>> delete(@HostParam("$host") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, @PathParam("watcherName") String watcherName, + @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Post("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/start") + @ExpectedResponses({ 200, 202 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono>> start(@HostParam("$host") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, @PathParam("watcherName") String watcherName, + @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Post("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/stop") + @ExpectedResponses({ 200, 202 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono>> stop(@HostParam("$host") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, @PathParam("watcherName") String watcherName, + @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); + } + + /** + * List Watcher resources by subscription ID. + * + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Watcher list operation 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 accept = "application/json"; + return FluxUtil + .withContext(context -> service.list(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), 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())); + } + + /** + * List Watcher resources by subscription 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 response of a Watcher list operation 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 accept = "application/json"; + context = this.client.mergeContext(context); + return service + .list(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), accept, + context) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + res.getValue().value(), res.getValue().nextLink(), null)); + } + + /** + * List Watcher resources by subscription ID. + * + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Watcher list operation as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync() { + return new PagedFlux<>(() -> listSinglePageAsync(), + nextLink -> listBySubscriptionNextSinglePageAsync(nextLink)); + } + + /** + * List Watcher resources by subscription 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 response of a Watcher list operation as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync(Context context) { + return new PagedFlux<>(() -> listSinglePageAsync(context), + nextLink -> listBySubscriptionNextSinglePageAsync(nextLink, context)); + } + + /** + * List Watcher resources by subscription ID. + * + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Watcher list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list() { + return new PagedIterable<>(listAsync()); + } + + /** + * List Watcher resources by subscription 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 response of a Watcher list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(Context context) { + return new PagedIterable<>(listAsync(context)); + } + + /** + * List Watcher resources by 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 the response of a Watcher list operation 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 accept = "application/json"; + return FluxUtil + .withContext(context -> service.listByResourceGroup(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, 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())); + } + + /** + * List Watcher resources by 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 the response of a Watcher list operation 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 accept = "application/json"; + context = this.client.mergeContext(context); + return service + .listByResourceGroup(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, accept, context) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + res.getValue().value(), res.getValue().nextLink(), null)); + } + + /** + * List Watcher resources by 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 the response of a Watcher list operation as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listByResourceGroupAsync(String resourceGroupName) { + return new PagedFlux<>(() -> listByResourceGroupSinglePageAsync(resourceGroupName), + nextLink -> listByResourceGroupNextSinglePageAsync(nextLink)); + } + + /** + * List Watcher resources by 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 the response of a Watcher list operation 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)); + } + + /** + * List Watcher resources by 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 the response of a Watcher list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listByResourceGroup(String resourceGroupName) { + return new PagedIterable<>(listByResourceGroupAsync(resourceGroupName)); + } + + /** + * List Watcher resources by 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 the response of a Watcher list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listByResourceGroup(String resourceGroupName, Context context) { + return new PagedIterable<>(listByResourceGroupAsync(resourceGroupName, context)); + } + + /** + * Get a Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @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 Watcher along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getByResourceGroupWithResponseAsync(String resourceGroupName, + String watcherName) { + 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 (watcherName == null) { + return Mono.error(new IllegalArgumentException("Parameter watcherName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getByResourceGroup(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, watcherName, accept, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get a Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @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 Watcher along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getByResourceGroupWithResponseAsync(String resourceGroupName, + String watcherName, 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 (watcherName == null) { + return Mono.error(new IllegalArgumentException("Parameter watcherName is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.getByResourceGroup(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, watcherName, accept, context); + } + + /** + * Get a Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @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 Watcher on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono getByResourceGroupAsync(String resourceGroupName, String watcherName) { + return getByResourceGroupWithResponseAsync(resourceGroupName, watcherName) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Get a Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @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 Watcher along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getByResourceGroupWithResponse(String resourceGroupName, String watcherName, + Context context) { + return getByResourceGroupWithResponseAsync(resourceGroupName, watcherName, context).block(); + } + + /** + * Get a Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @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 Watcher. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public WatcherInner getByResourceGroup(String resourceGroupName, String watcherName) { + return getByResourceGroupWithResponse(resourceGroupName, watcherName, Context.NONE).getValue(); + } + + /** + * Create a Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the DatabaseWatcherProviderHub resource along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> createOrUpdateWithResponseAsync(String resourceGroupName, + String watcherName, WatcherInner resource) { + 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 (watcherName == null) { + return Mono.error(new IllegalArgumentException("Parameter watcherName is required and cannot be null.")); + } + if (resource == null) { + return Mono.error(new IllegalArgumentException("Parameter resource is required and cannot be null.")); + } else { + resource.validate(); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.createOrUpdate(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, watcherName, resource, accept, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Create a Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the DatabaseWatcherProviderHub resource along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> createOrUpdateWithResponseAsync(String resourceGroupName, + String watcherName, WatcherInner resource, 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 (watcherName == null) { + return Mono.error(new IllegalArgumentException("Parameter watcherName is required and cannot be null.")); + } + if (resource == null) { + return Mono.error(new IllegalArgumentException("Parameter resource is required and cannot be null.")); + } else { + resource.validate(); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.createOrUpdate(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, watcherName, resource, accept, context); + } + + /** + * Create a Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link PollerFlux} for polling of the DatabaseWatcherProviderHub resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, WatcherInner> beginCreateOrUpdateAsync(String resourceGroupName, + String watcherName, WatcherInner resource) { + Mono>> mono + = createOrUpdateWithResponseAsync(resourceGroupName, watcherName, resource); + return this.client.getLroResult(mono, this.client.getHttpPipeline(), + WatcherInner.class, WatcherInner.class, this.client.getContext()); + } + + /** + * Create a Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link PollerFlux} for polling of the DatabaseWatcherProviderHub resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, WatcherInner> beginCreateOrUpdateAsync(String resourceGroupName, + String watcherName, WatcherInner resource, Context context) { + context = this.client.mergeContext(context); + Mono>> mono + = createOrUpdateWithResponseAsync(resourceGroupName, watcherName, resource, context); + return this.client.getLroResult(mono, this.client.getHttpPipeline(), + WatcherInner.class, WatcherInner.class, context); + } + + /** + * Create a Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of the DatabaseWatcherProviderHub resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, WatcherInner> beginCreateOrUpdate(String resourceGroupName, + String watcherName, WatcherInner resource) { + return this.beginCreateOrUpdateAsync(resourceGroupName, watcherName, resource).getSyncPoller(); + } + + /** + * Create a Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of the DatabaseWatcherProviderHub resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, WatcherInner> beginCreateOrUpdate(String resourceGroupName, + String watcherName, WatcherInner resource, Context context) { + return this.beginCreateOrUpdateAsync(resourceGroupName, watcherName, resource, context).getSyncPoller(); + } + + /** + * Create a Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the DatabaseWatcherProviderHub resource on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono createOrUpdateAsync(String resourceGroupName, String watcherName, + WatcherInner resource) { + return beginCreateOrUpdateAsync(resourceGroupName, watcherName, resource).last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Create a Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the DatabaseWatcherProviderHub resource on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono createOrUpdateAsync(String resourceGroupName, String watcherName, WatcherInner resource, + Context context) { + return beginCreateOrUpdateAsync(resourceGroupName, watcherName, resource, context).last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Create a Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the DatabaseWatcherProviderHub resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public WatcherInner createOrUpdate(String resourceGroupName, String watcherName, WatcherInner resource) { + return createOrUpdateAsync(resourceGroupName, watcherName, resource).block(); + } + + /** + * Create a Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the DatabaseWatcherProviderHub resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public WatcherInner createOrUpdate(String resourceGroupName, String watcherName, WatcherInner resource, + Context context) { + return createOrUpdateAsync(resourceGroupName, watcherName, resource, context).block(); + } + + /** + * Update a Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param properties The resource properties to be updated. + * @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 DatabaseWatcherProviderHub resource along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> updateWithResponseAsync(String resourceGroupName, String watcherName, + WatcherUpdate properties) { + 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 (watcherName == null) { + return Mono.error(new IllegalArgumentException("Parameter watcherName is required and cannot be null.")); + } + if (properties == null) { + return Mono.error(new IllegalArgumentException("Parameter properties is required and cannot be null.")); + } else { + properties.validate(); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.update(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, watcherName, properties, accept, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Update a Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param properties The resource properties to be updated. + * @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 DatabaseWatcherProviderHub resource along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> updateWithResponseAsync(String resourceGroupName, String watcherName, + WatcherUpdate properties, 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 (watcherName == null) { + return Mono.error(new IllegalArgumentException("Parameter watcherName is required and cannot be null.")); + } + if (properties == null) { + return Mono.error(new IllegalArgumentException("Parameter properties is required and cannot be null.")); + } else { + properties.validate(); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.update(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), + resourceGroupName, watcherName, properties, accept, context); + } + + /** + * Update a Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param properties The resource properties to be updated. + * @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 DatabaseWatcherProviderHub resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, WatcherInner> beginUpdateAsync(String resourceGroupName, + String watcherName, WatcherUpdate properties) { + Mono>> mono = updateWithResponseAsync(resourceGroupName, watcherName, properties); + return this.client.getLroResult(mono, this.client.getHttpPipeline(), + WatcherInner.class, WatcherInner.class, this.client.getContext()); + } + + /** + * Update a Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param properties The resource properties to be updated. + * @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 DatabaseWatcherProviderHub resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, WatcherInner> beginUpdateAsync(String resourceGroupName, + String watcherName, WatcherUpdate properties, Context context) { + context = this.client.mergeContext(context); + Mono>> mono + = updateWithResponseAsync(resourceGroupName, watcherName, properties, context); + return this.client.getLroResult(mono, this.client.getHttpPipeline(), + WatcherInner.class, WatcherInner.class, context); + } + + /** + * Update a Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param properties The resource properties to be updated. + * @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 DatabaseWatcherProviderHub resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, WatcherInner> beginUpdate(String resourceGroupName, String watcherName, + WatcherUpdate properties) { + return this.beginUpdateAsync(resourceGroupName, watcherName, properties).getSyncPoller(); + } + + /** + * Update a Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param properties The resource properties to be updated. + * @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 DatabaseWatcherProviderHub resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, WatcherInner> beginUpdate(String resourceGroupName, String watcherName, + WatcherUpdate properties, Context context) { + return this.beginUpdateAsync(resourceGroupName, watcherName, properties, context).getSyncPoller(); + } + + /** + * Update a Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param properties The resource properties to be updated. + * @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 DatabaseWatcherProviderHub resource on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono updateAsync(String resourceGroupName, String watcherName, WatcherUpdate properties) { + return beginUpdateAsync(resourceGroupName, watcherName, properties).last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Update a Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param properties The resource properties to be updated. + * @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 DatabaseWatcherProviderHub resource on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono updateAsync(String resourceGroupName, String watcherName, WatcherUpdate properties, + Context context) { + return beginUpdateAsync(resourceGroupName, watcherName, properties, context).last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Update a Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param properties The resource properties to be updated. + * @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 DatabaseWatcherProviderHub resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public WatcherInner update(String resourceGroupName, String watcherName, WatcherUpdate properties) { + return updateAsync(resourceGroupName, watcherName, properties).block(); + } + + /** + * Update a Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param properties The resource properties to be updated. + * @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 DatabaseWatcherProviderHub resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public WatcherInner update(String resourceGroupName, String watcherName, WatcherUpdate properties, + Context context) { + return updateAsync(resourceGroupName, watcherName, properties, context).block(); + } + + /** + * Delete a Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @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 watcherName) { + 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 (watcherName == null) { + return Mono.error(new IllegalArgumentException("Parameter watcherName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.delete(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, watcherName, accept, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Delete a Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @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 watcherName, + 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 (watcherName == null) { + return Mono.error(new IllegalArgumentException("Parameter watcherName is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.delete(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), + resourceGroupName, watcherName, accept, context); + } + + /** + * Delete a Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @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 long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, Void> beginDeleteAsync(String resourceGroupName, String watcherName) { + Mono>> mono = deleteWithResponseAsync(resourceGroupName, watcherName); + return this.client.getLroResult(mono, this.client.getHttpPipeline(), Void.class, Void.class, + this.client.getContext()); + } + + /** + * Delete a Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @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 long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, Void> beginDeleteAsync(String resourceGroupName, String watcherName, + Context context) { + context = this.client.mergeContext(context); + Mono>> mono = deleteWithResponseAsync(resourceGroupName, watcherName, context); + return this.client.getLroResult(mono, this.client.getHttpPipeline(), Void.class, Void.class, + context); + } + + /** + * Delete a Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @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 long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, Void> beginDelete(String resourceGroupName, String watcherName) { + return this.beginDeleteAsync(resourceGroupName, watcherName).getSyncPoller(); + } + + /** + * Delete a Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @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 long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, Void> beginDelete(String resourceGroupName, String watcherName, + Context context) { + return this.beginDeleteAsync(resourceGroupName, watcherName, context).getSyncPoller(); + } + + /** + * Delete a Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @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 watcherName) { + return beginDeleteAsync(resourceGroupName, watcherName).last().flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Delete a Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @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 {@link Mono} that completes when a successful response is received. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono deleteAsync(String resourceGroupName, String watcherName, Context context) { + return beginDeleteAsync(resourceGroupName, watcherName, context).last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Delete a Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @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 watcherName) { + deleteAsync(resourceGroupName, watcherName).block(); + } + + /** + * Delete a Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @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. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public void delete(String resourceGroupName, String watcherName, Context context) { + deleteAsync(resourceGroupName, watcherName, context).block(); + } + + /** + * The action to start monitoring all targets configured for a database watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @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 DatabaseWatcherProviderHub resource along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> startWithResponseAsync(String resourceGroupName, String watcherName) { + 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 (watcherName == null) { + return Mono.error(new IllegalArgumentException("Parameter watcherName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.start(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, watcherName, accept, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * The action to start monitoring all targets configured for a database watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @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 DatabaseWatcherProviderHub resource along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> startWithResponseAsync(String resourceGroupName, String watcherName, + 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 (watcherName == null) { + return Mono.error(new IllegalArgumentException("Parameter watcherName is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.start(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), + resourceGroupName, watcherName, accept, context); + } + + /** + * The action to start monitoring all targets configured for a database watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @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 DatabaseWatcherProviderHub resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, WatcherInner> beginStartAsync(String resourceGroupName, + String watcherName) { + Mono>> mono = startWithResponseAsync(resourceGroupName, watcherName); + return this.client.getLroResult(mono, this.client.getHttpPipeline(), + WatcherInner.class, WatcherInner.class, this.client.getContext()); + } + + /** + * The action to start monitoring all targets configured for a database watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @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 DatabaseWatcherProviderHub resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, WatcherInner> beginStartAsync(String resourceGroupName, + String watcherName, Context context) { + context = this.client.mergeContext(context); + Mono>> mono = startWithResponseAsync(resourceGroupName, watcherName, context); + return this.client.getLroResult(mono, this.client.getHttpPipeline(), + WatcherInner.class, WatcherInner.class, context); + } + + /** + * The action to start monitoring all targets configured for a database watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @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 DatabaseWatcherProviderHub resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, WatcherInner> beginStart(String resourceGroupName, String watcherName) { + return this.beginStartAsync(resourceGroupName, watcherName).getSyncPoller(); + } + + /** + * The action to start monitoring all targets configured for a database watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @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 DatabaseWatcherProviderHub resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, WatcherInner> beginStart(String resourceGroupName, String watcherName, + Context context) { + return this.beginStartAsync(resourceGroupName, watcherName, context).getSyncPoller(); + } + + /** + * The action to start monitoring all targets configured for a database watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @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 DatabaseWatcherProviderHub resource on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono startAsync(String resourceGroupName, String watcherName) { + return beginStartAsync(resourceGroupName, watcherName).last().flatMap(this.client::getLroFinalResultOrError); + } + + /** + * The action to start monitoring all targets configured for a database watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @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 DatabaseWatcherProviderHub resource on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono startAsync(String resourceGroupName, String watcherName, Context context) { + return beginStartAsync(resourceGroupName, watcherName, context).last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * The action to start monitoring all targets configured for a database watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @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 DatabaseWatcherProviderHub resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public WatcherInner start(String resourceGroupName, String watcherName) { + return startAsync(resourceGroupName, watcherName).block(); + } + + /** + * The action to start monitoring all targets configured for a database watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @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 DatabaseWatcherProviderHub resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public WatcherInner start(String resourceGroupName, String watcherName, Context context) { + return startAsync(resourceGroupName, watcherName, context).block(); + } + + /** + * The action to stop monitoring all targets configured for a database watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @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 DatabaseWatcherProviderHub resource along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> stopWithResponseAsync(String resourceGroupName, String watcherName) { + 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 (watcherName == null) { + return Mono.error(new IllegalArgumentException("Parameter watcherName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.stop(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, watcherName, accept, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * The action to stop monitoring all targets configured for a database watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @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 DatabaseWatcherProviderHub resource along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> stopWithResponseAsync(String resourceGroupName, String watcherName, + 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 (watcherName == null) { + return Mono.error(new IllegalArgumentException("Parameter watcherName is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.stop(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), + resourceGroupName, watcherName, accept, context); + } + + /** + * The action to stop monitoring all targets configured for a database watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @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 DatabaseWatcherProviderHub resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, WatcherInner> beginStopAsync(String resourceGroupName, + String watcherName) { + Mono>> mono = stopWithResponseAsync(resourceGroupName, watcherName); + return this.client.getLroResult(mono, this.client.getHttpPipeline(), + WatcherInner.class, WatcherInner.class, this.client.getContext()); + } + + /** + * The action to stop monitoring all targets configured for a database watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @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 DatabaseWatcherProviderHub resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, WatcherInner> beginStopAsync(String resourceGroupName, + String watcherName, Context context) { + context = this.client.mergeContext(context); + Mono>> mono = stopWithResponseAsync(resourceGroupName, watcherName, context); + return this.client.getLroResult(mono, this.client.getHttpPipeline(), + WatcherInner.class, WatcherInner.class, context); + } + + /** + * The action to stop monitoring all targets configured for a database watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @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 DatabaseWatcherProviderHub resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, WatcherInner> beginStop(String resourceGroupName, String watcherName) { + return this.beginStopAsync(resourceGroupName, watcherName).getSyncPoller(); + } + + /** + * The action to stop monitoring all targets configured for a database watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @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 DatabaseWatcherProviderHub resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, WatcherInner> beginStop(String resourceGroupName, String watcherName, + Context context) { + return this.beginStopAsync(resourceGroupName, watcherName, context).getSyncPoller(); + } + + /** + * The action to stop monitoring all targets configured for a database watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @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 DatabaseWatcherProviderHub resource on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono stopAsync(String resourceGroupName, String watcherName) { + return beginStopAsync(resourceGroupName, watcherName).last().flatMap(this.client::getLroFinalResultOrError); + } + + /** + * The action to stop monitoring all targets configured for a database watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @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 DatabaseWatcherProviderHub resource on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono stopAsync(String resourceGroupName, String watcherName, Context context) { + return beginStopAsync(resourceGroupName, watcherName, context).last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * The action to stop monitoring all targets configured for a database watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @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 DatabaseWatcherProviderHub resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public WatcherInner stop(String resourceGroupName, String watcherName) { + return stopAsync(resourceGroupName, watcherName).block(); + } + + /** + * The action to stop monitoring all targets configured for a database watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @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 DatabaseWatcherProviderHub resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public WatcherInner stop(String resourceGroupName, String watcherName, Context context) { + return stopAsync(resourceGroupName, watcherName, context).block(); + } + + /** + * Get the next page of items. + * + * @param nextLink The URL to get the next list of items. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Watcher list operation 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 the response of a Watcher list operation 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 the response of a Watcher list operation 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 the response of a Watcher list operation 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/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/implementation/WatchersImpl.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/implementation/WatchersImpl.java new file mode 100644 index 0000000000000..a26b2083fb23f --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/implementation/WatchersImpl.java @@ -0,0 +1,182 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.databasewatcher.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.databasewatcher.fluent.WatchersClient; +import com.azure.resourcemanager.databasewatcher.fluent.models.WatcherInner; +import com.azure.resourcemanager.databasewatcher.models.Watcher; +import com.azure.resourcemanager.databasewatcher.models.Watchers; + +public final class WatchersImpl implements Watchers { + private static final ClientLogger LOGGER = new ClientLogger(WatchersImpl.class); + + private final WatchersClient innerClient; + + private final com.azure.resourcemanager.databasewatcher.DatabasewatcherManager serviceManager; + + public WatchersImpl(WatchersClient innerClient, + com.azure.resourcemanager.databasewatcher.DatabasewatcherManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public PagedIterable list() { + PagedIterable inner = this.serviceClient().list(); + return ResourceManagerUtils.mapPage(inner, inner1 -> new WatcherImpl(inner1, this.manager())); + } + + public PagedIterable list(Context context) { + PagedIterable inner = this.serviceClient().list(context); + return ResourceManagerUtils.mapPage(inner, inner1 -> new WatcherImpl(inner1, this.manager())); + } + + public PagedIterable listByResourceGroup(String resourceGroupName) { + PagedIterable inner = this.serviceClient().listByResourceGroup(resourceGroupName); + return ResourceManagerUtils.mapPage(inner, inner1 -> new WatcherImpl(inner1, this.manager())); + } + + public PagedIterable listByResourceGroup(String resourceGroupName, Context context) { + PagedIterable inner = this.serviceClient().listByResourceGroup(resourceGroupName, context); + return ResourceManagerUtils.mapPage(inner, inner1 -> new WatcherImpl(inner1, this.manager())); + } + + public Response getByResourceGroupWithResponse(String resourceGroupName, String watcherName, + Context context) { + Response inner + = this.serviceClient().getByResourceGroupWithResponse(resourceGroupName, watcherName, context); + if (inner != null) { + return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(), + new WatcherImpl(inner.getValue(), this.manager())); + } else { + return null; + } + } + + public Watcher getByResourceGroup(String resourceGroupName, String watcherName) { + WatcherInner inner = this.serviceClient().getByResourceGroup(resourceGroupName, watcherName); + if (inner != null) { + return new WatcherImpl(inner, this.manager()); + } else { + return null; + } + } + + public void deleteByResourceGroup(String resourceGroupName, String watcherName) { + this.serviceClient().delete(resourceGroupName, watcherName); + } + + public void delete(String resourceGroupName, String watcherName, Context context) { + this.serviceClient().delete(resourceGroupName, watcherName, context); + } + + public Watcher start(String resourceGroupName, String watcherName) { + WatcherInner inner = this.serviceClient().start(resourceGroupName, watcherName); + if (inner != null) { + return new WatcherImpl(inner, this.manager()); + } else { + return null; + } + } + + public Watcher start(String resourceGroupName, String watcherName, Context context) { + WatcherInner inner = this.serviceClient().start(resourceGroupName, watcherName, context); + if (inner != null) { + return new WatcherImpl(inner, this.manager()); + } else { + return null; + } + } + + public Watcher stop(String resourceGroupName, String watcherName) { + WatcherInner inner = this.serviceClient().stop(resourceGroupName, watcherName); + if (inner != null) { + return new WatcherImpl(inner, this.manager()); + } else { + return null; + } + } + + public Watcher stop(String resourceGroupName, String watcherName, Context context) { + WatcherInner inner = this.serviceClient().stop(resourceGroupName, watcherName, context); + if (inner != null) { + return new WatcherImpl(inner, this.manager()); + } else { + return null; + } + } + + public Watcher 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 watcherName = ResourceManagerUtils.getValueFromIdByName(id, "watchers"); + if (watcherName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'watchers'.", id))); + } + return this.getByResourceGroupWithResponse(resourceGroupName, watcherName, 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 watcherName = ResourceManagerUtils.getValueFromIdByName(id, "watchers"); + if (watcherName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'watchers'.", id))); + } + return this.getByResourceGroupWithResponse(resourceGroupName, watcherName, 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 watcherName = ResourceManagerUtils.getValueFromIdByName(id, "watchers"); + if (watcherName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'watchers'.", id))); + } + this.delete(resourceGroupName, watcherName, Context.NONE); + } + + public void 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 watcherName = ResourceManagerUtils.getValueFromIdByName(id, "watchers"); + if (watcherName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'watchers'.", id))); + } + this.delete(resourceGroupName, watcherName, context); + } + + private WatchersClient serviceClient() { + return this.innerClient; + } + + private com.azure.resourcemanager.databasewatcher.DatabasewatcherManager manager() { + return this.serviceManager; + } + + public WatcherImpl define(String name) { + return new WatcherImpl(name, this.manager()); + } +} diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/implementation/package-info.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/implementation/package-info.java new file mode 100644 index 0000000000000..298acd69c5c96 --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/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 MicrosoftDatabaseWatcher. + * null. + */ +package com.azure.resourcemanager.databasewatcher.implementation; diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/ActionType.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/ActionType.java new file mode 100644 index 0000000000000..0b74ef3a47fa0 --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/ActionType.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.databasewatcher.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + */ +public final class ActionType extends ExpandableStringEnum { + /** + * Static value Internal for ActionType. + */ + public static final ActionType INTERNAL = fromString("Internal"); + + /** + * Creates a new instance of ActionType value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public ActionType() { + } + + /** + * Creates or finds a ActionType from its string representation. + * + * @param name a name to look for. + * @return the corresponding ActionType. + */ + public static ActionType fromString(String name) { + return fromString(name, ActionType.class); + } + + /** + * Gets known ActionType values. + * + * @return known ActionType values. + */ + public static Collection values() { + return values(ActionType.class); + } +} diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/AlertRuleCreationProperties.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/AlertRuleCreationProperties.java new file mode 100644 index 0000000000000..af66c9e1f0268 --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/AlertRuleCreationProperties.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.databasewatcher.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * The properties with which the alert rule resource was created. + */ +public final class AlertRuleCreationProperties extends ExpandableStringEnum { + /** + * Static value CreatedWithActionGroup for AlertRuleCreationProperties. + */ + public static final AlertRuleCreationProperties CREATED_WITH_ACTION_GROUP = fromString("CreatedWithActionGroup"); + + /** + * Static value None for AlertRuleCreationProperties. + */ + public static final AlertRuleCreationProperties NONE = fromString("None"); + + /** + * Creates a new instance of AlertRuleCreationProperties value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public AlertRuleCreationProperties() { + } + + /** + * Creates or finds a AlertRuleCreationProperties from its string representation. + * + * @param name a name to look for. + * @return the corresponding AlertRuleCreationProperties. + */ + public static AlertRuleCreationProperties fromString(String name) { + return fromString(name, AlertRuleCreationProperties.class); + } + + /** + * Gets known AlertRuleCreationProperties values. + * + * @return known AlertRuleCreationProperties values. + */ + public static Collection values() { + return values(AlertRuleCreationProperties.class); + } +} diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/AlertRuleResource.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/AlertRuleResource.java new file mode 100644 index 0000000000000..14cf541d4db57 --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/AlertRuleResource.java @@ -0,0 +1,334 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.databasewatcher.models; + +import com.azure.core.management.SystemData; +import com.azure.core.util.Context; +import com.azure.resourcemanager.databasewatcher.fluent.models.AlertRuleResourceInner; +import java.time.OffsetDateTime; + +/** + * An immutable client-side representation of AlertRuleResource. + */ +public interface AlertRuleResource { + /** + * 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 systemData property: Azure Resource Manager metadata containing createdBy and modifiedBy information. + * + * @return the systemData value. + */ + SystemData systemData(); + + /** + * Gets the alertRuleResourceId property: The resource ID of the alert rule resource. + * + * @return the alertRuleResourceId value. + */ + String alertRuleResourceId(); + + /** + * Gets the createdWithProperties property: The properties with which the alert rule resource was created. + * + * @return the createdWithProperties value. + */ + AlertRuleCreationProperties createdWithProperties(); + + /** + * Gets the creationTime property: The creation time of the alert rule resource. + * + * @return the creationTime value. + */ + OffsetDateTime creationTime(); + + /** + * Gets the provisioningState property: The provisioning state of the alert rule resource. + * + * @return the provisioningState value. + */ + ResourceProvisioningState provisioningState(); + + /** + * Gets the alertRuleTemplateId property: The template ID associated with alert rule resource. + * + * @return the alertRuleTemplateId value. + */ + String alertRuleTemplateId(); + + /** + * Gets the alertRuleTemplateVersion property: The alert rule template version. + * + * @return the alertRuleTemplateVersion value. + */ + String alertRuleTemplateVersion(); + + /** + * Gets the name of the resource group. + * + * @return the name of the resource group. + */ + String resourceGroupName(); + + /** + * Gets the inner com.azure.resourcemanager.databasewatcher.fluent.models.AlertRuleResourceInner object. + * + * @return the inner object. + */ + AlertRuleResourceInner innerModel(); + + /** + * The entirety of the AlertRuleResource definition. + */ + interface Definition + extends DefinitionStages.Blank, DefinitionStages.WithParentResource, DefinitionStages.WithCreate { + } + + /** + * The AlertRuleResource definition stages. + */ + interface DefinitionStages { + /** + * The first stage of the AlertRuleResource definition. + */ + interface Blank extends WithParentResource { + } + + /** + * The stage of the AlertRuleResource definition allowing to specify parent resource. + */ + interface WithParentResource { + /** + * Specifies resourceGroupName, watcherName. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @return the next definition stage. + */ + WithCreate withExistingWatcher(String resourceGroupName, String watcherName); + } + + /** + * The stage of the AlertRuleResource 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.WithAlertRuleResourceId, + DefinitionStages.WithCreatedWithProperties, DefinitionStages.WithCreationTime, + DefinitionStages.WithAlertRuleTemplateId, DefinitionStages.WithAlertRuleTemplateVersion { + /** + * Executes the create request. + * + * @return the created resource. + */ + AlertRuleResource create(); + + /** + * Executes the create request. + * + * @param context The context to associate with this operation. + * @return the created resource. + */ + AlertRuleResource create(Context context); + } + + /** + * The stage of the AlertRuleResource definition allowing to specify alertRuleResourceId. + */ + interface WithAlertRuleResourceId { + /** + * Specifies the alertRuleResourceId property: The resource ID of the alert rule resource.. + * + * @param alertRuleResourceId The resource ID of the alert rule resource. + * @return the next definition stage. + */ + WithCreate withAlertRuleResourceId(String alertRuleResourceId); + } + + /** + * The stage of the AlertRuleResource definition allowing to specify createdWithProperties. + */ + interface WithCreatedWithProperties { + /** + * Specifies the createdWithProperties property: The properties with which the alert rule resource was + * created.. + * + * @param createdWithProperties The properties with which the alert rule resource was created. + * @return the next definition stage. + */ + WithCreate withCreatedWithProperties(AlertRuleCreationProperties createdWithProperties); + } + + /** + * The stage of the AlertRuleResource definition allowing to specify creationTime. + */ + interface WithCreationTime { + /** + * Specifies the creationTime property: The creation time of the alert rule resource.. + * + * @param creationTime The creation time of the alert rule resource. + * @return the next definition stage. + */ + WithCreate withCreationTime(OffsetDateTime creationTime); + } + + /** + * The stage of the AlertRuleResource definition allowing to specify alertRuleTemplateId. + */ + interface WithAlertRuleTemplateId { + /** + * Specifies the alertRuleTemplateId property: The template ID associated with alert rule resource.. + * + * @param alertRuleTemplateId The template ID associated with alert rule resource. + * @return the next definition stage. + */ + WithCreate withAlertRuleTemplateId(String alertRuleTemplateId); + } + + /** + * The stage of the AlertRuleResource definition allowing to specify alertRuleTemplateVersion. + */ + interface WithAlertRuleTemplateVersion { + /** + * Specifies the alertRuleTemplateVersion property: The alert rule template version.. + * + * @param alertRuleTemplateVersion The alert rule template version. + * @return the next definition stage. + */ + WithCreate withAlertRuleTemplateVersion(String alertRuleTemplateVersion); + } + } + + /** + * Begins update for the AlertRuleResource resource. + * + * @return the stage of resource update. + */ + AlertRuleResource.Update update(); + + /** + * The template for AlertRuleResource update. + */ + interface Update extends UpdateStages.WithAlertRuleResourceId, UpdateStages.WithCreatedWithProperties, + UpdateStages.WithCreationTime, UpdateStages.WithAlertRuleTemplateId, UpdateStages.WithAlertRuleTemplateVersion { + /** + * Executes the update request. + * + * @return the updated resource. + */ + AlertRuleResource apply(); + + /** + * Executes the update request. + * + * @param context The context to associate with this operation. + * @return the updated resource. + */ + AlertRuleResource apply(Context context); + } + + /** + * The AlertRuleResource update stages. + */ + interface UpdateStages { + /** + * The stage of the AlertRuleResource update allowing to specify alertRuleResourceId. + */ + interface WithAlertRuleResourceId { + /** + * Specifies the alertRuleResourceId property: The resource ID of the alert rule resource.. + * + * @param alertRuleResourceId The resource ID of the alert rule resource. + * @return the next definition stage. + */ + Update withAlertRuleResourceId(String alertRuleResourceId); + } + + /** + * The stage of the AlertRuleResource update allowing to specify createdWithProperties. + */ + interface WithCreatedWithProperties { + /** + * Specifies the createdWithProperties property: The properties with which the alert rule resource was + * created.. + * + * @param createdWithProperties The properties with which the alert rule resource was created. + * @return the next definition stage. + */ + Update withCreatedWithProperties(AlertRuleCreationProperties createdWithProperties); + } + + /** + * The stage of the AlertRuleResource update allowing to specify creationTime. + */ + interface WithCreationTime { + /** + * Specifies the creationTime property: The creation time of the alert rule resource.. + * + * @param creationTime The creation time of the alert rule resource. + * @return the next definition stage. + */ + Update withCreationTime(OffsetDateTime creationTime); + } + + /** + * The stage of the AlertRuleResource update allowing to specify alertRuleTemplateId. + */ + interface WithAlertRuleTemplateId { + /** + * Specifies the alertRuleTemplateId property: The template ID associated with alert rule resource.. + * + * @param alertRuleTemplateId The template ID associated with alert rule resource. + * @return the next definition stage. + */ + Update withAlertRuleTemplateId(String alertRuleTemplateId); + } + + /** + * The stage of the AlertRuleResource update allowing to specify alertRuleTemplateVersion. + */ + interface WithAlertRuleTemplateVersion { + /** + * Specifies the alertRuleTemplateVersion property: The alert rule template version.. + * + * @param alertRuleTemplateVersion The alert rule template version. + * @return the next definition stage. + */ + Update withAlertRuleTemplateVersion(String alertRuleTemplateVersion); + } + } + + /** + * Refreshes the resource to sync with Azure. + * + * @return the refreshed resource. + */ + AlertRuleResource refresh(); + + /** + * Refreshes the resource to sync with Azure. + * + * @param context The context to associate with this operation. + * @return the refreshed resource. + */ + AlertRuleResource refresh(Context context); +} diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/AlertRuleResourceListResult.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/AlertRuleResourceListResult.java new file mode 100644 index 0000000000000..7a6d8a7db7532 --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/AlertRuleResourceListResult.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.databasewatcher.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.databasewatcher.fluent.models.AlertRuleResourceInner; +import java.io.IOException; +import java.util.List; + +/** + * The response of a AlertRuleResource list operation. + */ +@Fluent +public final class AlertRuleResourceListResult implements JsonSerializable { + /* + * The AlertRuleResource items on this page + */ + private List value; + + /* + * The link to the next page of items + */ + private String nextLink; + + /** + * Creates an instance of AlertRuleResourceListResult class. + */ + public AlertRuleResourceListResult() { + } + + /** + * Get the value property: The AlertRuleResource items on this page. + * + * @return the value value. + */ + public List value() { + return this.value; + } + + /** + * Set the value property: The AlertRuleResource items on this page. + * + * @param value the value value to set. + * @return the AlertRuleResourceListResult object itself. + */ + public AlertRuleResourceListResult withValue(List value) { + this.value = value; + return this; + } + + /** + * Get the nextLink property: The link to the next page of items. + * + * @return the nextLink value. + */ + public String nextLink() { + return this.nextLink; + } + + /** + * Set the nextLink property: The link to the next page of items. + * + * @param nextLink the nextLink value to set. + * @return the AlertRuleResourceListResult object itself. + */ + public AlertRuleResourceListResult 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) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property value in model AlertRuleResourceListResult")); + } else { + value().forEach(e -> e.validate()); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(AlertRuleResourceListResult.class); + + /** + * {@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 AlertRuleResourceListResult from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of AlertRuleResourceListResult 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 AlertRuleResourceListResult. + */ + public static AlertRuleResourceListResult fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + AlertRuleResourceListResult deserializedAlertRuleResourceListResult = new AlertRuleResourceListResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("value".equals(fieldName)) { + List value + = reader.readArray(reader1 -> AlertRuleResourceInner.fromJson(reader1)); + deserializedAlertRuleResourceListResult.value = value; + } else if ("nextLink".equals(fieldName)) { + deserializedAlertRuleResourceListResult.nextLink = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedAlertRuleResourceListResult; + }); + } +} diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/AlertRuleResources.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/AlertRuleResources.java new file mode 100644 index 0000000000000..cbea7d2fc1bba --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/AlertRuleResources.java @@ -0,0 +1,147 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.databasewatcher.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 AlertRuleResources. + */ +public interface AlertRuleResources { + /** + * List AlertRuleResource resources by Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a AlertRuleResource list operation as paginated response with {@link PagedIterable}. + */ + PagedIterable listByParent(String resourceGroupName, String watcherName); + + /** + * List AlertRuleResource resources by Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a AlertRuleResource list operation as paginated response with {@link PagedIterable}. + */ + PagedIterable listByParent(String resourceGroupName, String watcherName, Context context); + + /** + * Get a AlertRuleResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param alertRuleResourceName The alert rule proxy resource name. + * @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 AlertRuleResource along with {@link Response}. + */ + Response getWithResponse(String resourceGroupName, String watcherName, + String alertRuleResourceName, Context context); + + /** + * Get a AlertRuleResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param alertRuleResourceName The alert rule proxy resource name. + * @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 AlertRuleResource. + */ + AlertRuleResource get(String resourceGroupName, String watcherName, String alertRuleResourceName); + + /** + * Delete a AlertRuleResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param alertRuleResourceName The alert rule proxy resource name. + * @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 deleteWithResponse(String resourceGroupName, String watcherName, String alertRuleResourceName, + Context context); + + /** + * Delete a AlertRuleResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param alertRuleResourceName The alert rule proxy resource name. + * @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 delete(String resourceGroupName, String watcherName, String alertRuleResourceName); + + /** + * Get a AlertRuleResource. + * + * @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 a AlertRuleResource along with {@link Response}. + */ + AlertRuleResource getById(String id); + + /** + * Get a AlertRuleResource. + * + * @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 a AlertRuleResource along with {@link Response}. + */ + Response getByIdWithResponse(String id, Context context); + + /** + * Delete a AlertRuleResource. + * + * @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 a AlertRuleResource. + * + * @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 AlertRuleResource resource. + * + * @param name resource name. + * @return the first stage of the new AlertRuleResource definition. + */ + AlertRuleResource.DefinitionStages.Blank define(String name); +} diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/DatabaseWatcherProvisioningState.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/DatabaseWatcherProvisioningState.java new file mode 100644 index 0000000000000..06e5adbf78fdf --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/DatabaseWatcherProvisioningState.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.databasewatcher.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * The status of the last provisioning operation performed on the resource. + */ +public final class DatabaseWatcherProvisioningState extends ExpandableStringEnum { + /** + * Static value Succeeded for DatabaseWatcherProvisioningState. + */ + public static final DatabaseWatcherProvisioningState SUCCEEDED = fromString("Succeeded"); + + /** + * Static value Failed for DatabaseWatcherProvisioningState. + */ + public static final DatabaseWatcherProvisioningState FAILED = fromString("Failed"); + + /** + * Static value Canceled for DatabaseWatcherProvisioningState. + */ + public static final DatabaseWatcherProvisioningState CANCELED = fromString("Canceled"); + + /** + * Creates a new instance of DatabaseWatcherProvisioningState value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public DatabaseWatcherProvisioningState() { + } + + /** + * Creates or finds a DatabaseWatcherProvisioningState from its string representation. + * + * @param name a name to look for. + * @return the corresponding DatabaseWatcherProvisioningState. + */ + public static DatabaseWatcherProvisioningState fromString(String name) { + return fromString(name, DatabaseWatcherProvisioningState.class); + } + + /** + * Gets known DatabaseWatcherProvisioningState values. + * + * @return known DatabaseWatcherProvisioningState values. + */ + public static Collection values() { + return values(DatabaseWatcherProvisioningState.class); + } +} diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/Datastore.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/Datastore.java new file mode 100644 index 0000000000000..55d40516e2bd0 --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/Datastore.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.databasewatcher.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 properties of a data store. + */ +@Fluent +public final class Datastore implements JsonSerializable { + /* + * The Azure ResourceId of an Azure Data Explorer cluster. + */ + private String adxClusterResourceId; + + /* + * The Kusto cluster display name. + */ + private String kustoClusterDisplayName; + + /* + * The Kusto cluster URI. + */ + private String kustoClusterUri; + + /* + * The Kusto data ingestion URI. + */ + private String kustoDataIngestionUri; + + /* + * The name of a Kusto database. + */ + private String kustoDatabaseName; + + /* + * The Kusto management URL. + */ + private String kustoManagementUrl; + + /* + * The type of a Kusto offering. + */ + private KustoOfferingType kustoOfferingType; + + /** + * Creates an instance of Datastore class. + */ + public Datastore() { + } + + /** + * Get the adxClusterResourceId property: The Azure ResourceId of an Azure Data Explorer cluster. + * + * @return the adxClusterResourceId value. + */ + public String adxClusterResourceId() { + return this.adxClusterResourceId; + } + + /** + * Set the adxClusterResourceId property: The Azure ResourceId of an Azure Data Explorer cluster. + * + * @param adxClusterResourceId the adxClusterResourceId value to set. + * @return the Datastore object itself. + */ + public Datastore withAdxClusterResourceId(String adxClusterResourceId) { + this.adxClusterResourceId = adxClusterResourceId; + return this; + } + + /** + * Get the kustoClusterDisplayName property: The Kusto cluster display name. + * + * @return the kustoClusterDisplayName value. + */ + public String kustoClusterDisplayName() { + return this.kustoClusterDisplayName; + } + + /** + * Set the kustoClusterDisplayName property: The Kusto cluster display name. + * + * @param kustoClusterDisplayName the kustoClusterDisplayName value to set. + * @return the Datastore object itself. + */ + public Datastore withKustoClusterDisplayName(String kustoClusterDisplayName) { + this.kustoClusterDisplayName = kustoClusterDisplayName; + return this; + } + + /** + * Get the kustoClusterUri property: The Kusto cluster URI. + * + * @return the kustoClusterUri value. + */ + public String kustoClusterUri() { + return this.kustoClusterUri; + } + + /** + * Set the kustoClusterUri property: The Kusto cluster URI. + * + * @param kustoClusterUri the kustoClusterUri value to set. + * @return the Datastore object itself. + */ + public Datastore withKustoClusterUri(String kustoClusterUri) { + this.kustoClusterUri = kustoClusterUri; + return this; + } + + /** + * Get the kustoDataIngestionUri property: The Kusto data ingestion URI. + * + * @return the kustoDataIngestionUri value. + */ + public String kustoDataIngestionUri() { + return this.kustoDataIngestionUri; + } + + /** + * Set the kustoDataIngestionUri property: The Kusto data ingestion URI. + * + * @param kustoDataIngestionUri the kustoDataIngestionUri value to set. + * @return the Datastore object itself. + */ + public Datastore withKustoDataIngestionUri(String kustoDataIngestionUri) { + this.kustoDataIngestionUri = kustoDataIngestionUri; + return this; + } + + /** + * Get the kustoDatabaseName property: The name of a Kusto database. + * + * @return the kustoDatabaseName value. + */ + public String kustoDatabaseName() { + return this.kustoDatabaseName; + } + + /** + * Set the kustoDatabaseName property: The name of a Kusto database. + * + * @param kustoDatabaseName the kustoDatabaseName value to set. + * @return the Datastore object itself. + */ + public Datastore withKustoDatabaseName(String kustoDatabaseName) { + this.kustoDatabaseName = kustoDatabaseName; + return this; + } + + /** + * Get the kustoManagementUrl property: The Kusto management URL. + * + * @return the kustoManagementUrl value. + */ + public String kustoManagementUrl() { + return this.kustoManagementUrl; + } + + /** + * Set the kustoManagementUrl property: The Kusto management URL. + * + * @param kustoManagementUrl the kustoManagementUrl value to set. + * @return the Datastore object itself. + */ + public Datastore withKustoManagementUrl(String kustoManagementUrl) { + this.kustoManagementUrl = kustoManagementUrl; + return this; + } + + /** + * Get the kustoOfferingType property: The type of a Kusto offering. + * + * @return the kustoOfferingType value. + */ + public KustoOfferingType kustoOfferingType() { + return this.kustoOfferingType; + } + + /** + * Set the kustoOfferingType property: The type of a Kusto offering. + * + * @param kustoOfferingType the kustoOfferingType value to set. + * @return the Datastore object itself. + */ + public Datastore withKustoOfferingType(KustoOfferingType kustoOfferingType) { + this.kustoOfferingType = kustoOfferingType; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (kustoClusterUri() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property kustoClusterUri in model Datastore")); + } + if (kustoDataIngestionUri() == null) { + throw LOGGER.atError() + .log( + new IllegalArgumentException("Missing required property kustoDataIngestionUri in model Datastore")); + } + if (kustoDatabaseName() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property kustoDatabaseName in model Datastore")); + } + if (kustoManagementUrl() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property kustoManagementUrl in model Datastore")); + } + if (kustoOfferingType() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property kustoOfferingType in model Datastore")); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(Datastore.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("kustoClusterUri", this.kustoClusterUri); + jsonWriter.writeStringField("kustoDataIngestionUri", this.kustoDataIngestionUri); + jsonWriter.writeStringField("kustoDatabaseName", this.kustoDatabaseName); + jsonWriter.writeStringField("kustoManagementUrl", this.kustoManagementUrl); + jsonWriter.writeStringField("kustoOfferingType", + this.kustoOfferingType == null ? null : this.kustoOfferingType.toString()); + jsonWriter.writeStringField("adxClusterResourceId", this.adxClusterResourceId); + jsonWriter.writeStringField("kustoClusterDisplayName", this.kustoClusterDisplayName); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Datastore from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Datastore 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 Datastore. + */ + public static Datastore fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + Datastore deserializedDatastore = new Datastore(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("kustoClusterUri".equals(fieldName)) { + deserializedDatastore.kustoClusterUri = reader.getString(); + } else if ("kustoDataIngestionUri".equals(fieldName)) { + deserializedDatastore.kustoDataIngestionUri = reader.getString(); + } else if ("kustoDatabaseName".equals(fieldName)) { + deserializedDatastore.kustoDatabaseName = reader.getString(); + } else if ("kustoManagementUrl".equals(fieldName)) { + deserializedDatastore.kustoManagementUrl = reader.getString(); + } else if ("kustoOfferingType".equals(fieldName)) { + deserializedDatastore.kustoOfferingType = KustoOfferingType.fromString(reader.getString()); + } else if ("adxClusterResourceId".equals(fieldName)) { + deserializedDatastore.adxClusterResourceId = reader.getString(); + } else if ("kustoClusterDisplayName".equals(fieldName)) { + deserializedDatastore.kustoClusterDisplayName = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedDatastore; + }); + } +} diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/DatastoreUpdate.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/DatastoreUpdate.java new file mode 100644 index 0000000000000..4f92b3901bb38 --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/DatastoreUpdate.java @@ -0,0 +1,262 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.databasewatcher.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 properties of a data store. + */ +@Fluent +public final class DatastoreUpdate implements JsonSerializable { + /* + * The Azure ResourceId of an Azure Data Explorer cluster. + */ + private String adxClusterResourceId; + + /* + * The Kusto cluster display name. + */ + private String kustoClusterDisplayName; + + /* + * The Kusto cluster URI. + */ + private String kustoClusterUri; + + /* + * The Kusto data ingestion URI. + */ + private String kustoDataIngestionUri; + + /* + * The name of a Kusto database. + */ + private String kustoDatabaseName; + + /* + * The Kusto management URL. + */ + private String kustoManagementUrl; + + /* + * The type of a Kusto offering. + */ + private KustoOfferingType kustoOfferingType; + + /** + * Creates an instance of DatastoreUpdate class. + */ + public DatastoreUpdate() { + } + + /** + * Get the adxClusterResourceId property: The Azure ResourceId of an Azure Data Explorer cluster. + * + * @return the adxClusterResourceId value. + */ + public String adxClusterResourceId() { + return this.adxClusterResourceId; + } + + /** + * Set the adxClusterResourceId property: The Azure ResourceId of an Azure Data Explorer cluster. + * + * @param adxClusterResourceId the adxClusterResourceId value to set. + * @return the DatastoreUpdate object itself. + */ + public DatastoreUpdate withAdxClusterResourceId(String adxClusterResourceId) { + this.adxClusterResourceId = adxClusterResourceId; + return this; + } + + /** + * Get the kustoClusterDisplayName property: The Kusto cluster display name. + * + * @return the kustoClusterDisplayName value. + */ + public String kustoClusterDisplayName() { + return this.kustoClusterDisplayName; + } + + /** + * Set the kustoClusterDisplayName property: The Kusto cluster display name. + * + * @param kustoClusterDisplayName the kustoClusterDisplayName value to set. + * @return the DatastoreUpdate object itself. + */ + public DatastoreUpdate withKustoClusterDisplayName(String kustoClusterDisplayName) { + this.kustoClusterDisplayName = kustoClusterDisplayName; + return this; + } + + /** + * Get the kustoClusterUri property: The Kusto cluster URI. + * + * @return the kustoClusterUri value. + */ + public String kustoClusterUri() { + return this.kustoClusterUri; + } + + /** + * Set the kustoClusterUri property: The Kusto cluster URI. + * + * @param kustoClusterUri the kustoClusterUri value to set. + * @return the DatastoreUpdate object itself. + */ + public DatastoreUpdate withKustoClusterUri(String kustoClusterUri) { + this.kustoClusterUri = kustoClusterUri; + return this; + } + + /** + * Get the kustoDataIngestionUri property: The Kusto data ingestion URI. + * + * @return the kustoDataIngestionUri value. + */ + public String kustoDataIngestionUri() { + return this.kustoDataIngestionUri; + } + + /** + * Set the kustoDataIngestionUri property: The Kusto data ingestion URI. + * + * @param kustoDataIngestionUri the kustoDataIngestionUri value to set. + * @return the DatastoreUpdate object itself. + */ + public DatastoreUpdate withKustoDataIngestionUri(String kustoDataIngestionUri) { + this.kustoDataIngestionUri = kustoDataIngestionUri; + return this; + } + + /** + * Get the kustoDatabaseName property: The name of a Kusto database. + * + * @return the kustoDatabaseName value. + */ + public String kustoDatabaseName() { + return this.kustoDatabaseName; + } + + /** + * Set the kustoDatabaseName property: The name of a Kusto database. + * + * @param kustoDatabaseName the kustoDatabaseName value to set. + * @return the DatastoreUpdate object itself. + */ + public DatastoreUpdate withKustoDatabaseName(String kustoDatabaseName) { + this.kustoDatabaseName = kustoDatabaseName; + return this; + } + + /** + * Get the kustoManagementUrl property: The Kusto management URL. + * + * @return the kustoManagementUrl value. + */ + public String kustoManagementUrl() { + return this.kustoManagementUrl; + } + + /** + * Set the kustoManagementUrl property: The Kusto management URL. + * + * @param kustoManagementUrl the kustoManagementUrl value to set. + * @return the DatastoreUpdate object itself. + */ + public DatastoreUpdate withKustoManagementUrl(String kustoManagementUrl) { + this.kustoManagementUrl = kustoManagementUrl; + return this; + } + + /** + * Get the kustoOfferingType property: The type of a Kusto offering. + * + * @return the kustoOfferingType value. + */ + public KustoOfferingType kustoOfferingType() { + return this.kustoOfferingType; + } + + /** + * Set the kustoOfferingType property: The type of a Kusto offering. + * + * @param kustoOfferingType the kustoOfferingType value to set. + * @return the DatastoreUpdate object itself. + */ + public DatastoreUpdate withKustoOfferingType(KustoOfferingType kustoOfferingType) { + this.kustoOfferingType = kustoOfferingType; + 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("adxClusterResourceId", this.adxClusterResourceId); + jsonWriter.writeStringField("kustoClusterDisplayName", this.kustoClusterDisplayName); + jsonWriter.writeStringField("kustoClusterUri", this.kustoClusterUri); + jsonWriter.writeStringField("kustoDataIngestionUri", this.kustoDataIngestionUri); + jsonWriter.writeStringField("kustoDatabaseName", this.kustoDatabaseName); + jsonWriter.writeStringField("kustoManagementUrl", this.kustoManagementUrl); + jsonWriter.writeStringField("kustoOfferingType", + this.kustoOfferingType == null ? null : this.kustoOfferingType.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of DatastoreUpdate from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of DatastoreUpdate 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 DatastoreUpdate. + */ + public static DatastoreUpdate fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + DatastoreUpdate deserializedDatastoreUpdate = new DatastoreUpdate(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("adxClusterResourceId".equals(fieldName)) { + deserializedDatastoreUpdate.adxClusterResourceId = reader.getString(); + } else if ("kustoClusterDisplayName".equals(fieldName)) { + deserializedDatastoreUpdate.kustoClusterDisplayName = reader.getString(); + } else if ("kustoClusterUri".equals(fieldName)) { + deserializedDatastoreUpdate.kustoClusterUri = reader.getString(); + } else if ("kustoDataIngestionUri".equals(fieldName)) { + deserializedDatastoreUpdate.kustoDataIngestionUri = reader.getString(); + } else if ("kustoDatabaseName".equals(fieldName)) { + deserializedDatastoreUpdate.kustoDatabaseName = reader.getString(); + } else if ("kustoManagementUrl".equals(fieldName)) { + deserializedDatastoreUpdate.kustoManagementUrl = reader.getString(); + } else if ("kustoOfferingType".equals(fieldName)) { + deserializedDatastoreUpdate.kustoOfferingType = KustoOfferingType.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + + return deserializedDatastoreUpdate; + }); + } +} diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/KustoOfferingType.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/KustoOfferingType.java new file mode 100644 index 0000000000000..1177f3c5036ea --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/KustoOfferingType.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.databasewatcher.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * The type of Kusto offering. + */ +public final class KustoOfferingType extends ExpandableStringEnum { + /** + * Static value adx for KustoOfferingType. + */ + public static final KustoOfferingType ADX = fromString("adx"); + + /** + * Static value free for KustoOfferingType. + */ + public static final KustoOfferingType FREE = fromString("free"); + + /** + * Static value fabric for KustoOfferingType. + */ + public static final KustoOfferingType FABRIC = fromString("fabric"); + + /** + * Creates a new instance of KustoOfferingType value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public KustoOfferingType() { + } + + /** + * Creates or finds a KustoOfferingType from its string representation. + * + * @param name a name to look for. + * @return the corresponding KustoOfferingType. + */ + public static KustoOfferingType fromString(String name) { + return fromString(name, KustoOfferingType.class); + } + + /** + * Gets known KustoOfferingType values. + * + * @return known KustoOfferingType values. + */ + public static Collection values() { + return values(KustoOfferingType.class); + } +} diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/ManagedServiceIdentity.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/ManagedServiceIdentity.java new file mode 100644 index 0000000000000..34e2c383ea137 --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/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.databasewatcher.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/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/ManagedServiceIdentityType.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/ManagedServiceIdentityType.java new file mode 100644 index 0000000000000..467cd09c4083a --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/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.databasewatcher.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/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/Operation.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/Operation.java new file mode 100644 index 0000000000000..a638db2db3c77 --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/Operation.java @@ -0,0 +1,58 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.databasewatcher.models; + +import com.azure.resourcemanager.databasewatcher.fluent.models.OperationInner; + +/** + * An immutable client-side representation of Operation. + */ +public interface Operation { + /** + * Gets the name property: The name of the operation, as per Resource-Based Access Control (RBAC). Examples: + * "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action". + * + * @return the name value. + */ + String name(); + + /** + * Gets the isDataAction property: Whether the operation applies to data-plane. This is "true" for data-plane + * operations and "false" for ARM/control-plane operations. + * + * @return the isDataAction value. + */ + Boolean isDataAction(); + + /** + * Gets the display property: Localized display information for this particular operation. + * + * @return the display value. + */ + OperationDisplay display(); + + /** + * Gets the origin property: The intended executor of the operation; as in Resource Based Access Control (RBAC) and + * audit logs UX. Default value is "user,system". + * + * @return the origin value. + */ + Origin origin(); + + /** + * Gets the actionType property: Enum. Indicates the action type. "Internal" refers to actions that are for internal + * only APIs. + * + * @return the actionType value. + */ + ActionType actionType(); + + /** + * Gets the inner com.azure.resourcemanager.databasewatcher.fluent.models.OperationInner object. + * + * @return the inner object. + */ + OperationInner innerModel(); +} diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/OperationDisplay.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/OperationDisplay.java new file mode 100644 index 0000000000000..733737452e78a --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/OperationDisplay.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.databasewatcher.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; + +/** + * Localized display information for this particular operation. + */ +@Immutable +public final class OperationDisplay implements JsonSerializable { + /* + * The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or + * "Microsoft Compute". + */ + private String provider; + + /* + * The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or + * "Job Schedule Collections". + */ + private String resource; + + /* + * The concise, localized friendly name for the operation; suitable for dropdowns. E.g. + * "Create or Update Virtual Machine", "Restart Virtual Machine". + */ + private String operation; + + /* + * The short, localized friendly description of the operation; suitable for tool tips and detailed views. + */ + private String description; + + /** + * Creates an instance of OperationDisplay class. + */ + public OperationDisplay() { + } + + /** + * Get the provider property: The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring + * Insights" or "Microsoft Compute". + * + * @return the provider value. + */ + public String provider() { + return this.provider; + } + + /** + * Get the resource property: The localized friendly name of the resource type related to this operation. E.g. + * "Virtual Machines" or "Job Schedule Collections". + * + * @return the resource value. + */ + public String resource() { + return this.resource; + } + + /** + * Get the operation property: The concise, localized friendly name for the operation; suitable for dropdowns. E.g. + * "Create or Update Virtual Machine", "Restart Virtual Machine". + * + * @return the operation value. + */ + public String operation() { + return this.operation; + } + + /** + * Get the description property: The short, localized friendly description of the operation; suitable for tool tips + * and detailed views. + * + * @return the description value. + */ + public String description() { + return this.description; + } + + /** + * 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 OperationDisplay from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of OperationDisplay 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 OperationDisplay. + */ + public static OperationDisplay fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + OperationDisplay deserializedOperationDisplay = new OperationDisplay(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("provider".equals(fieldName)) { + deserializedOperationDisplay.provider = reader.getString(); + } else if ("resource".equals(fieldName)) { + deserializedOperationDisplay.resource = reader.getString(); + } else if ("operation".equals(fieldName)) { + deserializedOperationDisplay.operation = reader.getString(); + } else if ("description".equals(fieldName)) { + deserializedOperationDisplay.description = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedOperationDisplay; + }); + } +} diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/OperationListResult.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/OperationListResult.java new file mode 100644 index 0000000000000..482d5917385a3 --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/OperationListResult.java @@ -0,0 +1,104 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.databasewatcher.models; + +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.azure.resourcemanager.databasewatcher.fluent.models.OperationInner; +import java.io.IOException; +import java.util.List; + +/** + * A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of + * results. + */ +@Immutable +public final class OperationListResult implements JsonSerializable { + /* + * List of operations supported by the resource provider + */ + private List value; + + /* + * URL to get the next set of operation list results (if there are any). + */ + private String nextLink; + + /** + * Creates an instance of OperationListResult class. + */ + public OperationListResult() { + } + + /** + * Get the value property: List of operations supported by the resource provider. + * + * @return the value value. + */ + public List value() { + return this.value; + } + + /** + * Get the nextLink property: URL to get the next set of operation list results (if there are any). + * + * @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(); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of OperationListResult from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of OperationListResult 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 OperationListResult. + */ + public static OperationListResult fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + OperationListResult deserializedOperationListResult = new OperationListResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("value".equals(fieldName)) { + List value = reader.readArray(reader1 -> OperationInner.fromJson(reader1)); + deserializedOperationListResult.value = value; + } else if ("nextLink".equals(fieldName)) { + deserializedOperationListResult.nextLink = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedOperationListResult; + }); + } +} diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/Operations.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/Operations.java new file mode 100644 index 0000000000000..c0d0682bd5f81 --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/Operations.java @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.databasewatcher.models; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.util.Context; + +/** + * Resource collection API of Operations. + */ +public interface Operations { + /** + * List the operations for the provider. + * + * @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 REST API operations supported by an Azure Resource Provider as paginated response with + * {@link PagedIterable}. + */ + PagedIterable list(); + + /** + * List the operations for the provider. + * + * @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 REST API operations supported by an Azure Resource Provider as paginated response with + * {@link PagedIterable}. + */ + PagedIterable list(Context context); +} diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/Origin.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/Origin.java new file mode 100644 index 0000000000000..43e169851ec77 --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/Origin.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.databasewatcher.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default value + * is "user,system". + */ +public final class Origin extends ExpandableStringEnum { + /** + * Static value user for Origin. + */ + public static final Origin USER = fromString("user"); + + /** + * Static value system for Origin. + */ + public static final Origin SYSTEM = fromString("system"); + + /** + * Static value user,system for Origin. + */ + public static final Origin USER_SYSTEM = fromString("user,system"); + + /** + * Creates a new instance of Origin value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public Origin() { + } + + /** + * Creates or finds a Origin from its string representation. + * + * @param name a name to look for. + * @return the corresponding Origin. + */ + public static Origin fromString(String name) { + return fromString(name, Origin.class); + } + + /** + * Gets known Origin values. + * + * @return known Origin values. + */ + public static Collection values() { + return values(Origin.class); + } +} diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/ResourceProvisioningState.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/ResourceProvisioningState.java new file mode 100644 index 0000000000000..1ef240c1fed63 --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/ResourceProvisioningState.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.databasewatcher.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * The provisioning state of a resource type. + */ +public final class ResourceProvisioningState extends ExpandableStringEnum { + /** + * Static value Succeeded for ResourceProvisioningState. + */ + public static final ResourceProvisioningState SUCCEEDED = fromString("Succeeded"); + + /** + * Static value Failed for ResourceProvisioningState. + */ + public static final ResourceProvisioningState FAILED = fromString("Failed"); + + /** + * Static value Canceled for ResourceProvisioningState. + */ + public static final ResourceProvisioningState CANCELED = fromString("Canceled"); + + /** + * Creates a new instance of ResourceProvisioningState value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public ResourceProvisioningState() { + } + + /** + * Creates or finds a ResourceProvisioningState from its string representation. + * + * @param name a name to look for. + * @return the corresponding ResourceProvisioningState. + */ + public static ResourceProvisioningState fromString(String name) { + return fromString(name, ResourceProvisioningState.class); + } + + /** + * Gets known ResourceProvisioningState values. + * + * @return known ResourceProvisioningState values. + */ + public static Collection values() { + return values(ResourceProvisioningState.class); + } +} diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/SharedPrivateLinkResource.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/SharedPrivateLinkResource.java new file mode 100644 index 0000000000000..9fcc837cbcc37 --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/SharedPrivateLinkResource.java @@ -0,0 +1,220 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.databasewatcher.models; + +import com.azure.core.management.SystemData; +import com.azure.core.util.Context; +import com.azure.resourcemanager.databasewatcher.fluent.models.SharedPrivateLinkResourceInner; + +/** + * An immutable client-side representation of SharedPrivateLinkResource. + */ +public interface SharedPrivateLinkResource { + /** + * 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 systemData property: Azure Resource Manager metadata containing createdBy and modifiedBy information. + * + * @return the systemData value. + */ + SystemData systemData(); + + /** + * Gets the privateLinkResourceId property: The resource id of the resource the shared private link resource is for. + * + * @return the privateLinkResourceId value. + */ + String privateLinkResourceId(); + + /** + * Gets the groupId property: The group id from the provider of resource the shared private link resource is for. + * + * @return the groupId value. + */ + String groupId(); + + /** + * Gets the requestMessage property: The request message for requesting approval of the shared private link + * resource. + * + * @return the requestMessage value. + */ + String requestMessage(); + + /** + * Gets the dnsZone property: The DNS zone to be included in the DNS name of the shared private link. Value is + * service-specific. + * + * @return the dnsZone value. + */ + String dnsZone(); + + /** + * Gets the status property: Status of the shared private link resource. Can be Pending, Approved, Rejected or + * Disconnected. + * + * @return the status value. + */ + SharedPrivateLinkResourceStatus status(); + + /** + * Gets the provisioningState property: The provisioning state of the resource. + * + * @return the provisioningState value. + */ + ResourceProvisioningState provisioningState(); + + /** + * Gets the inner com.azure.resourcemanager.databasewatcher.fluent.models.SharedPrivateLinkResourceInner object. + * + * @return the inner object. + */ + SharedPrivateLinkResourceInner innerModel(); + + /** + * The entirety of the SharedPrivateLinkResource definition. + */ + interface Definition + extends DefinitionStages.Blank, DefinitionStages.WithParentResource, DefinitionStages.WithCreate { + } + + /** + * The SharedPrivateLinkResource definition stages. + */ + interface DefinitionStages { + /** + * The first stage of the SharedPrivateLinkResource definition. + */ + interface Blank extends WithParentResource { + } + + /** + * The stage of the SharedPrivateLinkResource definition allowing to specify parent resource. + */ + interface WithParentResource { + /** + * Specifies resourceGroupName, watcherName. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @return the next definition stage. + */ + WithCreate withExistingWatcher(String resourceGroupName, String watcherName); + } + + /** + * The stage of the SharedPrivateLinkResource 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.WithPrivateLinkResourceId, DefinitionStages.WithGroupId, + DefinitionStages.WithRequestMessage, DefinitionStages.WithDnsZone { + /** + * Executes the create request. + * + * @return the created resource. + */ + SharedPrivateLinkResource create(); + + /** + * Executes the create request. + * + * @param context The context to associate with this operation. + * @return the created resource. + */ + SharedPrivateLinkResource create(Context context); + } + + /** + * The stage of the SharedPrivateLinkResource definition allowing to specify privateLinkResourceId. + */ + interface WithPrivateLinkResourceId { + /** + * Specifies the privateLinkResourceId property: The resource id of the resource the shared private link + * resource is for.. + * + * @param privateLinkResourceId The resource id of the resource the shared private link resource is for. + * @return the next definition stage. + */ + WithCreate withPrivateLinkResourceId(String privateLinkResourceId); + } + + /** + * The stage of the SharedPrivateLinkResource definition allowing to specify groupId. + */ + interface WithGroupId { + /** + * Specifies the groupId property: The group id from the provider of resource the shared private link + * resource is for.. + * + * @param groupId The group id from the provider of resource the shared private link resource is for. + * @return the next definition stage. + */ + WithCreate withGroupId(String groupId); + } + + /** + * The stage of the SharedPrivateLinkResource definition allowing to specify requestMessage. + */ + interface WithRequestMessage { + /** + * Specifies the requestMessage property: The request message for requesting approval of the shared private + * link resource.. + * + * @param requestMessage The request message for requesting approval of the shared private link resource. + * @return the next definition stage. + */ + WithCreate withRequestMessage(String requestMessage); + } + + /** + * The stage of the SharedPrivateLinkResource definition allowing to specify dnsZone. + */ + interface WithDnsZone { + /** + * Specifies the dnsZone property: The DNS zone to be included in the DNS name of the shared private link. + * Value is service-specific.. + * + * @param dnsZone The DNS zone to be included in the DNS name of the shared private link. Value is + * service-specific. + * @return the next definition stage. + */ + WithCreate withDnsZone(String dnsZone); + } + } + + /** + * Refreshes the resource to sync with Azure. + * + * @return the refreshed resource. + */ + SharedPrivateLinkResource refresh(); + + /** + * Refreshes the resource to sync with Azure. + * + * @param context The context to associate with this operation. + * @return the refreshed resource. + */ + SharedPrivateLinkResource refresh(Context context); +} diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/SharedPrivateLinkResourceListResult.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/SharedPrivateLinkResourceListResult.java new file mode 100644 index 0000000000000..79863da65d755 --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/SharedPrivateLinkResourceListResult.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.databasewatcher.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.databasewatcher.fluent.models.SharedPrivateLinkResourceInner; +import java.io.IOException; +import java.util.List; + +/** + * The response of a SharedPrivateLinkResource list operation. + */ +@Fluent +public final class SharedPrivateLinkResourceListResult + implements JsonSerializable { + /* + * The SharedPrivateLinkResource items on this page + */ + private List value; + + /* + * The link to the next page of items + */ + private String nextLink; + + /** + * Creates an instance of SharedPrivateLinkResourceListResult class. + */ + public SharedPrivateLinkResourceListResult() { + } + + /** + * Get the value property: The SharedPrivateLinkResource items on this page. + * + * @return the value value. + */ + public List value() { + return this.value; + } + + /** + * Set the value property: The SharedPrivateLinkResource items on this page. + * + * @param value the value value to set. + * @return the SharedPrivateLinkResourceListResult object itself. + */ + public SharedPrivateLinkResourceListResult withValue(List value) { + this.value = value; + return this; + } + + /** + * Get the nextLink property: The link to the next page of items. + * + * @return the nextLink value. + */ + public String nextLink() { + return this.nextLink; + } + + /** + * Set the nextLink property: The link to the next page of items. + * + * @param nextLink the nextLink value to set. + * @return the SharedPrivateLinkResourceListResult object itself. + */ + public SharedPrivateLinkResourceListResult 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) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property value in model SharedPrivateLinkResourceListResult")); + } else { + value().forEach(e -> e.validate()); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(SharedPrivateLinkResourceListResult.class); + + /** + * {@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 SharedPrivateLinkResourceListResult from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SharedPrivateLinkResourceListResult 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 SharedPrivateLinkResourceListResult. + */ + public static SharedPrivateLinkResourceListResult fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + SharedPrivateLinkResourceListResult deserializedSharedPrivateLinkResourceListResult + = new SharedPrivateLinkResourceListResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("value".equals(fieldName)) { + List value + = reader.readArray(reader1 -> SharedPrivateLinkResourceInner.fromJson(reader1)); + deserializedSharedPrivateLinkResourceListResult.value = value; + } else if ("nextLink".equals(fieldName)) { + deserializedSharedPrivateLinkResourceListResult.nextLink = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedSharedPrivateLinkResourceListResult; + }); + } +} diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/SharedPrivateLinkResourceStatus.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/SharedPrivateLinkResourceStatus.java new file mode 100644 index 0000000000000..17759713b0546 --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/SharedPrivateLinkResourceStatus.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.databasewatcher.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Status of the shared private link resource. Can be Pending, Approved, Rejected or Disconnected. + */ +public final class SharedPrivateLinkResourceStatus extends ExpandableStringEnum { + /** + * Static value Pending for SharedPrivateLinkResourceStatus. + */ + public static final SharedPrivateLinkResourceStatus PENDING = fromString("Pending"); + + /** + * Static value Approved for SharedPrivateLinkResourceStatus. + */ + public static final SharedPrivateLinkResourceStatus APPROVED = fromString("Approved"); + + /** + * Static value Rejected for SharedPrivateLinkResourceStatus. + */ + public static final SharedPrivateLinkResourceStatus REJECTED = fromString("Rejected"); + + /** + * Static value Disconnected for SharedPrivateLinkResourceStatus. + */ + public static final SharedPrivateLinkResourceStatus DISCONNECTED = fromString("Disconnected"); + + /** + * Creates a new instance of SharedPrivateLinkResourceStatus value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public SharedPrivateLinkResourceStatus() { + } + + /** + * Creates or finds a SharedPrivateLinkResourceStatus from its string representation. + * + * @param name a name to look for. + * @return the corresponding SharedPrivateLinkResourceStatus. + */ + public static SharedPrivateLinkResourceStatus fromString(String name) { + return fromString(name, SharedPrivateLinkResourceStatus.class); + } + + /** + * Gets known SharedPrivateLinkResourceStatus values. + * + * @return known SharedPrivateLinkResourceStatus values. + */ + public static Collection values() { + return values(SharedPrivateLinkResourceStatus.class); + } +} diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/SharedPrivateLinkResources.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/SharedPrivateLinkResources.java new file mode 100644 index 0000000000000..b85799b5767b8 --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/SharedPrivateLinkResources.java @@ -0,0 +1,147 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.databasewatcher.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 SharedPrivateLinkResources. + */ +public interface SharedPrivateLinkResources { + /** + * List SharedPrivateLinkResource resources by Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a SharedPrivateLinkResource list operation as paginated response with + * {@link PagedIterable}. + */ + PagedIterable listByWatcher(String resourceGroupName, String watcherName); + + /** + * List SharedPrivateLinkResource resources by Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a SharedPrivateLinkResource list operation as paginated response with + * {@link PagedIterable}. + */ + PagedIterable listByWatcher(String resourceGroupName, String watcherName, + Context context); + + /** + * Get a SharedPrivateLinkResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param sharedPrivateLinkResourceName The Shared Private Link resource name. + * @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 SharedPrivateLinkResource along with {@link Response}. + */ + Response getWithResponse(String resourceGroupName, String watcherName, + String sharedPrivateLinkResourceName, Context context); + + /** + * Get a SharedPrivateLinkResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param sharedPrivateLinkResourceName The Shared Private Link resource name. + * @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 SharedPrivateLinkResource. + */ + SharedPrivateLinkResource get(String resourceGroupName, String watcherName, String sharedPrivateLinkResourceName); + + /** + * Delete a SharedPrivateLinkResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param sharedPrivateLinkResourceName The Shared Private Link resource name. + * @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 delete(String resourceGroupName, String watcherName, String sharedPrivateLinkResourceName); + + /** + * Delete a SharedPrivateLinkResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param sharedPrivateLinkResourceName The Shared Private Link resource name. + * @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. + */ + void delete(String resourceGroupName, String watcherName, String sharedPrivateLinkResourceName, Context context); + + /** + * Get a SharedPrivateLinkResource. + * + * @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 a SharedPrivateLinkResource along with {@link Response}. + */ + SharedPrivateLinkResource getById(String id); + + /** + * Get a SharedPrivateLinkResource. + * + * @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 a SharedPrivateLinkResource along with {@link Response}. + */ + Response getByIdWithResponse(String id, Context context); + + /** + * Delete a SharedPrivateLinkResource. + * + * @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 a SharedPrivateLinkResource. + * + * @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. + */ + void deleteByIdWithResponse(String id, Context context); + + /** + * Begins definition for a new SharedPrivateLinkResource resource. + * + * @param name resource name. + * @return the first stage of the new SharedPrivateLinkResource definition. + */ + SharedPrivateLinkResource.DefinitionStages.Blank define(String name); +} diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/SqlDbElasticPoolTargetProperties.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/SqlDbElasticPoolTargetProperties.java new file mode 100644 index 0000000000000..2346f10d5979c --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/SqlDbElasticPoolTargetProperties.java @@ -0,0 +1,243 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.databasewatcher.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The properties specific to elastic pool in Azure SQL Database. + */ +@Fluent +public final class SqlDbElasticPoolTargetProperties extends TargetProperties { + /* + * Discriminator property for TargetProperties. + */ + private String targetType = "SqlEp"; + + /* + * The Azure ResourceId of an Azure SQL DB elastic pool target. + */ + private String sqlEpResourceId; + + /* + * The Azure ResourceId of the anchor database used to connect to an elastic pool. + */ + private String anchorDatabaseResourceId; + + /* + * Set to true to monitor a high availability replica of specified target, if any. + */ + private Boolean readIntent; + + /* + * The provisioning state of the resource. + */ + private ResourceProvisioningState provisioningState; + + /** + * Creates an instance of SqlDbElasticPoolTargetProperties class. + */ + public SqlDbElasticPoolTargetProperties() { + } + + /** + * Get the targetType property: Discriminator property for TargetProperties. + * + * @return the targetType value. + */ + @Override + public String targetType() { + return this.targetType; + } + + /** + * Get the sqlEpResourceId property: The Azure ResourceId of an Azure SQL DB elastic pool target. + * + * @return the sqlEpResourceId value. + */ + public String sqlEpResourceId() { + return this.sqlEpResourceId; + } + + /** + * Set the sqlEpResourceId property: The Azure ResourceId of an Azure SQL DB elastic pool target. + * + * @param sqlEpResourceId the sqlEpResourceId value to set. + * @return the SqlDbElasticPoolTargetProperties object itself. + */ + public SqlDbElasticPoolTargetProperties withSqlEpResourceId(String sqlEpResourceId) { + this.sqlEpResourceId = sqlEpResourceId; + return this; + } + + /** + * Get the anchorDatabaseResourceId property: The Azure ResourceId of the anchor database used to connect to an + * elastic pool. + * + * @return the anchorDatabaseResourceId value. + */ + public String anchorDatabaseResourceId() { + return this.anchorDatabaseResourceId; + } + + /** + * Set the anchorDatabaseResourceId property: The Azure ResourceId of the anchor database used to connect to an + * elastic pool. + * + * @param anchorDatabaseResourceId the anchorDatabaseResourceId value to set. + * @return the SqlDbElasticPoolTargetProperties object itself. + */ + public SqlDbElasticPoolTargetProperties withAnchorDatabaseResourceId(String anchorDatabaseResourceId) { + this.anchorDatabaseResourceId = anchorDatabaseResourceId; + return this; + } + + /** + * Get the readIntent property: Set to true to monitor a high availability replica of specified target, if any. + * + * @return the readIntent value. + */ + public Boolean readIntent() { + return this.readIntent; + } + + /** + * Set the readIntent property: Set to true to monitor a high availability replica of specified target, if any. + * + * @param readIntent the readIntent value to set. + * @return the SqlDbElasticPoolTargetProperties object itself. + */ + public SqlDbElasticPoolTargetProperties withReadIntent(Boolean readIntent) { + this.readIntent = readIntent; + return this; + } + + /** + * Get the provisioningState property: The provisioning state of the resource. + * + * @return the provisioningState value. + */ + @Override + public ResourceProvisioningState provisioningState() { + return this.provisioningState; + } + + /** + * {@inheritDoc} + */ + @Override + public SqlDbElasticPoolTargetProperties + withTargetAuthenticationType(TargetAuthenticationType targetAuthenticationType) { + super.withTargetAuthenticationType(targetAuthenticationType); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public SqlDbElasticPoolTargetProperties withTargetVault(VaultSecret targetVault) { + super.withTargetVault(targetVault); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public SqlDbElasticPoolTargetProperties withConnectionServerName(String connectionServerName) { + super.withConnectionServerName(connectionServerName); + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + @Override + public void validate() { + super.validate(); + if (sqlEpResourceId() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property sqlEpResourceId in model SqlDbElasticPoolTargetProperties")); + } + if (anchorDatabaseResourceId() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property anchorDatabaseResourceId in model SqlDbElasticPoolTargetProperties")); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(SqlDbElasticPoolTargetProperties.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("targetAuthenticationType", + targetAuthenticationType() == null ? null : targetAuthenticationType().toString()); + jsonWriter.writeStringField("connectionServerName", connectionServerName()); + jsonWriter.writeJsonField("targetVault", targetVault()); + jsonWriter.writeStringField("sqlEpResourceId", this.sqlEpResourceId); + jsonWriter.writeStringField("anchorDatabaseResourceId", this.anchorDatabaseResourceId); + jsonWriter.writeStringField("targetType", this.targetType); + jsonWriter.writeBooleanField("readIntent", this.readIntent); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SqlDbElasticPoolTargetProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SqlDbElasticPoolTargetProperties 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 SqlDbElasticPoolTargetProperties. + */ + public static SqlDbElasticPoolTargetProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + SqlDbElasticPoolTargetProperties deserializedSqlDbElasticPoolTargetProperties + = new SqlDbElasticPoolTargetProperties(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("targetAuthenticationType".equals(fieldName)) { + deserializedSqlDbElasticPoolTargetProperties + .withTargetAuthenticationType(TargetAuthenticationType.fromString(reader.getString())); + } else if ("connectionServerName".equals(fieldName)) { + deserializedSqlDbElasticPoolTargetProperties.withConnectionServerName(reader.getString()); + } else if ("targetVault".equals(fieldName)) { + deserializedSqlDbElasticPoolTargetProperties.withTargetVault(VaultSecret.fromJson(reader)); + } else if ("provisioningState".equals(fieldName)) { + deserializedSqlDbElasticPoolTargetProperties.provisioningState + = ResourceProvisioningState.fromString(reader.getString()); + } else if ("sqlEpResourceId".equals(fieldName)) { + deserializedSqlDbElasticPoolTargetProperties.sqlEpResourceId = reader.getString(); + } else if ("anchorDatabaseResourceId".equals(fieldName)) { + deserializedSqlDbElasticPoolTargetProperties.anchorDatabaseResourceId = reader.getString(); + } else if ("targetType".equals(fieldName)) { + deserializedSqlDbElasticPoolTargetProperties.targetType = reader.getString(); + } else if ("readIntent".equals(fieldName)) { + deserializedSqlDbElasticPoolTargetProperties.readIntent + = reader.getNullable(JsonReader::getBoolean); + } else { + reader.skipChildren(); + } + } + + return deserializedSqlDbElasticPoolTargetProperties; + }); + } +} diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/SqlDbSingleDatabaseTargetProperties.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/SqlDbSingleDatabaseTargetProperties.java new file mode 100644 index 0000000000000..007b7b1d417b7 --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/SqlDbSingleDatabaseTargetProperties.java @@ -0,0 +1,208 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.databasewatcher.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The properties specific to single database in Azure SQL Database. + */ +@Fluent +public final class SqlDbSingleDatabaseTargetProperties extends TargetProperties { + /* + * Discriminator property for TargetProperties. + */ + private String targetType = "SqlDb"; + + /* + * The Azure ResourceId of an Azure SQL DB single database target. + */ + private String sqlDbResourceId; + + /* + * Set to true to monitor a high availability replica of specified target, if any. + */ + private Boolean readIntent; + + /* + * The provisioning state of the resource. + */ + private ResourceProvisioningState provisioningState; + + /** + * Creates an instance of SqlDbSingleDatabaseTargetProperties class. + */ + public SqlDbSingleDatabaseTargetProperties() { + } + + /** + * Get the targetType property: Discriminator property for TargetProperties. + * + * @return the targetType value. + */ + @Override + public String targetType() { + return this.targetType; + } + + /** + * Get the sqlDbResourceId property: The Azure ResourceId of an Azure SQL DB single database target. + * + * @return the sqlDbResourceId value. + */ + public String sqlDbResourceId() { + return this.sqlDbResourceId; + } + + /** + * Set the sqlDbResourceId property: The Azure ResourceId of an Azure SQL DB single database target. + * + * @param sqlDbResourceId the sqlDbResourceId value to set. + * @return the SqlDbSingleDatabaseTargetProperties object itself. + */ + public SqlDbSingleDatabaseTargetProperties withSqlDbResourceId(String sqlDbResourceId) { + this.sqlDbResourceId = sqlDbResourceId; + return this; + } + + /** + * Get the readIntent property: Set to true to monitor a high availability replica of specified target, if any. + * + * @return the readIntent value. + */ + public Boolean readIntent() { + return this.readIntent; + } + + /** + * Set the readIntent property: Set to true to monitor a high availability replica of specified target, if any. + * + * @param readIntent the readIntent value to set. + * @return the SqlDbSingleDatabaseTargetProperties object itself. + */ + public SqlDbSingleDatabaseTargetProperties withReadIntent(Boolean readIntent) { + this.readIntent = readIntent; + return this; + } + + /** + * Get the provisioningState property: The provisioning state of the resource. + * + * @return the provisioningState value. + */ + @Override + public ResourceProvisioningState provisioningState() { + return this.provisioningState; + } + + /** + * {@inheritDoc} + */ + @Override + public SqlDbSingleDatabaseTargetProperties + withTargetAuthenticationType(TargetAuthenticationType targetAuthenticationType) { + super.withTargetAuthenticationType(targetAuthenticationType); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public SqlDbSingleDatabaseTargetProperties withTargetVault(VaultSecret targetVault) { + super.withTargetVault(targetVault); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public SqlDbSingleDatabaseTargetProperties withConnectionServerName(String connectionServerName) { + super.withConnectionServerName(connectionServerName); + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + @Override + public void validate() { + super.validate(); + if (sqlDbResourceId() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property sqlDbResourceId in model SqlDbSingleDatabaseTargetProperties")); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(SqlDbSingleDatabaseTargetProperties.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("targetAuthenticationType", + targetAuthenticationType() == null ? null : targetAuthenticationType().toString()); + jsonWriter.writeStringField("connectionServerName", connectionServerName()); + jsonWriter.writeJsonField("targetVault", targetVault()); + jsonWriter.writeStringField("sqlDbResourceId", this.sqlDbResourceId); + jsonWriter.writeStringField("targetType", this.targetType); + jsonWriter.writeBooleanField("readIntent", this.readIntent); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SqlDbSingleDatabaseTargetProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SqlDbSingleDatabaseTargetProperties 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 SqlDbSingleDatabaseTargetProperties. + */ + public static SqlDbSingleDatabaseTargetProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + SqlDbSingleDatabaseTargetProperties deserializedSqlDbSingleDatabaseTargetProperties + = new SqlDbSingleDatabaseTargetProperties(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("targetAuthenticationType".equals(fieldName)) { + deserializedSqlDbSingleDatabaseTargetProperties + .withTargetAuthenticationType(TargetAuthenticationType.fromString(reader.getString())); + } else if ("connectionServerName".equals(fieldName)) { + deserializedSqlDbSingleDatabaseTargetProperties.withConnectionServerName(reader.getString()); + } else if ("targetVault".equals(fieldName)) { + deserializedSqlDbSingleDatabaseTargetProperties.withTargetVault(VaultSecret.fromJson(reader)); + } else if ("provisioningState".equals(fieldName)) { + deserializedSqlDbSingleDatabaseTargetProperties.provisioningState + = ResourceProvisioningState.fromString(reader.getString()); + } else if ("sqlDbResourceId".equals(fieldName)) { + deserializedSqlDbSingleDatabaseTargetProperties.sqlDbResourceId = reader.getString(); + } else if ("targetType".equals(fieldName)) { + deserializedSqlDbSingleDatabaseTargetProperties.targetType = reader.getString(); + } else if ("readIntent".equals(fieldName)) { + deserializedSqlDbSingleDatabaseTargetProperties.readIntent + = reader.getNullable(JsonReader::getBoolean); + } else { + reader.skipChildren(); + } + } + + return deserializedSqlDbSingleDatabaseTargetProperties; + }); + } +} diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/SqlMiTargetProperties.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/SqlMiTargetProperties.java new file mode 100644 index 0000000000000..da7fe2e08be07 --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/SqlMiTargetProperties.java @@ -0,0 +1,236 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.databasewatcher.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The properties specific to Azure SQL Managed Instance targets. + */ +@Fluent +public final class SqlMiTargetProperties extends TargetProperties { + /* + * Discriminator property for TargetProperties. + */ + private String targetType = "SqlMi"; + + /* + * The Azure ResourceId of an Azure SQL Managed Instance target. + */ + private String sqlMiResourceId; + + /* + * The TCP port number to optionally use in the connection string when connecting to an Azure SQL Managed Instance + * target. + */ + private Integer connectionTcpPort; + + /* + * Set to true to monitor a high availability replica of specified target, if any. + */ + private Boolean readIntent; + + /* + * The provisioning state of the resource. + */ + private ResourceProvisioningState provisioningState; + + /** + * Creates an instance of SqlMiTargetProperties class. + */ + public SqlMiTargetProperties() { + } + + /** + * Get the targetType property: Discriminator property for TargetProperties. + * + * @return the targetType value. + */ + @Override + public String targetType() { + return this.targetType; + } + + /** + * Get the sqlMiResourceId property: The Azure ResourceId of an Azure SQL Managed Instance target. + * + * @return the sqlMiResourceId value. + */ + public String sqlMiResourceId() { + return this.sqlMiResourceId; + } + + /** + * Set the sqlMiResourceId property: The Azure ResourceId of an Azure SQL Managed Instance target. + * + * @param sqlMiResourceId the sqlMiResourceId value to set. + * @return the SqlMiTargetProperties object itself. + */ + public SqlMiTargetProperties withSqlMiResourceId(String sqlMiResourceId) { + this.sqlMiResourceId = sqlMiResourceId; + return this; + } + + /** + * Get the connectionTcpPort property: The TCP port number to optionally use in the connection string when + * connecting to an Azure SQL Managed Instance target. + * + * @return the connectionTcpPort value. + */ + public Integer connectionTcpPort() { + return this.connectionTcpPort; + } + + /** + * Set the connectionTcpPort property: The TCP port number to optionally use in the connection string when + * connecting to an Azure SQL Managed Instance target. + * + * @param connectionTcpPort the connectionTcpPort value to set. + * @return the SqlMiTargetProperties object itself. + */ + public SqlMiTargetProperties withConnectionTcpPort(Integer connectionTcpPort) { + this.connectionTcpPort = connectionTcpPort; + return this; + } + + /** + * Get the readIntent property: Set to true to monitor a high availability replica of specified target, if any. + * + * @return the readIntent value. + */ + public Boolean readIntent() { + return this.readIntent; + } + + /** + * Set the readIntent property: Set to true to monitor a high availability replica of specified target, if any. + * + * @param readIntent the readIntent value to set. + * @return the SqlMiTargetProperties object itself. + */ + public SqlMiTargetProperties withReadIntent(Boolean readIntent) { + this.readIntent = readIntent; + return this; + } + + /** + * Get the provisioningState property: The provisioning state of the resource. + * + * @return the provisioningState value. + */ + @Override + public ResourceProvisioningState provisioningState() { + return this.provisioningState; + } + + /** + * {@inheritDoc} + */ + @Override + public SqlMiTargetProperties withTargetAuthenticationType(TargetAuthenticationType targetAuthenticationType) { + super.withTargetAuthenticationType(targetAuthenticationType); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public SqlMiTargetProperties withTargetVault(VaultSecret targetVault) { + super.withTargetVault(targetVault); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public SqlMiTargetProperties withConnectionServerName(String connectionServerName) { + super.withConnectionServerName(connectionServerName); + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + @Override + public void validate() { + super.validate(); + if (sqlMiResourceId() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property sqlMiResourceId in model SqlMiTargetProperties")); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(SqlMiTargetProperties.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("targetAuthenticationType", + targetAuthenticationType() == null ? null : targetAuthenticationType().toString()); + jsonWriter.writeStringField("connectionServerName", connectionServerName()); + jsonWriter.writeJsonField("targetVault", targetVault()); + jsonWriter.writeStringField("sqlMiResourceId", this.sqlMiResourceId); + jsonWriter.writeStringField("targetType", this.targetType); + jsonWriter.writeNumberField("connectionTcpPort", this.connectionTcpPort); + jsonWriter.writeBooleanField("readIntent", this.readIntent); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SqlMiTargetProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SqlMiTargetProperties 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 SqlMiTargetProperties. + */ + public static SqlMiTargetProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + SqlMiTargetProperties deserializedSqlMiTargetProperties = new SqlMiTargetProperties(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("targetAuthenticationType".equals(fieldName)) { + deserializedSqlMiTargetProperties + .withTargetAuthenticationType(TargetAuthenticationType.fromString(reader.getString())); + } else if ("connectionServerName".equals(fieldName)) { + deserializedSqlMiTargetProperties.withConnectionServerName(reader.getString()); + } else if ("targetVault".equals(fieldName)) { + deserializedSqlMiTargetProperties.withTargetVault(VaultSecret.fromJson(reader)); + } else if ("provisioningState".equals(fieldName)) { + deserializedSqlMiTargetProperties.provisioningState + = ResourceProvisioningState.fromString(reader.getString()); + } else if ("sqlMiResourceId".equals(fieldName)) { + deserializedSqlMiTargetProperties.sqlMiResourceId = reader.getString(); + } else if ("targetType".equals(fieldName)) { + deserializedSqlMiTargetProperties.targetType = reader.getString(); + } else if ("connectionTcpPort".equals(fieldName)) { + deserializedSqlMiTargetProperties.connectionTcpPort = reader.getNullable(JsonReader::getInt); + } else if ("readIntent".equals(fieldName)) { + deserializedSqlMiTargetProperties.readIntent = reader.getNullable(JsonReader::getBoolean); + } else { + reader.skipChildren(); + } + } + + return deserializedSqlMiTargetProperties; + }); + } +} diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/SqlVmTargetProperties.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/SqlVmTargetProperties.java new file mode 100644 index 0000000000000..b6c79b2acfa38 --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/SqlVmTargetProperties.java @@ -0,0 +1,237 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.databasewatcher.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The properties specific to Azure SQL VM targets. + */ +@Fluent +public final class SqlVmTargetProperties extends TargetProperties { + /* + * Discriminator property for TargetProperties. + */ + private String targetType = "SqlVm"; + + /* + * The Azure ResourceId of an Azure SQL VM target. + */ + private String sqlVmResourceId; + + /* + * The TCP port number to optionally use in the connection string when connecting to an Azure SQL VM target. + */ + private Integer connectionTcpPort; + + /* + * The SQL instance name to optionally use in the connection string when connecting to an Azure SQL VM target. + */ + private String sqlNamedInstanceName; + + /* + * The provisioning state of the resource. + */ + private ResourceProvisioningState provisioningState; + + /** + * Creates an instance of SqlVmTargetProperties class. + */ + public SqlVmTargetProperties() { + } + + /** + * Get the targetType property: Discriminator property for TargetProperties. + * + * @return the targetType value. + */ + @Override + public String targetType() { + return this.targetType; + } + + /** + * Get the sqlVmResourceId property: The Azure ResourceId of an Azure SQL VM target. + * + * @return the sqlVmResourceId value. + */ + public String sqlVmResourceId() { + return this.sqlVmResourceId; + } + + /** + * Set the sqlVmResourceId property: The Azure ResourceId of an Azure SQL VM target. + * + * @param sqlVmResourceId the sqlVmResourceId value to set. + * @return the SqlVmTargetProperties object itself. + */ + public SqlVmTargetProperties withSqlVmResourceId(String sqlVmResourceId) { + this.sqlVmResourceId = sqlVmResourceId; + return this; + } + + /** + * Get the connectionTcpPort property: The TCP port number to optionally use in the connection string when + * connecting to an Azure SQL VM target. + * + * @return the connectionTcpPort value. + */ + public Integer connectionTcpPort() { + return this.connectionTcpPort; + } + + /** + * Set the connectionTcpPort property: The TCP port number to optionally use in the connection string when + * connecting to an Azure SQL VM target. + * + * @param connectionTcpPort the connectionTcpPort value to set. + * @return the SqlVmTargetProperties object itself. + */ + public SqlVmTargetProperties withConnectionTcpPort(Integer connectionTcpPort) { + this.connectionTcpPort = connectionTcpPort; + return this; + } + + /** + * Get the sqlNamedInstanceName property: The SQL instance name to optionally use in the connection string when + * connecting to an Azure SQL VM target. + * + * @return the sqlNamedInstanceName value. + */ + public String sqlNamedInstanceName() { + return this.sqlNamedInstanceName; + } + + /** + * Set the sqlNamedInstanceName property: The SQL instance name to optionally use in the connection string when + * connecting to an Azure SQL VM target. + * + * @param sqlNamedInstanceName the sqlNamedInstanceName value to set. + * @return the SqlVmTargetProperties object itself. + */ + public SqlVmTargetProperties withSqlNamedInstanceName(String sqlNamedInstanceName) { + this.sqlNamedInstanceName = sqlNamedInstanceName; + return this; + } + + /** + * Get the provisioningState property: The provisioning state of the resource. + * + * @return the provisioningState value. + */ + @Override + public ResourceProvisioningState provisioningState() { + return this.provisioningState; + } + + /** + * {@inheritDoc} + */ + @Override + public SqlVmTargetProperties withTargetAuthenticationType(TargetAuthenticationType targetAuthenticationType) { + super.withTargetAuthenticationType(targetAuthenticationType); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public SqlVmTargetProperties withTargetVault(VaultSecret targetVault) { + super.withTargetVault(targetVault); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public SqlVmTargetProperties withConnectionServerName(String connectionServerName) { + super.withConnectionServerName(connectionServerName); + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + @Override + public void validate() { + super.validate(); + if (sqlVmResourceId() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property sqlVmResourceId in model SqlVmTargetProperties")); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(SqlVmTargetProperties.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("targetAuthenticationType", + targetAuthenticationType() == null ? null : targetAuthenticationType().toString()); + jsonWriter.writeStringField("connectionServerName", connectionServerName()); + jsonWriter.writeJsonField("targetVault", targetVault()); + jsonWriter.writeStringField("sqlVmResourceId", this.sqlVmResourceId); + jsonWriter.writeStringField("targetType", this.targetType); + jsonWriter.writeNumberField("connectionTcpPort", this.connectionTcpPort); + jsonWriter.writeStringField("sqlNamedInstanceName", this.sqlNamedInstanceName); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SqlVmTargetProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SqlVmTargetProperties 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 SqlVmTargetProperties. + */ + public static SqlVmTargetProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + SqlVmTargetProperties deserializedSqlVmTargetProperties = new SqlVmTargetProperties(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("targetAuthenticationType".equals(fieldName)) { + deserializedSqlVmTargetProperties + .withTargetAuthenticationType(TargetAuthenticationType.fromString(reader.getString())); + } else if ("connectionServerName".equals(fieldName)) { + deserializedSqlVmTargetProperties.withConnectionServerName(reader.getString()); + } else if ("targetVault".equals(fieldName)) { + deserializedSqlVmTargetProperties.withTargetVault(VaultSecret.fromJson(reader)); + } else if ("provisioningState".equals(fieldName)) { + deserializedSqlVmTargetProperties.provisioningState + = ResourceProvisioningState.fromString(reader.getString()); + } else if ("sqlVmResourceId".equals(fieldName)) { + deserializedSqlVmTargetProperties.sqlVmResourceId = reader.getString(); + } else if ("targetType".equals(fieldName)) { + deserializedSqlVmTargetProperties.targetType = reader.getString(); + } else if ("connectionTcpPort".equals(fieldName)) { + deserializedSqlVmTargetProperties.connectionTcpPort = reader.getNullable(JsonReader::getInt); + } else if ("sqlNamedInstanceName".equals(fieldName)) { + deserializedSqlVmTargetProperties.sqlNamedInstanceName = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedSqlVmTargetProperties; + }); + } +} diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/Target.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/Target.java new file mode 100644 index 0000000000000..04dc926bd6100 --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/Target.java @@ -0,0 +1,189 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.databasewatcher.models; + +import com.azure.core.management.SystemData; +import com.azure.core.util.Context; +import com.azure.resourcemanager.databasewatcher.fluent.models.TargetInner; + +/** + * An immutable client-side representation of Target. + */ +public interface Target { + /** + * Gets the id property: Fully qualified resource Id for the resource. + * + * @return the id value. + */ + String id(); + + /** + * Gets the name property: The name of the resource. + * + * @return the name value. + */ + String name(); + + /** + * Gets the type property: The type of the resource. + * + * @return the type value. + */ + String type(); + + /** + * Gets the properties property: The resource-specific properties for this resource. + * + * @return the properties value. + */ + TargetProperties properties(); + + /** + * Gets the systemData property: Azure Resource Manager metadata containing createdBy and modifiedBy information. + * + * @return the systemData value. + */ + SystemData systemData(); + + /** + * Gets the name of the resource group. + * + * @return the name of the resource group. + */ + String resourceGroupName(); + + /** + * Gets the inner com.azure.resourcemanager.databasewatcher.fluent.models.TargetInner object. + * + * @return the inner object. + */ + TargetInner innerModel(); + + /** + * The entirety of the Target definition. + */ + interface Definition + extends DefinitionStages.Blank, DefinitionStages.WithParentResource, DefinitionStages.WithCreate { + } + + /** + * The Target definition stages. + */ + interface DefinitionStages { + /** + * The first stage of the Target definition. + */ + interface Blank extends WithParentResource { + } + + /** + * The stage of the Target definition allowing to specify parent resource. + */ + interface WithParentResource { + /** + * Specifies resourceGroupName, watcherName. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @return the next definition stage. + */ + WithCreate withExistingWatcher(String resourceGroupName, String watcherName); + } + + /** + * The stage of the Target 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.WithProperties { + /** + * Executes the create request. + * + * @return the created resource. + */ + Target create(); + + /** + * Executes the create request. + * + * @param context The context to associate with this operation. + * @return the created resource. + */ + Target create(Context context); + } + + /** + * The stage of the Target definition allowing to specify properties. + */ + interface WithProperties { + /** + * Specifies the properties property: The resource-specific properties for this resource.. + * + * @param properties The resource-specific properties for this resource. + * @return the next definition stage. + */ + WithCreate withProperties(TargetProperties properties); + } + } + + /** + * Begins update for the Target resource. + * + * @return the stage of resource update. + */ + Target.Update update(); + + /** + * The template for Target update. + */ + interface Update extends UpdateStages.WithProperties { + /** + * Executes the update request. + * + * @return the updated resource. + */ + Target apply(); + + /** + * Executes the update request. + * + * @param context The context to associate with this operation. + * @return the updated resource. + */ + Target apply(Context context); + } + + /** + * The Target update stages. + */ + interface UpdateStages { + /** + * The stage of the Target update allowing to specify properties. + */ + interface WithProperties { + /** + * Specifies the properties property: The resource-specific properties for this resource.. + * + * @param properties The resource-specific properties for this resource. + * @return the next definition stage. + */ + Update withProperties(TargetProperties properties); + } + } + + /** + * Refreshes the resource to sync with Azure. + * + * @return the refreshed resource. + */ + Target refresh(); + + /** + * Refreshes the resource to sync with Azure. + * + * @param context The context to associate with this operation. + * @return the refreshed resource. + */ + Target refresh(Context context); +} diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/TargetAuthenticationType.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/TargetAuthenticationType.java new file mode 100644 index 0000000000000..51a3d0cebfae9 --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/TargetAuthenticationType.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.databasewatcher.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * The type of authentication to use when connecting to a target. + */ +public final class TargetAuthenticationType extends ExpandableStringEnum { + /** + * Static value Aad for TargetAuthenticationType. + */ + public static final TargetAuthenticationType AAD = fromString("Aad"); + + /** + * Static value Sql for TargetAuthenticationType. + */ + public static final TargetAuthenticationType SQL = fromString("Sql"); + + /** + * Creates a new instance of TargetAuthenticationType value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public TargetAuthenticationType() { + } + + /** + * Creates or finds a TargetAuthenticationType from its string representation. + * + * @param name a name to look for. + * @return the corresponding TargetAuthenticationType. + */ + public static TargetAuthenticationType fromString(String name) { + return fromString(name, TargetAuthenticationType.class); + } + + /** + * Gets known TargetAuthenticationType values. + * + * @return known TargetAuthenticationType values. + */ + public static Collection values() { + return values(TargetAuthenticationType.class); + } +} diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/TargetListResult.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/TargetListResult.java new file mode 100644 index 0000000000000..c9e901f136cbe --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/TargetListResult.java @@ -0,0 +1,134 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.databasewatcher.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.databasewatcher.fluent.models.TargetInner; +import java.io.IOException; +import java.util.List; + +/** + * The response of a Target list operation. + */ +@Fluent +public final class TargetListResult implements JsonSerializable { + /* + * The Target items on this page + */ + private List value; + + /* + * The link to the next page of items + */ + private String nextLink; + + /** + * Creates an instance of TargetListResult class. + */ + public TargetListResult() { + } + + /** + * Get the value property: The Target items on this page. + * + * @return the value value. + */ + public List value() { + return this.value; + } + + /** + * Set the value property: The Target items on this page. + * + * @param value the value value to set. + * @return the TargetListResult object itself. + */ + public TargetListResult withValue(List value) { + this.value = value; + return this; + } + + /** + * Get the nextLink property: The link to the next page of items. + * + * @return the nextLink value. + */ + public String nextLink() { + return this.nextLink; + } + + /** + * Set the nextLink property: The link to the next page of items. + * + * @param nextLink the nextLink value to set. + * @return the TargetListResult object itself. + */ + public TargetListResult 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) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property value in model TargetListResult")); + } else { + value().forEach(e -> e.validate()); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(TargetListResult.class); + + /** + * {@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 TargetListResult from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of TargetListResult 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 TargetListResult. + */ + public static TargetListResult fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + TargetListResult deserializedTargetListResult = new TargetListResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("value".equals(fieldName)) { + List value = reader.readArray(reader1 -> TargetInner.fromJson(reader1)); + deserializedTargetListResult.value = value; + } else if ("nextLink".equals(fieldName)) { + deserializedTargetListResult.nextLink = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedTargetListResult; + }); + } +} diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/TargetProperties.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/TargetProperties.java new file mode 100644 index 0000000000000..d085d55c3b2d7 --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/TargetProperties.java @@ -0,0 +1,250 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.databasewatcher.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 generic properties of a target. + */ +@Fluent +public class TargetProperties implements JsonSerializable { + /* + * Discriminator property for TargetProperties. + */ + private String targetType = "TargetProperties"; + + /* + * The type of authentication to use when connecting to a target. + */ + private TargetAuthenticationType targetAuthenticationType; + + /* + * To use SQL authentication when connecting to targets, specify the vault where the login name and password secrets + * are stored. + */ + private VaultSecret targetVault; + + /* + * The server name to use in the connection string when connecting to a target. Port number and instance name must + * be specified separately. + */ + private String connectionServerName; + + /* + * The provisioning state of the resource. + */ + private ResourceProvisioningState provisioningState; + + /** + * Creates an instance of TargetProperties class. + */ + public TargetProperties() { + } + + /** + * Get the targetType property: Discriminator property for TargetProperties. + * + * @return the targetType value. + */ + public String targetType() { + return this.targetType; + } + + /** + * Get the targetAuthenticationType property: The type of authentication to use when connecting to a target. + * + * @return the targetAuthenticationType value. + */ + public TargetAuthenticationType targetAuthenticationType() { + return this.targetAuthenticationType; + } + + /** + * Set the targetAuthenticationType property: The type of authentication to use when connecting to a target. + * + * @param targetAuthenticationType the targetAuthenticationType value to set. + * @return the TargetProperties object itself. + */ + public TargetProperties withTargetAuthenticationType(TargetAuthenticationType targetAuthenticationType) { + this.targetAuthenticationType = targetAuthenticationType; + return this; + } + + /** + * Get the targetVault property: To use SQL authentication when connecting to targets, specify the vault where the + * login name and password secrets are stored. + * + * @return the targetVault value. + */ + public VaultSecret targetVault() { + return this.targetVault; + } + + /** + * Set the targetVault property: To use SQL authentication when connecting to targets, specify the vault where the + * login name and password secrets are stored. + * + * @param targetVault the targetVault value to set. + * @return the TargetProperties object itself. + */ + public TargetProperties withTargetVault(VaultSecret targetVault) { + this.targetVault = targetVault; + return this; + } + + /** + * Get the connectionServerName property: The server name to use in the connection string when connecting to a + * target. Port number and instance name must be specified separately. + * + * @return the connectionServerName value. + */ + public String connectionServerName() { + return this.connectionServerName; + } + + /** + * Set the connectionServerName property: The server name to use in the connection string when connecting to a + * target. Port number and instance name must be specified separately. + * + * @param connectionServerName the connectionServerName value to set. + * @return the TargetProperties object itself. + */ + public TargetProperties withConnectionServerName(String connectionServerName) { + this.connectionServerName = connectionServerName; + return this; + } + + /** + * Get the provisioningState property: The provisioning state of the resource. + * + * @return the provisioningState value. + */ + public ResourceProvisioningState provisioningState() { + return this.provisioningState; + } + + /** + * Set the provisioningState property: The provisioning state of the resource. + * + * @param provisioningState the provisioningState value to set. + * @return the TargetProperties object itself. + */ + TargetProperties withProvisioningState(ResourceProvisioningState provisioningState) { + this.provisioningState = provisioningState; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (targetAuthenticationType() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property targetAuthenticationType in model TargetProperties")); + } + if (targetVault() != null) { + targetVault().validate(); + } + if (connectionServerName() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property connectionServerName in model TargetProperties")); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(TargetProperties.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("targetAuthenticationType", + this.targetAuthenticationType == null ? null : this.targetAuthenticationType.toString()); + jsonWriter.writeStringField("connectionServerName", this.connectionServerName); + jsonWriter.writeStringField("targetType", this.targetType); + jsonWriter.writeJsonField("targetVault", this.targetVault); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of TargetProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of TargetProperties 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 TargetProperties. + */ + public static TargetProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String discriminatorValue = null; + try (JsonReader readerToUse = reader.bufferObject()) { + readerToUse.nextToken(); // Prepare for reading + while (readerToUse.nextToken() != JsonToken.END_OBJECT) { + String fieldName = readerToUse.getFieldName(); + readerToUse.nextToken(); + if ("targetType".equals(fieldName)) { + discriminatorValue = readerToUse.getString(); + break; + } else { + readerToUse.skipChildren(); + } + } + // Use the discriminator value to determine which subtype should be deserialized. + if ("SqlEp".equals(discriminatorValue)) { + return SqlDbElasticPoolTargetProperties.fromJson(readerToUse.reset()); + } else if ("SqlDb".equals(discriminatorValue)) { + return SqlDbSingleDatabaseTargetProperties.fromJson(readerToUse.reset()); + } else if ("SqlMi".equals(discriminatorValue)) { + return SqlMiTargetProperties.fromJson(readerToUse.reset()); + } else if ("SqlVm".equals(discriminatorValue)) { + return SqlVmTargetProperties.fromJson(readerToUse.reset()); + } else { + return fromJsonKnownDiscriminator(readerToUse.reset()); + } + } + }); + } + + static TargetProperties fromJsonKnownDiscriminator(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + TargetProperties deserializedTargetProperties = new TargetProperties(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("targetAuthenticationType".equals(fieldName)) { + deserializedTargetProperties.targetAuthenticationType + = TargetAuthenticationType.fromString(reader.getString()); + } else if ("connectionServerName".equals(fieldName)) { + deserializedTargetProperties.connectionServerName = reader.getString(); + } else if ("targetType".equals(fieldName)) { + deserializedTargetProperties.targetType = reader.getString(); + } else if ("targetVault".equals(fieldName)) { + deserializedTargetProperties.targetVault = VaultSecret.fromJson(reader); + } else if ("provisioningState".equals(fieldName)) { + deserializedTargetProperties.provisioningState + = ResourceProvisioningState.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + + return deserializedTargetProperties; + }); + } +} diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/Targets.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/Targets.java new file mode 100644 index 0000000000000..3aee9364ae9e7 --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/Targets.java @@ -0,0 +1,145 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.databasewatcher.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 Targets. + */ +public interface Targets { + /** + * List Target resources by Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Target list operation as paginated response with {@link PagedIterable}. + */ + PagedIterable listByWatcher(String resourceGroupName, String watcherName); + + /** + * List Target resources by Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Target list operation as paginated response with {@link PagedIterable}. + */ + PagedIterable listByWatcher(String resourceGroupName, String watcherName, Context context); + + /** + * Get a Target. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param targetName The target resource name. + * @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 Target along with {@link Response}. + */ + Response getWithResponse(String resourceGroupName, String watcherName, String targetName, Context context); + + /** + * Get a Target. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param targetName The target resource name. + * @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 Target. + */ + Target get(String resourceGroupName, String watcherName, String targetName); + + /** + * Delete a Target. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param targetName The target resource name. + * @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 deleteWithResponse(String resourceGroupName, String watcherName, String targetName, Context context); + + /** + * Delete a Target. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @param targetName The target resource name. + * @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 delete(String resourceGroupName, String watcherName, String targetName); + + /** + * Get a Target. + * + * @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 a Target along with {@link Response}. + */ + Target getById(String id); + + /** + * Get a Target. + * + * @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 a Target along with {@link Response}. + */ + Response getByIdWithResponse(String id, Context context); + + /** + * Delete a Target. + * + * @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 a Target. + * + * @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 Target resource. + * + * @param name resource name. + * @return the first stage of the new Target definition. + */ + Target.DefinitionStages.Blank define(String name); +} diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/UserAssignedIdentity.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/UserAssignedIdentity.java new file mode 100644 index 0000000000000..b6c3642a9fdf7 --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/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.databasewatcher.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/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/VaultSecret.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/VaultSecret.java new file mode 100644 index 0000000000000..e2f38593fc730 --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/VaultSecret.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.databasewatcher.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 vault specific details required if using SQL authentication to connect to a target. + */ +@Fluent +public final class VaultSecret implements JsonSerializable { + /* + * The Azure ResourceId of the Key Vault instance storing database authentication secrets. + */ + private String akvResourceId; + + /* + * The path to the Key Vault secret storing the login name (aka user name, aka account name) for authentication to a + * target. + */ + private String akvTargetUser; + + /* + * The path to the Key Vault secret storing the password for authentication to a target. + */ + private String akvTargetPassword; + + /** + * Creates an instance of VaultSecret class. + */ + public VaultSecret() { + } + + /** + * Get the akvResourceId property: The Azure ResourceId of the Key Vault instance storing database authentication + * secrets. + * + * @return the akvResourceId value. + */ + public String akvResourceId() { + return this.akvResourceId; + } + + /** + * Set the akvResourceId property: The Azure ResourceId of the Key Vault instance storing database authentication + * secrets. + * + * @param akvResourceId the akvResourceId value to set. + * @return the VaultSecret object itself. + */ + public VaultSecret withAkvResourceId(String akvResourceId) { + this.akvResourceId = akvResourceId; + return this; + } + + /** + * Get the akvTargetUser property: The path to the Key Vault secret storing the login name (aka user name, aka + * account name) for authentication to a target. + * + * @return the akvTargetUser value. + */ + public String akvTargetUser() { + return this.akvTargetUser; + } + + /** + * Set the akvTargetUser property: The path to the Key Vault secret storing the login name (aka user name, aka + * account name) for authentication to a target. + * + * @param akvTargetUser the akvTargetUser value to set. + * @return the VaultSecret object itself. + */ + public VaultSecret withAkvTargetUser(String akvTargetUser) { + this.akvTargetUser = akvTargetUser; + return this; + } + + /** + * Get the akvTargetPassword property: The path to the Key Vault secret storing the password for authentication to a + * target. + * + * @return the akvTargetPassword value. + */ + public String akvTargetPassword() { + return this.akvTargetPassword; + } + + /** + * Set the akvTargetPassword property: The path to the Key Vault secret storing the password for authentication to a + * target. + * + * @param akvTargetPassword the akvTargetPassword value to set. + * @return the VaultSecret object itself. + */ + public VaultSecret withAkvTargetPassword(String akvTargetPassword) { + this.akvTargetPassword = akvTargetPassword; + 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("akvResourceId", this.akvResourceId); + jsonWriter.writeStringField("akvTargetUser", this.akvTargetUser); + jsonWriter.writeStringField("akvTargetPassword", this.akvTargetPassword); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of VaultSecret from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of VaultSecret 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 VaultSecret. + */ + public static VaultSecret fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + VaultSecret deserializedVaultSecret = new VaultSecret(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("akvResourceId".equals(fieldName)) { + deserializedVaultSecret.akvResourceId = reader.getString(); + } else if ("akvTargetUser".equals(fieldName)) { + deserializedVaultSecret.akvTargetUser = reader.getString(); + } else if ("akvTargetPassword".equals(fieldName)) { + deserializedVaultSecret.akvTargetPassword = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedVaultSecret; + }); + } +} diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/Watcher.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/Watcher.java new file mode 100644 index 0000000000000..5b942379b8346 --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/Watcher.java @@ -0,0 +1,392 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.databasewatcher.models; + +import com.azure.core.management.Region; +import com.azure.core.management.SystemData; +import com.azure.core.util.Context; +import com.azure.resourcemanager.databasewatcher.fluent.models.WatcherInner; +import java.util.Map; + +/** + * An immutable client-side representation of Watcher. + */ +public interface Watcher { + /** + * 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 managed service identities assigned to this resource. + * + * @return the identity value. + */ + ManagedServiceIdentity identity(); + + /** + * Gets the systemData property: Azure Resource Manager metadata containing createdBy and modifiedBy information. + * + * @return the systemData value. + */ + SystemData systemData(); + + /** + * Gets the datastore property: The data store for collected monitoring data. + * + * @return the datastore value. + */ + Datastore datastore(); + + /** + * Gets the status property: The monitoring collection status of the watcher. + * + * @return the status value. + */ + WatcherStatus status(); + + /** + * Gets the provisioningState property: The provisioning state of the resource watcher. + * + * @return the provisioningState value. + */ + DatabaseWatcherProvisioningState provisioningState(); + + /** + * Gets the defaultAlertRuleIdentityResourceId property: The resource ID of a user-assigned managed identity that + * will be assigned to a new alert rule. + * + * @return the defaultAlertRuleIdentityResourceId value. + */ + String defaultAlertRuleIdentityResourceId(); + + /** + * 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.databasewatcher.fluent.models.WatcherInner object. + * + * @return the inner object. + */ + WatcherInner innerModel(); + + /** + * The entirety of the Watcher definition. + */ + interface Definition extends DefinitionStages.Blank, DefinitionStages.WithLocation, + DefinitionStages.WithResourceGroup, DefinitionStages.WithCreate { + } + + /** + * The Watcher definition stages. + */ + interface DefinitionStages { + /** + * The first stage of the Watcher definition. + */ + interface Blank extends WithLocation { + } + + /** + * The stage of the Watcher 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 Watcher 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 Watcher 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.WithDatastore, DefinitionStages.WithDefaultAlertRuleIdentityResourceId { + /** + * Executes the create request. + * + * @return the created resource. + */ + Watcher create(); + + /** + * Executes the create request. + * + * @param context The context to associate with this operation. + * @return the created resource. + */ + Watcher create(Context context); + } + + /** + * The stage of the Watcher 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 Watcher definition allowing to specify identity. + */ + interface WithIdentity { + /** + * Specifies the identity property: The managed service identities assigned to this resource.. + * + * @param identity The managed service identities assigned to this resource. + * @return the next definition stage. + */ + WithCreate withIdentity(ManagedServiceIdentity identity); + } + + /** + * The stage of the Watcher definition allowing to specify datastore. + */ + interface WithDatastore { + /** + * Specifies the datastore property: The data store for collected monitoring data.. + * + * @param datastore The data store for collected monitoring data. + * @return the next definition stage. + */ + WithCreate withDatastore(Datastore datastore); + } + + /** + * The stage of the Watcher definition allowing to specify defaultAlertRuleIdentityResourceId. + */ + interface WithDefaultAlertRuleIdentityResourceId { + /** + * Specifies the defaultAlertRuleIdentityResourceId property: The resource ID of a user-assigned managed + * identity that will be assigned to a new alert rule.. + * + * @param defaultAlertRuleIdentityResourceId The resource ID of a user-assigned managed identity that will + * be assigned to a new alert rule. + * @return the next definition stage. + */ + WithCreate withDefaultAlertRuleIdentityResourceId(String defaultAlertRuleIdentityResourceId); + } + } + + /** + * Begins update for the Watcher resource. + * + * @return the stage of resource update. + */ + Watcher.Update update(); + + /** + * The template for Watcher update. + */ + interface Update extends UpdateStages.WithTags, UpdateStages.WithIdentity, UpdateStages.WithDatastore, + UpdateStages.WithDefaultAlertRuleIdentityResourceId { + /** + * Executes the update request. + * + * @return the updated resource. + */ + Watcher apply(); + + /** + * Executes the update request. + * + * @param context The context to associate with this operation. + * @return the updated resource. + */ + Watcher apply(Context context); + } + + /** + * The Watcher update stages. + */ + interface UpdateStages { + /** + * The stage of the Watcher 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 Watcher update allowing to specify identity. + */ + interface WithIdentity { + /** + * Specifies the identity property: The managed service identities assigned to this resource.. + * + * @param identity The managed service identities assigned to this resource. + * @return the next definition stage. + */ + Update withIdentity(ManagedServiceIdentity identity); + } + + /** + * The stage of the Watcher update allowing to specify datastore. + */ + interface WithDatastore { + /** + * Specifies the datastore property: The data store for collected monitoring data.. + * + * @param datastore The data store for collected monitoring data. + * @return the next definition stage. + */ + Update withDatastore(DatastoreUpdate datastore); + } + + /** + * The stage of the Watcher update allowing to specify defaultAlertRuleIdentityResourceId. + */ + interface WithDefaultAlertRuleIdentityResourceId { + /** + * Specifies the defaultAlertRuleIdentityResourceId property: The resource ID of a user-assigned managed + * identity that will be assigned to a new alert rule.. + * + * @param defaultAlertRuleIdentityResourceId The resource ID of a user-assigned managed identity that will + * be assigned to a new alert rule. + * @return the next definition stage. + */ + Update withDefaultAlertRuleIdentityResourceId(String defaultAlertRuleIdentityResourceId); + } + } + + /** + * Refreshes the resource to sync with Azure. + * + * @return the refreshed resource. + */ + Watcher refresh(); + + /** + * Refreshes the resource to sync with Azure. + * + * @param context The context to associate with this operation. + * @return the refreshed resource. + */ + Watcher refresh(Context context); + + /** + * The action to start monitoring all targets configured for a database watcher. + * + * @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 DatabaseWatcherProviderHub resource. + */ + Watcher start(); + + /** + * The action to start monitoring all targets configured for a database watcher. + * + * @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 DatabaseWatcherProviderHub resource. + */ + Watcher start(Context context); + + /** + * The action to stop monitoring all targets configured for a database watcher. + * + * @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 DatabaseWatcherProviderHub resource. + */ + Watcher stop(); + + /** + * The action to stop monitoring all targets configured for a database watcher. + * + * @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 DatabaseWatcherProviderHub resource. + */ + Watcher stop(Context context); +} diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/WatcherListResult.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/WatcherListResult.java new file mode 100644 index 0000000000000..6bed923375733 --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/WatcherListResult.java @@ -0,0 +1,134 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.databasewatcher.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.databasewatcher.fluent.models.WatcherInner; +import java.io.IOException; +import java.util.List; + +/** + * The response of a Watcher list operation. + */ +@Fluent +public final class WatcherListResult implements JsonSerializable { + /* + * The Watcher items on this page + */ + private List value; + + /* + * The link to the next page of items + */ + private String nextLink; + + /** + * Creates an instance of WatcherListResult class. + */ + public WatcherListResult() { + } + + /** + * Get the value property: The Watcher items on this page. + * + * @return the value value. + */ + public List value() { + return this.value; + } + + /** + * Set the value property: The Watcher items on this page. + * + * @param value the value value to set. + * @return the WatcherListResult object itself. + */ + public WatcherListResult withValue(List value) { + this.value = value; + return this; + } + + /** + * Get the nextLink property: The link to the next page of items. + * + * @return the nextLink value. + */ + public String nextLink() { + return this.nextLink; + } + + /** + * Set the nextLink property: The link to the next page of items. + * + * @param nextLink the nextLink value to set. + * @return the WatcherListResult object itself. + */ + public WatcherListResult 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) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property value in model WatcherListResult")); + } else { + value().forEach(e -> e.validate()); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(WatcherListResult.class); + + /** + * {@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 WatcherListResult from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of WatcherListResult 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 WatcherListResult. + */ + public static WatcherListResult fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + WatcherListResult deserializedWatcherListResult = new WatcherListResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("value".equals(fieldName)) { + List value = reader.readArray(reader1 -> WatcherInner.fromJson(reader1)); + deserializedWatcherListResult.value = value; + } else if ("nextLink".equals(fieldName)) { + deserializedWatcherListResult.nextLink = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedWatcherListResult; + }); + } +} diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/WatcherStatus.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/WatcherStatus.java new file mode 100644 index 0000000000000..34209bd70e52d --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/WatcherStatus.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.databasewatcher.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * The monitoring collection status of a watcher. + */ +public final class WatcherStatus extends ExpandableStringEnum { + /** + * Static value Starting for WatcherStatus. + */ + public static final WatcherStatus STARTING = fromString("Starting"); + + /** + * Static value Running for WatcherStatus. + */ + public static final WatcherStatus RUNNING = fromString("Running"); + + /** + * Static value Stopping for WatcherStatus. + */ + public static final WatcherStatus STOPPING = fromString("Stopping"); + + /** + * Static value Stopped for WatcherStatus. + */ + public static final WatcherStatus STOPPED = fromString("Stopped"); + + /** + * Static value Deleting for WatcherStatus. + */ + public static final WatcherStatus DELETING = fromString("Deleting"); + + /** + * Creates a new instance of WatcherStatus value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public WatcherStatus() { + } + + /** + * Creates or finds a WatcherStatus from its string representation. + * + * @param name a name to look for. + * @return the corresponding WatcherStatus. + */ + public static WatcherStatus fromString(String name) { + return fromString(name, WatcherStatus.class); + } + + /** + * Gets known WatcherStatus values. + * + * @return known WatcherStatus values. + */ + public static Collection values() { + return values(WatcherStatus.class); + } +} diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/WatcherUpdate.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/WatcherUpdate.java new file mode 100644 index 0000000000000..8e29f14d1f25e --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/WatcherUpdate.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.databasewatcher.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.databasewatcher.fluent.models.WatcherUpdateProperties; +import java.io.IOException; +import java.util.Map; + +/** + * The type used for update operations of the Watcher. + */ +@Fluent +public final class WatcherUpdate implements JsonSerializable { + /* + * The managed service identities assigned to this resource. + */ + private ManagedServiceIdentity identity; + + /* + * Resource tags. + */ + private Map tags; + + /* + * The resource-specific properties for this resource. + */ + private WatcherUpdateProperties innerProperties; + + /** + * Creates an instance of WatcherUpdate class. + */ + public WatcherUpdate() { + } + + /** + * Get the identity property: The managed service identities assigned to this resource. + * + * @return the identity value. + */ + public ManagedServiceIdentity identity() { + return this.identity; + } + + /** + * Set the identity property: The managed service identities assigned to this resource. + * + * @param identity the identity value to set. + * @return the WatcherUpdate object itself. + */ + public WatcherUpdate withIdentity(ManagedServiceIdentity 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 WatcherUpdate object itself. + */ + public WatcherUpdate withTags(Map tags) { + this.tags = tags; + return this; + } + + /** + * Get the innerProperties property: The resource-specific properties for this resource. + * + * @return the innerProperties value. + */ + private WatcherUpdateProperties innerProperties() { + return this.innerProperties; + } + + /** + * Get the datastore property: The data store for collected monitoring data. + * + * @return the datastore value. + */ + public DatastoreUpdate datastore() { + return this.innerProperties() == null ? null : this.innerProperties().datastore(); + } + + /** + * Set the datastore property: The data store for collected monitoring data. + * + * @param datastore the datastore value to set. + * @return the WatcherUpdate object itself. + */ + public WatcherUpdate withDatastore(DatastoreUpdate datastore) { + if (this.innerProperties() == null) { + this.innerProperties = new WatcherUpdateProperties(); + } + this.innerProperties().withDatastore(datastore); + return this; + } + + /** + * Get the defaultAlertRuleIdentityResourceId property: The resource ID of a user-assigned managed identity that + * will be assigned to a new alert rule. + * + * @return the defaultAlertRuleIdentityResourceId value. + */ + public String defaultAlertRuleIdentityResourceId() { + return this.innerProperties() == null ? null : this.innerProperties().defaultAlertRuleIdentityResourceId(); + } + + /** + * Set the defaultAlertRuleIdentityResourceId property: The resource ID of a user-assigned managed identity that + * will be assigned to a new alert rule. + * + * @param defaultAlertRuleIdentityResourceId the defaultAlertRuleIdentityResourceId value to set. + * @return the WatcherUpdate object itself. + */ + public WatcherUpdate withDefaultAlertRuleIdentityResourceId(String defaultAlertRuleIdentityResourceId) { + if (this.innerProperties() == null) { + this.innerProperties = new WatcherUpdateProperties(); + } + this.innerProperties().withDefaultAlertRuleIdentityResourceId(defaultAlertRuleIdentityResourceId); + 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 WatcherUpdate from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of WatcherUpdate 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 WatcherUpdate. + */ + public static WatcherUpdate fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + WatcherUpdate deserializedWatcherUpdate = new WatcherUpdate(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("identity".equals(fieldName)) { + deserializedWatcherUpdate.identity = ManagedServiceIdentity.fromJson(reader); + } else if ("tags".equals(fieldName)) { + Map tags = reader.readMap(reader1 -> reader1.getString()); + deserializedWatcherUpdate.tags = tags; + } else if ("properties".equals(fieldName)) { + deserializedWatcherUpdate.innerProperties = WatcherUpdateProperties.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedWatcherUpdate; + }); + } +} diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/Watchers.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/Watchers.java new file mode 100644 index 0000000000000..d2ee8710e4cc4 --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/Watchers.java @@ -0,0 +1,207 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.databasewatcher.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 Watchers. + */ +public interface Watchers { + /** + * List Watcher resources by subscription ID. + * + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Watcher list operation as paginated response with {@link PagedIterable}. + */ + PagedIterable list(); + + /** + * List Watcher resources by subscription ID. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Watcher list operation as paginated response with {@link PagedIterable}. + */ + PagedIterable list(Context context); + + /** + * List Watcher resources by 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 the response of a Watcher list operation as paginated response with {@link PagedIterable}. + */ + PagedIterable listByResourceGroup(String resourceGroupName); + + /** + * List Watcher resources by 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 the response of a Watcher list operation as paginated response with {@link PagedIterable}. + */ + PagedIterable listByResourceGroup(String resourceGroupName, Context context); + + /** + * Get a Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @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 Watcher along with {@link Response}. + */ + Response getByResourceGroupWithResponse(String resourceGroupName, String watcherName, Context context); + + /** + * Get a Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @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 Watcher. + */ + Watcher getByResourceGroup(String resourceGroupName, String watcherName); + + /** + * Delete a Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @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 watcherName); + + /** + * Delete a Watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @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. + */ + void delete(String resourceGroupName, String watcherName, Context context); + + /** + * The action to start monitoring all targets configured for a database watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @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 DatabaseWatcherProviderHub resource. + */ + Watcher start(String resourceGroupName, String watcherName); + + /** + * The action to start monitoring all targets configured for a database watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @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 DatabaseWatcherProviderHub resource. + */ + Watcher start(String resourceGroupName, String watcherName, Context context); + + /** + * The action to stop monitoring all targets configured for a database watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @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 DatabaseWatcherProviderHub resource. + */ + Watcher stop(String resourceGroupName, String watcherName); + + /** + * The action to stop monitoring all targets configured for a database watcher. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param watcherName The database watcher name. + * @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 DatabaseWatcherProviderHub resource. + */ + Watcher stop(String resourceGroupName, String watcherName, Context context); + + /** + * Get a Watcher. + * + * @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 a Watcher along with {@link Response}. + */ + Watcher getById(String id); + + /** + * Get a Watcher. + * + * @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 a Watcher along with {@link Response}. + */ + Response getByIdWithResponse(String id, Context context); + + /** + * Delete a Watcher. + * + * @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 a Watcher. + * + * @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. + */ + void deleteByIdWithResponse(String id, Context context); + + /** + * Begins definition for a new Watcher resource. + * + * @param name resource name. + * @return the first stage of the new Watcher definition. + */ + Watcher.DefinitionStages.Blank define(String name); +} diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/package-info.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/models/package-info.java new file mode 100644 index 0000000000000..73a15a79306c3 --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/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 MicrosoftDatabaseWatcher. + * null. + */ +package com.azure.resourcemanager.databasewatcher.models; diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/package-info.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/package-info.java new file mode 100644 index 0000000000000..25c46682d2c18 --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/com/azure/resourcemanager/databasewatcher/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 MicrosoftDatabaseWatcher. + * null. + */ +package com.azure.resourcemanager.databasewatcher; diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/module-info.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/module-info.java new file mode 100644 index 0000000000000..26cc26908cb0e --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/java/module-info.java @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +module com.azure.resourcemanager.databasewatcher { + requires transitive com.azure.core.management; + exports com.azure.resourcemanager.databasewatcher; + exports com.azure.resourcemanager.databasewatcher.fluent; + exports com.azure.resourcemanager.databasewatcher.fluent.models; + exports com.azure.resourcemanager.databasewatcher.models; + opens com.azure.resourcemanager.databasewatcher.fluent.models to com.azure.core; + opens com.azure.resourcemanager.databasewatcher.models to com.azure.core; +} \ No newline at end of file diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-databasewatcher/proxy-config.json b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-databasewatcher/proxy-config.json new file mode 100644 index 0000000000000..2c3535cb62860 --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-databasewatcher/proxy-config.json @@ -0,0 +1 @@ +[ [ "com.azure.resourcemanager.databasewatcher.implementation.AlertRuleResourcesClientImpl$AlertRuleResourcesService" ], [ "com.azure.resourcemanager.databasewatcher.implementation.OperationsClientImpl$OperationsService" ], [ "com.azure.resourcemanager.databasewatcher.implementation.SharedPrivateLinkResourcesClientImpl$SharedPrivateLinkResourcesService" ], [ "com.azure.resourcemanager.databasewatcher.implementation.TargetsClientImpl$TargetsService" ], [ "com.azure.resourcemanager.databasewatcher.implementation.WatchersClientImpl$WatchersService" ] ] \ No newline at end of file diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-databasewatcher/reflect-config.json b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-databasewatcher/reflect-config.json new file mode 100644 index 0000000000000..8878e547a7984 --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-databasewatcher/reflect-config.json @@ -0,0 +1 @@ +[ ] \ No newline at end of file diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/AlertRuleResourcesCreateOrUpdateSamples.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/AlertRuleResourcesCreateOrUpdateSamples.java new file mode 100644 index 0000000000000..4269339997849 --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/AlertRuleResourcesCreateOrUpdateSamples.java @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.databasewatcher.generated; + +import com.azure.resourcemanager.databasewatcher.models.AlertRuleCreationProperties; +import java.time.OffsetDateTime; + +/** + * Samples for AlertRuleResources CreateOrUpdate. + */ +public final class AlertRuleResourcesCreateOrUpdateSamples { + /* + * x-ms-original-file: + * specification/databasewatcher/resource-manager/Microsoft.DatabaseWatcher/preview/2024-07-19-preview/examples/ + * AlertRuleResources_CreateOrUpdate_MaximumSet_Gen.json + */ + /** + * Sample code: AlertRuleResources_CreateOrUpdate - generated by [MaximumSet] rule. + * + * @param manager Entry point to DatabasewatcherManager. + */ + public static void alertRuleResourcesCreateOrUpdateGeneratedByMaximumSetRule( + com.azure.resourcemanager.databasewatcher.DatabasewatcherManager manager) { + manager.alertRuleResources() + .define("testAlert") + .withExistingWatcher("rgWatcher", "testWatcher") + .withAlertRuleResourceId( + "/subscriptions/469DD77C-C8DB-47B7-B9E1-72D29F8C878Be/resourceGroups/rgWatcher/providers/microsoft.insights/scheduledqueryrules/alerts-demo") + .withCreatedWithProperties(AlertRuleCreationProperties.CREATED_WITH_ACTION_GROUP) + .withCreationTime(OffsetDateTime.parse("2024-07-25T15:38:47.798Z")) + .withAlertRuleTemplateId("someTemplateId") + .withAlertRuleTemplateVersion("1.0") + .create(); + } +} diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/AlertRuleResourcesDeleteSamples.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/AlertRuleResourcesDeleteSamples.java new file mode 100644 index 0000000000000..fa8bbf1bc15db --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/AlertRuleResourcesDeleteSamples.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.databasewatcher.generated; + +/** + * Samples for AlertRuleResources Delete. + */ +public final class AlertRuleResourcesDeleteSamples { + /* + * x-ms-original-file: + * specification/databasewatcher/resource-manager/Microsoft.DatabaseWatcher/preview/2024-07-19-preview/examples/ + * AlertRuleResources_Delete_MaximumSet_Gen.json + */ + /** + * Sample code: AlertRuleResources_Delete - generated by [MaximumSet] rule. + * + * @param manager Entry point to DatabasewatcherManager. + */ + public static void alertRuleResourcesDeleteGeneratedByMaximumSetRule( + com.azure.resourcemanager.databasewatcher.DatabasewatcherManager manager) { + manager.alertRuleResources() + .deleteWithResponse("rgWatcher", "testWatcher", "testAlert", com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/AlertRuleResourcesGetSamples.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/AlertRuleResourcesGetSamples.java new file mode 100644 index 0000000000000..5b0339c10036d --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/AlertRuleResourcesGetSamples.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.databasewatcher.generated; + +/** + * Samples for AlertRuleResources Get. + */ +public final class AlertRuleResourcesGetSamples { + /* + * x-ms-original-file: + * specification/databasewatcher/resource-manager/Microsoft.DatabaseWatcher/preview/2024-07-19-preview/examples/ + * AlertRuleResources_Get_MaximumSet_Gen.json + */ + /** + * Sample code: AlertRuleResources_Get - generated by [MaximumSet] rule. + * + * @param manager Entry point to DatabasewatcherManager. + */ + public static void alertRuleResourcesGetGeneratedByMaximumSetRule( + com.azure.resourcemanager.databasewatcher.DatabasewatcherManager manager) { + manager.alertRuleResources() + .getWithResponse("rgWatcher", "testWatcher", "testAlert", com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/AlertRuleResourcesListByParentSamples.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/AlertRuleResourcesListByParentSamples.java new file mode 100644 index 0000000000000..0cbc2281921fb --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/AlertRuleResourcesListByParentSamples.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.databasewatcher.generated; + +/** + * Samples for AlertRuleResources ListByParent. + */ +public final class AlertRuleResourcesListByParentSamples { + /* + * x-ms-original-file: + * specification/databasewatcher/resource-manager/Microsoft.DatabaseWatcher/preview/2024-07-19-preview/examples/ + * AlertRuleResources_ListByParent_MaximumSet_Gen.json + */ + /** + * Sample code: AlertRuleResources_ListByParent. + * + * @param manager Entry point to DatabasewatcherManager. + */ + public static void + alertRuleResourcesListByParent(com.azure.resourcemanager.databasewatcher.DatabasewatcherManager manager) { + manager.alertRuleResources().listByParent("rgWatcher", "testWatcher", com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/OperationsListSamples.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/OperationsListSamples.java new file mode 100644 index 0000000000000..23e9c637c2e38 --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/OperationsListSamples.java @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.databasewatcher.generated; + +/** + * Samples for Operations List. + */ +public final class OperationsListSamples { + /* + * x-ms-original-file: + * specification/databasewatcher/resource-manager/Microsoft.DatabaseWatcher/preview/2024-07-19-preview/examples/ + * Operations_List_MaximumSet_Gen.json + */ + /** + * Sample code: Operations_List - generated by [MaximumSet] rule. + * + * @param manager Entry point to DatabasewatcherManager. + */ + public static void operationsListGeneratedByMaximumSetRule( + com.azure.resourcemanager.databasewatcher.DatabasewatcherManager manager) { + manager.operations().list(com.azure.core.util.Context.NONE); + } + + /* + * x-ms-original-file: + * specification/databasewatcher/resource-manager/Microsoft.DatabaseWatcher/preview/2024-07-19-preview/examples/ + * Operations_List_MinimumSet_Gen.json + */ + /** + * Sample code: Operations_List - generated by [MinimumSet] rule. + * + * @param manager Entry point to DatabasewatcherManager. + */ + public static void operationsListGeneratedByMinimumSetRule( + com.azure.resourcemanager.databasewatcher.DatabasewatcherManager manager) { + manager.operations().list(com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/SharedPrivateLinkResourcesCreateSamples.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/SharedPrivateLinkResourcesCreateSamples.java new file mode 100644 index 0000000000000..0e1bdbc9a194c --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/SharedPrivateLinkResourcesCreateSamples.java @@ -0,0 +1,33 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.databasewatcher.generated; + +/** + * Samples for SharedPrivateLinkResources Create. + */ +public final class SharedPrivateLinkResourcesCreateSamples { + /* + * x-ms-original-file: + * specification/databasewatcher/resource-manager/Microsoft.DatabaseWatcher/preview/2024-07-19-preview/examples/ + * SharedPrivateLinkResources_Create_MaximumSet_Gen.json + */ + /** + * Sample code: SharedPrivateLinkResources_Create - generated by [MaximumSet] rule. + * + * @param manager Entry point to DatabasewatcherManager. + */ + public static void sharedPrivateLinkResourcesCreateGeneratedByMaximumSetRule( + com.azure.resourcemanager.databasewatcher.DatabasewatcherManager manager) { + manager.sharedPrivateLinkResources() + .define("monitoringh22eed") + .withExistingWatcher("apiTest-ddat4p", "databasemo3ej9ih") + .withPrivateLinkResourceId( + "/subscriptions/6f53185c-ea09-4fc3-9075-318dec805303/resourceGroups/apiTest-ddat4p/providers/Microsoft.KeyVault/vaults/kvmo3ej9ih") + .withGroupId("vault") + .withRequestMessage("request message") + .withDnsZone("ec3ae9d410ba") + .create(); + } +} diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/SharedPrivateLinkResourcesDeleteSamples.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/SharedPrivateLinkResourcesDeleteSamples.java new file mode 100644 index 0000000000000..6505b8dfc9f15 --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/SharedPrivateLinkResourcesDeleteSamples.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.databasewatcher.generated; + +/** + * Samples for SharedPrivateLinkResources Delete. + */ +public final class SharedPrivateLinkResourcesDeleteSamples { + /* + * x-ms-original-file: + * specification/databasewatcher/resource-manager/Microsoft.DatabaseWatcher/preview/2024-07-19-preview/examples/ + * SharedPrivateLinkResources_Delete_MaximumSet_Gen.json + */ + /** + * Sample code: SharedPrivateLinkResources_Delete - generated by [MaximumSet] rule. + * + * @param manager Entry point to DatabasewatcherManager. + */ + public static void sharedPrivateLinkResourcesDeleteGeneratedByMaximumSetRule( + com.azure.resourcemanager.databasewatcher.DatabasewatcherManager manager) { + manager.sharedPrivateLinkResources() + .delete("apiTest-ddat4p", "databasemo3ej9ih", "monitoringh22eed", com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/SharedPrivateLinkResourcesGetSamples.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/SharedPrivateLinkResourcesGetSamples.java new file mode 100644 index 0000000000000..4dfb40c229dae --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/SharedPrivateLinkResourcesGetSamples.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.databasewatcher.generated; + +/** + * Samples for SharedPrivateLinkResources Get. + */ +public final class SharedPrivateLinkResourcesGetSamples { + /* + * x-ms-original-file: + * specification/databasewatcher/resource-manager/Microsoft.DatabaseWatcher/preview/2024-07-19-preview/examples/ + * SharedPrivateLinkResources_Get_MaximumSet_Gen.json + */ + /** + * Sample code: SharedPrivateLinkResources_Get - generated by [MaximumSet] rule. + * + * @param manager Entry point to DatabasewatcherManager. + */ + public static void sharedPrivateLinkResourcesGetGeneratedByMaximumSetRule( + com.azure.resourcemanager.databasewatcher.DatabasewatcherManager manager) { + manager.sharedPrivateLinkResources() + .getWithResponse("apiTest-ddat4p", "databasemo3ej9ih", "monitoringh22eed", + com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/SharedPrivateLinkResourcesListByWatcherSamples.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/SharedPrivateLinkResourcesListByWatcherSamples.java new file mode 100644 index 0000000000000..c78d317b759b3 --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/SharedPrivateLinkResourcesListByWatcherSamples.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.databasewatcher.generated; + +/** + * Samples for SharedPrivateLinkResources ListByWatcher. + */ +public final class SharedPrivateLinkResourcesListByWatcherSamples { + /* + * x-ms-original-file: + * specification/databasewatcher/resource-manager/Microsoft.DatabaseWatcher/preview/2024-07-19-preview/examples/ + * SharedPrivateLinkResources_ListByWatcher_MaximumSet_Gen.json + */ + /** + * Sample code: SharedPrivateLinkResources_ListByWatcher - generated by [MaximumSet] rule. + * + * @param manager Entry point to DatabasewatcherManager. + */ + public static void sharedPrivateLinkResourcesListByWatcherGeneratedByMaximumSetRule( + com.azure.resourcemanager.databasewatcher.DatabasewatcherManager manager) { + manager.sharedPrivateLinkResources() + .listByWatcher("apiTest-ddat4p", "databasemo3ej9ih", com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/TargetsCreateOrUpdateSamples.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/TargetsCreateOrUpdateSamples.java new file mode 100644 index 0000000000000..9f66193acf4c2 --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/TargetsCreateOrUpdateSamples.java @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.databasewatcher.generated; + +import com.azure.resourcemanager.databasewatcher.models.SqlDbSingleDatabaseTargetProperties; +import com.azure.resourcemanager.databasewatcher.models.TargetAuthenticationType; + +/** + * Samples for Targets CreateOrUpdate. + */ +public final class TargetsCreateOrUpdateSamples { + /* + * x-ms-original-file: + * specification/databasewatcher/resource-manager/Microsoft.DatabaseWatcher/preview/2024-07-19-preview/examples/ + * Targets_CreateOrUpdate_MaximumSet_Gen.json + */ + /** + * Sample code: Targets_CreateOrUpdate - generated by [MaximumSet] rule. + * + * @param manager Entry point to DatabasewatcherManager. + */ + public static void targetsCreateOrUpdateGeneratedByMaximumSetRule( + com.azure.resourcemanager.databasewatcher.DatabasewatcherManager manager) { + manager.targets() + .define("monitoringh22eed") + .withExistingWatcher("apiTest-ddat4p", "databasemo3ej9ih") + .withProperties(new SqlDbSingleDatabaseTargetProperties() + .withTargetAuthenticationType(TargetAuthenticationType.AAD) + .withConnectionServerName("sqlServero1ihe2") + .withSqlDbResourceId( + "/subscriptions/6f53185c-ea09-4fc3-9075-318dec805303/resourceGroups/apiTest-ddat4p/providers/Microsoft.Sql/servers/m1/databases/m2")) + .create(); + } +} diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/TargetsDeleteSamples.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/TargetsDeleteSamples.java new file mode 100644 index 0000000000000..23af514b90872 --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/TargetsDeleteSamples.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.databasewatcher.generated; + +/** + * Samples for Targets Delete. + */ +public final class TargetsDeleteSamples { + /* + * x-ms-original-file: + * specification/databasewatcher/resource-manager/Microsoft.DatabaseWatcher/preview/2024-07-19-preview/examples/ + * Targets_Delete_MaximumSet_Gen.json + */ + /** + * Sample code: Targets_Delete - generated by [MaximumSet] rule. + * + * @param manager Entry point to DatabasewatcherManager. + */ + public static void targetsDeleteGeneratedByMaximumSetRule( + com.azure.resourcemanager.databasewatcher.DatabasewatcherManager manager) { + manager.targets() + .deleteWithResponse("apiTest-ddat4p", "databasemo3ej9ih", "monitoringh22eed", + com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/TargetsGetSamples.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/TargetsGetSamples.java new file mode 100644 index 0000000000000..78897e02f0061 --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/TargetsGetSamples.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.databasewatcher.generated; + +/** + * Samples for Targets Get. + */ +public final class TargetsGetSamples { + /* + * x-ms-original-file: + * specification/databasewatcher/resource-manager/Microsoft.DatabaseWatcher/preview/2024-07-19-preview/examples/ + * Targets_Get_MaximumSet_Gen.json + */ + /** + * Sample code: Targets_Get - generated by [MaximumSet] rule. + * + * @param manager Entry point to DatabasewatcherManager. + */ + public static void + targetsGetGeneratedByMaximumSetRule(com.azure.resourcemanager.databasewatcher.DatabasewatcherManager manager) { + manager.targets() + .getWithResponse("apiTest-ddat4p", "databasemo3ej9ih", "monitoringh22eed", + com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/TargetsListByWatcherSamples.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/TargetsListByWatcherSamples.java new file mode 100644 index 0000000000000..62af1389398d5 --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/TargetsListByWatcherSamples.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.databasewatcher.generated; + +/** + * Samples for Targets ListByWatcher. + */ +public final class TargetsListByWatcherSamples { + /* + * x-ms-original-file: + * specification/databasewatcher/resource-manager/Microsoft.DatabaseWatcher/preview/2024-07-19-preview/examples/ + * Targets_ListByWatcher_MaximumSet_Gen.json + */ + /** + * Sample code: Targets_ListByWatcher - generated by [MaximumSet] rule. + * + * @param manager Entry point to DatabasewatcherManager. + */ + public static void targetsListByWatcherGeneratedByMaximumSetRule( + com.azure.resourcemanager.databasewatcher.DatabasewatcherManager manager) { + manager.targets().listByWatcher("apiTest-ddat4p", "databasemo3ej9ih", com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/WatchersCreateOrUpdateSamples.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/WatchersCreateOrUpdateSamples.java new file mode 100644 index 0000000000000..1b3ebb0535ec9 --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/WatchersCreateOrUpdateSamples.java @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.databasewatcher.generated; + +import com.azure.resourcemanager.databasewatcher.models.Datastore; +import com.azure.resourcemanager.databasewatcher.models.KustoOfferingType; +import com.azure.resourcemanager.databasewatcher.models.ManagedServiceIdentity; +import com.azure.resourcemanager.databasewatcher.models.ManagedServiceIdentityType; +import java.util.HashMap; +import java.util.Map; + +/** + * Samples for Watchers CreateOrUpdate. + */ +public final class WatchersCreateOrUpdateSamples { + /* + * x-ms-original-file: + * specification/databasewatcher/resource-manager/Microsoft.DatabaseWatcher/preview/2024-07-19-preview/examples/ + * Watchers_CreateOrUpdate_MaximumSet_Gen.json + */ + /** + * Sample code: Watchers_CreateOrUpdate - generated by [MaximumSet] rule. + * + * @param manager Entry point to DatabasewatcherManager. + */ + public static void watchersCreateOrUpdateGeneratedByMaximumSetRule( + com.azure.resourcemanager.databasewatcher.DatabasewatcherManager manager) { + manager.watchers() + .define("testWatcher") + .withRegion("eastus2euap") + .withExistingResourceGroup("rgWatcher") + .withTags(mapOf()) + .withIdentity(new ManagedServiceIdentity().withType(ManagedServiceIdentityType.SYSTEM_ASSIGNED)) + .withDatastore(new Datastore().withAdxClusterResourceId( + "/subscriptions/6f53185c-ea09-4fc3-9075-318dec805303/resourceGroups/apiTest/providers/Microsoft.Kusto/clusters/apiTestKusto") + .withKustoClusterDisplayName("kustoUri-adx") + .withKustoClusterUri("https://kustouri-adx.eastus.kusto.windows.net") + .withKustoDataIngestionUri("https://ingest-kustouri-adx.eastus.kusto.windows.net") + .withKustoDatabaseName("kustoDatabaseName1") + .withKustoManagementUrl("https://portal.azure.com/") + .withKustoOfferingType(KustoOfferingType.ADX)) + .withDefaultAlertRuleIdentityResourceId( + "/subscriptions/469DD77C-C8DB-47B7-B9E1-72D29F8C878B/resourceGroups/rgWatcher/providers/Microsoft.ManagedIdentity/userAssignedIdentities/3pmtest") + .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/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/WatchersDeleteSamples.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/WatchersDeleteSamples.java new file mode 100644 index 0000000000000..3994b71ce808e --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/WatchersDeleteSamples.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.databasewatcher.generated; + +/** + * Samples for Watchers Delete. + */ +public final class WatchersDeleteSamples { + /* + * x-ms-original-file: + * specification/databasewatcher/resource-manager/Microsoft.DatabaseWatcher/preview/2024-07-19-preview/examples/ + * Watchers_Delete_MaximumSet_Gen.json + */ + /** + * Sample code: Watchers_Delete - generated by [MaximumSet] rule - generated by [MaximumSet] rule. + * + * @param manager Entry point to DatabasewatcherManager. + */ + public static void watchersDeleteGeneratedByMaximumSetRuleGeneratedByMaximumSetRule( + com.azure.resourcemanager.databasewatcher.DatabasewatcherManager manager) { + manager.watchers().delete("rgWatcher", "testWatcher", com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/WatchersGetByResourceGroupSamples.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/WatchersGetByResourceGroupSamples.java new file mode 100644 index 0000000000000..35adbff7ac8a7 --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/WatchersGetByResourceGroupSamples.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.databasewatcher.generated; + +/** + * Samples for Watchers GetByResourceGroup. + */ +public final class WatchersGetByResourceGroupSamples { + /* + * x-ms-original-file: + * specification/databasewatcher/resource-manager/Microsoft.DatabaseWatcher/preview/2024-07-19-preview/examples/ + * Watchers_Get_MaximumSet_Gen.json + */ + /** + * Sample code: Watchers_Get - generated by [MaximumSet] rule. + * + * @param manager Entry point to DatabasewatcherManager. + */ + public static void + watchersGetGeneratedByMaximumSetRule(com.azure.resourcemanager.databasewatcher.DatabasewatcherManager manager) { + manager.watchers().getByResourceGroupWithResponse("rgWatcher", "myWatcher", com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/WatchersListByResourceGroupSamples.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/WatchersListByResourceGroupSamples.java new file mode 100644 index 0000000000000..a0a2ae4147dbf --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/WatchersListByResourceGroupSamples.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.databasewatcher.generated; + +/** + * Samples for Watchers ListByResourceGroup. + */ +public final class WatchersListByResourceGroupSamples { + /* + * x-ms-original-file: + * specification/databasewatcher/resource-manager/Microsoft.DatabaseWatcher/preview/2024-07-19-preview/examples/ + * Watchers_ListByResourceGroup_MaximumSet_Gen.json + */ + /** + * Sample code: Watchers_ListByResourceGroup - generated by [MaximumSet] rule - generated by [MaximumSet] rule. + * + * @param manager Entry point to DatabasewatcherManager. + */ + public static void watchersListByResourceGroupGeneratedByMaximumSetRuleGeneratedByMaximumSetRule( + com.azure.resourcemanager.databasewatcher.DatabasewatcherManager manager) { + manager.watchers().listByResourceGroup("rgWatcher", com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/WatchersListSamples.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/WatchersListSamples.java new file mode 100644 index 0000000000000..97c8b071031b1 --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/WatchersListSamples.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.databasewatcher.generated; + +/** + * Samples for Watchers List. + */ +public final class WatchersListSamples { + /* + * x-ms-original-file: + * specification/databasewatcher/resource-manager/Microsoft.DatabaseWatcher/preview/2024-07-19-preview/examples/ + * Watchers_ListBySubscription_MaximumSet_Gen.json + */ + /** + * Sample code: Watchers_ListBySubscription - generated by [MaximumSet] rule - generated by [MaximumSet] rule. + * + * @param manager Entry point to DatabasewatcherManager. + */ + public static void watchersListBySubscriptionGeneratedByMaximumSetRuleGeneratedByMaximumSetRule( + com.azure.resourcemanager.databasewatcher.DatabasewatcherManager manager) { + manager.watchers().list(com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/WatchersStartSamples.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/WatchersStartSamples.java new file mode 100644 index 0000000000000..0f3ab712290da --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/WatchersStartSamples.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.databasewatcher.generated; + +/** + * Samples for Watchers Start. + */ +public final class WatchersStartSamples { + /* + * x-ms-original-file: + * specification/databasewatcher/resource-manager/Microsoft.DatabaseWatcher/preview/2024-07-19-preview/examples/ + * Watchers_Start_MaximumSet_Gen.json + */ + /** + * Sample code: Watchers_Start - generated by [MaximumSet] rule - generated by [MaximumSet] rule. + * + * @param manager Entry point to DatabasewatcherManager. + */ + public static void watchersStartGeneratedByMaximumSetRuleGeneratedByMaximumSetRule( + com.azure.resourcemanager.databasewatcher.DatabasewatcherManager manager) { + manager.watchers().start("rgWatcher", "testWatcher", com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/WatchersStopSamples.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/WatchersStopSamples.java new file mode 100644 index 0000000000000..3729442dc586d --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/WatchersStopSamples.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.databasewatcher.generated; + +/** + * Samples for Watchers Stop. + */ +public final class WatchersStopSamples { + /* + * x-ms-original-file: + * specification/databasewatcher/resource-manager/Microsoft.DatabaseWatcher/preview/2024-07-19-preview/examples/ + * Watchers_Stop_MaximumSet_Gen.json + */ + /** + * Sample code: Watchers_Stop - generated by [MaximumSet] rule - generated by [MaximumSet] rule. + * + * @param manager Entry point to DatabasewatcherManager. + */ + public static void watchersStopGeneratedByMaximumSetRuleGeneratedByMaximumSetRule( + com.azure.resourcemanager.databasewatcher.DatabasewatcherManager manager) { + manager.watchers().stop("rgWatcher", "myWatcher", com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/WatchersUpdateSamples.java b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/WatchersUpdateSamples.java new file mode 100644 index 0000000000000..b8e2c369499a3 --- /dev/null +++ b/sdk/databasewatcher/azure-resourcemanager-databasewatcher/src/samples/java/com/azure/resourcemanager/databasewatcher/generated/WatchersUpdateSamples.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.databasewatcher.generated; + +import com.azure.resourcemanager.databasewatcher.models.DatastoreUpdate; +import com.azure.resourcemanager.databasewatcher.models.KustoOfferingType; +import com.azure.resourcemanager.databasewatcher.models.ManagedServiceIdentity; +import com.azure.resourcemanager.databasewatcher.models.ManagedServiceIdentityType; +import com.azure.resourcemanager.databasewatcher.models.Watcher; +import java.util.HashMap; +import java.util.Map; + +/** + * Samples for Watchers Update. + */ +public final class WatchersUpdateSamples { + /* + * x-ms-original-file: + * specification/databasewatcher/resource-manager/Microsoft.DatabaseWatcher/preview/2024-07-19-preview/examples/ + * Watchers_Update_MaximumSet_Gen.json + */ + /** + * Sample code: Watchers_Update - generated by [MaximumSet] rule - generated by [MaximumSet] rule. + * + * @param manager Entry point to DatabasewatcherManager. + */ + public static void watchersUpdateGeneratedByMaximumSetRuleGeneratedByMaximumSetRule( + com.azure.resourcemanager.databasewatcher.DatabasewatcherManager manager) { + Watcher resource = manager.watchers() + .getByResourceGroupWithResponse("rgWatcher", "testWatcher", com.azure.core.util.Context.NONE) + .getValue(); + resource.update() + .withTags(mapOf()) + .withIdentity(new ManagedServiceIdentity().withType(ManagedServiceIdentityType.SYSTEM_ASSIGNED)) + .withDatastore(new DatastoreUpdate().withAdxClusterResourceId( + "/subscriptions/6f53185c-ea09-4fc3-9075-318dec805303/resourceGroups/apiTest/providers/Microsoft.Kusto/clusters/apiTestKusto") + .withKustoClusterDisplayName("kustoUri-adx") + .withKustoClusterUri("https://kustouri-adx.eastus.kusto.windows.net") + .withKustoDataIngestionUri("https://ingest-kustouri-adx.eastus.kusto.windows.net") + .withKustoDatabaseName("kustoDatabaseName1") + .withKustoManagementUrl("https://portal.azure.com/") + .withKustoOfferingType(KustoOfferingType.ADX)) + .withDefaultAlertRuleIdentityResourceId( + "/subscriptions/469DD77C-C8DB-47B7-B9E1-72D29F8C878B/resourceGroups/rgWatcher/providers/Microsoft.ManagedIdentity/userAssignedIdentities/newtest") + .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/databasewatcher/ci.yml b/sdk/databasewatcher/ci.yml new file mode 100644 index 0000000000000..60553b79960ec --- /dev/null +++ b/sdk/databasewatcher/ci.yml @@ -0,0 +1,46 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. + +trigger: + branches: + include: + - main + - hotfix/* + - release/* + paths: + include: + - sdk/databasewatcher/ci.yml + - sdk/databasewatcher/azure-resourcemanager-databasewatcher/ + exclude: + - sdk/databasewatcher/pom.xml + - sdk/databasewatcher/azure-resourcemanager-databasewatcher/pom.xml + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/databasewatcher/ci.yml + - sdk/databasewatcher/azure-resourcemanager-databasewatcher/ + exclude: + - sdk/databasewatcher/pom.xml + - sdk/databasewatcher/azure-resourcemanager-databasewatcher/pom.xml + +parameters: + - name: release_azureresourcemanagerdatabasewatcher + displayName: azure-resourcemanager-databasewatcher + type: boolean + default: false + +extends: + template: ../../eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: databasewatcher + Artifacts: + - name: azure-resourcemanager-databasewatcher + groupId: com.azure.resourcemanager + safeName: azureresourcemanagerdatabasewatcher + releaseInBatch: ${{ parameters.release_azureresourcemanagerdatabasewatcher }} diff --git a/sdk/databasewatcher/pom.xml b/sdk/databasewatcher/pom.xml new file mode 100644 index 0000000000000..a3dd9f80b4a63 --- /dev/null +++ b/sdk/databasewatcher/pom.xml @@ -0,0 +1,15 @@ + + + 4.0.0 + com.azure + azure-databasewatcher-service + pom + 1.0.0 + + + azure-resourcemanager-databasewatcher + + diff --git a/sdk/spring/spring-cloud-azure-feature-management-web/pom.xml b/sdk/spring/spring-cloud-azure-feature-management-web/pom.xml index 15921830c9479..b0c2403ea06d5 100644 --- a/sdk/spring/spring-cloud-azure-feature-management-web/pom.xml +++ b/sdk/spring/spring-cloud-azure-feature-management-web/pom.xml @@ -152,7 +152,7 @@ - com.azure.spring:spring-cloud-azure-feature-management:[5.14.0-beta.1] + com.azure.spring:spring-cloud-azure-feature-management:[5.15.0-beta.1] jakarta.servlet:jakarta.servlet-api:[6.0.0] org.springframework:spring-web:[6.1.11] org.springframework:spring-webmvc:[6.1.11]