From 9b1e4c9f913381ffaad841c8ea29578038fe3bd6 Mon Sep 17 00:00:00 2001 From: ZiWei Chen <98569699+kazrael2119@users.noreply.github.com> Date: Mon, 3 Mar 2025 13:34:44 +0800 Subject: [PATCH] [mgmt] databasewatcher release (#33079) https://github.com/Azure/sdk-release-request/issues/5835 --- .github/CODEOWNERS | 3 + common/config/rush/pnpm-lock.yaml | 71 +- eng/ignore-links.txt | 1 + rush.json | 9 +- .../arm-databasewatcher/CHANGELOG.md | 7 + .../arm-databasewatcher/LICENSE | 21 + .../arm-databasewatcher/README.md | 114 ++ .../arm-databasewatcher/api-extractor.json | 31 + .../arm-databasewatcher/assets.json | 6 + .../arm-databasewatcher/eslint.config.mjs | 16 + .../arm-databasewatcher/package.json | 164 ++ .../review/arm-databasewatcher-models.api.md | 357 +++++ .../review/arm-databasewatcher.api.md | 562 +++++++ .../arm-databasewatcher/sample.env | 1 + ...sAlertRuleResourcesCreateOrUpdateSample.ts | 39 + ...ResourcesAlertRuleResourcesDeleteSample.ts | 24 + ...uleResourcesAlertRuleResourcesGetSample.ts | 25 + ...cesAlertRuleResourcesListByParentSample.ts | 29 + ...thValidationsHealthValidationsGetSample.ts | 29 + ...ionsHealthValidationsListByParentSample.ts | 29 + ...sHealthValidationsStartValidationSample.ts | 29 + .../operationsOperationsListSample.ts | 48 + ...sSharedPrivateLinkResourcesCreateSample.ts | 39 + ...sSharedPrivateLinkResourcesDeleteSample.ts | 28 + ...rcesSharedPrivateLinkResourcesGetSample.ts | 29 + ...PrivateLinkResourcesListByWatcherSample.ts | 32 + .../targetsTargetsCreateOrUpdateSample.ts | 38 + .../samples-dev/targetsTargetsDeleteSample.ts | 24 + .../samples-dev/targetsTargetsGetSample.ts | 25 + .../targetsTargetsListByWatcherSample.ts | 29 + .../watchersWatchersCreateOrUpdateSample.ts | 44 + .../watchersWatchersDeleteSample.ts | 24 + .../samples-dev/watchersWatchersGetSample.ts | 25 + ...tchersWatchersListByResourceGroupSample.ts | 29 + ...atchersWatchersListBySubscriptionSample.ts | 29 + .../watchersWatchersStartSample.ts | 24 + .../samples-dev/watchersWatchersStopSample.ts | 24 + .../watchersWatchersUpdateSample.ts | 42 + .../samples/v1-beta/javascript/README.md | 96 ++ ...sAlertRuleResourcesCreateOrUpdateSample.js | 39 + ...ResourcesAlertRuleResourcesDeleteSample.js | 24 + ...uleResourcesAlertRuleResourcesGetSample.js | 25 + ...cesAlertRuleResourcesListByParentSample.js | 29 + ...thValidationsHealthValidationsGetSample.js | 29 + ...ionsHealthValidationsListByParentSample.js | 29 + ...sHealthValidationsStartValidationSample.js | 29 + .../operationsOperationsListSample.js | 48 + .../samples/v1-beta/javascript/package.json | 33 + .../samples/v1-beta/javascript/sample.env | 1 + ...sSharedPrivateLinkResourcesCreateSample.js | 39 + ...sSharedPrivateLinkResourcesDeleteSample.js | 28 + ...rcesSharedPrivateLinkResourcesGetSample.js | 29 + ...PrivateLinkResourcesListByWatcherSample.js | 32 + .../targetsTargetsCreateOrUpdateSample.js | 38 + .../javascript/targetsTargetsDeleteSample.js | 24 + .../javascript/targetsTargetsGetSample.js | 25 + .../targetsTargetsListByWatcherSample.js | 29 + .../watchersWatchersCreateOrUpdateSample.js | 44 + .../watchersWatchersDeleteSample.js | 24 + .../javascript/watchersWatchersGetSample.js | 25 + ...tchersWatchersListByResourceGroupSample.js | 29 + ...atchersWatchersListBySubscriptionSample.js | 29 + .../javascript/watchersWatchersStartSample.js | 24 + .../javascript/watchersWatchersStopSample.js | 24 + .../watchersWatchersUpdateSample.js | 42 + .../samples/v1-beta/typescript/README.md | 109 ++ .../samples/v1-beta/typescript/package.json | 42 + .../samples/v1-beta/typescript/sample.env | 1 + ...sAlertRuleResourcesCreateOrUpdateSample.ts | 39 + ...ResourcesAlertRuleResourcesDeleteSample.ts | 28 + ...uleResourcesAlertRuleResourcesGetSample.ts | 29 + ...cesAlertRuleResourcesListByParentSample.ts | 32 + ...thValidationsHealthValidationsGetSample.ts | 29 + ...ionsHealthValidationsListByParentSample.ts | 32 + ...sHealthValidationsStartValidationSample.ts | 29 + .../src/operationsOperationsListSample.ts | 48 + ...sSharedPrivateLinkResourcesCreateSample.ts | 39 + ...sSharedPrivateLinkResourcesDeleteSample.ts | 28 + ...rcesSharedPrivateLinkResourcesGetSample.ts | 29 + ...PrivateLinkResourcesListByWatcherSample.ts | 32 + .../src/targetsTargetsCreateOrUpdateSample.ts | 38 + .../src/targetsTargetsDeleteSample.ts | 24 + .../typescript/src/targetsTargetsGetSample.ts | 29 + .../src/targetsTargetsListByWatcherSample.ts | 32 + .../watchersWatchersCreateOrUpdateSample.ts | 44 + .../src/watchersWatchersDeleteSample.ts | 24 + .../src/watchersWatchersGetSample.ts | 25 + ...tchersWatchersListByResourceGroupSample.ts | 29 + ...atchersWatchersListBySubscriptionSample.ts | 29 + .../src/watchersWatchersStartSample.ts | 24 + .../src/watchersWatchersStopSample.ts | 24 + .../src/watchersWatchersUpdateSample.ts | 42 + .../samples/v1-beta/typescript/tsconfig.json | 20 + .../src/api/alertRuleResources/index.ts | 261 ++++ .../src/api/databaseWatcherContext.ts | 66 + .../src/api/healthValidations/index.ts | 206 +++ .../arm-databasewatcher/src/api/index.ts | 68 + .../src/api/operations/index.ts | 61 + .../arm-databasewatcher/src/api/options.ts | 100 ++ .../api/sharedPrivateLinkResources/index.ts | 293 ++++ .../src/api/targets/index.ts | 249 +++ .../src/api/watchers/index.ts | 433 ++++++ .../src/classic/alertRuleResources/index.ts | 109 ++ .../src/classic/healthValidations/index.ts | 79 + .../arm-databasewatcher/src/classic/index.ts | 9 + .../src/classic/operations/index.ts | 26 + .../sharedPrivateLinkResources/index.ts | 110 ++ .../src/classic/targets/index.ts | 86 ++ .../src/classic/watchers/index.ts | 121 ++ .../src/databaseWatcherClient.ts | 68 + .../arm-databasewatcher/src/index.ts | 104 ++ .../arm-databasewatcher/src/logger.ts | 5 + .../arm-databasewatcher/src/models/index.ts | 60 + .../arm-databasewatcher/src/models/models.ts | 1337 +++++++++++++++++ .../src/restorePollerHelpers.ts | 200 +++ .../src/static-helpers/pagingHelpers.ts | 241 +++ .../src/static-helpers/pollingHelpers.ts | 126 ++ .../databasewatcher_operations_test.spec.ts | 46 + .../test/public/utils/recordedClient.ts | 23 + .../arm-databasewatcher/test/snippets.spec.ts | 27 + .../tsconfig.browser.config.json | 3 + .../arm-databasewatcher/tsconfig.json | 13 + .../arm-databasewatcher/tsconfig.samples.json | 8 + .../arm-databasewatcher/tsconfig.src.json | 3 + .../arm-databasewatcher/tsconfig.test.json | 3 + .../arm-databasewatcher/tsp-location.yaml | 4 + .../vitest.browser.config.ts | 17 + .../arm-databasewatcher/vitest.config.ts | 16 + .../arm-databasewatcher/vitest.esm.config.ts | 12 + sdk/databasewatcher/ci.mgmt.yml | 35 + 130 files changed, 8509 insertions(+), 16 deletions(-) create mode 100644 sdk/databasewatcher/arm-databasewatcher/CHANGELOG.md create mode 100644 sdk/databasewatcher/arm-databasewatcher/LICENSE create mode 100644 sdk/databasewatcher/arm-databasewatcher/README.md create mode 100644 sdk/databasewatcher/arm-databasewatcher/api-extractor.json create mode 100644 sdk/databasewatcher/arm-databasewatcher/assets.json create mode 100644 sdk/databasewatcher/arm-databasewatcher/eslint.config.mjs create mode 100644 sdk/databasewatcher/arm-databasewatcher/package.json create mode 100644 sdk/databasewatcher/arm-databasewatcher/review/arm-databasewatcher-models.api.md create mode 100644 sdk/databasewatcher/arm-databasewatcher/review/arm-databasewatcher.api.md create mode 100644 sdk/databasewatcher/arm-databasewatcher/sample.env create mode 100644 sdk/databasewatcher/arm-databasewatcher/samples-dev/alertRuleResourcesAlertRuleResourcesCreateOrUpdateSample.ts create mode 100644 sdk/databasewatcher/arm-databasewatcher/samples-dev/alertRuleResourcesAlertRuleResourcesDeleteSample.ts create mode 100644 sdk/databasewatcher/arm-databasewatcher/samples-dev/alertRuleResourcesAlertRuleResourcesGetSample.ts create mode 100644 sdk/databasewatcher/arm-databasewatcher/samples-dev/alertRuleResourcesAlertRuleResourcesListByParentSample.ts create mode 100644 sdk/databasewatcher/arm-databasewatcher/samples-dev/healthValidationsHealthValidationsGetSample.ts create mode 100644 sdk/databasewatcher/arm-databasewatcher/samples-dev/healthValidationsHealthValidationsListByParentSample.ts create mode 100644 sdk/databasewatcher/arm-databasewatcher/samples-dev/healthValidationsHealthValidationsStartValidationSample.ts create mode 100644 sdk/databasewatcher/arm-databasewatcher/samples-dev/operationsOperationsListSample.ts create mode 100644 sdk/databasewatcher/arm-databasewatcher/samples-dev/sharedPrivateLinkResourcesSharedPrivateLinkResourcesCreateSample.ts create mode 100644 sdk/databasewatcher/arm-databasewatcher/samples-dev/sharedPrivateLinkResourcesSharedPrivateLinkResourcesDeleteSample.ts create mode 100644 sdk/databasewatcher/arm-databasewatcher/samples-dev/sharedPrivateLinkResourcesSharedPrivateLinkResourcesGetSample.ts create mode 100644 sdk/databasewatcher/arm-databasewatcher/samples-dev/sharedPrivateLinkResourcesSharedPrivateLinkResourcesListByWatcherSample.ts create mode 100644 sdk/databasewatcher/arm-databasewatcher/samples-dev/targetsTargetsCreateOrUpdateSample.ts create mode 100644 sdk/databasewatcher/arm-databasewatcher/samples-dev/targetsTargetsDeleteSample.ts create mode 100644 sdk/databasewatcher/arm-databasewatcher/samples-dev/targetsTargetsGetSample.ts create mode 100644 sdk/databasewatcher/arm-databasewatcher/samples-dev/targetsTargetsListByWatcherSample.ts create mode 100644 sdk/databasewatcher/arm-databasewatcher/samples-dev/watchersWatchersCreateOrUpdateSample.ts create mode 100644 sdk/databasewatcher/arm-databasewatcher/samples-dev/watchersWatchersDeleteSample.ts create mode 100644 sdk/databasewatcher/arm-databasewatcher/samples-dev/watchersWatchersGetSample.ts create mode 100644 sdk/databasewatcher/arm-databasewatcher/samples-dev/watchersWatchersListByResourceGroupSample.ts create mode 100644 sdk/databasewatcher/arm-databasewatcher/samples-dev/watchersWatchersListBySubscriptionSample.ts create mode 100644 sdk/databasewatcher/arm-databasewatcher/samples-dev/watchersWatchersStartSample.ts create mode 100644 sdk/databasewatcher/arm-databasewatcher/samples-dev/watchersWatchersStopSample.ts create mode 100644 sdk/databasewatcher/arm-databasewatcher/samples-dev/watchersWatchersUpdateSample.ts create mode 100644 sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/README.md create mode 100644 sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/alertRuleResourcesAlertRuleResourcesCreateOrUpdateSample.js create mode 100644 sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/alertRuleResourcesAlertRuleResourcesDeleteSample.js create mode 100644 sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/alertRuleResourcesAlertRuleResourcesGetSample.js create mode 100644 sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/alertRuleResourcesAlertRuleResourcesListByParentSample.js create mode 100644 sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/healthValidationsHealthValidationsGetSample.js create mode 100644 sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/healthValidationsHealthValidationsListByParentSample.js create mode 100644 sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/healthValidationsHealthValidationsStartValidationSample.js create mode 100644 sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/operationsOperationsListSample.js create mode 100644 sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/package.json create mode 100644 sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/sample.env create mode 100644 sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/sharedPrivateLinkResourcesSharedPrivateLinkResourcesCreateSample.js create mode 100644 sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/sharedPrivateLinkResourcesSharedPrivateLinkResourcesDeleteSample.js create mode 100644 sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/sharedPrivateLinkResourcesSharedPrivateLinkResourcesGetSample.js create mode 100644 sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/sharedPrivateLinkResourcesSharedPrivateLinkResourcesListByWatcherSample.js create mode 100644 sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/targetsTargetsCreateOrUpdateSample.js create mode 100644 sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/targetsTargetsDeleteSample.js create mode 100644 sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/targetsTargetsGetSample.js create mode 100644 sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/targetsTargetsListByWatcherSample.js create mode 100644 sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/watchersWatchersCreateOrUpdateSample.js create mode 100644 sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/watchersWatchersDeleteSample.js create mode 100644 sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/watchersWatchersGetSample.js create mode 100644 sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/watchersWatchersListByResourceGroupSample.js create mode 100644 sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/watchersWatchersListBySubscriptionSample.js create mode 100644 sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/watchersWatchersStartSample.js create mode 100644 sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/watchersWatchersStopSample.js create mode 100644 sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/watchersWatchersUpdateSample.js create mode 100644 sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/README.md create mode 100644 sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/package.json create mode 100644 sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/sample.env create mode 100644 sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/alertRuleResourcesAlertRuleResourcesCreateOrUpdateSample.ts create mode 100644 sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/alertRuleResourcesAlertRuleResourcesDeleteSample.ts create mode 100644 sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/alertRuleResourcesAlertRuleResourcesGetSample.ts create mode 100644 sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/alertRuleResourcesAlertRuleResourcesListByParentSample.ts create mode 100644 sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/healthValidationsHealthValidationsGetSample.ts create mode 100644 sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/healthValidationsHealthValidationsListByParentSample.ts create mode 100644 sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/healthValidationsHealthValidationsStartValidationSample.ts create mode 100644 sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/operationsOperationsListSample.ts create mode 100644 sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/sharedPrivateLinkResourcesSharedPrivateLinkResourcesCreateSample.ts create mode 100644 sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/sharedPrivateLinkResourcesSharedPrivateLinkResourcesDeleteSample.ts create mode 100644 sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/sharedPrivateLinkResourcesSharedPrivateLinkResourcesGetSample.ts create mode 100644 sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/sharedPrivateLinkResourcesSharedPrivateLinkResourcesListByWatcherSample.ts create mode 100644 sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/targetsTargetsCreateOrUpdateSample.ts create mode 100644 sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/targetsTargetsDeleteSample.ts create mode 100644 sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/targetsTargetsGetSample.ts create mode 100644 sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/targetsTargetsListByWatcherSample.ts create mode 100644 sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/watchersWatchersCreateOrUpdateSample.ts create mode 100644 sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/watchersWatchersDeleteSample.ts create mode 100644 sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/watchersWatchersGetSample.ts create mode 100644 sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/watchersWatchersListByResourceGroupSample.ts create mode 100644 sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/watchersWatchersListBySubscriptionSample.ts create mode 100644 sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/watchersWatchersStartSample.ts create mode 100644 sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/watchersWatchersStopSample.ts create mode 100644 sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/watchersWatchersUpdateSample.ts create mode 100644 sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/tsconfig.json create mode 100644 sdk/databasewatcher/arm-databasewatcher/src/api/alertRuleResources/index.ts create mode 100644 sdk/databasewatcher/arm-databasewatcher/src/api/databaseWatcherContext.ts create mode 100644 sdk/databasewatcher/arm-databasewatcher/src/api/healthValidations/index.ts create mode 100644 sdk/databasewatcher/arm-databasewatcher/src/api/index.ts create mode 100644 sdk/databasewatcher/arm-databasewatcher/src/api/operations/index.ts create mode 100644 sdk/databasewatcher/arm-databasewatcher/src/api/options.ts create mode 100644 sdk/databasewatcher/arm-databasewatcher/src/api/sharedPrivateLinkResources/index.ts create mode 100644 sdk/databasewatcher/arm-databasewatcher/src/api/targets/index.ts create mode 100644 sdk/databasewatcher/arm-databasewatcher/src/api/watchers/index.ts create mode 100644 sdk/databasewatcher/arm-databasewatcher/src/classic/alertRuleResources/index.ts create mode 100644 sdk/databasewatcher/arm-databasewatcher/src/classic/healthValidations/index.ts create mode 100644 sdk/databasewatcher/arm-databasewatcher/src/classic/index.ts create mode 100644 sdk/databasewatcher/arm-databasewatcher/src/classic/operations/index.ts create mode 100644 sdk/databasewatcher/arm-databasewatcher/src/classic/sharedPrivateLinkResources/index.ts create mode 100644 sdk/databasewatcher/arm-databasewatcher/src/classic/targets/index.ts create mode 100644 sdk/databasewatcher/arm-databasewatcher/src/classic/watchers/index.ts create mode 100644 sdk/databasewatcher/arm-databasewatcher/src/databaseWatcherClient.ts create mode 100644 sdk/databasewatcher/arm-databasewatcher/src/index.ts create mode 100644 sdk/databasewatcher/arm-databasewatcher/src/logger.ts create mode 100644 sdk/databasewatcher/arm-databasewatcher/src/models/index.ts create mode 100644 sdk/databasewatcher/arm-databasewatcher/src/models/models.ts create mode 100644 sdk/databasewatcher/arm-databasewatcher/src/restorePollerHelpers.ts create mode 100644 sdk/databasewatcher/arm-databasewatcher/src/static-helpers/pagingHelpers.ts create mode 100644 sdk/databasewatcher/arm-databasewatcher/src/static-helpers/pollingHelpers.ts create mode 100644 sdk/databasewatcher/arm-databasewatcher/test/public/databasewatcher_operations_test.spec.ts create mode 100644 sdk/databasewatcher/arm-databasewatcher/test/public/utils/recordedClient.ts create mode 100644 sdk/databasewatcher/arm-databasewatcher/test/snippets.spec.ts create mode 100644 sdk/databasewatcher/arm-databasewatcher/tsconfig.browser.config.json create mode 100644 sdk/databasewatcher/arm-databasewatcher/tsconfig.json create mode 100644 sdk/databasewatcher/arm-databasewatcher/tsconfig.samples.json create mode 100644 sdk/databasewatcher/arm-databasewatcher/tsconfig.src.json create mode 100644 sdk/databasewatcher/arm-databasewatcher/tsconfig.test.json create mode 100644 sdk/databasewatcher/arm-databasewatcher/tsp-location.yaml create mode 100644 sdk/databasewatcher/arm-databasewatcher/vitest.browser.config.ts create mode 100644 sdk/databasewatcher/arm-databasewatcher/vitest.config.ts create mode 100644 sdk/databasewatcher/arm-databasewatcher/vitest.esm.config.ts create mode 100644 sdk/databasewatcher/ci.mgmt.yml diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 46acd5f8116d..437dee27aff1 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -467,6 +467,9 @@ sdk/ai/ai-projects @ganeshyb @GraceBrigham # PRLabel: %Mgmt /sdk/customer-insights/arm-customerinsights/ @qiaozha @MaryGao +# PRLabel: %Mgmt +/sdk/databasewatcher/arm-databasewatcher/ @qiaozha @MaryGao + # PRLabel: %Mgmt /sdk/databox/arm-databox/ @qiaozha @MaryGao diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index 392d520fc430..65a31e348257 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -247,6 +247,9 @@ importers: '@rush-temp/arm-dashboard': specifier: file:./projects/arm-dashboard.tgz version: file:projects/arm-dashboard.tgz(@types/debug@4.1.12)(msw@2.7.2(@types/node@22.7.9)(typescript@5.7.3))(tsx@4.19.3)(vite@6.1.1(@types/node@22.7.9)(tsx@4.19.3)(yaml@2.7.0))(yaml@2.7.0) + '@rush-temp/arm-databasewatcher': + specifier: file:./projects/arm-databasewatcher.tgz + version: file:projects/arm-databasewatcher.tgz(@types/debug@4.1.12)(msw@2.7.2(@types/node@22.7.9)(typescript@5.7.3))(tsx@4.19.3)(vite@6.1.1(@types/node@22.7.9)(tsx@4.19.3)(yaml@2.7.0))(yaml@2.7.0) '@rush-temp/arm-databoundaries': specifier: file:./projects/arm-databoundaries.tgz version: file:projects/arm-databoundaries.tgz(@types/debug@4.1.12)(msw@2.7.2(@types/node@22.7.9)(typescript@5.7.3))(tsx@4.19.3)(vite@6.1.1(@types/node@22.7.9)(tsx@4.19.3)(yaml@2.7.0))(yaml@2.7.0) @@ -2824,6 +2827,10 @@ packages: resolution: {integrity: sha512-F3E5mVGf1SLYnCrCcwbwd/iS+vxKjqnAdXbAvbUh2Ai/raPFg2HwoHcPmVxMwXti8yE8TNjagtbd+MWI5nQVhg==, tarball: file:projects/arm-dashboard.tgz} version: 0.0.0 + '@rush-temp/arm-databasewatcher@file:projects/arm-databasewatcher.tgz': + resolution: {integrity: sha512-TErY+b4zxOXU6OxBEWGN/uwEhCNFGsHY447WHI0c9ZDAoJQ+KRYOtDIA6BF5FhGTxCdnLXQg84GG3NMBDEc4qg==, tarball: file:projects/arm-databasewatcher.tgz} + version: 0.0.0 + '@rush-temp/arm-databoundaries@file:projects/arm-databoundaries.tgz': resolution: {integrity: sha512-ItqSxMC9OYnKnBBA2gLnpQ+fFb6LlU5fZtdTiJ0h6Nb8H4oMmMfJo5x33rPQU9hTwHObNAVC8WmpzTqH748lWg==, tarball: file:projects/arm-databoundaries.tgz} version: 0.0.0 @@ -3225,7 +3232,7 @@ packages: version: 0.0.0 '@rush-temp/arm-networkcloud@file:projects/arm-networkcloud.tgz': - resolution: {integrity: sha512-Vget+Btjm5TB3NqDnubucSSFQxs2rp+rX5CQ9tIQ/m6vPwVTd8blkJ6IUqSIVsxxpgrFEhsJ8cbHbOwEuJ1dlA==, tarball: file:projects/arm-networkcloud.tgz} + resolution: {integrity: sha512-VhAlzN09Jw7ZFw8pdEML1m6X5WzGMXiopKrdfQ2Bou2XDD/mncjuIV0MCrYIFQFcVKvaame0Xh9qH+HIW9VWdA==, tarball: file:projects/arm-networkcloud.tgz} version: 0.0.0 '@rush-temp/arm-networkfunction@file:projects/arm-networkfunction.tgz': @@ -3237,7 +3244,7 @@ packages: version: 0.0.0 '@rush-temp/arm-nginx@file:projects/arm-nginx.tgz': - resolution: {integrity: sha512-0Zr+dEe7RW/QTtMzMKwynKxi9E2O8VUD7A4wPGxh/ehH5g11ea4Ay97Li0k/v4HCiizyeLRkXc0SC0bWuoeZxg==, tarball: file:projects/arm-nginx.tgz} + resolution: {integrity: sha512-T2JX94sR7Z2fyia9XglIcbr8Rx3o0M97D71+1xkmHlz1K/yqnGo/QyXhKo84lZMWC2voB2XxzjmpEPftoDHhxg==, tarball: file:projects/arm-nginx.tgz} version: 0.0.0 '@rush-temp/arm-notificationhubs@file:projects/arm-notificationhubs.tgz': @@ -12488,6 +12495,42 @@ snapshots: - webdriverio - yaml + '@rush-temp/arm-databasewatcher@file:projects/arm-databasewatcher.tgz(@types/debug@4.1.12)(msw@2.7.2(@types/node@22.7.9)(typescript@5.7.3))(tsx@4.19.3)(vite@6.1.1(@types/node@22.7.9)(tsx@4.19.3)(yaml@2.7.0))(yaml@2.7.0)': + dependencies: + '@microsoft/api-extractor': 7.50.1(@types/node@18.19.76) + '@types/node': 18.19.76 + '@vitest/browser': 3.0.6(@types/node@18.19.76)(playwright@1.50.1)(typescript@5.6.3)(vite@6.1.1(@types/node@22.7.9)(tsx@4.19.3)(yaml@2.7.0))(vitest@3.0.6) + '@vitest/coverage-istanbul': 3.0.6(vitest@3.0.6) + dotenv: 16.4.7 + eslint: 9.21.0 + playwright: 1.50.1 + tslib: 2.8.1 + typescript: 5.6.3 + vitest: 3.0.6(@types/debug@4.1.12)(@types/node@18.19.76)(@vitest/browser@3.0.6)(msw@2.7.2(@types/node@22.7.9)(typescript@5.7.3))(tsx@4.19.3)(yaml@2.7.0) + transitivePeerDependencies: + - '@edge-runtime/vm' + - '@types/debug' + - '@vitest/ui' + - bufferutil + - happy-dom + - jiti + - jsdom + - less + - lightningcss + - msw + - safaridriver + - sass + - sass-embedded + - stylus + - sugarss + - supports-color + - terser + - tsx + - utf-8-validate + - vite + - webdriverio + - yaml + '@rush-temp/arm-databoundaries@file:projects/arm-databoundaries.tgz(@types/debug@4.1.12)(msw@2.7.2(@types/node@22.7.9)(typescript@5.7.3))(tsx@4.19.3)(vite@6.1.1(@types/node@22.7.9)(tsx@4.19.3)(yaml@2.7.0))(yaml@2.7.0)': dependencies: '@types/node': 18.19.76 @@ -23840,13 +23883,13 @@ snapshots: '@types/connect@3.4.38': dependencies: - '@types/node': 18.19.76 + '@types/node': 22.7.9 '@types/cookie@0.6.0': {} '@types/cors@2.8.17': dependencies: - '@types/node': 18.19.76 + '@types/node': 22.7.9 '@types/debug@4.1.12': dependencies: @@ -23865,7 +23908,7 @@ snapshots: '@types/express-serve-static-core@4.19.6': dependencies: - '@types/node': 18.19.76 + '@types/node': 22.7.9 '@types/qs': 6.9.18 '@types/range-parser': 1.2.7 '@types/send': 0.17.4 @@ -23880,7 +23923,7 @@ snapshots: '@types/fs-extra@11.0.4': dependencies: '@types/jsonfile': 6.1.4 - '@types/node': 18.19.76 + '@types/node': 22.7.9 '@types/fs-extra@8.1.5': dependencies: @@ -23889,7 +23932,7 @@ snapshots: '@types/glob@7.2.0': dependencies: '@types/minimatch': 5.1.2 - '@types/node': 18.19.76 + '@types/node': 22.7.9 '@types/http-errors@2.0.4': {} @@ -23906,7 +23949,7 @@ snapshots: '@types/jsonfile@6.1.4': dependencies: - '@types/node': 18.19.76 + '@types/node': 22.7.9 '@types/jsonwebtoken@9.0.9': dependencies: @@ -23948,7 +23991,7 @@ snapshots: '@types/node-fetch@2.6.12': dependencies: - '@types/node': 18.19.76 + '@types/node': 22.7.9 form-data: 4.0.2 '@types/node@18.19.76': @@ -23990,7 +24033,7 @@ snapshots: '@types/readdir-glob@1.1.5': dependencies: - '@types/node': 18.19.76 + '@types/node': 22.7.9 '@types/resolve@1.20.2': {} @@ -24001,7 +24044,7 @@ snapshots: '@types/send@0.17.4': dependencies: '@types/mime': 1.3.5 - '@types/node': 18.19.76 + '@types/node': 22.7.9 '@types/serve-static@1.15.7': dependencies: @@ -24025,7 +24068,7 @@ snapshots: '@types/through@0.0.33': dependencies: - '@types/node': 18.19.76 + '@types/node': 22.7.9 '@types/tough-cookie@4.0.5': {} @@ -24057,7 +24100,7 @@ snapshots: '@types/yauzl@2.10.3': dependencies: - '@types/node': 18.19.76 + '@types/node': 22.7.9 optional: true '@typescript-eslint/eslint-plugin@8.24.1(@typescript-eslint/parser@8.24.1(eslint@9.21.0)(typescript@5.7.3))(eslint@9.21.0)(typescript@5.7.3)': @@ -25008,7 +25051,7 @@ snapshots: engine.io@6.6.4: dependencies: '@types/cors': 2.8.17 - '@types/node': 18.19.76 + '@types/node': 22.7.9 accepts: 1.3.8 base64id: 2.0.0 cookie: 0.7.2 diff --git a/eng/ignore-links.txt b/eng/ignore-links.txt index 5c1add0d404d..e7412af2fb74 100644 --- a/eng/ignore-links.txt +++ b/eng/ignore-links.txt @@ -18,4 +18,5 @@ https://docs.microsoft.com/javascript/api/@azure/arm-terraform?view=azure-node-p https://docs.microsoft.com/javascript/api/@azure/arm-connectedcache?view=azure-node-preview https://docs.microsoft.com/javascript/api/@azure/arm-neonpostgres?view=azure-node-preview https://learn.microsoft.com/javascript/api/@azure/arm-pineconevectordb?view=azure-node-preview +https://learn.microsoft.com/javascript/api/@azure/arm-databasewatcher?view=azure-node-preview https://learn.microsoft.com/javascript/api/@azure/arm-impactreporting?view=azure-node-preview diff --git a/rush.json b/rush.json index c8ce8538481f..c82d8d41fec7 100644 --- a/rush.json +++ b/rush.json @@ -1,7 +1,7 @@ /** * This is the main configuration file for Rush. * For full documentation, please see https://rushjs.io - */ { + */{ "$schema": "https://developer.microsoft.com/json-schemas/rush/v5/rush.schema.json", /** * (Required) This specifies the version of the Rush engine to be used in this repo. @@ -2326,6 +2326,11 @@ "packageName": "@azure/arm-pineconevectordb", "projectFolder": "sdk/pineconevectordb/arm-pineconevectordb", "versionPolicyName": "management" + }, + { + "packageName": "@azure/arm-databasewatcher", + "projectFolder": "sdk/databasewatcher/arm-databasewatcher", + "versionPolicyName": "management" } ] -} +} \ No newline at end of file diff --git a/sdk/databasewatcher/arm-databasewatcher/CHANGELOG.md b/sdk/databasewatcher/arm-databasewatcher/CHANGELOG.md new file mode 100644 index 000000000000..94316c241025 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/CHANGELOG.md @@ -0,0 +1,7 @@ +# Release History + +## 1.0.0-beta.1 (2025-02-28) + +### Features Added + +Initial release of the Azure Database Watcher package diff --git a/sdk/databasewatcher/arm-databasewatcher/LICENSE b/sdk/databasewatcher/arm-databasewatcher/LICENSE new file mode 100644 index 000000000000..2ad4de7b17f0 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2025 Microsoft + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/sdk/databasewatcher/arm-databasewatcher/README.md b/sdk/databasewatcher/arm-databasewatcher/README.md new file mode 100644 index 000000000000..c9f6fa08564f --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/README.md @@ -0,0 +1,114 @@ +# Azure DatabaseWatcher client library for JavaScript + +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for Azure DatabaseWatcher client. + + + +Key links: + +- [Source code](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/databasewatcher/arm-databasewatcher) +- [Package (NPM)](https://www.npmjs.com/package/@azure/arm-databasewatcher) +- [API reference documentation](https://learn.microsoft.com/javascript/api/@azure/arm-databasewatcher?view=azure-node-preview) +- [Samples](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/databasewatcher/arm-databasewatcher/samples) + +## Getting started + +### Currently supported environments + +- [LTS versions of Node.js](https://github.com/nodejs/release#release-schedule) +- Latest versions of Safari, Chrome, Edge and Firefox. + +See our [support policy](https://github.com/Azure/azure-sdk-for-js/blob/main/SUPPORT.md) for more details. + +### Prerequisites + +- An [Azure subscription][azure_sub]. + +### Install the `@azure/arm-databasewatcher` package + +Install the Azure DatabaseWatcher client library for JavaScript with `npm`: + +```bash +npm install @azure/arm-databasewatcher +``` + +### Create and authenticate a `DatabaseWatcherClient` + +To create a client object to access the Azure DatabaseWatcher API, you will need the `endpoint` of your Azure DatabaseWatcher resource and a `credential`. The Azure DatabaseWatcher client can use Azure Active Directory credentials to authenticate. +You can find the endpoint for your Azure DatabaseWatcher resource in the [Azure Portal][azure_portal]. + +You can authenticate with Azure Active Directory using a credential from the [@azure/identity][azure_identity] library or [an existing AAD Token](https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/identity/identity/samples/AzureIdentityExamples.md#authenticating-with-a-pre-fetched-access-token). + +To use the [DefaultAzureCredential][defaultazurecredential] provider shown below, or other credential providers provided with the Azure SDK, please install the `@azure/identity` package: + +```bash +npm install @azure/identity +``` + +You will also need to **register a new AAD application and grant access to Azure DatabaseWatcher** by assigning the suitable role to your service principal (note: roles such as `"Owner"` will not grant the necessary permissions). + +For more information about how to create an Azure AD Application check out [this guide](https://learn.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal). + +Using Node.js and Node-like environments, you can use the `DefaultAzureCredential` class to authenticate the client. + +```ts snippet:ReadmeSampleCreateClient_Node +import { DatabaseWatcherClient } from "../src/index.js"; +import { DefaultAzureCredential } from "@azure/identity"; + +const subscriptionId = "00000000-0000-0000-0000-000000000000"; +const client = new DatabaseWatcherClient(new DefaultAzureCredential(), subscriptionId); +``` + +For browser environments, use the `InteractiveBrowserCredential` from the `@azure/identity` package to authenticate. + +```ts snippet:ReadmeSampleCreateClient_Browser +import { InteractiveBrowserCredential } from "@azure/identity"; +import { DatabaseWatcherClient } from "../src/index.js"; + +const subscriptionId = "00000000-0000-0000-0000-000000000000"; +const credential = new InteractiveBrowserCredential({ + tenantId: "", + clientId: "", +}); +const client = new DatabaseWatcherClient(credential, subscriptionId); +``` + +### JavaScript Bundle +To use this client library in the browser, first you need to use a bundler. For details on how to do this, please refer to our [bundling documentation](https://aka.ms/AzureSDKBundling). + +## Key concepts + +### DatabaseWatcherClient + +`DatabaseWatcherClient` is the primary interface for developers using the Azure DatabaseWatcher client library. Explore the methods on this client object to understand the different features of the Azure DatabaseWatcher service that you can access. + +## Troubleshooting + +### Logging + +Enabling logging may help uncover useful information about failures. In order to see a log of HTTP requests and responses, set the `AZURE_LOG_LEVEL` environment variable to `info`. Alternatively, logging can be enabled at runtime by calling `setLogLevel` in the `@azure/logger`: + +```ts snippet:SetLogLevel +import { setLogLevel } from "@azure/logger"; + +setLogLevel("info"); +``` + +For more detailed instructions on how to enable logs, you can look at the [@azure/logger package docs](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/core/logger). + +## Next steps + +Please take a look at the [samples](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/databasewatcher/arm-databasewatcher/samples) directory for detailed examples on how to use this library. + +## Contributing + +If you'd like to contribute to this library, please read the [contributing guide](https://github.com/Azure/azure-sdk-for-js/blob/main/CONTRIBUTING.md) to learn more about how to build and test the code. + +## Related projects + +- [Microsoft Azure SDK for JavaScript](https://github.com/Azure/azure-sdk-for-js) + +[azure_sub]: https://azure.microsoft.com/free/ +[azure_portal]: https://portal.azure.com +[azure_identity]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity +[defaultazurecredential]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#defaultazurecredential diff --git a/sdk/databasewatcher/arm-databasewatcher/api-extractor.json b/sdk/databasewatcher/arm-databasewatcher/api-extractor.json new file mode 100644 index 000000000000..3f4001e343d5 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/api-extractor.json @@ -0,0 +1,31 @@ +{ + "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", + "mainEntryPointFilePath": "dist/esm/index.d.ts", + "docModel": { + "enabled": true + }, + "apiReport": { + "enabled": true, + "reportFolder": "./review" + }, + "dtsRollup": { + "enabled": true, + "untrimmedFilePath": "", + "publicTrimmedFilePath": "dist/arm-databasewatcher.d.ts" + }, + "messages": { + "tsdocMessageReporting": { + "default": { + "logLevel": "none" + } + }, + "extractorMessageReporting": { + "ae-missing-release-tag": { + "logLevel": "none" + }, + "ae-unresolved-link": { + "logLevel": "none" + } + } + } +} diff --git a/sdk/databasewatcher/arm-databasewatcher/assets.json b/sdk/databasewatcher/arm-databasewatcher/assets.json new file mode 100644 index 000000000000..399b983e1076 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/assets.json @@ -0,0 +1,6 @@ +{ + "AssetsRepo": "Azure/azure-sdk-assets", + "AssetsRepoPrefixPath": "js", + "TagPrefix": "js/databasewatcher/arm-databasewatcher", + "Tag": "js/databasewatcher/arm-databasewatcher_4dbb8e11d2" +} diff --git a/sdk/databasewatcher/arm-databasewatcher/eslint.config.mjs b/sdk/databasewatcher/arm-databasewatcher/eslint.config.mjs new file mode 100644 index 000000000000..a9fcfbef11ff --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/eslint.config.mjs @@ -0,0 +1,16 @@ +import azsdkEslint from "@azure/eslint-plugin-azure-sdk"; + +export default azsdkEslint.config([ + { + rules: { + "@azure/azure-sdk/ts-modules-only-named": "warn", + "@azure/azure-sdk/ts-apiextractor-json-types": "warn", + "@azure/azure-sdk/ts-package-json-types": "warn", + "@azure/azure-sdk/ts-package-json-engine-is-present": "warn", + "@azure/azure-sdk/ts-package-json-module": "off", + "@azure/azure-sdk/ts-package-json-files-required": "off", + "@azure/azure-sdk/ts-package-json-main-is-cjs": "off", + "tsdoc/syntax": "warn", + }, + }, +]); diff --git a/sdk/databasewatcher/arm-databasewatcher/package.json b/sdk/databasewatcher/arm-databasewatcher/package.json new file mode 100644 index 000000000000..234719966d40 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/package.json @@ -0,0 +1,164 @@ +{ + "name": "@azure/arm-databasewatcher", + "version": "1.0.0-beta.1", + "description": "A generated SDK for DatabaseWatcherClient.", + "engines": { + "node": ">=18.0.0" + }, + "sideEffects": false, + "autoPublish": false, + "tshy": { + "project": "./tsconfig.src.json", + "exports": { + "./package.json": "./package.json", + ".": "./src/index.ts", + "./models": "./src/models/index.ts" + }, + "dialects": [ + "esm", + "commonjs" + ], + "esmDialects": [ + "browser", + "react-native" + ], + "selfLink": false + }, + "type": "module", + "keywords": [ + "node", + "azure", + "cloud", + "typescript", + "browser", + "isomorphic" + ], + "author": "Microsoft Corporation", + "license": "MIT", + "files": [ + "dist/", + "README.md", + "LICENSE", + "review/", + "CHANGELOG.md" + ], + "sdk-type": "mgmt", + "repository": "github:Azure/azure-sdk-for-js", + "bugs": { + "url": "https://github.com/Azure/azure-sdk-for-js/issues" + }, + "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/databasewatcher/arm-databasewatcher/README.md", + "prettier": "@azure/eslint-plugin-azure-sdk/prettier.json", + "//metadata": { + "constantPaths": [ + { + "path": "src/api/databaseWatcherContext.ts", + "prefix": "userAgentInfo" + } + ] + }, + "dependencies": { + "@azure-rest/core-client": "^2.3.1", + "@azure/abort-controller": "^2.1.2", + "@azure/core-auth": "^1.9.0", + "@azure/core-lro": "^3.1.0", + "@azure/core-rest-pipeline": "^1.19.0", + "@azure/core-util": "^1.11.0", + "@azure/logger": "^1.1.4", + "tslib": "^2.8.1" + }, + "devDependencies": { + "@azure-tools/test-credential": "^2.0.0", + "@azure-tools/test-recorder": "^4.1.0", + "@azure-tools/test-utils-vitest": "^1.0.0", + "@azure/dev-tool": "^1.0.0", + "@azure/eslint-plugin-azure-sdk": "^3.0.0", + "@azure/identity": "^4.6.0", + "@microsoft/api-extractor": "^7.40.3", + "@types/node": "^18.0.0", + "@vitest/browser": "^3.0.5", + "@vitest/coverage-istanbul": "^3.0.5", + "dotenv": "^16.0.0", + "eslint": "^9.9.0", + "playwright": "^1.50.1", + "typescript": "~5.6.2", + "vitest": "^3.0.5" + }, + "scripts": { + "build": "npm run clean && dev-tool run build-package && dev-tool run extract-api", + "build:samples": "tsc -p tsconfig.samples.json && dev-tool samples publish -f", + "build:test": "npm run clean && dev-tool run build-package && dev-tool run build-test", + "check-format": "dev-tool run vendored prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.{ts,cts,mts}\" \"test/**/*.{ts,cts,mts}\" \"*.{js,cjs,mjs,json}\" \"samples-dev/*.ts\"", + "clean": "dev-tool run vendored rimraf --glob dist dist-browser dist-esm test-dist temp types *.tgz *.log", + "execute:samples": "dev-tool samples run samples-dev", + "extract-api": "dev-tool run vendored rimraf review && dev-tool run extract-api", + "format": "dev-tool run vendored prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.{ts,cts,mts}\" \"test/**/*.{ts,cts,mts}\" \"*.{js,cjs,mjs,json}\" \"samples-dev/*.ts\"", + "generate:client": "echo skipped", + "integration-test": "npm run integration-test:node && npm run integration-test:browser", + "integration-test:browser": "echo skipped", + "integration-test:node": "dev-tool run test:vitest --esm", + "lint": "echo skipped", + "lint:fix": "echo skipped", + "minify": "dev-tool run vendored uglifyjs -c -m --comments --source-map \"content='./dist/index.js.map'\" -o ./dist/index.min.js ./dist/index.js", + "pack": "npm pack 2>&1", + "test": "npm run clean && dev-tool run build-package && npm run unit-test:node && dev-tool run bundle && npm run unit-test:browser && npm run integration-test", + "test:browser": "npm run clean && npm run build:test && npm run unit-test:browser && npm run integration-test:browser", + "test:node": "npm run clean && dev-tool run build-package && npm run unit-test:node && npm run integration-test:node", + "unit-test": "npm run unit-test:node && npm run unit-test:browser", + "unit-test:browser": "echo skipped", + "unit-test:node": "dev-tool run test:vitest", + "update-snippets": "dev-tool run update-snippets" + }, + "//sampleConfiguration": { + "productName": "@azure/arm-databasewatcher", + "productSlugs": [ + "azure" + ], + "disableDocsMs": true, + "apiRefLink": "https://learn.microsoft.com/javascript/api/@azure/arm-databasewatcher?view=azure-node-preview" + }, + "browser": "./dist/browser/index.js", + "react-native": "./dist/react-native/index.js", + "exports": { + "./package.json": "./package.json", + ".": { + "browser": { + "types": "./dist/browser/index.d.ts", + "default": "./dist/browser/index.js" + }, + "react-native": { + "types": "./dist/react-native/index.d.ts", + "default": "./dist/react-native/index.js" + }, + "import": { + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" + }, + "require": { + "types": "./dist/commonjs/index.d.ts", + "default": "./dist/commonjs/index.js" + } + }, + "./models": { + "browser": { + "types": "./dist/browser/models/index.d.ts", + "default": "./dist/browser/models/index.js" + }, + "react-native": { + "types": "./dist/react-native/models/index.d.ts", + "default": "./dist/react-native/models/index.js" + }, + "import": { + "types": "./dist/esm/models/index.d.ts", + "default": "./dist/esm/models/index.js" + }, + "require": { + "types": "./dist/commonjs/models/index.d.ts", + "default": "./dist/commonjs/models/index.js" + } + } + }, + "main": "./dist/commonjs/index.js", + "types": "./dist/commonjs/index.d.ts", + "module": "./dist/esm/index.js" +} diff --git a/sdk/databasewatcher/arm-databasewatcher/review/arm-databasewatcher-models.api.md b/sdk/databasewatcher/arm-databasewatcher/review/arm-databasewatcher-models.api.md new file mode 100644 index 000000000000..92bbf932ebe9 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/review/arm-databasewatcher-models.api.md @@ -0,0 +1,357 @@ +## API Report File for "@azure/arm-databasewatcher" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts + +// @public +export type ActionType = string; + +// @public +export type AlertRuleCreationProperties = string; + +// @public +export interface AlertRuleResource extends ProxyResource { + properties?: AlertRuleResourceProperties; +} + +// @public +export interface AlertRuleResourceProperties { + alertRuleResourceId: string; + alertRuleTemplateId: string; + alertRuleTemplateVersion: string; + createdWithProperties: AlertRuleCreationProperties; + creationTime: Date; + readonly provisioningState?: ResourceProvisioningState; +} + +// @public +export type CreatedByType = string; + +// @public +export type DatabaseWatcherProvisioningState = string; + +// @public +export interface Datastore { + adxClusterResourceId?: string; + kustoClusterDisplayName?: string; + kustoClusterUri: string; + kustoDatabaseName: string; + kustoDataIngestionUri: string; + kustoManagementUrl: string; + kustoOfferingType: KustoOfferingType; +} + +// @public +export interface ErrorAdditionalInfo { + readonly info?: Record; + readonly type?: string; +} + +// @public +export interface ErrorDetail { + readonly additionalInfo?: ErrorAdditionalInfo[]; + readonly code?: string; + readonly details?: ErrorDetail[]; + readonly message?: string; + readonly target?: string; +} + +// @public +export interface ErrorResponse { + error?: ErrorDetail; +} + +// @public +export interface HealthValidation extends ProxyResource { + properties?: HealthValidationProperties; +} + +// @public +export interface HealthValidationProperties { + readonly endTime: Date; + readonly issues: ValidationIssue[]; + readonly provisioningState?: ResourceProvisioningState; + readonly startTime: Date; + readonly status: ValidationStatus; +} + +// @public +export enum KnownActionType { + Internal = "Internal" +} + +// @public +export enum KnownAlertRuleCreationProperties { + CreatedWithActionGroup = "CreatedWithActionGroup", + None = "None" +} + +// @public +export enum KnownCreatedByType { + Application = "Application", + Key = "Key", + ManagedIdentity = "ManagedIdentity", + User = "User" +} + +// @public +export enum KnownDatabaseWatcherProvisioningState { + Canceled = "Canceled", + Failed = "Failed", + Succeeded = "Succeeded" +} + +// @public +export enum KnownKustoOfferingType { + Adx = "adx", + Fabric = "fabric", + Free = "free" +} + +// @public +export enum KnownManagedServiceIdentityType { + None = "None", + SystemAndUserAssigned = "SystemAssigned, UserAssigned", + SystemAssigned = "SystemAssigned", + UserAssigned = "UserAssigned" +} + +// @public +export enum KnownOrigin { + System = "system", + User = "user", + UserSystem = "user,system" +} + +// @public +export enum KnownResourceProvisioningState { + Canceled = "Canceled", + Failed = "Failed", + Succeeded = "Succeeded" +} + +// @public +export enum KnownSharedPrivateLinkResourceStatus { + Approved = "Approved", + Disconnected = "Disconnected", + Pending = "Pending", + Rejected = "Rejected" +} + +// @public +export enum KnownTargetAuthenticationType { + Aad = "Aad", + Sql = "Sql" +} + +// @public +export enum KnownValidationStatus { + Canceled = "Canceled", + Failed = "Failed", + NotStarted = "NotStarted", + Running = "Running", + Succeeded = "Succeeded", + TimedOut = "TimedOut" +} + +// @public +export enum KnownVersions { + V20250102 = "2025-01-02" +} + +// @public +export enum KnownWatcherStatus { + Deleting = "Deleting", + Running = "Running", + Starting = "Starting", + Stopped = "Stopped", + Stopping = "Stopping" +} + +// @public +export type KustoOfferingType = string; + +// @public +export type ManagedServiceIdentityType = string; + +// @public +export interface ManagedServiceIdentityV4 { + readonly principalId?: string; + readonly tenantId?: string; + type: ManagedServiceIdentityType; + userAssignedIdentities?: Record; +} + +// @public +export interface Operation { + readonly actionType?: ActionType; + display?: OperationDisplay; + readonly isDataAction?: boolean; + readonly name?: string; + readonly origin?: Origin; +} + +// @public +export interface OperationDisplay { + readonly description?: string; + readonly operation?: string; + readonly provider?: string; + readonly resource?: string; +} + +// @public +export type Origin = string; + +// @public +export interface ProxyResource extends Resource { +} + +// @public +export interface Resource { + readonly id?: string; + readonly name?: string; + readonly systemData?: SystemData; + readonly type?: string; +} + +// @public +export type ResourceProvisioningState = string; + +// @public +export interface SharedPrivateLinkResource extends ProxyResource { + properties?: SharedPrivateLinkResourceProperties; +} + +// @public +export interface SharedPrivateLinkResourceProperties { + dnsZone?: string; + groupId: string; + privateLinkResourceId: string; + readonly provisioningState?: ResourceProvisioningState; + requestMessage: string; + readonly status?: SharedPrivateLinkResourceStatus; +} + +// @public +export type SharedPrivateLinkResourceStatus = string; + +// @public +export interface SqlDbElasticPoolTargetProperties extends TargetProperties { + anchorDatabaseResourceId: string; + readIntent?: boolean; + sqlEpResourceId: string; + targetType: "SqlEp"; +} + +// @public +export interface SqlDbSingleDatabaseTargetProperties extends TargetProperties { + readIntent?: boolean; + sqlDbResourceId: string; + targetType: "SqlDb"; +} + +// @public +export interface SqlMiTargetProperties extends TargetProperties { + connectionTcpPort?: number; + readIntent?: boolean; + sqlMiResourceId: string; + targetType: "SqlMi"; +} + +// @public +export interface SystemData { + createdAt?: Date; + createdBy?: string; + createdByType?: CreatedByType; + lastModifiedAt?: Date; + lastModifiedBy?: string; + lastModifiedByType?: CreatedByType; +} + +// @public +export interface Target extends ProxyResource { + properties?: TargetPropertiesUnion; +} + +// @public +export type TargetAuthenticationType = string; + +// @public +export interface TargetProperties { + connectionServerName: string; + readonly provisioningState?: ResourceProvisioningState; + targetAuthenticationType: TargetAuthenticationType; + targetType: string; + targetVault?: VaultSecret; +} + +// @public +export type TargetPropertiesUnion = SqlDbSingleDatabaseTargetProperties | SqlDbElasticPoolTargetProperties | SqlMiTargetProperties | TargetProperties; + +// @public +export interface TrackedResource extends Resource { + location: string; + tags?: Record; +} + +// @public +export interface UserAssignedIdentity { + readonly clientId?: string; + readonly principalId?: string; +} + +// @public +export interface ValidationIssue { + readonly additionalDetails?: string; + readonly errorCode: string; + readonly errorMessage: string; + readonly recommendationMessage: string; + readonly recommendationUrl?: string; + readonly relatedResourceId?: string; + readonly relatedResourceType?: string; +} + +// @public +export type ValidationStatus = string; + +// @public +export interface VaultSecret { + akvResourceId?: string; + akvTargetPassword?: string; + akvTargetUser?: string; +} + +// @public +export interface Watcher extends TrackedResource { + identity?: ManagedServiceIdentityV4; + properties?: WatcherProperties; +} + +// @public +export interface WatcherProperties { + datastore?: Datastore; + defaultAlertRuleIdentityResourceId?: string; + readonly provisioningState?: DatabaseWatcherProvisioningState; + readonly status?: WatcherStatus; +} + +// @public +export type WatcherStatus = string; + +// @public +export interface WatcherUpdate { + identity?: ManagedServiceIdentityV4; + properties?: WatcherUpdateProperties; + tags?: Record; +} + +// @public +export interface WatcherUpdateProperties { + datastore?: Datastore; + defaultAlertRuleIdentityResourceId?: string; +} + +// (No @packageDocumentation comment for this package) + +``` diff --git a/sdk/databasewatcher/arm-databasewatcher/review/arm-databasewatcher.api.md b/sdk/databasewatcher/arm-databasewatcher/review/arm-databasewatcher.api.md new file mode 100644 index 000000000000..662e0c7b8130 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/review/arm-databasewatcher.api.md @@ -0,0 +1,562 @@ +## API Report File for "@azure/arm-databasewatcher" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts + +import { AbortSignalLike } from '@azure/abort-controller'; +import { ClientOptions } from '@azure-rest/core-client'; +import { OperationOptions } from '@azure-rest/core-client'; +import { OperationState } from '@azure/core-lro'; +import { PathUncheckedResponse } from '@azure-rest/core-client'; +import { Pipeline } from '@azure/core-rest-pipeline'; +import { PollerLike } from '@azure/core-lro'; +import { TokenCredential } from '@azure/core-auth'; + +// @public +export type ActionType = string; + +// @public +export type AlertRuleCreationProperties = string; + +// @public +export interface AlertRuleResource extends ProxyResource { + properties?: AlertRuleResourceProperties; +} + +// @public +export interface AlertRuleResourceProperties { + alertRuleResourceId: string; + alertRuleTemplateId: string; + alertRuleTemplateVersion: string; + createdWithProperties: AlertRuleCreationProperties; + creationTime: Date; + readonly provisioningState?: ResourceProvisioningState; +} + +// @public +export interface AlertRuleResourcesCreateOrUpdateOptionalParams extends OperationOptions { +} + +// @public +export interface AlertRuleResourcesDeleteOptionalParams extends OperationOptions { +} + +// @public +export interface AlertRuleResourcesGetOptionalParams extends OperationOptions { +} + +// @public +export interface AlertRuleResourcesListByParentOptionalParams extends OperationOptions { +} + +// @public +export interface AlertRuleResourcesOperations { + createOrUpdate: (resourceGroupName: string, watcherName: string, alertRuleResourceName: string, resource: AlertRuleResource, options?: AlertRuleResourcesCreateOrUpdateOptionalParams) => Promise; + delete: (resourceGroupName: string, watcherName: string, alertRuleResourceName: string, options?: AlertRuleResourcesDeleteOptionalParams) => Promise; + get: (resourceGroupName: string, watcherName: string, alertRuleResourceName: string, options?: AlertRuleResourcesGetOptionalParams) => Promise; + listByParent: (resourceGroupName: string, watcherName: string, options?: AlertRuleResourcesListByParentOptionalParams) => PagedAsyncIterableIterator; +} + +// @public +export type ContinuablePage = TPage & { + continuationToken?: string; +}; + +// @public +export type CreatedByType = string; + +// @public (undocumented) +export class DatabaseWatcherClient { + constructor(credential: TokenCredential, subscriptionId: string, options?: DatabaseWatcherClientOptionalParams); + readonly alertRuleResources: AlertRuleResourcesOperations; + readonly healthValidations: HealthValidationsOperations; + readonly operations: OperationsOperations; + readonly pipeline: Pipeline; + readonly sharedPrivateLinkResources: SharedPrivateLinkResourcesOperations; + readonly targets: TargetsOperations; + readonly watchers: WatchersOperations; +} + +// @public +export interface DatabaseWatcherClientOptionalParams extends ClientOptions { + apiVersion?: string; +} + +// @public +export type DatabaseWatcherProvisioningState = string; + +// @public +export interface Datastore { + adxClusterResourceId?: string; + kustoClusterDisplayName?: string; + kustoClusterUri: string; + kustoDatabaseName: string; + kustoDataIngestionUri: string; + kustoManagementUrl: string; + kustoOfferingType: KustoOfferingType; +} + +// @public +export interface ErrorAdditionalInfo { + readonly info?: Record; + readonly type?: string; +} + +// @public +export interface ErrorDetail { + readonly additionalInfo?: ErrorAdditionalInfo[]; + readonly code?: string; + readonly details?: ErrorDetail[]; + readonly message?: string; + readonly target?: string; +} + +// @public +export interface ErrorResponse { + error?: ErrorDetail; +} + +// @public +export interface HealthValidation extends ProxyResource { + properties?: HealthValidationProperties; +} + +// @public +export interface HealthValidationProperties { + readonly endTime: Date; + readonly issues: ValidationIssue[]; + readonly provisioningState?: ResourceProvisioningState; + readonly startTime: Date; + readonly status: ValidationStatus; +} + +// @public +export interface HealthValidationsGetOptionalParams extends OperationOptions { +} + +// @public +export interface HealthValidationsListByParentOptionalParams extends OperationOptions { +} + +// @public +export interface HealthValidationsOperations { + get: (resourceGroupName: string, watcherName: string, healthValidationName: string, options?: HealthValidationsGetOptionalParams) => Promise; + listByParent: (resourceGroupName: string, watcherName: string, options?: HealthValidationsListByParentOptionalParams) => PagedAsyncIterableIterator; + startValidation: (resourceGroupName: string, watcherName: string, healthValidationName: string, options?: HealthValidationsStartValidationOptionalParams) => PollerLike, HealthValidation>; +} + +// @public +export interface HealthValidationsStartValidationOptionalParams extends OperationOptions { + updateIntervalInMs?: number; +} + +// @public +export enum KnownActionType { + Internal = "Internal" +} + +// @public +export enum KnownAlertRuleCreationProperties { + CreatedWithActionGroup = "CreatedWithActionGroup", + None = "None" +} + +// @public +export enum KnownCreatedByType { + Application = "Application", + Key = "Key", + ManagedIdentity = "ManagedIdentity", + User = "User" +} + +// @public +export enum KnownDatabaseWatcherProvisioningState { + Canceled = "Canceled", + Failed = "Failed", + Succeeded = "Succeeded" +} + +// @public +export enum KnownKustoOfferingType { + Adx = "adx", + Fabric = "fabric", + Free = "free" +} + +// @public +export enum KnownManagedServiceIdentityType { + None = "None", + SystemAndUserAssigned = "SystemAssigned, UserAssigned", + SystemAssigned = "SystemAssigned", + UserAssigned = "UserAssigned" +} + +// @public +export enum KnownOrigin { + System = "system", + User = "user", + UserSystem = "user,system" +} + +// @public +export enum KnownResourceProvisioningState { + Canceled = "Canceled", + Failed = "Failed", + Succeeded = "Succeeded" +} + +// @public +export enum KnownSharedPrivateLinkResourceStatus { + Approved = "Approved", + Disconnected = "Disconnected", + Pending = "Pending", + Rejected = "Rejected" +} + +// @public +export enum KnownTargetAuthenticationType { + Aad = "Aad", + Sql = "Sql" +} + +// @public +export enum KnownValidationStatus { + Canceled = "Canceled", + Failed = "Failed", + NotStarted = "NotStarted", + Running = "Running", + Succeeded = "Succeeded", + TimedOut = "TimedOut" +} + +// @public +export enum KnownVersions { + V20250102 = "2025-01-02" +} + +// @public +export enum KnownWatcherStatus { + Deleting = "Deleting", + Running = "Running", + Starting = "Starting", + Stopped = "Stopped", + Stopping = "Stopping" +} + +// @public +export type KustoOfferingType = string; + +// @public +export type ManagedServiceIdentityType = string; + +// @public +export interface ManagedServiceIdentityV4 { + readonly principalId?: string; + readonly tenantId?: string; + type: ManagedServiceIdentityType; + userAssignedIdentities?: Record; +} + +// @public +export interface Operation { + readonly actionType?: ActionType; + display?: OperationDisplay; + readonly isDataAction?: boolean; + readonly name?: string; + readonly origin?: Origin; +} + +// @public +export interface OperationDisplay { + readonly description?: string; + readonly operation?: string; + readonly provider?: string; + readonly resource?: string; +} + +// @public +export interface OperationsListOptionalParams extends OperationOptions { +} + +// @public +export interface OperationsOperations { + list: (options?: OperationsListOptionalParams) => PagedAsyncIterableIterator; +} + +// @public +export type Origin = string; + +// @public +export interface PagedAsyncIterableIterator { + [Symbol.asyncIterator](): PagedAsyncIterableIterator; + byPage: (settings?: TPageSettings) => AsyncIterableIterator>; + next(): Promise>; +} + +// @public +export interface PageSettings { + continuationToken?: string; +} + +// @public +export interface ProxyResource extends Resource { +} + +// @public +export interface Resource { + readonly id?: string; + readonly name?: string; + readonly systemData?: SystemData; + readonly type?: string; +} + +// @public +export type ResourceProvisioningState = string; + +// @public +export function restorePoller(client: DatabaseWatcherClient, serializedState: string, sourceOperation: (...args: any[]) => PollerLike, TResult>, options?: RestorePollerOptions): PollerLike, TResult>; + +// @public (undocumented) +export interface RestorePollerOptions extends OperationOptions { + abortSignal?: AbortSignalLike; + processResponseBody?: (result: TResponse) => Promise; + updateIntervalInMs?: number; +} + +// @public +export interface SharedPrivateLinkResource extends ProxyResource { + properties?: SharedPrivateLinkResourceProperties; +} + +// @public +export interface SharedPrivateLinkResourceProperties { + dnsZone?: string; + groupId: string; + privateLinkResourceId: string; + readonly provisioningState?: ResourceProvisioningState; + requestMessage: string; + readonly status?: SharedPrivateLinkResourceStatus; +} + +// @public +export interface SharedPrivateLinkResourcesCreateOptionalParams extends OperationOptions { + updateIntervalInMs?: number; +} + +// @public +export interface SharedPrivateLinkResourcesDeleteOptionalParams extends OperationOptions { + updateIntervalInMs?: number; +} + +// @public +export interface SharedPrivateLinkResourcesGetOptionalParams extends OperationOptions { +} + +// @public +export interface SharedPrivateLinkResourcesListByWatcherOptionalParams extends OperationOptions { +} + +// @public +export interface SharedPrivateLinkResourcesOperations { + create: (resourceGroupName: string, watcherName: string, sharedPrivateLinkResourceName: string, resource: SharedPrivateLinkResource, options?: SharedPrivateLinkResourcesCreateOptionalParams) => PollerLike, SharedPrivateLinkResource>; + delete: (resourceGroupName: string, watcherName: string, sharedPrivateLinkResourceName: string, options?: SharedPrivateLinkResourcesDeleteOptionalParams) => PollerLike, void>; + get: (resourceGroupName: string, watcherName: string, sharedPrivateLinkResourceName: string, options?: SharedPrivateLinkResourcesGetOptionalParams) => Promise; + listByWatcher: (resourceGroupName: string, watcherName: string, options?: SharedPrivateLinkResourcesListByWatcherOptionalParams) => PagedAsyncIterableIterator; +} + +// @public +export type SharedPrivateLinkResourceStatus = string; + +// @public +export interface SqlDbElasticPoolTargetProperties extends TargetProperties { + anchorDatabaseResourceId: string; + readIntent?: boolean; + sqlEpResourceId: string; + targetType: "SqlEp"; +} + +// @public +export interface SqlDbSingleDatabaseTargetProperties extends TargetProperties { + readIntent?: boolean; + sqlDbResourceId: string; + targetType: "SqlDb"; +} + +// @public +export interface SqlMiTargetProperties extends TargetProperties { + connectionTcpPort?: number; + readIntent?: boolean; + sqlMiResourceId: string; + targetType: "SqlMi"; +} + +// @public +export interface SystemData { + createdAt?: Date; + createdBy?: string; + createdByType?: CreatedByType; + lastModifiedAt?: Date; + lastModifiedBy?: string; + lastModifiedByType?: CreatedByType; +} + +// @public +export interface Target extends ProxyResource { + properties?: TargetPropertiesUnion; +} + +// @public +export type TargetAuthenticationType = string; + +// @public +export interface TargetProperties { + connectionServerName: string; + readonly provisioningState?: ResourceProvisioningState; + targetAuthenticationType: TargetAuthenticationType; + targetType: string; + targetVault?: VaultSecret; +} + +// @public +export type TargetPropertiesUnion = SqlDbSingleDatabaseTargetProperties | SqlDbElasticPoolTargetProperties | SqlMiTargetProperties | TargetProperties; + +// @public +export interface TargetsCreateOrUpdateOptionalParams extends OperationOptions { +} + +// @public +export interface TargetsDeleteOptionalParams extends OperationOptions { +} + +// @public +export interface TargetsGetOptionalParams extends OperationOptions { +} + +// @public +export interface TargetsListByWatcherOptionalParams extends OperationOptions { +} + +// @public +export interface TargetsOperations { + createOrUpdate: (resourceGroupName: string, watcherName: string, targetName: string, resource: Target, options?: TargetsCreateOrUpdateOptionalParams) => Promise; + delete: (resourceGroupName: string, watcherName: string, targetName: string, options?: TargetsDeleteOptionalParams) => Promise; + get: (resourceGroupName: string, watcherName: string, targetName: string, options?: TargetsGetOptionalParams) => Promise; + listByWatcher: (resourceGroupName: string, watcherName: string, options?: TargetsListByWatcherOptionalParams) => PagedAsyncIterableIterator; +} + +// @public +export interface TrackedResource extends Resource { + location: string; + tags?: Record; +} + +// @public +export interface UserAssignedIdentity { + readonly clientId?: string; + readonly principalId?: string; +} + +// @public +export interface ValidationIssue { + readonly additionalDetails?: string; + readonly errorCode: string; + readonly errorMessage: string; + readonly recommendationMessage: string; + readonly recommendationUrl?: string; + readonly relatedResourceId?: string; + readonly relatedResourceType?: string; +} + +// @public +export type ValidationStatus = string; + +// @public +export interface VaultSecret { + akvResourceId?: string; + akvTargetPassword?: string; + akvTargetUser?: string; +} + +// @public +export interface Watcher extends TrackedResource { + identity?: ManagedServiceIdentityV4; + properties?: WatcherProperties; +} + +// @public +export interface WatcherProperties { + datastore?: Datastore; + defaultAlertRuleIdentityResourceId?: string; + readonly provisioningState?: DatabaseWatcherProvisioningState; + readonly status?: WatcherStatus; +} + +// @public +export interface WatchersCreateOrUpdateOptionalParams extends OperationOptions { + updateIntervalInMs?: number; +} + +// @public +export interface WatchersDeleteOptionalParams extends OperationOptions { + updateIntervalInMs?: number; +} + +// @public +export interface WatchersGetOptionalParams extends OperationOptions { +} + +// @public +export interface WatchersListByResourceGroupOptionalParams extends OperationOptions { +} + +// @public +export interface WatchersListBySubscriptionOptionalParams extends OperationOptions { +} + +// @public +export interface WatchersOperations { + createOrUpdate: (resourceGroupName: string, watcherName: string, resource: Watcher, options?: WatchersCreateOrUpdateOptionalParams) => PollerLike, Watcher>; + delete: (resourceGroupName: string, watcherName: string, options?: WatchersDeleteOptionalParams) => PollerLike, void>; + get: (resourceGroupName: string, watcherName: string, options?: WatchersGetOptionalParams) => Promise; + listByResourceGroup: (resourceGroupName: string, options?: WatchersListByResourceGroupOptionalParams) => PagedAsyncIterableIterator; + listBySubscription: (options?: WatchersListBySubscriptionOptionalParams) => PagedAsyncIterableIterator; + start: (resourceGroupName: string, watcherName: string, options?: WatchersStartOptionalParams) => PollerLike, void>; + stop: (resourceGroupName: string, watcherName: string, options?: WatchersStopOptionalParams) => PollerLike, void>; + update: (resourceGroupName: string, watcherName: string, properties: WatcherUpdate, options?: WatchersUpdateOptionalParams) => PollerLike, Watcher>; +} + +// @public +export interface WatchersStartOptionalParams extends OperationOptions { + updateIntervalInMs?: number; +} + +// @public +export interface WatchersStopOptionalParams extends OperationOptions { + updateIntervalInMs?: number; +} + +// @public +export type WatcherStatus = string; + +// @public +export interface WatchersUpdateOptionalParams extends OperationOptions { + updateIntervalInMs?: number; +} + +// @public +export interface WatcherUpdate { + identity?: ManagedServiceIdentityV4; + properties?: WatcherUpdateProperties; + tags?: Record; +} + +// @public +export interface WatcherUpdateProperties { + datastore?: Datastore; + defaultAlertRuleIdentityResourceId?: string; +} + +// (No @packageDocumentation comment for this package) + +``` diff --git a/sdk/databasewatcher/arm-databasewatcher/sample.env b/sdk/databasewatcher/arm-databasewatcher/sample.env new file mode 100644 index 000000000000..508439fc7d62 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/sample.env @@ -0,0 +1 @@ +# Feel free to add your own environment variables. \ No newline at end of file diff --git a/sdk/databasewatcher/arm-databasewatcher/samples-dev/alertRuleResourcesAlertRuleResourcesCreateOrUpdateSample.ts b/sdk/databasewatcher/arm-databasewatcher/samples-dev/alertRuleResourcesAlertRuleResourcesCreateOrUpdateSample.ts new file mode 100644 index 000000000000..eb2ee63ce721 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/samples-dev/alertRuleResourcesAlertRuleResourcesCreateOrUpdateSample.ts @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { DatabaseWatcherClient } from "@azure/arm-databasewatcher"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to create a AlertRuleResource + * + * @summary create a AlertRuleResource + * x-ms-original-file: 2025-01-02/AlertRuleResources_CreateOrUpdate_MaximumSet_Gen.json + */ +async function alertRuleResourcesCreateOrUpdateMaximumSet(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "A76F9850-996B-40B3-94D4-C98110A0EEC9"; + const client = new DatabaseWatcherClient(credential, subscriptionId); + const result = await client.alertRuleResources.createOrUpdate( + "rgWatcher", + "testWatcher", + "testAlert", + { + properties: { + alertRuleResourceId: + "/subscriptions/469DD77C-C8DB-47B7-B9E1-72D29F8C878Be/resourceGroups/rgWatcher/providers/microsoft.insights/scheduledqueryrules/alerts-demo", + creationTime: new Date("2024-07-25T15:38:47.798Z"), + alertRuleTemplateVersion: "1.0", + alertRuleTemplateId: "someTemplateId", + createdWithProperties: "CreatedWithActionGroup", + }, + }, + ); + console.log(result); +} + +async function main(): Promise { + await alertRuleResourcesCreateOrUpdateMaximumSet(); +} + +main().catch(console.error); diff --git a/sdk/databasewatcher/arm-databasewatcher/samples-dev/alertRuleResourcesAlertRuleResourcesDeleteSample.ts b/sdk/databasewatcher/arm-databasewatcher/samples-dev/alertRuleResourcesAlertRuleResourcesDeleteSample.ts new file mode 100644 index 000000000000..399f83095706 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/samples-dev/alertRuleResourcesAlertRuleResourcesDeleteSample.ts @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { DatabaseWatcherClient } from "@azure/arm-databasewatcher"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to delete a AlertRuleResource + * + * @summary delete a AlertRuleResource + * x-ms-original-file: 2025-01-02/AlertRuleResources_Delete_MaximumSet_Gen.json + */ +async function alertRuleResourcesDeleteMaximumSet(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "A76F9850-996B-40B3-94D4-C98110A0EEC9"; + const client = new DatabaseWatcherClient(credential, subscriptionId); + await client.alertRuleResources.delete("rgWatcher", "testWatcher", "testAlert"); +} + +async function main(): Promise { + await alertRuleResourcesDeleteMaximumSet(); +} + +main().catch(console.error); diff --git a/sdk/databasewatcher/arm-databasewatcher/samples-dev/alertRuleResourcesAlertRuleResourcesGetSample.ts b/sdk/databasewatcher/arm-databasewatcher/samples-dev/alertRuleResourcesAlertRuleResourcesGetSample.ts new file mode 100644 index 000000000000..cae8391b376f --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/samples-dev/alertRuleResourcesAlertRuleResourcesGetSample.ts @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { DatabaseWatcherClient } from "@azure/arm-databasewatcher"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to get a AlertRuleResource + * + * @summary get a AlertRuleResource + * x-ms-original-file: 2025-01-02/AlertRuleResources_Get_MaximumSet_Gen.json + */ +async function alertRuleResourcesGetMaximumSet(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "A76F9850-996B-40B3-94D4-C98110A0EEC9"; + const client = new DatabaseWatcherClient(credential, subscriptionId); + const result = await client.alertRuleResources.get("rgWatcher", "testWatcher", "testAlert"); + console.log(result); +} + +async function main(): Promise { + await alertRuleResourcesGetMaximumSet(); +} + +main().catch(console.error); diff --git a/sdk/databasewatcher/arm-databasewatcher/samples-dev/alertRuleResourcesAlertRuleResourcesListByParentSample.ts b/sdk/databasewatcher/arm-databasewatcher/samples-dev/alertRuleResourcesAlertRuleResourcesListByParentSample.ts new file mode 100644 index 000000000000..acf2f2a7fa9a --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/samples-dev/alertRuleResourcesAlertRuleResourcesListByParentSample.ts @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { DatabaseWatcherClient } from "@azure/arm-databasewatcher"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to list AlertRuleResource resources by Watcher + * + * @summary list AlertRuleResource resources by Watcher + * x-ms-original-file: 2025-01-02/AlertRuleResources_ListByParent_MaximumSet_Gen.json + */ +async function alertRuleResourcesListByParentMaximumSet(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "A76F9850-996B-40B3-94D4-C98110A0EEC9"; + const client = new DatabaseWatcherClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.alertRuleResources.listByParent("rgWatcher", "testWatcher")) { + resArray.push(item); + } + + console.log(resArray); +} + +async function main(): Promise { + await alertRuleResourcesListByParentMaximumSet(); +} + +main().catch(console.error); diff --git a/sdk/databasewatcher/arm-databasewatcher/samples-dev/healthValidationsHealthValidationsGetSample.ts b/sdk/databasewatcher/arm-databasewatcher/samples-dev/healthValidationsHealthValidationsGetSample.ts new file mode 100644 index 000000000000..df0020d5c665 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/samples-dev/healthValidationsHealthValidationsGetSample.ts @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { DatabaseWatcherClient } from "@azure/arm-databasewatcher"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to get a HealthValidation + * + * @summary get a HealthValidation + * x-ms-original-file: 2025-01-02/HealthValidations_Get_MaximumSet_Gen.json + */ +async function healthValidationsGetMaximumSet(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "A76F9850-996B-40B3-94D4-C98110A0EEC9"; + const client = new DatabaseWatcherClient(credential, subscriptionId); + const result = await client.healthValidations.get( + "rgWatcher", + "testWatcher", + "testHealthValidation", + ); + console.log(result); +} + +async function main(): Promise { + await healthValidationsGetMaximumSet(); +} + +main().catch(console.error); diff --git a/sdk/databasewatcher/arm-databasewatcher/samples-dev/healthValidationsHealthValidationsListByParentSample.ts b/sdk/databasewatcher/arm-databasewatcher/samples-dev/healthValidationsHealthValidationsListByParentSample.ts new file mode 100644 index 000000000000..d769830ede71 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/samples-dev/healthValidationsHealthValidationsListByParentSample.ts @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { DatabaseWatcherClient } from "@azure/arm-databasewatcher"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to list HealthValidation resources by Watcher + * + * @summary list HealthValidation resources by Watcher + * x-ms-original-file: 2025-01-02/HealthValidations_ListByParent_MaximumSet_Gen.json + */ +async function healthValidationsListByParentMaximumSet(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "A76F9850-996B-40B3-94D4-C98110A0EEC9"; + const client = new DatabaseWatcherClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.healthValidations.listByParent("rgWatcher", "testWatcher")) { + resArray.push(item); + } + + console.log(resArray); +} + +async function main(): Promise { + await healthValidationsListByParentMaximumSet(); +} + +main().catch(console.error); diff --git a/sdk/databasewatcher/arm-databasewatcher/samples-dev/healthValidationsHealthValidationsStartValidationSample.ts b/sdk/databasewatcher/arm-databasewatcher/samples-dev/healthValidationsHealthValidationsStartValidationSample.ts new file mode 100644 index 000000000000..e7e63be5159b --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/samples-dev/healthValidationsHealthValidationsStartValidationSample.ts @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { DatabaseWatcherClient } from "@azure/arm-databasewatcher"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to starts health validation for a watcher. + * + * @summary starts health validation for a watcher. + * x-ms-original-file: 2025-01-02/HealthValidations_StartValidation_MaximumSet_Gen.json + */ +async function healthValidationsStartValidationMaximumSet(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "A76F9850-996B-40B3-94D4-C98110A0EEC9"; + const client = new DatabaseWatcherClient(credential, subscriptionId); + const result = await client.healthValidations.startValidation( + "rgWatcher", + "testWatcher", + "testHealthValidation", + ); + console.log(result); +} + +async function main(): Promise { + await healthValidationsStartValidationMaximumSet(); +} + +main().catch(console.error); diff --git a/sdk/databasewatcher/arm-databasewatcher/samples-dev/operationsOperationsListSample.ts b/sdk/databasewatcher/arm-databasewatcher/samples-dev/operationsOperationsListSample.ts new file mode 100644 index 000000000000..4288b7770b29 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/samples-dev/operationsOperationsListSample.ts @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { DatabaseWatcherClient } from "@azure/arm-databasewatcher"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to list the operations for the provider + * + * @summary list the operations for the provider + * x-ms-original-file: 2025-01-02/Operations_List_MaximumSet_Gen.json + */ +async function operationsListMaximumSet(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-00000000000"; + const client = new DatabaseWatcherClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.operations.list()) { + resArray.push(item); + } + + console.log(resArray); +} + +/** + * This sample demonstrates how to list the operations for the provider + * + * @summary list the operations for the provider + * x-ms-original-file: 2025-01-02/Operations_List_MinimumSet_Gen.json + */ +async function operationsListMinimumSet(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-00000000000"; + const client = new DatabaseWatcherClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.operations.list()) { + resArray.push(item); + } + + console.log(resArray); +} + +async function main(): Promise { + await operationsListMaximumSet(); + operationsListMinimumSet(); +} + +main().catch(console.error); diff --git a/sdk/databasewatcher/arm-databasewatcher/samples-dev/sharedPrivateLinkResourcesSharedPrivateLinkResourcesCreateSample.ts b/sdk/databasewatcher/arm-databasewatcher/samples-dev/sharedPrivateLinkResourcesSharedPrivateLinkResourcesCreateSample.ts new file mode 100644 index 000000000000..e15361f6f50b --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/samples-dev/sharedPrivateLinkResourcesSharedPrivateLinkResourcesCreateSample.ts @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { DatabaseWatcherClient } from "@azure/arm-databasewatcher"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to create a SharedPrivateLinkResource + * + * @summary create a SharedPrivateLinkResource + * x-ms-original-file: 2025-01-02/SharedPrivateLinkResources_Create_MaximumSet_Gen.json + */ +async function sharedPrivateLinkResourcesCreateMaximumSet(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "49e0fbd3-75e8-44e7-96fd-5b64d9ad818d"; + const client = new DatabaseWatcherClient(credential, subscriptionId); + const result = await client.sharedPrivateLinkResources.create( + "apiTest-ddat4p", + "databasemo3ej9ih", + "monitoringh22eed", + { + properties: { + privateLinkResourceId: + "/subscriptions/49e0fbd3-75e8-44e7-96fd-5b64d9ad818d/resourceGroups/apiTest-ddat4p/providers/Microsoft.KeyVault/vaults/kvmo3ej9ih", + groupId: "vault", + requestMessage: "request message", + dnsZone: "ec3ae9d410ba", + status: "Pending", + }, + }, + ); + console.log(result); +} + +async function main(): Promise { + await sharedPrivateLinkResourcesCreateMaximumSet(); +} + +main().catch(console.error); diff --git a/sdk/databasewatcher/arm-databasewatcher/samples-dev/sharedPrivateLinkResourcesSharedPrivateLinkResourcesDeleteSample.ts b/sdk/databasewatcher/arm-databasewatcher/samples-dev/sharedPrivateLinkResourcesSharedPrivateLinkResourcesDeleteSample.ts new file mode 100644 index 000000000000..13891adaef24 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/samples-dev/sharedPrivateLinkResourcesSharedPrivateLinkResourcesDeleteSample.ts @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { DatabaseWatcherClient } from "@azure/arm-databasewatcher"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to delete a SharedPrivateLinkResource + * + * @summary delete a SharedPrivateLinkResource + * x-ms-original-file: 2025-01-02/SharedPrivateLinkResources_Delete_MaximumSet_Gen.json + */ +async function sharedPrivateLinkResourcesDeleteMaximumSet(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "49e0fbd3-75e8-44e7-96fd-5b64d9ad818d"; + const client = new DatabaseWatcherClient(credential, subscriptionId); + await client.sharedPrivateLinkResources.delete( + "apiTest-ddat4p", + "databasemo3ej9ih", + "monitoringh22eed", + ); +} + +async function main(): Promise { + await sharedPrivateLinkResourcesDeleteMaximumSet(); +} + +main().catch(console.error); diff --git a/sdk/databasewatcher/arm-databasewatcher/samples-dev/sharedPrivateLinkResourcesSharedPrivateLinkResourcesGetSample.ts b/sdk/databasewatcher/arm-databasewatcher/samples-dev/sharedPrivateLinkResourcesSharedPrivateLinkResourcesGetSample.ts new file mode 100644 index 000000000000..1126b9473c4f --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/samples-dev/sharedPrivateLinkResourcesSharedPrivateLinkResourcesGetSample.ts @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { DatabaseWatcherClient } from "@azure/arm-databasewatcher"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to get a SharedPrivateLinkResource + * + * @summary get a SharedPrivateLinkResource + * x-ms-original-file: 2025-01-02/SharedPrivateLinkResources_Get_MaximumSet_Gen.json + */ +async function sharedPrivateLinkResourcesGetMaximumSet(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "49e0fbd3-75e8-44e7-96fd-5b64d9ad818d"; + const client = new DatabaseWatcherClient(credential, subscriptionId); + const result = await client.sharedPrivateLinkResources.get( + "apiTest-ddat4p", + "databasemo3ej9ih", + "monitoringh22eed", + ); + console.log(result); +} + +async function main(): Promise { + await sharedPrivateLinkResourcesGetMaximumSet(); +} + +main().catch(console.error); diff --git a/sdk/databasewatcher/arm-databasewatcher/samples-dev/sharedPrivateLinkResourcesSharedPrivateLinkResourcesListByWatcherSample.ts b/sdk/databasewatcher/arm-databasewatcher/samples-dev/sharedPrivateLinkResourcesSharedPrivateLinkResourcesListByWatcherSample.ts new file mode 100644 index 000000000000..a0048c76814d --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/samples-dev/sharedPrivateLinkResourcesSharedPrivateLinkResourcesListByWatcherSample.ts @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { DatabaseWatcherClient } from "@azure/arm-databasewatcher"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to list SharedPrivateLinkResource resources by Watcher + * + * @summary list SharedPrivateLinkResource resources by Watcher + * x-ms-original-file: 2025-01-02/SharedPrivateLinkResources_ListByWatcher_MaximumSet_Gen.json + */ +async function sharedPrivateLinkResourcesListByWatcherMaximumSet(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "49e0fbd3-75e8-44e7-96fd-5b64d9ad818d"; + const client = new DatabaseWatcherClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.sharedPrivateLinkResources.listByWatcher( + "apiTest-ddat4p", + "databasemo3ej9ih", + )) { + resArray.push(item); + } + + console.log(resArray); +} + +async function main(): Promise { + await sharedPrivateLinkResourcesListByWatcherMaximumSet(); +} + +main().catch(console.error); diff --git a/sdk/databasewatcher/arm-databasewatcher/samples-dev/targetsTargetsCreateOrUpdateSample.ts b/sdk/databasewatcher/arm-databasewatcher/samples-dev/targetsTargetsCreateOrUpdateSample.ts new file mode 100644 index 000000000000..50f5ec3972bb --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/samples-dev/targetsTargetsCreateOrUpdateSample.ts @@ -0,0 +1,38 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { DatabaseWatcherClient } from "@azure/arm-databasewatcher"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to create a Target + * + * @summary create a Target + * x-ms-original-file: 2025-01-02/Targets_CreateOrUpdate_MaximumSet_Gen.json + */ +async function targetsCreateOrUpdateMaximumSet(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "49e0fbd3-75e8-44e7-96fd-5b64d9ad818d"; + const client = new DatabaseWatcherClient(credential, subscriptionId); + const result = await client.targets.createOrUpdate( + "apiTest-ddat4p", + "databasemo3ej9ih", + "monitoringh22eed", + { + properties: { + targetType: "SqlDb", + targetAuthenticationType: "Aad", + connectionServerName: "sqlServero1ihe2", + sqlDbResourceId: + "/subscriptions/49e0fbd3-75e8-44e7-96fd-5b64d9ad818d/resourceGroups/apiTest-ddat4p/providers/Microsoft.Sql/servers/m1/databases/m2", + }, + }, + ); + console.log(result); +} + +async function main(): Promise { + await targetsCreateOrUpdateMaximumSet(); +} + +main().catch(console.error); diff --git a/sdk/databasewatcher/arm-databasewatcher/samples-dev/targetsTargetsDeleteSample.ts b/sdk/databasewatcher/arm-databasewatcher/samples-dev/targetsTargetsDeleteSample.ts new file mode 100644 index 000000000000..79a01005415d --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/samples-dev/targetsTargetsDeleteSample.ts @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { DatabaseWatcherClient } from "@azure/arm-databasewatcher"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to delete a Target + * + * @summary delete a Target + * x-ms-original-file: 2025-01-02/Targets_Delete_MaximumSet_Gen.json + */ +async function targetsDeleteMaximumSet(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "49e0fbd3-75e8-44e7-96fd-5b64d9ad818d"; + const client = new DatabaseWatcherClient(credential, subscriptionId); + await client.targets.delete("apiTest-ddat4p", "databasemo3ej9ih", "monitoringh22eed"); +} + +async function main(): Promise { + await targetsDeleteMaximumSet(); +} + +main().catch(console.error); diff --git a/sdk/databasewatcher/arm-databasewatcher/samples-dev/targetsTargetsGetSample.ts b/sdk/databasewatcher/arm-databasewatcher/samples-dev/targetsTargetsGetSample.ts new file mode 100644 index 000000000000..610062e2e61e --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/samples-dev/targetsTargetsGetSample.ts @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { DatabaseWatcherClient } from "@azure/arm-databasewatcher"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to get a Target + * + * @summary get a Target + * x-ms-original-file: 2025-01-02/Targets_Get_MaximumSet_Gen.json + */ +async function targetsGetMaximumSet(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "49e0fbd3-75e8-44e7-96fd-5b64d9ad818d"; + const client = new DatabaseWatcherClient(credential, subscriptionId); + const result = await client.targets.get("apiTest-ddat4p", "databasemo3ej9ih", "monitoringh22eed"); + console.log(result); +} + +async function main(): Promise { + await targetsGetMaximumSet(); +} + +main().catch(console.error); diff --git a/sdk/databasewatcher/arm-databasewatcher/samples-dev/targetsTargetsListByWatcherSample.ts b/sdk/databasewatcher/arm-databasewatcher/samples-dev/targetsTargetsListByWatcherSample.ts new file mode 100644 index 000000000000..c3de02625dd5 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/samples-dev/targetsTargetsListByWatcherSample.ts @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { DatabaseWatcherClient } from "@azure/arm-databasewatcher"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to list Target resources by Watcher + * + * @summary list Target resources by Watcher + * x-ms-original-file: 2025-01-02/Targets_ListByWatcher_MaximumSet_Gen.json + */ +async function targetsListByWatcherMaximumSet(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "49e0fbd3-75e8-44e7-96fd-5b64d9ad818d"; + const client = new DatabaseWatcherClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.targets.listByWatcher("apiTest-ddat4p", "databasemo3ej9ih")) { + resArray.push(item); + } + + console.log(resArray); +} + +async function main(): Promise { + await targetsListByWatcherMaximumSet(); +} + +main().catch(console.error); diff --git a/sdk/databasewatcher/arm-databasewatcher/samples-dev/watchersWatchersCreateOrUpdateSample.ts b/sdk/databasewatcher/arm-databasewatcher/samples-dev/watchersWatchersCreateOrUpdateSample.ts new file mode 100644 index 000000000000..42a05fc922e8 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/samples-dev/watchersWatchersCreateOrUpdateSample.ts @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { DatabaseWatcherClient } from "@azure/arm-databasewatcher"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to create a Watcher + * + * @summary create a Watcher + * x-ms-original-file: 2025-01-02/Watchers_CreateOrUpdate_MaximumSet_Gen.json + */ +async function watchersCreateOrUpdateMaximumSet(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "A76F9850-996B-40B3-94D4-C98110A0EEC9"; + const client = new DatabaseWatcherClient(credential, subscriptionId); + const result = await client.watchers.createOrUpdate("rgWatcher", "testWatcher", { + properties: { + status: "Starting", + defaultAlertRuleIdentityResourceId: + "/subscriptions/469DD77C-C8DB-47B7-B9E1-72D29F8C878B/resourceGroups/rgWatcher/providers/Microsoft.ManagedIdentity/userAssignedIdentities/3pmtest", + datastore: { + adxClusterResourceId: + "/subscriptions/49e0fbd3-75e8-44e7-96fd-5b64d9ad818d/resourceGroups/apiTest/providers/Microsoft.Kusto/clusters/apiTestKusto", + kustoClusterUri: "https://kustouri-adx.eastus.kusto.windows.net", + kustoClusterDisplayName: "kustoUri-adx", + kustoDataIngestionUri: "https://ingest-kustouri-adx.eastus.kusto.windows.net", + kustoDatabaseName: "kustoDatabaseName1", + kustoManagementUrl: "https://portal.azure.com/", + kustoOfferingType: "adx", + }, + }, + identity: { type: "SystemAssigned" }, + tags: {}, + location: "eastus2", + }); + console.log(result); +} + +async function main(): Promise { + await watchersCreateOrUpdateMaximumSet(); +} + +main().catch(console.error); diff --git a/sdk/databasewatcher/arm-databasewatcher/samples-dev/watchersWatchersDeleteSample.ts b/sdk/databasewatcher/arm-databasewatcher/samples-dev/watchersWatchersDeleteSample.ts new file mode 100644 index 000000000000..8302c0e0d5e4 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/samples-dev/watchersWatchersDeleteSample.ts @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { DatabaseWatcherClient } from "@azure/arm-databasewatcher"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to delete a Watcher + * + * @summary delete a Watcher + * x-ms-original-file: 2025-01-02/Watchers_Delete_MaximumSet_Gen.json + */ +async function watchersDeleteMaximumSet(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "A76F9850-996B-40B3-94D4-C98110A0EEC9"; + const client = new DatabaseWatcherClient(credential, subscriptionId); + await client.watchers.delete("rgWatcher", "testWatcher"); +} + +async function main(): Promise { + await watchersDeleteMaximumSet(); +} + +main().catch(console.error); diff --git a/sdk/databasewatcher/arm-databasewatcher/samples-dev/watchersWatchersGetSample.ts b/sdk/databasewatcher/arm-databasewatcher/samples-dev/watchersWatchersGetSample.ts new file mode 100644 index 000000000000..1c17b9051b70 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/samples-dev/watchersWatchersGetSample.ts @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { DatabaseWatcherClient } from "@azure/arm-databasewatcher"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to get a Watcher + * + * @summary get a Watcher + * x-ms-original-file: 2025-01-02/Watchers_Get_MaximumSet_Gen.json + */ +async function watchersGetMaximumSet(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "A76F9850-996B-40B3-94D4-C98110A0EEC9"; + const client = new DatabaseWatcherClient(credential, subscriptionId); + const result = await client.watchers.get("rgWatcher", "myWatcher"); + console.log(result); +} + +async function main(): Promise { + await watchersGetMaximumSet(); +} + +main().catch(console.error); diff --git a/sdk/databasewatcher/arm-databasewatcher/samples-dev/watchersWatchersListByResourceGroupSample.ts b/sdk/databasewatcher/arm-databasewatcher/samples-dev/watchersWatchersListByResourceGroupSample.ts new file mode 100644 index 000000000000..4673e66e6f43 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/samples-dev/watchersWatchersListByResourceGroupSample.ts @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { DatabaseWatcherClient } from "@azure/arm-databasewatcher"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to list Watcher resources by resource group + * + * @summary list Watcher resources by resource group + * x-ms-original-file: 2025-01-02/Watchers_ListByResourceGroup_MaximumSet_Gen.json + */ +async function watchersListByResourceGroupMaximumSet(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "A76F9850-996B-40B3-94D4-C98110A0EEC9"; + const client = new DatabaseWatcherClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.watchers.listByResourceGroup("rgWatcher")) { + resArray.push(item); + } + + console.log(resArray); +} + +async function main(): Promise { + await watchersListByResourceGroupMaximumSet(); +} + +main().catch(console.error); diff --git a/sdk/databasewatcher/arm-databasewatcher/samples-dev/watchersWatchersListBySubscriptionSample.ts b/sdk/databasewatcher/arm-databasewatcher/samples-dev/watchersWatchersListBySubscriptionSample.ts new file mode 100644 index 000000000000..6609315bc972 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/samples-dev/watchersWatchersListBySubscriptionSample.ts @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { DatabaseWatcherClient } from "@azure/arm-databasewatcher"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to list Watcher resources by subscription ID + * + * @summary list Watcher resources by subscription ID + * x-ms-original-file: 2025-01-02/Watchers_ListBySubscription_MaximumSet_Gen.json + */ +async function watchersListBySubscriptionMaximumSet(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "A76F9850-996B-40B3-94D4-C98110A0EEC9"; + const client = new DatabaseWatcherClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.watchers.listBySubscription()) { + resArray.push(item); + } + + console.log(resArray); +} + +async function main(): Promise { + await watchersListBySubscriptionMaximumSet(); +} + +main().catch(console.error); diff --git a/sdk/databasewatcher/arm-databasewatcher/samples-dev/watchersWatchersStartSample.ts b/sdk/databasewatcher/arm-databasewatcher/samples-dev/watchersWatchersStartSample.ts new file mode 100644 index 000000000000..72a309f44ef0 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/samples-dev/watchersWatchersStartSample.ts @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { DatabaseWatcherClient } from "@azure/arm-databasewatcher"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to the action to start monitoring all targets configured for a database watcher. + * + * @summary the action to start monitoring all targets configured for a database watcher. + * x-ms-original-file: 2025-01-02/Watchers_Start_MaximumSet_Gen.json + */ +async function watchersStartMaximumSet(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "A76F9850-996B-40B3-94D4-C98110A0EEC9"; + const client = new DatabaseWatcherClient(credential, subscriptionId); + await client.watchers.start("rgWatcher", "testWatcher"); +} + +async function main(): Promise { + await watchersStartMaximumSet(); +} + +main().catch(console.error); diff --git a/sdk/databasewatcher/arm-databasewatcher/samples-dev/watchersWatchersStopSample.ts b/sdk/databasewatcher/arm-databasewatcher/samples-dev/watchersWatchersStopSample.ts new file mode 100644 index 000000000000..1902fba8b9c5 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/samples-dev/watchersWatchersStopSample.ts @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { DatabaseWatcherClient } from "@azure/arm-databasewatcher"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to the action to stop monitoring all targets configured for a database watcher. + * + * @summary the action to stop monitoring all targets configured for a database watcher. + * x-ms-original-file: 2025-01-02/Watchers_Stop_MaximumSet_Gen.json + */ +async function watchersStopMaximumSet(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "A76F9850-996B-40B3-94D4-C98110A0EEC9"; + const client = new DatabaseWatcherClient(credential, subscriptionId); + await client.watchers.stop("rgWatcher", "myWatcher"); +} + +async function main(): Promise { + await watchersStopMaximumSet(); +} + +main().catch(console.error); diff --git a/sdk/databasewatcher/arm-databasewatcher/samples-dev/watchersWatchersUpdateSample.ts b/sdk/databasewatcher/arm-databasewatcher/samples-dev/watchersWatchersUpdateSample.ts new file mode 100644 index 000000000000..20782de42a18 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/samples-dev/watchersWatchersUpdateSample.ts @@ -0,0 +1,42 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { DatabaseWatcherClient } from "@azure/arm-databasewatcher"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to update a Watcher + * + * @summary update a Watcher + * x-ms-original-file: 2025-01-02/Watchers_Update_MaximumSet_Gen.json + */ +async function watchersUpdateMaximumSet(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "A76F9850-996B-40B3-94D4-C98110A0EEC9"; + const client = new DatabaseWatcherClient(credential, subscriptionId); + const result = await client.watchers.update("rgWatcher", "testWatcher", { + identity: { type: "SystemAssigned" }, + properties: { + datastore: { + adxClusterResourceId: + "/subscriptions/49e0fbd3-75e8-44e7-96fd-5b64d9ad818d/resourceGroups/apiTest/providers/Microsoft.Kusto/clusters/apiTestKusto", + kustoClusterUri: "https://kustouri-adx.eastus.kusto.windows.net", + kustoClusterDisplayName: "kustoUri-adx", + kustoDataIngestionUri: "https://ingest-kustouri-adx.eastus.kusto.windows.net", + kustoDatabaseName: "kustoDatabaseName1", + kustoManagementUrl: "https://portal.azure.com/", + kustoOfferingType: "adx", + }, + defaultAlertRuleIdentityResourceId: + "/subscriptions/469DD77C-C8DB-47B7-B9E1-72D29F8C878B/resourceGroups/rgWatcher/providers/Microsoft.ManagedIdentity/userAssignedIdentities/newtest", + }, + tags: {}, + }); + console.log(result); +} + +async function main(): Promise { + await watchersUpdateMaximumSet(); +} + +main().catch(console.error); diff --git a/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/README.md b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/README.md new file mode 100644 index 000000000000..d8e1ebe8c54f --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/README.md @@ -0,0 +1,96 @@ +# @azure/arm-databasewatcher client library samples for JavaScript (Beta) + +These sample programs show how to use the JavaScript client libraries for @azure/arm-databasewatcher in some common scenarios. + +| **File Name** | **Description** | +| ----------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- | +| [alertRuleResourcesAlertRuleResourcesCreateOrUpdateSample.js][alertruleresourcesalertruleresourcescreateorupdatesample] | create a AlertRuleResource x-ms-original-file: 2025-01-02/AlertRuleResources_CreateOrUpdate_MaximumSet_Gen.json | +| [alertRuleResourcesAlertRuleResourcesDeleteSample.js][alertruleresourcesalertruleresourcesdeletesample] | delete a AlertRuleResource x-ms-original-file: 2025-01-02/AlertRuleResources_Delete_MaximumSet_Gen.json | +| [alertRuleResourcesAlertRuleResourcesGetSample.js][alertruleresourcesalertruleresourcesgetsample] | get a AlertRuleResource x-ms-original-file: 2025-01-02/AlertRuleResources_Get_MaximumSet_Gen.json | +| [alertRuleResourcesAlertRuleResourcesListByParentSample.js][alertruleresourcesalertruleresourceslistbyparentsample] | list AlertRuleResource resources by Watcher x-ms-original-file: 2025-01-02/AlertRuleResources_ListByParent_MaximumSet_Gen.json | +| [healthValidationsHealthValidationsGetSample.js][healthvalidationshealthvalidationsgetsample] | get a HealthValidation x-ms-original-file: 2025-01-02/HealthValidations_Get_MaximumSet_Gen.json | +| [healthValidationsHealthValidationsListByParentSample.js][healthvalidationshealthvalidationslistbyparentsample] | list HealthValidation resources by Watcher x-ms-original-file: 2025-01-02/HealthValidations_ListByParent_MaximumSet_Gen.json | +| [healthValidationsHealthValidationsStartValidationSample.js][healthvalidationshealthvalidationsstartvalidationsample] | starts health validation for a watcher. x-ms-original-file: 2025-01-02/HealthValidations_StartValidation_MaximumSet_Gen.json | +| [operationsOperationsListSample.js][operationsoperationslistsample] | list the operations for the provider x-ms-original-file: 2025-01-02/Operations_List_MaximumSet_Gen.json | +| [sharedPrivateLinkResourcesSharedPrivateLinkResourcesCreateSample.js][sharedprivatelinkresourcessharedprivatelinkresourcescreatesample] | create a SharedPrivateLinkResource x-ms-original-file: 2025-01-02/SharedPrivateLinkResources_Create_MaximumSet_Gen.json | +| [sharedPrivateLinkResourcesSharedPrivateLinkResourcesDeleteSample.js][sharedprivatelinkresourcessharedprivatelinkresourcesdeletesample] | delete a SharedPrivateLinkResource x-ms-original-file: 2025-01-02/SharedPrivateLinkResources_Delete_MaximumSet_Gen.json | +| [sharedPrivateLinkResourcesSharedPrivateLinkResourcesGetSample.js][sharedprivatelinkresourcessharedprivatelinkresourcesgetsample] | get a SharedPrivateLinkResource x-ms-original-file: 2025-01-02/SharedPrivateLinkResources_Get_MaximumSet_Gen.json | +| [sharedPrivateLinkResourcesSharedPrivateLinkResourcesListByWatcherSample.js][sharedprivatelinkresourcessharedprivatelinkresourceslistbywatchersample] | list SharedPrivateLinkResource resources by Watcher x-ms-original-file: 2025-01-02/SharedPrivateLinkResources_ListByWatcher_MaximumSet_Gen.json | +| [targetsTargetsCreateOrUpdateSample.js][targetstargetscreateorupdatesample] | create a Target x-ms-original-file: 2025-01-02/Targets_CreateOrUpdate_MaximumSet_Gen.json | +| [targetsTargetsDeleteSample.js][targetstargetsdeletesample] | delete a Target x-ms-original-file: 2025-01-02/Targets_Delete_MaximumSet_Gen.json | +| [targetsTargetsGetSample.js][targetstargetsgetsample] | get a Target x-ms-original-file: 2025-01-02/Targets_Get_MaximumSet_Gen.json | +| [targetsTargetsListByWatcherSample.js][targetstargetslistbywatchersample] | list Target resources by Watcher x-ms-original-file: 2025-01-02/Targets_ListByWatcher_MaximumSet_Gen.json | +| [watchersWatchersCreateOrUpdateSample.js][watcherswatcherscreateorupdatesample] | create a Watcher x-ms-original-file: 2025-01-02/Watchers_CreateOrUpdate_MaximumSet_Gen.json | +| [watchersWatchersDeleteSample.js][watcherswatchersdeletesample] | delete a Watcher x-ms-original-file: 2025-01-02/Watchers_Delete_MaximumSet_Gen.json | +| [watchersWatchersGetSample.js][watcherswatchersgetsample] | get a Watcher x-ms-original-file: 2025-01-02/Watchers_Get_MaximumSet_Gen.json | +| [watchersWatchersListByResourceGroupSample.js][watcherswatcherslistbyresourcegroupsample] | list Watcher resources by resource group x-ms-original-file: 2025-01-02/Watchers_ListByResourceGroup_MaximumSet_Gen.json | +| [watchersWatchersListBySubscriptionSample.js][watcherswatcherslistbysubscriptionsample] | list Watcher resources by subscription ID x-ms-original-file: 2025-01-02/Watchers_ListBySubscription_MaximumSet_Gen.json | +| [watchersWatchersStartSample.js][watcherswatchersstartsample] | the action to start monitoring all targets configured for a database watcher. x-ms-original-file: 2025-01-02/Watchers_Start_MaximumSet_Gen.json | +| [watchersWatchersStopSample.js][watcherswatchersstopsample] | the action to stop monitoring all targets configured for a database watcher. x-ms-original-file: 2025-01-02/Watchers_Stop_MaximumSet_Gen.json | +| [watchersWatchersUpdateSample.js][watcherswatchersupdatesample] | update a Watcher x-ms-original-file: 2025-01-02/Watchers_Update_MaximumSet_Gen.json | + +## Prerequisites + +The sample programs are compatible with [LTS versions of Node.js](https://github.com/nodejs/release#release-schedule). + +You need [an Azure subscription][freesub] to run these sample programs. + +Samples retrieve credentials to access the service endpoint from environment variables. Alternatively, edit the source code to include the appropriate credentials. See each individual sample for details on which environment variables/credentials it requires to function. + +Adapting the samples to run in the browser may require some additional consideration. For details, please see the [package README][package]. + +## Setup + +To run the samples using the published version of the package: + +1. Install the dependencies using `npm`: + +```bash +npm install +``` + +2. Edit the file `sample.env`, adding the correct credentials to access the Azure service and run the samples. Then rename the file from `sample.env` to just `.env`. The sample programs will read this file automatically. + +3. Run whichever samples you like (note that some samples may require additional setup, see the table above): + +```bash +node alertRuleResourcesAlertRuleResourcesCreateOrUpdateSample.js +``` + +Alternatively, run a single sample with the correct environment variables set (setting up the `.env` file is not required if you do this), for example (cross-platform): + +```bash +npx dev-tool run vendored cross-env node alertRuleResourcesAlertRuleResourcesCreateOrUpdateSample.js +``` + +## Next Steps + +Take a look at our [API Documentation][apiref] for more information about the APIs that are available in the clients. + +[alertruleresourcesalertruleresourcescreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/alertRuleResourcesAlertRuleResourcesCreateOrUpdateSample.js +[alertruleresourcesalertruleresourcesdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/alertRuleResourcesAlertRuleResourcesDeleteSample.js +[alertruleresourcesalertruleresourcesgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/alertRuleResourcesAlertRuleResourcesGetSample.js +[alertruleresourcesalertruleresourceslistbyparentsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/alertRuleResourcesAlertRuleResourcesListByParentSample.js +[healthvalidationshealthvalidationsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/healthValidationsHealthValidationsGetSample.js +[healthvalidationshealthvalidationslistbyparentsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/healthValidationsHealthValidationsListByParentSample.js +[healthvalidationshealthvalidationsstartvalidationsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/healthValidationsHealthValidationsStartValidationSample.js +[operationsoperationslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/operationsOperationsListSample.js +[sharedprivatelinkresourcessharedprivatelinkresourcescreatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/sharedPrivateLinkResourcesSharedPrivateLinkResourcesCreateSample.js +[sharedprivatelinkresourcessharedprivatelinkresourcesdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/sharedPrivateLinkResourcesSharedPrivateLinkResourcesDeleteSample.js +[sharedprivatelinkresourcessharedprivatelinkresourcesgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/sharedPrivateLinkResourcesSharedPrivateLinkResourcesGetSample.js +[sharedprivatelinkresourcessharedprivatelinkresourceslistbywatchersample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/sharedPrivateLinkResourcesSharedPrivateLinkResourcesListByWatcherSample.js +[targetstargetscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/targetsTargetsCreateOrUpdateSample.js +[targetstargetsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/targetsTargetsDeleteSample.js +[targetstargetsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/targetsTargetsGetSample.js +[targetstargetslistbywatchersample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/targetsTargetsListByWatcherSample.js +[watcherswatcherscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/watchersWatchersCreateOrUpdateSample.js +[watcherswatchersdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/watchersWatchersDeleteSample.js +[watcherswatchersgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/watchersWatchersGetSample.js +[watcherswatcherslistbyresourcegroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/watchersWatchersListByResourceGroupSample.js +[watcherswatcherslistbysubscriptionsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/watchersWatchersListBySubscriptionSample.js +[watcherswatchersstartsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/watchersWatchersStartSample.js +[watcherswatchersstopsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/watchersWatchersStopSample.js +[watcherswatchersupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/watchersWatchersUpdateSample.js +[apiref]: https://learn.microsoft.com/javascript/api/@azure/arm-databasewatcher?view=azure-node-preview +[freesub]: https://azure.microsoft.com/free/ +[package]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/databasewatcher/arm-databasewatcher/README.md diff --git a/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/alertRuleResourcesAlertRuleResourcesCreateOrUpdateSample.js b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/alertRuleResourcesAlertRuleResourcesCreateOrUpdateSample.js new file mode 100644 index 000000000000..e59f51a5a726 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/alertRuleResourcesAlertRuleResourcesCreateOrUpdateSample.js @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { DatabaseWatcherClient } = require("@azure/arm-databasewatcher"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to create a AlertRuleResource + * + * @summary create a AlertRuleResource + * x-ms-original-file: 2025-01-02/AlertRuleResources_CreateOrUpdate_MaximumSet_Gen.json + */ +async function alertRuleResourcesCreateOrUpdateMaximumSet() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "A76F9850-996B-40B3-94D4-C98110A0EEC9"; + const client = new DatabaseWatcherClient(credential, subscriptionId); + const result = await client.alertRuleResources.createOrUpdate( + "rgWatcher", + "testWatcher", + "testAlert", + { + properties: { + alertRuleResourceId: + "/subscriptions/469DD77C-C8DB-47B7-B9E1-72D29F8C878Be/resourceGroups/rgWatcher/providers/microsoft.insights/scheduledqueryrules/alerts-demo", + creationTime: new Date("2024-07-25T15:38:47.798Z"), + alertRuleTemplateVersion: "1.0", + alertRuleTemplateId: "someTemplateId", + createdWithProperties: "CreatedWithActionGroup", + }, + }, + ); + console.log(result); +} + +async function main() { + await alertRuleResourcesCreateOrUpdateMaximumSet(); +} + +main().catch(console.error); diff --git a/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/alertRuleResourcesAlertRuleResourcesDeleteSample.js b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/alertRuleResourcesAlertRuleResourcesDeleteSample.js new file mode 100644 index 000000000000..0751010f40e5 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/alertRuleResourcesAlertRuleResourcesDeleteSample.js @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { DatabaseWatcherClient } = require("@azure/arm-databasewatcher"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to delete a AlertRuleResource + * + * @summary delete a AlertRuleResource + * x-ms-original-file: 2025-01-02/AlertRuleResources_Delete_MaximumSet_Gen.json + */ +async function alertRuleResourcesDeleteMaximumSet() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "A76F9850-996B-40B3-94D4-C98110A0EEC9"; + const client = new DatabaseWatcherClient(credential, subscriptionId); + await client.alertRuleResources.delete("rgWatcher", "testWatcher", "testAlert"); +} + +async function main() { + await alertRuleResourcesDeleteMaximumSet(); +} + +main().catch(console.error); diff --git a/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/alertRuleResourcesAlertRuleResourcesGetSample.js b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/alertRuleResourcesAlertRuleResourcesGetSample.js new file mode 100644 index 000000000000..e852c433ed56 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/alertRuleResourcesAlertRuleResourcesGetSample.js @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { DatabaseWatcherClient } = require("@azure/arm-databasewatcher"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to get a AlertRuleResource + * + * @summary get a AlertRuleResource + * x-ms-original-file: 2025-01-02/AlertRuleResources_Get_MaximumSet_Gen.json + */ +async function alertRuleResourcesGetMaximumSet() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "A76F9850-996B-40B3-94D4-C98110A0EEC9"; + const client = new DatabaseWatcherClient(credential, subscriptionId); + const result = await client.alertRuleResources.get("rgWatcher", "testWatcher", "testAlert"); + console.log(result); +} + +async function main() { + await alertRuleResourcesGetMaximumSet(); +} + +main().catch(console.error); diff --git a/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/alertRuleResourcesAlertRuleResourcesListByParentSample.js b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/alertRuleResourcesAlertRuleResourcesListByParentSample.js new file mode 100644 index 000000000000..addd47fa9223 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/alertRuleResourcesAlertRuleResourcesListByParentSample.js @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { DatabaseWatcherClient } = require("@azure/arm-databasewatcher"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to list AlertRuleResource resources by Watcher + * + * @summary list AlertRuleResource resources by Watcher + * x-ms-original-file: 2025-01-02/AlertRuleResources_ListByParent_MaximumSet_Gen.json + */ +async function alertRuleResourcesListByParentMaximumSet() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "A76F9850-996B-40B3-94D4-C98110A0EEC9"; + const client = new DatabaseWatcherClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.alertRuleResources.listByParent("rgWatcher", "testWatcher")) { + resArray.push(item); + } + + console.log(resArray); +} + +async function main() { + await alertRuleResourcesListByParentMaximumSet(); +} + +main().catch(console.error); diff --git a/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/healthValidationsHealthValidationsGetSample.js b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/healthValidationsHealthValidationsGetSample.js new file mode 100644 index 000000000000..c885974986e6 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/healthValidationsHealthValidationsGetSample.js @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { DatabaseWatcherClient } = require("@azure/arm-databasewatcher"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to get a HealthValidation + * + * @summary get a HealthValidation + * x-ms-original-file: 2025-01-02/HealthValidations_Get_MaximumSet_Gen.json + */ +async function healthValidationsGetMaximumSet() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "A76F9850-996B-40B3-94D4-C98110A0EEC9"; + const client = new DatabaseWatcherClient(credential, subscriptionId); + const result = await client.healthValidations.get( + "rgWatcher", + "testWatcher", + "testHealthValidation", + ); + console.log(result); +} + +async function main() { + await healthValidationsGetMaximumSet(); +} + +main().catch(console.error); diff --git a/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/healthValidationsHealthValidationsListByParentSample.js b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/healthValidationsHealthValidationsListByParentSample.js new file mode 100644 index 000000000000..488bde6f5d25 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/healthValidationsHealthValidationsListByParentSample.js @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { DatabaseWatcherClient } = require("@azure/arm-databasewatcher"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to list HealthValidation resources by Watcher + * + * @summary list HealthValidation resources by Watcher + * x-ms-original-file: 2025-01-02/HealthValidations_ListByParent_MaximumSet_Gen.json + */ +async function healthValidationsListByParentMaximumSet() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "A76F9850-996B-40B3-94D4-C98110A0EEC9"; + const client = new DatabaseWatcherClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.healthValidations.listByParent("rgWatcher", "testWatcher")) { + resArray.push(item); + } + + console.log(resArray); +} + +async function main() { + await healthValidationsListByParentMaximumSet(); +} + +main().catch(console.error); diff --git a/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/healthValidationsHealthValidationsStartValidationSample.js b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/healthValidationsHealthValidationsStartValidationSample.js new file mode 100644 index 000000000000..3d76a17b8f08 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/healthValidationsHealthValidationsStartValidationSample.js @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { DatabaseWatcherClient } = require("@azure/arm-databasewatcher"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to starts health validation for a watcher. + * + * @summary starts health validation for a watcher. + * x-ms-original-file: 2025-01-02/HealthValidations_StartValidation_MaximumSet_Gen.json + */ +async function healthValidationsStartValidationMaximumSet() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "A76F9850-996B-40B3-94D4-C98110A0EEC9"; + const client = new DatabaseWatcherClient(credential, subscriptionId); + const result = await client.healthValidations.startValidation( + "rgWatcher", + "testWatcher", + "testHealthValidation", + ); + console.log(result); +} + +async function main() { + await healthValidationsStartValidationMaximumSet(); +} + +main().catch(console.error); diff --git a/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/operationsOperationsListSample.js b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/operationsOperationsListSample.js new file mode 100644 index 000000000000..6682d837936e --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/operationsOperationsListSample.js @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { DatabaseWatcherClient } = require("@azure/arm-databasewatcher"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to list the operations for the provider + * + * @summary list the operations for the provider + * x-ms-original-file: 2025-01-02/Operations_List_MaximumSet_Gen.json + */ +async function operationsListMaximumSet() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-00000000000"; + const client = new DatabaseWatcherClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.operations.list()) { + resArray.push(item); + } + + console.log(resArray); +} + +/** + * This sample demonstrates how to list the operations for the provider + * + * @summary list the operations for the provider + * x-ms-original-file: 2025-01-02/Operations_List_MinimumSet_Gen.json + */ +async function operationsListMinimumSet() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-00000000000"; + const client = new DatabaseWatcherClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.operations.list()) { + resArray.push(item); + } + + console.log(resArray); +} + +async function main() { + await operationsListMaximumSet(); + operationsListMinimumSet(); +} + +main().catch(console.error); diff --git a/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/package.json b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/package.json new file mode 100644 index 000000000000..aaabe55ca6d2 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/package.json @@ -0,0 +1,33 @@ +{ + "name": "@azure-samples/arm-databasewatcher-js-beta", + "private": true, + "version": "1.0.0", + "description": "@azure/arm-databasewatcher client library samples for JavaScript (Beta)", + "engines": { + "node": ">=18.0.0" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/Azure/azure-sdk-for-js.git", + "directory": "sdk/databasewatcher/arm-databasewatcher" + }, + "keywords": [ + "node", + "azure", + "cloud", + "typescript", + "browser", + "isomorphic" + ], + "author": "Microsoft Corporation", + "license": "MIT", + "bugs": { + "url": "https://github.com/Azure/azure-sdk-for-js/issues" + }, + "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/databasewatcher/arm-databasewatcher", + "dependencies": { + "@azure/arm-databasewatcher": "next", + "dotenv": "latest", + "@azure/identity": "^4.6.0" + } +} diff --git a/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/sample.env b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/sample.env new file mode 100644 index 000000000000..508439fc7d62 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/sample.env @@ -0,0 +1 @@ +# Feel free to add your own environment variables. \ No newline at end of file diff --git a/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/sharedPrivateLinkResourcesSharedPrivateLinkResourcesCreateSample.js b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/sharedPrivateLinkResourcesSharedPrivateLinkResourcesCreateSample.js new file mode 100644 index 000000000000..ab59423d2fd9 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/sharedPrivateLinkResourcesSharedPrivateLinkResourcesCreateSample.js @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { DatabaseWatcherClient } = require("@azure/arm-databasewatcher"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to create a SharedPrivateLinkResource + * + * @summary create a SharedPrivateLinkResource + * x-ms-original-file: 2025-01-02/SharedPrivateLinkResources_Create_MaximumSet_Gen.json + */ +async function sharedPrivateLinkResourcesCreateMaximumSet() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "49e0fbd3-75e8-44e7-96fd-5b64d9ad818d"; + const client = new DatabaseWatcherClient(credential, subscriptionId); + const result = await client.sharedPrivateLinkResources.create( + "apiTest-ddat4p", + "databasemo3ej9ih", + "monitoringh22eed", + { + properties: { + privateLinkResourceId: + "/subscriptions/49e0fbd3-75e8-44e7-96fd-5b64d9ad818d/resourceGroups/apiTest-ddat4p/providers/Microsoft.KeyVault/vaults/kvmo3ej9ih", + groupId: "vault", + requestMessage: "request message", + dnsZone: "ec3ae9d410ba", + status: "Pending", + }, + }, + ); + console.log(result); +} + +async function main() { + await sharedPrivateLinkResourcesCreateMaximumSet(); +} + +main().catch(console.error); diff --git a/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/sharedPrivateLinkResourcesSharedPrivateLinkResourcesDeleteSample.js b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/sharedPrivateLinkResourcesSharedPrivateLinkResourcesDeleteSample.js new file mode 100644 index 000000000000..e199644010a8 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/sharedPrivateLinkResourcesSharedPrivateLinkResourcesDeleteSample.js @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { DatabaseWatcherClient } = require("@azure/arm-databasewatcher"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to delete a SharedPrivateLinkResource + * + * @summary delete a SharedPrivateLinkResource + * x-ms-original-file: 2025-01-02/SharedPrivateLinkResources_Delete_MaximumSet_Gen.json + */ +async function sharedPrivateLinkResourcesDeleteMaximumSet() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "49e0fbd3-75e8-44e7-96fd-5b64d9ad818d"; + const client = new DatabaseWatcherClient(credential, subscriptionId); + await client.sharedPrivateLinkResources.delete( + "apiTest-ddat4p", + "databasemo3ej9ih", + "monitoringh22eed", + ); +} + +async function main() { + await sharedPrivateLinkResourcesDeleteMaximumSet(); +} + +main().catch(console.error); diff --git a/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/sharedPrivateLinkResourcesSharedPrivateLinkResourcesGetSample.js b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/sharedPrivateLinkResourcesSharedPrivateLinkResourcesGetSample.js new file mode 100644 index 000000000000..9966a6b4d8f6 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/sharedPrivateLinkResourcesSharedPrivateLinkResourcesGetSample.js @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { DatabaseWatcherClient } = require("@azure/arm-databasewatcher"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to get a SharedPrivateLinkResource + * + * @summary get a SharedPrivateLinkResource + * x-ms-original-file: 2025-01-02/SharedPrivateLinkResources_Get_MaximumSet_Gen.json + */ +async function sharedPrivateLinkResourcesGetMaximumSet() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "49e0fbd3-75e8-44e7-96fd-5b64d9ad818d"; + const client = new DatabaseWatcherClient(credential, subscriptionId); + const result = await client.sharedPrivateLinkResources.get( + "apiTest-ddat4p", + "databasemo3ej9ih", + "monitoringh22eed", + ); + console.log(result); +} + +async function main() { + await sharedPrivateLinkResourcesGetMaximumSet(); +} + +main().catch(console.error); diff --git a/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/sharedPrivateLinkResourcesSharedPrivateLinkResourcesListByWatcherSample.js b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/sharedPrivateLinkResourcesSharedPrivateLinkResourcesListByWatcherSample.js new file mode 100644 index 000000000000..fd0626910ce2 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/sharedPrivateLinkResourcesSharedPrivateLinkResourcesListByWatcherSample.js @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { DatabaseWatcherClient } = require("@azure/arm-databasewatcher"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to list SharedPrivateLinkResource resources by Watcher + * + * @summary list SharedPrivateLinkResource resources by Watcher + * x-ms-original-file: 2025-01-02/SharedPrivateLinkResources_ListByWatcher_MaximumSet_Gen.json + */ +async function sharedPrivateLinkResourcesListByWatcherMaximumSet() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "49e0fbd3-75e8-44e7-96fd-5b64d9ad818d"; + const client = new DatabaseWatcherClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.sharedPrivateLinkResources.listByWatcher( + "apiTest-ddat4p", + "databasemo3ej9ih", + )) { + resArray.push(item); + } + + console.log(resArray); +} + +async function main() { + await sharedPrivateLinkResourcesListByWatcherMaximumSet(); +} + +main().catch(console.error); diff --git a/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/targetsTargetsCreateOrUpdateSample.js b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/targetsTargetsCreateOrUpdateSample.js new file mode 100644 index 000000000000..f91631a68f93 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/targetsTargetsCreateOrUpdateSample.js @@ -0,0 +1,38 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { DatabaseWatcherClient } = require("@azure/arm-databasewatcher"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to create a Target + * + * @summary create a Target + * x-ms-original-file: 2025-01-02/Targets_CreateOrUpdate_MaximumSet_Gen.json + */ +async function targetsCreateOrUpdateMaximumSet() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "49e0fbd3-75e8-44e7-96fd-5b64d9ad818d"; + const client = new DatabaseWatcherClient(credential, subscriptionId); + const result = await client.targets.createOrUpdate( + "apiTest-ddat4p", + "databasemo3ej9ih", + "monitoringh22eed", + { + properties: { + targetType: "SqlDb", + targetAuthenticationType: "Aad", + connectionServerName: "sqlServero1ihe2", + sqlDbResourceId: + "/subscriptions/49e0fbd3-75e8-44e7-96fd-5b64d9ad818d/resourceGroups/apiTest-ddat4p/providers/Microsoft.Sql/servers/m1/databases/m2", + }, + }, + ); + console.log(result); +} + +async function main() { + await targetsCreateOrUpdateMaximumSet(); +} + +main().catch(console.error); diff --git a/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/targetsTargetsDeleteSample.js b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/targetsTargetsDeleteSample.js new file mode 100644 index 000000000000..d845bad964bd --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/targetsTargetsDeleteSample.js @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { DatabaseWatcherClient } = require("@azure/arm-databasewatcher"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to delete a Target + * + * @summary delete a Target + * x-ms-original-file: 2025-01-02/Targets_Delete_MaximumSet_Gen.json + */ +async function targetsDeleteMaximumSet() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "49e0fbd3-75e8-44e7-96fd-5b64d9ad818d"; + const client = new DatabaseWatcherClient(credential, subscriptionId); + await client.targets.delete("apiTest-ddat4p", "databasemo3ej9ih", "monitoringh22eed"); +} + +async function main() { + await targetsDeleteMaximumSet(); +} + +main().catch(console.error); diff --git a/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/targetsTargetsGetSample.js b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/targetsTargetsGetSample.js new file mode 100644 index 000000000000..c810f358abdb --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/targetsTargetsGetSample.js @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { DatabaseWatcherClient } = require("@azure/arm-databasewatcher"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to get a Target + * + * @summary get a Target + * x-ms-original-file: 2025-01-02/Targets_Get_MaximumSet_Gen.json + */ +async function targetsGetMaximumSet() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "49e0fbd3-75e8-44e7-96fd-5b64d9ad818d"; + const client = new DatabaseWatcherClient(credential, subscriptionId); + const result = await client.targets.get("apiTest-ddat4p", "databasemo3ej9ih", "monitoringh22eed"); + console.log(result); +} + +async function main() { + await targetsGetMaximumSet(); +} + +main().catch(console.error); diff --git a/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/targetsTargetsListByWatcherSample.js b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/targetsTargetsListByWatcherSample.js new file mode 100644 index 000000000000..a640e6188058 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/targetsTargetsListByWatcherSample.js @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { DatabaseWatcherClient } = require("@azure/arm-databasewatcher"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to list Target resources by Watcher + * + * @summary list Target resources by Watcher + * x-ms-original-file: 2025-01-02/Targets_ListByWatcher_MaximumSet_Gen.json + */ +async function targetsListByWatcherMaximumSet() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "49e0fbd3-75e8-44e7-96fd-5b64d9ad818d"; + const client = new DatabaseWatcherClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.targets.listByWatcher("apiTest-ddat4p", "databasemo3ej9ih")) { + resArray.push(item); + } + + console.log(resArray); +} + +async function main() { + await targetsListByWatcherMaximumSet(); +} + +main().catch(console.error); diff --git a/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/watchersWatchersCreateOrUpdateSample.js b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/watchersWatchersCreateOrUpdateSample.js new file mode 100644 index 000000000000..b43b7cfe6425 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/watchersWatchersCreateOrUpdateSample.js @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { DatabaseWatcherClient } = require("@azure/arm-databasewatcher"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to create a Watcher + * + * @summary create a Watcher + * x-ms-original-file: 2025-01-02/Watchers_CreateOrUpdate_MaximumSet_Gen.json + */ +async function watchersCreateOrUpdateMaximumSet() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "A76F9850-996B-40B3-94D4-C98110A0EEC9"; + const client = new DatabaseWatcherClient(credential, subscriptionId); + const result = await client.watchers.createOrUpdate("rgWatcher", "testWatcher", { + properties: { + status: "Starting", + defaultAlertRuleIdentityResourceId: + "/subscriptions/469DD77C-C8DB-47B7-B9E1-72D29F8C878B/resourceGroups/rgWatcher/providers/Microsoft.ManagedIdentity/userAssignedIdentities/3pmtest", + datastore: { + adxClusterResourceId: + "/subscriptions/49e0fbd3-75e8-44e7-96fd-5b64d9ad818d/resourceGroups/apiTest/providers/Microsoft.Kusto/clusters/apiTestKusto", + kustoClusterUri: "https://kustouri-adx.eastus.kusto.windows.net", + kustoClusterDisplayName: "kustoUri-adx", + kustoDataIngestionUri: "https://ingest-kustouri-adx.eastus.kusto.windows.net", + kustoDatabaseName: "kustoDatabaseName1", + kustoManagementUrl: "https://portal.azure.com/", + kustoOfferingType: "adx", + }, + }, + identity: { type: "SystemAssigned" }, + tags: {}, + location: "eastus2", + }); + console.log(result); +} + +async function main() { + await watchersCreateOrUpdateMaximumSet(); +} + +main().catch(console.error); diff --git a/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/watchersWatchersDeleteSample.js b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/watchersWatchersDeleteSample.js new file mode 100644 index 000000000000..75692472b9f8 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/watchersWatchersDeleteSample.js @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { DatabaseWatcherClient } = require("@azure/arm-databasewatcher"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to delete a Watcher + * + * @summary delete a Watcher + * x-ms-original-file: 2025-01-02/Watchers_Delete_MaximumSet_Gen.json + */ +async function watchersDeleteMaximumSet() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "A76F9850-996B-40B3-94D4-C98110A0EEC9"; + const client = new DatabaseWatcherClient(credential, subscriptionId); + await client.watchers.delete("rgWatcher", "testWatcher"); +} + +async function main() { + await watchersDeleteMaximumSet(); +} + +main().catch(console.error); diff --git a/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/watchersWatchersGetSample.js b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/watchersWatchersGetSample.js new file mode 100644 index 000000000000..a21c8c983d2f --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/watchersWatchersGetSample.js @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { DatabaseWatcherClient } = require("@azure/arm-databasewatcher"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to get a Watcher + * + * @summary get a Watcher + * x-ms-original-file: 2025-01-02/Watchers_Get_MaximumSet_Gen.json + */ +async function watchersGetMaximumSet() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "A76F9850-996B-40B3-94D4-C98110A0EEC9"; + const client = new DatabaseWatcherClient(credential, subscriptionId); + const result = await client.watchers.get("rgWatcher", "myWatcher"); + console.log(result); +} + +async function main() { + await watchersGetMaximumSet(); +} + +main().catch(console.error); diff --git a/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/watchersWatchersListByResourceGroupSample.js b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/watchersWatchersListByResourceGroupSample.js new file mode 100644 index 000000000000..a6cd20aaf41b --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/watchersWatchersListByResourceGroupSample.js @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { DatabaseWatcherClient } = require("@azure/arm-databasewatcher"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to list Watcher resources by resource group + * + * @summary list Watcher resources by resource group + * x-ms-original-file: 2025-01-02/Watchers_ListByResourceGroup_MaximumSet_Gen.json + */ +async function watchersListByResourceGroupMaximumSet() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "A76F9850-996B-40B3-94D4-C98110A0EEC9"; + const client = new DatabaseWatcherClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.watchers.listByResourceGroup("rgWatcher")) { + resArray.push(item); + } + + console.log(resArray); +} + +async function main() { + await watchersListByResourceGroupMaximumSet(); +} + +main().catch(console.error); diff --git a/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/watchersWatchersListBySubscriptionSample.js b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/watchersWatchersListBySubscriptionSample.js new file mode 100644 index 000000000000..cdb0f9d52c08 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/watchersWatchersListBySubscriptionSample.js @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { DatabaseWatcherClient } = require("@azure/arm-databasewatcher"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to list Watcher resources by subscription ID + * + * @summary list Watcher resources by subscription ID + * x-ms-original-file: 2025-01-02/Watchers_ListBySubscription_MaximumSet_Gen.json + */ +async function watchersListBySubscriptionMaximumSet() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "A76F9850-996B-40B3-94D4-C98110A0EEC9"; + const client = new DatabaseWatcherClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.watchers.listBySubscription()) { + resArray.push(item); + } + + console.log(resArray); +} + +async function main() { + await watchersListBySubscriptionMaximumSet(); +} + +main().catch(console.error); diff --git a/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/watchersWatchersStartSample.js b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/watchersWatchersStartSample.js new file mode 100644 index 000000000000..c999eef97945 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/watchersWatchersStartSample.js @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { DatabaseWatcherClient } = require("@azure/arm-databasewatcher"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to the action to start monitoring all targets configured for a database watcher. + * + * @summary the action to start monitoring all targets configured for a database watcher. + * x-ms-original-file: 2025-01-02/Watchers_Start_MaximumSet_Gen.json + */ +async function watchersStartMaximumSet() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "A76F9850-996B-40B3-94D4-C98110A0EEC9"; + const client = new DatabaseWatcherClient(credential, subscriptionId); + await client.watchers.start("rgWatcher", "testWatcher"); +} + +async function main() { + await watchersStartMaximumSet(); +} + +main().catch(console.error); diff --git a/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/watchersWatchersStopSample.js b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/watchersWatchersStopSample.js new file mode 100644 index 000000000000..1d858411a6bc --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/watchersWatchersStopSample.js @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { DatabaseWatcherClient } = require("@azure/arm-databasewatcher"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to the action to stop monitoring all targets configured for a database watcher. + * + * @summary the action to stop monitoring all targets configured for a database watcher. + * x-ms-original-file: 2025-01-02/Watchers_Stop_MaximumSet_Gen.json + */ +async function watchersStopMaximumSet() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "A76F9850-996B-40B3-94D4-C98110A0EEC9"; + const client = new DatabaseWatcherClient(credential, subscriptionId); + await client.watchers.stop("rgWatcher", "myWatcher"); +} + +async function main() { + await watchersStopMaximumSet(); +} + +main().catch(console.error); diff --git a/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/watchersWatchersUpdateSample.js b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/watchersWatchersUpdateSample.js new file mode 100644 index 000000000000..ba9988b4b854 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/javascript/watchersWatchersUpdateSample.js @@ -0,0 +1,42 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { DatabaseWatcherClient } = require("@azure/arm-databasewatcher"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to update a Watcher + * + * @summary update a Watcher + * x-ms-original-file: 2025-01-02/Watchers_Update_MaximumSet_Gen.json + */ +async function watchersUpdateMaximumSet() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "A76F9850-996B-40B3-94D4-C98110A0EEC9"; + const client = new DatabaseWatcherClient(credential, subscriptionId); + const result = await client.watchers.update("rgWatcher", "testWatcher", { + identity: { type: "SystemAssigned" }, + properties: { + datastore: { + adxClusterResourceId: + "/subscriptions/49e0fbd3-75e8-44e7-96fd-5b64d9ad818d/resourceGroups/apiTest/providers/Microsoft.Kusto/clusters/apiTestKusto", + kustoClusterUri: "https://kustouri-adx.eastus.kusto.windows.net", + kustoClusterDisplayName: "kustoUri-adx", + kustoDataIngestionUri: "https://ingest-kustouri-adx.eastus.kusto.windows.net", + kustoDatabaseName: "kustoDatabaseName1", + kustoManagementUrl: "https://portal.azure.com/", + kustoOfferingType: "adx", + }, + defaultAlertRuleIdentityResourceId: + "/subscriptions/469DD77C-C8DB-47B7-B9E1-72D29F8C878B/resourceGroups/rgWatcher/providers/Microsoft.ManagedIdentity/userAssignedIdentities/newtest", + }, + tags: {}, + }); + console.log(result); +} + +async function main() { + await watchersUpdateMaximumSet(); +} + +main().catch(console.error); diff --git a/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/README.md b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/README.md new file mode 100644 index 000000000000..cea66969f4dc --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/README.md @@ -0,0 +1,109 @@ +# @azure/arm-databasewatcher client library samples for TypeScript (Beta) + +These sample programs show how to use the TypeScript client libraries for @azure/arm-databasewatcher in some common scenarios. + +| **File Name** | **Description** | +| ----------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- | +| [alertRuleResourcesAlertRuleResourcesCreateOrUpdateSample.ts][alertruleresourcesalertruleresourcescreateorupdatesample] | create a AlertRuleResource x-ms-original-file: 2025-01-02/AlertRuleResources_CreateOrUpdate_MaximumSet_Gen.json | +| [alertRuleResourcesAlertRuleResourcesDeleteSample.ts][alertruleresourcesalertruleresourcesdeletesample] | delete a AlertRuleResource x-ms-original-file: 2025-01-02/AlertRuleResources_Delete_MaximumSet_Gen.json | +| [alertRuleResourcesAlertRuleResourcesGetSample.ts][alertruleresourcesalertruleresourcesgetsample] | get a AlertRuleResource x-ms-original-file: 2025-01-02/AlertRuleResources_Get_MaximumSet_Gen.json | +| [alertRuleResourcesAlertRuleResourcesListByParentSample.ts][alertruleresourcesalertruleresourceslistbyparentsample] | list AlertRuleResource resources by Watcher x-ms-original-file: 2025-01-02/AlertRuleResources_ListByParent_MaximumSet_Gen.json | +| [healthValidationsHealthValidationsGetSample.ts][healthvalidationshealthvalidationsgetsample] | get a HealthValidation x-ms-original-file: 2025-01-02/HealthValidations_Get_MaximumSet_Gen.json | +| [healthValidationsHealthValidationsListByParentSample.ts][healthvalidationshealthvalidationslistbyparentsample] | list HealthValidation resources by Watcher x-ms-original-file: 2025-01-02/HealthValidations_ListByParent_MaximumSet_Gen.json | +| [healthValidationsHealthValidationsStartValidationSample.ts][healthvalidationshealthvalidationsstartvalidationsample] | starts health validation for a watcher. x-ms-original-file: 2025-01-02/HealthValidations_StartValidation_MaximumSet_Gen.json | +| [operationsOperationsListSample.ts][operationsoperationslistsample] | list the operations for the provider x-ms-original-file: 2025-01-02/Operations_List_MaximumSet_Gen.json | +| [sharedPrivateLinkResourcesSharedPrivateLinkResourcesCreateSample.ts][sharedprivatelinkresourcessharedprivatelinkresourcescreatesample] | create a SharedPrivateLinkResource x-ms-original-file: 2025-01-02/SharedPrivateLinkResources_Create_MaximumSet_Gen.json | +| [sharedPrivateLinkResourcesSharedPrivateLinkResourcesDeleteSample.ts][sharedprivatelinkresourcessharedprivatelinkresourcesdeletesample] | delete a SharedPrivateLinkResource x-ms-original-file: 2025-01-02/SharedPrivateLinkResources_Delete_MaximumSet_Gen.json | +| [sharedPrivateLinkResourcesSharedPrivateLinkResourcesGetSample.ts][sharedprivatelinkresourcessharedprivatelinkresourcesgetsample] | get a SharedPrivateLinkResource x-ms-original-file: 2025-01-02/SharedPrivateLinkResources_Get_MaximumSet_Gen.json | +| [sharedPrivateLinkResourcesSharedPrivateLinkResourcesListByWatcherSample.ts][sharedprivatelinkresourcessharedprivatelinkresourceslistbywatchersample] | list SharedPrivateLinkResource resources by Watcher x-ms-original-file: 2025-01-02/SharedPrivateLinkResources_ListByWatcher_MaximumSet_Gen.json | +| [targetsTargetsCreateOrUpdateSample.ts][targetstargetscreateorupdatesample] | create a Target x-ms-original-file: 2025-01-02/Targets_CreateOrUpdate_MaximumSet_Gen.json | +| [targetsTargetsDeleteSample.ts][targetstargetsdeletesample] | delete a Target x-ms-original-file: 2025-01-02/Targets_Delete_MaximumSet_Gen.json | +| [targetsTargetsGetSample.ts][targetstargetsgetsample] | get a Target x-ms-original-file: 2025-01-02/Targets_Get_MaximumSet_Gen.json | +| [targetsTargetsListByWatcherSample.ts][targetstargetslistbywatchersample] | list Target resources by Watcher x-ms-original-file: 2025-01-02/Targets_ListByWatcher_MaximumSet_Gen.json | +| [watchersWatchersCreateOrUpdateSample.ts][watcherswatcherscreateorupdatesample] | create a Watcher x-ms-original-file: 2025-01-02/Watchers_CreateOrUpdate_MaximumSet_Gen.json | +| [watchersWatchersDeleteSample.ts][watcherswatchersdeletesample] | delete a Watcher x-ms-original-file: 2025-01-02/Watchers_Delete_MaximumSet_Gen.json | +| [watchersWatchersGetSample.ts][watcherswatchersgetsample] | get a Watcher x-ms-original-file: 2025-01-02/Watchers_Get_MaximumSet_Gen.json | +| [watchersWatchersListByResourceGroupSample.ts][watcherswatcherslistbyresourcegroupsample] | list Watcher resources by resource group x-ms-original-file: 2025-01-02/Watchers_ListByResourceGroup_MaximumSet_Gen.json | +| [watchersWatchersListBySubscriptionSample.ts][watcherswatcherslistbysubscriptionsample] | list Watcher resources by subscription ID x-ms-original-file: 2025-01-02/Watchers_ListBySubscription_MaximumSet_Gen.json | +| [watchersWatchersStartSample.ts][watcherswatchersstartsample] | the action to start monitoring all targets configured for a database watcher. x-ms-original-file: 2025-01-02/Watchers_Start_MaximumSet_Gen.json | +| [watchersWatchersStopSample.ts][watcherswatchersstopsample] | the action to stop monitoring all targets configured for a database watcher. x-ms-original-file: 2025-01-02/Watchers_Stop_MaximumSet_Gen.json | +| [watchersWatchersUpdateSample.ts][watcherswatchersupdatesample] | update a Watcher x-ms-original-file: 2025-01-02/Watchers_Update_MaximumSet_Gen.json | + +## Prerequisites + +The sample programs are compatible with [LTS versions of Node.js](https://github.com/nodejs/release#release-schedule). + +Before running the samples in Node, they must be compiled to JavaScript using the TypeScript compiler. For more information on TypeScript, see the [TypeScript documentation][typescript]. Install the TypeScript compiler using: + +```bash +npm install -g typescript +``` + +You need [an Azure subscription][freesub] to run these sample programs. + +Samples retrieve credentials to access the service endpoint from environment variables. Alternatively, edit the source code to include the appropriate credentials. See each individual sample for details on which environment variables/credentials it requires to function. + +Adapting the samples to run in the browser may require some additional consideration. For details, please see the [package README][package]. + +## Setup + +To run the samples using the published version of the package: + +1. Install the dependencies using `npm`: + +```bash +npm install +``` + +2. Compile the samples: + +```bash +npm run build +``` + +3. Edit the file `sample.env`, adding the correct credentials to access the Azure service and run the samples. Then rename the file from `sample.env` to just `.env`. The sample programs will read this file automatically. + +4. Run whichever samples you like (note that some samples may require additional setup, see the table above): + +```bash +node dist/alertRuleResourcesAlertRuleResourcesCreateOrUpdateSample.js +``` + +Alternatively, run a single sample with the correct environment variables set (setting up the `.env` file is not required if you do this), for example (cross-platform): + +```bash +npx dev-tool run vendored cross-env node dist/alertRuleResourcesAlertRuleResourcesCreateOrUpdateSample.js +``` + +## Next Steps + +Take a look at our [API Documentation][apiref] for more information about the APIs that are available in the clients. + +[alertruleresourcesalertruleresourcescreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/alertRuleResourcesAlertRuleResourcesCreateOrUpdateSample.ts +[alertruleresourcesalertruleresourcesdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/alertRuleResourcesAlertRuleResourcesDeleteSample.ts +[alertruleresourcesalertruleresourcesgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/alertRuleResourcesAlertRuleResourcesGetSample.ts +[alertruleresourcesalertruleresourceslistbyparentsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/alertRuleResourcesAlertRuleResourcesListByParentSample.ts +[healthvalidationshealthvalidationsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/healthValidationsHealthValidationsGetSample.ts +[healthvalidationshealthvalidationslistbyparentsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/healthValidationsHealthValidationsListByParentSample.ts +[healthvalidationshealthvalidationsstartvalidationsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/healthValidationsHealthValidationsStartValidationSample.ts +[operationsoperationslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/operationsOperationsListSample.ts +[sharedprivatelinkresourcessharedprivatelinkresourcescreatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/sharedPrivateLinkResourcesSharedPrivateLinkResourcesCreateSample.ts +[sharedprivatelinkresourcessharedprivatelinkresourcesdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/sharedPrivateLinkResourcesSharedPrivateLinkResourcesDeleteSample.ts +[sharedprivatelinkresourcessharedprivatelinkresourcesgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/sharedPrivateLinkResourcesSharedPrivateLinkResourcesGetSample.ts +[sharedprivatelinkresourcessharedprivatelinkresourceslistbywatchersample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/sharedPrivateLinkResourcesSharedPrivateLinkResourcesListByWatcherSample.ts +[targetstargetscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/targetsTargetsCreateOrUpdateSample.ts +[targetstargetsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/targetsTargetsDeleteSample.ts +[targetstargetsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/targetsTargetsGetSample.ts +[targetstargetslistbywatchersample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/targetsTargetsListByWatcherSample.ts +[watcherswatcherscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/watchersWatchersCreateOrUpdateSample.ts +[watcherswatchersdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/watchersWatchersDeleteSample.ts +[watcherswatchersgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/watchersWatchersGetSample.ts +[watcherswatcherslistbyresourcegroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/watchersWatchersListByResourceGroupSample.ts +[watcherswatcherslistbysubscriptionsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/watchersWatchersListBySubscriptionSample.ts +[watcherswatchersstartsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/watchersWatchersStartSample.ts +[watcherswatchersstopsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/watchersWatchersStopSample.ts +[watcherswatchersupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/watchersWatchersUpdateSample.ts +[apiref]: https://learn.microsoft.com/javascript/api/@azure/arm-databasewatcher?view=azure-node-preview +[freesub]: https://azure.microsoft.com/free/ +[package]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/databasewatcher/arm-databasewatcher/README.md +[typescript]: https://www.typescriptlang.org/docs/home.html diff --git a/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/package.json b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/package.json new file mode 100644 index 000000000000..6a7348bf80c6 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/package.json @@ -0,0 +1,42 @@ +{ + "name": "@azure-samples/arm-databasewatcher-ts-beta", + "private": true, + "version": "1.0.0", + "description": "@azure/arm-databasewatcher client library samples for TypeScript (Beta)", + "engines": { + "node": ">=18.0.0" + }, + "scripts": { + "build": "tsc", + "prebuild": "rimraf dist/" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/Azure/azure-sdk-for-js.git", + "directory": "sdk/databasewatcher/arm-databasewatcher" + }, + "keywords": [ + "node", + "azure", + "cloud", + "typescript", + "browser", + "isomorphic" + ], + "author": "Microsoft Corporation", + "license": "MIT", + "bugs": { + "url": "https://github.com/Azure/azure-sdk-for-js/issues" + }, + "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/databasewatcher/arm-databasewatcher", + "dependencies": { + "@azure/arm-databasewatcher": "next", + "dotenv": "latest", + "@azure/identity": "^4.6.0" + }, + "devDependencies": { + "@types/node": "^18.0.0", + "typescript": "~5.7.2", + "rimraf": "latest" + } +} diff --git a/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/sample.env b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/sample.env new file mode 100644 index 000000000000..508439fc7d62 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/sample.env @@ -0,0 +1 @@ +# Feel free to add your own environment variables. \ No newline at end of file diff --git a/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/alertRuleResourcesAlertRuleResourcesCreateOrUpdateSample.ts b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/alertRuleResourcesAlertRuleResourcesCreateOrUpdateSample.ts new file mode 100644 index 000000000000..eb2ee63ce721 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/alertRuleResourcesAlertRuleResourcesCreateOrUpdateSample.ts @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { DatabaseWatcherClient } from "@azure/arm-databasewatcher"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to create a AlertRuleResource + * + * @summary create a AlertRuleResource + * x-ms-original-file: 2025-01-02/AlertRuleResources_CreateOrUpdate_MaximumSet_Gen.json + */ +async function alertRuleResourcesCreateOrUpdateMaximumSet(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "A76F9850-996B-40B3-94D4-C98110A0EEC9"; + const client = new DatabaseWatcherClient(credential, subscriptionId); + const result = await client.alertRuleResources.createOrUpdate( + "rgWatcher", + "testWatcher", + "testAlert", + { + properties: { + alertRuleResourceId: + "/subscriptions/469DD77C-C8DB-47B7-B9E1-72D29F8C878Be/resourceGroups/rgWatcher/providers/microsoft.insights/scheduledqueryrules/alerts-demo", + creationTime: new Date("2024-07-25T15:38:47.798Z"), + alertRuleTemplateVersion: "1.0", + alertRuleTemplateId: "someTemplateId", + createdWithProperties: "CreatedWithActionGroup", + }, + }, + ); + console.log(result); +} + +async function main(): Promise { + await alertRuleResourcesCreateOrUpdateMaximumSet(); +} + +main().catch(console.error); diff --git a/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/alertRuleResourcesAlertRuleResourcesDeleteSample.ts b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/alertRuleResourcesAlertRuleResourcesDeleteSample.ts new file mode 100644 index 000000000000..d9410486411d --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/alertRuleResourcesAlertRuleResourcesDeleteSample.ts @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { DatabaseWatcherClient } from "@azure/arm-databasewatcher"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to delete a AlertRuleResource + * + * @summary delete a AlertRuleResource + * x-ms-original-file: 2025-01-02/AlertRuleResources_Delete_MaximumSet_Gen.json + */ +async function alertRuleResourcesDeleteMaximumSet(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "A76F9850-996B-40B3-94D4-C98110A0EEC9"; + const client = new DatabaseWatcherClient(credential, subscriptionId); + await client.alertRuleResources.delete( + "rgWatcher", + "testWatcher", + "testAlert", + ); +} + +async function main(): Promise { + await alertRuleResourcesDeleteMaximumSet(); +} + +main().catch(console.error); diff --git a/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/alertRuleResourcesAlertRuleResourcesGetSample.ts b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/alertRuleResourcesAlertRuleResourcesGetSample.ts new file mode 100644 index 000000000000..72368622662d --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/alertRuleResourcesAlertRuleResourcesGetSample.ts @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { DatabaseWatcherClient } from "@azure/arm-databasewatcher"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to get a AlertRuleResource + * + * @summary get a AlertRuleResource + * x-ms-original-file: 2025-01-02/AlertRuleResources_Get_MaximumSet_Gen.json + */ +async function alertRuleResourcesGetMaximumSet(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "A76F9850-996B-40B3-94D4-C98110A0EEC9"; + const client = new DatabaseWatcherClient(credential, subscriptionId); + const result = await client.alertRuleResources.get( + "rgWatcher", + "testWatcher", + "testAlert", + ); + console.log(result); +} + +async function main(): Promise { + await alertRuleResourcesGetMaximumSet(); +} + +main().catch(console.error); diff --git a/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/alertRuleResourcesAlertRuleResourcesListByParentSample.ts b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/alertRuleResourcesAlertRuleResourcesListByParentSample.ts new file mode 100644 index 000000000000..402ea6ccfa03 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/alertRuleResourcesAlertRuleResourcesListByParentSample.ts @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { DatabaseWatcherClient } from "@azure/arm-databasewatcher"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to list AlertRuleResource resources by Watcher + * + * @summary list AlertRuleResource resources by Watcher + * x-ms-original-file: 2025-01-02/AlertRuleResources_ListByParent_MaximumSet_Gen.json + */ +async function alertRuleResourcesListByParentMaximumSet(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "A76F9850-996B-40B3-94D4-C98110A0EEC9"; + const client = new DatabaseWatcherClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.alertRuleResources.listByParent( + "rgWatcher", + "testWatcher", + )) { + resArray.push(item); + } + + console.log(resArray); +} + +async function main(): Promise { + await alertRuleResourcesListByParentMaximumSet(); +} + +main().catch(console.error); diff --git a/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/healthValidationsHealthValidationsGetSample.ts b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/healthValidationsHealthValidationsGetSample.ts new file mode 100644 index 000000000000..df0020d5c665 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/healthValidationsHealthValidationsGetSample.ts @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { DatabaseWatcherClient } from "@azure/arm-databasewatcher"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to get a HealthValidation + * + * @summary get a HealthValidation + * x-ms-original-file: 2025-01-02/HealthValidations_Get_MaximumSet_Gen.json + */ +async function healthValidationsGetMaximumSet(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "A76F9850-996B-40B3-94D4-C98110A0EEC9"; + const client = new DatabaseWatcherClient(credential, subscriptionId); + const result = await client.healthValidations.get( + "rgWatcher", + "testWatcher", + "testHealthValidation", + ); + console.log(result); +} + +async function main(): Promise { + await healthValidationsGetMaximumSet(); +} + +main().catch(console.error); diff --git a/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/healthValidationsHealthValidationsListByParentSample.ts b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/healthValidationsHealthValidationsListByParentSample.ts new file mode 100644 index 000000000000..eaffff37e1f1 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/healthValidationsHealthValidationsListByParentSample.ts @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { DatabaseWatcherClient } from "@azure/arm-databasewatcher"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to list HealthValidation resources by Watcher + * + * @summary list HealthValidation resources by Watcher + * x-ms-original-file: 2025-01-02/HealthValidations_ListByParent_MaximumSet_Gen.json + */ +async function healthValidationsListByParentMaximumSet(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "A76F9850-996B-40B3-94D4-C98110A0EEC9"; + const client = new DatabaseWatcherClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.healthValidations.listByParent( + "rgWatcher", + "testWatcher", + )) { + resArray.push(item); + } + + console.log(resArray); +} + +async function main(): Promise { + await healthValidationsListByParentMaximumSet(); +} + +main().catch(console.error); diff --git a/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/healthValidationsHealthValidationsStartValidationSample.ts b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/healthValidationsHealthValidationsStartValidationSample.ts new file mode 100644 index 000000000000..e7e63be5159b --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/healthValidationsHealthValidationsStartValidationSample.ts @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { DatabaseWatcherClient } from "@azure/arm-databasewatcher"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to starts health validation for a watcher. + * + * @summary starts health validation for a watcher. + * x-ms-original-file: 2025-01-02/HealthValidations_StartValidation_MaximumSet_Gen.json + */ +async function healthValidationsStartValidationMaximumSet(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "A76F9850-996B-40B3-94D4-C98110A0EEC9"; + const client = new DatabaseWatcherClient(credential, subscriptionId); + const result = await client.healthValidations.startValidation( + "rgWatcher", + "testWatcher", + "testHealthValidation", + ); + console.log(result); +} + +async function main(): Promise { + await healthValidationsStartValidationMaximumSet(); +} + +main().catch(console.error); diff --git a/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/operationsOperationsListSample.ts b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/operationsOperationsListSample.ts new file mode 100644 index 000000000000..4288b7770b29 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/operationsOperationsListSample.ts @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { DatabaseWatcherClient } from "@azure/arm-databasewatcher"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to list the operations for the provider + * + * @summary list the operations for the provider + * x-ms-original-file: 2025-01-02/Operations_List_MaximumSet_Gen.json + */ +async function operationsListMaximumSet(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-00000000000"; + const client = new DatabaseWatcherClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.operations.list()) { + resArray.push(item); + } + + console.log(resArray); +} + +/** + * This sample demonstrates how to list the operations for the provider + * + * @summary list the operations for the provider + * x-ms-original-file: 2025-01-02/Operations_List_MinimumSet_Gen.json + */ +async function operationsListMinimumSet(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-00000000000"; + const client = new DatabaseWatcherClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.operations.list()) { + resArray.push(item); + } + + console.log(resArray); +} + +async function main(): Promise { + await operationsListMaximumSet(); + operationsListMinimumSet(); +} + +main().catch(console.error); diff --git a/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/sharedPrivateLinkResourcesSharedPrivateLinkResourcesCreateSample.ts b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/sharedPrivateLinkResourcesSharedPrivateLinkResourcesCreateSample.ts new file mode 100644 index 000000000000..e15361f6f50b --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/sharedPrivateLinkResourcesSharedPrivateLinkResourcesCreateSample.ts @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { DatabaseWatcherClient } from "@azure/arm-databasewatcher"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to create a SharedPrivateLinkResource + * + * @summary create a SharedPrivateLinkResource + * x-ms-original-file: 2025-01-02/SharedPrivateLinkResources_Create_MaximumSet_Gen.json + */ +async function sharedPrivateLinkResourcesCreateMaximumSet(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "49e0fbd3-75e8-44e7-96fd-5b64d9ad818d"; + const client = new DatabaseWatcherClient(credential, subscriptionId); + const result = await client.sharedPrivateLinkResources.create( + "apiTest-ddat4p", + "databasemo3ej9ih", + "monitoringh22eed", + { + properties: { + privateLinkResourceId: + "/subscriptions/49e0fbd3-75e8-44e7-96fd-5b64d9ad818d/resourceGroups/apiTest-ddat4p/providers/Microsoft.KeyVault/vaults/kvmo3ej9ih", + groupId: "vault", + requestMessage: "request message", + dnsZone: "ec3ae9d410ba", + status: "Pending", + }, + }, + ); + console.log(result); +} + +async function main(): Promise { + await sharedPrivateLinkResourcesCreateMaximumSet(); +} + +main().catch(console.error); diff --git a/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/sharedPrivateLinkResourcesSharedPrivateLinkResourcesDeleteSample.ts b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/sharedPrivateLinkResourcesSharedPrivateLinkResourcesDeleteSample.ts new file mode 100644 index 000000000000..13891adaef24 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/sharedPrivateLinkResourcesSharedPrivateLinkResourcesDeleteSample.ts @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { DatabaseWatcherClient } from "@azure/arm-databasewatcher"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to delete a SharedPrivateLinkResource + * + * @summary delete a SharedPrivateLinkResource + * x-ms-original-file: 2025-01-02/SharedPrivateLinkResources_Delete_MaximumSet_Gen.json + */ +async function sharedPrivateLinkResourcesDeleteMaximumSet(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "49e0fbd3-75e8-44e7-96fd-5b64d9ad818d"; + const client = new DatabaseWatcherClient(credential, subscriptionId); + await client.sharedPrivateLinkResources.delete( + "apiTest-ddat4p", + "databasemo3ej9ih", + "monitoringh22eed", + ); +} + +async function main(): Promise { + await sharedPrivateLinkResourcesDeleteMaximumSet(); +} + +main().catch(console.error); diff --git a/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/sharedPrivateLinkResourcesSharedPrivateLinkResourcesGetSample.ts b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/sharedPrivateLinkResourcesSharedPrivateLinkResourcesGetSample.ts new file mode 100644 index 000000000000..1126b9473c4f --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/sharedPrivateLinkResourcesSharedPrivateLinkResourcesGetSample.ts @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { DatabaseWatcherClient } from "@azure/arm-databasewatcher"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to get a SharedPrivateLinkResource + * + * @summary get a SharedPrivateLinkResource + * x-ms-original-file: 2025-01-02/SharedPrivateLinkResources_Get_MaximumSet_Gen.json + */ +async function sharedPrivateLinkResourcesGetMaximumSet(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "49e0fbd3-75e8-44e7-96fd-5b64d9ad818d"; + const client = new DatabaseWatcherClient(credential, subscriptionId); + const result = await client.sharedPrivateLinkResources.get( + "apiTest-ddat4p", + "databasemo3ej9ih", + "monitoringh22eed", + ); + console.log(result); +} + +async function main(): Promise { + await sharedPrivateLinkResourcesGetMaximumSet(); +} + +main().catch(console.error); diff --git a/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/sharedPrivateLinkResourcesSharedPrivateLinkResourcesListByWatcherSample.ts b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/sharedPrivateLinkResourcesSharedPrivateLinkResourcesListByWatcherSample.ts new file mode 100644 index 000000000000..a0048c76814d --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/sharedPrivateLinkResourcesSharedPrivateLinkResourcesListByWatcherSample.ts @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { DatabaseWatcherClient } from "@azure/arm-databasewatcher"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to list SharedPrivateLinkResource resources by Watcher + * + * @summary list SharedPrivateLinkResource resources by Watcher + * x-ms-original-file: 2025-01-02/SharedPrivateLinkResources_ListByWatcher_MaximumSet_Gen.json + */ +async function sharedPrivateLinkResourcesListByWatcherMaximumSet(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "49e0fbd3-75e8-44e7-96fd-5b64d9ad818d"; + const client = new DatabaseWatcherClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.sharedPrivateLinkResources.listByWatcher( + "apiTest-ddat4p", + "databasemo3ej9ih", + )) { + resArray.push(item); + } + + console.log(resArray); +} + +async function main(): Promise { + await sharedPrivateLinkResourcesListByWatcherMaximumSet(); +} + +main().catch(console.error); diff --git a/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/targetsTargetsCreateOrUpdateSample.ts b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/targetsTargetsCreateOrUpdateSample.ts new file mode 100644 index 000000000000..50f5ec3972bb --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/targetsTargetsCreateOrUpdateSample.ts @@ -0,0 +1,38 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { DatabaseWatcherClient } from "@azure/arm-databasewatcher"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to create a Target + * + * @summary create a Target + * x-ms-original-file: 2025-01-02/Targets_CreateOrUpdate_MaximumSet_Gen.json + */ +async function targetsCreateOrUpdateMaximumSet(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "49e0fbd3-75e8-44e7-96fd-5b64d9ad818d"; + const client = new DatabaseWatcherClient(credential, subscriptionId); + const result = await client.targets.createOrUpdate( + "apiTest-ddat4p", + "databasemo3ej9ih", + "monitoringh22eed", + { + properties: { + targetType: "SqlDb", + targetAuthenticationType: "Aad", + connectionServerName: "sqlServero1ihe2", + sqlDbResourceId: + "/subscriptions/49e0fbd3-75e8-44e7-96fd-5b64d9ad818d/resourceGroups/apiTest-ddat4p/providers/Microsoft.Sql/servers/m1/databases/m2", + }, + }, + ); + console.log(result); +} + +async function main(): Promise { + await targetsCreateOrUpdateMaximumSet(); +} + +main().catch(console.error); diff --git a/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/targetsTargetsDeleteSample.ts b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/targetsTargetsDeleteSample.ts new file mode 100644 index 000000000000..79a01005415d --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/targetsTargetsDeleteSample.ts @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { DatabaseWatcherClient } from "@azure/arm-databasewatcher"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to delete a Target + * + * @summary delete a Target + * x-ms-original-file: 2025-01-02/Targets_Delete_MaximumSet_Gen.json + */ +async function targetsDeleteMaximumSet(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "49e0fbd3-75e8-44e7-96fd-5b64d9ad818d"; + const client = new DatabaseWatcherClient(credential, subscriptionId); + await client.targets.delete("apiTest-ddat4p", "databasemo3ej9ih", "monitoringh22eed"); +} + +async function main(): Promise { + await targetsDeleteMaximumSet(); +} + +main().catch(console.error); diff --git a/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/targetsTargetsGetSample.ts b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/targetsTargetsGetSample.ts new file mode 100644 index 000000000000..03d7b7217ce9 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/targetsTargetsGetSample.ts @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { DatabaseWatcherClient } from "@azure/arm-databasewatcher"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to get a Target + * + * @summary get a Target + * x-ms-original-file: 2025-01-02/Targets_Get_MaximumSet_Gen.json + */ +async function targetsGetMaximumSet(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "49e0fbd3-75e8-44e7-96fd-5b64d9ad818d"; + const client = new DatabaseWatcherClient(credential, subscriptionId); + const result = await client.targets.get( + "apiTest-ddat4p", + "databasemo3ej9ih", + "monitoringh22eed", + ); + console.log(result); +} + +async function main(): Promise { + await targetsGetMaximumSet(); +} + +main().catch(console.error); diff --git a/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/targetsTargetsListByWatcherSample.ts b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/targetsTargetsListByWatcherSample.ts new file mode 100644 index 000000000000..764c9a835b91 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/targetsTargetsListByWatcherSample.ts @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { DatabaseWatcherClient } from "@azure/arm-databasewatcher"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to list Target resources by Watcher + * + * @summary list Target resources by Watcher + * x-ms-original-file: 2025-01-02/Targets_ListByWatcher_MaximumSet_Gen.json + */ +async function targetsListByWatcherMaximumSet(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "49e0fbd3-75e8-44e7-96fd-5b64d9ad818d"; + const client = new DatabaseWatcherClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.targets.listByWatcher( + "apiTest-ddat4p", + "databasemo3ej9ih", + )) { + resArray.push(item); + } + + console.log(resArray); +} + +async function main(): Promise { + await targetsListByWatcherMaximumSet(); +} + +main().catch(console.error); diff --git a/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/watchersWatchersCreateOrUpdateSample.ts b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/watchersWatchersCreateOrUpdateSample.ts new file mode 100644 index 000000000000..42a05fc922e8 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/watchersWatchersCreateOrUpdateSample.ts @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { DatabaseWatcherClient } from "@azure/arm-databasewatcher"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to create a Watcher + * + * @summary create a Watcher + * x-ms-original-file: 2025-01-02/Watchers_CreateOrUpdate_MaximumSet_Gen.json + */ +async function watchersCreateOrUpdateMaximumSet(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "A76F9850-996B-40B3-94D4-C98110A0EEC9"; + const client = new DatabaseWatcherClient(credential, subscriptionId); + const result = await client.watchers.createOrUpdate("rgWatcher", "testWatcher", { + properties: { + status: "Starting", + defaultAlertRuleIdentityResourceId: + "/subscriptions/469DD77C-C8DB-47B7-B9E1-72D29F8C878B/resourceGroups/rgWatcher/providers/Microsoft.ManagedIdentity/userAssignedIdentities/3pmtest", + datastore: { + adxClusterResourceId: + "/subscriptions/49e0fbd3-75e8-44e7-96fd-5b64d9ad818d/resourceGroups/apiTest/providers/Microsoft.Kusto/clusters/apiTestKusto", + kustoClusterUri: "https://kustouri-adx.eastus.kusto.windows.net", + kustoClusterDisplayName: "kustoUri-adx", + kustoDataIngestionUri: "https://ingest-kustouri-adx.eastus.kusto.windows.net", + kustoDatabaseName: "kustoDatabaseName1", + kustoManagementUrl: "https://portal.azure.com/", + kustoOfferingType: "adx", + }, + }, + identity: { type: "SystemAssigned" }, + tags: {}, + location: "eastus2", + }); + console.log(result); +} + +async function main(): Promise { + await watchersCreateOrUpdateMaximumSet(); +} + +main().catch(console.error); diff --git a/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/watchersWatchersDeleteSample.ts b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/watchersWatchersDeleteSample.ts new file mode 100644 index 000000000000..8302c0e0d5e4 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/watchersWatchersDeleteSample.ts @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { DatabaseWatcherClient } from "@azure/arm-databasewatcher"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to delete a Watcher + * + * @summary delete a Watcher + * x-ms-original-file: 2025-01-02/Watchers_Delete_MaximumSet_Gen.json + */ +async function watchersDeleteMaximumSet(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "A76F9850-996B-40B3-94D4-C98110A0EEC9"; + const client = new DatabaseWatcherClient(credential, subscriptionId); + await client.watchers.delete("rgWatcher", "testWatcher"); +} + +async function main(): Promise { + await watchersDeleteMaximumSet(); +} + +main().catch(console.error); diff --git a/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/watchersWatchersGetSample.ts b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/watchersWatchersGetSample.ts new file mode 100644 index 000000000000..1c17b9051b70 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/watchersWatchersGetSample.ts @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { DatabaseWatcherClient } from "@azure/arm-databasewatcher"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to get a Watcher + * + * @summary get a Watcher + * x-ms-original-file: 2025-01-02/Watchers_Get_MaximumSet_Gen.json + */ +async function watchersGetMaximumSet(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "A76F9850-996B-40B3-94D4-C98110A0EEC9"; + const client = new DatabaseWatcherClient(credential, subscriptionId); + const result = await client.watchers.get("rgWatcher", "myWatcher"); + console.log(result); +} + +async function main(): Promise { + await watchersGetMaximumSet(); +} + +main().catch(console.error); diff --git a/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/watchersWatchersListByResourceGroupSample.ts b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/watchersWatchersListByResourceGroupSample.ts new file mode 100644 index 000000000000..4673e66e6f43 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/watchersWatchersListByResourceGroupSample.ts @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { DatabaseWatcherClient } from "@azure/arm-databasewatcher"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to list Watcher resources by resource group + * + * @summary list Watcher resources by resource group + * x-ms-original-file: 2025-01-02/Watchers_ListByResourceGroup_MaximumSet_Gen.json + */ +async function watchersListByResourceGroupMaximumSet(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "A76F9850-996B-40B3-94D4-C98110A0EEC9"; + const client = new DatabaseWatcherClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.watchers.listByResourceGroup("rgWatcher")) { + resArray.push(item); + } + + console.log(resArray); +} + +async function main(): Promise { + await watchersListByResourceGroupMaximumSet(); +} + +main().catch(console.error); diff --git a/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/watchersWatchersListBySubscriptionSample.ts b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/watchersWatchersListBySubscriptionSample.ts new file mode 100644 index 000000000000..6609315bc972 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/watchersWatchersListBySubscriptionSample.ts @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { DatabaseWatcherClient } from "@azure/arm-databasewatcher"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to list Watcher resources by subscription ID + * + * @summary list Watcher resources by subscription ID + * x-ms-original-file: 2025-01-02/Watchers_ListBySubscription_MaximumSet_Gen.json + */ +async function watchersListBySubscriptionMaximumSet(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "A76F9850-996B-40B3-94D4-C98110A0EEC9"; + const client = new DatabaseWatcherClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.watchers.listBySubscription()) { + resArray.push(item); + } + + console.log(resArray); +} + +async function main(): Promise { + await watchersListBySubscriptionMaximumSet(); +} + +main().catch(console.error); diff --git a/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/watchersWatchersStartSample.ts b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/watchersWatchersStartSample.ts new file mode 100644 index 000000000000..72a309f44ef0 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/watchersWatchersStartSample.ts @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { DatabaseWatcherClient } from "@azure/arm-databasewatcher"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to the action to start monitoring all targets configured for a database watcher. + * + * @summary the action to start monitoring all targets configured for a database watcher. + * x-ms-original-file: 2025-01-02/Watchers_Start_MaximumSet_Gen.json + */ +async function watchersStartMaximumSet(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "A76F9850-996B-40B3-94D4-C98110A0EEC9"; + const client = new DatabaseWatcherClient(credential, subscriptionId); + await client.watchers.start("rgWatcher", "testWatcher"); +} + +async function main(): Promise { + await watchersStartMaximumSet(); +} + +main().catch(console.error); diff --git a/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/watchersWatchersStopSample.ts b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/watchersWatchersStopSample.ts new file mode 100644 index 000000000000..1902fba8b9c5 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/watchersWatchersStopSample.ts @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { DatabaseWatcherClient } from "@azure/arm-databasewatcher"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to the action to stop monitoring all targets configured for a database watcher. + * + * @summary the action to stop monitoring all targets configured for a database watcher. + * x-ms-original-file: 2025-01-02/Watchers_Stop_MaximumSet_Gen.json + */ +async function watchersStopMaximumSet(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "A76F9850-996B-40B3-94D4-C98110A0EEC9"; + const client = new DatabaseWatcherClient(credential, subscriptionId); + await client.watchers.stop("rgWatcher", "myWatcher"); +} + +async function main(): Promise { + await watchersStopMaximumSet(); +} + +main().catch(console.error); diff --git a/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/watchersWatchersUpdateSample.ts b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/watchersWatchersUpdateSample.ts new file mode 100644 index 000000000000..20782de42a18 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/src/watchersWatchersUpdateSample.ts @@ -0,0 +1,42 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { DatabaseWatcherClient } from "@azure/arm-databasewatcher"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to update a Watcher + * + * @summary update a Watcher + * x-ms-original-file: 2025-01-02/Watchers_Update_MaximumSet_Gen.json + */ +async function watchersUpdateMaximumSet(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "A76F9850-996B-40B3-94D4-C98110A0EEC9"; + const client = new DatabaseWatcherClient(credential, subscriptionId); + const result = await client.watchers.update("rgWatcher", "testWatcher", { + identity: { type: "SystemAssigned" }, + properties: { + datastore: { + adxClusterResourceId: + "/subscriptions/49e0fbd3-75e8-44e7-96fd-5b64d9ad818d/resourceGroups/apiTest/providers/Microsoft.Kusto/clusters/apiTestKusto", + kustoClusterUri: "https://kustouri-adx.eastus.kusto.windows.net", + kustoClusterDisplayName: "kustoUri-adx", + kustoDataIngestionUri: "https://ingest-kustouri-adx.eastus.kusto.windows.net", + kustoDatabaseName: "kustoDatabaseName1", + kustoManagementUrl: "https://portal.azure.com/", + kustoOfferingType: "adx", + }, + defaultAlertRuleIdentityResourceId: + "/subscriptions/469DD77C-C8DB-47B7-B9E1-72D29F8C878B/resourceGroups/rgWatcher/providers/Microsoft.ManagedIdentity/userAssignedIdentities/newtest", + }, + tags: {}, + }); + console.log(result); +} + +async function main(): Promise { + await watchersUpdateMaximumSet(); +} + +main().catch(console.error); diff --git a/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/tsconfig.json b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/tsconfig.json new file mode 100644 index 000000000000..400db87cf648 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/samples/v1-beta/typescript/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "target": "ES2023", + "module": "commonjs", + "lib": [], + "importHelpers": true, + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true, + "moduleResolution": "node10", + "esModuleInterop": true, + "outDir": "./dist", + "resolveJsonModule": true + }, + "include": [ + "./src" + ] +} diff --git a/sdk/databasewatcher/arm-databasewatcher/src/api/alertRuleResources/index.ts b/sdk/databasewatcher/arm-databasewatcher/src/api/alertRuleResources/index.ts new file mode 100644 index 000000000000..86f96f1fb71a --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/src/api/alertRuleResources/index.ts @@ -0,0 +1,261 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { + AlertRuleResourcesCreateOrUpdateOptionalParams, + AlertRuleResourcesDeleteOptionalParams, + AlertRuleResourcesGetOptionalParams, + AlertRuleResourcesListByParentOptionalParams, + DatabaseWatcherContext as Client, +} from "../index.js"; +import { + errorResponseDeserializer, + AlertRuleResource, + alertRuleResourceSerializer, + alertRuleResourceDeserializer, + _AlertRuleResourceListResult, + _alertRuleResourceListResultDeserializer, +} from "../../models/models.js"; +import { + PagedAsyncIterableIterator, + buildPagedAsyncIterator, +} from "../../static-helpers/pagingHelpers.js"; +import { + StreamableMethod, + PathUncheckedResponse, + createRestError, + operationOptionsToRequestParameters, +} from "@azure-rest/core-client"; + +export function _alertRuleResourcesListByParentSend( + context: Client, + resourceGroupName: string, + watcherName: string, + options: AlertRuleResourcesListByParentOptionalParams = { + requestOptions: {}, + }, +): StreamableMethod { + return context + .path( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/alertRuleResources", + context.subscriptionId, + resourceGroupName, + watcherName, + ) + .get({ + ...operationOptionsToRequestParameters(options), + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + queryParameters: { "api-version": context.apiVersion }, + }); +} + +export async function _alertRuleResourcesListByParentDeserialize( + result: PathUncheckedResponse, +): Promise<_AlertRuleResourceListResult> { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return _alertRuleResourceListResultDeserializer(result.body); +} + +/** List AlertRuleResource resources by Watcher */ +export function alertRuleResourcesListByParent( + context: Client, + resourceGroupName: string, + watcherName: string, + options: AlertRuleResourcesListByParentOptionalParams = { + requestOptions: {}, + }, +): PagedAsyncIterableIterator { + return buildPagedAsyncIterator( + context, + () => _alertRuleResourcesListByParentSend(context, resourceGroupName, watcherName, options), + _alertRuleResourcesListByParentDeserialize, + ["200"], + { itemName: "value", nextLinkName: "nextLink" }, + ); +} + +export function _alertRuleResourcesDeleteSend( + context: Client, + resourceGroupName: string, + watcherName: string, + alertRuleResourceName: string, + options: AlertRuleResourcesDeleteOptionalParams = { requestOptions: {} }, +): StreamableMethod { + return context + .path( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/alertRuleResources/{alertRuleResourceName}", + context.subscriptionId, + resourceGroupName, + watcherName, + alertRuleResourceName, + ) + .delete({ + ...operationOptionsToRequestParameters(options), + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + queryParameters: { "api-version": context.apiVersion }, + }); +} + +export async function _alertRuleResourcesDeleteDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["200", "204"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return; +} + +/** Delete a AlertRuleResource */ +export async function alertRuleResourcesDelete( + context: Client, + resourceGroupName: string, + watcherName: string, + alertRuleResourceName: string, + options: AlertRuleResourcesDeleteOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _alertRuleResourcesDeleteSend( + context, + resourceGroupName, + watcherName, + alertRuleResourceName, + options, + ); + return _alertRuleResourcesDeleteDeserialize(result); +} + +export function _alertRuleResourcesCreateOrUpdateSend( + context: Client, + resourceGroupName: string, + watcherName: string, + alertRuleResourceName: string, + resource: AlertRuleResource, + options: AlertRuleResourcesCreateOrUpdateOptionalParams = { + requestOptions: {}, + }, +): StreamableMethod { + return context + .path( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/alertRuleResources/{alertRuleResourceName}", + context.subscriptionId, + resourceGroupName, + watcherName, + alertRuleResourceName, + ) + .put({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json", + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + queryParameters: { "api-version": context.apiVersion }, + body: alertRuleResourceSerializer(resource), + }); +} + +export async function _alertRuleResourcesCreateOrUpdateDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["200", "201"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return alertRuleResourceDeserializer(result.body); +} + +/** Create a AlertRuleResource */ +export async function alertRuleResourcesCreateOrUpdate( + context: Client, + resourceGroupName: string, + watcherName: string, + alertRuleResourceName: string, + resource: AlertRuleResource, + options: AlertRuleResourcesCreateOrUpdateOptionalParams = { + requestOptions: {}, + }, +): Promise { + const result = await _alertRuleResourcesCreateOrUpdateSend( + context, + resourceGroupName, + watcherName, + alertRuleResourceName, + resource, + options, + ); + return _alertRuleResourcesCreateOrUpdateDeserialize(result); +} + +export function _alertRuleResourcesGetSend( + context: Client, + resourceGroupName: string, + watcherName: string, + alertRuleResourceName: string, + options: AlertRuleResourcesGetOptionalParams = { requestOptions: {} }, +): StreamableMethod { + return context + .path( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/alertRuleResources/{alertRuleResourceName}", + context.subscriptionId, + resourceGroupName, + watcherName, + alertRuleResourceName, + ) + .get({ + ...operationOptionsToRequestParameters(options), + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + queryParameters: { "api-version": context.apiVersion }, + }); +} + +export async function _alertRuleResourcesGetDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return alertRuleResourceDeserializer(result.body); +} + +/** Get a AlertRuleResource */ +export async function alertRuleResourcesGet( + context: Client, + resourceGroupName: string, + watcherName: string, + alertRuleResourceName: string, + options: AlertRuleResourcesGetOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _alertRuleResourcesGetSend( + context, + resourceGroupName, + watcherName, + alertRuleResourceName, + options, + ); + return _alertRuleResourcesGetDeserialize(result); +} diff --git a/sdk/databasewatcher/arm-databasewatcher/src/api/databaseWatcherContext.ts b/sdk/databasewatcher/arm-databasewatcher/src/api/databaseWatcherContext.ts new file mode 100644 index 000000000000..ec1ebabc167e --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/src/api/databaseWatcherContext.ts @@ -0,0 +1,66 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { logger } from "../logger.js"; +import { KnownVersions } from "../models/models.js"; +import { Client, ClientOptions, getClient } from "@azure-rest/core-client"; +import { TokenCredential } from "@azure/core-auth"; + +export interface DatabaseWatcherContext extends Client { + /** The API version to use for this operation. */ + /** Known values of {@link KnownVersions} that the service accepts. */ + apiVersion: string; + /** The ID of the target subscription. The value must be an UUID. */ + subscriptionId: string; +} + +/** Optional parameters for the client. */ +export interface DatabaseWatcherClientOptionalParams extends ClientOptions { + /** The API version to use for this operation. */ + /** Known values of {@link KnownVersions} that the service accepts. */ + apiVersion?: string; +} + +export function createDatabaseWatcher( + credential: TokenCredential, + subscriptionId: string, + options: DatabaseWatcherClientOptionalParams = {}, +): DatabaseWatcherContext { + const endpointUrl = options.endpoint ?? options.baseUrl ?? "https://management.azure.com"; + const prefixFromOptions = options?.userAgentOptions?.userAgentPrefix; + const userAgentInfo = `azsdk-js-arm-databasewatcher/1.0.0-beta.1`; + const userAgentPrefix = prefixFromOptions + ? `${prefixFromOptions} azsdk-js-api ${userAgentInfo}` + : `azsdk-js-api ${userAgentInfo}`; + const { apiVersion: _, ...updatedOptions } = { + ...options, + userAgentOptions: { userAgentPrefix }, + loggingOptions: { logger: options.loggingOptions?.logger ?? logger.info }, + credentials: { + scopes: options.credentials?.scopes ?? [`${endpointUrl}/.default`], + }, + }; + const clientContext = getClient(endpointUrl, credential, updatedOptions); + clientContext.pipeline.removePolicy({ name: "ApiVersionPolicy" }); + const apiVersion = options.apiVersion ?? "2025-01-02"; + clientContext.pipeline.addPolicy({ + name: "ClientApiVersionPolicy", + sendRequest: (req, next) => { + // Use the apiVersion defined in request url directly + // Append one if there is no apiVersion and we have one at client options + const url = new URL(req.url); + if (!url.searchParams.get("api-version")) { + req.url = `${req.url}${ + Array.from(url.searchParams.keys()).length > 0 ? "&" : "?" + }api-version=${apiVersion}`; + } + + return next(req); + }, + }); + return { + ...clientContext, + apiVersion, + subscriptionId, + } as DatabaseWatcherContext; +} diff --git a/sdk/databasewatcher/arm-databasewatcher/src/api/healthValidations/index.ts b/sdk/databasewatcher/arm-databasewatcher/src/api/healthValidations/index.ts new file mode 100644 index 000000000000..15f6028e1255 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/src/api/healthValidations/index.ts @@ -0,0 +1,206 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { + DatabaseWatcherContext as Client, + HealthValidationsGetOptionalParams, + HealthValidationsListByParentOptionalParams, + HealthValidationsStartValidationOptionalParams, +} from "../index.js"; +import { + errorResponseDeserializer, + HealthValidation, + healthValidationDeserializer, + _HealthValidationListResult, + _healthValidationListResultDeserializer, +} from "../../models/models.js"; +import { + PagedAsyncIterableIterator, + buildPagedAsyncIterator, +} from "../../static-helpers/pagingHelpers.js"; +import { getLongRunningPoller } from "../../static-helpers/pollingHelpers.js"; +import { + StreamableMethod, + PathUncheckedResponse, + createRestError, + operationOptionsToRequestParameters, +} from "@azure-rest/core-client"; +import { PollerLike, OperationState } from "@azure/core-lro"; + +export function _healthValidationsStartValidationSend( + context: Client, + resourceGroupName: string, + watcherName: string, + healthValidationName: string, + options: HealthValidationsStartValidationOptionalParams = { + requestOptions: {}, + }, +): StreamableMethod { + return context + .path( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/healthValidations/{healthValidationName}/startValidation", + context.subscriptionId, + resourceGroupName, + watcherName, + healthValidationName, + ) + .post({ + ...operationOptionsToRequestParameters(options), + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + queryParameters: { "api-version": context.apiVersion }, + }); +} + +export async function _healthValidationsStartValidationDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["202", "200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return healthValidationDeserializer(result.body); +} + +/** Starts health validation for a watcher. */ +export function healthValidationsStartValidation( + context: Client, + resourceGroupName: string, + watcherName: string, + healthValidationName: string, + options: HealthValidationsStartValidationOptionalParams = { + requestOptions: {}, + }, +): PollerLike, HealthValidation> { + return getLongRunningPoller( + context, + _healthValidationsStartValidationDeserialize, + ["202", "200"], + { + updateIntervalInMs: options?.updateIntervalInMs, + abortSignal: options?.abortSignal, + getInitialResponse: () => + _healthValidationsStartValidationSend( + context, + resourceGroupName, + watcherName, + healthValidationName, + options, + ), + resourceLocationConfig: "location", + }, + ) as PollerLike, HealthValidation>; +} + +export function _healthValidationsListByParentSend( + context: Client, + resourceGroupName: string, + watcherName: string, + options: HealthValidationsListByParentOptionalParams = { requestOptions: {} }, +): StreamableMethod { + return context + .path( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/healthValidations", + context.subscriptionId, + resourceGroupName, + watcherName, + ) + .get({ + ...operationOptionsToRequestParameters(options), + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + queryParameters: { "api-version": context.apiVersion }, + }); +} + +export async function _healthValidationsListByParentDeserialize( + result: PathUncheckedResponse, +): Promise<_HealthValidationListResult> { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return _healthValidationListResultDeserializer(result.body); +} + +/** List HealthValidation resources by Watcher */ +export function healthValidationsListByParent( + context: Client, + resourceGroupName: string, + watcherName: string, + options: HealthValidationsListByParentOptionalParams = { requestOptions: {} }, +): PagedAsyncIterableIterator { + return buildPagedAsyncIterator( + context, + () => _healthValidationsListByParentSend(context, resourceGroupName, watcherName, options), + _healthValidationsListByParentDeserialize, + ["200"], + { itemName: "value", nextLinkName: "nextLink" }, + ); +} + +export function _healthValidationsGetSend( + context: Client, + resourceGroupName: string, + watcherName: string, + healthValidationName: string, + options: HealthValidationsGetOptionalParams = { requestOptions: {} }, +): StreamableMethod { + return context + .path( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/healthValidations/{healthValidationName}", + context.subscriptionId, + resourceGroupName, + watcherName, + healthValidationName, + ) + .get({ + ...operationOptionsToRequestParameters(options), + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + queryParameters: { "api-version": context.apiVersion }, + }); +} + +export async function _healthValidationsGetDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return healthValidationDeserializer(result.body); +} + +/** Get a HealthValidation */ +export async function healthValidationsGet( + context: Client, + resourceGroupName: string, + watcherName: string, + healthValidationName: string, + options: HealthValidationsGetOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _healthValidationsGetSend( + context, + resourceGroupName, + watcherName, + healthValidationName, + options, + ); + return _healthValidationsGetDeserialize(result); +} diff --git a/sdk/databasewatcher/arm-databasewatcher/src/api/index.ts b/sdk/databasewatcher/arm-databasewatcher/src/api/index.ts new file mode 100644 index 000000000000..37e4a5e08d13 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/src/api/index.ts @@ -0,0 +1,68 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +export { + createDatabaseWatcher, + DatabaseWatcherContext, + DatabaseWatcherClientOptionalParams, +} from "./databaseWatcherContext.js"; +export { + SharedPrivateLinkResourcesListByWatcherOptionalParams, + SharedPrivateLinkResourcesDeleteOptionalParams, + SharedPrivateLinkResourcesCreateOptionalParams, + SharedPrivateLinkResourcesGetOptionalParams, + TargetsListByWatcherOptionalParams, + TargetsDeleteOptionalParams, + TargetsCreateOrUpdateOptionalParams, + TargetsGetOptionalParams, + HealthValidationsStartValidationOptionalParams, + HealthValidationsListByParentOptionalParams, + HealthValidationsGetOptionalParams, + AlertRuleResourcesListByParentOptionalParams, + AlertRuleResourcesDeleteOptionalParams, + AlertRuleResourcesCreateOrUpdateOptionalParams, + AlertRuleResourcesGetOptionalParams, + WatchersStopOptionalParams, + WatchersStartOptionalParams, + WatchersListBySubscriptionOptionalParams, + WatchersListByResourceGroupOptionalParams, + WatchersDeleteOptionalParams, + WatchersUpdateOptionalParams, + WatchersCreateOrUpdateOptionalParams, + WatchersGetOptionalParams, + OperationsListOptionalParams, +} from "./options.js"; +export { + alertRuleResourcesListByParent, + alertRuleResourcesDelete, + alertRuleResourcesCreateOrUpdate, + alertRuleResourcesGet, +} from "./alertRuleResources/index.js"; +export { + healthValidationsStartValidation, + healthValidationsListByParent, + healthValidationsGet, +} from "./healthValidations/index.js"; +export { operationsList } from "./operations/index.js"; +export { + sharedPrivateLinkResourcesListByWatcher, + sharedPrivateLinkResourcesDelete, + sharedPrivateLinkResourcesCreate, + sharedPrivateLinkResourcesGet, +} from "./sharedPrivateLinkResources/index.js"; +export { + targetsListByWatcher, + targetsDelete, + targetsCreateOrUpdate, + targetsGet, +} from "./targets/index.js"; +export { + watchersStop, + watchersStart, + watchersListBySubscription, + watchersListByResourceGroup, + watchersDelete, + watchersUpdate, + watchersCreateOrUpdate, + watchersGet, +} from "./watchers/index.js"; diff --git a/sdk/databasewatcher/arm-databasewatcher/src/api/operations/index.ts b/sdk/databasewatcher/arm-databasewatcher/src/api/operations/index.ts new file mode 100644 index 000000000000..17384a0565bc --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/src/api/operations/index.ts @@ -0,0 +1,61 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { DatabaseWatcherContext as Client, OperationsListOptionalParams } from "../index.js"; +import { + errorResponseDeserializer, + _OperationListResult, + _operationListResultDeserializer, + Operation, +} from "../../models/models.js"; +import { + PagedAsyncIterableIterator, + buildPagedAsyncIterator, +} from "../../static-helpers/pagingHelpers.js"; +import { + StreamableMethod, + PathUncheckedResponse, + createRestError, + operationOptionsToRequestParameters, +} from "@azure-rest/core-client"; + +export function _operationsListSend( + context: Client, + options: OperationsListOptionalParams = { requestOptions: {} }, +): StreamableMethod { + return context.path("/providers/Microsoft.DatabaseWatcher/operations").get({ + ...operationOptionsToRequestParameters(options), + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + queryParameters: { "api-version": context.apiVersion }, + }); +} + +export async function _operationsListDeserialize( + result: PathUncheckedResponse, +): Promise<_OperationListResult> { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return _operationListResultDeserializer(result.body); +} + +/** List the operations for the provider */ +export function operationsList( + context: Client, + options: OperationsListOptionalParams = { requestOptions: {} }, +): PagedAsyncIterableIterator { + return buildPagedAsyncIterator( + context, + () => _operationsListSend(context, options), + _operationsListDeserialize, + ["200"], + { itemName: "value", nextLinkName: "nextLink" }, + ); +} diff --git a/sdk/databasewatcher/arm-databasewatcher/src/api/options.ts b/sdk/databasewatcher/arm-databasewatcher/src/api/options.ts new file mode 100644 index 000000000000..2bcaf442a60b --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/src/api/options.ts @@ -0,0 +1,100 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { OperationOptions } from "@azure-rest/core-client"; + +/** Optional parameters. */ +export interface SharedPrivateLinkResourcesListByWatcherOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface SharedPrivateLinkResourcesDeleteOptionalParams extends OperationOptions { + /** Delay to wait until next poll, in milliseconds. */ + updateIntervalInMs?: number; +} + +/** Optional parameters. */ +export interface SharedPrivateLinkResourcesCreateOptionalParams extends OperationOptions { + /** Delay to wait until next poll, in milliseconds. */ + updateIntervalInMs?: number; +} + +/** Optional parameters. */ +export interface SharedPrivateLinkResourcesGetOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface TargetsListByWatcherOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface TargetsDeleteOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface TargetsCreateOrUpdateOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface TargetsGetOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface HealthValidationsStartValidationOptionalParams extends OperationOptions { + /** Delay to wait until next poll, in milliseconds. */ + updateIntervalInMs?: number; +} + +/** Optional parameters. */ +export interface HealthValidationsListByParentOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface HealthValidationsGetOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface AlertRuleResourcesListByParentOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface AlertRuleResourcesDeleteOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface AlertRuleResourcesCreateOrUpdateOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface AlertRuleResourcesGetOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface WatchersStopOptionalParams extends OperationOptions { + /** Delay to wait until next poll, in milliseconds. */ + updateIntervalInMs?: number; +} + +/** Optional parameters. */ +export interface WatchersStartOptionalParams extends OperationOptions { + /** Delay to wait until next poll, in milliseconds. */ + updateIntervalInMs?: number; +} + +/** Optional parameters. */ +export interface WatchersListBySubscriptionOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface WatchersListByResourceGroupOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface WatchersDeleteOptionalParams extends OperationOptions { + /** Delay to wait until next poll, in milliseconds. */ + updateIntervalInMs?: number; +} + +/** Optional parameters. */ +export interface WatchersUpdateOptionalParams extends OperationOptions { + /** Delay to wait until next poll, in milliseconds. */ + updateIntervalInMs?: number; +} + +/** Optional parameters. */ +export interface WatchersCreateOrUpdateOptionalParams extends OperationOptions { + /** Delay to wait until next poll, in milliseconds. */ + updateIntervalInMs?: number; +} + +/** Optional parameters. */ +export interface WatchersGetOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface OperationsListOptionalParams extends OperationOptions {} diff --git a/sdk/databasewatcher/arm-databasewatcher/src/api/sharedPrivateLinkResources/index.ts b/sdk/databasewatcher/arm-databasewatcher/src/api/sharedPrivateLinkResources/index.ts new file mode 100644 index 000000000000..ce11eec92ee1 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/src/api/sharedPrivateLinkResources/index.ts @@ -0,0 +1,293 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { + DatabaseWatcherContext as Client, + SharedPrivateLinkResourcesCreateOptionalParams, + SharedPrivateLinkResourcesDeleteOptionalParams, + SharedPrivateLinkResourcesGetOptionalParams, + SharedPrivateLinkResourcesListByWatcherOptionalParams, +} from "../index.js"; +import { + SharedPrivateLinkResource, + sharedPrivateLinkResourceSerializer, + sharedPrivateLinkResourceDeserializer, + errorResponseDeserializer, + _SharedPrivateLinkResourceListResult, + _sharedPrivateLinkResourceListResultDeserializer, +} from "../../models/models.js"; +import { + PagedAsyncIterableIterator, + buildPagedAsyncIterator, +} from "../../static-helpers/pagingHelpers.js"; +import { getLongRunningPoller } from "../../static-helpers/pollingHelpers.js"; +import { + StreamableMethod, + PathUncheckedResponse, + createRestError, + operationOptionsToRequestParameters, +} from "@azure-rest/core-client"; +import { PollerLike, OperationState } from "@azure/core-lro"; + +export function _sharedPrivateLinkResourcesListByWatcherSend( + context: Client, + resourceGroupName: string, + watcherName: string, + options: SharedPrivateLinkResourcesListByWatcherOptionalParams = { + requestOptions: {}, + }, +): StreamableMethod { + return context + .path( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/sharedPrivateLinkResources", + context.subscriptionId, + resourceGroupName, + watcherName, + ) + .get({ + ...operationOptionsToRequestParameters(options), + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + queryParameters: { "api-version": context.apiVersion }, + }); +} + +export async function _sharedPrivateLinkResourcesListByWatcherDeserialize( + result: PathUncheckedResponse, +): Promise<_SharedPrivateLinkResourceListResult> { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return _sharedPrivateLinkResourceListResultDeserializer(result.body); +} + +/** List SharedPrivateLinkResource resources by Watcher */ +export function sharedPrivateLinkResourcesListByWatcher( + context: Client, + resourceGroupName: string, + watcherName: string, + options: SharedPrivateLinkResourcesListByWatcherOptionalParams = { + requestOptions: {}, + }, +): PagedAsyncIterableIterator { + return buildPagedAsyncIterator( + context, + () => + _sharedPrivateLinkResourcesListByWatcherSend( + context, + resourceGroupName, + watcherName, + options, + ), + _sharedPrivateLinkResourcesListByWatcherDeserialize, + ["200"], + { itemName: "value", nextLinkName: "nextLink" }, + ); +} + +export function _sharedPrivateLinkResourcesDeleteSend( + context: Client, + resourceGroupName: string, + watcherName: string, + sharedPrivateLinkResourceName: string, + options: SharedPrivateLinkResourcesDeleteOptionalParams = { + requestOptions: {}, + }, +): StreamableMethod { + return context + .path( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}", + context.subscriptionId, + resourceGroupName, + watcherName, + sharedPrivateLinkResourceName, + ) + .delete({ + ...operationOptionsToRequestParameters(options), + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + queryParameters: { "api-version": context.apiVersion }, + }); +} + +export async function _sharedPrivateLinkResourcesDeleteDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["202", "204", "200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return; +} + +/** Delete a SharedPrivateLinkResource */ +export function sharedPrivateLinkResourcesDelete( + context: Client, + resourceGroupName: string, + watcherName: string, + sharedPrivateLinkResourceName: string, + options: SharedPrivateLinkResourcesDeleteOptionalParams = { + requestOptions: {}, + }, +): PollerLike, void> { + return getLongRunningPoller( + context, + _sharedPrivateLinkResourcesDeleteDeserialize, + ["202", "204", "200"], + { + updateIntervalInMs: options?.updateIntervalInMs, + abortSignal: options?.abortSignal, + getInitialResponse: () => + _sharedPrivateLinkResourcesDeleteSend( + context, + resourceGroupName, + watcherName, + sharedPrivateLinkResourceName, + options, + ), + resourceLocationConfig: "location", + }, + ) as PollerLike, void>; +} + +export function _sharedPrivateLinkResourcesCreateSend( + context: Client, + resourceGroupName: string, + watcherName: string, + sharedPrivateLinkResourceName: string, + resource: SharedPrivateLinkResource, + options: SharedPrivateLinkResourcesCreateOptionalParams = { + requestOptions: {}, + }, +): StreamableMethod { + return context + .path( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}", + context.subscriptionId, + resourceGroupName, + watcherName, + sharedPrivateLinkResourceName, + ) + .put({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json", + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + queryParameters: { "api-version": context.apiVersion }, + body: sharedPrivateLinkResourceSerializer(resource), + }); +} + +export async function _sharedPrivateLinkResourcesCreateDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["200", "201"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return sharedPrivateLinkResourceDeserializer(result.body); +} + +/** Create a SharedPrivateLinkResource */ +export function sharedPrivateLinkResourcesCreate( + context: Client, + resourceGroupName: string, + watcherName: string, + sharedPrivateLinkResourceName: string, + resource: SharedPrivateLinkResource, + options: SharedPrivateLinkResourcesCreateOptionalParams = { + requestOptions: {}, + }, +): PollerLike, SharedPrivateLinkResource> { + return getLongRunningPoller( + context, + _sharedPrivateLinkResourcesCreateDeserialize, + ["200", "201"], + { + updateIntervalInMs: options?.updateIntervalInMs, + abortSignal: options?.abortSignal, + getInitialResponse: () => + _sharedPrivateLinkResourcesCreateSend( + context, + resourceGroupName, + watcherName, + sharedPrivateLinkResourceName, + resource, + options, + ), + resourceLocationConfig: "azure-async-operation", + }, + ) as PollerLike, SharedPrivateLinkResource>; +} + +export function _sharedPrivateLinkResourcesGetSend( + context: Client, + resourceGroupName: string, + watcherName: string, + sharedPrivateLinkResourceName: string, + options: SharedPrivateLinkResourcesGetOptionalParams = { requestOptions: {} }, +): StreamableMethod { + return context + .path( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}", + context.subscriptionId, + resourceGroupName, + watcherName, + sharedPrivateLinkResourceName, + ) + .get({ + ...operationOptionsToRequestParameters(options), + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + queryParameters: { "api-version": context.apiVersion }, + }); +} + +export async function _sharedPrivateLinkResourcesGetDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return sharedPrivateLinkResourceDeserializer(result.body); +} + +/** Get a SharedPrivateLinkResource */ +export async function sharedPrivateLinkResourcesGet( + context: Client, + resourceGroupName: string, + watcherName: string, + sharedPrivateLinkResourceName: string, + options: SharedPrivateLinkResourcesGetOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _sharedPrivateLinkResourcesGetSend( + context, + resourceGroupName, + watcherName, + sharedPrivateLinkResourceName, + options, + ); + return _sharedPrivateLinkResourcesGetDeserialize(result); +} diff --git a/sdk/databasewatcher/arm-databasewatcher/src/api/targets/index.ts b/sdk/databasewatcher/arm-databasewatcher/src/api/targets/index.ts new file mode 100644 index 000000000000..9a7f278abfa4 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/src/api/targets/index.ts @@ -0,0 +1,249 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { + DatabaseWatcherContext as Client, + TargetsCreateOrUpdateOptionalParams, + TargetsDeleteOptionalParams, + TargetsGetOptionalParams, + TargetsListByWatcherOptionalParams, +} from "../index.js"; +import { + errorResponseDeserializer, + Target, + targetSerializer, + targetDeserializer, + _TargetListResult, + _targetListResultDeserializer, +} from "../../models/models.js"; +import { + PagedAsyncIterableIterator, + buildPagedAsyncIterator, +} from "../../static-helpers/pagingHelpers.js"; +import { + StreamableMethod, + PathUncheckedResponse, + createRestError, + operationOptionsToRequestParameters, +} from "@azure-rest/core-client"; + +export function _targetsListByWatcherSend( + context: Client, + resourceGroupName: string, + watcherName: string, + options: TargetsListByWatcherOptionalParams = { requestOptions: {} }, +): StreamableMethod { + return context + .path( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/targets", + context.subscriptionId, + resourceGroupName, + watcherName, + ) + .get({ + ...operationOptionsToRequestParameters(options), + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + queryParameters: { "api-version": context.apiVersion }, + }); +} + +export async function _targetsListByWatcherDeserialize( + result: PathUncheckedResponse, +): Promise<_TargetListResult> { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return _targetListResultDeserializer(result.body); +} + +/** List Target resources by Watcher */ +export function targetsListByWatcher( + context: Client, + resourceGroupName: string, + watcherName: string, + options: TargetsListByWatcherOptionalParams = { requestOptions: {} }, +): PagedAsyncIterableIterator { + return buildPagedAsyncIterator( + context, + () => _targetsListByWatcherSend(context, resourceGroupName, watcherName, options), + _targetsListByWatcherDeserialize, + ["200"], + { itemName: "value", nextLinkName: "nextLink" }, + ); +} + +export function _targetsDeleteSend( + context: Client, + resourceGroupName: string, + watcherName: string, + targetName: string, + options: TargetsDeleteOptionalParams = { requestOptions: {} }, +): StreamableMethod { + return context + .path( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/targets/{targetName}", + context.subscriptionId, + resourceGroupName, + watcherName, + targetName, + ) + .delete({ + ...operationOptionsToRequestParameters(options), + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + queryParameters: { "api-version": context.apiVersion }, + }); +} + +export async function _targetsDeleteDeserialize(result: PathUncheckedResponse): Promise { + const expectedStatuses = ["200", "204"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return; +} + +/** Delete a Target */ +export async function targetsDelete( + context: Client, + resourceGroupName: string, + watcherName: string, + targetName: string, + options: TargetsDeleteOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _targetsDeleteSend( + context, + resourceGroupName, + watcherName, + targetName, + options, + ); + return _targetsDeleteDeserialize(result); +} + +export function _targetsCreateOrUpdateSend( + context: Client, + resourceGroupName: string, + watcherName: string, + targetName: string, + resource: Target, + options: TargetsCreateOrUpdateOptionalParams = { requestOptions: {} }, +): StreamableMethod { + return context + .path( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/targets/{targetName}", + context.subscriptionId, + resourceGroupName, + watcherName, + targetName, + ) + .put({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json", + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + queryParameters: { "api-version": context.apiVersion }, + body: targetSerializer(resource), + }); +} + +export async function _targetsCreateOrUpdateDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["200", "201"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return targetDeserializer(result.body); +} + +/** Create a Target */ +export async function targetsCreateOrUpdate( + context: Client, + resourceGroupName: string, + watcherName: string, + targetName: string, + resource: Target, + options: TargetsCreateOrUpdateOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _targetsCreateOrUpdateSend( + context, + resourceGroupName, + watcherName, + targetName, + resource, + options, + ); + return _targetsCreateOrUpdateDeserialize(result); +} + +export function _targetsGetSend( + context: Client, + resourceGroupName: string, + watcherName: string, + targetName: string, + options: TargetsGetOptionalParams = { requestOptions: {} }, +): StreamableMethod { + return context + .path( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/targets/{targetName}", + context.subscriptionId, + resourceGroupName, + watcherName, + targetName, + ) + .get({ + ...operationOptionsToRequestParameters(options), + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + queryParameters: { "api-version": context.apiVersion }, + }); +} + +export async function _targetsGetDeserialize(result: PathUncheckedResponse): Promise { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return targetDeserializer(result.body); +} + +/** Get a Target */ +export async function targetsGet( + context: Client, + resourceGroupName: string, + watcherName: string, + targetName: string, + options: TargetsGetOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _targetsGetSend( + context, + resourceGroupName, + watcherName, + targetName, + options, + ); + return _targetsGetDeserialize(result); +} diff --git a/sdk/databasewatcher/arm-databasewatcher/src/api/watchers/index.ts b/sdk/databasewatcher/arm-databasewatcher/src/api/watchers/index.ts new file mode 100644 index 000000000000..a30bb320a099 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/src/api/watchers/index.ts @@ -0,0 +1,433 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { + DatabaseWatcherContext as Client, + WatchersCreateOrUpdateOptionalParams, + WatchersDeleteOptionalParams, + WatchersGetOptionalParams, + WatchersListByResourceGroupOptionalParams, + WatchersListBySubscriptionOptionalParams, + WatchersStartOptionalParams, + WatchersStopOptionalParams, + WatchersUpdateOptionalParams, +} from "../index.js"; +import { + errorResponseDeserializer, + Watcher, + watcherSerializer, + watcherDeserializer, + WatcherUpdate, + watcherUpdateSerializer, + _WatcherListResult, + _watcherListResultDeserializer, +} from "../../models/models.js"; +import { + PagedAsyncIterableIterator, + buildPagedAsyncIterator, +} from "../../static-helpers/pagingHelpers.js"; +import { getLongRunningPoller } from "../../static-helpers/pollingHelpers.js"; +import { + StreamableMethod, + PathUncheckedResponse, + createRestError, + operationOptionsToRequestParameters, +} from "@azure-rest/core-client"; +import { PollerLike, OperationState } from "@azure/core-lro"; + +export function _watchersStopSend( + context: Client, + resourceGroupName: string, + watcherName: string, + options: WatchersStopOptionalParams = { requestOptions: {} }, +): StreamableMethod { + return context + .path( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/stop", + context.subscriptionId, + resourceGroupName, + watcherName, + ) + .post({ + ...operationOptionsToRequestParameters(options), + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + queryParameters: { "api-version": context.apiVersion }, + }); +} + +export async function _watchersStopDeserialize(result: PathUncheckedResponse): Promise { + const expectedStatuses = ["202", "200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return; +} + +/** The action to stop monitoring all targets configured for a database watcher. */ +export function watchersStop( + context: Client, + resourceGroupName: string, + watcherName: string, + options: WatchersStopOptionalParams = { requestOptions: {} }, +): PollerLike, void> { + return getLongRunningPoller(context, _watchersStopDeserialize, ["202", "200"], { + updateIntervalInMs: options?.updateIntervalInMs, + abortSignal: options?.abortSignal, + getInitialResponse: () => _watchersStopSend(context, resourceGroupName, watcherName, options), + resourceLocationConfig: "location", + }) as PollerLike, void>; +} + +export function _watchersStartSend( + context: Client, + resourceGroupName: string, + watcherName: string, + options: WatchersStartOptionalParams = { requestOptions: {} }, +): StreamableMethod { + return context + .path( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/start", + context.subscriptionId, + resourceGroupName, + watcherName, + ) + .post({ + ...operationOptionsToRequestParameters(options), + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + queryParameters: { "api-version": context.apiVersion }, + }); +} + +export async function _watchersStartDeserialize(result: PathUncheckedResponse): Promise { + const expectedStatuses = ["202", "200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return; +} + +/** The action to start monitoring all targets configured for a database watcher. */ +export function watchersStart( + context: Client, + resourceGroupName: string, + watcherName: string, + options: WatchersStartOptionalParams = { requestOptions: {} }, +): PollerLike, void> { + return getLongRunningPoller(context, _watchersStartDeserialize, ["202", "200"], { + updateIntervalInMs: options?.updateIntervalInMs, + abortSignal: options?.abortSignal, + getInitialResponse: () => _watchersStartSend(context, resourceGroupName, watcherName, options), + resourceLocationConfig: "location", + }) as PollerLike, void>; +} + +export function _watchersListBySubscriptionSend( + context: Client, + options: WatchersListBySubscriptionOptionalParams = { requestOptions: {} }, +): StreamableMethod { + return context + .path( + "/subscriptions/{subscriptionId}/providers/Microsoft.DatabaseWatcher/watchers", + context.subscriptionId, + ) + .get({ + ...operationOptionsToRequestParameters(options), + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + queryParameters: { "api-version": context.apiVersion }, + }); +} + +export async function _watchersListBySubscriptionDeserialize( + result: PathUncheckedResponse, +): Promise<_WatcherListResult> { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return _watcherListResultDeserializer(result.body); +} + +/** List Watcher resources by subscription ID */ +export function watchersListBySubscription( + context: Client, + options: WatchersListBySubscriptionOptionalParams = { requestOptions: {} }, +): PagedAsyncIterableIterator { + return buildPagedAsyncIterator( + context, + () => _watchersListBySubscriptionSend(context, options), + _watchersListBySubscriptionDeserialize, + ["200"], + { itemName: "value", nextLinkName: "nextLink" }, + ); +} + +export function _watchersListByResourceGroupSend( + context: Client, + resourceGroupName: string, + options: WatchersListByResourceGroupOptionalParams = { requestOptions: {} }, +): StreamableMethod { + return context + .path( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers", + context.subscriptionId, + resourceGroupName, + ) + .get({ + ...operationOptionsToRequestParameters(options), + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + queryParameters: { "api-version": context.apiVersion }, + }); +} + +export async function _watchersListByResourceGroupDeserialize( + result: PathUncheckedResponse, +): Promise<_WatcherListResult> { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return _watcherListResultDeserializer(result.body); +} + +/** List Watcher resources by resource group */ +export function watchersListByResourceGroup( + context: Client, + resourceGroupName: string, + options: WatchersListByResourceGroupOptionalParams = { requestOptions: {} }, +): PagedAsyncIterableIterator { + return buildPagedAsyncIterator( + context, + () => _watchersListByResourceGroupSend(context, resourceGroupName, options), + _watchersListByResourceGroupDeserialize, + ["200"], + { itemName: "value", nextLinkName: "nextLink" }, + ); +} + +export function _watchersDeleteSend( + context: Client, + resourceGroupName: string, + watcherName: string, + options: WatchersDeleteOptionalParams = { requestOptions: {} }, +): StreamableMethod { + return context + .path( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}", + context.subscriptionId, + resourceGroupName, + watcherName, + ) + .delete({ + ...operationOptionsToRequestParameters(options), + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + queryParameters: { "api-version": context.apiVersion }, + }); +} + +export async function _watchersDeleteDeserialize(result: PathUncheckedResponse): Promise { + const expectedStatuses = ["202", "204", "200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return; +} + +/** Delete a Watcher */ +export function watchersDelete( + context: Client, + resourceGroupName: string, + watcherName: string, + options: WatchersDeleteOptionalParams = { requestOptions: {} }, +): PollerLike, void> { + return getLongRunningPoller(context, _watchersDeleteDeserialize, ["202", "204", "200"], { + updateIntervalInMs: options?.updateIntervalInMs, + abortSignal: options?.abortSignal, + getInitialResponse: () => _watchersDeleteSend(context, resourceGroupName, watcherName, options), + resourceLocationConfig: "location", + }) as PollerLike, void>; +} + +export function _watchersUpdateSend( + context: Client, + resourceGroupName: string, + watcherName: string, + properties: WatcherUpdate, + options: WatchersUpdateOptionalParams = { requestOptions: {} }, +): StreamableMethod { + return context + .path( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}", + context.subscriptionId, + resourceGroupName, + watcherName, + ) + .patch({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json", + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + queryParameters: { "api-version": context.apiVersion }, + body: watcherUpdateSerializer(properties), + }); +} + +export async function _watchersUpdateDeserialize(result: PathUncheckedResponse): Promise { + const expectedStatuses = ["200", "202"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return watcherDeserializer(result.body); +} + +/** Update a Watcher */ +export function watchersUpdate( + context: Client, + resourceGroupName: string, + watcherName: string, + properties: WatcherUpdate, + options: WatchersUpdateOptionalParams = { requestOptions: {} }, +): PollerLike, Watcher> { + return getLongRunningPoller(context, _watchersUpdateDeserialize, ["200", "202"], { + updateIntervalInMs: options?.updateIntervalInMs, + abortSignal: options?.abortSignal, + getInitialResponse: () => + _watchersUpdateSend(context, resourceGroupName, watcherName, properties, options), + resourceLocationConfig: "location", + }) as PollerLike, Watcher>; +} + +export function _watchersCreateOrUpdateSend( + context: Client, + resourceGroupName: string, + watcherName: string, + resource: Watcher, + options: WatchersCreateOrUpdateOptionalParams = { requestOptions: {} }, +): StreamableMethod { + return context + .path( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}", + context.subscriptionId, + resourceGroupName, + watcherName, + ) + .put({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json", + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + queryParameters: { "api-version": context.apiVersion }, + body: watcherSerializer(resource), + }); +} + +export async function _watchersCreateOrUpdateDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["200", "201"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return watcherDeserializer(result.body); +} + +/** Create a Watcher */ +export function watchersCreateOrUpdate( + context: Client, + resourceGroupName: string, + watcherName: string, + resource: Watcher, + options: WatchersCreateOrUpdateOptionalParams = { requestOptions: {} }, +): PollerLike, Watcher> { + return getLongRunningPoller(context, _watchersCreateOrUpdateDeserialize, ["200", "201"], { + updateIntervalInMs: options?.updateIntervalInMs, + abortSignal: options?.abortSignal, + getInitialResponse: () => + _watchersCreateOrUpdateSend(context, resourceGroupName, watcherName, resource, options), + resourceLocationConfig: "azure-async-operation", + }) as PollerLike, Watcher>; +} + +export function _watchersGetSend( + context: Client, + resourceGroupName: string, + watcherName: string, + options: WatchersGetOptionalParams = { requestOptions: {} }, +): StreamableMethod { + return context + .path( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}", + context.subscriptionId, + resourceGroupName, + watcherName, + ) + .get({ + ...operationOptionsToRequestParameters(options), + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + queryParameters: { "api-version": context.apiVersion }, + }); +} + +export async function _watchersGetDeserialize(result: PathUncheckedResponse): Promise { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return watcherDeserializer(result.body); +} + +/** Get a Watcher */ +export async function watchersGet( + context: Client, + resourceGroupName: string, + watcherName: string, + options: WatchersGetOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _watchersGetSend(context, resourceGroupName, watcherName, options); + return _watchersGetDeserialize(result); +} diff --git a/sdk/databasewatcher/arm-databasewatcher/src/classic/alertRuleResources/index.ts b/sdk/databasewatcher/arm-databasewatcher/src/classic/alertRuleResources/index.ts new file mode 100644 index 000000000000..0ae92345d9a8 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/src/classic/alertRuleResources/index.ts @@ -0,0 +1,109 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { DatabaseWatcherContext } from "../../api/databaseWatcherContext.js"; +import { + alertRuleResourcesListByParent, + alertRuleResourcesDelete, + alertRuleResourcesCreateOrUpdate, + alertRuleResourcesGet, +} from "../../api/alertRuleResources/index.js"; +import { AlertRuleResource } from "../../models/models.js"; +import { PagedAsyncIterableIterator } from "../../static-helpers/pagingHelpers.js"; +import { + AlertRuleResourcesListByParentOptionalParams, + AlertRuleResourcesDeleteOptionalParams, + AlertRuleResourcesCreateOrUpdateOptionalParams, + AlertRuleResourcesGetOptionalParams, +} from "../../api/options.js"; + +/** Interface representing a AlertRuleResources operations. */ +export interface AlertRuleResourcesOperations { + /** List AlertRuleResource resources by Watcher */ + listByParent: ( + resourceGroupName: string, + watcherName: string, + options?: AlertRuleResourcesListByParentOptionalParams, + ) => PagedAsyncIterableIterator; + /** Delete a AlertRuleResource */ + delete: ( + resourceGroupName: string, + watcherName: string, + alertRuleResourceName: string, + options?: AlertRuleResourcesDeleteOptionalParams, + ) => Promise; + /** Create a AlertRuleResource */ + createOrUpdate: ( + resourceGroupName: string, + watcherName: string, + alertRuleResourceName: string, + resource: AlertRuleResource, + options?: AlertRuleResourcesCreateOrUpdateOptionalParams, + ) => Promise; + /** Get a AlertRuleResource */ + get: ( + resourceGroupName: string, + watcherName: string, + alertRuleResourceName: string, + options?: AlertRuleResourcesGetOptionalParams, + ) => Promise; +} + +function _getAlertRuleResources(context: DatabaseWatcherContext) { + return { + listByParent: ( + resourceGroupName: string, + watcherName: string, + options?: AlertRuleResourcesListByParentOptionalParams, + ) => alertRuleResourcesListByParent(context, resourceGroupName, watcherName, options), + delete: ( + resourceGroupName: string, + watcherName: string, + alertRuleResourceName: string, + options?: AlertRuleResourcesDeleteOptionalParams, + ) => + alertRuleResourcesDelete( + context, + resourceGroupName, + watcherName, + alertRuleResourceName, + options, + ), + createOrUpdate: ( + resourceGroupName: string, + watcherName: string, + alertRuleResourceName: string, + resource: AlertRuleResource, + options?: AlertRuleResourcesCreateOrUpdateOptionalParams, + ) => + alertRuleResourcesCreateOrUpdate( + context, + resourceGroupName, + watcherName, + alertRuleResourceName, + resource, + options, + ), + get: ( + resourceGroupName: string, + watcherName: string, + alertRuleResourceName: string, + options?: AlertRuleResourcesGetOptionalParams, + ) => + alertRuleResourcesGet( + context, + resourceGroupName, + watcherName, + alertRuleResourceName, + options, + ), + }; +} + +export function _getAlertRuleResourcesOperations( + context: DatabaseWatcherContext, +): AlertRuleResourcesOperations { + return { + ..._getAlertRuleResources(context), + }; +} diff --git a/sdk/databasewatcher/arm-databasewatcher/src/classic/healthValidations/index.ts b/sdk/databasewatcher/arm-databasewatcher/src/classic/healthValidations/index.ts new file mode 100644 index 000000000000..00e334839875 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/src/classic/healthValidations/index.ts @@ -0,0 +1,79 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { DatabaseWatcherContext } from "../../api/databaseWatcherContext.js"; +import { + healthValidationsStartValidation, + healthValidationsListByParent, + healthValidationsGet, +} from "../../api/healthValidations/index.js"; +import { + HealthValidationsStartValidationOptionalParams, + HealthValidationsListByParentOptionalParams, + HealthValidationsGetOptionalParams, +} from "../../api/options.js"; +import { HealthValidation } from "../../models/models.js"; +import { PagedAsyncIterableIterator } from "../../static-helpers/pagingHelpers.js"; +import { PollerLike, OperationState } from "@azure/core-lro"; + +/** Interface representing a HealthValidations operations. */ +export interface HealthValidationsOperations { + /** Starts health validation for a watcher. */ + startValidation: ( + resourceGroupName: string, + watcherName: string, + healthValidationName: string, + options?: HealthValidationsStartValidationOptionalParams, + ) => PollerLike, HealthValidation>; + /** List HealthValidation resources by Watcher */ + listByParent: ( + resourceGroupName: string, + watcherName: string, + options?: HealthValidationsListByParentOptionalParams, + ) => PagedAsyncIterableIterator; + /** Get a HealthValidation */ + get: ( + resourceGroupName: string, + watcherName: string, + healthValidationName: string, + options?: HealthValidationsGetOptionalParams, + ) => Promise; +} + +function _getHealthValidations(context: DatabaseWatcherContext) { + return { + startValidation: ( + resourceGroupName: string, + watcherName: string, + healthValidationName: string, + options?: HealthValidationsStartValidationOptionalParams, + ) => + healthValidationsStartValidation( + context, + resourceGroupName, + watcherName, + healthValidationName, + options, + ), + listByParent: ( + resourceGroupName: string, + watcherName: string, + options?: HealthValidationsListByParentOptionalParams, + ) => healthValidationsListByParent(context, resourceGroupName, watcherName, options), + get: ( + resourceGroupName: string, + watcherName: string, + healthValidationName: string, + options?: HealthValidationsGetOptionalParams, + ) => + healthValidationsGet(context, resourceGroupName, watcherName, healthValidationName, options), + }; +} + +export function _getHealthValidationsOperations( + context: DatabaseWatcherContext, +): HealthValidationsOperations { + return { + ..._getHealthValidations(context), + }; +} diff --git a/sdk/databasewatcher/arm-databasewatcher/src/classic/index.ts b/sdk/databasewatcher/arm-databasewatcher/src/classic/index.ts new file mode 100644 index 000000000000..18e2ac1ba564 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/src/classic/index.ts @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +export { AlertRuleResourcesOperations } from "./alertRuleResources/index.js"; +export { HealthValidationsOperations } from "./healthValidations/index.js"; +export { OperationsOperations } from "./operations/index.js"; +export { SharedPrivateLinkResourcesOperations } from "./sharedPrivateLinkResources/index.js"; +export { TargetsOperations } from "./targets/index.js"; +export { WatchersOperations } from "./watchers/index.js"; diff --git a/sdk/databasewatcher/arm-databasewatcher/src/classic/operations/index.ts b/sdk/databasewatcher/arm-databasewatcher/src/classic/operations/index.ts new file mode 100644 index 000000000000..9c54d7c83f76 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/src/classic/operations/index.ts @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { DatabaseWatcherContext } from "../../api/databaseWatcherContext.js"; +import { operationsList } from "../../api/operations/index.js"; +import { OperationsListOptionalParams } from "../../api/options.js"; +import { Operation } from "../../models/models.js"; +import { PagedAsyncIterableIterator } from "../../static-helpers/pagingHelpers.js"; + +/** Interface representing a Operations operations. */ +export interface OperationsOperations { + /** List the operations for the provider */ + list: (options?: OperationsListOptionalParams) => PagedAsyncIterableIterator; +} + +function _getOperations(context: DatabaseWatcherContext) { + return { + list: (options?: OperationsListOptionalParams) => operationsList(context, options), + }; +} + +export function _getOperationsOperations(context: DatabaseWatcherContext): OperationsOperations { + return { + ..._getOperations(context), + }; +} diff --git a/sdk/databasewatcher/arm-databasewatcher/src/classic/sharedPrivateLinkResources/index.ts b/sdk/databasewatcher/arm-databasewatcher/src/classic/sharedPrivateLinkResources/index.ts new file mode 100644 index 000000000000..f82d1e35e56b --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/src/classic/sharedPrivateLinkResources/index.ts @@ -0,0 +1,110 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { DatabaseWatcherContext } from "../../api/databaseWatcherContext.js"; +import { + SharedPrivateLinkResourcesListByWatcherOptionalParams, + SharedPrivateLinkResourcesDeleteOptionalParams, + SharedPrivateLinkResourcesCreateOptionalParams, + SharedPrivateLinkResourcesGetOptionalParams, +} from "../../api/options.js"; +import { + sharedPrivateLinkResourcesListByWatcher, + sharedPrivateLinkResourcesDelete, + sharedPrivateLinkResourcesCreate, + sharedPrivateLinkResourcesGet, +} from "../../api/sharedPrivateLinkResources/index.js"; +import { SharedPrivateLinkResource } from "../../models/models.js"; +import { PagedAsyncIterableIterator } from "../../static-helpers/pagingHelpers.js"; +import { PollerLike, OperationState } from "@azure/core-lro"; + +/** Interface representing a SharedPrivateLinkResources operations. */ +export interface SharedPrivateLinkResourcesOperations { + /** List SharedPrivateLinkResource resources by Watcher */ + listByWatcher: ( + resourceGroupName: string, + watcherName: string, + options?: SharedPrivateLinkResourcesListByWatcherOptionalParams, + ) => PagedAsyncIterableIterator; + /** Delete a SharedPrivateLinkResource */ + delete: ( + resourceGroupName: string, + watcherName: string, + sharedPrivateLinkResourceName: string, + options?: SharedPrivateLinkResourcesDeleteOptionalParams, + ) => PollerLike, void>; + /** Create a SharedPrivateLinkResource */ + create: ( + resourceGroupName: string, + watcherName: string, + sharedPrivateLinkResourceName: string, + resource: SharedPrivateLinkResource, + options?: SharedPrivateLinkResourcesCreateOptionalParams, + ) => PollerLike, SharedPrivateLinkResource>; + /** Get a SharedPrivateLinkResource */ + get: ( + resourceGroupName: string, + watcherName: string, + sharedPrivateLinkResourceName: string, + options?: SharedPrivateLinkResourcesGetOptionalParams, + ) => Promise; +} + +function _getSharedPrivateLinkResources(context: DatabaseWatcherContext) { + return { + listByWatcher: ( + resourceGroupName: string, + watcherName: string, + options?: SharedPrivateLinkResourcesListByWatcherOptionalParams, + ) => sharedPrivateLinkResourcesListByWatcher(context, resourceGroupName, watcherName, options), + delete: ( + resourceGroupName: string, + watcherName: string, + sharedPrivateLinkResourceName: string, + options?: SharedPrivateLinkResourcesDeleteOptionalParams, + ) => + sharedPrivateLinkResourcesDelete( + context, + resourceGroupName, + watcherName, + sharedPrivateLinkResourceName, + options, + ), + create: ( + resourceGroupName: string, + watcherName: string, + sharedPrivateLinkResourceName: string, + resource: SharedPrivateLinkResource, + options?: SharedPrivateLinkResourcesCreateOptionalParams, + ) => + sharedPrivateLinkResourcesCreate( + context, + resourceGroupName, + watcherName, + sharedPrivateLinkResourceName, + resource, + options, + ), + get: ( + resourceGroupName: string, + watcherName: string, + sharedPrivateLinkResourceName: string, + options?: SharedPrivateLinkResourcesGetOptionalParams, + ) => + sharedPrivateLinkResourcesGet( + context, + resourceGroupName, + watcherName, + sharedPrivateLinkResourceName, + options, + ), + }; +} + +export function _getSharedPrivateLinkResourcesOperations( + context: DatabaseWatcherContext, +): SharedPrivateLinkResourcesOperations { + return { + ..._getSharedPrivateLinkResources(context), + }; +} diff --git a/sdk/databasewatcher/arm-databasewatcher/src/classic/targets/index.ts b/sdk/databasewatcher/arm-databasewatcher/src/classic/targets/index.ts new file mode 100644 index 000000000000..363c7f7c8a61 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/src/classic/targets/index.ts @@ -0,0 +1,86 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { DatabaseWatcherContext } from "../../api/databaseWatcherContext.js"; +import { + TargetsListByWatcherOptionalParams, + TargetsDeleteOptionalParams, + TargetsCreateOrUpdateOptionalParams, + TargetsGetOptionalParams, +} from "../../api/options.js"; +import { + targetsListByWatcher, + targetsDelete, + targetsCreateOrUpdate, + targetsGet, +} from "../../api/targets/index.js"; +import { Target } from "../../models/models.js"; +import { PagedAsyncIterableIterator } from "../../static-helpers/pagingHelpers.js"; + +/** Interface representing a Targets operations. */ +export interface TargetsOperations { + /** List Target resources by Watcher */ + listByWatcher: ( + resourceGroupName: string, + watcherName: string, + options?: TargetsListByWatcherOptionalParams, + ) => PagedAsyncIterableIterator; + /** Delete a Target */ + delete: ( + resourceGroupName: string, + watcherName: string, + targetName: string, + options?: TargetsDeleteOptionalParams, + ) => Promise; + /** Create a Target */ + createOrUpdate: ( + resourceGroupName: string, + watcherName: string, + targetName: string, + resource: Target, + options?: TargetsCreateOrUpdateOptionalParams, + ) => Promise; + /** Get a Target */ + get: ( + resourceGroupName: string, + watcherName: string, + targetName: string, + options?: TargetsGetOptionalParams, + ) => Promise; +} + +function _getTargets(context: DatabaseWatcherContext) { + return { + listByWatcher: ( + resourceGroupName: string, + watcherName: string, + options?: TargetsListByWatcherOptionalParams, + ) => targetsListByWatcher(context, resourceGroupName, watcherName, options), + delete: ( + resourceGroupName: string, + watcherName: string, + targetName: string, + options?: TargetsDeleteOptionalParams, + ) => targetsDelete(context, resourceGroupName, watcherName, targetName, options), + createOrUpdate: ( + resourceGroupName: string, + watcherName: string, + targetName: string, + resource: Target, + options?: TargetsCreateOrUpdateOptionalParams, + ) => + targetsCreateOrUpdate(context, resourceGroupName, watcherName, targetName, resource, options), + get: ( + resourceGroupName: string, + watcherName: string, + targetName: string, + options?: TargetsGetOptionalParams, + ) => targetsGet(context, resourceGroupName, watcherName, targetName, options), + }; +} + +export function _getTargetsOperations(context: DatabaseWatcherContext): TargetsOperations { + return { + ..._getTargets(context), + }; +} diff --git a/sdk/databasewatcher/arm-databasewatcher/src/classic/watchers/index.ts b/sdk/databasewatcher/arm-databasewatcher/src/classic/watchers/index.ts new file mode 100644 index 000000000000..e5e58c5f230f --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/src/classic/watchers/index.ts @@ -0,0 +1,121 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { DatabaseWatcherContext } from "../../api/databaseWatcherContext.js"; +import { + WatchersStopOptionalParams, + WatchersStartOptionalParams, + WatchersListBySubscriptionOptionalParams, + WatchersListByResourceGroupOptionalParams, + WatchersDeleteOptionalParams, + WatchersUpdateOptionalParams, + WatchersCreateOrUpdateOptionalParams, + WatchersGetOptionalParams, +} from "../../api/options.js"; +import { + watchersStop, + watchersStart, + watchersListBySubscription, + watchersListByResourceGroup, + watchersDelete, + watchersUpdate, + watchersCreateOrUpdate, + watchersGet, +} from "../../api/watchers/index.js"; +import { Watcher, WatcherUpdate } from "../../models/models.js"; +import { PagedAsyncIterableIterator } from "../../static-helpers/pagingHelpers.js"; +import { PollerLike, OperationState } from "@azure/core-lro"; + +/** Interface representing a Watchers operations. */ +export interface WatchersOperations { + /** The action to stop monitoring all targets configured for a database watcher. */ + stop: ( + resourceGroupName: string, + watcherName: string, + options?: WatchersStopOptionalParams, + ) => PollerLike, void>; + /** The action to start monitoring all targets configured for a database watcher. */ + start: ( + resourceGroupName: string, + watcherName: string, + options?: WatchersStartOptionalParams, + ) => PollerLike, void>; + /** List Watcher resources by subscription ID */ + listBySubscription: ( + options?: WatchersListBySubscriptionOptionalParams, + ) => PagedAsyncIterableIterator; + /** List Watcher resources by resource group */ + listByResourceGroup: ( + resourceGroupName: string, + options?: WatchersListByResourceGroupOptionalParams, + ) => PagedAsyncIterableIterator; + /** Delete a Watcher */ + delete: ( + resourceGroupName: string, + watcherName: string, + options?: WatchersDeleteOptionalParams, + ) => PollerLike, void>; + /** Update a Watcher */ + update: ( + resourceGroupName: string, + watcherName: string, + properties: WatcherUpdate, + options?: WatchersUpdateOptionalParams, + ) => PollerLike, Watcher>; + /** Create a Watcher */ + createOrUpdate: ( + resourceGroupName: string, + watcherName: string, + resource: Watcher, + options?: WatchersCreateOrUpdateOptionalParams, + ) => PollerLike, Watcher>; + /** Get a Watcher */ + get: ( + resourceGroupName: string, + watcherName: string, + options?: WatchersGetOptionalParams, + ) => Promise; +} + +function _getWatchers(context: DatabaseWatcherContext) { + return { + stop: (resourceGroupName: string, watcherName: string, options?: WatchersStopOptionalParams) => + watchersStop(context, resourceGroupName, watcherName, options), + start: ( + resourceGroupName: string, + watcherName: string, + options?: WatchersStartOptionalParams, + ) => watchersStart(context, resourceGroupName, watcherName, options), + listBySubscription: (options?: WatchersListBySubscriptionOptionalParams) => + watchersListBySubscription(context, options), + listByResourceGroup: ( + resourceGroupName: string, + options?: WatchersListByResourceGroupOptionalParams, + ) => watchersListByResourceGroup(context, resourceGroupName, options), + delete: ( + resourceGroupName: string, + watcherName: string, + options?: WatchersDeleteOptionalParams, + ) => watchersDelete(context, resourceGroupName, watcherName, options), + update: ( + resourceGroupName: string, + watcherName: string, + properties: WatcherUpdate, + options?: WatchersUpdateOptionalParams, + ) => watchersUpdate(context, resourceGroupName, watcherName, properties, options), + createOrUpdate: ( + resourceGroupName: string, + watcherName: string, + resource: Watcher, + options?: WatchersCreateOrUpdateOptionalParams, + ) => watchersCreateOrUpdate(context, resourceGroupName, watcherName, resource, options), + get: (resourceGroupName: string, watcherName: string, options?: WatchersGetOptionalParams) => + watchersGet(context, resourceGroupName, watcherName, options), + }; +} + +export function _getWatchersOperations(context: DatabaseWatcherContext): WatchersOperations { + return { + ..._getWatchers(context), + }; +} diff --git a/sdk/databasewatcher/arm-databasewatcher/src/databaseWatcherClient.ts b/sdk/databasewatcher/arm-databasewatcher/src/databaseWatcherClient.ts new file mode 100644 index 000000000000..2dd6c546e77e --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/src/databaseWatcherClient.ts @@ -0,0 +1,68 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { + _getSharedPrivateLinkResourcesOperations, + SharedPrivateLinkResourcesOperations, +} from "./classic/sharedPrivateLinkResources/index.js"; +import { _getTargetsOperations, TargetsOperations } from "./classic/targets/index.js"; +import { + _getHealthValidationsOperations, + HealthValidationsOperations, +} from "./classic/healthValidations/index.js"; +import { + _getAlertRuleResourcesOperations, + AlertRuleResourcesOperations, +} from "./classic/alertRuleResources/index.js"; +import { _getWatchersOperations, WatchersOperations } from "./classic/watchers/index.js"; +import { _getOperationsOperations, OperationsOperations } from "./classic/operations/index.js"; +import { + createDatabaseWatcher, + DatabaseWatcherContext, + DatabaseWatcherClientOptionalParams, +} from "./api/index.js"; +import { Pipeline } from "@azure/core-rest-pipeline"; +import { TokenCredential } from "@azure/core-auth"; + +export { DatabaseWatcherClientOptionalParams } from "./api/databaseWatcherContext.js"; + +export class DatabaseWatcherClient { + private _client: DatabaseWatcherContext; + /** The pipeline used by this client to make requests */ + public readonly pipeline: Pipeline; + + constructor( + credential: TokenCredential, + subscriptionId: string, + options: DatabaseWatcherClientOptionalParams = {}, + ) { + const prefixFromOptions = options?.userAgentOptions?.userAgentPrefix; + const userAgentPrefix = prefixFromOptions + ? `${prefixFromOptions} azsdk-js-client` + : `azsdk-js-client`; + this._client = createDatabaseWatcher(credential, subscriptionId, { + ...options, + userAgentOptions: { userAgentPrefix }, + }); + this.pipeline = this._client.pipeline; + this.sharedPrivateLinkResources = _getSharedPrivateLinkResourcesOperations(this._client); + this.targets = _getTargetsOperations(this._client); + this.healthValidations = _getHealthValidationsOperations(this._client); + this.alertRuleResources = _getAlertRuleResourcesOperations(this._client); + this.watchers = _getWatchersOperations(this._client); + this.operations = _getOperationsOperations(this._client); + } + + /** The operation groups for sharedPrivateLinkResources */ + public readonly sharedPrivateLinkResources: SharedPrivateLinkResourcesOperations; + /** The operation groups for targets */ + public readonly targets: TargetsOperations; + /** The operation groups for healthValidations */ + public readonly healthValidations: HealthValidationsOperations; + /** The operation groups for alertRuleResources */ + public readonly alertRuleResources: AlertRuleResourcesOperations; + /** The operation groups for watchers */ + public readonly watchers: WatchersOperations; + /** The operation groups for operations */ + public readonly operations: OperationsOperations; +} diff --git a/sdk/databasewatcher/arm-databasewatcher/src/index.ts b/sdk/databasewatcher/arm-databasewatcher/src/index.ts new file mode 100644 index 000000000000..0cc3dfd0eb50 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/src/index.ts @@ -0,0 +1,104 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { + PageSettings, + ContinuablePage, + PagedAsyncIterableIterator, +} from "./static-helpers/pagingHelpers.js"; + +export { DatabaseWatcherClient } from "./databaseWatcherClient.js"; +export { restorePoller, RestorePollerOptions } from "./restorePollerHelpers.js"; +export { + SharedPrivateLinkResource, + SharedPrivateLinkResourceProperties, + KnownSharedPrivateLinkResourceStatus, + SharedPrivateLinkResourceStatus, + KnownResourceProvisioningState, + ResourceProvisioningState, + ProxyResource, + Resource, + SystemData, + KnownCreatedByType, + CreatedByType, + ErrorResponse, + ErrorDetail, + ErrorAdditionalInfo, + Target, + TargetProperties, + TargetPropertiesUnion, + KnownTargetAuthenticationType, + TargetAuthenticationType, + VaultSecret, + SqlDbSingleDatabaseTargetProperties, + SqlDbElasticPoolTargetProperties, + SqlMiTargetProperties, + HealthValidation, + HealthValidationProperties, + KnownValidationStatus, + ValidationStatus, + ValidationIssue, + AlertRuleResource, + AlertRuleResourceProperties, + KnownAlertRuleCreationProperties, + AlertRuleCreationProperties, + Watcher, + WatcherProperties, + Datastore, + KnownKustoOfferingType, + KustoOfferingType, + KnownWatcherStatus, + WatcherStatus, + KnownDatabaseWatcherProvisioningState, + DatabaseWatcherProvisioningState, + ManagedServiceIdentityV4, + KnownManagedServiceIdentityType, + ManagedServiceIdentityType, + UserAssignedIdentity, + TrackedResource, + WatcherUpdate, + WatcherUpdateProperties, + Operation, + OperationDisplay, + KnownOrigin, + Origin, + KnownActionType, + ActionType, + KnownVersions, +} from "./models/index.js"; +export { + DatabaseWatcherClientOptionalParams, + SharedPrivateLinkResourcesListByWatcherOptionalParams, + SharedPrivateLinkResourcesDeleteOptionalParams, + SharedPrivateLinkResourcesCreateOptionalParams, + SharedPrivateLinkResourcesGetOptionalParams, + TargetsListByWatcherOptionalParams, + TargetsDeleteOptionalParams, + TargetsCreateOrUpdateOptionalParams, + TargetsGetOptionalParams, + HealthValidationsStartValidationOptionalParams, + HealthValidationsListByParentOptionalParams, + HealthValidationsGetOptionalParams, + AlertRuleResourcesListByParentOptionalParams, + AlertRuleResourcesDeleteOptionalParams, + AlertRuleResourcesCreateOrUpdateOptionalParams, + AlertRuleResourcesGetOptionalParams, + WatchersStopOptionalParams, + WatchersStartOptionalParams, + WatchersListBySubscriptionOptionalParams, + WatchersListByResourceGroupOptionalParams, + WatchersDeleteOptionalParams, + WatchersUpdateOptionalParams, + WatchersCreateOrUpdateOptionalParams, + WatchersGetOptionalParams, + OperationsListOptionalParams, +} from "./api/index.js"; +export { + AlertRuleResourcesOperations, + HealthValidationsOperations, + OperationsOperations, + SharedPrivateLinkResourcesOperations, + TargetsOperations, + WatchersOperations, +} from "./classic/index.js"; +export { PageSettings, ContinuablePage, PagedAsyncIterableIterator }; diff --git a/sdk/databasewatcher/arm-databasewatcher/src/logger.ts b/sdk/databasewatcher/arm-databasewatcher/src/logger.ts new file mode 100644 index 000000000000..45fed267cd6d --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/src/logger.ts @@ -0,0 +1,5 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { createClientLogger } from "@azure/logger"; +export const logger = createClientLogger("arm-databasewatcher"); diff --git a/sdk/databasewatcher/arm-databasewatcher/src/models/index.ts b/sdk/databasewatcher/arm-databasewatcher/src/models/index.ts new file mode 100644 index 000000000000..9707e2b6f270 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/src/models/index.ts @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +export { + SharedPrivateLinkResource, + SharedPrivateLinkResourceProperties, + KnownSharedPrivateLinkResourceStatus, + SharedPrivateLinkResourceStatus, + KnownResourceProvisioningState, + ResourceProvisioningState, + ProxyResource, + Resource, + SystemData, + KnownCreatedByType, + CreatedByType, + ErrorResponse, + ErrorDetail, + ErrorAdditionalInfo, + Target, + TargetProperties, + TargetPropertiesUnion, + KnownTargetAuthenticationType, + TargetAuthenticationType, + VaultSecret, + SqlDbSingleDatabaseTargetProperties, + SqlDbElasticPoolTargetProperties, + SqlMiTargetProperties, + HealthValidation, + HealthValidationProperties, + KnownValidationStatus, + ValidationStatus, + ValidationIssue, + AlertRuleResource, + AlertRuleResourceProperties, + KnownAlertRuleCreationProperties, + AlertRuleCreationProperties, + Watcher, + WatcherProperties, + Datastore, + KnownKustoOfferingType, + KustoOfferingType, + KnownWatcherStatus, + WatcherStatus, + KnownDatabaseWatcherProvisioningState, + DatabaseWatcherProvisioningState, + ManagedServiceIdentityV4, + KnownManagedServiceIdentityType, + ManagedServiceIdentityType, + UserAssignedIdentity, + TrackedResource, + WatcherUpdate, + WatcherUpdateProperties, + Operation, + OperationDisplay, + KnownOrigin, + Origin, + KnownActionType, + ActionType, + KnownVersions, +} from "./models.js"; diff --git a/sdk/databasewatcher/arm-databasewatcher/src/models/models.ts b/sdk/databasewatcher/arm-databasewatcher/src/models/models.ts new file mode 100644 index 000000000000..09b6c525d281 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/src/models/models.ts @@ -0,0 +1,1337 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +/** Concrete proxy resource types can be created by aliasing this type using a specific property type. */ +export interface SharedPrivateLinkResource extends ProxyResource { + /** The resource-specific properties for this resource. */ + properties?: SharedPrivateLinkResourceProperties; +} + +export function sharedPrivateLinkResourceSerializer(item: SharedPrivateLinkResource): any { + return { + properties: !item["properties"] + ? item["properties"] + : sharedPrivateLinkResourcePropertiesSerializer(item["properties"]), + }; +} + +export function sharedPrivateLinkResourceDeserializer(item: any): SharedPrivateLinkResource { + return { + id: item["id"], + name: item["name"], + type: item["type"], + systemData: !item["systemData"] + ? item["systemData"] + : systemDataDeserializer(item["systemData"]), + properties: !item["properties"] + ? item["properties"] + : sharedPrivateLinkResourcePropertiesDeserializer(item["properties"]), + }; +} + +/** The generic properties of a Shared Private Link resource. */ +export interface SharedPrivateLinkResourceProperties { + /** The resource ID of the resource the shared private link resource is for. */ + privateLinkResourceId: string; + /** The group id from the provider of resource the shared private link resource is for. */ + groupId: string; + /** The request message for requesting approval of the shared private link resource. */ + requestMessage: string; + /** The DNS zone to be included in the DNS name of the shared private link. Value is required for Azure Data Explorer clusters and SQL managed instances. The value to use is the second segment of the host FQDN name of the resource that the shared private link resource is for. */ + dnsZone?: string; + /** Status of the shared private link resource. Can be Pending, Approved, Rejected or Disconnected. */ + readonly status?: SharedPrivateLinkResourceStatus; + /** The provisioning state of the resource. */ + readonly provisioningState?: ResourceProvisioningState; +} + +export function sharedPrivateLinkResourcePropertiesSerializer( + item: SharedPrivateLinkResourceProperties, +): any { + return { + privateLinkResourceId: item["privateLinkResourceId"], + groupId: item["groupId"], + requestMessage: item["requestMessage"], + dnsZone: item["dnsZone"], + }; +} + +export function sharedPrivateLinkResourcePropertiesDeserializer( + item: any, +): SharedPrivateLinkResourceProperties { + return { + privateLinkResourceId: item["privateLinkResourceId"], + groupId: item["groupId"], + requestMessage: item["requestMessage"], + dnsZone: item["dnsZone"], + status: item["status"], + provisioningState: item["provisioningState"], + }; +} + +/** Status of the shared private link resource. Can be Pending, Approved, Rejected or Disconnected. */ +export enum KnownSharedPrivateLinkResourceStatus { + /** The shared private link connection request was not yet authorized by the resource owner. */ + Pending = "Pending", + /** The shared private link connection request was approved by the resource owner. */ + Approved = "Approved", + /** The shared private link connection request was rejected by the resource owner. */ + Rejected = "Rejected", + /** The shared private link connection request was disconnected by the resource owner. */ + Disconnected = "Disconnected", +} + +/** + * Status of the shared private link resource. Can be Pending, Approved, Rejected or Disconnected. \ + * {@link KnownSharedPrivateLinkResourceStatus} can be used interchangeably with SharedPrivateLinkResourceStatus, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **Pending**: The shared private link connection request was not yet authorized by the resource owner. \ + * **Approved**: The shared private link connection request was approved by the resource owner. \ + * **Rejected**: The shared private link connection request was rejected by the resource owner. \ + * **Disconnected**: The shared private link connection request was disconnected by the resource owner. + */ +export type SharedPrivateLinkResourceStatus = string; + +/** The provisioning state of a resource type. */ +export enum KnownResourceProvisioningState { + /** Resource has been created. */ + Succeeded = "Succeeded", + /** Resource creation failed. */ + Failed = "Failed", + /** Resource creation was canceled. */ + Canceled = "Canceled", +} + +/** + * The provisioning state of a resource type. \ + * {@link KnownResourceProvisioningState} can be used interchangeably with ResourceProvisioningState, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **Succeeded**: Resource has been created. \ + * **Failed**: Resource creation failed. \ + * **Canceled**: Resource creation was canceled. + */ +export type ResourceProvisioningState = string; + +/** The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a location */ +export interface ProxyResource extends Resource {} + +export function proxyResourceSerializer(item: ProxyResource): any { + return item; +} + +export function proxyResourceDeserializer(item: any): ProxyResource { + return { + id: item["id"], + name: item["name"], + type: item["type"], + systemData: !item["systemData"] + ? item["systemData"] + : systemDataDeserializer(item["systemData"]), + }; +} + +/** Common fields that are returned in the response for all Azure Resource Manager resources */ +export interface Resource { + /** Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} */ + readonly id?: string; + /** The name of the resource */ + readonly name?: string; + /** The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" */ + readonly type?: string; + /** Azure Resource Manager metadata containing createdBy and modifiedBy information. */ + readonly systemData?: SystemData; +} + +export function resourceSerializer(item: Resource): any { + return item; +} + +export function resourceDeserializer(item: any): Resource { + return { + id: item["id"], + name: item["name"], + type: item["type"], + systemData: !item["systemData"] + ? item["systemData"] + : systemDataDeserializer(item["systemData"]), + }; +} + +/** Metadata pertaining to creation and last modification of the resource. */ +export interface SystemData { + /** The identity that created the resource. */ + createdBy?: string; + /** The type of identity that created the resource. */ + createdByType?: CreatedByType; + /** The timestamp of resource creation (UTC). */ + createdAt?: Date; + /** The identity that last modified the resource. */ + lastModifiedBy?: string; + /** The type of identity that last modified the resource. */ + lastModifiedByType?: CreatedByType; + /** The timestamp of resource last modification (UTC) */ + lastModifiedAt?: Date; +} + +export function systemDataDeserializer(item: any): SystemData { + return { + createdBy: item["createdBy"], + createdByType: item["createdByType"], + createdAt: !item["createdAt"] ? item["createdAt"] : new Date(item["createdAt"]), + lastModifiedBy: item["lastModifiedBy"], + lastModifiedByType: item["lastModifiedByType"], + lastModifiedAt: !item["lastModifiedAt"] + ? item["lastModifiedAt"] + : new Date(item["lastModifiedAt"]), + }; +} + +/** The kind of entity that created the resource. */ +export enum KnownCreatedByType { + /** The entity was created by a user. */ + User = "User", + /** The entity was created by an application. */ + Application = "Application", + /** The entity was created by a managed identity. */ + ManagedIdentity = "ManagedIdentity", + /** The entity was created by a key. */ + Key = "Key", +} + +/** + * The kind of entity that created the resource. \ + * {@link KnowncreatedByType} can be used interchangeably with createdByType, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **User**: The entity was created by a user. \ + * **Application**: The entity was created by an application. \ + * **ManagedIdentity**: The entity was created by a managed identity. \ + * **Key**: The entity was created by a key. + */ +export type CreatedByType = string; + +/** Common error response for all Azure Resource Manager APIs to return error details for failed operations. */ +export interface ErrorResponse { + /** The error object. */ + error?: ErrorDetail; +} + +export function errorResponseDeserializer(item: any): ErrorResponse { + return { + error: !item["error"] ? item["error"] : errorDetailDeserializer(item["error"]), + }; +} + +/** The error detail. */ +export interface ErrorDetail { + /** The error code. */ + readonly code?: string; + /** The error message. */ + readonly message?: string; + /** The error target. */ + readonly target?: string; + /** The error details. */ + readonly details?: ErrorDetail[]; + /** The error additional info. */ + readonly additionalInfo?: ErrorAdditionalInfo[]; +} + +export function errorDetailDeserializer(item: any): ErrorDetail { + return { + code: item["code"], + message: item["message"], + target: item["target"], + details: !item["details"] ? item["details"] : errorDetailArrayDeserializer(item["details"]), + additionalInfo: !item["additionalInfo"] + ? item["additionalInfo"] + : errorAdditionalInfoArrayDeserializer(item["additionalInfo"]), + }; +} + +export function errorDetailArrayDeserializer(result: Array): any[] { + return result.map((item) => { + return errorDetailDeserializer(item); + }); +} + +export function errorAdditionalInfoArrayDeserializer(result: Array): any[] { + return result.map((item) => { + return errorAdditionalInfoDeserializer(item); + }); +} + +/** The resource management error additional info. */ +export interface ErrorAdditionalInfo { + /** The additional info type. */ + readonly type?: string; + /** The additional info. */ + readonly info?: Record; +} + +export function errorAdditionalInfoDeserializer(item: any): ErrorAdditionalInfo { + return { + type: item["type"], + info: !item["info"] ? item["info"] : _errorAdditionalInfoInfoDeserializer(item["info"]), + }; +} + +/** model interface _ErrorAdditionalInfoInfo */ +export interface _ErrorAdditionalInfoInfo {} + +export function _errorAdditionalInfoInfoDeserializer(item: any): _ErrorAdditionalInfoInfo { + return item; +} + +/** The response of a SharedPrivateLinkResource list operation. */ +export interface _SharedPrivateLinkResourceListResult { + /** The SharedPrivateLinkResource items on this page */ + value: SharedPrivateLinkResource[]; + /** The link to the next page of items */ + nextLink?: string; +} + +export function _sharedPrivateLinkResourceListResultDeserializer( + item: any, +): _SharedPrivateLinkResourceListResult { + return { + value: sharedPrivateLinkResourceArrayDeserializer(item["value"]), + nextLink: item["nextLink"], + }; +} + +export function sharedPrivateLinkResourceArraySerializer( + result: Array, +): any[] { + return result.map((item) => { + return sharedPrivateLinkResourceSerializer(item); + }); +} + +export function sharedPrivateLinkResourceArrayDeserializer( + result: Array, +): any[] { + return result.map((item) => { + return sharedPrivateLinkResourceDeserializer(item); + }); +} + +/** Concrete proxy resource types can be created by aliasing this type using a specific property type. */ +export interface Target extends ProxyResource { + /** The resource-specific properties for this resource. */ + properties?: TargetPropertiesUnion; +} + +export function targetSerializer(item: Target): any { + return { + properties: !item["properties"] + ? item["properties"] + : targetPropertiesUnionSerializer(item["properties"]), + }; +} + +export function targetDeserializer(item: any): Target { + return { + id: item["id"], + name: item["name"], + type: item["type"], + systemData: !item["systemData"] + ? item["systemData"] + : systemDataDeserializer(item["systemData"]), + properties: !item["properties"] + ? item["properties"] + : targetPropertiesUnionDeserializer(item["properties"]), + }; +} + +/** The generic properties of a target. */ +export interface TargetProperties { + /** Discriminator property for TargetProperties. */ + /** The discriminator possible values: SqlDb, SqlEp, SqlMi */ + targetType: string; + /** The type of authentication to use when connecting to a target. */ + targetAuthenticationType: TargetAuthenticationType; + /** To use SQL authentication when connecting to targets, specify the vault where the login name and password secrets are stored. */ + targetVault?: VaultSecret; + /** The server name to use in the connection string when connecting to a target. Port number and instance name must be specified separately. */ + connectionServerName: string; + /** The provisioning state of the resource. */ + readonly provisioningState?: ResourceProvisioningState; +} + +export function targetPropertiesSerializer(item: TargetProperties): any { + return { + targetType: item["targetType"], + targetAuthenticationType: item["targetAuthenticationType"], + targetVault: !item["targetVault"] + ? item["targetVault"] + : vaultSecretSerializer(item["targetVault"]), + connectionServerName: item["connectionServerName"], + }; +} + +export function targetPropertiesDeserializer(item: any): TargetProperties { + return { + targetType: item["targetType"], + targetAuthenticationType: item["targetAuthenticationType"], + targetVault: !item["targetVault"] + ? item["targetVault"] + : vaultSecretDeserializer(item["targetVault"]), + connectionServerName: item["connectionServerName"], + provisioningState: item["provisioningState"], + }; +} + +/** Alias for TargetPropertiesUnion */ +export type TargetPropertiesUnion = + | SqlDbSingleDatabaseTargetProperties + | SqlDbElasticPoolTargetProperties + | SqlMiTargetProperties + | TargetProperties; + +export function targetPropertiesUnionSerializer(item: TargetPropertiesUnion): any { + switch (item.targetType) { + case "SqlDb": + return sqlDbSingleDatabaseTargetPropertiesSerializer( + item as SqlDbSingleDatabaseTargetProperties, + ); + + case "SqlEp": + return sqlDbElasticPoolTargetPropertiesSerializer(item as SqlDbElasticPoolTargetProperties); + + case "SqlMi": + return sqlMiTargetPropertiesSerializer(item as SqlMiTargetProperties); + + default: + return targetPropertiesSerializer(item); + } +} + +export function targetPropertiesUnionDeserializer(item: any): TargetPropertiesUnion { + switch (item.targetType) { + case "SqlDb": + return sqlDbSingleDatabaseTargetPropertiesDeserializer( + item as SqlDbSingleDatabaseTargetProperties, + ); + + case "SqlEp": + return sqlDbElasticPoolTargetPropertiesDeserializer(item as SqlDbElasticPoolTargetProperties); + + case "SqlMi": + return sqlMiTargetPropertiesDeserializer(item as SqlMiTargetProperties); + + default: + return targetPropertiesDeserializer(item); + } +} + +/** The type of authentication to use when connecting to a target. */ +export enum KnownTargetAuthenticationType { + /** The Azure Active Directory authentication. */ + Aad = "Aad", + /** The SQL password authentication. */ + Sql = "Sql", +} + +/** + * The type of authentication to use when connecting to a target. \ + * {@link KnownTargetAuthenticationType} can be used interchangeably with TargetAuthenticationType, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **Aad**: The Azure Active Directory authentication. \ + * **Sql**: The SQL password authentication. + */ +export type TargetAuthenticationType = string; + +/** The vault specific details required if using SQL authentication to connect to a target. */ +export interface VaultSecret { + /** The Azure resource ID of the Key Vault instance storing database authentication secrets. */ + akvResourceId?: string; + /** The path to the Key Vault secret storing the login name (aka user name, aka account name) for authentication to a target. */ + akvTargetUser?: string; + /** The path to the Key Vault secret storing the password for authentication to a target. */ + akvTargetPassword?: string; +} + +export function vaultSecretSerializer(item: VaultSecret): any { + return { + akvResourceId: item["akvResourceId"], + akvTargetUser: item["akvTargetUser"], + akvTargetPassword: item["akvTargetPassword"], + }; +} + +export function vaultSecretDeserializer(item: any): VaultSecret { + return { + akvResourceId: item["akvResourceId"], + akvTargetUser: item["akvTargetUser"], + akvTargetPassword: item["akvTargetPassword"], + }; +} + +/** The properties specific to single database in Azure SQL Database. */ +export interface SqlDbSingleDatabaseTargetProperties extends TargetProperties { + /** The Azure SQL DB single database target. */ + targetType: "SqlDb"; + /** The Azure resource ID of an Azure SQL DB single database target. */ + sqlDbResourceId: string; + /** Set to true to monitor a high availability replica of specified target, if any. */ + readIntent?: boolean; +} + +export function sqlDbSingleDatabaseTargetPropertiesSerializer( + item: SqlDbSingleDatabaseTargetProperties, +): any { + return { + targetType: item["targetType"], + targetAuthenticationType: item["targetAuthenticationType"], + targetVault: !item["targetVault"] + ? item["targetVault"] + : vaultSecretSerializer(item["targetVault"]), + connectionServerName: item["connectionServerName"], + sqlDbResourceId: item["sqlDbResourceId"], + readIntent: item["readIntent"], + }; +} + +export function sqlDbSingleDatabaseTargetPropertiesDeserializer( + item: any, +): SqlDbSingleDatabaseTargetProperties { + return { + targetType: item["targetType"], + targetAuthenticationType: item["targetAuthenticationType"], + targetVault: !item["targetVault"] + ? item["targetVault"] + : vaultSecretDeserializer(item["targetVault"]), + connectionServerName: item["connectionServerName"], + provisioningState: item["provisioningState"], + sqlDbResourceId: item["sqlDbResourceId"], + readIntent: item["readIntent"], + }; +} + +/** The properties specific to elastic pool in Azure SQL Database. */ +export interface SqlDbElasticPoolTargetProperties extends TargetProperties { + /** The Azure SQL DB elastic pool target. */ + targetType: "SqlEp"; + /** The Azure resource ID of an Azure SQL DB elastic pool target. */ + sqlEpResourceId: string; + /** The Azure resource ID of the anchor database used to connect to an elastic pool. */ + anchorDatabaseResourceId: string; + /** Set to true to monitor a high availability replica of specified target, if any. */ + readIntent?: boolean; +} + +export function sqlDbElasticPoolTargetPropertiesSerializer( + item: SqlDbElasticPoolTargetProperties, +): any { + return { + targetType: item["targetType"], + targetAuthenticationType: item["targetAuthenticationType"], + targetVault: !item["targetVault"] + ? item["targetVault"] + : vaultSecretSerializer(item["targetVault"]), + connectionServerName: item["connectionServerName"], + sqlEpResourceId: item["sqlEpResourceId"], + anchorDatabaseResourceId: item["anchorDatabaseResourceId"], + readIntent: item["readIntent"], + }; +} + +export function sqlDbElasticPoolTargetPropertiesDeserializer( + item: any, +): SqlDbElasticPoolTargetProperties { + return { + targetType: item["targetType"], + targetAuthenticationType: item["targetAuthenticationType"], + targetVault: !item["targetVault"] + ? item["targetVault"] + : vaultSecretDeserializer(item["targetVault"]), + connectionServerName: item["connectionServerName"], + provisioningState: item["provisioningState"], + sqlEpResourceId: item["sqlEpResourceId"], + anchorDatabaseResourceId: item["anchorDatabaseResourceId"], + readIntent: item["readIntent"], + }; +} + +/** The properties specific to Azure SQL Managed Instance targets. */ +export interface SqlMiTargetProperties extends TargetProperties { + /** The Azure SQL Managed Instance target. */ + targetType: "SqlMi"; + /** The Azure resource ID of an Azure SQL Managed Instance target. */ + sqlMiResourceId: string; + /** The TCP port number to optionally use in the connection string when connecting to an Azure SQL Managed Instance target. */ + connectionTcpPort?: number; + /** Set to true to monitor a high availability replica of specified target, if any. */ + readIntent?: boolean; +} + +export function sqlMiTargetPropertiesSerializer(item: SqlMiTargetProperties): any { + return { + targetType: item["targetType"], + targetAuthenticationType: item["targetAuthenticationType"], + targetVault: !item["targetVault"] + ? item["targetVault"] + : vaultSecretSerializer(item["targetVault"]), + connectionServerName: item["connectionServerName"], + sqlMiResourceId: item["sqlMiResourceId"], + connectionTcpPort: item["connectionTcpPort"], + readIntent: item["readIntent"], + }; +} + +export function sqlMiTargetPropertiesDeserializer(item: any): SqlMiTargetProperties { + return { + targetType: item["targetType"], + targetAuthenticationType: item["targetAuthenticationType"], + targetVault: !item["targetVault"] + ? item["targetVault"] + : vaultSecretDeserializer(item["targetVault"]), + connectionServerName: item["connectionServerName"], + provisioningState: item["provisioningState"], + sqlMiResourceId: item["sqlMiResourceId"], + connectionTcpPort: item["connectionTcpPort"], + readIntent: item["readIntent"], + }; +} + +/** The response of a Target list operation. */ +export interface _TargetListResult { + /** The Target items on this page */ + value: Target[]; + /** The link to the next page of items */ + nextLink?: string; +} + +export function _targetListResultDeserializer(item: any): _TargetListResult { + return { + value: targetArrayDeserializer(item["value"]), + nextLink: item["nextLink"], + }; +} + +export function targetArraySerializer(result: Array): any[] { + return result.map((item) => { + return targetSerializer(item); + }); +} + +export function targetArrayDeserializer(result: Array): any[] { + return result.map((item) => { + return targetDeserializer(item); + }); +} + +/** Concrete proxy resource types can be created by aliasing this type using a specific property type. */ +export interface HealthValidation extends ProxyResource { + /** The resource-specific properties for this resource. */ + properties?: HealthValidationProperties; +} + +export function healthValidationDeserializer(item: any): HealthValidation { + return { + id: item["id"], + name: item["name"], + type: item["type"], + systemData: !item["systemData"] + ? item["systemData"] + : systemDataDeserializer(item["systemData"]), + properties: !item["properties"] + ? item["properties"] + : healthValidationPropertiesDeserializer(item["properties"]), + }; +} + +/** The generic properties of the health validation resource. */ +export interface HealthValidationProperties { + /** The start time of health validation, in UTC. */ + readonly startTime: Date; + /** The end time of health validation, in UTC. */ + readonly endTime: Date; + /** The current health validation status. */ + readonly status: ValidationStatus; + /** The list of issues found by health validation. */ + readonly issues: ValidationIssue[]; + /** The provisioning state of the health validation resource. */ + readonly provisioningState?: ResourceProvisioningState; +} + +export function healthValidationPropertiesDeserializer(item: any): HealthValidationProperties { + return { + startTime: new Date(item["startTime"]), + endTime: new Date(item["endTime"]), + status: item["status"], + issues: validationIssueArrayDeserializer(item["issues"]), + provisioningState: item["provisioningState"], + }; +} + +/** Health validation status. */ +export enum KnownValidationStatus { + /** Health validation has not started. */ + NotStarted = "NotStarted", + /** Health validation is running. */ + Running = "Running", + /** Health validation completed successfully. */ + Succeeded = "Succeeded", + /** Health validation failed. */ + Failed = "Failed", + /** Health validation was canceled. */ + Canceled = "Canceled", + /** Health validation timed out. */ + TimedOut = "TimedOut", +} + +/** + * Health validation status. \ + * {@link KnownvalidationStatus} can be used interchangeably with validationStatus, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **NotStarted**: Health validation has not started. \ + * **Running**: Health validation is running. \ + * **Succeeded**: Health validation completed successfully. \ + * **Failed**: Health validation failed. \ + * **Canceled**: Health validation was canceled. \ + * **TimedOut**: Health validation timed out. + */ +export type ValidationStatus = string; + +export function validationIssueArrayDeserializer(result: Array): any[] { + return result.map((item) => { + return validationIssueDeserializer(item); + }); +} + +/** The model of a health validation issue. */ +export interface ValidationIssue { + /** The error code of the issue. */ + readonly errorCode: string; + /** The error message of the issue. */ + readonly errorMessage: string; + /** The additional details for the issue. */ + readonly additionalDetails?: string; + /** The recommendation for resolving the issue. */ + readonly recommendationMessage: string; + /** The URL related to resolving the issue. */ + readonly recommendationUrl?: string; + /** The resource ID of the Azure resource related to the issue. */ + readonly relatedResourceId?: string; + /** The type of the Azure resource related to the issue. */ + readonly relatedResourceType?: string; +} + +export function validationIssueDeserializer(item: any): ValidationIssue { + return { + errorCode: item["errorCode"], + errorMessage: item["errorMessage"], + additionalDetails: item["additionalDetails"], + recommendationMessage: item["recommendationMessage"], + recommendationUrl: item["recommendationUrl"], + relatedResourceId: item["relatedResourceId"], + relatedResourceType: item["relatedResourceType"], + }; +} + +/** The response of a HealthValidation list operation. */ +export interface _HealthValidationListResult { + /** The HealthValidation items on this page */ + value: HealthValidation[]; + /** The link to the next page of items */ + nextLink?: string; +} + +export function _healthValidationListResultDeserializer(item: any): _HealthValidationListResult { + return { + value: healthValidationArrayDeserializer(item["value"]), + nextLink: item["nextLink"], + }; +} + +export function healthValidationArrayDeserializer(result: Array): any[] { + return result.map((item) => { + return healthValidationDeserializer(item); + }); +} + +/** Concrete proxy resource types can be created by aliasing this type using a specific property type. */ +export interface AlertRuleResource extends ProxyResource { + /** The resource-specific properties for this resource. */ + properties?: AlertRuleResourceProperties; +} + +export function alertRuleResourceSerializer(item: AlertRuleResource): any { + return { + properties: !item["properties"] + ? item["properties"] + : alertRuleResourcePropertiesSerializer(item["properties"]), + }; +} + +export function alertRuleResourceDeserializer(item: any): AlertRuleResource { + return { + id: item["id"], + name: item["name"], + type: item["type"], + systemData: !item["systemData"] + ? item["systemData"] + : systemDataDeserializer(item["systemData"]), + properties: !item["properties"] + ? item["properties"] + : alertRuleResourcePropertiesDeserializer(item["properties"]), + }; +} + +/** The generic properties of the alert rule proxy resource. */ +export interface AlertRuleResourceProperties { + /** The resource ID of the alert rule resource. */ + alertRuleResourceId: string; + /** The properties with which the alert rule resource was created. */ + createdWithProperties: AlertRuleCreationProperties; + /** The creation time of the alert rule resource. */ + creationTime: Date; + /** The provisioning state of the alert rule resource. */ + readonly provisioningState?: ResourceProvisioningState; + /** The template ID associated with alert rule resource. */ + alertRuleTemplateId: string; + /** The alert rule template version. */ + alertRuleTemplateVersion: string; +} + +export function alertRuleResourcePropertiesSerializer(item: AlertRuleResourceProperties): any { + return { + alertRuleResourceId: item["alertRuleResourceId"], + createdWithProperties: item["createdWithProperties"], + creationTime: item["creationTime"].toISOString(), + alertRuleTemplateId: item["alertRuleTemplateId"], + alertRuleTemplateVersion: item["alertRuleTemplateVersion"], + }; +} + +export function alertRuleResourcePropertiesDeserializer(item: any): AlertRuleResourceProperties { + return { + alertRuleResourceId: item["alertRuleResourceId"], + createdWithProperties: item["createdWithProperties"], + creationTime: new Date(item["creationTime"]), + provisioningState: item["provisioningState"], + alertRuleTemplateId: item["alertRuleTemplateId"], + alertRuleTemplateVersion: item["alertRuleTemplateVersion"], + }; +} + +/** The properties with which the alert rule resource was created. */ +export enum KnownAlertRuleCreationProperties { + /** The alert rule was created with an action group. */ + CreatedWithActionGroup = "CreatedWithActionGroup", + /** The alert rule was created with no properties. */ + None = "None", +} + +/** + * The properties with which the alert rule resource was created. \ + * {@link KnownalertRuleCreationProperties} can be used interchangeably with alertRuleCreationProperties, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **CreatedWithActionGroup**: The alert rule was created with an action group. \ + * **None**: The alert rule was created with no properties. + */ +export type AlertRuleCreationProperties = string; + +/** The response of a AlertRuleResource list operation. */ +export interface _AlertRuleResourceListResult { + /** The AlertRuleResource items on this page */ + value: AlertRuleResource[]; + /** The link to the next page of items */ + nextLink?: string; +} + +export function _alertRuleResourceListResultDeserializer(item: any): _AlertRuleResourceListResult { + return { + value: alertRuleResourceArrayDeserializer(item["value"]), + nextLink: item["nextLink"], + }; +} + +export function alertRuleResourceArraySerializer(result: Array): any[] { + return result.map((item) => { + return alertRuleResourceSerializer(item); + }); +} + +export function alertRuleResourceArrayDeserializer(result: Array): any[] { + return result.map((item) => { + return alertRuleResourceDeserializer(item); + }); +} + +/** The DatabaseWatcherProviderHub resource. */ +export interface Watcher extends TrackedResource { + /** The resource-specific properties for this resource. */ + properties?: WatcherProperties; + /** The managed service identities assigned to this resource. */ + identity?: ManagedServiceIdentityV4; +} + +export function watcherSerializer(item: Watcher): any { + return { + tags: item["tags"], + location: item["location"], + properties: !item["properties"] + ? item["properties"] + : watcherPropertiesSerializer(item["properties"]), + identity: !item["identity"] + ? item["identity"] + : managedServiceIdentityV4Serializer(item["identity"]), + }; +} + +export function watcherDeserializer(item: any): Watcher { + return { + tags: item["tags"], + location: item["location"], + id: item["id"], + name: item["name"], + type: item["type"], + systemData: !item["systemData"] + ? item["systemData"] + : systemDataDeserializer(item["systemData"]), + properties: !item["properties"] + ? item["properties"] + : watcherPropertiesDeserializer(item["properties"]), + identity: !item["identity"] + ? item["identity"] + : managedServiceIdentityV4Deserializer(item["identity"]), + }; +} + +/** The RP specific properties of the resource. */ +export interface WatcherProperties { + /** The data store for collected monitoring data. */ + datastore?: Datastore; + /** The monitoring collection status of the watcher. */ + readonly status?: WatcherStatus; + /** The provisioning state of the resource watcher. */ + readonly provisioningState?: DatabaseWatcherProvisioningState; + /** The resource ID of a user-assigned managed identity that will be assigned to a new alert rule. */ + defaultAlertRuleIdentityResourceId?: string; +} + +export function watcherPropertiesSerializer(item: WatcherProperties): any { + return { + datastore: !item["datastore"] ? item["datastore"] : datastoreSerializer(item["datastore"]), + defaultAlertRuleIdentityResourceId: item["defaultAlertRuleIdentityResourceId"], + }; +} + +export function watcherPropertiesDeserializer(item: any): WatcherProperties { + return { + datastore: !item["datastore"] ? item["datastore"] : datastoreDeserializer(item["datastore"]), + status: item["status"], + provisioningState: item["provisioningState"], + defaultAlertRuleIdentityResourceId: item["defaultAlertRuleIdentityResourceId"], + }; +} + +/** The properties of a data store. */ +export interface Datastore { + /** The Azure resource ID of an Azure Data Explorer cluster. */ + adxClusterResourceId?: string; + /** The Kusto cluster display name. */ + kustoClusterDisplayName?: string; + /** The Kusto cluster URI. */ + kustoClusterUri: string; + /** The Kusto data ingestion URI. */ + kustoDataIngestionUri: string; + /** The name of a Kusto database. */ + kustoDatabaseName: string; + /** The Kusto management URL. */ + kustoManagementUrl: string; + /** The type of a Kusto offering. */ + kustoOfferingType: KustoOfferingType; +} + +export function datastoreSerializer(item: Datastore): any { + return { + adxClusterResourceId: item["adxClusterResourceId"], + kustoClusterDisplayName: item["kustoClusterDisplayName"], + kustoClusterUri: item["kustoClusterUri"], + kustoDataIngestionUri: item["kustoDataIngestionUri"], + kustoDatabaseName: item["kustoDatabaseName"], + kustoManagementUrl: item["kustoManagementUrl"], + kustoOfferingType: item["kustoOfferingType"], + }; +} + +export function datastoreDeserializer(item: any): Datastore { + return { + adxClusterResourceId: item["adxClusterResourceId"], + kustoClusterDisplayName: item["kustoClusterDisplayName"], + kustoClusterUri: item["kustoClusterUri"], + kustoDataIngestionUri: item["kustoDataIngestionUri"], + kustoDatabaseName: item["kustoDatabaseName"], + kustoManagementUrl: item["kustoManagementUrl"], + kustoOfferingType: item["kustoOfferingType"], + }; +} + +/** The type of Kusto offering. */ +export enum KnownKustoOfferingType { + /** The Azure Data Explorer cluster Kusto offering. */ + Adx = "adx", + /** The free Azure Data Explorer cluster Kusto offering. */ + Free = "free", + /** The Fabric Real-Time Analytics Kusto offering. */ + Fabric = "fabric", +} + +/** + * The type of Kusto offering. \ + * {@link KnownKustoOfferingType} can be used interchangeably with KustoOfferingType, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **adx**: The Azure Data Explorer cluster Kusto offering. \ + * **free**: The free Azure Data Explorer cluster Kusto offering. \ + * **fabric**: The Fabric Real-Time Analytics Kusto offering. + */ +export type KustoOfferingType = string; + +/** The monitoring collection status of a watcher. */ +export enum KnownWatcherStatus { + /** Denotes the watcher is in a starting state. */ + Starting = "Starting", + /** Denotes the watcher is in a running state. */ + Running = "Running", + /** Denotes the watcher is in a stopping state. */ + Stopping = "Stopping", + /** Denotes the watcher is in a stopped state. */ + Stopped = "Stopped", + /** Denotes the watcher is in a deleting state. */ + Deleting = "Deleting", +} + +/** + * The monitoring collection status of a watcher. \ + * {@link KnownWatcherStatus} can be used interchangeably with WatcherStatus, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **Starting**: Denotes the watcher is in a starting state. \ + * **Running**: Denotes the watcher is in a running state. \ + * **Stopping**: Denotes the watcher is in a stopping state. \ + * **Stopped**: Denotes the watcher is in a stopped state. \ + * **Deleting**: Denotes the watcher is in a deleting state. + */ +export type WatcherStatus = string; + +/** The status of the last provisioning operation performed on the resource. */ +export enum KnownDatabaseWatcherProvisioningState { + /** Resource has been created. */ + Succeeded = "Succeeded", + /** Resource creation failed. */ + Failed = "Failed", + /** Resource creation was canceled. */ + Canceled = "Canceled", +} + +/** + * The status of the last provisioning operation performed on the resource. \ + * {@link KnownDatabaseWatcherProvisioningState} can be used interchangeably with DatabaseWatcherProvisioningState, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **Succeeded**: Resource has been created. \ + * **Failed**: Resource creation failed. \ + * **Canceled**: Resource creation was canceled. + */ +export type DatabaseWatcherProvisioningState = string; + +/** Managed service identity (system assigned and/or user assigned identities) */ +export interface ManagedServiceIdentityV4 { + /** The service principal ID of the system assigned identity. This property will only be provided for a system assigned identity. */ + readonly principalId?: string; + /** The tenant ID of the system assigned identity. This property will only be provided for a system assigned identity. */ + readonly tenantId?: string; + /** The type of managed identity assigned to this resource. */ + type: ManagedServiceIdentityType; + /** The identities assigned to this resource by the user. */ + userAssignedIdentities?: Record; +} + +export function managedServiceIdentityV4Serializer(item: ManagedServiceIdentityV4): any { + return { + type: item["type"], + userAssignedIdentities: !item["userAssignedIdentities"] + ? item["userAssignedIdentities"] + : userAssignedIdentityRecordSerializer(item["userAssignedIdentities"]), + }; +} + +export function managedServiceIdentityV4Deserializer(item: any): ManagedServiceIdentityV4 { + return { + principalId: item["principalId"], + tenantId: item["tenantId"], + type: item["type"], + userAssignedIdentities: !item["userAssignedIdentities"] + ? item["userAssignedIdentities"] + : userAssignedIdentityRecordDeserializer(item["userAssignedIdentities"]), + }; +} + +/** Type of managed service identity (where both SystemAssigned and UserAssigned types are allowed). */ +export enum KnownManagedServiceIdentityType { + /** No managed identity. */ + None = "None", + /** System assigned managed identity. */ + SystemAssigned = "SystemAssigned", + /** User assigned managed identity. */ + UserAssigned = "UserAssigned", + /** System and user assigned managed identity. */ + SystemAndUserAssigned = "SystemAssigned, UserAssigned", +} + +/** + * Type of managed service identity (where both SystemAssigned and UserAssigned types are allowed). \ + * {@link KnownManagedServiceIdentityType} can be used interchangeably with ManagedServiceIdentityType, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **None**: No managed identity. \ + * **SystemAssigned**: System assigned managed identity. \ + * **UserAssigned**: User assigned managed identity. \ + * **SystemAssigned, UserAssigned**: System and user assigned managed identity. + */ +export type ManagedServiceIdentityType = string; + +export function userAssignedIdentityRecordSerializer( + item: Record, +): Record { + const result: Record = {}; + Object.keys(item).map((key) => { + result[key] = !item[key] ? item[key] : userAssignedIdentitySerializer(item[key]); + }); + return result; +} + +export function userAssignedIdentityRecordDeserializer( + item: Record, +): Record { + const result: Record = {}; + Object.keys(item).map((key) => { + result[key] = !item[key] ? item[key] : userAssignedIdentityDeserializer(item[key]); + }); + return result; +} + +/** User assigned identity properties */ +export interface UserAssignedIdentity { + /** The principal ID of the assigned identity. */ + readonly principalId?: string; + /** The client ID of the assigned identity. */ + readonly clientId?: string; +} + +export function userAssignedIdentitySerializer(item: UserAssignedIdentity): any { + return item; +} + +export function userAssignedIdentityDeserializer(item: any): UserAssignedIdentity { + return { + principalId: item["principalId"], + clientId: item["clientId"], + }; +} + +/** The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' and a 'location' */ +export interface TrackedResource extends Resource { + /** Resource tags. */ + tags?: Record; + /** The geo-location where the resource lives */ + location: string; +} + +export function trackedResourceSerializer(item: TrackedResource): any { + return { tags: item["tags"], location: item["location"] }; +} + +export function trackedResourceDeserializer(item: any): TrackedResource { + return { + id: item["id"], + name: item["name"], + type: item["type"], + systemData: !item["systemData"] + ? item["systemData"] + : systemDataDeserializer(item["systemData"]), + tags: item["tags"], + location: item["location"], + }; +} + +/** The type used for update operations of the Watcher. */ +export interface WatcherUpdate { + /** The managed service identities assigned to this resource. */ + identity?: ManagedServiceIdentityV4; + /** Resource tags. */ + tags?: Record; + /** The resource-specific properties for this resource. */ + properties?: WatcherUpdateProperties; +} + +export function watcherUpdateSerializer(item: WatcherUpdate): any { + return { + identity: !item["identity"] + ? item["identity"] + : managedServiceIdentityV4Serializer(item["identity"]), + tags: item["tags"], + properties: !item["properties"] + ? item["properties"] + : watcherUpdatePropertiesSerializer(item["properties"]), + }; +} + +/** The updatable properties of the Watcher. */ +export interface WatcherUpdateProperties { + /** The data store for collected monitoring data. */ + datastore?: Datastore; + /** The resource ID of a user-assigned managed identity that will be assigned to a new alert rule. */ + defaultAlertRuleIdentityResourceId?: string; +} + +export function watcherUpdatePropertiesSerializer(item: WatcherUpdateProperties): any { + return { + datastore: !item["datastore"] ? item["datastore"] : datastoreSerializer(item["datastore"]), + defaultAlertRuleIdentityResourceId: item["defaultAlertRuleIdentityResourceId"], + }; +} + +/** The response of a Watcher list operation. */ +export interface _WatcherListResult { + /** The Watcher items on this page */ + value: Watcher[]; + /** The link to the next page of items */ + nextLink?: string; +} + +export function _watcherListResultDeserializer(item: any): _WatcherListResult { + return { + value: watcherArrayDeserializer(item["value"]), + nextLink: item["nextLink"], + }; +} + +export function watcherArraySerializer(result: Array): any[] { + return result.map((item) => { + return watcherSerializer(item); + }); +} + +export function watcherArrayDeserializer(result: Array): any[] { + return result.map((item) => { + return watcherDeserializer(item); + }); +} + +/** A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results. */ +export interface _OperationListResult { + /** The Operation items on this page */ + value: Operation[]; + /** The link to the next page of items */ + nextLink?: string; +} + +export function _operationListResultDeserializer(item: any): _OperationListResult { + return { + value: operationArrayDeserializer(item["value"]), + nextLink: item["nextLink"], + }; +} + +export function operationArrayDeserializer(result: Array): any[] { + return result.map((item) => { + return operationDeserializer(item); + }); +} + +/** Details of a REST API operation, returned from the Resource Provider Operations API */ +export interface Operation { + /** The name of the operation, as per Resource-Based Access Control (RBAC). Examples: "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action" */ + readonly name?: string; + /** Whether the operation applies to data-plane. This is "true" for data-plane operations and "false" for Azure Resource Manager/control-plane operations. */ + readonly isDataAction?: boolean; + /** Localized display information for this particular operation. */ + display?: OperationDisplay; + /** The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default value is "user,system" */ + readonly origin?: Origin; + /** Extensible enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. */ + readonly actionType?: ActionType; +} + +export function operationDeserializer(item: any): Operation { + return { + name: item["name"], + isDataAction: item["isDataAction"], + display: !item["display"] ? item["display"] : operationDisplayDeserializer(item["display"]), + origin: item["origin"], + actionType: item["actionType"], + }; +} + +/** Localized display information for and operation. */ +export interface OperationDisplay { + /** The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft Compute". */ + readonly provider?: string; + /** The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or "Job Schedule Collections". */ + readonly resource?: string; + /** The concise, localized friendly name for the operation; suitable for dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual Machine". */ + readonly operation?: string; + /** The short, localized friendly description of the operation; suitable for tool tips and detailed views. */ + readonly description?: string; +} + +export function operationDisplayDeserializer(item: any): OperationDisplay { + return { + provider: item["provider"], + resource: item["resource"], + operation: item["operation"], + description: item["description"], + }; +} + +/** The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default value is "user,system" */ +export enum KnownOrigin { + /** Indicates the operation is initiated by a user. */ + User = "user", + /** Indicates the operation is initiated by a system. */ + System = "system", + /** Indicates the operation is initiated by a user or system. */ + UserSystem = "user,system", +} + +/** + * The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default value is "user,system" \ + * {@link KnownOrigin} can be used interchangeably with Origin, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **user**: Indicates the operation is initiated by a user. \ + * **system**: Indicates the operation is initiated by a system. \ + * **user,system**: Indicates the operation is initiated by a user or system. + */ +export type Origin = string; + +/** Extensible enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. */ +export enum KnownActionType { + /** Actions are for internal-only APIs. */ + Internal = "Internal", +} + +/** + * Extensible enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. \ + * {@link KnownActionType} can be used interchangeably with ActionType, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **Internal**: Actions are for internal-only APIs. + */ +export type ActionType = string; + +/** Versions info. */ +export enum KnownVersions { + /** The 2025-01-02 version. */ + V20250102 = "2025-01-02", +} diff --git a/sdk/databasewatcher/arm-databasewatcher/src/restorePollerHelpers.ts b/sdk/databasewatcher/arm-databasewatcher/src/restorePollerHelpers.ts new file mode 100644 index 000000000000..e6877716fd62 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/src/restorePollerHelpers.ts @@ -0,0 +1,200 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { DatabaseWatcherClient } from "./databaseWatcherClient.js"; +import { + _sharedPrivateLinkResourcesDeleteDeserialize, + _sharedPrivateLinkResourcesCreateDeserialize, +} from "./api/sharedPrivateLinkResources/index.js"; +import { _healthValidationsStartValidationDeserialize } from "./api/healthValidations/index.js"; +import { + _watchersStopDeserialize, + _watchersStartDeserialize, + _watchersDeleteDeserialize, + _watchersUpdateDeserialize, + _watchersCreateOrUpdateDeserialize, +} from "./api/watchers/index.js"; +import { getLongRunningPoller } from "./static-helpers/pollingHelpers.js"; +import { OperationOptions, PathUncheckedResponse } from "@azure-rest/core-client"; +import { AbortSignalLike } from "@azure/abort-controller"; +import { + PollerLike, + OperationState, + deserializeState, + ResourceLocationConfig, +} from "@azure/core-lro"; + +export interface RestorePollerOptions< + TResult, + TResponse extends PathUncheckedResponse = PathUncheckedResponse, +> extends OperationOptions { + /** Delay to wait until next poll, in milliseconds. */ + updateIntervalInMs?: number; + /** + * The signal which can be used to abort requests. + */ + abortSignal?: AbortSignalLike; + /** Deserialization function for raw response body */ + processResponseBody?: (result: TResponse) => Promise; +} + +/** + * Creates a poller from the serialized state of another poller. This can be + * useful when you want to create pollers on a different host or a poller + * needs to be constructed after the original one is not in scope. + */ +export function restorePoller( + client: DatabaseWatcherClient, + serializedState: string, + sourceOperation: (...args: any[]) => PollerLike, TResult>, + options?: RestorePollerOptions, +): PollerLike, TResult> { + const pollerConfig = deserializeState(serializedState).config; + const { initialRequestUrl, requestMethod, metadata } = pollerConfig; + if (!initialRequestUrl || !requestMethod) { + throw new Error( + `Invalid serialized state: ${serializedState} for sourceOperation ${sourceOperation?.name}`, + ); + } + const resourceLocationConfig = metadata?.["resourceLocationConfig"] as + | ResourceLocationConfig + | undefined; + const { deserializer, expectedStatuses = [] } = + getDeserializationHelper(initialRequestUrl, requestMethod) ?? {}; + const deserializeHelper = options?.processResponseBody ?? deserializer; + if (!deserializeHelper) { + throw new Error( + `Please ensure the operation is in this client! We can't find its deserializeHelper for ${sourceOperation?.name}.`, + ); + } + return getLongRunningPoller( + (client as any)["_client"] ?? client, + deserializeHelper as (result: TResponse) => Promise, + expectedStatuses, + { + updateIntervalInMs: options?.updateIntervalInMs, + abortSignal: options?.abortSignal, + resourceLocationConfig, + restoreFrom: serializedState, + initialRequestUrl, + }, + ); +} + +interface DeserializationHelper { + deserializer: Function; + expectedStatuses: string[]; +} + +const deserializeMap: Record = { + "DELETE /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}": + { + deserializer: _sharedPrivateLinkResourcesDeleteDeserialize, + expectedStatuses: ["202", "204", "200"], + }, + "PUT /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}": + { + deserializer: _sharedPrivateLinkResourcesCreateDeserialize, + expectedStatuses: ["200", "201"], + }, + "POST /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/healthValidations/{healthValidationName}/startValidation": + { + deserializer: _healthValidationsStartValidationDeserialize, + expectedStatuses: ["202", "200"], + }, + "POST /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/stop": + { + deserializer: _watchersStopDeserialize, + expectedStatuses: ["202", "200"], + }, + "POST /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/start": + { + deserializer: _watchersStartDeserialize, + expectedStatuses: ["202", "200"], + }, + "DELETE /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}": + { + deserializer: _watchersDeleteDeserialize, + expectedStatuses: ["202", "204", "200"], + }, + "PATCH /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}": + { + deserializer: _watchersUpdateDeserialize, + expectedStatuses: ["200", "202"], + }, + "PUT /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}": + { + deserializer: _watchersCreateOrUpdateDeserialize, + expectedStatuses: ["200", "201"], + }, +}; + +function getDeserializationHelper( + urlStr: string, + method: string, +): DeserializationHelper | undefined { + const path = new URL(urlStr).pathname; + const pathParts = path.split("/"); + + // Traverse list to match the longest candidate + // matchedLen: the length of candidate path + // matchedValue: the matched status code array + let matchedLen = -1, + matchedValue: DeserializationHelper | undefined; + + // Iterate the responseMap to find a match + for (const [key, value] of Object.entries(deserializeMap)) { + // Extracting the path from the map key which is in format + // GET /path/foo + if (!key.startsWith(method)) { + continue; + } + const candidatePath = getPathFromMapKey(key); + // Get each part of the url path + const candidateParts = candidatePath.split("/"); + + // track if we have found a match to return the values found. + let found = true; + for (let i = candidateParts.length - 1, j = pathParts.length - 1; i >= 1 && j >= 1; i--, j--) { + if (candidateParts[i]?.startsWith("{") && candidateParts[i]?.indexOf("}") !== -1) { + const start = candidateParts[i]!.indexOf("}") + 1, + end = candidateParts[i]?.length; + // If the current part of the candidate is a "template" part + // Try to use the suffix of pattern to match the path + // {guid} ==> $ + // {guid}:export ==> :export$ + const isMatched = new RegExp(`${candidateParts[i]?.slice(start, end)}`).test( + pathParts[j] || "", + ); + + if (!isMatched) { + found = false; + break; + } + continue; + } + + // If the candidate part is not a template and + // the parts don't match mark the candidate as not found + // to move on with the next candidate path. + if (candidateParts[i] !== pathParts[j]) { + found = false; + break; + } + } + + // We finished evaluating the current candidate parts + // Update the matched value if and only if we found the longer pattern + if (found && candidatePath.length > matchedLen) { + matchedLen = candidatePath.length; + matchedValue = value; + } + } + + return matchedValue; +} + +function getPathFromMapKey(mapKey: string): string { + const pathStart = mapKey.indexOf("/"); + return mapKey.slice(pathStart); +} diff --git a/sdk/databasewatcher/arm-databasewatcher/src/static-helpers/pagingHelpers.ts b/sdk/databasewatcher/arm-databasewatcher/src/static-helpers/pagingHelpers.ts new file mode 100644 index 000000000000..ce33af5f4178 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/src/static-helpers/pagingHelpers.ts @@ -0,0 +1,241 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { Client, createRestError, PathUncheckedResponse } from "@azure-rest/core-client"; +import { RestError } from "@azure/core-rest-pipeline"; + +/** + * Options for the byPage method + */ +export interface PageSettings { + /** + * A reference to a specific page to start iterating from. + */ + continuationToken?: string; +} + +/** + * An interface that describes a page of results. + */ +export type ContinuablePage = TPage & { + /** + * The token that keeps track of where to continue the iterator + */ + continuationToken?: string; +}; + +/** + * An interface that allows async iterable iteration both to completion and by page. + */ +export interface PagedAsyncIterableIterator< + TElement, + TPage = TElement[], + TPageSettings extends PageSettings = PageSettings, +> { + /** + * The next method, part of the iteration protocol + */ + next(): Promise>; + /** + * The connection to the async iterator, part of the iteration protocol + */ + [Symbol.asyncIterator](): PagedAsyncIterableIterator; + /** + * Return an AsyncIterableIterator that works a page at a time + */ + byPage: (settings?: TPageSettings) => AsyncIterableIterator>; +} + +/** + * An interface that describes how to communicate with the service. + */ +export interface PagedResult< + TElement, + TPage = TElement[], + TPageSettings extends PageSettings = PageSettings, +> { + /** + * Link to the first page of results. + */ + firstPageLink?: string; + /** + * A method that returns a page of results. + */ + getPage: (pageLink?: string) => Promise<{ page: TPage; nextPageLink?: string } | undefined>; + /** + * a function to implement the `byPage` method on the paged async iterator. + */ + byPage?: (settings?: TPageSettings) => AsyncIterableIterator>; + + /** + * A function to extract elements from a page. + */ + toElements?: (page: TPage) => TElement[]; +} + +/** + * Options for the paging helper + */ +export interface BuildPagedAsyncIteratorOptions { + itemName?: string; + nextLinkName?: string; +} + +/** + * Helper to paginate results in a generic way and return a PagedAsyncIterableIterator + */ +export function buildPagedAsyncIterator< + TElement, + TPage = TElement[], + TPageSettings extends PageSettings = PageSettings, + TResponse extends PathUncheckedResponse = PathUncheckedResponse, +>( + client: Client, + getInitialResponse: () => PromiseLike, + processResponseBody: (result: TResponse) => PromiseLike, + expectedStatuses: string[], + options: BuildPagedAsyncIteratorOptions = {}, +): PagedAsyncIterableIterator { + const itemName = options.itemName ?? "value"; + const nextLinkName = options.nextLinkName ?? "nextLink"; + const pagedResult: PagedResult = { + getPage: async (pageLink?: string) => { + const result = + pageLink === undefined + ? await getInitialResponse() + : await client.pathUnchecked(pageLink).get(); + checkPagingRequest(result, expectedStatuses); + const results = await processResponseBody(result as TResponse); + const nextLink = getNextLink(results, nextLinkName); + const values = getElements(results, itemName) as TPage; + return { + page: values, + nextPageLink: nextLink, + }; + }, + byPage: (settings?: TPageSettings) => { + const { continuationToken } = settings ?? {}; + return getPageAsyncIterator(pagedResult, { + pageLink: continuationToken, + }); + }, + }; + return getPagedAsyncIterator(pagedResult); +} + +/** + * returns an async iterator that iterates over results. It also has a `byPage` + * method that returns pages of items at once. + * + * @param pagedResult - an object that specifies how to get pages. + * @returns a paged async iterator that iterates over results. + */ + +function getPagedAsyncIterator< + TElement, + TPage = TElement[], + TPageSettings extends PageSettings = PageSettings, +>( + pagedResult: PagedResult, +): PagedAsyncIterableIterator { + const iter = getItemAsyncIterator(pagedResult); + return { + next() { + return iter.next(); + }, + [Symbol.asyncIterator]() { + return this; + }, + byPage: + pagedResult?.byPage ?? + ((settings?: TPageSettings) => { + const { continuationToken } = settings ?? {}; + return getPageAsyncIterator(pagedResult, { + pageLink: continuationToken, + }); + }), + }; +} + +async function* getItemAsyncIterator( + pagedResult: PagedResult, +): AsyncIterableIterator { + const pages = getPageAsyncIterator(pagedResult); + for await (const page of pages) { + yield* page as unknown as TElement[]; + } +} + +async function* getPageAsyncIterator( + pagedResult: PagedResult, + options: { + pageLink?: string; + } = {}, +): AsyncIterableIterator> { + const { pageLink } = options; + let response = await pagedResult.getPage(pageLink ?? pagedResult.firstPageLink); + if (!response) { + return; + } + let result = response.page as ContinuablePage; + result.continuationToken = response.nextPageLink; + yield result; + while (response.nextPageLink) { + response = await pagedResult.getPage(response.nextPageLink); + if (!response) { + return; + } + result = response.page as ContinuablePage; + result.continuationToken = response.nextPageLink; + yield result; + } +} + +/** + * Gets for the value of nextLink in the body + */ +function getNextLink(body: unknown, nextLinkName?: string): string | undefined { + if (!nextLinkName) { + return undefined; + } + + const nextLink = (body as Record)[nextLinkName]; + + if (typeof nextLink !== "string" && typeof nextLink !== "undefined" && nextLink !== null) { + throw new RestError( + `Body Property ${nextLinkName} should be a string or undefined or null but got ${typeof nextLink}`, + ); + } + + if (nextLink === null) { + return undefined; + } + + return nextLink; +} + +/** + * Gets the elements of the current request in the body. + */ +function getElements(body: unknown, itemName: string): T[] { + const value = (body as Record)[itemName] as T[]; + if (!Array.isArray(value)) { + throw new RestError( + `Couldn't paginate response\n Body doesn't contain an array property with name: ${itemName}`, + ); + } + + return value ?? []; +} + +/** + * Checks if a request failed + */ +function checkPagingRequest(response: PathUncheckedResponse, expectedStatuses: string[]): void { + if (!expectedStatuses.includes(response.status)) { + throw createRestError( + `Pagination failed with unexpected statusCode ${response.status}`, + response, + ); + } +} diff --git a/sdk/databasewatcher/arm-databasewatcher/src/static-helpers/pollingHelpers.ts b/sdk/databasewatcher/arm-databasewatcher/src/static-helpers/pollingHelpers.ts new file mode 100644 index 000000000000..f01c41bab69d --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/src/static-helpers/pollingHelpers.ts @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { + PollerLike, + OperationState, + ResourceLocationConfig, + RunningOperation, + createHttpPoller, + OperationResponse, +} from "@azure/core-lro"; + +import { Client, PathUncheckedResponse, createRestError } from "@azure-rest/core-client"; +import { AbortSignalLike } from "@azure/abort-controller"; + +export interface GetLongRunningPollerOptions { + /** Delay to wait until next poll, in milliseconds. */ + updateIntervalInMs?: number; + /** + * The signal which can be used to abort requests. + */ + abortSignal?: AbortSignalLike; + /** + * The potential location of the result of the LRO if specified by the LRO extension in the swagger. + */ + resourceLocationConfig?: ResourceLocationConfig; + /** + * The original url of the LRO + * Should not be null when restoreFrom is set + */ + initialRequestUrl?: string; + /** + * A serialized poller which can be used to resume an existing paused Long-Running-Operation. + */ + restoreFrom?: string; + /** + * The function to get the initial response + */ + getInitialResponse?: () => PromiseLike; +} +export function getLongRunningPoller( + client: Client, + processResponseBody: (result: TResponse) => Promise, + expectedStatuses: string[], + options: GetLongRunningPollerOptions, +): PollerLike, TResult> { + const { restoreFrom, getInitialResponse } = options; + if (!restoreFrom && !getInitialResponse) { + throw new Error("Either restoreFrom or getInitialResponse must be specified"); + } + let initialResponse: TResponse | undefined = undefined; + const pollAbortController = new AbortController(); + const poller: RunningOperation = { + sendInitialRequest: async () => { + if (!getInitialResponse) { + throw new Error("getInitialResponse is required when initializing a new poller"); + } + initialResponse = await getInitialResponse(); + return getLroResponse(initialResponse, expectedStatuses); + }, + sendPollRequest: async ( + path: string, + pollOptions?: { + abortSignal?: AbortSignalLike; + }, + ) => { + // The poll request would both listen to the user provided abort signal and the poller's own abort signal + function abortListener(): void { + pollAbortController.abort(); + } + const abortSignal = pollAbortController.signal; + if (options.abortSignal?.aborted) { + pollAbortController.abort(); + } else if (pollOptions?.abortSignal?.aborted) { + pollAbortController.abort(); + } else if (!abortSignal.aborted) { + options.abortSignal?.addEventListener("abort", abortListener, { + once: true, + }); + pollOptions?.abortSignal?.addEventListener("abort", abortListener, { + once: true, + }); + } + let response; + try { + response = await client.pathUnchecked(path).get({ abortSignal }); + } finally { + options.abortSignal?.removeEventListener("abort", abortListener); + pollOptions?.abortSignal?.removeEventListener("abort", abortListener); + } + + return getLroResponse(response as TResponse, expectedStatuses); + }, + }; + return createHttpPoller(poller, { + intervalInMs: options?.updateIntervalInMs, + resourceLocationConfig: options?.resourceLocationConfig, + restoreFrom: options?.restoreFrom, + processResult: (result: unknown) => { + return processResponseBody(result as TResponse); + }, + }); +} +/** + * Converts a Rest Client response to a response that the LRO implementation understands + * @param response - a rest client http response + * @param deserializeFn - deserialize function to convert Rest response to modular output + * @returns - An LRO response that the LRO implementation understands + */ +function getLroResponse( + response: TResponse, + expectedStatuses: string[], +): OperationResponse { + if (!expectedStatuses.includes(response.status)) { + throw createRestError(response); + } + + return { + flatResponse: response, + rawResponse: { + ...response, + statusCode: Number.parseInt(response.status), + body: response.body, + }, + }; +} diff --git a/sdk/databasewatcher/arm-databasewatcher/test/public/databasewatcher_operations_test.spec.ts b/sdk/databasewatcher/arm-databasewatcher/test/public/databasewatcher_operations_test.spec.ts new file mode 100644 index 000000000000..a00296bf4b5b --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/test/public/databasewatcher_operations_test.spec.ts @@ -0,0 +1,46 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import { env, Recorder, isPlaybackMode } from "@azure-tools/test-recorder"; +import { createTestCredential } from "@azure-tools/test-credential"; +import { assert, beforeEach, afterEach, it, describe } from "vitest"; +import { createRecorder } from "./utils/recordedClient.js"; +import { DatabaseWatcherClient } from "../../src/databaseWatcherClient.js"; + +export const testPollingOptions = { + updateIntervalInMs: isPlaybackMode() ? 0 : undefined, +}; + +describe("DatabaseWatcher test", () => { + let recorder: Recorder; + let subscriptionId: string; + let client: DatabaseWatcherClient; + + beforeEach(async (context) => { + process.env.SystemRoot = process.env.SystemRoot || "C:\\Windows"; + recorder = await createRecorder(context); + subscriptionId = env.SUBSCRIPTION_ID || ""; + // This is an example of how the environment variables are used + const credential = createTestCredential(); + client = new DatabaseWatcherClient( + credential, + subscriptionId, + recorder.configureClientOptions({}), + ); + }); + + afterEach(async function () { + await recorder.stop(); + }); + it("operations list test", async () => { + const resArray = new Array(); + for await (let item of client.operations.list()) { + resArray.push(item); + } + assert.notEqual(resArray.length, 0); + }); +}); diff --git a/sdk/databasewatcher/arm-databasewatcher/test/public/utils/recordedClient.ts b/sdk/databasewatcher/arm-databasewatcher/test/public/utils/recordedClient.ts new file mode 100644 index 000000000000..14dcd9fa397c --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/test/public/utils/recordedClient.ts @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { Recorder, RecorderStartOptions, VitestTestContext } from "@azure-tools/test-recorder"; + +const replaceableVariables: Record = { + SUBSCRIPTION_ID: "azure_subscription_id", +}; + +const recorderEnvSetup: RecorderStartOptions = { + envSetupForPlayback: replaceableVariables, +}; + +/** + * creates the recorder and reads the environment variables from the `.env` file. + * Should be called first in the test suite to make sure environment variables are + * read before they are being used. + */ +export async function createRecorder(context: VitestTestContext): Promise { + const recorder = new Recorder(context); + await recorder.start(recorderEnvSetup); + return recorder; +} diff --git a/sdk/databasewatcher/arm-databasewatcher/test/snippets.spec.ts b/sdk/databasewatcher/arm-databasewatcher/test/snippets.spec.ts new file mode 100644 index 000000000000..fb48e11a82a9 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/test/snippets.spec.ts @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { DatabaseWatcherClient } from "../src/index.js"; +import { DefaultAzureCredential, InteractiveBrowserCredential } from "@azure/identity"; +import { setLogLevel } from "@azure/logger"; +import { describe, it } from "vitest"; + +describe("snippets", () => { + it("ReadmeSampleCreateClient_Node", async () => { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new DatabaseWatcherClient(new DefaultAzureCredential(), subscriptionId); + }); + + it("ReadmeSampleCreateClient_Browser", async () => { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const credential = new InteractiveBrowserCredential({ + tenantId: "", + clientId: "", + }); + const client = new DatabaseWatcherClient(credential, subscriptionId); + }); + + it("SetLogLevel", async () => { + setLogLevel("info"); + }); +}); diff --git a/sdk/databasewatcher/arm-databasewatcher/tsconfig.browser.config.json b/sdk/databasewatcher/arm-databasewatcher/tsconfig.browser.config.json new file mode 100644 index 000000000000..75871518e3a0 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/tsconfig.browser.config.json @@ -0,0 +1,3 @@ +{ + "extends": ["./tsconfig.test.json", "../../../tsconfig.browser.base.json"] +} diff --git a/sdk/databasewatcher/arm-databasewatcher/tsconfig.json b/sdk/databasewatcher/arm-databasewatcher/tsconfig.json new file mode 100644 index 000000000000..19ceb382b521 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/tsconfig.json @@ -0,0 +1,13 @@ +{ + "references": [ + { + "path": "./tsconfig.src.json" + }, + { + "path": "./tsconfig.samples.json" + }, + { + "path": "./tsconfig.test.json" + } + ] +} diff --git a/sdk/databasewatcher/arm-databasewatcher/tsconfig.samples.json b/sdk/databasewatcher/arm-databasewatcher/tsconfig.samples.json new file mode 100644 index 000000000000..af5f05870ca7 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/tsconfig.samples.json @@ -0,0 +1,8 @@ +{ + "extends": "../../../tsconfig.samples.base.json", + "compilerOptions": { + "paths": { + "@azure/arm-databasewatcher": ["./dist/esm"] + } + } +} diff --git a/sdk/databasewatcher/arm-databasewatcher/tsconfig.src.json b/sdk/databasewatcher/arm-databasewatcher/tsconfig.src.json new file mode 100644 index 000000000000..bae70752dd38 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/tsconfig.src.json @@ -0,0 +1,3 @@ +{ + "extends": "../../../tsconfig.lib.json" +} diff --git a/sdk/databasewatcher/arm-databasewatcher/tsconfig.test.json b/sdk/databasewatcher/arm-databasewatcher/tsconfig.test.json new file mode 100644 index 000000000000..290ca214aebc --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/tsconfig.test.json @@ -0,0 +1,3 @@ +{ + "extends": ["./tsconfig.src.json", "../../../tsconfig.test.base.json"] +} diff --git a/sdk/databasewatcher/arm-databasewatcher/tsp-location.yaml b/sdk/databasewatcher/arm-databasewatcher/tsp-location.yaml new file mode 100644 index 000000000000..de1483c24408 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/databasewatcher/DatabaseWatcher.Management +commit: 6f6ff28362346bf0cbbe8affca9122cc9200c9e2 +repo: Azure/azure-rest-api-specs +additionalDirectories: diff --git a/sdk/databasewatcher/arm-databasewatcher/vitest.browser.config.ts b/sdk/databasewatcher/arm-databasewatcher/vitest.browser.config.ts new file mode 100644 index 000000000000..182729ab5ce9 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/vitest.browser.config.ts @@ -0,0 +1,17 @@ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { defineConfig, mergeConfig } from "vitest/config"; +import viteConfig from "../../../vitest.browser.shared.config.ts"; + +export default mergeConfig( + viteConfig, + defineConfig({ + test: { + include: ["dist-test/browser/test/**/*.spec.js",], + testTimeout: 1200000, + hookTimeout: 1200000, + }, + }), +); diff --git a/sdk/databasewatcher/arm-databasewatcher/vitest.config.ts b/sdk/databasewatcher/arm-databasewatcher/vitest.config.ts new file mode 100644 index 000000000000..40e031385dd8 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/vitest.config.ts @@ -0,0 +1,16 @@ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { defineConfig, mergeConfig } from "vitest/config"; +import viteConfig from "../../../vitest.shared.config.ts"; + +export default mergeConfig( + viteConfig, + defineConfig({ + test: { + testTimeout: 1200000, + hookTimeout: 1200000, + }, + }), +); diff --git a/sdk/databasewatcher/arm-databasewatcher/vitest.esm.config.ts b/sdk/databasewatcher/arm-databasewatcher/vitest.esm.config.ts new file mode 100644 index 000000000000..a70127279fc9 --- /dev/null +++ b/sdk/databasewatcher/arm-databasewatcher/vitest.esm.config.ts @@ -0,0 +1,12 @@ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { mergeConfig } from "vitest/config"; +import vitestConfig from "./vitest.config.ts"; +import vitestEsmConfig from "../../../vitest.esm.shared.config.ts"; + +export default mergeConfig( + vitestConfig, + vitestEsmConfig +); diff --git a/sdk/databasewatcher/ci.mgmt.yml b/sdk/databasewatcher/ci.mgmt.yml new file mode 100644 index 000000000000..fa0fe21d5363 --- /dev/null +++ b/sdk/databasewatcher/ci.mgmt.yml @@ -0,0 +1,35 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. + +trigger: + branches: + include: + - main + - feature/* + - release/* + - hotfix/* + exclude: + - feature/v4 + paths: + include: + - sdk/databasewatcher/arm-databasewatcher + - sdk/databasewatcher/ci.mgmt.yml +pr: + branches: + include: + - main + - feature/* + - release/* + - hotfix/* + exclude: + - feature/v4 + paths: + include: + - sdk/databasewatcher/arm-databasewatcher + - sdk/databasewatcher/ci.mgmt.yml +extends: + template: /eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: sdk/databasewatcher + Artifacts: + - name: azure-arm-databasewatcher + safeName: azurearmdatabasewatcher